Joel King | e9cd527 | 2012-01-28 12:48:59 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved. |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 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 | |
| 14 | #include <linux/module.h> |
| 15 | #include <linux/platform_device.h> |
| 16 | #include <linux/err.h> |
| 17 | #include <linux/slab.h> |
| 18 | #include <linux/io.h> |
| 19 | #include <linux/mutex.h> |
| 20 | #include <linux/miscdevice.h> |
| 21 | #include <linux/fs.h> |
| 22 | #include <linux/gpio.h> |
| 23 | #include <linux/kernel.h> |
| 24 | #include <linux/irq.h> |
| 25 | #include <linux/ioctl.h> |
| 26 | #include <linux/delay.h> |
| 27 | #include <linux/reboot.h> |
| 28 | #include <linux/debugfs.h> |
| 29 | #include <linux/completion.h> |
| 30 | #include <linux/workqueue.h> |
| 31 | #include <linux/clk.h> |
| 32 | #include <linux/mfd/pmic8058.h> |
| 33 | #include <asm/mach-types.h> |
| 34 | #include <asm/uaccess.h> |
| 35 | #include <mach/mdm2.h> |
| 36 | #include <mach/restart.h> |
| 37 | #include <mach/subsystem_notif.h> |
| 38 | #include <mach/subsystem_restart.h> |
Joel King | ef39084 | 2012-05-23 16:42:48 -0700 | [diff] [blame] | 39 | #include <mach/rpm.h> |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 40 | #include <linux/msm_charm.h> |
| 41 | #include "msm_watchdog.h" |
| 42 | #include "mdm_private.h" |
Joel King | 30fdd66 | 2012-05-07 19:39:29 -0700 | [diff] [blame] | 43 | #include "sysmon.h" |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 44 | |
| 45 | #define MDM_MODEM_TIMEOUT 6000 |
| 46 | #define MDM_MODEM_DELTA 100 |
Joel King | 52d7fa6 | 2012-03-21 08:40:52 -0700 | [diff] [blame] | 47 | #define MDM_BOOT_TIMEOUT 60000L |
| 48 | #define MDM_RDUMP_TIMEOUT 60000L |
Joel King | 493b3ac | 2012-05-14 11:39:45 -0700 | [diff] [blame] | 49 | #define MDM2AP_STATUS_TIMEOUT_MS 60000L |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 50 | |
| 51 | static int mdm_debug_on; |
| 52 | static struct workqueue_struct *mdm_queue; |
Joel King | 30fdd66 | 2012-05-07 19:39:29 -0700 | [diff] [blame] | 53 | static struct workqueue_struct *mdm_sfr_queue; |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 54 | |
| 55 | #define EXTERNAL_MODEM "external_modem" |
| 56 | |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 57 | static struct mdm_modem_drv *mdm_drv; |
| 58 | |
| 59 | DECLARE_COMPLETION(mdm_needs_reload); |
| 60 | DECLARE_COMPLETION(mdm_boot); |
| 61 | DECLARE_COMPLETION(mdm_ram_dumps); |
| 62 | |
| 63 | static int first_boot = 1; |
| 64 | |
Joel King | 30fdd66 | 2012-05-07 19:39:29 -0700 | [diff] [blame] | 65 | #define RD_BUF_SIZE 100 |
| 66 | #define SFR_MAX_RETRIES 10 |
| 67 | #define SFR_RETRY_INTERVAL 1000 |
| 68 | |
Joel King | ef39084 | 2012-05-23 16:42:48 -0700 | [diff] [blame] | 69 | static irqreturn_t mdm_vddmin_change(int irq, void *dev_id) |
| 70 | { |
| 71 | int value = gpio_get_value( |
| 72 | mdm_drv->pdata->vddmin_resource->mdm2ap_vddmin_gpio); |
| 73 | |
| 74 | if (value == 0) |
| 75 | pr_info("External Modem entered Vddmin\n"); |
| 76 | else |
| 77 | pr_info("External Modem exited Vddmin\n"); |
| 78 | |
| 79 | return IRQ_HANDLED; |
| 80 | } |
| 81 | |
| 82 | static void mdm_setup_vddmin_gpios(void) |
| 83 | { |
| 84 | struct msm_rpm_iv_pair req; |
| 85 | struct mdm_vddmin_resource *vddmin_res; |
| 86 | int irq, ret; |
| 87 | |
| 88 | /* This resource may not be supported by some platforms. */ |
| 89 | vddmin_res = mdm_drv->pdata->vddmin_resource; |
| 90 | if (!vddmin_res) |
| 91 | return; |
| 92 | |
| 93 | req.id = vddmin_res->rpm_id; |
| 94 | req.value = ((uint32_t)vddmin_res->ap2mdm_vddmin_gpio & 0x0000FFFF) |
| 95 | << 16; |
| 96 | req.value |= ((uint32_t)vddmin_res->modes & 0x000000FF) << 8; |
| 97 | req.value |= (uint32_t)vddmin_res->drive_strength & 0x000000FF; |
| 98 | |
| 99 | msm_rpm_set(MSM_RPM_CTX_SET_0, &req, 1); |
| 100 | |
| 101 | /* Monitor low power gpio from mdm */ |
| 102 | irq = MSM_GPIO_TO_INT(vddmin_res->mdm2ap_vddmin_gpio); |
| 103 | if (irq < 0) { |
| 104 | pr_err("%s: could not get LPM POWER IRQ resource.\n", |
| 105 | __func__); |
| 106 | goto error_end; |
| 107 | } |
| 108 | |
| 109 | ret = request_threaded_irq(irq, NULL, mdm_vddmin_change, |
| 110 | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, |
| 111 | "mdm lpm", NULL); |
| 112 | |
| 113 | if (ret < 0) |
| 114 | pr_err("%s: MDM LPM IRQ#%d request failed with error=%d", |
| 115 | __func__, irq, ret); |
| 116 | error_end: |
| 117 | return; |
| 118 | } |
| 119 | |
Joel King | 30fdd66 | 2012-05-07 19:39:29 -0700 | [diff] [blame] | 120 | static void mdm_restart_reason_fn(struct work_struct *work) |
| 121 | { |
| 122 | int ret, ntries = 0; |
| 123 | char sfr_buf[RD_BUF_SIZE]; |
| 124 | |
| 125 | do { |
| 126 | msleep(SFR_RETRY_INTERVAL); |
| 127 | ret = sysmon_get_reason(SYSMON_SS_EXT_MODEM, |
| 128 | sfr_buf, sizeof(sfr_buf)); |
| 129 | if (ret) { |
| 130 | /* |
| 131 | * The sysmon device may not have been probed as yet |
| 132 | * after the restart. |
| 133 | */ |
| 134 | pr_err("%s: Error retrieving mdm restart reason, ret = %d, " |
| 135 | "%d/%d tries\n", __func__, ret, |
| 136 | ntries + 1, SFR_MAX_RETRIES); |
| 137 | } else { |
| 138 | pr_err("mdm restart reason: %s\n", sfr_buf); |
| 139 | break; |
| 140 | } |
| 141 | } while (++ntries < SFR_MAX_RETRIES); |
| 142 | } |
| 143 | |
| 144 | static DECLARE_WORK(sfr_reason_work, mdm_restart_reason_fn); |
| 145 | |
Joel King | 493b3ac | 2012-05-14 11:39:45 -0700 | [diff] [blame] | 146 | static void mdm2ap_status_check(struct work_struct *work) |
| 147 | { |
| 148 | /* |
| 149 | * If the mdm modem did not pull the MDM2AP_STATUS gpio |
| 150 | * high then call subsystem_restart. |
| 151 | */ |
| 152 | if (gpio_get_value(mdm_drv->mdm2ap_status_gpio) == 0) { |
| 153 | pr_err("%s: MDM2AP_STATUS gpio did not go high\n", |
| 154 | __func__); |
| 155 | mdm_drv->mdm_ready = 0; |
| 156 | subsystem_restart(EXTERNAL_MODEM); |
| 157 | } |
| 158 | } |
| 159 | |
| 160 | static DECLARE_DELAYED_WORK(mdm2ap_status_check_work, mdm2ap_status_check); |
| 161 | |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 162 | long mdm_modem_ioctl(struct file *filp, unsigned int cmd, |
| 163 | unsigned long arg) |
| 164 | { |
| 165 | int status, ret = 0; |
| 166 | |
| 167 | if (_IOC_TYPE(cmd) != CHARM_CODE) { |
| 168 | pr_err("%s: invalid ioctl code\n", __func__); |
| 169 | return -EINVAL; |
| 170 | } |
| 171 | |
Joel King | 2a42f50 | 2012-02-03 11:36:25 -0800 | [diff] [blame] | 172 | pr_debug("%s: Entering ioctl cmd = %d\n", __func__, _IOC_NR(cmd)); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 173 | switch (cmd) { |
| 174 | case WAKE_CHARM: |
Joel King | 2a42f50 | 2012-02-03 11:36:25 -0800 | [diff] [blame] | 175 | pr_info("%s: Powering on mdm\n", __func__); |
Joel King | e9cd527 | 2012-01-28 12:48:59 -0800 | [diff] [blame] | 176 | mdm_drv->ops->power_on_mdm_cb(mdm_drv); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 177 | break; |
| 178 | case CHECK_FOR_BOOT: |
| 179 | if (gpio_get_value(mdm_drv->mdm2ap_status_gpio) == 0) |
| 180 | put_user(1, (unsigned long __user *) arg); |
| 181 | else |
| 182 | put_user(0, (unsigned long __user *) arg); |
| 183 | break; |
| 184 | case NORMAL_BOOT_DONE: |
Joel King | 2a42f50 | 2012-02-03 11:36:25 -0800 | [diff] [blame] | 185 | pr_debug("%s: check if mdm is booted up\n", __func__); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 186 | get_user(status, (unsigned long __user *) arg); |
Joel King | 2a42f50 | 2012-02-03 11:36:25 -0800 | [diff] [blame] | 187 | if (status) { |
| 188 | pr_debug("%s: normal boot failed\n", __func__); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 189 | mdm_drv->mdm_boot_status = -EIO; |
Joel King | 2a42f50 | 2012-02-03 11:36:25 -0800 | [diff] [blame] | 190 | } else { |
| 191 | pr_info("%s: normal boot done\n", __func__); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 192 | mdm_drv->mdm_boot_status = 0; |
Joel King | 2a42f50 | 2012-02-03 11:36:25 -0800 | [diff] [blame] | 193 | } |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 194 | mdm_drv->mdm_ready = 1; |
| 195 | |
Joel King | e9cd527 | 2012-01-28 12:48:59 -0800 | [diff] [blame] | 196 | if (mdm_drv->ops->normal_boot_done_cb != NULL) |
| 197 | mdm_drv->ops->normal_boot_done_cb(mdm_drv); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 198 | |
| 199 | if (!first_boot) |
| 200 | complete(&mdm_boot); |
| 201 | else |
| 202 | first_boot = 0; |
Joel King | 493b3ac | 2012-05-14 11:39:45 -0700 | [diff] [blame] | 203 | |
| 204 | /* Start a timer to check that the mdm2ap_status gpio |
| 205 | * goes high. |
| 206 | */ |
| 207 | |
| 208 | if (gpio_get_value(mdm_drv->mdm2ap_status_gpio) == 0) |
| 209 | schedule_delayed_work(&mdm2ap_status_check_work, |
| 210 | msecs_to_jiffies(MDM2AP_STATUS_TIMEOUT_MS)); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 211 | break; |
| 212 | case RAM_DUMP_DONE: |
Joel King | 2a42f50 | 2012-02-03 11:36:25 -0800 | [diff] [blame] | 213 | pr_debug("%s: mdm done collecting RAM dumps\n", __func__); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 214 | get_user(status, (unsigned long __user *) arg); |
| 215 | if (status) |
| 216 | mdm_drv->mdm_ram_dump_status = -EIO; |
Joel King | 2a42f50 | 2012-02-03 11:36:25 -0800 | [diff] [blame] | 217 | else { |
| 218 | pr_info("%s: ramdump collection completed\n", __func__); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 219 | mdm_drv->mdm_ram_dump_status = 0; |
Joel King | 2a42f50 | 2012-02-03 11:36:25 -0800 | [diff] [blame] | 220 | } |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 221 | complete(&mdm_ram_dumps); |
| 222 | break; |
| 223 | case WAIT_FOR_RESTART: |
Joel King | 2a42f50 | 2012-02-03 11:36:25 -0800 | [diff] [blame] | 224 | pr_debug("%s: wait for mdm to need images reloaded\n", |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 225 | __func__); |
| 226 | ret = wait_for_completion_interruptible(&mdm_needs_reload); |
| 227 | if (!ret) |
| 228 | put_user(mdm_drv->boot_type, |
| 229 | (unsigned long __user *) arg); |
| 230 | INIT_COMPLETION(mdm_needs_reload); |
| 231 | break; |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 232 | case GET_DLOAD_STATUS: |
| 233 | pr_debug("getting status of mdm2ap_errfatal_gpio\n"); |
| 234 | if (gpio_get_value(mdm_drv->mdm2ap_errfatal_gpio) == 1 && |
| 235 | !mdm_drv->mdm_ready) |
| 236 | put_user(1, (unsigned long __user *) arg); |
| 237 | else |
| 238 | put_user(0, (unsigned long __user *) arg); |
| 239 | break; |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 240 | default: |
| 241 | pr_err("%s: invalid ioctl cmd = %d\n", __func__, _IOC_NR(cmd)); |
| 242 | ret = -EINVAL; |
| 243 | break; |
| 244 | } |
| 245 | |
| 246 | return ret; |
| 247 | } |
| 248 | |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 249 | static void mdm_status_fn(struct work_struct *work) |
| 250 | { |
Vamsi Krishna | 3392563 | 2011-12-13 15:43:09 -0800 | [diff] [blame] | 251 | int value = gpio_get_value(mdm_drv->mdm2ap_status_gpio); |
| 252 | |
Joel King | 2a42f50 | 2012-02-03 11:36:25 -0800 | [diff] [blame] | 253 | pr_debug("%s: status:%d\n", __func__, value); |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 254 | if (mdm_drv->mdm_ready && mdm_drv->ops->status_cb) |
| 255 | mdm_drv->ops->status_cb(mdm_drv, value); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 256 | } |
| 257 | |
| 258 | static DECLARE_WORK(mdm_status_work, mdm_status_fn); |
| 259 | |
| 260 | static void mdm_disable_irqs(void) |
| 261 | { |
| 262 | disable_irq_nosync(mdm_drv->mdm_errfatal_irq); |
| 263 | disable_irq_nosync(mdm_drv->mdm_status_irq); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 264 | } |
| 265 | |
| 266 | static irqreturn_t mdm_errfatal(int irq, void *dev_id) |
| 267 | { |
Joel King | 2a42f50 | 2012-02-03 11:36:25 -0800 | [diff] [blame] | 268 | pr_debug("%s: mdm got errfatal interrupt\n", __func__); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 269 | if (mdm_drv->mdm_ready && |
| 270 | (gpio_get_value(mdm_drv->mdm2ap_status_gpio) == 1)) { |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 271 | pr_info("%s: Reseting the mdm due to an errfatal\n", __func__); |
| 272 | mdm_drv->mdm_ready = 0; |
| 273 | subsystem_restart(EXTERNAL_MODEM); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 274 | } |
| 275 | return IRQ_HANDLED; |
| 276 | } |
| 277 | |
| 278 | static int mdm_modem_open(struct inode *inode, struct file *file) |
| 279 | { |
| 280 | return 0; |
| 281 | } |
| 282 | |
| 283 | static const struct file_operations mdm_modem_fops = { |
| 284 | .owner = THIS_MODULE, |
| 285 | .open = mdm_modem_open, |
| 286 | .unlocked_ioctl = mdm_modem_ioctl, |
| 287 | }; |
| 288 | |
| 289 | |
| 290 | static struct miscdevice mdm_modem_misc = { |
| 291 | .minor = MISC_DYNAMIC_MINOR, |
| 292 | .name = "mdm", |
| 293 | .fops = &mdm_modem_fops |
| 294 | }; |
| 295 | |
| 296 | static int mdm_panic_prep(struct notifier_block *this, |
| 297 | unsigned long event, void *ptr) |
| 298 | { |
| 299 | int i; |
| 300 | |
Joel King | 2a42f50 | 2012-02-03 11:36:25 -0800 | [diff] [blame] | 301 | pr_debug("%s: setting AP2MDM_ERRFATAL high for a non graceful reset\n", |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 302 | __func__); |
| 303 | mdm_disable_irqs(); |
| 304 | gpio_set_value(mdm_drv->ap2mdm_errfatal_gpio, 1); |
| 305 | |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 306 | for (i = MDM_MODEM_TIMEOUT; i > 0; i -= MDM_MODEM_DELTA) { |
| 307 | pet_watchdog(); |
| 308 | mdelay(MDM_MODEM_DELTA); |
| 309 | if (gpio_get_value(mdm_drv->mdm2ap_status_gpio) == 0) |
| 310 | break; |
| 311 | } |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 312 | if (i <= 0) { |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 313 | pr_err("%s: MDM2AP_STATUS never went low\n", __func__); |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 314 | /* Reset the modem so that it will go into download mode. */ |
| 315 | if (mdm_drv && mdm_drv->ops->reset_mdm_cb) |
| 316 | mdm_drv->ops->reset_mdm_cb(mdm_drv); |
| 317 | } |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 318 | return NOTIFY_DONE; |
| 319 | } |
| 320 | |
| 321 | static struct notifier_block mdm_panic_blk = { |
| 322 | .notifier_call = mdm_panic_prep, |
| 323 | }; |
| 324 | |
| 325 | static irqreturn_t mdm_status_change(int irq, void *dev_id) |
| 326 | { |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 327 | int value = gpio_get_value(mdm_drv->mdm2ap_status_gpio); |
| 328 | |
Joel King | 2a42f50 | 2012-02-03 11:36:25 -0800 | [diff] [blame] | 329 | pr_debug("%s: mdm sent status change interrupt\n", __func__); |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 330 | if (value == 0 && mdm_drv->mdm_ready == 1) { |
| 331 | pr_info("%s: unexpected reset external modem\n", __func__); |
| 332 | mdm_drv->mdm_unexpected_reset_occurred = 1; |
| 333 | mdm_drv->mdm_ready = 0; |
| 334 | subsystem_restart(EXTERNAL_MODEM); |
| 335 | } else if (value == 1) { |
Joel King | 493b3ac | 2012-05-14 11:39:45 -0700 | [diff] [blame] | 336 | cancel_delayed_work(&mdm2ap_status_check_work); |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 337 | pr_info("%s: status = 1: mdm is now ready\n", __func__); |
| 338 | queue_work(mdm_queue, &mdm_status_work); |
| 339 | } |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 340 | return IRQ_HANDLED; |
| 341 | } |
| 342 | |
Vamsi Krishna | c6dcd5e | 2012-05-09 15:38:01 -0700 | [diff] [blame^] | 343 | static irqreturn_t mdm_pblrdy_change(int irq, void *dev_id) |
| 344 | { |
| 345 | pr_info("%s: pbl ready:%d\n", __func__, |
| 346 | gpio_get_value(mdm_drv->mdm2ap_pblrdy)); |
| 347 | |
| 348 | return IRQ_HANDLED; |
| 349 | } |
| 350 | |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 351 | static int mdm_subsys_shutdown(const struct subsys_data *crashed_subsys) |
| 352 | { |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 353 | gpio_direction_output(mdm_drv->ap2mdm_errfatal_gpio, 1); |
Joel King | 415af51 | 2012-02-03 10:22:43 -0800 | [diff] [blame] | 354 | if (mdm_drv->pdata->ramdump_delay_ms > 0) { |
| 355 | /* Wait for the external modem to complete |
| 356 | * its preparation for ramdumps. |
| 357 | */ |
Joel King | 6e7a3e8 | 2012-04-13 17:37:33 -0700 | [diff] [blame] | 358 | msleep(mdm_drv->pdata->ramdump_delay_ms); |
Joel King | 415af51 | 2012-02-03 10:22:43 -0800 | [diff] [blame] | 359 | } |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 360 | if (!mdm_drv->mdm_unexpected_reset_occurred) |
| 361 | mdm_drv->ops->reset_mdm_cb(mdm_drv); |
| 362 | else |
| 363 | mdm_drv->mdm_unexpected_reset_occurred = 0; |
| 364 | |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 365 | return 0; |
| 366 | } |
| 367 | |
| 368 | static int mdm_subsys_powerup(const struct subsys_data *crashed_subsys) |
| 369 | { |
Joel King | bc48e4c | 2012-02-27 13:18:52 -0800 | [diff] [blame] | 370 | gpio_direction_output(mdm_drv->ap2mdm_errfatal_gpio, 0); |
| 371 | gpio_direction_output(mdm_drv->ap2mdm_status_gpio, 1); |
Joel King | e9cd527 | 2012-01-28 12:48:59 -0800 | [diff] [blame] | 372 | mdm_drv->ops->power_on_mdm_cb(mdm_drv); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 373 | mdm_drv->boot_type = CHARM_NORMAL_BOOT; |
| 374 | complete(&mdm_needs_reload); |
Joel King | 52d7fa6 | 2012-03-21 08:40:52 -0700 | [diff] [blame] | 375 | if (!wait_for_completion_timeout(&mdm_boot, |
| 376 | msecs_to_jiffies(MDM_BOOT_TIMEOUT))) { |
| 377 | mdm_drv->mdm_boot_status = -ETIMEDOUT; |
| 378 | pr_info("%s: mdm modem restart timed out.\n", __func__); |
Joel King | 30fdd66 | 2012-05-07 19:39:29 -0700 | [diff] [blame] | 379 | } else { |
Joel King | 52d7fa6 | 2012-03-21 08:40:52 -0700 | [diff] [blame] | 380 | pr_info("%s: mdm modem has been restarted\n", __func__); |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 381 | |
Joel King | 30fdd66 | 2012-05-07 19:39:29 -0700 | [diff] [blame] | 382 | /* Log the reason for the restart */ |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 383 | if (mdm_drv->pdata->sfr_query) |
| 384 | queue_work(mdm_sfr_queue, &sfr_reason_work); |
Joel King | 30fdd66 | 2012-05-07 19:39:29 -0700 | [diff] [blame] | 385 | } |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 386 | INIT_COMPLETION(mdm_boot); |
| 387 | return mdm_drv->mdm_boot_status; |
| 388 | } |
| 389 | |
| 390 | static int mdm_subsys_ramdumps(int want_dumps, |
| 391 | const struct subsys_data *crashed_subsys) |
| 392 | { |
| 393 | mdm_drv->mdm_ram_dump_status = 0; |
| 394 | if (want_dumps) { |
| 395 | mdm_drv->boot_type = CHARM_RAM_DUMPS; |
| 396 | complete(&mdm_needs_reload); |
Joel King | 52d7fa6 | 2012-03-21 08:40:52 -0700 | [diff] [blame] | 397 | if (!wait_for_completion_timeout(&mdm_ram_dumps, |
| 398 | msecs_to_jiffies(MDM_RDUMP_TIMEOUT))) { |
| 399 | mdm_drv->mdm_ram_dump_status = -ETIMEDOUT; |
| 400 | pr_info("%s: mdm modem ramdumps timed out.\n", |
| 401 | __func__); |
| 402 | } else |
| 403 | pr_info("%s: mdm modem ramdumps completed.\n", |
| 404 | __func__); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 405 | INIT_COMPLETION(mdm_ram_dumps); |
Joel King | e9cd527 | 2012-01-28 12:48:59 -0800 | [diff] [blame] | 406 | mdm_drv->ops->power_down_mdm_cb(mdm_drv); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 407 | } |
| 408 | return mdm_drv->mdm_ram_dump_status; |
| 409 | } |
| 410 | |
| 411 | static struct subsys_data mdm_subsystem = { |
| 412 | .shutdown = mdm_subsys_shutdown, |
| 413 | .ramdump = mdm_subsys_ramdumps, |
| 414 | .powerup = mdm_subsys_powerup, |
| 415 | .name = EXTERNAL_MODEM, |
| 416 | }; |
| 417 | |
| 418 | static int mdm_debug_on_set(void *data, u64 val) |
| 419 | { |
| 420 | mdm_debug_on = val; |
Joel King | e9cd527 | 2012-01-28 12:48:59 -0800 | [diff] [blame] | 421 | if (mdm_drv->ops->debug_state_changed_cb) |
| 422 | mdm_drv->ops->debug_state_changed_cb(mdm_debug_on); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 423 | return 0; |
| 424 | } |
| 425 | |
| 426 | static int mdm_debug_on_get(void *data, u64 *val) |
| 427 | { |
| 428 | *val = mdm_debug_on; |
| 429 | return 0; |
| 430 | } |
| 431 | |
| 432 | DEFINE_SIMPLE_ATTRIBUTE(mdm_debug_on_fops, |
| 433 | mdm_debug_on_get, |
| 434 | mdm_debug_on_set, "%llu\n"); |
| 435 | |
| 436 | static int mdm_debugfs_init(void) |
| 437 | { |
| 438 | struct dentry *dent; |
| 439 | |
| 440 | dent = debugfs_create_dir("mdm_dbg", 0); |
| 441 | if (IS_ERR(dent)) |
| 442 | return PTR_ERR(dent); |
| 443 | |
| 444 | debugfs_create_file("debug_on", 0644, dent, NULL, |
| 445 | &mdm_debug_on_fops); |
| 446 | return 0; |
| 447 | } |
| 448 | |
| 449 | static void mdm_modem_initialize_data(struct platform_device *pdev, |
Joel King | e9cd527 | 2012-01-28 12:48:59 -0800 | [diff] [blame] | 450 | struct mdm_ops *mdm_ops) |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 451 | { |
| 452 | struct resource *pres; |
| 453 | |
| 454 | /* MDM2AP_ERRFATAL */ |
| 455 | pres = platform_get_resource_byname(pdev, IORESOURCE_IO, |
| 456 | "MDM2AP_ERRFATAL"); |
| 457 | if (pres) |
| 458 | mdm_drv->mdm2ap_errfatal_gpio = pres->start; |
| 459 | |
| 460 | /* AP2MDM_ERRFATAL */ |
| 461 | pres = platform_get_resource_byname(pdev, IORESOURCE_IO, |
| 462 | "AP2MDM_ERRFATAL"); |
| 463 | if (pres) |
| 464 | mdm_drv->ap2mdm_errfatal_gpio = pres->start; |
| 465 | |
| 466 | /* MDM2AP_STATUS */ |
| 467 | pres = platform_get_resource_byname(pdev, IORESOURCE_IO, |
| 468 | "MDM2AP_STATUS"); |
| 469 | if (pres) |
| 470 | mdm_drv->mdm2ap_status_gpio = pres->start; |
| 471 | |
| 472 | /* AP2MDM_STATUS */ |
| 473 | pres = platform_get_resource_byname(pdev, IORESOURCE_IO, |
| 474 | "AP2MDM_STATUS"); |
| 475 | if (pres) |
| 476 | mdm_drv->ap2mdm_status_gpio = pres->start; |
| 477 | |
| 478 | /* MDM2AP_WAKEUP */ |
| 479 | pres = platform_get_resource_byname(pdev, IORESOURCE_IO, |
| 480 | "MDM2AP_WAKEUP"); |
| 481 | if (pres) |
| 482 | mdm_drv->mdm2ap_wakeup_gpio = pres->start; |
| 483 | |
| 484 | /* AP2MDM_WAKEUP */ |
| 485 | pres = platform_get_resource_byname(pdev, IORESOURCE_IO, |
| 486 | "AP2MDM_WAKEUP"); |
| 487 | if (pres) |
| 488 | mdm_drv->ap2mdm_wakeup_gpio = pres->start; |
| 489 | |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 490 | /* AP2MDM_SOFT_RESET */ |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 491 | pres = platform_get_resource_byname(pdev, IORESOURCE_IO, |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 492 | "AP2MDM_SOFT_RESET"); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 493 | if (pres) |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 494 | mdm_drv->ap2mdm_soft_reset_gpio = pres->start; |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 495 | |
| 496 | /* AP2MDM_KPDPWR_N */ |
| 497 | pres = platform_get_resource_byname(pdev, IORESOURCE_IO, |
| 498 | "AP2MDM_KPDPWR_N"); |
| 499 | if (pres) |
| 500 | mdm_drv->ap2mdm_kpdpwr_n_gpio = pres->start; |
| 501 | |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 502 | /* AP2MDM_PMIC_PWR_EN */ |
| 503 | pres = platform_get_resource_byname(pdev, IORESOURCE_IO, |
| 504 | "AP2MDM_PMIC_PWR_EN"); |
| 505 | if (pres) |
| 506 | mdm_drv->ap2mdm_pmic_pwr_en_gpio = pres->start; |
| 507 | |
Vamsi Krishna | c6dcd5e | 2012-05-09 15:38:01 -0700 | [diff] [blame^] | 508 | /* MDM2AP_PBLRDY */ |
| 509 | pres = platform_get_resource_byname(pdev, IORESOURCE_IO, |
| 510 | "MDM2AP_PBLRDY"); |
| 511 | if (pres) |
| 512 | mdm_drv->mdm2ap_pblrdy = pres->start; |
| 513 | |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 514 | mdm_drv->boot_type = CHARM_NORMAL_BOOT; |
| 515 | |
Joel King | e9cd527 | 2012-01-28 12:48:59 -0800 | [diff] [blame] | 516 | mdm_drv->ops = mdm_ops; |
Joel King | 415af51 | 2012-02-03 10:22:43 -0800 | [diff] [blame] | 517 | mdm_drv->pdata = pdev->dev.platform_data; |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 518 | } |
| 519 | |
| 520 | int mdm_common_create(struct platform_device *pdev, |
Joel King | e9cd527 | 2012-01-28 12:48:59 -0800 | [diff] [blame] | 521 | struct mdm_ops *p_mdm_cb) |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 522 | { |
| 523 | int ret = -1, irq; |
| 524 | |
| 525 | mdm_drv = kzalloc(sizeof(struct mdm_modem_drv), GFP_KERNEL); |
| 526 | if (mdm_drv == NULL) { |
| 527 | pr_err("%s: kzalloc fail.\n", __func__); |
| 528 | goto alloc_err; |
| 529 | } |
| 530 | |
| 531 | mdm_modem_initialize_data(pdev, p_mdm_cb); |
Joel King | e9cd527 | 2012-01-28 12:48:59 -0800 | [diff] [blame] | 532 | if (mdm_drv->ops->debug_state_changed_cb) |
| 533 | mdm_drv->ops->debug_state_changed_cb(mdm_debug_on); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 534 | |
| 535 | gpio_request(mdm_drv->ap2mdm_status_gpio, "AP2MDM_STATUS"); |
| 536 | gpio_request(mdm_drv->ap2mdm_errfatal_gpio, "AP2MDM_ERRFATAL"); |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 537 | if (mdm_drv->ap2mdm_kpdpwr_n_gpio > 0) |
| 538 | gpio_request(mdm_drv->ap2mdm_kpdpwr_n_gpio, "AP2MDM_KPDPWR_N"); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 539 | gpio_request(mdm_drv->mdm2ap_status_gpio, "MDM2AP_STATUS"); |
| 540 | gpio_request(mdm_drv->mdm2ap_errfatal_gpio, "MDM2AP_ERRFATAL"); |
Vamsi Krishna | c6dcd5e | 2012-05-09 15:38:01 -0700 | [diff] [blame^] | 541 | if (mdm_drv->mdm2ap_pblrdy > 0) |
| 542 | gpio_request(mdm_drv->mdm2ap_pblrdy, "MDM2AP_PBLRDY"); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 543 | |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 544 | if (mdm_drv->ap2mdm_pmic_pwr_en_gpio > 0) |
| 545 | gpio_request(mdm_drv->ap2mdm_pmic_pwr_en_gpio, |
| 546 | "AP2MDM_PMIC_PWR_EN"); |
| 547 | if (mdm_drv->ap2mdm_soft_reset_gpio > 0) |
| 548 | gpio_request(mdm_drv->ap2mdm_soft_reset_gpio, |
| 549 | "AP2MDM_SOFT_RESET"); |
| 550 | |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 551 | if (mdm_drv->ap2mdm_wakeup_gpio > 0) |
| 552 | gpio_request(mdm_drv->ap2mdm_wakeup_gpio, "AP2MDM_WAKEUP"); |
| 553 | |
| 554 | gpio_direction_output(mdm_drv->ap2mdm_status_gpio, 1); |
| 555 | gpio_direction_output(mdm_drv->ap2mdm_errfatal_gpio, 0); |
| 556 | |
| 557 | if (mdm_drv->ap2mdm_wakeup_gpio > 0) |
| 558 | gpio_direction_output(mdm_drv->ap2mdm_wakeup_gpio, 0); |
| 559 | |
| 560 | gpio_direction_input(mdm_drv->mdm2ap_status_gpio); |
| 561 | gpio_direction_input(mdm_drv->mdm2ap_errfatal_gpio); |
| 562 | |
| 563 | mdm_queue = create_singlethread_workqueue("mdm_queue"); |
| 564 | if (!mdm_queue) { |
| 565 | pr_err("%s: could not create workqueue. All mdm " |
| 566 | "functionality will be disabled\n", |
| 567 | __func__); |
| 568 | ret = -ENOMEM; |
| 569 | goto fatal_err; |
| 570 | } |
| 571 | |
Joel King | 30fdd66 | 2012-05-07 19:39:29 -0700 | [diff] [blame] | 572 | mdm_sfr_queue = alloc_workqueue("mdm_sfr_queue", 0, 0); |
| 573 | if (!mdm_sfr_queue) { |
| 574 | pr_err("%s: could not create workqueue mdm_sfr_queue." |
| 575 | " All mdm functionality will be disabled\n", |
| 576 | __func__); |
| 577 | ret = -ENOMEM; |
| 578 | destroy_workqueue(mdm_queue); |
| 579 | goto fatal_err; |
| 580 | } |
| 581 | |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 582 | atomic_notifier_chain_register(&panic_notifier_list, &mdm_panic_blk); |
| 583 | mdm_debugfs_init(); |
| 584 | |
| 585 | /* Register subsystem handlers */ |
| 586 | ssr_register_subsystem(&mdm_subsystem); |
| 587 | |
| 588 | /* ERR_FATAL irq. */ |
| 589 | irq = MSM_GPIO_TO_INT(mdm_drv->mdm2ap_errfatal_gpio); |
| 590 | if (irq < 0) { |
| 591 | pr_err("%s: could not get MDM2AP_ERRFATAL IRQ resource. " |
| 592 | "error=%d No IRQ will be generated on errfatal.", |
| 593 | __func__, irq); |
| 594 | goto errfatal_err; |
| 595 | } |
| 596 | ret = request_irq(irq, mdm_errfatal, |
| 597 | IRQF_TRIGGER_RISING , "mdm errfatal", NULL); |
| 598 | |
| 599 | if (ret < 0) { |
| 600 | pr_err("%s: MDM2AP_ERRFATAL IRQ#%d request failed with error=%d" |
| 601 | ". No IRQ will be generated on errfatal.", |
| 602 | __func__, irq, ret); |
| 603 | goto errfatal_err; |
| 604 | } |
| 605 | mdm_drv->mdm_errfatal_irq = irq; |
| 606 | |
| 607 | errfatal_err: |
| 608 | |
| 609 | /* status irq */ |
| 610 | irq = MSM_GPIO_TO_INT(mdm_drv->mdm2ap_status_gpio); |
| 611 | if (irq < 0) { |
| 612 | pr_err("%s: could not get MDM2AP_STATUS IRQ resource. " |
| 613 | "error=%d No IRQ will be generated on status change.", |
| 614 | __func__, irq); |
| 615 | goto status_err; |
| 616 | } |
| 617 | |
| 618 | ret = request_threaded_irq(irq, NULL, mdm_status_change, |
Vamsi Krishna | 3392563 | 2011-12-13 15:43:09 -0800 | [diff] [blame] | 619 | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_SHARED, |
| 620 | "mdm status", mdm_drv); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 621 | |
| 622 | if (ret < 0) { |
| 623 | pr_err("%s: MDM2AP_STATUS IRQ#%d request failed with error=%d" |
| 624 | ". No IRQ will be generated on status change.", |
| 625 | __func__, irq, ret); |
| 626 | goto status_err; |
| 627 | } |
| 628 | mdm_drv->mdm_status_irq = irq; |
| 629 | |
| 630 | status_err: |
Vamsi Krishna | c6dcd5e | 2012-05-09 15:38:01 -0700 | [diff] [blame^] | 631 | if (mdm_drv->mdm2ap_pblrdy > 0) { |
| 632 | irq = MSM_GPIO_TO_INT(mdm_drv->mdm2ap_pblrdy); |
| 633 | if (irq < 0) { |
| 634 | pr_err("%s: could not get MDM2AP_PBLRDY IRQ resource", |
| 635 | __func__); |
| 636 | goto pblrdy_err; |
| 637 | } |
| 638 | |
| 639 | ret = request_threaded_irq(irq, NULL, mdm_pblrdy_change, |
| 640 | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | |
| 641 | IRQF_SHARED, |
| 642 | "mdm pbl ready", mdm_drv); |
| 643 | |
| 644 | if (ret < 0) { |
| 645 | pr_err("%s: MDM2AP_PBL IRQ#%d request failed error=%d", |
| 646 | __func__, irq, ret); |
| 647 | goto pblrdy_err; |
| 648 | } |
| 649 | } |
| 650 | |
| 651 | pblrdy_err: |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 652 | /* |
| 653 | * If AP2MDM_PMIC_PWR_EN gpio is used, pull it high. It remains |
| 654 | * high until the whole phone is shut down. |
| 655 | */ |
| 656 | if (mdm_drv->ap2mdm_pmic_pwr_en_gpio > 0) |
| 657 | gpio_direction_output(mdm_drv->ap2mdm_pmic_pwr_en_gpio, 1); |
Joel King | ef39084 | 2012-05-23 16:42:48 -0700 | [diff] [blame] | 658 | /* Register VDDmin gpios with RPM */ |
| 659 | mdm_setup_vddmin_gpios(); |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 660 | |
Joel King | 35f819e | 2012-02-05 12:05:57 -0800 | [diff] [blame] | 661 | /* Perform early powerup of the external modem in order to |
| 662 | * allow tabla devices to be found. |
| 663 | */ |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 664 | if (mdm_drv->pdata->early_power_on) |
| 665 | mdm_drv->ops->power_on_mdm_cb(mdm_drv); |
Joel King | 35f819e | 2012-02-05 12:05:57 -0800 | [diff] [blame] | 666 | |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 667 | pr_info("%s: Registering mdm modem\n", __func__); |
| 668 | return misc_register(&mdm_modem_misc); |
| 669 | |
| 670 | fatal_err: |
| 671 | gpio_free(mdm_drv->ap2mdm_status_gpio); |
| 672 | gpio_free(mdm_drv->ap2mdm_errfatal_gpio); |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 673 | if (mdm_drv->ap2mdm_kpdpwr_n_gpio > 0) |
| 674 | gpio_free(mdm_drv->ap2mdm_kpdpwr_n_gpio); |
| 675 | if (mdm_drv->ap2mdm_pmic_pwr_en_gpio > 0) |
| 676 | gpio_free(mdm_drv->ap2mdm_pmic_pwr_en_gpio); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 677 | gpio_free(mdm_drv->mdm2ap_status_gpio); |
| 678 | gpio_free(mdm_drv->mdm2ap_errfatal_gpio); |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 679 | if (mdm_drv->ap2mdm_soft_reset_gpio > 0) |
| 680 | gpio_free(mdm_drv->ap2mdm_soft_reset_gpio); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 681 | |
| 682 | if (mdm_drv->ap2mdm_wakeup_gpio > 0) |
| 683 | gpio_free(mdm_drv->ap2mdm_wakeup_gpio); |
| 684 | |
| 685 | kfree(mdm_drv); |
| 686 | ret = -ENODEV; |
| 687 | |
| 688 | alloc_err: |
| 689 | return ret; |
| 690 | } |
| 691 | |
| 692 | int mdm_common_modem_remove(struct platform_device *pdev) |
| 693 | { |
| 694 | int ret; |
| 695 | |
| 696 | gpio_free(mdm_drv->ap2mdm_status_gpio); |
| 697 | gpio_free(mdm_drv->ap2mdm_errfatal_gpio); |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 698 | if (mdm_drv->ap2mdm_kpdpwr_n_gpio > 0) |
| 699 | gpio_free(mdm_drv->ap2mdm_kpdpwr_n_gpio); |
| 700 | if (mdm_drv->ap2mdm_pmic_pwr_en_gpio > 0) |
| 701 | gpio_free(mdm_drv->ap2mdm_pmic_pwr_en_gpio); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 702 | gpio_free(mdm_drv->mdm2ap_status_gpio); |
| 703 | gpio_free(mdm_drv->mdm2ap_errfatal_gpio); |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 704 | if (mdm_drv->ap2mdm_soft_reset_gpio > 0) |
| 705 | gpio_free(mdm_drv->ap2mdm_soft_reset_gpio); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 706 | |
| 707 | if (mdm_drv->ap2mdm_wakeup_gpio > 0) |
| 708 | gpio_free(mdm_drv->ap2mdm_wakeup_gpio); |
| 709 | |
| 710 | kfree(mdm_drv); |
| 711 | |
| 712 | ret = misc_deregister(&mdm_modem_misc); |
| 713 | return ret; |
| 714 | } |
| 715 | |
| 716 | void mdm_common_modem_shutdown(struct platform_device *pdev) |
| 717 | { |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 718 | mdm_disable_irqs(); |
| 719 | |
Joel King | e9cd527 | 2012-01-28 12:48:59 -0800 | [diff] [blame] | 720 | mdm_drv->ops->power_down_mdm_cb(mdm_drv); |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 721 | if (mdm_drv->ap2mdm_pmic_pwr_en_gpio > 0) |
| 722 | gpio_direction_output(mdm_drv->ap2mdm_pmic_pwr_en_gpio, 0); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 723 | } |
| 724 | |