[6/6] sunxi: Add initial Banana-Pi Zero support

Message ID 1515137821-30583-7-git-send-email-jun.nie@linaro.org
State New
Headers show
Series
  • Add Bananapi Zero board with OTG supported
Related show

Commit Message

Jun Nie Jan. 5, 2018, 7:37 a.m.
Banana-Pi Zero is designed for IOT development
using the Allwinner H2+ SOC.

Key features
- Allwinner H2+, Quad-core Cortex-A7
- 512MB DRAM
- microSD slot
- Serial Debug Port
- Combo WiFi/BT
- HDMI

Signed-off-by: Jun Nie <jun.nie@linaro.org>
---
 arch/arm/dts/Makefile                           |   1 +
 arch/arm/dts/sun8i-h2-plus-bananapi-m2-zero.dts | 113 ++++++++++++++++++++++++
 configs/bananapi_zero_defconfig                 |  17 ++++
 3 files changed, 131 insertions(+)
 create mode 100644 arch/arm/dts/sun8i-h2-plus-bananapi-m2-zero.dts
 create mode 100644 configs/bananapi_zero_defconfig

Comments

Maxime Ripard Jan. 5, 2018, 8:35 a.m. | #1
Hi Jun,

On Fri, Jan 05, 2018 at 03:37:01PM +0800, Jun Nie wrote:
> Banana-Pi Zero is designed for IOT development

> using the Allwinner H2+ SOC.

> 

> Key features

> - Allwinner H2+, Quad-core Cortex-A7

> - 512MB DRAM

> - microSD slot

> - Serial Debug Port

> - Combo WiFi/BT

> - HDMI

> 

> Signed-off-by: Jun Nie <jun.nie@linaro.org>

> ---

>  arch/arm/dts/Makefile                           |   1 +

>  arch/arm/dts/sun8i-h2-plus-bananapi-m2-zero.dts | 113 ++++++++++++++++++++++++

>  configs/bananapi_zero_defconfig                 |  17 ++++

>  3 files changed, 131 insertions(+)

>  create mode 100644 arch/arm/dts/sun8i-h2-plus-bananapi-m2-zero.dts

>  create mode 100644 configs/bananapi_zero_defconfig

> 

> diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile

> index a895c70..80eec7e 100644

> --- a/arch/arm/dts/Makefile

> +++ b/arch/arm/dts/Makefile

> @@ -327,6 +327,7 @@ dtb-$(CONFIG_MACH_SUN8I_A83T) += \

>  	sun8i-a83t-cubietruck-plus.dtb \

>  	sun8i-a83t-tbs-a711.dts

>  dtb-$(CONFIG_MACH_SUN8I_H3) += \

> +	sun8i-h2-plus-bananapi-m2-zero.dtb \

>  	sun8i-h2-plus-orangepi-zero.dtb \

>  	sun8i-h3-bananapi-m2-plus.dtb \

>  	sun8i-h3-orangepi-2.dtb \

> diff --git a/arch/arm/dts/sun8i-h2-plus-bananapi-m2-zero.dts b/arch/arm/dts/sun8i-h2-plus-bananapi-m2-zero.dts

> new file mode 100644

> index 0000000..4d96c16

> --- /dev/null

> +++ b/arch/arm/dts/sun8i-h2-plus-bananapi-m2-zero.dts

> @@ -0,0 +1,113 @@

> +/*

> + * Copyright (C) 2017 Jun Nie <jun.nie@linaro.org>

> + *

> + * This file is dual-licensed: you can use it either under the terms

> + * of the GPL or the X11 license, at your option. Note that this dual

> + * licensing only applies to this file, and not this project as a

> + * whole.

> + *

> + *  a) This file 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.

> + *

> + *     This file is distributed in the hope that it will be useful,

> + *     but WITHOUT ANY WARRANTY; without even the implied warranty of

> + *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

> + *     GNU General Public License for more details.

> + *

> + * Or, alternatively,

> + *

> + *  b) Permission is hereby granted, free of charge, to any person

> + *     obtaining a copy of this software and associated documentation

> + *     files (the "Software"), to deal in the Software without

> + *     restriction, including without limitation the rights to use,

> + *     copy, modify, merge, publish, distribute, sublicense, and/or

> + *     sell copies of the Software, and to permit persons to whom the

> + *     Software is furnished to do so, subject to the following

> + *     conditions:

> + *

> + *     The above copyright notice and this permission notice shall be

> + *     included in all copies or substantial portions of the Software.

> + *

> + *     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,

> + *     EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES

> + *     OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND

> + *     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT

> + *     HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,

> + *     WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

> + *     FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR

> + *     OTHER DEALINGS IN THE SOFTWARE.

> + */

