PMIC: TI: TPS65903X errata (SLIA087) code
PATCH 1/1 PMIC: TI: TPS65903X errata (SLIA087) code
This patch adds code, which comply with TPS65903X errata pseudocode described in SLIA087 - "Guide to Using the GPADC in TPS65903x and TPS6591x Devices".
It is enabled by proper Kconfig option, when TI's palmas PMIC support is added.
The TI's e2e thread with test procedure description:
https://e2e.ti.com/support/power_management/pmu/f/200/p/579649/2130910#2130910
--- drivers/power/palmas.c | 110 +++++++++++++++++++++++++++++++++++++++++++++ drivers/power/pmic/Kconfig | 8 ++++ include/palmas.h | 21 +++++++++ 3 files changed, 139 insertions(+)
drivers/power/palmas.c +110 -0
@@ -23,6 +23,116 @@ void palmas_init_settings(void)#endif } +#ifdef CONFIG_PMIC_TPS65903X_ERRATA +/* +* This errata code follows the "Workaround for known issues" +* -> SLIA087 – May 2015 (point 3.) +*/ +static int tps65903x_errata_dummy_GPADC_conv (void ) +{ +int ret, timeout =100 ; +u16 temp =0 ; +u8 val; + +/* Unmask interrupt for GPADC_EOC_SW */ + ret =palmas_i2c_read_u8 (TPS65903X_CHIP_P2 ,INT3_MASK , &val); + val &= ~INT3_MASK_GPADC_EOC_SW ; + ret |=palmas_i2c_write_u8 (TPS65903X_CHIP_P2 ,INT3_MASK , val); + +/* Enable software conversion and select channel 12 */ + val =GPADC_SW_SELECT_CONV_EN |0xC ; + ret |=palmas_i2c_write_u8 (TPS65903X_CHIP_P2 ,GPADC_SW_SELECT , val); + + val |=GPADC_SW_SELECT_ST_CONV0 ; + ret |=palmas_i2c_write_u8 (TPS65903X_CHIP_P2 ,GPADC_SW_SELECT , val); + +/* Wait for any pending conversion to complete */ +do { + val =0 ; + ret |=palmas_i2c_read_u8 (TPS65903X_CHIP_P2 , +GPADC_STATUS , &val); +udelay (10 ); + }while (!val && timeout--); + +/* The "dummy" GPADC conversion is finished - read results */ + ret |=palmas_i2c_read_u8 (TPS65903X_CHIP_P2 ,GPADC_SW_CONV0_LSB , &val); + temp = val; + ret |=palmas_i2c_read_u8 (TPS65903X_CHIP_P2 ,GPADC_SW_CONV0_MSB , &val); + temp |= (val <<8 ); + +/* +* Temperature conversion equation for tps65903x +* +* TEMP = ( ( ( ADC_Read_Data / 2^12) * 1.25 ) – 0.753V ) / 2.64 mV +* +* It might also happen that value 0x0 will be read - this is the +* case when the "dummy" read is needed to have consecutive reads +* from GPADC correct. +*/ +debug ("%s: on-die temperature (from channel 12): 0x%x\n" , + __func__, temp); + +return ret; +} + +static int tps65903x_errata_locked_GPADC (void ) +{ +int ret, timeout =100 ; +u8 val; + + ret =palmas_i2c_read_u8 (TPS65903X_CHIP_P2 ,GPADC_STUCK , &val); +if (val &GPADC_STUCK_STUCK ) { +debug ("%s: Recovering from Locked GPADC State!\n" , __func__); + +/* Make sure GPADC AUTO mode is disabled */ + ret |=palmas_i2c_write_u8 (TPS65903X_CHIP_P2 ,GPADC_AUTO_CTRL , +0x00 ); + +/* Enable flush operation */ + ret |=palmas_i2c_write_u8 (TPS65903X_CHIP_P2 ,GPADC_FLUSH_EN , +GPADC_FLUSH_EN_FLUSH_EN ); + +/* Start the flush operation */ + ret |=palmas_i2c_write_u8 (TPS65903X_CHIP_P2 ,GPADC_FLUSH , +GPADC_FLUSH_FLUSH ); + +/* Wait for flush operation to complete */ +do { + val =0 ; + ret |=palmas_i2c_read_u8 (TPS65903X_CHIP_P2 , +GPADC_STUCK , &val); +udelay (10 ); + }while ((val &GPADC_STUCK_STUCK ) && timeout--); + + ret |=palmas_i2c_write_u8 (TPS65903X_CHIP_P2 ,GPADC_FLUSH_EN , +0x00 ); + ret |=palmas_i2c_write_u8 (TPS65903X_CHIP_P2 ,GPADC_FLUSH , +0x00 ); + } + +return ret; +} + +int tps65903x_errata (void ) +{ +int ret; + +debug ("%s:\n" , __func__); + + ret =tps65903x_errata_dummy_GPADC_conv (); +if (ret) { +error ("tps65903x errata - dummy GPADC conversion failed!" ); +return ret; + } + + ret =tps65903x_errata_locked_GPADC (); +if (ret) +error ("tps65903x errata - locked GPADC failed!" ); + +return ret; +} +#endif +int palmas_mmc1_poweron_ldo (void ) {u8 val =0 ;
drivers/power/pmic/Kconfig +8 -0
@@ -151,6 +151,14 @@ config PMIC_PALMAS The PALMAS is a PMIC containing several LDOs, SMPS. This driver binds the pmic children. +config PMIC_TPS65903X_ERRATA + bool "Enable TPS65903X errata (SLIA087)" + depends on PMIC_PALMAS + ---help--- + Enable code providing errata (software workarounds for known issues) + for TPS65903X series of PMIC devices according to SLIA87 document + (Guide to Using the GPADC in TPS65903x and TPS6591x Devices). + config PMIC_LP873X bool "Enable driver for Texas Instruments LP873X PMIC" depends on DM_PMIC
include/palmas.h +21 -0
@@ -17,6 +17,7 @@/* TPS659038/39 */ #define TPS65903X_CHIP_P1 0x58/* Page 1 */ +#define TPS65903X_CHIP_P2 0x59/* Page 2 */ /* Page 1 registers (0x1XY translates to page 1, reg addr 0xXY): */
@@ -114,6 +115,25 @@/* Bit definition for SWOFF_COLDRST */ #define SWOFF_COLDRST_RESET_IN (1 << 3) +/* GPADC - page 2 */ +#define GPADC_FLUSH 0xC2 +#define GPADC_FLUSH_FLUSH (1 << 0) +#define GPADC_AUTO_CTRL 0xC3 +#define GPADC_STATUS 0xC4 +#define GPADC_FLUSH_EN 0xC5 +#define GPADC_FLUSH_EN_FLUSH_EN (1 << 7) +#define GPADC_STUCK 0xC7 +#define GPADC_STUCK_STUCK (1 << 4) +#define GPADC_SW_SELECT 0xCD +#define GPADC_SW_SELECT_CONV_EN (1 << 7) +#define GPADC_SW_SELECT_ST_CONV0 (1 << 4) +#define GPADC_SW_CONV0_LSB 0xCE +#define GPADC_SW_CONV0_MSB 0xCF + +/* INTx - page 2 */ +#define INT3_MASK 0x1B +#define INT3_MASK_GPADC_EOC_SW (1 << 2) +/* * Functions to read and write from TPS659038/TWL6035/TWL6037 * or other Palmas family of TI PMICs
@@ -134,5 +154,6 @@ int twl603x_mmc1_set_ldo9(u8 vsel);int twl603x_audio_power (u8 on);int twl603x_enable_bb_charge (u8 bb_fields);int palmas_enable_ss_ldo (void ); +int tps65903x_errata (void );#endif /* PALMAS_H */
Signature · 1 line
2.1.4
PATCH 1/1 PMIC: TI: TPS65903X errata (SLIA087) code
Quoted 11 lines · Lukasz Majewski
This patch adds code, which comply with TPS65903X errata pseudocode described in SLIA087 - "Guide to Using the GPADC in TPS65903x and TPS6591x Devices".
It is enabled by proper
Kconfigoption, when TI's palmas PMIC support is added.The TI's e2e thread with test procedure description:
https://e2e.ti.com/support/power_management/pmu/f/200/p/579649/2130910#2130910Signed-off-by Lukasz Majewski <[email protected]>
I assume you have hardware that also uses this, so please submit with it as it's not clear to me when the errata function you add should be called. Thanks!
[snip]
drivers/power/pmic/Kconfig config PMIC_PALMAS · line 157
Quoted 4 lines
drivers/power/pmic/Kconfig +4
-0+config PMIC_TPS65903X_ERRATA + bool "Enable TPS65903X errata (SLIA087)" + depends on PMIC_PALMAS + ---help---
We just do 'help' normally and indent the text.
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170314/5809c3d3/attachment.sig>
PATCH 1/1 PMIC: TI: TPS65903X errata (SLIA087) code
Quoted 9 lines · On Tue, 14 Mar 2017 09:22:02 -0400 Tom Rini <[email protected]> wrote:
Quoted 7 lines · Lukasz Majewski
This patch adds code, which comply with TPS65903X errata pseudocode described in SLIA087 - "Guide to Using the GPADC in TPS65903x and TPS6591x Devices".
It is enabled by proper
Kconfigoption, when TI's palmas PMIC support is added.
Quoted 8 lines
Quoted 4 lines
The TI's e2e thread with test procedure description:
https://e2e.ti.com/support/power_management/pmu/f/200/p/579649/2130910#2130910Signed-off-by Lukasz Majewski <[email protected]>I assume you have hardware that also uses this, so please submit with it as it's not clear to me when the errata function you add should be called.
I'm working on AM57xx based system, which will utilize this.
I wanted to share it early, since it might take some time to make the "devel" code suitable for ML.
Nonetheless, other TI boards can use those fixes if they use this type of PMIC (TPS65903x) despite the lack of my board in ML.
Quoted 10 lines
Thanks!
[snip]
drivers/power/pmic/Kconfig config PMIC_PALMAS · line 157
Quoted 4 lines
drivers/power/pmic/Kconfig +4
-0+config PMIC_TPS65903X_ERRATA + bool "Enable TPS65903X errata (SLIA087)" + depends on PMIC_PALMAS + ---help---We just do 'help' normally and indent the text.
Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de -------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170315/3b387e27/attachment.sig>
PATCH 1/1 PMIC: TI: TPS65903X errata (SLIA087) code
Quoted 21 lines · Lukasz Majewski
Quoted 9 lines · On Tue, 14 Mar 2017 09:22:02 -0400 Tom Rini <[email protected]> wrote:
Quoted 7 lines · Lukasz Majewski
This patch adds code, which comply with TPS65903X errata pseudocode described in SLIA087 - "Guide to Using the GPADC in TPS65903x and TPS6591x Devices".
It is enabled by proper
Kconfigoption, when TI's palmas PMIC support is added.Quoted 8 lines
Quoted 4 lines
The TI's e2e thread with test procedure description:
https://e2e.ti.com/support/power_management/pmu/f/200/p/579649/2130910#2130910Signed-off-by Lukasz Majewski <[email protected]>I assume you have hardware that also uses this, so please submit with it as it's not clear to me when the errata function you add should be called.
Quoted 7 lines
I'm working on AM57xx based system, which will utilize this.
I wanted to share it early, since it might take some time to make the "devel" code suitable for ML.
Nonetheless, other TI boards can use those fixes if they use this type of PMIC (TPS65903x) despite the lack of my board in ML.
So, the am57xx EVMs, the dra7xx EVMs and the am57xx compulab SoM? I assume you have at least one of the TI EVMs, can you enable it there and show how it would be used? Is there a case where we would not want to be enabling this errata? Thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170315/0b8fbae4/attachment.sig>
PATCH 1/1 PMIC: TI: TPS65903X errata (SLIA087) code
Quoted 24 lines · On Wed, 15 Mar 2017 09:35:29 -0400 Tom Rini <[email protected]> wrote:
Quoted 23 lines · Lukasz Majewski
Quoted 9 lines · On Tue, 14 Mar 2017 09:22:02 -0400 Tom Rini <[email protected]> wrote:
Quoted 7 lines · Lukasz Majewski
This patch adds code, which comply with TPS65903X errata pseudocode described in SLIA087 - "Guide to Using the GPADC in TPS65903x and TPS6591x Devices".
It is enabled by proper
Kconfigoption, when TI's palmas PMIC support is added.Quoted 8 lines
Quoted 4 lines
The TI's e2e thread with test procedure description:
https://e2e.ti.com/support/power_management/pmu/f/200/p/579649/2130910#2130910Signed-off-by Lukasz Majewski <[email protected]>I assume you have hardware that also uses this, so please submit with it as it's not clear to me when the errata function you add should be called.
I'm working on AM57xx based system, which will utilize this.
Quoted 7 lines
Quoted 5 lines
I wanted to share it early, since it might take some time to make the "devel" code suitable for ML.
Nonetheless, other TI boards can use those fixes if they use this type of PMIC (TPS65903x) despite the lack of my board in ML.
So, the am57xx EVMs, the dra7xx EVMs and the am57xx compulab SoM?
Yes, if they use this PMIC
Quoted 3 lines
I
assume you have at least one of the TI EVMs, can you enable it there and show how it would be used?
I had one of them. Now I do have only my custom board(s).
Quoted 2 lines
Is there a case where we would not
want to be enabling this errata?
This errata is about GPACD - General Purpose Analog Digital Converter in PMIC. It is not critical for system booting, but can save some high-level user's stress when enabled.
For example - he/she will not have to do "dummy" read to have correct ADC values in the user space Linux program after booting.
Quoted 2 lines
Thanks!
I've added it to
int board_late_init(void)
{
....
ret = tps65903x_errata(); if (ret) return ret;
....
}
Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de -------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170315/4cd6b1e0/attachment.sig>
PATCH 1/1 PMIC: TI: TPS65903X errata (SLIA087) code
In reply to Lukasz MajewskiHi Lucas,
Quoted 9 lines · Lukasz Majewski
This patch adds code, which comply with TPS65903X errata pseudocode described in SLIA087 - "Guide to Using the GPADC in TPS65903x and TPS6591x Devices".
It is enabled by proper
Kconfigoption, when TI's palmas PMIC support is added.The TI's e2e thread with test procedure description:
https://e2e.ti.com/support/power_management/pmu/f/200/p/579649/2130910#2130910
I could not understand the reason for why this is being done in U-Boot. Can you explain a it more on this?
Thanks and regards,
Lokesh
PATCH 1/1 PMIC: TI: TPS65903X errata (SLIA087) code
Hi Lokesh,
Quoted 7 lines
Hi Lucas,
Quoted 4 lines · Lukasz Majewski
This patch adds code, which comply with TPS65903X errata pseudocode described in SLIA087 - "Guide to Using the GPADC in TPS65903x and TPS6591x Devices".
Quoted 8 lines
Quoted 5 lines
It is enabled by proper
Kconfigoption, when TI's palmas PMIC support is added.The TI's e2e thread with test procedure description:
https://e2e.ti.com/support/power_management/pmu/f/200/p/579649/2130910#2130910I could not understand the reason for why this is being done in U-Boot. Can you explain a it more on this?
Just as a safety matter. Doing this for GPADC PMIC in u-boot avoids "surprises" latter on - when the high level user wants to use the GPADC results from the first measurement that he/she does (for example at safety critical application).
The u-boot driver (as it touches it first) is responsible to give the TPS65903x PMIC to latter boot stage as free from any known problems (i.e erratas).
Quoted 3 lines
Thanks and regards,
Lokesh
Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
PATCH 1/1 PMIC: TI: TPS65903X errata (SLIA087) code
Hi Lucas,
Quoted 18 lines · Lukasz Majewski
Hi Lokesh,
Quoted 7 lines
Hi Lucas,
Quoted 4 lines · Lukasz Majewski
This patch adds code, which comply with TPS65903X errata pseudocode described in SLIA087 - "Guide to Using the GPADC in TPS65903x and TPS6591x Devices".
Quoted 8 lines
Quoted 5 lines
It is enabled by proper
Kconfigoption, when TI's palmas PMIC support is added.The TI's e2e thread with test procedure description:
https://e2e.ti.com/support/power_management/pmu/f/200/p/579649/2130910#2130910I could not understand the reason for why this is being done in U-Boot. Can you explain a it more on this?
Quoted 8 lines
Just as a safety matter. Doing this for GPADC PMIC in u-boot avoids "surprises" latter on - when the high level user wants to use the GPADC results from the first measurement that he/she does (for example at safety critical application).
The u-boot driver (as it touches it first) is responsible to give the TPS65903x PMIC to latter boot stage as free from any known problems (i.e erratas).
okay. Patch as such looks good to me.
Thanks and regards,
Lokesh