Adrian Alonso | ee7c4ca | 2015-09-02 13:54:15 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 Freescale Semiconductor, Inc. |
| 3 | * |
| 4 | * SPDX-License-Identifier: GPL-2.0+ |
| 5 | */ |
| 6 | |
| 7 | #include <asm/io.h> |
| 8 | #include <asm/arch/imx-regs.h> |
| 9 | #include <asm/arch/clock.h> |
| 10 | #include <asm/arch/sys_proto.h> |
| 11 | #include <asm/imx-common/boot_mode.h> |
| 12 | #include <asm/arch/crm_regs.h> |
| 13 | |
| 14 | void init_aips(void) |
| 15 | { |
Adrian Alonso | c792900 | 2015-09-02 13:54:20 -0500 | [diff] [blame] | 16 | struct aipstz_regs *aips1, *aips2, *aips3; |
Adrian Alonso | ee7c4ca | 2015-09-02 13:54:15 -0500 | [diff] [blame] | 17 | |
| 18 | aips1 = (struct aipstz_regs *)AIPS1_BASE_ADDR; |
| 19 | aips2 = (struct aipstz_regs *)AIPS2_BASE_ADDR; |
Adrian Alonso | ee7c4ca | 2015-09-02 13:54:15 -0500 | [diff] [blame] | 20 | aips3 = (struct aipstz_regs *)AIPS3_BASE_ADDR; |
Adrian Alonso | ee7c4ca | 2015-09-02 13:54:15 -0500 | [diff] [blame] | 21 | |
| 22 | /* |
| 23 | * Set all MPROTx to be non-bufferable, trusted for R/W, |
| 24 | * not forced to user-mode. |
| 25 | */ |
| 26 | writel(0x77777777, &aips1->mprot0); |
| 27 | writel(0x77777777, &aips1->mprot1); |
| 28 | writel(0x77777777, &aips2->mprot0); |
| 29 | writel(0x77777777, &aips2->mprot1); |
| 30 | |
| 31 | /* |
| 32 | * Set all OPACRx to be non-bufferable, not require |
| 33 | * supervisor privilege level for access,allow for |
| 34 | * write access and untrusted master access. |
| 35 | */ |
| 36 | writel(0x00000000, &aips1->opacr0); |
| 37 | writel(0x00000000, &aips1->opacr1); |
| 38 | writel(0x00000000, &aips1->opacr2); |
| 39 | writel(0x00000000, &aips1->opacr3); |
| 40 | writel(0x00000000, &aips1->opacr4); |
| 41 | writel(0x00000000, &aips2->opacr0); |
| 42 | writel(0x00000000, &aips2->opacr1); |
| 43 | writel(0x00000000, &aips2->opacr2); |
| 44 | writel(0x00000000, &aips2->opacr3); |
| 45 | writel(0x00000000, &aips2->opacr4); |
| 46 | |
Adrian Alonso | c792900 | 2015-09-02 13:54:20 -0500 | [diff] [blame] | 47 | if (is_cpu_type(MXC_CPU_MX6SX) || is_soc_type(MXC_SOC_MX7)) |
| 48 | { |
| 49 | /* |
| 50 | * Set all MPROTx to be non-bufferable, trusted for R/W, |
| 51 | * not forced to user-mode. |
| 52 | */ |
| 53 | writel(0x77777777, &aips3->mprot0); |
| 54 | writel(0x77777777, &aips3->mprot1); |
Adrian Alonso | ee7c4ca | 2015-09-02 13:54:15 -0500 | [diff] [blame] | 55 | |
Adrian Alonso | c792900 | 2015-09-02 13:54:20 -0500 | [diff] [blame] | 56 | /* |
| 57 | * Set all OPACRx to be non-bufferable, not require |
| 58 | * supervisor privilege level for access,allow for |
| 59 | * write access and untrusted master access. |
| 60 | */ |
| 61 | writel(0x00000000, &aips3->opacr0); |
| 62 | writel(0x00000000, &aips3->opacr1); |
| 63 | writel(0x00000000, &aips3->opacr2); |
| 64 | writel(0x00000000, &aips3->opacr3); |
| 65 | writel(0x00000000, &aips3->opacr4); |
| 66 | } |
Adrian Alonso | ee7c4ca | 2015-09-02 13:54:15 -0500 | [diff] [blame] | 67 | } |
| 68 | |
Adrian Alonso | 51d70f7 | 2015-09-02 13:54:21 -0500 | [diff] [blame] | 69 | void imx_set_wdog_powerdown(bool enable) |
| 70 | { |
| 71 | struct wdog_regs *wdog1 = (struct wdog_regs *)WDOG1_BASE_ADDR; |
| 72 | struct wdog_regs *wdog2 = (struct wdog_regs *)WDOG2_BASE_ADDR; |
| 73 | struct wdog_regs *wdog3 = (struct wdog_regs *)WDOG3_BASE_ADDR; |
| 74 | #ifdef CONFIG_MX7D |
| 75 | struct wdog_regs *wdog4 = (struct wdog_regs *)WDOG4_BASE_ADDR; |
| 76 | #endif |
| 77 | |
| 78 | /* Write to the PDE (Power Down Enable) bit */ |
| 79 | writew(enable, &wdog1->wmcr); |
| 80 | writew(enable, &wdog2->wmcr); |
| 81 | |
| 82 | if (is_cpu_type(MXC_CPU_MX6SX) || is_cpu_type(MXC_CPU_MX6UL) || |
| 83 | is_soc_type(MXC_SOC_MX7)) |
| 84 | writew(enable, &wdog3->wmcr); |
| 85 | #ifdef CONFIG_MX7D |
| 86 | writew(enable, &wdog4->wmcr); |
| 87 | #endif |
| 88 | } |
| 89 | |
Adrian Alonso | ee7c4ca | 2015-09-02 13:54:15 -0500 | [diff] [blame] | 90 | #define SRC_SCR_WARM_RESET_ENABLE 0 |
| 91 | |
| 92 | void init_src(void) |
| 93 | { |
| 94 | struct src *src_regs = (struct src *)SRC_BASE_ADDR; |
| 95 | u32 val; |
| 96 | |
| 97 | /* |
| 98 | * force warm reset sources to generate cold reset |
| 99 | * for a more reliable restart |
| 100 | */ |
| 101 | val = readl(&src_regs->scr); |
| 102 | val &= ~(1 << SRC_SCR_WARM_RESET_ENABLE); |
| 103 | writel(val, &src_regs->scr); |
| 104 | } |
| 105 | |
Peng Fan | 40a85d4 | 2015-09-15 14:05:06 +0800 | [diff] [blame^] | 106 | #ifdef CONFIG_CMD_BMODE |
Adrian Alonso | ee7c4ca | 2015-09-02 13:54:15 -0500 | [diff] [blame] | 107 | void boot_mode_apply(unsigned cfg_val) |
| 108 | { |
| 109 | unsigned reg; |
| 110 | struct src *psrc = (struct src *)SRC_BASE_ADDR; |
| 111 | writel(cfg_val, &psrc->gpr9); |
| 112 | reg = readl(&psrc->gpr10); |
| 113 | if (cfg_val) |
| 114 | reg |= 1 << 28; |
| 115 | else |
| 116 | reg &= ~(1 << 28); |
| 117 | writel(reg, &psrc->gpr10); |
| 118 | } |
Peng Fan | 40a85d4 | 2015-09-15 14:05:06 +0800 | [diff] [blame^] | 119 | #endif |