Kyle Yan | e45fa02 | 2016-08-29 11:40:26 -0700 | [diff] [blame] | 1 | /* |
Puja Gupta | 6caaa23 | 2016-05-04 12:03:31 -0700 | [diff] [blame] | 2 | * Copyright (c) 2012-2017, The Linux Foundation. All rights reserved. |
Kyle Yan | e45fa02 | 2016-08-29 11:40:26 -0700 | [diff] [blame] | 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/init.h> |
| 15 | #include <linux/module.h> |
| 16 | #include <linux/platform_device.h> |
Puja Gupta | 6caaa23 | 2016-05-04 12:03:31 -0700 | [diff] [blame] | 17 | #include <linux/of_platform.h> |
Kyle Yan | e45fa02 | 2016-08-29 11:40:26 -0700 | [diff] [blame] | 18 | #include <linux/io.h> |
| 19 | #include <linux/iopoll.h> |
| 20 | #include <linux/ioport.h> |
| 21 | #include <linux/delay.h> |
| 22 | #include <linux/sched.h> |
| 23 | #include <linux/clk.h> |
| 24 | #include <linux/err.h> |
| 25 | #include <linux/of.h> |
| 26 | #include <linux/regulator/consumer.h> |
| 27 | #include <linux/interrupt.h> |
| 28 | #include <linux/dma-mapping.h> |
| 29 | #include <linux/of_gpio.h> |
| 30 | #include <soc/qcom/subsystem_restart.h> |
| 31 | #include <soc/qcom/ramdump.h> |
| 32 | #include <soc/qcom/smem.h> |
| 33 | |
| 34 | #include "peripheral-loader.h" |
| 35 | #include "pil-q6v5.h" |
| 36 | #include "pil-msa.h" |
| 37 | |
Kyle Yan | e45fa02 | 2016-08-29 11:40:26 -0700 | [diff] [blame] | 38 | #define PROXY_TIMEOUT_MS 10000 |
Kyle Yan | fe3813e | 2017-06-06 17:03:58 -0700 | [diff] [blame] | 39 | #define MAX_SSR_REASON_LEN 256U |
Kyle Yan | e45fa02 | 2016-08-29 11:40:26 -0700 | [diff] [blame] | 40 | #define STOP_ACK_TIMEOUT_MS 1000 |
Avaneesh Kumar Dwivedi | 94619d9 | 2017-10-05 17:58:38 +0530 | [diff] [blame] | 41 | #define QDSP6SS_NMI_STATUS 0x44 |
Kyle Yan | e45fa02 | 2016-08-29 11:40:26 -0700 | [diff] [blame] | 42 | |
| 43 | #define subsys_to_drv(d) container_of(d, struct modem_data, subsys_desc) |
| 44 | |
| 45 | static void log_modem_sfr(void) |
| 46 | { |
| 47 | u32 size; |
| 48 | char *smem_reason, reason[MAX_SSR_REASON_LEN]; |
| 49 | |
| 50 | smem_reason = smem_get_entry_no_rlock(SMEM_SSR_REASON_MSS0, &size, 0, |
| 51 | SMEM_ANY_HOST_FLAG); |
| 52 | if (!smem_reason || !size) { |
| 53 | pr_err("modem subsystem failure reason: (unknown, smem_get_entry_no_rlock failed).\n"); |
| 54 | return; |
| 55 | } |
| 56 | if (!smem_reason[0]) { |
| 57 | pr_err("modem subsystem failure reason: (unknown, empty string found).\n"); |
| 58 | return; |
| 59 | } |
| 60 | |
| 61 | strlcpy(reason, smem_reason, min(size, MAX_SSR_REASON_LEN)); |
| 62 | pr_err("modem subsystem failure reason: %s.\n", reason); |
| 63 | |
| 64 | smem_reason[0] = '\0'; |
| 65 | wmb(); |
| 66 | } |
| 67 | |
| 68 | static void restart_modem(struct modem_data *drv) |
| 69 | { |
| 70 | log_modem_sfr(); |
| 71 | drv->ignore_errors = true; |
| 72 | subsystem_restart_dev(drv->subsys); |
| 73 | } |
| 74 | |
| 75 | static irqreturn_t modem_err_fatal_intr_handler(int irq, void *dev_id) |
| 76 | { |
| 77 | struct modem_data *drv = subsys_to_drv(dev_id); |
Avaneesh Kumar Dwivedi | 94619d9 | 2017-10-05 17:58:38 +0530 | [diff] [blame] | 78 | u32 nmi_status = readl_relaxed(drv->q6->reg_base + QDSP6SS_NMI_STATUS); |
Kyle Yan | e45fa02 | 2016-08-29 11:40:26 -0700 | [diff] [blame] | 79 | |
| 80 | /* Ignore if we're the one that set the force stop GPIO */ |
| 81 | if (drv->crash_shutdown) |
| 82 | return IRQ_HANDLED; |
| 83 | |
Avaneesh Kumar Dwivedi | 94619d9 | 2017-10-05 17:58:38 +0530 | [diff] [blame] | 84 | if (nmi_status & 0x04) |
| 85 | pr_err("%s: Fatal error on the modem due to TZ NMI\n", |
| 86 | __func__); |
| 87 | else |
| 88 | pr_err("%s: Fatal error on the modem\n", __func__); |
Satya Durga Srinivasu Prabhala | 30af7d0 | 2016-12-15 13:33:39 -0800 | [diff] [blame] | 89 | subsys_set_crash_status(drv->subsys, CRASH_STATUS_ERR_FATAL); |
Kyle Yan | e45fa02 | 2016-08-29 11:40:26 -0700 | [diff] [blame] | 90 | restart_modem(drv); |
| 91 | return IRQ_HANDLED; |
| 92 | } |
| 93 | |
| 94 | static irqreturn_t modem_stop_ack_intr_handler(int irq, void *dev_id) |
| 95 | { |
| 96 | struct modem_data *drv = subsys_to_drv(dev_id); |
| 97 | |
| 98 | pr_info("Received stop ack interrupt from modem\n"); |
| 99 | complete(&drv->stop_ack); |
| 100 | return IRQ_HANDLED; |
| 101 | } |
| 102 | |
| 103 | static int modem_shutdown(const struct subsys_desc *subsys, bool force_stop) |
| 104 | { |
| 105 | struct modem_data *drv = subsys_to_drv(subsys); |
| 106 | unsigned long ret; |
| 107 | |
| 108 | if (subsys->is_not_loadable) |
| 109 | return 0; |
| 110 | |
| 111 | if (!subsys_get_crash_status(drv->subsys) && force_stop && |
| 112 | subsys->force_stop_gpio) { |
| 113 | gpio_set_value(subsys->force_stop_gpio, 1); |
| 114 | ret = wait_for_completion_timeout(&drv->stop_ack, |
| 115 | msecs_to_jiffies(STOP_ACK_TIMEOUT_MS)); |
| 116 | if (!ret) |
| 117 | pr_warn("Timed out on stop ack from modem.\n"); |
| 118 | gpio_set_value(subsys->force_stop_gpio, 0); |
| 119 | } |
| 120 | |
| 121 | if (drv->subsys_desc.ramdump_disable_gpio) { |
| 122 | drv->subsys_desc.ramdump_disable = gpio_get_value( |
| 123 | drv->subsys_desc.ramdump_disable_gpio); |
| 124 | pr_warn("Ramdump disable gpio value is %d\n", |
| 125 | drv->subsys_desc.ramdump_disable); |
| 126 | } |
| 127 | |
| 128 | pil_shutdown(&drv->q6->desc); |
| 129 | |
| 130 | return 0; |
| 131 | } |
| 132 | |
| 133 | static int modem_powerup(const struct subsys_desc *subsys) |
| 134 | { |
| 135 | struct modem_data *drv = subsys_to_drv(subsys); |
| 136 | |
| 137 | if (subsys->is_not_loadable) |
| 138 | return 0; |
| 139 | /* |
| 140 | * At this time, the modem is shutdown. Therefore this function cannot |
| 141 | * run concurrently with the watchdog bite error handler, making it safe |
| 142 | * to unset the flag below. |
| 143 | */ |
| 144 | reinit_completion(&drv->stop_ack); |
| 145 | drv->subsys_desc.ramdump_disable = 0; |
| 146 | drv->ignore_errors = false; |
| 147 | drv->q6->desc.fw_name = subsys->fw_name; |
| 148 | return pil_boot(&drv->q6->desc); |
| 149 | } |
| 150 | |
| 151 | static void modem_crash_shutdown(const struct subsys_desc *subsys) |
| 152 | { |
| 153 | struct modem_data *drv = subsys_to_drv(subsys); |
| 154 | |
| 155 | drv->crash_shutdown = true; |
| 156 | if (!subsys_get_crash_status(drv->subsys) && |
| 157 | subsys->force_stop_gpio) { |
| 158 | gpio_set_value(subsys->force_stop_gpio, 1); |
| 159 | mdelay(STOP_ACK_TIMEOUT_MS); |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | static int modem_ramdump(int enable, const struct subsys_desc *subsys) |
| 164 | { |
| 165 | struct modem_data *drv = subsys_to_drv(subsys); |
| 166 | int ret; |
| 167 | |
| 168 | if (!enable) |
| 169 | return 0; |
| 170 | |
| 171 | ret = pil_mss_make_proxy_votes(&drv->q6->desc); |
| 172 | if (ret) |
| 173 | return ret; |
| 174 | |
| 175 | ret = pil_mss_reset_load_mba(&drv->q6->desc); |
| 176 | if (ret) |
| 177 | return ret; |
| 178 | |
| 179 | ret = pil_do_ramdump(&drv->q6->desc, drv->ramdump_dev); |
| 180 | if (ret < 0) |
| 181 | pr_err("Unable to dump modem fw memory (rc = %d).\n", ret); |
| 182 | |
| 183 | ret = __pil_mss_deinit_image(&drv->q6->desc, false); |
| 184 | if (ret < 0) |
| 185 | pr_err("Unable to free up resources (rc = %d).\n", ret); |
| 186 | |
| 187 | pil_mss_remove_proxy_votes(&drv->q6->desc); |
| 188 | return ret; |
| 189 | } |
| 190 | |
| 191 | static irqreturn_t modem_wdog_bite_intr_handler(int irq, void *dev_id) |
| 192 | { |
| 193 | struct modem_data *drv = subsys_to_drv(dev_id); |
| 194 | |
| 195 | if (drv->ignore_errors) |
| 196 | return IRQ_HANDLED; |
| 197 | |
| 198 | pr_err("Watchdog bite received from modem software!\n"); |
| 199 | if (drv->subsys_desc.system_debug && |
| 200 | !gpio_get_value(drv->subsys_desc.err_fatal_gpio)) |
| 201 | panic("%s: System ramdump requested. Triggering device restart!\n", |
| 202 | __func__); |
Satya Durga Srinivasu Prabhala | 30af7d0 | 2016-12-15 13:33:39 -0800 | [diff] [blame] | 203 | subsys_set_crash_status(drv->subsys, CRASH_STATUS_WDOG_BITE); |
Kyle Yan | e45fa02 | 2016-08-29 11:40:26 -0700 | [diff] [blame] | 204 | restart_modem(drv); |
| 205 | return IRQ_HANDLED; |
| 206 | } |
| 207 | |
| 208 | static int pil_subsys_init(struct modem_data *drv, |
| 209 | struct platform_device *pdev) |
| 210 | { |
| 211 | int ret; |
| 212 | |
| 213 | drv->subsys_desc.name = "modem"; |
| 214 | drv->subsys_desc.dev = &pdev->dev; |
| 215 | drv->subsys_desc.owner = THIS_MODULE; |
| 216 | drv->subsys_desc.shutdown = modem_shutdown; |
| 217 | drv->subsys_desc.powerup = modem_powerup; |
| 218 | drv->subsys_desc.ramdump = modem_ramdump; |
| 219 | drv->subsys_desc.crash_shutdown = modem_crash_shutdown; |
| 220 | drv->subsys_desc.err_fatal_handler = modem_err_fatal_intr_handler; |
| 221 | drv->subsys_desc.stop_ack_handler = modem_stop_ack_intr_handler; |
| 222 | drv->subsys_desc.wdog_bite_handler = modem_wdog_bite_intr_handler; |
| 223 | |
| 224 | drv->q6->desc.modem_ssr = false; |
Kyle Yan | 0ceeb64 | 2017-09-13 11:21:35 -0700 | [diff] [blame] | 225 | drv->q6->desc.signal_aop = of_property_read_bool(pdev->dev.of_node, |
| 226 | "qcom,signal-aop"); |
| 227 | if (drv->q6->desc.signal_aop) { |
| 228 | drv->q6->desc.cl.dev = &pdev->dev; |
| 229 | drv->q6->desc.cl.tx_block = true; |
| 230 | drv->q6->desc.cl.tx_tout = 1000; |
| 231 | drv->q6->desc.cl.knows_txdone = false; |
| 232 | drv->q6->desc.mbox = mbox_request_channel(&drv->q6->desc.cl, 0); |
| 233 | if (IS_ERR(drv->q6->desc.mbox)) { |
| 234 | ret = PTR_ERR(drv->q6->desc.mbox); |
| 235 | dev_err(&pdev->dev, "Failed to get mailbox channel %pK %d\n", |
| 236 | drv->q6->desc.mbox, ret); |
| 237 | goto err_subsys; |
| 238 | } |
| 239 | } |
| 240 | |
Kyle Yan | e45fa02 | 2016-08-29 11:40:26 -0700 | [diff] [blame] | 241 | drv->subsys = subsys_register(&drv->subsys_desc); |
| 242 | if (IS_ERR(drv->subsys)) { |
| 243 | ret = PTR_ERR(drv->subsys); |
| 244 | goto err_subsys; |
| 245 | } |
| 246 | |
| 247 | drv->ramdump_dev = create_ramdump_device("modem", &pdev->dev); |
| 248 | if (!drv->ramdump_dev) { |
| 249 | pr_err("%s: Unable to create a modem ramdump device.\n", |
| 250 | __func__); |
| 251 | ret = -ENOMEM; |
| 252 | goto err_ramdump; |
| 253 | } |
| 254 | |
| 255 | return 0; |
| 256 | |
| 257 | err_ramdump: |
| 258 | subsys_unregister(drv->subsys); |
| 259 | err_subsys: |
| 260 | return ret; |
| 261 | } |
| 262 | |
| 263 | static int pil_mss_loadable_init(struct modem_data *drv, |
| 264 | struct platform_device *pdev) |
| 265 | { |
| 266 | struct q6v5_data *q6; |
| 267 | struct pil_desc *q6_desc; |
| 268 | struct resource *res; |
| 269 | struct property *prop; |
| 270 | int ret; |
| 271 | |
| 272 | q6 = pil_q6v5_init(pdev); |
| 273 | if (IS_ERR_OR_NULL(q6)) |
| 274 | return PTR_ERR(q6); |
| 275 | drv->q6 = q6; |
| 276 | drv->xo = q6->xo; |
| 277 | |
| 278 | q6_desc = &q6->desc; |
| 279 | q6_desc->owner = THIS_MODULE; |
| 280 | q6_desc->proxy_timeout = PROXY_TIMEOUT_MS; |
| 281 | |
| 282 | q6_desc->ops = &pil_msa_mss_ops; |
| 283 | |
| 284 | q6->self_auth = of_property_read_bool(pdev->dev.of_node, |
| 285 | "qcom,pil-self-auth"); |
| 286 | if (q6->self_auth) { |
| 287 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, |
| 288 | "rmb_base"); |
| 289 | q6->rmb_base = devm_ioremap_resource(&pdev->dev, res); |
Kyle Yan | 33e6702 | 2017-04-09 11:33:31 -0700 | [diff] [blame] | 290 | if (IS_ERR(q6->rmb_base)) |
| 291 | return PTR_ERR(q6->rmb_base); |
Kyle Yan | e45fa02 | 2016-08-29 11:40:26 -0700 | [diff] [blame] | 292 | drv->rmb_base = q6->rmb_base; |
| 293 | q6_desc->ops = &pil_msa_mss_ops_selfauth; |
| 294 | } |
| 295 | |
| 296 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "restart_reg"); |
| 297 | if (!res) { |
| 298 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, |
| 299 | "restart_reg_sec"); |
Kyle Yan | aaa8972 | 2017-06-05 13:56:28 -0700 | [diff] [blame] | 300 | if (!res) { |
| 301 | dev_err(&pdev->dev, "No restart register defined\n"); |
| 302 | return -ENOMEM; |
| 303 | } |
Kyle Yan | e45fa02 | 2016-08-29 11:40:26 -0700 | [diff] [blame] | 304 | q6->restart_reg_sec = true; |
| 305 | } |
| 306 | |
| 307 | q6->restart_reg = devm_ioremap(&pdev->dev, |
| 308 | res->start, resource_size(res)); |
| 309 | if (!q6->restart_reg) |
| 310 | return -ENOMEM; |
| 311 | |
Kyle Yan | 0e660cb | 2017-05-01 11:13:14 -0700 | [diff] [blame] | 312 | q6->pdc_sync = NULL; |
| 313 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "pdc_sync"); |
| 314 | if (res) { |
| 315 | q6->pdc_sync = devm_ioremap(&pdev->dev, |
| 316 | res->start, resource_size(res)); |
Kyle Yan | 506c07f | 2017-09-14 11:20:59 -0700 | [diff] [blame] | 317 | if (of_property_read_u32(pdev->dev.of_node, |
| 318 | "qcom,mss_pdc_offset", &q6->mss_pdc_offset)) { |
| 319 | dev_err(&pdev->dev, |
| 320 | "Offset for MSS PDC not specified\n"); |
| 321 | return -EINVAL; |
| 322 | } |
| 323 | |
Kyle Yan | 0e660cb | 2017-05-01 11:13:14 -0700 | [diff] [blame] | 324 | } |
| 325 | |
Kyle Yan | 05f6e10 | 2017-04-25 18:30:04 -0700 | [diff] [blame] | 326 | q6->alt_reset = NULL; |
| 327 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "alt_reset"); |
| 328 | if (res) { |
| 329 | q6->alt_reset = devm_ioremap(&pdev->dev, |
| 330 | res->start, resource_size(res)); |
| 331 | } |
| 332 | |
Kyle Yan | e45fa02 | 2016-08-29 11:40:26 -0700 | [diff] [blame] | 333 | q6->vreg = NULL; |
| 334 | |
| 335 | prop = of_find_property(pdev->dev.of_node, "vdd_mss-supply", NULL); |
| 336 | if (prop) { |
| 337 | q6->vreg = devm_regulator_get(&pdev->dev, "vdd_mss"); |
| 338 | if (IS_ERR(q6->vreg)) |
| 339 | return PTR_ERR(q6->vreg); |
Kyle Yan | e45fa02 | 2016-08-29 11:40:26 -0700 | [diff] [blame] | 340 | } |
| 341 | |
| 342 | q6->vreg_mx = devm_regulator_get(&pdev->dev, "vdd_mx"); |
| 343 | if (IS_ERR(q6->vreg_mx)) |
| 344 | return PTR_ERR(q6->vreg_mx); |
| 345 | prop = of_find_property(pdev->dev.of_node, "vdd_mx-uV", NULL); |
| 346 | if (!prop) { |
| 347 | dev_err(&pdev->dev, "Missing vdd_mx-uV property\n"); |
| 348 | return -EINVAL; |
| 349 | } |
| 350 | |
| 351 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, |
| 352 | "cxrail_bhs_reg"); |
| 353 | if (res) |
| 354 | q6->cxrail_bhs = devm_ioremap(&pdev->dev, res->start, |
| 355 | resource_size(res)); |
| 356 | |
| 357 | q6->ahb_clk = devm_clk_get(&pdev->dev, "iface_clk"); |
| 358 | if (IS_ERR(q6->ahb_clk)) |
| 359 | return PTR_ERR(q6->ahb_clk); |
| 360 | |
| 361 | q6->axi_clk = devm_clk_get(&pdev->dev, "bus_clk"); |
| 362 | if (IS_ERR(q6->axi_clk)) |
| 363 | return PTR_ERR(q6->axi_clk); |
| 364 | |
| 365 | q6->rom_clk = devm_clk_get(&pdev->dev, "mem_clk"); |
| 366 | if (IS_ERR(q6->rom_clk)) |
| 367 | return PTR_ERR(q6->rom_clk); |
| 368 | |
| 369 | ret = of_property_read_u32(pdev->dev.of_node, |
| 370 | "qcom,pas-id", &drv->pas_id); |
| 371 | if (ret) |
| 372 | dev_info(&pdev->dev, "No pas_id found.\n"); |
| 373 | |
| 374 | drv->subsys_desc.pil_mss_memsetup = |
| 375 | of_property_read_bool(pdev->dev.of_node, "qcom,pil-mss-memsetup"); |
| 376 | |
| 377 | /* Optional. */ |
| 378 | if (of_property_match_string(pdev->dev.of_node, |
| 379 | "qcom,active-clock-names", "gpll0_mss_clk") >= 0) |
| 380 | q6->gpll0_mss_clk = devm_clk_get(&pdev->dev, "gpll0_mss_clk"); |
| 381 | |
| 382 | if (of_property_match_string(pdev->dev.of_node, |
| 383 | "qcom,active-clock-names", "snoc_axi_clk") >= 0) |
| 384 | q6->snoc_axi_clk = devm_clk_get(&pdev->dev, "snoc_axi_clk"); |
| 385 | |
| 386 | if (of_property_match_string(pdev->dev.of_node, |
| 387 | "qcom,active-clock-names", "mnoc_axi_clk") >= 0) |
| 388 | q6->mnoc_axi_clk = devm_clk_get(&pdev->dev, "mnoc_axi_clk"); |
| 389 | |
| 390 | ret = pil_desc_init(q6_desc); |
| 391 | |
| 392 | return ret; |
| 393 | } |
| 394 | |
| 395 | static int pil_mss_driver_probe(struct platform_device *pdev) |
| 396 | { |
| 397 | struct modem_data *drv; |
| 398 | int ret, is_not_loadable; |
| 399 | |
| 400 | drv = devm_kzalloc(&pdev->dev, sizeof(*drv), GFP_KERNEL); |
| 401 | if (!drv) |
| 402 | return -ENOMEM; |
| 403 | platform_set_drvdata(pdev, drv); |
| 404 | |
| 405 | is_not_loadable = of_property_read_bool(pdev->dev.of_node, |
| 406 | "qcom,is-not-loadable"); |
| 407 | if (is_not_loadable) { |
| 408 | drv->subsys_desc.is_not_loadable = 1; |
| 409 | } else { |
| 410 | ret = pil_mss_loadable_init(drv, pdev); |
| 411 | if (ret) |
| 412 | return ret; |
| 413 | } |
| 414 | init_completion(&drv->stop_ack); |
| 415 | |
Puja Gupta | 6caaa23 | 2016-05-04 12:03:31 -0700 | [diff] [blame] | 416 | /* Probe the MBA mem device if present */ |
| 417 | ret = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev); |
| 418 | if (ret) |
| 419 | return ret; |
| 420 | |
Kyle Yan | e45fa02 | 2016-08-29 11:40:26 -0700 | [diff] [blame] | 421 | return pil_subsys_init(drv, pdev); |
| 422 | } |
| 423 | |
| 424 | static int pil_mss_driver_exit(struct platform_device *pdev) |
| 425 | { |
| 426 | struct modem_data *drv = platform_get_drvdata(pdev); |
| 427 | |
| 428 | subsys_unregister(drv->subsys); |
| 429 | destroy_ramdump_device(drv->ramdump_dev); |
| 430 | pil_desc_release(&drv->q6->desc); |
| 431 | return 0; |
| 432 | } |
| 433 | |
Puja Gupta | 6caaa23 | 2016-05-04 12:03:31 -0700 | [diff] [blame] | 434 | static int pil_mba_mem_driver_probe(struct platform_device *pdev) |
| 435 | { |
| 436 | struct modem_data *drv; |
| 437 | |
| 438 | if (!pdev->dev.parent) { |
| 439 | pr_err("No parent found.\n"); |
| 440 | return -EINVAL; |
| 441 | } |
| 442 | drv = dev_get_drvdata(pdev->dev.parent); |
| 443 | drv->mba_mem_dev_fixed = &pdev->dev; |
| 444 | return 0; |
| 445 | } |
| 446 | |
| 447 | static const struct of_device_id mba_mem_match_table[] = { |
| 448 | { .compatible = "qcom,pil-mba-mem" }, |
| 449 | {} |
| 450 | }; |
| 451 | |
| 452 | static struct platform_driver pil_mba_mem_driver = { |
| 453 | .probe = pil_mba_mem_driver_probe, |
| 454 | .driver = { |
| 455 | .name = "pil-mba-mem", |
| 456 | .of_match_table = mba_mem_match_table, |
| 457 | .owner = THIS_MODULE, |
| 458 | }, |
| 459 | }; |
| 460 | |
Kyle Yan | e45fa02 | 2016-08-29 11:40:26 -0700 | [diff] [blame] | 461 | static const struct of_device_id mss_match_table[] = { |
| 462 | { .compatible = "qcom,pil-q6v5-mss" }, |
| 463 | { .compatible = "qcom,pil-q6v55-mss" }, |
| 464 | { .compatible = "qcom,pil-q6v56-mss" }, |
| 465 | {} |
| 466 | }; |
| 467 | |
| 468 | static struct platform_driver pil_mss_driver = { |
| 469 | .probe = pil_mss_driver_probe, |
| 470 | .remove = pil_mss_driver_exit, |
| 471 | .driver = { |
| 472 | .name = "pil-q6v5-mss", |
| 473 | .of_match_table = mss_match_table, |
| 474 | .owner = THIS_MODULE, |
| 475 | }, |
| 476 | }; |
| 477 | |
| 478 | static int __init pil_mss_init(void) |
| 479 | { |
Puja Gupta | 6caaa23 | 2016-05-04 12:03:31 -0700 | [diff] [blame] | 480 | int ret; |
| 481 | |
| 482 | ret = platform_driver_register(&pil_mba_mem_driver); |
| 483 | if (!ret) |
| 484 | ret = platform_driver_register(&pil_mss_driver); |
| 485 | return ret; |
Kyle Yan | e45fa02 | 2016-08-29 11:40:26 -0700 | [diff] [blame] | 486 | } |
| 487 | module_init(pil_mss_init); |
| 488 | |
| 489 | static void __exit pil_mss_exit(void) |
| 490 | { |
| 491 | platform_driver_unregister(&pil_mss_driver); |
| 492 | } |
| 493 | module_exit(pil_mss_exit); |
| 494 | |
| 495 | MODULE_DESCRIPTION("Support for booting modem subsystems with QDSP6v5 Hexagon processors"); |
| 496 | MODULE_LICENSE("GPL v2"); |