All of lore.kernel.org
 help / color / mirror / Atom feed
* Device Tree file for Zyxel NSA320
@ 2014-03-01  0:40 Adam Baker
  2014-03-01 10:34 ` Andrew Lunn
  0 siblings, 1 reply; 7+ messages in thread
From: Adam Baker @ 2014-03-01  0:40 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

I've been trying to get my Zyxel NSA320 working with kernel 3.14-rc1 and 
device tree. I've included on CC the two developers who produced old 
style board files for the NSA310 / 320 in case you've already looked at 
this.

I've developed a file (below) which is enough to get it to boot but I've 
got a couple of outstanding issues that I'd appreciate some advice on.

First, the USB ports aren't working. I presume this is because on this 
board mpp21, instead of taking it's usual role as MPP21_SATA0_ACTn is 
used as a control line for power to the USB ports. My dmesg contains

Kirkwood: MV88F6281-A1.
Feroceon L2: Enabling L2
Feroceon L2: Cache support initialised.
[Firmware Info]: /ocp at f1000000/ethernet-controller at 72000/ethernet0-
port at 0: local-mac-address is not set
bio: create slab <bio-0> at 0
USB Power Off: Failed to request enable GPIO21: -517
reg-fixed-voltage 1.regulator: Failed to register regulator: -517
platform 1.regulator: Driver reg-fixed-voltage requests probe deferral
vgaarb: loaded
SCSI subsystem initialized

and I can't see any indication that the deferred registration ever succeeds.

/sys/kernel/debug/pinctrl/f1010000.pinctrl/pinmux-pins contains

pin 21 (PIN21): (MUX UNCLAIMED) mvebu-gpio:21

but /sys/kernel/debug/pinctrl/f1010000.pinctrl/pinconf-groups says
21 (mpp21):current: gpio(io), available = [ ts(mp1) tdm(rx0ql) ge1(txd1) 
audio(spdifo) sata0(act) ]

so I suspect it has defaulted to the right mode but 
/sys/kernel/debug/gpio says

  gpio-21  (USB Power Off       ) out lo

so it is being held in the wrong state and sysfs thinks the kernel owns 
it so won't let me export it to modify from userspace.

The other issue I've found is that the Ethernet only works if I have 
booted the original kernel at least once since the unit was powered on. 
It does get the correct MAC address when it doesn't work. I'm not sure 
what might be causing that other than that Ethernet from uboot 
apparently only works if connected to a 1G switch.

Whilst writing this device tree file I have noticed that the Ethernet 
node is missing from the NSA310 files. Unfortunately there are 2 
variants of the 310 and I've only ever seen one board setup file that 
specifies the phy number and as that doesn't match the 320 I don't feel 
able to fix that without someone to test it.

I do realise that when sending this as a proper patch you will need a 
signed off by and you will need it sent via something other than 
Thunderbird that can be relied upon not to mangle the patch. It would 
also seem to make sense to rename kirkwood-nsa310-common.dtsi to 
kirkwood-nsa3x0-common.dtsi (I believe that whilst the 310 and 320 are 
fairly similar from a hardware perspective the 325 is quite different so 
I believe 3x0 is an appropriate name)

Thanks

Adam Baker

diff --git a/arch/arm/boot/dts/kirkwood-nsa320.dts 
b/arch/arm/boot/dts/kirkwood-nsa320.dts
new file mode 100644
index 0000000..d91a480
--- /dev/null
+++ b/arch/arm/boot/dts/kirkwood-nsa320.dts
@@ -0,0 +1,203 @@
+/dts-v1/;
+
+#include "kirkwood-nsa310-common.dtsi"
+
+/ {
+       model = "Zyxel NSA320";
+	compatible = "zyxel,nsa320", "marvell,kirkwood-88f6281", 
"marvell,kirkwood";
+
+	memory {
+		device_type = "memory";
+		reg = <0x00000000 0x20000000>;
+	};
+
+	chosen {
+		bootargs = "console=ttyS0,115200";
+	};
+
+	mbus {
+		pcie-controller {
+			status = "okay";
+
+			pcie at 1,0 {
+				status = "okay";
+			};
+		};
+	};
+
+	ocp at f1000000 {
+		pinctrl: pinctrl at 10000 {
+			pinctrl-0 = <&pmx_unknown>;
+			pinctrl-names = "default";
+
+			pmx_led_hdd2_green: pmx-led-hdd2-green {
+				marvell,pins = "mpp12";
+				marvell,function = "gpio";
+			};
+
+			pmx_led_hdd2_red: pmx-led-hdd2-red {
+				marvell,pins = "mpp13";
+				marvell,function = "gpio";
+			};
+
+			pmx_led_usb_green: pmx-led-usb-green {
+				marvell,pins = "mpp15";
+				marvell,function = "gpio";
+			};
+
+			pmx_led_usb_red: pmx-led-usb-red {
+				marvell,pins = "mpp16";
+				marvell,function = "gpio";
+			};
+
+			pmx_led_sys_green: pmx-led-sys-green {
+				marvell,pins = "mpp28";
+				marvell,function = "gpio";
+			};
+
+			pmx_led_sys_red: pmx-led-sys-red {
+				marvell,pins = "mpp29";
+				marvell,function = "gpio";
+			};
+
+			pmx_btn_reset: pmx-btn-reset {
+				marvell,pins = "mpp36";
+				marvell,function = "gpio";
+			};
+
+			pmx_btn_copy: pmx-btn-copy {
+				marvell,pins = "mpp37";
+				marvell,function = "gpio";
+			};
+
+			pmx_led_copy_green: pmx-led-copy-green {
+				marvell,pins = "mpp39";
+				marvell,function = "gpio";
+			};
+
+			pmx_led_copy_red: pmx-led-copy-red {
+				marvell,pins = "mpp40";
+				marvell,function = "gpio";
+			};
+
+			pmx_led_hdd1_green: pmx-led-hdd1-green {
+				marvell,pins = "mpp41";
+				marvell,function = "gpio";
+			};
+
+			pmx_led_hdd1_red: pmx-led-hdd1-red {
+				marvell,pins = "mpp42";
+				marvell,function = "gpio";
+			};
+
+			pmx_unknown: pmx-unknown {
+				marvell,pins = "mpp44";
+				marvell,function = "gpio";
+			};
+
+			pmx_btn_power: pmx-btn-power {
+				marvell,pins = "mpp46";
+				marvell,function = "gpio";
+			};
+		};
+
+		i2c at 11000 {
+			status = "okay";
+
+			pcf8563: pcf8563 at 51 {
+				compatible = "pcf8563";
+				reg = <0x51>;
+			};
+		};
+	};
+
+	gpio_keys {
+		compatible = "gpio-keys";
+		#address-cells = <1>;
+		#size-cells = <0>;
+		pinctrl-0 = <&pmx_btn_reset &pmx_btn_copy &pmx_btn_power>;
+		pinctrl-names = "default";
+
+		button at 1 {
+			label = "Power Button";
+			linux,code = <KEY_POWER>;
+			gpios = <&gpio1 14 GPIO_ACTIVE_HIGH>;
+		};
+		button at 2 {
+			label = "Copy Button";
+			linux,code = <KEY_COPY>;
+			gpios = <&gpio1 5 GPIO_ACTIVE_LOW>;
+		};
+		button at 3 {
+			label = "Reset Button";
+			linux,code = <KEY_RESTART>;
+			gpios = <&gpio1 4 GPIO_ACTIVE_LOW>;
+		};
+	};
+
+	gpio-leds {
+		compatible = "gpio-leds";
+		pinctrl-0 = <&pmx_led_hdd2_green &pmx_led_hdd2_red
+			     &pmx_led_usb_green &pmx_led_usb_red
+			     &pmx_led_sys_green &pmx_led_sys_red
+			     &pmx_led_copy_green &pmx_led_copy_red
+			     &pmx_led_hdd1_green &pmx_led_hdd1_red>;
+		pinctrl-names = "default";
+
+		green-sys {
+			label = "nsa320:green:sys";
+			gpios = <&gpio0 28 GPIO_ACTIVE_HIGH>;
+		};
+		red-sys {
+			label = "nsa320:red:sys";
+			gpios = <&gpio0 29 GPIO_ACTIVE_HIGH>;
+		};
+		green-hdd1 {
+			label = "nsa320:green:hdd1";
+			gpios = <&gpio1 9 GPIO_ACTIVE_HIGH>;
+		};
+		red-hdd1 {
+			label = "nsa320:red:hdd1";
+			gpios = <&gpio1 10 GPIO_ACTIVE_HIGH>;
+		};
+		green-hdd2 {
+			label = "nsa320:green:hdd2";
+			gpios = <&gpio0 12 GPIO_ACTIVE_HIGH>;
+		};
+		red-hdd2 {
+			label = "nsa320:red:hdd2";
+			gpios = <&gpio0 13 GPIO_ACTIVE_HIGH>;
+		};
+		green-usb {
+			label = "nsa320:green:usb";
+			gpios = <&gpio0 15 GPIO_ACTIVE_HIGH>;
+		};
+		red-usb {
+			label = "nsa320:red:usb";
+			gpios = <&gpio0 16 GPIO_ACTIVE_HIGH>;
+		};
+		green-copy {
+			label = "nsa320:green:copy";
+			gpios = <&gpio1 7 GPIO_ACTIVE_HIGH>;
+		};
+		red-copy {
+			label = "nsa320:red:copy";
+			gpios = <&gpio1 8 GPIO_ACTIVE_HIGH>;
+		};
+	};
+};
+
+&mdio {
+       	status = "okay";
+
+        ethphy0: ethernet-phy at 1 {
+                reg = <1>;
+       	};
+};
+
+&eth0 {
+       	status = "okay";
+       	ethernet0-port at 0 {
+               	phy-handle = <&ethphy0>;
+       	};
+};

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Device Tree file for Zyxel NSA320
  2014-03-01  0:40 Device Tree file for Zyxel NSA320 Adam Baker
@ 2014-03-01 10:34 ` Andrew Lunn
  2014-03-02 23:44   ` Adam Baker
  0 siblings, 1 reply; 7+ messages in thread
From: Andrew Lunn @ 2014-03-01 10:34 UTC (permalink / raw)
  To: linux-arm-kernel

On Sat, Mar 01, 2014 at 12:40:35AM +0000, Adam Baker wrote:
> Hi,
> 
> I've been trying to get my Zyxel NSA320 working with kernel 3.14-rc1
> and device tree. I've included on CC the two developers who produced
> old style board files for the NSA310 / 320 in case you've already
> looked at this.

Hi Adam

It is good to also CC the Marvell maintainers. I added them.

First off, thanks for working on a new board. 

> I've developed a file (below) which is enough to get it to boot but
> I've got a couple of outstanding issues that I'd appreciate some
> advice on.

Great. I will review it and try to help with your issues.

> First, the USB ports aren't working. I presume this is because on
> this board mpp21, instead of taking it's usual role as
> MPP21_SATA0_ACTn is used as a control line for power to the USB
> ports. My dmesg contains
> 
> Kirkwood: MV88F6281-A1.
> Feroceon L2: Enabling L2
> Feroceon L2: Cache support initialised.
> [Firmware Info]: /ocp at f1000000/ethernet-controller at 72000/ethernet0-
> port at 0: local-mac-address is not set
> bio: create slab <bio-0> at 0
> USB Power Off: Failed to request enable GPIO21: -517
> reg-fixed-voltage 1.regulator: Failed to register regulator: -517
> platform 1.regulator: Driver reg-fixed-voltage requests probe deferral
> vgaarb: loaded
> SCSI subsystem initialized
> 
> and I can't see any indication that the deferred registration ever succeeds.

I'm not sure you ever do. But you should be able to see something in
/sys/kernel/debug/regulator/
 
> /sys/kernel/debug/pinctrl/f1010000.pinctrl/pinmux-pins contains
> 
> pin 21 (PIN21): (MUX UNCLAIMED) mvebu-gpio:21
> 
> but /sys/kernel/debug/pinctrl/f1010000.pinctrl/pinconf-groups says
> 21 (mpp21):current: gpio(io), available = [ ts(mp1) tdm(rx0ql)
> ge1(txd1) audio(spdifo) sata0(act) ]
> 
> so I suspect it has defaulted to the right mode but
> /sys/kernel/debug/gpio says
> 
>  gpio-21  (USB Power Off       ) out lo

What is interesting is that it has the name. Some something is working
here. What might help is turning on REGULATOR_DEBUG.

> The other issue I've found is that the Ethernet only works if I have
> booted the original kernel at least once since the unit was powered
> on. It does get the correct MAC address when it doesn't work. I'm
> not sure what might be causing that other than that Ethernet from
> uboot apparently only works if connected to a 1G switch.

This sounds like a phy issue. You have it at address one. Does your
u-boot have the commands:

Marvell>> help phyRead
phyRead  Phy_address Phy_offset. 
        Read the Phy register. 

What do you get with:

phyRead 1 0

> Whilst writing this device tree file I have noticed that the
> Ethernet node is missing from the NSA310 files. Unfortunately there
> are 2 variants of the 310 and I've only ever seen one board setup
> file that specifies the phy number and as that doesn't match the 320
> I don't feel able to fix that without someone to test it.

We can probably get somebody to test, if you can provide a patch.
 
> I do realise that when sending this as a proper patch you will need
> a signed off by and you will need it sent via something other than
> Thunderbird that can be relied upon not to mangle the patch.

git send-email is the preferred method.

> diff --git a/arch/arm/boot/dts/kirkwood-nsa320.dts
> b/arch/arm/boot/dts/kirkwood-nsa320.dts
> new file mode 100644
> index 0000000..d91a480
> --- /dev/null
> +++ b/arch/arm/boot/dts/kirkwood-nsa320.dts
> @@ -0,0 +1,203 @@
> +/dts-v1/;
> +
> +#include "kirkwood-nsa310-common.dtsi"
> +
> +/ {
> +       model = "Zyxel NSA320";
> +	compatible = "zyxel,nsa320", "marvell,kirkwood-88f6281",
> "marvell,kirkwood";

You have a mixture of tabs and space in this file. Please use tabs.


> +
> +	memory {
> +		device_type = "memory";
> +		reg = <0x00000000 0x20000000>;
> +	};
> +
> +	chosen {
> +		bootargs = "console=ttyS0,115200";
> +	};
> +
> +	mbus {
> +		pcie-controller {
> +			status = "okay";
> +
> +			pcie at 1,0 {
> +				status = "okay";
> +			};
> +		};
> +	};
> +
> +	ocp at f1000000 {
> +		pinctrl: pinctrl at 10000 {
> +			pinctrl-0 = <&pmx_unknown>;
> +			pinctrl-names = "default";
> +
> +			pmx_led_hdd2_green: pmx-led-hdd2-green {
> +				marvell,pins = "mpp12";
> +				marvell,function = "gpio";
> +			};
> +
> +			pmx_led_hdd2_red: pmx-led-hdd2-red {
> +				marvell,pins = "mpp13";
> +				marvell,function = "gpio";
> +			};
> +
> +			pmx_led_usb_green: pmx-led-usb-green {
> +				marvell,pins = "mpp15";
> +				marvell,function = "gpio";
> +			};
> +
> +			pmx_led_usb_red: pmx-led-usb-red {
> +				marvell,pins = "mpp16";
> +				marvell,function = "gpio";
> +			};
> +
> +			pmx_led_sys_green: pmx-led-sys-green {
> +				marvell,pins = "mpp28";
> +				marvell,function = "gpio";
> +			};
> +
> +			pmx_led_sys_red: pmx-led-sys-red {
> +				marvell,pins = "mpp29";
> +				marvell,function = "gpio";
> +			};
> +
> +			pmx_btn_reset: pmx-btn-reset {
> +				marvell,pins = "mpp36";
> +				marvell,function = "gpio";
> +			};
> +
> +			pmx_btn_copy: pmx-btn-copy {
> +				marvell,pins = "mpp37";
> +				marvell,function = "gpio";
> +			};
> +
> +			pmx_led_copy_green: pmx-led-copy-green {
> +				marvell,pins = "mpp39";
> +				marvell,function = "gpio";
> +			};
> +
> +			pmx_led_copy_red: pmx-led-copy-red {
> +				marvell,pins = "mpp40";
> +				marvell,function = "gpio";
> +			};
> +
> +			pmx_led_hdd1_green: pmx-led-hdd1-green {
> +				marvell,pins = "mpp41";
> +				marvell,function = "gpio";
> +			};
> +
> +			pmx_led_hdd1_red: pmx-led-hdd1-red {
> +				marvell,pins = "mpp42";
> +				marvell,function = "gpio";
> +			};
> +
> +			pmx_unknown: pmx-unknown {
> +				marvell,pins = "mpp44";
> +				marvell,function = "gpio";
> +			};
> +
> +			pmx_btn_power: pmx-btn-power {
> +				marvell,pins = "mpp46";
> +				marvell,function = "gpio";
> +			};
> +		};

These all look identical to nsa310. Maybe it makes sense to refactor
kirkwood-nsa310.dts and place the common parts into a .dtsi file?

> +
> +		i2c at 11000 {
> +			status = "okay";
> +
> +			pcf8563: pcf8563 at 51 {
> +				compatible = "pcf8563";

Please put a vendor name in the compatible string. So it should be
"nxp,pcf8563". We have only just started to enforce this, and lots of
existing files need fixing.

> +				reg = <0x51>;
> +			};
> +		};
> +	};
> +
> +	gpio_keys {
> +		compatible = "gpio-keys";
> +		#address-cells = <1>;
> +		#size-cells = <0>;
> +		pinctrl-0 = <&pmx_btn_reset &pmx_btn_copy &pmx_btn_power>;
> +		pinctrl-names = "default";
> +
> +		button at 1 {
> +			label = "Power Button";
> +			linux,code = <KEY_POWER>;
> +			gpios = <&gpio1 14 GPIO_ACTIVE_HIGH>;
> +		};
> +		button at 2 {
> +			label = "Copy Button";
> +			linux,code = <KEY_COPY>;
> +			gpios = <&gpio1 5 GPIO_ACTIVE_LOW>;
> +		};
> +		button at 3 {
> +			label = "Reset Button";
> +			linux,code = <KEY_RESTART>;
> +			gpios = <&gpio1 4 GPIO_ACTIVE_LOW>;
> +		};
> +	};
> +
> +	gpio-leds {
> +		compatible = "gpio-leds";
> +		pinctrl-0 = <&pmx_led_hdd2_green &pmx_led_hdd2_red
> +			     &pmx_led_usb_green &pmx_led_usb_red
> +			     &pmx_led_sys_green &pmx_led_sys_red
> +			     &pmx_led_copy_green &pmx_led_copy_red
> +			     &pmx_led_hdd1_green &pmx_led_hdd1_red>;
> +		pinctrl-names = "default";
> +
> +		green-sys {
> +			label = "nsa320:green:sys";
> +			gpios = <&gpio0 28 GPIO_ACTIVE_HIGH>;
> +		};
> +		red-sys {
> +			label = "nsa320:red:sys";
> +			gpios = <&gpio0 29 GPIO_ACTIVE_HIGH>;
> +		};
> +		green-hdd1 {
> +			label = "nsa320:green:hdd1";
> +			gpios = <&gpio1 9 GPIO_ACTIVE_HIGH>;
> +		};
> +		red-hdd1 {
> +			label = "nsa320:red:hdd1";
> +			gpios = <&gpio1 10 GPIO_ACTIVE_HIGH>;
> +		};
> +		green-hdd2 {
> +			label = "nsa320:green:hdd2";
> +			gpios = <&gpio0 12 GPIO_ACTIVE_HIGH>;
> +		};
> +		red-hdd2 {
> +			label = "nsa320:red:hdd2";
> +			gpios = <&gpio0 13 GPIO_ACTIVE_HIGH>;
> +		};
> +		green-usb {
> +			label = "nsa320:green:usb";
> +			gpios = <&gpio0 15 GPIO_ACTIVE_HIGH>;
> +		};
> +		red-usb {
> +			label = "nsa320:red:usb";
> +			gpios = <&gpio0 16 GPIO_ACTIVE_HIGH>;
> +		};
> +		green-copy {
> +			label = "nsa320:green:copy";
> +			gpios = <&gpio1 7 GPIO_ACTIVE_HIGH>;
> +		};
> +		red-copy {
> +			label = "nsa320:red:copy";
> +			gpios = <&gpio1 8 GPIO_ACTIVE_HIGH>;
> +		};
> +	};
> +};
> +
> +&mdio {
> +       	status = "okay";
> +
> +        ethphy0: ethernet-phy at 1 {
> +                reg = <1>;
> +       	};
> +};
> +
> +&eth0 {
> +       	status = "okay";
> +       	ethernet0-port at 0 {
> +               	phy-handle = <&ethphy0>;
> +       	};
> +};

Here you can see how the mixture of tabs and spaces causes problems...

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Device Tree file for Zyxel NSA320
  2014-03-01 10:34 ` Andrew Lunn
