diff mbox

[3/3] ARM: dts: bcm2835: Add Raspberry Pi Zero W

Message ID 1500579429-9101-4-git-send-email-stefan.wahren@i2se.com (mailing list archive)
State New, archived
Headers show

Commit Message

Stefan Wahren July 20, 2017, 7:37 p.m. UTC
The Raspberry Pi Zero W has the same components like the Zero plus
a Cypress CYW43438 wireless chip (wifi + bl).

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
---
 arch/arm/boot/dts/Makefile               |  3 +-
 arch/arm/boot/dts/bcm2835-rpi-zero-w.dts | 73 ++++++++++++++++++++++++++++++++
 2 files changed, 75 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/boot/dts/bcm2835-rpi-zero-w.dts

Comments

Eric Anholt July 26, 2017, 8:09 p.m. UTC | #1
Stefan Wahren <stefan.wahren@i2se.com> writes:

> The Raspberry Pi Zero W has the same components like the Zero plus
> a Cypress CYW43438 wireless chip (wifi + bl).

I sent out v2 of the arm64 patch so that hopefully we can get started
merging this.  Couple of comments on a re-read.

> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
> Reviewed-by: Eric Anholt <eric@anholt.net>
> ---
>  arch/arm/boot/dts/Makefile               |  3 +-
>  arch/arm/boot/dts/bcm2835-rpi-zero-w.dts | 73 ++++++++++++++++++++++++++++++++
>  2 files changed, 75 insertions(+), 1 deletion(-)
>  create mode 100644 arch/arm/boot/dts/bcm2835-rpi-zero-w.dts
>
> diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
> index ec60f4f..f3bf9397 100644
> --- a/arch/arm/boot/dts/Makefile
> +++ b/arch/arm/boot/dts/Makefile
> @@ -74,7 +74,8 @@ dtb-$(CONFIG_ARCH_BCM2835) += \
>  	bcm2835-rpi-a-plus.dtb \
>  	bcm2836-rpi-2-b.dtb \
>  	bcm2837-rpi-3-b.dtb \
> -	bcm2835-rpi-zero.dtb
> +	bcm2835-rpi-zero.dtb \
> +	bcm2835-rpi-zero-w.dtb
>  dtb-$(CONFIG_ARCH_BCM_5301X) += \
>  	bcm4708-asus-rt-ac56u.dtb \
>  	bcm4708-asus-rt-ac68u.dtb \
> diff --git a/arch/arm/boot/dts/bcm2835-rpi-zero-w.dts b/arch/arm/boot/dts/bcm2835-rpi-zero-w.dts
> new file mode 100644
> index 0000000..9c6d714
> --- /dev/null
> +++ b/arch/arm/boot/dts/bcm2835-rpi-zero-w.dts
> @@ -0,0 +1,73 @@
> +/*
> + * Copyright (C) 2017 Stefan Wahren <stefan.wahren@i2se.com>
> + *
> + * The code contained herein is licensed under the GNU General Public
> + * License. You may obtain a copy of the GNU General Public License
> + * Version 2 or later at the following locations:
> + *
> + * http://www.opensource.org/licenses/gpl-license.html
> + * http://www.gnu.org/copyleft/gpl.html
> + */
> +
> +/dts-v1/;
> +#include "bcm2835.dtsi"
> +#include "bcm2835-rpi.dtsi"
> +#include "bcm283x-rpi-usb-host.dtsi"
> +
> +/ {
> +	compatible = "raspberrypi,model-zero-w", "brcm,bcm2835";
> +	model = "Raspberry Pi Zero W";
> +
> +	aliases {
> +		uart0 = "/soc/serial@7e201000";
> +		uart1 = "/soc/serial@7e215040";
> +		serial0 = "/soc/serial@7e201000";
> +		serial1 = "/soc/serial@7e215040";
> +	};

Should we have this in the other board DTs?  What does it do?

> +
> +	leds {
> +		act {
> +			gpios = <&gpio 47 GPIO_ACTIVE_HIGH>;
> +		};
> +	};
> +
> +	wifi_pwrseq: wifi-pwrseq {
> +		compatible = "mmc-pwrseq-simple";
> +		pinctrl-names = "default";
> +		pinctrl-0 = <&wl_on>;
> +		reset-gpios = <&gpio 41 GPIO_ACTIVE_LOW>;
> +	};
> +};
> +
> +&gpio {
> +	pinctrl-0 = <&gpioout &alt0>;
> +
> +	wl_on: wl-on {
> +		brcm,pins = <41>;
> +		brcm,function = <BCM2835_FSEL_GPIO_OUT>;
> +	};
> +};

