pmu: stpmic1: change specific NVM api to MISC

Use MISC u-class to export the NVM register (starting at 0xF8 offset)
and avoid specific API.
- SHADOW have offset < 0.
- NVM have register > 0

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
This commit is contained in:
Patrick Delaunay
2019-08-02 13:08:03 +02:00
committed by Patrice Chotard
parent 0c8620d2ff
commit 234a60244c
3 changed files with 100 additions and 57 deletions

View File

@@ -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 */