Skip to contentSkip to conversation

CPSW switch plus SPL net support

PATCH New Ilya Yanok 3 participants 13 messages Jul 24, 2012 – Aug 3, 2012

Subsystems (5)
lore
Share & tools
lore

Ilya Yanok

author
#0 lore raw

v3 cover CPSW switch plus SPL net support

These patches add CPSW switch driver and enable support for it on TI AM335x based boards. This version is rebased on top of u-boot-ti/next. Also now CPSW driver uses internal controller memory for DMA descriptors so coherent allocator is no longer a requirement for this series.

The second part of the series provides support for networking in SPL. These patches try to use network infrasctructure as is, without trying to cut some minimal set of it, so the resulting SPL image is quite big and only useful for boards with plenty of SRAM/OCRAM (like TI AM335x based ones).

Changes in v2:
- fix timeout handling
- use internal RAM for descriptors

Changes in v3:
- add support for setting different VCI in SPL
- change calls to miiphy_{speed,duplex}() to phy_startup()
- drop volatiles
- fix whitespace problem
- set Vendor Class Identifier for SPL
- stop DMA on driver halt (fix by Mugunthan V N)
- use BOOTP in SPL regardless of CONFIG_CMD_DHCP

Chandan Nath (3):
am33xx: CPSW init and definitions
am33xx: pin mux defintions for CPSW switch
am335x_evm: CPSW support

Cyril Chemparathy (1):
cpsw: add driver for cpsw ethernet device

Ilya Yanok (4):
am335x_evm: read the on-board EEPROM
net/bootp: add VCI support for BOOTP also
OMAP: networking support for SPL
am335x_evm: enable networking in SPL

 arch/arm/cpu/armv7/am33xx/clock.c             |    8 +-
 arch/arm/cpu/armv7/omap-common/Makefile       |    3 +
 arch/arm/cpu/armv7/omap-common/spl.c          |    5 +
 arch/arm/cpu/armv7/omap-common/spl_eth.c      |   50 ++
 arch/arm/include/asm/arch-am33xx/common_def.h |    2 +
 arch/arm/include/asm/arch-am33xx/cpu.h        |   11 +
 arch/arm/include/asm/arch-am33xx/hardware.h   |    5 +
 arch/arm/include/asm/omap_common.h            |    4 +
 board/ti/am335x/evm.c                         |  175 ++++-
 board/ti/am335x/mux.c                         |   47 ++
 common/Makefile                               |    6 +
 common/cmd_nvedit.c                           |    6 +-
 common/env_common.c                           |    3 +-
 drivers/net/Makefile                          |    1 +
 drivers/net/cpsw.c                            |  991 +++++++++++++++++++++++++
 include/configs/am335x_evm.h                  |   26 +-
 include/cpsw.h                                |   51 ++
 lib/Makefile                                  |   10 +-
 lib/vsprintf.c                                |    2 +-
 net/bootp.c                                   |   28 +-
 net/net.c                                     |    3 +
 spl/Makefile                                  |    3 +
 22 files changed, 1424 insertions(+), 16 deletions(-)
 create mode 100644 arch/arm/cpu/armv7/omap-common/spl_eth.c
 create mode 100644 drivers/net/cpsw.c
 create mode 100644 include/cpsw.h
Signature · 1 line
1.7.9.5
author
#1 lore raw

PATCH v3 1/8 cpsw: add driver for cpsw ethernet device

From: Cyril Chemparathy <[email protected]>

CPSW is an on-chip ethernet switch that is found on various SoCs from Texas Instruments. This patch adds a simple driver (based on the Linux driver) for this hardware module.

This patch also adds support to clean and flush dcache during packet send and receive.

Changes by Sandhya: Added support to clean and flush dcache during packet
send/receive and added timeouts.

[Ilya: Cleaned cache handling, some style cleanup, some small fixes, use of internal RAM for descriptors]

---
Changes in v2:
- fix timeout handling
- use internal RAM for descriptors

Changes in v3:
- change calls to miiphy_{speed,duplex}() to phy_startup()
- drop volatiles
- stop DMA on driver halt (fix by Mugunthan V N)

 drivers/net/Makefile |    1 +
 drivers/net/cpsw.c   |  991 ++++++++++++++++++++++++++++++++++++++++++++++++++
 include/cpsw.h       |   51 +++
 3 files changed, 1043 insertions(+)
 create mode 100644 drivers/net/cpsw.c
 create mode 100644 include/cpsw.h
drivers/net/Makefile +1 -0
index 430f90c..011cd51 100644
@@ -71,6 +71,7 @@ COBJS-$(CONFIG_SMC91111) += smc91111.o
 COBJS-$(CONFIG_SMC911X) += smc911x.o
 COBJS-$(CONFIG_DRIVER_TI_EMAC) += davinci_emac.o
 COBJS-$(CONFIG_TSEC_ENET) += tsec.o fsl_mdio.o
+COBJS-$(CONFIG_DRIVER_TI_CPSW) += cpsw.o
 COBJS-$(CONFIG_FMAN_ENET) += fsl_mdio.o
 COBJS-$(CONFIG_TSI108_ETH) += tsi108_eth.o
 COBJS-$(CONFIG_ULI526X) += uli526x.o
drivers/net/cpsw.c new file +991 -0

991 lines not on this page · raw message

include/cpsw.h new file +51 -0

51 lines not on this page · raw message

Signature · 1 line
1.7.9.5
author
#2 lore raw

PATCH v3 2/8 am33xx: CPSW init and definitions

