From: Kever Yang <kever.yang@rock-chips.com>
To: Jonas Karlman <jonas@kwiboo.se>, Simon Glass <sjg@chromium.org>,
Philipp Tomsich <philipp.tomsich@vrull.eu>,
Tom Rini <trini@konsulko.com>
Cc: u-boot@lists.denx.de
Subject: Re: [PATCH 10/16] phy: rockchip: usbdp: Find phy-id from the io address
Date: Tue, 7 May 2024 11:34:21 +0800 [thread overview]
Message-ID: <5cecc023-15c4-4c8c-bf64-d4408b2e66b3@rock-chips.com> (raw)
In-Reply-To: <20240504194346.2462489-11-jonas@kwiboo.se>
On 2024/5/5 03:43, Jonas Karlman wrote:
> The upstream Linux kernel driver find the phy-id from the io address.
>
> Change to use a similar method as the U-Boot inno-usb2 phy driver and
> the Linux kernel driver to set correct phy-id.
>
> This is based on the linux-phy next commit 2f70bbddeb45 ("phy: rockchip:
> add usbdp combo phy driver").
>
> Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
Thanks,
- Kever
> ---
> drivers/phy/rockchip/phy-rockchip-usbdp.c | 39 ++++++++++++++++++++---
> 1 file changed, 34 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/phy/rockchip/phy-rockchip-usbdp.c b/drivers/phy/rockchip/phy-rockchip-usbdp.c
> index baf92529348c..8e5821069757 100644
> --- a/drivers/phy/rockchip/phy-rockchip-usbdp.c
> +++ b/drivers/phy/rockchip/phy-rockchip-usbdp.c
> @@ -74,6 +74,8 @@ struct udphy_grf_cfg {
> struct rockchip_udphy;
>
> struct rockchip_udphy_cfg {
> + unsigned int num_phys;
> + unsigned int phy_ids[2];
> /* resets to be requested */
> const char * const *rst_list;
> int num_rsts;
> @@ -640,17 +642,25 @@ int rockchip_u3phy_uboot_init(void)
>
> static int rockchip_udphy_probe(struct udevice *dev)
> {
> - const struct device_node *np = ofnode_to_np(dev_ofnode(dev));
> struct rockchip_udphy *udphy = dev_get_priv(dev);
> const struct rockchip_udphy_cfg *phy_cfgs;
> + unsigned int reg;
> int id, ret;
>
> udphy->dev = dev;
>
> - id = of_alias_get_id(np, "usbdp");
> - if (id < 0)
> - id = 0;
> - udphy->id = id;
> + ret = ofnode_read_u32_index(dev_ofnode(dev), "reg", 0, ®);
> + if (ret) {
> + dev_err(dev, "failed to read reg[0] property\n");
> + return ret;
> + }
> + if (reg == 0 && dev_read_addr_cells(dev) == 2) {
> + ret = ofnode_read_u32_index(dev_ofnode(dev), "reg", 1, ®);
> + if (ret) {
> + dev_err(dev, "failed to read reg[1] property\n");
> + return ret;
> + }
> + }
>
> phy_cfgs = (const struct rockchip_udphy_cfg *)dev_get_driver_data(dev);
> if (!phy_cfgs) {
> @@ -659,6 +669,20 @@ static int rockchip_udphy_probe(struct udevice *dev)
> }
> udphy->cfgs = phy_cfgs;
>
> + /* find the phy-id from the io address */
> + udphy->id = -ENODEV;
> + for (id = 0; id < udphy->cfgs->num_phys; id++) {
> + if (reg == udphy->cfgs->phy_ids[id]) {
> + udphy->id = id;
> + break;
> + }
> + }
> +
> + if (udphy->id < 0) {
> + dev_err(dev, "no matching device found\n");
> + return -ENODEV;
> + }
> +
> ret = regmap_init_mem(dev_ofnode(dev), &udphy->pma_regmap);
> if (ret)
> return ret;
> @@ -838,6 +862,11 @@ static const char * const rk3588_udphy_rst_l[] = {
> };
>
> static const struct rockchip_udphy_cfg rk3588_udphy_cfgs = {
> + .num_phys = 2,
> + .phy_ids = {
> + 0xfed80000,
> + 0xfed90000,
> + },
> .num_rsts = ARRAY_SIZE(rk3588_udphy_rst_l),
> .rst_list = rk3588_udphy_rst_l,
> .grfcfg = {
next prev parent reply other threads:[~2024-05-07 3:34 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-04 19:42 [PATCH 00/16] rockchip: Migrate RK3308, RK3328, RK356x and RK3588 to OF_UPSTREAM Jonas Karlman
2024-05-04 19:42 ` [PATCH 01/16] rockchip: rk3308: Migrate " Jonas Karlman
2024-05-07 3:29 ` Kever Yang
2024-05-04 19:42 ` [PATCH 02/16] rockchip: rk3308: Remove redundant device tree files Jonas Karlman
2024-05-07 3:30 ` Kever Yang
2024-05-04 19:42 ` [PATCH 03/16] rockchip: rk3328: Migrate to OF_UPSTREAM Jonas Karlman
2024-05-07 3:32 ` Kever Yang
2024-05-04 19:42 ` [PATCH 04/16] rockchip: rk3328: Remove redundant device tree files Jonas Karlman
2024-05-07 3:32 ` Kever Yang
2024-05-04 19:42 ` [PATCH 05/16] rockchip: rk3399: Migrate to OF_UPSTREAM Jonas Karlman
2024-05-07 3:33 ` Kever Yang
2024-05-04 19:42 ` [PATCH 06/16] rockchip: rk3399: Remove redundant device tree files Jonas Karlman
2024-05-07 3:33 ` Kever Yang
2024-05-04 19:42 ` [PATCH 07/16] rockchip: rk356x: Add rk3568-u-boot.dtsi Jonas Karlman
2024-05-07 3:33 ` Kever Yang
2024-05-04 19:43 ` [PATCH 08/16] rockchip: rk356x: Migrate to OF_UPSTREAM Jonas Karlman
2024-05-07 3:33 ` Kever Yang
2024-05-04 19:43 ` [PATCH 09/16] rockchip: rk356x: Remove redundant device tree files Jonas Karlman
2024-05-04 20:51 ` Chris Morgan
2024-05-04 21:15 ` Jonas Karlman
2024-05-07 3:34 ` Kever Yang
2024-05-04 19:43 ` [PATCH 10/16] phy: rockchip: usbdp: Find phy-id from the io address Jonas Karlman
2024-05-07 3:34 ` Kever Yang [this message]
2024-05-04 19:43 ` [PATCH 11/16] phy: rockchip: usbdp: Drop rockchip_u3phy_uboot_init() Jonas Karlman
2024-05-07 3:34 ` Kever Yang
2024-05-04 19:43 ` [PATCH 12/16] phy: rockchip: usbdp: Adopt driver to work with upstream DT Jonas Karlman
2024-05-07 3:34 ` Kever Yang
2024-05-04 19:43 ` [PATCH 13/16] rockchip: rk3588-rock-5b: Drop usb-typec node from u-boot.dtsi Jonas Karlman
2024-05-07 3:34 ` Kever Yang
2024-05-04 19:43 ` [PATCH 14/16] rockchip: rk3588: Update USB3 related nodes in u-boot.dtsi Jonas Karlman
2024-05-07 7:20 ` Kever Yang
2024-05-04 19:43 ` [PATCH 15/16] rockchip: rk3588: Migrate to OF_UPSTREAM Jonas Karlman
2024-05-07 7:20 ` Kever Yang
2024-05-04 19:43 ` [PATCH 16/16] rockchip: rk3588: Remove redundant device tree files Jonas Karlman
2024-05-07 7:19 ` Kever Yang
2024-05-05 2:58 ` [PATCH 00/16] rockchip: Migrate RK3308, RK3328, RK356x and RK3588 to OF_UPSTREAM Dragan Simic
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5cecc023-15c4-4c8c-bf64-d4408b2e66b3@rock-chips.com \
--to=kever.yang@rock-chips.com \
--cc=jonas@kwiboo.se \
--cc=philipp.tomsich@vrull.eu \
--cc=sjg@chromium.org \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox