blob: 478005e2ee82353e7aee0a9812630cb0abc3a8d6 [file] [log] [blame]
Jacky Bai3bf04a52019-06-12 17:41:47 +08001/*
2 * Copyright (c) 2019, NXP. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <lib/mmio.h>
8
9#include <imx8m_caam.h>
10
11void imx8m_caam_init(void)
12{
13 uint32_t sm_cmd;
14
15 /* Dealloc part 0 and 2 with current DID */
16 sm_cmd = (0 << SMC_PART_SHIFT | SMC_CMD_DEALLOC_PART);
17 mmio_write_32(SM_CMD, sm_cmd);
18
19 sm_cmd = (2 << SMC_PART_SHIFT | SMC_CMD_DEALLOC_PART);
20 mmio_write_32(SM_CMD, sm_cmd);
21
22 /* config CAAM JRaMID set MID to Cortex A */
23 mmio_write_32(CAAM_JR0MID, CAAM_NS_MID);
24 mmio_write_32(CAAM_JR1MID, CAAM_NS_MID);
25 mmio_write_32(CAAM_JR2MID, CAAM_NS_MID);
26
27 /* Alloc partition 0 writing SMPO and SMAGs */
28 mmio_write_32(SM_P0_PERM, 0xff);
29 mmio_write_32(SM_P0_SMAG2, 0xffffffff);
30 mmio_write_32(SM_P0_SMAG1, 0xffffffff);
31
32 /* Allocate page 0 and 1 to partition 0 with DID set */
33 sm_cmd = (0 << SMC_PAGE_SHIFT | 0 << SMC_PART_SHIFT |
34 SMC_CMD_ALLOC_PAGE);
35 mmio_write_32(SM_CMD, sm_cmd);
36
37 sm_cmd = (1 << SMC_PAGE_SHIFT | 0 << SMC_PART_SHIFT |
38 SMC_CMD_ALLOC_PAGE);
39 mmio_write_32(SM_CMD, sm_cmd);
40}