In reply to Ilya Yanok

From: Chandan Nath <[email protected]>

This patch adds platform-specific initialization for CPSW switch on TI AM33XX SoCs.

[Ilya: split init out of original patch]

---
Changes in v3:
- fix whitespace problem

 arch/arm/cpu/armv7/am33xx/clock.c           |    8 +++++++-
 arch/arm/include/asm/arch-am33xx/cpu.h      |   11 +++++++++++
 arch/arm/include/asm/arch-am33xx/hardware.h |    5 +++++
 3 files changed, 23 insertions(+), 1 deletion(-)
arch/arm/cpu/armv7/am33xx/clock.c +7 -1
index 16beb4f..e3c4fd8 100644
@@ -24,6 +24,7 @@
 
 #define PRCM_MOD_EN		0x2
 #define PRCM_FORCE_WAKEUP	0x2
+#define PRCM_FUNCTL		0x0
 
 #define PRCM_EMIF_CLK_ACTIVITY	BIT(2)
 #define PRCM_L3_GCLK_ACTIVITY	BIT(4)
@@ -38,7 +39,7 @@
 #define CLK_MODE_SEL		0x7
 #define CLK_MODE_MASK		0xfffffff8
 #define CLK_DIV_SEL		0xFFFFFFE0
-
+#define CPGMAC0_IDLE		0x30000
 
 const struct cm_perpll *cmper = (struct cm_perpll *)CM_PER;
 const struct cm_wkuppll *cmwkup = (struct cm_wkuppll *)CM_WKUP;
@@ -138,6 +139,11 @@ static void enable_per_clocks(void)
 	writel(PRCM_MOD_EN, &cmper->i2c1clkctrl);
 	while (readl(&cmper->i2c1clkctrl) != PRCM_MOD_EN)
 		;
+
+	/* Ethernet */
+	writel(PRCM_MOD_EN, &cmper->cpgmac0clkctrl);
+	while ((readl(&cmper->cpgmac0clkctrl) & CPGMAC0_IDLE) != PRCM_FUNCTL)
+		;
 }
 
 static void mpu_pll_config(void)
