Matt Wagantall | 292aace | 2012-01-26 19:12:34 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2012, Code Aurora Forum. All rights reserved. |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License version 2 and |
| 6 | * only version 2 as published by the Free Software Foundation. |
| 7 | * |
| 8 | * This program is distributed in the hope that it will be useful, |
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | * GNU General Public License for more details. |
| 12 | */ |
| 13 | |
| 14 | #include <linux/kernel.h> |
| 15 | #include <linux/err.h> |
| 16 | #include <linux/io.h> |
| 17 | #include <linux/elf.h> |
| 18 | #include <linux/delay.h> |
| 19 | #include <linux/module.h> |
| 20 | #include <linux/slab.h> |
| 21 | #include <linux/platform_device.h> |
| 22 | #include <linux/workqueue.h> |
| 23 | #include <linux/clk.h> |
Matt Wagantall | 19ac4fd | 2012-02-03 20:18:23 -0800 | [diff] [blame] | 24 | #include <linux/smp.h> |
Matt Wagantall | 292aace | 2012-01-26 19:12:34 -0800 | [diff] [blame] | 25 | |
| 26 | #include <mach/msm_iomap.h> |
| 27 | #include <mach/msm_xo.h> |
Matt Wagantall | 556d3f7 | 2012-02-16 17:36:29 -0800 | [diff] [blame] | 28 | #include <mach/socinfo.h> |
Matt Wagantall | f3471ef | 2012-03-09 14:21:54 -0800 | [diff] [blame^] | 29 | #include <mach/msm_bus_board.h> |
| 30 | #include <mach/msm_bus.h> |
Matt Wagantall | 292aace | 2012-01-26 19:12:34 -0800 | [diff] [blame] | 31 | |
| 32 | #include "peripheral-loader.h" |
| 33 | #include "scm-pas.h" |
| 34 | |
| 35 | #define GSS_CSR_AHB_CLK_SEL 0x0 |
| 36 | #define GSS_CSR_RESET 0x4 |
| 37 | #define GSS_CSR_CLK_BLK_CONFIG 0x8 |
| 38 | #define GSS_CSR_CLK_ENABLE 0xC |
| 39 | #define GSS_CSR_BOOT_REMAP 0x14 |
| 40 | #define GSS_CSR_POWER_UP_DOWN 0x18 |
Matt Wagantall | 19ac4fd | 2012-02-03 20:18:23 -0800 | [diff] [blame] | 41 | #define GSS_CSR_CFG_HID 0x2C |
Matt Wagantall | 292aace | 2012-01-26 19:12:34 -0800 | [diff] [blame] | 42 | |
| 43 | #define GSS_SLP_CLK_CTL (MSM_CLK_CTL_BASE + 0x2C60) |
| 44 | #define GSS_RESET (MSM_CLK_CTL_BASE + 0x2C64) |
| 45 | #define GSS_CLAMP_ENA (MSM_CLK_CTL_BASE + 0x2C68) |
| 46 | #define GSS_CXO_SRC_CTL (MSM_CLK_CTL_BASE + 0x2C74) |
| 47 | |
Matt Wagantall | 292aace | 2012-01-26 19:12:34 -0800 | [diff] [blame] | 48 | #define PLL5_STATUS (MSM_CLK_CTL_BASE + 0x30F8) |
| 49 | #define PLL_ENA_GSS (MSM_CLK_CTL_BASE + 0x3480) |
Matt Wagantall | 292aace | 2012-01-26 19:12:34 -0800 | [diff] [blame] | 50 | |
| 51 | #define PLL5_VOTE BIT(5) |
| 52 | #define PLL_STATUS BIT(16) |
| 53 | #define REMAP_ENABLE BIT(16) |
| 54 | #define A5_POWER_STATUS BIT(4) |
| 55 | #define A5_POWER_ENA BIT(0) |
| 56 | #define NAV_POWER_ENA BIT(1) |
| 57 | #define XO_CLK_BRANCH_ENA BIT(0) |
| 58 | #define SLP_CLK_BRANCH_ENA BIT(4) |
| 59 | #define A5_RESET BIT(0) |
| 60 | |
| 61 | #define PROXY_VOTE_TIMEOUT 10000 |
| 62 | |
| 63 | struct gss_data { |
| 64 | void __iomem *base; |
Matt Wagantall | 19ac4fd | 2012-02-03 20:18:23 -0800 | [diff] [blame] | 65 | void __iomem *qgic2_base; |
Matt Wagantall | 292aace | 2012-01-26 19:12:34 -0800 | [diff] [blame] | 66 | unsigned long start_addr; |
| 67 | struct delayed_work work; |
| 68 | struct clk *xo; |
Stephen Boyd | 6d67d25 | 2011-09-27 11:50:05 -0700 | [diff] [blame] | 69 | struct pil_device *pil; |
Matt Wagantall | 292aace | 2012-01-26 19:12:34 -0800 | [diff] [blame] | 70 | }; |
| 71 | |
| 72 | static int nop_verify_blob(struct pil_desc *pil, u32 phy_addr, size_t size) |
| 73 | { |
| 74 | return 0; |
| 75 | } |
| 76 | |
| 77 | static int pil_gss_init_image(struct pil_desc *pil, const u8 *metadata, |
| 78 | size_t size) |
| 79 | { |
| 80 | const struct elf32_hdr *ehdr = (struct elf32_hdr *)metadata; |
| 81 | struct gss_data *drv = dev_get_drvdata(pil->dev); |
| 82 | drv->start_addr = ehdr->e_entry; |
| 83 | return 0; |
| 84 | } |
| 85 | |
| 86 | static int make_gss_proxy_votes(struct device *dev) |
| 87 | { |
| 88 | int ret; |
| 89 | struct gss_data *drv = dev_get_drvdata(dev); |
| 90 | |
| 91 | ret = clk_prepare_enable(drv->xo); |
| 92 | if (ret) { |
| 93 | dev_err(dev, "Failed to enable XO\n"); |
| 94 | return ret; |
| 95 | } |
| 96 | schedule_delayed_work(&drv->work, msecs_to_jiffies(PROXY_VOTE_TIMEOUT)); |
| 97 | return 0; |
| 98 | } |
| 99 | |
| 100 | static void remove_gss_proxy_votes(struct work_struct *work) |
| 101 | { |
| 102 | struct gss_data *drv = container_of(work, struct gss_data, work.work); |
| 103 | clk_disable_unprepare(drv->xo); |
| 104 | } |
| 105 | |
| 106 | static void remove_gss_proxy_votes_now(struct gss_data *drv) |
| 107 | { |
| 108 | flush_delayed_work(&drv->work); |
| 109 | } |
| 110 | |
| 111 | static void gss_init(struct gss_data *drv) |
| 112 | { |
| 113 | void __iomem *base = drv->base; |
| 114 | |
| 115 | /* Supply clocks to GSS. */ |
| 116 | writel_relaxed(XO_CLK_BRANCH_ENA, GSS_CXO_SRC_CTL); |
| 117 | writel_relaxed(SLP_CLK_BRANCH_ENA, GSS_SLP_CLK_CTL); |
| 118 | |
| 119 | /* Deassert GSS reset and clamps. */ |
| 120 | writel_relaxed(0x0, GSS_RESET); |
| 121 | writel_relaxed(0x0, GSS_CLAMP_ENA); |
| 122 | mb(); |
| 123 | |
| 124 | /* |
| 125 | * Configure clock source and dividers for 288MHz core, 144MHz AXI and |
| 126 | * 72MHz AHB, all derived from the 288MHz PLL. |
| 127 | */ |
| 128 | writel_relaxed(0x341, base + GSS_CSR_CLK_BLK_CONFIG); |
| 129 | writel_relaxed(0x1, base + GSS_CSR_AHB_CLK_SEL); |
| 130 | |
| 131 | /* Assert all GSS resets. */ |
| 132 | writel_relaxed(0x7F, base + GSS_CSR_RESET); |
| 133 | |
| 134 | /* Enable all bus clocks and wait for resets to propagate. */ |
| 135 | writel_relaxed(0x1F, base + GSS_CSR_CLK_ENABLE); |
| 136 | mb(); |
| 137 | udelay(1); |
| 138 | |
| 139 | /* Release subsystem from reset, but leave A5 in reset. */ |
| 140 | writel_relaxed(A5_RESET, base + GSS_CSR_RESET); |
| 141 | } |
| 142 | |
Matt Wagantall | 556d3f7 | 2012-02-16 17:36:29 -0800 | [diff] [blame] | 143 | static void cfg_qgic2_bus_access(void *data) |
Matt Wagantall | 292aace | 2012-01-26 19:12:34 -0800 | [diff] [blame] | 144 | { |
Matt Wagantall | 19ac4fd | 2012-02-03 20:18:23 -0800 | [diff] [blame] | 145 | struct gss_data *drv = data; |
Matt Wagantall | 19ac4fd | 2012-02-03 20:18:23 -0800 | [diff] [blame] | 146 | int i; |
Matt Wagantall | 292aace | 2012-01-26 19:12:34 -0800 | [diff] [blame] | 147 | |
Matt Wagantall | 556d3f7 | 2012-02-16 17:36:29 -0800 | [diff] [blame] | 148 | /* |
| 149 | * Apply a 8064 v1.0 workaround to configure QGIC bus access. |
| 150 | * This must be done from Krait 0 to configure the Master ID |
| 151 | * correctly. |
| 152 | */ |
| 153 | writel_relaxed(0x2, drv->base + GSS_CSR_CFG_HID); |
Matt Wagantall | 19ac4fd | 2012-02-03 20:18:23 -0800 | [diff] [blame] | 154 | for (i = 0; i <= 3; i++) |
| 155 | readl_relaxed(drv->qgic2_base); |
Matt Wagantall | 292aace | 2012-01-26 19:12:34 -0800 | [diff] [blame] | 156 | } |
| 157 | |
| 158 | static int pil_gss_shutdown(struct pil_desc *pil) |
| 159 | { |
| 160 | struct gss_data *drv = dev_get_drvdata(pil->dev); |
| 161 | void __iomem *base = drv->base; |
| 162 | u32 regval; |
| 163 | int ret; |
| 164 | |
| 165 | ret = clk_prepare_enable(drv->xo); |
| 166 | if (ret) { |
| 167 | dev_err(pil->dev, "Failed to enable XO\n"); |
| 168 | return ret; |
| 169 | } |
| 170 | |
Matt Wagantall | f3471ef | 2012-03-09 14:21:54 -0800 | [diff] [blame^] | 171 | /* Make sure bus port is halted. */ |
| 172 | msm_bus_axi_porthalt(MSM_BUS_MASTER_GSS_NAV); |
| 173 | |
Matt Wagantall | 292aace | 2012-01-26 19:12:34 -0800 | [diff] [blame] | 174 | /* |
| 175 | * Vote PLL on in GSS's voting register and wait for it to enable. |
| 176 | * The PLL must be enable to switch the GFMUX to a low-power source. |
| 177 | */ |
| 178 | writel_relaxed(PLL5_VOTE, PLL_ENA_GSS); |
| 179 | while ((readl_relaxed(PLL5_STATUS) & PLL_STATUS) == 0) |
| 180 | cpu_relax(); |
| 181 | |
| 182 | /* Perform one-time GSS initialization. */ |
| 183 | gss_init(drv); |
| 184 | |
| 185 | /* Assert A5 reset. */ |
| 186 | regval = readl_relaxed(base + GSS_CSR_RESET); |
| 187 | regval |= A5_RESET; |
| 188 | writel_relaxed(regval, base + GSS_CSR_RESET); |
| 189 | |
| 190 | /* Power down A5 and NAV. */ |
| 191 | regval = readl_relaxed(base + GSS_CSR_POWER_UP_DOWN); |
| 192 | regval &= ~(A5_POWER_ENA|NAV_POWER_ENA); |
| 193 | writel_relaxed(regval, base + GSS_CSR_POWER_UP_DOWN); |
| 194 | |
| 195 | /* Select XO clock source and increase dividers to save power. */ |
| 196 | regval = readl_relaxed(base + GSS_CSR_CLK_BLK_CONFIG); |
| 197 | regval |= 0x3FF; |
| 198 | writel_relaxed(regval, base + GSS_CSR_CLK_BLK_CONFIG); |
| 199 | |
| 200 | /* Disable bus clocks. */ |
| 201 | writel_relaxed(0x1F, base + GSS_CSR_CLK_ENABLE); |
| 202 | |
| 203 | /* Clear GSS PLL votes. */ |
| 204 | writel_relaxed(0, PLL_ENA_GSS); |
| 205 | mb(); |
| 206 | |
| 207 | clk_disable_unprepare(drv->xo); |
| 208 | remove_gss_proxy_votes_now(drv); |
| 209 | |
| 210 | return 0; |
| 211 | } |
| 212 | |
Matt Wagantall | 19ac4fd | 2012-02-03 20:18:23 -0800 | [diff] [blame] | 213 | static int pil_gss_reset(struct pil_desc *pil) |
| 214 | { |
| 215 | struct gss_data *drv = dev_get_drvdata(pil->dev); |
| 216 | void __iomem *base = drv->base; |
| 217 | unsigned long start_addr = drv->start_addr; |
| 218 | int ret; |
| 219 | |
| 220 | ret = make_gss_proxy_votes(pil->dev); |
| 221 | if (ret) |
| 222 | return ret; |
| 223 | |
Matt Wagantall | f3471ef | 2012-03-09 14:21:54 -0800 | [diff] [blame^] | 224 | /* Unhalt bus port. */ |
| 225 | ret = msm_bus_axi_portunhalt(MSM_BUS_MASTER_GSS_NAV); |
| 226 | if (ret) { |
| 227 | dev_err(pil->dev, "Failed to unhalt bus port\n"); |
| 228 | remove_gss_proxy_votes_now(drv); |
| 229 | return ret; |
| 230 | } |
| 231 | |
Matt Wagantall | 19ac4fd | 2012-02-03 20:18:23 -0800 | [diff] [blame] | 232 | /* Vote PLL on in GSS's voting register and wait for it to enable. */ |
| 233 | writel_relaxed(PLL5_VOTE, PLL_ENA_GSS); |
| 234 | while ((readl_relaxed(PLL5_STATUS) & PLL_STATUS) == 0) |
| 235 | cpu_relax(); |
| 236 | |
| 237 | /* Perform GSS initialization. */ |
| 238 | gss_init(drv); |
| 239 | |
| 240 | /* Configure boot address and enable remap. */ |
| 241 | writel_relaxed(REMAP_ENABLE | (start_addr >> 16), |
| 242 | base + GSS_CSR_BOOT_REMAP); |
| 243 | |
| 244 | /* Power up A5 core. */ |
| 245 | writel_relaxed(A5_POWER_ENA, base + GSS_CSR_POWER_UP_DOWN); |
| 246 | while (!(readl_relaxed(base + GSS_CSR_POWER_UP_DOWN) & A5_POWER_STATUS)) |
| 247 | cpu_relax(); |
| 248 | |
Matt Wagantall | 556d3f7 | 2012-02-16 17:36:29 -0800 | [diff] [blame] | 249 | if (cpu_is_apq8064() && |
| 250 | ((SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 1) && |
| 251 | (SOCINFO_VERSION_MINOR(socinfo_get_version()) == 0))) { |
| 252 | ret = smp_call_function_single(0, cfg_qgic2_bus_access, drv, 1); |
| 253 | if (ret) { |
| 254 | pr_err("Failed to configure QGIC2 bus access\n"); |
| 255 | pil_gss_shutdown(pil); |
| 256 | return ret; |
| 257 | } |
Matt Wagantall | 19ac4fd | 2012-02-03 20:18:23 -0800 | [diff] [blame] | 258 | } |
| 259 | |
| 260 | /* Release A5 from reset. */ |
| 261 | writel_relaxed(0x0, base + GSS_CSR_RESET); |
| 262 | |
| 263 | return 0; |
| 264 | } |
| 265 | |
Matt Wagantall | 292aace | 2012-01-26 19:12:34 -0800 | [diff] [blame] | 266 | static struct pil_reset_ops pil_gss_ops = { |
| 267 | .init_image = pil_gss_init_image, |
| 268 | .verify_blob = nop_verify_blob, |
| 269 | .auth_and_reset = pil_gss_reset, |
| 270 | .shutdown = pil_gss_shutdown, |
| 271 | }; |
| 272 | |
Matt Wagantall | 11afeee | 2012-02-07 18:38:59 -0800 | [diff] [blame] | 273 | static int pil_gss_init_image_trusted(struct pil_desc *pil, |
| 274 | const u8 *metadata, size_t size) |
| 275 | { |
| 276 | return pas_init_image(PAS_GSS, metadata, size); |
| 277 | } |
| 278 | |
Matt Wagantall | 556d3f7 | 2012-02-16 17:36:29 -0800 | [diff] [blame] | 279 | static int pil_gss_shutdown_trusted(struct pil_desc *pil) |
| 280 | { |
| 281 | struct gss_data *drv = dev_get_drvdata(pil->dev); |
| 282 | int ret; |
| 283 | |
Stephen Boyd | 7663ccc | 2012-02-21 19:34:55 -0800 | [diff] [blame] | 284 | /* |
| 285 | * CXO is used in the secure shutdown code to configure the processor |
| 286 | * for low power mode. |
| 287 | */ |
| 288 | ret = clk_prepare_enable(drv->xo); |
| 289 | if (ret) { |
| 290 | dev_err(pil->dev, "Failed to enable XO\n"); |
Matt Wagantall | 556d3f7 | 2012-02-16 17:36:29 -0800 | [diff] [blame] | 291 | return ret; |
Stephen Boyd | 7663ccc | 2012-02-21 19:34:55 -0800 | [diff] [blame] | 292 | } |
Matt Wagantall | 556d3f7 | 2012-02-16 17:36:29 -0800 | [diff] [blame] | 293 | |
Matt Wagantall | f3471ef | 2012-03-09 14:21:54 -0800 | [diff] [blame^] | 294 | msm_bus_axi_porthalt(MSM_BUS_MASTER_GSS_NAV); |
Stephen Boyd | 7663ccc | 2012-02-21 19:34:55 -0800 | [diff] [blame] | 295 | ret = pas_shutdown(PAS_GSS); |
| 296 | clk_disable_unprepare(drv->xo); |
Matt Wagantall | 556d3f7 | 2012-02-16 17:36:29 -0800 | [diff] [blame] | 297 | remove_gss_proxy_votes_now(drv); |
| 298 | |
| 299 | return ret; |
| 300 | } |
| 301 | |
Matt Wagantall | 11afeee | 2012-02-07 18:38:59 -0800 | [diff] [blame] | 302 | static int pil_gss_reset_trusted(struct pil_desc *pil) |
| 303 | { |
| 304 | struct gss_data *drv = dev_get_drvdata(pil->dev); |
| 305 | int err; |
| 306 | |
| 307 | err = make_gss_proxy_votes(pil->dev); |
| 308 | if (err) |
Matt Wagantall | f3471ef | 2012-03-09 14:21:54 -0800 | [diff] [blame^] | 309 | goto out; |
| 310 | |
| 311 | err = msm_bus_axi_portunhalt(MSM_BUS_MASTER_GSS_NAV); |
| 312 | if (err) { |
| 313 | dev_err(pil->dev, "Failed to unhalt bus port\n"); |
| 314 | goto remove_votes; |
| 315 | } |
Matt Wagantall | 11afeee | 2012-02-07 18:38:59 -0800 | [diff] [blame] | 316 | |
| 317 | err = pas_auth_and_reset(PAS_GSS); |
| 318 | if (err) |
Matt Wagantall | f3471ef | 2012-03-09 14:21:54 -0800 | [diff] [blame^] | 319 | goto halt_port; |
Matt Wagantall | 11afeee | 2012-02-07 18:38:59 -0800 | [diff] [blame] | 320 | |
Matt Wagantall | 556d3f7 | 2012-02-16 17:36:29 -0800 | [diff] [blame] | 321 | if (cpu_is_apq8064() && |
| 322 | ((SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 1) && |
| 323 | (SOCINFO_VERSION_MINOR(socinfo_get_version()) == 0))) { |
| 324 | err = smp_call_function_single(0, cfg_qgic2_bus_access, drv, 1); |
| 325 | if (err) { |
| 326 | pr_err("Failed to configure QGIC2 bus access\n"); |
| 327 | pil_gss_shutdown_trusted(pil); |
| 328 | return err; |
| 329 | } |
| 330 | /* |
| 331 | * On 8064v1.0, pas_auth_and_reset() will not release the A5 |
| 332 | * from reset. Linux must do this after cfg_qgic2_bus_access() |
| 333 | * is called on CPU0. |
| 334 | */ |
| 335 | writel_relaxed(0x0, drv->base + GSS_CSR_RESET); |
| 336 | } |
Matt Wagantall | f3471ef | 2012-03-09 14:21:54 -0800 | [diff] [blame^] | 337 | return 0; |
Matt Wagantall | 556d3f7 | 2012-02-16 17:36:29 -0800 | [diff] [blame] | 338 | |
Matt Wagantall | f3471ef | 2012-03-09 14:21:54 -0800 | [diff] [blame^] | 339 | halt_port: |
| 340 | msm_bus_axi_porthalt(MSM_BUS_MASTER_GSS_NAV); |
| 341 | remove_votes: |
| 342 | remove_gss_proxy_votes_now(drv); |
| 343 | out: |
Matt Wagantall | 11afeee | 2012-02-07 18:38:59 -0800 | [diff] [blame] | 344 | return err; |
| 345 | } |
| 346 | |
Matt Wagantall | 11afeee | 2012-02-07 18:38:59 -0800 | [diff] [blame] | 347 | static struct pil_reset_ops pil_gss_ops_trusted = { |
| 348 | .init_image = pil_gss_init_image_trusted, |
| 349 | .verify_blob = nop_verify_blob, |
| 350 | .auth_and_reset = pil_gss_reset_trusted, |
| 351 | .shutdown = pil_gss_shutdown_trusted, |
| 352 | }; |
| 353 | |
Matt Wagantall | 292aace | 2012-01-26 19:12:34 -0800 | [diff] [blame] | 354 | static int __devinit pil_gss_probe(struct platform_device *pdev) |
| 355 | { |
| 356 | struct gss_data *drv; |
| 357 | struct resource *res; |
| 358 | struct pil_desc *desc; |
Matt Wagantall | 292aace | 2012-01-26 19:12:34 -0800 | [diff] [blame] | 359 | |
| 360 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 361 | if (!res) |
| 362 | return -EINVAL; |
| 363 | |
| 364 | drv = devm_kzalloc(&pdev->dev, sizeof(*drv), GFP_KERNEL); |
| 365 | if (!drv) |
| 366 | return -ENOMEM; |
| 367 | platform_set_drvdata(pdev, drv); |
| 368 | |
| 369 | drv->base = devm_ioremap(&pdev->dev, res->start, resource_size(res)); |
| 370 | if (!drv->base) |
| 371 | return -ENOMEM; |
| 372 | |
| 373 | desc = devm_kzalloc(&pdev->dev, sizeof(*desc), GFP_KERNEL); |
| 374 | if (!desc) |
| 375 | return -ENOMEM; |
| 376 | |
Matt Wagantall | 19ac4fd | 2012-02-03 20:18:23 -0800 | [diff] [blame] | 377 | res = platform_get_resource(pdev, IORESOURCE_MEM, 1); |
| 378 | if (!res) |
| 379 | return -EINVAL; |
| 380 | |
| 381 | drv->qgic2_base = devm_ioremap(&pdev->dev, res->start, |
| 382 | resource_size(res)); |
| 383 | if (!drv->qgic2_base) |
| 384 | return -ENOMEM; |
| 385 | |
Matt Wagantall | 292aace | 2012-01-26 19:12:34 -0800 | [diff] [blame] | 386 | drv->xo = clk_get(&pdev->dev, "xo"); |
| 387 | if (IS_ERR(drv->xo)) |
| 388 | return PTR_ERR(drv->xo); |
| 389 | |
| 390 | desc->name = "gss"; |
| 391 | desc->dev = &pdev->dev; |
Stephen Boyd | 6d67d25 | 2011-09-27 11:50:05 -0700 | [diff] [blame] | 392 | desc->owner = THIS_MODULE; |
Matt Wagantall | 292aace | 2012-01-26 19:12:34 -0800 | [diff] [blame] | 393 | |
Matt Wagantall | 11afeee | 2012-02-07 18:38:59 -0800 | [diff] [blame] | 394 | if (pas_supported(PAS_GSS) > 0) { |
| 395 | desc->ops = &pil_gss_ops_trusted; |
| 396 | dev_info(&pdev->dev, "using secure boot\n"); |
| 397 | } else { |
| 398 | desc->ops = &pil_gss_ops; |
| 399 | dev_info(&pdev->dev, "using non-secure boot\n"); |
| 400 | } |
Matt Wagantall | 292aace | 2012-01-26 19:12:34 -0800 | [diff] [blame] | 401 | |
| 402 | INIT_DELAYED_WORK(&drv->work, remove_gss_proxy_votes); |
| 403 | |
Stephen Boyd | 6d67d25 | 2011-09-27 11:50:05 -0700 | [diff] [blame] | 404 | drv->pil = msm_pil_register(desc); |
| 405 | if (IS_ERR(drv->pil)) { |
Matt Wagantall | 292aace | 2012-01-26 19:12:34 -0800 | [diff] [blame] | 406 | flush_delayed_work_sync(&drv->work); |
| 407 | clk_put(drv->xo); |
Stephen Boyd | 6d67d25 | 2011-09-27 11:50:05 -0700 | [diff] [blame] | 408 | return PTR_ERR(drv->pil); |
Matt Wagantall | 292aace | 2012-01-26 19:12:34 -0800 | [diff] [blame] | 409 | } |
Stephen Boyd | 6d67d25 | 2011-09-27 11:50:05 -0700 | [diff] [blame] | 410 | return 0; |
Matt Wagantall | 292aace | 2012-01-26 19:12:34 -0800 | [diff] [blame] | 411 | } |
| 412 | |
| 413 | static int __devexit pil_gss_remove(struct platform_device *pdev) |
| 414 | { |
| 415 | struct gss_data *drv = platform_get_drvdata(pdev); |
Stephen Boyd | 6d67d25 | 2011-09-27 11:50:05 -0700 | [diff] [blame] | 416 | msm_pil_unregister(drv->pil); |
Matt Wagantall | 292aace | 2012-01-26 19:12:34 -0800 | [diff] [blame] | 417 | flush_delayed_work_sync(&drv->work); |
| 418 | clk_put(drv->xo); |
| 419 | return 0; |
| 420 | } |
| 421 | |
| 422 | static struct platform_driver pil_gss_driver = { |
| 423 | .probe = pil_gss_probe, |
| 424 | .remove = __devexit_p(pil_gss_remove), |
| 425 | .driver = { |
| 426 | .name = "pil_gss", |
| 427 | .owner = THIS_MODULE, |
| 428 | }, |
| 429 | }; |
| 430 | |
| 431 | static int __init pil_gss_init(void) |
| 432 | { |
| 433 | return platform_driver_register(&pil_gss_driver); |
| 434 | } |
| 435 | module_init(pil_gss_init); |
| 436 | |
| 437 | static void __exit pil_gss_exit(void) |
| 438 | { |
| 439 | platform_driver_unregister(&pil_gss_driver); |
| 440 | } |
| 441 | module_exit(pil_gss_exit); |
| 442 | |
| 443 | MODULE_DESCRIPTION("Support for booting the GSS processor"); |
| 444 | MODULE_LICENSE("GPL v2"); |