Skip to contentSkip to conversation

arm: dts: nes: add Nintendo NES Classic Edition support

PATCH New Miquel Raynal 2 participants 6 messages Mar 7, 2018 – Mar 9, 2018

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

PATCH 1/1 arm: dts: nes: add Nintendo NES Classic Edition support

The Nintendo NES Classic features an R16 already well supported in mainline.

The console over UART0 may be wired on two ports of the R16, both available on the NES Classic PCB.

USB host can be used after a bit of soldering to wire a 5V power supply directly on the PCB, in order to free the micro-USB port from that task and allow the plug of any USB device.

---
 arch/arm/boot/dts/Makefile                         |  1 +
 arch/arm/boot/dts/sun8i-a23-a33.dtsi               | 18 ++++++
 .../dts/sun8i-r16-nintendo-nes-classic-edition.dts | 71 ++++++++++++++++++++++
 3 files changed, 90 insertions(+)
 create mode 100644 arch/arm/boot/dts/sun8i-r16-nintendo-nes-classic-edition.dts
arch/arm/boot/dts/Makefile +1 -0
index ade7a38543dc..eed4e1222897 100644
@@ -990,6 +990,7 @@ dtb-$(CONFIG_MACH_SUN8I) += \
 	sun8i-h3-orangepi-plus.dtb \
 	sun8i-h3-orangepi-plus2e.dtb \
 	sun8i-r16-bananapi-m2m.dtb \
+	sun8i-r16-nintendo-nes-classic-edition.dtb \
 	sun8i-r16-parrot.dtb \
 	sun8i-r40-bananapi-m2-ultra.dtb \
 	sun8i-v3s-licheepi-zero.dtb \
arch/arm/boot/dts/sun8i-a23-a33.dtsi +18 -0
index 971f9be699a7..1ad7291581be 100644
@@ -315,6 +315,24 @@
 				bias-pull-up;
 			};
 
+			nand_pins_a: nand-base0 at 0 {
+				pins = "PC0", "PC1", "PC2",
+				       "PC5", "PC8", "PC9", "PC10",
+				       "PC11", "PC12", "PC13", "PC14",
+				       "PC15";
+				function = "nand0";
+			};
+
+			nand_cs0_pins_a: nand-cs at 0 {
+				pins = "PC4";
+				function = "nand0";
+			};
+
+			nand_rb0_pins_a: nand-rb at 0 {
+				pins = "PC6";
+				function = "nand0";
+			};
+
 			pwm0_pins: pwm0 {
 				pins = "PH0";
 				function = "pwm0";
arch/arm/boot/dts/sun8i-r16-nintendo-nes-classic-edition.dts new file +71 -0

71 lines not on this page · raw message

Signature · 1 line
2.14.1
#1 lore raw

PATCH 1/1 arm: dts: nes: add Nintendo NES Classic Edition support

Hi Miquel,

Quoted 46 lines · Miquel Raynal

The Nintendo NES Classic features an R16 already well supported in mainline.

The console over UART0 may be wired on two ports of the R16, both available on the NES Classic PCB.

USB host can be used after a bit of soldering to wire a 5V power supply directly on the PCB, in order to free the micro-USB port from that task and allow the plug of any USB device.

---
 arch/arm/boot/dts/Makefile                         |  1 +
 arch/arm/boot/dts/sun8i-a23-a33.dtsi               | 18 ++++++
 .../dts/sun8i-r16-nintendo-nes-classic-edition.dts | 71 ++++++++++++++++++++++
 3 files changed, 90 insertions(+)
 create mode 100644 arch/arm/boot/dts/sun8i-r16-nintendo-nes-classic-edition.dts
arch/arm/boot/dts/Makefile +1 -0
index ade7a38543dc..eed4e1222897 100644
@@ -990,6 +990,7 @@ dtb-$(CONFIG_MACH_SUN8I) += \
 	sun8i-h3-orangepi-plus.dtb \
 	sun8i-h3-orangepi-plus2e.dtb \
 	sun8i-r16-bananapi-m2m.dtb \
+	sun8i-r16-nintendo-nes-classic-edition.dtb \
 	sun8i-r16-parrot.dtb \
 	sun8i-r40-bananapi-m2-ultra.dtb \
 	sun8i-v3s-licheepi-zero.dtb \
arch/arm/boot/dts/sun8i-a23-a33.dtsi +8 -0
index 971f9be699a7..1ad7291581be 100644
@@ -315,6 +315,24 @@
 				bias-pull-up;
 			};
 
