1 /*
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 <imx_rdc.h>
10 
imx_rdc_init(const struct imx_rdc_cfg * rdc_cfg)11 void imx_rdc_init(const struct imx_rdc_cfg *rdc_cfg)
12 {
13 	const struct imx_rdc_cfg *rdc = rdc_cfg;
14 
15 	while (rdc->type != RDC_INVALID) {
16 		switch (rdc->type) {
17 		case RDC_MDA:
18 			/* MDA config */
19 			mmio_write_32(MDAn(rdc->index), rdc->setting.rdc_mda);
20 			break;
21 		case RDC_PDAP:
22 			/* peripheral access permission config */
23 			mmio_write_32(PDAPn(rdc->index), rdc->setting.rdc_pdap);
24 			break;
25 		case RDC_MEM_REGION:
26 			/* memory region access permission config */
27 			mmio_write_32(MRSAn(rdc->index), rdc->setting.rdc_mem_region[0]);
28 			mmio_write_32(MREAn(rdc->index), rdc->setting.rdc_mem_region[1]);
29 			mmio_write_32(MRCn(rdc->index), rdc->setting.rdc_mem_region[2]);
30 			break;
31 		default:
32 			break;
33 		}
34 
35 		rdc++;
36 	}
37 }
38