Skip to contentSkip to conversation

keystone2: add network support for K2E SoC and EVM

PATCH Superseded Ivan Khoronzhuk 2 participants 14 messages Oct 17, 2014 – Oct 23, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v2 cover keystone2: add network support for K2E SoC and EVM

These patches add network support for Keystne2 Edison SoC boards.

Based on
"[U-boot] [Patch v2 0/5] keystone_net: use MDIO bus and eth PHY frameworks"
http://patchwork.ozlabs.org/patch/322289/

v2..v1
ARM: keystone: clock: add support for K2E SoCs
- firstly added

Hao Zhang (1):
board: k2e_evm: add network support

Ivan Khoronzhuk (5):
ARM: keystone2: keysonte_nav: add support for K2E SoC
net: keystone_serdes: add keystone K2E SoC support
net: keystone_net: add Keystone2 K2E SoC support
net: keystone_net: increase PHY auto negotiate time
ARM: keystone: clock: add support for K2E SoCs

 arch/arm/cpu/armv7/keystone/clock.c               | 17 ++++--
 arch/arm/include/asm/arch-keystone/clock.h        |  1 +
 arch/arm/include/asm/arch-keystone/hardware-k2e.h | 20 +++++++
 board/ti/ks2_evm/board.c                          |  1 +
 board/ti/ks2_evm/board_k2e.c                      | 68 ++++++++++++++++++++++-
 drivers/net/keystone_net.c                        | 47 ++++++++++++++--
 include/configs/k2e_evm.h                         | 11 ++++
 include/configs/ks2_evm.h                         |  1 +
 8 files changed, 156 insertions(+), 10 deletions(-)
Signature · 1 line
1.8.3.2
#1 lore raw

PATCH v2 1/6 ARM: keystone2: keysonte_nav: add support for K2E SoC

Keystone2 Edison SoC uses the same keystone navigator, but uses different NETCP PktDMA definitions. This patch adds required definitions.

---
 arch/arm/include/asm/arch-keystone/hardware-k2e.h | 13 +++++++++++++
 1 file changed, 13 insertions(+)
arch/arm/include/asm/arch-keystone/hardware-k2e.h +13 -0
index 62172a4..f09aa93 100644
@@ -41,4 +41,17 @@
 /* Number of DSP cores */
 #define KS2_NUM_DSPS			1
 
+/* NETCP pktdma */
+#define KS2_NETCP_PDMA_CTRL_BASE	0x24186000
+#define KS2_NETCP_PDMA_TX_BASE		0x24187000
+#define KS2_NETCP_PDMA_TX_CH_NUM	21
+#define KS2_NETCP_PDMA_RX_BASE		0x24188000
+#define KS2_NETCP_PDMA_RX_CH_NUM	91
+#define KS2_NETCP_PDMA_SCHED_BASE	0x24186100
+#define KS2_NETCP_PDMA_RX_FLOW_BASE	0x24189000
+#define KS2_NETCP_PDMA_RX_FLOW_NUM	96
+#define KS2_NETCP_PDMA_RX_FREE_QUEUE	4001
+#define KS2_NETCP_PDMA_RX_RCV_QUEUE	4002
+#define KS2_NETCP_PDMA_TX_SND_QUEUE	896
+
 #endif
Signature · 1 line
1.8.3.2
#2 lore raw

PATCH v2 1/6 ARM: keystone2: keysonte_nav: add support for K2E SoC

Quoted 7 lines · Ivan

Keystone2 Edison SoC uses the same keystone navigator, but uses different NETCP PktDMA definitions. This patch adds required definitions.

Applied to u-boot-ti/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20141023/7ba0e508/attachment.pgp>
#3 lore raw

PATCH v2 2/6 net: keystone_serdes: add keystone K2E SoC support

In reply to Ivan Khoronzhuk

Keystone2 Edison SoC uses the same keystone SerDes driver. This patch adds support for K2E SoCs.

---
 arch/arm/include/asm/arch-keystone/hardware-k2e.h | 4 ++++
 drivers/net/keystone_net.c                        | 6 ++++++
 include/configs/k2e_evm.h                         | 3 +++
 include/configs/ks2_evm.h                         | 1 +
 4 files changed, 14 insertions(+)
