Skip to contentSkip to conversation

arm: bcm281xx: Add Ethernet Clock support

PATCH New Steve Rae 2 participants 7 messages Aug 2, 2014 – Aug 30, 2014

Subsystems (4)
lore
Share & tools
lore

Steve Rae

author
#0 lore raw

PATCH v2 1/3 arm: bcm281xx: Add Ethernet Clock support

From: Jiandong Zheng <[email protected]>

Enable Ethernet clock when Broadcom StarFighter2 Ethernet block (CONFIG_BCM_SF2_ETH) is enabled.

---
- with the changes to boards.cfg, the board with this feature will be added separately

Changes in v2:
- removed 'boards.cfg' from this commit
- (no other changes)

 arch/arm/cpu/armv7/bcm281xx/Makefile        |   1 +
 arch/arm/cpu/armv7/bcm281xx/clk-bcm281xx.c  |  34 +++++++
 arch/arm/cpu/armv7/bcm281xx/clk-eth.c       | 143 ++++++++++++++++++++++++++++
 arch/arm/include/asm/arch-bcm281xx/sysmap.h |   3 +
 4 files changed, 181 insertions(+)
 create mode 100644 arch/arm/cpu/armv7/bcm281xx/clk-eth.c
arch/arm/cpu/armv7/bcm281xx/Makefile +1 -0
index 98f5aa5..bd867a2 100644
@@ -9,3 +9,4 @@ obj-y	+= clk-core.o
 obj-y	+= clk-bcm281xx.o
 obj-y	+= clk-sdio.o
 obj-y	+= clk-bsc.o
+obj-$(CONFIG_BCM_SF2_ETH) += clk-eth.o
arch/arm/cpu/armv7/bcm281xx/clk-bcm281xx.c +34 -0
index bc8a170..d16b99f 100644
@@ -118,6 +118,16 @@ unsigned long slave_apb_freq_tbl[8] = {
 	78 * CLOCK_1M
 };
 
+unsigned long esub_freq_tbl[8] = {
+	78 * CLOCK_1M,
+	156 * CLOCK_1M,
+	156 * CLOCK_1M,
+	156 * CLOCK_1M,
+	208 * CLOCK_1M,
+	208 * CLOCK_1M,
+	208 * CLOCK_1M
+};
+
 static struct bus_clk_data bsc1_apb_data = {
 	.gate = HW_SW_GATE_AUTO(0x0458, 16, 0, 1),
 };
@@ -295,6 +305,27 @@ static struct ccu_clock kps_ccu_clk = {
 	.freq_tbl = slave_axi_freq_tbl,
 };
 
+#ifdef CONFIG_BCM_SF2_ETH
+static struct ccu_clock esub_ccu_clk = {
+	.clk = {
+		.name = "esub_ccu_clk",
+		.ops = &ccu_clk_ops,
+		.ccu_clk_mgr_base = ESUB_CLK_BASE_ADDR,
+	},
+	.num_policy_masks = 1,
+	.policy_freq_offset = 0x00000008,
+	.freq_bit_shift = 8,
+	.policy_ctl_offset = 0x0000000c,
+	.policy0_mask_offset = 0x00000010,
+	.policy1_mask_offset = 0x00000014,
+	.policy2_mask_offset = 0x00000018,
+	.policy3_mask_offset = 0x0000001c,
+	.lvm_en_offset = 0x00000034,
+	.freq_id = 2,
+	.freq_tbl = esub_freq_tbl,
+};
+#endif
+
 /*
  * Bus clocks
  */
@@ -517,6 +548,9 @@ struct clk_lookup arch_clk_tbl[] = {
 	CLK_LK(bsc1_apb),
 	CLK_LK(bsc2_apb),
 	CLK_LK(bsc3_apb),
+#ifdef CONFIG_BCM_SF2_ETH
+	CLK_LK(esub_ccu),
+#endif
 };
 
 /* public array size */
arch/arm/cpu/armv7/bcm281xx/clk-eth.c new file +143 -0

143 lines not on this page · raw message

arch/arm/include/asm/arch-bcm281xx/sysmap.h +3 -0
index 880b4e0..350e7f6 100644
@@ -9,6 +9,9 @@
 #define BSC1_BASE_ADDR		0x3e016000
 #define BSC2_BASE_ADDR		0x3e017000
 #define BSC3_BASE_ADDR		0x3e018000
+#define DWDMA_AHB_BASE_ADDR	0x38100000
+#define ESUB_CLK_BASE_ADDR	0x38000000
+#define ESW_CONTRL_BASE_ADDR	0x38200000
 #define GPIO2_BASE_ADDR		0x35003000
 #define KONA_MST_CLK_BASE_ADDR	0x3f001000
 #define KONA_SLV_CLK_BASE_ADDR	0x3e011000
Signature · 1 line
1.8.5
author
#2 lore raw

PATCH v2 2/3 arm: bcm281xx: net: Add Ethernet Driver

From: Jiandong Zheng <[email protected]>

The Broadcom StarFighter2 Ethernet driver is used in multiple Broadcom SoC(s) and:
- supports multiple MAC blocks,
- provides support for the Broadcom GMAC.
This driver requires MII and PHYLIB.

---

Changes in v2:
- added Ethernet Driver

 drivers/net/Makefile           |   2 +
 drivers/net/bcm-sf2-eth-gmac.c | 971 +++++++++++++++++++++++++++++++++++++++++
 drivers/net/bcm-sf2-eth-gmac.h | 224 ++++++++++
 drivers/net/bcm-sf2-eth.c      | 268 ++++++++++++
 drivers/net/bcm-sf2-eth.h      |  70 +++
 include/netdev.h               |   1 +
 6 files changed, 1536 insertions(+)
 create mode 100644 drivers/net/bcm-sf2-eth-gmac.c
 create mode 100644 drivers/net/bcm-sf2-eth-gmac.h
 create mode 100644 drivers/net/bcm-sf2-eth.c
 create mode 100644 drivers/net/bcm-sf2-eth.h
drivers/net/Makefile +2 -0
index 7cc6b6f..14b5eb2 100644
@@ -10,6 +10,8 @@ obj-$(CONFIG_ALTERA_TSE) += altera_tse.o
 obj-$(CONFIG_ARMADA100_FEC) += armada100_fec.o
 obj-$(CONFIG_DRIVER_AT91EMAC) += at91_emac.o
 obj-$(CONFIG_DRIVER_AX88180) += ax88180.o
+obj-$(CONFIG_BCM_SF2_ETH) += bcm-sf2-eth.o
+obj-$(CONFIG_BCM_SF2_ETH_GMAC) += bcm-sf2-eth-gmac.o
 obj-$(CONFIG_BFIN_MAC) += bfin_mac.o
 obj-$(CONFIG_CALXEDA_XGMAC) += calxedaxgmac.o
 obj-$(CONFIG_CS8900) += cs8900.o
drivers/net/bcm-sf2-eth-gmac.c new file +971 -0

971 lines not on this page · raw message

drivers/net/bcm-sf2-eth-gmac.h new file +224 -0

224 lines not on this page · raw message

drivers/net/bcm-sf2-eth.c new file +268 -0

268 lines not on this page · raw message

drivers/net/bcm-sf2-eth.h new file +70 -0

70 lines not on this page · raw message