@ 2014-03-02 23:44   ` Adam Baker
  2014-03-03  9:41     ` Andrew Lunn
  0 siblings, 1 reply; 7+ messages in thread
From: Adam Baker @ 2014-03-02 23:44 UTC (permalink / raw)
  To: linux-arm-kernel

On 01/03/14 10:34, Andrew Lunn wrote:
> On Sat, Mar 01, 2014 at 12:40:35AM +0000, Adam Baker wrote:
>> Hi,
>>
>> I've been trying to get my Zyxel NSA320 working with kernel 3.14-rc1
>> and device tree. I've included on CC the two developers who produced
>> old style board files for the NSA310 / 320 in case you've already
>> looked at this.
>
> Hi Adam
>
> It is good to also CC the Marvell maintainers. I added them.
>

Thanks for that.

> First off, thanks for working on a new board.
>
>> I've developed a file (below) which is enough to get it to boot but
>> I've got a couple of outstanding issues that I'd appreciate some
>> advice on.
>
> Great. I will review it and try to help with your issues.
>
>> First, the USB ports aren't working. I presume this is because on
>> this board mpp21, instead of taking it's usual role as
>> MPP21_SATA0_ACTn is used as a control line for power to the USB
>> ports. My dmesg contains
>>
snip
>> so I suspect it has defaulted to the right mode but
>> /sys/kernel/debug/gpio says
>>
>>   gpio-21  (USB Power Off       ) out lo
>
> What is interesting is that it has the name. Some something is working
> here. What might help is turning on REGULATOR_DEBUG.

