[PATCH 12/16] phy: rockchip: usbdp: Adopt driver to work with upstream DT
Kever Yang
kever.yang at rock-chips.com
Tue May 7 05:34:40 CEST 2024
On 2024/5/5 03:43, Jonas Karlman wrote:
> The upstream DT binding added in linux-phy next commit a75d8056e9fe
> ("dt-bindings: phy: add rockchip usbdp combo phy document") does not
> define subnodes for the type of PHY, instead it is expected that phandle
> args are used for setting the type of the PHY.
>
> phys = <&usbdp_phy0 PHY_TYPE_USB3>
>
> Adopt the usbdp phy driver to work with upstream DT binding targeted for
> Linux kernel v6.10.
>
> Signed-off-by: Jonas Karlman <jonas at kwiboo.se>
Reviewed-by: Kever Yang <kever.yang at rock-chips.com>
Thanks,
- Kever
> ---
> drivers/phy/rockchip/phy-rockchip-usbdp.c | 63 ++++++-----------------
> 1 file changed, 17 insertions(+), 46 deletions(-)
>
> diff --git a/drivers/phy/rockchip/phy-rockchip-usbdp.c b/drivers/phy/rockchip/phy-rockchip-usbdp.c
> index bf0fb6d8288f..18e76402799b 100644
> --- a/drivers/phy/rockchip/phy-rockchip-usbdp.c
> +++ b/drivers/phy/rockchip/phy-rockchip-usbdp.c
> @@ -21,7 +21,7 @@
> #include <reset.h>
> #include <syscon.h>
> #include <asm/arch-rockchip/clock.h>
> -
> +#include <dt-bindings/phy/phy.h>
> #include <linux/usb/phy-rockchip-usbdp.h>
>
> #define BIT_WRITEABLE_SHIFT 16
> @@ -585,10 +585,21 @@ static int udphy_power_off(struct rockchip_udphy *udphy, u8 mode)
> return 0;
> }
>
> +static int rockchip_u3phy_of_xlate(struct phy *phy,
> + struct ofnode_phandle_args *args)
> +{
> + if (args->args_count == 0)
> + return -EINVAL;
> +
> + if (args->args[0] != PHY_TYPE_USB3)
> + return -EINVAL;
> +
> + return 0;
> +}
> +
> static int rockchip_u3phy_init(struct phy *phy)
> {
> - struct udevice *parent = phy->dev->parent;
> - struct rockchip_udphy *udphy = dev_get_priv(parent);
> + struct rockchip_udphy *udphy = dev_get_priv(phy->dev);
>
> /* DP only or high-speed, disable U3 port */
> if (!(udphy->mode & UDPHY_MODE_USB) || udphy->hs) {
> @@ -601,8 +612,7 @@ static int rockchip_u3phy_init(struct phy *phy)
>
> static int rockchip_u3phy_exit(struct phy *phy)
> {
> - struct udevice *parent = phy->dev->parent;
> - struct rockchip_udphy *udphy = dev_get_priv(parent);
> + struct rockchip_udphy *udphy = dev_get_priv(phy->dev);
>
> /* DP only or high-speed */
> if (!(udphy->mode & UDPHY_MODE_USB) || udphy->hs)
> @@ -612,6 +622,7 @@ static int rockchip_u3phy_exit(struct phy *phy)
> }
>
> static const struct phy_ops rockchip_u3phy_ops = {
> + .of_xlate = rockchip_u3phy_of_xlate,
> .init = rockchip_u3phy_init,
> .exit = rockchip_u3phy_exit,
> };
> @@ -671,40 +682,6 @@ static int rockchip_udphy_probe(struct udevice *dev)
> return 0;
> }
>
> -static int rockchip_udphy_bind(struct udevice *parent)
> -{
> - struct udevice *child;
> - ofnode subnode;
> - const char *node_name;
> - int ret;
> -
> - dev_for_each_subnode(subnode, parent) {
> - if (!ofnode_valid(subnode)) {
> - printf("%s: no subnode for %s", __func__, parent->name);
> - return -ENXIO;
> - }
> -
> - node_name = ofnode_get_name(subnode);
> - debug("%s: subnode %s\n", __func__, node_name);
> -
> - /* if there is no match, continue */
> - if (strcasecmp(node_name, "usb3-port"))
> - continue;
> -
> - /* node name is usb3-port */
> - ret = device_bind_driver_to_node(parent,
> - "rockchip_udphy_u3_port",
> - node_name, subnode, &child);
> - if (ret) {
> - printf("%s: '%s' cannot bind its driver\n",
> - __func__, node_name);
> - return ret;
> - }
> - }
> -
> - return 0;
> -}
> -
> static int rk3588_udphy_refclk_set(struct rockchip_udphy *udphy)
> {
> /* configure phy reference clock */
> @@ -869,17 +846,11 @@ static const struct udevice_id rockchip_udphy_dt_match[] = {
> { /* sentinel */ }
> };
>
> -U_BOOT_DRIVER(rockchip_udphy_u3_port) = {
> - .name = "rockchip_udphy_u3_port",
> - .id = UCLASS_PHY,
> - .ops = &rockchip_u3phy_ops,
> -};
> -
> U_BOOT_DRIVER(rockchip_udphy) = {
> .name = "rockchip_udphy",
> .id = UCLASS_PHY,
> .of_match = rockchip_udphy_dt_match,
> .probe = rockchip_udphy_probe,
> - .bind = rockchip_udphy_bind,
> + .ops = &rockchip_u3phy_ops,
> .priv_auto = sizeof(struct rockchip_udphy),
> };
More information about the U-Boot
mailing list