Skip to contentSkip to conversation

net: stmmac: Add OXNAS DWMAC Glue

PATCH Superseded Neil Armstrong 2 participants 5 messages Oct 31, 2016 – Nov 2, 2016

Subsystems (5)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover net: stmmac: Add OXNAS DWMAC Glue

This patchset add support for the Sysnopsys DWMAC Gigabit Ethernet controller Glue layer of the Oxford Semiconductor OX820 SoC.

Changes since v1 at https://patchwork.kernel.org/patch/9388231/ :
- Split dt-bindings in a separate patch
- Add IP version in the dt-bindings compatible
- Check return of clk_prepare_enable()
- use get_stmmac_bsp_priv() helper
- hardwire setup values in oxnas_dwmac_init()

Changes since RFC at https://patchwork.kernel.org/patch/9387257 :
- Drop init/exit callbacks
- Implement proper remove and PM callback
- Call init from probe
- Disable/Unprepare clock if stmmac probe fails

Neil Armstrong (2):
net: stmmac: Add OXNAS Glue Driver
dt-bindings: net: Add OXNAS DWMAC Bindings

 .../devicetree/bindings/net/oxnas-dwmac.txt        |  39 ++++
 drivers/net/ethernet/stmicro/stmmac/Kconfig        |  11 ++
 drivers/net/ethernet/stmicro/stmmac/Makefile       |   1 +
 drivers/net/ethernet/stmicro/stmmac/dwmac-oxnas.c  | 215 +++++++++++++++++++++
 4 files changed, 266 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/oxnas-dwmac.txt
 create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-oxnas.c
Signature · 1 line
2.7.0
#4 lore raw

PATCH v2 2/2 dt-bindings: net: Add OXNAS DWMAC Bindings

---
 .../devicetree/bindings/net/oxnas-dwmac.txt        | 39 ++++++++++++++++++++++
 1 file changed, 39 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/oxnas-dwmac.txt
Documentation/devicetree/bindings/net/oxnas-dwmac.txt new file +39 -0
new file mode 100644
index 0000000..df0534e
@@ -0,0 +1,39 @@
+* Oxford Semiconductor OXNAS DWMAC Ethernet controller
+
+The device inherits all the properties of the dwmac/stmmac devices
+described in the file stmmac.txt in the current directory with the
+following changes.
+
+Required properties on all platforms:
+
+- compatible:	For the OX820 SoC, it should be :
+		- "oxsemi,ox820-dwmac" to select glue
+		- "snps,dwmac-3.512" to select IP version.
+
+- clocks: Should contain phandles to the following clocks
+- clock-names:	Should contain the following:
+		- "stmmaceth" for the host clock - see stmmac.txt
+		- "gmac" for the peripheral gate clock
+
+- oxsemi,sys-ctrl: a phandle to the system controller syscon node
+
+Example :
+
+etha: ethernet at 40400000 {
+	compatible = "oxsemi,ox820-dwmac", "snps,dwmac-3.512";
+	reg = <0x40400000 0x2000>;
+	interrupts = <GIC_SPI 8 IRQ_TYPE_LEVEL_HIGH>,
+		     <GIC_SPI 17 IRQ_TYPE_LEVEL_HIGH>;
+	interrupt-names = "macirq", "eth_wake_irq";
+	mac-address = [000000000000]; /* Filled in by U-Boot */
+	phy-mode = "rgmii";
+
+	clocks = <&stdclk CLK_820_ETHA>, <&gmacclk>;
+	clock-names = "gmac", "stmmaceth";
+	resets = <&reset RESET_MAC>;
+
+	/* Regmap for sys registers */
+	oxsemi,sys-ctrl = <&sys>;
+
+	status = "disabled";
+};
Signature · 1 line
2.7.0
#1 lore raw

PATCH v2 1/2 net: stmmac: Add OXNAS Glue Driver

In reply to Neil Armstrong

Add Synopsys Designware MAC Glue layer for the Oxford Semiconductor OX820.

---
 drivers/net/ethernet/stmicro/stmmac/Kconfig       |  11 ++
 drivers/net/ethernet/stmicro/stmmac/Makefile      |   1 +
 drivers/net/ethernet/stmicro/stmmac/dwmac-oxnas.c | 215 ++++++++++++++++++++++
 3 files changed, 227 insertions(+)
 create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-oxnas.c
drivers/net/ethernet/stmicro/stmmac/Kconfig +11 -0
index 3818c5e..6e9fcc3 100644
@@ -69,6 +69,17 @@ config DWMAC_MESON
 	  the stmmac device driver. This driver is used for Meson6,
 	  Meson8, Meson8b and GXBB SoCs.
 
+config DWMAC_OXNAS
+	tristate "Oxford Semiconductor OXNAS dwmac support"
+	default ARCH_OXNAS
+	depends on OF && COMMON_CLK && (ARCH_OXNAS || COMPILE_TEST)
+	select MFD_SYSCON
+	help
+	  Support for Ethernet controller on Oxford Semiconductor OXNAS SoCs.
+
+	  This selects the Oxford Semiconductor OXNASSoC glue layer support for
+	  the stmmac device driver. This driver is used for OX820.
+
 config DWMAC_ROCKCHIP
 	tristate "Rockchip dwmac support"
 	default ARCH_ROCKCHIP