> +

> +/dts-v1/;

> +#include "sun8i-h3.dtsi"

> +#include "sunxi-common-regulators.dtsi"

> +

> +#include <dt-bindings/gpio/gpio.h>

> +#include <dt-bindings/input/input.h>


Where is that DT coming from?

Usually, we'll just merge a DT merged in Linux.

> +/ {

> +	model = "Banana Pi BPI-M2-Zero";

> +	compatible = "sinovoip,bpi-m2-zero", "allwinner,sun8i-h2-plus";

> +

> +	aliases {

> +		serial0 = &uart0;

> +	};

> +

> +	chosen {

> +		stdout-path = "serial0:115200n8";

> +	};

> +

> +	leds {

> +		compatible = "gpio-leds";

> +		pinctrl-names = "default";

> +

> +		pwr_led {

> +			label = "bananapi-m2-zero:red:pwr";

> +			gpios = <&r_pio 0 10 GPIO_ACTIVE_HIGH>; /* PL10 */

> +			default-state = "on";

> +		};

> +	};

> +

> +	gpio_keys {

> +		compatible = "gpio-keys";

> +		pinctrl-names = "default";

> +

> +		sw4 {

> +			label = "power";

> +			linux,code = <BTN_0>;

> +			gpios = <&r_pio 0 3 GPIO_ACTIVE_LOW>;

> +		};

> +	};

> +};

> +

> +&mmc0 {

> +	pinctrl-names = "default";

> +	pinctrl-0 = <&mmc0_pins_a>;

> +	vmmc-supply = <&reg_vcc3v3>;

> +	bus-width = <4>;

> +	/*

> +	 * In different revisions the board have different card detect

> +	 * configuration.

> +	 */

> +	broken-cd;

> +	status = "okay";

> +};

> +

> +&uart0 {

> +	pinctrl-names = "default";

> +	pinctrl-0 = <&uart0_pins_a>;

> +	status = "okay";

> +};

> +

> +&usb_otg {

> +	dr_mode = "otg";

> +	status = "okay";

> +};

> +

> +&usbphy {

> +	usb0_id_det-gpios = <&r_pio 0 6 GPIO_ACTIVE_HIGH>; /* PL6 */

> +	/* USB OTG VBUS is directly connected to 5V without any regulators */


Then it cannot really do OTG, but rather only peripheral (or host, if
the power is provided by the board).

> +	status = "okay";

> +};

> diff --git a/configs/bananapi_zero_defconfig b/configs/bananapi_zero_defconfig

> new file mode 100644

> index 0000000..9c78b21

> --- /dev/null

> +++ b/configs/bananapi_zero_defconfig

> @@ -0,0 +1,17 @@

> +CONFIG_ARM=y

> +CONFIG_ARCH_SUNXI=y

> +CONFIG_MACH_SUN8I_H3=y

> +CONFIG_DRAM_CLK=408

> +CONFIG_DRAM_ZQ=3881979

> +CONFIG_DRAM_ODT_EN=y

> +CONFIG_DEFAULT_DEVICE_TREE="sun8i-h2-plus-bananapi-m2-zero"

> +# CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set

> +CONFIG_SPL=y

> +# CONFIG_CMD_FLASH is not set

> +# CONFIG_CMD_FPGA is not set

> +CONFIG_CMD_USB_MASS_STORAGE=y


This shouldn't be enabled in the defconfig.