+			nand_pins_a: nand-base0 at 0 {
+				pins = "PC0", "PC1", "PC2",
+				       "PC5", "PC8", "PC9", "PC10",
+				       "PC11", "PC12", "PC13", "PC14",
+				       "PC15";
+				function = "nand0";
+			};
+

arch/arm/boot/dts/sun8i-a23-a33.dtsi line 335

Quoted 10 lines
arch/arm/boot/dts/sun8i-a23-a33.dtsi +10 -0
+			nand_cs0_pins_a: nand-cs at 0 {
+				pins = "PC4";
+				function = "nand0";
+			};
+
+			nand_rb0_pins_a: nand-rb at 0 {
+				pins = "PC6";
+				function = "nand0";
+			};
+

This should be in a separate patch.

Also, these will generate dtc warnings.

If there is multiple muxing options, I'd suggest to have the node names be nand-pc-pins, and the label nand_pc_pins. If there's only one, you can drop the pc part.

Quoted 24 lines
arch/arm/boot/dts/sun8i-a23-a33.dtsi +0 -0
 			pwm0_pins: pwm0 {
 				pins = "PH0";
 				function = "pwm0";
arch/arm/boot/dts/sun8i-r16-nintendo-nes-classic-edition.dts new file +15 -0
new file mode 100644
index 000000000000..63c289f1f46d
@@ -0,0 +1,71 @@
+// SPDX-License-Identifier: GPL-2.0 OR X11
+/* Copyright (c) 2016 FUKAUMI Naoki <[email protected]> */
+
+/dts-v1/;
+#include "sun8i-a33.dtsi"
+#include "sunxi-common-regulators.dtsi"
+
+/ {
+	model = "Nintendo NES Classic Edition";
+	compatible = "nintendo,nes-classic-edition", "allwinner,sun8i-a33";
+
+	aliases {
+		serial0 = &uart0;
+	};
+

arch/arm/boot/dts/sun8i-r16-nintendo-nes-classic-edition.dts line 25

Quoted 10 lines
arch/arm/boot/dts/sun8i-r16-nintendo-nes-classic-edition.dts new file +10 -0
+	chosen {
+		stdout-path = "serial0:115200n8";
+	};
+};
+
+&uart0 {
+	/*
+	 * UART0 is available on two ports, both accessible on the NES Classic
+	 * PCB. One can use the <&uart0_pins_b> handle instead.
+	 */

I guess you should mention that the PF pins will also rule out the SD option that might be convenient.

Quoted 22 lines
arch/arm/boot/dts/sun8i-r16-nintendo-nes-classic-edition.dts new file +22 -0
+	pinctrl-names = "default";
+	pinctrl-0 = <&uart0_pins_a>;
+	status = "okay";
+};
+
+&nfc {
+	pinctrl-names = "default";
+	pinctrl-0 = <&nand_pins_a &nand_cs0_pins_a &nand_rb0_pins_a>;
+	status = "okay";
+
+	/* 2Gb Macronix MX30LF2G18AC (3V) */
+	nand at 0 {
+		#address-cells = <1>;
+		#size-cells = <1>;
+		reg = <0>;
+		allwinner,rb = <0>;
+		nand-ecc-mode = "hw";
+		nand-ecc-strength = <16>;
+		nand-ecc-step-size = <1024>;
+	};
+};
+

arch/arm/boot/dts/sun8i-r16-nintendo-nes-classic-edition.dts line 57

Quoted 10 lines
arch/arm/boot/dts/sun8i-r16-nintendo-nes-classic-edition.dts new file +10 -0
+/*
+ * The NES is powered by the USB port. However it is possible to solder a wire
+ * from the internal side of the connector on VBUS pin to supply the required 5V
+ * without the need of a cable plugged in the micro USB port. This way it is
+ * easy to use any USB device.
+ */
+&usb_otg {
+	dr_mode = "host";
+	status = "okay";
+};

We want to support the default setup, and not require some hackery to be done. It will thus be some OTG / peripheral mode, most likely with an ID pin somewhere.

Since you tested on a SuperNES Classic, I think you should also create a new DT (possibly include it) with a compatible of its own.

That way, if we ever find some differences, it will be easy to deal with them.

Maxime

Signature · 10 lines
Maxime Ripard, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20180309/40fd2d91/attachment.sig>
#2 lore raw

PATCH 1/1 arm: dts: nes: add Nintendo NES Classic Edition support

Hi Maxime,

Quoted 41 lines · Maxime Ripard

Hi Miquel,

Quoted 38 lines · Miquel Raynal

The Nintendo NES Classic features an R16 already well supported in mainline.

The console over UART0 may be wired on two ports of the R16, both available on the NES Classic PCB.

USB host can be used after a bit of soldering to wire a 5V power supply directly on the PCB, in order to free the micro-USB port from that task and allow the plug of any USB device.

---
 arch/arm/boot/dts/Makefile                         |  1 +
 arch/arm/boot/dts/sun8i-a23-a33.dtsi               | 18 ++++++
 .../dts/sun8i-r16-nintendo-nes-classic-edition.dts | 71 ++++++++++++++++++++++
 3 files changed, 90 insertions(+)
 create mode 100644 arch/arm/boot/dts/sun8i-r16-nintendo-nes-classic-edition.dts
arch/arm/boot/dts/Makefile +1 -0
index ade7a38543dc..eed4e1222897 100644
@@ -990,6 +990,7 @@ dtb-$(CONFIG_MACH_SUN8I) += \
 	sun8i-h3-orangepi-plus.dtb \
 	sun8i-h3-orangepi-plus2e.dtb \
 	sun8i-r16-bananapi-m2m.dtb \
+	sun8i-r16-nintendo-nes-classic-edition.dtb \
 	sun8i-r16-parrot.dtb \
 	sun8i-r40-bananapi-m2-ultra.dtb \
 	sun8i-v3s-licheepi-zero.dtb \
arch/arm/boot/dts/sun8i-a23-a33.dtsi +0 -0
index 971f9be699a7..1ad7291581be 100644
@@ -315,6 +315,24 @@
 				bias-pull-up;
 			};
 
