Skip to contentSkip to conversation

usb: phy: add usb phy notify port status API

PATCH Superseded Stanley Chang 4 participants 33 messages Jun 7, 2023 – Jun 8, 2023

Subsystems (3)

v3 of 9 Superseded Latest is v9 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/5 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.

The Realtek phy driver is designed to dynamically adjust disconnection level and calibrate phy parameters. When the device connected bit changes and when the disconnected bit changes, do port status change notification:

Check if portstatus is USB_PORT_STAT_CONNECTION and portchange is USB_PORT_STAT_C_CONNECTION.
1. 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.

When controller to notify connect that device is already ready. 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. Therefore, we add an api to notify phy the port status changes.

---
v2 to v3 change:
Add more comments about the reason for adding this api
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
index 97a0f8faea6e..b4fbbeae1927 100644
@@ -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
index e4de6bc1f69b..53bf3540098f 100644
@@ -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
#1 lore raw

PATCH v3 2/5 phy: realtek: usb: Add driver for the Realtek SoC USB 2.0 PHY

Realtek DHC (digital home center) RTD SoCs support DWC3 XHCI USB controller. Added the driver to drive the USB 2.0 PHY transceivers.

---
v2 to v3 change:
1. Broken down into two patches, one for each of USB 2 & 3 PHY.
2. Removed parameter v1 support for simplification.
3. Use remove_new for driver remove callback.
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 kernel test robot.

---
 drivers/phy/Kconfig                |    1 +
 drivers/phy/Makefile               |    1 +
 drivers/phy/realtek/Kconfig        |   13 +
 drivers/phy/realtek/Makefile       |    2 +
 drivers/phy/realtek/phy-rtk-usb2.c | 1914 ++++++++++++++++++++++++++++
 5 files changed, 1931 insertions(+)
 create mode 100644 drivers/phy/realtek/Kconfig
 create mode 100644 drivers/phy/realtek/Makefile
 create mode 100644 drivers/phy/realtek/phy-rtk-usb2.c
drivers/phy/Kconfig +1 -0
index f46e3148d286..6d04a0029c6c 100644
@@ -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
index 54f312c10a40..ba7c100b14fc 100644
@@ -26,6 +26,7 @@ obj-y					+= allwinner/	\
 					   mscc/	\
 					   qualcomm/	\
 					   ralink/	\
+					   realtek/	\
 					   renesas/	\
 					   rockchip/	\
 					   samsung/	\
drivers/phy/realtek/Kconfig new file +13 -0
new file mode 100644
index 000000000000..76e31f6abdee
@@ -0,0 +1,13 @@
+# 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.
drivers/phy/realtek/Makefile new file +2 -0
new file mode 100644
index 000000000000..cf5d440841a2
@@ -0,0 +1,2 @@
+# SPDX-License-Identifier: GPL-2.0
+obj-$(CONFIG_PHY_RTK_RTD_USB2PHY)	+= phy-rtk-usb2.o
drivers/phy/realtek/phy-rtk-usb2.c new file +1914 -0

1,914 lines not on this page · raw message

Signature · 1 line
2.34.1
#2 lore raw

Re: [PATCH v3 2/5] phy: realtek: usb: Add driver for the Realtek SoC USB 2.0 PHY

kernel test robot noticed the following build errors:

Hi Stanley,

kernel test robot noticed the following build errors:

[auto build test ERROR on usb/usb-testing]
[also build test ERROR on usb/usb-next usb/usb-linus robh/for-next linus/master v6.4-rc5 next-20230607] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Stanley-Chang/phy-realtek-usb-Add-driver-for-the-Realtek-SoC-USB-2-0-PHY/20230607-142704
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing
patch link:    https://lore.kernel.org/r/20230607062500.24669-2-stanley_chang%40realtek.com
patch subject: [PATCH v3 2/5] phy: realtek: usb: Add driver for the Realtek SoC USB 2.0 PHY
config: sh-randconfig-r033-20230607 (https://download.01.org/0day-ci/archive/20230607/[email protected]/config)
compiler: sh4-linux-gcc (GCC) 12.3.0

reproduce (this is a W=1 build):
mkdir -p ~/bin
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git remote add usb https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git
git fetch usb usb-testing
git checkout usb/usb-testing
b4 shazam https://lore.kernel.org/r/[email protected]
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.3.0 ~/bin/make.cross W=1 O=build_dir --shuffle=2827500481 ARCH=sh olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.3.0 ~/bin/make.cross W=1 O=build_dir --shuffle=2827500481 ARCH=sh SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

sh4-linux-ld: drivers/phy/realtek/phy-rtk-usb2.o: in function `rtk_usb2phy_remove':

>> drivers/phy/realtek/phy-rtk-usb2.c:1891: undefined reference to `usb_remove_phy'
   sh4-linux-ld: drivers/phy/realtek/phy-rtk-usb2.o: in function `create_debug_files':
>> drivers/phy/realtek/phy-rtk-usb2.c:1378: undefined reference to `usb_debug_root'
   sh4-linux-ld: drivers/phy/realtek/phy-rtk-usb2.o: in function `rtk_usb2phy_probe':
>> drivers/phy/realtek/phy-rtk-usb2.c:1882: undefined reference to `usb_add_phy_dev'
   sh4-linux-ld: drivers/power/supply/wm831x_power.o: in function `wm831x_power_probe':
>> drivers/power/supply/wm831x_power.c:695: undefined reference to `devm_usb_get_phy_by_phandle'
   sh4-linux-ld: drivers/power/supply/rt9455_charger.o: in function `rt9455_probe':
>> drivers/power/supply/rt9455_charger.c:1682: undefined reference to `devm_usb_get_phy'
   sh4-linux-ld: drivers/power/supply/isp1704_charger.o: in function `isp1704_charger_probe':
>> drivers/power/supply/isp1704_charger.c:73: undefined reference to `devm_usb_get_phy_by_phandle'
>> sh4-linux-ld: drivers/power/supply/isp1704_charger.c:73: undefined reference to `devm_usb_get_phy'
   sh4-linux-ld: drivers/power/supply/bq25890_charger.o: in function `bq25890_probe':
>> drivers/power/supply/bq25890_charger.c:1511: undefined reference to `devm_usb_get_phy'
   sh4-linux-ld: drivers/power/supply/bq256xx_charger.o: in function `bq256xx_probe':
>> drivers/power/supply/bq256xx_charger.c:1743: undefined reference to `devm_usb_get_phy'

Kconfig warnings: (for reference only)
WARNING: unmet direct dependencies detected for USB_PHY Depends on [n]: USB_SUPPORT [=n]
Selected by [y]:
- PHY_RTK_RTD_USB2PHY [=y]

vim +1891 drivers/phy/realtek/phy-rtk-usb2.c

1802
1803 static int rtk_usb2phy_probe(struct platform_device *pdev)
1804 {
1805 struct rtk_usb_phy *rtk_phy;
1806 struct device *dev = &pdev->dev;
1807 struct device_node *node;
1808 struct device_node *sub_node;
1809 struct phy *generic_phy;
1810 struct phy_provider *phy_provider;
1811 int phyN, ret = 0;
1812
1813 rtk_phy = devm_kzalloc(dev, sizeof(*rtk_phy), GFP_KERNEL);
1814 if (!rtk_phy)
1815 return -ENOMEM;
1816
1817 rtk_phy->dev = &pdev->dev;
1818 rtk_phy->phy.dev = rtk_phy->dev;
1819 rtk_phy->phy.label = "rtk-usb2phy";
1820 rtk_phy->phy.notify_port_status = rtk_usb_phy_notify_port_status;
1821
1822 if (!dev->of_node) {
1823 dev_err(dev, "%s %d No device node\n", __func__, __LINE__);
1824 goto err;
1825 }
1826
1827 node = dev->of_node;
1828
1829 rtk_phy->usb_ctrl_regs = syscon_regmap_lookup_by_phandle(node, "realtek,usb-ctrl");
1830 if (IS_ERR(rtk_phy->usb_ctrl_regs)) {
1831 dev_info(dev, "%s: DTS no support usb_ctrl regs syscon\n", __func__);
1832 rtk_phy->usb_ctrl_regs = NULL;
1833 }
1834
1835 phyN = of_get_child_count(node);
1836 rtk_phy->phyN = phyN;
1837 dev_dbg(dev, "%s phyN=%d\n", __func__, rtk_phy->phyN);
1838
1839 rtk_phy->reg_addr = devm_kzalloc(dev,
1840 sizeof(struct reg_addr) * phyN, GFP_KERNEL);
1841 if (!rtk_phy->reg_addr)
1842 return -ENOMEM;
1843
1844 rtk_phy->phy_data = devm_kzalloc(dev,
1845 sizeof(struct phy_data) * phyN, GFP_KERNEL);
1846 if (!rtk_phy->phy_data)
1847 return -ENOMEM;
1848
1849 for (sub_node = of_get_next_child(node, NULL); sub_node != NULL;
1850 sub_node = of_get_next_child(node, sub_node)) {
1851 ret = get_phy_parameter(rtk_phy, sub_node);
1852 if (ret) {
1853 dev_err(dev, "%s: get_phy_parameter fail ret=%d\n",
1854 __func__, ret);
1855 goto err;
1856 }
1857 }
1858
1859 platform_set_drvdata(pdev, rtk_phy);
1860
1861 generic_phy = devm_phy_create(rtk_phy->dev, NULL, &ops);
1862 if (IS_ERR(generic_phy))
1863 return PTR_ERR(generic_phy);
1864
1865 phy_set_drvdata(generic_phy, rtk_phy);
1866
1867 phy_provider = devm_of_phy_provider_register(rtk_phy->dev,
1868 of_phy_simple_xlate);
1869 if (IS_ERR(phy_provider))
1870 return PTR_ERR(phy_provider);
1871
1872 ret = usb_add_phy_dev(&rtk_phy->phy);
1873 if (ret)
1874 goto err;
1875
1876 create_debug_files(rtk_phy);
1877
1878 err:
1879 dev_dbg(dev, "Probe RTK USB 2.0 PHY (ret=%d)\n", ret);
1880
1881 return ret;

> 1882	}
  1883	
  1884	static void rtk_usb2phy_remove(struct platform_device *pdev)
  1885	{
  1886		struct rtk_usb_phy *rtk_phy = platform_get_drvdata(pdev);
  1887	
  1888		remove_debug_files(rtk_phy);
  1889	
  1890		usb_remove_phy(&rtk_phy->phy);
> 1891	}

1892

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#3 lore raw

Re: [PATCH v3 2/5] phy: realtek: usb: Add driver for the Realtek SoC USB 2.0 PHY

In reply to Stanley Chang
Quoted 9 lines · Stanley Chang

Realtek DHC (digital home center) RTD SoCs support DWC3 XHCI USB controller. Added the driver to drive the USB 2.0 PHY transceivers.

---
v2 to v3 change:
1. Broken down into two patches, one for each of USB 2 & 3 PHY.
2. Removed parameter v1 support for simplification.
3. Use remove_new for driver remove callback.

...

Quoted 11 lines
drivers/phy/realtek/phy-rtk-usb2.c new file +11 -0
+	platform_set_drvdata(pdev, rtk_phy);
+
+	generic_phy = devm_phy_create(rtk_phy->dev, NULL, &ops);
+	if (IS_ERR(generic_phy))
+		return PTR_ERR(generic_phy);
+
+	phy_set_drvdata(generic_phy, rtk_phy);
+
+	phy_provider = devm_of_phy_provider_register(rtk_phy->dev,
+				    of_phy_simple_xlate);
+	if (IS_ERR(phy_provider))

drivers/phy/realtek/phy-rtk-usb2.c line 1879

Quoted 10 lines
drivers/phy/realtek/phy-rtk-usb2.c new file +10 -0
+		return PTR_ERR(phy_provider);
+
+	ret = usb_add_phy_dev(&rtk_phy->phy);
+	if (ret)
+		goto err;
+
+	create_debug_files(rtk_phy);
+
+err:
+	dev_dbg(dev, "Probe RTK USB 2.0 PHY (ret=%d)\n", ret);

I commented on your second patch, but everything is applicable here as well. You have many useless debug messages. Many incorrect or useless "if() return" which point to broken driver design (e.g. concurrent access to half initialized structures where you substitute lack of synchronization with incorrect "if() return"). Undocumented user interface is one more big trouble.

I doubt you run checkpatch on this (be sure to run it with --strict and fix almost everything).

Best regards,
Krzysztof

Signature · 3 lines
linux-phy mailing list
[email protected]
https://lists.infradead.org/mailman/listinfo/linux-phy
#4 lore raw

RE: [PATCH v3 2/5] phy: realtek: usb: Add driver for the Realtek SoC USB 2.0 PHY

Hi Krzysztof,

Quoted 10 lines

I commented on your second patch, but everything is applicable here as well. You have many useless debug messages. Many incorrect or useless "if() return" which point to broken driver design (e.g. concurrent access to half initialized structures where you substitute lack of synchronization with incorrect "if() return"). Undocumented user interface is one more big trouble.

I doubt you run checkpatch on this (be sure to run it with --strict and fix almost everything).

1. I use checkpatch but without --strict. I will add it add and check again.
2. Do the debugfs interfaces need to provide a document?
I don't find any reference about this.
3. I will follow the comment of second patch to fix this patch

Thanks,
Stanley

#5 lore raw

Re: [PATCH v3 2/5] phy: realtek: usb: Add driver for the Realtek SoC USB 2.0 PHY

Quoted 9 lines · Stanley Chang[昌育德]

Hi Krzysztof,

Quoted 6 lines

I commented on your second patch, but everything is applicable here as well. You have many useless debug messages. Many incorrect or useless "if() return" which point to broken driver design (e.g. concurrent access to half initialized structures where you substitute lack of synchronization with incorrect "if() return"). Undocumented user interface is one more big trouble.

Quoted 7 lines
Quoted 4 lines

I doubt you run checkpatch on this (be sure to run it with --strict and fix almost everything).

1. I use checkpatch but without --strict. I will add it add and check again.
2. Do the debugfs interfaces need to provide a document?
I don't find any reference about this.

debugfs interface is for debug but in your case you don't use it that way.

Best regards,
Krzysztof

Signature · 3 lines
linux-phy mailing list
[email protected]
https://lists.infradead.org/mailman/listinfo/linux-phy
#6 lore raw

Re: [PATCH v3 2/5] phy: realtek: usb: Add driver for the Realtek SoC USB 2.0 PHY

In reply to Stanley Chang[昌育德]
Quoted 9 lines · Stanley Chang[昌育德]

Hi Krzysztof,

Quoted 6 lines

I commented on your second patch, but everything is applicable here as well. You have many useless debug messages. Many incorrect or useless "if() return" which point to broken driver design (e.g. concurrent access to half initialized structures where you substitute lack of synchronization with incorrect "if() return"). Undocumented user interface is one more big trouble.

Quoted 5 lines
Quoted 4 lines

I doubt you run checkpatch on this (be sure to run it with --strict and fix almost everything).

1. I use checkpatch but without --strict. I will add it add and check again.

Around 300 issues pointed out...

Quoted 2 lines

2. Do the debugfs interfaces need to provide a document? I don't find any reference about this.

Not sure if we have it in docs, but it is discussed every now and then...

https://lore.kernel.org/all/CAMuHMdUaugQ5+Zhmg=oe=X2wvhazMiT=K-su0EJYKzD4Hdyn3Q@mail.gmail.com/
https://lore.kernel.org/all/2023060209-scouts-affection-f54d@gregkh/

Best regards,
Krzysztof

Signature · 3 lines
linux-phy mailing list
[email protected]
https://lists.infradead.org/mailman/listinfo/linux-phy
#7 lore raw

Re: [PATCH v3 2/5] phy: realtek: usb: Add driver for the Realtek SoC USB 2.0 PHY

In reply to Stanley Chang
kernel test robot noticed the following build errors:

Hi Stanley,

kernel test robot noticed the following build errors:

[auto build test ERROR on usb/usb-testing]
[also build test ERROR on usb/usb-next usb/usb-linus robh/for-next linus/master v6.4-rc5 next-20230607] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Stanley-Chang/phy-realtek-usb-Add-driver-for-the-Realtek-SoC-USB-2-0-PHY/20230607-142704
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing
patch link:    https://lore.kernel.org/r/20230607062500.24669-2-stanley_chang%40realtek.com
patch subject: [PATCH v3 2/5] phy: realtek: usb: Add driver for the Realtek SoC USB 2.0 PHY
config: arm64-randconfig-r014-20230607 (https://download.01.org/0day-ci/archive/20230608/[email protected]/config)
compiler: aarch64-linux-gcc (GCC) 12.3.0

reproduce (this is a W=1 build):
mkdir -p ~/bin
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
git remote add usb https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git
git fetch usb usb-testing
git checkout usb/usb-testing
b4 shazam https://lore.kernel.org/r/[email protected]
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.3.0 ~/bin/make.cross W=1 O=build_dir ARCH=arm64 olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.3.0 ~/bin/make.cross W=1 O=build_dir ARCH=arm64 SHELL=/bin/bash

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>, old ones prefixed by <<):

ERROR: modpost: "devm_usb_get_phy_by_phandle" [drivers/power/supply/wm831x_power.ko] undefined!

>> ERROR: modpost: "devm_usb_get_phy" [drivers/power/supply/da9150-charger.ko] undefined!

Kconfig warnings: (for reference only)
WARNING: unmet direct dependencies detected for USB_PHY Depends on [n]: USB_SUPPORT [=n]
Selected by [y]:
- PHY_RTK_RTD_USB2PHY [=y]

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#8 lore raw

RE: [PATCH v3 2/5] phy: realtek: usb: Add driver for the Realtek SoC USB 2.0 PHY

Quoted 11 lines

ERROR: modpost: "devm_usb_get_phy_by_phandle"
[drivers/power/supply/wm831x_power.ko] undefined!

Quoted 1 line
Quoted 1 line

ERROR: modpost: "devm_usb_get_phy"

[drivers/power/supply/da9150-charger.ko] undefined!

Kconfig warnings: (for reference only)
WARNING: unmet direct dependencies detected for USB_PHY Depends on [n]: USB_SUPPORT [=n]
Selected by [y]:
- PHY_RTK_RTD_USB2PHY [=y]

I will add USB_SUUPRT dependency to Kconfig.

drivers/phy/realtek/Kconfig +2 -0
index 28ee3d9be568..a5a5a71edc9c 100644
@@ -4,6 +4,7 @@
 #
 config PHY_RTK_RTD_USB2PHY
        tristate "Realtek RTD USB2 PHY Transceiver Driver"
+       depends on USB_SUPPORT
        select GENERIC_PHY
        select USB_PHY
        help
@@ -14,6 +15,7 @@ config PHY_RTK_RTD_USB2PHY
 
 config PHY_RTK_RTD_USB3PHY
        tristate "Realtek RTD USB3 PHY Transceiver Driver"
+       depends on USB_SUPPORT
        select GENERIC_PHY
        select USB_PHY
        help
#9 lore raw

Re: [PATCH v3 2/5] phy: realtek: usb: Add driver for the Realtek SoC USB 2.0 PHY

Quoted 5 lines · Stanley Chang[昌育德]
Quoted 5 lines

ERROR: modpost: "devm_usb_get_phy_by_phandle"
[drivers/power/supply/wm831x_power.ko] undefined!

Quoted 1 line
Quoted 1 line

ERROR: modpost: "devm_usb_get_phy"

[drivers/power/supply/da9150-charger.ko] undefined!

Quoted 8 lines
Quoted 6 lines

Kconfig warnings: (for reference only)
WARNING: unmet direct dependencies detected for USB_PHY Depends on [n]: USB_SUPPORT [=n]
Selected by [y]:
- PHY_RTK_RTD_USB2PHY [=y]

I will add USB_SUUPRT dependency to Kconfig.

Why? Do you see other phy drivers needing it? Few have it but many don't, so you should really investigate the root cause, not just add some dependencies.

Build test your patches locally before sending and investigate the issues.

Best regards,
Krzysztof

#10 lore raw

RE: [PATCH v3 2/5] phy: realtek: usb: Add driver for the Realtek SoC USB 2.0 PHY

Hi Krzysztof,

Quoted 13 lines · Stanley Chang[昌育德]
Quoted 12 lines
Quoted 11 lines

ERROR: modpost: "devm_usb_get_phy_by_phandle"
[drivers/power/supply/wm831x_power.ko] undefined!

Quoted 1 line
Quoted 1 line

ERROR: modpost: "devm_usb_get_phy"

[drivers/power/supply/da9150-charger.ko] undefined!

Kconfig warnings: (for reference only)
WARNING: unmet direct dependencies detected for USB_PHY Depends on [n]: USB_SUPPORT [=n]
Selected by [y]:
- PHY_RTK_RTD_USB2PHY [=y]

Quoted 6 lines
Quoted 1 line

I will add USB_SUUPRT dependency to Kconfig.

Why? Do you see other phy drivers needing it? Few have it but many don't, so you should really investigate the root cause, not just add some dependencies.

Build test your patches locally before sending and investigate the issues.

USB_SUPPORT is required.
Because I have select Kconfig USB_PHY.
Some drivers have used it as follow
drivers/phy/ti/Kconfig
drivers/phy/amlogic/Kconfig
drivers/phy/renesas/Kconfig
drivers/phy/rockchip/Kconfig
drivers/phy/allwinner/Kconfig

Thanks,
Stanley

#11 lore raw

PATCH v3 3/5 phy: realtek: usb: Add driver for the Realtek SoC USB 3.0 PHY

In reply to Stanley Chang

Realtek DHC (digital home center) RTD SoCs support DWC3 XHCI USB controller. Added the driver to drive the USB 3.0 PHY transceivers.

---
v2 to v3 change:
1. Broken down into two patches, one for each of USB 2 & 3 PHY.
2. Removed parameter v1 support for simplification.
3. Used remove_new for driver remove callback.
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 kernel test robot.

---
 drivers/phy/realtek/Kconfig        |   10 +
 drivers/phy/realtek/Makefile       |    1 +
 drivers/phy/realtek/phy-rtk-usb3.c | 1070 ++++++++++++++++++++++++++++
 3 files changed, 1081 insertions(+)
 create mode 100644 drivers/phy/realtek/phy-rtk-usb3.c
drivers/phy/realtek/Kconfig +10 -0
index 76e31f6abdee..28ee3d9be568 100644
@@ -11,3 +11,13 @@ config PHY_RTK_RTD_USB2PHY
 	  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 +1 -0
index cf5d440841a2..ed7b47ff8a26 100644
@@ -1,2 +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-usb3.c new file +1070 -0

1,070 lines not on this page · raw message

Signature · 1 line
2.34.1
#12 lore raw

Re: [PATCH v3 3/5] phy: realtek: usb: Add driver for the Realtek SoC USB 3.0 PHY

Quoted 62 lines · Stanley Chang

Realtek DHC (digital home center) RTD SoCs support DWC3 XHCI USB controller. Added the driver to drive the USB 3.0 PHY transceivers.

---

drivers/phy/realtek/phy-rtk-usb3.c new file +55 -0
+static inline int utmi_wait_register(void __iomem *reg, u32 mask, u32 result)
+{
+	int ret;
+	unsigned int val;
+
+	ret = read_poll_timeout(readl, val, ((val & mask) == result),
+		    PHY_IO_DELAY_US, PHY_IO_TIMEOUT_USEC, false, reg);
+	if (ret) {
+		pr_err("%s can't program USB phy\n", __func__);
+		return -ETIMEDOUT;
+	}
+
+	return 0;
+}
+
+static int rtk_usb_phy3_wait_vbusy(struct reg_addr *regAddr)
+{
+	return utmi_wait_register(regAddr->reg_mdio_ctl, USB_MDIO_CTRL_PHY_BUSY, 0);
+}
+
+static u16 rtk_usb_phy_read(struct reg_addr *regAddr, char addr)
+{
+	unsigned int regVal;
+	u32 value;
+
+	regVal = (addr << USB_MDIO_CTRL_PHY_ADDR_SHIFT);
+
+	writel(regVal, regAddr->reg_mdio_ctl);
+
+	rtk_usb_phy3_wait_vbusy(regAddr);
+
+	value = readl(regAddr->reg_mdio_ctl);
+	value = value >> USB_MDIO_CTRL_PHY_DATA_SHIFT;
+
+	return (u16)value;
+}
+
+static int rtk_usb_phy_write(struct reg_addr *regAddr, char addr, u16 data)
+{
+	unsigned int regVal;
+
+	regVal = USB_MDIO_CTRL_PHY_WRITE |
+		    (addr << USB_MDIO_CTRL_PHY_ADDR_SHIFT) |
+		    (data << USB_MDIO_CTRL_PHY_DATA_SHIFT);
+
+	writel(regVal, regAddr->reg_mdio_ctl);
+
+	rtk_usb_phy3_wait_vbusy(regAddr);
+
+	return 0;
+}
+
+static void do_rtk_usb3_phy_toggle(struct rtk_usb_phy *rtk_phy, int i,
+	    bool isConnect)
+{

drivers/phy/realtek/phy-rtk-usb3.c line 149

Quoted 10 lines
drivers/phy/realtek/phy-rtk-usb3.c new file +10 -0
+	struct reg_addr *regAddr;
+	struct phy_data *phy_data;
+	struct phy_parameter *phy_parameter;
+	size_t index;
+
+	regAddr = &((struct reg_addr *)rtk_phy->reg_addr)[i];
+	phy_data = &((struct phy_data *)rtk_phy->phy_data)[i];
+
+	if (!phy_data) {
+		dev_err(rtk_phy->dev, "%s phy_data is NULL!\n", __func__);

???

Quoted 20 lines
drivers/phy/realtek/phy-rtk-usb3.c new file +20 -0
+		return;
+	}
+
+	if (!phy_data->do_toggle)
+		return;
+
+	phy_parameter = phy_data->parameter;
+
+	index = PHY_ADDR_MAP_ARRAY_INDEX(PHY_ADDR_0x09);
+
+	if (index < phy_data->size) {
+		u8 addr = (phy_parameter + index)->addr;
+		u16 data = (phy_parameter + index)->data;
+
+		if (addr == 0xFF) {
+			addr = ARRAY_INDEX_MAP_PHY_ADDR(index);
+			data = rtk_usb_phy_read(regAddr, addr);
+			(phy_parameter + index)->addr = addr;
+			(phy_parameter + index)->data = data;
+		}

drivers/phy/realtek/phy-rtk-usb3.c line 179

Quoted 10 lines
drivers/phy/realtek/phy-rtk-usb3.c new file +10 -0
+		mdelay(1);
+		dev_info(rtk_phy->dev,
+			    "%s ########## to toggle PHY addr 0x09 BIT(9)\n",
+			    __func__);
+		rtk_usb_phy_write(regAddr, addr, data&(~BIT(9)));
+		mdelay(1);
+		rtk_usb_phy_write(regAddr, addr, data);
+	}
+	dev_info(rtk_phy->dev, "%s ########## PHY addr 0x1f = 0x%04x\n",
+		    __func__, rtk_usb_phy_read(regAddr, PHY_ADDR_0x1F));

Please drop all simple debug success messages. Linux has already infrastructure for this.

...

drivers/phy/realtek/phy-rtk-usb3.c line 318

Quoted 12 lines
drivers/phy/realtek/phy-rtk-usb3.c new file +12 -0
+	return 0;
+}
+
+static int rtk_usb_phy_init(struct phy *phy)
+{
+	struct rtk_usb_phy *rtk_phy = phy_get_drvdata(phy);
+	int ret = 0;
+	int i;
+	unsigned long phy_init_time = jiffies;
+
+	if (!rtk_phy) {
+		pr_err("%s rtk_phy is NULL!\n", __func__);

What? How is this possible?

drivers/phy/realtek/phy-rtk-usb3.c line 327

Quoted 9 lines
drivers/phy/realtek/phy-rtk-usb3.c new file +9 -0
+		return -ENODEV;
+	}
+
+	dev_dbg(rtk_phy->dev, "Init RTK USB 3.0 PHY\n");
+	for (i = 0; i < rtk_phy->phyN; i++)
+		ret = do_rtk_usb_phy_init(rtk_phy, i);
+
+	dev_info(rtk_phy->dev, "Initialized RTK USB 3.0 PHY (take %dms)\n",
+		    jiffies_to_msecs(jiffies - phy_init_time));

Please drop all simple debug success messages. Linux has already infrastructure for this.

drivers/phy/realtek/phy-rtk-usb3.c line 340

Quoted 13 lines
drivers/phy/realtek/phy-rtk-usb3.c new file +13 -0
+	return ret;
+}
+
+static int rtk_usb_phy_exit(struct phy *phy)
+{
+	struct rtk_usb_phy *rtk_phy = phy_get_drvdata(phy);
+
+	if (!rtk_phy) {
+		pr_err("%s rtk_phy is NULL!\n", __func__);
+		return -ENODEV;
+	}
+
+	dev_dbg(rtk_phy->dev, "Exit RTK USB 3.0 PHY\n");

Please drop all simple debug success messages. Linux has already infrastructure for this.

drivers/phy/realtek/phy-rtk-usb3.c line 360

Quoted 10 lines
drivers/phy/realtek/phy-rtk-usb3.c new file +10 -0
+static void rtk_usb_phy_toggle(struct usb_phy *usb3_phy, bool isConnect, int port)
+{
+	int index = port;
+	struct rtk_usb_phy *rtk_phy = NULL;
+
+	if (usb3_phy != NULL && usb3_phy->dev != NULL)
+		rtk_phy = dev_get_drvdata(usb3_phy->dev);
+
+	if (rtk_phy == NULL) {
+		pr_err("%s ERROR! NO this device\n", __func__);

Your error messages are not helping. No need to shout, no need to handle some non-existing cases. If this is real case, you have broken driver. I actually suspect that.

How can you interface with a driver where there is no device?

Quoted 6 lines
drivers/phy/realtek/phy-rtk-usb3.c new file +6 -0
+		return;
+	}
+
+	if (index > rtk_phy->phyN) {
+		pr_err("%s %d ERROR! port=%d > phyN=%d\n",
+			    __func__, __LINE__, index, rtk_phy->phyN);

drivers/phy/realtek/phy-rtk-usb3.c line 376

Quoted 10 lines
drivers/phy/realtek/phy-rtk-usb3.c new file +10 -0
+		return;
+	}
+
+	do_rtk_usb3_phy_toggle(rtk_phy, index, isConnect);
+}
+
+static int rtk_usb_phy_notify_port_status(struct usb_phy *x, int port,
+	    u16 portstatus, u16 portchange)
+{
+	bool isConnect = false;

This is not C++. Don't use camelcase. See Coding style document.

Quoted 6 lines
drivers/phy/realtek/phy-rtk-usb3.c new file +6 -0
+
+	pr_debug("%s port=%d portstatus=0x%x portchange=0x%x\n",
+		    __func__, port, (int)portstatus, (int)portchange);
+	if (portstatus & USB_PORT_STAT_CONNECTION)
+		isConnect = true;
+

...

Quoted 15 lines
drivers/phy/realtek/phy-rtk-usb3.c new file +15 -0
+
+static int rtk_usb3_set_parameter_show(struct seq_file *s, void *unused)
+{
+	struct rtk_usb_phy *rtk_phy = s->private;
+	const struct file *file = s->file;
+	const char *file_name = file_dentry(file)->d_iname;
+	struct dentry *p_dentry = file_dentry(file)->d_parent;
+	const char *phy_dir_name = p_dentry->d_iname;
+	int ret, index;
+	struct phy_data *phy_data = NULL;
+
+	for (index = 0; index < rtk_phy->phyN; index++) {
+		size_t sz = 30;
+		char name[30] = {0};
+

drivers/phy/realtek/phy-rtk-usb3.c line 564

Quoted 10 lines
drivers/phy/realtek/phy-rtk-usb3.c new file +10 -0
+		snprintf(name, sz, "phy%d", index);
+		if (strncmp(name, phy_dir_name, strlen(name)) == 0) {
+			phy_data = &((struct phy_data *)rtk_phy->phy_data)[index];
+			break;
+		}
+	}
+	if (!phy_data) {
+		dev_err(rtk_phy->dev,
+				    "%s: No phy_data for %s/%s\n",
+				    __func__, phy_dir_name, file_name);

Mess wrapping/indentation. Actually everywhere in the file...

Quoted 36 lines
drivers/phy/realtek/phy-rtk-usb3.c new file +36 -0
+		return -EINVAL;
+	}
+
+	ret = __get_parameter_at_page(s, rtk_phy, phy_data->parameter, file_name);
+	if (ret < 0)
+		return ret;
+
+	seq_puts(s, "Set phy parameter by following command\n");
+	seq_printf(s, "echo \"value\" > %s/%s\n",
+		    phy_dir_name, file_name);
+
+	return 0;
+}
+
+static int rtk_usb3_set_parameter_open(struct inode *inode, struct file *file)
+{
+	return single_open(file, rtk_usb3_set_parameter_show, inode->i_private);
+}
+
+static ssize_t rtk_usb3_set_parameter_write(struct file *file,
+		const char __user *ubuf, size_t count, loff_t *ppos)
+{
+	const char *file_name = file_dentry(file)->d_iname;
+	struct dentry *p_dentry = file_dentry(file)->d_parent;
+	const char *phy_dir_name = p_dentry->d_iname;
+	struct seq_file		*s = file->private_data;
+	struct rtk_usb_phy		*rtk_phy = s->private;
+	struct reg_addr *regAddr = NULL;
+	struct phy_data *phy_data = NULL;
+	int ret = 0;
+	char buffer[40] = {0};
+	int index;
+
+	if (copy_from_user(&buffer, ubuf,
+		    min_t(size_t, sizeof(buffer) - 1, count)))
+		return -EFAULT;

drivers/phy/realtek/phy-rtk-usb3.c line 610

Quoted 10 lines
drivers/phy/realtek/phy-rtk-usb3.c new file +10 -0
+
+	for (index = 0; index < rtk_phy->phyN; index++) {
+		size_t sz = 30;
+		char name[30] = {0};
+
+		snprintf(name, sz, "phy%d", index);
+		if (strncmp(name, phy_dir_name, strlen(name)) == 0) {
+			regAddr = &((struct reg_addr *)rtk_phy->reg_addr)[index];
+			phy_data = &((struct phy_data *)rtk_phy->phy_data)[index];
+			break;

Where is the ABI documentation for user interface?

Quoted 7 lines
drivers/phy/realtek/phy-rtk-usb3.c new file +7 -0
+
+static inline void create_debug_files(struct rtk_usb_phy *rtk_phy)
+{
+	struct dentry *phy_debug_root = NULL;
+	struct dentry *set_parameter_dir = NULL;
+
+	phy_debug_root = create_phy_debug_root();

drivers/phy/realtek/phy-rtk-usb3.c line 734

Quoted 10 lines
drivers/phy/realtek/phy-rtk-usb3.c new file +10 -0
+
+	if (!phy_debug_root) {
+		dev_err(rtk_phy->dev, "%s Error phy_debug_root is NULL",
+			    __func__);
+		return;
+	}
+	rtk_phy->debug_dir = debugfs_create_dir(dev_name(rtk_phy->dev),
+		    phy_debug_root);
+	if (!rtk_phy->debug_dir) {
+		dev_err(rtk_phy->dev, "%s Error debug_dir is NULL", __func__);

Are you sure you run checkpatch on this? Error messages on debugfs are almost always incorrect.

Quoted 171 lines
drivers/phy/realtek/phy-rtk-usb3.c new file +171 -0
+		return;
+	}
+
+	if (!debugfs_create_file("parameter", 0444,
+		    rtk_phy->debug_dir, rtk_phy,
+		    &rtk_usb3_parameter_fops))
+		goto file_error;
+
+	set_parameter_dir = debugfs_create_dir("set_parameter",
+		    rtk_phy->debug_dir);
+	if (set_parameter_dir) {
+		int index, ret;
+
+		for (index = 0; index < rtk_phy->phyN; index++) {
+			struct dentry *phy_dir;
+			struct phy_data *phy_data;
+			size_t sz = 30;
+			char name[30] = {0};
+
+			snprintf(name, sz, "phy%d", index);
+
+			phy_data = &((struct phy_data *)rtk_phy->phy_data)[index];
+
+			phy_dir = debugfs_create_dir(name, set_parameter_dir);
+			if (!phy_dir) {
+				dev_err(rtk_phy->dev,
+					    "%s Error create folder %s fail\n",
+					    name, __func__);
+				goto file_error;
+			}
+
+			ret = create_debug_set_parameter_files(rtk_phy, phy_dir,
+				    phy_data->size);
+			if (ret < 0) {
+				dev_err(rtk_phy->dev,
+					    "%s Error create files fail\n",
+					    __func__);
+				goto file_error;
+			}
+		}
+	}
+
+	if (!debugfs_create_file("toggle", 0644, rtk_phy->debug_dir, rtk_phy,
+		    &rtk_usb3_toggle_fops))
+		goto file_error;
+
+	return;
+
+file_error:
+	debugfs_remove_recursive(rtk_phy->debug_dir);
+}
+
+static inline void remove_debug_files(struct rtk_usb_phy *rtk_phy)
+{
+	debugfs_remove_recursive(rtk_phy->debug_dir);
+}
+#else
+static inline void create_debug_files(struct rtk_usb_phy *rtk_phy) { }
+static inline void remove_debug_files(struct rtk_usb_phy *rtk_phy) { }
+#endif /* CONFIG_DEBUG_FS */
+
+static int __get_phy_parameter_by_efuse(struct rtk_usb_phy *rtk_phy,
+	    struct phy_data *phy_data, int index)
+{
+	u8 value = 0;
+	struct nvmem_cell *cell;
+
+	if (!phy_data->check_efuse)
+		goto out;
+
+	cell = nvmem_cell_get(rtk_phy->dev, "usb_u3_tx_lfps_swing_trim");
+	if (IS_ERR(cell)) {
+		dev_warn(rtk_phy->dev,
+			    "%s failed to get usb_u3_tx_lfps_swing_trim: %ld\n",
+			    __func__, PTR_ERR(cell));
+	} else {
+		unsigned char *buf;
+		size_t buf_size;
+
+		buf = nvmem_cell_read(cell, &buf_size);
+
+		value = buf[0] & USB_U3_TX_LFPS_SWING_TRIM_MASK;
+
+		dev_dbg(rtk_phy->dev,
+			    "phy index=%d buf=0x%x buf_size=%d value=0x%x\n",
+			    index, buf[0], (int)buf_size, value);
+		kfree(buf);
+		nvmem_cell_put(cell);
+	}
+
+	if ((value > 0) && (value < 0x8))
+		phy_data->efuse_usb_u3_tx_lfps_swing_trim = 0x8;
+	else
+		phy_data->efuse_usb_u3_tx_lfps_swing_trim = (u8)value;
+
+	dev_dbg(rtk_phy->dev, "Get Efuse usb_u3_tx_lfps_swing_trim=0x%x (value=0x%x)\n",
+		    phy_data->efuse_usb_u3_tx_lfps_swing_trim, value);
+
+out:
+	return 0;
+}
+
+static int __get_phy_parameter(struct device *dev, struct phy_data *phy_data,
+	    struct device_node *sub_node)
+{
+	struct phy_parameter *phy_parameter;
+	int i, ret = 0;
+	int data_size, num_cells = 2;
+
+	phy_data->size = MAX_USB_PHY_DATA_SIZE;
+	phy_data->parameter = devm_kzalloc(dev,
+		    sizeof(struct phy_parameter) * phy_data->size, GFP_KERNEL);
+	if (!phy_data->parameter)
+		return -ENOMEM;
+
+	if (!of_get_property(sub_node, "realtek,param", &data_size)) {
+		dev_dbg(dev, "%s No parameter (data_size=%d)\n",
+			    __func__, data_size);
+		data_size = 0;
+	}
+
+	if (!data_size)
+		goto out;
+
+	phy_parameter = phy_data->parameter;
+	/* Set default addr to 0xff for no data case */
+	for (i = 0; i < phy_data->size; i++)
+		(phy_parameter + i)->addr = 0xFF;
+
+	data_size = data_size / (sizeof(u32) * num_cells);
+	for (i = 0; i < data_size; i++) {
+		struct phy_parameter *parameter;
+		u32 addr, data;
+		int offset, index;
+
+		offset = i * num_cells;
+
+		ret = of_property_read_u32_index(sub_node, "realtek,param",
+			    offset, &addr);
+		if (ret) {
+			dev_err(dev, "ERROR: To get param i=%d addr=0x%x\n",
+				    i, addr);
+			break;
+		}
+
+		ret = of_property_read_u32_index(sub_node, "realtek,param",
+			    offset + 1, &data);
+		if (ret) {
+			dev_err(dev, "ERROR: To get param i=%d addr=0x%x\n",
+				    i, data);
+			break;
+		}
+
+		index = PHY_ADDR_MAP_ARRAY_INDEX(addr);
+		parameter = (phy_parameter + index);
+		parameter->addr = (u8)addr;
+		parameter->data = (u16)data;
+
+		dev_dbg(dev, "param index=%d addr=0x%x data=0x%x\n", index,
+			    parameter->addr, parameter->data);
+	}
+
+out:
+	return ret;
+}
+
+static int get_phy_parameter(struct rtk_usb_phy *rtk_phy,
+	    struct device_node *sub_node)
+{
+	struct device *dev = rtk_phy->dev;
+	struct reg_addr *addr;

drivers/phy/realtek/phy-rtk-usb3.c line 915

Quoted 10 lines
drivers/phy/realtek/phy-rtk-usb3.c new file +10 -0
+	struct phy_data *phy_data;
+	int ret = 0;
+	int index;
+
+	if (of_property_read_u32(sub_node, "reg", &index)) {
+		dev_err(dev, "sub_node without reg\n");
+		return -EINVAL;
+	}
+
+	dev_dbg(dev, "sub_node index=%d\n", index);

Please drop all simple debug success messages. Linux has already infrastructure for this.

...

Quoted 12 lines
drivers/phy/realtek/phy-rtk-usb3.c new file +12 -0
+
+static int rtk_usb3phy_probe(struct platform_device *pdev)
+{
+	struct rtk_usb_phy *rtk_phy;
+	struct device *dev = &pdev->dev;
+	struct device_node *node;
+	struct device_node *sub_node;
+	struct phy *generic_phy;
+	struct phy_provider *phy_provider;
+	int ret, phyN;
+
+	rtk_phy = devm_kzalloc(dev, sizeof(*rtk_phy), GFP_KERNEL);

drivers/phy/realtek/phy-rtk-usb3.c line 984

Quoted 10 lines
drivers/phy/realtek/phy-rtk-usb3.c new file +10 -0
+	if (!rtk_phy)
+		return -ENOMEM;
+
+	rtk_phy->dev			= &pdev->dev;
+	rtk_phy->phy.dev		= rtk_phy->dev;
+	rtk_phy->phy.label		= "rtk-usb3phy";
+	rtk_phy->phy.notify_port_status = rtk_usb_phy_notify_port_status;
+
+	if (!dev->of_node) {
+		dev_err(dev, "%s %d No device node\n", __func__, __LINE__);

How is it even possible? If you do not have device node here, how did it probe?

drivers/phy/realtek/phy-rtk-usb3.c line 993

Quoted 9 lines
drivers/phy/realtek/phy-rtk-usb3.c new file +9 -0
+		ret = -ENODEV;
+		goto err;
+	}
+
+	node = dev->of_node;
+
+	phyN = of_get_child_count(node);
+	rtk_phy->phyN = phyN;
+	dev_dbg(dev, "%s phyN=%d\n", __func__, rtk_phy->phyN);

Please drop all simple debug success messages. Linux has already infrastructure for this.

Quoted 32 lines
drivers/phy/realtek/phy-rtk-usb3.c new file +32 -0
+
+	rtk_phy->reg_addr = devm_kzalloc(dev,
+		    sizeof(struct reg_addr) * phyN, GFP_KERNEL);
+	if (!rtk_phy->reg_addr)
+		return -ENOMEM;
+
+	rtk_phy->phy_data = devm_kzalloc(dev,
+		    sizeof(struct phy_data) * phyN, GFP_KERNEL);
+	if (!rtk_phy->phy_data)
+		return -ENOMEM;
+
+	for (sub_node = of_get_next_child(node, NULL); sub_node != NULL;
+		    sub_node = of_get_next_child(node, sub_node)) {
+		ret = get_phy_parameter(rtk_phy, sub_node);
+		if (ret) {
+			dev_err(dev, "%s: get_phy_parameter fail ret=%d\n",
+				    __func__, ret);
+			goto err;
+		}
+	}
+
+	platform_set_drvdata(pdev, rtk_phy);
+
+	generic_phy = devm_phy_create(rtk_phy->dev, NULL, &ops);
+	if (IS_ERR(generic_phy))
+		return PTR_ERR(generic_phy);
+
+	phy_set_drvdata(generic_phy, rtk_phy);
+
+	phy_provider = devm_of_phy_provider_register(rtk_phy->dev,
+				    of_phy_simple_xlate);
+	if (IS_ERR(phy_provider))

drivers/phy/realtek/phy-rtk-usb3.c line 1035

Quoted 10 lines
drivers/phy/realtek/phy-rtk-usb3.c new file +10 -0
+		return PTR_ERR(phy_provider);
+
+	ret = usb_add_phy_dev(&rtk_phy->phy);
+	if (ret)
+		goto err;
+
+	create_debug_files(rtk_phy);
+
+err:
+	dev_dbg(&pdev->dev, "Probe RTK USB 3.0 PHY (ret=%d)\n", ret);

Please drop all simple debug success messages. Linux has already infrastructure for this.

Best regards,
Krzysztof

Signature · 3 lines
linux-phy mailing list
[email protected]
https://lists.infradead.org/mailman/listinfo/linux-phy
#13 lore raw

RE: [PATCH v3 3/5] phy: realtek: usb: Add driver for the Realtek SoC USB 3.0 PHY

Hi Krzysztof,

Quoted 8 lines
Quoted 8 lines
drivers/phy/realtek/phy-rtk-usb3.c new file +8 -0
+static void do_rtk_usb3_phy_toggle(struct rtk_usb_phy *rtk_phy, int i,
+         bool isConnect)
+{
+     struct reg_addr *regAddr;
+     struct phy_data *phy_data;
+     struct phy_parameter *phy_parameter;
+     size_t index;
+
Quoted 8 lines
Quoted 6 lines

+     regAddr = &((struct reg_addr *)rtk_phy->reg_addr)[i]; +     phy_data = &((struct phy_data *)rtk_phy->phy_data)[i]; +
+     if (!phy_data) {
+             dev_err(rtk_phy->dev, "%s phy_data is NULL!\n",
+ __func__);

???

Sorry, this check is redundant.

Quoted 32 lines
Quoted 14 lines

+             return;
+     }

drivers/phy/realtek/phy-rtk-usb3.c new file +11 -0
+
+     if (!phy_data->do_toggle)
+             return;
+
+     phy_parameter = phy_data->parameter;
+
+     index = PHY_ADDR_MAP_ARRAY_INDEX(PHY_ADDR_0x09);
+
+     if (index < phy_data->size) {
+             u8 addr = (phy_parameter + index)->addr;
+             u16 data = (phy_parameter + index)->data;

drivers/phy/realtek/phy-rtk-usb3.c

Quoted 10 lines
drivers/phy/realtek/phy-rtk-usb3.c new file +10 -0
+
+             if (addr == 0xFF) {
+                     addr = ARRAY_INDEX_MAP_PHY_ADDR(index);
+                     data = rtk_usb_phy_read(regAddr, addr);
+                     (phy_parameter + index)->addr = addr;
+                     (phy_parameter + index)->data = data;
+             }
+             mdelay(1);
+             dev_info(rtk_phy->dev,
+                         "%s ########## to toggle PHY addr 0x09

BIT(9)\n",

Quoted 7 lines

+                         __func__);
+             rtk_usb_phy_write(regAddr, addr, data&(~BIT(9))); +             mdelay(1);
+             rtk_usb_phy_write(regAddr, addr, data);
+     }
+     dev_info(rtk_phy->dev, "%s ########## PHY addr 0x1f = 0x%04x\n", +                 __func__, rtk_usb_phy_read(regAddr,

Quoted 5 lines

PHY_ADDR_0x1F));

Please drop all simple debug success messages. Linux has already infrastructure for this.

Okay. I will change the print dev_info to dev_dbg about debug message.

Quoted 15 lines

...

drivers/phy/realtek/phy-rtk-usb3.c line 318

Quoted 11 lines

+     return 0;

drivers/phy/realtek/phy-rtk-usb3.c new file +10 -0
+}
+
+static int rtk_usb_phy_init(struct phy *phy) {
+     struct rtk_usb_phy *rtk_phy = phy_get_drvdata(phy);
+     int ret = 0;
+     int i;
+     unsigned long phy_init_time = jiffies;
+
+     if (!rtk_phy) {
+             pr_err("%s rtk_phy is NULL!\n", __func__);

What? How is this possible?

It should be not necessary. I will remove it.

Quoted 4 lines
Quoted 4 lines

+             return -ENODEV;
+     }
+
+     dev_dbg(rtk_phy->dev, "Init RTK USB 3.0 PHY\n");

Quoted 8 lines
Quoted 5 lines

+     for (i = 0; i < rtk_phy->phyN; i++)
+             ret = do_rtk_usb_phy_init(rtk_phy, i);
+
+     dev_info(rtk_phy->dev, "Initialized RTK USB 3.0 PHY (take %dms)\n", +                 jiffies_to_msecs(jiffies - phy_init_time));

Please drop all simple debug success messages. Linux has already infrastructure for this.

Ok, Thanks.

Quoted 7 lines
Quoted 7 lines

+     return ret;

drivers/phy/realtek/phy-rtk-usb3.c new file +6 -0
+}
+
+static int rtk_usb_phy_exit(struct phy *phy) {
+     struct rtk_usb_phy *rtk_phy = phy_get_drvdata(phy);
+
+     if (!rtk_phy) {
Quoted 8 lines
Quoted 5 lines

+             pr_err("%s rtk_phy is NULL!\n", __func__); +             return -ENODEV;
+     }
+
+     dev_dbg(rtk_phy->dev, "Exit RTK USB 3.0 PHY\n");

Please drop all simple debug success messages. Linux has already infrastructure for this.

Can I keep log for dev_dbg?

Quoted 15 lines

drivers/phy/realtek/phy-rtk-usb3.c line 360

Quoted 10 lines
drivers/phy/realtek/phy-rtk-usb3.c new file +10 -0
+static void rtk_usb_phy_toggle(struct usb_phy *usb3_phy, bool
+isConnect, int port) {
+     int index = port;
+     struct rtk_usb_phy *rtk_phy = NULL;
+
+     if (usb3_phy != NULL && usb3_phy->dev != NULL)
+             rtk_phy = dev_get_drvdata(usb3_phy->dev);
+
+     if (rtk_phy == NULL) {
+             pr_err("%s ERROR! NO this device\n", __func__);

Your error messages are not helping. No need to shout, no need to handle some non-existing cases. If this is real case, you have broken driver. I actually suspect that.

Quoted 1 line

How can you interface with a driver where there is no device?

OK, I know this is not good programming practice, I will improve this question.

Quoted 8 lines
Quoted 8 lines

+             return;
+     }
+
+     if (index > rtk_phy->phyN) {
+             pr_err("%s %d ERROR! port=%d > phyN=%d\n", +                         __func__, __LINE__, index, rtk_phy->phyN); +             return;
+     }

Quoted 8 lines

drivers/phy/realtek/phy-rtk-usb3.c line 376

Quoted 6 lines
drivers/phy/realtek/phy-rtk-usb3.c new file +6 -0
+
+     do_rtk_usb3_phy_toggle(rtk_phy, index, isConnect); }
+
+static int rtk_usb_phy_notify_port_status(struct usb_phy *x, int port,
+         u16 portstatus, u16 portchange) {
+     bool isConnect = false;

This is not C++. Don't use camelcase. See Coding style document.

I will revised for this style.

Quoted 35 lines
Quoted 6 lines
drivers/phy/realtek/phy-rtk-usb3.c new file +6 -0
+
+     pr_debug("%s port=%d portstatus=0x%x portchange=0x%x\n",
+                 __func__, port, (int)portstatus, (int)portchange);
+     if (portstatus & USB_PORT_STAT_CONNECTION)
+             isConnect = true;
+

...

Quoted 8 lines
drivers/phy/realtek/phy-rtk-usb3.c new file +8 -0
+
+static int rtk_usb3_set_parameter_show(struct seq_file *s, void
+*unused) {
+     struct rtk_usb_phy *rtk_phy = s->private;
+     const struct file *file = s->file;
+     const char *file_name = file_dentry(file)->d_iname;
+     struct dentry *p_dentry = file_dentry(file)->d_parent;
+     const char *phy_dir_name = p_dentry->d_iname;

drivers/phy/realtek/phy-rtk-usb3.c

Quoted 10 lines
drivers/phy/realtek/phy-rtk-usb3.c new file +10 -0
+     int ret, index;
+     struct phy_data *phy_data = NULL;
+
+     for (index = 0; index < rtk_phy->phyN; index++) {
+             size_t sz = 30;
+             char name[30] = {0};
+
+             snprintf(name, sz, "phy%d", index);
+             if (strncmp(name, phy_dir_name, strlen(name)) == 0) {
+                     phy_data = &((struct phy_data

*)rtk_phy->phy_data)[index];

Quoted 7 lines

+                     break;
+             }
+     }
+     if (!phy_data) {
+             dev_err(rtk_phy->dev,
+                                 "%s: No phy_data for %s/%s\n", +                                 __func__, phy_dir_name,

Quoted 3 lines

file_name);

Mess wrapping/indentation. Actually everywhere in the file...

I will improve this.

Quoted 30 lines
Quoted 19 lines
drivers/phy/realtek/phy-rtk-usb3.c new file +19 -0
+static int rtk_usb3_set_parameter_open(struct inode *inode, struct
+file *file) {
+     return single_open(file, rtk_usb3_set_parameter_show,
+inode->i_private); }
+
+static ssize_t rtk_usb3_set_parameter_write(struct file *file,
+             const char __user *ubuf, size_t count, loff_t *ppos) {
+     const char *file_name = file_dentry(file)->d_iname;
+     struct dentry *p_dentry = file_dentry(file)->d_parent;
+     const char *phy_dir_name = p_dentry->d_iname;
+     struct seq_file         *s = file->private_data;
+     struct rtk_usb_phy              *rtk_phy = s->private;
+     struct reg_addr *regAddr = NULL;
+     struct phy_data *phy_data = NULL;
+     int ret = 0;
+     char buffer[40] = {0};
+     int index;
+
+     if (copy_from_user(&buffer, ubuf,

drivers/phy/realtek/phy-rtk-usb3.c

Quoted 10 lines
drivers/phy/realtek/phy-rtk-usb3.c new file +10 -0
+                 min_t(size_t, sizeof(buffer) - 1, count)))
+             return -EFAULT;
+
+     for (index = 0; index < rtk_phy->phyN; index++) {
+             size_t sz = 30;
+             char name[30] = {0};
+
+             snprintf(name, sz, "phy%d", index);
+             if (strncmp(name, phy_dir_name, strlen(name)) == 0) {
+                     regAddr = &((struct reg_addr

*)rtk_phy->reg_addr)[index];

Quoted 6 lines
Quoted 1 line

+                     phy_data = &((struct phy_data

*)rtk_phy->phy_data)[index];

Quoted 1 line

+                     break;

Where is the ABI documentation for user interface?

Do debugfs nodes need ABI documentation? Is there a reference?

Quoted 13 lines
Quoted 13 lines
drivers/phy/realtek/phy-rtk-usb3.c new file +12 -0
+
+static inline void create_debug_files(struct rtk_usb_phy *rtk_phy) {
+     struct dentry *phy_debug_root = NULL;
+     struct dentry *set_parameter_dir = NULL;
+
+     phy_debug_root = create_phy_debug_root();
+
+     if (!phy_debug_root) {
+             dev_err(rtk_phy->dev, "%s Error phy_debug_root is NULL",
+                         __func__);
+             return;
+     }
Quoted 8 lines
Quoted 5 lines

+     rtk_phy->debug_dir = debugfs_create_dir(dev_name(rtk_phy->dev), +                 phy_debug_root);
+     if (!rtk_phy->debug_dir) {
+             dev_err(rtk_phy->dev, "%s Error debug_dir is NULL",
+ __func__);

Are you sure you run checkpatch on this? Error messages on debugfs are almost always incorrect.

Yes, I have run checkpatch for patches. Why the message is incorrect?

Quoted 9 lines
Quoted 9 lines
drivers/phy/realtek/phy-rtk-usb3.c new file +9 -0
+static int get_phy_parameter(struct rtk_usb_phy *rtk_phy,
+         struct device_node *sub_node) {
+     struct device *dev = rtk_phy->dev;
+     struct reg_addr *addr;
+     struct phy_data *phy_data;
+     int ret = 0;
+     int index;
+
+     if (of_property_read_u32(sub_node, "reg", &index)) {
Quoted 8 lines
Quoted 5 lines

+             dev_err(dev, "sub_node without reg\n"); +             return -EINVAL;
+     }
+
+     dev_dbg(dev, "sub_node index=%d\n", index);

Please drop all simple debug success messages. Linux has already infrastructure for this.

Can I keep log for dev_dbg?

Quoted 19 lines

...

Quoted 17 lines
drivers/phy/realtek/phy-rtk-usb3.c new file +17 -0
+
+static int rtk_usb3phy_probe(struct platform_device *pdev) {
+     struct rtk_usb_phy *rtk_phy;
+     struct device *dev = &pdev->dev;
+     struct device_node *node;
+     struct device_node *sub_node;
+     struct phy *generic_phy;
+     struct phy_provider *phy_provider;
+     int ret, phyN;
+
+     rtk_phy = devm_kzalloc(dev, sizeof(*rtk_phy), GFP_KERNEL);
+     if (!rtk_phy)
+             return -ENOMEM;
+
+     rtk_phy->dev                    = &pdev->dev;
+     rtk_phy->phy.dev                = rtk_phy->dev;
+     rtk_phy->phy.label              = "rtk-usb3phy";
Quoted 8 lines
Quoted 6 lines

+     rtk_phy->phy.notify_port_status =
+ rtk_usb_phy_notify_port_status;
+
+     if (!dev->of_node) {
+             dev_err(dev, "%s %d No device node\n", __func__,
+ __LINE__);

How is it even possible? If you do not have device node here, how did it probe?

You are right. The of_node is always exist. I will remove it.

Quoted 13 lines

drivers/phy/realtek/phy-rtk-usb3.c line 993

Quoted 10 lines

+             ret = -ENODEV;
+             goto err;
+     }

drivers/phy/realtek/phy-rtk-usb3.c new file +6 -0
+
+     node = dev->of_node;
+
+     phyN = of_get_child_count(node);
+     rtk_phy->phyN = phyN;
+     dev_dbg(dev, "%s phyN=%d\n", __func__, rtk_phy->phyN);

Please drop all simple debug success messages. Linux has already infrastructure for this.

Okay. I will remove debug message.

Thanks,
Stanley

#14 lore raw

Re: [PATCH v3 3/5] phy: realtek: usb: Add driver for the Realtek SoC USB 3.0 PHY

Quoted 52 lines · Stanley Chang[昌育德]

Hi Krzysztof,

Quoted 8 lines
Quoted 8 lines
drivers/phy/realtek/phy-rtk-usb3.c new file +8 -0
+static void do_rtk_usb3_phy_toggle(struct rtk_usb_phy *rtk_phy, int i,
+         bool isConnect)
+{
+     struct reg_addr *regAddr;
+     struct phy_data *phy_data;
+     struct phy_parameter *phy_parameter;
+     size_t index;
+
Quoted 8 lines
Quoted 6 lines

+     regAddr = &((struct reg_addr *)rtk_phy->reg_addr)[i]; +     phy_data = &((struct phy_data *)rtk_phy->phy_data)[i]; +
+     if (!phy_data) {
+             dev_err(rtk_phy->dev, "%s phy_data is NULL!\n",
+ __func__);

???

Sorry, this check is redundant.

Quoted 32 lines
Quoted 14 lines

+             return;
+     }

drivers/phy/realtek/phy-rtk-usb3.c new file +11 -0
+
+     if (!phy_data->do_toggle)
+             return;
+
+     phy_parameter = phy_data->parameter;
+
+     index = PHY_ADDR_MAP_ARRAY_INDEX(PHY_ADDR_0x09);
+
+     if (index < phy_data->size) {
+             u8 addr = (phy_parameter + index)->addr;
+             u16 data = (phy_parameter + index)->data;

drivers/phy/realtek/phy-rtk-usb3.c

Quoted 10 lines
drivers/phy/realtek/phy-rtk-usb3.c new file +10 -0
+
+             if (addr == 0xFF) {
+                     addr = ARRAY_INDEX_MAP_PHY_ADDR(index);
+                     data = rtk_usb_phy_read(regAddr, addr);
+                     (phy_parameter + index)->addr = addr;
+                     (phy_parameter + index)->data = data;
+             }
+             mdelay(1);
+             dev_info(rtk_phy->dev,
+                         "%s ########## to toggle PHY addr 0x09

BIT(9)\n",

Quoted 7 lines

+                         __func__);
+             rtk_usb_phy_write(regAddr, addr, data&(~BIT(9))); +             mdelay(1);
+             rtk_usb_phy_write(regAddr, addr, data);
+     }
+     dev_info(rtk_phy->dev, "%s ########## PHY addr 0x1f = 0x%04x\n", +                 __func__, rtk_usb_phy_read(regAddr,

Quoted 6 lines
Quoted 5 lines

PHY_ADDR_0x1F));

Please drop all simple debug success messages. Linux has already infrastructure for this.

Okay. I will change the print dev_info to dev_dbg about debug message.

No, drop them. This piece of code had already 2 printks for register contents! Your driver is overloaded with printks and they are mostly useless for the user.

Quoted 49 lines
Quoted 16 lines

...

drivers/phy/realtek/phy-rtk-usb3.c line 318

Quoted 11 lines

+     return 0;

drivers/phy/realtek/phy-rtk-usb3.c new file +10 -0
+}
+
+static int rtk_usb_phy_init(struct phy *phy) {
+     struct rtk_usb_phy *rtk_phy = phy_get_drvdata(phy);
+     int ret = 0;
+     int i;
+     unsigned long phy_init_time = jiffies;
+
+     if (!rtk_phy) {
+             pr_err("%s rtk_phy is NULL!\n", __func__);

What? How is this possible?

It should be not necessary. I will remove it.

Quoted 4 lines
Quoted 4 lines

+             return -ENODEV;
+     }
+
+     dev_dbg(rtk_phy->dev, "Init RTK USB 3.0 PHY\n");

Quoted 8 lines
Quoted 5 lines

+     for (i = 0; i < rtk_phy->phyN; i++)
+             ret = do_rtk_usb_phy_init(rtk_phy, i);
+
+     dev_info(rtk_phy->dev, "Initialized RTK USB 3.0 PHY (take %dms)\n", +                 jiffies_to_msecs(jiffies - phy_init_time));

Please drop all simple debug success messages. Linux has already infrastructure for this.

Ok, Thanks.

Quoted 7 lines
Quoted 7 lines

+     return ret;

drivers/phy/realtek/phy-rtk-usb3.c new file +6 -0
+}
+
+static int rtk_usb_phy_exit(struct phy *phy) {
+     struct rtk_usb_phy *rtk_phy = phy_get_drvdata(phy);
+
+     if (!rtk_phy) {
Quoted 8 lines
Quoted 5 lines

+             pr_err("%s rtk_phy is NULL!\n", __func__); +             return -ENODEV;
+     }
+
+     dev_dbg(rtk_phy->dev, "Exit RTK USB 3.0 PHY\n");

Please drop all simple debug success messages. Linux has already infrastructure for this.

Quoted 1 line

Can I keep log for dev_dbg?

Of course not. This was dev_dbg and I commented on this. This is not a good debug, we do not print anything on function entrance and exit. ftrace() is for this.

Quoted 141 lines
Quoted 16 lines

drivers/phy/realtek/phy-rtk-usb3.c line 360

Quoted 11 lines
drivers/phy/realtek/phy-rtk-usb3.c new file +10 -0
+static void rtk_usb_phy_toggle(struct usb_phy *usb3_phy, bool
+isConnect, int port) {
+     int index = port;
+     struct rtk_usb_phy *rtk_phy = NULL;
+
+     if (usb3_phy != NULL && usb3_phy->dev != NULL)
+             rtk_phy = dev_get_drvdata(usb3_phy->dev);
+
+     if (rtk_phy == NULL) {
+             pr_err("%s ERROR! NO this device\n", __func__);

Your error messages are not helping. No need to shout, no need to handle some non-existing cases. If this is real case, you have broken driver. I actually suspect that.

Quoted 1 line

How can you interface with a driver where there is no device?

OK, I know this is not good programming practice, I will improve this question.

Quoted 8 lines
Quoted 8 lines

+             return;
+     }
+
+     if (index > rtk_phy->phyN) {
+             pr_err("%s %d ERROR! port=%d > phyN=%d\n", +                         __func__, __LINE__, index, rtk_phy->phyN); +             return;
+     }

Quoted 8 lines

drivers/phy/realtek/phy-rtk-usb3.c line 376

Quoted 6 lines
drivers/phy/realtek/phy-rtk-usb3.c new file +6 -0
+
+     do_rtk_usb3_phy_toggle(rtk_phy, index, isConnect); }
+
+static int rtk_usb_phy_notify_port_status(struct usb_phy *x, int port,
+         u16 portstatus, u16 portchange) {
+     bool isConnect = false;

This is not C++. Don't use camelcase. See Coding style document.

I will revised for this style.

Quoted 35 lines
Quoted 6 lines
drivers/phy/realtek/phy-rtk-usb3.c new file +6 -0
+
+     pr_debug("%s port=%d portstatus=0x%x portchange=0x%x\n",
+                 __func__, port, (int)portstatus, (int)portchange);
+     if (portstatus & USB_PORT_STAT_CONNECTION)
+             isConnect = true;
+

...

Quoted 8 lines
drivers/phy/realtek/phy-rtk-usb3.c new file +8 -0
+
+static int rtk_usb3_set_parameter_show(struct seq_file *s, void
+*unused) {
+     struct rtk_usb_phy *rtk_phy = s->private;
+     const struct file *file = s->file;
+     const char *file_name = file_dentry(file)->d_iname;
+     struct dentry *p_dentry = file_dentry(file)->d_parent;
+     const char *phy_dir_name = p_dentry->d_iname;

drivers/phy/realtek/phy-rtk-usb3.c

Quoted 10 lines
drivers/phy/realtek/phy-rtk-usb3.c new file +10 -0
+     int ret, index;
+     struct phy_data *phy_data = NULL;
+
+     for (index = 0; index < rtk_phy->phyN; index++) {
+             size_t sz = 30;
+             char name[30] = {0};
+
+             snprintf(name, sz, "phy%d", index);
+             if (strncmp(name, phy_dir_name, strlen(name)) == 0) {
+                     phy_data = &((struct phy_data

*)rtk_phy->phy_data)[index];

Quoted 7 lines

+                     break;
+             }
+     }
+     if (!phy_data) {
+             dev_err(rtk_phy->dev,
+                                 "%s: No phy_data for %s/%s\n", +                                 __func__, phy_dir_name,

Quoted 3 lines

file_name);

Mess wrapping/indentation. Actually everywhere in the file...

I will improve this.

Quoted 30 lines
Quoted 19 lines
drivers/phy/realtek/phy-rtk-usb3.c new file +19 -0
+static int rtk_usb3_set_parameter_open(struct inode *inode, struct
+file *file) {
+     return single_open(file, rtk_usb3_set_parameter_show,
+inode->i_private); }
+
+static ssize_t rtk_usb3_set_parameter_write(struct file *file,
+             const char __user *ubuf, size_t count, loff_t *ppos) {
+     const char *file_name = file_dentry(file)->d_iname;
+     struct dentry *p_dentry = file_dentry(file)->d_parent;
+     const char *phy_dir_name = p_dentry->d_iname;
+     struct seq_file         *s = file->private_data;
+     struct rtk_usb_phy              *rtk_phy = s->private;
+     struct reg_addr *regAddr = NULL;
+     struct phy_data *phy_data = NULL;
+     int ret = 0;
+     char buffer[40] = {0};
+     int index;
+
+     if (copy_from_user(&buffer, ubuf,

drivers/phy/realtek/phy-rtk-usb3.c

Quoted 10 lines
drivers/phy/realtek/phy-rtk-usb3.c new file +10 -0
+                 min_t(size_t, sizeof(buffer) - 1, count)))
+             return -EFAULT;
+
+     for (index = 0; index < rtk_phy->phyN; index++) {
+             size_t sz = 30;
+             char name[30] = {0};
+
+             snprintf(name, sz, "phy%d", index);
+             if (strncmp(name, phy_dir_name, strlen(name)) == 0) {
+                     regAddr = &((struct reg_addr

*)rtk_phy->reg_addr)[index];

Quoted 6 lines
Quoted 1 line

+                     phy_data = &((struct phy_data

*)rtk_phy->phy_data)[index];

Quoted 1 line

+                     break;

Where is the ABI documentation for user interface?

Do debugfs nodes need ABI documentation?
Is there a reference?

Quoted 13 lines
Quoted 13 lines
drivers/phy/realtek/phy-rtk-usb3.c new file +12 -0
+
+static inline void create_debug_files(struct rtk_usb_phy *rtk_phy) {
+     struct dentry *phy_debug_root = NULL;
+     struct dentry *set_parameter_dir = NULL;
+
+     phy_debug_root = create_phy_debug_root();
+
+     if (!phy_debug_root) {
+             dev_err(rtk_phy->dev, "%s Error phy_debug_root is NULL",
+                         __func__);
+             return;
+     }
Quoted 8 lines
Quoted 5 lines

+     rtk_phy->debug_dir = debugfs_create_dir(dev_name(rtk_phy->dev), +                 phy_debug_root);
+     if (!rtk_phy->debug_dir) {
+             dev_err(rtk_phy->dev, "%s Error debug_dir is NULL",
+ __func__);

Are you sure you run checkpatch on this? Error messages on debugfs are almost always incorrect.

Quoted 2 lines

Yes, I have run checkpatch for patches.
Why the message is incorrect?

Because debugfs failures should not cause any error prints. It's debug, not important.

Do you see anywhere error messages?

Entire debugfs handling code should be silent and even skip all error checking, as most API is ready for handling previous errors, I think.

Quoted 19 lines
Quoted 10 lines
Quoted 10 lines
drivers/phy/realtek/phy-rtk-usb3.c new file +9 -0
+static int get_phy_parameter(struct rtk_usb_phy *rtk_phy,
+         struct device_node *sub_node) {
+     struct device *dev = rtk_phy->dev;
+     struct reg_addr *addr;
+     struct phy_data *phy_data;
+     int ret = 0;
+     int index;
+
+     if (of_property_read_u32(sub_node, "reg", &index)) {
Quoted 8 lines
Quoted 5 lines

+             dev_err(dev, "sub_node without reg\n"); +             return -EINVAL;
+     }
+
+     dev_dbg(dev, "sub_node index=%d\n", index);

Please drop all simple debug success messages. Linux has already infrastructure for this.

Quoted 1 line

Can I keep log for dev_dbg?

No, this was dev_dbg and I commented on this to remove it. Keep only useful debug messages, not hundreds of them in every place.

Best regards,
Krzysztof

Signature · 3 lines
linux-phy mailing list
[email protected]
https://lists.infradead.org/mailman/listinfo/linux-phy
#15 lore raw

RE: [PATCH v3 3/5] phy: realtek: usb: Add driver for the Realtek SoC USB 3.0 PHY

Quoted 7 lines
Quoted 4 lines
Quoted 3 lines

Please drop all simple debug success messages. Linux has already infrastructure for this.

Okay. I will change the print dev_info to dev_dbg about debug message.

No, drop them. This piece of code had already 2 printks for register contents! Your driver is overloaded with printks and they are mostly useless for the user.

I will drop them to simplify the code.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

Please drop all simple debug success messages. Linux has already infrastructure for this.

Can I keep log for dev_dbg?

Of course not. This was dev_dbg and I commented on this. This is not a good debug, we do not print anything on function entrance and exit. ftrace() is for this.

Well, for debugging purposes, I'm going to have to dig into ftrace. This is a great tip.

Quoted 7 lines
Quoted 6 lines
Quoted 3 lines

Are you sure you run checkpatch on this? Error messages on debugfs are almost always incorrect.

Yes, I have run checkpatch for patches.
Why the message is incorrect?

Quoted 7 lines

Because debugfs failures should not cause any error prints. It's debug, not important.

Do you see anywhere error messages?

Entire debugfs handling code should be silent and even skip all error checking, as most API is ready for handling previous errors, I think.

Thanks, I understand now.

Thanks,
Stanley

#16 lore raw

Re: [PATCH v3 3/5] phy: realtek: usb: Add driver for the Realtek SoC USB 3.0 PHY

In reply to Stanley Chang
kernel test robot noticed the following build errors:

Hi Stanley,

kernel test robot noticed the following build errors:

[auto build test ERROR on usb/usb-testing]
[also build test ERROR on usb/usb-next usb/usb-linus robh/for-next linus/master v6.4-rc5 next-20230607] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Stanley-Chang/phy-realtek-usb-Add-driver-for-the-Realtek-SoC-USB-2-0-PHY/20230607-142704
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing
patch link:    https://lore.kernel.org/r/20230607062500.24669-3-stanley_chang%40realtek.com
patch subject: [PATCH v3 3/5] phy: realtek: usb: Add driver for the Realtek SoC USB 3.0 PHY
config: s390-allmodconfig (https://download.01.org/0day-ci/archive/20230608/[email protected]/config)
compiler: s390-linux-gcc (GCC) 12.3.0

reproduce (this is a W=1 build):
mkdir -p ~/bin
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
git remote add usb https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git
git fetch usb usb-testing
git checkout usb/usb-testing
b4 shazam https://lore.kernel.org/r/[email protected]
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.3.0 ~/bin/make.cross W=1 O=build_dir ARCH=s390 olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.3.0 ~/bin/make.cross W=1 O=build_dir ARCH=s390 SHELL=/bin/bash

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>, old ones prefixed by <<):

ERROR: modpost: "usb_remove_phy" [drivers/phy/realtek/phy-rtk-usb2.ko] undefined!
ERROR: modpost: "usb_debug_root" [drivers/phy/realtek/phy-rtk-usb2.ko] undefined!
ERROR: modpost: "of_iomap" [drivers/phy/realtek/phy-rtk-usb2.ko] undefined!
ERROR: modpost: "usb_add_phy_dev" [drivers/phy/realtek/phy-rtk-usb2.ko] undefined!

>> ERROR: modpost: "usb_remove_phy" [drivers/phy/realtek/phy-rtk-usb3.ko] undefined!
>> ERROR: modpost: "usb_debug_root" [drivers/phy/realtek/phy-rtk-usb3.ko] undefined!
>> ERROR: modpost: "of_iomap" [drivers/phy/realtek/phy-rtk-usb3.ko] undefined!
>> ERROR: modpost: "usb_add_phy_dev" [drivers/phy/realtek/phy-rtk-usb3.ko] undefined!

ERROR: modpost: "devm_ioremap_resource" [drivers/dma/qcom/hdma.ko] undefined!
ERROR: modpost: "devm_platform_ioremap_resource" [drivers/dma/fsl-edma.ko] undefined!
WARNING: modpost: suppressed 26 unresolved symbol warnings because there were too many)

Kconfig warnings: (for reference only)
WARNING: unmet direct dependencies detected for USB_PHY Depends on [n]: USB_SUPPORT [=n]
Selected by [m]:
- PHY_RTK_RTD_USB2PHY [=m]
- PHY_RTK_RTD_USB3PHY [=m]

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#17 lore raw

RE: [PATCH v3 3/5] phy: realtek: usb: Add driver for the Realtek SoC USB 3.0 PHY

Quoted 24 lines

All errors (new ones prefixed by >>, old ones prefixed by <<):

ERROR: modpost: "usb_remove_phy" [drivers/phy/realtek/phy-rtk-usb2.ko] undefined!
ERROR: modpost: "usb_debug_root" [drivers/phy/realtek/phy-rtk-usb2.ko] undefined!
ERROR: modpost: "of_iomap" [drivers/phy/realtek/phy-rtk-usb2.ko] undefined!
ERROR: modpost: "usb_add_phy_dev" [drivers/phy/realtek/phy-rtk-usb2.ko] undefined!

Quoted 1 line
Quoted 1 line

ERROR: modpost: "usb_remove_phy" [drivers/phy/realtek/phy-rtk-usb3.ko]

undefined!

Quoted 1 line
Quoted 1 line

ERROR: modpost: "usb_debug_root" [drivers/phy/realtek/phy-rtk-usb3.ko]

undefined!

Quoted 1 line
Quoted 1 line

ERROR: modpost: "of_iomap" [drivers/phy/realtek/phy-rtk-usb3.ko]

undefined!

Quoted 1 line
Quoted 1 line

ERROR: modpost: "usb_add_phy_dev" [drivers/phy/realtek/phy-rtk-usb3.ko]

undefined!
ERROR: modpost: "devm_ioremap_resource" [drivers/dma/qcom/hdma.ko] undefined!
ERROR: modpost: "devm_platform_ioremap_resource" [drivers/dma/fsl-edma.ko] undefined!
WARNING: modpost: suppressed 26 unresolved symbol warnings because there were too many)

Quoted 7 lines

Kconfig warnings: (for reference only)
WARNING: unmet direct dependencies detected for USB_PHY Depends on [n]: USB_SUPPORT [=n]
Selected by [m]:
- PHY_RTK_RTD_USB2PHY [=m]
- PHY_RTK_RTD_USB3PHY [=m]

I will add USB_SUUPRT dependency to Kconfig.

drivers/phy/realtek/Kconfig +2 -0
index 28ee3d9be568..a5a5a71edc9c 100644
@@ -4,6 +4,7 @@
 #
 config PHY_RTK_RTD_USB2PHY
        tristate "Realtek RTD USB2 PHY Transceiver Driver"
+       depends on USB_SUPPORT
        select GENERIC_PHY
        select USB_PHY
        help
@@ -14,6 +15,7 @@ config PHY_RTK_RTD_USB2PHY
 
 config PHY_RTK_RTD_USB3PHY
        tristate "Realtek RTD USB3 PHY Transceiver Driver"
+       depends on USB_SUPPORT
        select GENERIC_PHY
        select USB_PHY
        help
#18 lore raw

PATCH v3 4/5 dt-bindings: phy: realtek: Add the doc about the Realtek SoC USB 2.0 PHY

In reply to Stanley Chang

Add the documentation explain the property about Realtek USB PHY driver.

Realtek DHC (digital home center) RTD SoCs support DWC3 XHCI USB controller. Added the driver to drive the USB 2.0 PHY transceivers.

---
v2 to v3 change:
1. Broken down into two patches, one for each of USB 2 & 3.
2. Add more description about Realtek RTD SoCs architecture.
3. Removed parameter v1 support for simplification.
4. Revised the compatible name for fallback compatible.
5. Remove some properties that can be set in the driver.
v1 to v2 change:
Add phy-cells for generic phy driver

---
 .../bindings/phy/realtek,usb2phy.yaml         | 213 ++++++++++++++++++
 1 file changed, 213 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml new file +213 -0
new file mode 100644
index 000000000000..69911e20a561
@@ -0,0 +1,213 @@
+# 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 USB 2.0 PHY
+
+maintainers:
+  - Stanley Chang <[email protected]>
+
+description:
+  Realtek USB 2.0 PHY support the digital home center (DHC) RTD series SoCs.
+  The USB 2.0 PHY driver is designed to support the XHCI controller. The SoCs
+  support multiple XHCI controllers. One PHY device node maps to one XHCI
+  controller.
+
+  RTD1295/RTD1619 SoCs USB
+  The USB architecture includes three XHCI controllers.
+  Each XHCI maps to one USB 2.0 PHY and map one USB 3.0 PHY on some
+  controllers.
+  XHCI controller#0 -- usb2phy -- phy#0
+                    |- usb3phy -- phy#0
+  XHCI controller#1 -- usb2phy -- phy#0
+  XHCI controller#2 -- usb2phy -- phy#0
+                    |- usb3phy -- phy#0
+
+  RTD1395 SoCs USB
+  The USB architecture includes two XHCI controllers.
+  The controller#0 has one USB 2.0 PHY. The controller#1 includes two USB 2.0
+  PHY.
+  XHCI controller#0 -- usb2phy -- phy#0
+  XHCI controller#1 -- usb2phy -- phy#0
+                               |- phy#1
+
+  RTD1319/RTD1619b SoCs USB
+  The USB architecture includes three XHCI controllers.
+  Each XHCI maps to one USB 2.0 PHY and map one USB 3.0 PHY on controllers#2.
+  XHCI controller#0 -- usb2phy -- phy#0
+  XHCI controller#1 -- usb2phy -- phy#0
+  XHCI controller#2 -- usb2phy -- phy#0
+                    |- usb3phy -- phy#0
+
+  RTD1319d SoCs USB
+  The USB architecture includes three XHCI controllers.
+  Each xhci maps to one USB 2.0 PHY and map one USB 3.0 PHY on controllers#0.
+  XHCI controller#0 -- usb2phy -- phy#0
+                    |- usb3phy -- phy#0
+  XHCI controller#1 -- usb2phy -- phy#0
+  XHCI controller#2 -- usb2phy -- phy#0
+
+  RTD1312c/RTD1315e SoCs USB
+  The USB architecture includes three XHCI controllers.
+  Each XHCI maps to one USB 2.0 PHY.
+  XHCI controller#0 -- usb2phy -- phy#0
+  XHCI controller#1 -- usb2phy -- phy#0
+  XHCI controller#2 -- usb2phy -- phy#0
+
+properties:
+  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
+
+  reg:
+    items:
+      - description: PHY data registers
+      - description: PHY control registers
+
+  "#address-cells":
+    const: 1
+
+  "#size-cells":
+    const: 0
+
+  "#phy-cells":
+    const: 0
+
+  realtek,usb-ctrl:
+    description: The phandle of syscon used to control USB PHY power domain.
+    $ref: /schemas/types.yaml#/definitions/phandle
+
+patternProperties:
+  "^phy@[0-3]+$":
+    type: object
+    description:
+      Each sub-node is a PHY device for one XHCI controller.
+      For most Relatek SoCs, one XHCI controller only support one the USB 2.0
+      phy. For RTD1395 SoC, the one XHCI controller has two USB 2.0 PHYs.
+    properties:
+      realtek,page0-param:
+        description: PHY parameter at page 0. The data are the pair of the
+          offset and value.
+        $ref: /schemas/types.yaml#/definitions/uint32-array
+
+      realtek,page1-param:
+        description: PHY parameter at page 1. The data are the pair of the
+          offset and value.
+        $ref: /schemas/types.yaml#/definitions/uint32-array
+
+      realtek,page2-param:
+        description: PHY parameter at page 2. The data are the pair of the
+          offset and value. If the PHY support the page 2 parameter.
+        $ref: /schemas/types.yaml#/definitions/uint32-array
+
+      realtek,support-page2-param:
+        description: Set this flag if PHY support page 2 parameter.
+        type: boolean
+
+      realtek,do-toggle:
+        description: Set this flag to enable PHY parameter toggle when port
+          status change.
+        type: boolean
+
+      realtek,do-toggle-driving:
+        description: Set this flag to enable PHY parameter toggle for adjust
+          the driving when port status change.
+        type: boolean
+
+      realtek,check-efuse:
+        description: Enable to update PHY parameter from reading otp table.
+        type: boolean
+
+      realtek,use-default-parameter:
+        description: Don't set parameter and use default value in hardware.
+        type: boolean
+
+      realtek,is-double-sensitivity-mode:
+        description: Set this flag to enable double sensitivity mode.
+        type: boolean
+
+      realtek,ldo-force-enable:
+        description: Set this flag to force enable ldo mode.
+        type: boolean
+
+      realtek,ldo-driving-compensate:
+        description: Set the value for adjust the PHY driving for ldo mode.
+        $ref: /schemas/types.yaml#/definitions/uint32
+
+      realtek,driving-compensate:
+        description: Set the value for adjust the PHY driving for efuse
+          table v2.
+        $ref: /schemas/types.yaml#/definitions/uint32
+
+required:
+  - compatible
+  - reg
+  - "#address-cells"
+  - "#size-cells"
+  - "#phy-cells"
+
+additionalProperties: false
+
+examples:
+  - |
+    usb_port0_usb2phy: usb-phy@13214 {
+        compatible = "realtek,rtd1319d-usb2phy", "realtek,usb2phy";
+        reg = <0x13214 0x4>, <0x28280 0x4>;
+        #address-cells = <1>;
+        #size-cells = <0>;
+        #phy-cells = <0>;
+        realtek,usb-ctrl = <&usb_ctrl>;
+
+        phy@0 {
+            reg = <0>;
+            realtek,page0-param =
+                    <0xe0 0xa3>, <0xe4 0xb2>, <0xe5 0x4e>, <0xe6 0x42>;
+            realtek,page1-param = <0xe3 0x64>;
+            realtek,page2-param = <0xe7 0x45>;
+            realtek,support-page2-param;
+            realtek,do-toggle;
+            realtek.do-toggle-driving;
+            realtek,check-efuse;
+            realtek,is-double-sensitivity-mode;
+            realtek,ldo-force-enable;
+        };
+    };
+
+  - |
+    usb_port1_usb2phy: usb-phy@13c14 {
+        compatible = "realtek,rtd1395-usb2phy", "realtek,usb2phy";
+        reg = <0x132c4 0x4>, <0x31280 0x8>;
+        #address-cells = <1>;
+        #size-cells = <0>;
+        #phy-cells = <0>;
+        realtek,usb-ctrl = <&usb_ctrl>;
+
+        phy@0 {
+            reg = <0>;
+            realtek,page0-param =
+                    <0xe0 0xa3>, <0xe4 0xb2>, <0xe5 0x4e>, <0xe6 0x42>;
+            realtek,page1-param = <0xe3 0x00>;
+            realtek,do-toggle;
+            realtek,check-efuse;
+        };
+        phy@1 {
+            reg = <1>;
+            realtek,page0-param =
+                    <0xe0 0xe0>, <0xe4 0xb2>, <0xe5 0x4e>, <0xe6 0x42>;
+            realtek,page1-param = <0xe3 0x00>;
+            realtek,do-toggle;
+            realtek,check-efuse;
+        };
+    };
Signature · 1 line
2.34.1
#19 lore raw

Re: [PATCH v3 4/5] dt-bindings: phy: realtek: Add the doc about the Realtek SoC USB 2.0 PHY

Quoted 87 lines · Stanley Chang

Add the documentation explain the property about Realtek USB PHY driver.

Realtek DHC (digital home center) RTD SoCs support DWC3 XHCI USB controller. Added the driver to drive the USB 2.0 PHY transceivers.

---
v2 to v3 change:
1. Broken down into two patches, one for each of USB 2 & 3.
2. Add more description about Realtek RTD SoCs architecture.
3. Removed parameter v1 support for simplification.
4. Revised the compatible name for fallback compatible.
5. Remove some properties that can be set in the driver.
v1 to v2 change:
Add phy-cells for generic phy driver

---
 .../bindings/phy/realtek,usb2phy.yaml         | 213 ++++++++++++++++++
 1 file changed, 213 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml new file +61 -0
new file mode 100644
index 000000000000..69911e20a561
@@ -0,0 +1,213 @@
+# 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 USB 2.0 PHY
+
+maintainers:
+  - Stanley Chang <[email protected]>
+
+description:
+  Realtek USB 2.0 PHY support the digital home center (DHC) RTD series SoCs.
+  The USB 2.0 PHY driver is designed to support the XHCI controller. The SoCs
+  support multiple XHCI controllers. One PHY device node maps to one XHCI
+  controller.
+
+  RTD1295/RTD1619 SoCs USB
+  The USB architecture includes three XHCI controllers.
+  Each XHCI maps to one USB 2.0 PHY and map one USB 3.0 PHY on some
+  controllers.
+  XHCI controller#0 -- usb2phy -- phy#0
+                    |- usb3phy -- phy#0
+  XHCI controller#1 -- usb2phy -- phy#0
+  XHCI controller#2 -- usb2phy -- phy#0
+                    |- usb3phy -- phy#0
+
+  RTD1395 SoCs USB
+  The USB architecture includes two XHCI controllers.
+  The controller#0 has one USB 2.0 PHY. The controller#1 includes two USB 2.0
+  PHY.
+  XHCI controller#0 -- usb2phy -- phy#0
+  XHCI controller#1 -- usb2phy -- phy#0
+                               |- phy#1
+
+  RTD1319/RTD1619b SoCs USB
+  The USB architecture includes three XHCI controllers.
+  Each XHCI maps to one USB 2.0 PHY and map one USB 3.0 PHY on controllers#2.
+  XHCI controller#0 -- usb2phy -- phy#0
+  XHCI controller#1 -- usb2phy -- phy#0
+  XHCI controller#2 -- usb2phy -- phy#0
+                    |- usb3phy -- phy#0
+
+  RTD1319d SoCs USB
+  The USB architecture includes three XHCI controllers.
+  Each xhci maps to one USB 2.0 PHY and map one USB 3.0 PHY on controllers#0.
+  XHCI controller#0 -- usb2phy -- phy#0
+                    |- usb3phy -- phy#0
+  XHCI controller#1 -- usb2phy -- phy#0
+  XHCI controller#2 -- usb2phy -- phy#0
+
+  RTD1312c/RTD1315e SoCs USB
+  The USB architecture includes three XHCI controllers.
+  Each XHCI maps to one USB 2.0 PHY.
+  XHCI controller#0 -- usb2phy -- phy#0
+  XHCI controller#1 -- usb2phy -- phy#0
+  XHCI controller#2 -- usb2phy -- phy#0
+
+properties:
+  compatible:

Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml line 71

Quoted 10 lines
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml new file +10 -0
+    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

Keep entries ordered alphabetically.

Quoted 9 lines
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml new file +9 -0
+      - const: realtek,usb2phy
+
+  reg:
+    items:
+      - description: PHY data registers
+      - description: PHY control registers
+
+  "#address-cells":
+    const: 1

Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml line 90

Quoted 10 lines
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml new file +10 -0
+
+  "#size-cells":
+    const: 0
+
+  "#phy-cells":
+    const: 0
+
+  realtek,usb-ctrl:
+    description: The phandle of syscon used to control USB PHY power domain.
+    $ref: /schemas/types.yaml#/definitions/phandle

No, we have power-domains for this.

Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml line 96

Quoted 6 lines
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml new file +6 -0
+
+patternProperties:
+  "^phy@[0-3]+$":
+    type: object
+    description:
+      Each sub-node is a PHY device for one XHCI controller.

I don't think it is true. You claim above that you have 0 as phy-cells, means you have one phy. Here you say you can have up to 4 phys.

Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml line 102

Quoted 6 lines
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml new file +6 -0
+      For most Relatek SoCs, one XHCI controller only support one the USB 2.0
+      phy. For RTD1395 SoC, the one XHCI controller has two USB 2.0 PHYs.
+    properties:
+      realtek,page0-param:
+        description: PHY parameter at page 0. The data are the pair of the
+          offset and value.

This needs to be specific. What the heck is "PHY parameter"?

Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml line 103

Quoted 1 line
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml new file +1 -0
+        $ref: /schemas/types.yaml#/definitions/uint32-array

Array? Then maxItems.

Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml line 116

Quoted 13 lines
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml new file +13 -0
+
+      realtek,page1-param:
+        description: PHY parameter at page 1. The data are the pair of the
+          offset and value.
+        $ref: /schemas/types.yaml#/definitions/uint32-array
+
+      realtek,page2-param:
+        description: PHY parameter at page 2. The data are the pair of the
+          offset and value. If the PHY support the page 2 parameter.
+        $ref: /schemas/types.yaml#/definitions/uint32-array
+
+      realtek,support-page2-param:
+        description: Set this flag if PHY support page 2 parameter.

Why this cannot be deducted from compatible?

Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml line 121

Quoted 5 lines
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml new file +5 -0
+        type: boolean
+
+      realtek,do-toggle:
+        description: Set this flag to enable PHY parameter toggle when port
+          status change.

Do not instruct OS what to do. Explain why this is a hardware characteristic.

Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml line 126

Quoted 5 lines
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml new file +5 -0
+        type: boolean
+
+      realtek,do-toggle-driving:
+        description: Set this flag to enable PHY parameter toggle for adjust
+          the driving when port status change.

Do not instruct OS what to do. Explain why this is a hardware characteristic.

Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml line 130

Quoted 4 lines
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml new file +4 -0
+        type: boolean
+
+      realtek,check-efuse:
+        description: Enable to update PHY parameter from reading otp table.

Do not instruct OS what to do. Explain why this is a hardware characteristic.

Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml line 134

Quoted 4 lines
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml new file +4 -0
+        type: boolean
+
+      realtek,use-default-parameter:
+        description: Don't set parameter and use default value in hardware.

NAK, you are just making things up.

Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml line 138

Quoted 4 lines
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml new file +4 -0
+        type: boolean
+
+      realtek,is-double-sensitivity-mode:
+        description: Set this flag to enable double sensitivity mode.

All your descriptions copy the name of property. You basically say nothing more. I already mentioned this before. Don't ignore the feedback, but address it.

Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml line 142

Quoted 4 lines
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml new file +4 -0
+        type: boolean
+
+      realtek,ldo-force-enable:
+        description: Set this flag to force enable ldo mode.

Drop everywhere "Set this flag to", because it is redundant. Now compare what is left with property name.

Property name: realtek,ldo-force-enable
Your description: "force enable ldo mode"

How is this helpful to anybody?

Best regards,
Krzysztof

Signature · 3 lines
linux-phy mailing list
[email protected]
https://lists.infradead.org/mailman/listinfo/linux-phy
#20 lore raw

RE: [PATCH v3 4/5] dt-bindings: phy: realtek: Add the doc about the Realtek SoC USB 2.0 PHY

Hi Krzysztof,

Quoted 97 lines · Stanley Chang
Quoted 15 lines

Add the documentation explain the property about Realtek USB PHY driver.

Realtek DHC (digital home center) RTD SoCs support DWC3 XHCI USB controller. Added the driver to drive the USB 2.0 PHY transceivers.

---
v2 to v3 change:
1. Broken down into two patches, one for each of USB 2 & 3.
2. Add more description about Realtek RTD SoCs architecture.
3. Removed parameter v1 support for simplification.
4. Revised the compatible name for fallback compatible.
5. Remove some properties that can be set in the driver.
v1 to v2 change:
Add phy-cells for generic phy driver

Quoted 2 lines
---
 .../bindings/phy/realtek,usb2phy.yaml         | 213

++++++++++++++++++

Quoted 15 lines
 1 file changed, 213 insertions(+)
 create mode 100644

Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml

diff --git a/Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml b/Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml new file mode 100644
index 000000000000..69911e20a561

Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml new file +3 -0
@@ -0,0 +1,213 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) # Copyright 2023
+Realtek Semiconductor Corporation %YAML 1.2
+---

Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml line 13

Quoted 10 lines
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml new file +10 -0
+$id: http://devicetree.org/schemas/phy/realtek,usb2phy.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Realtek DHC SoCs USB 2.0 PHY
+
+maintainers:
+  - Stanley Chang <[email protected]>
+
+description:
+  Realtek USB 2.0 PHY support the digital home center (DHC) RTD series

SoCs.

Quoted 16 lines
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml new file +16 -0
+  The USB 2.0 PHY driver is designed to support the XHCI controller.
+The SoCs
+  support multiple XHCI controllers. One PHY device node maps to one
+XHCI
+  controller.
+
+  RTD1295/RTD1619 SoCs USB
+  The USB architecture includes three XHCI controllers.
+  Each XHCI maps to one USB 2.0 PHY and map one USB 3.0 PHY on some
+ controllers.
+  XHCI controller#0 -- usb2phy -- phy#0
+                    |- usb3phy -- phy#0  XHCI controller#1 -- usb2phy
+ -- phy#0  XHCI controller#2 -- usb2phy -- phy#0
+                    |- usb3phy -- phy#0
+
+  RTD1395 SoCs USB

Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml

Quoted 10 lines
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml new file +10 -0
+  The USB architecture includes two XHCI controllers.
+  The controller#0 has one USB 2.0 PHY. The controller#1 includes two
+ USB 2.0  PHY.
+  XHCI controller#0 -- usb2phy -- phy#0  XHCI controller#1 -- usb2phy
+ -- phy#0
+                               |- phy#1
+
+  RTD1319/RTD1619b SoCs USB
+  The USB architecture includes three XHCI controllers.
+  Each XHCI maps to one USB 2.0 PHY and map one USB 3.0 PHY on

controllers#2.

Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml

Quoted 7 lines
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml new file +7 -0
+  XHCI controller#0 -- usb2phy -- phy#0  XHCI controller#1 -- usb2phy
+ -- phy#0  XHCI controller#2 -- usb2phy -- phy#0
+                    |- usb3phy -- phy#0
+
+  RTD1319d SoCs USB
+  The USB architecture includes three XHCI controllers.
+  Each xhci maps to one USB 2.0 PHY and map one USB 3.0 PHY on

controllers#0.

Quoted 16 lines
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml new file +16 -0
+  XHCI controller#0 -- usb2phy -- phy#0
+                    |- usb3phy -- phy#0  XHCI controller#1 -- usb2phy
+ -- phy#0  XHCI controller#2 -- usb2phy -- phy#0
+
+  RTD1312c/RTD1315e SoCs USB
+  The USB architecture includes three XHCI controllers.
+  Each XHCI maps to one USB 2.0 PHY.
+  XHCI controller#0 -- usb2phy -- phy#0  XHCI controller#1 -- usb2phy
+ -- phy#0  XHCI controller#2 -- usb2phy -- phy#0
+
+properties:
+  compatible:
+    items:
+      - enum:
+          - realtek,rtd1295-usb2phy
+          - realtek,rtd1395-usb2phy
Quoted 8 lines

Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml line 71

Quoted 6 lines
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml new file +6 -0
+          - realtek,rtd1619-usb2phy
+          - realtek,rtd1319-usb2phy
+          - realtek,rtd1619b-usb2phy
+          - realtek,rtd1312c-usb2phy
+          - realtek,rtd1319d-usb2phy
+          - realtek,rtd1315e-usb2phy

Keep entries ordered alphabetically.

Okay.

Quoted 19 lines
Quoted 8 lines
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml new file +8 -0
+      - const: realtek,usb2phy
+
+  reg:
+    items:
+      - description: PHY data registers
+      - description: PHY control registers
+
+  "#address-cells":

Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml

Quoted 10 lines
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml new file +10 -0
+    const: 1
+
+  "#size-cells":
+    const: 0
+
+  "#phy-cells":
+    const: 0
+
+  realtek,usb-ctrl:
+    description: The phandle of syscon used to control USB PHY power

domain.

Quoted 3 lines

Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml line 90

Quoted 1 line
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml new file +1 -0
+    $ref: /schemas/types.yaml#/definitions/phandle

No, we have power-domains for this.

Maybe I use the word "control power domain" is not well, I just want to control the ldo of usb phy. Revised:
The phandle of syscon used to control the ldo of USB PHY.

Quoted 9 lines

Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml line 96

Quoted 6 lines
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml new file +6 -0
+
+patternProperties:
+  "^phy@[0-3]+$":
+    type: object
+    description:
+      Each sub-node is a PHY device for one XHCI controller.

I don't think it is true. You claim above that you have 0 as phy-cells, means you have one phy. Here you say you can have up to 4 phys.

I mean the driver can support up to 4 phys.
For RTD1295 has only one phy.
For RTD1395 has two phys.

Quoted 7 lines

Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml line 94

Quoted 1 line
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml new file +1 -0
+      For most Relatek SoCs, one XHCI controller only support one the USB

2.0

Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml line 95

Quoted 1 line
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml new file +1 -0
+      phy. For RTD1395 SoC, the one XHCI controller has two USB 2.0

PHYs.

Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml

Quoted 3 lines
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml new file +3 -0
+    properties:
+      realtek,page0-param:
+        description: PHY parameter at page 0. The data are the pair of
Quoted 8 lines

the

Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml line 99

Quoted 1 line
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml new file +1 -0
+          offset and value.

This needs to be specific. What the heck is "PHY parameter"?

Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml line 100

Quoted 1 line
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml new file +1 -0
+        $ref: /schemas/types.yaml#/definitions/uint32-array

Array? Then maxItems.

I have found other document.
It should be a uint32-matrix.
I will add the maxItems.

Quoted 9 lines

Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml

Quoted 3 lines
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml new file +3 -0
+
+      realtek,page1-param:
+        description: PHY parameter at page 1. The data are the pair of

the

Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml

Quoted 5 lines
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml new file +5 -0
+          offset and value.
+        $ref: /schemas/types.yaml#/definitions/uint32-array
+
+      realtek,page2-param:
+        description: PHY parameter at page 2. The data are the pair of
Quoted 8 lines

the

Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml line 116

Quoted 5 lines
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml new file +5 -0
+          offset and value. If the PHY support the page 2 parameter.
+        $ref: /schemas/types.yaml#/definitions/uint32-array
+
+      realtek,support-page2-param:
+        description: Set this flag if PHY support page 2 parameter.

Why this cannot be deducted from compatible?

It can identify by compatible.

Quoted 9 lines

Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml

Quoted 5 lines
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml new file +4 -0
+        type: boolean
+
+      realtek,do-toggle:
+        description: Set this flag to enable PHY parameter toggle when

port

Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml line 121

Quoted 1 line
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml new file +1 -0
+          status change.

Do not instruct OS what to do. Explain why this is a hardware characteristic.

In my original intention, we hope that this property can be used to control the phy driver do parameter toggle. Is it a hardware characteristic? I don't think it's exactly a hardware feature.
Maybe it can be specified by the compatible.

Quoted 10 lines

Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml

Quoted 4 lines
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml new file +4 -0
+        type: boolean
+
+      realtek,do-toggle-driving:
+        description: Set this flag to enable PHY parameter toggle for

adjust

Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml line 126

Quoted 1 line
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml new file +1 -0
+          the driving when port status change.

Do not instruct OS what to do. Explain why this is a hardware characteristic.

Quoted 7 lines

Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml

Quoted 4 lines
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml new file +4 -0
+        type: boolean
+
+      realtek,check-efuse:
+        description: Enable to update PHY parameter from reading otp

table.

Do not instruct OS what to do. Explain why this is a hardware characteristic.

Same above.

Quoted 7 lines

Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml

Quoted 4 lines
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml new file +4 -0
+        type: boolean
+
+      realtek,use-default-parameter:
+        description: Don't set parameter and use default value in

hardware.

NAK, you are just making things up.

This is a software flow control.
I will remove it.

Quoted 8 lines

Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml line 138

Quoted 5 lines
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml new file +4 -0
+        type: boolean
+
+      realtek,is-double-sensitivity-mode:
+        description: Set this flag to enable double sensitivity mode.

All your descriptions copy the name of property. You basically say nothing more. I already mentioned this before. Don't ignore the feedback, but address it.

I will improve this.

Quoted 5 lines

Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml line 142

Quoted 4 lines
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml new file +4 -0
+        type: boolean
+
+      realtek,ldo-force-enable:
+        description: Set this flag to force enable ldo mode.
Quoted 7 lines

Drop everywhere "Set this flag to", because it is redundant. Now compare what is left with property name.

Property name: realtek,ldo-force-enable
Your description: "force enable ldo mode"

How is this helpful to anybody?

This is a software flow control.
I will remove it.

Thanks,
Stanley
.

#21 lore raw

Re: [PATCH v3 4/5] dt-bindings: phy: realtek: Add the doc about the Realtek SoC USB 2.0 PHY

Quoted 10 lines · Stanley Chang[昌育德]
Quoted 6 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+  realtek,usb-ctrl:
+    description: The phandle of syscon used to control USB PHY power

domain.

Quoted 1 line

+ $ref: /schemas/types.yaml#/definitions/phandle

No, we have power-domains for this.

Maybe I use the word "control power domain" is not well, I just want to control the ldo of usb phy. Revised:
The phandle of syscon used to control the ldo of USB PHY.

Isn't this still a power domain?

Quoted 11 lines
Quoted 10 lines

Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml line 96

Quoted 7 lines
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml new file +6 -0
+
+patternProperties:
+  "^phy@[0-3]+$":
+    type: object
+    description:
+      Each sub-node is a PHY device for one XHCI controller.

I don't think it is true. You claim above that you have 0 as phy-cells, means you have one phy. Here you say you can have up to 4 phys.

Quoted 1 line

I mean the driver can support up to 4 phys.

What driver can or cannot do, does not matter. This is about hardware.

Quoted 2 lines

For RTD1295 has only one phy.
For RTD1395 has two phys.

Two phys? So how do you reference them when cells=0?

Quoted 11 lines
Quoted 11 lines
Quoted 2 lines

+ For most Relatek SoCs, one XHCI controller only support one the USB

2.0

Quoted 1 line

+ phy. For RTD1395 SoC, the one XHCI controller has two USB 2.0

PHYs.

Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml

Quoted 3 lines
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml new file +3 -0
+    properties:
+      realtek,page0-param:
+        description: PHY parameter at page 0. The data are the pair of

the

Quoted 1 line

+ offset and value.

Quoted 8 lines
Quoted 5 lines

This needs to be specific. What the heck is "PHY parameter"?

Quoted 1 line

+ $ref: /schemas/types.yaml#/definitions/uint32-array

Array? Then maxItems.

I have found other document.
It should be a uint32-matrix.
I will add the maxItems.

Entire property should be dropped.

Quoted 11 lines
Quoted 11 lines

Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml

Quoted 4 lines
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml new file +3 -0
+
+      realtek,page1-param:
+        description: PHY parameter at page 1. The data are the pair of

the

Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml

Quoted 5 lines
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml new file +5 -0
+          offset and value.
+        $ref: /schemas/types.yaml#/definitions/uint32-array
+
+      realtek,page2-param:
+        description: PHY parameter at page 2. The data are the pair of

the

Quoted 8 lines
Quoted 7 lines

Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml line 116

Quoted 5 lines
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml new file +5 -0
+          offset and value. If the PHY support the page 2 parameter.
+        $ref: /schemas/types.yaml#/definitions/uint32-array
+
+      realtek,support-page2-param:
+        description: Set this flag if PHY support page 2 parameter.

Why this cannot be deducted from compatible?

It can identify by compatible.

So drop it.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml new file +4 -0
+        type: boolean
+
+      realtek,do-toggle:
+        description: Set this flag to enable PHY parameter toggle when
Quoted 8 lines
Quoted 4 lines

port

Quoted 1 line

+ status change.

Do not instruct OS what to do. Explain why this is a hardware characteristic.

In my original intention, we hope that this property can be used to control the phy driver do parameter toggle. Is it a hardware characteristic? I don't think it's exactly a hardware feature.
Maybe it can be specified by the compatible.

Drop it.

Quoted 15 lines
Quoted 15 lines

Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml

Quoted 5 lines
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml new file +4 -0
+        type: boolean
+
+      realtek,do-toggle-driving:
+        description: Set this flag to enable PHY parameter toggle for

adjust

Quoted 1 line

+ the driving when port status change.

Do not instruct OS what to do. Explain why this is a hardware characteristic.

Quoted 4 lines
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml new file +4 -0
+        type: boolean
+
+      realtek,check-efuse:
+        description: Enable to update PHY parameter from reading otp
Quoted 5 lines
Quoted 3 lines

table.

Do not instruct OS what to do. Explain why this is a hardware characteristic.

Same above.

So drop all of these.

Best regards,
Krzysztof

Signature · 3 lines
linux-phy mailing list
[email protected]
https://lists.infradead.org/mailman/listinfo/linux-phy
#22 lore raw

RE: [PATCH v3 4/5] dt-bindings: phy: realtek: Add the doc about the Realtek SoC USB 2.0 PHY

Quoted 7 lines
Quoted 2 lines

Maybe I use the word "control power domain" is not well, I just want to

control the ldo of usb phy.

Quoted 2 lines

Revised:
The phandle of syscon used to control the ldo of USB PHY.

Isn't this still a power domain?

I only control a register, it is not needed a driver of power domain.

Quoted 11 lines
Quoted 11 lines
Quoted 10 lines

Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml line 96

Quoted 7 lines
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml new file +6 -0
+
+patternProperties:
+  "^phy@[0-3]+$":
+    type: object
+    description:
+      Each sub-node is a PHY device for one XHCI controller.

I don't think it is true. You claim above that you have 0 as phy-cells, means you have one phy. Here you say you can have up to 4 phys.

Quoted 8 lines
Quoted 1 line

I mean the driver can support up to 4 phys.

What driver can or cannot do, does not matter. This is about hardware.

Quoted 2 lines

For RTD1295 has only one phy.
For RTD1395 has two phys.

Two phys? So how do you reference them when cells=0?

About RTD1395 SoCs USB
XHCI controller#1 -- usb2phy -- phy#0

                          |- phy#1

One xhci controller map to one phy driver. And one phy driver have two phys (phy@0 and phy@1).

Maybe the "phy" name is confusing. This "phy" not mean a phy driver. Would "port" be more appropriate?

For example,
Using phy@0 and phy@1:

    usb_port1_usb2phy: usb-phy@13c14 {
        compatible = "realtek,rtd1395-usb2phy", "realtek,usb2phy";
        reg = <0x132c4 0x4>, <0x31280 0x8>;
        #address-cells = <1>;
        #size-cells = <0>;
        #phy-cells = <0>;
        realtek,usb-ctrl = <&usb_ctrl>;

        phy@0 {
            reg = <0>;
        };
        phy@1 {
            reg = <1>;
        };
    };

Change: port@0 and port@1

    usb_port1_usb2phy: usb-phy@13c14 {
        compatible = "realtek,rtd1395-usb2phy", "realtek,usb2phy";
        reg = <0x132c4 0x4>, <0x31280 0x8>;
        #address-cells = <1>;
        #size-cells = <0>;
        #phy-cells = <0>;
        realtek,usb-ctrl = <&usb_ctrl>;

        prot@0 {
            reg = <0>;
        };
        port@1 {
            reg = <1>;
        };
    };
#23 lore raw

Re: [PATCH v3 4/5] dt-bindings: phy: realtek: Add the doc about the Realtek SoC USB 2.0 PHY

Quoted 9 lines · Stanley Chang[昌育德]
Quoted 7 lines
Quoted 2 lines

Maybe I use the word "control power domain" is not well, I just want to

control the ldo of usb phy.

Quoted 2 lines

Revised:
The phandle of syscon used to control the ldo of USB PHY.

Isn't this still a power domain?

I only control a register, it is not needed a driver of power domain.

Aren't many power domains just a registers? What about other drivers? Don't you want in other driver control LDO of something else? And in other something else?

Quoted 23 lines
Quoted 13 lines
Quoted 13 lines
Quoted 12 lines

Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml line 96

Quoted 9 lines
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml new file +6 -0
+
+patternProperties:
+  "^phy@[0-3]+$":
+    type: object
+    description:
+      Each sub-node is a PHY device for one XHCI controller.

I don't think it is true. You claim above that you have 0 as phy-cells, means you have one phy. Here you say you can have up to 4 phys.

Quoted 8 lines
Quoted 1 line

I mean the driver can support up to 4 phys.

What driver can or cannot do, does not matter. This is about hardware.

Quoted 2 lines

For RTD1295 has only one phy.
For RTD1395 has two phys.

Two phys? So how do you reference them when cells=0?

Quoted 8 lines

About RTD1395 SoCs USB
XHCI controller#1 -- usb2phy -- phy#0

                          |- phy#1

One xhci controller map to one phy driver. And one phy driver have two phys (phy@0 and phy@1).

Maybe the "phy" name is confusing.
This "phy" not mean a phy driver.

We do not talk about drivers, but DTS and hardware.

Quoted 4 lines

Would "port" be more appropriate?

For example,
Using phy@0 and phy@1:

Quoted 10 lines
    usb_port1_usb2phy: usb-phy@13c14 {
        compatible = "realtek,rtd1395-usb2phy", "realtek,usb2phy";
        reg = <0x132c4 0x4>, <0x31280 0x8>;
        #address-cells = <1>;
        #size-cells = <0>;
        #phy-cells = <0>;
        realtek,usb-ctrl = <&usb_ctrl>;

        phy@0 {
            reg = <0>;

So such child is a NAK... you have nothing here. But it's unrelated topic.

Quoted 7 lines
        };
        phy@1 {
            reg = <1>;
        };
    };

Change: port@0 and port@1

Quoted 15 lines
    usb_port1_usb2phy: usb-phy@13c14 {
        compatible = "realtek,rtd1395-usb2phy", "realtek,usb2phy";
        reg = <0x132c4 0x4>, <0x31280 0x8>;
        #address-cells = <1>;
        #size-cells = <0>;
        #phy-cells = <0>;
        realtek,usb-ctrl = <&usb_ctrl>;

        prot@0 {
            reg = <0>;
        };
        port@1 {
            reg = <1>;
        };
    };

This is not the answer. This is the provider. How do you reference it from the consumer.

Upstream your entire DTS. It's frustrating to try to understand your DTS from pieces of information you are sharing. Also very time consuming and you are not the only one sending patches for review...

Best regards,
Krzysztof

Signature · 3 lines
linux-phy mailing list
[email protected]
https://lists.infradead.org/mailman/listinfo/linux-phy
#24 lore raw

RE: [PATCH v3 4/5] dt-bindings: phy: realtek: Add the doc about the Realtek SoC USB 2.0 PHY

Quoted 5 lines
Quoted 1 line

I only control a register, it is not needed a driver of power domain.

Aren't many power domains just a registers? What about other drivers? Don't you want in other driver control LDO of something else? And in other something else?

I will use power domain to instead this.

Quoted 12 lines
Quoted 12 lines

Would "port" be more appropriate?

For example,
Using phy@0 and phy@1:

    usb_port1_usb2phy: usb-phy@13c14 {
        compatible = "realtek,rtd1395-usb2phy", "realtek,usb2phy";
        reg = <0x132c4 0x4>, <0x31280 0x8>;
        #address-cells = <1>;
        #size-cells = <0>;
        #phy-cells = <0>;
        realtek,usb-ctrl = <&usb_ctrl>;
Quoted 4 lines
Quoted 2 lines
        phy@0 {
            reg = <0>;

So such child is a NAK... you have nothing here. But it's unrelated topic.

Here is for simple, so some items ignore.

Quoted 23 lines
Quoted 7 lines
        };
        phy@1 {
            reg = <1>;
        };
    };

Change: port@0 and port@1

Quoted 15 lines
    usb_port1_usb2phy: usb-phy@13c14 {
        compatible = "realtek,rtd1395-usb2phy", "realtek,usb2phy";
        reg = <0x132c4 0x4>, <0x31280 0x8>;
        #address-cells = <1>;
        #size-cells = <0>;
        #phy-cells = <0>;
        realtek,usb-ctrl = <&usb_ctrl>;

        prot@0 {
            reg = <0>;
        };
        port@1 {
            reg = <1>;
        };
    };
Quoted 7 lines

This is not the answer. This is the provider. How do you reference it from the consumer.

Upstream your entire DTS. It's frustrating to try to understand your DTS from pieces of information you are sharing. Also very time consuming and you are not the only one sending patches for review...

Sorry to take up a lot of your time.
Apparently I don't know enough about dts.
I will reference more device tree document to understand the relating between DTS and hardware.

Thanks,
Stanley

#25 lore raw

RE: [PATCH v3 4/5] dt-bindings: phy: realtek: Add the doc about the Realtek SoC USB 2.0 PHY

In reply to Krzysztof Kozlowski

Hi Krzysztof,

Quoted 12 lines
Quoted 1 line

+ For most Relatek SoCs, one XHCI controller only support one the USB

2.0

Quoted 1 line

+ phy. For RTD1395 SoC, the one XHCI controller has two USB 2.0

PHYs.

Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml

Quoted 3 lines
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml new file +3 -0
+    properties:
+      realtek,page0-param:
+        description: PHY parameter at page 0. The data are the pair of

the

Quoted 1 line

+ offset and value.

This needs to be specific. What the heck is "PHY parameter"?

It contains more parameters
page0 has 16 parameters
page1 has 8 parameters
page2 has 8 parameters
It's tedious if we list them all.
And we only set the part that differs from the default.
It's hard to explain which parameters were changed because each platform is different.

Thanks,
Stanley

#26 lore raw

Re: [PATCH v3 4/5] dt-bindings: phy: realtek: Add the doc about the Realtek SoC USB 2.0 PHY

Quoted 13 lines · Stanley Chang[昌育德]

Hi Krzysztof,

Quoted 10 lines
Quoted 1 line

+ For most Relatek SoCs, one XHCI controller only support one the USB

2.0

Quoted 1 line

+ phy. For RTD1395 SoC, the one XHCI controller has two USB 2.0

PHYs.

Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml

Quoted 3 lines
Documentation/devicetree/bindings/phy/realtek,usb2phy.yaml new file +3 -0
+    properties:
+      realtek,page0-param:
+        description: PHY parameter at page 0. The data are the pair of

the

Quoted 1 line

+ offset and value.

Quoted 7 lines
Quoted 2 lines

This needs to be specific. What the heck is "PHY parameter"?

It contains more parameters
page0 has 16 parameters
page1 has 8 parameters
page2 has 8 parameters
It's tedious if we list them all.

Sure, if you prefer not to list them, then they should be removed from DT.

Quoted 2 lines

And we only set the part that differs from the default.
It's hard to explain which parameters were changed because each platform is different.

If this is phy tuning per board, you need to explain and justify them. If this is per platform, then drop it - not even needed, because you have compatible for this.

Best regards,
Krzysztof

Signature · 3 lines
linux-phy mailing list
[email protected]
https://lists.infradead.org/mailman/listinfo/linux-phy
#27 lore raw

RE: [PATCH v3 4/5] dt-bindings: phy: realtek: Add the doc about the Realtek SoC USB 2.0 PHY

Quoted 11 lines
Quoted 8 lines
Quoted 3 lines

This needs to be specific. What the heck is "PHY parameter"?

It contains more parameters
page0 has 16 parameters
page1 has 8 parameters
page2 has 8 parameters
It's tedious if we list them all.

Sure, if you prefer not to list them, then they should be removed from DT.

Quoted 8 lines
Quoted 2 lines

And we only set the part that differs from the default.
It's hard to explain which parameters were changed because each platform is

different.

If this is phy tuning per board, you need to explain and justify them. If this is per platform, then drop it - not even needed, because you have compatible for this.

Okay, I try to specify by the compatible.

Thanks,
Stanley

#28 lore raw

PATCH v3 5/5 dt-bindings: phy: realtek: Add the doc about the Realtek SoC USB 3.0 PHY

In reply to Stanley Chang

Add the documentation explain the property about Realtek USB PHY driver.

Realtek DHC (digital home center) RTD SoCs support DWC3 XHCI USB controller. Added the driver to drive the USB 3.0 PHY transceivers.

---
v2 to v3 change:
1. Broken down into two patches, one for each of USB 2 & 3.
2. Add more description about Realtek RTD SoCs architecture.
3. Removed parameter v1 support for simplification.
4. Revised the compatible name for fallback compatible.
5. Remove some properties that can be set in the driver.
v1 to v2 change:
Add phy-cells for generic phy driver

---
 .../bindings/phy/realtek,usb3phy.yaml         | 156 ++++++++++++++++++
 1 file changed, 156 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/realtek,usb3phy.yaml
Documentation/devicetree/bindings/phy/realtek,usb3phy.yaml new file +156 -0
new file mode 100644
index 000000000000..b45c398bba5f
@@ -0,0 +1,156 @@
+# 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,usb3phy.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Realtek DHC SoCs USB 3.0 PHY
+
+maintainers:
+  - Stanley Chang <[email protected]>
+
+description:
+  Realtek USB 3.0 PHY support the digital home center (DHC) RTD series SoCs.
+  The USB 3.0 PHY driver is designed to support the XHCI controller. The SoCs
+  support multiple XHCI controllers. One PHY device node maps to one XHCI
+  controller.
+
+  RTD1295/RTD1619 SoCs USB
+  The USB architecture includes three XHCI controllers.
+  Each XHCI maps to one USB 2.0 PHY and map one USB 3.0 PHY on some
+  controllers.
+  XHCI controller#0 -- usb2phy -- phy#0
+                    |- usb3phy -- phy#0
+  XHCI controller#1 -- usb2phy -- phy#0
+  XHCI controller#2 -- usb2phy -- phy#0
+                    |- usb3phy -- phy#0
+
+  RTD1395 SoCs USB
+  The USB architecture includes two XHCI controllers.
+  The controller#0 has one USB 2.0 PHY. The controller#1 includes two USB 2.0
+  PHY.
+  XHCI controller#0 -- usb2phy -- phy#0
+  XHCI controller#1 -- usb2phy -- phy#0
+                               |- phy#1
+
+  RTD1319/RTD1619b SoCs USB
+  The USB architecture includes three XHCI controllers.
+  Each XHCI maps to one USB 2.0 PHY and map one USB 3.0 PHY on controllers#2.
+  XHCI controller#0 -- usb2phy -- phy#0
+  XHCI controller#1 -- usb2phy -- phy#0
+  XHCI controller#2 -- usb2phy -- phy#0
+                    |- usb3phy -- phy#0
+
+  RTD1319d SoCs USB
+  The USB architecture includes three XHCI controllers.
+  Each xhci maps to one USB 2.0 PHY and map one USB 3.0 PHY on controllers#0.
+  XHCI controller#0 -- usb2phy -- phy#0
+                    |- usb3phy -- phy#0
+  XHCI controller#1 -- usb2phy -- phy#0
+  XHCI controller#2 -- usb2phy -- phy#0
+
+  RTD1312c/RTD1315e SoCs USB
+  The USB architecture includes three XHCI controllers.
+  Each XHCI maps to one USB 2.0 PHY.
+  XHCI controller#0 -- usb2phy -- phy#0
+  XHCI controller#1 -- usb2phy -- phy#0
+  XHCI controller#2 -- usb2phy -- phy#0
+
+properties:
+  compatible:
+    items:
+      - enum:
+          - realtek,rtd1295-usb3phy
+          - realtek,rtd1619-usb3phy
+          - realtek,rtd1319-usb3phy
+          - realtek,rtd1619b-usb3phy
+          - realtek,rtd1319d-usb3phy
+      - const: realtek,usb3phy
+
+  reg:
+    description: PHY data registers
+    maxItems: 1
+
+  "#address-cells":
+    const: 1
+
+  "#size-cells":
+    const: 0
+
+  "#phy-cells":
+    const: 0
+
+patternProperties:
+  "^phy@[0-3]+$":
+    description: Each sub-node is a PHY device for one XHCI controller.
+    type: object
+    properties:
+      realtek,param:
+        description: The data of PHY parameter are the pair of the
+          offset and value.
+        $ref: /schemas/types.yaml#/definitions/uint8-array
+
+      realtek,do-toggle:
+        description: Set this flag to enable the PHY parameter toggle
+          when port status change.
+        type: boolean
+
+      realtek,do-toggle-once:
+        description: Set this flag to do PHY parameter toggle only on
+          PHY init.
+        type: boolean
+
+      realtek,check-efuse:
+        description: Enable to update PHY parameter from reading otp table.
+        type: boolean
+
+      realtek,use-default-parameter:
+        description: Don't set parameter and use default value in hardware.
+        type: boolean
+
+      realtek,check-rx-front-end-offset:
+        description: Enable to check rx front end offset.
+        type: boolean
+
+required:
+  - compatible
+  - reg
+  - "#address-cells"
+  - "#size-cells"
+  - "#phy-cells"
+
+additionalProperties: false
+
+examples:
+  - |
+    usb_port2_usb3phy: usb-phy@13e10 {
+        compatible = "realtek,rtd1319d-usb3phy", "realtek,usb3phy";
+        reg = <0x13e10 0x4>;
+        #address-cells = <1>;
+        #size-cells = <0>;
+        #phy-cells = <0>;
+
+        phy@0 {
+            reg = <0>;
+            realtek,param =
+                    <0x01 0xac8c>,
+                    <0x06 0x0017>,
+                    <0x09 0x724c>,
+                    <0x0B 0xb90d>,
+                    <0x0A 0xb610>,
+                    <0x0D 0xef2a>,
+                    <0x0F 0x9050>,
+                    <0x10 0x000c>,
+                    <0x20 0x70ff>,
+                    <0x21 0xcfaa>,
+                    <0x22 0x0013>,
+                    <0x23 0xdb66>,
+                    <0x26 0x8609>,
+                    <0x29 0xff13>,
+                    <0x2A 0x3070>;
+            realtek,do-toggle-once;
+            realtek,check-efuse;
+        };
+    };
+
Signature · 1 line
2.34.1
#29 lore raw

Re: [PATCH v3 5/5] dt-bindings: phy: realtek: Add the doc about the Realtek SoC USB 3.0 PHY

Quoted 51 lines · Stanley Chang

Add the documentation explain the property about Realtek USB PHY driver.

Realtek DHC (digital home center) RTD SoCs support DWC3 XHCI USB controller. Added the driver to drive the USB 3.0 PHY transceivers.

---
v2 to v3 change:
1. Broken down into two patches, one for each of USB 2 & 3.
2. Add more description about Realtek RTD SoCs architecture.
3. Removed parameter v1 support for simplification.
4. Revised the compatible name for fallback compatible.
5. Remove some properties that can be set in the driver.
v1 to v2 change:
Add phy-cells for generic phy driver

---
 .../bindings/phy/realtek,usb3phy.yaml         | 156 ++++++++++++++++++
 1 file changed, 156 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/realtek,usb3phy.yaml
Documentation/devicetree/bindings/phy/realtek,usb3phy.yaml new file +25 -0
new file mode 100644
index 000000000000..b45c398bba5f
@@ -0,0 +1,156 @@
+# 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,usb3phy.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Realtek DHC SoCs USB 3.0 PHY
+
+maintainers:
+  - Stanley Chang <[email protected]>
+
+description:
+  Realtek USB 3.0 PHY support the digital home center (DHC) RTD series SoCs.
+  The USB 3.0 PHY driver is designed to support the XHCI controller. The SoCs
+  support multiple XHCI controllers. One PHY device node maps to one XHCI
+  controller.
+
+  RTD1295/RTD1619 SoCs USB
+  The USB architecture includes three XHCI controllers.
+  Each XHCI maps to one USB 2.0 PHY and map one USB 3.0 PHY on some
+  controllers.
+  XHCI controller#0 -- usb2phy -- phy#0
+                    |- usb3phy -- phy#0
+  XHCI controller#1 -- usb2phy -- phy#0

Documentation/devicetree/bindings/phy/realtek,usb3phy.yaml line 35

Quoted 10 lines
Documentation/devicetree/bindings/phy/realtek,usb3phy.yaml new file +10 -0
+  XHCI controller#2 -- usb2phy -- phy#0
+                    |- usb3phy -- phy#0
+
+  RTD1395 SoCs USB
+  The USB architecture includes two XHCI controllers.
+  The controller#0 has one USB 2.0 PHY. The controller#1 includes two USB 2.0
+  PHY.
+  XHCI controller#0 -- usb2phy -- phy#0
+  XHCI controller#1 -- usb2phy -- phy#0
+                               |- phy#1

Skip unrelated devices.

Quoted 23 lines
Documentation/devicetree/bindings/phy/realtek,usb3phy.yaml new file +23 -0
+
+  RTD1319/RTD1619b SoCs USB
+  The USB architecture includes three XHCI controllers.
+  Each XHCI maps to one USB 2.0 PHY and map one USB 3.0 PHY on controllers#2.
+  XHCI controller#0 -- usb2phy -- phy#0
+  XHCI controller#1 -- usb2phy -- phy#0
+  XHCI controller#2 -- usb2phy -- phy#0
+                    |- usb3phy -- phy#0
+
+  RTD1319d SoCs USB
+  The USB architecture includes three XHCI controllers.
+  Each xhci maps to one USB 2.0 PHY and map one USB 3.0 PHY on controllers#0.
+  XHCI controller#0 -- usb2phy -- phy#0
+                    |- usb3phy -- phy#0
+  XHCI controller#1 -- usb2phy -- phy#0
+  XHCI controller#2 -- usb2phy -- phy#0
+
+  RTD1312c/RTD1315e SoCs USB
+  The USB architecture includes three XHCI controllers.
+  Each XHCI maps to one USB 2.0 PHY.
+  XHCI controller#0 -- usb2phy -- phy#0
+  XHCI controller#1 -- usb2phy -- phy#0
+  XHCI controller#2 -- usb2phy -- phy#0

Documentation/devicetree/bindings/phy/realtek,usb3phy.yaml line 68

Quoted 10 lines
Documentation/devicetree/bindings/phy/realtek,usb3phy.yaml new file +10 -0
+
+properties:
+  compatible:
+    items:
+      - enum:
+          - realtek,rtd1295-usb3phy
+          - realtek,rtd1619-usb3phy
+          - realtek,rtd1319-usb3phy
+          - realtek,rtd1619b-usb3phy
+          - realtek,rtd1319d-usb3phy

Same comments as for previous patch.

Quoted 4 lines
Documentation/devicetree/bindings/phy/realtek,usb3phy.yaml new file +4 -0
+      - const: realtek,usb3phy
+
+  reg:
+    description: PHY data registers

Documentation/devicetree/bindings/phy/realtek,usb3phy.yaml line 82

Quoted 10 lines
Documentation/devicetree/bindings/phy/realtek,usb3phy.yaml new file +10 -0
+    maxItems: 1
+
+  "#address-cells":
+    const: 1
+
+  "#size-cells":
+    const: 0
+
+  "#phy-cells":
+    const: 0

1 phy or 4? Decide.

Documentation/devicetree/bindings/phy/realtek,usb3phy.yaml line 92

Quoted 10 lines
Documentation/devicetree/bindings/phy/realtek,usb3phy.yaml new file +10 -0
+
+patternProperties:
+  "^phy@[0-3]+$":
+    description: Each sub-node is a PHY device for one XHCI controller.
+    type: object
+    properties:
+      realtek,param:
+        description: The data of PHY parameter are the pair of the
+          offset and value.
+        $ref: /schemas/types.yaml#/definitions/uint8-array

Your choice of types is surprising. If this is array, than maxItems (and please don't tell me it is maxItems: 1). Anyway, why 8 bits long?

Quoted 36 lines
Documentation/devicetree/bindings/phy/realtek,usb3phy.yaml new file +36 -0
+
+      realtek,do-toggle:
+        description: Set this flag to enable the PHY parameter toggle
+          when port status change.
+        type: boolean
+
+      realtek,do-toggle-once:
+        description: Set this flag to do PHY parameter toggle only on
+          PHY init.
+        type: boolean
+
+      realtek,check-efuse:
+        description: Enable to update PHY parameter from reading otp table.
+        type: boolean
+
+      realtek,use-default-parameter:
+        description: Don't set parameter and use default value in hardware.
+        type: boolean
+
+      realtek,check-rx-front-end-offset:
+        description: Enable to check rx front end offset.
+        type: boolean
+
+required:
+  - compatible
+  - reg
+  - "#address-cells"
+  - "#size-cells"
+  - "#phy-cells"
+
+additionalProperties: false
+
+examples:
+  - |
+    usb_port2_usb3phy: usb-phy@13e10 {
+        compatible = "realtek,rtd1319d-usb3phy", "realtek,usb3phy";

Documentation/devicetree/bindings/phy/realtek,usb3phy.yaml line 138

Quoted 10 lines
Documentation/devicetree/bindings/phy/realtek,usb3phy.yaml new file +10 -0
+        reg = <0x13e10 0x4>;
+        #address-cells = <1>;
+        #size-cells = <0>;
+        #phy-cells = <0>;
+
+        phy@0 {
+            reg = <0>;
+            realtek,param =
+                    <0x01 0xac8c>,
+                    <0x06 0x0017>,

First, this is matrix, not uint8 array. Second, 0xac8c is past 16 bits long, not 8. Third, you put some magic register programming to DT. Please don't. Drop all this from DT.

Best regards,
Krzysztof

#30 lore raw

RE: [PATCH v3 5/5] dt-bindings: phy: realtek: Add the doc about the Realtek SoC USB 3.0 PHY

Hi Krzysztof,

Quoted 2 lines

1 phy or 4? Decide.

In actually, we have one phy for one controller. I mean the driver can support up to 4 phys. I can revised as
"^phy@[0]+$"
Or only "phy"

Quoted 5 lines
Quoted 5 lines
Documentation/devicetree/bindings/phy/realtek,usb3phy.yaml new file +5 -0
+
+patternProperties:
+  "^phy@[0-3]+$":
+    description: Each sub-node is a PHY device for one XHCI controller.
+    type: object
Quoted 8 lines

Documentation/devicetree/bindings/phy/realtek,usb3phy.yaml line 92

Quoted 5 lines
Documentation/devicetree/bindings/phy/realtek,usb3phy.yaml new file +5 -0
+    properties:
+      realtek,param:
+        description: The data of PHY parameter are the pair of the
+          offset and value.
+        $ref: /schemas/types.yaml#/definitions/uint8-array

Your choice of types is surprising. If this is array, than maxItems (and please don't tell me it is maxItems: 1). Anyway, why 8 bits long?

It should be a uint32-matrix.

Quoted 44 lines

Documentation/devicetree/bindings/phy/realtek,usb3phy.yaml

Quoted 13 lines
Documentation/devicetree/bindings/phy/realtek,usb3phy.yaml new file +13 -0
+
+      realtek,do-toggle:
+        description: Set this flag to enable the PHY parameter toggle
+          when port status change.
+        type: boolean
+
+      realtek,do-toggle-once:
+        description: Set this flag to do PHY parameter toggle only on
+          PHY init.
+        type: boolean
+
+      realtek,check-efuse:
+        description: Enable to update PHY parameter from reading otp

table.

Documentation/devicetree/bindings/phy/realtek,usb3phy.yaml

Quoted 4 lines
Documentation/devicetree/bindings/phy/realtek,usb3phy.yaml new file +4 -0
+        type: boolean
+
+      realtek,use-default-parameter:
+        description: Don't set parameter and use default value in

hardware.

Quoted 25 lines
Documentation/devicetree/bindings/phy/realtek,usb3phy.yaml new file +25 -0
+        type: boolean
+
+      realtek,check-rx-front-end-offset:
+        description: Enable to check rx front end offset.
+        type: boolean
+
+required:
+  - compatible
+  - reg
+  - "#address-cells"
+  - "#size-cells"
+  - "#phy-cells"
+
+additionalProperties: false
+
+examples:
+  - |
+    usb_port2_usb3phy: usb-phy@13e10 {
+        compatible = "realtek,rtd1319d-usb3phy", "realtek,usb3phy";
+        reg = <0x13e10 0x4>;
+        #address-cells = <1>;
+        #size-cells = <0>;
+        #phy-cells = <0>;
+
+        phy@0 {
Quoted 8 lines

Documentation/devicetree/bindings/phy/realtek,usb3phy.yaml line 138

Quoted 4 lines
Documentation/devicetree/bindings/phy/realtek,usb3phy.yaml new file +4 -0
+            reg = <0>;
+            realtek,param =
+                    <0x01 0xac8c>,
+                    <0x06 0x0017>,

First, this is matrix, not uint8 array. Second, 0xac8c is past 16 bits long, not 8. Third, you put some magic register programming to DT.
Please don't. Drop all this from DT.

realtek,param is an uint32-matrx.
I will revised the type.

Thanks,
Stanley

#31 lore raw

Re: [PATCH v3 5/5] dt-bindings: phy: realtek: Add the doc about the Realtek SoC USB 3.0 PHY

Quoted 19 lines · Stanley Chang[昌育德]
Quoted 10 lines
Quoted 10 lines
Documentation/devicetree/bindings/phy/realtek,usb3phy.yaml new file +10 -0
+examples:
+  - |
+    usb_port2_usb3phy: usb-phy@13e10 {
+        compatible = "realtek,rtd1319d-usb3phy", "realtek,usb3phy";
+        reg = <0x13e10 0x4>;
+        #address-cells = <1>;
+        #size-cells = <0>;
+        #phy-cells = <0>;
+
+        phy@0 {
Quoted 8 lines

Documentation/devicetree/bindings/phy/realtek,usb3phy.yaml line 138

Quoted 4 lines
Documentation/devicetree/bindings/phy/realtek,usb3phy.yaml new file +4 -0
+            reg = <0>;
+            realtek,param =
+                    <0x01 0xac8c>,
+                    <0x06 0x0017>,

First, this is matrix, not uint8 array. Second, 0xac8c is past 16 bits long, not 8. Third, you put some magic register programming to DT.
Please don't. Drop all this from DT.

Quoted 2 lines

realtek,param is an uint32-matrx.
I will revised the type.

Drop the property. It is not explained and not justified to be in DT.

Best regards,
Krzysztof

Signature · 3 lines
linux-phy mailing list
[email protected]
https://lists.infradead.org/mailman/listinfo/linux-phy
#32 lore raw

RE: [PATCH v3 5/5] dt-bindings: phy: realtek: Add the doc about the Realtek SoC USB 3.0 PHY

Quoted 4 lines
Quoted 2 lines

realtek,param is an uint32-matrx.
I will revised the type.

Drop the property. It is not explained and not justified to be in DT.

Okay, I try to specify by the compatible.
Thanks,
Stanley