2023-09-17 21:50:48

by Abdel Alkuor

[permalink] [raw]
Subject: [PATCH v5 05/15] USB: typec: Check for EEPROM present

From: Abdel Alkuor <[email protected]>

When an EEPROM is present, tps25750 loads the binary configuration from
EEPROM. Hence, all we need to do is wait for the device to switch to APP
mode

Signed-off-by: Abdel Alkuor <[email protected]>
---
drivers/usb/typec/tipd/core.c | 13 +++++++++++++
drivers/usb/typec/tipd/tps6598x.h | 3 +++
2 files changed, 16 insertions(+)

diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c
index fea139c72d6d..b3d4b2b5bf5f 100644
--- a/drivers/usb/typec/tipd/core.c
+++ b/drivers/usb/typec/tipd/core.c
@@ -37,6 +37,7 @@
#define TPS_REG_STATUS 0x1a
#define TPS_REG_SYSTEM_CONF 0x28
#define TPS_REG_CTRL_CONF 0x29
+#define TPS_REG_BOOT_STATUS 0x2D
#define TPS_REG_POWER_STATUS 0x3f
#define TPS_REG_RX_IDENTITY_SOP 0x48
#define TPS_REG_DATA_STATUS 0x5f
@@ -897,6 +898,17 @@ static int tps25750_apply_patch(struct tps6598x *tps)
int ret;
unsigned long timeout;
u8 mode;
+ u64 status = 0;
+
+ ret = tps6598x_block_read(tps, TPS_REG_BOOT_STATUS, &status, 5);
+ if (ret)
+ return ret;
+ /*
+ * Nothing to be done if the configuration
+ * is being loaded from EERPOM
+ */
+ if (status & TPS25750_BOOT_STATUS_I2C_EEPROM_PRESENT)
+ goto wait_for_app;

