mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-24 14:25:56 +00:00
imx: mach: correct SCU API usage
The return value is int type, not sc_err_t(u8), correct the usage. Signed-off-by: Peng Fan <peng.fan@nxp.com>
This commit is contained in:
parent
e064fe4f37
commit
dd654caac0
6 changed files with 98 additions and 106 deletions
|
@ -154,7 +154,7 @@ error:
|
|||
|
||||
static int blob_encap_dek(u32 src_addr, u32 dst_addr, u32 len)
|
||||
{
|
||||
sc_err_t err;
|
||||
int err;
|
||||
sc_rm_mr_t mr_input, mr_output;
|
||||
struct generate_key_blob_hdr hdr;
|
||||
u8 in_size, out_size;
|
||||
|
|
|
@ -147,7 +147,7 @@ int authenticate_os_container(ulong addr)
|
|||
}
|
||||
|
||||
exit:
|
||||
if (sc_seco_authenticate(-1, SC_SECO_REL_CONTAINER, 0) != SC_ERR_NONE)
|
||||
if (sc_seco_authenticate(-1, SC_SECO_REL_CONTAINER, 0))
|
||||
printf("Error: release container failed!\n");
|
||||
|
||||
return ret;
|
||||
|
@ -263,7 +263,7 @@ static int do_ahab_status(struct cmd_tbl *cmdtp, int flag, int argc,
|
|||
u16 lc;
|
||||
|
||||
err = sc_seco_chip_info(-1, &lc, NULL, NULL, NULL);
|
||||
if (err != SC_ERR_NONE) {
|
||||
if (err) {
|
||||
printf("Error in get lifecycle\n");
|
||||
return -EIO;
|
||||
}
|
||||
|
@ -271,7 +271,7 @@ static int do_ahab_status(struct cmd_tbl *cmdtp, int flag, int argc,
|
|||
display_life_cycle(lc);
|
||||
|
||||
err = sc_seco_get_event(-1, idx, &event);
|
||||
while (err == SC_ERR_NONE) {
|
||||
while (!err) {
|
||||
printf("SECO Event[%u] = 0x%08X\n", idx, event);
|
||||
display_ahab_auth_event(event);
|
||||
|
||||
|
@ -312,7 +312,7 @@ static int do_ahab_close(struct cmd_tbl *cmdtp, int flag, int argc,
|
|||
return -EACCES;
|
||||
|
||||
err = sc_seco_chip_info(-1, &lc, NULL, NULL, NULL);
|
||||
if (err != SC_ERR_NONE) {
|
||||
if (err) {
|
||||
printf("Error in get lifecycle\n");
|
||||
return -EIO;
|
||||
}
|
||||
|
@ -324,7 +324,7 @@ static int do_ahab_close(struct cmd_tbl *cmdtp, int flag, int argc,
|
|||
}
|
||||
|
||||
err = sc_seco_forward_lifecycle(-1, 16);
|
||||
if (err != SC_ERR_NONE) {
|
||||
if (err) {
|
||||
printf("Error in forward lifecycle to OEM closed\n");
|
||||
return -EIO;
|
||||
}
|
||||
|
|
|
@ -195,7 +195,7 @@ enum boot_device get_boot_device(void)
|
|||
#define FUSE_UNIQUE_ID_WORD1 17
|
||||
void get_board_serial(struct tag_serialnr *serialnr)
|
||||
{
|
||||
sc_err_t err;
|
||||
int err;
|
||||
u32 val1 = 0, val2 = 0;
|
||||
u32 word1, word2;
|
||||
|
||||
|
@ -206,13 +206,13 @@ void get_board_serial(struct tag_serialnr *serialnr)
|
|||
word2 = FUSE_UNIQUE_ID_WORD1;
|
||||
|
||||
err = sc_misc_otp_fuse_read(-1, word1, &val1);
|
||||
if (err != SC_ERR_NONE) {
|
||||
if (err) {
|
||||
printf("%s fuse %d read error: %d\n", __func__, word1, err);
|
||||
return;
|
||||
}
|
||||
|
||||
err = sc_misc_otp_fuse_read(-1, word2, &val2);
|
||||
if (err != SC_ERR_NONE) {
|
||||
if (err) {
|
||||
printf("%s fuse %d read error: %d\n", __func__, word2, err);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -110,7 +110,7 @@ static int config_smmu_resource_sid(int rsrc, int sid)
|
|||
|
||||
err = sc_rm_set_master_sid(-1, rsrc, sid);
|
||||
debug("set_master_sid rsrc=%d sid=0x%x err=%d\n", rsrc, sid, err);
|
||||
if (err != SC_ERR_NONE) {
|
||||
if (err) {
|
||||
if (!check_owned_resource(rsrc)) {
|
||||
printf("%s rsrc[%d] not owned\n", __func__, rsrc);
|
||||
return -1;
|
||||
|
|
|
@ -286,16 +286,15 @@ static int check_write_secvio_config(u32 id, u32 *_p1, u32 *_p2,
|
|||
u32 *_p3, u32 *_p4, u32 *_p5,
|
||||
u32 _cnt)
|
||||
{
|
||||
int scierr = 0;
|
||||
int err;
|
||||
u32 d1 = ptr_value(_p1);
|
||||
u32 d2 = ptr_value(_p2);
|
||||
u32 d3 = ptr_value(_p3);
|
||||
u32 d4 = ptr_value(_p4);
|
||||
u32 d5 = ptr_value(_p5);
|
||||
|
||||
scierr = sc_seco_secvio_config(-1, id, SC_WRITE_CONF, &d1, &d2, &d3,
|
||||
&d4, &d4, _cnt);
|
||||
if (scierr != SC_ERR_NONE) {
|
||||
err = sc_seco_secvio_config(-1, id, SC_WRITE_CONF, &d1, &d2, &d3, &d4, &d4, _cnt);
|
||||
if (err) {
|
||||
printf("Failed to set secvio configuration\n");
|
||||
debug("Failed to set conf id 0x%x with values ", id);
|
||||
debug("0x%.8x 0x%.8x 0x%.8x 0x%.8x 0x%.8x (cnt: %d)\n",
|
||||
|
@ -315,7 +314,7 @@ static int check_write_secvio_config(u32 id, u32 *_p1, u32 *_p2,
|
|||
*(u32 *)_p5 = d5;
|
||||
|
||||
exit:
|
||||
return scierr;
|
||||
return err;
|
||||
}
|
||||
|
||||
#define SC_CHECK_WRITE1(id, _p1) \
|
||||
|
@ -323,7 +322,7 @@ exit:
|
|||
|
||||
static int apply_snvs_config(struct snvs_security_sc_conf *cnf)
|
||||
{
|
||||
int scierr = 0;
|
||||
int err = 0;
|
||||
|
||||
debug("%s\n", __func__);
|
||||
|
||||
|
@ -365,92 +364,88 @@ static int apply_snvs_config(struct snvs_security_sc_conf *cnf)
|
|||
cnf->lp.act_tamper_routing_ctl1,
|
||||
cnf->lp.act_tamper_routing_ctl2);
|
||||
|
||||
scierr = check_write_secvio_config(SC_CONF_OFFSET_OF(lp.tamper_filt_cfg),
|
||||
err = check_write_secvio_config(SC_CONF_OFFSET_OF(lp.tamper_filt_cfg),
|
||||
&cnf->lp.tamper_filt_cfg,
|
||||
&cnf->lp.tamper_filt1_cfg,
|
||||
&cnf->lp.tamper_filt2_cfg, NULL,
|
||||
NULL, 3);
|
||||
if (scierr != SC_ERR_NONE)
|
||||
&cnf->lp.tamper_filt2_cfg,
|
||||
NULL, NULL, 3);
|
||||
if (err)
|
||||
goto exit;
|
||||
|
||||
/* Configure AT */
|
||||
scierr = check_write_secvio_config(SC_CONF_OFFSET_OF(lp.act_tamper1_cfg),
|
||||
err = check_write_secvio_config(SC_CONF_OFFSET_OF(lp.act_tamper1_cfg),
|
||||
&cnf->lp.act_tamper1_cfg,
|
||||
&cnf->lp.act_tamper2_cfg,
|
||||
&cnf->lp.act_tamper2_cfg,
|
||||
&cnf->lp.act_tamper2_cfg,
|
||||
&cnf->lp.act_tamper2_cfg, 5);
|
||||
if (scierr != SC_ERR_NONE)
|
||||
if (err)
|
||||
goto exit;
|
||||
|
||||
/* Configure AT routing */
|
||||
scierr = check_write_secvio_config(SC_CONF_OFFSET_OF(lp.act_tamper_routing_ctl1),
|
||||
err = check_write_secvio_config(SC_CONF_OFFSET_OF(lp.act_tamper_routing_ctl1),
|
||||
&cnf->lp.act_tamper_routing_ctl1,
|
||||
&cnf->lp.act_tamper_routing_ctl2,
|
||||
NULL, NULL, NULL, 2);
|
||||
if (scierr != SC_ERR_NONE)
|
||||
if (err)
|
||||
goto exit;
|
||||
|
||||
/* Configure AT frequency */
|
||||
scierr = SC_CHECK_WRITE1(SC_CONF_OFFSET_OF(lp.act_tamper_clk_ctl),
|
||||
err = SC_CHECK_WRITE1(SC_CONF_OFFSET_OF(lp.act_tamper_clk_ctl),
|
||||
&cnf->lp.act_tamper_clk_ctl);
|
||||
if (scierr != SC_ERR_NONE)
|
||||
if (err)
|
||||
goto exit;
|
||||
|
||||
/* Activate the ATs */
|
||||
scierr = SC_CHECK_WRITE1(SC_CONF_OFFSET_OF(lp.act_tamper_ctl),
|
||||
&cnf->lp.act_tamper_ctl);
|
||||
if (scierr != SC_ERR_NONE)
|
||||
err = SC_CHECK_WRITE1(SC_CONF_OFFSET_OF(lp.act_tamper_ctl), &cnf->lp.act_tamper_ctl);
|
||||
if (err)
|
||||
goto exit;
|
||||
|
||||
/* Activate the detectors */
|
||||
scierr = check_write_secvio_config(SC_CONF_OFFSET_OF(lp.tamper_det_cfg),
|
||||
err = check_write_secvio_config(SC_CONF_OFFSET_OF(lp.tamper_det_cfg),
|
||||
&cnf->lp.tamper_det_cfg,
|
||||
&cnf->lp.tamper_det_cfg2, NULL, NULL,
|
||||
NULL, 2);
|
||||
if (scierr != SC_ERR_NONE)
|
||||
&cnf->lp.tamper_det_cfg2, NULL, NULL, NULL, 2);
|
||||
if (err)
|
||||
goto exit;
|
||||
|
||||
/* Configure LP secvio */
|
||||
scierr = SC_CHECK_WRITE1(SC_CONF_OFFSET_OF(lp.secvio_ctl),
|
||||
&cnf->lp.secvio_ctl);
|
||||
if (scierr != SC_ERR_NONE)
|
||||
err = SC_CHECK_WRITE1(SC_CONF_OFFSET_OF(lp.secvio_ctl), &cnf->lp.secvio_ctl);
|
||||
if (err)
|
||||
goto exit;
|
||||
|
||||
/* Configure HP secvio */
|
||||
scierr = SC_CHECK_WRITE1(SC_CONF_OFFSET_OF(hp.secvio_ctl),
|
||||
&cnf->hp.secvio_ctl);
|
||||
if (scierr != SC_ERR_NONE)
|
||||
err = SC_CHECK_WRITE1(SC_CONF_OFFSET_OF(hp.secvio_ctl), &cnf->hp.secvio_ctl);
|
||||
if (err)
|
||||
goto exit;
|
||||
|
||||
/* Lock access */
|
||||
scierr = SC_CHECK_WRITE1(SC_CONF_OFFSET_OF(hp.lock), &cnf->hp.lock);
|
||||
if (scierr != SC_ERR_NONE)
|
||||
err = SC_CHECK_WRITE1(SC_CONF_OFFSET_OF(hp.lock), &cnf->hp.lock);
|
||||
if (err)
|
||||
goto exit;
|
||||
|
||||
scierr = SC_CHECK_WRITE1(SC_CONF_OFFSET_OF(lp.lock), &cnf->lp.lock);
|
||||
if (scierr != SC_ERR_NONE)
|
||||
err = SC_CHECK_WRITE1(SC_CONF_OFFSET_OF(lp.lock), &cnf->lp.lock);
|
||||
if (err)
|
||||
goto exit;
|
||||
|
||||
exit:
|
||||
return (scierr == SC_ERR_NONE) ? 0 : -EIO;
|
||||
return err;
|
||||
}
|
||||
|
||||
static int dgo_write(u32 _id, u8 _access, u32 *_pdata)
|
||||
{
|
||||
int scierr = sc_seco_secvio_dgo_config(-1, _id, _access, _pdata);
|
||||
int err = sc_seco_secvio_dgo_config(-1, _id, _access, _pdata);
|
||||
|
||||
if (scierr != SC_ERR_NONE) {
|
||||
if (err) {
|
||||
printf("Failed to set dgo configuration\n");
|
||||
debug("Failed to set conf id 0x%x : 0x%.8x", _id, *_pdata);
|
||||
}
|
||||
|
||||
return scierr;
|
||||
return err;
|
||||
}
|
||||
|
||||
static int apply_snvs_dgo_config(struct snvs_dgo_conf *cnf)
|
||||
{
|
||||
int scierr = 0;
|
||||
int err;
|
||||
|
||||
debug("%s\n", __func__);
|
||||
|
||||
|
@ -468,50 +463,50 @@ static int apply_snvs_dgo_config(struct snvs_dgo_conf *cnf)
|
|||
cnf->tamper_misc_ctl,
|
||||
cnf->tamper_core_volt_mon_ctl);
|
||||
|
||||
dgo_write(0x04, 1, &cnf->tamper_offset_ctl);
|
||||
if (scierr != SC_ERR_NONE)
|
||||
err = dgo_write(0x04, 1, &cnf->tamper_offset_ctl);
|
||||
if (err)
|
||||
goto exit;
|
||||
|
||||
dgo_write(0x14, 1, &cnf->tamper_pull_ctl);
|
||||
if (scierr != SC_ERR_NONE)
|
||||
err = dgo_write(0x14, 1, &cnf->tamper_pull_ctl);
|
||||
if (err)
|
||||
goto exit;
|
||||
|
||||
dgo_write(0x24, 1, &cnf->tamper_ana_test_ctl);
|
||||
if (scierr != SC_ERR_NONE)
|
||||
err = dgo_write(0x24, 1, &cnf->tamper_ana_test_ctl);
|
||||
if (err)
|
||||
goto exit;
|
||||
|
||||
dgo_write(0x34, 1, &cnf->tamper_sensor_trim_ctl);
|
||||
if (scierr != SC_ERR_NONE)
|
||||
err = dgo_write(0x34, 1, &cnf->tamper_sensor_trim_ctl);
|
||||
if (err)
|
||||
goto exit;
|
||||
|
||||
dgo_write(0x54, 1, &cnf->tamper_core_volt_mon_ctl);
|
||||
if (scierr != SC_ERR_NONE)
|
||||
err = dgo_write(0x54, 1, &cnf->tamper_core_volt_mon_ctl);
|
||||
if (err)
|
||||
goto exit;
|
||||
|
||||
/* Last as it could lock the writes */
|
||||
dgo_write(0x44, 1, &cnf->tamper_misc_ctl);
|
||||
if (scierr != SC_ERR_NONE)
|
||||
err = dgo_write(0x44, 1, &cnf->tamper_misc_ctl);
|
||||
if (err)
|
||||
goto exit;
|
||||
|
||||
exit:
|
||||
return (scierr == SC_ERR_NONE) ? 0 : -EIO;
|
||||
return err;
|
||||
}
|
||||
|
||||
static int pad_write(u32 _pad, u32 _value)
|
||||
{
|
||||
int scierr = sc_pad_set(-1, _pad, _value);
|
||||
int err = sc_pad_set(-1, _pad, _value);
|
||||
|
||||
if (scierr != SC_ERR_NONE) {
|
||||
if (err) {
|
||||
printf("Failed to set pad configuration\n");
|
||||
debug("Failed to set conf pad 0x%x : 0x%.8x", _pad, _value);
|
||||
}
|
||||
|
||||
return scierr;
|
||||
return err;
|
||||
}
|
||||
|
||||
static int apply_tamper_pin_list_config(struct tamper_pin_cfg *confs, u32 size)
|
||||
{
|
||||
int scierr = 0;
|
||||
int err = 0;
|
||||
u32 idx;
|
||||
|
||||
debug("%s\n", __func__);
|
||||
|
@ -519,13 +514,13 @@ static int apply_tamper_pin_list_config(struct tamper_pin_cfg *confs, u32 size)
|
|||
for (idx = 0; idx < size; idx++) {
|
||||
debug("\t idx %d: pad %d: 0x%.8x\n", idx, confs[idx].pad,
|
||||
confs[idx].mux_conf);
|
||||
pad_write(confs[idx].pad, 3 << 30 | confs[idx].mux_conf);
|
||||
if (scierr != SC_ERR_NONE)
|
||||
err = pad_write(confs[idx].pad, 3 << 30 | confs[idx].mux_conf);
|
||||
if (err)
|
||||
goto exit;
|
||||
}
|
||||
|
||||
exit:
|
||||
return (scierr == SC_ERR_NONE) ? 0 : -EIO;
|
||||
return err;
|
||||
}
|
||||
|
||||
int examples(void)
|
||||
|
@ -753,7 +748,7 @@ static char snvs_clear_status_help_text[] =
|
|||
static int do_snvs_clear_status(struct cmd_tbl *cmdtp, int flag, int argc,
|
||||
char *const argv[])
|
||||
{
|
||||
int scierr = 0;
|
||||
int err;
|
||||
u32 idx = 0;
|
||||
|
||||
struct snvs_security_sc_conf conf = {0};
|
||||
|
@ -764,20 +759,18 @@ static int do_snvs_clear_status(struct cmd_tbl *cmdtp, int flag, int argc,
|
|||
conf.lp.status = hextoul(argv[++idx], NULL);
|
||||
conf.lp.tamper_det_status = hextoul(argv[++idx], NULL);
|
||||
|
||||
scierr = check_write_secvio_config(SC_CONF_OFFSET_OF(lp.status),
|
||||
&conf.lp.status, NULL, NULL, NULL,
|
||||
NULL, 1);
|
||||
if (scierr != SC_ERR_NONE)
|
||||
err = check_write_secvio_config(SC_CONF_OFFSET_OF(lp.status),
|
||||
&conf.lp.status, NULL, NULL, NULL, NULL, 1);
|
||||
if (err)
|
||||
goto exit;
|
||||
|
||||
scierr = check_write_secvio_config(SC_CONF_OFFSET_OF(lp.tamper_det_status),
|
||||
&conf.lp.tamper_det_status, NULL,
|
||||
NULL, NULL, NULL, 1);
|
||||
if (scierr != SC_ERR_NONE)
|
||||
err = check_write_secvio_config(SC_CONF_OFFSET_OF(lp.tamper_det_status),
|
||||
&conf.lp.tamper_det_status, NULL, NULL, NULL, NULL, 1);
|
||||
if (err)
|
||||
goto exit;
|
||||
|
||||
exit:
|
||||
return (scierr == SC_ERR_NONE) ? 0 : 1;
|
||||
return err;
|
||||
}
|
||||
|
||||
U_BOOT_CMD(snvs_clear_status,
|
||||
|
@ -793,7 +786,7 @@ static char snvs_sec_status_help_text[] =
|
|||
static int do_snvs_sec_status(struct cmd_tbl *cmdtp, int flag, int argc,
|
||||
char *const argv[])
|
||||
{
|
||||
int scierr;
|
||||
int err;
|
||||
u32 idx;
|
||||
|
||||
u32 data[5];
|
||||
|
@ -864,8 +857,8 @@ static int do_snvs_sec_status(struct cmd_tbl *cmdtp, int flag, int argc,
|
|||
for (idx = 0; idx < ARRAY_SIZE(pads); idx++) {
|
||||
u8 pad_id = pads[idx];
|
||||
|
||||
scierr = sc_pad_get(-1, pad_id, &data[0]);
|
||||
if (scierr == 0)
|
||||
err = sc_pad_get(-1, pad_id, &data[0]);
|
||||
if (!err)
|
||||
printf("\t- Pin %d: %.8x\n", pad_id, data[0]);
|
||||
else
|
||||
printf("Failed to read Pin %d\n", pad_id);
|
||||
|
@ -876,8 +869,8 @@ static int do_snvs_sec_status(struct cmd_tbl *cmdtp, int flag, int argc,
|
|||
for (idx = 0; idx < ARRAY_SIZE(fuses); idx++) {
|
||||
u32 fuse_id = fuses[idx];
|
||||
|
||||
scierr = sc_misc_otp_fuse_read(-1, fuse_id, &data[0]);
|
||||
if (scierr == 0)
|
||||
err = sc_misc_otp_fuse_read(-1, fuse_id, &data[0]);
|
||||
if (!err)
|
||||
printf("\t- Fuse %d: %.8x\n", fuse_id, data[0]);
|
||||
else
|
||||
printf("Failed to read Fuse %d\n", fuse_id);
|
||||
|
@ -888,10 +881,10 @@ static int do_snvs_sec_status(struct cmd_tbl *cmdtp, int flag, int argc,
|
|||
for (idx = 0; idx < ARRAY_SIZE(snvs); idx++) {
|
||||
struct snvs_reg *reg = &snvs[idx];
|
||||
|
||||
scierr = sc_seco_secvio_config(-1, reg->id, 0, &data[0],
|
||||
err = sc_seco_secvio_config(-1, reg->id, 0, &data[0],
|
||||
&data[1], &data[2], &data[3],
|
||||
&data[4], reg->nb);
|
||||
if (scierr == 0) {
|
||||
if (!err) {
|
||||
int subidx;
|
||||
|
||||
printf("\t- SNVS %.2x(%d):", reg->id, reg->nb);
|
||||
|
@ -908,8 +901,8 @@ static int do_snvs_sec_status(struct cmd_tbl *cmdtp, int flag, int argc,
|
|||
for (idx = 0; idx < ARRAY_SIZE(dgo); idx++) {
|
||||
u8 dgo_id = dgo[idx];
|
||||
|
||||
scierr = sc_seco_secvio_dgo_config(-1, dgo_id, 0, &data[0]);
|
||||
if (scierr == 0)
|
||||
err = sc_seco_secvio_dgo_config(-1, dgo_id, 0, &data[0]);
|
||||
if (!err)
|
||||
printf("\t- DGO %.2x: %.8x\n", dgo_id, data[0]);
|
||||
else
|
||||
printf("Failed to read DGO %d\n", dgo_id);
|
||||
|
|
|
@ -89,7 +89,6 @@ static int imx8_power_domain_on(struct power_domain *power_domain)
|
|||
struct udevice *dev = power_domain->dev;
|
||||
struct imx8_power_domain_plat *pdata;
|
||||
struct imx8_power_domain_priv *ppriv;
|
||||
sc_err_t ret;
|
||||
int err;
|
||||
|
||||
struct power_domain parent_domain;
|
||||
|
@ -117,11 +116,11 @@ static int imx8_power_domain_on(struct power_domain *power_domain)
|
|||
if (!sc_rm_is_resource_owned(-1, pdata->resource_id))
|
||||
printf("%s [%d] not owned by curr partition\n", dev->name, pdata->resource_id);
|
||||
|
||||
ret = sc_pm_set_resource_power_mode(-1, pdata->resource_id,
|
||||
err = sc_pm_set_resource_power_mode(-1, pdata->resource_id,
|
||||
SC_PM_PW_MODE_ON);
|
||||
if (ret) {
|
||||
if (err) {
|
||||
printf("Error: %s Power up failed! (error = %d)\n",
|
||||
dev->name, ret);
|
||||
dev->name, err);
|
||||
return -EIO;
|
||||
}
|
||||
}
|
||||
|
@ -139,7 +138,7 @@ static int imx8_power_domain_off_node(struct power_domain *power_domain)
|
|||
struct imx8_power_domain_priv *ppriv;
|
||||
struct imx8_power_domain_priv *child_ppriv;
|
||||
struct imx8_power_domain_plat *pdata;
|
||||
sc_err_t ret;
|
||||
int ret;
|
||||
|
||||
ppriv = dev_get_priv(dev);
|
||||
pdata = dev_get_plat(dev);
|
||||
|
|
Loading…
Add table
Reference in a new issue