arch/arm/include/asm/arch-am33xx/cpu.h +11 -0
index e63ab74..de9ee91 100644
@@ -255,6 +255,17 @@ struct ctrl_stat {
 #define OMAP_GPIO_CLEARDATAOUT		0x0190
 #define OMAP_GPIO_SETDATAOUT		0x0194
 
+/* Control Device Register */
+struct ctrl_dev {
+	unsigned int deviceid;		/* offset 0x00 */
+	unsigned int resv1[11];
+	unsigned int macid0l;		/* offset 0x30 */
+	unsigned int macid0h;		/* offset 0x34 */
+	unsigned int macid1l;		/* offset 0x38 */
+	unsigned int macid1h;		/* offset 0x3c */
+	unsigned int resv2[4];
+	unsigned int miisel;		/* offset 0x50 */
+};
 #endif /* __ASSEMBLY__ */
 #endif /* __KERNEL_STRICT_NAMES */
 
arch/arm/include/asm/arch-am33xx/hardware.h +5 -0
index 0ec22eb..4b1c725 100644
@@ -46,6 +46,7 @@
 
 /* Control Module Base Address */
 #define CTRL_BASE			0x44E10000
+#define CTRL_DEVICE_BASE		0x44E10600
 
 /* PRCM Base Address */
 #define PRCM_BASE			0x44E00000
@@ -78,4 +79,8 @@
 #define DDRPHY_0_CONFIG_BASE		(CTRL_BASE + 0x1400)
 #define DDRPHY_CONFIG_BASE		DDRPHY_0_CONFIG_BASE
 
+/* CPSW Config space */
+#define AM335X_CPSW_BASE		0x4A100000
+#define AM335X_CPSW_MDIO_BASE		0x4A101000
+
 #endif /* __AM33XX_HARDWARE_H */
Signature · 1 line
1.7.9.5
author
#3 lore raw

PATCH v3 3/8 am33xx: pin mux defintions for CPSW switch

In reply to Ilya Yanok

From: Chandan Nath <[email protected]>

This patch adds pin mux settings for CPSW switch found on TI AM335X based boards (MII and RGMII modes).

[Ilya: split pinmux into separate patch]

---

 arch/arm/include/asm/arch-am33xx/common_def.h |    2 ++
 board/ti/am335x/mux.c                         |   47 +++++++++++++++++++++++++
 2 files changed, 49 insertions(+)
arch/arm/include/asm/arch-am33xx/common_def.h +2 -0
index aa3b554..5a7b0f3 100644
@@ -19,5 +19,7 @@
 extern void enable_uart0_pin_mux(void);
 extern void enable_mmc0_pin_mux(void);
 extern void enable_i2c0_pin_mux(void);
+extern void enable_mii1_pin_mux(void);
+extern void enable_rgmii1_pin_mux(void);
 
 #endif/*__COMMON_DEF_H__ */
board/ti/am335x/mux.c +47 -0

56 lines not on this page · raw message

Signature · 1 line
1.7.9.5
author
#4 lore raw

PATCH v3 4/8 am335x_evm: read the on-board EEPROM

In reply to Ilya Yanok

Read the on-board EEPROM during startup to detect the version of the board we are running on (as for now only BeagleBone vs EVM detection is supported).

---

 board/ti/am335x/evm.c |   72 +++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 70 insertions(+), 2 deletions(-)
board/ti/am335x/evm.c +70 -2
index 0d0affa..55e24a8 100644
@@ -14,6 +14,7 @@
  */
 
 #include <common.h>
+#include <errno.h>
 #include <asm/arch/cpu.h>
 #include <asm/arch/hardware.h>
 #include <asm/arch/common_def.h>
@@ -22,17 +23,84 @@
 DECLARE_GLOBAL_DATA_PTR;
 
 /*
+ * I2C Address of on-board EEPROM
+ */
+#define I2C_BASE_BOARD_ADDR	0x50
+
+#define NO_OF_MAC_ADDR          3
+#define ETH_ALEN		6
+
+#define NAME_LEN	8
+
+struct am335x_baseboard_id {
+	unsigned int  magic;
+	char name[NAME_LEN];
+	char version[4];
+	char serial[12];
+	char config[32];
+	char mac_addr[NO_OF_MAC_ADDR][ETH_ALEN];
+};
+
+static struct am335x_baseboard_id header;
+
+static inline int board_is_bone(void)
+{
+	return !strncmp(header.name, "A335BONE", NAME_LEN);
+}
+
+/*
+ * Read header information from EEPROM into global structure.
+ */
+int read_eeprom(void)
+{
+	/* Check if baseboard eeprom is available */
+	if (i2c_probe(I2C_BASE_BOARD_ADDR)) {
+		printf("Could not probe the EEPROM; something fundamentally "
+			"wrong on the I2C bus.\n");
+		return -ENODEV;
+	}
+
+	/* read the eeprom using i2c */
+	if (i2c_read(I2C_BASE_BOARD_ADDR, 0, 2, (uchar *)&header,
+							sizeof(header))) {
+		printf("Could not read the EEPROM; something fundamentally"
+			" wrong on the I2C bus.\n");
+		return -EIO;
+	}
+
+	if (header.magic != 0xEE3355AA) {
+		/*
+		 * read the eeprom using i2c again,
+		 * but use only a 1 byte address
+		 */
+		if (i2c_read(I2C_BASE_BOARD_ADDR, 0, 1, (uchar *)&header,
+							sizeof(header))) {
+			printf("Could not read the EEPROM; something "
+				"fundamentally wrong on the I2C bus.\n");
+			return -EIO;
+		}
+
+		if (header.magic != 0xEE3355AA) {
+			printf("Incorrect magic number in EEPROM\n");
+			return -EINVAL;
+		}
+	}
+
+	return 0;
+}
+
+/*
  * Basic board specific setup
  */
 int board_init(void)
 {
 	enable_uart0_pin_mux();
 
-#ifdef CONFIG_I2C
 	enable_i2c0_pin_mux();
 	enable_i2c1_pin_mux();
 	i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
-#endif
+	if (read_eeprom() < 0)
+		printf("Could not get board ID.\n");
 
 	gd->bd->bi_boot_params = PHYS_DRAM_1 + 0x100;
 
Signature · 1 line
1.7.9.5
author
#5 lore raw

PATCH v3 5/8 am335x_evm: CPSW support

In reply to Ilya Yanok

From: Chandan Nath <[email protected]>

This patch adds board-specific initialization for CPSW on TI AM335X based boards. Tested on BeagleBone.

[Ilya: split board-specific part into separate patch]

---

 board/ti/am335x/evm.c        |   91 ++++++++++++++++++++++++++++++++++++++++++
 include/configs/am335x_evm.h |   20 +++++++++-
 2 files changed, 110 insertions(+), 1 deletion(-)
board/ti/am335x/evm.c +91 -0
index 55e24a8..b7eee80 100644
@@ -15,13 +15,26 @@
 
 #include <common.h>
 #include <errno.h>
+#include <asm/io.h>
 #include <asm/arch/cpu.h>
 #include <asm/arch/hardware.h>
 #include <asm/arch/common_def.h>
 #include <i2c.h>
+#include <miiphy.h>
+#include <cpsw.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
+#define UART_RESET		(0x1 << 1)
+#define UART_CLK_RUNNING_MASK	0x1
+#define UART_SMART_IDLE_EN	(0x1 << 0x3)
+
+/* MII mode defines */
+#define MII_MODE_ENABLE		0x0
+#define RGMII_MODE_ENABLE	0xA
+
+struct ctrl_dev *cdev = (struct ctrl_dev *)CTRL_DEVICE_BASE;
+
 /*
  * I2C Address of on-board EEPROM
  */
@@ -106,3 +119,81 @@ int board_init(void)
 
 	return 0;
 }
+
+#ifdef CONFIG_DRIVER_TI_CPSW
+static void cpsw_control(int enabled)
+{
+	/* VTP can be added here */
+
+	return;
+}
+
+static struct cpsw_slave_data cpsw_slaves[] = {
+	{
+		.slave_reg_ofs	= 0x208,
+		.sliver_reg_ofs	= 0xd80,
+		.phy_id		= 0,
+	},
+	{
+		.slave_reg_ofs	= 0x308,
+		.sliver_reg_ofs	= 0xdc0,
+		.phy_id		= 1,
+	},
+};
+
+static struct cpsw_platform_data cpsw_data = {
+	.mdio_base		= AM335X_CPSW_MDIO_BASE,
+	.cpsw_base		= AM335X_CPSW_BASE,
+	.mdio_div		= 0xff,
+	.channels		= 8,
+	.cpdma_reg_ofs		= 0x800,
+	.slaves			= 1,
+	.slave_data		= cpsw_slaves,
+	.ale_reg_ofs		= 0xd00,
+	.ale_entries		= 1024,
+	.host_port_reg_ofs	= 0x108,
+	.hw_stats_reg_ofs	= 0x900,
+	.mac_control		= (1 << 5),
+	.control		= cpsw_control,
+	.host_port_num		= 0,
+	.version		= CPSW_CTRL_VERSION_2,
+};
+
+int board_eth_init(bd_t *bis)
+{
+	uint8_t mac_addr[6];
+	uint32_t mac_hi, mac_lo;
+
+	if (!eth_getenv_enetaddr("ethaddr", mac_addr)) {
+		debug("<ethaddr> not set. Reading from E-fuse\n");
+		/* try reading mac address from efuse */
+		mac_lo = readl(&cdev->macid0l);
+		mac_hi = readl(&cdev->macid0h);
+		mac_addr[0] = mac_hi & 0xFF;
+		mac_addr[1] = (mac_hi & 0xFF00) >> 8;
+		mac_addr[2] = (mac_hi & 0xFF0000) >> 16;
+		mac_addr[3] = (mac_hi & 0xFF000000) >> 24;
+		mac_addr[4] = mac_lo & 0xFF;
+		mac_addr[5] = (mac_lo & 0xFF00) >> 8;
+
+		if (is_valid_ether_addr(mac_addr))
+			eth_setenv_enetaddr("ethaddr", mac_addr);
+		else
+			return -1;
+	}
+
+	if (board_is_bone()) {
+		enable_mii1_pin_mux();
+		writel(MII_MODE_ENABLE, &cdev->miisel);
+		cpsw_slaves[0].phy_if = cpsw_slaves[1].phy_if =
+				PHY_INTERFACE_MODE_MII;
+	} else {
+		enable_rgmii1_pin_mux();
+		writel(RGMII_MODE_ENABLE, &cdev->miisel);
+		cpsw_slaves[0].phy_if = cpsw_slaves[1].phy_if =
+				PHY_INTERFACE_MODE_RGMII;
+	}
+
+	return cpsw_register(&cpsw_data);
+}
+#endif
include/configs/am335x_evm.h +19 -1
index 2b41c1c..2a3251b 100644
@@ -21,11 +21,13 @@
 #undef CONFIG_GZIP
 #undef CONFIG_ZLIB
 #undef CONFIG_SYS_HUSH_PARSER
-#undef CONFIG_CMD_NET
 
 #include <asm/arch/cpu.h>
 #include <asm/arch/hardware.h>
 
+#define CONFIG_DMA_COHERENT
+#define CONFIG_DMA_COHERENT_SIZE	(1 << 20)
+
 #define CONFIG_ENV_SIZE			0x400
 #define CONFIG_SYS_MALLOC_LEN		(CONFIG_ENV_SIZE + (8 * 1024))
 #define CONFIG_SYS_PROMPT		"U-Boot# "
@@ -168,4 +170,20 @@
 /* Unsupported features */
 #undef CONFIG_USE_IRQ
 
+#define CONFIG_CMD_NET
+#define CONFIG_CMD_DHCP
+#define CONFIG_CMD_PING
+#define CONFIG_DRIVER_TI_CPSW
+#define CONFIG_MII
+#define CONFIG_BOOTP_DEFAULT
+#define CONFIG_BOOTP_DNS
+#define CONFIG_BOOTP_DNS2
+#define CONFIG_BOOTP_SEND_HOSTNAME
+#define CONFIG_BOOTP_GATEWAY
+#define CONFIG_BOOTP_SUBNETMASK
+#define CONFIG_NET_RETRY_COUNT         10
+#define CONFIG_NET_MULTI
+#define CONFIG_PHY_GIGE
+#define CONFIG_PHYLIB
+
 #endif	/* ! __CONFIG_AM335X_EVM_H */
Signature · 1 line
1.7.9.5
author
#6 lore raw

PATCH v3 6/8 net/bootp: add VCI support for BOOTP also

In reply to Ilya Yanok

Vendor Class Identifier option is common to BOOTP and DHCP and can be useful without PXE. So send VCI in both BOOTP and DHCP requests if CONFIG_BOOTP_VCI_STRING is defined.

---

 net/bootp.c |   20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)
