Rajeshwari Shinde | bed2442 | 2013-07-04 12:29:17 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Lowlevel setup for EXYNOS5 based board |
| 3 | * |
| 4 | * Copyright (C) 2013 Samsung Electronics |
| 5 | * Rajeshwari Shinde <rajeshwari.s@samsung.com> |
| 6 | * |
| 7 | * See file CREDITS for list of people who contributed to this |
| 8 | * project. |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or |
| 11 | * modify it under the terms of the GNU General Public License as |
| 12 | * published by the Free Software Foundation; either version 2 of |
| 13 | * the License, or (at your option) any later version. |
| 14 | * |
| 15 | * This program is distributed in the hope that it will be useful, |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | * GNU General Public License for more details. |
| 19 | * |
| 20 | * You should have received a copy of the GNU General Public License |
| 21 | * along with this program; if not, write to the Free Software |
| 22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 23 | * MA 02111-1307 USA |
| 24 | */ |
| 25 | |
| 26 | #include <common.h> |
| 27 | #include <config.h> |
| 28 | #include <asm/arch/cpu.h> |
| 29 | #include <asm/arch/dmc.h> |
| 30 | #include <asm/arch/power.h> |
| 31 | #include <asm/arch/tzpc.h> |
| 32 | #include <asm/arch/periph.h> |
| 33 | #include <asm/arch/pinmux.h> |
Akshay Saraswat | 1d575af | 2015-02-20 13:27:12 +0530 | [diff] [blame^] | 34 | #include <asm/arch/system.h> |
Rajeshwari Shinde | bed2442 | 2013-07-04 12:29:17 +0530 | [diff] [blame] | 35 | #include "common_setup.h" |
Akshay Saraswat | 1d575af | 2015-02-20 13:27:12 +0530 | [diff] [blame^] | 36 | #include "exynos5_setup.h" |
Rajeshwari Shinde | bed2442 | 2013-07-04 12:29:17 +0530 | [diff] [blame] | 37 | |
| 38 | /* These are the things we can do during low-level init */ |
| 39 | enum { |
| 40 | DO_WAKEUP = 1 << 0, |
| 41 | DO_CLOCKS = 1 << 1, |
| 42 | DO_MEM_RESET = 1 << 2, |
| 43 | DO_UART = 1 << 3, |
Doug Anderson | 6a39e7f | 2014-05-29 21:40:54 +0530 | [diff] [blame] | 44 | DO_POWER = 1 << 4, |
Rajeshwari Shinde | bed2442 | 2013-07-04 12:29:17 +0530 | [diff] [blame] | 45 | }; |
| 46 | |
Akshay Saraswat | 1d575af | 2015-02-20 13:27:12 +0530 | [diff] [blame^] | 47 | #ifdef CONFIG_EXYNOS5420 |
| 48 | /* |
| 49 | * Pointer to this function is stored in iRam which is used |
| 50 | * for jump and power down of a specific core. |
| 51 | */ |
| 52 | static void power_down_core(void) |
| 53 | { |
| 54 | uint32_t tmp, core_id, core_config; |
| 55 | |
| 56 | /* Get the unique core id */ |
| 57 | /* |
| 58 | * Multiprocessor Affinity Register |
| 59 | * [11:8] Cluster ID |
| 60 | * [1:0] CPU ID |
| 61 | */ |
| 62 | mrc_mpafr(core_id); |
| 63 | tmp = core_id & 0x3; |
| 64 | core_id = (core_id >> 6) & ~3; |
| 65 | core_id |= tmp; |
| 66 | core_id &= 0x3f; |
| 67 | |
| 68 | /* Set the status of the core to low */ |
| 69 | core_config = (core_id * CPU_CONFIG_STATUS_OFFSET); |
| 70 | core_config += EXYNOS5420_CPU_CONFIG_BASE; |
| 71 | writel(0x0, core_config); |
| 72 | |
| 73 | /* Core enter WFI */ |
| 74 | wfi(); |
| 75 | } |
| 76 | |
| 77 | /* |
| 78 | * Configurations for secondary cores are inapt at this stage. |
| 79 | * Reconfigure secondary cores. Shutdown and change the status |
| 80 | * of all cores except the primary core. |
| 81 | */ |
| 82 | static void secondary_cores_configure(void) |
| 83 | { |
| 84 | uint32_t core_id; |
| 85 | |
| 86 | /* Store jump address for power down of secondary cores */ |
| 87 | writel((uint32_t)&power_down_core, CONFIG_PHY_IRAM_BASE + 0x4); |
| 88 | |
| 89 | /* Need all core power down check */ |
| 90 | dsb(); |
| 91 | sev(); |
| 92 | |
| 93 | /* |
| 94 | * Power down all cores(secondary) while primary core must |
| 95 | * wait for all cores to go down. |
| 96 | */ |
| 97 | for (core_id = 1; core_id != CONFIG_CORE_COUNT; core_id++) { |
| 98 | while ((readl(EXYNOS5420_CPU_STATUS_BASE |
| 99 | + (core_id * CPU_CONFIG_STATUS_OFFSET)) |
| 100 | & 0xff) != 0x0) { |
| 101 | isb(); |
| 102 | sev(); |
| 103 | } |
| 104 | isb(); |
| 105 | } |
| 106 | } |
| 107 | #endif |
| 108 | |
Rajeshwari Shinde | bed2442 | 2013-07-04 12:29:17 +0530 | [diff] [blame] | 109 | int do_lowlevel_init(void) |
| 110 | { |
| 111 | uint32_t reset_status; |
| 112 | int actions = 0; |
| 113 | |
| 114 | arch_cpu_init(); |
| 115 | |
Akshay Saraswat | 1d575af | 2015-02-20 13:27:12 +0530 | [diff] [blame^] | 116 | #ifdef CONFIG_EXYNOS5420 |
| 117 | /* Reconfigure secondary cores */ |
| 118 | secondary_cores_configure(); |
| 119 | #endif |
| 120 | |
Rajeshwari Shinde | bed2442 | 2013-07-04 12:29:17 +0530 | [diff] [blame] | 121 | reset_status = get_reset_status(); |
| 122 | |
| 123 | switch (reset_status) { |
| 124 | case S5P_CHECK_SLEEP: |
| 125 | actions = DO_CLOCKS | DO_WAKEUP; |
| 126 | break; |
| 127 | case S5P_CHECK_DIDLE: |
| 128 | case S5P_CHECK_LPA: |
| 129 | actions = DO_WAKEUP; |
| 130 | break; |
| 131 | default: |
| 132 | /* This is a normal boot (not a wake from sleep) */ |
Doug Anderson | 6a39e7f | 2014-05-29 21:40:54 +0530 | [diff] [blame] | 133 | actions = DO_CLOCKS | DO_MEM_RESET | DO_POWER; |
Rajeshwari Shinde | bed2442 | 2013-07-04 12:29:17 +0530 | [diff] [blame] | 134 | } |
| 135 | |
Doug Anderson | 6a39e7f | 2014-05-29 21:40:54 +0530 | [diff] [blame] | 136 | if (actions & DO_POWER) |
| 137 | set_ps_hold_ctrl(); |
| 138 | |
Rajeshwari Shinde | bed2442 | 2013-07-04 12:29:17 +0530 | [diff] [blame] | 139 | if (actions & DO_CLOCKS) { |
| 140 | system_clock_init(); |
| 141 | mem_ctrl_init(actions & DO_MEM_RESET); |
| 142 | tzpc_init(); |
| 143 | } |
| 144 | |
| 145 | return actions & DO_WAKEUP; |
| 146 | } |