drivers/net/ethernet/stmicro/stmmac/Makefile +1 -0
index 5d6ece5..8f83a86 100644
@@ -10,6 +10,7 @@ obj-$(CONFIG_STMMAC_PLATFORM)	+= stmmac-platform.o
 obj-$(CONFIG_DWMAC_IPQ806X)	+= dwmac-ipq806x.o
 obj-$(CONFIG_DWMAC_LPC18XX)	+= dwmac-lpc18xx.o
 obj-$(CONFIG_DWMAC_MESON)	+= dwmac-meson.o dwmac-meson8b.o
+obj-$(CONFIG_DWMAC_OXNAS)	+= dwmac-oxnas.o
 obj-$(CONFIG_DWMAC_ROCKCHIP)	+= dwmac-rk.o
 obj-$(CONFIG_DWMAC_SOCFPGA)	+= dwmac-altr-socfpga.o
 obj-$(CONFIG_DWMAC_STI)		+= dwmac-sti.o
drivers/net/ethernet/stmicro/stmmac/dwmac-oxnas.c new file +215 -0

215 lines not on this page · raw message

Signature · 1 line
2.7.0
#2 lore raw

Re: [PATCH v2 1/2] net: stmmac: Add OXNAS Glue Driver

Hi Neil,

Quoted 12 lines · Neil Armstrong

Add Synopsys Designware MAC Glue layer for the Oxford Semiconductor OX820.

---

drivers/net/ethernet/stmicro/stmmac/dwmac-oxnas.c new file +7 -0
+static int oxnas_dwmac_init(struct oxnas_dwmac *dwmac)
+{
+       unsigned int value;
+       int ret;
+
+       /* Reset HW here before changing the glue configuration */
+       ret = device_reset(dwmac->dev);

drivers/net/ethernet/stmicro/stmmac/dwmac-oxnas.c line 79

Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-oxnas.c new file +10 -0
+       if (ret)
+               return ret;
+
+       ret = clk_prepare_enable(dwmac->clk);
+       if (ret)
+               return ret;
+
+       ret = regmap_read(dwmac->regmap, OXNAS_DWMAC_CTRL_REGOFFSET, &value);
+       if (ret < 0)
+               return ret;

If regmap reading fails here, the clock will be left on as probe fails.

Quoted 15 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-oxnas.c new file +15 -0
+
+       /* Enable GMII_GTXCLK to follow GMII_REFCLK, required for gigabit PHY */
+       value |= BIT(DWMAC_CKEN_GTX)            |
+                /* Use simple mux for 25/125 Mhz clock switching */
+                BIT(DWMAC_SIMPLE_MUX)          |
+                /* set auto switch tx clock source */
+                BIT(DWMAC_AUTO_TX_SOURCE)      |
+                /* enable tx & rx vardelay */
+                BIT(DWMAC_CKEN_TX_OUT)         |
+                BIT(DWMAC_CKEN_TXN_OUT)        |
+                BIT(DWMAC_CKEN_TX_IN)          |
+                BIT(DWMAC_CKEN_RX_OUT)         |
+                BIT(DWMAC_CKEN_RXN_OUT)        |
+                BIT(DWMAC_CKEN_RX_IN);
+       regmap_write(dwmac->regmap, OXNAS_DWMAC_CTRL_REGOFFSET, value);

drivers/net/ethernet/stmicro/stmmac/dwmac-oxnas.c line 104

Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-oxnas.c new file +10 -0
+
+       /* set tx & rx vardelay */
+       value = DWMAC_TX_VARDELAY(4)    |
+               DWMAC_TXN_VARDELAY(2)   |
+               DWMAC_RX_VARDELAY(10)   |
+               DWMAC_RXN_VARDELAY(8);
+       regmap_write(dwmac->regmap, OXNAS_DWMAC_DELAY_REGOFFSET, value);
+
+       return 0;
+}

regards,
Joachim Eastwood

#3 lore raw

Re: [PATCH v2 1/2] net: stmmac: Add OXNAS Glue Driver

Quoted 19 lines · Joachim Eastwood

Hi Neil,

Quoted 16 lines · Neil Armstrong

Add Synopsys Designware MAC Glue layer for the Oxford Semiconductor OX820.

---

drivers/net/ethernet/stmicro/stmmac/dwmac-oxnas.c new file +11 -0
+static int oxnas_dwmac_init(struct oxnas_dwmac *dwmac)
+{
+       unsigned int value;
+       int ret;
+
+       /* Reset HW here before changing the glue configuration */
+       ret = device_reset(dwmac->dev);
+       if (ret)
+               return ret;
+
+       ret = clk_prepare_enable(dwmac->clk);
Quoted 9 lines

drivers/net/ethernet/stmicro/stmmac/dwmac-oxnas.c line 79

Quoted 6 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-oxnas.c new file +6 -0
+       if (ret)
+               return ret;
+
+       ret = regmap_read(dwmac->regmap, OXNAS_DWMAC_CTRL_REGOFFSET, &value);
+       if (ret < 0)
+               return ret;

If regmap reading fails here, the clock will be left on as probe fails.

Indeed, thanks.

Neil

[...]

Quoted 5 lines

regards,
Joachim Eastwood