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,
38 printf("stm32mp %s: wrong value for bank %i\n", __func__, bank);
46 int fuse_prog(u32 bank, u32 word, u32 val)
52 case STM32MP_OTP_BANK:
53 ret = uclass_get_device_by_driver(UCLASS_MISC,
54 DM_GET_DRIVER(stm32mp_bsec),
58 ret = misc_write(dev, word * 4 + STM32_BSEC_OTP_OFFSET,
66 printf("stm32mp %s: wrong value for bank %i\n", __func__, bank);
74 int fuse_sense(u32 bank, u32 word, u32 *val)
80 case STM32MP_OTP_BANK:
81 ret = uclass_get_device_by_driver(UCLASS_MISC,
82 DM_GET_DRIVER(stm32mp_bsec),
86 ret = misc_read(dev, word * 4 + STM32_BSEC_OTP_OFFSET, val, 4);
93 printf("stm32mp %s: wrong value for bank %i\n", __func__, bank);
101 int fuse_override(u32 bank, u32 word, u32 val)
107 case STM32MP_OTP_BANK:
108 ret = uclass_get_device_by_driver(UCLASS_MISC,
109 DM_GET_DRIVER(stm32mp_bsec),
113 ret = misc_write(dev, word * 4 + STM32_BSEC_SHADOW_OFFSET,
121 printf("stm32mp %s: wrong value for bank %i\n",