arch/arm/include/asm/arch-keystone/hardware-k2e.h +4 -0
index f09aa93..4eac5f8 100644
@@ -38,6 +38,10 @@
 #define KS2_CIC2_DDR3_ECC_IRQ_NUM	-1	/* not defined in K2E */
 #define KS2_CIC2_DDR3_ECC_CHAN_NUM	-1	/* not defined in K2E */
 
+/* SGMII SerDes */
+#define KS2_SGMII_SERDES2_BASE		0x02324000
+#define KS2_LANES_PER_SGMII_SERDES	4
+
 /* Number of DSP cores */
 #define KS2_NUM_DSPS			1
 
drivers/net/keystone_net.c +6 -0
index 13a1778..43c263e 100644
@@ -551,6 +551,12 @@ static void keystone2_net_serdes_setup(void)
 			&ks2_serdes_sgmii_156p25mhz,
 			CONFIG_KSNET_SERDES_LANES_PER_SGMII);
 
+#ifdef CONFIG_SOC_K2E
+	ks2_serdes_init(CONFIG_KSNET_SERDES_SGMII2_BASE,
+			&ks2_serdes_sgmii_156p25mhz,
+			CONFIG_KSNET_SERDES_LANES_PER_SGMII);
+#endif
+
 	/* wait till setup */
 	udelay(5000);
 }
include/configs/k2e_evm.h +3 -0
index 3502d10..fd45d61 100644
@@ -34,4 +34,7 @@
 /* NAND Configuration */
 #define CONFIG_SYS_NAND_PAGE_2K
 
+/* SerDes */
+#define CONFIG_TI_KEYSTONE_SERDES
+
 #endif /* __CONFIG_K2E_EVM_H */
include/configs/ks2_evm.h +1 -0
index dcce7c3..a92ab04 100644
@@ -140,6 +140,7 @@
 #define CONFIG_KSNET_MAC_ID_BASE		KS2_MAC_ID_BASE_ADDR
 #define CONFIG_KSNET_NETCP_BASE			KS2_NETCP_BASE
 #define CONFIG_KSNET_SERDES_SGMII_BASE		KS2_SGMII_SERDES_BASE
+#define CONFIG_KSNET_SERDES_SGMII2_BASE		KS2_SGMII_SERDES2_BASE
 #define CONFIG_KSNET_SERDES_LANES_PER_SGMII	KS2_LANES_PER_SGMII_SERDES
 
 /* AEMIF */
Signature · 1 line
1.8.3.2
#4 lore raw

PATCH v2 2/6 net: keystone_serdes: add keystone K2E SoC support

Quoted 6 lines · Ivan

Keystone2 Edison SoC uses the same keystone SerDes driver. This patch adds support for K2E SoCs.

Applied to u-boot-ti/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20141023/78847ecb/attachment.pgp>
#5 lore raw

PATCH v2 3/6 net: keystone_net: add Keystone2 K2E SoC support

In reply to Ivan Khoronzhuk

The Keystone2 Edison SoC uses the same keystone net driver. This patch adds opportunity to use it by K2E SoCs.

---
 arch/arm/include/asm/arch-keystone/hardware-k2e.h | 3 +++
 drivers/net/keystone_net.c                        | 5 +++++
 2 files changed, 8 insertions(+)
arch/arm/include/asm/arch-keystone/hardware-k2e.h +3 -0
index 4eac5f8..ab0d5f9 100644
@@ -58,4 +58,7 @@
 #define KS2_NETCP_PDMA_RX_RCV_QUEUE	4002
 #define KS2_NETCP_PDMA_TX_SND_QUEUE	896
 
+/* NETCP */
+#define KS2_NETCP_BASE			0x24000000
+
 #endif
drivers/net/keystone_net.c +5 -0
index 43c263e..1186188 100644
@@ -289,6 +289,11 @@ int mac_sl_config(u_int16_t port, struct mac_sl_cfg *cfg)
 	writel(cfg->max_rx_len, DEVICE_EMACSL_BASE(port) + CPGMACSL_REG_MAXLEN);
 	writel(cfg->ctl, DEVICE_EMACSL_BASE(port) + CPGMACSL_REG_CTL);
 
