Add network support for Ocelots SoCs
Subsystems (2)
cover Add network support for Ocelots SoCs
Hello,
this series allows to use the switch component of the Ocelots SoC as a network interface.
The binding used is exactly the same of the one already used by Linux.
There is also a patch adding a workaround needed on the Ocelot based
boards: indeed the pin connected to the DDR reset is part of the switch subsystem. So we need ensure that the DDR is not reset during the switch reset.
Gregory
Gregory CLEMENT (4):
MIPS: mscc: ocelot: Add ethernet nodes for Ocelot
net: add MSCC Ocelot switch support
MIPS: mscc: ocelot: add switch reset support
configs: mscc_ocelot: add network support
MAINTAINERS | 1 + arch/mips/dts/mscc,ocelot.dtsi | 97 ++++ arch/mips/dts/ocelot_pcb123.dts | 20 + board/mscc/ocelot/ocelot.c | 28 ++ configs/mscc_ocelot_defconfig | 1 + drivers/net/Kconfig | 7 + drivers/net/Makefile | 1 + drivers/net/ocelot_switch.c | 837 ++++++++++++++++++++++++++++++++ 8 files changed, 992 insertions(+) create mode 100644 drivers/net/ocelot_switch.c
Signature · 1 line
2.20.1
PATCH 1/4 MIPS: mscc: ocelot: Add ethernet nodes for Ocelot
Import Ethernet related nodes from Linux
--- arch/mips/dts/mscc,ocelot.dtsi | 97 +++++++++++++++++++++++++++++++++ arch/mips/dts/ocelot_pcb123.dts | 20 +++++++ 2 files changed, 117 insertions(+)
arch/mips/dts/mscc,ocelot.dtsi +97 -0
@@ -112,6 +112,98 @@ status = "disabled"; }; + switch at 1010000 { + pinctrl-0 = <&miim1_pins>; + pinctrl-names = "default"; + + compatible = "mscc,vsc7514-switch"; + reg = <0x1010000 0x10000>, /* VTSS_TO_SYS */ + <0x1030000 0x10000>, /* VTSS_TO_REW */ + <0x1080000 0x100>, /* VTSS_TO_DEVCPU_QS */ + <0x10d0000 0x10000>, /* VTSS_TO_HSIO */ + <0x11e0000 0x100>, /* VTSS_TO_DEV_0 */ + <0x11f0000 0x100>, /* VTSS_TO_DEV_1 */ + <0x1200000 0x100>, /* VTSS_TO_DEV_2 */ + <0x1210000 0x100>, /* VTSS_TO_DEV_3 */ + <0x1220000 0x100>, /* VTSS_TO_DEV_4 */ + <0x1230000 0x100>, /* VTSS_TO_DEV_5 */ + <0x1240000 0x100>, /* VTSS_TO_DEV_6 */ + <0x1250000 0x100>, /* VTSS_TO_DEV_7 */ + <0x1260000 0x100>, /* VTSS_TO_DEV_8 */ + <0x1270000 0x100>, /* NA */ + <0x1280000 0x100>, /* NA */ + <0x1800000 0x80000>, /* VTSS_TO_QSYS */ + <0x1880000 0x10000>; /* VTSS_TO_ANA */ + reg-names = "sys", "rew", "qs", "hsio", "port0", + "port1", "port2", "port3", "port4", "port5", + "port6", "port7", "port8", "port9", + "port10", "qsys", "ana"; + interrupts = <21 22>; + interrupt-names = "xtr", "inj"; + status = "okay"; + + ethernet-ports { + #address-cells = <1>; + #size-cells = <0>; + + port0: port at 0 { + reg = <0>; + }; + port1: port at 1 { + reg = <1>; + }; + port2: port at 2 { + reg = <2>; + }; + port3: port at 3 { + reg = <3>; + }; + port4: port at 4 { + reg = <4>; + }; + port5: port at 5 { + reg = <5>; + }; + port6: port at 6 { + reg = <6>; + }; + port7: port at 7 { + reg = <7>; + }; + port8: port at 8 { + reg = <8>; + }; + port9: port at 9 { + reg = <9>; + }; + port10: port at 10 { + reg = <10>; + }; + }; + }; + + mdio0: mdio at 107009c { + #address-cells = <1>; + #size-cells = <0>; + compatible = "mscc,ocelot-miim"; + reg = <0x107009c 0x24>, <0x10700f0 0x8>; + interrupts = <14>; + status = "disabled"; + + phy0: ethernet-phy at 0 { + reg = <0>; + }; + phy1: ethernet-phy at 1 { + reg = <1>; + }; + phy2: ethernet-phy at 2 { + reg = <2>; + }; + phy3: ethernet-phy at 3 { + reg = <3>; + }; + }; + reset at 1070008 { compatible = "mscc,ocelot-chip-reset"; reg = <0x1070008 0x4>;
@@ -144,6 +236,11 @@ function = "si"; }; + miim1_pins: miim1-pins { + pins = "GPIO_14", "GPIO_15"; + function = "miim1"; + }; + spi_cs2_pin: spi-cs2-pin { pins = "GPIO_9"; function = "si";
arch/mips/dts/ocelot_pcb123.dts +20 -0
@@ -35,3 +35,23 @@ status = "okay"; mscc,sgpio-ports = <0x00FFFFFF>; }; + +&mdio0 { + status = "okay"; +}; + +&port0 { + phy-handle = <&phy0>; +}; + +&port1 { + phy-handle = <&phy1>; +}; + +&port2 { + phy-handle = <&phy2>; +}; + +&port3 { + phy-handle = <&phy3>; +};
Signature · 1 line
2.20.1
PATCH 2/4 net: add MSCC Ocelot switch support
In reply to Gregory CLEMENTThis patch adds support for the Microsemi Ethernet switch present on Ocelot SoCs.
--- MAINTAINERS | 1 + drivers/net/Kconfig | 7 + drivers/net/Makefile | 1 + drivers/net/ocelot_switch.c | 837 ++++++++++++++++++++++++++++++++++++ 4 files changed, 846 insertions(+) create mode 100644 drivers/net/ocelot_switch.c
MAINTAINERS +1 -0
@@ -529,6 +529,7 @@ F: drivers/gpio/mscc_sgpio.c F: drivers/spi/mscc_bb_spi.c F: include/configs/vcoreiii.h F: drivers/pinctrl/mscc/ +F: drivers/net/ocelot_switch.c MIPS JZ4780 M: Ezequiel Garcia <[email protected]>
drivers/net/Kconfig +7 -0
@@ -432,6 +432,13 @@ config SNI_AVE This driver implements support for the Socionext AVE Ethernet controller, as found on the Socionext UniPhier family. +config MSCC_OCELOT_SWITCH + bool "Ocelot switch driver" + depends on DM_ETH && ARCH_MSCC + select PHYLIB + help + This driver supports the Ocelot network switch device. + config ETHER_ON_FEC1 bool "FEC1" depends on MPC8XX_FEC
drivers/net/Makefile +1 -0
@@ -74,3 +74,4 @@ obj-$(CONFIG_DWC_ETH_QOS) += dwc_eth_qos.o obj-$(CONFIG_FSL_PFE) += pfe_eth/ obj-$(CONFIG_SNI_AVE) += sni_ave.o obj-y += ti/ +obj-$(CONFIG_MSCC_OCELOT_SWITCH) += ocelot_switch.o
drivers/net/ocelot_switch.c new file +837 -0
837 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH 3/4 MIPS: mscc: ocelot: add switch reset support
In reply to Gregory CLEMENTOn some ocelots platform a workaround is needed in order to be able to reset the switch without resetting the DDR.
--- board/mscc/ocelot/ocelot.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
board/mscc/ocelot/ocelot.c +28 -0
@@ -18,6 +18,34 @@ enum { BOARD_TYPE_PCB123, }; +void mscc_switch_reset (bool enter) +{ +u32 reg, count =0 ; + +/* Nasty workaround to avoid GPIO19 (DDR!) being reset */ +mscc_gpio_set_alternate (19 ,2 ); + +printf ("applying SwC reset\n" ); + +writel (ICPU_RESET_CORE_RST_PROTECT ,BASE_CFG +ICPU_RESET ); +writel (PERF_SOFT_RST_SOFT_CHIP_RST ,BASE_DEVCPU_GCB +PERF_SOFT_RST ); + +do { + reg =readl (BASE_DEVCPU_GCB +PERF_SOFT_RST ); + count++; + }while (reg &PERF_SOFT_RST_SOFT_CHIP_RST ); + +printf ("SwC reset done - reg = 0x%08x, count %u\n" , reg, count); + +/* +* Reset GPIO19 mode back as regular GPIO, output, high (DDR +* not reset) (Order is important) +*/ +setbits_le32 (BASE_DEVCPU_GCB +PERF_GPIO_OE ,BIT (19 )); +writel (BIT (19 ),BASE_DEVCPU_GCB +PERF_GPIO_OUT_SET ); +mscc_gpio_set_alternate (19 ,0 ); +} +void board_debug_uart_init (void ) {/* too early for the pinctrl driver, so configure the UART pins here */
Signature · 1 line
2.20.1
PATCH 3/4 MIPS: mscc: ocelot: add switch reset support
Quoted 22 lines · Gregory CLEMENT
On some ocelots platform a workaround is needed in order to be able to reset the switch without resetting the DDR.
Signed-off-by Gregory CLEMENT <[email protected]>--- board/mscc/ocelot/ocelot.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)board/mscc/ocelot/ocelot.c +6
-0@@ -18,6 +18,34 @@ enum { BOARD_TYPE_PCB123, }; +void mscc_switch_reset (bool enter) +{ +u32 reg, count =0 ; + +/* Nasty workaround to avoid GPIO19 (DDR!) being reset */ +mscc_gpio_set_alternate (19 ,2 );
board/mscc/ocelot/ocelot.c enum { · line 36
Quoted 10 lines
board/mscc/ocelot/ocelot.c +10
-0+ +printf ("applying SwC reset\n" ); + +writel (ICPU_RESET_CORE_RST_PROTECT ,BASE_CFG +ICPU_RESET ); +writel (PERF_SOFT_RST_SOFT_CHIP_RST ,BASE_DEVCPU_GCB +PERF_SOFT_RST ); + +do { + reg =readl (BASE_DEVCPU_GCB +PERF_SOFT_RST ); + count++; + }while (reg &PERF_SOFT_RST_SOFT_CHIP_RST );
Perhaps use wait_for_bit_XX() to add some timeout handling as well?
Thanks,
Stefan
PATCH 4/4 configs: mscc_ocelot: add network support
In reply to Gregory CLEMENTNow that network support is added for the ocelot platform, let's add it in the default configuration.
--- configs/mscc_ocelot_defconfig | 1 + 1 file changed, 1 insertion(+)
configs/mscc_ocelot_defconfig +1 -0
@@ -60,6 +60,7 @@ CONFIG_SPI_FLASH_SPANSION=y CONFIG_SPI_FLASH_WINBOND=y CONFIG_SPI_FLASH_MTD=y CONFIG_DM_ETH=y +CONFIG_MSCC_OCELOT_SWITCH=y CONFIG_PINCTRL=y CONFIG_PINCONF=y CONFIG_DM_SERIAL=y
Signature · 1 line
2.20.1