misc: update drivers for stm32mp1
Subsystems (4)
v2 cover misc: update drivers for stm32mp1
Update the stm32mp1 drivers after the commit 8729b1ae2cbd ("misc: Update read() and write() methods to return bytes xfered") And the introduction of NOP u-class.
Changes in v2:
- udpate bsec patch after rebase (use offs)
- impact in added command stboard after rebase
- rebase v2019.10-rc1
Patrick Delaunay (7):
bsec: update after MISC u-class update
pmu: stpmic1: change specific NVM api to MISC
stpmic1: simplify stpmic1_sysreset_request
stm32mp1: update test on misc_read result
stm32mp1: update sysconf_init on misc_read result
stm32mp1: board update command stboard on misc_read result
misc: change RCC form MISC to NOP uclass
arch/arm/mach-stm32mp/bsec.c | 30 +++++------ board/st/stm32mp1/cmd_stboard.c | 2 +- board/st/stm32mp1/stm32mp1.c | 4 +- drivers/misc/stm32_rcc.c | 5 +- drivers/misc/stm32mp_fuse.c | 74 ++++++++++++++++++++------- drivers/power/pmic/stpmic1.c | 107 +++++++++++++++++++++------------------- include/power/stpmic1.h | 7 --- 7 files changed, 134 insertions(+), 95 deletions(-)
Signature · 1 line
2.7.4
PATCH v2 1/7 bsec: update after MISC u-class update
Since the commit 8729b1ae2cbd ("misc: Update read() and write() methods to return bytes xfered"); The misc bsec driver need to be adapted to reflect the number of transferred bytes.
---
Changes in v2:
- udpate bsec patch after rebase (use offs)
arch/arm/mach-stm32mp/bsec.c | 30 ++++++++++++++++-------------- drivers/misc/stm32mp_fuse.c | 30 +++++++++++++++++------------- 2 files changed, 33 insertions(+), 27 deletions(-)
arch/arm/mach-stm32mp/bsec.c +16 -14
@@ -364,15 +364,13 @@ static int stm32mp_bsec_read(struct udevice *dev, int offset, offs -=STM32_BSEC_OTP_OFFSET ; shadow = false; } - otp = offs /sizeof (u32); -if (otp <0 || (otp + nb_otp -1 ) >BSEC_OTP_MAX_VALUE ) { -dev_err (dev,"wrong value for otp, max value : %i\n" , -BSEC_OTP_MAX_VALUE ); +if (offs <0 || (offs %4 ) || (size %4 ))return -EINVAL ; - } -for (i = otp; i < (otp + nb_otp); i++) { + otp = offs /sizeof (u32); + +for (i = otp; i < (otp + nb_otp) && i <=BSEC_OTP_MAX_VALUE ; i++) {u32 *addr = &((u32 *)buf)[i - otp];if (shadow)
@@ -383,7 +381,10 @@ static int stm32mp_bsec_read(struct udevice *dev, int offset,if (ret)break ; } -return ret; +if (ret) +return ret; +else +return (i - otp) *4 ; } static int stm32mp_bsec_write(struct udevice *dev, int offset,
@@ -400,15 +401,13 @@ static int stm32mp_bsec_write(struct udevice *dev, int offset, offs -=STM32_BSEC_OTP_OFFSET ; shadow = false; } - otp = offs /sizeof (u32); -if (otp <0 || (otp + nb_otp -1 ) >BSEC_OTP_MAX_VALUE ) { -dev_err (dev,"wrong value for otp, max value : %d\n" , -BSEC_OTP_MAX_VALUE ); +if (offs <0 || (offs %4 ) || (size %4 ))return -EINVAL ; - } -for (i = otp; i < otp + nb_otp; i++) { + otp = offs /sizeof (u32); + +for (i = otp; i < otp + nb_otp && i <=BSEC_OTP_MAX_VALUE ; i++) {u32 *val = &((u32 *)buf)[i - otp];if (shadow)
@@ -418,7 +417,10 @@ static int stm32mp_bsec_write(struct udevice *dev, int offset,if (ret)break ; } -return ret; +if (ret) +return ret; +else +return (i - otp) *4 ; }static const struct misc_ops stm32mp_bsec_ops = {
drivers/misc/stm32mp_fuse.c +17 -13
@@ -20,7 +20,7 @@*/ int fuse_read (u32 bank,u32 word,u32 *val) { -int ret =0 ; +int ret;struct udevice *dev;switch (bank) {
@@ -32,9 +32,10 @@ int fuse_read(u32 bank, u32 word, u32 *val)return ret; ret =misc_read (dev, word *4 +STM32_BSEC_SHADOW_OFFSET , val,4 ); -if (ret <0 ) -return ret; - ret =0 ; +if (ret !=4 ) + ret = -EINVAL ; +else + ret =0 ;break ;#ifdef CONFIG_PMIC_STPMIC1
@@ -67,9 +68,10 @@ int fuse_prog(u32 bank, u32 word, u32 val)return ret; ret =misc_write (dev, word *4 +STM32_BSEC_OTP_OFFSET , &val,4 ); -if (ret <0 ) -return ret; - ret =0 ; +if (ret !=4 ) + ret = -EINVAL ; +else + ret =0 ;break ;#ifdef CONFIG_PMIC_STPMIC1
@@ -100,9 +102,10 @@ int fuse_sense(u32 bank, u32 word, u32 *val)if (ret)return ret; ret =misc_read (dev, word *4 +STM32_BSEC_OTP_OFFSET , val,4 ); -if (ret <0 ) -return ret; - ret =0 ; +if (ret !=4 ) + ret = -EINVAL ; +else + ret =0 ;break ;#ifdef CONFIG_PMIC_STPMIC1
@@ -135,9 +138,10 @@ int fuse_override(u32 bank, u32 word, u32 val)return ret; ret =misc_write (dev, word *4 +STM32_BSEC_SHADOW_OFFSET , &val,4 ); -if (ret <0 ) -return ret; - ret =0 ; +if (ret !=4 ) + ret = -EINVAL ; +else + ret =0 ;break ;#ifdef CONFIG_PMIC_STPMIC1
Signature · 1 line
2.7.4
PATCH v2 2/7 pmu: stpmic1: change specific NVM api to MISC
In reply to Patrick DelaunayUse MISC u-class to export the NVM register (starting at 0xF8 offset) and avoid specific API.
- SHADOW have offset < 0.
- NVM have register > 0
---
Changes in v2: None
drivers/misc/stm32mp_fuse.c | 44 ++++++++++++++++++-- drivers/power/pmic/stpmic1.c | 98 +++++++++++++++++++++++++------------------- include/power/stpmic1.h | 7 ---- 3 files changed, 96 insertions(+), 53 deletions(-)
drivers/misc/stm32mp_fuse.c +40 -4
@@ -40,8 +40,17 @@ int fuse_read(u32 bank, u32 word, u32 *val)#ifdef CONFIG_PMIC_STPMIC1 case STM32MP_NVM_BANK : + ret =uclass_get_device_by_driver (UCLASS_MISC , +DM_GET_DRIVER (stpmic1_nvm), + &dev); +if (ret) +return ret; *val =0 ; - ret =stpmic1_shadow_read_byte (word, (u8 *)val); + ret =misc_read (dev, -word, val,1 ); +if (ret !=1 ) + ret = -EINVAL ; +else + ret =0 ;break ;#endif /* CONFIG_PMIC_STPMIC1 */
@@ -76,7 +85,16 @@ int fuse_prog(u32 bank, u32 word, u32 val)#ifdef CONFIG_PMIC_STPMIC1 case STM32MP_NVM_BANK : - ret =stpmic1_nvm_write_byte (word, (u8 *)&val); + ret =uclass_get_device_by_driver (UCLASS_MISC , +DM_GET_DRIVER (stpmic1_nvm), + &dev); +if (ret) +return ret; + ret =misc_write (dev, word, &val,1 ); +if (ret !=1 ) + ret = -EINVAL ; +else + ret =0 ;break ;#endif /* CONFIG_PMIC_STPMIC1 */
@@ -110,8 +128,17 @@ int fuse_sense(u32 bank, u32 word, u32 *val)#ifdef CONFIG_PMIC_STPMIC1 case STM32MP_NVM_BANK : + ret =uclass_get_device_by_driver (UCLASS_MISC , +DM_GET_DRIVER (stpmic1_nvm), + &dev); +if (ret) +return ret; *val =0 ; - ret =stpmic1_nvm_read_byte (word, (u8 *)val); + ret =misc_read (dev, word, val,1 ); +if (ret !=1 ) + ret = -EINVAL ; +else + ret =0 ;break ;#endif /* CONFIG_PMIC_STPMIC1 */
@@ -146,7 +173,16 @@ int fuse_override(u32 bank, u32 word, u32 val)#ifdef CONFIG_PMIC_STPMIC1 case STM32MP_NVM_BANK : - ret =stpmic1_shadow_write_byte (word, (u8 *)&val); + ret =uclass_get_device_by_driver (UCLASS_MISC , +DM_GET_DRIVER (stpmic1_nvm), + &dev); +if (ret) +return ret; + ret =misc_write (dev, -word, &val,1 ); +if (ret !=1 ) + ret = -EINVAL ; +else + ret =0 ;break ;#endif /* CONFIG_PMIC_STPMIC1 */
drivers/power/pmic/stpmic1.c +56 -42
157 lines not on this page · raw message
include/power/stpmic1.h +0 -7
@@ -107,11 +107,4 @@ enum {STPMIC1_PWR_SW2 , STPMIC1_MAX_PWR_SW, }; - -int stpmic1_shadow_read_byte (u8 addr,u8 *buf); -int stpmic1_shadow_write_byte (u8 addr,u8 *buf); -int stpmic1_nvm_read_byte (u8 addr,u8 *buf); -int stpmic1_nvm_write_byte (u8 addr,u8 *buf); -int stpmic1_nvm_read_all (u8 *buf,int buf_len); -int stpmic1_nvm_write_all (u8 *buf,int buf_len);#endif
Signature · 1 line
2.7.4
PATCH v2 3/7 stpmic1: simplify stpmic1_sysreset_request
In reply to Patrick DelaunayRetrieve parent device from dev->parent instead of calling uclass_get_device_by_driver()
---
Changes in v2: None
drivers/power/pmic/stpmic1.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-)
drivers/power/pmic/stpmic1.c +1 -8
@@ -232,19 +232,12 @@ U_BOOT_DRIVER(stpmic1_nvm) = {#ifdef CONFIG_SYSRESET static int stpmic1_sysreset_request (struct udevice *dev,enum sysreset_t type) { -struct udevice *pmic_dev; +struct udevice *pmic_dev = dev->parent;int ret;if (type !=SYSRESET_POWER && type !=SYSRESET_POWER_OFF )return -EPROTONOSUPPORT ; - ret =uclass_get_device_by_driver (UCLASS_PMIC , -DM_GET_DRIVER (pmic_stpmic1), - &pmic_dev); - -if (ret) -return -EOPNOTSUPP ; - ret =pmic_reg_read (pmic_dev,STPMIC1_MAIN_CR );if (ret <0 )return ret;
Signature · 1 line
2.7.4
PATCH v2 4/7 stm32mp1: update test on misc_read result
In reply to Patrick DelaunayUpdate the stm32mp1 baord after the commit 8729b1ae2cbd ("misc: Update read() and write() methods to return bytes xfered")
---
Changes in v2: None
board/st/stm32mp1/stm32mp1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
board/st/stm32mp1/stm32mp1.c +1 -1
@@ -101,7 +101,7 @@ int checkboard(void)if (!ret) ret =misc_read (dev,STM32_BSEC_SHADOW (BSEC_OTP_BOARD ), &otp,sizeof (otp)); -if (!ret && otp) { +if (ret >0 && otp) { printf("Board: MB%04x Var%d Rev.%c-%02d\n", otp >> 16, (otp >> 12) & 0xF,
Signature · 1 line
2.7.4
PATCH v2 5/7 stm32mp1: update sysconf_init on misc_read result
In reply to Patrick DelaunayUpdate management of misc_read in sysconf_init, which now return length of data after the commit 8729b1ae2cbd ("misc: Update read() and write() methods to return bytes xfered")
---
Changes in v2: None
board/st/stm32mp1/stm32mp1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
board/st/stm32mp1/stm32mp1.c +1 -1
@@ -464,7 +464,7 @@ static void sysconf_init(void) } ret =misc_read (dev,STM32_BSEC_SHADOW (18 ), &otp,4 ); -if (!ret) +if (ret >0 ) otp = otp &BIT (13 );/* get VDD = pwr-supply */
Signature · 1 line
2.7.4
PATCH v2 6/7 stm32mp1: board update command stboard on misc_read result
In reply to Patrick DelaunayUpdate management of misc_read, which now return length of data after the commit 8729b1ae2cbd ("misc: Update read() and write() methods to return bytes xfered")
---
Changes in v2:
- impact in added command stboard after rebase
board/st/stm32mp1/cmd_stboard.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
board/st/stm32mp1/cmd_stboard.c +1 -1
@@ -60,7 +60,7 @@ static int do_stboard(cmd_tbl_t *cmdtp, int flag, int argc, ret =misc_read (dev,STM32_BSEC_SHADOW (BSEC_OTP_BOARD ), &otp,sizeof (otp)); -if (ret) { +if (ret <0 ) {puts ("OTP read error" );return CMD_RET_FAILURE ; }
Signature · 1 line
2.7.4
PATCH v2 7/7 misc: change RCC form MISC to NOP uclass
In reply to Patrick DelaunayThe RCC driver have no operation so the new NOP uclass
is more appropriate. It only used as parent for clock and reset driver.
---
Changes in v2:
- rebase v2019.10-rc1
drivers/misc/stm32_rcc.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/misc/stm32_rcc.c +1 -4
@@ -68,8 +68,6 @@ static int stm32_rcc_bind(struct udevice *dev) dev_ofnode(dev), &child); } -static const struct misc_ops stm32_rcc_ops = { -};static const struct udevice_id stm32_rcc_ids[] = { {.compatible ="st,stm32f42xx-rcc" , .data = (ulong)&stm32_rcc_clk_f42x },
@@ -82,8 +80,7 @@ static const struct udevice_id stm32_rcc_ids[] = {U_BOOT_DRIVER (stm32_rcc) = { .name ="stm32-rcc" , - .id =UCLASS_MISC , + .id =UCLASS_NOP , .of_match = stm32_rcc_ids, .bind = stm32_rcc_bind, - .ops = &stm32_rcc_ops, };
Signature · 1 line
2.7.4