2023-09-17 17:46:19

by Abdel Alkuor

[permalink] [raw]
Subject: [PATCH v5 15/15] USB: typec: Do not check VID for tps25750

From: Abdel Alkuor <[email protected]>

tps25750 doesn't have VID register, check VID for PD controllers
other than tps25750

Signed-off-by: Abdel Alkuor <[email protected]>
---
drivers/usb/typec/tipd/core.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c
index 326c23bfa8e6..c1399e12a170 100644
--- a/drivers/usb/typec/tipd/core.c
+++ b/drivers/usb/typec/tipd/core.c
@@ -1142,10 +1142,6 @@ static int tps6598x_probe(struct i2c_client *client)
if (IS_ERR(tps->regmap))
return PTR_ERR(tps->regmap);

- ret = tps6598x_read32(tps, TPS_REG_VID, &vid);
- if (ret < 0 || !vid)
- return -ENODEV;
-
/*
* Checking can the adapter handle SMBus protocol. If it can not, the
* driver needs to take care of block reads separately.
@@ -1176,6 +1172,12 @@ static int tps6598x_probe(struct i2c_client *client)

tps->irq_handler = irq_handler;

+ if (!tps->is_tps25750) {
+ ret = tps6598x_read32(tps, TPS_REG_VID, &vid);
+ if (ret < 0 || !vid)
+ return -ENODEV;
+ }
+
/* Make sure the controller has application firmware running */
ret = tps6598x_check_mode(tps, &mode);
if (ret)
--
2.34.1


2023-09-19 01:06:44

by Heikki Krogerus

[permalink] [raw]
Subject: Re: [PATCH v5 15/15] USB: typec: Do not check VID for tps25750

Hi,

On Sun, Sep 17, 2023 at 11:26:39AM -0400, Abdel Alkuor wrote:
> From: Abdel Alkuor <[email protected]>
>
> tps25750 doesn't have VID register, check VID for PD controllers
> other than tps25750
>
> Signed-off-by: Abdel Alkuor <[email protected]>
> ---
> drivers/usb/typec/tipd/core.c | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c
> index 326c23bfa8e6..c1399e12a170 100644
> --- a/drivers/usb/typec/tipd/core.c
> +++ b/drivers/usb/typec/tipd/core.c
> @@ -1142,10 +1142,6 @@ static int tps6598x_probe(struct i2c_client *client)
> if (IS_ERR(tps->regmap))
> return PTR_ERR(tps->regmap);
>
> - ret = tps6598x_read32(tps, TPS_REG_VID, &vid);
> - if (ret < 0 || !vid)
> - return -ENODEV;
> -
> /*
> * Checking can the adapter handle SMBus protocol. If it can not, the
> * driver needs to take care of block reads separately.
> @@ -1176,6 +1172,12 @@ static int tps6598x_probe(struct i2c_client *client)
>
> tps->irq_handler = irq_handler;
>
> + if (!tps->is_tps25750) {
> + ret = tps6598x_read32(tps, TPS_REG_VID, &vid);
> + if (ret < 0 || !vid)
> + return -ENODEV;
> + }

You need to do this at the same time you enable tps25750, so I'm
guessing in patch 4.

You are also changing the execution order just because of that
is_tps25750. Instead you need to make sure you have that flag set as
soon as possible in the first place, so right after "tps" is
allocated:

mutex_init(&tps->lock);
tps->dev = &client->dev;
+ tps->is_tps25750 = of_device_is_compatible(np, "ti,tps25750");

tps->regmap = devm_regmap_init_i2c(client, &tps6598x_regmap_config);
if (IS_ERR(tps->regmap))


thanks,

--
heikki

2023-09-20 18:15:36

by Abdel Alkuor

[permalink] [raw]
Subject: Re: [PATCH v5 15/15] USB: typec: Do not check VID for tps25750

On Mon, Sep 18, 2023 at 04:29:43PM +0300, Heikki Krogerus wrote:
> Hi,
>
> On Sun, Sep 17, 2023 at 11:26:39AM -0400, Abdel Alkuor wrote:
> > From: Abdel Alkuor <[email protected]>
> >
> > tps25750 doesn't have VID register, check VID for PD controllers
> > other than tps25750
> >
> > Signed-off-by: Abdel Alkuor <[email protected]>
> > ---
> > drivers/usb/typec/tipd/core.c | 10 ++++++----
> > 1 file changed, 6 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c
> > index 326c23bfa8e6..c1399e12a170 100644
> > --- a/drivers/usb/typec/tipd/core.c
> > +++ b/drivers/usb/typec/tipd/core.c
> > @@ -1142,10 +1142,6 @@ static int tps6598x_probe(struct i2c_client *client)
> > if (IS_ERR(tps->regmap))
> > return PTR_ERR(tps->regmap);
> >
> > - ret = tps6598x_read32(tps, TPS_REG_VID, &vid);
> > - if (ret < 0 || !vid)
> > - return -ENODEV;
> > -
> > /*
> > * Checking can the adapter handle SMBus protocol. If it can not, the
> > * driver needs to take care of block reads separately.
> > @@ -1176,6 +1172,12 @@ static int tps6598x_probe(struct i2c_client *client)
> >
> > tps->irq_handler = irq_handler;
> >
> > + if (!tps->is_tps25750) {
> > + ret = tps6598x_read32(tps, TPS_REG_VID, &vid);
> > + if (ret < 0 || !vid)
> > + return -ENODEV;
> > + }
>
> You need to do this at the same time you enable tps25750, so I'm
> guessing in patch 4.
>
> You are also changing the execution order just because of that
> is_tps25750. Instead you need to make sure you have that flag set as
> soon as possible in the first place, so right after "tps" is
> allocated:
>
Good point. I will move the check in patch 4 and check it after allocating
tps.
> mutex_init(&tps->lock);
> tps->dev = &client->dev;
> + tps->is_tps25750 = of_device_is_compatible(np, "ti,tps25750");
>
> tps->regmap = devm_regmap_init_i2c(client, &tps6598x_regmap_config);
> if (IS_ERR(tps->regmap))
>
>
> thanks,
>
> --
> heikki
Thanks,
Abdel