1 /* 2 * Copyright 2014 Freescale Semiconductor 3 * 4 * SPDX-License-Identifier: GPL-2.0+ 5 */ 6 7 #include <common.h> 8 #include <asm/io.h> 9 #include <fsl_csu.h> 10 #include <asm/arch/ns_access.h> 11 12 static void enable_devices_ns_access(struct csu_ns_dev *ns_dev, uint32_t num) 13 { 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 } 32 33 void enable_layerscape_ns_access(void) 34 { 35 enable_devices_ns_access(ns_dev, ARRAY_SIZE(ns_dev)); 36 } 37