net/bootp.c +15 -5
index 0f0867b..a68f914 100644
@@ -339,6 +339,14 @@ BootpTimeout(void)
 	}
 }
 
+#define put_vci(e, str)				\
+	do {					\
+		*e++ = 60;			\
+		*e++ = sizeof(str);		\
+		memcpy(e, str, sizeof(str));	\
+		e += sizeof(str);		\
+	} while (0)
+
 /*
  *	Initialize BOOTP extension fields in the request.
  */
@@ -435,12 +443,10 @@ static int DhcpExtended(u8 *e, int message_type, IPaddr_t ServerID,
 			printf("Invalid pxeuuid: %s\n", uuid);
 		}
 	}
+#endif
 
-	*e++ = 60;	/* Vendor Class Identifier */
-	vci_strlen = strlen(CONFIG_BOOTP_VCI_STRING);
-	*e++ = vci_strlen;
-	memcpy(e, CONFIG_BOOTP_VCI_STRING, vci_strlen);
-	e += vci_strlen;
+#ifdef CONFIG_BOOTP_VCI_STRING
+	put_vci(e, CONFIG_VCI_STRING);
 #endif
 
 #if defined(CONFIG_BOOTP_VENDOREX)
@@ -527,6 +533,10 @@ static int BootpExtended(u8 *e)
 	*e++ = (576 - 312 + OPT_FIELD_SIZE) & 0xff;
 #endif
 
