ARM: mach-meson: update & rework USB for GXL, GXM & AXG
Subsystems (9)
cover ARM: mach-meson: update & rework USB for GXL, GXM & AXG
This serie follows the recent work under Linux to rework and update support of the USB complex in the Amlogic GXL, GXM & AXG SoCs.
This rework follows the clean implementation for the G12A & following SoCs to support Host, Device & OTG functionnality.
The GXL, GXM & AXG USB complex is architectured in the same was as the G12A & later USB complex, thus we can use the same architecture but adapted to the different init & config flow found in the Amlogic GXL, GXM & AXG SoCs.
With this patchset, USB Host functionnality is retained, working & tested on the Khadas VIM2 (GXM), Libretech-CC (GXL) & S400 (AXG), with Device mode added and tested by using the UMS gadget.
Neil Armstrong (8):
ARM: dts: sync amlogic AXG/GXL/GXM DT from Linux 5.8-rc1
usb: dwc3: add Amlogic GXL & GXL DWC3 Glue
ARM: mach-meson: use new DWC3 glue for GXL & GXM
phy: meson-gxl: remove invalid USB3 PHY driver
phy: meson-gxl-usb: depend on Meson AXG aswell
arm: meson-axg: add board_usb_init()/cleanup() for USB gadget
ARM: dts: meson-axg: add USB nodes for S400
configs: s400: enable USB
arch/arm/dts/meson-axg-s400-u-boot.dtsi | 12 + arch/arm/dts/meson-axg-u-boot.dtsi | 62 +++ arch/arm/dts/meson-axg.dtsi | 6 +- arch/arm/dts/meson-gx-libretech-pc.dtsi | 78 +++- arch/arm/dts/meson-gx.dtsi | 23 +- arch/arm/dts/meson-gxbb-nanopi-k2.dts | 2 +- arch/arm/dts/meson-gxbb-odroidc2.dts | 2 +- arch/arm/dts/meson-gxbb.dtsi | 23 + .../meson-gxl-s805x-libretech-ac-u-boot.dtsi | 4 - arch/arm/dts/meson-gxl-s805x-libretech-ac.dts | 73 ++- .../meson-gxl-s905d-libretech-pc-u-boot.dtsi | 4 - .../meson-gxl-s905x-khadas-vim-u-boot.dtsi | 4 - arch/arm/dts/meson-gxl-s905x-khadas-vim.dts | 4 + .../meson-gxl-s905x-libretech-cc-u-boot.dtsi | 4 - arch/arm/dts/meson-gxl-s905x-libretech-cc.dts | 77 +++- arch/arm/dts/meson-gxl-s905x-p212.dtsi | 3 +- arch/arm/dts/meson-gxl-u-boot.dtsi | 16 - arch/arm/dts/meson-gxl.dtsi | 79 +++- .../arm/dts/meson-gxm-khadas-vim2-u-boot.dtsi | 4 - arch/arm/dts/meson-gxm-khadas-vim2.dts | 3 +- .../meson-gxm-s912-libretech-pc-u-boot.dtsi | 4 - arch/arm/dts/meson-gxm.dtsi | 7 +- arch/arm/include/asm/arch-meson/usb-gx.h | 3 +- arch/arm/mach-meson/board-axg.c | 128 ++++++ arch/arm/mach-meson/board-gx.c | 127 +++--- configs/khadas-vim2_defconfig | 2 +- configs/khadas-vim_defconfig | 2 +- configs/libretech-ac_defconfig | 2 +- configs/libretech-cc_defconfig | 2 +- configs/libretech-s905d-pc_defconfig | 2 +- configs/libretech-s912-pc_defconfig | 2 +- configs/p212_defconfig | 2 +- configs/s400_defconfig | 15 + drivers/phy/Kconfig | 2 +- drivers/phy/Makefile | 2 +- drivers/phy/meson-gxl-usb3.c | 219 --------- drivers/usb/dwc3/Kconfig | 8 + drivers/usb/dwc3/Makefile | 1 + drivers/usb/dwc3/dwc3-meson-gxl.c | 425 ++++++++++++++++++ .../reset/amlogic,meson-gxbb-reset.h | 2 +- include/dt-bindings/sound/meson-aiu.h | 18 + 41 files changed, 1092 insertions(+), 366 deletions(-) create mode 100644 arch/arm/dts/meson-axg-u-boot.dtsi delete mode 100644 drivers/phy/meson-gxl-usb3.c create mode 100644 drivers/usb/dwc3/dwc3-meson-gxl.c create mode 100644 include/dt-bindings/sound/meson-aiu.h
Signature · 1 line
2.22.0
PATCH 1/8 ARM: dts: sync amlogic AXG/GXL/GXM DT from Linux 5.8-rc1
This imports the AXG, GXL & GXM SoC and boards DT changes from the Linux commit b3a9e3b9622a ("Linux 5.8-rc1").
This change also removes GXL & GXM u-boot.dtsi hacks for USB gadget.
--- arch/arm/dts/meson-axg.dtsi | 6 +- arch/arm/dts/meson-gx-libretech-pc.dtsi | 78 +++++++++++++++++- arch/arm/dts/meson-gx.dtsi | 23 ++++-- arch/arm/dts/meson-gxbb-nanopi-k2.dts | 2 +- arch/arm/dts/meson-gxbb-odroidc2.dts | 2 +- arch/arm/dts/meson-gxbb.dtsi | 23 ++++++ .../meson-gxl-s805x-libretech-ac-u-boot.dtsi | 4 - arch/arm/dts/meson-gxl-s805x-libretech-ac.dts | 73 ++++++++++++++++- .../meson-gxl-s905d-libretech-pc-u-boot.dtsi | 4 - .../meson-gxl-s905x-khadas-vim-u-boot.dtsi | 4 - arch/arm/dts/meson-gxl-s905x-khadas-vim.dts | 4 + .../meson-gxl-s905x-libretech-cc-u-boot.dtsi | 4 - arch/arm/dts/meson-gxl-s905x-libretech-cc.dts | 77 +++++++++++++++++- arch/arm/dts/meson-gxl-s905x-p212.dtsi | 3 +- arch/arm/dts/meson-gxl-u-boot.dtsi | 16 ---- arch/arm/dts/meson-gxl.dtsi | 79 ++++++++++++++----- .../arm/dts/meson-gxm-khadas-vim2-u-boot.dtsi | 4 - arch/arm/dts/meson-gxm-khadas-vim2.dts | 3 +- .../meson-gxm-s912-libretech-pc-u-boot.dtsi | 4 - arch/arm/dts/meson-gxm.dtsi | 7 +- .../reset/amlogic,meson-gxbb-reset.h | 2 +- include/dt-bindings/sound/meson-aiu.h | 18 +++++ 22 files changed, 358 insertions(+), 82 deletions(-) create mode 100644 include/dt-bindings/sound/meson-aiu.h
arch/arm/dts/meson-axg.dtsi +3 -3
@@ -1735,18 +1735,18 @@ }; sram: sram at fffc0000 { - compatible = "amlogic,meson-axg-sram", "mmio-sram"; + compatible = "mmio-sram"; reg = <0x0 0xfffc0000 0x0 0x20000>; #address-cells = <1>; #size-cells = <1>; ranges = <0 0x0 0xfffc0000 0x20000>; - cpu_scp_lpri: scp-shmem at 13000 { + cpu_scp_lpri: scp-sram at 13000 { compatible = "amlogic,meson-axg-scp-shmem"; reg = <0x13000 0x400>; }; - cpu_scp_hpri: scp-shmem at 13400 { + cpu_scp_hpri: scp-sram at 13400 { compatible = "amlogic,meson-axg-scp-shmem"; reg = <0x13400 0x400>; };
arch/arm/dts/meson-gx-libretech-pc.dtsi +75 -3
115 lines not on this page · raw message
arch/arm/dts/meson-gx.dtsi +18 -5
@@ -278,6 +278,17 @@ #reset-cells = <1>; }; + aiu: audio-controller at 5400 { + compatible = "amlogic,aiu"; + #sound-dai-cells = <2>; + sound-name-prefix = "AIU"; + reg = <0x0 0x5400 0x0 0x2ac>; + interrupts = <GIC_SPI 48 IRQ_TYPE_EDGE_RISING>, + <GIC_SPI 50 IRQ_TYPE_EDGE_RISING>; + interrupt-names = "i2s", "spdif"; + status = "disabled"; + }; + uart_A: serial at 84c0 { compatible = "amlogic,meson-gx-uart"; reg = <0x0 0x84c0 0x0 0x18>;
@@ -398,20 +409,20 @@ }; sram: sram at c8000000 { - compatible = "amlogic,meson-gx-sram", "amlogic,meson-gxbb-sram", "mmio-sram"; + compatible = "mmio-sram"; reg = <0x0 0xc8000000 0x0 0x14000>; #address-cells = <1>; #size-cells = <1>; ranges = <0 0x0 0xc8000000 0x14000>; - cpu_scp_lpri: scp-shmem at 0 { - compatible = "amlogic,meson-gx-scp-shmem", "amlogic,meson-gxbb-scp-shmem"; + cpu_scp_lpri: scp-sram at 0 { + compatible = "amlogic,meson-gxbb-scp-shmem"; reg = <0x13000 0x400>; }; - cpu_scp_hpri: scp-shmem at 200 { - compatible = "amlogic,meson-gx-scp-shmem", "amlogic,meson-gxbb-scp-shmem"; + cpu_scp_hpri: scp-sram at 200 { + compatible = "amlogic,meson-gxbb-scp-shmem"; reg = <0x13400 0x400>; }; };
@@ -626,6 +637,8 @@ interrupts = <GIC_SPI 57 IRQ_TYPE_EDGE_RISING>; #address-cells = <1>; #size-cells = <0>; + #sound-dai-cells = <0>; + sound-name-prefix = "HDMITX"; status = "disabled"; /* VPU VENC Input */
arch/arm/dts/meson-gxbb-nanopi-k2.dts +1 -1
@@ -29,7 +29,7 @@ leds { compatible = "gpio-leds"; - stat { + led-stat { label = "nanopi-k2:blue:stat"; gpios = <&gpio_ao GPIOAO_13 GPIO_ACTIVE_HIGH>; default-state = "on";
arch/arm/dts/meson-gxbb-odroidc2.dts +1 -1
@@ -49,7 +49,7 @@ leds { compatible = "gpio-leds"; - blue { + led-blue { label = "c2:blue:alive"; gpios = <&gpio_ao GPIOAO_13 GPIO_ACTIVE_LOW>; linux,default-trigger = "heartbeat";
arch/arm/dts/meson-gxbb.dtsi +23 -0
@@ -60,6 +60,29 @@ }; }; +&aiu { + compatible = "amlogic,aiu-gxbb", "amlogic,aiu"; + clocks = <&clkc CLKID_AIU_GLUE>, + <&clkc CLKID_I2S_OUT>, + <&clkc CLKID_AOCLK_GATE>, + <&clkc CLKID_CTS_AMCLK>, + <&clkc CLKID_MIXER_IFACE>, + <&clkc CLKID_IEC958>, + <&clkc CLKID_IEC958_GATE>, + <&clkc CLKID_CTS_MCLK_I958>, + <&clkc CLKID_CTS_I958>; + clock-names = "pclk", + "i2s_pclk", + "i2s_aoclk", + "i2s_mclk", + "i2s_mixer", + "spdif_pclk", + "spdif_aoclk", + "spdif_mclk", + "spdif_mclk_sel"; + resets = <&reset RESET_AIU>; +}; + &aobus { pinctrl_aobus: pinctrl at 14 { compatible = "amlogic,meson-gxbb-aobus-pinctrl";
arch/arm/dts/meson-gxl-s805x-libretech-ac-u-boot.dtsi +0 -4
@@ -5,7 +5,3 @@ */ #include "meson-gxl-u-boot.dtsi" - -&dwc2 { - status = "okay"; -};
arch/arm/dts/meson-gxl-s805x-libretech-ac.dts +72 -1
96 lines not on this page · raw message
arch/arm/dts/meson-gxl-s905d-libretech-pc-u-boot.dtsi +0 -4
@@ -5,7 +5,3 @@ */ #include "meson-gxl-u-boot.dtsi" - -&dwc2 { - status = "okay"; -};
arch/arm/dts/meson-gxl-s905x-khadas-vim-u-boot.dtsi +0 -4
@@ -5,7 +5,3 @@ */ #include "meson-gxl-u-boot.dtsi" - -&dwc2 { - status = "okay"; -};
arch/arm/dts/meson-gxl-s905x-khadas-vim.dts +4 -0
@@ -207,3 +207,7 @@ pinctrl-0 = <&uart_ao_b_pins>; pinctrl-names = "default"; }; + +&usb { + dr_mode = "peripheral"; +};
arch/arm/dts/meson-gxl-s905x-libretech-cc-u-boot.dtsi +0 -4
@@ -5,7 +5,3 @@ */ #include "meson-gxl-u-boot.dtsi" - -&dwc2 { - status = "okay"; -};
arch/arm/dts/meson-gxl-s905x-libretech-cc.dts +74 -3
114 lines not on this page · raw message
arch/arm/dts/meson-gxl-s905x-p212.dtsi +2 -1
@@ -195,8 +195,9 @@ pinctrl-names = "default"; }; -&usb0 { +&usb { status = "okay"; + dr_mode = "host"; }; &usb2_phy0 {
arch/arm/dts/meson-gxl-u-boot.dtsi +0 -16
@@ -5,19 +5,3 @@ */ #include "meson-gx-u-boot.dtsi" - -&usb0 { - dwc2: usb at c9100000 { - compatible = "snps,dwc2"; - reg = <0x0 0xc9100000 0x0 0x40000>; - interrupts = <GIC_SPI 31 IRQ_TYPE_LEVEL_HIGH>; - clocks = <&clkc CLKID_USB1_DDR_BRIDGE>; - clock-names = "ddr"; - phys = <&usb3_phy>, <&usb2_phy1>; - dr_mode = "peripheral"; - g-rx-fifo-size = <192>; - g-np-tx-fifo-size = <128>; - g-tx-fifo-size = <128 128 16 16 16>; - status = "disabled"; - }; -};
arch/arm/dts/meson-gxl.dtsi +59 -20
112 lines not on this page · raw message
arch/arm/dts/meson-gxm-khadas-vim2-u-boot.dtsi +0 -4
@@ -12,10 +12,6 @@ }; }; -&dwc2 { - status = "okay"; -}; - &sd_emmc_c { status = "okay"; pinctrl-0 = <&emmc_pins>;
arch/arm/dts/meson-gxm-khadas-vim2.dts +2 -1
@@ -380,6 +380,7 @@ vref-supply = <&vddio_ao18>; }; -&usb0 { +&usb { status = "okay"; + dr_mode = "peripheral"; };
arch/arm/dts/meson-gxm-s912-libretech-pc-u-boot.dtsi +0 -4
@@ -5,7 +5,3 @@ */ #include "meson-gxl-u-boot.dtsi" - -&dwc2 { - status = "okay"; -};
arch/arm/dts/meson-gxm.dtsi +5 -2
@@ -169,8 +169,11 @@ compatible = "amlogic,meson-gxm-dw-hdmi", "amlogic,meson-gx-dw-hdmi"; }; -&dwc3 { - phys = <&usb3_phy>, <&usb2_phy0>, <&usb2_phy1>, <&usb2_phy2>; +&usb { + compatible = "amlogic,meson-gxm-usb-ctrl"; + + phy-names = "usb2-phy0", "usb2-phy1", "usb2-phy2"; + phys = <&usb2_phy0>, <&usb2_phy1>, <&usb2_phy2>; }; &vdec {
include/dt-bindings/reset/amlogic,meson-gxbb-reset.h +1 -1
@@ -69,7 +69,7 @@#define RESET_SYS_CPU_L2 58#define RESET_SYS_CPU_P 59#define RESET_SYS_CPU_MBIST 60 -/* 61 */ +#define RESET_ACODEC 61/* 62 */ /* 63 */ /* RESET2 */
include/dt-bindings/sound/meson-aiu.h new file +18 -0
@@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __DT_MESON_AIU_H +#define __DT_MESON_AIU_H + +#define AIU_CPU 0 +#define AIU_HDMI 1 +#define AIU_ACODEC 2 + +#define CPU_I2S_FIFO 0 +#define CPU_SPDIF_FIFO 1 +#define CPU_I2S_ENCODER 2 +#define CPU_SPDIF_ENCODER 3 + +#define CTRL_I2S 0 +#define CTRL_PCM 1 +#define CTRL_OUT 2 + +#endif /* __DT_MESON_AIU_H */
Signature · 1 line
2.22.0
PATCH 2/8 usb: dwc3: add Amlogic GXL & GXL DWC3 Glue
In reply to Neil ArmstrongThe USB support was initialy done with a set of PHYs and dwc3-of-simple because the architecture of the USB complex was not understood correctly at the time (and proper documentation was missing...).
But with the G12A family, the USB complex was correctly understood and implemented correctly.
This adds a proper driver for the glue, based on the G12A one, but with enough changes to require a different driver in U-Boot.
--- arch/arm/include/asm/arch-meson/usb-gx.h | 2 + drivers/usb/dwc3/Kconfig | 8 + drivers/usb/dwc3/Makefile | 1 + drivers/usb/dwc3/dwc3-meson-gxl.c | 425 +++++++++++++++++++++++ 4 files changed, 436 insertions(+) create mode 100644 drivers/usb/dwc3/dwc3-meson-gxl.c
arch/arm/include/asm/arch-meson/usb-gx.h +2 -0
@@ -13,4 +13,6 @@void phy_meson_gxl_usb2_set_mode (struct phy *phy,enum usb_dr_mode mode);void phy_meson_gxl_usb3_set_mode (struct phy *phy,enum usb_dr_mode mode); +int dwc3_meson_gxl_force_mode (struct udevice *dev,enum usb_dr_mode mode); +#endif
drivers/usb/dwc3/Kconfig +8 -0
@@ -38,6 +38,14 @@ config USB_DWC3_MESON_G12A Select this for Amlogic Meson G12A Platforms. This wrapper supports Host and Peripheral operation modes. +config USB_DWC3_MESON_GXL + bool "Amlogic Meson GXL USB wrapper" + depends on DM_USB && USB_DWC3 && ARCH_MESON + imply PHY + help + Select this for Amlogic Meson GXL and GXM Platforms. + This wrapper supports Host and Peripheral operation modes. + config USB_DWC3_UNIPHIER bool "DesignWare USB3 Host Support on UniPhier Platforms" depends on ARCH_UNIPHIER && USB_XHCI_DWC3
drivers/usb/dwc3/Makefile +1 -0
@@ -8,6 +8,7 @@ obj-$(CONFIG_USB_DWC3_GADGET) += gadget.o ep0.o obj-$(CONFIG_USB_DWC3_OMAP) += dwc3-omap.o obj-$(CONFIG_USB_DWC3_MESON_G12A) += dwc3-meson-g12a.o +obj-$(CONFIG_USB_DWC3_MESON_GXL) += dwc3-meson-gxl.o obj-$(CONFIG_USB_DWC3_GENERIC) += dwc3-generic.o obj-$(CONFIG_USB_DWC3_UNIPHIER) += dwc3-uniphier.o obj-$(CONFIG_USB_DWC3_PHY_OMAP) += ti_usb_phy.o
drivers/usb/dwc3/dwc3-meson-gxl.c new file +425 -0
425 lines not on this page · raw message
Signature · 1 line
2.22.0
PATCH 3/8 ARM: mach-meson: use new DWC3 glue for GXL & GXM
In reply to Neil ArmstrongUse the new Amlogic GXL/GXM USB Glue instead of the set of USB3 PHY and Simple DWC3 wrapper.
--- arch/arm/mach-meson/board-gx.c | 127 +++++++++++++++------------ configs/khadas-vim2_defconfig | 2 +- configs/khadas-vim_defconfig | 2 +- configs/libretech-ac_defconfig | 2 +- configs/libretech-cc_defconfig | 2 +- configs/libretech-s905d-pc_defconfig | 2 +- configs/libretech-s912-pc_defconfig | 2 +- configs/p212_defconfig | 2 +- 8 files changed, 79 insertions(+), 62 deletions(-)
arch/arm/mach-meson/board-gx.c +72 -55
@@ -156,79 +156,70 @@ void meson_eth_init(phy_interface_t mode, unsigned int flags)clrbits_le32 (GX_MEM_PD_REG_0 ,GX_MEM_PD_REG_0_ETH_MASK ); } -#if CONFIG_IS_ENABLED (USB_XHCI_DWC3_OF_SIMPLE ) && \ +#if CONFIG_IS_ENABLED (USB_DWC3_MESON_GXL ) && \CONFIG_IS_ENABLED (USB_GADGET_DWC2_OTG )static struct dwc2_plat_otg_data meson_gx_dwc2_data; -static struct phy usb_phys[2 ];int board_usb_init (int index,enum usb_init_type init) { -struct ofnode_phandle_args args; -struct udevice *clk_dev; -ofnode dwc2_node; +struct fdtdec_phandle_args args; +const void *blob = gd->fdt_blob; +int node, dwc2_node; +struct udevice *dev, *clk_dev;struct clk clk; -int ret, i; -u32 val; - -/* find the dwc2 node */ - dwc2_node =ofnode_by_compatible (ofnode_null (),"snps,dwc2" ); -if (!ofnode_valid (dwc2_node)) { -debug ("Not found dwc2 node\n" ); -return -ENODEV ; +int ret; + +/* find the usb glue node */ + node =fdt_node_offset_by_compatible (blob,-1 , +"amlogic,meson-gxl-usb-ctrl" ); +if (node <0 ) { + node =fdt_node_offset_by_compatible (blob,-1 , +"amlogic,meson-gxm-usb-ctrl" ); +if (node <0 ) { +debug ("Not found usb-control node\n" ); +return -ENODEV ; + } } -if (!ofnode_is_available (dwc2_node)) { -debug ("dwc2 is disabled in the device tree\n" ); +if (!fdtdec_get_is_enabled (blob, node)) { +debug ("usb is disabled in the device tree\n" );return -ENODEV ; } -/* get the PHYs */ -for (i =0 ; i <2 ; i++) { - ret =generic_phy_get_by_index_nodev (dwc2_node, i, - &usb_phys[i]); -if (ret && ret != -ENOENT ) { -pr_err ("Failed to get USB PHY%d for %s\n" , - i,ofnode_get_name (dwc2_node)); -return ret; - } + ret =uclass_get_device_by_of_offset (UCLASS_SIMPLE_BUS , node, &dev); +if (ret) { +debug ("Not found usb-control device\n" ); +return ret; } -for (i =0 ; i <2 ; i++) { - ret =generic_phy_init (&usb_phys[i]); -if (ret) { -pr_err ("Can't init USB PHY%d for %s\n" , - i,ofnode_get_name (dwc2_node)); -return ret; - } +/* find the dwc2 node */ + dwc2_node =fdt_node_offset_by_compatible (blob, node, +"amlogic,meson-g12a-usb" ); +if (dwc2_node <0 ) { +debug ("Not found dwc2 node\n" ); +return -ENODEV ; } -for (i =0 ; i <2 ; i++) { - ret =generic_phy_power_on (&usb_phys[i]); -if (ret) { -pr_err ("Can't power USB PHY%d for %s\n" , - i,ofnode_get_name (dwc2_node)); -return ret; - } +if (!fdtdec_get_is_enabled (blob, dwc2_node)) { +debug ("dwc2 is disabled in the device tree\n" ); +return -ENODEV ; } -phy_meson_gxl_usb3_set_mode (&usb_phys[0 ],USB_DR_MODE_PERIPHERAL ); -phy_meson_gxl_usb2_set_mode (&usb_phys[1 ],USB_DR_MODE_PERIPHERAL ); - - meson_gx_dwc2_data.regs_otg =ofnode_get_addr (dwc2_node); + meson_gx_dwc2_data.regs_otg =fdtdec_get_addr (blob, dwc2_node,"reg" );if (meson_gx_dwc2_data.regs_otg ==FDT_ADDR_T_NONE ) {debug ("usbotg: can't get base address\n" );return -ENODATA ; }/* Enable clock */ - ret =ofnode_parse_phandle_with_args (dwc2_node,"clocks" , + ret =fdtdec_parse_phandle_with_args (blob, dwc2_node,"clocks" ,"#clock-cells" ,0 ,0 , &args);if (ret) {debug ("usbotg has no clocks defined in the device tree\n" );return ret; } - ret =uclass_get_device_by_ofnode (UCLASS_CLK , args.node, &clk_dev); + ret =uclass_get_device_by_of_offset (UCLASS_CLK , args.node, &clk_dev);if (ret)return ret;
@@ -246,25 +237,51 @@ int board_usb_init(int index, enum usb_init_type init)return ret; } -ofnode_read_u32 (dwc2_node,"g-rx-fifo-size" , &val); - meson_gx_dwc2_data.rx_fifo_sz = val; -ofnode_read_u32 (dwc2_node,"g-np-tx-fifo-size" , &val); - meson_gx_dwc2_data.np_tx_fifo_sz = val; -ofnode_read_u32 (dwc2_node,"g-tx-fifo-size" , &val); - meson_gx_dwc2_data.tx_fifo_sz = val; + meson_gx_dwc2_data.rx_fifo_sz =fdtdec_get_int (blob, dwc2_node, +"g-rx-fifo-size" ,0 ); + meson_gx_dwc2_data.np_tx_fifo_sz =fdtdec_get_int (blob, dwc2_node, +"g-np-tx-fifo-size" ,0 ); + meson_gx_dwc2_data.tx_fifo_sz =fdtdec_get_int (blob, dwc2_node, +"g-tx-fifo-size" ,0 ); + +/* Switch to peripheral mode */ + ret =dwc3_meson_gxl_force_mode (dev,USB_DR_MODE_PERIPHERAL ); +if (ret) +return ret;return dwc2_udc_probe (&meson_gx_dwc2_data); }int board_usb_cleanup (int index,enum usb_init_type init) { -int i; +const void *blob = gd->fdt_blob; +struct udevice *dev; +int node; +int ret; + +/* find the usb glue node */ + node =fdt_node_offset_by_compatible (blob,-1 , +"amlogic,meson-gxl-usb-ctrl" ); +if (node <0 ) { + node =fdt_node_offset_by_compatible (blob,-1 , +"amlogic,meson-gxm-usb-ctrl" ); +if (node <0 ) { +debug ("Not found usb-control node\n" ); +return -ENODEV ; + } + } -phy_meson_gxl_usb3_set_mode (&usb_phys[0 ],USB_DR_MODE_HOST ); -phy_meson_gxl_usb2_set_mode (&usb_phys[1 ],USB_DR_MODE_HOST ); +if (!fdtdec_get_is_enabled (blob, node)) +return -ENODEV ; -for (i =0 ; i <2 ; i++) - usb_phys[i].dev =NULL ; + ret =uclass_get_device_by_of_offset (UCLASS_SIMPLE_BUS , node, &dev); +if (ret) +return ret; + +/* Switch to OTG mode */ + ret =dwc3_meson_gxl_force_mode (dev,USB_DR_MODE_HOST ); +if (ret) +return ret;return 0 ; }
configs/khadas-vim2_defconfig +1 -1
@@ -41,6 +41,7 @@ CONFIG_DM_ETH=y CONFIG_ETH_DESIGNWARE=y CONFIG_PHY=y CONFIG_MESON_GXL_USB_PHY=y +CONFIG_USB_DWC3_MESON_GXL=y CONFIG_PINCTRL=y CONFIG_PINCTRL_MESON_GXL=y CONFIG_DM_REGULATOR_FIXED=y
@@ -55,7 +56,6 @@ CONFIG_USB=y CONFIG_DM_USB=y CONFIG_USB_XHCI_HCD=y CONFIG_USB_XHCI_DWC3=y -CONFIG_USB_XHCI_DWC3_OF_SIMPLE=y CONFIG_USB_DWC3=y # CONFIG_USB_DWC3_GADGET is not set CONFIG_USB_GADGET=y
configs/khadas-vim_defconfig +1 -1
@@ -37,6 +37,7 @@ CONFIG_DM_ETH=y CONFIG_ETH_DESIGNWARE=y CONFIG_PHY=y CONFIG_MESON_GXL_USB_PHY=y +CONFIG_USB_DWC3_MESON_GXL=y CONFIG_PINCTRL=y CONFIG_PINCTRL_MESON_GXL=y CONFIG_DM_REGULATOR_FIXED=y
@@ -48,7 +49,6 @@ CONFIG_USB=y CONFIG_DM_USB=y CONFIG_USB_XHCI_HCD=y CONFIG_USB_XHCI_DWC3=y -CONFIG_USB_XHCI_DWC3_OF_SIMPLE=y CONFIG_USB_DWC3=y # CONFIG_USB_DWC3_GADGET is not set CONFIG_USB_GADGET=y
configs/libretech-ac_defconfig +1 -1
@@ -49,6 +49,7 @@ CONFIG_DM_ETH=y CONFIG_ETH_DESIGNWARE=y CONFIG_PHY=y CONFIG_MESON_GXL_USB_PHY=y +CONFIG_USB_DWC3_MESON_GXL=y CONFIG_PINCTRL=y CONFIG_PINCTRL_MESON_GXL=y CONFIG_POWER_DOMAIN=y
@@ -65,7 +66,6 @@ CONFIG_USB=y CONFIG_DM_USB=y CONFIG_USB_XHCI_HCD=y CONFIG_USB_XHCI_DWC3=y -CONFIG_USB_XHCI_DWC3_OF_SIMPLE=y CONFIG_USB_DWC3=y # CONFIG_USB_DWC3_GADGET is not set CONFIG_USB_KEYBOARD=y
configs/libretech-cc_defconfig +1 -1
@@ -36,6 +36,7 @@ CONFIG_DM_ETH=y CONFIG_ETH_DESIGNWARE=y CONFIG_PHY=y CONFIG_MESON_GXL_USB_PHY=y +CONFIG_USB_DWC3_MESON_GXL=y CONFIG_PINCTRL=y CONFIG_PINCTRL_MESON_GXL=y CONFIG_POWER_DOMAIN=y
@@ -49,7 +50,6 @@ CONFIG_USB=y CONFIG_DM_USB=y CONFIG_USB_XHCI_HCD=y CONFIG_USB_XHCI_DWC3=y -CONFIG_USB_XHCI_DWC3_OF_SIMPLE=y CONFIG_USB_DWC3=y # CONFIG_USB_DWC3_GADGET is not set CONFIG_USB_GADGET=y
configs/libretech-s905d-pc_defconfig +1 -1
@@ -44,6 +44,7 @@ CONFIG_DM_ETH=y CONFIG_ETH_DESIGNWARE=y CONFIG_PHY=y CONFIG_MESON_GXL_USB_PHY=y +CONFIG_USB_DWC3_MESON_GXL=y CONFIG_PINCTRL=y CONFIG_PINCTRL_MESON_GXL=y CONFIG_POWER_DOMAIN=y
@@ -60,7 +61,6 @@ CONFIG_USB=y CONFIG_DM_USB=y CONFIG_USB_XHCI_HCD=y CONFIG_USB_XHCI_DWC3=y -CONFIG_USB_XHCI_DWC3_OF_SIMPLE=y CONFIG_USB_DWC3=y # CONFIG_USB_DWC3_GADGET is not set CONFIG_USB_KEYBOARD=y
configs/libretech-s912-pc_defconfig +1 -1
@@ -43,6 +43,7 @@ CONFIG_DM_ETH=y CONFIG_ETH_DESIGNWARE=y CONFIG_PHY=y CONFIG_MESON_GXL_USB_PHY=y +CONFIG_USB_DWC3_MESON_GXL=y CONFIG_PINCTRL=y CONFIG_PINCTRL_MESON_GXL=y CONFIG_POWER_DOMAIN=y
@@ -59,7 +60,6 @@ CONFIG_USB=y CONFIG_DM_USB=y CONFIG_USB_XHCI_HCD=y CONFIG_USB_XHCI_DWC3=y -CONFIG_USB_XHCI_DWC3_OF_SIMPLE=y CONFIG_USB_DWC3=y # CONFIG_USB_DWC3_GADGET is not set CONFIG_USB_KEYBOARD=y
configs/p212_defconfig +1 -1
@@ -34,6 +34,7 @@ CONFIG_DM_ETH=y CONFIG_ETH_DESIGNWARE=y CONFIG_PHY=y CONFIG_MESON_GXL_USB_PHY=y +CONFIG_USB_DWC3_MESON_GXL=y CONFIG_PINCTRL=y CONFIG_PINCTRL_MESON_GXL=y CONFIG_DM_REGULATOR=y
@@ -46,6 +47,5 @@ CONFIG_USB=y CONFIG_DM_USB=y CONFIG_USB_XHCI_HCD=y CONFIG_USB_XHCI_DWC3=y -CONFIG_USB_XHCI_DWC3_OF_SIMPLE=y CONFIG_USB_DWC3=y CONFIG_OF_LIBFDT_OVERLAY=y
Signature · 1 line
2.22.0
PATCH 4/8 phy: meson-gxl: remove invalid USB3 PHY driver
In reply to Neil ArmstrongThe registers which are managed by the meson-gxl-usb3 PHY driver are actually "USB control" registers (which are "glue" registers which manage OTG detection and routing of the OTG capable port between the DWC2 peripheral-only controller and the DWC3 host-only controller).
Drop the meson-gxl-usb3 PHY driver now that the dwc3-meson-gxl-usb driver supports the USB control registers on GXL and GXM SoCs (these were previously managed by the meson-gxl-usb3 PHY driver).
--- arch/arm/include/asm/arch-meson/usb-gx.h | 1 - drivers/phy/Makefile | 2 +- drivers/phy/meson-gxl-usb3.c | 219 ----------------------- 3 files changed, 1 insertion(+), 221 deletions(-) delete mode 100644 drivers/phy/meson-gxl-usb3.c
arch/arm/include/asm/arch-meson/usb-gx.h +0 -1
@@ -11,7 +11,6 @@/* TOFIX add set_mode to struct phy_ops */ void phy_meson_gxl_usb2_set_mode (struct phy *phy,enum usb_dr_mode mode); -void phy_meson_gxl_usb3_set_mode (struct phy *phy,enum usb_dr_mode mode);int dwc3_meson_gxl_force_mode (struct udevice *dev,enum usb_dr_mode mode);
drivers/phy/Makefile +1 -1
@@ -17,7 +17,7 @@ obj-$(CONFIG_PHY_RCAR_GEN2) += phy-rcar-gen2.o obj-$(CONFIG_PHY_RCAR_GEN3) += phy-rcar-gen3.o obj-$(CONFIG_PHY_STM32_USBPHYC) += phy-stm32-usbphyc.o obj-$(CONFIG_MESON_GXBB_USB_PHY) += meson-gxbb-usb2.o -obj-$(CONFIG_MESON_GXL_USB_PHY) += meson-gxl-usb2.o meson-gxl-usb3.o +obj-$(CONFIG_MESON_GXL_USB_PHY) += meson-gxl-usb2.o obj-$(CONFIG_MESON_G12A_USB_PHY) += meson-g12a-usb2.o meson-g12a-usb3-pcie.o obj-$(CONFIG_MSM8916_USB_PHY) += msm8916-usbh-phy.o obj-$(CONFIG_OMAP_USB2_PHY) += omap-usb2-phy.o
drivers/phy/meson-gxl-usb3.c deleted +0 -219
219 lines not on this page · raw message
Signature · 1 line
2.22.0
PATCH 5/8 phy: meson-gxl-usb: depend on Meson AXG aswell
In reply to Neil ArmstrongEnable build of meson-gxl-usb PHY for the AXG architecture aswell.
--- drivers/phy/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/phy/Kconfig +1 -1
@@ -164,7 +164,7 @@ config MESON_GXBB_USB_PHY config MESON_GXL_USB_PHY bool "Amlogic Meson GXL USB PHYs" - depends on PHY && ARCH_MESON && (MESON_GXL || MESON_GXM) + depends on PHY && ARCH_MESON && (MESON_GXL || MESON_GXM || MESON_AXG) imply REGMAP help This is the generic phy driver for the Amlogic Meson GXL
Signature · 1 line
2.22.0
PATCH 6/8 arm: meson-axg: add board_usb_init()/cleanup() for USB gadget
In reply to Neil ArmstrongAdd the board_usb_init()/cleanup() for USB gadget for AXG based on the code for the G12A architecture.
--- arch/arm/mach-meson/board-axg.c | 128 ++++++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+)
arch/arm/mach-meson/board-axg.c +128 -0
@@ -14,6 +14,11 @@#include <asm/io.h> #include <asm/armv8/mmu.h> #include <linux/sizes.h> +#include <usb.h> +#include <linux/usb/otg.h> +#include <asm/arch/usb-gx.h> +#include <usb/dwc2_udc.h> +#include <clk.h> #include <phy.h> DECLARE_GLOBAL_DATA_PTR ;
@@ -118,3 +123,126 @@ void meson_eth_init(phy_interface_t mode, unsigned int flags)/* Enable power gate */ clrbits_le32 (AXG_MEM_PD_REG_0 ,AXG_MEM_PD_REG_0_ETH_MASK ); } + +#if CONFIG_IS_ENABLED (USB_DWC3_MESON_GXL ) && \ +CONFIG_IS_ENABLED (USB_GADGET_DWC2_OTG ) +static struct dwc2_plat_otg_data meson_gx_dwc2_data; + +int board_usb_init (int index,enum usb_init_type init) +{ +struct fdtdec_phandle_args args; +const void *blob = gd->fdt_blob; +int node, dwc2_node; +struct udevice *dev, *clk_dev; +struct clk clk; +int ret; + +/* find the usb glue node */ + node =fdt_node_offset_by_compatible (blob,-1 , +"amlogic,meson-gxl-usb-ctrl" ); +if (node <0 ) { +debug ("Not found usb-control node\n" ); +return -ENODEV ; + } + +if (!fdtdec_get_is_enabled (blob, node)) { +debug ("usb is disabled in the device tree\n" ); +return -ENODEV ; + } + + ret =uclass_get_device_by_of_offset (UCLASS_SIMPLE_BUS , node, &dev); +if (ret) { +debug ("Not found usb-control device\n" ); +return ret; + } + +/* find the dwc2 node */ + dwc2_node =fdt_node_offset_by_compatible (blob, node, +"amlogic,meson-g12a-usb" ); +if (dwc2_node <0 ) { +debug ("Not found dwc2 node\n" ); +return -ENODEV ; + } + +if (!fdtdec_get_is_enabled (blob, dwc2_node)) { +debug ("dwc2 is disabled in the device tree\n" ); +return -ENODEV ; + } + + meson_gx_dwc2_data.regs_otg =fdtdec_get_addr (blob, dwc2_node,"reg" ); +if (meson_gx_dwc2_data.regs_otg ==FDT_ADDR_T_NONE ) { +debug ("usbotg: can't get base address\n" ); +return -ENODATA ; + } + +/* Enable clock */ + ret =fdtdec_parse_phandle_with_args (blob, dwc2_node,"clocks" , +"#clock-cells" ,0 ,0 , &args); +if (ret) { +debug ("usbotg has no clocks defined in the device tree\n" ); +return ret; + } + + ret =uclass_get_device_by_of_offset (UCLASS_CLK , args.node, &clk_dev); +if (ret) +return ret; + +if (args.args_count !=1 ) { +debug ("Can't find clock ID in the device tree\n" ); +return -ENODATA ; + } + + clk.dev = clk_dev; + clk.id = args.args[0 ]; + + ret =clk_enable (&clk); +if (ret) { +debug ("Failed to enable usbotg clock\n" ); +return ret; + } + + meson_gx_dwc2_data.rx_fifo_sz =fdtdec_get_int (blob, dwc2_node, +"g-rx-fifo-size" ,0 ); + meson_gx_dwc2_data.np_tx_fifo_sz =fdtdec_get_int (blob, dwc2_node, +"g-np-tx-fifo-size" ,0 ); + meson_gx_dwc2_data.tx_fifo_sz =fdtdec_get_int (blob, dwc2_node, +"g-tx-fifo-size" ,0 ); + +/* Switch to peripheral mode */ + ret =dwc3_meson_gxl_force_mode (dev,USB_DR_MODE_PERIPHERAL ); +if (ret) +return ret; + +return dwc2_udc_probe (&meson_gx_dwc2_data); +} + +int board_usb_cleanup (int index,enum usb_init_type init) +{ +const void *blob = gd->fdt_blob; +struct udevice *dev; +int node; +int ret; + +/* find the usb glue node */ + node =fdt_node_offset_by_compatible (blob,-1 , +"amlogic,meson-gxl-usb-ctrl" ); +if (node <0 ) { +debug ("Not found usb-control node\n" ); +return -ENODEV ; + } + +if (!fdtdec_get_is_enabled (blob, node)) +return -ENODEV ; + + ret =uclass_get_device_by_of_offset (UCLASS_SIMPLE_BUS , node, &dev); +if (ret) +return ret; + +/* Switch to OTG mode */ + ret =dwc3_meson_gxl_force_mode (dev,USB_DR_MODE_HOST ); +if (ret) +return ret; + +return 0 ; +} +#endif
Signature · 1 line
2.22.0
PATCH 7/8 ARM: dts: meson-axg: add USB nodes for S400
In reply to Neil ArmstrongAdd the correcly architectured USB Glue node for Meson AXG and the S400 board in -u-boot.dtsi until support in upstream Linux then backported.
--- arch/arm/dts/meson-axg-s400-u-boot.dtsi | 12 +++++ arch/arm/dts/meson-axg-u-boot.dtsi | 62 +++++++++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 arch/arm/dts/meson-axg-u-boot.dtsi
arch/arm/dts/meson-axg-s400-u-boot.dtsi +12 -0
@@ -3,6 +3,8 @@ * Copyright (c) 2017 Amlogic, Inc. All rights reserved. */ +#include "meson-axg-u-boot.dtsi" + /* wifi module */ &sd_emmc_b { status = "disabled";
@@ -12,3 +14,13 @@ &sd_emmc_c { status = "okay"; }; + +&usb { + status = "okay"; + dr_mode = "otg"; + vbus-supply = <&usb_pwr>; +}; + +&usb2_phy1 { + phy-supply = <&vcc_5v>; +};
arch/arm/dts/meson-axg-u-boot.dtsi new file +62 -0
62 lines not on this page · raw message
Signature · 1 line
2.22.0
PATCH 8/8 configs: s400: enable USB
In reply to Neil ArmstrongEnable USB Host & Gadget on the Amlogic S400 board.
--- configs/s400_defconfig | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
configs/s400_defconfig +15 -0
@@ -18,6 +18,8 @@ CONFIG_MISC_INIT_R=y CONFIG_CMD_GPIO=y # CONFIG_CMD_LOADS is not set CONFIG_CMD_MMC=y +CONFIG_CMD_USB=y +CONFIG_CMD_USB_MASS_STORAGE=y # CONFIG_CMD_SETEXPR is not set CONFIG_CMD_REGULATOR=y CONFIG_OF_CONTROL=y
@@ -28,6 +30,7 @@ CONFIG_MMC_MESON_GX=y CONFIG_PHY_REALTEK=y CONFIG_DM_ETH=y CONFIG_ETH_DESIGNWARE=y +CONFIG_MESON_GXL_USB_PHY=y CONFIG_PINCTRL=y CONFIG_PINCTRL_MESON_AXG=y CONFIG_DM_REGULATOR=y
@@ -36,4 +39,16 @@ CONFIG_DM_RESET=y CONFIG_DEBUG_UART_ANNOUNCE=y CONFIG_DEBUG_UART_SKIP_INIT=y CONFIG_MESON_SERIAL=y +CONFIG_USB=y +CONFIG_DM_USB=y +CONFIG_USB_XHCI_HCD=y +CONFIG_USB_XHCI_DWC3=y +CONFIG_USB_DWC3=y +# CONFIG_USB_DWC3_GADGET is not set +CONFIG_USB_DWC3_MESON_GXL=y +CONFIG_USB_GADGET=y +CONFIG_USB_GADGET_VENDOR_NUM=0x1b8e +CONFIG_USB_GADGET_PRODUCT_NUM=0xfada +CONFIG_USB_GADGET_DWC2_OTG=y +CONFIG_USB_GADGET_DOWNLOAD=y CONFIG_OF_LIBFDT_OVERLAY=y
Signature · 1 line
2.22.0
cover ARM: mach-meson: update & rework USB for GXL, GXM & AXG
In reply to Neil ArmstrongQuoted 61 lines · Neil Armstrong
This serie follows the recent work under Linux to rework and update support of the USB complex in the Amlogic GXL, GXM & AXG SoCs.
This rework follows the clean implementation for the G12A & following SoCs to support Host, Device & OTG functionnality.
The GXL, GXM & AXG USB complex is architectured in the same was as the G12A & later USB complex, thus we can use the same architecture but adapted to the different init & config flow found in the Amlogic GXL, GXM & AXG SoCs.
With this patchset, USB Host functionnality is retained, working & tested on the Khadas VIM2 (GXM), Libretech-CC (GXL) & S400 (AXG), with Device mode added and tested by using the UMS gadget.
Neil Armstrong (8):
ARM: dts: sync amlogic AXG/GXL/GXM DT from Linux 5.8-rc1
usb: dwc3: add Amlogic GXL & GXL DWC3 Glue
ARM: mach-meson: use new DWC3 glue for GXL & GXM
phy: meson-gxl: remove invalid USB3 PHY driver
phy: meson-gxl-usb: depend on Meson AXG aswell
arm: meson-axg: add board_usb_init()/cleanup() for USB gadget
ARM: dts: meson-axg: add USB nodes for S400
configs: s400: enable USBarch/arm/dts/meson-axg-s400-u-boot.dtsi | 12 + arch/arm/dts/meson-axg-u-boot.dtsi | 62 +++ arch/arm/dts/meson-axg.dtsi | 6 +- arch/arm/dts/meson-gx-libretech-pc.dtsi | 78 +++- arch/arm/dts/meson-gx.dtsi | 23 +- arch/arm/dts/meson-gxbb-nanopi-k2.dts | 2 +- arch/arm/dts/meson-gxbb-odroidc2.dts | 2 +- arch/arm/dts/meson-gxbb.dtsi | 23 + .../meson-gxl-s805x-libretech-ac-u-boot.dtsi | 4 - arch/arm/dts/meson-gxl-s805x-libretech-ac.dts | 73 ++- .../meson-gxl-s905d-libretech-pc-u-boot.dtsi | 4 - .../meson-gxl-s905x-khadas-vim-u-boot.dtsi | 4 - arch/arm/dts/meson-gxl-s905x-khadas-vim.dts | 4 + .../meson-gxl-s905x-libretech-cc-u-boot.dtsi | 4 - arch/arm/dts/meson-gxl-s905x-libretech-cc.dts | 77 +++- arch/arm/dts/meson-gxl-s905x-p212.dtsi | 3 +- arch/arm/dts/meson-gxl-u-boot.dtsi | 16 - arch/arm/dts/meson-gxl.dtsi | 79 +++- .../arm/dts/meson-gxm-khadas-vim2-u-boot.dtsi | 4 - arch/arm/dts/meson-gxm-khadas-vim2.dts | 3 +- .../meson-gxm-s912-libretech-pc-u-boot.dtsi | 4 - arch/arm/dts/meson-gxm.dtsi | 7 +- arch/arm/include/asm/arch-meson/usb-gx.h | 3 +- arch/arm/mach-meson/board-axg.c | 128 ++++++ arch/arm/mach-meson/board-gx.c | 127 +++--- configs/khadas-vim2_defconfig | 2 +- configs/khadas-vim_defconfig | 2 +- configs/libretech-ac_defconfig | 2 +- configs/libretech-cc_defconfig | 2 +- configs/libretech-s905d-pc_defconfig | 2 +- configs/libretech-s912-pc_defconfig | 2 +- configs/p212_defconfig | 2 +- configs/s400_defconfig | 15 + drivers/phy/Kconfig | 2 +- drivers/phy/Makefile | 2 +- drivers/phy/meson-gxl-usb3.c | 219 --------- drivers/usb/dwc3/Kconfig | 8 + drivers/usb/dwc3/Makefile | 1 +
Quoted 9 lines
drivers/usb/dwc3/dwc3-meson-gxl.c | 425 ++++++++++++++++++ .../reset/amlogic,meson-gxbb-reset.h | 2 +- include/dt-bindings/sound/meson-aiu.h | 18 + 41 files changed, 1092 insertions(+), 366 deletions(-) create mode 100644 arch/arm/dts/meson-axg-u-boot.dtsi delete mode 100644 drivers/phy/meson-gxl-usb3.c create mode 100644 drivers/usb/dwc3/dwc3-meson-gxl.c create mode 100644 include/dt-bindings/sound/meson-aiu.h
Applied to u-boot-amlogic-next