Enable CPSW on TI814x EVM
Subsystems (3)
cover Enable CPSW on TI814x EVM
This series adds support for CPSW on the PG1.0 TI814x EVM board. The V1 CPSW on TI814x requires minor register changes to the existing driver as well as TI814x-specific pll/clock support. An ET1011C phy driver is added to support the PHY present on the PG1.0 EVM.
It has been tested loading/booting a Linux kernel and regression tested on BeagleBone and EVM-SK AM33XX boards. It has also been MAKEALL tested for all am33xx platforms.
The series applies on top of the following patches:
- am33xx: Add required includes to some omap/am33xx code http://patchwork.ozlabs.org/patch/227804/ - Add TI814x EVM Support v4 http://www.mail-archive.com/u-boot at lists.denx.de/msg108356.html
Matt Porter (4):
am33xx: add pll and clock support for TI814x CPSW
cpsw: add support for TI814x slave_regs differences
phy: add support for ET1011C phys
ti814x_evm: enable CPSW support
arch/arm/cpu/armv7/am33xx/clock_ti814x.c | 56 +++++++++- arch/arm/include/asm/arch-am33xx/hardware_ti814x.h | 1 + board/ti/ti814x/evm.c | 75 +++++++++++++ board/ti/ti814x/evm.h | 1 + board/ti/ti814x/mux.c | 35 +++++++ drivers/net/cpsw.c | 6 ++ drivers/net/phy/Makefile | 1 + drivers/net/phy/et1011c.c | 110 ++++++++++++++++++++ drivers/net/phy/phy.c | 3 + include/configs/ti814x_evm.h | 21 ++++ include/phy.h | 1 + 11 files changed, 308 insertions(+), 2 deletions(-) create mode 100644 drivers/net/phy/et1011c.c
Signature · 1 line
1.7.9.5
PATCH 1/4 am33xx: add pll and clock support for TI814x CPSW
Enables required PLLs and clocks for CPSW on TI814x.
--- arch/arm/cpu/armv7/am33xx/clock_ti814x.c | 56 +++++++++++++++++++- arch/arm/include/asm/arch-am33xx/hardware_ti814x.h | 1 + board/ti/ti814x/evm.c | 3 ++ 3 files changed, 58 insertions(+), 2 deletions(-)
arch/arm/cpu/armv7/am33xx/clock_ti814x.c +54 -2
@@ -183,7 +183,7 @@ struct cm_alwon {unsigned int resv5[2 ];unsigned int gpmcclkctrl;unsigned int ethernet0clkctrl; -unsigned int resv6[1 ]; +unsigned int ethernet1clkctrl;unsigned int mpuclkctrl;unsigned int debugssclkctrl;unsigned int l3clkctrl;
@@ -203,9 +203,23 @@ struct cm_alwon {unsigned int custefuseclkctrl; }; +#define SATA_PLL_BASE (CTRL_BASE + 0x0720) + +struct sata_pll { +unsigned int pllcfg0; +unsigned int pllcfg1; +unsigned int pllcfg2; +unsigned int pllcfg3; +unsigned int pllcfg4; +unsigned int pllstatus; +unsigned int rxstatus; +unsigned int txstatus; +unsigned int testcfg; +};const struct cm_alwon *cmalwon = (struct cm_alwon *)CM_ALWON_BASE ;const struct cm_def *cmdef = (struct cm_def *)CM_DEFAULT_BASE ; +const struct sata_pll *spll = (struct sata_pll *)SATA_PLL_BASE ;/* * Enable the peripheral clock for required peripherals
@@ -221,6 +235,18 @@ static void enable_per_clocks(void)writel (PRCM_MOD_EN , &cmalwon->mmchs1clkctrl);while (readl (&cmalwon->mmchs1clkctrl) !=PRCM_MOD_EN ) ; + +/* Ethernet */ +writel (PRCM_MOD_EN , &cmalwon->l3slowclkstctrl); +while ((readl (&cmalwon->l3slowclkstctrl) &0x2100 ) !=0x2100 ) + ; +writel (PRCM_MOD_EN , &cmalwon->ethclkstctrl); +writel (PRCM_MOD_EN , &cmalwon->ethernet0clkctrl); +while ((readl (&cmalwon->ethernet0clkctrl) &0x30000 ) !=0 ) + ; +writel (PRCM_MOD_EN , &cmalwon->ethernet1clkctrl); +while ((readl (&cmalwon->ethernet1clkctrl) &0x30000 ) !=0 ) + ; }/*
@@ -365,6 +391,31 @@ void ddr_pll_config(unsigned int ddrpll_m)pll_config (DDR_PLL_BASE ,DDR_N ,DDR_M ,DDR_M2 ,DDR_CLKCTRL ,1 ); } +void sata_pll_config (void ) +{ +/* TRM 21.3.1 */ +writel (0xc12c003c , &spll->pllcfg1); +udelay (50 ); + +writel (0x004008e0 , &spll->pllcfg3); +udelay (50 ); + +writel (0x80000004 , &spll->pllcfg0); +udelay (50 ); + +writel (0x80000014 , &spll->pllcfg0); +udelay (50 ); + +writel (0x80000016 , &spll->pllcfg0); +udelay (50 ); + +writel (0xc0000017 , &spll->pllcfg0); +udelay (50 ); + +while (((readl (&spll->pllstatus) &0x01 ) ==0 )) + ; +} +void enable_emif_clocks (void ) {};void enable_dmm_clocks (void )
@@ -397,9 +448,10 @@ void pll_init()/* Enable the control module */ writel (PRCM_MOD_EN , &cmalwon->controlclkctrl); +/* Configure PLLs */ mpu_pll_config (); -l3_pll_config (); +sata_pll_config ();/* Enable the required peripherals */ enable_per_clocks ();
arch/arm/include/asm/arch-am33xx/hardware_ti814x.h +1 -0
@@ -29,6 +29,7 @@/* Control Module Base Address */ #define CTRL_BASE 0x48140000 +#define CTRL_DEVICE_BASE 0x48140600/* PRCM Base Address */ #define PRCM_BASE 0x48180000
board/ti/ti814x/evm.c +3 -0
@@ -151,6 +151,9 @@ void s_init(void)*/ wdt_disable (); +/* Enable timer */ +timer_init (); +/* Setup the PLLs and the clocks for the peripherals */ pll_init ();
Signature · 1 line
1.7.9.5
PATCH 1/4 am33xx: add pll and clock support for TI814x CPSW
On Fri, Mar 15, 2013 at 04:58:17PM -0400, Matt Porter wrote:
[snip]
arch/arm/cpu/armv7/am33xx/clock_ti814x.c static void enable_per_clocks(void) · line 248
Quoted 10 lines
arch/arm/cpu/armv7/am33xx/clock_ti814x.c +10
-0+/* Ethernet */ +writel (PRCM_MOD_EN , &cmalwon->l3slowclkstctrl); +while ((readl (&cmalwon->l3slowclkstctrl) &0x2100 ) !=0x2100 ) + ; +writel (PRCM_MOD_EN , &cmalwon->ethclkstctrl); +writel (PRCM_MOD_EN , &cmalwon->ethernet0clkctrl); +while ((readl (&cmalwon->ethernet0clkctrl) &0x30000 ) !=0 ) + ; +writel (PRCM_MOD_EN , &cmalwon->ethernet1clkctrl); +while ((readl (&cmalwon->ethernet1clkctrl) &0x30000 ) !=0 )
Please define away the magic numbers.
[snip]
arch/arm/cpu/armv7/am33xx/clock_ti814x.c void ddr_pll_config(unsigned int ddrpll_m) · line 397
Quoted 4 lines
arch/arm/cpu/armv7/am33xx/clock_ti814x.c +4
-0+void sata_pll_config (void ) +{ +/* TRM 21.3.1 */ +writel (0xc12c003c , &spll->pllcfg1);
I'm OK with comments, but please make it a multi-line thing that explains what's going on so that it's clear that yes, really, we shouldn't have defined these.
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/20130315/ed782504/attachment.pgp>
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/4 am33xx: add pll and clock support for TI814x CPSW
Quoted 17 lines · Tom Rini
On Fri, Mar 15, 2013 at 04:58:17PM -0400, Matt Porter wrote:
[snip]
arch/arm/cpu/armv7/am33xx/clock_ti814x.c static void enable_per_clocks(void) · line 248
Quoted 10 lines
arch/arm/cpu/armv7/am33xx/clock_ti814x.c +10
-0+/* Ethernet */ +writel (PRCM_MOD_EN , &cmalwon->l3slowclkstctrl); +while ((readl (&cmalwon->l3slowclkstctrl) &0x2100 ) !=0x2100 ) + ; +writel (PRCM_MOD_EN , &cmalwon->ethclkstctrl); +writel (PRCM_MOD_EN , &cmalwon->ethernet0clkctrl); +while ((readl (&cmalwon->ethernet0clkctrl) &0x30000 ) !=0 ) + ; +writel (PRCM_MOD_EN , &cmalwon->ethernet1clkctrl); +while ((readl (&cmalwon->ethernet1clkctrl) &0x30000 ) !=0 )Please define away the magic numbers.
[snip]
Quoted 8 lines
arch/arm/cpu/armv7/am33xx/clock_ti814x.c void ddr_pll_config(unsigned int ddrpll_m) · line 397
Quoted 4 lines
arch/arm/cpu/armv7/am33xx/clock_ti814x.c +4
-0+void sata_pll_config (void ) +{ +/* TRM 21.3.1 */ +writel (0xc12c003c , &spll->pllcfg1);I'm OK with comments, but please make it a multi-line thing that explains what's going on so that it's clear that yes, really, we shouldn't have defined these.
I'll address this with gratuitous defines in v2...and expand the comment.
-Matt
PATCH 2/4 cpsw: add support for TI814x slave_regs differences
In reply to Matt PorterTI814x's version 1 CPSW has a different slave_regs layout. Add support for the differing registers.
--- drivers/net/cpsw.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/cpsw.c +6 -0
@@ -109,7 +109,13 @@ struct cpsw_slave_regs {u32 flow_thresh;u32 port_vlan;u32 tx_pri_map; +#ifdef CONFIG_AM33XX u32 gap_thresh; +#elif defined(CONFIG_TI814X ) +u32 ts_ctl; +u32 ts_seq_ltype; +u32 ts_vlan; +#endif u32 sa_lo;u32 sa_hi; };
Signature · 1 line
1.7.9.5
PATCH 2/4 cpsw: add support for TI814x slave_regs differences
Quoted 4 lines · Matt Porter
TI814x's version 1 CPSW has a different
slave_regslayout. Add support for the differing registers.Signed-off-by Matt Porter <[email protected]>
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/20130315/52950f00/attachment.pgp>
PATCH 3/4 phy: add support for ET1011C phys
In reply to Matt PorterAdds an ET1011C PHY driver which is derived from the current Linux kernel PHY driver. Note that an errata workaround config option is implemented to allow for TX_CLK to be enabled even when gigabit mode is negotiated. This workaround is used on the TI814x-EVM.
--- drivers/net/phy/Makefile | 1 + drivers/net/phy/et1011c.c | 110 +++++++++++++++++++++++++++++++++++++++++++++ drivers/net/phy/phy.c | 3 ++ include/phy.h | 1 + 4 files changed, 115 insertions(+) create mode 100644 drivers/net/phy/et1011c.c
drivers/net/phy/Makefile +1 -0
@@ -34,6 +34,7 @@ COBJS-$(CONFIG_PHYLIB_10G) += generic_10g.o COBJS-$(CONFIG_PHY_ATHEROS) += atheros.o COBJS-$(CONFIG_PHY_BROADCOM) += broadcom.o COBJS-$(CONFIG_PHY_DAVICOM) += davicom.o +COBJS-$(CONFIG_PHY_ET1011C) += et1011c.o COBJS-$(CONFIG_PHY_LXT) += lxt.o COBJS-$(CONFIG_PHY_MARVELL) += marvell.o COBJS-$(CONFIG_PHY_MICREL) += micrel.o
drivers/net/phy/et1011c.c new file +110 -0
110 lines not on this page · raw message
drivers/net/phy/phy.c +3 -0
@@ -430,6 +430,9 @@ int phy_init(void)#ifdef CONFIG_PHY_DAVICOM phy_davicom_init ();#endif +#ifdef CONFIG_PHY_ET1011C +phy_et1011c_init (); +#endif #ifdef CONFIG_PHY_LXT phy_lxt_init ();#endif
include/phy.h +1 -0
@@ -223,6 +223,7 @@ int gen10g_discover_mmds(struct phy_device *phydev);int phy_atheros_init (void );int phy_broadcom_init (void );int phy_davicom_init (void ); +int phy_et1011c_init (void );int phy_lxt_init (void );int phy_marvell_init (void );int phy_micrel_init (void );
Signature · 1 line
1.7.9.5
PATCH 3/4 phy: add support for ET1011C phys
Quoted 6 lines · Matt Porter
Adds an ET1011C PHY driver which is derived from the current Linux kernel PHY driver. Note that an errata workaround config option is implemented to allow for
TX_CLKto be enabled even when gigabit mode is negotiated. This workaround is used on the TI814x-EVM.
You need to specify the git hash or tag, not just "current".
The code itself is fine, so
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/20130315/de377a08/attachment.pgp>
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 3/4 phy: add support for ET1011C phys
Quoted 10 lines · Tom Rini
Quoted 6 lines · Matt Porter
Adds an ET1011C PHY driver which is derived from the current Linux kernel PHY driver. Note that an errata workaround config option is implemented to allow for
TX_CLKto be enabled even when gigabit mode is negotiated. This workaround is used on the TI814x-EVM.You need to specify the git hash or tag, not just "current".
Updated in v2
Quoted 3 lines
The code itself is fine, so
Reviewed-by Tom Rini <[email protected]>
-Matt
PATCH 4/4 ti814x_evm: enable CPSW support
In reply to Matt PorterAdds CPSW support to the TI814X EVM configured with an ET1011C PHY in GMII mode.
--- board/ti/ti814x/evm.c | 72 ++++++++++++++++++++++++++++++++++++++++++ board/ti/ti814x/evm.h | 1 + board/ti/ti814x/mux.c | 35 ++++++++++++++++++++ include/configs/ti814x_evm.h | 21 ++++++++++++ 4 files changed, 129 insertions(+)
board/ti/ti814x/evm.c +72 -0
@@ -17,6 +17,7 @@*/ #include <common.h> +#include <cpsw.h> #include <errno.h> #include <spl.h> #include <asm/arch/cpu.h>
@@ -39,6 +40,8 @@ static struct wd_timer *wdtimer = (struct wd_timer *)WDT_BASE;static struct uart_sys *uart_base = (struct uart_sys *)DEFAULT_UART_BASE ;#endif +static struct ctrl_dev *cdev = (struct ctrl_dev *)CTRL_DEVICE_BASE ; +/* UART Defines */ #ifdef CONFIG_SPL_BUILD #define UART_RESET (0x1 << 1)
@@ -166,6 +169,9 @@ void s_init(void)/* Set MMC pins */ enable_mmc1_pin_mux (); +/* Set Ethernet pins */ +enable_enet_pin_mux (); +/* Enable UART */ uart_enable ();
@@ -199,3 +205,69 @@ int board_mmc_init(bd_t *bis)return 0 ; }#endif + +#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 =0x50 , + .sliver_reg_ofs =0x700 , + .phy_id =1 , + }, + { + .slave_reg_ofs =0x90 , + .sliver_reg_ofs =0x740 , + .phy_id =0 , + }, +}; + +static struct cpsw_platform_data cpsw_data = { + .mdio_base =CPSW_MDIO_BASE , + .cpsw_base =CPSW_BASE , + .mdio_div =0xff , + .channels =8 , + .cpdma_reg_ofs =0x100 , + .slaves =1 , + .slave_data = cpsw_slaves, + .ale_reg_ofs =0x600 , + .ale_entries =1024 , + .host_port_reg_ofs =0x28 , + .hw_stats_reg_ofs =0x400 , + .mac_control = (1 <<5 ), + .control = cpsw_control, + .host_port_num =0 , + .version =CPSW_CTRL_VERSION_1 , +}; +#endif + +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)) { +printf ("<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 +printf ("Unable to read MAC address. Set <ethaddr>\n" ); + } + +return cpsw_register (&cpsw_data); +}
board/ti/ti814x/evm.h +1 -0
@@ -3,5 +3,6 @@void enable_uart0_pin_mux (void );void enable_mmc1_pin_mux (void ); +void enable_enet_pin_mux (void );#endif /* _EVM_H */
board/ti/ti814x/mux.c +35 -0
@@ -40,6 +40,36 @@ static struct module_pin_mux mmc1_pin_mux[] = { {-1}, }; +static struct module_pin_mux enet_pin_mux[] = { + {OFFSET (pincntl232),MODE (0x01 )},/* EMAC_RMREFCLK */ + {OFFSET (pincntl233),PULLUP_EN |MODE (0x01 )},/* MDCLK */ + {OFFSET (pincntl234),PULLUP_EN |MODE (0x01 )},/* MDIO */ + {OFFSET (pincntl235),MODE (0x01 )},/* EMAC[0]_MTCLK */ + {OFFSET (pincntl236),MODE (0x01 )},/* EMAC[0]_MCOL */ + {OFFSET (pincntl237),MODE (0x01 )},/* EMAC[0]_MCRS */ + {OFFSET (pincntl238),MODE (0x01 )},/* EMAC[0]_MRXER */ + {OFFSET (pincntl239),MODE (0x01 )},/* EMAC[0]_MRCLK */ + {OFFSET (pincntl240),MODE (0x01 )},/* EMAC[0]_MRXD[0] */ + {OFFSET (pincntl241),MODE (0x01 )},/* EMAC[0]_MRXD[1] */ + {OFFSET (pincntl242),MODE (0x01 )},/* EMAC[0]_MRXD[2] */ + {OFFSET (pincntl243),MODE (0x01 )},/* EMAC[0]_MRXD[3] */ + {OFFSET (pincntl244),MODE (0x01 )},/* EMAC[0]_MRXD[4] */ + {OFFSET (pincntl245),MODE (0x01 )},/* EMAC[0]_MRXD[5] */ + {OFFSET (pincntl246),MODE (0x01 )},/* EMAC[0]_MRXD[6] */ + {OFFSET (pincntl247),MODE (0x01 )},/* EMAC[0]_MRXD[7] */ + {OFFSET (pincntl248),MODE (0x01 )},/* EMAC[0]_MRXDV */ + {OFFSET (pincntl249),MODE (0x01 )},/* EMAC[0]_GMTCLK */ + {OFFSET (pincntl250),MODE (0x01 )},/* EMAC[0]_MTXD[0] */ + {OFFSET (pincntl251),MODE (0x01 )},/* EMAC[0]_MTXD[1] */ + {OFFSET (pincntl252),MODE (0x01 )},/* EMAC[0]_MTXD[2] */ + {OFFSET (pincntl253),MODE (0x01 )},/* EMAC[0]_MTXD[3] */ + {OFFSET (pincntl254),MODE (0x01 )},/* EMAC[0]_MTXD[4] */ + {OFFSET (pincntl255),MODE (0x01 )},/* EMAC[0]_MTXD[5] */ + {OFFSET (pincntl256),MODE (0x01 )},/* EMAC[0]_MTXD[6] */ + {OFFSET (pincntl257),MODE (0x01 )},/* EMAC[0]_MTXD[7] */ + {OFFSET (pincntl258),MODE (0x01 )},/* EMAC[0]_MTXEN */ +}; +void enable_uart0_pin_mux (void ) {configure_module_pin_mux (uart0_pin_mux);
@@ -49,3 +79,8 @@ void enable_mmc1_pin_mux(void) {configure_module_pin_mux (mmc1_pin_mux); } + +void enable_enet_pin_mux (void ) +{ +configure_module_pin_mux (enet_pin_mux); +}
include/configs/ti814x_evm.h +21 -0
@@ -217,4 +217,25 @@/* Unsupported features */ #undef CONFIG_USE_IRQ +/* Ethernet */ +#define CONFIG_CMD_NET +#define CONFIG_CMD_DHCP +#define CONFIG_CMD_PING +#define CONFIG_CMD_MII +#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 +#define CONFIG_PHY_ADDR 1 +#define CONFIG_PHY_ET1011C +#define CONFIG_PHY_ET1011C_TX_CLK_FIX +#endif /* ! __CONFIG_TI814X_EVM_H */
Signature · 1 line
1.7.9.5
PATCH 4/4 ti814x_evm: enable CPSW support
Quoted 4 lines · Matt Porter
Adds CPSW support to the TI814X EVM configured with an ET1011C PHY in GMII mode.
Signed-off-by Matt Porter <[email protected]>
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/20130315/06d80497/attachment.pgp>