]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
arm: stm32mp: move the get_otp helper function in bsec
authorPatrick Delaunay <patrick.delaunay@foss.st.com>
Fri, 20 May 2022 16:24:41 +0000 (18:24 +0200)
committerPatrick Delaunay <patrick.delaunay@foss.st.com>
Fri, 17 Jun 2022 07:58:21 +0000 (09:58 +0200)
As the get_otp() helper function in bsec are common for all STM32MP family,
move this function in bsec driver

Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
arch/arm/mach-stm32mp/bsec.c
arch/arm/mach-stm32mp/cpu.c
arch/arm/mach-stm32mp/include/mach/sys_proto.h

index 506caa0a31b1916f6f391e2a947fa2db5e546f03..c00130b08b3630e97855753478794e67a9c122d5 100644 (file)
@@ -632,3 +632,20 @@ bool bsec_dbgswenable(void)
 
        return false;
 }
+
+u32 get_otp(int index, int shift, int mask)
+{
+       int ret;
+       struct udevice *dev;
+       u32 otp = 0;
+
+       ret = uclass_get_device_by_driver(UCLASS_MISC,
+                                         DM_DRIVER_GET(stm32mp_bsec),
+                                         &dev);
+
+       if (!ret)
+               ret = misc_read(dev, STM32_BSEC_SHADOW(index),
+                               &otp, sizeof(otp));
+
+       return (otp >> shift) & mask;
+}
index 0ad5f307dba2c3d9455263ced6bc6567fa2f97c6..6f44c75515be7e21656e3d6d0aa336077702b946 100644 (file)
@@ -349,23 +349,6 @@ u32 get_cpu_rev(void)
        return (read_idc() & DBGMCU_IDC_REV_ID_MASK) >> DBGMCU_IDC_REV_ID_SHIFT;
 }
 
-static u32 get_otp(int index, int shift, int mask)
-{
-       int ret;
-       struct udevice *dev;
-       u32 otp = 0;
-
-       ret = uclass_get_device_by_driver(UCLASS_MISC,
-                                         DM_DRIVER_GET(stm32mp_bsec),
-                                         &dev);
-
-       if (!ret)
-               ret = misc_read(dev, STM32_BSEC_SHADOW(index),
-                               &otp, sizeof(otp));
-
-       return (otp >> shift) & mask;
-}
-
 /* Get Device Part Number (RPN) from OTP */
 static u32 get_cpu_rpn(void)
 {
index b91f98eb4515a1486f35781e227de86a6581b45e..dc98f0c5a41a64f64eea91c5de24ae1dd56b8578 100644 (file)
@@ -52,3 +52,6 @@ int setup_mac_address(void);
 
 /* board power management : configure vddcore according OPP */
 void board_vddcore_init(u32 voltage_mv);
+
+/* helper function: read data from OTP */
+u32 get_otp(int index, int shift, int mask);