#include <linux/iopoll.h>
#include <linux/printk.h>
-#define BSEC_OTP_MAX_VALUE 95
#define BSEC_OTP_UPPER_START 32
#define BSEC_TIMEOUT_US 10000
struct udevice *tee;
};
+struct stm32mp_bsec_drvdata {
+ int size;
+ bool ta;
+};
+
static int stm32mp_bsec_read_otp(struct udevice *dev, u32 *val, u32 otp)
{
struct stm32mp_bsec_plat *plat;
void *buf, int size)
{
struct stm32mp_bsec_priv *priv = dev_get_priv(dev);
+ struct stm32mp_bsec_drvdata *data = (struct stm32mp_bsec_drvdata *)dev_get_driver_data(dev);
int ret;
int i;
bool shadow = true, lock = false;
otp = offs / sizeof(u32);
- for (i = otp; i < (otp + nb_otp) && i <= BSEC_OTP_MAX_VALUE; i++) {
+ for (i = otp; i < (otp + nb_otp) && i < data->size; i++) {
u32 *addr = &((u32 *)buf)[i - otp];
if (lock)
const void *buf, int size)
{
struct stm32mp_bsec_priv *priv = dev_get_priv(dev);
+ struct stm32mp_bsec_drvdata *data = (struct stm32mp_bsec_drvdata *)dev_get_driver_data(dev);
int ret = 0;
int i;
bool shadow = true, lock = false;
otp = offs / sizeof(u32);
- for (i = otp; i < otp + nb_otp && i <= BSEC_OTP_MAX_VALUE; i++) {
+ for (i = otp; i < otp + nb_otp && i < data->size; i++) {
u32 *val = &((u32 *)buf)[i - otp];
if (lock)
static int stm32mp_bsec_probe(struct udevice *dev)
{
+ struct stm32mp_bsec_drvdata *data = (struct stm32mp_bsec_drvdata *)dev_get_driver_data(dev);
int otp;
struct stm32mp_bsec_plat *plat;
struct clk_bulk clk_bulk;
}
if (IS_ENABLED(CONFIG_OPTEE))
- bsec_optee_open(dev);
+ ret = bsec_optee_open(dev);
+ else
+ ret = -ENOTSUPP;
+ /* failed if OP-TEE TA is required */
+ if (data->ta && !ret)
+ return ret;
/*
* update unlocked shadow for OTP cleared by the rom code
* only executed in SPL, it is done in TF-A for TFABOOT
*/
- if (IS_ENABLED(CONFIG_SPL_BUILD)) {
+ if (IS_ENABLED(CONFIG_SPL_BUILD) && !data->ta) {
plat = dev_get_plat(dev);
- for (otp = 57; otp <= BSEC_OTP_MAX_VALUE; otp++)
+ /* here 57 is the value for STM32MP15x ROM code, only MPU with SPL support*/
+ for (otp = 57; otp < data->size; otp++)
if (!bsec_read_SR_lock(plat->base, otp))
bsec_shadow_register(dev, plat->base, otp);
}
return 0;
}
+static const struct stm32mp_bsec_drvdata stm32mp13_data = {
+ .size = 96,
+ .ta = true,
+};
+
+static const struct stm32mp_bsec_drvdata stm32mp15_data = {
+ .size = 96,
+ .ta = false,
+};
static const struct udevice_id stm32mp_bsec_ids[] = {
- { .compatible = "st,stm32mp13-bsec" },
- { .compatible = "st,stm32mp15-bsec" },
+ { .compatible = "st,stm32mp13-bsec", .data = (ulong)&stm32mp13_data},
+ { .compatible = "st,stm32mp15-bsec", .data = (ulong)&stm32mp15_data},
{}
};