+#ifdef CONFIG_BOOTP_VCI_STRING
+	put_vci(e, CONFIG_VCI_STRING);
+#endif
+
 #if defined(CONFIG_BOOTP_SUBNETMASK)
 	*e++ = 1;		/* Subnet mask request */
 	*e++ = 4;
Signature · 1 line
1.7.9.5
#7 lore raw

PATCH v3 6/8 net/bootp: add VCI support for BOOTP also

Hi Ilya,

Quoted 15 lines · Ilya Yanok

Vendor Class Identifier option is common to BOOTP and DHCP and can be useful without PXE. So send VCI in both BOOTP and DHCP requests if CONFIG_BOOTP_VCI_STRING is defined.

---

 net/bootp.c |   20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)
net/bootp.c +0 -0
index 0f0867b..a68f914 100644

net/bootp.c BootpTimeout(void) · line 344

Quoted 6 lines
net/bootp.c +3 -0
@@ -339,6 +339,14 @@ BootpTimeout(void)
        }
 }
 
+#define put_vci(e, str)                                \
+       do {                                    \
+               *e++ = 60;                      \

Please keep the comment on the magic number.

net/bootp.c BootpTimeout(void) · line 345

Quoted 1 line
net/bootp.c +1 -0
+               *e++ = sizeof(str);             \

Did you mean to change this from strlen() to sizeof()? These are not the same thing.

Quoted 8 lines
net/bootp.c +4 -0
+               memcpy(e, str, sizeof(str));    \
+               e += sizeof(str);               \
+       } while (0)
+
 /*
  *     Initialize BOOTP extension fields in the request.
  */

net/bootp.c static int DhcpExtended(u8 *e, int message_type, IPaddr_t ServerID, · line 440

Quoted 7 lines
net/bootp.c +1 -2
@@ -435,12 +443,10 @@ static int DhcpExtended(u8 *e, int message_type, IPaddr_t ServerID,
                        printf("Invalid pxeuuid: %s\n", uuid);
                }
        }
+#endif
 
-       *e++ = 60;      /* Vendor Class Identifier */
-       vci_strlen = strlen(CONFIG_BOOTP_VCI_STRING);

If you aren't using this anymore, then you should remove size_t vci_strlen; from the top of the file.

Quoted 20 lines
net/bootp.c +6 -4
-       *e++ = vci_strlen;
-       memcpy(e, CONFIG_BOOTP_VCI_STRING, vci_strlen);
-       e += vci_strlen;
+#ifdef CONFIG_BOOTP_VCI_STRING
+       put_vci(e, CONFIG_VCI_STRING);
 #endif
 
 #if defined(CONFIG_BOOTP_VENDOREX)
@@ -527,6 +533,10 @@ static int BootpExtended(u8 *e)
        *e++ = (576 - 312 + OPT_FIELD_SIZE) & 0xff;
 #endif
 
+#ifdef CONFIG_BOOTP_VCI_STRING
+       put_vci(e, CONFIG_VCI_STRING);
+#endif
+
 #if defined(CONFIG_BOOTP_SUBNETMASK)
        *e++ = 1;               /* Subnet mask request */
        *e++ = 4;
--
Quoted 1 line

1.7.9.5

-Joe

author
#8 lore raw

PATCH v3 6/8 net/bootp: add VCI support for BOOTP also

Hi Joe,

Quoted 8 lines · Joe Hershberger

net/bootp.c BootpTimeout(void) · line 344

Quoted 4 lines
net/bootp.c +3 -0
+#define put_vci(e, str)                                \
+       do {                                    \
+               *e++ = 60;                      \

Please keep the comment on the magic number.

Sure.

Quoted 6 lines
Quoted 2 lines

+ *e++ = sizeof(str); \

Did you mean to change this from strlen() to sizeof()? These are not the same thing.

Good catch, will change it.

Quoted 15 lines

net/bootp.c static int DhcpExtended(u8 *e, int message_type,

Quoted 9 lines
net/bootp.c +4 -0
+               memcpy(e, str, sizeof(str));    \
+               e += sizeof(str);               \
+       } while (0)
+
 /*
  *     Initialize BOOTP extension fields in the request.
  */
@@ -435,12 +443,10 @@ static int DhcpExtended(u8 *e, int message_type,

IPaddr_t ServerID,

Quoted 5 lines
net/bootp.c +1 -0
                        printf("Invalid pxeuuid: %s\n", uuid);
                }
        }
+#endif
 
Quoted 6 lines

