1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2018, STMicroelectronics - All Rights Reserved
10 #include <dm/device.h>
11 #include <dm/uclass.h>
13 #define STM32MP_OTP_BANK 0
16 * The 'fuse' command API
18 int fuse_read(u32 bank, u32 word, u32 *val)
24 case STM32MP_OTP_BANK:
25 ret = uclass_get_device_by_driver(UCLASS_MISC,
26 DM_GET_DRIVER(stm32mp_bsec),
30 ret = misc_read(dev, word * 4 + STM32_BSEC_SHADOW_OFFSET,
35 printf("stm32mp %s: wrong value for bank %i\n", __func__, bank);
43 int fuse_prog(u32 bank, u32 word, u32 val)
49 case STM32MP_OTP_BANK:
50 ret = uclass_get_device_by_driver(UCLASS_MISC,
51 DM_GET_DRIVER(stm32mp_bsec),
55 ret = misc_write(dev, word * 4 + STM32_BSEC_OTP_OFFSET,
60 printf("stm32mp %s: wrong value for bank %i\n", __func__, bank);
68 int fuse_sense(u32 bank, u32 word, u32 *val)
74 case STM32MP_OTP_BANK:
75 ret = uclass_get_device_by_driver(UCLASS_MISC,
76 DM_GET_DRIVER(stm32mp_bsec),
80 ret = misc_read(dev, word * 4 + STM32_BSEC_OTP_OFFSET, val, 4);
84 printf("stm32mp %s: wrong value for bank %i\n", __func__, bank);
92 int fuse_override(u32 bank, u32 word, u32 val)
98 case STM32MP_OTP_BANK:
99 ret = uclass_get_device_by_driver(UCLASS_MISC,
100 DM_GET_DRIVER(stm32mp_bsec),
104 ret = misc_write(dev, word * 4 + STM32_BSEC_SHADOW_OFFSET,
109 printf("stm32mp %s: wrong value for bank %i\n",