Skip to contentSkip to conversation

Add support for Realtek RTL838x/RTL839x switch SoCs

PATCH Superseded Bert Vermeulen 3 participants 9 messages Jan 19, 2021 – Feb 4, 2021

Subsystems (2)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v4 cover Add support for Realtek RTL838x/RTL839x switch SoCs

v4:
- Device tree bindings for SoC in separate patch.
- Removed ioremap.h, and declare physical address bases in device tree.

v3:
- all code removed, the base system is now only device tree files and docs and some build config.
- ioremap.h restored to the v1 version, with hardcoded I/O ranges, since I got flak on changing that as suggested. This brings it in line with other systems in arch/mips/generic.

v2:
- Removed all new arch/mips/ code, using arch/mips/generic/ instead.
- Use device tree ranges instead of hardcoded addresses for ioremap.
- Moved IRQ driver to drivers/irqchip/
- Removed reset handling code, will be replaced by device tree config.
- All SoC family id code moved to new soc driver.
- Header moved to realtek/ instead of mach-realtek/
- As more of the base system now depends on device tree, a sample dts for the Cisco SG220-26 switch is included. This will be further filled out, and bindings documented, as drivers get merged.

Bert Vermeulen (5):
dt-bindings: mips: Add support for RTL83xx SoC series Add support for Realtek RTL838x/RTL839x switch SoCs
MIPS: Add Realtek RTL838x/RTL839x support as generic MIPS system
dt-bindings: Add Cisco prefix to vendor list
mips: dts: Add support for Cisco SG220-26 switch

 .../devicetree/bindings/mips/realtek-rtl.yaml | 24 ++++++++
 .../devicetree/bindings/vendor-prefixes.yaml  |  2 +
 arch/mips/Kconfig                             | 31 ++++++++++
 arch/mips/boot/dts/Makefile                   |  1 +
 arch/mips/boot/dts/realtek/Makefile           |  2 +
 arch/mips/boot/dts/realtek/cisco_sg220-26.dts | 25 ++++++++
 arch/mips/boot/dts/realtek/rtl838x.dtsi       | 21 +++++++
 arch/mips/boot/dts/realtek/rtl83xx.dtsi       | 59 +++++++++++++++++++
 8 files changed, 165 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mips/realtek-rtl.yaml
 create mode 100644 arch/mips/boot/dts/realtek/Makefile
 create mode 100644 arch/mips/boot/dts/realtek/cisco_sg220-26.dts
 create mode 100644 arch/mips/boot/dts/realtek/rtl838x.dtsi
 create mode 100644 arch/mips/boot/dts/realtek/rtl83xx.dtsi
Signature · 1 line
2.25.1
#1 lore raw

PATCH v4 1/5 dt-bindings: mips: Add support for RTL83xx SoC series

---
 .../devicetree/bindings/mips/realtek-rtl.yaml | 24 +++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mips/realtek-rtl.yaml
Documentation/devicetree/bindings/mips/realtek-rtl.yaml new file +24 -0
new file mode 100644
index 000000000000..aadff8ce0f49
@@ -0,0 +1,24 @@
+# SPDX-License-Identifier: GPL-2.0-or-later OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mips/realtek-rtl.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Realtek RTL83xx/93xx SoC series device tree bindings
+
+maintainers:
+  - Bert Vermeulen <[email protected]>
+  - Sander Vanheule <[email protected]>
+
+properties:
+  $nodename:
+    const: "/"
+  compatible:
+    oneOf:
+      # RTL8382-based boards
+      - items:
+          - enum:
+              - cisco,sg220-26
+          - const: realtek,rtl8382-soc
+
+additionalProperties: true
Signature · 1 line
2.25.1
#2 lore raw

PATCH v4 2/5 Add support for Realtek RTL838x/RTL839x switch SoCs

In reply to Bert Vermeulen

The RTL838x/839x family of SoCs are Realtek switches with an embedded MIPS core.

