usb: phy: add usb phy notify port status API
Subsystems (3)
PATCH v2 1/3 usb: phy: add usb phy notify port status API
In Realtek SoC, the parameter of usb phy is designed to can dynamic tuning base on port status. Therefore, add a notify callback of phy driver when usb port status change.
---
v1 to v2 change:
No change
--- drivers/usb/core/hub.c | 13 +++++++++++++ include/linux/usb/phy.h | 14 ++++++++++++++ 2 files changed, 27 insertions(+)
drivers/usb/core/hub.c +13 -0
@@ -614,6 +614,19 @@ static int hub_ext_port_status(struct usb_hub *hub, int port1, int type, ret =0 ; }mutex_unlock (&hub->status_mutex); + +if (!ret) { +struct usb_device *hdev = hub->hdev; + +if (hdev && !hdev->parent) { +struct usb_hcd *hcd =bus_to_hcd (hdev->bus); + +if (hcd->usb_phy) +usb_phy_notify_port_status (hcd->usb_phy, + port1 -1 , *status, *change); + } + } +return ret; }
include/linux/usb/phy.h +14 -0
@@ -144,6 +144,10 @@ struct usb_phy {*/ int (*set_wakeup)(struct usb_phy *x,bool enabled); +/* notify phy port status change */ +int (*notify_port_status)(struct usb_phy *x, +int port,u16 portstatus,u16 portchange); +/* notify phy connect status change */ int (*notify_connect)(struct usb_phy *x,enum usb_device_speed speed);
@@ -316,6 +320,16 @@ usb_phy_set_wakeup(struct usb_phy *x, bool enabled)return 0 ; } +static inline int +usb_phy_notify_port_status (struct usb_phy *x,int port,u16 portstatus, +u16 portchange) +{ +if (x && x->notify_port_status) +return x->notify_port_status (x, port, portstatus, portchange); +else +return 0 ; +} +static inline int usb_phy_notify_connect (struct usb_phy *x,enum usb_device_speed speed) {
Signature · 1 line
2.34.1
PATCH v2 2/3 phy: realtek: usb: Add driver for the Realtek SoC USB 2.0/3.0 PHY
Realtek DHC (digital home center) RTD SoCs support DWC3 XHCI USB 2.0/3.0 controller. Added two drivers to drive the USB 2.0/3.0 PHY transceivers. For USB 3.0 transceivers, a driver phy-rtk-usb3 is provided. The driver phy-rtk-usb2 is used to support USB 2.0 transceivers.
---
v1 to v2 change:
1. Move the drivers to drivers/phy/ for generic phy driver
2. Use the generic phy driver api to initialize phy
3. Use readl/writel to instead phy_read/phy_write directly.
4. Use read_poll_timeout() in function utmi_wait_register.
5. Revised some coding styles.
6. fix the compiler warning for kerenl test robot.
--- drivers/phy/Kconfig | 1 + drivers/phy/Makefile | 1 + drivers/phy/realtek/Kconfig | 23 + drivers/phy/realtek/Makefile | 3 + drivers/phy/realtek/phy-rtk-usb.h | 82 ++ drivers/phy/realtek/phy-rtk-usb2.c | 2203 ++++++++++++++++++++++++++++ drivers/phy/realtek/phy-rtk-usb3.c | 1180 +++++++++++++++ 7 files changed, 3493 insertions(+) create mode 100644 drivers/phy/realtek/Kconfig create mode 100644 drivers/phy/realtek/Makefile create mode 100644 drivers/phy/realtek/phy-rtk-usb.h create mode 100644 drivers/phy/realtek/phy-rtk-usb2.c create mode 100644 drivers/phy/realtek/phy-rtk-usb3.c
drivers/phy/Kconfig +1 -0
@@ -86,6 +86,7 @@ source "drivers/phy/motorola/Kconfig" source "drivers/phy/mscc/Kconfig" source "drivers/phy/qualcomm/Kconfig" source "drivers/phy/ralink/Kconfig" +source "drivers/phy/realtek/Kconfig" source "drivers/phy/renesas/Kconfig" source "drivers/phy/rockchip/Kconfig" source "drivers/phy/samsung/Kconfig"
drivers/phy/Makefile +1 -0
@@ -26,6 +26,7 @@ obj-y += allwinner/ \ mscc/ \ qualcomm/ \ ralink/ \ + realtek/ \ renesas/ \ rockchip/ \ samsung/ \
drivers/phy/realtek/Kconfig new file +23 -0
@@ -0,0 +1,23 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# Phy drivers for Realtek platforms +# +config PHY_RTK_RTD_USB2PHY + tristate "Realtek RTD USB2 PHY Transceiver Driver" + select GENERIC_PHY + select USB_PHY + help + Enable this to support Realtek SoC USB2 phy transceiver. + The DHC (digital home center) RTD series SoCs used the Synopsys + DWC3 USB IP. This driver will do the PHY initialization + of the parameters. + +config PHY_RTK_RTD_USB3PHY + tristate "Realtek RTD USB3 PHY Transceiver Driver" + select GENERIC_PHY + select USB_PHY + help + Enable this to support Realtek SoC USB3 phy transceiver. + The DHC (digital home center) RTD series SoCs used the Synopsys + DWC3 USB IP. This driver will do the PHY initialization + of the parameters.
drivers/phy/realtek/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0 +obj-$(CONFIG_PHY_RTK_RTD_USB2PHY) += phy-rtk-usb2.o +obj-$(CONFIG_PHY_RTK_RTD_USB3PHY) += phy-rtk-usb3.o
drivers/phy/realtek/phy-rtk-usb.h new file +82 -0
82 lines not on this page · raw message
drivers/phy/realtek/phy-rtk-usb2.c new file +2203 -0
2,203 lines not on this page · raw message
drivers/phy/realtek/phy-rtk-usb3.c new file +1180 -0
675 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.34.1
Part of the diff is not shown here. View the raw message.
Greg Kroah-Hartman
maintainerRe: [PATCH v2 2/3] phy: realtek: usb: Add driver for the Realtek SoC USB 2.0/3.0 PHY
Quoted 7 lines · Stanley Chang
Realtek DHC (digital home center) RTD SoCs support DWC3 XHCI USB 2.0/3.0 controller. Added two drivers to drive the USB 2.0/3.0 PHY transceivers. For USB 3.0 transceivers, a driver phy-rtk-usb3 is provided. The driver phy-rtk-usb2 is used to support USB 2.0 transceivers.
Signed-off-by Stanley Chang <[email protected]>Reported-by kernel test robot <[email protected]>
The kernel test robot did not report that a new driver was needed :(
Signature · 3 lines
linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
RE: [PATCH v2 2/3] phy: realtek: usb: Add driver for the Realtek SoC USB 2.0/3.0 PHY
Hi Greg,
Quoted 12 lines · Stanley Chang
Quoted 2 lines
Realtek DHC (digital home center) RTD SoCs support DWC3 XHCI USB 2.0/3.0 controller. Added two drivers to drive the USB 2.0/3.0 PHY
transceivers.
Quoted 5 lines
For USB 3.0 transceivers, a driver phy-rtk-usb3 is provided. The driver phy-rtk-usb2 is used to support USB 2.0 transceivers.
Signed-off-by Stanley Chang <[email protected]>Reported-by kernel test robot <[email protected]>The kernel test robot did not report that a new driver was needed :(
This report is based on v1 patch.
https://patchwork.kernel.org/project/linux-usb/patch/[email protected]/
The original driver is at drivers/usb/phy/ If this report is not appropriate, I will remove it.
Thanks,
Stanley
Greg Kroah-Hartman
maintainerRe: [PATCH v2 2/3] phy: realtek: usb: Add driver for the Realtek SoC USB 2.0/3.0 PHY
Quoted 12 lines · Stanley Chang[昌育德]
Hi Greg,
Quoted 10 lines · Stanley Chang
Quoted 2 lines
Realtek DHC (digital home center) RTD SoCs support DWC3 XHCI USB 2.0/3.0 controller. Added two drivers to drive the USB 2.0/3.0 PHY
transceivers.
Quoted 5 lines
For USB 3.0 transceivers, a driver phy-rtk-usb3 is provided. The driver phy-rtk-usb2 is used to support USB 2.0 transceivers.
Signed-off-by Stanley Chang <[email protected]>Reported-by kernel test robot <[email protected]>
Quoted 8 lines
Quoted 2 lines
The kernel test robot did not report that a new driver was needed :(
This report is based on v1 patch.
https://patchwork.kernel.org/project/linux-usb/patch/[email protected]/The original driver is at
drivers/usb/phy/If this report is not appropriate, I will remove it.
Does it make sense to include it?
Signature · 3 lines
linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
RE: [PATCH v2 2/3] phy: realtek: usb: Add driver for the Realtek SoC USB 2.0/3.0 PHY
Hi Greg,
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 3 lines
Signed-off-by Stanley Chang <[email protected]>Reported-by kernel test robot <[email protected]>The kernel test robot did not report that a new driver was needed :(
Quoted 8 lines
Quoted 6 lines
This report is based on v1 patch.
https://patchwork.kernel.org/project/linux-usb/patch/20230519045825.28
[email protected]/The original driver is at
drivers/usb/phy/If this report is not appropriate, I will remove it.Does it make sense to include it?
I have fixed the same errors in v2 as v1. So I added it. I will remove it at next version.
Thanks,
Stanley
PATCH v2 3/3 dt-bindings: phy: realtek: Add the doc about the Realtek SoC USB 2.0/3.0 PHY
In reply to Stanley ChangTwo documentations explain the property about realtek USB PHY drivers.
Realtek DHC (digital home center) RTD SoCs support DWC3 XHCI USB 2.0/3.0 controller. Added two drivers to drive the USB 2.0/3.0 PHY transceivers. For USB 3.0 transceivers, a driver phy-rtk-usb3 is provided. The driver phy-rtk-usb2 is used to support USB 2.0 transceivers.
---
v1 to v2 change:
Add phy-cells for generic phy driver
--- .../bindings/phy/realtek,usb2phy.yaml | 255 ++++++++++++++++++ .../bindings/phy/realtek,usb3phy.yaml | 201 ++++++++++++++ 2 files changed, 456 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml create mode 100644 Documentation/devicetree/bindings/phy/realtek,usb3phy.yaml
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml new file +255 -0
@@ -0,0 +1,255 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +# Copyright 2023 Realtek Semiconductor Corporation +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/phy/realtek,usb2phy.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Realtek DHC SoCs USB2 PHY + +maintainers: + - Stanley Chang <[email protected]> + +description: | + Realtek USB 2.0 PHY support the digital home center (DHC) RTD series SoCs. + +properties: + compatible: + enum: + - realtek,usb2phy + - realtek,rtd-usb2phy + - realtek,rtd1295-usb2phy + - realtek,rtd1395-usb2phy + - realtek,rtd1619-usb2phy + - realtek,rtd1319-usb2phy + - realtek,rtd1619b-usb2phy + - realtek,rtd1312c-usb2phy + - realtek,rtd1319d-usb2phy + - realtek,rtd1315e-usb2phy + + reg: + items: + - description: PHY data registers + - description: PHY control registers + + "#phy-cells": + const: 0 + + realtek,usb: + description: The phandler of realtek dwc3 node + $ref: /schemas/types.yaml#/definitions/phandle + + realtek,mac: + description: The phandler of dwc3 node + $ref: /schemas/types.yaml#/definitions/phandle + + realtek,usb_ctrl: + description: The phandler of usb power control node + $ref: /schemas/types.yaml#/definitions/phandle + + realtek,port-index: + description: The index of USB 2.0 PHY + $ref: /schemas/types.yaml#/definitions/uint32 + + realtek,phyN: + description: The total amount of USB 2.0 PHY + $ref: /schemas/types.yaml#/definitions/uint32 + + phy0: + description: The child node of PHY for the parameter v1. + type: object + properties: + realtek,phy-data-page0-size: + description: PHY data page 0 size + $ref: /schemas/types.yaml#/definitions/uint32 + + realtek,phy-data-page0-addr: + description: PHY data page 0 address + $ref: /schemas/types.yaml#/definitions/uint8-array + + realtek,phy-data-page0-A00: + description: PHY data page 0 value + $ref: /schemas/types.yaml#/definitions/uint8-array + + realtek,phy-data-page1-size: + description: PHY data page 1 size + $ref: /schemas/types.yaml#/definitions/uint32 + + realtek,phy-data-page1-addr: + description: PHY data page 1 address + $ref: /schemas/types.yaml#/definitions/uint8-array + + realtek,phy-data-page1-A00: + description: PHY data page 1 value + $ref: /schemas/types.yaml#/definitions/uint8-array + + realtek,phy-data-page2-size: + description: PHY data page 2 size + $ref: /schemas/types.yaml#/definitions/uint32 + + realtek,phy-data-page2-addr: + description: PHY data page 2 address + $ref: /schemas/types.yaml#/definitions/uint8-array + + realtek,phy-data-page2-A00: + description: PHY data page 2 value + $ref: /schemas/types.yaml#/definitions/uint8-array + + realtek,do-toggle: + description: Do PHY parameter toggle when port status change + type: boolean + + realtek,check-efuse: + description: Enable to fix PHY parameter from reading otp table + type: boolean + + realtek,use-default-parameter: + description: Don't set parameter and use default value + type: boolean + + realtek,is-double-sensitivity-mode: + description: Enable double sensitivity mode + type: boolean + + realtek,ldo-page0-e4-compensate: + description: Adjust the PHY parameter for page 0 0xE4 for ldo mode + $ref: /schemas/types.yaml#/definitions/uint32 + + realtek,page0-e4-compensate: + description: Adjust the PHY parameter for page 0 0xE4 + for efuse table v2 + $ref: /schemas/types.yaml#/definitions/uint32 + + phy0_data: + description: The child node of PHY for parameter v2. + type: object + properties: + realtek,page0-size: + description: PHY data page 0 size + $ref: /schemas/types.yaml#/definitions/uint32 + + realtek,page0-data-A00: + description: PHY data page 0 address and value + $ref: /schemas/types.yaml#/definitions/uint32-array + + realtek,page1-size: + description: PHY data page 1 size + $ref: /schemas/types.yaml#/definitions/uint32 + + realtek,page1-data-A00: + description: PHY data page 1 address and value + $ref: /schemas/types.yaml#/definitions/uint32-array + + realtek,page2-size: + description: PHY data page 2 size + $ref: /schemas/types.yaml#/definitions/uint32 + + realtek,page2-data-A00: + description: PHY data page 2 address and value + $ref: /schemas/types.yaml#/definitions/uint32-array + + realtek,do-toggle: + description: Do PHY parameter toggle when port status change + type: boolean + + realtek,do-toggle-driving: + description: Do PHY parameter toggle for driving when port + status change + type: boolean + + realtek,check-efuse: + description: Enable to fix PHY parameter from reading otp table + type: boolean + + realtek,use-default-parameter: + description: Don't set parameter and use default value + type: boolean + + realtek,is-double-sensitivity-mode: + description: Enable double sensitivity mode + type: boolean + + realtek,ldo-force-enable: + description: Force enable ldo mode + type: boolean + + realtek,ldo-page0-e4-compensate: + description: Adjust the PHY parameter for page0 0xE4 for ldo mode + $ref: /schemas/types.yaml#/definitions/uint32 + + realtek,page0-e4-compensate: + description: Adjust the PHY parameter for page0 0xE4 + for efuse table v2 + $ref: /schemas/types.yaml#/definitions/uint32 + +required: + - compatible + - reg + - "#phy-cells" + +additionalProperties: false + +examples: + - | + dwc3_u3drd_usb2phy: dwc3_u3drd_usb2phy@98013e14 { + compatible = "realtek,usb2phy"; + reg = <0x98013e14 0x4>, <0x98058280 0x4>; + #phy-cells = <0>; + status = "okay"; + realtek,phyN = <1>; + + phy0 { + realtek,phy-data-page0-size = <16>; + realtek,phy-data-page0-addr = /bits/ 8 + <0xE0 0xE1 0xE2 0xE3 0xE4 0xE5 0xE6 0xE7 0xF0 0xF1 + 0xF2 0xF3 0xF4 0xF5 0xF6 0xF7>; + realtek,phy-data-page0-A00 = /bits/ 8 + <0xE0 0x30 0x79 0x8D 0x6A 0x65 0x01 0x71 0xFC 0x8C + 0x00 0x11 0x9B 0x00 0x00 0x0A>; + realtek,phy-data-page0-B00 = /bits/ 8 + <0x18 0x30 0x79 0x8D 0x6A 0x65 0x01 0x71 0xFC 0x8C + 0x00 0x11 0x9B 0x00 0x00 0x32>; + realtek,phy-data-page1-size = <8>; + realtek,phy-data-page1-addr = /bits/ 8 + <0xE0 0xE1 0xE2 0xE3 0xE4 0xE5 0xE6 0xE7>; + realtek,phy-data-page1-A00 = /bits/ 8 + <0x25 0xEF 0x60 0x44 0x00 0x0F 0x18 0xE3>; + realtek,phy-data-page2-size = <1>; + realtek,phy-data-page2-addr = /bits/ 8 + <0xE0>; + realtek,phy-data-page2-A00 = /bits/ 8 + <0x01>; + realtek,do-toggle; + realtek,check-efuse; + realtek,is-double-sensitivity-mode; + realtek,ldo-page0-e4-compensate = <(-2)>; + }; + }; + + - | + usb_port0_usb2phy: usb_port0_usb2phy@13214 { + compatible = "realtek,usb2phy"; + reg = <0x13214 0x4>, <0x28280 0x4>; + #phy-cells = <0>; + realtek,usb = <&usb_port0>; + realtek,mac = <&port0_dwc3>; + realtek,usb_ctrl = <&usb_ctrl>; + + realtek,port-index = <0>; + realtek,phyN = <1>; + phy0_data { + realtek,page0-size = <16>; + realtek,page0-data-A00 = /* < addr data > */ + <0xE0 0xA3>, <0xE4 0xB2>, <0xE5 0x4F>, <0xE6 0x42>; + realtek,page1-size = <8>; + realtek,page1-data-A00 = <0xE3 0x64>; + realtek,page2-size = <8>; + realtek,page2-data-A00 = <0xE7 0x45>; + realtek,do-toggle; + realtek.do-toggle-driving; + realtek,disconnect-driving-updated = <0x8>; + realtek,check-efuse; + realtek,is-double-sensitivity-mode; + realtek,ldo-force-enable; + }; + };
Documentation/devicetree/bindings/phy/realtek,usb3phy.yaml new file +201 -0
201 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH v2 3/3] dt-bindings: phy: realtek: Add the doc about the Realtek SoC USB 2.0/3.0 PHY
Hey,
Quoted 14 lines · Stanley Chang
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml new file +13
-0+properties: + compatible: + enum: + - realtek,usb2phy + - realtek,rtd-usb2phy + - realtek,rtd1295-usb2phy + - realtek,rtd1395-usb2phy + - realtek,rtd1619-usb2phy + - realtek,rtd1319-usb2phy + - realtek,rtd1619b-usb2phy + - realtek,rtd1312c-usb2phy + - realtek,rtd1319d-usb2phy + - realtek,rtd1315e-usb2phy
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml
Quoted 10 lines
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml new file +10
-0+properties: + compatible: + enum: + - realtek,usb3phy + - realtek,rtd-usb3phy + - realtek,rtd1295-usb3phy + - realtek,rtd1619-usb3phy + - realtek,rtd1319-usb3phy + - realtek,rtd1619b-usb3phy + - realtek,rtd1319d-usb3phy
Ignoring everything else, because I really want Krzysztof or Rob to review this rather than me, but what's going on here with the compatibles?
What hardware do "usbNphy" and "rtd-usbNphy" represent?
You have device-specific compatibles, which is great, but you also allow only those two generic ones. I had a _brief_ look at the driver, and it seems like there is no decision making done based on the compatibles, only on the properties. Is that correct?
If it is, I would understand having "realtek,usb3phy" as a fallback compatible for "realtek,rtd1619-usb3phy", but I do not get the current setup.
Also, I really think this should be broken down into two patches, one for each of USB 2 & 3.
Cheers,
Conor.
RE: [PATCH v2 3/3] dt-bindings: phy: realtek: Add the doc about the Realtek SoC USB 2.0/3.0 PHY
Hi Conor,
Quoted 30 lines
Quoted 14 lines
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml new file +13
-0+properties: + compatible: + enum: + - realtek,usb2phy + - realtek,rtd-usb2phy + - realtek,rtd1295-usb2phy + - realtek,rtd1395-usb2phy + - realtek,rtd1619-usb2phy + - realtek,rtd1319-usb2phy + - realtek,rtd1619b-usb2phy + - realtek,rtd1312c-usb2phy + - realtek,rtd1319d-usb2phy + - realtek,rtd1315e-usb2phyDocumentation/devicetree/bindings/phy/realtek,usb2phy.yaml
Quoted 10 lines
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml new file +10
-0+properties: + compatible: + enum: + - realtek,usb3phy + - realtek,rtd-usb3phy + - realtek,rtd1295-usb3phy + - realtek,rtd1619-usb3phy + - realtek,rtd1319-usb3phy + - realtek,rtd1619b-usb3phy + - realtek,rtd1319d-usb3phyIgnoring everything else, because I really want Krzysztof or Rob to review this rather than me, but what's going on here with the compatibles?
What hardware do "usbNphy" and "rtd-usbNphy" represent?
Quoted 7 lines
You have device-specific compatibles, which is great, but you also allow only those two generic ones. I had a _brief_ look at the driver, and it seems like there is no decision making done based on the compatibles, only on the properties. Is that correct?
If it is, I would understand having "realtek,usb3phy" as a fallback compatible for "realtek,rtd1619-usb3phy", but I do not get the current setup.
This driver is compatible with all Realtek RTD SoCs without specifying different settings. So use "realtek,usb3phy" as fallback compatible for all SoCs.
This is the compatible name we use.
Other compatible names simply indicate that the driver supports the SoCs.
The name "usbNphy" and "rtd-usbNphy" seem to be more generic for all RTD SoCs, but they are not device-specific compatible.
Do you have a better suggestion?
Quoted 3 lines
Also, I really think this should be broken down into two patches, one for each of USB 2 & 3.
Okay, I will split to two patches.
Thanks,
Stanley
Re: [PATCH v2 3/3] dt-bindings: phy: realtek: Add the doc about the Realtek SoC USB 2.0/3.0 PHY
Quoted 40 lines · Stanley Chang[昌育德]
Hi Conor,
Quoted 30 lines
Quoted 14 lines
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml new file +13
-0+properties: + compatible: + enum: + - realtek,usb2phy + - realtek,rtd-usb2phy + - realtek,rtd1295-usb2phy + - realtek,rtd1395-usb2phy + - realtek,rtd1619-usb2phy + - realtek,rtd1319-usb2phy + - realtek,rtd1619b-usb2phy + - realtek,rtd1312c-usb2phy + - realtek,rtd1319d-usb2phy + - realtek,rtd1315e-usb2phyDocumentation/devicetree/bindings/phy/realtek,usb2phy.yaml
Quoted 10 lines
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml new file +10
-0+properties: + compatible: + enum: + - realtek,usb3phy + - realtek,rtd-usb3phy + - realtek,rtd1295-usb3phy + - realtek,rtd1619-usb3phy + - realtek,rtd1319-usb3phy + - realtek,rtd1619b-usb3phy + - realtek,rtd1319d-usb3phyIgnoring everything else, because I really want Krzysztof or Rob to review this rather than me, but what's going on here with the compatibles?
What hardware do "usbNphy" and "rtd-usbNphy" represent?Quoted 7 lines
You have device-specific compatibles, which is great, but you also allow only those two generic ones. I had a _brief_ look at the driver, and it seems like there is no decision making done based on the compatibles, only on the properties. Is that correct?
If it is, I would understand having "realtek,usb3phy" as a fallback compatible for "realtek,rtd1619-usb3phy", but I do not get the current setup.
Quoted 4 lines
This driver is compatible with all Realtek RTD SoCs without specifying different settings. So use "realtek,usb3phy" as fallback compatible for all SoCs.
This is the compatible name we use.
Other compatible names simply indicate that the driver supports the SoCs.
Then you should write the binding such that having fallback compatibles is permitted. Try plugging
compatible = "realtek,rtd1295-usb2phy", "realtek,rtd-usb2phy", "realtek,usb2phy"; into your example below and see what happens.
Quoted 3 lines
The name "usbNphy" and "rtd-usbNphy" seem to be more generic for all RTD SoCs, but they are not device-specific compatible.
Do you have a better suggestion?
Write the binding so that having fallback compatibles in the DT actually works, don't add the SoC-specific ones merely as indicators that those SoCs are supported and don't permit "realtek,usbNphy" or "realtek,rtd-usbNphy" in isolation ;)
Cheers,
Conor.
A message that is not in the archive (sent off-list or not yet received): [email protected]
RE: [PATCH v2 3/3] dt-bindings: phy: realtek: Add the doc about the Realtek SoC USB 2.0/3.0 PHY
Hi Conor,
Quoted 18 lines
Quoted 8 lines
Quoted 7 lines
You have device-specific compatibles, which is great, but you also allow only those two generic ones. I had a _brief_ look at the driver, and it seems like there is no decision making done based on the compatibles, only on the properties. Is that correct?
If it is, I would understand having "realtek,usb3phy" as a fallback compatible for "realtek,rtd1619-usb3phy", but I do not get the current setup.Quoted 4 lines
This driver is compatible with all Realtek RTD SoCs without specifying different settings. So use "realtek,usb3phy" as fallback compatible for all SoCs.
This is the compatible name we use.
Other compatible names simply indicate that the driver supports the SoCs.Then you should write the binding such that having fallback compatibles is permitted. Try plugging
compatible = "realtek,rtd1295-usb2phy", "realtek,rtd-usb2phy", "realtek,usb2phy"; into your example below and see what happens.
Quoted 9 lines
Quoted 3 lines
The name "usbNphy" and "rtd-usbNphy" seem to be more generic for all RTD SoCs, but they are not device-specific compatible.
Do you have a better suggestion?Write the binding so that having fallback compatibles in the DT actually works, don't add the SoC-specific ones merely as indicators that those SoCs are supported and don't permit "realtek,usbNphy" or "realtek,rtd-usbNphy" in isolation ;)
As far as I understand what you mean.
I should follow other docs to define compatible. Reference:
Documentation/devicetree/bindings/phy/mediatek,xsphy.yaml drivers/phy/mediatek/phy-mtk-xsphy.c
For example:
compatible:
items:
- enum:
- realtek,rtd1295-usb2phy
- realtek,rtd1395-usb2phy
- realtek,rtd1619-usb2phy
- realtek,rtd1319-usb2phy
- realtek,rtd1619b-usb2phy
- realtek,rtd1312c-usb2phy
- realtek,rtd1319d-usb2phy
- realtek,rtd1315e-usb2phy
- const: realtek,usb2phy
examples:
-
dwc3_u3drd_usb2phy: dwc3_u3drd_usb2phy@98013e14 {
compatible = "realtek,rtd1319-usb2phy", "realtek,usb2phy";And use only "Realtek, usb2phy" in the driver.
static const struct of_device_id usbphy_rtk_dt_match[] = {
{ .compatible = "realtek,usb2phy", },
{},
};Re: [PATCH v2 3/3] dt-bindings: phy: realtek: Add the doc about the Realtek SoC USB 2.0/3.0 PHY
Quoted 53 lines · Stanley Chang[昌育德]
Hi Conor,
Quoted 18 lines
Quoted 8 lines
Quoted 7 lines
You have device-specific compatibles, which is great, but you also allow only those two generic ones. I had a _brief_ look at the driver, and it seems like there is no decision making done based on the compatibles, only on the properties. Is that correct?
If it is, I would understand having "realtek,usb3phy" as a fallback compatible for "realtek,rtd1619-usb3phy", but I do not get the current setup.Quoted 4 lines
This driver is compatible with all Realtek RTD SoCs without specifying different settings. So use "realtek,usb3phy" as fallback compatible for all SoCs.
This is the compatible name we use.
Other compatible names simply indicate that the driver supports the SoCs.Then you should write the binding such that having fallback compatibles is permitted. Try plugging
compatible = "realtek,rtd1295-usb2phy", "realtek,rtd-usb2phy", "realtek,usb2phy"; into your example below and see what happens.Quoted 9 lines
Quoted 3 lines
The name "usbNphy" and "rtd-usbNphy" seem to be more generic for all RTD SoCs, but they are not device-specific compatible.
Do you have a better suggestion?Write the binding so that having fallback compatibles in the DT actually works, don't add the SoC-specific ones merely as indicators that those SoCs are supported and don't permit "realtek,usbNphy" or "realtek,rtd-usbNphy" in isolation ;)
As far as I understand what you mean.
I should follow other docs to define compatible. Reference:
Documentation/devicetree/bindings/phy/mediatek,xsphy.yamldrivers/phy/mediatek/phy-mtk-xsphy.cFor example:
compatible:
items:
- enum:
- realtek,rtd1295-usb2phy
- realtek,rtd1395-usb2phy
- realtek,rtd1619-usb2phy
- realtek,rtd1319-usb2phy
- realtek,rtd1619b-usb2phy
- realtek,rtd1312c-usb2phy
- realtek,rtd1319d-usb2phy
- realtek,rtd1315e-usb2phy
- const: realtek,usb2phyexamples:
-
Quoted 8 lines
dwc3_u3drd_usb2phy: dwc3_u3drd_usb2phy@98013e14 { compatible = "realtek,rtd1319-usb2phy", "realtek,usb2phy";And use only "Realtek, usb2phy" in the driver.
static const struct of_device_id usbphy_rtk_dt_match[] = { { .compatible = "realtek,usb2phy", }, {}, };
Yes, this would be a vast improvement, thanks.
A message that is not in the archive (sent off-list or not yet received): [email protected]
RE: [PATCH v2 3/3] dt-bindings: phy: realtek: Add the doc about the Realtek SoC USB 2.0/3.0 PHY
Hi Krzysztof,
Quoted 3 lines
Thank you for your patch. There is something to discuss/improve.
Actually a lot... The bindings are not suitable for review.
Thanks for your patience in reviewing my patches.
Most of the properties are about the phy parameters. Is the phy parameter data suitable to be placed in DTS? I referenced other phy drivers.
These parameters should not be defined in dts. I would move the parameters to the driver.
Quoted 5 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ realtek,usb: + description: The phandler of realtek dwc3 node"phandler"? Except obvious typo, drop "The phandler of" and describe what is it for.
realtek,usb is a phandle of syscon used to control realtek dwc3 register.
Quoted 3 lines
Quoted 1 line
+ $ref: /schemas/types.yaml#/definitions/phandle
Anyway, it shouldn't be here. No, no.
Can I use it for phandle of syscon?
Quoted 5 lines
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml line 52
Quoted 3 lines
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml new file +3
-0+ realtek,port-index: + description: The index of USB 2.0 PHY + $ref: /schemas/types.yaml#/definitions/uint32No. No reason for this. You have reg.
This index is used for phy parameters. I will move it to phy driver.
Quoted 6 lines
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml line 56
Quoted 4 lines
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml new file +4
-0+ + realtek,phyN: + description: The total amount of USB 2.0 PHY + $ref: /schemas/types.yaml#/definitions/uint32No. Compatible defines it.
This amount is used for phy parameters. I will move it to phy driver.
Quoted 5 lines
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml line 59
Quoted 3 lines
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml new file +3
-0+ + phy0: + description: The child node of PHY for the parameter v1.??? Open other phy bindings and use them as example.
phy0 Child node is defined to assign the phy parameter. I will remove it.
Quoted 64 lines
Quoted 46 lines
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml new file +46
-0+ type: object + properties: + realtek,phy-data-page0-size: + description: PHY data page 0 size + $ref: /schemas/types.yaml#/definitions/uint32 + + realtek,phy-data-page0-addr: + description: PHY data page 0 address + $ref: /schemas/types.yaml#/definitions/uint8-array + + realtek,phy-data-page0-A00: + description: PHY data page 0 value + $ref: /schemas/types.yaml#/definitions/uint8-array + + realtek,phy-data-page1-size: + description: PHY data page 1 size + $ref: /schemas/types.yaml#/definitions/uint32 + + realtek,phy-data-page1-addr: + description: PHY data page 1 address + $ref: /schemas/types.yaml#/definitions/uint8-array + + realtek,phy-data-page1-A00: + description: PHY data page 1 value + $ref: /schemas/types.yaml#/definitions/uint8-array + + realtek,phy-data-page2-size: + description: PHY data page 2 size + $ref: /schemas/types.yaml#/definitions/uint32 + + realtek,phy-data-page2-addr: + description: PHY data page 2 address + $ref: /schemas/types.yaml#/definitions/uint8-array + + realtek,phy-data-page2-A00: + description: PHY data page 2 value + $ref: /schemas/types.yaml#/definitions/uint8-array + + realtek,do-toggle: + description: Do PHY parameter toggle when port status change + type: boolean + + realtek,check-efuse: + description: Enable to fix PHY parameter from reading otp table + type: boolean +Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml
Quoted 10 lines
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml new file +10
-0+ realtek,use-default-parameter: + description: Don't set parameter and use default value + type: boolean + + realtek,is-double-sensitivity-mode: + description: Enable double sensitivity mode + type: boolean + + realtek,ldo-page0-e4-compensate: + description: Adjust the PHY parameter for page 0 0xE4 for ldomode
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml line 121
Quoted 6 lines
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml new file +6
-0+ $ref: /schemas/types.yaml#/definitions/uint32 + + realtek,page0-e4-compensate: + description: Adjust the PHY parameter for page 0 0xE4 + for efuse table v2 + $ref: /schemas/types.yaml#/definitions/uint32
Quoted 2 lines
I don't understand what's all this for. Most of these descriptions do not explain anything except duplicating name of property.
I'll simplify these properties and remove the one about the phy parameter.
Quoted 5 lines
One huge NAK for these bindings. It looks like copy-paste from downstream stuff which should never be sent as is to upstream. I am sorry for being harsh, but amount of questions, coding and naming styles, incorrect choices is just too big to handle in one review.
I will refactor this dts based on your comments.
Thanks,
Stanley
Re: [PATCH v2 3/3] dt-bindings: phy: realtek: Add the doc about the Realtek SoC USB 2.0/3.0 PHY
Quoted 6 lines · Stanley Chang[昌育德]
Hi Krzysztof,
Quoted 3 lines
Thank you for your patch. There is something to discuss/improve.
Actually a lot... The bindings are not suitable for review.
Quoted 7 lines
Thanks for your patience in reviewing my patches.
Most of the properties are about the phy parameters. Is the phy parameter data suitable to be placed in DTS? I referenced other phy drivers.
These parameters should not be defined in dts. I would move the parameters to the driver.
If these can be in the driver, why would ever they be in DTS in the first place?
Quoted 8 lines
Quoted 6 lines
Review
Quoted 3 lines
(quoted diff) +2
-0+ realtek,usb: + description: The phandler of realtek dwc3 node"phandler"? Except obvious typo, drop "The phandler of" and describe what is it for.
realtek,usb is a phandle of syscon used to control realtek dwc3 register.
Then no, phy should not control dwc3.
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
+ $ref: /schemas/types.yaml#/definitions/phandle
Anyway, it shouldn't be here. No, no.
Can I use it for phandle of syscon?
PHY getting phandle to block using this PHY? Looks wrong. Why would PHY need to poke IP block register?
Best regards,
Krzysztof
Signature · 3 lines
linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
RE: [PATCH v2 3/3] dt-bindings: phy: realtek: Add the doc about the Realtek SoC USB 2.0/3.0 PHY
Hi Krzysztof,
Quoted 9 lines
Quoted 6 lines
Most of the properties are about the phy parameters. Is the phy parameter data suitable to be placed in DTS? I referenced other phy drivers.
These parameters should not be defined in dts. I would move the parameters to the driver.If these can be in the driver, why would ever they be in DTS in the first place?
Our platforms have 3 xhci controllers which map to 3 different phy ports. And the three phy ports use the same driver, but the parameters are different. So I put the parameter settings in DTS, we have 3 usb-phy nodes representing 3 phy ports. Also, some parameters have to be adjusted for different boards.
Therefore, it is more applicable in DTS than in driver.
Quoted 9 lines
Quoted 7 lines
Quoted 5 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ realtek,usb: + description: The phandler of realtek dwc3 node"phandler"? Except obvious typo, drop "The phandler of" and describe what is it for.
realtek,usb is a phandle of syscon used to control realtek dwc3 register.
Then no, phy should not control dwc3.
OK I know it doesn't make sense.
We want to disable phy suspend from mac layer.
I will try other method.
Quoted 10 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
+ $ref: /schemas/types.yaml#/definitions/phandle
Anyway, it shouldn't be here. No, no.
Can I use it for phandle of syscon?
PHY getting phandle to block using this PHY? Looks wrong. Why would PHY need to poke IP block register?
OK. I know it doesn't make sense.
Re: [PATCH v2 3/3] dt-bindings: phy: realtek: Add the doc about the Realtek SoC USB 2.0/3.0 PHY
Quoted 9 lines · Stanley Chang[昌育德]
Hi Krzysztof,
Quoted 7 lines
Quoted 6 lines
Most of the properties are about the phy parameters. Is the phy parameter data suitable to be placed in DTS? I referenced other phy drivers.
These parameters should not be defined in dts. I would move the parameters to the driver.
Quoted 3 lines
Quoted 2 lines
If these can be in the driver, why would ever they be in DTS in the first place?
Our platforms have 3 xhci controllers which map to 3 different phy ports.
You mean on the same SoC?
Quoted 4 lines
And the three phy ports use the same driver, but the parameters are different. So I put the parameter settings in DTS, we have 3 usb-phy nodes representing 3 phy ports. Also, some parameters have to be adjusted for different boards.
Therefore, it is more applicable in DTS than in driver.
Then it looks justified in DT, so please write proper descriptions for proper properties. Underscores are not allowed in node names. No fake nodes. Properties should usually describe physical/hardware effect not the register value.
qcom,usb-snps-femto-v2.yaml is nice example. Few Mediatek bindings also would work.
'
Best regards,
Krzysztof
Signature · 3 lines
linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
RE: [PATCH v2 3/3] dt-bindings: phy: realtek: Add the doc about the Realtek SoC USB 2.0/3.0 PHY
Hi Krzysztof,
Quoted 6 lines
Quoted 1 line
Quoted 1 line
If these can be in the driver, why would ever they be in DTS in the first
place?
Quoted 2 lines
Quoted 1 line
Our platforms have 3 xhci controllers which map to 3 different phy ports.
You mean on the same SoC?
Yes, one SoC has three xhci controllers.
Quoted 11 lines
Quoted 1 line
And the three phy ports use the same driver, but the parameters are
different.
Quoted 1 line
So I put the parameter settings in DTS, we have 3 usb-phy nodes representing
3 phy ports.
Quoted 2 lines
Also, some parameters have to be adjusted for different boards. Therefore, it is more applicable in DTS than in driver.
Then it looks justified in DT, so please write proper descriptions for proper properties. Underscores are not allowed in node names. No fake nodes. Properties should usually describe physical/hardware effect not the register value.
I will write more detail for properties.
Quoted 3 lines
qcom,usb-snps-femto-v2.yaml is nice example. Few Mediatek bindings also would work.
'
Thanks,
Stanley
Greg Kroah-Hartman
maintainerQuoted 42 lines · Stanley Chang
In Realtek SoC, the parameter of usb phy is designed to can dynamic tuning base on port status. Therefore, add a notify callback of phy driver when usb port status change.
Signed-off-by Stanley Chang <[email protected]>---
v1 to v2 change:
No change--- drivers/usb/core/hub.c | 13 +++++++++++++ include/linux/usb/phy.h | 14 ++++++++++++++ 2 files changed, 27 insertions(+)drivers/usb/core/hub.c +13
-0@@ -614,6 +614,19 @@ static int hub_ext_port_status(struct usb_hub *hub, int port1, int type, ret =0 ; }mutex_unlock (&hub->status_mutex); + +if (!ret) { +struct usb_device *hdev = hub->hdev; + +if (hdev && !hdev->parent) { +struct usb_hcd *hcd =bus_to_hcd (hdev->bus); + +if (hcd->usb_phy) +usb_phy_notify_port_status (hcd->usb_phy, + port1 -1 , *status, *change); + } + } +return ret; }include/linux/usb/phy.h +0
-0
include/linux/usb/phy.h struct usb_phy { · line 153
Quoted 10 lines
include/linux/usb/phy.h +4
-0@@ -144,6 +144,10 @@ struct usb_phy {*/ int (*set_wakeup)(struct usb_phy *x,bool enabled); +/* notify phy port status change */ +int (*notify_port_status)(struct usb_phy *x, +int port,u16 portstatus,u16 portchange); +/* notify phy connect status change */ int (*notify_connect)(struct usb_phy *x,enum usb_device_speed speed);
Why can't this be part of the same notify_connect() callback?
What makes it different somehow? Please document this much better.
include/linux/usb/phy.h usb_phy_set_wakeup(struct usb_phy *x, bool enabled) · line 327
Quoted 9 lines
include/linux/usb/phy.h +5
-0@@ -316,6 +320,16 @@ usb_phy_set_wakeup(struct usb_phy *x, bool enabled)return 0 ; } +static inline int +usb_phy_notify_port_status (struct usb_phy *x,int port,u16 portstatus, +u16 portchange) +{ +if (x && x->notify_port_status)
How can x ever be NULL?
thanks,
greg k-h
Signature · 3 lines
linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
Hi Greg,
Quoted 6 lines
Quoted 6 lines
include/linux/usb/phy.h +0
-0@@ -144,6 +144,10 @@ struct usb_phy {*/ int (*set_wakeup)(struct usb_phy *x,bool enabled);
Quoted 9 lines
include/linux/usb/phy.h struct usb_phy { · line 153
Quoted 7 lines
include/linux/usb/phy.h +4
-0+/* notify phy port status change */ +int (*notify_port_status)(struct usb_phy *x, +int port,u16 portstatus,u16 portchange); +/* notify phy connect status change */ int (*notify_connect)(struct usb_phy *x,enum usb_device_speed speed);Why can't this be part of the same
notify_connect()callback?
The notify connect is at device ready. But I want notify port status change before port reset.
Quoted 1 line
What makes it different somehow? Please document this much better.
In Realtek phy driver, we have designed to dynamically adjust disconnection level and calibrate phy parameters. So we do this when the device connected bit changes and when the disconnected bit changes. Port status change notification:
1. Check if portstatus is USB_PORT_STAT_CONNECTION and portchange is USB_PORT_STAT_C_CONNECTION. The device is connected, the driver lowers the disconnection level and calibrates the phy parameters.
2. The device disconnects, the driver increases the disconnect level and calibrates the phy parameters.
If we adjust the disconnection level in notify_connect , the disconnect may have been triggered at this stage. So we need to change that as early as possible.
Quoted 6 lines
include/linux/usb/phy.h usb_phy_set_wakeup(struct usb_phy *x, bool
Quoted 2 lines
include/linux/usb/phy.h +0
-0@@ -316,6 +320,16 @@ usb_phy_set_wakeup(struct usb_phy *x, boolenabled)
Quoted 3 lines
include/linux/usb/phy.h +0
-0return 0 ; }
Quoted 7 lines
include/linux/usb/phy.h usb_phy_set_wakeup(struct usb_phy *x, bool enabled) · line 327
Quoted 5 lines
include/linux/usb/phy.h +5
-0+static inline int +usb_phy_notify_port_status (struct usb_phy *x,int port,u16 portstatus, +u16 portchange) +{ +if (x && x->notify_port_status)How can x ever be NULL?
It is possible.
If the controller not use usb-phy driver. It is NULL.
Thanks,
Stanley
Greg Kroah-Hartman
maintainerQuoted 29 lines · Stanley Chang[昌育德]
Hi Greg,
Quoted 6 lines
Quoted 6 lines
include/linux/usb/phy.h +0
-0@@ -144,6 +144,10 @@ struct usb_phy {*/ int (*set_wakeup)(struct usb_phy *x,bool enabled);Quoted 9 lines
include/linux/usb/phy.h struct usb_phy { · line 153
Quoted 7 lines
include/linux/usb/phy.h +4
-0+/* notify phy port status change */ +int (*notify_port_status)(struct usb_phy *x, +int port,u16 portstatus,u16 portchange); +/* notify phy connect status change */ int (*notify_connect)(struct usb_phy *x,enum usb_device_speed speed);Why can't this be part of the same
notify_connect()callback?The notify connect is at device ready. But I want notify port status change before port reset.
Quoted 1 line
What makes it different somehow? Please document this much better.
In Realtek phy driver, we have designed to dynamically adjust disconnection level and calibrate phy parameters. So we do this when the device connected bit changes and when the disconnected bit changes. Port status change notification:
1. Check if portstatus isUSB_PORT_STAT_CONNECTIONand portchange isUSB_PORT_STAT_C_CONNECTION. The device is connected, the driver lowers the disconnection level and calibrates the phy parameters.
2. The device disconnects, the driver increases the disconnect level and calibrates the phy parameters.
Quoted 2 lines
If we adjust the disconnection level in
notify_connect, the disconnect may have been triggered at this stage. So we need to change that as early as possible.
Please put this type of information in the changelog and in the comments for the callback when you resubmit it.
thanks,
greg k-h
Signature · 3 lines
linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
Hi Greg,
Quoted 17 lines
Quoted 3 lines
Why can't this be part of the same
notify_connect()callback?The notify connect is at device ready. But I want notify port status change
before port reset.
Quoted 4 lines
Quoted 2 lines
What makes it different somehow? Please document this much better.
In Realtek phy driver, we have designed to dynamically adjust disconnection
level and calibrate phy parameters.
Quoted 1 line
So we do this when the device connected bit changes and when the
disconnected bit changes.
Quoted 2 lines
Port status change notification:
1. Check if portstatus isUSB_PORT_STAT_CONNECTIONand portchange is
USB_PORT_STAT_C_CONNECTION.Quoted 1 line
The device is connected, the driver lowers the disconnection level and
calibrates the phy parameters.
Quoted 1 line
2. The device disconnects, the driver increases the disconnect level and
Quoted 8 lines
calibrates the phy parameters.
Quoted 2 lines
If we adjust the disconnection level in
notify_connect, the disconnect mayhave been triggered at this stage.
Quoted 1 line
So we need to change that as early as possible.
Please put this type of information in the changelog and in the comments for the callback when you resubmit it.
Okay, I will add this information at next version.
Thanks,
Stanley