+#ifdef CONFIG_K2E_EVM
+	/* Map RX packet flow priority to 0 */
+	writel(0, DEVICE_EMACSL_BASE(port) + CPGMACSL_REG_RX_PRI_MAP);
+#endif
+
 	return ret;
 }
 
Signature · 1 line
1.8.3.2
#6 lore raw

PATCH v2 3/6 net: keystone_net: add Keystone2 K2E SoC support

Quoted 6 lines · Ivan

The Keystone2 Edison SoC uses the same keystone net driver. This patch adds opportunity to use it by K2E SoCs.

Applied to u-boot-ti/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20141023/ebae0878/attachment-0001.pgp>
#7 lore raw

PATCH v2 4/6 net: keystone_net: increase PHY auto negotiate time

In reply to Ivan Khoronzhuk

The new Marvel PHY (88E1514) used on K2L/K2E EVM requires longer time to auto negotiate with SoC's SGMII port.

It can take about 3 sec to up the PHY after reset, so add code to expose sgmii auto negotiation waiting process.

---
 drivers/net/keystone_net.c | 36 +++++++++++++++++++++++++++++++-----
 1 file changed, 31 insertions(+), 5 deletions(-)
drivers/net/keystone_net.c +31 -5
index 1186188..c8681d0 100644
@@ -11,6 +11,7 @@
 
 #include <net.h>
 #include <phy.h>
+#include <errno.h>
 #include <miiphy.h>
 #include <malloc.h>
 #include <asm/ti-common/keystone_nav.h>
@@ -30,6 +31,7 @@ static unsigned int sys_has_mdio = 1;
 #define RX_BUFF_NUMS	24
 #define RX_BUFF_LEN	1520
 #define MAX_SIZE_STREAM_BUFFER RX_BUFF_LEN
+#define SGMII_ANEG_TIMEOUT		4000
 
 static u8 rx_buffs[RX_BUFF_NUMS * RX_BUFF_LEN] __aligned(16);
 
@@ -169,7 +171,7 @@ int keystone_sgmii_link_status(int port)
 	       (status & SGMII_REG_STATUS_LINK);
 }
 
