From e99abfed490d28181ec10eff99c9ae2ccb8ec9ac Mon Sep 17 00:00:00 2001 From: zador-blood-stained Date: Thu, 17 Mar 2016 21:31:05 +0300 Subject: [PATCH] Patches for sunxi ethernet in u-boot 2016.03 --- configuration.sh | 8 +- .../u-boot-default/sunxi-gmac-fix.patch | 118 ++++++++++++++++++ patch/u-boot/u-boot-next/sunxi-gmac-fix.patch | 118 ++++++++++++++++++ 3 files changed, 240 insertions(+), 4 deletions(-) create mode 100644 patch/u-boot/u-boot-default/sunxi-gmac-fix.patch create mode 100644 patch/u-boot/u-boot-next/sunxi-gmac-fix.patch diff --git a/configuration.sh b/configuration.sh index 359d0e98e..f108989f4 100644 --- a/configuration.sh +++ b/configuration.sh @@ -365,10 +365,10 @@ case $LINUXFAMILY in UBOOT_DEV_BRANCH="" UBOOT_DEV_SOURCE=$UBOOT_DEFAULT_SOURCE # latest stable v2016.03 broken gmac on sun7i, fixing it for DEFAULT and NEXT - if [[ $LINUXFAMILY != sun8i ]]; then - UBOOT_DEFAULT_BRANCH="v2016.01" - UBOOT_NEXT_BRANCH="v2016.01" - fi + #if [[ $LINUXFAMILY != sun8i ]]; then + # UBOOT_DEFAULT_BRANCH="v2016.01" + # UBOOT_NEXT_BRANCH="v2016.01" + #fi ;; odroidxu4) diff --git a/patch/u-boot/u-boot-default/sunxi-gmac-fix.patch b/patch/u-boot/u-boot-default/sunxi-gmac-fix.patch new file mode 100644 index 000000000..15144418f --- /dev/null +++ b/patch/u-boot/u-boot-default/sunxi-gmac-fix.patch @@ -0,0 +1,118 @@ +cpu_eth_init is no longer called for dm enabled eth drivers, this +was causing the sunxi gmac eth controller to no longer work in u-boot. + +This commit fixes this by moving the gpio setup to gpio_init() and by +calling the clock, reset and pinmux setup function from s_init(). + +Note that the mdelay is dropped as the phy gets enabled much earlier +now, so it is no longer needed. + +Signed-off-by: Hans de Goede +--- + arch/arm/cpu/armv7/sunxi/board.c | 32 +++++------------------------ + arch/arm/include/asm/arch-sunxi/sys_proto.h | 6 +++++- + board/sunxi/gmac.c | 14 +------------ + 3 files changed, 11 insertions(+), 41 deletions(-) + +diff --git a/arch/arm/cpu/armv7/sunxi/board.c b/arch/arm/cpu/armv7/sunxi/board.c +index e80785b..9a97049 100644 +--- a/arch/arm/cpu/armv7/sunxi/board.c ++++ b/arch/arm/cpu/armv7/sunxi/board.c +@@ -100,6 +100,10 @@ static int gpio_init(void) + #error Unsupported console port number. Please fix pin mux settings in board.c + #endif + ++#ifdef CONFIG_MACPWR ++ gpio_request(CONFIG_MACPWR, "macpwr"); ++ gpio_direction_output(CONFIG_MACPWR, 1); ++#endif + return 0; + } + +@@ -152,6 +156,7 @@ void s_init(void) + timer_init(); + gpio_init(); + i2c_init_board(); ++ eth_init_board(); + } + + #ifdef CONFIG_SPL_BUILD +@@ -259,30 +264,3 @@ void enable_caches(void) + dcache_enable(); + } + #endif +- +-#ifdef CONFIG_CMD_NET +-/* +- * Initializes on-chip ethernet controllers. +- * to override, implement board_eth_init() +- */ +-int cpu_eth_init(bd_t *bis) +-{ +- __maybe_unused int rc; +- +-#ifdef CONFIG_MACPWR +- gpio_request(CONFIG_MACPWR, "macpwr"); +- gpio_direction_output(CONFIG_MACPWR, 1); +- mdelay(200); +-#endif +- +-#ifdef CONFIG_SUNXI_GMAC +- rc = sunxi_gmac_initialize(bis); +- if (rc < 0) { +- printf("sunxi: failed to initialize gmac\n"); +- return rc; +- } +-#endif +- +- return 0; +-} +-#endif +diff --git a/arch/arm/include/asm/arch-sunxi/sys_proto.h b/arch/arm/include/asm/arch-sunxi/sys_proto.h +index 9df3744..a373319 100644 +--- a/arch/arm/include/asm/arch-sunxi/sys_proto.h ++++ b/arch/arm/include/asm/arch-sunxi/sys_proto.h +@@ -24,6 +24,10 @@ void sdelay(unsigned long); + void return_to_fel(uint32_t lr, uint32_t sp); + + /* Board / SoC level designware gmac init */ +-int sunxi_gmac_initialize(bd_t *bis); ++#if !defined CONFIG_SPL_BUILD && defined CONFIG_SUNXI_GMAC ++void eth_init_board(void); ++#else ++static inline void eth_init_board(void) {} ++#endif + + #endif +diff --git a/board/sunxi/gmac.c b/board/sunxi/gmac.c +index 4e222d8..69eb8ff 100644 +--- a/board/sunxi/gmac.c ++++ b/board/sunxi/gmac.c +@@ -6,7 +6,7 @@ + #include + #include + +-int sunxi_gmac_initialize(bd_t *bis) ++void eth_init_board(void) + { + int pin; + struct sunxi_ccm_reg *const ccm = +@@ -79,16 +79,4 @@ int sunxi_gmac_initialize(bd_t *bis) + for (pin = SUNXI_GPA(26); pin <= SUNXI_GPA(27); pin++) + sunxi_gpio_set_cfgpin(pin, SUN6I_GPA_GMAC); + #endif +- +-#ifdef CONFIG_DM_ETH +- return 0; +-#else +-# ifdef CONFIG_RGMII +- return designware_initialize(SUNXI_GMAC_BASE, PHY_INTERFACE_MODE_RGMII); +-# elif defined CONFIG_GMII +- return designware_initialize(SUNXI_GMAC_BASE, PHY_INTERFACE_MODE_GMII); +-# else +- return designware_initialize(SUNXI_GMAC_BASE, PHY_INTERFACE_MODE_MII); +-# endif +-#endif + } +-- +2.7.3 \ No newline at end of file diff --git a/patch/u-boot/u-boot-next/sunxi-gmac-fix.patch b/patch/u-boot/u-boot-next/sunxi-gmac-fix.patch new file mode 100644 index 000000000..15144418f --- /dev/null +++ b/patch/u-boot/u-boot-next/sunxi-gmac-fix.patch @@ -0,0 +1,118 @@ +cpu_eth_init is no longer called for dm enabled eth drivers, this +was causing the sunxi gmac eth controller to no longer work in u-boot. + +This commit fixes this by moving the gpio setup to gpio_init() and by +calling the clock, reset and pinmux setup function from s_init(). + +Note that the mdelay is dropped as the phy gets enabled much earlier +now, so it is no longer needed. + +Signed-off-by: Hans de Goede +--- + arch/arm/cpu/armv7/sunxi/board.c | 32 +++++------------------------ + arch/arm/include/asm/arch-sunxi/sys_proto.h | 6 +++++- + board/sunxi/gmac.c | 14 +------------ + 3 files changed, 11 insertions(+), 41 deletions(-) + +diff --git a/arch/arm/cpu/armv7/sunxi/board.c b/arch/arm/cpu/armv7/sunxi/board.c +index e80785b..9a97049 100644 +--- a/arch/arm/cpu/armv7/sunxi/board.c ++++ b/arch/arm/cpu/armv7/sunxi/board.c +@@ -100,6 +100,10 @@ static int gpio_init(void) + #error Unsupported console port number. Please fix pin mux settings in board.c + #endif + ++#ifdef CONFIG_MACPWR ++ gpio_request(CONFIG_MACPWR, "macpwr"); ++ gpio_direction_output(CONFIG_MACPWR, 1); ++#endif + return 0; + } + +@@ -152,6 +156,7 @@ void s_init(void) + timer_init(); + gpio_init(); + i2c_init_board(); ++ eth_init_board(); + } + + #ifdef CONFIG_SPL_BUILD +@@ -259,30 +264,3 @@ void enable_caches(void) + dcache_enable(); + } + #endif +- +-#ifdef CONFIG_CMD_NET +-/* +- * Initializes on-chip ethernet controllers. +- * to override, implement board_eth_init() +- */ +-int cpu_eth_init(bd_t *bis) +-{ +- __maybe_unused int rc; +- +-#ifdef CONFIG_MACPWR +- gpio_request(CONFIG_MACPWR, "macpwr"); +- gpio_direction_output(CONFIG_MACPWR, 1); +- mdelay(200); +-#endif +- +-#ifdef CONFIG_SUNXI_GMAC +- rc = sunxi_gmac_initialize(bis); +- if (rc < 0) { +- printf("sunxi: failed to initialize gmac\n"); +- return rc; +- } +-#endif +- +- return 0; +-} +-#endif +diff --git a/arch/arm/include/asm/arch-sunxi/sys_proto.h b/arch/arm/include/asm/arch-sunxi/sys_proto.h +index 9df3744..a373319 100644 +--- a/arch/arm/include/asm/arch-sunxi/sys_proto.h ++++ b/arch/arm/include/asm/arch-sunxi/sys_proto.h +@@ -24,6 +24,10 @@ void sdelay(unsigned long); + void return_to_fel(uint32_t lr, uint32_t sp); + + /* Board / SoC level designware gmac init */ +-int sunxi_gmac_initialize(bd_t *bis); ++#if !defined CONFIG_SPL_BUILD && defined CONFIG_SUNXI_GMAC ++void eth_init_board(void); ++#else ++static inline void eth_init_board(void) {} ++#endif + + #endif +diff --git a/board/sunxi/gmac.c b/board/sunxi/gmac.c +index 4e222d8..69eb8ff 100644 +--- a/board/sunxi/gmac.c ++++ b/board/sunxi/gmac.c +@@ -6,7 +6,7 @@ + #include + #include + +-int sunxi_gmac_initialize(bd_t *bis) ++void eth_init_board(void) + { + int pin; + struct sunxi_ccm_reg *const ccm = +@@ -79,16 +79,4 @@ int sunxi_gmac_initialize(bd_t *bis) + for (pin = SUNXI_GPA(26); pin <= SUNXI_GPA(27); pin++) + sunxi_gpio_set_cfgpin(pin, SUN6I_GPA_GMAC); + #endif +- +-#ifdef CONFIG_DM_ETH +- return 0; +-#else +-# ifdef CONFIG_RGMII +- return designware_initialize(SUNXI_GMAC_BASE, PHY_INTERFACE_MODE_RGMII); +-# elif defined CONFIG_GMII +- return designware_initialize(SUNXI_GMAC_BASE, PHY_INTERFACE_MODE_GMII); +-# else +- return designware_initialize(SUNXI_GMAC_BASE, PHY_INTERFACE_MODE_MII); +-# endif +-#endif + } +-- +2.7.3 \ No newline at end of file