2019-12-11 01:57:18

by Min Guo

[permalink] [raw]
Subject: [PATCH v9 0/6] Add MediaTek MUSB Controller Driver

From: Min Guo <[email protected]>

These patches introduce the MediaTek MUSB controller driver.

The driver can be configured as Dual-Role Device (DRD),
Peripheral Only and Host Only modes. This has beed tested on
MT2701 with a variety of devices in host mode and with the
f_mass gadget driver in peripheral mode, plugging otg cables
in/out a lot of times in all possible imaginable plug orders.

changes in v9:
changes of dt-bindings and DTS:
1. Add usb-role-switch
2. Remove label of usb connector child node
3. Change usb connector child node compatible as "gpio-usb-b-connector", "usb-b-connector";

changes in v8:
changes of dt-bindings:
1.Add reviewed by Rob

changes in v7:
changes of dt-bindings and DTS:
1. Change compatible string
2. Change usb connector child node compatible as "gpio-usb-b-connector"

changes in v6:
changes of dt-bindings:
1. Modify usb connector child node
changes of DTS:
1. Modify usb connector child node
changes of driver:
1. Add of_platform_populate in probe to populate connector platform_devices
from device tree data
2. Replace extcon with usb role switch mechanism to support dual-role mode,
depends on [1]
3. Remove set vbus function

[1] [v6,09/10] usb: roles: add USB Type-B GPIO connector driver
https://patchwork.kernel.org/patch/10966361/

changes in v5:
changes of dt-bindings suggested by Rob:
1. Modify compatible as
- compatible : should be one of:
"mediatek,mt-2701"
...
followed by "mediatek,mtk-musb"
2. Add usb connector child node
changes of DTS:
1. Add usb connector child node
changes of driver suggested by Bin:
1. Replace musb_readb() with musb_clearb() to clear dma pending interrupts
2. Replace musb_readb() with musb_clearb() to clear common/tx/rx pending interrupts
3. Make musb_clearb/w() return the value of musb_readb/w()

changes in v4:
changes of dt-bindings suggested by Sergei:
1. String alignment
changes of driver suggested by Tony and Bin:
1. Add a new patch for set/get_toggle()
2. Add a new patch for noirq type of dma
3. Add a new patch musb_clearb/w()
4. Abondon patch "usb: musb: Delete the const attribute of addr parameter in readb/w/l hooks"

changes in v3:
changes of driver suggested by Bin:
1. Add a new patch for musb_readb/w/l() to remove const attribute
2. Use is_out as function parameter in set_toggle/get_toggle() hooks
3. Remove 'u8/u16 data' parameter in clearb/w() hooks
4. Remove musb_default_clearb/w()
5. Replace musb_readb/w() with musb_clearb/w() to clear pending interrupts
6. Add comments to clearb/w() hooks
7. Replace musb_save_toggle() with musb->io.get_toggle()
8. Replace musb_set_toggle() with musb->io.set_toggle()

changes in v2:
changes of dt-bindings suggested by Rob and Bin:
1. Modify DRC to DRD
2. Drop the "<soc-model>-musb" in compatible
3. Remove phy-names
4. Add space after comma in clock-names
dtsi:
1. Remove phy-names
changes of driver suggested by Bin:
1. Add a new patch for musb_set_toggle
2. Add summarize of MediaTek musb controller differences in the commit log
3. Abondon patch "usb: musb: Move musbhsdma macro definition to musb_dma.h"
4. Add "|| COMPILE_TEST" in Kconfig
5. Add musb_clearb() and musb_clearw() hooks
6. Add get_toggle() and set_toggle() hooks
7. Replace musb_readl() with musb_readw() to read 16bit toggle register
8. Move MediaTek's private toggle registers from musb_regs.h to mediatek.c
9. Create musbhs_dma_controller_create_noirq()

Min Guo (6):
dt-bindings: usb: musb: Add support for MediaTek musb controller
arm: dts: mt2701: Add usb2 device nodes
usb: musb: Add get/set toggle hooks
usb: musb: Add noirq type of dma create interface
usb: musb: Add musb_clearb/w() interface
usb: musb: Add support for MediaTek musb controller

.../devicetree/bindings/usb/mediatek,musb.txt | 57 ++
arch/arm/boot/dts/mt2701-evb.dts | 21 +
arch/arm/boot/dts/mt2701.dtsi | 33 +
drivers/usb/musb/Kconfig | 9 +-
drivers/usb/musb/Makefile | 1 +
drivers/usb/musb/mediatek.c | 582 ++++++++++++++++++
drivers/usb/musb/musb_core.c | 74 ++-
drivers/usb/musb/musb_core.h | 13 +-
drivers/usb/musb/musb_dma.h | 9 +
drivers/usb/musb/musb_host.c | 46 +-
drivers/usb/musb/musb_io.h | 12 +-
drivers/usb/musb/musbhsdma.c | 56 +-
drivers/usb/musb/sunxi.c | 4 +-
drivers/usb/musb/tusb6010.c | 2 +-
14 files changed, 847 insertions(+), 72 deletions(-)
create mode 100644 Documentation/devicetree/bindings/usb/mediatek,musb.txt
create mode 100644 drivers/usb/musb/mediatek.c

--
2.24.0


2019-12-11 01:57:55

by Min Guo

[permalink] [raw]
Subject: [PATCH v9 1/6] dt-bindings: usb: musb: Add support for MediaTek musb controller

From: Min Guo <[email protected]>

This adds support for MediaTek musb controller in
host, peripheral and otg mode.

Signed-off-by: Min Guo <[email protected]>
---
changes in v9:
1. Add usb-role-switch
2. Remove label of usb connector child node
3. Change usb connector child node compatible as "gpio-usb-b-connector", "usb-b-connector";

