phy: some updates
Subsystems (7)
Sascha Hauer
maintainercover phy: some updates
Collect all phy devices in their own class and implement of_phy_simple_xlate().
---
Sascha Hauer (3):
phy: make of_phandle_args constant
phy: put phy devices in class
phy: add of_phy_simple_xlate()
drivers/phy/freescale/phy-fsl-imx8mq-usb.c | 2 +- drivers/phy/phy-core.c | 34 ++++++++++++++++++++-- drivers/phy/phy-stm32-usbphyc.c | 2 +- drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 2 +- drivers/phy/rockchip/phy-rockchip-naneng-combphy.c | 2 +- drivers/phy/rockchip/phy-rockchip-snps-pcie3.c | 2 +- drivers/phy/usb-nop-xceiv.c | 2 +- drivers/pinctrl/pinctrl-tegra-xusb.c | 2 +- drivers/usb/imx/imx-usb-phy.c | 2 +- include/linux/phy/phy.h | 7 +++-- 10 files changed, 44 insertions(+), 13 deletions(-)
---
base-commit: e55e492573e33823f25935ee00fe7fa7bf2c5c90
change-id: 20241025-phy-class-8918df8448e1
Best regards,
Signature · 1 line
Sascha Hauer <[email protected]>
Sascha Hauer
maintainerPATCH 1/3 phy: make of_phandle_args constant
Like done in Linux the of_xlate() args argument should be constant.
--- drivers/phy/freescale/phy-fsl-imx8mq-usb.c | 2 +- drivers/phy/phy-core.c | 2 +- drivers/phy/phy-stm32-usbphyc.c | 2 +- drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 2 +- drivers/phy/rockchip/phy-rockchip-naneng-combphy.c | 2 +- drivers/phy/rockchip/phy-rockchip-snps-pcie3.c | 2 +- drivers/phy/usb-nop-xceiv.c | 2 +- drivers/pinctrl/pinctrl-tegra-xusb.c | 2 +- drivers/usb/imx/imx-usb-phy.c | 2 +- include/linux/phy/phy.h | 4 ++-- 10 files changed, 11 insertions(+), 11 deletions(-)
drivers/phy/freescale/phy-fsl-imx8mq-usb.c +1 -1
@@ -144,7 +144,7 @@ static const struct of_device_id imx8mq_usb_phy_of_match[] = {MODULE_DEVICE_TABLE (of, imx8mq_usb_phy_of_match);static struct phy *imx8mq_usb_phy_xlate (struct device *dev, -struct of_phandle_args *args) +const struct of_phandle_args *args) {struct imx8mq_usb_phy *imx_phy = dev->priv;
drivers/phy/phy-core.c +1 -1
@@ -81,7 +81,7 @@ struct phy *phy_create(struct device *dev, struct device_node *node,*/ struct phy_provider *__of_phy_provider_register (struct device *dev,struct phy * (*of_xlate)(struct device *dev, -struct of_phandle_args *args)) +const struct of_phandle_args *args)) {struct phy_provider *phy_provider;
drivers/phy/phy-stm32-usbphyc.c +1 -1
@@ -567,7 +567,7 @@ static void stm32_usbphyc_switch_setup(struct stm32_usbphyc *usbphyc, }static struct phy *stm32_usbphyc_of_xlate (struct device *dev, -struct of_phandle_args *args) +const struct of_phandle_args *args) {struct stm32_usbphyc *usbphyc = dev->priv;struct stm32_usbphyc_phy *usbphyc_phy =NULL ;
drivers/phy/rockchip/phy-rockchip-inno-usb2.c +1 -1
@@ -257,7 +257,7 @@ static int rockchip_usb2phy_power_off(struct phy *phy) }static struct phy *rockchip_usb2phy_of_xlate (struct device *dev, -struct of_phandle_args *args) +const struct of_phandle_args *args) {struct rockchip_usb2phy *rphy = dev->priv;struct device_node *phynode = args->np;
drivers/phy/rockchip/phy-rockchip-naneng-combphy.c +1 -1
@@ -270,7 +270,7 @@ static const struct phy_ops rochchip_combphy_ops = { };static struct phy *rockchip_combphy_xlate (struct device *dev, -struct of_phandle_args *args) +const struct of_phandle_args *args) {struct rockchip_combphy_priv *priv = dev->priv;
drivers/phy/rockchip/phy-rockchip-snps-pcie3.c +1 -1
@@ -209,7 +209,7 @@ static const struct phy_ops rochchip_p3phy_ops = { };static struct phy *rockchip_p3phy_xlate (struct device *dev, -struct of_phandle_args *args) +const struct of_phandle_args *args) {struct rockchip_p3phy_priv *priv = dev->priv;
drivers/phy/usb-nop-xceiv.c +1 -1
@@ -25,7 +25,7 @@ struct nop_usbphy { };static struct phy *nop_usbphy_xlate (struct device *dev, -struct of_phandle_args *args) +const struct of_phandle_args *args) {struct nop_usbphy *nopphy = dev->priv;
drivers/pinctrl/pinctrl-tegra-xusb.c +1 -1
@@ -269,7 +269,7 @@ static const struct phy_ops sata_phy_ops = { };static struct phy *tegra_xusb_padctl_xlate (struct device *dev, -struct of_phandle_args *args) +const struct of_phandle_args *args) {struct tegra_xusb_padctl *padctl = dev->priv;unsigned int index = args->args[0 ];
drivers/usb/imx/imx-usb-phy.c +1 -1
@@ -109,7 +109,7 @@ static int imx_usbphy_notify_disconnect(struct usb_phy *phy, }static struct phy *imx_usbphy_xlate (struct device *dev, -struct of_phandle_args *args) +const struct of_phandle_args *args) {struct imx_usbphy *imxphy = dev->priv;
include/linux/phy/phy.h +2 -2
@@ -102,7 +102,7 @@ struct phy_provider {struct device *dev;struct list_head list;struct phy * (*of_xlate)(struct device *dev, -struct of_phandle_args *args); +const struct of_phandle_args *args); };/**
@@ -174,7 +174,7 @@ struct phy *phy_create(struct device *dev, struct device_node *node,void phy_destroy (struct phy *phy);struct phy_provider *__of_phy_provider_register (struct device *dev,struct phy * (*of_xlate)(struct device *dev, -struct of_phandle_args *args)); +const struct of_phandle_args *args));void of_phy_provider_unregister (struct phy_provider *phy_provider);struct usb_phy *phy_to_usbphy (struct phy *phy);struct phy *phy_get_by_index (struct device *dev,int index);
Signature · 1 line
2.39.5
Sascha Hauer
maintainerPATCH 2/3 phy: put phy devices in class
In reply to Sascha HauerCollect all phy devices in their own class. Let's us list the phy devices in the class command and gives us an iterator over phy devices for free.
--- drivers/phy/phy-core.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/phy/phy-core.c +5 -2
@@ -16,6 +16,10 @@static LIST_HEAD (phy_provider_list);static int phy_ida; +#define for_each_phy (p) list_for_each_entry(p, &phy_class.devices, dev.class_list) + +DEFINE_DEV_CLASS (phy_class,"phy" ); +/** * phy_create() - create a new phy * @dev: device that is creating the new phy
@@ -40,7 +44,6 @@ struct phy *phy_create(struct device *dev, struct device_node *node, id = phy_ida++; -dev_set_name (&phy->dev,"phy" ); phy->dev.id = id; phy->dev.parent = dev; phy->dev.of_node = node ?: dev->of_node;
@@ -57,7 +60,7 @@ struct phy *phy_create(struct device *dev, struct device_node *node, phy->pwr =NULL ; } - ret =register_device (&phy->dev); + ret =class_register_device (&phy_class, &phy->dev,"phy" );if (ret) goto free_ida;
Signature · 1 line
2.39.5
Sascha Hauer
maintainerPATCH 3/3 phy: add of_phy_simple_xlate()
In reply to Sascha Hauerof_phy_provider_register() needs a of_xlate function. For simple one-phy-per-device-node type phys of_phy_simple_xlate() can be used.
--- drivers/phy/phy-core.c | 25 +++++++++++++++++++++++++ include/linux/phy/phy.h | 3 +++ 2 files changed, 28 insertions(+)
drivers/phy/phy-core.c +25 -0
@@ -254,6 +254,31 @@ static struct phy_provider *of_phy_provider_lookup(struct device_node *node)return ERR_PTR (-EPROBE_DEFER ); } +/** +* of_phy_simple_xlate() - returns the phy instance from phy provider +* @dev: the PHY provider device +* @args: of_phandle_args (not used here) +* +* Intended to be used by phy provider for the common case where #phy-cells is +* 0. For other cases where #phy-cells is greater than '0', the phy provider +* should provide a custom of_xlate function that reads the *args* and returns +* the appropriate phy. +*/ +struct phy *of_phy_simple_xlate (struct device *dev, +const struct of_phandle_args *args) +{ +struct phy *phy; + +for_each_phy (phy) { +if (args->np != phy->dev.of_node) +continue ; + +return phy; + } + +return ERR_PTR (-ENODEV ); +} +/** * _of_phy_get() - lookup and obtain a reference to a phy by phandle * @np: device_node for which to get the phy
include/linux/phy/phy.h +3 -0
@@ -147,6 +147,9 @@ static inline void *phy_get_drvdata(struct phy *phy)return phy->dev.priv; } +struct phy *of_phy_simple_xlate (struct device *dev, +const struct of_phandle_args *args); +#if IS_ENABLED (CONFIG_GENERIC_PHY )int phy_init (struct phy *phy);int phy_exit (struct phy *phy);
Signature · 1 line
2.39.5
Quoted 4 lines · Sascha Hauer
Collect all phy devices in their own class and implement
of_phy_simple_xlate().
Applied, thanks!
[1/3] phy: make of_phandle_args constant
https://git.pengutronix.de/cgit/barebox/commit/?id=b3d258e440d5 (link may not be stable)
[2/3] phy: put phy devices in class
https://git.pengutronix.de/cgit/barebox/commit/?id=a55e60429963 (link may not be stable)
[3/3] phy: add of_phy_simple_xlate()
https://git.pengutronix.de/cgit/barebox/commit/?id=1c393f5556a3 (link may not be stable)
Best regards,
Signature · 1 line
Sascha Hauer <[email protected]>