The rest of the serie looks good, thanks!
Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
Jun Nie Jan. 5, 2018, 8:51 a.m. | #2
>> +/dts-v1/;
>> +#include "sun8i-h3.dtsi"
>> +#include "sunxi-common-regulators.dtsi"
>> +
>> +#include <dt-bindings/gpio/gpio.h>
>> +#include <dt-bindings/input/input.h>
>
> Where is that DT coming from?
>
> Usually, we'll just merge a DT merged in Linux.

The DT come from Linux but modified with removing necessary nodes.
>
>> +/ {
>> +     model = "Banana Pi BPI-M2-Zero";
>> +     compatible = "sinovoip,bpi-m2-zero", "allwinner,sun8i-h2-plus";
>> +
>> +     aliases {
>> +             serial0 = &uart0;
>> +     };
>> +
>> +     chosen {
>> +             stdout-path = "serial0:115200n8";
>> +     };
>> +
>> +     leds {
>> +             compatible = "gpio-leds";
>> +             pinctrl-names = "default";
>> +
>> +             pwr_led {
>> +                     label = "bananapi-m2-zero:red:pwr";
>> +                     gpios = <&r_pio 0 10 GPIO_ACTIVE_HIGH>; /* PL10 */
>> +                     default-state = "on";
>> +             };
>> +     };
>> +
>> +     gpio_keys {
>> +             compatible = "gpio-keys";
>> +             pinctrl-names = "default";
>> +
>> +             sw4 {
>> +                     label = "power";
>> +                     linux,code = <BTN_0>;
>> +                     gpios = <&r_pio 0 3 GPIO_ACTIVE_LOW>;
>> +             };
>> +     };
>> +};
>> +
>> +&mmc0 {
>> +     pinctrl-names = "default";
>> +     pinctrl-0 = <&mmc0_pins_a>;
>> +     vmmc-supply = <&reg_vcc3v3>;
>> +     bus-width = <4>;
>> +     /*
>> +      * In different revisions the board have different card detect
>> +      * configuration.
>> +      */
>> +     broken-cd;
>> +     status = "okay";
>> +};
>> +
>> +&uart0 {
>> +     pinctrl-names = "default";
>> +     pinctrl-0 = <&uart0_pins_a>;
>> +     status = "okay";
>> +};
>> +
>> +&usb_otg {
>> +     dr_mode = "otg";
>> +     status = "okay";
>> +};
>> +
>> +&usbphy {
>> +     usb0_id_det-gpios = <&r_pio 0 6 GPIO_ACTIVE_HIGH>; /* PL6 */
>> +     /* USB OTG VBUS is directly connected to 5V without any regulators */
>
> Then it cannot really do OTG, but rather only peripheral (or host, if
> the power is provided by the board).

Right, and working mode in u-boot is decided in compile time,
CONFIG_USB_MUSB_HOST.

>
>> +     status = "okay";
>> +};
>> diff --git a/configs/bananapi_zero_defconfig b/configs/bananapi_zero_defconfig
>> new file mode 100644
>> index 0000000..9c78b21
>> --- /dev/null
>> +++ b/configs/bananapi_zero_defconfig
>> @@ -0,0 +1,17 @@
>> +CONFIG_ARM=y
>> +CONFIG_ARCH_SUNXI=y
>> +CONFIG_MACH_SUN8I_H3=y
>> +CONFIG_DRAM_CLK=408
>> +CONFIG_DRAM_ZQ=3881979
>> +CONFIG_DRAM_ODT_EN=y
>> +CONFIG_DEFAULT_DEVICE_TREE="sun8i-h2-plus-bananapi-m2-zero"
>> +# CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
>> +CONFIG_SPL=y
>> +# CONFIG_CMD_FLASH is not set
>> +# CONFIG_CMD_FPGA is not set
>> +CONFIG_CMD_USB_MASS_STORAGE=y
>
> This shouldn't be enabled in the defconfig.

Thanks for pointing out! Is there any guidance, where DTS should come
from, what defconfig shall include, ...?  I am new to u-boot :-)

>
> The rest of the serie looks good, thanks!
> Maxime