net/bootp.c static int DhcpExtended(u8 *e, int message_type, IPaddr_t ServerID, · line 440

Quoted 2 lines
net/bootp.c +0 -2
-       *e++ = 60;      /* Vendor Class Identifier */
-       vci_strlen = strlen(CONFIG_BOOTP_VCI_STRING);

If you aren't using this anymore, then you should remove size_t vci_strlen; from the top of the file.

Will move it inside macro.

Regards, Ilya.

author
#9 lore raw

PATCH v3 7/8 OMAP: networking support for SPL

In reply to Ilya Yanok

This patch adds support for networking in SPL. Some devices are capable of loading SPL via network so it makes sense to load the main U-Boot binary via network too. This patch tries to use existing network code as much as possible. Unfortunately, it depends on environment which in turn depends on other code so SPL size is increased significantly. No effort was done to decouple network code and environment so far.

---
Changes in v3:
- add support for setting different VCI in SPL
- use BOOTP in SPL regardless of CONFIG_CMD_DHCP

 arch/arm/cpu/armv7/omap-common/Makefile  |    3 ++
 arch/arm/cpu/armv7/omap-common/spl.c     |    5 +++
 arch/arm/cpu/armv7/omap-common/spl_eth.c |   50 ++++++++++++++++++++++++++++++
 arch/arm/include/asm/omap_common.h       |    4 +++
 common/Makefile                          |    6 ++++
 common/cmd_nvedit.c                      |    6 ++--
 common/env_common.c                      |    3 +-
 lib/Makefile                             |   10 ++++--
 lib/vsprintf.c                           |    2 +-
 net/bootp.c                              |   10 +++++-
 net/net.c                                |    3 ++
 spl/Makefile                             |    3 ++
 12 files changed, 98 insertions(+), 7 deletions(-)
 create mode 100644 arch/arm/cpu/armv7/omap-common/spl_eth.c
arch/arm/cpu/armv7/omap-common/Makefile +3 -0
index 1394c3f..4945bdf 100644
@@ -56,6 +56,9 @@ endif
 ifdef CONFIG_SPL_YMODEM_SUPPORT
 COBJS	+= spl_ymodem.o
 endif
+ifdef CONFIG_SPL_ETH_SUPPORT
+COBJS	+= spl_eth.o
+endif
 endif
 
 ifndef CONFIG_SPL_BUILD
arch/arm/cpu/armv7/omap-common/spl.c +5 -0
index 4d1ac85..e7127fb 100644
@@ -176,6 +176,11 @@ void board_init_r(gd_t *id, ulong dummy)
 		spl_ymodem_load_image();
 		break;
 #endif
+#ifdef CONFIG_SPL_ETH_SUPPORT
+	case BOOT_DEVICE_CPGMAC:
+		spl_eth_load_image();
+		break;
+#endif
 	default:
 		printf("SPL: Un-supported Boot Device - %d!!!\n", boot_device);
 		hang();
arch/arm/cpu/armv7/omap-common/spl_eth.c new file +50 -0

50 lines not on this page · raw message

arch/arm/include/asm/omap_common.h +4 -0
index 4e95eee..a433836 100644
@@ -69,6 +69,7 @@ void preloader_console_init(void);
 #define BOOT_DEVICE_MMC1	8
 #define BOOT_DEVICE_MMC2	0
 #define BOOT_DEVICE_UART	65
+#define BOOT_DEVICE_CPGMAC	70
 #define BOOT_DEVICE_MMC2_2      0xFF
 #endif
 
@@ -107,6 +108,9 @@ void spl_mmc_load_image(void);
 /* YMODEM SPL functions */
 void spl_ymodem_load_image(void);
 
+/* Ethernet SPL functions */
+void spl_eth_load_image(void);
+
 #ifdef CONFIG_SPL_BOARD_INIT
 void spl_board_init(void);
 #endif
common/Makefile +6 -0
index 483eb4d..d8b4b2a 100644
@@ -187,6 +187,12 @@ endif
 
 ifdef CONFIG_SPL_BUILD
 COBJS-$(CONFIG_SPL_YMODEM_SUPPORT) += xyzModem.o
+COBJS-$(CONFIG_SPL_NET_SUPPORT) += cmd_nvedit.o
+COBJS-$(CONFIG_SPL_NET_SUPPORT) += command.o
+COBJS-$(CONFIG_SPL_NET_SUPPORT) += env_common.o
+COBJS-$(CONFIG_SPL_NET_SUPPORT) += env_nowhere.o
+COBJS-$(CONFIG_SPL_NET_SUPPORT) += main.o
+COBJS-$(CONFIG_SPL_NET_SUPPORT) += miiphyutil.o
 endif
 COBJS-y += console.o
 COBJS-y += dlmalloc.o
common/cmd_nvedit.c +4 -2
index fd05e72..9bacf02 100644
@@ -578,7 +578,8 @@ ulong getenv_ulong(const char *name, int base, ulong default_val)
 	return str ? simple_strtoul(str, NULL, base) : default_val;
 }
 
