blob: d8d16c520f8234468c8a8f3c7dbe1638c6f70743 [file] [log] [blame]
Xiubo Lie87f3b32014-11-21 17:40:58 +08001/*
2 * Copyright 2014 Freescale Semiconductor
3 *
4 * SPDX-License-Identifier: GPL-2.0+
5 */
6
7#include <common.h>
8#include <asm/io.h>
Mingkai Hu435acd82015-10-26 19:47:41 +08009#include <fsl_csu.h>
Xiubo Lie87f3b32014-11-21 17:40:58 +080010#include <asm/arch/ns_access.h>
11
Mingkai Hu435acd82015-10-26 19:47:41 +080012static void enable_devices_ns_access(struct csu_ns_dev *ns_dev, uint32_t num)
Xiubo Lie87f3b32014-11-21 17:40:58 +080013{
14 u32 *base = (u32 *)CONFIG_SYS_FSL_CSU_ADDR;
15 u32 *reg;
16 uint32_t val;
17 int i;
18
19 for (i = 0; i < num; i++) {
20 reg = base + ns_dev[i].ind / 2;
21 val = in_be32(reg);
22 if (ns_dev[i].ind % 2 == 0) {
23 val &= 0x0000ffff;
24 val |= ns_dev[i].val << 16;
25 } else {
26 val &= 0xffff0000;
27 val |= ns_dev[i].val;
28 }
29 out_be32(reg, val);
30 }
31}
Mingkai Hu435acd82015-10-26 19:47:41 +080032
33void enable_layerscape_ns_access(void)
34{
35 enable_devices_ns_access(ns_dev, ARRAY_SIZE(ns_dev));
36}