Thanks for review!
Jun
Maxime Ripard Jan. 8, 2018, 9:06 a.m. | #3
Hi Jun,

On Fri, Jan 05, 2018 at 04:51:11PM +0800, Jun Nie wrote:
> >> +/dts-v1/;

> >> +#include "sun8i-h3.dtsi"

> >> +#include "sunxi-common-regulators.dtsi"

> >> +

> >> +#include <dt-bindings/gpio/gpio.h>

> >> +#include <dt-bindings/input/input.h>

> >

> > Where is that DT coming from?

> >

> > Usually, we'll just merge a DT merged in Linux.

> 

> The DT come from Linux but modified with removing necessary nodes.


It seems weird, the pinctrl-names in your LED GPIOs nodes are
unneeded. We shouldn't have merged that.

> >> +&usb_otg {

> >> +     dr_mode = "otg";

> >> +     status = "okay";

> >> +};

> >> +

> >> +&usbphy {

> >> +     usb0_id_det-gpios = <&r_pio 0 6 GPIO_ACTIVE_HIGH>; /* PL6 */

> >> +     /* USB OTG VBUS is directly connected to 5V without any regulators */

> >

> > Then it cannot really do OTG, but rather only peripheral (or host, if

> > the power is provided by the board).

> 

> Right, and working mode in u-boot is decided in compile time,

> CONFIG_USB_MUSB_HOST.


Yes, but then your dr_mode in your DT is wrong.

> >

> >> +     status = "okay";

> >> +};

> >> diff --git a/configs/bananapi_zero_defconfig b/configs/bananapi_zero_defconfig

> >> new file mode 100644

> >> index 0000000..9c78b21

> >> --- /dev/null

> >> +++ b/configs/bananapi_zero_defconfig

> >> @@ -0,0 +1,17 @@

> >> +CONFIG_ARM=y

> >> +CONFIG_ARCH_SUNXI=y

> >> +CONFIG_MACH_SUN8I_H3=y

> >> +CONFIG_DRAM_CLK=408

> >> +CONFIG_DRAM_ZQ=3881979

> >> +CONFIG_DRAM_ODT_EN=y

> >> +CONFIG_DEFAULT_DEVICE_TREE="sun8i-h2-plus-bananapi-m2-zero"

> >> +# CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set

> >> +CONFIG_SPL=y

> >> +# CONFIG_CMD_FLASH is not set

> >> +# CONFIG_CMD_FPGA is not set

> >> +CONFIG_CMD_USB_MASS_STORAGE=y

> >

> > This shouldn't be enabled in the defconfig.

> 

> Thanks for pointing out! Is there any guidance, where DTS should come

> from, what defconfig shall include, ...?  I am new to u-boot :-)


As a general basis, and that's more the policy we try to have for
sunxi since we have so many boards, we try to have as less things as
possible in the defconfig and have a consistent set of commands
enabled by default. Therefore, you should have only the board specific
stuff in there (so RAM parameters, SoC, device tree to use, etc.)

The rest should come from Kconfig itself.

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

Patch

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index a895c70..80eec7e 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -327,6 +327,7 @@  dtb-$(CONFIG_MACH_SUN8I_A83T) += \
 	sun8i-a83t-cubietruck-plus.dtb \
 	sun8i-a83t-tbs-a711.dts
 dtb-$(CONFIG_MACH_SUN8I_H3) += \
+	sun8i-h2-plus-bananapi-m2-zero.dtb \
 	sun8i-h2-plus-orangepi-zero.dtb \
 	sun8i-h3-bananapi-m2-plus.dtb \
 	sun8i-h3-orangepi-2.dtb \