-int keystone_sgmii_config(int port, int interface)
+int keystone_sgmii_config(struct phy_device *phy_dev, int port, int interface)
 {
 	unsigned int i, status, mask;
 	unsigned int mr_adv_ability, control;
@@ -230,11 +232,35 @@ int keystone_sgmii_config(int port, int interface)
 	if (control & SGMII_REG_CONTROL_AUTONEG)
 		mask |= SGMII_REG_STATUS_AUTONEG;
 
-	for (i = 0; i < 1000; i++) {
+	status = __raw_readl(SGMII_STATUS_REG(port));
+	if ((status & mask) == mask)
+		return 0;
+
+	printf("\n%s Waiting for SGMII auto negotiation to complete",
+	       phy_dev->dev->name);
+	while ((status & mask) != mask) {
+		/*
+		 * Timeout reached ?
+		 */
+		if (i > SGMII_ANEG_TIMEOUT) {
+			puts(" TIMEOUT !\n");
+			phy_dev->link = 0;
+			return 0;
+		}
+
+		if (ctrlc()) {
+			puts("user interrupt!\n");
+			phy_dev->link = 0;
+			return -EINTR;
+		}
+
+		if ((i++ % 500) == 0)
+			printf(".");
+
+		udelay(1000);   /* 1 ms */
 		status = __raw_readl(SGMII_STATUS_REG(port));
-		if ((status & mask) == mask)
-			break;
 	}
+	puts(" done\n");
 
 	return 0;
 }
@@ -374,7 +400,7 @@ static int keystone2_eth_open(struct eth_device *dev, bd_t *bis)
 
 	keystone2_net_serdes_setup();
 
-	keystone_sgmii_config(eth_priv->slave_port - 1,
+	keystone_sgmii_config(phy_dev, eth_priv->slave_port - 1,
 			      eth_priv->sgmii_link_type);
 
 	udelay(10000);
Signature · 1 line
1.8.3.2
#8 lore raw

PATCH v2 4/6 net: keystone_net: increase PHY auto negotiate time

Quoted 8 lines · Ivan

The new Marvel PHY (88E1514) used on K2L/K2E EVM requires longer time to auto negotiate with SoC's SGMII port.

It can take about 3 sec to up the PHY after reset, so add code to expose sgmii auto negotiation waiting process.

Applied to u-boot-ti/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20141023/b356932c/attachment-0001.pgp>
#9 lore raw

PATCH v2 5/6 ARM: keystone: clock: add support for K2E SoCs

In reply to Ivan Khoronzhuk

For K2E and K2L SoCs clock output from PASS PLL has to be enabled after NETCP domain and PA module are enabled. So create new function for that and call it after PA module is enabled.

---
 arch/arm/cpu/armv7/keystone/clock.c        | 17 +++++++++++++----
 arch/arm/include/asm/arch-keystone/clock.h |  1 +
 board/ti/ks2_evm/board.c                   |  1 +
 3 files changed, 15 insertions(+), 4 deletions(-)
arch/arm/cpu/armv7/keystone/clock.c +13 -4
index 47fc893..d13fbc1 100644
@@ -185,10 +185,6 @@ void init_pll(const struct pll_init_data *data)
 		tmp &= ~(PLL_BWADJ_HI_MASK);
 		tmp |= ((bwadj >> 8) & PLL_BWADJ_HI_MASK);
 
-		/* set PLL Select (bit 13) for PASS PLL */
-		if (data->pll == PASS_PLL)
-			tmp |= PLLCTL_PAPLL;
-
 		__raw_writel(tmp, keystone_pll_regs[data->pll].reg1);
 
 		/* Reset bit: bit 14 for both DDR3 & PASS PLL */
@@ -261,3 +257,16 @@ inline int get_max_arm_speed(void)
 	return get_max_speed((read_efuse_bootrom() >> 16) & 0xffff, arm_speeds);
 }
 #endif
+
+void pass_pll_pa_clk_enable(void)
+{
+	u32 reg;
+
+	reg = readl(keystone_pll_regs[PASS_PLL].reg1);
+
+	reg |= PLLCTL_PAPLL;
+	writel(reg, keystone_pll_regs[PASS_PLL].reg1);
+
+	/* wait till clock is enabled */
+	sdelay(15000);
+}
arch/arm/include/asm/arch-keystone/clock.h +1 -0
index bc31267..9480e62 100644
@@ -50,6 +50,7 @@ void init_pll(const struct pll_init_data *data);
 unsigned long clk_get_rate(unsigned int clk);
 unsigned long clk_round_rate(unsigned int clk, unsigned long hz);
 int clk_set_rate(unsigned int clk, unsigned long hz);
+void pass_pll_pa_clk_enable(void);
 int get_max_dev_speed(void);
 int get_max_arm_speed(void);
 
board/ti/ks2_evm/board.c +1 -0
index 279ec8e..8991786 100644
@@ -77,6 +77,7 @@ int board_eth_init(bd_t *bis)
 		return -1;
 	if (psc_enable_module(KS2_LPSC_CRYPTO))
 		return -1;
+	pass_pll_pa_clk_enable();
 
 	port_num = get_num_eth_ports();
 
Signature · 1 line
1.8.3.2
#10 lore raw

PATCH v2 5/6 ARM: keystone: clock: add support for K2E SoCs

Quoted 5 lines · Ivan

For K2E and K2L SoCs clock output from PASS PLL has to be enabled after NETCP domain and PA module are enabled. So create new function for that and call it after PA module is enabled.

Applied to u-boot-ti/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20141023/f05119b8/attachment-0001.pgp>
#11 lore raw

PATCH v2 6/6 board: k2e_evm: add network support

In reply to Ivan Khoronzhuk

From: Hao Zhang <[email protected]>

This patch adds network support code and enables keystone_net driver usage for k2e_evm evaluation board.

---
 board/ti/ks2_evm/board_k2e.c | 68 +++++++++++++++++++++++++++++++++++++++++++-
 include/configs/k2e_evm.h    |  8 ++++++
 2 files changed, 75 insertions(+), 1 deletion(-)
board/ti/ks2_evm/board_k2e.c +67 -1
index 810a8e2..43dfc48 100644
@@ -10,6 +10,7 @@
 #include <common.h>
 #include <asm/arch/ddr3.h>
 #include <asm/arch/hardware.h>
+#include <asm/ti-common/keystone_net.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -35,10 +36,75 @@ static struct pll_init_data core_pll_config[] = {
 	CORE_PLL_1500,
 };
 