* RTL838x - 500MHz 4kce single core - 1Gbit ports and L2 features
* RTL839x - 700MHz 34Kc single core - 1Gbit ports and L2 features

These switches, depending on the exact part number, will have anywhere between 8 and 52 ports. The MIPS core is wired to a switch cpu port which has a tagging feature allowing us to make use of the DSA subsystem. The SoCs are somewhat basic in certain areas, getting better with more advanced features on newer series.

The switch functionality is MMIO-mapped via a large MFD region.

The SoCs have the following peripherals
* ethernet
* switch
* uart - ns16550a
* spi-flash interface
* gpio
* wdt
* led

The code was derived from various vendor SDKs based on Linux v2.6 kernels.

This patchset allows us to boot RTL838x/RTL839x units with basic support. Most of the other drivers are already written and functional, and work to get them upstream is already in progress.

---
 arch/mips/boot/dts/Makefile             |  1 +
 arch/mips/boot/dts/realtek/rtl838x.dtsi | 21 +++++++++
 arch/mips/boot/dts/realtek/rtl83xx.dtsi | 59 +++++++++++++++++++++++++
 3 files changed, 81 insertions(+)
 create mode 100644 arch/mips/boot/dts/realtek/rtl838x.dtsi
 create mode 100644 arch/mips/boot/dts/realtek/rtl83xx.dtsi
arch/mips/boot/dts/Makefile +1 -0
index 0259238d7a2e..60bd7d2a9ad8 100644
@@ -14,6 +14,7 @@ subdir-$(CONFIG_FIT_IMAGE_FDT_NI169445)	+= ni
 subdir-$(CONFIG_MACH_PIC32)		+= pic32
 subdir-$(CONFIG_ATH79)			+= qca
 subdir-$(CONFIG_RALINK)			+= ralink
+subdir-$(CONFIG_MACH_REALTEK_RTL)	+= realtek
 subdir-$(CONFIG_FIT_IMAGE_FDT_XILFPGA)	+= xilfpga
 
 obj-$(CONFIG_BUILTIN_DTB)	:= $(addsuffix /, $(subdir-y))
arch/mips/boot/dts/realtek/rtl838x.dtsi new file +21 -0
new file mode 100644
index 000000000000..6cc4ff5c0d19
@@ -0,0 +1,21 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR BSD-2-Clause
+
+/ {
+	cpus {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		cpu@0 {
+			compatible = "mips,mips4KEc";
+			reg = <0>;
+			clocks = <&baseclk 0>;
+			clock-names = "cpu";
+		};
+	};
+
+	baseclk: baseclk {
+		compatible = "fixed-clock";
+		#clock-cells = <0>;
+		clock-frequency = <500000000>;
+	};
+};
arch/mips/boot/dts/realtek/rtl83xx.dtsi new file +59 -0

59 lines not on this page · raw message

Signature · 1 line
2.25.1
#3 lore raw

PATCH v4 3/5 MIPS: Add Realtek RTL838x/RTL839x support as generic MIPS system

In reply to Bert Vermeulen

This is just enough system to boot the kernel with earlycon working.

---
 arch/mips/Kconfig | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
arch/mips/Kconfig +21 -0
index 0a17bedf4f0d..0986d0c4405f 100644
@@ -627,6 +627,27 @@ config RALINK
 	select ARCH_HAS_RESET_CONTROLLER
 	select RESET_CONTROLLER
 
+config MACH_REALTEK_RTL
+	bool "Realtek RTL838x/RTL839x based machines"
+	select MIPS_GENERIC
+	select DMA_NONCOHERENT
+	select IRQ_MIPS_CPU
+	select CSRC_R4K
+	select CEVT_R4K
+	select SYS_HAS_CPU_MIPS32_R1
+	select SYS_HAS_CPU_MIPS32_R2
+	select SYS_SUPPORTS_BIG_ENDIAN
+	select SYS_SUPPORTS_32BIT_KERNEL
+	select SYS_SUPPORTS_MIPS16
+	select SYS_SUPPORTS_MULTITHREADING
+	select SYS_SUPPORTS_VPE_LOADER
+	select SYS_HAS_EARLY_PRINTK
+	select SYS_HAS_EARLY_PRINTK_8250
+	select USE_GENERIC_EARLY_PRINTK_8250
+	select BOOT_RAW
+	select PINCTRL
+	select USE_OF
+
 config SGI_IP22
 	bool "SGI IP22 (Indy/Indigo2)"
 	select ARC_MEMORY
