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