ret = tps25750_start_patch_burst_mode(tps);
if (ret) {
@@ -908,6 +920,7 @@ static int tps25750_apply_patch(struct tps6598x *tps)
if (ret)
return ret;

+wait_for_app:
timeout = jiffies + msecs_to_jiffies(1000);

do {
diff --git a/drivers/usb/typec/tipd/tps6598x.h b/drivers/usb/typec/tipd/tps6598x.h
index 527857549d69..5e942c089c27 100644
--- a/drivers/usb/typec/tipd/tps6598x.h
+++ b/drivers/usb/typec/tipd/tps6598x.h
@@ -199,4 +199,7 @@
#define TPS_DATA_STATUS_DP_SPEC_PIN_ASSIGNMENT_A BIT(2)
#define TPS_DATA_STATUS_DP_SPEC_PIN_ASSIGNMENT_B (BIT(2) | BIT(1))

+/* BOOT STATUS REG*/
+#define TPS25750_BOOT_STATUS_I2C_EEPROM_PRESENT BIT(3)
+
#endif /* __TPS6598X_H__ */
--
2.34.1


2023-09-18 20:17:40

by Heikki Krogerus

[permalink] [raw]
Subject: Re: [PATCH v5 05/15] USB: typec: Check for EEPROM present

On Sun, Sep 17, 2023 at 11:26:29AM -0400, Abdel Alkuor wrote:
> From: Abdel Alkuor <[email protected]>
>
> When an EEPROM is present, tps25750 loads the binary configuration from
> EEPROM. Hence, all we need to do is wait for the device to switch to APP
> mode
>
> Signed-off-by: Abdel Alkuor <[email protected]>
> ---
> drivers/usb/typec/tipd/core.c | 13 +++++++++++++
> drivers/usb/typec/tipd/tps6598x.h | 3 +++
> 2 files changed, 16 insertions(+)
>
> diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c
> index fea139c72d6d..b3d4b2b5bf5f 100644
> --- a/drivers/usb/typec/tipd/core.c
> +++ b/drivers/usb/typec/tipd/core.c
> @@ -37,6 +37,7 @@
> #define TPS_REG_STATUS 0x1a
> #define TPS_REG_SYSTEM_CONF 0x28
> #define TPS_REG_CTRL_CONF 0x29
> +#define TPS_REG_BOOT_STATUS 0x2D
> #define TPS_REG_POWER_STATUS 0x3f
> #define TPS_REG_RX_IDENTITY_SOP 0x48
> #define TPS_REG_DATA_STATUS 0x5f
> @@ -897,6 +898,17 @@ static int tps25750_apply_patch(struct tps6598x *tps)
> int ret;
> unsigned long timeout;
> u8 mode;
> + u64 status = 0;
> +
> + ret = tps6598x_block_read(tps, TPS_REG_BOOT_STATUS, &status, 5);
> + if (ret)
> + return ret;
> + /*
> + * Nothing to be done if the configuration
> + * is being loaded from EERPOM
> + */
> + if (status & TPS25750_BOOT_STATUS_I2C_EEPROM_PRESENT)
> + goto wait_for_app;
>
> ret = tps25750_start_patch_burst_mode(tps);
> if (ret) {
> @@ -908,6 +920,7 @@ static int tps25750_apply_patch(struct tps6598x *tps)
> if (ret)
> return ret;
>
> +wait_for_app:
> timeout = jiffies + msecs_to_jiffies(1000);
>
> do {
> diff --git a/drivers/usb/typec/tipd/tps6598x.h b/drivers/usb/typec/tipd/tps6598x.h
> index 527857549d69..5e942c089c27 100644
> --- a/drivers/usb/typec/tipd/tps6598x.h
> +++ b/drivers/usb/typec/tipd/tps6598x.h
> @@ -199,4 +199,7 @@
> #define TPS_DATA_STATUS_DP_SPEC_PIN_ASSIGNMENT_A BIT(2)
> #define TPS_DATA_STATUS_DP_SPEC_PIN_ASSIGNMENT_B (BIT(2) | BIT(1))
>
> +/* BOOT STATUS REG*/
> +#define TPS25750_BOOT_STATUS_I2C_EEPROM_PRESENT BIT(3)

That's not TPS25750 specific bit, so please rename that to
TPS_BOOT_STATUS_I2C_EEPROM_PRESENT

thanks,

--
heikki

2023-09-21 04:42:32

by Abdel Alkuor

[permalink] [raw]
Subject: Re: [PATCH v5 05/15] USB: typec: Check for EEPROM present

On Mon, Sep 18, 2023 at 03:45:04PM +0300, Heikki Krogerus wrote:
> On Sun, Sep 17, 2023 at 11:26:29AM -0400, Abdel Alkuor wrote:
> > From: Abdel Alkuor <[email protected]>
> >
> > When an EEPROM is present, tps25750 loads the binary configuration from
> > EEPROM. Hence, all we need to do is wait for the device to switch to APP
> > mode
> >
> > Signed-off-by: Abdel Alkuor <[email protected]>
> > ---
> > drivers/usb/typec/tipd/core.c | 13 +++++++++++++
> > drivers/usb/typec/tipd/tps6598x.h | 3 +++
> > 2 files changed, 16 insertions(+)
> >
> > diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c
> > index fea139c72d6d..b3d4b2b5bf5f 100644
> > --- a/drivers/usb/typec/tipd/core.c
> > +++ b/drivers/usb/typec/tipd/core.c
> > @@ -37,6 +37,7 @@
> > #define TPS_REG_STATUS 0x1a
> > #define TPS_REG_SYSTEM_CONF 0x28
> > #define TPS_REG_CTRL_CONF 0x29
> > +#define TPS_REG_BOOT_STATUS 0x2D
> > #define TPS_REG_POWER_STATUS 0x3f
> > #define TPS_REG_RX_IDENTITY_SOP 0x48
> > #define TPS_REG_DATA_STATUS 0x5f
> > @@ -897,6 +898,17 @@ static int tps25750_apply_patch(struct tps6598x *tps)
> > int ret;
> > unsigned long timeout;
> > u8 mode;
> > + u64 status = 0;
> > +
> > + ret = tps6598x_block_read(tps, TPS_REG_BOOT_STATUS, &status, 5);
> > + if (ret)
> > + return ret;
> > + /*
> > + * Nothing to be done if the configuration
> > + * is being loaded from EERPOM
> > + */
> > + if (status & TPS25750_BOOT_STATUS_I2C_EEPROM_PRESENT)
> > + goto wait_for_app;
> >
> > ret = tps25750_start_patch_burst_mode(tps);
> > if (ret) {
> > @@ -908,6 +920,7 @@ static int tps25750_apply_patch(struct tps6598x *tps)
> > if (ret)
> > return ret;
> >
> > +wait_for_app:
> > timeout = jiffies + msecs_to_jiffies(1000);
> >
> > do {
> > diff --git a/drivers/usb/typec/tipd/tps6598x.h b/drivers/usb/typec/tipd/tps6598x.h
> > index 527857549d69..5e942c089c27 100644
> > --- a/drivers/usb/typec/tipd/tps6598x.h
> > +++ b/drivers/usb/typec/tipd/tps6598x.h
> > @@ -199,4 +199,7 @@
> > #define TPS_DATA_STATUS_DP_SPEC_PIN_ASSIGNMENT_A BIT(2)
> > #define TPS_DATA_STATUS_DP_SPEC_PIN_ASSIGNMENT_B (BIT(2) | BIT(1))
> >
> > +/* BOOT STATUS REG*/
> > +#define TPS25750_BOOT_STATUS_I2C_EEPROM_PRESENT BIT(3)
>
> That's not TPS25750 specific bit, so please rename that to
> TPS_BOOT_STATUS_I2C_EEPROM_PRESENT
>
I will fix it in v6.
> thanks,
>
> --
> heikki

Thanks,
Abdel