Would you be up for adding gpio-line-names based on the dt-blob.dts?

> +
> +&hdmi {
> +	hpd-gpios = <&gpio 46 GPIO_ACTIVE_LOW>;
> +};
> +
> +&sdhci {
> +	#address-cells = <1>;
> +	#size-cells = <0>;
> +	pinctrl-0 = <&emmc_gpio34 &gpclk2_gpio43>;
> +	mmc-pwrseq = <&wifi_pwrseq>;
> +	non-removable;
> +	status = "okay";
> +
> +	brcmf: wifi@1 {
> +		reg = <1>;
> +		compatible = "brcm,bcm4329-fmac";
> +	};
> +};
> +
> +&uart0 {
> +	pinctrl-names = "default";
> +	pinctrl-0 = <&uart0_gpio14>;
> +	status = "okay";
> +};
> -- 
> 2.7.4
Stefan Wahren July 27, 2017, 11:35 a.m. UTC | #2
Am 26.07.2017 um 22:09 schrieb Eric Anholt:
> Stefan Wahren <stefan.wahren@i2se.com> writes:
>
>> The Raspberry Pi Zero W has the same components like the Zero plus
>> a Cypress CYW43438 wireless chip (wifi + bl).
> I sent out v2 of the arm64 patch so that hopefully we can get started
> merging this.  Couple of comments on a re-read.
>
>> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
>> Reviewed-by: Eric Anholt <eric@anholt.net>
>> ---
>>  arch/arm/boot/dts/Makefile               |  3 +-
>>  arch/arm/boot/dts/bcm2835-rpi-zero-w.dts | 73 ++++++++++++++++++++++++++++++++
>>  2 files changed, 75 insertions(+), 1 deletion(-)
>>  create mode 100644 arch/arm/boot/dts/bcm2835-rpi-zero-w.dts
>>
>> diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
>> index ec60f4f..f3bf9397 100644
>> --- a/arch/arm/boot/dts/Makefile
>> +++ b/arch/arm/boot/dts/Makefile
>> @@ -74,7 +74,8 @@ dtb-$(CONFIG_ARCH_BCM2835) += \
>>  	bcm2835-rpi-a-plus.dtb \
>>  	bcm2836-rpi-2-b.dtb \
>>  	bcm2837-rpi-3-b.dtb \
>> -	bcm2835-rpi-zero.dtb
>> +	bcm2835-rpi-zero.dtb \
>> +	bcm2835-rpi-zero-w.dtb
>>  dtb-$(CONFIG_ARCH_BCM_5301X) += \
>>  	bcm4708-asus-rt-ac56u.dtb \
>>  	bcm4708-asus-rt-ac68u.dtb \
>> diff --git a/arch/arm/boot/dts/bcm2835-rpi-zero-w.dts b/arch/arm/boot/dts/bcm2835-rpi-zero-w.dts
>> new file mode 100644
>> index 0000000..9c6d714
>> --- /dev/null
>> +++ b/arch/arm/boot/dts/bcm2835-rpi-zero-w.dts
>> @@ -0,0 +1,73 @@
>> +/*
>> + * Copyright (C) 2017 Stefan Wahren <stefan.wahren@i2se.com>
>> + *
>> + * The code contained herein is licensed under the GNU General Public
>> + * License. You may obtain a copy of the GNU General Public License
>> + * Version 2 or later at the following locations:
>> + *
>> + * http://www.opensource.org/licenses/gpl-license.html
>> + * http://www.gnu.org/copyleft/gpl.html
>> + */
>> +
>> +/dts-v1/;
>> +#include "bcm2835.dtsi"
>> +#include "bcm2835-rpi.dtsi"
>> +#include "bcm283x-rpi-usb-host.dtsi"
>> +
>> +/ {
>> +	compatible = "raspberrypi,model-zero-w", "brcm,bcm2835";
>> +	model = "Raspberry Pi Zero W";
>> +
>> +	aliases {
>> +		uart0 = "/soc/serial@7e201000";
>> +		uart1 = "/soc/serial@7e215040";
>> +		serial0 = "/soc/serial@7e201000";
>> +		serial1 = "/soc/serial@7e215040";
>> +	};
> Should we have this in the other board DTs?  What does it do?

This was the hardest part to make the Zero W useable. I took it from
downstream [1], because without it i don't see anything on debug UART
(config.txt already has enable_uart=1).

I could add a helpful comment, but i can't explain why it's necessary
for RPI Zero W and not for the older RPI Zero.

Maybe the foundation guys have an alternative solution or at least
explanation.

[1] -
https://github.com/raspberrypi/linux/blob/rpi-4.9.y/arch/arm/boot/dts/bcm2708-rpi.dtsi
[2] -
https://github.com/raspberrypi/linux/blob/rpi-4.9.y/arch/arm/boot/dts/overlays/pi3-disable-bt-overlay.dts

>
>> +
>> +	leds {
>> +		act {
>> +			gpios = <&gpio 47 GPIO_ACTIVE_HIGH>;
>> +		};
>> +	};
>> +
>> +	wifi_pwrseq: wifi-pwrseq {
>> +		compatible = "mmc-pwrseq-simple";
>> +		pinctrl-names = "default";
>> +		pinctrl-0 = <&wl_on>;
>> +		reset-gpios = <&gpio 41 GPIO_ACTIVE_LOW>;
>> +	};
>> +};
>> +
>> +&gpio {
>> +	pinctrl-0 = <&gpioout &alt0>;
>> +
>> +	wl_on: wl-on {
>> +		brcm,pins = <41>;
>> +		brcm,function = <BCM2835_FSEL_GPIO_OUT>;
>> +	};
>> +};
> Would you be up for adding gpio-line-names based on the dt-blob.dts?