Quoted 5 lines

arch/arm/boot/dts/sun8i-a23-a33.dtsi line 322

Quoted 5 lines
arch/arm/boot/dts/sun8i-a23-a33.dtsi +5 -0
+			nand_pins_a: nand-base0 at 0 {
+				pins = "PC0", "PC1", "PC2",
+				       "PC5", "PC8", "PC9", "PC10",
+				       "PC11", "PC12", "PC13", "PC14",
+				       "PC15";

I will change a bit the visual organization.

Quoted 7 lines
Quoted 7 lines
arch/arm/boot/dts/sun8i-a23-a33.dtsi +7 -0
+				function = "nand0";
+			};
+
+			nand_cs0_pins_a: nand-cs at 0 {
+				pins = "PC4";
+				function = "nand0";
+			};
Quoted 8 lines

arch/arm/boot/dts/sun8i-a23-a33.dtsi line 335

Quoted 6 lines
arch/arm/boot/dts/sun8i-a23-a33.dtsi +6 -0
+
+			nand_rb0_pins_a: nand-rb at 0 {
+				pins = "PC6";
+				function = "nand0";
+			};
+  

This should be in a separate patch.

Ok.

Quoted 2 lines

Also, these will generate dtc warnings.

I will remove the trailing @0.

Quoted 4 lines

If there is multiple muxing options, I'd suggest to have the node names be nand-pc-pins, and the label nand_pc_pins. If there's only one, you can drop the pc part.

There is only one, I will name it nand_pins: nand-pins.

For CS and RB pins, there are two of them each time, I will declare them all:
nand_pins_cs0 PC4
nand_pins_cs1 PC3
nand_pins_rb0 PC6
nand_pins_rb1 PC7

