summaryrefslogtreecommitdiff
path: root/plat/imx/common/scu_otp.c
blob: 73dd7250d99b1ccbad45689b4a0251395693287e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
 * Copyright 2018 NXP
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

#include <debug.h>
#include <stdlib.h>
#include <stdint.h>
#include <smcc_helpers.h>
#include <std_svc.h>
#include <types.h>
#include <platform_def.h>
#include <fsl_sip.h>
#include <sci/sci.h>

extern sc_ipc_t ipc_handle;

int imx_otp_handler(uint32_t smc_fid,
                    void *handle,
                    u_register_t x1,
                    u_register_t x2)
{
        int ret;
        uint32_t fuse;

        switch (smc_fid) {
            case FSL_SIP_OTP_READ:
                ret = sc_misc_otp_fuse_read(ipc_handle, x1, &fuse);
                SMC_RET2(handle, ret, fuse);
                break;
            case FSL_SIP_OTP_WRITE:
                ret = sc_misc_otp_fuse_write(ipc_handle, x1, x2);
                SMC_RET1(handle, ret);
            default:
                ret = SMC_UNK;
                SMC_RET1(handle, ret);
        }
}