Add support for nuvoton ma35 usb2 phy
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.
hpchen0 (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,ma35-usb2-phy.yaml | 51 ++++++ drivers/phy/Kconfig | 1 + drivers/phy/Makefile | 1 + drivers/phy/nuvoton/Kconfig | 13 ++ drivers/phy/nuvoton/Makefile | 3 + drivers/phy/nuvoton/phy-ma35-usb2.c | 160 ++++++++++++++++++ 6 files changed, 229 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/nuvoton,ma35-usb2-phy.yaml create mode 100644 drivers/phy/nuvoton/Kconfig create mode 100644 drivers/phy/nuvoton/Makefile create mode 100644 drivers/phy/nuvoton/phy-ma35-usb2.c
Signature · 1 line
2.25.1
PATCH 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,ma35-usb2-phy.yaml | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/nuvoton,ma35-usb2-phy.yaml
Documentation/devicetree/bindings/phy/nuvoton,ma35-usb2-phy.yaml new file +51 -0
@@ -0,0 +1,51 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/phy/nuvoton,ma35-usb2-phy.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Nuvoton MA35 USB2 phy + +maintainers: + - hpchen0 <[email protected]> + +properties: + compatible: + enum: + - nuvoton,ma35-usb2-phy + + "#phy-cells": + const: 0 + + clocks: + maxItems: 1 + description: USB PHY clock + + clock-names: + const: usbd_gate + + nuvoton,sys: + $ref: /schemas/types.yaml#/definitions/phandle + description: + phandle of the system-management node. + +required: + - compatible + - clocks + - nuvoton,sys + - "#phy-cells" + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/clock/nuvoton,ma35d1-clk.h> + + usb_phy: usb-phy { + compatible = "nuvoton,ma35-usb2-phy"; + clocks = <&clk USBD_GATE>; + clock-names = "usbd_gate"; + nuvoton,sys = <&sys>; + #phy-cells = <0>; + };
Signature · 1 line
2.25.1
Re: [PATCH 1/2] dt-bindings: phy: nuvoton,ma35-usb2-phy: add new bindings
Quoted 3 lines · On 29/07/2024 08:15, hpchen0 wrote:
Add dt-bindings for USB2 PHY found on the Nuvoton MA35 SoC.
Signed-off-by hpchen0 <[email protected]>
Please use proper name.
Quoted 11 lines
--- .../bindings/phy/nuvoton,ma35-usb2-phy.yaml | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/nuvoton,ma35-usb2-phy.yamlDocumentation/devicetree/bindings/phy/nuvoton,ma35-usb2-phy.yaml new file +0
-0
Documentation/devicetree/bindings/phy/nuvoton,ma35-usb2-phy.yaml line 10
Quoted 10 lines
Documentation/devicetree/bindings/phy/nuvoton,ma35-usb2-phy.yaml new file +10
-0@@ -0,0 +1,51 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/phy/nuvoton,ma35-usb2-phy.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Nuvoton MA35 USB2 phy + +maintainers: + - hpchen0 <[email protected]>
Same here
Documentation/devicetree/bindings/phy/nuvoton,ma35-usb2-phy.yaml line 15
Quoted 5 lines
Documentation/devicetree/bindings/phy/nuvoton,ma35-usb2-phy.yaml new file +5
-0+ +properties: + compatible: + enum: + - nuvoton,ma35-usb2-phy
All other devices have name ma35d1. Is this a different SoC?
Documentation/devicetree/bindings/phy/nuvoton,ma35-usb2-phy.yaml line 22
Quoted 7 lines
Documentation/devicetree/bindings/phy/nuvoton,ma35-usb2-phy.yaml new file +7
-0+ + "#phy-cells": + const: 0 + + clocks: + maxItems: 1 + description: USB PHY clock
Drop description, it's obvious.
Documentation/devicetree/bindings/phy/nuvoton,ma35-usb2-phy.yaml line 25
Quoted 3 lines
Documentation/devicetree/bindings/phy/nuvoton,ma35-usb2-phy.yaml new file +3
-0+ + clock-names: + const: usbd_gate
Drop clock-names, you do not bring any new information.
Documentation/devicetree/bindings/phy/nuvoton,ma35-usb2-phy.yaml line 30
Quoted 5 lines
Documentation/devicetree/bindings/phy/nuvoton,ma35-usb2-phy.yaml new file +5
-0+ + nuvoton,sys: + $ref: /schemas/types.yaml#/definitions/phandle + description: + phandle of the system-management node.
Describe what is it for.
Documentation/devicetree/bindings/phy/nuvoton,ma35-usb2-phy.yaml line 36
Quoted 6 lines
Documentation/devicetree/bindings/phy/nuvoton,ma35-usb2-phy.yaml new file +6
-0+ +required: + - compatible + - clocks + - nuvoton,sys + - "#phy-cells"
Keep the same order as in properties.
Documentation/devicetree/bindings/phy/nuvoton,ma35-usb2-phy.yaml line 42
Quoted 6 lines
Documentation/devicetree/bindings/phy/nuvoton,ma35-usb2-phy.yaml new file +6
-0+ +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h>
Where do you use it?
Documentation/devicetree/bindings/phy/nuvoton,ma35-usb2-phy.yaml line 51
Quoted 9 lines
Documentation/devicetree/bindings/phy/nuvoton,ma35-usb2-phy.yaml new file +9
-0+ #include <dt-bindings/clock/nuvoton,ma35d1-clk.h> + + usb_phy: usb-phy { + compatible = "nuvoton,ma35-usb2-phy"; + clocks = <&clk USBD_GATE>; + clock-names = "usbd_gate"; + nuvoton,sys = <&sys>; + #phy-cells = <0>; + };
Best regards,
Krzysztof
Re: [PATCH 1/2] dt-bindings: phy: nuvoton,ma35-usb2-phy: add new bindings
Dear Krzysztof,
Thank you for your reply.
Quoted 5 lines · Krzysztof Kozlowski
Quoted 3 lines · On 29/07/2024 08:15, hpchen0 wrote:
Add dt-bindings for USB2 PHY found on the Nuvoton MA35 SoC.
Signed-off-by hpchen0 <[email protected]>Please use proper name.
Okay, I will make the correction and use the correct name.
Quoted 14 lines
Quoted 14 lines
--- .../bindings/phy/nuvoton,ma35-usb2-phy.yaml | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+)create mode 100644
Documentation/devicetree/bindings/phy/nuvoton,ma35-usb2-phy.yamlDocumentation/devicetree/bindings/phy/nuvoton,ma35-usb2-phy.yaml new file +3
-0@@ -0,0 +1,51 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +---
Quoted 8 lines
Documentation/devicetree/bindings/phy/nuvoton,ma35-usb2-phy.yaml line 10
Quoted 7 lines
Documentation/devicetree/bindings/phy/nuvoton,ma35-usb2-phy.yaml new file +7
-0+$id: http://devicetree.org/schemas/phy/nuvoton,ma35-usb2-phy.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Nuvoton MA35 USB2 phy + +maintainers: + - hpchen0 <[email protected]>Same here
Okay, I will make the correction and use the correct name.
Quoted 6 lines
Documentation/devicetree/bindings/phy/nuvoton,ma35-usb2-phy.yaml line 15
Quoted 5 lines
Documentation/devicetree/bindings/phy/nuvoton,ma35-usb2-phy.yaml new file +5
-0+ +properties: + compatible: + enum: + - nuvoton,ma35-usb2-phyAll other devices have name ma35d1. Is this a different SoC?
The SoC is the same as ma35d1. I will modify ma35 to ma35d1.
Originally, I intended to create a series of shared drivers.
Quoted 8 lines
Documentation/devicetree/bindings/phy/nuvoton,ma35-usb2-phy.yaml line 22
Quoted 7 lines
Documentation/devicetree/bindings/phy/nuvoton,ma35-usb2-phy.yaml new file +7
-0+ + "#phy-cells": + const: 0 + + clocks: + maxItems: 1 + description: USB PHY clockDrop description, it's obvious.
Okay, I will remove the description.
Quoted 4 lines
Documentation/devicetree/bindings/phy/nuvoton,ma35-usb2-phy.yaml line 25
Quoted 3 lines
Documentation/devicetree/bindings/phy/nuvoton,ma35-usb2-phy.yaml new file +3
-0+ + clock-names: + const: usbd_gateDrop clock-names, you do not bring any new information.
Okay, I will remove the clock-names.
Quoted 6 lines
Documentation/devicetree/bindings/phy/nuvoton,ma35-usb2-phy.yaml line 30
Quoted 5 lines
Documentation/devicetree/bindings/phy/nuvoton,ma35-usb2-phy.yaml new file +5
-0+ + nuvoton,sys: + $ref: /schemas/types.yaml#/definitions/phandle + description: + phandle of the system-management node.Describe what is it for.
Because this driver has some status bits located in the sys, it is necessary to reference the sys link.
Quoted 7 lines
Documentation/devicetree/bindings/phy/nuvoton,ma35-usb2-phy.yaml line 36
Quoted 6 lines
Documentation/devicetree/bindings/phy/nuvoton,ma35-usb2-phy.yaml new file +6
-0+ +required: + - compatible + - clocks + - nuvoton,sys + - "#phy-cells"Keep the same order as in properties.
Okay, I will correct this issue.
Quoted 7 lines
Documentation/devicetree/bindings/phy/nuvoton,ma35-usb2-phy.yaml line 42
Quoted 6 lines
Documentation/devicetree/bindings/phy/nuvoton,ma35-usb2-phy.yaml new file +6
-0+ +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h>Where do you use it?
This is not used and will be removed. Thanks for the reminder.
Quoted 11 lines
Documentation/devicetree/bindings/phy/nuvoton,ma35-usb2-phy.yaml line 51
Quoted 9 lines
Documentation/devicetree/bindings/phy/nuvoton,ma35-usb2-phy.yaml new file +9
-0+ #include <dt-bindings/clock/nuvoton,ma35d1-clk.h> + + usb_phy: usb-phy { + compatible = "nuvoton,ma35-usb2-phy"; + clocks = <&clk USBD_GATE>; + clock-names = "usbd_gate"; + nuvoton,sys = <&sys>; + #phy-cells = <0>; + };Best regards,
Krzysztof
Best regards,
Hui-Ping Chen
Re: [PATCH 1/2] dt-bindings: phy: nuvoton,ma35-usb2-phy: add new bindings
Quoted 10 lines · Hui-Ping Chen
Quoted 7 lines
Documentation/devicetree/bindings/phy/nuvoton,ma35-usb2-phy.yaml line 30
Quoted 6 lines
Documentation/devicetree/bindings/phy/nuvoton,ma35-usb2-phy.yaml new file +5
-0+ + nuvoton,sys: + $ref: /schemas/types.yaml#/definitions/phandle + description: + phandle of the system-management node.Describe what is it for.
Because this driver has some status bits located in the sys, it is necessary to reference the sys link.
Describe it in the binding - what usb2 phy needs to do in sysmgmt node.
Best regards,
Krzysztof
Re: [PATCH 1/2] dt-bindings: phy: nuvoton,ma35-usb2-phy: add new bindings
Dear Krzysztof,
Thank you for your reply.
Quoted 11 lines · Krzysztof Kozlowski
Quoted 8 lines · Hui-Ping Chen
Quoted 6 lines
Documentation/devicetree/bindings/phy/nuvoton,ma35-usb2-phy.yaml line 30
Quoted 5 lines
Documentation/devicetree/bindings/phy/nuvoton,ma35-usb2-phy.yaml new file +5
-0+ + nuvoton,sys: + $ref: /schemas/types.yaml#/definitions/phandle + description: + phandle of the system-management node.Describe what is it for.
Because this driver has some status bits located in the sys, it is necessary to reference the sys link.
Describe it in the binding - what usb2 phy needs to do in sysmgmt node.
Okay. I will add this description to the binding.
Quoted 3 lines
Best regards,
Krzysztof
Best regards,
Hui-Ping Chen
Re: [PATCH 1/2] dt-bindings: phy: nuvoton,ma35-usb2-phy: add new bindings
In reply to Krzysztof KozlowskiDear Krzysztof,
Thank you for your reply.
Quoted 5 lines · Krzysztof Kozlowski
Quoted 3 lines · On 29/07/2024 08:15, hpchen0 wrote:
Add dt-bindings for USB2 PHY found on the Nuvoton MA35 SoC.
Signed-off-by hpchen0 <[email protected]>Please use proper name.
Okay, I will make the correction and use the correct name.
Quoted 14 lines
Quoted 14 lines
--- .../bindings/phy/nuvoton,ma35-usb2-phy.yaml | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+)create mode 100644
Documentation/devicetree/bindings/phy/nuvoton,ma35-usb2-phy.yamlDocumentation/devicetree/bindings/phy/nuvoton,ma35-usb2-phy.yaml new file +3
-0@@ -0,0 +1,51 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +---
Quoted 8 lines
Documentation/devicetree/bindings/phy/nuvoton,ma35-usb2-phy.yaml line 10
Quoted 7 lines
Documentation/devicetree/bindings/phy/nuvoton,ma35-usb2-phy.yaml new file +7
-0+$id: http://devicetree.org/schemas/phy/nuvoton,ma35-usb2-phy.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Nuvoton MA35 USB2 phy + +maintainers: + - hpchen0 <[email protected]>Same here
Okay, I will make the correction and use the correct name.
Quoted 6 lines
Documentation/devicetree/bindings/phy/nuvoton,ma35-usb2-phy.yaml line 15
Quoted 5 lines
Documentation/devicetree/bindings/phy/nuvoton,ma35-usb2-phy.yaml new file +5
-0+ +properties: + compatible: + enum: + - nuvoton,ma35-usb2-phyAll other devices have name ma35d1. Is this a different SoC?
The SoC is the same as ma35d1. I will modify ma35 to ma35d1.
Originally, I intended to create a series of shared drivers.
Quoted 8 lines
Documentation/devicetree/bindings/phy/nuvoton,ma35-usb2-phy.yaml line 22
Quoted 7 lines
Documentation/devicetree/bindings/phy/nuvoton,ma35-usb2-phy.yaml new file +7
-0+ + "#phy-cells": + const: 0 + + clocks: + maxItems: 1 + description: USB PHY clockDrop description, it's obvious.
Okay, I will remove the description.
Quoted 4 lines
Documentation/devicetree/bindings/phy/nuvoton,ma35-usb2-phy.yaml line 25
Quoted 3 lines
Documentation/devicetree/bindings/phy/nuvoton,ma35-usb2-phy.yaml new file +3
-0+ + clock-names: + const: usbd_gateDrop clock-names, you do not bring any new information.
Okay, I will remove the clock-names.
Quoted 6 lines
Documentation/devicetree/bindings/phy/nuvoton,ma35-usb2-phy.yaml line 30
Quoted 5 lines
Documentation/devicetree/bindings/phy/nuvoton,ma35-usb2-phy.yaml new file +5
-0+ + nuvoton,sys: + $ref: /schemas/types.yaml#/definitions/phandle + description: + phandle of the system-management node.Describe what is it for.
Because this driver has some status bits located in the sys, it is necessary to reference the sys link.
Quoted 7 lines
Documentation/devicetree/bindings/phy/nuvoton,ma35-usb2-phy.yaml line 36
Quoted 6 lines
Documentation/devicetree/bindings/phy/nuvoton,ma35-usb2-phy.yaml new file +6
-0+ +required: + - compatible + - clocks + - nuvoton,sys + - "#phy-cells"Keep the same order as in properties.
Okay, I will correct this issue.
Quoted 7 lines
Documentation/devicetree/bindings/phy/nuvoton,ma35-usb2-phy.yaml line 42
Quoted 6 lines
Documentation/devicetree/bindings/phy/nuvoton,ma35-usb2-phy.yaml new file +6
-0+ +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h>Where do you use it?
This is not used and will be removed. Thanks for the reminder.
Quoted 11 lines
Documentation/devicetree/bindings/phy/nuvoton,ma35-usb2-phy.yaml line 51
Quoted 9 lines
Documentation/devicetree/bindings/phy/nuvoton,ma35-usb2-phy.yaml new file +9
-0+ #include <dt-bindings/clock/nuvoton,ma35d1-clk.h> + + usb_phy: usb-phy { + compatible = "nuvoton,ma35-usb2-phy"; + clocks = <&clk USBD_GATE>; + clock-names = "usbd_gate"; + nuvoton,sys = <&sys>; + #phy-cells = <0>; + };Best regards,
Krzysztof
Best regards,
Hui-Ping Chen
PATCH 2/2 phy: nuvoton: add new driver for the Nuvoton MA35 SoC USB 2.0 PHY
In reply to hpchen0Nuvoton 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-ma35-usb2.c | 160 ++++++++++++++++++++++++++++ 5 files changed, 178 insertions(+) create mode 100644 drivers/phy/nuvoton/Kconfig create mode 100644 drivers/phy/nuvoton/Makefile create mode 100644 drivers/phy/nuvoton/phy-ma35-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-ma35-usb2.o
drivers/phy/nuvoton/phy-ma35-usb2.c new file +160 -0
160 lines not on this page · raw message
Signature · 1 line
2.25.1
Re: [PATCH 2/2] phy: nuvoton: add new driver for the Nuvoton MA35 SoC USB 2.0 PHY
Quoted 15 lines · On 29/07/2024 08:15, hpchen0 wrote:
Nuvoton MA35 SoCs support DWC2 USB controller. Add the driver to drive the USB 2.0 PHY transceivers.
Signed-off-by hpchen0 <[email protected]>drivers/phy/nuvoton/phy-ma35-usb2.c new file +10
-0+ + ret =clk_prepare_enable (p_phy->clk); +if (ret <0 ) { +dev_err (p_phy->dev,"Failed to enable PHY clock: %d\n" , ret); +return ret; + } + +regmap_read (p_phy->sysreg,MA35_SYS_REG_USBPMISCR , &val); +if (val &PHY0SUSPEND ) { +/*
drivers/phy/nuvoton/phy-ma35-usb2.c line 55
Quoted 10 lines
drivers/phy/nuvoton/phy-ma35-usb2.c new file +10
-0+* USB PHY0 is in operation mode already +* make sure USB PHY 60 MHz UTMI Interface Clock ready +*/ + timeout = jiffies +msecs_to_jiffies (200 ); +while (time_before (jiffies, timeout)) { +regmap_read (p_phy->sysreg,MA35_SYS_REG_USBPMISCR , &val); +if (val &PHY0DEVCKSTB ) +return 0 ; +usleep_range (1000 ,1500 ); + }
You want some readl_poll_timeout version here.
Quoted 59 lines
drivers/phy/nuvoton/phy-ma35-usb2.c new file +59
-0+ } + +/* +* reset USB PHY0. +* wait until USB PHY0 60 MHz UTMI Interface Clock ready +*/ +regmap_update_bits (p_phy->sysreg,MA35_SYS_REG_USBPMISCR ,0x7 , (PHY0POR |PHY0SUSPEND )); + timeout = jiffies +msecs_to_jiffies (200 ); +while (time_before (jiffies, timeout)) { +regmap_read (p_phy->sysreg,MA35_SYS_REG_USBPMISCR , &val); +if (val &PHY0DEVCKSTB ) +break ; +usleep_range (1000 ,1500 ); + } + +/* 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 */ + timeout = jiffies +msecs_to_jiffies (200 ); +while (time_before (jiffies, timeout)) { +regmap_read (p_phy->sysreg,MA35_SYS_REG_USBPMISCR , &val); +if (val &PHY0DEVCKSTB ) +return 0 ; +usleep_range (1000 ,1500 ); + } + +dev_err (p_phy->dev,"Timed out waiting for PHY to power on\n" ); + ret = -ETIMEDOUT ; + +clk_disable_unprepare (p_phy->clk); +return ret; +} + +static int ma35_usb_phy_power_off (struct phy *phy) +{ +struct ma35_usb_phy *p_phy =phy_get_drvdata (phy); + +clk_disable_unprepare (p_phy->clk); +return 0 ; +} + +static const struct phy_ops ma35_usb_phy_ops = { + .power_on = ma35_usb_phy_power_on, + .power_off = ma35_usb_phy_power_off, + .owner =THIS_MODULE , +}; + +static int ma35_usb_phy_probe (struct platform_device *pdev) +{ +struct phy_provider *provider; +struct ma35_usb_phy *p_phy; +const char *clkgate; +struct phy *phy; + + p_phy =devm_kzalloc (&pdev->dev,sizeof (*p_phy),GFP_KERNEL ); +if (!p_phy) +return -ENOMEM ; +
drivers/phy/nuvoton/phy-ma35-usb2.c line 124
Quoted 10 lines
drivers/phy/nuvoton/phy-ma35-usb2.c new file +10
-0+ p_phy->dev = &pdev->dev; +platform_set_drvdata (pdev, p_phy); + + p_phy->sysreg =syscon_regmap_lookup_by_phandle (p_phy->dev->of_node,"nuvoton,sys" ); +if (IS_ERR (p_phy->sysreg)) +return dev_err_probe (&pdev->dev,PTR_ERR (p_phy->sysreg), +"Failed to get SYS registers\n" ); + +/* enable clock */ +of_property_read_string (p_phy->dev->of_node,"clock-enable" , &clkgate);
There is no such property.
drivers/phy/nuvoton/phy-ma35-usb2.c line 125
Quoted 1 line
drivers/phy/nuvoton/phy-ma35-usb2.c new file +1
-0+ p_phy->clk =devm_clk_get (p_phy->dev, clkgate);
Don't mix styles of variables: you were using pdev->dev but now entirely different. Stick to pdev->dev.
drivers/phy/nuvoton/phy-ma35-usb2.c line 127
Quoted 2 lines
drivers/phy/nuvoton/phy-ma35-usb2.c new file +2
-0+if (IS_ERR (p_phy->clk)) + return dev_err_probe(&pdev->dev, PTR_ERR(p_phy->clk),
And here again pdev->dev... Bring some consistency, not random coding style.
Review
Quoted 2 lines
(quoted diff) +2
-0+ "Failed to get usb_phy clock\n"); +
Best regards,
Krzysztof
Re: [PATCH 2/2] phy: nuvoton: add new driver for the Nuvoton MA35 SoC USB 2.0 PHY
Dear Krzysztof,
Thank you for your reply.
Quoted 18 lines · Krzysztof Kozlowski
Quoted 17 lines · On 29/07/2024 08:15, hpchen0 wrote:
Nuvoton MA35 SoCs support DWC2 USB controller. Add the driver to drive the USB 2.0 PHY transceivers.
Signed-off-by hpchen0 <[email protected]>drivers/phy/nuvoton/phy-ma35-usb2.c new file +13
-0+ + ret =clk_prepare_enable (p_phy->clk); +if (ret <0 ) { +dev_err (p_phy->dev,"Failed to enable PHY clock: %d\n" , ret); +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 +*/
Quoted 8 lines
drivers/phy/nuvoton/phy-ma35-usb2.c line 55
Quoted 7 lines
drivers/phy/nuvoton/phy-ma35-usb2.c new file +7
-0+ timeout = jiffies +msecs_to_jiffies (200 ); +while (time_before (jiffies, timeout)) { +regmap_read (p_phy->sysreg,MA35_SYS_REG_USBPMISCR , &val); +if (val &PHY0DEVCKSTB ) +return 0 ; +usleep_range (1000 ,1500 ); + }You want some
readl_poll_timeoutversion here.
Okay. The readl_poll_timeout function will be used instead.
Quoted 62 lines
Quoted 62 lines
drivers/phy/nuvoton/phy-ma35-usb2.c new file +62
-0+ } + +/* +* reset USB PHY0. +* wait until USB PHY0 60 MHz UTMI Interface Clock ready +*/ +regmap_update_bits (p_phy->sysreg,MA35_SYS_REG_USBPMISCR ,0x7 , (PHY0POR |PHY0SUSPEND )); + timeout = jiffies +msecs_to_jiffies (200 ); +while (time_before (jiffies, timeout)) { +regmap_read (p_phy->sysreg,MA35_SYS_REG_USBPMISCR , &val); +if (val &PHY0DEVCKSTB ) +break ; +usleep_range (1000 ,1500 ); + } + +/* 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 */ + timeout = jiffies +msecs_to_jiffies (200 ); +while (time_before (jiffies, timeout)) { +regmap_read (p_phy->sysreg,MA35_SYS_REG_USBPMISCR , &val); +if (val &PHY0DEVCKSTB ) +return 0 ; +usleep_range (1000 ,1500 ); + } + +dev_err (p_phy->dev,"Timed out waiting for PHY to power on\n" ); + ret = -ETIMEDOUT ; + +clk_disable_unprepare (p_phy->clk); +return ret; +} + +static int ma35_usb_phy_power_off (struct phy *phy) +{ +struct ma35_usb_phy *p_phy =phy_get_drvdata (phy); + +clk_disable_unprepare (p_phy->clk); +return 0 ; +} + +static const struct phy_ops ma35_usb_phy_ops = { + .power_on = ma35_usb_phy_power_on, + .power_off = ma35_usb_phy_power_off, + .owner =THIS_MODULE , +}; + +static int ma35_usb_phy_probe (struct platform_device *pdev) +{ +struct phy_provider *provider; +struct ma35_usb_phy *p_phy; +const char *clkgate; +struct phy *phy; + + p_phy =devm_kzalloc (&pdev->dev,sizeof (*p_phy),GFP_KERNEL ); +if (!p_phy) +return -ENOMEM ; + + p_phy->dev = &pdev->dev; +platform_set_drvdata (pdev, p_phy); +
Quoted 8 lines
drivers/phy/nuvoton/phy-ma35-usb2.c line 124
Quoted 7 lines
drivers/phy/nuvoton/phy-ma35-usb2.c new file +7
-0+ p_phy->sysreg =syscon_regmap_lookup_by_phandle (p_phy->dev->of_node,"nuvoton,sys" ); +if (IS_ERR (p_phy->sysreg)) +return dev_err_probe (&pdev->dev,PTR_ERR (p_phy->sysreg), +"Failed to get SYS registers\n" ); + +/* enable clock */ +of_property_read_string (p_phy->dev->of_node,"clock-enable" , &clkgate);There is no such property.
I'm sorry, I forgot to remove this part. I will remove it and correct it.
Quoted 3 lines
drivers/phy/nuvoton/phy-ma35-usb2.c line 125
Quoted 1 line
drivers/phy/nuvoton/phy-ma35-usb2.c new file +1
-0+ p_phy->clk =devm_clk_get (p_phy->dev, clkgate);Don't mix styles of variables: you were using
pdev->devbut now entirely different. Stick topdev->dev.
Okay. I will consistently use pdev->dev|.|
Thank you for the reminder.
Quoted 3 lines
drivers/phy/nuvoton/phy-ma35-usb2.c line 127
Quoted 2 lines
drivers/phy/nuvoton/phy-ma35-usb2.c new file +2
-0+if (IS_ERR (p_phy->clk)) + return dev_err_probe(&pdev->dev, PTR_ERR(p_phy->clk),And here again
pdev->dev... Bring some consistency, not random coding style.
Okay. I will consistently use pdev->dev|.|
Thank you for the reminder.
Quoted 5 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ "Failed to get usb_phy clock\n"); +Best regards,
Krzysztof
Best regards,
Hui-Ping Chen