Support the Allwinner F1C100s USB stack
Subsystems (5)
v2 cover Support the Allwinner F1C100s USB stack
The Allwinner F1C100s has an MUSB-based USB peripheral. This patch series implements support for it alongside existing Allwinner support code.
This series was originally written by Icenowy Zheng for Linux v4.14. I've rebased and bugfixed that work against mainline and tested it on both the Lichee Nano and my custom hardware. Where I've made functional changes, I have changed the commit author to myself.
This is a follow-up to the previous series [1], a little late on my self-imposed schedule but here nonetheless.
[1]: https://patchwork.kernel.org/cover/11428003/
George Hilliard (2):
dt-bindings: Add new F1C100s compatible strings for USB
musb: sunxi: add support for the suniv MUSB controller
Icenowy Zheng (3):
phy: sun4i-usb: add support for the USB PHY on suniv SoC
ARM: suniv: add USB-related device nodes
ARM: suniv: f1c100s: enable USB on Lichee Pi Nano
.../phy/allwinner,sun4i-a10-usb-phy.yaml | 1 + .../usb/allwinner,sun4i-a10-musb.yaml | 1 + .../boot/dts/suniv-f1c100s-licheepi-nano.dts | 16 ++++++++++ arch/arm/boot/dts/suniv-f1c100s.dtsi | 29 +++++++++++++++++++ drivers/phy/allwinner/phy-sun4i-usb.c | 10 +++++++ drivers/usb/musb/sunxi.c | 8 +++-- 6 files changed, 63 insertions(+), 2 deletions(-)
Signature · 1 line
2.26.0
PATCH v2 1/5 dt-bindings: Add new F1C100s compatible strings for USB
This chip contains variants of the already-supported peripherals present on other Allwinner parts. Add a new compatible line for them.
--- .../devicetree/bindings/phy/allwinner,sun4i-a10-usb-phy.yaml | 1 + .../devicetree/bindings/usb/allwinner,sun4i-a10-musb.yaml | 1 + 2 files changed, 2 insertions(+)
Documentation/devicetree/bindings/phy/allwinner,sun4i-a10-usb-phy.yaml +1 -0
@@ -18,6 +18,7 @@ properties: enum: - allwinner,sun4i-a10-usb-phy - allwinner,sun7i-a20-usb-phy + - allwinner,suniv-f1c100s-usb-phy reg: items:
Documentation/devicetree/bindings/usb/allwinner,sun4i-a10-musb.yaml +1 -0
@@ -17,6 +17,7 @@ properties: - const: allwinner,sun6i-a31-musb - const: allwinner,sun8i-a33-musb - const: allwinner,sun8i-h3-musb + - const: allwinner,suniv-f1c100s-musb - items: - enum: - allwinner,sun8i-a83t-musb
Signature · 1 line
2.26.0
PATCH v2 2/5 phy: sun4i-usb: add support for the USB PHY on suniv SoC
In reply to George HilliardFrom: Icenowy Zheng <[email protected]>
The suniv SoC has one USB OTG port connected to a MUSB controller.
Add support for its USB PHY.
George Hilliard: changed style to match existing code.
---
v1..v2: reordered sun{50,iv} to match sort order.
drivers/phy/allwinner/phy-sun4i-usb.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/phy/allwinner/phy-sun4i-usb.c +10 -0
@@ -107,6 +107,7 @@ enum sun4i_usb_phy_type { sun8i_v3s_phy, sun50i_a64_phy, sun50i_h6_phy, + suniv_f1c100s_phy, }; struct sun4i_usb_phy_cfg {
@@ -972,6 +973,14 @@ static const struct sun4i_usb_phy_cfg sun50i_h6_cfg = { .missing_phys = BIT(1) | BIT(2), }; +static const struct sun4i_usb_phy_cfg suniv_f1c100s_cfg = { + .num_phys =1 , + .type = suniv_f1c100s_phy, + .disc_thresh =3 , + .phyctl_offset =REG_PHYCTL_A10 , + .dedicated_clocks = true, +}; +static const struct of_device_id sun4i_usb_phy_of_match[] = { { .compatible ="allwinner,sun4i-a10-usb-phy" , .data = &sun4i_a10_cfg }, { .compatible ="allwinner,sun5i-a13-usb-phy" , .data = &sun5i_a13_cfg },
@@ -986,6 +995,7 @@ static const struct of_device_id sun4i_usb_phy_of_match[] = { { .compatible = "allwinner,sun50i-a64-usb-phy", .data = &sun50i_a64_cfg}, { .compatible = "allwinner,sun50i-h6-usb-phy", .data = &sun50i_h6_cfg }, + { .compatible = "allwinner,suniv-f1c100s-usb-phy", .data = &suniv_f1c100s_cfg }, { }, };MODULE_DEVICE_TABLE (of, sun4i_usb_phy_of_match);
Signature · 1 line
2.26.0
PATCH v2 3/5 musb: sunxi: add support for the suniv MUSB controller
In reply to George HilliardThe suniv SoC has a MUSB controller like the one in A33, but with a SRAM region to be claimed.
Add support for it.
George Hilliard: debugged, match existing style
---
v1..v2: reordered sun{50,iv} to match sort order.
drivers/usb/musb/sunxi.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/usb/musb/sunxi.c +6 -2
@@ -714,14 +714,17 @@ static int sunxi_musb_probe(struct platform_device *pdev)INIT_WORK (&glue->work, sunxi_musb_work); glue->host_nb.notifier_call = sunxi_musb_host_notifier; -if (of_device_is_compatible (np,"allwinner,sun4i-a10-musb" )) +if (of_device_is_compatible (np,"allwinner,sun4i-a10-musb" ) || +of_device_is_compatible (np,"allwinner,suniv-f1c100s-musb" )) {set_bit (SUNXI_MUSB_FL_HAS_SRAM , &glue->flags); + }if (of_device_is_compatible (np,"allwinner,sun6i-a31-musb" ))set_bit (SUNXI_MUSB_FL_HAS_RESET , &glue->flags);if (of_device_is_compatible (np,"allwinner,sun8i-a33-musb" ) || -of_device_is_compatible (np,"allwinner,sun8i-h3-musb" )) { +of_device_is_compatible (np,"allwinner,sun8i-h3-musb" ) || +of_device_is_compatible (np,"allwinner,suniv-f1c100s-musb" )) {set_bit (SUNXI_MUSB_FL_HAS_RESET , &glue->flags);set_bit (SUNXI_MUSB_FL_NO_CONFIGDATA , &glue->flags); }
@@ -818,6 +821,7 @@ static const struct of_device_id sunxi_musb_match[] = { { .compatible = "allwinner,sun6i-a31-musb", }, { .compatible = "allwinner,sun8i-a33-musb", }, { .compatible = "allwinner,sun8i-h3-musb", }, + { .compatible = "allwinner,suniv-f1c100s-musb", }, {} }; MODULE_DEVICE_TABLE(of, sunxi_musb_match);
Signature · 1 line
2.26.0
PATCH v2 4/5 ARM: suniv: add USB-related device nodes
In reply to George HilliardFrom: Icenowy Zheng <[email protected]>
The suniv SoC has a USB OTG controller and a USB PHY like other Allwinner SoCs.
Add their device tree node.
--- arch/arm/boot/dts/suniv-f1c100s.dtsi | 29 ++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)
arch/arm/boot/dts/suniv-f1c100s.dtsi +29 -0
@@ -4,6 +4,9 @@ * Copyright 2018 Mesih Kilinc <[email protected]> */ +#include <dt-bindings/clock/suniv-ccu-f1c100s.h> +#include <dt-bindings/reset/suniv-ccu-f1c100s.h> + / { #address-cells = <1>; #size-cells = <1>;
@@ -140,5 +143,31 @@ uart2: serial@1c25800 { resets = <&ccu 26>; status = "disabled"; }; + + usb_otg: usb@1c13000 { + compatible = "allwinner,suniv-f1c100s-musb"; + reg = <0x01c13000 0x0400>; + clocks = <&ccu CLK_BUS_OTG>; + resets = <&ccu RST_BUS_OTG>; + interrupts = <26>; + interrupt-names = "mc"; + phys = <&usbphy 0>; + phy-names = "usb"; + extcon = <&usbphy 0>; + allwinner,sram = <&otg_sram 1>; + status = "disabled"; + }; + + usbphy: phy@1c13400 { + compatible = "allwinner,suniv-f1c100s-usb-phy"; + reg = <0x01c13400 0x10>; + reg-names = "phy_ctrl"; + clocks = <&ccu CLK_USB_PHY0>; + clock-names = "usb0_phy"; + resets = <&ccu RST_USB_PHY0>; + reset-names = "usb0_reset"; + #phy-cells = <1>; + status = "disabled"; + }; }; };
Signature · 1 line
2.26.0
PATCH v2 5/5 ARM: suniv: f1c100s: enable USB on Lichee Pi Nano
In reply to George HilliardFrom: Icenowy Zheng <[email protected]>
Lichee Pi Nano has a Micro-USB connector, with its D+, D- pins connected to the USB pins of the SoC and ID pin connected to PE2 GPIO.
Enable the USB functionality.
This patch depends on the previous change to the F1C100s device tree.
--- .../arm/boot/dts/suniv-f1c100s-licheepi-nano.dts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
arch/arm/boot/dts/suniv-f1c100s-licheepi-nano.dts +16 -0
@@ -6,6 +6,8 @@ /dts-v1/; #include "suniv-f1c100s.dtsi" +#include <dt-bindings/gpio/gpio.h> + / { model = "Lichee Pi Nano"; compatible = "licheepi,licheepi-nano", "allwinner,suniv-f1c100s";
@@ -19,8 +21,22 @@ chosen { }; }; +&otg_sram { + status = "okay"; +}; + &uart0 { pinctrl-names = "default"; pinctrl-0 = <&uart0_pe_pins>; status = "okay"; }; + +&usb_otg { + dr_mode = "otg"; + status = "okay"; +}; + +&usbphy { + usb0_id_det-gpio = <&pio 4 2 GPIO_ACTIVE_HIGH>; /* PE2 */ + status = "okay"; +};
Signature · 1 line
2.26.0