1 /* 2 * Copyright (c) 2018-2019, ARM Limited and Contributors. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #include <endian.h> 8 9 #include <platform_def.h> 10 11 #include <common/debug.h> 12 #include <lib/mmio.h> 13 14 #include "ns_access.h" 15 enable_devices_ns_access(struct csu_ns_dev * _ns_dev,uint32_t num)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 enable_layerscape_ns_access(void)37void enable_layerscape_ns_access(void) 38 { 39 enable_devices_ns_access(ns_dev, ARRAY_SIZE(ns_dev)); 40 } 41