Add support for nuvoton ma35 usb2 phy
v2 cover Add support for nuvoton ma35 usb2 phy
This patch series adds the usb2 phy driver for the nuvoton ma35 ARMv8 SoC. It includes DT binding documentation and the ma35 usb2 phy driver.
v2:
- Update nuvoton,ma35d1-usb2-phy.yaml
- Update the 'nuvoton,ma35-usb2-phy' to 'nuvoton,ma35d1-usb2-phy'.
- Remove unnecessary descriptions.
- Add explanations related to SYS.
- Update ma35d1 usb2 phy driver
- Update the 'nuvoton,ma35-usb2-phy' to 'nuvoton,ma35d1-usb2-phy'.
- Use readl_poll_timeout() to make the system more efficient and the code more streamlined.
- Use the same variable name. Update the 'p_phy->dev' to 'pdev->dev'.
Hui-Ping Chen (2):
dt-bindings: phy: nuvoton,ma35-usb2-phy: add new bindings
phy: nuvoton: add new driver for the Nuvoton MA35 SoC USB 2.0 PHY
.../bindings/phy/nuvoton,ma35d1-usb2-phy.yaml | 47 ++++++ drivers/phy/Kconfig | 1 + drivers/phy/Makefile | 1 + drivers/phy/nuvoton/Kconfig | 13 ++ drivers/phy/nuvoton/Makefile | 3 + drivers/phy/nuvoton/phy-ma35d1-usb2.c | 146 ++++++++++++++++++ 6 files changed, 211 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/nuvoton,ma35d1-usb2-phy.yaml create mode 100644 drivers/phy/nuvoton/Kconfig create mode 100644 drivers/phy/nuvoton/Makefile create mode 100644 drivers/phy/nuvoton/phy-ma35d1-usb2.c
Signature · 1 line
2.25.1
PATCH v2 1/2 dt-bindings: phy: nuvoton,ma35-usb2-phy: add new bindings
Add dt-bindings for USB2 PHY found on the Nuvoton MA35 SoC.
--- .../bindings/phy/nuvoton,ma35d1-usb2-phy.yaml | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/nuvoton,ma35d1-usb2-phy.yaml
Documentation/devicetree/bindings/phy/nuvoton,ma35d1-usb2-phy.yaml new file +47 -0
@@ -0,0 +1,47 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/phy/nuvoton,ma35d1-usb2-phy.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Nuvoton MA35D1 USB2 phy + +maintainers: + - Hui-Ping Chen <[email protected]> + +properties: + compatible: + enum: + - nuvoton,ma35d1-usb2-phy + + "#phy-cells": + const: 0 + + clocks: + maxItems: 1 + + nuvoton,sys: + $ref: /schemas/types.yaml#/definitions/phandle + description: + phandle of the system-management node. + This driver has some status bits located in the sys, + it is necessary to reference the sys link. + +required: + - compatible + - "#phy-cells" + - clocks + - nuvoton,sys + +additionalProperties: false + +examples: + - | + #include <dt-bindings/clock/nuvoton,ma35d1-clk.h> + + usb_phy: usb-phy { + compatible = "nuvoton,ma35d1-usb2-phy"; + clocks = <&clk USBD_GATE>; + nuvoton,sys = <&sys>; + #phy-cells = <0>; + };
Signature · 1 line
2.25.1
Re: [PATCH v2 1/2] dt-bindings: phy: nuvoton,ma35-usb2-phy: add new bindings
Quoted 31 lines · Hui-Ping Chen
Add dt-bindings for USB2 PHY found on the Nuvoton MA35 SoC.
Signed-off-by Hui-Ping Chen <[email protected]>--- .../bindings/phy/nuvoton,ma35d1-usb2-phy.yaml | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/nuvoton,ma35d1-usb2-phy.yamlDocumentation/devicetree/bindings/phy/nuvoton,ma35d1-usb2-phy.yaml new file +17
-0@@ -0,0 +1,47 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/phy/nuvoton,ma35d1-usb2-phy.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Nuvoton MA35D1 USB2 phy + +maintainers: + - Hui-Ping Chen <[email protected]> + +properties: + compatible: + enum: + - nuvoton,ma35d1-usb2-phy + + "#phy-cells":
Documentation/devicetree/bindings/phy/nuvoton,ma35d1-usb2-phy.yaml line 27
Quoted 10 lines
Documentation/devicetree/bindings/phy/nuvoton,ma35d1-usb2-phy.yaml new file +10
-0+ const: 0 + + clocks: + maxItems: 1 + + nuvoton,sys: + $ref: /schemas/types.yaml#/definitions/phandle + description: + phandle of the system-management node. + This driver has some status bits located in the sys,
Do not reference drivers, but hardware.
Documentation/devicetree/bindings/phy/nuvoton,ma35d1-usb2-phy.yaml line 28
Quoted 1 line
Documentation/devicetree/bindings/phy/nuvoton,ma35d1-usb2-phy.yaml new file +1
-0+ it is necessary to reference the sys link.
This tells me nothing. You must be specific - WHAT IS THE PURPOSE of this syscon usage in USB2 PHY?
Best regards,
Krzysztof
Re: [PATCH v2 1/2] dt-bindings: phy: nuvoton,ma35-usb2-phy: add new bindings
Dear Krzysztof,
Thank you for your reply.
Quoted 35 lines · Krzysztof Kozlowski
Quoted 34 lines · Hui-Ping Chen
Add dt-bindings for USB2 PHY found on the Nuvoton MA35 SoC.
Signed-off-by Hui-Ping Chen <[email protected]>--- .../bindings/phy/nuvoton,ma35d1-usb2-phy.yaml | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+)create mode 100644
Documentation/devicetree/bindings/phy/nuvoton,ma35d1-usb2-phy.yamlDocumentation/devicetree/bindings/phy/nuvoton,ma35d1-usb2-phy.yaml new file +20
-0@@ -0,0 +1,47 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/phy/nuvoton,ma35d1-usb2-phy.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Nuvoton MA35D1 USB2 phy + +maintainers: + - Hui-Ping Chen <[email protected]> + +properties: + compatible: + enum: + - nuvoton,ma35d1-usb2-phy + + "#phy-cells": + const: 0 + + clocks:
Quoted 8 lines
Documentation/devicetree/bindings/phy/nuvoton,ma35d1-usb2-phy.yaml line 27
Quoted 7 lines
Documentation/devicetree/bindings/phy/nuvoton,ma35d1-usb2-phy.yaml new file +7
-0+ maxItems: 1 + + nuvoton,sys: + $ref: /schemas/types.yaml#/definitions/phandle + description: + phandle of the system-management node. + This driver has some status bits located in the sys,Do not reference drivers, but hardware.
Okay. I will revise the description.
Quoted 3 lines
Documentation/devicetree/bindings/phy/nuvoton,ma35d1-usb2-phy.yaml line 28
Quoted 1 line
Documentation/devicetree/bindings/phy/nuvoton,ma35d1-usb2-phy.yaml new file +1
-0+ it is necessary to reference the sys link.This tells me nothing. You must be specific - WHAT IS THE PURPOSE of this syscon usage in USB2 PHY?
Sorry, I misunderstood. I will correct the description.
Thank you for the reminder.
Quoted 2 lines
Best regards,
Krzysztof
Best regards,
Hui-Ping Chen
PATCH v2 2/2 phy: nuvoton: add new driver for the Nuvoton MA35 SoC USB 2.0 PHY
In reply to Hui-Ping ChenNuvoton MA35 SoCs support DWC2 USB controller. Add the driver to drive the USB 2.0 PHY transceivers.
--- drivers/phy/Kconfig | 1 + drivers/phy/Makefile | 1 + drivers/phy/nuvoton/Kconfig | 13 +++ drivers/phy/nuvoton/Makefile | 3 + drivers/phy/nuvoton/phy-ma35d1-usb2.c | 146 ++++++++++++++++++++++++++ 5 files changed, 164 insertions(+) create mode 100644 drivers/phy/nuvoton/Kconfig create mode 100644 drivers/phy/nuvoton/Makefile create mode 100644 drivers/phy/nuvoton/phy-ma35d1-usb2.c
drivers/phy/Kconfig +1 -0
@@ -95,6 +95,7 @@ source "drivers/phy/mediatek/Kconfig" source "drivers/phy/microchip/Kconfig" source "drivers/phy/motorola/Kconfig" source "drivers/phy/mscc/Kconfig" +source "drivers/phy/nuvoton/Kconfig" source "drivers/phy/qualcomm/Kconfig" source "drivers/phy/ralink/Kconfig" source "drivers/phy/realtek/Kconfig"
drivers/phy/Makefile +1 -0
@@ -25,6 +25,7 @@ obj-y += allwinner/ \ microchip/ \ motorola/ \ mscc/ \ + nuvoton/ \ qualcomm/ \ ralink/ \ realtek/ \
drivers/phy/nuvoton/Kconfig new file +13 -0
@@ -0,0 +1,13 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# PHY drivers for Nuvoton MA35 platforms +# +config PHY_MA35_USB + tristate "Nuvoton MA35 USB2.0 PHY driver" + depends on ARCH_MA35 || COMPILE_TEST + depends on OF + select GENERIC_PHY + help + Enable this to support the USB2.0 PHY on the Nuvoton MA35 + series SoCs. +
drivers/phy/nuvoton/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0 + +obj-$(CONFIG_PHY_MA35_USB) += phy-ma35d1-usb2.o
drivers/phy/nuvoton/phy-ma35d1-usb2.c new file +146 -0
146 lines not on this page · raw message
Signature · 1 line
2.25.1
Re: [PATCH v2 2/2] phy: nuvoton: add new driver for the Nuvoton MA35 SoC USB 2.0 PHY
Quoted 21 lines · Hui-Ping Chen
Nuvoton MA35 SoCs support DWC2 USB controller. Add the driver to drive the USB 2.0 PHY transceivers.
Signed-off-by Hui-Ping Chen <[email protected]>drivers/phy/nuvoton/phy-ma35d1-usb2.c new file +15
-0+struct ma35_usb_phy { +struct clk *clk; +struct device *dev; +struct regmap *sysreg; +}; + +static int ma35_usb_phy_power_on (struct phy *phy) +{ +struct ma35_usb_phy *p_phy =phy_get_drvdata (phy); +unsigned int val; +int ret; + + ret =clk_prepare_enable (p_phy->clk); +if (ret <0 ) { +dev_err (p_phy->dev,"Failed to enable PHY clock: %d\n" , ret);
drivers/phy/nuvoton/phy-ma35d1-usb2.c line 48
Quoted 10 lines
drivers/phy/nuvoton/phy-ma35d1-usb2.c new file +10
-0+return ret; + } + +regmap_read (p_phy->sysreg,MA35_SYS_REG_USBPMISCR , &val); +if (val &PHY0SUSPEND ) { +/* +* USB PHY0 is in operation mode already +* make sure USB PHY 60 MHz UTMI Interface Clock ready +*/ + ret = readl_poll_timeout((void __iomem *)p_phy->sysreg + MA35_SYS_REG_USBPMISCR,
sysreg is a regmap, not io address. How could it possibly work and be tested?!? This cannot work. Test your code *before* sending it.
Quoted 10 lines
drivers/phy/nuvoton/phy-ma35d1-usb2.c new file +10
-0+ val, val & PHY0DEVCKSTB, 1, 100); +if (ret == -ETIMEDOUT ) { +dev_err (p_phy->dev,"1.Check PHY clock, Timeout: %d\n" , val); +return ret; + } +return 0 ; + } + +/* +* reset USB PHY0.
drivers/phy/nuvoton/phy-ma35d1-usb2.c line 68
Quoted 10 lines
drivers/phy/nuvoton/phy-ma35d1-usb2.c new file +10
-0+* wait until USB PHY0 60 MHz UTMI Interface Clock ready +*/ +regmap_update_bits (p_phy->sysreg,MA35_SYS_REG_USBPMISCR ,0x7 , (PHY0POR |PHY0SUSPEND )); +udelay (10 ); + +/* make USB PHY0 enter operation mode */ +regmap_update_bits (p_phy->sysreg,MA35_SYS_REG_USBPMISCR ,0x7 ,PHY0SUSPEND ); + +/* make sure USB PHY 60 MHz UTMI Interface Clock ready */ + ret = readl_poll_timeout((void __iomem *)p_phy->sysreg + MA35_SYS_REG_USBPMISCR,
Same problem.
Best regards,
Krzysztof