I'm now suspicious as to whether this actually works on NSA310. The 
regulator was named USB Power Off and was set to always-on. Hence USB 
Power Off was always enabled, i.e. USB was off. Changing the name 
(because having the word off in the name of a regulator doesn't make 
sense) and making it an active high regulator brings the USB to life.

Whilst debugging this issue I thought it would be helpful to be able to 
access the GPIO and pin multiplexing state from user space. I've 
therefore attached a small program I wrote to do that in case it is of 
use to others. It assumes the normal mapping of the processor I/O block 
to 0xf1000000.

>
>> The other issue I've found is that the Ethernet only works if I have
>> booted the original kernel at least once since the unit was powered
>> on. It does get the correct MAC address when it doesn't work. I'm
>> not sure what might be causing that other than that Ethernet from
>> uboot apparently only works if connected to a 1G switch.
>
> This sounds like a phy issue. You have it at address one. Does your
> u-boot have the commands:
>
> Marvell>> help phyRead
> phyRead  Phy_address Phy_offset.
>          Read the Phy register.
>
> What do you get with:
>
> phyRead 1 0
>

Yes, uboot does have that command but I can no longer reproduce the 
failure. I'll keep watching this in case it fails again.

>> Whilst writing this device tree file I have noticed that the
>> Ethernet node is missing from the NSA310 files. Unfortunately there
>> are 2 variants of the 310 and I've only ever seen one board setup
>> file that specifies the phy number and as that doesn't match the 320
>> I don't feel able to fix that without someone to test it.
>
> We can probably get somebody to test, if you can provide a patch.

Once I'm happy with the rest of the changes I'll add the Ethernet node 
to the nsa310 files and assume the phy number is 0 for both as that is 
the only value I can find in board setup files for the 310.

>
>> I do realise that when sending this as a proper patch you will need
>> a signed off by and you will need it sent via something other than
>> Thunderbird that can be relied upon not to mangle the patch.
>
> git send-email is the preferred method.
>

I'll use that once I get something that is fit to submit then

For now I'll answer your comments then attach the latest diff


>
> You have a mixture of tabs and space in this file. Please use tabs.
>
I'd fixed that then forgot to stage the change - sorry.


>> +			pmx_unknown: pmx-unknown {
>> +				marvell,pins = "mpp44";
>> +				marvell,function = "gpio";
>> +			};
>> +
>> +			pmx_btn_power: pmx-btn-power {
>> +				marvell,pins = "mpp46";
>> +				marvell,function = "gpio";
>> +			};
>> +		};
>
> These all look identical to nsa310. Maybe it makes sense to refactor
> kirkwood-nsa310.dts and place the common parts into a .dtsi file?
>
They were copy / pasted with just the one change I'd spotted at the time 
(esata is now hdd2) but I've since found some more differences. I'll 
refactor once I get to the bottom of what really is common.

