Xiubo Li | 54de065 | 2014-11-21 17:40:58 +0800 | [diff] [blame] | 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> |
Mingkai Hu | 5b0df8a | 2015-10-26 19:47:41 +0800 | [diff] [blame] | 9 | #include <fsl_csu.h> |
Xiubo Li | 54de065 | 2014-11-21 17:40:58 +0800 | [diff] [blame] | 10 | #include <asm/arch/ns_access.h> |
| 11 | |
Mingkai Hu | 5b0df8a | 2015-10-26 19:47:41 +0800 | [diff] [blame] | 12 | static void enable_devices_ns_access(struct csu_ns_dev *ns_dev, uint32_t num) |
Xiubo Li | 54de065 | 2014-11-21 17:40:58 +0800 | [diff] [blame] | 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 | } |
Mingkai Hu | 5b0df8a | 2015-10-26 19:47:41 +0800 | [diff] [blame] | 32 | |
| 33 | void enable_layerscape_ns_access(void) |
| 34 | { |
| 35 | enable_devices_ns_access(ns_dev, ARRAY_SIZE(ns_dev)); |
| 36 | } |