diff --git a/arch/arm/dts/sun8i-h2-plus-bananapi-m2-zero.dts b/arch/arm/dts/sun8i-h2-plus-bananapi-m2-zero.dts
new file mode 100644
index 0000000..4d96c16
--- /dev/null
+++ b/arch/arm/dts/sun8i-h2-plus-bananapi-m2-zero.dts
@@ -0,0 +1,113 @@ 
+/*
+ * Copyright (C) 2017 Jun Nie <jun.nie@linaro.org>
+ *
+ * This file is dual-licensed: you can use it either under the terms
+ * of the GPL or the X11 license, at your option. Note that this dual
+ * licensing only applies to this file, and not this project as a
+ * whole.
+ *
+ *  a) This file 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.
+ *
+ *     This file is distributed in the hope that it will be useful,
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *     GNU General Public License for more details.
+ *
+ * Or, alternatively,
+ *
+ *  b) Permission is hereby granted, free of charge, to any person
+ *     obtaining a copy of this software and associated documentation
+ *     files (the "Software"), to deal in the Software without
+ *     restriction, including without limitation the rights to use,
+ *     copy, modify, merge, publish, distribute, sublicense, and/or
+ *     sell copies of the Software, and to permit persons to whom the
+ *     Software is furnished to do so, subject to the following
+ *     conditions:
+ *
+ *     The above copyright notice and this permission notice shall be
+ *     included in all copies or substantial portions of the Software.
+ *
+ *     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *     EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ *     OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ *     HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ *     WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ *     FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ *     OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/dts-v1/;
+#include "sun8i-h3.dtsi"
+#include "sunxi-common-regulators.dtsi"
+
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
+
+/ {
+	model = "Banana Pi BPI-M2-Zero";
+	compatible = "sinovoip,bpi-m2-zero", "allwinner,sun8i-h2-plus";
+
+	aliases {
+		serial0 = &uart0;
+	};
+
+	chosen {
+		stdout-path = "serial0:115200n8";
+	};
+
+	leds {
+		compatible = "gpio-leds";
+		pinctrl-names = "default";
+
+		pwr_led {
+			label = "bananapi-m2-zero:red:pwr";
+			gpios = <&r_pio 0 10 GPIO_ACTIVE_HIGH>; /* PL10 */
+			default-state = "on";
+		};
+	};
+
+	gpio_keys {
+		compatible = "gpio-keys";
+		pinctrl-names = "default";
+
+		sw4 {
+			label = "power";
+			linux,code = <BTN_0>;
+			gpios = <&r_pio 0 3 GPIO_ACTIVE_LOW>;
+		};
+	};
+};
+
+&mmc0 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&mmc0_pins_a>;
+	vmmc-supply = <&reg_vcc3v3>;
+	bus-width = <4>;
+	/*
+	 * In different revisions the board have different card detect
+	 * configuration.
+	 */
+	broken-cd;
+	status = "okay";
+};
+
+&uart0 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&uart0_pins_a>;
+	status = "okay";
+};
+
+&usb_otg {
+	dr_mode = "otg";
+	status = "okay";
+};
+
+&usbphy {
+	usb0_id_det-gpios = <&r_pio 0 6 GPIO_ACTIVE_HIGH>; /* PL6 */
+	/* USB OTG VBUS is directly connected to 5V without any regulators */
+	status = "okay";
+};
diff --git a/configs/bananapi_zero_defconfig b/configs/bananapi_zero_defconfig
new file mode 100644
index 0000000..9c78b21
--- /dev/null
+++ b/configs/bananapi_zero_defconfig
@@ -0,0 +1,17 @@ 
+CONFIG_ARM=y
+CONFIG_ARCH_SUNXI=y
+CONFIG_MACH_SUN8I_H3=y
+CONFIG_DRAM_CLK=408
+CONFIG_DRAM_ZQ=3881979
+CONFIG_DRAM_ODT_EN=y
+CONFIG_DEFAULT_DEVICE_TREE="sun8i-h2-plus-bananapi-m2-zero"
+# CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
+CONFIG_SPL=y
+# CONFIG_CMD_FLASH is not set
+# CONFIG_CMD_FPGA is not set
+CONFIG_CMD_USB_MASS_STORAGE=y
+# CONFIG_SPL_DOS_PARTITION is not set
+# CONFIG_SPL_ISO_PARTITION is not set
+# CONFIG_SPL_EFI_PARTITION is not set
+CONFIG_MMC_BROKEN_CD=y
+CONFIG_USB_MUSB_GADGET=y