changes in v8:
1. Add reviewed by Rob

changes in v7:
1. Modify compatible as
- compatible : should be one of:
"mediatek,mt2701-musb"
...
followed by "mediatek,mtk-musb"
2. Change usb connector child node compatible as "gpio-usb-b-connector"

changes in v6:
1. Modify usb connector child node

changes in v5:
suggested by Rob:
1. Modify compatible as
- compatible : should be one of:
"mediatek,mt-2701"
...
followed by "mediatek,mtk-musb"
2. Add usb connector child node

changes in v4:
suggested by Sergei:
1. String alignment

changes in v3:
1. no changes

changes in v2:
suggested by Bin:
1. Modify DRC to DRD
suggested by Rob:
2. Drop the "<soc-model>-musb" in compatible
3. Remove phy-names
4. Add space after comma in clock-names
---
.../devicetree/bindings/usb/mediatek,musb.txt | 57 +++++++++++++++++++
1 file changed, 57 insertions(+)
create mode 100644 Documentation/devicetree/bindings/usb/mediatek,musb.txt

diff --git a/Documentation/devicetree/bindings/usb/mediatek,musb.txt b/Documentation/devicetree/bindings/usb/mediatek,musb.txt
new file mode 100644
index 000000000000..2b8a87c90d9e
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/mediatek,musb.txt
@@ -0,0 +1,57 @@
+MediaTek musb DRD/OTG controller
+-------------------------------------------
+
+Required properties:
+ - compatible : should be one of:
+ "mediatek,mt2701-musb"
+ ...
+ followed by "mediatek,mtk-musb"
+ - reg : specifies physical base address and size of
+ the registers
+ - interrupts : interrupt used by musb controller
+ - interrupt-names : must be "mc"
+ - phys : PHY specifier for the OTG phy
+ - dr_mode : should be one of "host", "peripheral" or "otg",
+ refer to usb/generic.txt
+ - clocks : a list of phandle + clock-specifier pairs, one for
+ each entry in clock-names
+ - clock-names : must contain "main", "mcu", "univpll"
+ for clocks of controller
+
+Optional properties:
+ - power-domains : a phandle to USB power domain node to control USB's
+ MTCMOS
+
+Required child nodes:
+ usb connector node as defined in bindings/connector/usb-connector.txt
+Optional properties:
+ - id-gpios : input GPIO for USB ID pin.
+ - vbus-gpios : input GPIO for USB VBUS pin.
+ - vbus-supply : reference to the VBUS regulator, needed when supports
+ dual-role mode
+ - usb-role-switch : use USB Role Switch to support dual-role switch, see
+ usb/generic.txt.
+
+Example:
+
+usb2: usb@11200000 {
+ compatible = "mediatek,mt2701-musb",
+ "mediatek,mtk-musb";
+ reg = <0 0x11200000 0 0x1000>;
+ interrupts = <GIC_SPI 32 IRQ_TYPE_LEVEL_LOW>;
+ interrupt-names = "mc";
+ phys = <&u2port2 PHY_TYPE_USB2>;
+ dr_mode = "otg";
+ clocks = <&pericfg CLK_PERI_USB0>,
+ <&pericfg CLK_PERI_USB0_MCU>,
+ <&pericfg CLK_PERI_USB_SLV>;
+ clock-names = "main","mcu","univpll";
+ power-domains = <&scpsys MT2701_POWER_DOMAIN_IFR_MSC>;
+ usb-role-switch;
+ connector{
+ compatible = "gpio-usb-b-connector", "usb-b-connector";
+ type = "micro";
+ id-gpios = <&pio 44 GPIO_ACTIVE_HIGH>;
+ vbus-supply = <&usb_vbus>;
+ };
+};
--
2.24.0

2019-12-13 19:04:42

by Rob Herring (Arm)

[permalink] [raw]
Subject: Re: [PATCH v9 1/6] dt-bindings: usb: musb: Add support for MediaTek musb controller

On Wed, Dec 11, 2019 at 09:54:41AM +0800, [email protected] wrote:
> From: Min Guo <[email protected]>
>
> This adds support for MediaTek musb controller in
> host, peripheral and otg mode.
>
> Signed-off-by: Min Guo <[email protected]>
> ---
> changes in v9:
> 1. Add usb-role-switch
> 2. Remove label of usb connector child node
> 3. Change usb connector child node compatible as "gpio-usb-b-connector", "usb-b-connector";
>
> changes in v8:
> 1. Add reviewed by Rob
>
> changes in v7:
> 1. Modify compatible as
> - compatible : should be one of:
> "mediatek,mt2701-musb"
> ...
> followed by "mediatek,mtk-musb"
> 2. Change usb connector child node compatible as "gpio-usb-b-connector"
>
> changes in v6:
> 1. Modify usb connector child node
>
> changes in v5:
> suggested by Rob:
> 1. Modify compatible as
> - compatible : should be one of:
> "mediatek,mt-2701"
> ...
> followed by "mediatek,mtk-musb"
> 2. Add usb connector child node
>
> changes in v4:
> suggested by Sergei:
> 1. String alignment
>
> changes in v3:
> 1. no changes
>
> changes in v2:
> suggested by Bin:
> 1. Modify DRC to DRD
> suggested by Rob:
> 2. Drop the "<soc-model>-musb" in compatible
> 3. Remove phy-names
> 4. Add space after comma in clock-names
> ---
> .../devicetree/bindings/usb/mediatek,musb.txt | 57 +++++++++++++++++++
> 1 file changed, 57 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/usb/mediatek,musb.txt

Reviewed-by: Rob Herring <[email protected]>