diff mbox

[U-Boot,PATCHv3] socfpga: initialize designware ethernet

Message ID 20140714121417.GA17801@amd.pavel.ucw.cz
State Accepted
Delegated to: Tom Rini
Headers show

Commit Message

Pavel Machek July 14, 2014, 12:14 p.m. UTC
Enable initialization fo designware ethernet controller. With this
patch, ethernet works in my configuration, provided I set ethernet
address in the environment.

Signed-off-by: Pavel Machek <pavel@denx.de>

---
 
Changes from v1: moved ethernet initialization to arch/arm, as
suggested by Marek.

Changes from v2: use right function name after moving to
arch/arm. Thanks to Marek.

Patch hand-edited so that it can be applied after the "timer counts
down" fix.

Comments

Marek Vasut July 14, 2014, 12:28 p.m. UTC | #1
On Monday, July 14, 2014 at 02:14:17 PM, Pavel Machek wrote:
> Enable initialization fo designware ethernet controller. With this
> patch, ethernet works in my configuration, provided I set ethernet
> address in the environment.
> 
> Signed-off-by: Pavel Machek <pavel@denx.de>
> 
> ---

btw. is there any reason why the patch is missing a diffstat ?

Best regards,
Marek Vasut
Pavel Machek July 14, 2014, 12:38 p.m. UTC | #2
On Mon 2014-07-14 14:28:43, Marek Vasut wrote:
> On Monday, July 14, 2014 at 02:14:17 PM, Pavel Machek wrote:
> > Enable initialization fo designware ethernet controller. With this
> > patch, ethernet works in my configuration, provided I set ethernet
> > address in the environment.
> > 
> > Signed-off-by: Pavel Machek <pavel@denx.de>
> > 
> > ---
> 
> btw. is there any reason why the patch is missing a diffstat ?

I had to hand-edit the patch to make it fit after the time fixes...

(Plus, I don't normally do diffstats as they are not required for
kernel submissions.)

									Pavel
Tom Rini Aug. 30, 2014, 3:13 p.m. UTC | #3
On Mon, Jul 14, 2014 at 02:14:17PM +0200, Pavel Machek wrote:

> Enable initialization fo designware ethernet controller. With this
> patch, ethernet works in my configuration, provided I set ethernet
> address in the environment.
> 
> Signed-off-by: Pavel Machek <pavel@denx.de>

Applied to u-boot/master, thanks!
diff mbox

Patch

diff --git a/arch/arm/cpu/armv7/socfpga/misc.c b/arch/arm/cpu/armv7/socfpga/misc.c
index 2f1c716..bb71c91 100644
--- a/arch/arm/cpu/armv7/socfpga/misc.c
+++ b/arch/arm/cpu/armv7/socfpga/misc.c
@@ -6,6 +6,8 @@ 
 
 #include <common.h>
 #include <asm/io.h>
+#include <miiphy.h>
+#include <netdev.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -14,3 +16,18 @@  int dram_init(void)
 	gd->ram_size = get_ram_size((long *)PHYS_SDRAM_1, PHYS_SDRAM_1_SIZE);
 	return 0;
 }
+
+
+/*
+ * DesignWare Ethernet initialization
+ */
+int cpu_eth_init(bd_t *bis)
+{
+#if !defined(CONFIG_SOCFPGA_VIRTUAL_TARGET) && !defined(CONFIG_SPL_BUILD)
+       /* initialize and register the emac */
+	return designware_initialize(CONFIG_EMAC_BASE,
+				     CONFIG_PHY_INTERFACE_MODE);
+#else
+	return 0;
+#endif
+}
diff --git a/arch/arm/include/asm/arch-socfpga/socfpga_base_addrs.h b/arch/arm/include/asm/arch-socfpga/socfpga_base_addrs.h
index f564046..a6d1680 100644
--- a/arch/arm/include/asm/arch-socfpga/socfpga_base_addrs.h
+++ b/arch/arm/include/asm/arch-socfpga/socfpga_base_addrs.h
@@ -14,5 +14,7 @@ 
 #define SOCFPGA_CLKMGR_ADDRESS 0xffd04000
 #define SOCFPGA_RSTMGR_ADDRESS 0xffd05000
 #define SOCFPGA_SYSMGR_ADDRESS 0xffd08000
+#define SOCFPGA_EMAC0_ADDRESS 0xff700000
+#define SOCFPGA_EMAC1_ADDRESS 0xff702000
 
 #endif /* _SOCFPGA_BASE_ADDRS_H_ */
diff --git a/board/altera/socfpga/socfpga_cyclone5.c b/board/altera/socfpga/socfpga_cyclone5.c
index a960eb6..5cbe695 100644
--- a/board/altera/socfpga/socfpga_cyclone5.c
+++ b/board/altera/socfpga/socfpga_cyclone5.c
@@ -60,12 +59,3 @@  int overwrite_console(void)
 	return 0;
 }
 #endif
-
-/*
- * DesignWare Ethernet initialization
- */
-/* We know all the init functions have been run now */
-int board_eth_init(bd_t *bis)
-{
-	return 0;
-}
diff --git a/include/configs/socfpga_cyclone5.h b/include/configs/socfpga_cyclone5.h
index 0254249..cc4f690 100644
--- a/include/configs/socfpga_cyclone5.h
+++ b/include/configs/socfpga_cyclone5.h
@@ -201,12 +204,44 @@ 
 #else
 #define CONFIG_SYS_TIMER_RATE		25000000
 #endif
 #define CONFIG_SYS_TIMER_COUNTS_DOWN
 #define CONFIG_SYS_TIMER_COUNTER	(CONFIG_SYS_TIMERBASE + 0x4)
 
 #define CONFIG_ENV_IS_NOWHERE
 
 /*
+ * network support
+ */
+#ifndef CONFIG_SOCFPGA_VIRTUAL_TARGET
+#define CONFIG_DESIGNWARE_ETH          1
+#endif
+
+#ifdef CONFIG_DESIGNWARE_ETH
+#define CONFIG_EMAC0_BASE              SOCFPGA_EMAC0_ADDRESS
+#define CONFIG_EMAC1_BASE              SOCFPGA_EMAC1_ADDRESS
+/* console support for network */
+#define CONFIG_CMD_DHCP
+#define CONFIG_CMD_MII
+#define CONFIG_CMD_NET
+#define CONFIG_CMD_PING
+/* designware */
+#define CONFIG_NET_MULTI
+#define CONFIG_DW_ALTDESCRIPTOR
+#define CONFIG_DW_SEARCH_PHY
+#define CONFIG_MII
+#define CONFIG_PHY_GIGE
+#define CONFIG_DW_AUTONEG
+#define CONFIG_AUTONEG_TIMEOUT         (15 * CONFIG_SYS_HZ)
+#define CONFIG_PHYLIB
+#define CONFIG_PHY_MICREL
+#define CONFIG_PHY_MICREL_KSZ9021
+/* EMAC controller and PHY used */
+#define CONFIG_EMAC_BASE               CONFIG_EMAC1_BASE
+#define CONFIG_EPHY_PHY_ADDR           CONFIG_EPHY1_PHY_ADDR
+#define CONFIG_PHY_INTERFACE_MODE      PHY_INTERFACE_MODE_RGMII
+#endif /* CONFIG_DESIGNWARE_ETH */
+
+/*
  * SPL "Second Program Loader" aka Initial Software
  */