]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
sunxi: add gmac Ethernet support
authorIan Campbell <ijc@hellion.org.uk>
Mon, 5 May 2014 10:52:28 +0000 (11:52 +0100)
committerAlbert ARIBAUD <albert.u.boot@aribaud.net>
Sun, 25 May 2014 14:25:12 +0000 (16:25 +0200)
Add support for the GMAC Ethernet controller on Allwinner A20 (sun7i)
processors. Enable for the Cubietruck.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Jens Kuske <jenskuske@gmail.com>
Signed-off-by: Ian Campbell <ijc@hellion.org.uk>
Reviewed-by: Marek Vasut <marex@denx.de>
Reviewed-by: Tom Rini <trini@ti.com>
arch/arm/cpu/armv7/sunxi/board.c
board/sunxi/Makefile
board/sunxi/gmac.c [new file with mode: 0644]
boards.cfg
include/configs/sunxi-common.h
include/netdev.h

index b5c0cb7487465605b0e156d6b6471854a3a3e229..49c94489ee5d2f7d145055b0614f9eacd63f184d 100644 (file)
@@ -11,6 +11,8 @@
  */
 
 #include <common.h>
+#include <netdev.h>
+#include <miiphy.h>
 #include <serial.h>
 #ifdef CONFIG_SPL_BUILD
 #include <spl.h>
@@ -86,3 +88,24 @@ 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)
+{
+       int rc;
+
+#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
index 18b1e1173354800af7f266529c0c57c49fc676b4..cbf8f086a95af88f16c081e99d5eaf6b2cf83a1c 100644 (file)
@@ -9,4 +9,5 @@
 # SPDX-License-Identifier:     GPL-2.0+
 #
 obj-y  += board.o
+obj-$(CONFIG_SUNXI_GMAC)       += gmac.o
 obj-$(CONFIG_CUBIETRUCK)       += dram_cubietruck.o
diff --git a/board/sunxi/gmac.c b/board/sunxi/gmac.c
new file mode 100644 (file)
index 0000000..e48328d
--- /dev/null
@@ -0,0 +1,32 @@
+#include <common.h>
+#include <netdev.h>
+#include <miiphy.h>
+#include <asm/gpio.h>
+#include <asm/io.h>
+#include <asm/arch/clock.h>
+#include <asm/arch/gpio.h>
+
+int sunxi_gmac_initialize(bd_t *bis)
+{
+       int pin;
+       struct sunxi_ccm_reg *const ccm =
+               (struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
+
+       /* Set up clock gating */
+       setbits_le32(&ccm->ahb_gate1, 0x1 << AHB_GATE_OFFSET_GMAC);
+
+       /* Set MII clock */
+       setbits_le32(&ccm->gmac_clk_cfg, CCM_GMAC_CTRL_TX_CLK_SRC_INT_RGMII |
+               CCM_GMAC_CTRL_GPIT_RGMII);
+
+       /* Configure pin mux settings for GMAC */
+       for (pin = SUNXI_GPA(0); pin <= SUNXI_GPA(16); pin++) {
+               /* skip unused pins in RGMII mode */
+               if (pin == SUNXI_GPA(9) || pin == SUNXI_GPA(14))
+                       continue;
+               sunxi_gpio_set_cfgpin(pin, SUN7I_GPA0_GMAC);
+               sunxi_gpio_set_drv(pin, 3);
+       }
+
+       return designware_initialize(SUNXI_GMAC_BASE, PHY_INTERFACE_MODE_RGMII);
+}
index db3a6aef75f30e74170e83778bb21073bce43a77..bc0503048fe1f6522d96e4122786bb8a7e20ff37 100644 (file)
@@ -379,7 +379,7 @@ Active  arm         armv7          rmobile     renesas         lager
 Active  arm         armv7          s5pc1xx     samsung         goni                s5p_goni                              -                                                                                                                                 Przemyslaw Marczak <p.marczak@samsung.com>
 Active  arm         armv7          s5pc1xx     samsung         smdkc100            smdkc100                              -                                                                                                                                 Minkyu Kang <mk7.kang@samsung.com>
 Active  arm         armv7          socfpga     altera          socfpga             socfpga_cyclone5                      -                                                                                                                                 -
-Active  arm         armv7          sunxi       -               sunxi               Cubietruck_FEL                        sun7i:CUBIETRUCK,SPL_FEL                                                                                                          -
+Active  arm         armv7          sunxi       -               sunxi               Cubietruck_FEL                        sun7i:CUBIETRUCK,SPL_FEL,SUNXI_GMAC,RGMII                                                                                         -
 Active  arm         armv7          u8500       st-ericsson     snowball            snowball                              -                                                                                                                                 Mathieu Poirier <mathieu.poirier@linaro.org>
 Active  arm         armv7          u8500       st-ericsson     u8500               u8500_href                            -                                                                                                                                 -
 Active  arm         armv7          vf610       freescale       vf610twr            vf610twr                              vf610twr:IMX_CONFIG=board/freescale/vf610twr/imximage.cfg                                                                         Alison Wang <b18965@freescale.com>
index 3f7e314a8b471d7de4196e26792a512808254754..e844110d7a323ee7bdad8ccf9d8583dd250ee590 100644 (file)
 
 #define CONFIG_CONS_INDEX              1       /* UART0 */
 
+#ifdef CONFIG_SUNXI_GMAC
+#define CONFIG_DESIGNWARE_ETH          /* GMAC can use designware driver */
+#define CONFIG_DW_AUTONEG
+#define CONFIG_PHY_GIGE                        /* GMAC can use gigabit PHY     */
+#define CONFIG_PHY_ADDR                1
+#define CONFIG_MII                     /* MII PHY management           */
+#define CONFIG_PHYLIB
+#endif
+
+#ifdef CONFIG_CMD_NET
+#define CONFIG_CMD_NFS
+#define CONFIG_CMD_DNS
+#define CONFIG_NETCONSOLE
+#define CONFIG_BOOTP_DNS2
+#define CONFIG_BOOTP_SEND_HOSTNAME
+#endif
+
 #if !defined CONFIG_ENV_IS_IN_MMC && \
     !defined CONFIG_ENV_IS_IN_NAND && \
     !defined CONFIG_ENV_IS_IN_FAT && \
index e211f1841f60d7dac07d43d4dd9297a720854ac2..63481eca22688080f5b26e7da99013af88f06c1d 100644 (file)
@@ -78,6 +78,7 @@ int sh_eth_initialize(bd_t *bis);
 int skge_initialize(bd_t *bis);
 int smc91111_initialize(u8 dev_num, int base_addr);
 int smc911x_initialize(u8 dev_num, int base_addr);
+int sunxi_gmac_initialize(bd_t *bis);
 int sunxi_wemac_initialize(bd_t *bis);
 int tsi108_eth_initialize(bd_t *bis);
 int uec_standard_init(bd_t *bis);