misc: update drivers for stm32mp1
Subsystems (4)
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.
Patrick Delaunay (5):
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
misc: change RCC form MISC to NOP uclass
arch/arm/mach-stm32mp/bsec.c | 31 +++++++------ board/st/stm32mp1/stm32mp1.c | 2 +- drivers/misc/stm32_rcc.c | 5 +- drivers/misc/stm32mp_fuse.c | 74 +++++++++++++++++++++++------- drivers/power/pmic/stpmic1.c | 107 +++++++++++++++++++++++-------------------- include/power/stpmic1.h | 7 --- 6 files changed, 132 insertions(+), 94 deletions(-)
Signature · 1 line
2.7.4
PATCH 1/5 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.
---
arch/arm/mach-stm32mp/bsec.c | 31 ++++++++++++++++--------------- drivers/misc/stm32mp_fuse.c | 30 +++++++++++++++++------------- 2 files changed, 33 insertions(+), 28 deletions(-)
arch/arm/mach-stm32mp/bsec.c +16 -15
@@ -363,15 +363,13 @@ static int stm32mp_bsec_read(struct udevice *dev, int offset, offset -=STM32_BSEC_OTP_OFFSET ; shadow = false; } - otp = offset /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 (offset <0 || (offset %4 ) || (size %4 ))return -EINVAL ; - } -for (i = otp; i < (otp + nb_otp); i++) { + otp = offset /sizeof (u32); + +for (i = otp; i < (otp + nb_otp) && i <=BSEC_OTP_MAX_VALUE ; i++) {u32 *addr = &((u32 *)buf)[i - otp];if (shadow)
@@ -382,7 +380,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,
@@ -398,15 +399,12 @@ static int stm32mp_bsec_write(struct udevice *dev, int offset, offset -=STM32_BSEC_OTP_OFFSET ; shadow = false; } - otp = offset /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 (offset <0 || (offset %4 ) || (size %4 ))return -EINVAL ; - } -for (i = otp; i < otp + nb_otp; i++) { + otp = offset /sizeof (u32); + +for (i = otp; i < otp + nb_otp && i <=BSEC_OTP_MAX_VALUE ; i++) {u32 *val = &((u32 *)buf)[i - otp];if (shadow)
@@ -416,7 +414,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
@@ -19,7 +19,7 @@*/ int fuse_read (u32 bank,u32 word,u32 *val) { -int ret =0 ; +int ret;struct udevice *dev;switch (bank) {
@@ -31,9 +31,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
@@ -66,9 +67,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
@@ -99,9 +101,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
@@ -134,9 +137,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 1/5 bsec: update after MISC u-class update
Hi,
Quoted 9 lines
From: Patrick DELAUNAY <[email protected]>
Sent: vendredi 19 juillet 2019 11:39
Subject: [PATCH 1/5] bsec: update after MISC u-class update
Importance: HighSince the commit
8729b1ae2cbd("misc: Updateread()andwrite()methods to return bytes xfered"); The misc bsec driver need to be adapted to reflect the number of transferred bytes.
Quoted 6 lines
Signed-off-by Patrick Delaunay <[email protected]>---
arch/arm/mach-stm32mp/bsec.c | 31 ++++++++++++++++--------------- drivers/misc/stm32mp_fuse.c | 30 +++++++++++++++++------------- 2 files changed, 33 insertions(+), 28 deletions(-)
For information, this patch need rework after commit dae0bd28c1638ea751021045bd1453b2ba3f3245 "stm32mp1: bsec: Fix warnings when compiling with W=1"
This commit is integrated in v2019.10-rc1 and I will rebase the patchset and sent a V2.
Regards
Patrick
PATCH 2/5 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
---
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
@@ -39,8 +39,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 */
@@ -75,7 +84,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 */
@@ -109,8 +127,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 */
@@ -145,7 +172,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 3/5 stpmic1: simplify stpmic1_sysreset_request
In reply to Patrick DelaunayRetrieve parent device from dev->parent instead of calling uclass_get_device_by_driver()
---
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 )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 4/5 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")
---
board/st/stm32mp1/stm32mp1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
board/st/stm32mp1/stm32mp1.c +1 -1
@@ -95,7 +95,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 5/5 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.
---
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