-
 static struct pll_init_data pa_pll_config =
 	PASS_PLL_1000;
 
+#ifdef CONFIG_DRIVER_TI_KEYSTONE_NET
+struct eth_priv_t eth_priv_cfg[] = {
+	{
+		.int_name        = "K2E_EMAC0",
+		.rx_flow         = 0,
+		.phy_addr        = 0,
+		.slave_port      = 1,
+		.sgmii_link_type = SGMII_LINK_MAC_PHY,
+	},
+	{
+		.int_name        = "K2E_EMAC1",
+		.rx_flow         = 8,
+		.phy_addr        = 1,
+		.slave_port      = 2,
+		.sgmii_link_type = SGMII_LINK_MAC_PHY,
+	},
+	{
+		.int_name        = "K2E_EMAC2",
+		.rx_flow         = 16,
+		.phy_addr        = 2,
+		.slave_port      = 3,
+		.sgmii_link_type = SGMII_LINK_MAC_MAC_FORCED,
+	},
+	{
+		.int_name        = "K2E_EMAC3",
+		.rx_flow         = 24,
+		.phy_addr        = 3,
+		.slave_port      = 4,
+		.sgmii_link_type = SGMII_LINK_MAC_MAC_FORCED,
+	},
+	{
+		.int_name        = "K2E_EMAC4",
+		.rx_flow         = 32,
+		.phy_addr        = 4,
+		.slave_port      = 5,
+		.sgmii_link_type = SGMII_LINK_MAC_MAC_FORCED,
+	},
+	{
+		.int_name        = "K2E_EMAC5",
+		.rx_flow         = 40,
+		.phy_addr        = 5,
+		.slave_port      = 6,
+		.sgmii_link_type = SGMII_LINK_MAC_MAC_FORCED,
+	},
+	{
+		.int_name        = "K2E_EMAC6",
+		.rx_flow         = 48,
+		.phy_addr        = 6,
+		.slave_port      = 7,
+		.sgmii_link_type = SGMII_LINK_MAC_MAC_FORCED,
+	},
+	{
+		.int_name        = "K2E_EMAC7",
+		.rx_flow         = 56,
+		.phy_addr        = 7,
+		.slave_port      = 8,
+		.sgmii_link_type = SGMII_LINK_MAC_MAC_FORCED,
+	},
+};
+
+int get_num_eth_ports(void)
+{
+	return sizeof(eth_priv_cfg) / sizeof(struct eth_priv_t);
+}
+#endif
+
 #if defined(CONFIG_BOARD_EARLY_INIT_F)
 int board_early_init_f(void)
 {
include/configs/k2e_evm.h +8 -0
index fd45d61..7c8065a 100644
@@ -34,6 +34,14 @@
 /* NAND Configuration */
 #define CONFIG_SYS_NAND_PAGE_2K
 
+/* Network */
+#define CONFIG_DRIVER_TI_KEYSTONE_NET
+#define CONFIG_TI_KSNAV
+#define CONFIG_KSNAV_PKTDMA_NETCP
+#define CONFIG_KSNET_NETCP_V1_5
+#define CONFIG_KSNET_CPSW_NUM_PORTS	9
+#define CONFIG_KSNET_MDIO_PHY_CONFIG_ENABLE
+
 /* SerDes */
 #define CONFIG_TI_KEYSTONE_SERDES
 
Signature · 1 line
1.8.3.2
#12 lore raw

PATCH v2 6/6 board: k2e_evm: add network support

Quoted 9 lines · Ivan

From: Hao Zhang <[email protected]>

This patch adds network support code and enables keystone_net driver usage for k2e_evm evaluation board.

Applied to u-boot-ti/master, thanks!

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