Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2011, Code Aurora Forum. All rights reserved. |
| 2 | * |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License version 2 and |
| 5 | * only version 2 as published by the Free Software Foundation. |
| 6 | * |
| 7 | * This program is distributed in the hope that it will be useful, |
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | * GNU General Public License for more details. |
| 11 | */ |
| 12 | |
| 13 | #include <linux/kernel.h> |
| 14 | #include <linux/err.h> |
| 15 | #include <linux/io.h> |
| 16 | #include <linux/elf.h> |
| 17 | #include <linux/delay.h> |
| 18 | #include <linux/module.h> |
| 19 | #include <linux/slab.h> |
| 20 | #include <linux/regulator/consumer.h> |
Stephen Boyd | 9802ca9 | 2011-05-25 15:09:59 -0700 | [diff] [blame] | 21 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 22 | #include <asm/mach-types.h> |
| 23 | |
Stephen Boyd | 9802ca9 | 2011-05-25 15:09:59 -0700 | [diff] [blame] | 24 | #include <mach/msm_iomap.h> |
| 25 | #include <mach/scm.h> |
| 26 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 27 | #include "peripheral-loader.h" |
Stephen Boyd | e44ec39 | 2011-08-29 12:03:24 -0700 | [diff] [blame^] | 28 | #include "scm-pas.h" |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 29 | |
| 30 | #define MSM_FW_QDSP6SS_PHYS 0x08800000 |
| 31 | #define MSM_SW_QDSP6SS_PHYS 0x08900000 |
| 32 | #define MSM_LPASS_QDSP6SS_PHYS 0x28800000 |
| 33 | #define MSM_MSS_ENABLE_PHYS 0x08B00000 |
| 34 | |
| 35 | #define QDSP6SS_RST_EVB 0x0 |
| 36 | #define QDSP6SS_RESET 0x04 |
| 37 | #define QDSP6SS_CGC_OVERRIDE 0x18 |
| 38 | #define QDSP6SS_STRAP_TCM 0x1C |
| 39 | #define QDSP6SS_STRAP_AHB 0x20 |
| 40 | #define QDSP6SS_GFMUX_CTL 0x30 |
| 41 | #define QDSP6SS_PWR_CTL 0x38 |
| 42 | |
| 43 | #define MSS_S_HCLK_CTL (MSM_CLK_CTL_BASE + 0x2C70) |
| 44 | #define MSS_SLP_CLK_CTL (MSM_CLK_CTL_BASE + 0x2C60) |
| 45 | #define SFAB_MSS_M_ACLK_CTL (MSM_CLK_CTL_BASE + 0x2340) |
| 46 | #define SFAB_MSS_S_HCLK_CTL (MSM_CLK_CTL_BASE + 0x2C00) |
| 47 | #define SFAB_MSS_Q6_FW_ACLK_CTL (MSM_CLK_CTL_BASE + 0x2044) |
| 48 | #define SFAB_MSS_Q6_SW_ACLK_CTL (MSM_CLK_CTL_BASE + 0x2040) |
| 49 | #define SFAB_LPASS_Q6_ACLK_CTL (MSM_CLK_CTL_BASE + 0x23A0) |
| 50 | #define MSS_Q6FW_JTAG_CLK_CTL (MSM_CLK_CTL_BASE + 0x2C6C) |
| 51 | #define MSS_Q6SW_JTAG_CLK_CTL (MSM_CLK_CTL_BASE + 0x2C68) |
| 52 | #define MSS_RESET (MSM_CLK_CTL_BASE + 0x2C64) |
| 53 | |
| 54 | #define Q6SS_SS_ARES BIT(0) |
| 55 | #define Q6SS_CORE_ARES BIT(1) |
| 56 | #define Q6SS_ISDB_ARES BIT(2) |
| 57 | #define Q6SS_ETM_ARES BIT(3) |
| 58 | #define Q6SS_STOP_CORE_ARES BIT(4) |
| 59 | #define Q6SS_PRIV_ARES BIT(5) |
| 60 | |
| 61 | #define Q6SS_L2DATA_SLP_NRET_N BIT(0) |
| 62 | #define Q6SS_SLP_RET_N BIT(1) |
| 63 | #define Q6SS_L1TCM_SLP_NRET_N BIT(2) |
| 64 | #define Q6SS_L2TAG_SLP_NRET_N BIT(3) |
| 65 | #define Q6SS_ETB_SLEEP_NRET_N BIT(4) |
| 66 | #define Q6SS_ARR_STBY_N BIT(5) |
| 67 | #define Q6SS_CLAMP_IO BIT(6) |
| 68 | |
| 69 | #define Q6SS_CLK_ENA BIT(1) |
| 70 | #define Q6SS_SRC_SWITCH_CLK_OVR BIT(8) |
| 71 | #define Q6SS_AXIS_ACLK_EN BIT(9) |
| 72 | |
| 73 | #define MSM_RIVA_PHYS 0x03204000 |
| 74 | #define RIVA_PMU_A2XB_CFG (msm_riva_base + 0xB8) |
| 75 | #define RIVA_PMU_A2XB_CFG_EN BIT(0) |
| 76 | |
| 77 | #define RIVA_PMU_CFG (msm_riva_base + 0x28) |
| 78 | #define RIVA_PMU_CFG_WARM_BOOT BIT(0) |
| 79 | #define RIVA_PMU_CFG_IRIS_XO_MODE 0x6 |
| 80 | #define RIVA_PMU_CFG_IRIS_XO_MODE_48 (3 << 1) |
| 81 | |
| 82 | #define RIVA_PMU_OVRD_VAL (msm_riva_base + 0x30) |
| 83 | #define RIVA_PMU_OVRD_VAL_CCPU_RESET BIT(0) |
| 84 | #define RIVA_PMU_OVRD_VAL_CCPU_CLK BIT(1) |
| 85 | |
| 86 | #define RIVA_PMU_CCPU_CTL (msm_riva_base + 0x9C) |
| 87 | #define RIVA_PMU_CCPU_CTL_HIGH_IVT BIT(0) |
| 88 | #define RIVA_PMU_CCPU_CTL_REMAP_EN BIT(2) |
| 89 | |
| 90 | #define RIVA_PMU_CCPU_BOOT_REMAP_ADDR (msm_riva_base + 0xA0) |
| 91 | |
| 92 | #define RIVA_PLL_MODE (MSM_CLK_CTL_BASE + 0x31A0) |
| 93 | #define PLL_MODE_OUTCTRL BIT(0) |
| 94 | #define PLL_MODE_BYPASSNL BIT(1) |
| 95 | #define PLL_MODE_RESET_N BIT(2) |
| 96 | #define PLL_MODE_REF_XO_SEL 0x30 |
| 97 | #define PLL_MODE_REF_XO_SEL_CXO (2 << 4) |
| 98 | #define PLL_MODE_REF_XO_SEL_RF (3 << 4) |
| 99 | #define RIVA_PLL_L_VAL (MSM_CLK_CTL_BASE + 0x31A4) |
| 100 | #define RIVA_PLL_M_VAL (MSM_CLK_CTL_BASE + 0x31A8) |
| 101 | #define RIVA_PLL_N_VAL (MSM_CLK_CTL_BASE + 0x31Ac) |
| 102 | #define RIVA_PLL_CONFIG (MSM_CLK_CTL_BASE + 0x31B4) |
| 103 | #define RIVA_PLL_STATUS (MSM_CLK_CTL_BASE + 0x31B8) |
| 104 | |
| 105 | #define RIVA_PMU_ROOT_CLK_SEL (msm_riva_base + 0xC8) |
| 106 | #define RIVA_PMU_ROOT_CLK_SEL_3 BIT(2) |
| 107 | |
| 108 | #define RIVA_PMU_CLK_ROOT3 (msm_riva_base + 0x78) |
| 109 | #define RIVA_PMU_CLK_ROOT3_ENA BIT(0) |
| 110 | #define RIVA_PMU_CLK_ROOT3_SRC0_DIV 0x3C |
| 111 | #define RIVA_PMU_CLK_ROOT3_SRC0_DIV_2 (1 << 2) |
| 112 | #define RIVA_PMU_CLK_ROOT3_SRC0_SEL 0x1C0 |
| 113 | #define RIVA_PMU_CLK_ROOT3_SRC0_SEL_RIVA (1 << 6) |
| 114 | #define RIVA_PMU_CLK_ROOT3_SRC1_DIV 0x1E00 |
| 115 | #define RIVA_PMU_CLK_ROOT3_SRC1_DIV_2 (1 << 9) |
| 116 | #define RIVA_PMU_CLK_ROOT3_SRC1_SEL 0xE000 |
| 117 | #define RIVA_PMU_CLK_ROOT3_SRC1_SEL_RIVA (1 << 13) |
| 118 | |
| 119 | #define PPSS_RESET (MSM_CLK_CTL_BASE + 0x2594) |
| 120 | #define PPSS_PROC_CLK_CTL (MSM_CLK_CTL_BASE + 0x2588) |
| 121 | #define PPSS_HCLK_CTL (MSM_CLK_CTL_BASE + 0x2580) |
| 122 | |
| 123 | struct q6_data { |
| 124 | const unsigned strap_tcm_base; |
| 125 | const unsigned strap_ahb_upper; |
| 126 | const unsigned strap_ahb_lower; |
Matt Wagantall | 0b2f982 | 2011-07-12 20:11:28 -0700 | [diff] [blame] | 127 | const unsigned reg_base_phys; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 128 | void __iomem *reg_base; |
| 129 | void __iomem *aclk_reg; |
| 130 | void __iomem *jtag_clk_reg; |
| 131 | int start_addr; |
| 132 | struct regulator *vreg; |
| 133 | bool vreg_enabled; |
| 134 | const char *name; |
| 135 | }; |
| 136 | |
| 137 | static struct q6_data q6_lpass = { |
| 138 | .strap_tcm_base = (0x146 << 16), |
| 139 | .strap_ahb_upper = (0x029 << 16), |
| 140 | .strap_ahb_lower = (0x028 << 4), |
Matt Wagantall | 0b2f982 | 2011-07-12 20:11:28 -0700 | [diff] [blame] | 141 | .reg_base_phys = MSM_LPASS_QDSP6SS_PHYS, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 142 | .aclk_reg = SFAB_LPASS_Q6_ACLK_CTL, |
| 143 | .name = "q6_lpass", |
| 144 | }; |
| 145 | |
| 146 | static struct q6_data q6_modem_fw = { |
| 147 | .strap_tcm_base = (0x40 << 16), |
| 148 | .strap_ahb_upper = (0x09 << 16), |
| 149 | .strap_ahb_lower = (0x08 << 4), |
Matt Wagantall | 0b2f982 | 2011-07-12 20:11:28 -0700 | [diff] [blame] | 150 | .reg_base_phys = MSM_FW_QDSP6SS_PHYS, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 151 | .aclk_reg = SFAB_MSS_Q6_FW_ACLK_CTL, |
| 152 | .jtag_clk_reg = MSS_Q6FW_JTAG_CLK_CTL, |
| 153 | .name = "q6_modem_fw", |
| 154 | }; |
| 155 | |
| 156 | static struct q6_data q6_modem_sw = { |
| 157 | .strap_tcm_base = (0x42 << 16), |
| 158 | .strap_ahb_upper = (0x09 << 16), |
| 159 | .strap_ahb_lower = (0x08 << 4), |
Matt Wagantall | 0b2f982 | 2011-07-12 20:11:28 -0700 | [diff] [blame] | 160 | .reg_base_phys = MSM_SW_QDSP6SS_PHYS, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 161 | .aclk_reg = SFAB_MSS_Q6_SW_ACLK_CTL, |
| 162 | .jtag_clk_reg = MSS_Q6SW_JTAG_CLK_CTL, |
| 163 | .name = "q6_modem_sw", |
| 164 | }; |
| 165 | |
| 166 | static void __iomem *mss_enable_reg; |
| 167 | static void __iomem *msm_riva_base; |
| 168 | static unsigned long riva_start; |
| 169 | |
Stephen Boyd | 5bd999a | 2011-08-02 18:50:57 -0700 | [diff] [blame] | 170 | static int init_image_lpass_q6_trusted(struct pil_device *pil, |
| 171 | const u8 *metadata, size_t size) |
Stephen Boyd | 9802ca9 | 2011-05-25 15:09:59 -0700 | [diff] [blame] | 172 | { |
Stephen Boyd | e44ec39 | 2011-08-29 12:03:24 -0700 | [diff] [blame^] | 173 | return pas_init_image(PAS_Q6, metadata, size); |
Stephen Boyd | 9802ca9 | 2011-05-25 15:09:59 -0700 | [diff] [blame] | 174 | } |
| 175 | |
Stephen Boyd | 5bd999a | 2011-08-02 18:50:57 -0700 | [diff] [blame] | 176 | static int init_image_modem_fw_q6_trusted(struct pil_device *pil, |
| 177 | const u8 *metadata, size_t size) |
Stephen Boyd | 9802ca9 | 2011-05-25 15:09:59 -0700 | [diff] [blame] | 178 | { |
Stephen Boyd | e44ec39 | 2011-08-29 12:03:24 -0700 | [diff] [blame^] | 179 | return pas_init_image(PAS_MODEM_FW, metadata, size); |
Stephen Boyd | 9802ca9 | 2011-05-25 15:09:59 -0700 | [diff] [blame] | 180 | } |
| 181 | |
Stephen Boyd | 5bd999a | 2011-08-02 18:50:57 -0700 | [diff] [blame] | 182 | static int init_image_modem_sw_q6_trusted(struct pil_device *pil, |
| 183 | const u8 *metadata, size_t size) |
Stephen Boyd | 9802ca9 | 2011-05-25 15:09:59 -0700 | [diff] [blame] | 184 | { |
Stephen Boyd | e44ec39 | 2011-08-29 12:03:24 -0700 | [diff] [blame^] | 185 | return pas_init_image(PAS_MODEM_SW, metadata, size); |
Stephen Boyd | 9802ca9 | 2011-05-25 15:09:59 -0700 | [diff] [blame] | 186 | } |
| 187 | |
Stephen Boyd | 5bd999a | 2011-08-02 18:50:57 -0700 | [diff] [blame] | 188 | static int init_image_lpass_q6_untrusted(struct pil_device *pil, |
| 189 | const u8 *metadata, size_t size) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 190 | { |
| 191 | const struct elf32_hdr *ehdr = (struct elf32_hdr *)metadata; |
| 192 | q6_lpass.start_addr = ehdr->e_entry; |
| 193 | return 0; |
| 194 | } |
| 195 | |
Stephen Boyd | 5bd999a | 2011-08-02 18:50:57 -0700 | [diff] [blame] | 196 | static int init_image_modem_fw_q6_untrusted(struct pil_device *pil, |
| 197 | const u8 *metadata, size_t size) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 198 | { |
| 199 | const struct elf32_hdr *ehdr = (struct elf32_hdr *)metadata; |
| 200 | q6_modem_fw.start_addr = ehdr->e_entry; |
| 201 | return 0; |
| 202 | } |
| 203 | |
Stephen Boyd | 5bd999a | 2011-08-02 18:50:57 -0700 | [diff] [blame] | 204 | static int init_image_modem_sw_q6_untrusted(struct pil_device *pil, |
| 205 | const u8 *metadata, size_t size) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 206 | { |
| 207 | const struct elf32_hdr *ehdr = (struct elf32_hdr *)metadata; |
| 208 | q6_modem_sw.start_addr = ehdr->e_entry; |
| 209 | return 0; |
| 210 | } |
| 211 | |
Stephen Boyd | 5bd999a | 2011-08-02 18:50:57 -0700 | [diff] [blame] | 212 | static int verify_blob(struct pil_device *pil, u32 phy_addr, size_t size) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 213 | { |
| 214 | return 0; |
| 215 | } |
| 216 | |
Stephen Boyd | b6b5485 | 2011-08-16 14:16:27 -0700 | [diff] [blame] | 217 | static int power_up_q6(struct q6_data *q6) |
Stephen Boyd | 9802ca9 | 2011-05-25 15:09:59 -0700 | [diff] [blame] | 218 | { |
| 219 | int err; |
| 220 | |
| 221 | err = regulator_set_voltage(q6->vreg, 1050000, 1050000); |
| 222 | if (err) { |
| 223 | pr_err("Failed to set %s regulator's voltage.\n", q6->name); |
| 224 | return err; |
| 225 | } |
Stephen Boyd | b6b5485 | 2011-08-16 14:16:27 -0700 | [diff] [blame] | 226 | err = regulator_set_optimum_mode(q6->vreg, 100000); |
| 227 | if (err < 0) { |
| 228 | pr_err("Failed to set %s regulator's mode.\n", q6->name); |
| 229 | return err; |
| 230 | } |
Stephen Boyd | 9802ca9 | 2011-05-25 15:09:59 -0700 | [diff] [blame] | 231 | err = regulator_enable(q6->vreg); |
| 232 | if (err) { |
| 233 | pr_err("Failed to enable %s's regulator.\n", q6->name); |
| 234 | return err; |
| 235 | } |
| 236 | q6->vreg_enabled = true; |
Stephen Boyd | b6b5485 | 2011-08-16 14:16:27 -0700 | [diff] [blame] | 237 | return 0; |
Stephen Boyd | 9802ca9 | 2011-05-25 15:09:59 -0700 | [diff] [blame] | 238 | } |
| 239 | |
Stephen Boyd | b6b5485 | 2011-08-16 14:16:27 -0700 | [diff] [blame] | 240 | static int reset_q6_trusted(int id, struct q6_data *q6) |
| 241 | { |
| 242 | int err = power_up_q6(q6); |
| 243 | if (err) |
| 244 | return err; |
Stephen Boyd | e44ec39 | 2011-08-29 12:03:24 -0700 | [diff] [blame^] | 245 | return pas_auth_and_reset(id); |
Stephen Boyd | b6b5485 | 2011-08-16 14:16:27 -0700 | [diff] [blame] | 246 | } |
Stephen Boyd | 9802ca9 | 2011-05-25 15:09:59 -0700 | [diff] [blame] | 247 | |
Stephen Boyd | 5bd999a | 2011-08-02 18:50:57 -0700 | [diff] [blame] | 248 | static int reset_lpass_q6_trusted(struct pil_device *pil) |
Stephen Boyd | 9802ca9 | 2011-05-25 15:09:59 -0700 | [diff] [blame] | 249 | { |
| 250 | return reset_q6_trusted(PAS_Q6, &q6_lpass); |
| 251 | } |
| 252 | |
Stephen Boyd | 5bd999a | 2011-08-02 18:50:57 -0700 | [diff] [blame] | 253 | static int reset_modem_fw_q6_trusted(struct pil_device *pil) |
Stephen Boyd | 9802ca9 | 2011-05-25 15:09:59 -0700 | [diff] [blame] | 254 | { |
| 255 | return reset_q6_trusted(PAS_MODEM_FW, &q6_modem_fw); |
| 256 | } |
| 257 | |
Stephen Boyd | 5bd999a | 2011-08-02 18:50:57 -0700 | [diff] [blame] | 258 | static int reset_modem_sw_q6_trusted(struct pil_device *pil) |
Stephen Boyd | 9802ca9 | 2011-05-25 15:09:59 -0700 | [diff] [blame] | 259 | { |
| 260 | return reset_q6_trusted(PAS_MODEM_SW, &q6_modem_sw); |
| 261 | } |
| 262 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 263 | static int reset_q6_untrusted(struct q6_data *q6) |
| 264 | { |
| 265 | u32 reg, err = 0; |
| 266 | |
Stephen Boyd | b6b5485 | 2011-08-16 14:16:27 -0700 | [diff] [blame] | 267 | err = power_up_q6(q6); |
| 268 | if (err) |
| 269 | return err; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 270 | /* Enable Q6 ACLK */ |
| 271 | writel_relaxed(0x10, q6->aclk_reg); |
| 272 | |
| 273 | if (q6 == &q6_modem_fw || q6 == &q6_modem_sw) { |
| 274 | /* Enable MSS clocks */ |
| 275 | writel_relaxed(0x10, SFAB_MSS_M_ACLK_CTL); |
| 276 | writel_relaxed(0x10, SFAB_MSS_S_HCLK_CTL); |
| 277 | writel_relaxed(0x10, MSS_S_HCLK_CTL); |
| 278 | writel_relaxed(0x10, MSS_SLP_CLK_CTL); |
| 279 | /* Wait for clocks to enable */ |
| 280 | mb(); |
| 281 | udelay(10); |
| 282 | |
| 283 | /* Enable JTAG clocks */ |
| 284 | /* TODO: Remove if/when Q6 software enables them? */ |
| 285 | writel_relaxed(0x10, q6->jtag_clk_reg); |
| 286 | |
| 287 | /* De-assert MSS reset */ |
| 288 | writel_relaxed(0x0, MSS_RESET); |
| 289 | mb(); |
| 290 | udelay(10); |
| 291 | |
| 292 | /* Enable MSS */ |
| 293 | writel_relaxed(0x7, mss_enable_reg); |
| 294 | } |
| 295 | |
| 296 | /* |
| 297 | * Assert AXIS_ACLK_EN override to allow for correct updating of the |
| 298 | * QDSP6_CORE_STATE status bit. This is mandatory only for the SW Q6 |
| 299 | * in 8960v1 and optional elsewhere. |
| 300 | */ |
| 301 | reg = readl_relaxed(q6->reg_base + QDSP6SS_CGC_OVERRIDE); |
| 302 | reg |= Q6SS_AXIS_ACLK_EN; |
| 303 | writel_relaxed(reg, q6->reg_base + QDSP6SS_CGC_OVERRIDE); |
| 304 | |
| 305 | /* Deassert Q6SS_SS_ARES */ |
| 306 | reg = readl_relaxed(q6->reg_base + QDSP6SS_RESET); |
| 307 | reg &= ~(Q6SS_SS_ARES); |
| 308 | writel_relaxed(reg, q6->reg_base + QDSP6SS_RESET); |
| 309 | |
| 310 | /* Program boot address */ |
| 311 | writel_relaxed((q6->start_addr >> 8) & 0xFFFFFF, |
| 312 | q6->reg_base + QDSP6SS_RST_EVB); |
| 313 | |
| 314 | /* Program TCM and AHB address ranges */ |
| 315 | writel_relaxed(q6->strap_tcm_base, q6->reg_base + QDSP6SS_STRAP_TCM); |
| 316 | writel_relaxed(q6->strap_ahb_upper | q6->strap_ahb_lower, |
| 317 | q6->reg_base + QDSP6SS_STRAP_AHB); |
| 318 | |
| 319 | /* Turn off Q6 core clock */ |
| 320 | writel_relaxed(Q6SS_SRC_SWITCH_CLK_OVR, |
| 321 | q6->reg_base + QDSP6SS_GFMUX_CTL); |
| 322 | |
| 323 | /* Put memories to sleep */ |
| 324 | writel_relaxed(Q6SS_CLAMP_IO, q6->reg_base + QDSP6SS_PWR_CTL); |
| 325 | |
| 326 | /* Assert resets */ |
| 327 | reg = readl_relaxed(q6->reg_base + QDSP6SS_RESET); |
| 328 | reg |= (Q6SS_CORE_ARES | Q6SS_ISDB_ARES | Q6SS_ETM_ARES |
| 329 | | Q6SS_STOP_CORE_ARES); |
| 330 | writel_relaxed(reg, q6->reg_base + QDSP6SS_RESET); |
| 331 | |
| 332 | /* Wait 8 AHB cycles for Q6 to be fully reset (AHB = 1.5Mhz) */ |
| 333 | mb(); |
| 334 | usleep_range(20, 30); |
| 335 | |
| 336 | /* Turn on Q6 memories */ |
| 337 | reg = Q6SS_L2DATA_SLP_NRET_N | Q6SS_SLP_RET_N | Q6SS_L1TCM_SLP_NRET_N |
| 338 | | Q6SS_L2TAG_SLP_NRET_N | Q6SS_ETB_SLEEP_NRET_N | Q6SS_ARR_STBY_N |
| 339 | | Q6SS_CLAMP_IO; |
| 340 | writel_relaxed(reg, q6->reg_base + QDSP6SS_PWR_CTL); |
| 341 | |
| 342 | /* Turn on Q6 core clock */ |
| 343 | reg = Q6SS_CLK_ENA | Q6SS_SRC_SWITCH_CLK_OVR; |
| 344 | writel_relaxed(reg, q6->reg_base + QDSP6SS_GFMUX_CTL); |
| 345 | |
| 346 | /* Remove Q6SS_CLAMP_IO */ |
| 347 | reg = readl_relaxed(q6->reg_base + QDSP6SS_PWR_CTL); |
| 348 | reg &= ~Q6SS_CLAMP_IO; |
| 349 | writel_relaxed(reg, q6->reg_base + QDSP6SS_PWR_CTL); |
| 350 | |
| 351 | /* Bring Q6 core out of reset and start execution. */ |
| 352 | writel_relaxed(0x0, q6->reg_base + QDSP6SS_RESET); |
| 353 | |
| 354 | /* |
| 355 | * Re-enable auto-gating of AXIS_ACLK at lease one AXI clock cycle |
| 356 | * after resets are de-asserted. |
| 357 | */ |
| 358 | mb(); |
| 359 | usleep_range(1, 10); |
| 360 | reg = readl_relaxed(q6->reg_base + QDSP6SS_CGC_OVERRIDE); |
| 361 | reg &= ~Q6SS_AXIS_ACLK_EN; |
| 362 | writel_relaxed(reg, q6->reg_base + QDSP6SS_CGC_OVERRIDE); |
| 363 | |
Stephen Boyd | b6b5485 | 2011-08-16 14:16:27 -0700 | [diff] [blame] | 364 | return 0; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 365 | } |
| 366 | |
Stephen Boyd | 5bd999a | 2011-08-02 18:50:57 -0700 | [diff] [blame] | 367 | static int reset_lpass_q6_untrusted(struct pil_device *pil) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 368 | { |
| 369 | return reset_q6_untrusted(&q6_lpass); |
| 370 | } |
| 371 | |
Stephen Boyd | 5bd999a | 2011-08-02 18:50:57 -0700 | [diff] [blame] | 372 | static int reset_modem_fw_q6_untrusted(struct pil_device *pil) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 373 | { |
| 374 | return reset_q6_untrusted(&q6_modem_fw); |
| 375 | } |
| 376 | |
Stephen Boyd | 5bd999a | 2011-08-02 18:50:57 -0700 | [diff] [blame] | 377 | static int reset_modem_sw_q6_untrusted(struct pil_device *pil) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 378 | { |
| 379 | return reset_q6_untrusted(&q6_modem_sw); |
| 380 | } |
| 381 | |
Stephen Boyd | 9802ca9 | 2011-05-25 15:09:59 -0700 | [diff] [blame] | 382 | static int shutdown_q6_trusted(int id, struct q6_data *q6) |
| 383 | { |
| 384 | int ret; |
| 385 | |
Stephen Boyd | e44ec39 | 2011-08-29 12:03:24 -0700 | [diff] [blame^] | 386 | ret = pas_shutdown(id); |
Matt Wagantall | dafcd3d | 2011-08-02 20:27:59 -0700 | [diff] [blame] | 387 | if (ret) |
| 388 | return ret; |
| 389 | |
Stephen Boyd | 9802ca9 | 2011-05-25 15:09:59 -0700 | [diff] [blame] | 390 | if (q6->vreg_enabled) { |
| 391 | regulator_disable(q6->vreg); |
| 392 | q6->vreg_enabled = false; |
| 393 | } |
| 394 | |
| 395 | return ret; |
| 396 | } |
| 397 | |
Stephen Boyd | 5bd999a | 2011-08-02 18:50:57 -0700 | [diff] [blame] | 398 | static int shutdown_lpass_q6_trusted(struct pil_device *pil) |
Stephen Boyd | 9802ca9 | 2011-05-25 15:09:59 -0700 | [diff] [blame] | 399 | { |
| 400 | return shutdown_q6_trusted(PAS_Q6, &q6_lpass); |
| 401 | } |
| 402 | |
Stephen Boyd | 5bd999a | 2011-08-02 18:50:57 -0700 | [diff] [blame] | 403 | static int shutdown_modem_fw_q6_trusted(struct pil_device *pil) |
Stephen Boyd | 9802ca9 | 2011-05-25 15:09:59 -0700 | [diff] [blame] | 404 | { |
| 405 | return shutdown_q6_trusted(PAS_MODEM_FW, &q6_modem_fw); |
| 406 | } |
| 407 | |
Stephen Boyd | 5bd999a | 2011-08-02 18:50:57 -0700 | [diff] [blame] | 408 | static int shutdown_modem_sw_q6_trusted(struct pil_device *pil) |
Stephen Boyd | 9802ca9 | 2011-05-25 15:09:59 -0700 | [diff] [blame] | 409 | { |
| 410 | return shutdown_q6_trusted(PAS_MODEM_SW, &q6_modem_sw); |
| 411 | } |
| 412 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 413 | static int shutdown_q6_untrusted(struct q6_data *q6) |
| 414 | { |
| 415 | u32 reg; |
| 416 | |
| 417 | /* Turn off Q6 core clock */ |
| 418 | writel_relaxed(Q6SS_SRC_SWITCH_CLK_OVR, |
| 419 | q6->reg_base + QDSP6SS_GFMUX_CTL); |
| 420 | |
| 421 | /* Assert resets */ |
| 422 | reg = (Q6SS_SS_ARES | Q6SS_CORE_ARES | Q6SS_ISDB_ARES |
| 423 | | Q6SS_ETM_ARES | Q6SS_STOP_CORE_ARES | Q6SS_PRIV_ARES); |
| 424 | writel_relaxed(reg, q6->reg_base + QDSP6SS_RESET); |
| 425 | |
| 426 | /* Turn off Q6 memories */ |
| 427 | writel_relaxed(Q6SS_CLAMP_IO, q6->reg_base + QDSP6SS_PWR_CTL); |
| 428 | |
| 429 | /* Put Modem Subsystem back into reset when shutting down FWQ6 */ |
| 430 | if (q6 == &q6_modem_fw) |
| 431 | writel_relaxed(0x1, MSS_RESET); |
| 432 | |
| 433 | if (q6->vreg_enabled) { |
| 434 | regulator_disable(q6->vreg); |
| 435 | q6->vreg_enabled = false; |
| 436 | } |
| 437 | |
| 438 | return 0; |
| 439 | } |
| 440 | |
Stephen Boyd | 5bd999a | 2011-08-02 18:50:57 -0700 | [diff] [blame] | 441 | static int shutdown_lpass_q6_untrusted(struct pil_device *pil) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 442 | { |
| 443 | return shutdown_q6_untrusted(&q6_lpass); |
| 444 | } |
| 445 | |
Stephen Boyd | 5bd999a | 2011-08-02 18:50:57 -0700 | [diff] [blame] | 446 | static int shutdown_modem_fw_q6_untrusted(struct pil_device *pil) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 447 | { |
| 448 | return shutdown_q6_untrusted(&q6_modem_fw); |
| 449 | } |
| 450 | |
Stephen Boyd | 5bd999a | 2011-08-02 18:50:57 -0700 | [diff] [blame] | 451 | static int shutdown_modem_sw_q6_untrusted(struct pil_device *pil) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 452 | { |
| 453 | return shutdown_q6_untrusted(&q6_modem_sw); |
| 454 | } |
| 455 | |
Stephen Boyd | 5bd999a | 2011-08-02 18:50:57 -0700 | [diff] [blame] | 456 | static int init_image_riva_untrusted(struct pil_device *pil, const u8 *metadata, |
| 457 | size_t size) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 458 | { |
| 459 | const struct elf32_hdr *ehdr = (struct elf32_hdr *)metadata; |
| 460 | riva_start = ehdr->e_entry; |
| 461 | return 0; |
| 462 | } |
| 463 | |
Stephen Boyd | 5bd999a | 2011-08-02 18:50:57 -0700 | [diff] [blame] | 464 | static int reset_riva_untrusted(struct pil_device *pil) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 465 | { |
| 466 | u32 reg; |
| 467 | bool xo; |
| 468 | |
| 469 | /* Enable A2XB bridge */ |
| 470 | reg = readl(RIVA_PMU_A2XB_CFG); |
| 471 | reg |= RIVA_PMU_A2XB_CFG_EN; |
| 472 | writel(reg, RIVA_PMU_A2XB_CFG); |
| 473 | |
| 474 | /* Determine which XO to use */ |
| 475 | reg = readl(RIVA_PMU_CFG); |
| 476 | xo = (reg & RIVA_PMU_CFG_IRIS_XO_MODE) == RIVA_PMU_CFG_IRIS_XO_MODE_48; |
| 477 | |
| 478 | /* Program PLL 13 to 960 MHz */ |
| 479 | reg = readl(RIVA_PLL_MODE); |
| 480 | reg &= ~(PLL_MODE_BYPASSNL | PLL_MODE_OUTCTRL | PLL_MODE_RESET_N); |
| 481 | writel(reg, RIVA_PLL_MODE); |
| 482 | |
| 483 | if (xo) |
| 484 | writel(0x40000C00 | 40, RIVA_PLL_L_VAL); |
| 485 | else |
| 486 | writel(0x40000C00 | 50, RIVA_PLL_L_VAL); |
| 487 | writel(0, RIVA_PLL_M_VAL); |
| 488 | writel(1, RIVA_PLL_N_VAL); |
| 489 | writel_relaxed(0x01495227, RIVA_PLL_CONFIG); |
| 490 | |
| 491 | reg = readl(RIVA_PLL_MODE); |
| 492 | reg &= ~(PLL_MODE_REF_XO_SEL); |
| 493 | reg |= xo ? PLL_MODE_REF_XO_SEL_RF : PLL_MODE_REF_XO_SEL_CXO; |
| 494 | writel(reg, RIVA_PLL_MODE); |
| 495 | |
| 496 | /* Enable PLL 13 */ |
| 497 | reg |= PLL_MODE_BYPASSNL; |
| 498 | writel(reg, RIVA_PLL_MODE); |
| 499 | |
| 500 | usleep_range(10, 20); |
| 501 | |
| 502 | reg |= PLL_MODE_RESET_N; |
| 503 | writel(reg, RIVA_PLL_MODE); |
| 504 | reg |= PLL_MODE_OUTCTRL; |
| 505 | writel(reg, RIVA_PLL_MODE); |
| 506 | |
| 507 | /* Wait for PLL to settle */ |
| 508 | usleep_range(50, 100); |
| 509 | |
| 510 | /* Configure cCPU for 240 MHz */ |
| 511 | reg = readl(RIVA_PMU_CLK_ROOT3); |
| 512 | if (readl(RIVA_PMU_ROOT_CLK_SEL) & RIVA_PMU_ROOT_CLK_SEL_3) { |
| 513 | reg &= ~(RIVA_PMU_CLK_ROOT3_SRC0_SEL | |
| 514 | RIVA_PMU_CLK_ROOT3_SRC0_DIV); |
| 515 | reg |= RIVA_PMU_CLK_ROOT3_SRC0_SEL_RIVA | |
| 516 | RIVA_PMU_CLK_ROOT3_SRC0_DIV_2; |
| 517 | } else { |
| 518 | reg &= ~(RIVA_PMU_CLK_ROOT3_SRC1_SEL | |
| 519 | RIVA_PMU_CLK_ROOT3_SRC1_DIV); |
| 520 | reg |= RIVA_PMU_CLK_ROOT3_SRC1_SEL_RIVA | |
| 521 | RIVA_PMU_CLK_ROOT3_SRC1_DIV_2; |
| 522 | } |
| 523 | writel(reg, RIVA_PMU_CLK_ROOT3); |
| 524 | reg |= RIVA_PMU_CLK_ROOT3_ENA; |
| 525 | writel(reg, RIVA_PMU_CLK_ROOT3); |
| 526 | reg = readl(RIVA_PMU_ROOT_CLK_SEL); |
| 527 | reg ^= RIVA_PMU_ROOT_CLK_SEL_3; |
| 528 | writel(reg, RIVA_PMU_ROOT_CLK_SEL); |
| 529 | |
| 530 | /* Use the high vector table */ |
| 531 | reg = readl(RIVA_PMU_CCPU_CTL); |
| 532 | reg |= RIVA_PMU_CCPU_CTL_HIGH_IVT | RIVA_PMU_CCPU_CTL_REMAP_EN; |
| 533 | writel(reg, RIVA_PMU_CCPU_CTL); |
| 534 | |
| 535 | /* Set base memory address */ |
| 536 | writel_relaxed(riva_start >> 16, RIVA_PMU_CCPU_BOOT_REMAP_ADDR); |
| 537 | |
| 538 | /* Clear warmboot bit indicating this is a cold boot */ |
| 539 | reg = readl(RIVA_PMU_CFG); |
| 540 | reg &= ~(RIVA_PMU_CFG_WARM_BOOT); |
| 541 | writel(reg, RIVA_PMU_CFG); |
| 542 | |
| 543 | /* Enable the cCPU clock */ |
| 544 | reg = readl(RIVA_PMU_OVRD_VAL); |
| 545 | reg |= RIVA_PMU_OVRD_VAL_CCPU_CLK; |
| 546 | writel(reg, RIVA_PMU_OVRD_VAL); |
| 547 | |
| 548 | /* Take cCPU out of reset */ |
| 549 | reg |= RIVA_PMU_OVRD_VAL_CCPU_RESET; |
| 550 | writel(reg, RIVA_PMU_OVRD_VAL); |
| 551 | |
| 552 | return 0; |
| 553 | } |
| 554 | |
Stephen Boyd | 5bd999a | 2011-08-02 18:50:57 -0700 | [diff] [blame] | 555 | static int shutdown_riva_untrusted(struct pil_device *pil) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 556 | { |
| 557 | u32 reg; |
| 558 | /* Put riva into reset */ |
| 559 | reg = readl(RIVA_PMU_OVRD_VAL); |
| 560 | reg &= ~(RIVA_PMU_OVRD_VAL_CCPU_RESET | RIVA_PMU_OVRD_VAL_CCPU_CLK); |
| 561 | writel(reg, RIVA_PMU_OVRD_VAL); |
| 562 | return 0; |
| 563 | } |
| 564 | |
Stephen Boyd | 5bd999a | 2011-08-02 18:50:57 -0700 | [diff] [blame] | 565 | static int init_image_riva_trusted(struct pil_device *pil, const u8 *metadata, |
| 566 | size_t size) |
Stephen Boyd | cc72423 | 2011-08-17 17:56:00 -0700 | [diff] [blame] | 567 | { |
Stephen Boyd | e44ec39 | 2011-08-29 12:03:24 -0700 | [diff] [blame^] | 568 | return pas_init_image(PAS_RIVA, metadata, size); |
Stephen Boyd | cc72423 | 2011-08-17 17:56:00 -0700 | [diff] [blame] | 569 | } |
| 570 | |
Stephen Boyd | 5bd999a | 2011-08-02 18:50:57 -0700 | [diff] [blame] | 571 | static int reset_riva_trusted(struct pil_device *pil) |
Stephen Boyd | cc72423 | 2011-08-17 17:56:00 -0700 | [diff] [blame] | 572 | { |
Stephen Boyd | e44ec39 | 2011-08-29 12:03:24 -0700 | [diff] [blame^] | 573 | return pas_auth_and_reset(PAS_RIVA); |
Stephen Boyd | cc72423 | 2011-08-17 17:56:00 -0700 | [diff] [blame] | 574 | } |
| 575 | |
Stephen Boyd | 5bd999a | 2011-08-02 18:50:57 -0700 | [diff] [blame] | 576 | static int shutdown_riva_trusted(struct pil_device *pil) |
Stephen Boyd | cc72423 | 2011-08-17 17:56:00 -0700 | [diff] [blame] | 577 | { |
Stephen Boyd | e44ec39 | 2011-08-29 12:03:24 -0700 | [diff] [blame^] | 578 | return pas_shutdown(PAS_RIVA); |
Stephen Boyd | cc72423 | 2011-08-17 17:56:00 -0700 | [diff] [blame] | 579 | } |
| 580 | |
Stephen Boyd | 5bd999a | 2011-08-02 18:50:57 -0700 | [diff] [blame] | 581 | static int init_image_dsps_untrusted(struct pil_device *pil, const u8 *metadata, |
| 582 | size_t size) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 583 | { |
| 584 | /* Bring memory and bus interface out of reset */ |
| 585 | writel_relaxed(0x2, PPSS_RESET); |
| 586 | writel_relaxed(0x10, PPSS_HCLK_CTL); |
| 587 | return 0; |
| 588 | } |
| 589 | |
Stephen Boyd | 5bd999a | 2011-08-02 18:50:57 -0700 | [diff] [blame] | 590 | static int reset_dsps_untrusted(struct pil_device *pil) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 591 | { |
| 592 | writel_relaxed(0x10, PPSS_PROC_CLK_CTL); |
| 593 | /* Bring DSPS out of reset */ |
| 594 | writel_relaxed(0x0, PPSS_RESET); |
| 595 | return 0; |
| 596 | } |
| 597 | |
Stephen Boyd | 5bd999a | 2011-08-02 18:50:57 -0700 | [diff] [blame] | 598 | static int shutdown_dsps_untrusted(struct pil_device *pil) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 599 | { |
| 600 | writel_relaxed(0x2, PPSS_RESET); |
| 601 | writel_relaxed(0x0, PPSS_PROC_CLK_CTL); |
| 602 | return 0; |
| 603 | } |
| 604 | |
Stephen Boyd | 5bd999a | 2011-08-02 18:50:57 -0700 | [diff] [blame] | 605 | static int init_image_dsps_trusted(struct pil_device *pil, const u8 *metadata, |
| 606 | size_t size) |
Stephen Boyd | 9802ca9 | 2011-05-25 15:09:59 -0700 | [diff] [blame] | 607 | { |
Stephen Boyd | e44ec39 | 2011-08-29 12:03:24 -0700 | [diff] [blame^] | 608 | return pas_init_image(PAS_DSPS, metadata, size); |
Stephen Boyd | 9802ca9 | 2011-05-25 15:09:59 -0700 | [diff] [blame] | 609 | } |
| 610 | |
Stephen Boyd | 5bd999a | 2011-08-02 18:50:57 -0700 | [diff] [blame] | 611 | static int reset_dsps_trusted(struct pil_device *pil) |
Stephen Boyd | 9802ca9 | 2011-05-25 15:09:59 -0700 | [diff] [blame] | 612 | { |
Stephen Boyd | e44ec39 | 2011-08-29 12:03:24 -0700 | [diff] [blame^] | 613 | return pas_auth_and_reset(PAS_DSPS); |
Stephen Boyd | 9802ca9 | 2011-05-25 15:09:59 -0700 | [diff] [blame] | 614 | } |
| 615 | |
Stephen Boyd | 5bd999a | 2011-08-02 18:50:57 -0700 | [diff] [blame] | 616 | static int shutdown_dsps_trusted(struct pil_device *pil) |
Stephen Boyd | 9802ca9 | 2011-05-25 15:09:59 -0700 | [diff] [blame] | 617 | { |
Stephen Boyd | e44ec39 | 2011-08-29 12:03:24 -0700 | [diff] [blame^] | 618 | return pas_shutdown(PAS_DSPS); |
Stephen Boyd | 9802ca9 | 2011-05-25 15:09:59 -0700 | [diff] [blame] | 619 | } |
| 620 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 621 | static struct pil_reset_ops pil_modem_fw_q6_ops = { |
| 622 | .init_image = init_image_modem_fw_q6_untrusted, |
| 623 | .verify_blob = verify_blob, |
| 624 | .auth_and_reset = reset_modem_fw_q6_untrusted, |
| 625 | .shutdown = shutdown_modem_fw_q6_untrusted, |
| 626 | }; |
| 627 | |
| 628 | static struct pil_reset_ops pil_modem_sw_q6_ops = { |
| 629 | .init_image = init_image_modem_sw_q6_untrusted, |
| 630 | .verify_blob = verify_blob, |
| 631 | .auth_and_reset = reset_modem_sw_q6_untrusted, |
| 632 | .shutdown = shutdown_modem_sw_q6_untrusted, |
| 633 | }; |
| 634 | |
| 635 | static struct pil_reset_ops pil_lpass_q6_ops = { |
| 636 | .init_image = init_image_lpass_q6_untrusted, |
| 637 | .verify_blob = verify_blob, |
| 638 | .auth_and_reset = reset_lpass_q6_untrusted, |
| 639 | .shutdown = shutdown_lpass_q6_untrusted, |
| 640 | }; |
| 641 | |
| 642 | static struct pil_reset_ops pil_riva_ops = { |
| 643 | .init_image = init_image_riva_untrusted, |
| 644 | .verify_blob = verify_blob, |
| 645 | .auth_and_reset = reset_riva_untrusted, |
| 646 | .shutdown = shutdown_riva_untrusted, |
| 647 | }; |
| 648 | |
| 649 | struct pil_reset_ops pil_dsps_ops = { |
| 650 | .init_image = init_image_dsps_untrusted, |
| 651 | .verify_blob = verify_blob, |
| 652 | .auth_and_reset = reset_dsps_untrusted, |
| 653 | .shutdown = shutdown_dsps_untrusted, |
| 654 | }; |
| 655 | |
Matt Wagantall | 0b2f982 | 2011-07-12 20:11:28 -0700 | [diff] [blame] | 656 | static struct pil_device pil_lpass_q6 = { |
| 657 | .name = "q6", |
| 658 | .pdev = { |
| 659 | .name = "pil_lpass_q6", |
| 660 | .id = -1, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 661 | }, |
Matt Wagantall | 0b2f982 | 2011-07-12 20:11:28 -0700 | [diff] [blame] | 662 | .ops = &pil_lpass_q6_ops, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 663 | }; |
| 664 | |
Matt Wagantall | 0b2f982 | 2011-07-12 20:11:28 -0700 | [diff] [blame] | 665 | static struct pil_device pil_modem_fw_q6 = { |
| 666 | .name = "modem_fw", |
| 667 | .depends_on = "q6", |
| 668 | .pdev = { |
| 669 | .name = "pil_modem_fw_q6", |
| 670 | .id = -1, |
| 671 | }, |
| 672 | .ops = &pil_modem_fw_q6_ops, |
| 673 | }; |
| 674 | |
| 675 | static struct pil_device pil_modem_sw_q6 = { |
| 676 | .name = "modem", |
| 677 | .depends_on = "modem_fw", |
| 678 | .pdev = { |
| 679 | .name = "pil_modem_sw_q6", |
| 680 | .id = -1, |
| 681 | }, |
| 682 | .ops = &pil_modem_sw_q6_ops, |
| 683 | }; |
| 684 | |
| 685 | static struct pil_device pil_riva = { |
| 686 | .name = "wcnss", |
| 687 | .pdev = { |
| 688 | .name = "pil_riva", |
| 689 | .id = -1, |
| 690 | }, |
| 691 | .ops = &pil_riva_ops, |
| 692 | }; |
| 693 | |
| 694 | static struct pil_device pil_dsps = { |
| 695 | .name = "dsps", |
| 696 | .pdev = { |
| 697 | .name = "pil_dsps", |
| 698 | .id = -1, |
| 699 | }, |
| 700 | .ops = &pil_dsps_ops, |
| 701 | }; |
| 702 | |
| 703 | static int __init q6_reset_init(struct q6_data *q6) |
| 704 | { |
| 705 | int err; |
| 706 | |
| 707 | q6->reg_base = ioremap(q6->reg_base_phys, SZ_256); |
| 708 | if (!q6->reg_base) { |
| 709 | err = -ENOMEM; |
| 710 | goto err_map; |
| 711 | } |
| 712 | |
| 713 | q6->vreg = regulator_get(NULL, q6->name); |
| 714 | if (IS_ERR(q6->vreg)) { |
| 715 | err = PTR_ERR(q6->vreg); |
| 716 | goto err_vreg; |
| 717 | } |
| 718 | |
| 719 | return 0; |
| 720 | |
| 721 | err_vreg: |
| 722 | iounmap(q6->reg_base); |
| 723 | err_map: |
| 724 | return err; |
| 725 | } |
| 726 | |
Saravana Kannan | 76cc49b | 2011-09-07 19:59:04 -0700 | [diff] [blame] | 727 | static void __init use_secure_pil(void) |
| 728 | { |
| 729 | |
Stephen Boyd | e44ec39 | 2011-08-29 12:03:24 -0700 | [diff] [blame^] | 730 | if (pas_supported(PAS_Q6) > 0) { |
Saravana Kannan | 76cc49b | 2011-09-07 19:59:04 -0700 | [diff] [blame] | 731 | pil_lpass_q6_ops.init_image = init_image_lpass_q6_trusted; |
| 732 | pil_lpass_q6_ops.auth_and_reset = reset_lpass_q6_trusted; |
| 733 | pil_lpass_q6_ops.shutdown = shutdown_lpass_q6_trusted; |
| 734 | } |
| 735 | |
Stephen Boyd | e44ec39 | 2011-08-29 12:03:24 -0700 | [diff] [blame^] | 736 | if (pas_supported(PAS_MODEM_FW) > 0) { |
Saravana Kannan | 76cc49b | 2011-09-07 19:59:04 -0700 | [diff] [blame] | 737 | pil_modem_fw_q6_ops.init_image = init_image_modem_fw_q6_trusted; |
| 738 | pil_modem_fw_q6_ops.auth_and_reset = reset_modem_fw_q6_trusted; |
| 739 | pil_modem_fw_q6_ops.shutdown = shutdown_modem_fw_q6_trusted; |
| 740 | } |
| 741 | |
Stephen Boyd | e44ec39 | 2011-08-29 12:03:24 -0700 | [diff] [blame^] | 742 | if (pas_supported(PAS_MODEM_SW) > 0) { |
Saravana Kannan | 76cc49b | 2011-09-07 19:59:04 -0700 | [diff] [blame] | 743 | pil_modem_sw_q6_ops.init_image = init_image_modem_sw_q6_trusted; |
| 744 | pil_modem_sw_q6_ops.auth_and_reset = reset_modem_sw_q6_trusted; |
| 745 | pil_modem_sw_q6_ops.shutdown = shutdown_modem_sw_q6_trusted; |
| 746 | } |
| 747 | |
Stephen Boyd | e44ec39 | 2011-08-29 12:03:24 -0700 | [diff] [blame^] | 748 | if (pas_supported(PAS_DSPS) > 0) { |
Saravana Kannan | 76cc49b | 2011-09-07 19:59:04 -0700 | [diff] [blame] | 749 | pil_dsps_ops.init_image = init_image_dsps_trusted; |
| 750 | pil_dsps_ops.auth_and_reset = reset_dsps_trusted; |
| 751 | pil_dsps_ops.shutdown = shutdown_dsps_trusted; |
| 752 | } |
| 753 | |
Stephen Boyd | e44ec39 | 2011-08-29 12:03:24 -0700 | [diff] [blame^] | 754 | if (pas_supported(PAS_RIVA) > 0) { |
Saravana Kannan | 76cc49b | 2011-09-07 19:59:04 -0700 | [diff] [blame] | 755 | pil_riva_ops.init_image = init_image_riva_trusted; |
| 756 | pil_riva_ops.auth_and_reset = reset_riva_trusted; |
| 757 | pil_riva_ops.shutdown = shutdown_riva_trusted; |
| 758 | } |
| 759 | } |
Stephen Boyd | 9802ca9 | 2011-05-25 15:09:59 -0700 | [diff] [blame] | 760 | |
Stephen Boyd | e44ec39 | 2011-08-29 12:03:24 -0700 | [diff] [blame^] | 761 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 762 | static int __init msm_peripheral_reset_init(void) |
| 763 | { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 764 | int err; |
| 765 | |
| 766 | /* |
| 767 | * Don't initialize PIL on simulated targets, as some |
| 768 | * subsystems may not be emulated on them. |
| 769 | */ |
| 770 | if (machine_is_msm8960_sim() || machine_is_msm8960_rumi3()) |
| 771 | return 0; |
| 772 | |
Stephen Boyd | e44ec39 | 2011-08-29 12:03:24 -0700 | [diff] [blame^] | 773 | use_secure_pil(); |
Stephen Boyd | 9802ca9 | 2011-05-25 15:09:59 -0700 | [diff] [blame] | 774 | |
Matt Wagantall | 0b2f982 | 2011-07-12 20:11:28 -0700 | [diff] [blame] | 775 | err = q6_reset_init(&q6_lpass); |
| 776 | if (err) |
| 777 | return err; |
| 778 | msm_pil_add_device(&pil_lpass_q6); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 779 | |
Matt Wagantall | 0b2f982 | 2011-07-12 20:11:28 -0700 | [diff] [blame] | 780 | mss_enable_reg = ioremap(MSM_MSS_ENABLE_PHYS, 4); |
| 781 | if (!mss_enable_reg) |
| 782 | return -ENOMEM; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 783 | |
Matt Wagantall | 0b2f982 | 2011-07-12 20:11:28 -0700 | [diff] [blame] | 784 | err = q6_reset_init(&q6_modem_fw); |
| 785 | if (err) { |
| 786 | iounmap(mss_enable_reg); |
| 787 | return err; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 788 | } |
Matt Wagantall | 0b2f982 | 2011-07-12 20:11:28 -0700 | [diff] [blame] | 789 | msm_pil_add_device(&pil_modem_fw_q6); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 790 | |
Matt Wagantall | 0b2f982 | 2011-07-12 20:11:28 -0700 | [diff] [blame] | 791 | err = q6_reset_init(&q6_modem_sw); |
| 792 | if (err) |
| 793 | return err; |
| 794 | msm_pil_add_device(&pil_modem_sw_q6); |
| 795 | |
| 796 | msm_pil_add_device(&pil_dsps); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 797 | |
| 798 | msm_riva_base = ioremap(MSM_RIVA_PHYS, SZ_256); |
Matt Wagantall | 0b2f982 | 2011-07-12 20:11:28 -0700 | [diff] [blame] | 799 | if (!msm_riva_base) |
| 800 | return -ENOMEM; |
| 801 | msm_pil_add_device(&pil_riva); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 802 | |
| 803 | return 0; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 804 | } |
| 805 | arch_initcall(msm_peripheral_reset_init); |