>> +			pcf8563: pcf8563 at 51 {
>> +				compatible = "pcf8563";
>
> Please put a vendor name in the compatible string. So it should be
> "nxp,pcf8563". We have only just started to enforce this, and lots of
> existing files need fixing.
>
done

My biggest outstanding issue is now with the GPIO pins that are not used 
in any of the setup files I have seen. Running my pin state monitor with 
the vendor kernel I can see that that configures some of the unused 
pins, 43, 45 and 49 as GPIO inputs. Currently 43 ends up configured as a 
TDM input which isn't too bad, 45 ends up configured as TDM I/O and 49 
ends up configured as GPIO output which ought to be fixed as it will 
increase power consumption if nothing else. It seems the 
marvell,function in the pinctrl is ignored if the pin isn't used. Is 
there a good way to fix that?

I've located a driver at http://pastebin.com/3LNtYZSD that claims to be 
able to use some of the other unused pins to talk to a temperature 
sensor and also uses these pins to configure the response to power on 
after a power failure so I guess that needs adding eventually too.


diff --git a/arch/arm/boot/dts/kirkwood-nsa310-common.dtsi 
b/arch/arm/boot/dts/kirkwood-nsa310-common.dtsi
index aa78c2d..63e1b6f 100644
--- a/arch/arm/boot/dts/kirkwood-nsa310-common.dtsi
+++ b/arch/arm/boot/dts/kirkwood-nsa310-common.dtsi
@@ -7,7 +7,7 @@
  	ocp at f1000000 {
  		pinctrl: pinctrl at 10000 {

-			pmx_usb_power_off: pmx-usb-power-off {
+			pmx_usb_power: pmx-usb-power {
  				marvell,pins = "mpp21";
  				marvell,function = "gpio";
  			};
@@ -47,17 +47,18 @@
  		compatible = "simple-bus";
  		#address-cells = <1>;
  		#size-cells = <0>;
-		pinctrl-0 = <&pmx_usb_power_off>;
+		pinctrl-0 = <&pmx_usb_power>;
  		pinctrl-names = "default";

-		usb0_power_off: regulator at 1 {
+		usb0_power: regulator at 1 {
  			compatible = "regulator-fixed";
  			reg = <1>;
-			regulator-name = "USB Power Off";
+			regulator-name = "USB Power";
  			regulator-min-microvolt = <5000000>;
  			regulator-max-microvolt = <5000000>;
  			regulator-always-on;
  			regulator-boot-on;
+			enable-active-high;
  			gpio = <&gpio0 21 GPIO_ACTIVE_HIGH>;
  		};
  	};
diff --git a/arch/arm/boot/dts/kirkwood-nsa320.dts 
b/arch/arm/boot/dts/kirkwood-nsa320.dts
new file mode 100644
index 0000000..43f1e1d
--- /dev/null
+++ b/arch/arm/boot/dts/kirkwood-nsa320.dts
@@ -0,0 +1,252 @@
+/dts-v1/;
+
+/* Device tree file for the Zyxel NSA 320 NAS box.
+   Based upon the board setup file created by Peter Schildmann */
+
+#include "kirkwood-nsa310-common.dtsi"
+
+/ {
+	model = "Zyxel NSA320";
+	compatible = "zyxel,nsa320", "marvell,kirkwood-88f6281", 
"marvell,kirkwood";
+
+	memory {
+		device_type = "memory";
+		reg = <0x00000000 0x20000000>;
+	};
+
+	chosen {
+		bootargs = "console=ttyS0,115200";
+	};
+
+	mbus {
+		pcie-controller {
+			status = "okay";
+
+			pcie at 1,0 {
+				status = "okay";
+			};
+		};
+	};
+
+	ocp at f1000000 {
+		pinctrl: pinctrl at 10000 {
+			pinctrl-names = "default";
+
+			/* SATA Activity and Present pins are not connected */
+			pmx_sata0: pmx-sata0 {
+				marvell,pins ;
+				marvell,function = "sata0";
+			};
+
+			pmx_sata1: pmx-sata1 {
+				marvell,pins ;
+				marvell,function = "sata1";
+			};
+
+			pmx_led_hdd2_green: pmx-led-hdd2-green {
+				marvell,pins = "mpp12";
+				marvell,function = "gpio";
+			};
+
+			pmx_led_hdd2_red: pmx-led-hdd2-red {
+				marvell,pins = "mpp13";
+				marvell,function = "gpio";
+			};
+
+			pmx_mcu_data: pmx-mcu-data {
+				marvell,pins = "mpp14";
+				marvell,function = "gpio";
+			};
+
+			pmx_led_usb_green: pmx-led-usb-green {
+				marvell,pins = "mpp15";
+				marvell,function = "gpio";
+			};
+
+			pmx_mcu_clk: pmx-mcu-clk {
+				marvell,pins = "mpp16";
+				marvell,function = "gpio";
+			};
+
+			pmx_mcu_act: pmx-mcu-act {
+				marvell,pins = "mpp17";
+				marvell,function = "gpio";
+			};
+
+			pmx_led_sys_green: pmx-led-sys-green {
+				marvell,pins = "mpp28";
+				marvell,function = "gpio";
+			};
+
+			pmx_led_sys_orange: pmx-led-sys-orange {
+				marvell,pins = "mpp29";
+				marvell,function = "gpio";
+			};
+
+			pmx_btn_reset: pmx-btn-reset {
+				marvell,pins = "mpp36";
+				marvell,function = "gpio";
+			};
+
+			pmx_btn_copy: pmx-btn-copy {
+				marvell,pins = "mpp37";
+				marvell,function = "gpio";
+			};
+
+			pmx_led_copy_green: pmx-led-copy-green {
+				marvell,pins = "mpp39";
+				marvell,function = "gpio";
+			};
+
+			pmx_led_copy_red: pmx-led-copy-red {
+				marvell,pins = "mpp40";
+				marvell,function = "gpio";
+			};
+
+			pmx_led_hdd1_green: pmx-led-hdd1-green {
+				marvell,pins = "mpp41";
+				marvell,function = "gpio";
+			};
+
+			pmx_led_hdd1_red: pmx-led-hdd1-red {
+				marvell,pins = "mpp42";
+				marvell,function = "gpio";
+			};
+
+			pmx_htp: pmx-htp {
+				marvell,pins = "mpp43";
+				marvell,function = "gpio";
+			};
+
+			pmx_buzzer: pmx-buzzer {
+				marvell,pins = "mpp44";
+				marvell,function = "gpio";
+			};
+
+			pmx_vid_b1: pmx-vid-b1 {
+				marvell,pins = "mpp45";
+				marvell,function = "gpio";
+			};
+
+			pmx_btn_power: pmx-btn-power {
+				marvell,pins = "mpp46";
+				marvell,function = "gpio";
+			};
+
+			pmx_power_resume_data: pmx-power-resume-data {
+				marvell,pins = "mpp47";
+				marvell,function = "gpio";
+			};
+
+			pmx_power_resume_clk: pmx-power-resume-clk {
+				marvell,pins = "mpp49";
+				marvell,function = "gpio";
+			};
+		};
+
+		i2c at 11000 {
+			status = "okay";
+
+			pcf8563: pcf8563 at 51 {
+				compatible = "nxp,pcf8563";
+				reg = <0x51>;
+			};
+		};
+	};
+
+	gpio_keys {
+		compatible = "gpio-keys";
+		#address-cells = <1>;
+		#size-cells = <0>;
+		pinctrl-0 = <&pmx_btn_reset &pmx_btn_copy &pmx_btn_power>;
+		pinctrl-names = "default";
+
+		button at 1 {
+			label = "Power Button";
+			linux,code = <KEY_POWER>;
+			gpios = <&gpio1 14 GPIO_ACTIVE_HIGH>;
+		};
+		button at 2 {
+			label = "Copy Button";
+			linux,code = <KEY_COPY>;
+			gpios = <&gpio1 5 GPIO_ACTIVE_LOW>;
+		};
+		button at 3 {
+			label = "Reset Button";
+			linux,code = <KEY_RESTART>;
+			gpios = <&gpio1 4 GPIO_ACTIVE_LOW>;
+		};
+	};
+
+	gpio-leds {
+		compatible = "gpio-leds";
+		pinctrl-0 = <&pmx_led_hdd2_green &pmx_led_hdd2_red
+			     &pmx_led_usb_green
+			     &pmx_led_sys_green &pmx_led_sys_orange
+			     &pmx_led_copy_green &pmx_led_copy_red
+			     &pmx_led_hdd1_green &pmx_led_hdd1_red
+			     &pmx_buzzer>;
+		pinctrl-names = "default";
+
+		green-sys {
+			label = "nsa320:green:sys";
+			gpios = <&gpio0 28 GPIO_ACTIVE_HIGH>;
+		};
+		orange-sys {
+			label = "nsa320:orange:sys";
+			gpios = <&gpio0 29 GPIO_ACTIVE_HIGH>;
+		};
+		green-hdd1 {
+			label = "nsa320:green:hdd1";
+			gpios = <&gpio1 9 GPIO_ACTIVE_HIGH>;
+		};
+		red-hdd1 {
+			label = "nsa320:red:hdd1";
+			gpios = <&gpio1 10 GPIO_ACTIVE_HIGH>;
+		};
+		green-hdd2 {
+			label = "nsa320:green:hdd2";
+			gpios = <&gpio0 12 GPIO_ACTIVE_HIGH>;
+		};
+		red-hdd2 {
+			label = "nsa320:red:hdd2";
+			gpios = <&gpio0 13 GPIO_ACTIVE_HIGH>;
+		};
+		green-usb {
+			label = "nsa320:green:usb";
+			gpios = <&gpio0 15 GPIO_ACTIVE_HIGH>;
+		};
+		green-copy {
+			label = "nsa320:green:copy";
+			gpios = <&gpio1 7 GPIO_ACTIVE_HIGH>;
+		};
+		red-copy {
+			label = "nsa320:red:copy";
+			gpios = <&gpio1 8 GPIO_ACTIVE_HIGH>;
+		};
+	};
+	beeper: beeper {
+		compatible = "gpio-beeper";
+		gpios = <&gpio1 12 GPIO_ACTIVE_HIGH>;
+	};
+
+	/* The following pins are currently not assigned to a driver,
+	   some of them should be configured as inputs.
+	pinctrl-0 = <&pmx_mcu_data &pmx_mcu_clk &pmx_mcu_act
+		     &pmx_htp &pmx_vid_b1
+		     &pmx_power_resume_data &pmx_power_resume_clk>; */
+};
+
+&mdio {
+	status = "okay";
+	ethphy0: ethernet-phy at 1 {
+		reg = <1>;
+	};
+};
+
+&eth0 {
+	status = "okay";
+	ethernet0-port at 0 {
+		phy-handle = <&ethphy0>;
+	};
+};

-------------- next part --------------
A non-text attachment was scrubbed...
Name: kw-gpio.c
Type: text/x-csrc
Size: 2035 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140302/cf487a73/attachment.bin>

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Device Tree file for Zyxel NSA320
  2014-03-02 23:44   ` Adam Baker
@ 2014-03-03  9:41     ` Andrew Lunn
  2014-03-26  1:06       ` Jason Cooper
  0 siblings, 1 reply; 7+ messages in thread
From: Andrew Lunn @ 2014-03-03  9:41 UTC (permalink / raw)
  To: linux-arm-kernel

> I'm now suspicious as to whether this actually works on NSA310. The
> regulator was named USB Power Off and was set to always-on. Hence
> USB Power Off was always enabled, i.e. USB was off. Changing the
> name (because having the word off in the name of a regulator doesn't
> make sense) and making it an active high regulator brings the USB to
> life.

Hi Adam

So either the original definition is wrong, our your board has the
level inverted. I would guess yours is inverted. I think removing the
_off is O.K, but for the moment i would not invert it in the
-common.dtsi. We should get it verifies that the current code does
work/is broken.

You should also be able to override the node in your own .dts
file. Something like:

        regulators {
                usb0_power: regulator at 1 {
			enable-active-high;
		} 		 	     
	}

I often "decompile" the .dtb file back to .dts so you can see what
actually happened. This device tree language can be error prone.

> They were copy / pasted with just the one change I'd spotted at the
> time (esata is now hdd2) but I've since found some more differences.
> I'll refactor once I get to the bottom of what really is common.

O.K. If there is not too much common, don't bother refactoring.
 
> My biggest outstanding issue is now with the GPIO pins that are not
> used in any of the setup files I have seen. Running my pin state
> monitor with the vendor kernel I can see that that configures some
> of the unused pins, 43, 45 and 49 as GPIO inputs. Currently 43 ends
> up configured as a TDM input which isn't too bad, 45 ends up
> configured as TDM I/O and 49 ends up configured as GPIO output which
> ought to be fixed as it will increase power consumption if nothing
> else. It seems the marvell,function in the pinctrl is ignored if the
> pin isn't used. Is there a good way to fix that?

Yes, partially, using pin hogs. You can at least set the function as
gpio, or any other function you want. You cannot however set the
direction if its a gpio.

Taking an example from kirkwood-ts219-6282.dts

                pinctrl: pinctrl at 10000 {

                        pinctrl-0 = <&pmx_ram_size &pmx_board_id>;
                        pinctrl-names = "default";

this results in pmx_ram_size and pmx_board_id being configured be
default, even if no driver claims them.
 
> I've located a driver at http://pastebin.com/3LNtYZSD that claims to
> be able to use some of the other unused pins to talk to a
> temperature sensor and also uses these pins to configure the
> response to power on after a power failure so I guess that needs
> adding eventually too.

OpenWRT also has a patch containing a driver.
 
> diff --git a/arch/arm/boot/dts/kirkwood-nsa310-common.dtsi
> b/arch/arm/boot/dts/kirkwood-nsa310-common.dtsi
> index aa78c2d..63e1b6f 100644
> --- a/arch/arm/boot/dts/kirkwood-nsa310-common.dtsi
> +++ b/arch/arm/boot/dts/kirkwood-nsa310-common.dtsi
> @@ -7,7 +7,7 @@
>  	ocp at f1000000 {
>  		pinctrl: pinctrl at 10000 {
> 
> -			pmx_usb_power_off: pmx-usb-power-off {
> +			pmx_usb_power: pmx-usb-power {
>  				marvell,pins = "mpp21";
>  				marvell,function = "gpio";
>  			};
> @@ -47,17 +47,18 @@
>  		compatible = "simple-bus";
>  		#address-cells = <1>;
>  		#size-cells = <0>;
> -		pinctrl-0 = <&pmx_usb_power_off>;
> +		pinctrl-0 = <&pmx_usb_power>;
>  		pinctrl-names = "default";
> 
> -		usb0_power_off: regulator at 1 {
> +		usb0_power: regulator at 1 {
>  			compatible = "regulator-fixed";
>  			reg = <1>;
> -			regulator-name = "USB Power Off";
> +			regulator-name = "USB Power";
>  			regulator-min-microvolt = <5000000>;
>  			regulator-max-microvolt = <5000000>;
>  			regulator-always-on;
>  			regulator-boot-on;
> +			enable-active-high;
>  			gpio = <&gpio0 21 GPIO_ACTIVE_HIGH>;
>  		};
>  	};

This makes sense as a general cleanup. Please submit as a separate
patch, but as i said above, without the enable-active-high until we
can test it.

> diff --git a/arch/arm/boot/dts/kirkwood-nsa320.dts
> b/arch/arm/boot/dts/kirkwood-nsa320.dts
> new file mode 100644
> index 0000000..43f1e1d
> --- /dev/null
> +++ b/arch/arm/boot/dts/kirkwood-nsa320.dts
> @@ -0,0 +1,252 @@
> +/dts-v1/;
> +
> +/* Device tree file for the Zyxel NSA 320 NAS box.
> +   Based upon the board setup file created by Peter Schildmann */

Just nice to have, but a copyright notice and license would be
good. Not all .dts files have them, but i suspect it will become more
important when these files move out of the kernel and into a repo of
there own.

> +
> +#include "kirkwood-nsa310-common.dtsi"
> +
> +/ {
> +	model = "Zyxel NSA320";
> +	compatible = "zyxel,nsa320", "marvell,kirkwood-88f6281",
> "marvell,kirkwood";
> +
> +	memory {
> +		device_type = "memory";
> +		reg = <0x00000000 0x20000000>;
> +	};
> +
> +	chosen {
> +		bootargs = "console=ttyS0,115200";
> +	};
> +
> +	mbus {
> +		pcie-controller {
> +			status = "okay";
> +
> +			pcie at 1,0 {
> +				status = "okay";
> +			};
> +		};
> +	};
> +
> +	ocp at f1000000 {
> +		pinctrl: pinctrl at 10000 {
> +			pinctrl-names = "default";
> +
> +			/* SATA Activity and Present pins are not connected */
> +			pmx_sata0: pmx-sata0 {
> +				marvell,pins ;
> +				marvell,function = "sata0";
> +			};
> +
> +			pmx_sata1: pmx-sata1 {
> +				marvell,pins ;
> +				marvell,function = "sata1";
> +			};
> +
> +			pmx_led_hdd2_green: pmx-led-hdd2-green {
> +				marvell,pins = "mpp12";
> +				marvell,function = "gpio";
> +			};
> +
> +			pmx_led_hdd2_red: pmx-led-hdd2-red {
> +				marvell,pins = "mpp13";
> +				marvell,function = "gpio";
> +			};
> +
> +			pmx_mcu_data: pmx-mcu-data {
> +				marvell,pins = "mpp14";
> +				marvell,function = "gpio";
> +			};
> +
> +			pmx_led_usb_green: pmx-led-usb-green {
> +				marvell,pins = "mpp15";
> +				marvell,function = "gpio";
> +			};
> +
> +			pmx_mcu_clk: pmx-mcu-clk {
> +				marvell,pins = "mpp16";
> +				marvell,function = "gpio";
> +			};
> +
> +			pmx_mcu_act: pmx-mcu-act {
> +				marvell,pins = "mpp17";
> +				marvell,function = "gpio";
> +			};
> +
> +			pmx_led_sys_green: pmx-led-sys-green {
> +				marvell,pins = "mpp28";
> +				marvell,function = "gpio";
> +			};
> +
> +			pmx_led_sys_orange: pmx-led-sys-orange {
> +				marvell,pins = "mpp29";
> +				marvell,function = "gpio";
> +			};
> +
> +			pmx_btn_reset: pmx-btn-reset {
> +				marvell,pins = "mpp36";
> +				marvell,function = "gpio";
> +			};
> +
> +			pmx_btn_copy: pmx-btn-copy {
> +				marvell,pins = "mpp37";
> +				marvell,function = "gpio";
> +			};
> +
> +			pmx_led_copy_green: pmx-led-copy-green {
> +				marvell,pins = "mpp39";
> +				marvell,function = "gpio";
> +			};
> +
> +			pmx_led_copy_red: pmx-led-copy-red {
> +				marvell,pins = "mpp40";
> +				marvell,function = "gpio";
> +			};
> +
> +			pmx_led_hdd1_green: pmx-led-hdd1-green {
> +				marvell,pins = "mpp41";
> +				marvell,function = "gpio";
> +			};
> +
> +			pmx_led_hdd1_red: pmx-led-hdd1-red {
> +				marvell,pins = "mpp42";
> +				marvell,function = "gpio";
> +			};
> +
> +			pmx_htp: pmx-htp {
> +				marvell,pins = "mpp43";
> +				marvell,function = "gpio";
> +			};
> +
> +			pmx_buzzer: pmx-buzzer {
> +				marvell,pins = "mpp44";
> +				marvell,function = "gpio";
> +			};
> +
> +			pmx_vid_b1: pmx-vid-b1 {
> +				marvell,pins = "mpp45";
> +				marvell,function = "gpio";
> +			};
> +
> +			pmx_btn_power: pmx-btn-power {
> +				marvell,pins = "mpp46";
> +				marvell,function = "gpio";
> +			};
> +
> +			pmx_power_resume_data: pmx-power-resume-data {
> +				marvell,pins = "mpp47";
> +				marvell,function = "gpio";
> +			};
> +
> +			pmx_power_resume_clk: pmx-power-resume-clk {
> +				marvell,pins = "mpp49";
> +				marvell,function = "gpio";
> +			};
> +		};
> +
> +		i2c at 11000 {
> +			status = "okay";
> +
> +			pcf8563: pcf8563 at 51 {
> +				compatible = "nxp,pcf8563";
> +				reg = <0x51>;
> +			};
> +		};
> +	};
> +
> +	gpio_keys {
> +		compatible = "gpio-keys";
> +		#address-cells = <1>;
> +		#size-cells = <0>;
> +		pinctrl-0 = <&pmx_btn_reset &pmx_btn_copy &pmx_btn_power>;
> +		pinctrl-names = "default";
> +
> +		button at 1 {
> +			label = "Power Button";
> +			linux,code = <KEY_POWER>;
> +			gpios = <&gpio1 14 GPIO_ACTIVE_HIGH>;
> +		};
> +		button at 2 {
> +			label = "Copy Button";
> +			linux,code = <KEY_COPY>;
> +			gpios = <&gpio1 5 GPIO_ACTIVE_LOW>;
> +		};
> +		button at 3 {
> +			label = "Reset Button";
> +			linux,code = <KEY_RESTART>;
> +			gpios = <&gpio1 4 GPIO_ACTIVE_LOW>;
> +		};
> +	};
> +
> +	gpio-leds {
> +		compatible = "gpio-leds";
> +		pinctrl-0 = <&pmx_led_hdd2_green &pmx_led_hdd2_red
> +			     &pmx_led_usb_green
> +			     &pmx_led_sys_green &pmx_led_sys_orange
> +			     &pmx_led_copy_green &pmx_led_copy_red
> +			     &pmx_led_hdd1_green &pmx_led_hdd1_red
> +			     &pmx_buzzer>;

I guess this last one does not belong here. It should be in the beeper
node below.

> +		pinctrl-names = "default";
> +
> +		green-sys {
> +			label = "nsa320:green:sys";
> +			gpios = <&gpio0 28 GPIO_ACTIVE_HIGH>;
> +		};
> +		orange-sys {
> +			label = "nsa320:orange:sys";
> +			gpios = <&gpio0 29 GPIO_ACTIVE_HIGH>;
> +		};
> +		green-hdd1 {
> +			label = "nsa320:green:hdd1";
> +			gpios = <&gpio1 9 GPIO_ACTIVE_HIGH>;
> +		};
> +		red-hdd1 {
> +			label = "nsa320:red:hdd1";
> +			gpios = <&gpio1 10 GPIO_ACTIVE_HIGH>;
> +		};
> +		green-hdd2 {
> +			label = "nsa320:green:hdd2";
> +			gpios = <&gpio0 12 GPIO_ACTIVE_HIGH>;
> +		};
> +		red-hdd2 {
> +			label = "nsa320:red:hdd2";
> +			gpios = <&gpio0 13 GPIO_ACTIVE_HIGH>;
> +		};
> +		green-usb {
> +			label = "nsa320:green:usb";
> +			gpios = <&gpio0 15 GPIO_ACTIVE_HIGH>;
> +		};
> +		green-copy {
> +			label = "nsa320:green:copy";
> +			gpios = <&gpio1 7 GPIO_ACTIVE_HIGH>;
> +		};
> +		red-copy {
> +			label = "nsa320:red:copy";
> +			gpios = <&gpio1 8 GPIO_ACTIVE_HIGH>;
> +		};
> +	};
> +	beeper: beeper {
> +		compatible = "gpio-beeper";
> +		gpios = <&gpio1 12 GPIO_ACTIVE_HIGH>;
> +	};
> +
> +	/* The following pins are currently not assigned to a driver,
> +	   some of them should be configured as inputs.
> +	pinctrl-0 = <&pmx_mcu_data &pmx_mcu_clk &pmx_mcu_act
> +		     &pmx_htp &pmx_vid_b1
> +		     &pmx_power_resume_data &pmx_power_resume_clk>; */

These will become your pin hogs.

> +};
> +
> +&mdio {
> +	status = "okay";
> +	ethphy0: ethernet-phy at 1 {
> +		reg = <1>;
> +	};
> +};
> +
> +&eth0 {
> +	status = "okay";
> +	ethernet0-port at 0 {
> +		phy-handle = <&ethphy0>;
> +	};
> +};
> 

Looking good otherwise.

	Andrew

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Device Tree file for Zyxel NSA320
  2014-03-03  9:41     ` Andrew Lunn
@ 2014-03-26  1:06       ` Jason Cooper
  2014-03-26 23:07         ` mvebu: Kirkwood: " Adam Baker
  0 siblings, 1 reply; 7+ messages in thread
From: Jason Cooper @ 2014-03-26  1:06 UTC (permalink / raw)
  To: linux-arm-kernel

Adam,

Any progress on this?

thx,

Jason.

On Mon, Mar 03, 2014 at 10:41:02AM +0100, Andrew Lunn wrote:
> > I'm now suspicious as to whether this actually works on NSA310. The
> > regulator was named USB Power Off and was set to always-on. Hence
> > USB Power Off was always enabled, i.e. USB was off. Changing the
> > name (because having the word off in the name of a regulator doesn't
> > make sense) and making it an active high regulator brings the USB to
> > life.
> 
> Hi Adam
> 
> So either the original definition is wrong, our your board has the
> level inverted. I would guess yours is inverted. I think removing the
> _off is O.K, but for the moment i would not invert it in the
> -common.dtsi. We should get it verifies that the current code does
> work/is broken.
> 
> You should also be able to override the node in your own .dts
> file. Something like:
> 
>         regulators {
>                 usb0_power: regulator at 1 {
> 			enable-active-high;
> 		} 		 	     
> 	}
> 
> I often "decompile" the .dtb file back to .dts so you can see what
> actually happened. This device tree language can be error prone.
> 
> > They were copy / pasted with just the one change I'd spotted at the
> > time (esata is now hdd2) but I've since found some more differences.
> > I'll refactor once I get to the bottom of what really is common.
> 
> O.K. If there is not too much common, don't bother refactoring.
>  
> > My biggest outstanding issue is now with the GPIO pins that are not
> > used in any of the setup files I have seen. Running my pin state
> > monitor with the vendor kernel I can see that that configures some
> > of the unused pins, 43, 45 and 49 as GPIO inputs. Currently 43 ends
> > up configured as a TDM input which isn't too bad, 45 ends up
> > configured as TDM I/O and 49 ends up configured as GPIO output which
> > ought to be fixed as it will increase power consumption if nothing
> > else. It seems the marvell,function in the pinctrl is ignored if the
> > pin isn't used. Is there a good way to fix that?
> 
> Yes, partially, using pin hogs. You can at least set the function as
> gpio, or any other function you want. You cannot however set the
> direction if its a gpio.
> 
> Taking an example from kirkwood-ts219-6282.dts
> 
>                 pinctrl: pinctrl at 10000 {
> 
>                         pinctrl-0 = <&pmx_ram_size &pmx_board_id>;
>                         pinctrl-names = "default";
> 
> this results in pmx_ram_size and pmx_board_id being configured be
> default, even if no driver claims them.
>  
> > I've located a driver at http://pastebin.com/3LNtYZSD that claims to
> > be able to use some of the other unused pins to talk to a
> > temperature sensor and also uses these pins to configure the
> > response to power on after a power failure so I guess that needs
> > adding eventually too.
> 
> OpenWRT also has a patch containing a driver.
>  
> > diff --git a/arch/arm/boot/dts/kirkwood-nsa310-common.dtsi
> > b/arch/arm/boot/dts/kirkwood-nsa310-common.dtsi
> > index aa78c2d..63e1b6f 100644
> > --- a/arch/arm/boot/dts/kirkwood-nsa310-common.dtsi
> > +++ b/arch/arm/boot/dts/kirkwood-nsa310-common.dtsi
> > @@ -7,7 +7,7 @@
> >  	ocp at f1000000 {
> >  		pinctrl: pinctrl at 10000 {
> > 
> > -			pmx_usb_power_off: pmx-usb-power-off {
> > +			pmx_usb_power: pmx-usb-power {
> >  				marvell,pins = "mpp21";
> >  				marvell,function = "gpio";
> >  			};
> > @@ -47,17 +47,18 @@
> >  		compatible = "simple-bus";
> >  		#address-cells = <1>;
> >  		#size-cells = <0>;
> > -		pinctrl-0 = <&pmx_usb_power_off>;
> > +		pinctrl-0 = <&pmx_usb_power>;
> >  		pinctrl-names = "default";
> > 
> > -		usb0_power_off: regulator at 1 {
> > +		usb0_power: regulator at 1 {
> >  			compatible = "regulator-fixed";
> >  			reg = <1>;
> > -			regulator-name = "USB Power Off";
> > +			regulator-name = "USB Power";
> >  			regulator-min-microvolt = <5000000>;
> >  			regulator-max-microvolt = <5000000>;
> >  			regulator-always-on;
> >  			regulator-boot-on;
> > +			enable-active-high;
> >  			gpio = <&gpio0 21 GPIO_ACTIVE_HIGH>;
> >  		};
> >  	};
> 
> This makes sense as a general cleanup. Please submit as a separate
> patch, but as i said above, without the enable-active-high until we
> can test it.
> 
> > diff --git a/arch/arm/boot/dts/kirkwood-nsa320.dts
> > b/arch/arm/boot/dts/kirkwood-nsa320.dts
> > new file mode 100644
> > index 0000000..43f1e1d
> > --- /dev/null
> > +++ b/arch/arm/boot/dts/kirkwood-nsa320.dts
> > @@ -0,0 +1,252 @@
> > +/dts-v1/;
> > +
> > +/* Device tree file for the Zyxel NSA 320 NAS box.
> > +   Based upon the board setup file created by Peter Schildmann */
> 
> Just nice to have, but a copyright notice and license would be
> good. Not all .dts files have them, but i suspect it will become more
> important when these files move out of the kernel and into a repo of
> there own.
> 
> > +
> > +#include "kirkwood-nsa310-common.dtsi"
> > +
> > +/ {
> > +	model = "Zyxel NSA320";
> > +	compatible = "zyxel,nsa320", "marvell,kirkwood-88f6281",
> > "marvell,kirkwood";
> > +
> > +	memory {
> > +		device_type = "memory";
> > +		reg = <0x00000000 0x20000000>;
> > +	};
> > +
> > +	chosen {
> > +		bootargs = "console=ttyS0,115200";
> > +	};
> > +
> > +	mbus {
> > +		pcie-controller {
> > +			status = "okay";
> > +
> > +			pcie at 1,0 {
> > +				status = "okay";
> > +			};
> > +		};
> > +	};
> > +
> > +	ocp at f1000000 {
> > +		pinctrl: pinctrl at 10000 {
> > +			pinctrl-names = "default";
> > +
> > +			/* SATA Activity and Present pins are not connected */
> > +			pmx_sata0: pmx-sata0 {
> > +				marvell,pins ;
> > +				marvell,function = "sata0";
> > +			};
> > +
> > +			pmx_sata1: pmx-sata1 {
> > +				marvell,pins ;
> > +				marvell,function = "sata1";
> > +			};
> > +
> > +			pmx_led_hdd2_green: pmx-led-hdd2-green {
> > +				marvell,pins = "mpp12";
> > +				marvell,function = "gpio";
> > +			};
> > +
> > +			pmx_led_hdd2_red: pmx-led-hdd2-red {
> > +				marvell,pins = "mpp13";
> > +				marvell,function = "gpio";
> > +			};
> > +
> > +			pmx_mcu_data: pmx-mcu-data {
> > +				marvell,pins = "mpp14";
> > +				marvell,function = "gpio";
> > +			};
> > +
> > +			pmx_led_usb_green: pmx-led-usb-green {
> > +				marvell,pins = "mpp15";
> > +				marvell,function = "gpio";
> > +			};
> > +
> > +			pmx_mcu_clk: pmx-mcu-clk {
> > +				marvell,pins = "mpp16";
> > +				marvell,function = "gpio";
> > +			};
> > +
> > +			pmx_mcu_act: pmx-mcu-act {
> > +				marvell,pins = "mpp17";
> > +				marvell,function = "gpio";
> > +			};
> > +
> > +			pmx_led_sys_green: pmx-led-sys-green {
> > +				marvell,pins = "mpp28";
> > +				marvell,function = "gpio";
> > +			};
> > +
> > +			pmx_led_sys_orange: pmx-led-sys-orange {
> > +				marvell,pins = "mpp29";
> > +				marvell,function = "gpio";
> > +			};
> > +
> > +			pmx_btn_reset: pmx-btn-reset {
> > +				marvell,pins = "mpp36";
> > +				marvell,function = "gpio";
> > +			};
> > +
> > +			pmx_btn_copy: pmx-btn-copy {
> > +				marvell,pins = "mpp37";
> > +				marvell,function = "gpio";
> > +			};
> > +
> > +			pmx_led_copy_green: pmx-led-copy-green {
> > +				marvell,pins = "mpp39";
> > +				marvell,function = "gpio";
> > +			};
> > +
> > +			pmx_led_copy_red: pmx-led-copy-red {
> > +				marvell,pins = "mpp40";
> > +				marvell,function = "gpio";
> > +			};
> > +
> > +			pmx_led_hdd1_green: pmx-led-hdd1-green {
> > +				marvell,pins = "mpp41";
> > +				marvell,function = "gpio";
> > +			};
> > +
> > +			pmx_led_hdd1_red: pmx-led-hdd1-red {
> > +				marvell,pins = "mpp42";
> > +				marvell,function = "gpio";
> > +			};
> > +
> > +			pmx_htp: pmx-htp {
> > +				marvell,pins = "mpp43";
> > +				marvell,function = "gpio";
> > +			};
> > +
> > +			pmx_buzzer: pmx-buzzer {
> > +				marvell,pins = "mpp44";
> > +				marvell,function = "gpio";
> > +			};
> > +
> > +			pmx_vid_b1: pmx-vid-b1 {
> > +				marvell,pins = "mpp45";
> > +				marvell,function = "gpio";
> > +			};
> > +
> > +			pmx_btn_power: pmx-btn-power {
> > +				marvell,pins = "mpp46";
> > +				marvell,function = "gpio";
> > +			};
> > +
> > +			pmx_power_resume_data: pmx-power-resume-data {
> > +				marvell,pins = "mpp47";
> > +				marvell,function = "gpio";
> > +			};
> > +
> > +			pmx_power_resume_clk: pmx-power-resume-clk {
> > +				marvell,pins = "mpp49";
> > +				marvell,function = "gpio";
> > +			};
> > +		};
> > +
> > +		i2c at 11000 {
> > +			status = "okay";
> > +
> > +			pcf8563: pcf8563 at 51 {
> > +				compatible = "nxp,pcf8563";
> > +				reg = <0x51>;
> > +			};
> > +		};
> > +	};
> > +
> > +	gpio_keys {
> > +		compatible = "gpio-keys";
> > +		#address-cells = <1>;
> > +		#size-cells = <0>;
> > +		pinctrl-0 = <&pmx_btn_reset &pmx_btn_copy &pmx_btn_power>;
> > +		pinctrl-names = "default";
> > +
> > +		button at 1 {
> > +			label = "Power Button";
> > +			linux,code = <KEY_POWER>;
> > +			gpios = <&gpio1 14 GPIO_ACTIVE_HIGH>;
> > +		};
> > +		button at 2 {
> > +			label = "Copy Button";
> > +			linux,code = <KEY_COPY>;
> > +			gpios = <&gpio1 5 GPIO_ACTIVE_LOW>;
> > +		};
> > +		button at 3 {
> > +			label = "Reset Button";
> > +			linux,code = <KEY_RESTART>;
> > +			gpios = <&gpio1 4 GPIO_ACTIVE_LOW>;
> > +		};
> > +	};
> > +
> > +	gpio-leds {
> > +		compatible = "gpio-leds";
> > +		pinctrl-0 = <&pmx_led_hdd2_green &pmx_led_hdd2_red
> > +			     &pmx_led_usb_green
> > +			     &pmx_led_sys_green &pmx_led_sys_orange
> > +			     &pmx_led_copy_green &pmx_led_copy_red
> > +			     &pmx_led_hdd1_green &pmx_led_hdd1_red
> > +			     &pmx_buzzer>;
> 
> I guess this last one does not belong here. It should be in the beeper
> node below.
> 
> > +		pinctrl-names = "default";
> > +
> > +		green-sys {
> > +			label = "nsa320:green:sys";
> > +			gpios = <&gpio0 28 GPIO_ACTIVE_HIGH>;
> > +		};
> > +		orange-sys {
> > +			label = "nsa320:orange:sys";
> > +			gpios = <&gpio0 29 GPIO_ACTIVE_HIGH>;
> > +		};
> > +		green-hdd1 {
> > +			label = "nsa320:green:hdd1";
> > +			gpios = <&gpio1 9 GPIO_ACTIVE_HIGH>;
> > +		};
> > +		red-hdd1 {
> > +			label = "nsa320:red:hdd1";
> > +			gpios = <&gpio1 10 GPIO_ACTIVE_HIGH>;
> > +		};
> > +		green-hdd2 {
> > +			label = "nsa320:green:hdd2";
> > +			gpios = <&gpio0 12 GPIO_ACTIVE_HIGH>;
> > +		};
> > +		red-hdd2 {
> > +			label = "nsa320:red:hdd2";
> > +			gpios = <&gpio0 13 GPIO_ACTIVE_HIGH>;
> > +		};
> > +		green-usb {
> > +			label = "nsa320:green:usb";
> > +			gpios = <&gpio0 15 GPIO_ACTIVE_HIGH>;
> > +		};
> > +		green-copy {
> > +			label = "nsa320:green:copy";
> > +			gpios = <&gpio1 7 GPIO_ACTIVE_HIGH>;
> > +		};
> > +		red-copy {
> > +			label = "nsa320:red:copy";
> > +			gpios = <&gpio1 8 GPIO_ACTIVE_HIGH>;
> > +		};
> > +	};
> > +	beeper: beeper {
> > +		compatible = "gpio-beeper";
> > +		gpios = <&gpio1 12 GPIO_ACTIVE_HIGH>;
> > +	};
> > +
> > +	/* The following pins are currently not assigned to a driver,
> > +	   some of them should be configured as inputs.
> > +	pinctrl-0 = <&pmx_mcu_data &pmx_mcu_clk &pmx_mcu_act
> > +		     &pmx_htp &pmx_vid_b1
> > +		     &pmx_power_resume_data &pmx_power_resume_clk>; */
> 
> These will become your pin hogs.
> 
> > +};
> > +
> > +&mdio {
> > +	status = "okay";
> > +	ethphy0: ethernet-phy at 1 {
> > +		reg = <1>;
> > +	};
> > +};
> > +
> > +&eth0 {
> > +	status = "okay";
> > +	ethernet0-port at 0 {
> > +		phy-handle = <&ethphy0>;
> > +	};
> > +};
> > 
> 
> Looking good otherwise.
> 
> 	Andrew
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* mvebu: Kirkwood: Device Tree file for Zyxel NSA320
  2014-03-26  1:06       ` Jason Cooper
@ 2014-03-26 23:07         ` Adam Baker
  2014-03-28 17:45           ` Andrew Lunn
  0 siblings, 1 reply; 7+ messages in thread
From: Adam Baker @ 2014-03-26 23:07 UTC (permalink / raw)
  To: linux-arm-kernel

On 26/03/14 01:06, Jason Cooper wrote:
> Adam,
> 
> Any progress on this?
> 
> thx,
> 
> Jason.

I think it's about ready, I'm just trying to find time to tidy it up to
post properly. My current thinking is that it should be split into 3 patches

1 - Move some things that are common to both nsa310, nsa310a and nsa320 into
    kirkwood-nsa310-common.dtsi
2 - add the dts for nsa320
3 - rename kirkwood-nsa310-common.dtsi to kirkwood-nsa3x0-common.dtsi (I suspect
    the nsa325 is sufficiently different to not share this file). I suggest
    making this change last as it can easily be dropped till later if it causes
    conflicts.

Current diff for changes 1 & 2 is below in case anyone wants to make any further
comments.

Other than splitting into separate patches I'm now happy with this so

Signed-off-by: Adam Baker <linux@baker-net.org.uk>

----

diff --git a/arch/arm/boot/dts/kirkwood-nsa310-common.dtsi b/arch/arm/boot/dts/kirkwood-nsa310-common.dtsi
index aa78c2d..843b8b5 100644
--- a/arch/arm/boot/dts/kirkwood-nsa310-common.dtsi
+++ b/arch/arm/boot/dts/kirkwood-nsa310-common.dtsi
@@ -7,15 +7,40 @@
 	ocp at f1000000 {
 		pinctrl: pinctrl at 10000 {
 
-			pmx_usb_power_off: pmx-usb-power-off {
+			pmx_usb_power: pmx-usb-power {
 				marvell,pins = "mpp21";
 				marvell,function = "gpio";
 			};
+
 			pmx_pwr_off: pmx-pwr-off {
 				marvell,pins = "mpp48";
 				marvell,function = "gpio";
 			};
 
+			pmx_btn_reset: pmx-btn-reset {
+				marvell,pins = "mpp36";
+				marvell,function = "gpio";
+			};
+
+			pmx_btn_copy: pmx-btn-copy {
+				marvell,pins = "mpp37";
+				marvell,function = "gpio";
+			};
+
+			pmx_btn_power: pmx-btn-power {
+				marvell,pins = "mpp46";
+				marvell,function = "gpio";
+			};
+
+			pmx_led_copy_green: pmx-led-copy-green {
+				marvell,pins = "mpp39";
+				marvell,function = "gpio";
+			};
+
+			pmx_led_copy_red: pmx-led-copy-red {
+				marvell,pins = "mpp40";
+				marvell,function = "gpio";
+			};
 		};
 
 		serial at 12000 {
@@ -43,17 +68,42 @@
 		gpios = <&gpio1 16 GPIO_ACTIVE_HIGH>;
 	};
 
+	gpio_keys {
+		compatible = "gpio-keys";
+		#address-cells = <1>;
+		#size-cells = <0>;
+		pinctrl-0 = <&pmx_btn_reset &pmx_btn_copy &pmx_btn_power>;
+		pinctrl-names = "default";
+
+		button at 1 {
+			label = "Power Button";
+			linux,code = <KEY_POWER>;
+			gpios = <&gpio1 14 GPIO_ACTIVE_HIGH>;
+		};
+		button at 2 {
+			label = "Copy Button";
+			linux,code = <KEY_COPY>;
+			gpios = <&gpio1 5 GPIO_ACTIVE_LOW>;
+		};
+		button at 3 {
+			label = "Reset Button";
+			linux,code = <KEY_RESTART>;
+			gpios = <&gpio1 4 GPIO_ACTIVE_LOW>;
+		};
+	};
+
+
 	regulators {
 		compatible = "simple-bus";
 		#address-cells = <1>;
 		#size-cells = <0>;
-		pinctrl-0 = <&pmx_usb_power_off>;
+		pinctrl-0 = <&pmx_usb_power>;
 		pinctrl-names = "default";
 
-		usb0_power_off: regulator at 1 {
+		usb0_power: regulator at 1 {
 			compatible = "regulator-fixed";
 			reg = <1>;
-			regulator-name = "USB Power Off";
+			regulator-name = "USB Power";
 			regulator-min-microvolt = <5000000>;
 			regulator-max-microvolt = <5000000>;
 			regulator-always-on;
diff --git a/arch/arm/boot/dts/kirkwood-nsa310.dts b/arch/arm/boot/dts/kirkwood-nsa310.dts
index 03fa24c..372f701 100644
--- a/arch/arm/boot/dts/kirkwood-nsa310.dts
+++ b/arch/arm/boot/dts/kirkwood-nsa310.dts
@@ -59,26 +59,6 @@
 				marvell,function = "gpio";
 			};
 
-			pmx_btn_reset: pmx-btn-reset {
-				marvell,pins = "mpp36";
-				marvell,function = "gpio";
-			};
-
-			pmx_btn_copy: pmx-btn-copy {
-				marvell,pins = "mpp37";
-				marvell,function = "gpio";
-			};
-
-			pmx_led_copy_green: pmx-led-copy-green {
-				marvell,pins = "mpp39";
-				marvell,function = "gpio";
-			};
-
-			pmx_led_copy_red: pmx-led-copy-red {
-				marvell,pins = "mpp40";
-				marvell,function = "gpio";
-			};
-
 			pmx_led_hdd_green: pmx-led-hdd-green {
 				marvell,pins = "mpp41";
 				marvell,function = "gpio";
@@ -94,10 +74,6 @@
 				marvell,function = "gpio";
 			};
 
-			pmx_btn_power: pmx-btn-power {
-				marvell,pins = "mpp46";
-				marvell,function = "gpio";
-			};
 		};
 
 		i2c at 11000 {
@@ -110,30 +86,6 @@
 		};
 	};
 
-	gpio_keys {
-		compatible = "gpio-keys";
-		#address-cells = <1>;
-		#size-cells = <0>;
-		pinctrl-0 = <&pmx_btn_reset &pmx_btn_copy &pmx_btn_power>;
-		pinctrl-names = "default";
-
-		button at 1 {
-			label = "Power Button";
-			linux,code = <KEY_POWER>;
-			gpios = <&gpio1 14 GPIO_ACTIVE_HIGH>;
-		};
-		button at 2 {
-			label = "Copy Button";
-			linux,code = <KEY_COPY>;
-			gpios = <&gpio1 5 GPIO_ACTIVE_LOW>;
-		};
-		button at 3 {
-			label = "Reset Button";
-			linux,code = <KEY_RESTART>;
-			gpios = <&gpio1 4 GPIO_ACTIVE_LOW>;
-		};
-	};
-
 	gpio-leds {
 		compatible = "gpio-leds";
 		pinctrl-0 = <&pmx_led_esata_green &pmx_led_esata_red
diff --git a/arch/arm/boot/dts/kirkwood-nsa310a.dts b/arch/arm/boot/dts/kirkwood-nsa310a.dts
index a5e7794..ead7a36 100644
--- a/arch/arm/boot/dts/kirkwood-nsa310a.dts
+++ b/arch/arm/boot/dts/kirkwood-nsa310a.dts
@@ -38,11 +38,6 @@
 				marvell,function = "gpio";
 			};
 
-			pmx_usb_power_off: pmx-usb-power-off {
-				marvell,pins = "mpp21";
-				marvell,function = "gpio";
-			};
-
 			pmx_led_sys_green: pmx-led-sys-green {
 				marvell,pins = "mpp28";
 				marvell,function = "gpio";
@@ -53,26 +48,6 @@
 				marvell,function = "gpio";
 			};
 
-			pmx_btn_reset: pmx-btn-reset {
-				marvell,pins = "mpp36";
-				marvell,function = "gpio";
-			};
-
-			pmx_btn_copy: pmx-btn-copy {
-				marvell,pins = "mpp37";
-				marvell,function = "gpio";
-			};
-
-			pmx_led_copy_green: pmx-led-copy-green {
-				marvell,pins = "mpp39";
-				marvell,function = "gpio";
-			};
-
-			pmx_led_copy_red: pmx-led-copy-red {
-				marvell,pins = "mpp40";
-				marvell,function = "gpio";
-			};
-
 			pmx_led_hdd_green: pmx-led-hdd-green {
 				marvell,pins = "mpp41";
 				marvell,function = "gpio";
@@ -83,11 +58,6 @@
 				marvell,function = "gpio";
 			};
 
-			pmx_btn_power: pmx-btn-power {
-				marvell,pins = "mpp46";
-				marvell,function = "gpio";
-			};
-
 		};
 
 		i2c@11000 {
@@ -100,28 +70,6 @@
 		};
 	};
 
-	gpio_keys {
-		compatible = "gpio-keys";
-		#address-cells = <1>;
-		#size-cells = <0>;
-
-		button at 1 {
-			label = "Power Button";
-			linux,code = <KEY_POWER>;
-			gpios = <&gpio1 14 GPIO_ACTIVE_HIGH>;
-		};
-		button at 2 {
-			label = "Copy Button";
-			linux,code = <KEY_COPY>;
-			gpios = <&gpio1 5 GPIO_ACTIVE_LOW>;
-		};
-		button at 3 {
-			label = "Reset Button";
-			linux,code = <KEY_RESTART>;
-			gpios = <&gpio1 4 GPIO_ACTIVE_LOW>;
-		};
-	};
-
 	gpio-leds {
 		compatible = "gpio-leds";
 
diff --git a/arch/arm/boot/dts/kirkwood-nsa320.dts b/arch/arm/boot/dts/kirkwood-nsa320.dts
new file mode 100644
index 0000000..6c8f692
--- /dev/null
+++ b/arch/arm/boot/dts/kirkwood-nsa320.dts
@@ -0,0 +1,214 @@
+/* Device tree file for the Zyxel NSA 320 NAS box.
+ *
+ * Copyright (c) 2014, Adam Baker <linux@baker-net.org.uk>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ *
+ * Based upon the board setup file created by Peter Schildmann */
+
+/dts-v1/;
+
+#include "kirkwood-nsa310-common.dtsi"
+
+/ {
+	model = "Zyxel NSA320";
+	compatible = "zyxel,nsa320", "marvell,kirkwood-88f6281", "marvell,kirkwood";
+
+	memory {
+		device_type = "memory";
+		reg = <0x00000000 0x20000000>;
+	};
+
+	chosen {
+		bootargs = "console=ttyS0,115200";
+	};
+
+	mbus {
+		pcie-controller {
+			status = "okay";
+
+			pcie at 1,0 {
+				status = "okay";
+			};
+		};
+	};
+
+	ocp at f1000000 {
+		pinctrl: pinctrl at 10000 {
+			pinctrl-names = "default";
+
+			/* SATA Activity and Present pins are not connected */
+			pmx_sata0: pmx-sata0 {
+				marvell,pins ;
+				marvell,function = "sata0";
+			};
+
+			pmx_sata1: pmx-sata1 {
+				marvell,pins ;
+				marvell,function = "sata1";
+			};
+
+			pmx_led_hdd2_green: pmx-led-hdd2-green {
+				marvell,pins = "mpp12";
+				marvell,function = "gpio";
+			};
+
+			pmx_led_hdd2_red: pmx-led-hdd2-red {
+				marvell,pins = "mpp13";
+				marvell,function = "gpio";
+			};
+
+			pmx_mcu_data: pmx-mcu-data {
+				marvell,pins = "mpp14";
+				marvell,function = "gpio";
+			};
+
+			pmx_led_usb_green: pmx-led-usb-green {
+				marvell,pins = "mpp15";
+				marvell,function = "gpio";
+			};
+
+			pmx_mcu_clk: pmx-mcu-clk {
+				marvell,pins = "mpp16";
+				marvell,function = "gpio";
+			};
+
+			pmx_mcu_act: pmx-mcu-act {
+				marvell,pins = "mpp17";
+				marvell,function = "gpio";
+			};
+
+			pmx_led_sys_green: pmx-led-sys-green {
+				marvell,pins = "mpp28";
+				marvell,function = "gpio";
+			};
+
+			pmx_led_sys_orange: pmx-led-sys-orange {
+				marvell,pins = "mpp29";
+				marvell,function = "gpio";
+			};
+
+			pmx_led_hdd1_green: pmx-led-hdd1-green {
+				marvell,pins = "mpp41";
+				marvell,function = "gpio";
+			};
+
+			pmx_led_hdd1_red: pmx-led-hdd1-red {
+				marvell,pins = "mpp42";
+				marvell,function = "gpio";
+			};
+
+			pmx_htp: pmx-htp {
+				marvell,pins = "mpp43";
+				marvell,function = "gpio";
+			};
+
+			/* Buzzer needs to be switched at around 1kHz so is
+			   not compatible with the gpio-beeper driver. */
+			pmx_buzzer: pmx-buzzer {
+				marvell,pins = "mpp44";
+				marvell,function = "gpio";
+			};
+
+			pmx_vid_b1: pmx-vid-b1 {
+				marvell,pins = "mpp45";
+				marvell,function = "gpio";
+			};
+
+			pmx_power_resume_data: pmx-power-resume-data {
+				marvell,pins = "mpp47";
+				marvell,function = "gpio";
+			};
+
+			pmx_power_resume_clk: pmx-power-resume-clk {
+				marvell,pins = "mpp49";
+				marvell,function = "gpio";
+			};
+		};
+
+		i2c at 11000 {
+			status = "okay";
+
+			pcf8563: pcf8563 at 51 {
+				compatible = "nxp,pcf8563";
+				reg = <0x51>;
+			};
+		};
+	};
+
+	regulators {
+		usb0_power: regulator at 1 {
+			enable-active-high;
+		};
+	};
+
+	gpio-leds {
+		compatible = "gpio-leds";
+		pinctrl-0 = <&pmx_led_hdd2_green &pmx_led_hdd2_red
+			     &pmx_led_usb_green
+			     &pmx_led_sys_green &pmx_led_sys_orange
+			     &pmx_led_copy_green &pmx_led_copy_red
+			     &pmx_led_hdd1_green &pmx_led_hdd1_red>;
+		pinctrl-names = "default";
+
+		green-sys {
+			label = "nsa320:green:sys";
+			gpios = <&gpio0 28 GPIO_ACTIVE_HIGH>;
+		};
+		orange-sys {
+			label = "nsa320:orange:sys";
+			gpios = <&gpio0 29 GPIO_ACTIVE_HIGH>;
+		};
+		green-hdd1 {
+			label = "nsa320:green:hdd1";
+			gpios = <&gpio1 9 GPIO_ACTIVE_HIGH>;
+		};
+		red-hdd1 {
+			label = "nsa320:red:hdd1";
+			gpios = <&gpio1 10 GPIO_ACTIVE_HIGH>;
+		};
+		green-hdd2 {
+			label = "nsa320:green:hdd2";
+			gpios = <&gpio0 12 GPIO_ACTIVE_HIGH>;
+		};
+		red-hdd2 {
+			label = "nsa320:red:hdd2";
+			gpios = <&gpio0 13 GPIO_ACTIVE_HIGH>;
+		};
+		green-usb {
+			label = "nsa320:green:usb";
+			gpios = <&gpio0 15 GPIO_ACTIVE_HIGH>;
+		};
+		green-copy {
+			label = "nsa320:green:copy";
+			gpios = <&gpio1 7 GPIO_ACTIVE_HIGH>;
+		};
+		red-copy {
+			label = "nsa320:red:copy";
+			gpios = <&gpio1 8 GPIO_ACTIVE_HIGH>;
+		};
+	};
+
+	/* The following pins are currently not assigned to a driver,
+	   some of them should be configured as inputs.
+	pinctrl-0 = <&pmx_mcu_data &pmx_mcu_clk &pmx_mcu_act
+		     &pmx_htp &pmx_vid_b1
+		     &pmx_power_resume_data &pmx_power_resume_clk>; */
+};
+
+&mdio {
+	status = "okay";
+	ethphy0: ethernet-phy at 1 {
+		reg = <1>;
+	};
+};
+
+&eth0 {
+	status = "okay";
+	ethernet0-port at 0 {
+		phy-handle = <&ethphy0>;
+	};
+};

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* mvebu: Kirkwood: Device Tree file for Zyxel NSA320
  2014-03-26 23:07         ` mvebu: Kirkwood: " Adam Baker
@ 2014-03-28 17:45           ` Andrew Lunn
  0 siblings, 0 replies; 7+ messages in thread
From: Andrew Lunn @ 2014-03-28 17:45 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Mar 26, 2014 at 11:07:09PM +0000, Adam Baker wrote:
> On 26/03/14 01:06, Jason Cooper wrote:
> > Adam,
> > 
> > Any progress on this?
> > 
> > thx,
> > 
> > Jason.
> 
> I think it's about ready, I'm just trying to find time to tidy it up to
> post properly. My current thinking is that it should be split into 3 patches
> 
> 1 - Move some things that are common to both nsa310, nsa310a and nsa320 into
>     kirkwood-nsa310-common.dtsi
> 2 - add the dts for nsa320
> 3 - rename kirkwood-nsa310-common.dtsi to kirkwood-nsa3x0-common.dtsi (I suspect
>     the nsa325 is sufficiently different to not share this file). I suggest
>     making this change last as it can easily be dropped till later if it causes
>     conflicts.
> 
> Current diff for changes 1 & 2 is below in case anyone wants to make any further
> comments.

Hi Adam

I took a quick look. Everything looks O.K. Shame the buzzer does not
work via a simple GPIO.

     Andrew

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-03-28 17:45 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-01  0:40 Device Tree file for Zyxel NSA320 Adam Baker
2014-03-01 10:34 ` Andrew Lunn
2014-03-02 23:44   ` Adam Baker
2014-03-03  9:41     ` Andrew Lunn
2014-03-26  1:06       ` Jason Cooper
2014-03-26 23:07         ` mvebu: Kirkwood: " Adam Baker
2014-03-28 17:45           ` Andrew Lunn

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.