Quoted 30 lines
Quoted 30 lines
arch/arm/boot/dts/sun8i-a23-a33.dtsi +0 -0
 			pwm0_pins: pwm0 {
 				pins = "PH0";
 				function = "pwm0";
arch/arm/boot/dts/sun8i-r16-nintendo-nes-classic-edition.dts new file +20 -0
new file mode 100644
index 000000000000..63c289f1f46d
@@ -0,0 +1,71 @@
+// SPDX-License-Identifier: GPL-2.0 OR X11
+/* Copyright (c) 2016 FUKAUMI Naoki <[email protected]> */
+
+/dts-v1/;
+#include "sun8i-a33.dtsi"
+#include "sunxi-common-regulators.dtsi"
+
+/ {
+	model = "Nintendo NES Classic Edition";
+	compatible = "nintendo,nes-classic-edition", "allwinner,sun8i-a33";
+
+	aliases {
+		serial0 = &uart0;
+	};
+
+	chosen {
+		stdout-path = "serial0:115200n8";
+	};
+};
+
Quoted 8 lines

arch/arm/boot/dts/sun8i-r16-nintendo-nes-classic-edition.dts line 25

Quoted 5 lines
arch/arm/boot/dts/sun8i-r16-nintendo-nes-classic-edition.dts new file +5 -0
+&uart0 {
+	/*
+	 * UART0 is available on two ports, both accessible on the NES Classic
+	 * PCB. One can use the <&uart0_pins_b> handle instead.
+	 */  

I guess you should mention that the PF pins will also rule out the SD option that might be convenient.

Sure. I will add that port PB and PF can both mux UART0, but PF can also be used for the SD card, so PB is preferred (

Quoted 9 lines

arch/arm/boot/dts/sun8i-r16-nintendo-nes-classic-edition.dts line 33

Quoted 9 lines
arch/arm/boot/dts/sun8i-r16-nintendo-nes-classic-edition.dts new file +8 -0
+	pinctrl-names = "default";
+	pinctrl-0 = <&uart0_pins_a>;
+	status = "okay";
+};
+
+&nfc {
+	pinctrl-names = "default";
+	pinctrl-0 = <&nand_pins_a &nand_cs0_pins_a &nand_rb0_pins_a>;

I'll move this in the DTSI also.

Quoted 29 lines
Quoted 14 lines
arch/arm/boot/dts/sun8i-r16-nintendo-nes-classic-edition.dts new file +14 -0
+	status = "okay";
+
+	/* 2Gb Macronix MX30LF2G18AC (3V) */
+	nand at 0 {
+		#address-cells = <1>;
+		#size-cells = <1>;
+		reg = <0>;
+		allwinner,rb = <0>;
+		nand-ecc-mode = "hw";
+		nand-ecc-strength = <16>;
+		nand-ecc-step-size = <1024>;
+	};
+};
+

arch/arm/boot/dts/sun8i-r16-nintendo-nes-classic-edition.dts line 57

Quoted 10 lines
arch/arm/boot/dts/sun8i-r16-nintendo-nes-classic-edition.dts new file +10 -0
+/*
+ * The NES is powered by the USB port. However it is possible to solder a wire
+ * from the internal side of the connector on VBUS pin to supply the required 5V
+ * without the need of a cable plugged in the micro USB port. This way it is
+ * easy to use any USB device.
+ */
+&usb_otg {
+	dr_mode = "host";
+	status = "okay";
+};  

We want to support the default setup, and not require some hackery to be done. It will thus be some OTG / peripheral mode, most likely with an ID pin somewhere.

Quoted 5 lines

Since you tested on a SuperNES Classic, I think you should also create a new DT (possibly include it) with a compatible of its own.

That way, if we ever find some differences, it will be easy to deal with them.

So, what you would prefer is:
1/ Move this entire DTS but the usb_otg node into a "sun8i-r16-nintendo-nes.dtsi"
2/ Include that DTSI from a "sun8i-r16-nintendo-super-nes-classic-edition.dts" that would add the usb_otg node as it is above.

Right?

Thanks,
Miqu?l

Signature · 3 lines
Miquel Raynal, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
#3 lore raw

PATCH 1/1 arm: dts: nes: add Nintendo NES Classic Edition support

Quoted 6 lines · Miquel Raynal
Quoted 5 lines

Since you tested on a SuperNES Classic, I think you should also create a new DT (possibly include it) with a compatible of its own.

That way, if we ever find some differences, it will be easy to deal with them.

Quoted 6 lines

So, what you would prefer is:
1/ Move this entire DTS but the usb_otg node into a "sun8i-r16-nintendo-nes.dtsi"
2/ Include that DTSI from a "sun8i-r16-nintendo-super-nes-classic-edition.dts" that would add the usb_otg node as it is above.

My remark had nothing to do with USB OTG. You can just create a DT called sun8i-r16-nintendo-nes-classic.dts, and then create another one call sun8i-r16-nintendo-supernes-classic.dts that would include the former, only overriding the compatible.

Maxime

Signature · 10 lines
Maxime Ripard, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20180309/8a22240d/attachment-0001.sig>
#4 lore raw

PATCH 1/1 arm: dts: nes: add Nintendo NES Classic Edition support

Hi Maxime,

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

We want to support the default setup, and not require some hackery to be done. It will thus be some OTG / peripheral mode, most likely with an ID pin somewhere.

I would really appreciate to let the comment because with this kind of boards, almost everything is hackery. Think about the SD card support. Pins are there, but nothing is wired on it. However we still want to let these pins available for it.

I can drop the mode = "host" property though.

Quoted 7 lines · Miquel Raynal
Quoted 6 lines
Quoted 5 lines

Since you tested on a SuperNES Classic, I think you should also create a new DT (possibly include it) with a compatible of its own.

That way, if we ever find some differences, it will be easy to deal with them.

Quoted 8 lines
Quoted 6 lines

So, what you would prefer is:
1/ Move this entire DTS but the usb_otg node into a "sun8i-r16-nintendo-nes.dtsi"
2/ Include that DTSI from a "sun8i-r16-nintendo-super-nes-classic-edition.dts" that would add the usb_otg node as it is above.

My remark had nothing to do with USB OTG.

OK, sorry.

Quoted 4 lines

You can just create a DT
called sun8i-r16-nintendo-nes-classic.dts, and then create another one call sun8i-r16-nintendo-supernes-classic.dts that would include the former, only overriding the compatible.

And being almost empty then?

Quoted 3 lines

Maxime

Signature · 3 lines
Miquel Raynal, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
#5 lore raw

PATCH 1/1 arm: dts: nes: add Nintendo NES Classic Edition support

Quoted 8 lines · Miquel Raynal
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

We want to support the default setup, and not require some hackery to be done. It will thus be some OTG / peripheral mode, most likely with an ID pin somewhere.

I would really appreciate to let the comment because with this kind of boards, almost everything is hackery. Think about the SD card support. Pins are there, but nothing is wired on it. However we still want to let these pins available for it.

I disagree here. That kind of information in the device tree is neither easily discoverable nor comprehensive.

The chance for a regular user to think about going to look to the device tree for that kind of informations is leaning towards 0. And you cannot even describe fully the modifications that need to be done to achieve that.

These infos should belong in the wiki, with images, pictures, whatever is needed, and not in the device tree.

Quoted 18 lines

I can drop the mode = "host" property though.

Quoted 7 lines · Miquel Raynal
Quoted 6 lines
Quoted 5 lines

Since you tested on a SuperNES Classic, I think you should also create a new DT (possibly include it) with a compatible of its own.

That way, if we ever find some differences, it will be easy to deal with them.

Quoted 8 lines
Quoted 6 lines

So, what you would prefer is:
1/ Move this entire DTS but the usb_otg node into a "sun8i-r16-nintendo-nes.dtsi"
2/ Include that DTSI from a "sun8i-r16-nintendo-super-nes-classic-edition.dts" that would add the usb_otg node as it is above.

My remark had nothing to do with USB OTG.

Quoted 8 lines

OK, sorry.

Quoted 4 lines

You can just create a DT
called sun8i-r16-nintendo-nes-classic.dts, and then create another one call sun8i-r16-nintendo-supernes-classic.dts that would include the former, only overriding the compatible.

And being almost empty then?

Yep, in the best scenario. But we're also preparing for the worst :)

Maxime

Signature · 10 lines
Maxime Ripard, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20180309/59ffe530/attachment-0001.sig>