Sure

>
>> +
>> +&hdmi {
>> +	hpd-gpios = <&gpio 46 GPIO_ACTIVE_LOW>;
>> +};
>> +
>> +&sdhci {
>> +	#address-cells = <1>;
>> +	#size-cells = <0>;
>> +	pinctrl-0 = <&emmc_gpio34 &gpclk2_gpio43>;
>> +	mmc-pwrseq = <&wifi_pwrseq>;
>> +	non-removable;
>> +	status = "okay";
>> +
>> +	brcmf: wifi@1 {
>> +		reg = <1>;
>> +		compatible = "brcm,bcm4329-fmac";
>> +	};
>> +};
>> +
>> +&uart0 {
>> +	pinctrl-names = "default";
>> +	pinctrl-0 = <&uart0_gpio14>;
>> +	status = "okay";
>> +};
>> -- 
>> 2.7.4
>>
>>
>> _______________________________________________
>> linux-arm-kernel mailing list
>> linux-arm-kernel@lists.infradead.org
>> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Stefan Wahren July 27, 2017, 6:41 p.m. UTC | #3
> Stefan Wahren <stefan.wahren@i2se.com> hat am 27. Juli 2017 um 13:35 geschrieben:
> 
> 
> Am 26.07.2017 um 22:09 schrieb Eric Anholt:
> > Stefan Wahren <stefan.wahren@i2se.com> writes:
> >
> >> +/dts-v1/;
> >> +#include "bcm2835.dtsi"
> >> +#include "bcm2835-rpi.dtsi"
> >> +#include "bcm283x-rpi-usb-host.dtsi"
> >> +
> >> +/ {
> >> +	compatible = "raspberrypi,model-zero-w", "brcm,bcm2835";
> >> +	model = "Raspberry Pi Zero W";
> >> +
> >> +	aliases {
> >> +		uart0 = "/soc/serial@7e201000";
> >> +		uart1 = "/soc/serial@7e215040";
> >> +		serial0 = "/soc/serial@7e201000";
> >> +		serial1 = "/soc/serial@7e215040";
> >> +	};
> > Should we have this in the other board DTs?  What does it do?
> 
> This was the hardest part to make the Zero W useable. I took it from
> downstream [1], because without it i don't see anything on debug UART
> (config.txt already has enable_uart=1).
> 
> I could add a helpful comment, but i can't explain why it's necessary
> for RPI Zero W and not for the older RPI Zero.
> 
> Maybe the foundation guys have an alternative solution or at least
> explanation.
> 

Here is Phil Elwell's explanation (he couldn't reply via plain text today):

Serial port usage became an issue with the release of the Pi 3. The good
UART (uart0, ttyAMA0, pl011) was required to drive the Bluetooth modem,
leaving the "mini-UART" (uart1, ttyS0, AUX UART, 8250), with limited
capabilities and even smaller FIFOs, available for a console and other
uses. However, not all users want to use Bluetooth, and some need the
better UART for other purposes.

For some reason (possibly clock related) the firmware initialises a UART
for the OS to use - I believe UBoot makes use of it. If the roles are no
longer fixed there has to be a way to tell the firmware which UART to
initialise. This is particularly important using ttyS0 because the VPU
clock has to be fixed to avoid data corruption due to baud rate changes.