include/netdev.h +1 -0
index e45dd7a..b3b5930 100644
@@ -31,6 +31,7 @@ int altera_tse_initialize(u8 dev_num, int mac_base,
 int at91emac_register(bd_t *bis, unsigned long iobase);
 int au1x00_enet_initialize(bd_t*);
 int ax88180_initialize(bd_t *bis);
+int bcm_sf2_eth_register(bd_t *bis, u8 dev_num);
 int bfin_EMAC_initialize(bd_t *bis);
 int calxedaxgmac_initialize(u32 id, ulong base_addr);
 int cs8900_initialize(u8 dev_num, int base_addr);
Signature · 1 line
1.8.5
author
#4 lore raw

PATCH v2 3/3 arm: bcm281xx: add board with Ethernet capability

In reply to Steve Rae

Add board which has Broadcom StarFighter2 Ethernet capability.

---

Changes in v2:
- created from previous boards.cfg

 board/broadcom/bcm28155_w1d/MAINTAINERS | 6 ++++++
 configs/bcm28155_w1d_defconfig          | 3 +++
 2 files changed, 9 insertions(+)
 create mode 100644 board/broadcom/bcm28155_w1d/MAINTAINERS
 create mode 100644 configs/bcm28155_w1d_defconfig
board/broadcom/bcm28155_w1d/MAINTAINERS new file +6 -0
new file mode 100644
index 0000000..a436490
@@ -0,0 +1,6 @@
+BCM28155_W1D BOARD
+M:	Steve Rae <[email protected]>
+S:	Maintained
+F:	board/broadcom/bcm28155_ap/
+F:	include/configs/bcm28155_ap.h
+F:	configs/bcm28155_w1d_defconfig
configs/bcm28155_w1d_defconfig new file +3 -0
new file mode 100644
index 0000000..94b791c
@@ -0,0 +1,3 @@
+CONFIG_SYS_EXTRA_OPTIONS="BCM_SF2_ETH,BCM_SF2_ETH_GMAC"
+CONFIG_ARM=y
+CONFIG_TARGET_BCM28155_AP=y
Signature · 1 line
1.8.5
author
#1 lore raw

PATCH v2 1/3 arm: bcm281xx: Add Ethernet Clock support

In reply to Steve Rae
Quoted 244 lines · Steve Rae

From: Jiandong Zheng <[email protected]>

Enable Ethernet clock when Broadcom StarFighter2 Ethernet block (CONFIG_BCM_SF2_ETH) is enabled.

---
- with the changes to boards.cfg, the board with this feature will be added separately

Changes in v2:
- removed 'boards.cfg' from this commit
- (no other changes)

  arch/arm/cpu/armv7/bcm281xx/Makefile        |   1 +
  arch/arm/cpu/armv7/bcm281xx/clk-bcm281xx.c  |  34 +++++++
  arch/arm/cpu/armv7/bcm281xx/clk-eth.c       | 143 ++++++++++++++++++++++++++++
  arch/arm/include/asm/arch-bcm281xx/sysmap.h |   3 +
  4 files changed, 181 insertions(+)

create mode 100644 arch/arm/cpu/armv7/bcm281xx/clk-eth.c

arch/arm/cpu/armv7/bcm281xx/Makefile +1 -0
index 98f5aa5..bd867a2 100644
@@ -9,3 +9,4 @@ obj-y	+= clk-core.o
  obj-y	+= clk-bcm281xx.o
  obj-y	+= clk-sdio.o
  obj-y	+= clk-bsc.o
+obj-$(CONFIG_BCM_SF2_ETH) += clk-eth.o
arch/arm/cpu/armv7/bcm281xx/clk-bcm281xx.c +34 -0
index bc8a170..d16b99f 100644
@@ -118,6 +118,16 @@ unsigned long slave_apb_freq_tbl[8] = {
  	78 * CLOCK_1M
  };
 
+unsigned long esub_freq_tbl[8] = {
+	78 * CLOCK_1M,
+	156 * CLOCK_1M,
+	156 * CLOCK_1M,
+	156 * CLOCK_1M,
+	208 * CLOCK_1M,
+	208 * CLOCK_1M,
+	208 * CLOCK_1M
+};
+
  static struct bus_clk_data bsc1_apb_data = {
  	.gate = HW_SW_GATE_AUTO(0x0458, 16, 0, 1),
  };
@@ -295,6 +305,27 @@ static struct ccu_clock kps_ccu_clk = {
  	.freq_tbl = slave_axi_freq_tbl,
  };
 
+#ifdef CONFIG_BCM_SF2_ETH
+static struct ccu_clock esub_ccu_clk = {
+	.clk = {
+		.name = "esub_ccu_clk",
+		.ops = &ccu_clk_ops,
+		.ccu_clk_mgr_base = ESUB_CLK_BASE_ADDR,
+	},
+	.num_policy_masks = 1,
+	.policy_freq_offset = 0x00000008,
+	.freq_bit_shift = 8,
+	.policy_ctl_offset = 0x0000000c,
+	.policy0_mask_offset = 0x00000010,
+	.policy1_mask_offset = 0x00000014,
+	.policy2_mask_offset = 0x00000018,
+	.policy3_mask_offset = 0x0000001c,
+	.lvm_en_offset = 0x00000034,
+	.freq_id = 2,
+	.freq_tbl = esub_freq_tbl,
+};
+#endif
+
  /*
   * Bus clocks
   */
@@ -517,6 +548,9 @@ struct clk_lookup arch_clk_tbl[] = {
  	CLK_LK(bsc1_apb),
  	CLK_LK(bsc2_apb),
  	CLK_LK(bsc3_apb),
+#ifdef CONFIG_BCM_SF2_ETH
+	CLK_LK(esub_ccu),
+#endif
  };
 
  /* public array size */
arch/arm/cpu/armv7/bcm281xx/clk-eth.c new file +143 -0
new file mode 100644
index 0000000..b0b92b9
@@ -0,0 +1,143 @@
+/*
+ * Copyright 2014 Broadcom Corporation.
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <asm/errno.h>
+#include <asm/arch/sysmap.h>
+#include <asm/kona-common/clk.h>
+#include "clk-core.h"
+
+#define WR_ACCESS_ADDR			ESUB_CLK_BASE_ADDR
+#define WR_ACCESS_PASSWORD				0xA5A500
+
+#define PLLE_POST_RESETB_ADDR		(ESUB_CLK_BASE_ADDR + 0x00000C00)
+
+#define PLLE_RESETB_ADDR		(ESUB_CLK_BASE_ADDR + 0x00000C58)
+#define PLLE_RESETB_I_PLL_RESETB_PLLE_MASK		0x00010000
+#define PLLE_POST_RESETB_I_POST_RESETB_PLLE_MASK	0x00000001
+
+#define PLL_LOCK_ADDR			(ESUB_CLK_BASE_ADDR + 0x00000C38)
+#define PLL_LOCK_PLL_LOCK_PLLE_MASK			0x00000001
+
+#define ESW_SYS_DIV_ADDR		(ESUB_CLK_BASE_ADDR + 0x00000A04)
+#define ESW_SYS_DIV_PLL_SELECT_MASK			0x00000300
+#define ESW_SYS_DIV_DIV_MASK				0x0000001C
+#define ESW_SYS_DIV_PLL_VAR_208M_CLK_SELECT		0x00000100
+#define ESW_SYS_DIV_DIV_SELECT				0x4
+#define ESW_SYS_DIV_TRIGGER_MASK			0x00000001
+
+#define ESUB_AXI_DIV_DEBUG_ADDR		(ESUB_CLK_BASE_ADDR + 0x00000E04)
+#define ESUB_AXI_DIV_DEBUG_PLL_SELECT_MASK		0x0000001C
+#define ESUB_AXI_DIV_DEBUG_PLL_SELECT_OVERRIDE_MASK	0x00000040
+#define ESUB_AXI_DIV_DEBUG_PLL_VAR_208M_CLK_SELECT	0x0
+#define ESUB_AXI_DIV_DEBUG_TRIGGER_MASK			0x00000001
+
+#define PLL_MAX_RETRY	100
+
+/* Enable appropriate clocks for Ethernet */
+int clk_eth_enable(void)
+{
+	int rc = -1;
+	int retry_count = 0;
+	rc = clk_get_and_enable("esub_ccu_clk");
+
+	/* Enable Access to CCU registers */
+	writel((1 | WR_ACCESS_PASSWORD), WR_ACCESS_ADDR);
+
+	writel(readl(PLLE_POST_RESETB_ADDR) &
+	       ~PLLE_POST_RESETB_I_POST_RESETB_PLLE_MASK,
+	       PLLE_POST_RESETB_ADDR);
+
+	/* Take PLL out of reset and put into normal mode */
+	writel(readl(PLLE_RESETB_ADDR) | PLLE_RESETB_I_PLL_RESETB_PLLE_MASK,
+	       PLLE_RESETB_ADDR);
+
+	/* Wait for PLL lock */
+	rc = -1;
+	while (retry_count < PLL_MAX_RETRY) {
+		udelay(100);
+		if (readl(PLL_LOCK_ADDR) & PLL_LOCK_PLL_LOCK_PLLE_MASK) {
+			rc = 0;
+			break;
+		}
+		retry_count++;
+	}
+
+	if (rc == -1) {
+		printf("%s: ETH-PLL lock timeout, Ethernet is not enabled!\n",
+		       __func__);
+		return -1;
+	}
+
+	writel(readl(PLLE_POST_RESETB_ADDR) |
+	       PLLE_POST_RESETB_I_POST_RESETB_PLLE_MASK,
+	       PLLE_POST_RESETB_ADDR);
+
+	/* Switch esw_sys_clk to use 104MHz(208MHz/2) clock */
+	writel((readl(ESW_SYS_DIV_ADDR) &
+		~(ESW_SYS_DIV_PLL_SELECT_MASK | ESW_SYS_DIV_DIV_MASK)) |
+	       ESW_SYS_DIV_PLL_VAR_208M_CLK_SELECT | ESW_SYS_DIV_DIV_SELECT,
+	       ESW_SYS_DIV_ADDR);
+
+	writel(readl(ESW_SYS_DIV_ADDR) | ESW_SYS_DIV_TRIGGER_MASK,
+	       ESW_SYS_DIV_ADDR);
+
+	/* Wait for trigger complete */
+	rc = -1;
+	retry_count = 0;
+	while (retry_count < PLL_MAX_RETRY) {
+		udelay(100);
+		if (!(readl(ESW_SYS_DIV_ADDR) & ESW_SYS_DIV_TRIGGER_MASK)) {
+			rc = 0;
+			break;
+		}
+		retry_count++;
+	}
+
+	if (rc == -1) {
+		printf("%s: SYS CLK Trigger timeout, Ethernet is not enabled!\n",
+		       __func__);
+		return -1;
+	}
+
+	/* switch Esub AXI clock to 208MHz */
+	writel((readl(ESUB_AXI_DIV_DEBUG_ADDR) &
+		~(ESUB_AXI_DIV_DEBUG_PLL_SELECT_MASK |
+		  ESUB_AXI_DIV_DEBUG_PLL_SELECT_OVERRIDE_MASK |
+		  ESUB_AXI_DIV_DEBUG_TRIGGER_MASK)) |
+	       ESUB_AXI_DIV_DEBUG_PLL_VAR_208M_CLK_SELECT |
+	       ESUB_AXI_DIV_DEBUG_PLL_SELECT_OVERRIDE_MASK,
+	       ESUB_AXI_DIV_DEBUG_ADDR);
+
+	writel(readl(ESUB_AXI_DIV_DEBUG_ADDR) |
+	       ESUB_AXI_DIV_DEBUG_TRIGGER_MASK,
+	       ESUB_AXI_DIV_DEBUG_ADDR);
+
+	/* Wait for trigger complete */
+	rc = -1;
+	retry_count = 0;
+	while (retry_count < PLL_MAX_RETRY) {
+		udelay(100);
+		if (!(readl(ESUB_AXI_DIV_DEBUG_ADDR) &
+		      ESUB_AXI_DIV_DEBUG_TRIGGER_MASK)) {
+			rc = 0;
+			break;
+		}
+		retry_count++;
+	}
+
+	if (rc == -1) {
+		printf("%s: AXI CLK Trigger timeout, Ethernet is not enabled!\n",
+		       __func__);
+		return -1;
+	}
+
+	/* Disable Access to CCU registers */
+	writel(WR_ACCESS_PASSWORD, WR_ACCESS_ADDR);
+
+	return rc;
+}
arch/arm/include/asm/arch-bcm281xx/sysmap.h +0 -0
index 880b4e0..350e7f6 100644

arch/arm/include/asm/arch-bcm281xx/sysmap.h line 17

Quoted 9 lines
arch/arm/include/asm/arch-bcm281xx/sysmap.h +3 -0
@@ -9,6 +9,9 @@
  #define BSC1_BASE_ADDR		0x3e016000
  #define BSC2_BASE_ADDR		0x3e017000
  #define BSC3_BASE_ADDR		0x3e018000
+#define DWDMA_AHB_BASE_ADDR	0x38100000
+#define ESUB_CLK_BASE_ADDR	0x38000000
+#define ESW_CONTRL_BASE_ADDR	0x38200000
  #define GPIO2_BASE_ADDR		0x35003000
  #define KONA_MST_CLK_BASE_ADDR	0x3f001000
  #define KONA_SLV_CLK_BASE_ADDR	0x3e011000

Any chance of getting this series in soon?
( we have an upcoming release.... )
Thanks, Steve

#6 lore raw

PATCH v2 1/3 arm: bcm281xx: Add Ethernet Clock support

In reply to Steve Rae
Quoted 7 lines · Steve Rae

From: Jiandong Zheng <[email protected]>

Enable Ethernet clock when Broadcom StarFighter2 Ethernet block (CONFIG_BCM_SF2_ETH) is enabled.

Applied to u-boot/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/20140830/8b760400/attachment.pgp>
#3 lore raw

PATCH v2 2/3 arm: bcm281xx: net: Add Ethernet Driver

In reply to Steve Rae
Quoted 10 lines · Steve Rae

From: Jiandong Zheng <[email protected]>

The Broadcom StarFighter2 Ethernet driver is used in multiple Broadcom SoC(s) and:
- supports multiple MAC blocks,
- provides support for the Broadcom GMAC.
This driver requires MII and PHYLIB.

Applied to u-boot/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/20140830/676edd89/attachment.pgp>
#5 lore raw

PATCH v2 3/3 arm: bcm281xx: add board with Ethernet capability

In reply to Steve Rae
Quoted 3 lines · Steve Rae

Add board which has Broadcom StarFighter2 Ethernet capability.

Applied to u-boot/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/20140830/5392ae7c/attachment.pgp>