blob: b84fdbd7e09029ba75c26ded461890d241f4e61d [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
Jiafei Pan46367ad2018-03-02 07:23:30 +00007#include <endian.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00008
9#include <platform_def.h>
10
11#include <common/debug.h>
12#include <lib/mmio.h>
13
Jiafei Pan46367ad2018-03-02 07:23:30 +000014#include "ns_access.h"
Jiafei Pan46367ad2018-03-02 07:23:30 +000015
16static void enable_devices_ns_access(struct csu_ns_dev *ns_dev, uint32_t num)
17{
18 uint32_t *base = (uint32_t *)CONFIG_SYS_FSL_CSU_ADDR;
19 uint32_t *reg;
20 uint32_t val;
21 int i;
22
23 for (i = 0; i < num; i++) {
24 reg = base + ns_dev[i].ind / 2;
25 val = be32toh(mmio_read_32((uintptr_t)reg));
26 if (ns_dev[i].ind % 2 == 0) {
27 val &= 0x0000ffff;
28 val |= ns_dev[i].val << 16;
29 } else {
30 val &= 0xffff0000;
31 val |= ns_dev[i].val;
32 }
33 mmio_write_32((uintptr_t)reg, htobe32(val));
34 }
35}
36
37void enable_layerscape_ns_access(void)
38{
39 enable_devices_ns_access(ns_dev, ARRAY_SIZE(ns_dev));
40}