-#if defined(CONFIG_CMD_SAVEENV) && !defined(CONFIG_ENV_IS_NOWHERE)
+#if defined(CONFIG_CMD_SAVEENV) && !defined(CONFIG_ENV_IS_NOWHERE) && \
+	!defined(CONFIG_SPL_BUILD)
 int do_env_save(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	printf("Saving Environment to %s...\n", env_name_spec);
@@ -912,7 +913,8 @@ static cmd_tbl_t cmd_env_sub[] = {
 #if defined(CONFIG_CMD_RUN)
 	U_BOOT_CMD_MKENT(run, CONFIG_SYS_MAXARGS, 1, do_run, "", ""),
 #endif
-#if defined(CONFIG_CMD_SAVEENV) && !defined(CONFIG_ENV_IS_NOWHERE)
+#if defined(CONFIG_CMD_SAVEENV) && !defined(CONFIG_ENV_IS_NOWHERE) && \
+	!defined(CONFIG_SPL_BUILD)
 	U_BOOT_CMD_MKENT(save, 1, 0, do_env_save, "", ""),
 #endif
 	U_BOOT_CMD_MKENT(set, CONFIG_SYS_MAXARGS, 0, do_env_set, "", ""),
common/env_common.c +2 -1
index c33d22d..493aff4 100644
@@ -225,7 +225,8 @@ void env_relocate(void)
 	env_reloc();
 #endif
 	if (gd->env_valid == 0) {
-#if defined(CONFIG_ENV_IS_NOWHERE)	/* Environment not changable */
+#if defined(CONFIG_ENV_IS_NOWHERE) || defined(CONFIG_SPL_BUILD)
+		/* Environment not changable */
 		set_default_env(NULL);
 #else
 		bootstage_error(BOOTSTAGE_ID_NET_CHECKSUM);
lib/Makefile +8 -2
index c60c380..59b4e05 100644
@@ -52,12 +52,18 @@ COBJS-$(CONFIG_SHA1) += sha1.o
 COBJS-$(CONFIG_SHA256) += sha256.o
 COBJS-y	+= strmhz.o
 COBJS-$(CONFIG_RBTREE)	+= rbtree.o
-else
-COBJS-$(CONFIG_SPL_SPI_FLASH_SUPPORT) += display_options.o
 endif
 
 ifdef CONFIG_SPL_BUILD
 COBJS-$(CONFIG_SPL_YMODEM_SUPPORT) += crc16.o
+COBJS-$(CONFIG_SPL_NET_SUPPORT) += crc32.o
+ifneq ($(CONFIG_SPL_SPI_FLASH_SUPPORT)$(CONFIG_SPL_NET_SUPPORT),)
+COBJS-y += display_options.o
+endif
+COBJS-$(CONFIG_SPL_NET_SUPPORT) += errno.o
+COBJS-$(CONFIG_SPL_NET_SUPPORT) += hashtable.o
+COBJS-$(CONFIG_SPL_NET_SUPPORT) += net_utils.o
+COBJS-$(CONFIG_SPL_NET_SUPPORT) += qsort.o
 endif
 COBJS-y += crc32.o
 COBJS-y += ctype.o
lib/vsprintf.c +1 -1
index e38a4b7..6bb819c 100644
@@ -784,7 +784,7 @@ void panic(const char *fmt, ...)
 	vprintf(fmt, args);
 	putc('\n');
 	va_end(args);
-#if defined (CONFIG_PANIC_HANG)
+#if defined (CONFIG_PANIC_HANG) || defined(CONFIG_SPL_BUILD)
 	hang();
 #else
 	udelay (100000);	/* allow messages to go out */
net/bootp.c +9 -1
index a68f914..13acf9a 100644
@@ -9,6 +9,9 @@
  */
 
 #include <common.h>
+#ifdef CONFIG_SPL_BUILD
+#undef CONFIG_CMD_DHCP
+#endif
 #include <command.h>
 #include <net.h>
 #include "bootp.h"
@@ -533,8 +536,13 @@ static int BootpExtended(u8 *e)
 	*e++ = (576 - 312 + OPT_FIELD_SIZE) & 0xff;
 #endif
 
-#ifdef CONFIG_BOOTP_VCI_STRING
+#if defined(CONFIG_BOOTP_VCI_STRING) || \
+	(defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_NET_VCI_STRING))
+#ifndef CONFIG_SPL_BUILD
 	put_vci(e, CONFIG_VCI_STRING);
+#else
+	put_vci(e, CONFIG_SPL_NET_VCI_STRING);
+#endif
 #endif
 
 #if defined(CONFIG_BOOTP_SUBNETMASK)
net/net.c +3 -0
index 9de7d92..91d3e73 100644
@@ -81,6 +81,9 @@
 
 
 #include <common.h>
+#ifdef CONFIG_SPL_BUILD
+#undef CONFIG_CMD_DHCP
+#endif
 #include <command.h>
 #include <net.h>
 #if defined(CONFIG_STATUS_LED)
spl/Makefile +3 -0
index ea7d475..925e84f 100644
@@ -57,6 +57,9 @@ LIBS-$(CONFIG_SPL_NAND_SUPPORT) += drivers/mtd/nand/libnand.o
 LIBS-$(CONFIG_SPL_ONENAND_SUPPORT) += drivers/mtd/onenand/libonenand.o
 LIBS-$(CONFIG_SPL_DMA_SUPPORT) += drivers/dma/libdma.o
 LIBS-$(CONFIG_SPL_POST_MEM_SUPPORT) += post/drivers/memory.o
+LIBS-$(CONFIG_SPL_NET_SUPPORT) += net/libnet.o
+LIBS-$(CONFIG_SPL_ETH_SUPPORT) += drivers/net/libnet.o
+LIBS-$(CONFIG_SPL_ETH_SUPPORT) += drivers/net/phy/libphy.o
 
 ifneq ($(CONFIG_AM33XX)$(CONFIG_OMAP34XX)$(CONFIG_OMAP44XX)$(CONFIG_OMAP54XX),)
 LIBS-y += $(CPUDIR)/omap-common/libomap-common.o
Signature · 1 line
1.7.9.5
author
#10 lore raw

PATCH v3 8/8 am335x_evm: enable networking in SPL

In reply to Ilya Yanok

This patch adds support for networking in SPL on TI AM335x based boards. Vendor Class Identifier used by SPL during BOOTP is "AM335x U-Boot SPL".

---
Changes in v3:
- set Vendor Class Identifier for SPL

 board/ti/am335x/evm.c        |   12 ++++++++++++
 include/configs/am335x_evm.h |    6 +++++-
 2 files changed, 17 insertions(+), 1 deletion(-)
board/ti/am335x/evm.c +12 -0
index b7eee80..597fced 100644
@@ -120,6 +120,18 @@ int board_init(void)
 	return 0;
 }
 
+#ifdef CONFIG_SPL_BUILD
+int spl_board_init(void)
+{
+	enable_i2c0_pin_mux();
+	i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
+	if (read_eeprom() < 0)
+		printf("Could not get board ID.\n");
+
+	return 0;
+}
+#endif
+
 #ifdef CONFIG_DRIVER_TI_CPSW
 static void cpsw_control(int enabled)
 {
include/configs/am335x_evm.h +5 -1
index 2a3251b..22eefa4 100644
@@ -128,8 +128,9 @@
 
 /* Defines for SPL */
 #define CONFIG_SPL
+#define CONFIG_SPL_BOARD_INIT
 #define CONFIG_SPL_TEXT_BASE		0x402F0400
-#define CONFIG_SPL_MAX_SIZE		(46 * 1024)
+#define CONFIG_SPL_MAX_SIZE		(101 * 1024)
 #define CONFIG_SPL_STACK		LOW_LEVEL_SRAM_STACK
 
 #define CONFIG_SPL_BSS_START_ADDR	0x80000000
@@ -148,6 +149,9 @@
 #define CONFIG_SPL_LIBGENERIC_SUPPORT
 #define CONFIG_SPL_SERIAL_SUPPORT
 #define CONFIG_SPL_YMODEM_SUPPORT
+#define CONFIG_SPL_NET_SUPPORT
+#define CONFIG_SPL_NET_VCI_STRING	"AM335x U-Boot SPL"
+#define CONFIG_SPL_ETH_SUPPORT
 #define CONFIG_SPL_LDSCRIPT		"$(CPUDIR)/omap-common/u-boot-spl.lds"
 
 /*
Signature · 1 line
1.7.9.5
#11 lore raw

v3 cover CPSW switch plus SPL net support

In reply to Ilya Yanok
Quoted 7 lines · Ilya Yanok

These patches add CPSW switch driver and enable support for it on TI AM335x based boards. This version is rebased on top of u-boot-ti/next. Also now CPSW driver uses internal controller memory for DMA descriptors so coherent allocator is no longer a requirement for this series.

Quoted 5 lines

The second part of the series provides support for networking in SPL. These patches try to use network infrasctructure as is, without trying to cut some minimal set of it, so the resulting SPL image is quite big and only useful for boards with plenty of SRAM/OCRAM (like TI AM335x based ones).

Parts 1 to 5 look good, barring comments from someone else, I'll pick those up Friday or so and you can v4 just 6/7/8.

Signature · 1 line
Tom
#12 lore raw

v3 cover CPSW switch plus SPL net support

In reply to Ilya Yanok
Quoted 58 lines · Ilya Yanok

These patches add CPSW switch driver and enable support for it on TI AM335x based boards. This version is rebased on top of u-boot-ti/next. Also now CPSW driver uses internal controller memory for DMA descriptors so coherent allocator is no longer a requirement for this series.

The second part of the series provides support for networking in SPL. These patches try to use network infrasctructure as is, without trying to cut some minimal set of it, so the resulting SPL image is quite big and only useful for boards with plenty of SRAM/OCRAM (like TI AM335x based ones).

Changes in v2:
- fix timeout handling
- use internal RAM for descriptors

Changes in v3:
- add support for setting different VCI in SPL
- change calls to miiphy_{speed,duplex}() to phy_startup()
- drop volatiles
- fix whitespace problem
- set Vendor Class Identifier for SPL
- stop DMA on driver halt (fix by Mugunthan V N)
- use BOOTP in SPL regardless of CONFIG_CMD_DHCP

Chandan Nath (3):
am33xx: CPSW init and definitions
am33xx: pin mux defintions for CPSW switch
am335x_evm: CPSW support

Cyril Chemparathy (1):
cpsw: add driver for cpsw ethernet device

Ilya Yanok (4):
am335x_evm: read the on-board EEPROM
net/bootp: add VCI support for BOOTP also
OMAP: networking support for SPL
am335x_evm: enable networking in SPL

 arch/arm/cpu/armv7/am33xx/clock.c             |    8 +-
 arch/arm/cpu/armv7/omap-common/Makefile       |    3 +
 arch/arm/cpu/armv7/omap-common/spl.c          |    5 +
 arch/arm/cpu/armv7/omap-common/spl_eth.c      |   50 ++
 arch/arm/include/asm/arch-am33xx/common_def.h |    2 +
 arch/arm/include/asm/arch-am33xx/cpu.h        |   11 +
 arch/arm/include/asm/arch-am33xx/hardware.h   |    5 +
 arch/arm/include/asm/omap_common.h            |    4 +
 board/ti/am335x/evm.c                         |  175 ++++-
 board/ti/am335x/mux.c                         |   47 ++
 common/Makefile                               |    6 +
 common/cmd_nvedit.c                           |    6 +-
 common/env_common.c                           |    3 +-
 drivers/net/Makefile                          |    1 +
 drivers/net/cpsw.c                            |  991 +++++++++++++++++++++++++
 include/configs/am335x_evm.h                  |   26 +-
 include/cpsw.h                                |   51 ++
 lib/Makefile                                  |   10 +-
Quoted 8 lines
 lib/vsprintf.c                                |    2 +-
 net/bootp.c                                   |   28 +-
 net/net.c                                     |    3 +
 spl/Makefile                                  |    3 +
 22 files changed, 1424 insertions(+), 16 deletions(-)
 create mode 100644 arch/arm/cpu/armv7/omap-common/spl_eth.c
 create mode 100644 drivers/net/cpsw.c
 create mode 100644 include/cpsw.h

Applied parts 1 to 5 to u-boot-ti/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120803/a40b2d1e/attachment.pgp>