Signature · 1 line
2.25.1
#4 lore raw

PATCH v4 4/5 dt-bindings: Add Cisco prefix to vendor list

In reply to Bert Vermeulen
---
 Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++
 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/vendor-prefixes.yaml +2 -0
index 041ae90b0d8f..e6e3a51fc2e3 100644
@@ -229,6 +229,8 @@ patternProperties:
     description: Computadora Industrial Abierta Argentina
   "^cirrus,.*":
     description: Cirrus Logic, Inc.
+  "^cisco,.*":
+    description: Cisco Systems, Inc.
   "^cloudengines,.*":
     description: Cloud Engines, Inc.
   "^cnm,.*":
Signature · 1 line
2.25.1
maintainer
#5 lore raw

Re: [PATCH v4 4/5] dt-bindings: Add Cisco prefix to vendor list

Quoted 5 lines · Bert Vermeulen
---
 Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++
 1 file changed, 2 insertions(+)

Please add Acked-by/Reviewed-by tags when posting new versions. However, there's no need to repost patches *only* to add the tags. The upstream maintainer will do that for acks received on the version they apply.

If a tag was not added on purpose, please state why and what changed.

#6 lore raw

PATCH v4 5/5 mips: dts: Add support for Cisco SG220-26 switch

In reply to Bert Vermeulen
---
 arch/mips/Kconfig                             | 10 ++++++++
 arch/mips/boot/dts/realtek/Makefile           |  2 ++
 arch/mips/boot/dts/realtek/cisco_sg220-26.dts | 25 +++++++++++++++++++
 3 files changed, 37 insertions(+)
 create mode 100644 arch/mips/boot/dts/realtek/Makefile
 create mode 100644 arch/mips/boot/dts/realtek/cisco_sg220-26.dts
arch/mips/Kconfig +10 -0
index 0986d0c4405f..a398416842ca 100644
@@ -1055,6 +1055,16 @@ config NLM_XLP_BOARD
 
 endchoice
 
+if MACH_REALTEK_RTL
+choice
+	prompt "Realtek RTL838x/RTL839x-based switch"
+	optional
+
+	config DT_CISCO_SG220_26
+		bool "Cisco SG220-26"
+endchoice
+endif
+
 source "arch/mips/alchemy/Kconfig"
 source "arch/mips/ath25/Kconfig"
 source "arch/mips/ath79/Kconfig"
arch/mips/boot/dts/realtek/Makefile new file +2 -0
new file mode 100644
index 000000000000..f0a3e5816767
@@ -0,0 +1,2 @@
+# SPDX-License-Identifier: GPL-2.0
+dtb-$(CONFIG_DT_CISCO_SG220_26)		+= cisco_sg220-26.dtb
arch/mips/boot/dts/realtek/cisco_sg220-26.dts new file +25 -0
new file mode 100644
index 000000000000..1cdbb09297ef
@@ -0,0 +1,25 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR BSD-2-Clause
+
+/dts-v1/;
+
+#include "rtl83xx.dtsi"
+#include "rtl838x.dtsi"
+
+/ {
+	model = "Cisco SG220-26";
+	compatible = "cisco,sg220-26", "realtek,rtl8382-soc";
+
+	chosen {
+		stdout-path = "serial0:9600n8";
+		bootargs = "earlycon console=ttyS0,9600";
+	};
+
+	memory@0 {
+		device_type = "memory";
+		reg = <0x0 0x8000000>;
+	};
+};
+
+&uart0 {
+	status = "okay";
+};
Signature · 1 line
2.25.1
#7 lore raw

Re: [PATCH v4 5/5] mips: dts: Add support for Cisco SG220-26 switch

Quoted 17 lines · Bert Vermeulen
---
 arch/mips/Kconfig                             | 10 ++++++++
 arch/mips/boot/dts/realtek/Makefile           |  2 ++
 arch/mips/boot/dts/realtek/cisco_sg220-26.dts | 25 +++++++++++++++++++
 3 files changed, 37 insertions(+)
 create mode 100644 arch/mips/boot/dts/realtek/Makefile
 create mode 100644 arch/mips/boot/dts/realtek/cisco_sg220-26.dts
arch/mips/Kconfig +0 -0
index 0986d0c4405f..a398416842ca 100644
@@ -1055,6 +1055,16 @@ config NLM_XLP_BOARD
 
 endchoice
 

arch/mips/Kconfig config NLM_XLP_BOARD · line 1067

Quoted 10 lines
arch/mips/Kconfig +10 -0
+if MACH_REALTEK_RTL
+choice
+	prompt "Realtek RTL838x/RTL839x-based switch"
+	optional
+
+	config DT_CISCO_SG220_26
+		bool "Cisco SG220-26"
+endchoice
+endif
+

I've dropped that while applying, because it's just one DT so far and if there are more of them, please move to arch/mips/realtek/Kconfig

Thomas.

Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]
#8 lore raw
In reply to Bert Vermeulen
Quoted 29 lines · Bert Vermeulen

v4:
- Device tree bindings for SoC in separate patch.
- Removed ioremap.h, and declare physical address bases in device tree.

v3:
- all code removed, the base system is now only device tree files and docs and some build config.
- ioremap.h restored to the v1 version, with hardcoded I/O ranges, since I got flak on changing that as suggested. This brings it in line with other systems in arch/mips/generic.

v2:
- Removed all new arch/mips/ code, using arch/mips/generic/ instead.
- Use device tree ranges instead of hardcoded addresses for ioremap.
- Moved IRQ driver to drivers/irqchip/
- Removed reset handling code, will be replaced by device tree config.
- All SoC family id code moved to new soc driver.
- Header moved to realtek/ instead of mach-realtek/
- As more of the base system now depends on device tree, a sample dts for the Cisco SG220-26 switch is included. This will be further filled out, and bindings documented, as drivers get merged.

Bert Vermeulen (5):
dt-bindings: mips: Add support for RTL83xx SoC series Add support for Realtek RTL838x/RTL839x switch SoCs
MIPS: Add Realtek RTL838x/RTL839x support as generic MIPS system
dt-bindings: Add Cisco prefix to vendor list
mips: dts: Add support for Cisco SG220-26 switch

Quoted 14 lines
 .../devicetree/bindings/mips/realtek-rtl.yaml | 24 ++++++++
 .../devicetree/bindings/vendor-prefixes.yaml  |  2 +
 arch/mips/Kconfig                             | 31 ++++++++++
 arch/mips/boot/dts/Makefile                   |  1 +
 arch/mips/boot/dts/realtek/Makefile           |  2 +
 arch/mips/boot/dts/realtek/cisco_sg220-26.dts | 25 ++++++++
 arch/mips/boot/dts/realtek/rtl838x.dtsi       | 21 +++++++
 arch/mips/boot/dts/realtek/rtl83xx.dtsi       | 59 +++++++++++++++++++
 8 files changed, 165 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mips/realtek-rtl.yaml
 create mode 100644 arch/mips/boot/dts/realtek/Makefile
 create mode 100644 arch/mips/boot/dts/realtek/cisco_sg220-26.dts
 create mode 100644 arch/mips/boot/dts/realtek/rtl838x.dtsi
 create mode 100644 arch/mips/boot/dts/realtek/rtl83xx.dtsi

series applied to mips-next.

Thomas.

Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]