At the same time, we have always tried to make it possible to use the same
SD card in any Pi, so we wanted a way to abstract away the differences in
serial port usage. I couldn't find a standard mechanism to give serial
ports in Linux arbitrary names or numbers to insulate userland from the
hardware specifics, so I added the /dev/serial<n> symbolic links.

I was trying to move away from a proliferation of config.txt settings and
make device tree the communication mechanism between user, firmware and
kernel, so I chose to use DT aliases to declare the name-to-UART mapping -
it seemed like a nice fit. Overlays can change them, and the firmware,
kernel and userspace scripts can read them. For example, a udev rule
creates the symbolic links during the boot process based on the contents of
/proc/device-tree/aliases, and the firmware rewrites the kernel command
line, replacing the aliases with the appropriate device name.

On the firmware side we added one new setting - enable_uart - which
defaults to 1 unless the mini-UART is the primary (console) UART, in which
case it must be explicitly set to 1 in config.txt in order for the UART
(and GPIO pins) to be configured. This difference is because most users
will never use the serial ports, and the need for a constant baud rate
makes it necessary to lock the VPU core frequency to 250MHz which could be
seen as a performance penalty.

To answer the question you originally asked, the aliases are needed on a
Zero W (just as on a Pi 3) because by default it uses ttyS0 for Bluetooth,
but the firmware doesn't know this unless the DT tells it so via the
aliases. Otherwise it behaves like all Pis before the 3 and puts the
console on ttyAMA0.
diff mbox

Patch

diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index ec60f4f..f3bf9397 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -74,7 +74,8 @@  dtb-$(CONFIG_ARCH_BCM2835) += \
 	bcm2835-rpi-a-plus.dtb \
 	bcm2836-rpi-2-b.dtb \
 	bcm2837-rpi-3-b.dtb \
-	bcm2835-rpi-zero.dtb
+	bcm2835-rpi-zero.dtb \
+	bcm2835-rpi-zero-w.dtb
 dtb-$(CONFIG_ARCH_BCM_5301X) += \
 	bcm4708-asus-rt-ac56u.dtb \
 	bcm4708-asus-rt-ac68u.dtb \
diff --git a/arch/arm/boot/dts/bcm2835-rpi-zero-w.dts b/arch/arm/boot/dts/bcm2835-rpi-zero-w.dts
new file mode 100644
index 0000000..9c6d714
--- /dev/null
+++ b/arch/arm/boot/dts/bcm2835-rpi-zero-w.dts
@@ -0,0 +1,73 @@ 
+/*
+ * Copyright (C) 2017 Stefan Wahren <stefan.wahren@i2se.com>
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+/dts-v1/;
+#include "bcm2835.dtsi"
+#include "bcm2835-rpi.dtsi"
+#include "bcm283x-rpi-usb-host.dtsi"
+
+/ {
+	compatible = "raspberrypi,model-zero-w", "brcm,bcm2835";
+	model = "Raspberry Pi Zero W";
+
+	aliases {
+		uart0 = "/soc/serial@7e201000";
+		uart1 = "/soc/serial@7e215040";
+		serial0 = "/soc/serial@7e201000";
+		serial1 = "/soc/serial@7e215040";
+	};
+
+	leds {
+		act {
+			gpios = <&gpio 47 GPIO_ACTIVE_HIGH>;
+		};
+	};
+
+	wifi_pwrseq: wifi-pwrseq {
+		compatible = "mmc-pwrseq-simple";
+		pinctrl-names = "default";
+		pinctrl-0 = <&wl_on>;
+		reset-gpios = <&gpio 41 GPIO_ACTIVE_LOW>;
+	};
+};
+
+&gpio {
+	pinctrl-0 = <&gpioout &alt0>;
+
+	wl_on: wl-on {
+		brcm,pins = <41>;
+		brcm,function = <BCM2835_FSEL_GPIO_OUT>;
+	};
+};
+
+&hdmi {
+	hpd-gpios = <&gpio 46 GPIO_ACTIVE_LOW>;
+};
+
+&sdhci {
+	#address-cells = <1>;
+	#size-cells = <0>;
+	pinctrl-0 = <&emmc_gpio34 &gpclk2_gpio43>;
+	mmc-pwrseq = <&wifi_pwrseq>;
+	non-removable;
+	status = "okay";
+
+	brcmf: wifi@1 {
+		reg = <1>;
+		compatible = "brcm,bcm4329-fmac";
+	};
+};
+
+&uart0 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&uart0_gpio14>;
+	status = "okay";
+};