blob: e1daaed92abecc4afe8ba822dd769e2e64d90d9e [file] [log] [blame]
Jiafei Pan46367ad2018-03-02 07:23:30 +00001/*
2 * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <mmio.h>
8#include <endian.h>
9#include <debug.h>
10#include "ns_access.h"
11#include "platform_def.h"
12
13static void enable_devices_ns_access(struct csu_ns_dev *ns_dev, uint32_t num)
14{
15 uint32_t *base = (uint32_t *)CONFIG_SYS_FSL_CSU_ADDR;
16 uint32_t *reg;
17 uint32_t val;
18 int i;
19
20 for (i = 0; i < num; i++) {
21 reg = base + ns_dev[i].ind / 2;
22 val = be32toh(mmio_read_32((uintptr_t)reg));
23 if (ns_dev[i].ind % 2 == 0) {
24 val &= 0x0000ffff;
25 val |= ns_dev[i].val << 16;
26 } else {
27 val &= 0xffff0000;
28 val |= ns_dev[i].val;
29 }
30 mmio_write_32((uintptr_t)reg, htobe32(val));
31 }
32}
33
34void enable_layerscape_ns_access(void)
35{
36 enable_devices_ns_access(ns_dev, ARRAY_SIZE(ns_dev));
37}