Taniya Das | 2b7646b | 2013-01-15 11:28:14 +0530 | [diff] [blame] | 1 | /* Copyright (c) 2011-2013, The Linux Foundation. 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> |
Joel King | 269aa60 | 2012-07-23 08:07:35 -0700 | [diff] [blame] | 33 | #include <linux/msm_charm.h> |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 34 | #include <asm/mach-types.h> |
| 35 | #include <asm/uaccess.h> |
| 36 | #include <mach/mdm2.h> |
| 37 | #include <mach/restart.h> |
| 38 | #include <mach/subsystem_notif.h> |
| 39 | #include <mach/subsystem_restart.h> |
Joel King | ef39084 | 2012-05-23 16:42:48 -0700 | [diff] [blame] | 40 | #include <mach/rpm.h> |
Joel King | 269aa60 | 2012-07-23 08:07:35 -0700 | [diff] [blame] | 41 | #include <mach/gpiomux.h> |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 42 | #include "msm_watchdog.h" |
| 43 | #include "mdm_private.h" |
Joel King | 30fdd66 | 2012-05-07 19:39:29 -0700 | [diff] [blame] | 44 | #include "sysmon.h" |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 45 | |
| 46 | #define MDM_MODEM_TIMEOUT 6000 |
| 47 | #define MDM_MODEM_DELTA 100 |
Joel King | 52d7fa6 | 2012-03-21 08:40:52 -0700 | [diff] [blame] | 48 | #define MDM_BOOT_TIMEOUT 60000L |
Joel King | 733377c | 2012-06-20 13:07:38 -0700 | [diff] [blame] | 49 | #define MDM_RDUMP_TIMEOUT 120000L |
Joel King | 493b3ac | 2012-05-14 11:39:45 -0700 | [diff] [blame] | 50 | #define MDM2AP_STATUS_TIMEOUT_MS 60000L |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 51 | |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 52 | /* Allow a maximum device id of this many digits */ |
| 53 | #define MAX_DEVICE_DIGITS 10 |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 54 | #define EXTERNAL_MODEM "external_modem" |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 55 | #define SUBSYS_NAME_LENGTH \ |
| 56 | (sizeof(EXTERNAL_MODEM) + MAX_DEVICE_DIGITS) |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 57 | |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 58 | #define DEVICE_BASE_NAME "mdm" |
| 59 | #define DEVICE_NAME_LENGTH \ |
| 60 | (sizeof(DEVICE_BASE_NAME) + MAX_DEVICE_DIGITS) |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 61 | |
Joel King | 30fdd66 | 2012-05-07 19:39:29 -0700 | [diff] [blame] | 62 | #define RD_BUF_SIZE 100 |
| 63 | #define SFR_MAX_RETRIES 10 |
| 64 | #define SFR_RETRY_INTERVAL 1000 |
| 65 | |
Joel King | 269aa60 | 2012-07-23 08:07:35 -0700 | [diff] [blame] | 66 | enum gpio_update_config { |
| 67 | GPIO_UPDATE_BOOTING_CONFIG = 1, |
| 68 | GPIO_UPDATE_RUNNING_CONFIG, |
| 69 | }; |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 70 | |
| 71 | struct mdm_device { |
| 72 | struct list_head link; |
| 73 | struct mdm_modem_drv mdm_data; |
| 74 | |
| 75 | int mdm2ap_status_valid_old_config; |
| 76 | struct gpiomux_setting mdm2ap_status_old_config; |
| 77 | int first_boot; |
| 78 | struct workqueue_struct *mdm_queue; |
| 79 | struct workqueue_struct *mdm_sfr_queue; |
| 80 | unsigned int dump_timeout_ms; |
| 81 | |
| 82 | char subsys_name[SUBSYS_NAME_LENGTH]; |
| 83 | struct subsys_desc mdm_subsys; |
| 84 | struct subsys_device *mdm_subsys_dev; |
| 85 | |
| 86 | char device_name[DEVICE_NAME_LENGTH]; |
| 87 | struct miscdevice misc_device; |
| 88 | |
| 89 | struct completion mdm_needs_reload; |
| 90 | struct completion mdm_boot; |
| 91 | struct completion mdm_ram_dumps; |
| 92 | int mdm_errfatal_irq; |
| 93 | int mdm_status_irq; |
| 94 | int mdm_pblrdy_irq; |
| 95 | |
| 96 | struct delayed_work mdm2ap_status_check_work; |
| 97 | struct work_struct mdm_status_work; |
| 98 | struct work_struct sfr_reason_work; |
| 99 | |
| 100 | struct notifier_block mdm_panic_blk; |
| 101 | |
| 102 | int ssr_started_internally; |
| 103 | }; |
| 104 | |
| 105 | static struct list_head mdm_devices; |
| 106 | static DEFINE_SPINLOCK(mdm_devices_lock); |
| 107 | |
| 108 | static int ssr_count; |
| 109 | static DEFINE_SPINLOCK(ssr_lock); |
| 110 | |
| 111 | static unsigned int mdm_debug_mask; |
| 112 | int vddmin_gpios_sent; |
| 113 | static struct mdm_ops *mdm_ops; |
| 114 | |
| 115 | static void mdm_device_list_add(struct mdm_device *mdev) |
| 116 | { |
| 117 | unsigned long flags; |
| 118 | |
| 119 | spin_lock_irqsave(&mdm_devices_lock, flags); |
| 120 | list_add_tail(&mdev->link, &mdm_devices); |
| 121 | spin_unlock_irqrestore(&mdm_devices_lock, flags); |
| 122 | } |
| 123 | |
| 124 | static void mdm_device_list_remove(struct mdm_device *mdev) |
| 125 | { |
| 126 | unsigned long flags; |
| 127 | struct mdm_device *lmdev, *tmp; |
| 128 | |
| 129 | spin_lock_irqsave(&mdm_devices_lock, flags); |
| 130 | list_for_each_entry_safe(lmdev, tmp, &mdm_devices, link) { |
| 131 | if (mdev && mdev == lmdev) { |
| 132 | pr_debug("%s: removing device id %d\n", |
| 133 | __func__, mdev->mdm_data.device_id); |
| 134 | list_del(&mdev->link); |
| 135 | break; |
| 136 | } |
| 137 | } |
| 138 | spin_unlock_irqrestore(&mdm_devices_lock, flags); |
| 139 | } |
| 140 | |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 141 | /* If the platform's cascading_ssr flag is set, the subsystem |
| 142 | * restart module will restart the other modems so stop |
| 143 | * monitoring them as well. |
| 144 | * This function can be called from interrupt context. |
| 145 | */ |
| 146 | static void mdm_start_ssr(struct mdm_device *mdev) |
| 147 | { |
| 148 | unsigned long flags; |
| 149 | int start_ssr = 1; |
| 150 | |
| 151 | spin_lock_irqsave(&ssr_lock, flags); |
| 152 | if (mdev->mdm_data.pdata->cascading_ssr && |
| 153 | ssr_count > 0) { |
| 154 | start_ssr = 0; |
| 155 | } else { |
| 156 | ssr_count++; |
| 157 | mdev->ssr_started_internally = 1; |
| 158 | } |
| 159 | spin_unlock_irqrestore(&ssr_lock, flags); |
| 160 | |
| 161 | if (start_ssr) { |
| 162 | atomic_set(&mdev->mdm_data.mdm_ready, 0); |
| 163 | pr_debug("%s: Resetting mdm id %d due to mdm error\n", |
| 164 | __func__, mdev->mdm_data.device_id); |
| 165 | subsystem_restart_dev(mdev->mdm_subsys_dev); |
| 166 | } else { |
| 167 | pr_debug("%s: Another modem is already in SSR\n", |
| 168 | __func__); |
| 169 | } |
| 170 | } |
| 171 | |
| 172 | /* Increment the reference count to handle the case where |
| 173 | * subsystem restart is initiated by the SSR service. |
| 174 | */ |
| 175 | static void mdm_ssr_started(struct mdm_device *mdev) |
| 176 | { |
| 177 | unsigned long flags; |
| 178 | |
| 179 | spin_lock_irqsave(&ssr_lock, flags); |
| 180 | ssr_count++; |
| 181 | atomic_set(&mdev->mdm_data.mdm_ready, 0); |
| 182 | spin_unlock_irqrestore(&ssr_lock, flags); |
| 183 | } |
| 184 | |
| 185 | /* mdm_ssr_completed assumes that mdm_ssr_started has previously |
| 186 | * been called. |
| 187 | */ |
| 188 | static void mdm_ssr_completed(struct mdm_device *mdev) |
| 189 | { |
| 190 | unsigned long flags; |
| 191 | |
| 192 | spin_lock_irqsave(&ssr_lock, flags); |
| 193 | ssr_count--; |
| 194 | if (mdev->ssr_started_internally) { |
| 195 | mdev->ssr_started_internally = 0; |
| 196 | ssr_count--; |
| 197 | } |
| 198 | |
| 199 | if (ssr_count < 0) { |
| 200 | pr_err("%s: ssr_count = %d\n", |
| 201 | __func__, ssr_count); |
| 202 | panic("%s: ssr_count = %d < 0\n", |
| 203 | __func__, ssr_count); |
| 204 | } |
| 205 | spin_unlock_irqrestore(&ssr_lock, flags); |
| 206 | } |
Joel King | 269aa60 | 2012-07-23 08:07:35 -0700 | [diff] [blame] | 207 | |
Joel King | ef39084 | 2012-05-23 16:42:48 -0700 | [diff] [blame] | 208 | static irqreturn_t mdm_vddmin_change(int irq, void *dev_id) |
| 209 | { |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 210 | struct mdm_device *mdev = (struct mdm_device *)dev_id; |
| 211 | struct mdm_vddmin_resource *vddmin_res; |
| 212 | int value; |
Joel King | ef39084 | 2012-05-23 16:42:48 -0700 | [diff] [blame] | 213 | |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 214 | if (!mdev) |
| 215 | goto handled; |
| 216 | |
| 217 | vddmin_res = mdev->mdm_data.pdata->vddmin_resource; |
| 218 | if (!vddmin_res) |
| 219 | goto handled; |
| 220 | |
| 221 | value = gpio_get_value( |
| 222 | vddmin_res->mdm2ap_vddmin_gpio); |
Joel King | ef39084 | 2012-05-23 16:42:48 -0700 | [diff] [blame] | 223 | if (value == 0) |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 224 | pr_debug("External Modem id %d entered Vddmin\n", |
| 225 | mdev->mdm_data.device_id); |
Joel King | ef39084 | 2012-05-23 16:42:48 -0700 | [diff] [blame] | 226 | else |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 227 | pr_debug("External Modem id %d exited Vddmin\n", |
| 228 | mdev->mdm_data.device_id); |
| 229 | handled: |
Joel King | ef39084 | 2012-05-23 16:42:48 -0700 | [diff] [blame] | 230 | return IRQ_HANDLED; |
| 231 | } |
| 232 | |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 233 | /* The vddmin_res resource may not be supported by some platforms. */ |
Joel King | ef39084 | 2012-05-23 16:42:48 -0700 | [diff] [blame] | 234 | static void mdm_setup_vddmin_gpios(void) |
| 235 | { |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 236 | unsigned long flags; |
Joel King | ef39084 | 2012-05-23 16:42:48 -0700 | [diff] [blame] | 237 | struct msm_rpm_iv_pair req; |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 238 | struct mdm_device *mdev; |
Joel King | ef39084 | 2012-05-23 16:42:48 -0700 | [diff] [blame] | 239 | struct mdm_vddmin_resource *vddmin_res; |
| 240 | int irq, ret; |
| 241 | |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 242 | spin_lock_irqsave(&mdm_devices_lock, flags); |
| 243 | list_for_each_entry(mdev, &mdm_devices, link) { |
| 244 | vddmin_res = mdev->mdm_data.pdata->vddmin_resource; |
| 245 | if (!vddmin_res) |
| 246 | continue; |
Joel King | ef39084 | 2012-05-23 16:42:48 -0700 | [diff] [blame] | 247 | |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 248 | pr_debug("Enabling vddmin logging on modem id %d\n", |
| 249 | mdev->mdm_data.device_id); |
| 250 | req.id = vddmin_res->rpm_id; |
| 251 | req.value = |
| 252 | ((uint32_t)vddmin_res->ap2mdm_vddmin_gpio & 0x0000FFFF) |
| 253 | << 16; |
| 254 | req.value |= ((uint32_t)vddmin_res->modes & 0x000000FF) << 8; |
| 255 | req.value |= (uint32_t)vddmin_res->drive_strength & 0x000000FF; |
Joel King | ef39084 | 2012-05-23 16:42:48 -0700 | [diff] [blame] | 256 | |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 257 | msm_rpm_set(MSM_RPM_CTX_SET_0, &req, 1); |
Joel King | ef39084 | 2012-05-23 16:42:48 -0700 | [diff] [blame] | 258 | |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 259 | /* Start monitoring low power gpio from mdm */ |
| 260 | irq = gpio_to_irq(vddmin_res->mdm2ap_vddmin_gpio); |
| 261 | if (irq < 0) |
| 262 | pr_err("%s: could not get LPM POWER IRQ resource mdm id %d.\n", |
| 263 | __func__, mdev->mdm_data.device_id); |
| 264 | else { |
| 265 | ret = request_threaded_irq(irq, NULL, mdm_vddmin_change, |
| 266 | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, |
| 267 | "mdm lpm", mdev); |
| 268 | |
| 269 | if (ret < 0) |
| 270 | pr_err("%s: MDM LPM IRQ#%d request failed with error=%d", |
| 271 | __func__, irq, ret); |
| 272 | } |
Joel King | ef39084 | 2012-05-23 16:42:48 -0700 | [diff] [blame] | 273 | } |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 274 | spin_unlock_irqrestore(&mdm_devices_lock, flags); |
Joel King | ef39084 | 2012-05-23 16:42:48 -0700 | [diff] [blame] | 275 | return; |
| 276 | } |
| 277 | |
Joel King | 30fdd66 | 2012-05-07 19:39:29 -0700 | [diff] [blame] | 278 | static void mdm_restart_reason_fn(struct work_struct *work) |
| 279 | { |
| 280 | int ret, ntries = 0; |
| 281 | char sfr_buf[RD_BUF_SIZE]; |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 282 | struct mdm_platform_data *pdata; |
| 283 | struct mdm_device *mdev = container_of(work, |
| 284 | struct mdm_device, sfr_reason_work); |
Joel King | 30fdd66 | 2012-05-07 19:39:29 -0700 | [diff] [blame] | 285 | |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 286 | pdata = mdev->mdm_data.pdata; |
| 287 | if (pdata->sysmon_subsys_id_valid) { |
| 288 | do { |
| 289 | ret = sysmon_get_reason(pdata->sysmon_subsys_id, |
Joel King | 30fdd66 | 2012-05-07 19:39:29 -0700 | [diff] [blame] | 290 | sfr_buf, sizeof(sfr_buf)); |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 291 | if (!ret) { |
| 292 | pr_err("mdm restart reason: %s\n", sfr_buf); |
| 293 | return; |
| 294 | } |
| 295 | /* Wait for the modem to be fully booted after a |
| 296 | * subsystem restart. This may take several seconds. |
Joel King | 30fdd66 | 2012-05-07 19:39:29 -0700 | [diff] [blame] | 297 | */ |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 298 | msleep(SFR_RETRY_INTERVAL); |
| 299 | } while (++ntries < SFR_MAX_RETRIES); |
| 300 | pr_debug("%s: Error retrieving restart reason: %d\n", |
| 301 | __func__, ret); |
| 302 | } |
Joel King | 30fdd66 | 2012-05-07 19:39:29 -0700 | [diff] [blame] | 303 | } |
| 304 | |
Joel King | 493b3ac | 2012-05-14 11:39:45 -0700 | [diff] [blame] | 305 | static void mdm2ap_status_check(struct work_struct *work) |
| 306 | { |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 307 | struct mdm_device *mdev = |
| 308 | container_of(work, struct mdm_device, |
| 309 | mdm2ap_status_check_work.work); |
| 310 | struct mdm_modem_drv *mdm_drv = &mdev->mdm_data; |
Joel King | 493b3ac | 2012-05-14 11:39:45 -0700 | [diff] [blame] | 311 | /* |
| 312 | * If the mdm modem did not pull the MDM2AP_STATUS gpio |
| 313 | * high then call subsystem_restart. |
| 314 | */ |
Ameya Thakur | 43248fd | 2012-07-10 18:50:52 -0700 | [diff] [blame] | 315 | if (!mdm_drv->disable_status_check) { |
| 316 | if (gpio_get_value(mdm_drv->mdm2ap_status_gpio) == 0) { |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 317 | pr_debug("%s: MDM2AP_STATUS did not go high on mdm id %d\n", |
| 318 | __func__, mdev->mdm_data.device_id); |
| 319 | mdm_start_ssr(mdev); |
Ameya Thakur | 43248fd | 2012-07-10 18:50:52 -0700 | [diff] [blame] | 320 | } |
Joel King | 493b3ac | 2012-05-14 11:39:45 -0700 | [diff] [blame] | 321 | } |
| 322 | } |
| 323 | |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 324 | static void mdm_update_gpio_configs(struct mdm_device *mdev, |
| 325 | enum gpio_update_config gpio_config) |
Joel King | 269aa60 | 2012-07-23 08:07:35 -0700 | [diff] [blame] | 326 | { |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 327 | struct mdm_modem_drv *mdm_drv = &mdev->mdm_data; |
| 328 | |
Joel King | 269aa60 | 2012-07-23 08:07:35 -0700 | [diff] [blame] | 329 | /* Some gpio configuration may need updating after modem bootup.*/ |
| 330 | switch (gpio_config) { |
| 331 | case GPIO_UPDATE_RUNNING_CONFIG: |
| 332 | if (mdm_drv->pdata->mdm2ap_status_gpio_run_cfg) { |
| 333 | if (msm_gpiomux_write(mdm_drv->mdm2ap_status_gpio, |
| 334 | GPIOMUX_ACTIVE, |
| 335 | mdm_drv->pdata->mdm2ap_status_gpio_run_cfg, |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 336 | &mdev->mdm2ap_status_old_config)) |
| 337 | pr_err("%s: failed updating running gpio config mdm id %d\n", |
| 338 | __func__, mdev->mdm_data.device_id); |
Joel King | 269aa60 | 2012-07-23 08:07:35 -0700 | [diff] [blame] | 339 | else |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 340 | mdev->mdm2ap_status_valid_old_config = 1; |
Joel King | 269aa60 | 2012-07-23 08:07:35 -0700 | [diff] [blame] | 341 | } |
| 342 | break; |
| 343 | case GPIO_UPDATE_BOOTING_CONFIG: |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 344 | if (mdev->mdm2ap_status_valid_old_config) { |
Joel King | 269aa60 | 2012-07-23 08:07:35 -0700 | [diff] [blame] | 345 | msm_gpiomux_write(mdm_drv->mdm2ap_status_gpio, |
| 346 | GPIOMUX_ACTIVE, |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 347 | &mdev->mdm2ap_status_old_config, |
Joel King | 269aa60 | 2012-07-23 08:07:35 -0700 | [diff] [blame] | 348 | NULL); |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 349 | mdev->mdm2ap_status_valid_old_config = 0; |
Joel King | 269aa60 | 2012-07-23 08:07:35 -0700 | [diff] [blame] | 350 | } |
| 351 | break; |
| 352 | default: |
| 353 | pr_err("%s: called with no config\n", __func__); |
| 354 | break; |
| 355 | } |
| 356 | } |
| 357 | |
Pavankumar Kondeti | 0161cf9 | 2013-02-12 18:10:21 +0530 | [diff] [blame] | 358 | static long mdm_modem_ioctl(struct file *filp, unsigned int cmd, |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 359 | unsigned long arg) |
| 360 | { |
| 361 | int status, ret = 0; |
Pavankumar Kondeti | 0161cf9 | 2013-02-12 18:10:21 +0530 | [diff] [blame] | 362 | struct mdm_device *mdev = filp->private_data; |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 363 | struct mdm_modem_drv *mdm_drv; |
| 364 | |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 365 | if (_IOC_TYPE(cmd) != CHARM_CODE) { |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 366 | pr_err("%s: invalid ioctl code to mdm id %d\n", |
| 367 | __func__, mdev->mdm_data.device_id); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 368 | return -EINVAL; |
| 369 | } |
| 370 | |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 371 | mdm_drv = &mdev->mdm_data; |
| 372 | pr_debug("%s: Entering ioctl cmd = %d, mdm id = %d\n", |
| 373 | __func__, _IOC_NR(cmd), mdev->mdm_data.device_id); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 374 | switch (cmd) { |
| 375 | case WAKE_CHARM: |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 376 | pr_debug("%s: Powering on mdm id %d\n", |
| 377 | __func__, mdev->mdm_data.device_id); |
| 378 | mdm_ops->power_on_mdm_cb(mdm_drv); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 379 | break; |
| 380 | case CHECK_FOR_BOOT: |
| 381 | if (gpio_get_value(mdm_drv->mdm2ap_status_gpio) == 0) |
| 382 | put_user(1, (unsigned long __user *) arg); |
| 383 | else |
| 384 | put_user(0, (unsigned long __user *) arg); |
| 385 | break; |
| 386 | case NORMAL_BOOT_DONE: |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 387 | pr_debug("%s: check if mdm id %d is booted up\n", |
| 388 | __func__, mdev->mdm_data.device_id); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 389 | get_user(status, (unsigned long __user *) arg); |
Joel King | 2a42f50 | 2012-02-03 11:36:25 -0800 | [diff] [blame] | 390 | if (status) { |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 391 | pr_debug("%s: normal boot of mdm id %d failed\n", |
| 392 | __func__, mdev->mdm_data.device_id); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 393 | mdm_drv->mdm_boot_status = -EIO; |
Joel King | 2a42f50 | 2012-02-03 11:36:25 -0800 | [diff] [blame] | 394 | } else { |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 395 | pr_debug("%s: normal boot of mdm id %d done\n", |
| 396 | __func__, mdev->mdm_data.device_id); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 397 | mdm_drv->mdm_boot_status = 0; |
Joel King | 2a42f50 | 2012-02-03 11:36:25 -0800 | [diff] [blame] | 398 | } |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 399 | atomic_set(&mdm_drv->mdm_ready, 1); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 400 | |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 401 | if (mdm_ops->normal_boot_done_cb != NULL) |
| 402 | mdm_ops->normal_boot_done_cb(mdm_drv); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 403 | |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 404 | if (!mdev->first_boot) |
| 405 | complete(&mdev->mdm_boot); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 406 | else |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 407 | mdev->first_boot = 0; |
Joel King | 493b3ac | 2012-05-14 11:39:45 -0700 | [diff] [blame] | 408 | |
Joel King | 269aa60 | 2012-07-23 08:07:35 -0700 | [diff] [blame] | 409 | /* If successful, start a timer to check that the mdm2ap_status |
| 410 | * gpio goes high. |
Joel King | 493b3ac | 2012-05-14 11:39:45 -0700 | [diff] [blame] | 411 | */ |
Joel King | 269aa60 | 2012-07-23 08:07:35 -0700 | [diff] [blame] | 412 | if (!status && gpio_get_value(mdm_drv->mdm2ap_status_gpio) == 0) |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 413 | schedule_delayed_work(&mdev->mdm2ap_status_check_work, |
Joel King | 493b3ac | 2012-05-14 11:39:45 -0700 | [diff] [blame] | 414 | msecs_to_jiffies(MDM2AP_STATUS_TIMEOUT_MS)); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 415 | break; |
| 416 | case RAM_DUMP_DONE: |
Joel King | 2a42f50 | 2012-02-03 11:36:25 -0800 | [diff] [blame] | 417 | pr_debug("%s: mdm done collecting RAM dumps\n", __func__); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 418 | get_user(status, (unsigned long __user *) arg); |
| 419 | if (status) |
| 420 | mdm_drv->mdm_ram_dump_status = -EIO; |
Joel King | 2a42f50 | 2012-02-03 11:36:25 -0800 | [diff] [blame] | 421 | else { |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 422 | pr_debug("%s: ramdump collection completed\n", |
| 423 | __func__); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 424 | mdm_drv->mdm_ram_dump_status = 0; |
Joel King | 2a42f50 | 2012-02-03 11:36:25 -0800 | [diff] [blame] | 425 | } |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 426 | complete(&mdev->mdm_ram_dumps); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 427 | break; |
| 428 | case WAIT_FOR_RESTART: |
Joel King | 2a42f50 | 2012-02-03 11:36:25 -0800 | [diff] [blame] | 429 | pr_debug("%s: wait for mdm to need images reloaded\n", |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 430 | __func__); |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 431 | ret = wait_for_completion_interruptible( |
| 432 | &mdev->mdm_needs_reload); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 433 | if (!ret) |
| 434 | put_user(mdm_drv->boot_type, |
| 435 | (unsigned long __user *) arg); |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 436 | init_completion(&mdev->mdm_needs_reload); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 437 | break; |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 438 | case GET_DLOAD_STATUS: |
| 439 | pr_debug("getting status of mdm2ap_errfatal_gpio\n"); |
| 440 | if (gpio_get_value(mdm_drv->mdm2ap_errfatal_gpio) == 1 && |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 441 | !atomic_read(&mdm_drv->mdm_ready)) |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 442 | put_user(1, (unsigned long __user *) arg); |
| 443 | else |
| 444 | put_user(0, (unsigned long __user *) arg); |
| 445 | break; |
Ameya Thakur | 43248fd | 2012-07-10 18:50:52 -0700 | [diff] [blame] | 446 | case IMAGE_UPGRADE: |
| 447 | pr_debug("%s Image upgrade ioctl recieved\n", __func__); |
| 448 | if (mdm_drv->pdata->image_upgrade_supported && |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 449 | mdm_ops->image_upgrade_cb) { |
Ameya Thakur | 43248fd | 2012-07-10 18:50:52 -0700 | [diff] [blame] | 450 | get_user(status, (unsigned long __user *) arg); |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 451 | mdm_ops->image_upgrade_cb(mdm_drv, status); |
Ameya Thakur | 43248fd | 2012-07-10 18:50:52 -0700 | [diff] [blame] | 452 | } else |
| 453 | pr_debug("%s Image upgrade not supported\n", __func__); |
| 454 | break; |
Joel King | bf3e4b5 | 2012-09-26 09:10:34 -0700 | [diff] [blame] | 455 | case SHUTDOWN_CHARM: |
| 456 | if (!mdm_drv->pdata->send_shdn) |
| 457 | break; |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 458 | atomic_set(&mdm_drv->mdm_ready, 0); |
Joel King | bf3e4b5 | 2012-09-26 09:10:34 -0700 | [diff] [blame] | 459 | if (mdm_debug_mask & MDM_DEBUG_MASK_SHDN_LOG) |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 460 | pr_debug("Sending shutdown request to mdm\n"); |
Joel King | bf3e4b5 | 2012-09-26 09:10:34 -0700 | [diff] [blame] | 461 | ret = sysmon_send_shutdown(SYSMON_SS_EXT_MODEM); |
| 462 | if (ret) |
| 463 | pr_err("%s: Graceful shutdown of the external modem failed, ret = %d\n", |
| 464 | __func__, ret); |
Taniya Das | d1ed37b | 2012-11-29 12:56:38 +0530 | [diff] [blame] | 465 | put_user(ret, (unsigned long __user *) arg); |
Joel King | bf3e4b5 | 2012-09-26 09:10:34 -0700 | [diff] [blame] | 466 | break; |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 467 | default: |
| 468 | pr_err("%s: invalid ioctl cmd = %d\n", __func__, _IOC_NR(cmd)); |
| 469 | ret = -EINVAL; |
| 470 | break; |
| 471 | } |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 472 | return ret; |
| 473 | } |
| 474 | |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 475 | static void mdm_status_fn(struct work_struct *work) |
| 476 | { |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 477 | struct mdm_device *mdev = |
| 478 | container_of(work, struct mdm_device, mdm_status_work); |
| 479 | struct mdm_modem_drv *mdm_drv = &mdev->mdm_data; |
Vamsi Krishna | 3392563 | 2011-12-13 15:43:09 -0800 | [diff] [blame] | 480 | int value = gpio_get_value(mdm_drv->mdm2ap_status_gpio); |
| 481 | |
Joel King | 2a42f50 | 2012-02-03 11:36:25 -0800 | [diff] [blame] | 482 | pr_debug("%s: status:%d\n", __func__, value); |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 483 | if (atomic_read(&mdm_drv->mdm_ready) && mdm_ops->status_cb) |
| 484 | mdm_ops->status_cb(mdm_drv, value); |
Joel King | 269aa60 | 2012-07-23 08:07:35 -0700 | [diff] [blame] | 485 | |
| 486 | /* Update gpio configuration to "running" config. */ |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 487 | mdm_update_gpio_configs(mdev, GPIO_UPDATE_RUNNING_CONFIG); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 488 | } |
| 489 | |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 490 | static void mdm_disable_irqs(struct mdm_device *mdev) |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 491 | { |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 492 | if (!mdev) |
| 493 | return; |
| 494 | disable_irq_nosync(mdev->mdm_errfatal_irq); |
| 495 | disable_irq_nosync(mdev->mdm_status_irq); |
| 496 | disable_irq_nosync(mdev->mdm_pblrdy_irq); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 497 | } |
| 498 | |
| 499 | static irqreturn_t mdm_errfatal(int irq, void *dev_id) |
| 500 | { |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 501 | struct mdm_modem_drv *mdm_drv; |
| 502 | struct mdm_device *mdev = (struct mdm_device *)dev_id; |
| 503 | if (!mdev) |
| 504 | return IRQ_HANDLED; |
| 505 | |
| 506 | pr_debug("%s: mdm id %d sent errfatal interrupt\n", |
| 507 | __func__, mdev->mdm_data.device_id); |
| 508 | mdm_drv = &mdev->mdm_data; |
| 509 | if (atomic_read(&mdm_drv->mdm_ready) && |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 510 | (gpio_get_value(mdm_drv->mdm2ap_status_gpio) == 1)) { |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 511 | pr_debug("%s: Received err fatal from mdm id %d\n", |
| 512 | __func__, mdev->mdm_data.device_id); |
| 513 | mdm_start_ssr(mdev); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 514 | } |
| 515 | return IRQ_HANDLED; |
| 516 | } |
| 517 | |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 518 | /* set the mdm_device as the file's private data */ |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 519 | static int mdm_modem_open(struct inode *inode, struct file *file) |
| 520 | { |
Pavankumar Kondeti | 0161cf9 | 2013-02-12 18:10:21 +0530 | [diff] [blame] | 521 | struct miscdevice *misc = file->private_data; |
| 522 | struct mdm_device *mdev = container_of(misc, |
| 523 | struct mdm_device, misc_device); |
| 524 | |
| 525 | file->private_data = mdev; |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 526 | return 0; |
| 527 | } |
| 528 | |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 529 | static int mdm_panic_prep(struct notifier_block *this, |
| 530 | unsigned long event, void *ptr) |
| 531 | { |
| 532 | int i; |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 533 | struct mdm_modem_drv *mdm_drv; |
| 534 | struct mdm_device *mdev = |
| 535 | container_of(this, struct mdm_device, mdm_panic_blk); |
| 536 | |
| 537 | mdm_drv = &mdev->mdm_data; |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 538 | |
Joel King | 2a42f50 | 2012-02-03 11:36:25 -0800 | [diff] [blame] | 539 | 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] | 540 | __func__); |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 541 | mdm_disable_irqs(mdev); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 542 | gpio_set_value(mdm_drv->ap2mdm_errfatal_gpio, 1); |
| 543 | |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 544 | for (i = MDM_MODEM_TIMEOUT; i > 0; i -= MDM_MODEM_DELTA) { |
| 545 | pet_watchdog(); |
| 546 | mdelay(MDM_MODEM_DELTA); |
| 547 | if (gpio_get_value(mdm_drv->mdm2ap_status_gpio) == 0) |
| 548 | break; |
| 549 | } |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 550 | if (i <= 0) { |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 551 | pr_err("%s: MDM2AP_STATUS never went low\n", __func__); |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 552 | /* Reset the modem so that it will go into download mode. */ |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 553 | if (mdm_drv && mdm_ops->atomic_reset_mdm_cb) |
| 554 | mdm_ops->atomic_reset_mdm_cb(mdm_drv); |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 555 | } |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 556 | return NOTIFY_DONE; |
| 557 | } |
| 558 | |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 559 | static irqreturn_t mdm_status_change(int irq, void *dev_id) |
| 560 | { |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 561 | struct mdm_modem_drv *mdm_drv; |
| 562 | struct mdm_device *mdev = (struct mdm_device *)dev_id; |
| 563 | int value; |
| 564 | if (!mdev) |
| 565 | return IRQ_HANDLED; |
| 566 | |
| 567 | mdm_drv = &mdev->mdm_data; |
| 568 | value = gpio_get_value(mdm_drv->mdm2ap_status_gpio); |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 569 | |
Joel King | bf3e4b5 | 2012-09-26 09:10:34 -0700 | [diff] [blame] | 570 | if ((mdm_debug_mask & MDM_DEBUG_MASK_SHDN_LOG) && (value == 0)) |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 571 | pr_debug("%s: mdm2ap_status went low\n", __func__); |
Joel King | bf3e4b5 | 2012-09-26 09:10:34 -0700 | [diff] [blame] | 572 | |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 573 | pr_debug("%s: mdm id %d sent status change interrupt\n", |
| 574 | __func__, mdev->mdm_data.device_id); |
| 575 | if (value == 0 && atomic_read(&mdm_drv->mdm_ready)) { |
| 576 | pr_debug("%s: unexpected reset external modem id %d\n", |
| 577 | __func__, mdev->mdm_data.device_id); |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 578 | mdm_drv->mdm_unexpected_reset_occurred = 1; |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 579 | mdm_start_ssr(mdev); |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 580 | } else if (value == 1) { |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 581 | cancel_delayed_work(&mdev->mdm2ap_status_check_work); |
| 582 | pr_debug("%s: status = 1: mdm id %d is now ready\n", |
| 583 | __func__, mdev->mdm_data.device_id); |
| 584 | queue_work(mdev->mdm_queue, &mdev->mdm_status_work); |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 585 | } |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 586 | return IRQ_HANDLED; |
| 587 | } |
| 588 | |
Vamsi Krishna | c6dcd5e | 2012-05-09 15:38:01 -0700 | [diff] [blame] | 589 | static irqreturn_t mdm_pblrdy_change(int irq, void *dev_id) |
| 590 | { |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 591 | struct mdm_modem_drv *mdm_drv; |
| 592 | struct mdm_device *mdev = (struct mdm_device *)dev_id; |
| 593 | if (!mdev) |
| 594 | return IRQ_HANDLED; |
Vamsi Krishna | c6dcd5e | 2012-05-09 15:38:01 -0700 | [diff] [blame] | 595 | |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 596 | mdm_drv = &mdev->mdm_data; |
| 597 | pr_debug("%s: mdm id %d: pbl ready:%d\n", |
| 598 | __func__, mdev->mdm_data.device_id, |
| 599 | gpio_get_value(mdm_drv->mdm2ap_pblrdy)); |
Vamsi Krishna | c6dcd5e | 2012-05-09 15:38:01 -0700 | [diff] [blame] | 600 | return IRQ_HANDLED; |
| 601 | } |
| 602 | |
Stephen Boyd | 0ebf721 | 2012-04-30 20:42:35 -0700 | [diff] [blame] | 603 | static int mdm_subsys_shutdown(const struct subsys_desc *crashed_subsys) |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 604 | { |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 605 | struct mdm_device *mdev = |
| 606 | container_of(crashed_subsys, struct mdm_device, mdm_subsys); |
| 607 | struct mdm_modem_drv *mdm_drv = &mdev->mdm_data; |
| 608 | |
| 609 | pr_debug("%s: ssr on modem id %d\n", __func__, |
| 610 | mdev->mdm_data.device_id); |
| 611 | |
| 612 | mdm_ssr_started(mdev); |
| 613 | cancel_delayed_work(&mdev->mdm2ap_status_check_work); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 614 | gpio_direction_output(mdm_drv->ap2mdm_errfatal_gpio, 1); |
Joel King | 415af51 | 2012-02-03 10:22:43 -0800 | [diff] [blame] | 615 | if (mdm_drv->pdata->ramdump_delay_ms > 0) { |
| 616 | /* Wait for the external modem to complete |
| 617 | * its preparation for ramdumps. |
| 618 | */ |
Joel King | 6e7a3e8 | 2012-04-13 17:37:33 -0700 | [diff] [blame] | 619 | msleep(mdm_drv->pdata->ramdump_delay_ms); |
Joel King | 415af51 | 2012-02-03 10:22:43 -0800 | [diff] [blame] | 620 | } |
Joel King | 269aa60 | 2012-07-23 08:07:35 -0700 | [diff] [blame] | 621 | if (!mdm_drv->mdm_unexpected_reset_occurred) { |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 622 | mdm_ops->reset_mdm_cb(mdm_drv); |
Joel King | 269aa60 | 2012-07-23 08:07:35 -0700 | [diff] [blame] | 623 | /* Update gpio configuration to "booting" config. */ |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 624 | mdm_update_gpio_configs(mdev, GPIO_UPDATE_BOOTING_CONFIG); |
Joel King | 269aa60 | 2012-07-23 08:07:35 -0700 | [diff] [blame] | 625 | } else { |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 626 | mdm_drv->mdm_unexpected_reset_occurred = 0; |
Joel King | 269aa60 | 2012-07-23 08:07:35 -0700 | [diff] [blame] | 627 | } |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 628 | return 0; |
| 629 | } |
| 630 | |
Stephen Boyd | 0ebf721 | 2012-04-30 20:42:35 -0700 | [diff] [blame] | 631 | static int mdm_subsys_powerup(const struct subsys_desc *crashed_subsys) |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 632 | { |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 633 | struct mdm_device *mdev = |
| 634 | container_of(crashed_subsys, struct mdm_device, |
| 635 | mdm_subsys); |
| 636 | struct mdm_modem_drv *mdm_drv = &mdev->mdm_data; |
| 637 | |
| 638 | pr_debug("%s: ssr on modem id %d\n", |
| 639 | __func__, mdev->mdm_data.device_id); |
| 640 | |
Joel King | bc48e4c | 2012-02-27 13:18:52 -0800 | [diff] [blame] | 641 | gpio_direction_output(mdm_drv->ap2mdm_errfatal_gpio, 0); |
| 642 | gpio_direction_output(mdm_drv->ap2mdm_status_gpio, 1); |
Taniya Das | 2b7646b | 2013-01-15 11:28:14 +0530 | [diff] [blame] | 643 | |
| 644 | if (mdm_drv->pdata->ps_hold_delay_ms > 0) |
| 645 | msleep(mdm_drv->pdata->ps_hold_delay_ms); |
| 646 | |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 647 | mdm_ops->power_on_mdm_cb(mdm_drv); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 648 | mdm_drv->boot_type = CHARM_NORMAL_BOOT; |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 649 | mdm_ssr_completed(mdev); |
| 650 | complete(&mdev->mdm_needs_reload); |
| 651 | if (!wait_for_completion_timeout(&mdev->mdm_boot, |
Joel King | 52d7fa6 | 2012-03-21 08:40:52 -0700 | [diff] [blame] | 652 | msecs_to_jiffies(MDM_BOOT_TIMEOUT))) { |
| 653 | mdm_drv->mdm_boot_status = -ETIMEDOUT; |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 654 | pr_debug("%s: mdm modem restart timed out.\n", __func__); |
Joel King | 30fdd66 | 2012-05-07 19:39:29 -0700 | [diff] [blame] | 655 | } else { |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 656 | pr_debug("%s: id %d: mdm modem has been restarted\n", |
| 657 | __func__, mdm_drv->device_id); |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 658 | |
Joel King | 30fdd66 | 2012-05-07 19:39:29 -0700 | [diff] [blame] | 659 | /* Log the reason for the restart */ |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 660 | if (mdm_drv->pdata->sfr_query) |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 661 | queue_work(mdev->mdm_sfr_queue, &mdev->sfr_reason_work); |
Joel King | 30fdd66 | 2012-05-07 19:39:29 -0700 | [diff] [blame] | 662 | } |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 663 | init_completion(&mdev->mdm_boot); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 664 | return mdm_drv->mdm_boot_status; |
| 665 | } |
| 666 | |
| 667 | static int mdm_subsys_ramdumps(int want_dumps, |
Stephen Boyd | 0ebf721 | 2012-04-30 20:42:35 -0700 | [diff] [blame] | 668 | const struct subsys_desc *crashed_subsys) |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 669 | { |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 670 | struct mdm_device *mdev = |
| 671 | container_of(crashed_subsys, struct mdm_device, |
| 672 | mdm_subsys); |
| 673 | struct mdm_modem_drv *mdm_drv = &mdev->mdm_data; |
| 674 | |
| 675 | pr_debug("%s: ssr on modem id %d\n", __func__, |
| 676 | mdev->mdm_data.device_id); |
| 677 | |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 678 | mdm_drv->mdm_ram_dump_status = 0; |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 679 | cancel_delayed_work(&mdev->mdm2ap_status_check_work); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 680 | if (want_dumps) { |
| 681 | mdm_drv->boot_type = CHARM_RAM_DUMPS; |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 682 | complete(&mdev->mdm_needs_reload); |
| 683 | if (!wait_for_completion_timeout(&mdev->mdm_ram_dumps, |
| 684 | msecs_to_jiffies(mdev->dump_timeout_ms))) { |
Joel King | 52d7fa6 | 2012-03-21 08:40:52 -0700 | [diff] [blame] | 685 | mdm_drv->mdm_ram_dump_status = -ETIMEDOUT; |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 686 | mdm_ssr_completed(mdev); |
| 687 | pr_err("%s: mdm modem ramdumps timed out.\n", |
Joel King | 52d7fa6 | 2012-03-21 08:40:52 -0700 | [diff] [blame] | 688 | __func__); |
| 689 | } else |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 690 | pr_debug("%s: mdm modem ramdumps completed.\n", |
Joel King | 52d7fa6 | 2012-03-21 08:40:52 -0700 | [diff] [blame] | 691 | __func__); |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 692 | init_completion(&mdev->mdm_ram_dumps); |
Joel King | 269aa60 | 2012-07-23 08:07:35 -0700 | [diff] [blame] | 693 | if (!mdm_drv->pdata->no_powerdown_after_ramdumps) { |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 694 | mdm_ops->power_down_mdm_cb(mdm_drv); |
Joel King | 269aa60 | 2012-07-23 08:07:35 -0700 | [diff] [blame] | 695 | /* Update gpio configuration to "booting" config. */ |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 696 | mdm_update_gpio_configs(mdev, |
| 697 | GPIO_UPDATE_BOOTING_CONFIG); |
Joel King | 269aa60 | 2012-07-23 08:07:35 -0700 | [diff] [blame] | 698 | } |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 699 | } |
| 700 | return mdm_drv->mdm_ram_dump_status; |
| 701 | } |
| 702 | |
Joel King | 96c96dc | 2012-07-30 09:06:15 -0700 | [diff] [blame] | 703 | /* Once the gpios are sent to RPM and debugging |
| 704 | * starts, there is no way to stop it without |
| 705 | * rebooting the device. |
| 706 | */ |
| 707 | static int mdm_debug_mask_set(void *data, u64 val) |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 708 | { |
Joel King | 96c96dc | 2012-07-30 09:06:15 -0700 | [diff] [blame] | 709 | if (!vddmin_gpios_sent && |
| 710 | (val & MDM_DEBUG_MASK_VDDMIN_SETUP)) { |
| 711 | mdm_setup_vddmin_gpios(); |
| 712 | vddmin_gpios_sent = 1; |
| 713 | } |
| 714 | |
| 715 | mdm_debug_mask = val; |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 716 | if (mdm_ops->debug_state_changed_cb) |
| 717 | mdm_ops->debug_state_changed_cb(mdm_debug_mask); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 718 | return 0; |
| 719 | } |
| 720 | |
Joel King | 96c96dc | 2012-07-30 09:06:15 -0700 | [diff] [blame] | 721 | static int mdm_debug_mask_get(void *data, u64 *val) |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 722 | { |
Joel King | 96c96dc | 2012-07-30 09:06:15 -0700 | [diff] [blame] | 723 | *val = mdm_debug_mask; |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 724 | return 0; |
| 725 | } |
| 726 | |
Joel King | 96c96dc | 2012-07-30 09:06:15 -0700 | [diff] [blame] | 727 | DEFINE_SIMPLE_ATTRIBUTE(mdm_debug_mask_fops, |
| 728 | mdm_debug_mask_get, |
| 729 | mdm_debug_mask_set, "%llu\n"); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 730 | |
| 731 | static int mdm_debugfs_init(void) |
| 732 | { |
| 733 | struct dentry *dent; |
| 734 | |
| 735 | dent = debugfs_create_dir("mdm_dbg", 0); |
| 736 | if (IS_ERR(dent)) |
| 737 | return PTR_ERR(dent); |
| 738 | |
Joel King | 96c96dc | 2012-07-30 09:06:15 -0700 | [diff] [blame] | 739 | debugfs_create_file("debug_mask", 0644, dent, NULL, |
| 740 | &mdm_debug_mask_fops); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 741 | return 0; |
| 742 | } |
| 743 | |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 744 | static const struct file_operations mdm_modem_fops = { |
| 745 | .owner = THIS_MODULE, |
| 746 | .open = mdm_modem_open, |
| 747 | .unlocked_ioctl = mdm_modem_ioctl, |
| 748 | }; |
| 749 | |
| 750 | static void mdm_modem_initialize_data(struct platform_device *pdev, |
| 751 | struct mdm_device *mdev) |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 752 | { |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 753 | struct mdm_modem_drv *mdm_drv = &mdev->mdm_data; |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 754 | struct resource *pres; |
| 755 | |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 756 | mdm_drv->pdata = pdev->dev.platform_data; |
| 757 | if (pdev->id < 0) |
| 758 | mdm_drv->device_id = 0; |
| 759 | else |
| 760 | mdm_drv->device_id = pdev->id; |
| 761 | |
| 762 | memset((void *)&mdev->mdm_subsys, 0, |
| 763 | sizeof(struct subsys_desc)); |
| 764 | if (mdev->mdm_data.device_id <= 0) |
| 765 | snprintf(mdev->subsys_name, sizeof(mdev->subsys_name), |
| 766 | "%s", EXTERNAL_MODEM); |
| 767 | else |
| 768 | snprintf(mdev->subsys_name, sizeof(mdev->subsys_name), |
| 769 | "%s.%d", EXTERNAL_MODEM, mdev->mdm_data.device_id); |
| 770 | mdev->mdm_subsys.shutdown = mdm_subsys_shutdown; |
| 771 | mdev->mdm_subsys.ramdump = mdm_subsys_ramdumps; |
| 772 | mdev->mdm_subsys.powerup = mdm_subsys_powerup; |
| 773 | mdev->mdm_subsys.name = mdev->subsys_name; |
| 774 | |
| 775 | memset((void *)&mdev->misc_device, 0, |
| 776 | sizeof(struct miscdevice)); |
| 777 | if (mdev->mdm_data.device_id <= 0) |
| 778 | snprintf(mdev->device_name, sizeof(mdev->device_name), |
| 779 | "%s", DEVICE_BASE_NAME); |
| 780 | else |
| 781 | snprintf(mdev->device_name, sizeof(mdev->device_name), |
| 782 | "%s%d", DEVICE_BASE_NAME, mdev->mdm_data.device_id); |
| 783 | mdev->misc_device.minor = MISC_DYNAMIC_MINOR; |
| 784 | mdev->misc_device.name = mdev->device_name; |
| 785 | mdev->misc_device.fops = &mdm_modem_fops; |
| 786 | |
| 787 | memset((void *)&mdev->mdm_panic_blk, 0, |
| 788 | sizeof(struct notifier_block)); |
| 789 | mdev->mdm_panic_blk.notifier_call = mdm_panic_prep; |
| 790 | atomic_notifier_chain_register(&panic_notifier_list, |
| 791 | &mdev->mdm_panic_blk); |
| 792 | |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 793 | /* MDM2AP_ERRFATAL */ |
| 794 | pres = platform_get_resource_byname(pdev, IORESOURCE_IO, |
| 795 | "MDM2AP_ERRFATAL"); |
Ameya Thakur | e155ece | 2012-07-09 12:08:37 -0700 | [diff] [blame] | 796 | mdm_drv->mdm2ap_errfatal_gpio = pres ? pres->start : -1; |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 797 | |
| 798 | /* AP2MDM_ERRFATAL */ |
| 799 | pres = platform_get_resource_byname(pdev, IORESOURCE_IO, |
| 800 | "AP2MDM_ERRFATAL"); |
Ameya Thakur | e155ece | 2012-07-09 12:08:37 -0700 | [diff] [blame] | 801 | mdm_drv->ap2mdm_errfatal_gpio = pres ? pres->start : -1; |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 802 | |
| 803 | /* MDM2AP_STATUS */ |
| 804 | pres = platform_get_resource_byname(pdev, IORESOURCE_IO, |
| 805 | "MDM2AP_STATUS"); |
Ameya Thakur | e155ece | 2012-07-09 12:08:37 -0700 | [diff] [blame] | 806 | mdm_drv->mdm2ap_status_gpio = pres ? pres->start : -1; |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 807 | |
| 808 | /* AP2MDM_STATUS */ |
| 809 | pres = platform_get_resource_byname(pdev, IORESOURCE_IO, |
| 810 | "AP2MDM_STATUS"); |
Ameya Thakur | e155ece | 2012-07-09 12:08:37 -0700 | [diff] [blame] | 811 | mdm_drv->ap2mdm_status_gpio = pres ? pres->start : -1; |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 812 | |
| 813 | /* MDM2AP_WAKEUP */ |
| 814 | pres = platform_get_resource_byname(pdev, IORESOURCE_IO, |
| 815 | "MDM2AP_WAKEUP"); |
Ameya Thakur | e155ece | 2012-07-09 12:08:37 -0700 | [diff] [blame] | 816 | mdm_drv->mdm2ap_wakeup_gpio = pres ? pres->start : -1; |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 817 | |
| 818 | /* AP2MDM_WAKEUP */ |
| 819 | pres = platform_get_resource_byname(pdev, IORESOURCE_IO, |
| 820 | "AP2MDM_WAKEUP"); |
Ameya Thakur | e155ece | 2012-07-09 12:08:37 -0700 | [diff] [blame] | 821 | mdm_drv->ap2mdm_wakeup_gpio = pres ? pres->start : -1; |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 822 | |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 823 | /* AP2MDM_SOFT_RESET */ |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 824 | pres = platform_get_resource_byname(pdev, IORESOURCE_IO, |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 825 | "AP2MDM_SOFT_RESET"); |
Ameya Thakur | e155ece | 2012-07-09 12:08:37 -0700 | [diff] [blame] | 826 | mdm_drv->ap2mdm_soft_reset_gpio = pres ? pres->start : -1; |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 827 | |
| 828 | /* AP2MDM_KPDPWR_N */ |
| 829 | pres = platform_get_resource_byname(pdev, IORESOURCE_IO, |
| 830 | "AP2MDM_KPDPWR_N"); |
Ameya Thakur | e155ece | 2012-07-09 12:08:37 -0700 | [diff] [blame] | 831 | mdm_drv->ap2mdm_kpdpwr_n_gpio = pres ? pres->start : -1; |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 832 | |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 833 | /* AP2MDM_PMIC_PWR_EN */ |
| 834 | pres = platform_get_resource_byname(pdev, IORESOURCE_IO, |
| 835 | "AP2MDM_PMIC_PWR_EN"); |
Ameya Thakur | e155ece | 2012-07-09 12:08:37 -0700 | [diff] [blame] | 836 | mdm_drv->ap2mdm_pmic_pwr_en_gpio = pres ? pres->start : -1; |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 837 | |
Vamsi Krishna | c6dcd5e | 2012-05-09 15:38:01 -0700 | [diff] [blame] | 838 | /* MDM2AP_PBLRDY */ |
| 839 | pres = platform_get_resource_byname(pdev, IORESOURCE_IO, |
| 840 | "MDM2AP_PBLRDY"); |
Ameya Thakur | e155ece | 2012-07-09 12:08:37 -0700 | [diff] [blame] | 841 | mdm_drv->mdm2ap_pblrdy = pres ? pres->start : -1; |
Vamsi Krishna | c6dcd5e | 2012-05-09 15:38:01 -0700 | [diff] [blame] | 842 | |
Ameya Thakur | 43248fd | 2012-07-10 18:50:52 -0700 | [diff] [blame] | 843 | /*USB_SW*/ |
| 844 | pres = platform_get_resource_byname(pdev, IORESOURCE_IO, |
| 845 | "USB_SW"); |
Ameya Thakur | e155ece | 2012-07-09 12:08:37 -0700 | [diff] [blame] | 846 | mdm_drv->usb_switch_gpio = pres ? pres->start : -1; |
Ameya Thakur | 43248fd | 2012-07-10 18:50:52 -0700 | [diff] [blame] | 847 | |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 848 | mdm_drv->boot_type = CHARM_NORMAL_BOOT; |
| 849 | |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 850 | mdm_drv->dump_timeout_ms = mdm_drv->pdata->ramdump_timeout_ms > 0 ? |
Ameya Thakur | c9a7a84 | 2012-06-24 22:47:52 -0700 | [diff] [blame] | 851 | mdm_drv->pdata->ramdump_timeout_ms : MDM_RDUMP_TIMEOUT; |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 852 | |
| 853 | init_completion(&mdev->mdm_needs_reload); |
| 854 | init_completion(&mdev->mdm_boot); |
| 855 | init_completion(&mdev->mdm_ram_dumps); |
| 856 | |
| 857 | mdev->first_boot = 1; |
| 858 | mutex_init(&mdm_drv->peripheral_status_lock); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 859 | } |
| 860 | |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 861 | static void mdm_deconfigure_ipc(struct mdm_device *mdev) |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 862 | { |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 863 | struct mdm_modem_drv *mdm_drv = &mdev->mdm_data; |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 864 | |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 865 | gpio_free(mdm_drv->ap2mdm_status_gpio); |
| 866 | gpio_free(mdm_drv->ap2mdm_errfatal_gpio); |
| 867 | if (GPIO_IS_VALID(mdm_drv->ap2mdm_kpdpwr_n_gpio)) |
| 868 | gpio_free(mdm_drv->ap2mdm_kpdpwr_n_gpio); |
| 869 | if (GPIO_IS_VALID(mdm_drv->ap2mdm_pmic_pwr_en_gpio)) |
| 870 | gpio_free(mdm_drv->ap2mdm_pmic_pwr_en_gpio); |
| 871 | gpio_free(mdm_drv->mdm2ap_status_gpio); |
| 872 | gpio_free(mdm_drv->mdm2ap_errfatal_gpio); |
| 873 | if (GPIO_IS_VALID(mdm_drv->ap2mdm_soft_reset_gpio)) |
| 874 | gpio_free(mdm_drv->ap2mdm_soft_reset_gpio); |
| 875 | |
| 876 | if (GPIO_IS_VALID(mdm_drv->ap2mdm_wakeup_gpio)) |
| 877 | gpio_free(mdm_drv->ap2mdm_wakeup_gpio); |
| 878 | |
| 879 | if (mdev->mdm_queue) { |
| 880 | destroy_workqueue(mdev->mdm_queue); |
| 881 | mdev->mdm_queue = NULL; |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 882 | } |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 883 | if (mdev->mdm_sfr_queue) { |
| 884 | destroy_workqueue(mdev->mdm_sfr_queue); |
| 885 | mdev->mdm_sfr_queue = NULL; |
| 886 | } |
| 887 | } |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 888 | |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 889 | static int mdm_configure_ipc(struct mdm_device *mdev) |
| 890 | { |
| 891 | struct mdm_modem_drv *mdm_drv = &mdev->mdm_data; |
| 892 | int ret = -1, irq; |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 893 | |
| 894 | gpio_request(mdm_drv->ap2mdm_status_gpio, "AP2MDM_STATUS"); |
| 895 | gpio_request(mdm_drv->ap2mdm_errfatal_gpio, "AP2MDM_ERRFATAL"); |
Ameya Thakur | e155ece | 2012-07-09 12:08:37 -0700 | [diff] [blame] | 896 | if (GPIO_IS_VALID(mdm_drv->ap2mdm_kpdpwr_n_gpio)) |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 897 | gpio_request(mdm_drv->ap2mdm_kpdpwr_n_gpio, "AP2MDM_KPDPWR_N"); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 898 | gpio_request(mdm_drv->mdm2ap_status_gpio, "MDM2AP_STATUS"); |
| 899 | gpio_request(mdm_drv->mdm2ap_errfatal_gpio, "MDM2AP_ERRFATAL"); |
Ameya Thakur | e155ece | 2012-07-09 12:08:37 -0700 | [diff] [blame] | 900 | if (GPIO_IS_VALID(mdm_drv->mdm2ap_pblrdy)) |
Vamsi Krishna | c6dcd5e | 2012-05-09 15:38:01 -0700 | [diff] [blame] | 901 | gpio_request(mdm_drv->mdm2ap_pblrdy, "MDM2AP_PBLRDY"); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 902 | |
Ameya Thakur | e155ece | 2012-07-09 12:08:37 -0700 | [diff] [blame] | 903 | if (GPIO_IS_VALID(mdm_drv->ap2mdm_pmic_pwr_en_gpio)) |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 904 | gpio_request(mdm_drv->ap2mdm_pmic_pwr_en_gpio, |
| 905 | "AP2MDM_PMIC_PWR_EN"); |
Ameya Thakur | e155ece | 2012-07-09 12:08:37 -0700 | [diff] [blame] | 906 | if (GPIO_IS_VALID(mdm_drv->ap2mdm_soft_reset_gpio)) |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 907 | gpio_request(mdm_drv->ap2mdm_soft_reset_gpio, |
| 908 | "AP2MDM_SOFT_RESET"); |
| 909 | |
Ameya Thakur | e155ece | 2012-07-09 12:08:37 -0700 | [diff] [blame] | 910 | if (GPIO_IS_VALID(mdm_drv->ap2mdm_wakeup_gpio)) |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 911 | gpio_request(mdm_drv->ap2mdm_wakeup_gpio, "AP2MDM_WAKEUP"); |
| 912 | |
Ameya Thakur | e155ece | 2012-07-09 12:08:37 -0700 | [diff] [blame] | 913 | if (GPIO_IS_VALID(mdm_drv->usb_switch_gpio)) { |
Ameya Thakur | 43248fd | 2012-07-10 18:50:52 -0700 | [diff] [blame] | 914 | if (gpio_request(mdm_drv->usb_switch_gpio, "USB_SW")) { |
| 915 | pr_err("%s Failed to get usb switch gpio\n", __func__); |
| 916 | mdm_drv->usb_switch_gpio = -1; |
| 917 | } |
| 918 | } |
Taniya Das | a1a14a9 | 2013-01-21 15:14:15 +0530 | [diff] [blame] | 919 | gpio_direction_output(mdm_drv->ap2mdm_status_gpio, 0); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 920 | gpio_direction_output(mdm_drv->ap2mdm_errfatal_gpio, 0); |
| 921 | |
Ameya Thakur | e155ece | 2012-07-09 12:08:37 -0700 | [diff] [blame] | 922 | if (GPIO_IS_VALID(mdm_drv->ap2mdm_wakeup_gpio)) |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 923 | gpio_direction_output(mdm_drv->ap2mdm_wakeup_gpio, 0); |
| 924 | |
| 925 | gpio_direction_input(mdm_drv->mdm2ap_status_gpio); |
| 926 | gpio_direction_input(mdm_drv->mdm2ap_errfatal_gpio); |
| 927 | |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 928 | mdev->mdm_queue = alloc_workqueue("mdm_queue", 0, 0); |
| 929 | if (!mdev->mdm_queue) { |
| 930 | pr_err("%s: could not create mdm_queue for mdm id %d\n", |
| 931 | __func__, mdev->mdm_data.device_id); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 932 | ret = -ENOMEM; |
| 933 | goto fatal_err; |
| 934 | } |
| 935 | |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 936 | mdev->mdm_sfr_queue = alloc_workqueue("mdm_sfr_queue", 0, 0); |
| 937 | if (!mdev->mdm_sfr_queue) { |
| 938 | pr_err("%s: could not create mdm_sfr_queue for mdm id %d\n", |
| 939 | __func__, mdev->mdm_data.device_id); |
Joel King | 30fdd66 | 2012-05-07 19:39:29 -0700 | [diff] [blame] | 940 | ret = -ENOMEM; |
Joel King | 30fdd66 | 2012-05-07 19:39:29 -0700 | [diff] [blame] | 941 | goto fatal_err; |
| 942 | } |
| 943 | |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 944 | /* Register subsystem handlers */ |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 945 | mdev->mdm_subsys_dev = subsys_register(&mdev->mdm_subsys); |
| 946 | if (IS_ERR(mdev->mdm_subsys_dev)) { |
| 947 | ret = PTR_ERR(mdev->mdm_subsys_dev); |
Stephen Boyd | 0ebf721 | 2012-04-30 20:42:35 -0700 | [diff] [blame] | 948 | goto fatal_err; |
| 949 | } |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 950 | subsys_default_online(mdev->mdm_subsys_dev); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 951 | |
| 952 | /* ERR_FATAL irq. */ |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 953 | irq = gpio_to_irq(mdm_drv->mdm2ap_errfatal_gpio); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 954 | if (irq < 0) { |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 955 | pr_err("%s: bad MDM2AP_ERRFATAL IRQ resource, err = %d\n", |
| 956 | __func__, irq); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 957 | goto errfatal_err; |
| 958 | } |
| 959 | ret = request_irq(irq, mdm_errfatal, |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 960 | IRQF_TRIGGER_RISING , "mdm errfatal", mdev); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 961 | |
| 962 | if (ret < 0) { |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 963 | pr_err("%s: MDM2AP_ERRFATAL IRQ#%d request failed, err=%d\n", |
| 964 | __func__, irq, ret); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 965 | goto errfatal_err; |
| 966 | } |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 967 | mdev->mdm_errfatal_irq = irq; |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 968 | |
| 969 | errfatal_err: |
| 970 | |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 971 | /* status irq */ |
| 972 | irq = gpio_to_irq(mdm_drv->mdm2ap_status_gpio); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 973 | if (irq < 0) { |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 974 | pr_err("%s: bad MDM2AP_STATUS IRQ resource, err = %d\n", |
| 975 | __func__, irq); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 976 | goto status_err; |
| 977 | } |
| 978 | |
| 979 | ret = request_threaded_irq(irq, NULL, mdm_status_change, |
Vamsi Krishna | 3392563 | 2011-12-13 15:43:09 -0800 | [diff] [blame] | 980 | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_SHARED, |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 981 | "mdm status", mdev); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 982 | |
| 983 | if (ret < 0) { |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 984 | pr_err("%s: MDM2AP_STATUS IRQ#%d request failed, err=%d", |
| 985 | __func__, irq, ret); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 986 | goto status_err; |
| 987 | } |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 988 | mdev->mdm_status_irq = irq; |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 989 | |
| 990 | status_err: |
Ameya Thakur | e155ece | 2012-07-09 12:08:37 -0700 | [diff] [blame] | 991 | if (GPIO_IS_VALID(mdm_drv->mdm2ap_pblrdy)) { |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 992 | irq = gpio_to_irq(mdm_drv->mdm2ap_pblrdy); |
Vamsi Krishna | c6dcd5e | 2012-05-09 15:38:01 -0700 | [diff] [blame] | 993 | if (irq < 0) { |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 994 | pr_err("%s: could not get MDM2AP_PBLRDY IRQ resource\n", |
| 995 | __func__); |
Vamsi Krishna | c6dcd5e | 2012-05-09 15:38:01 -0700 | [diff] [blame] | 996 | goto pblrdy_err; |
| 997 | } |
| 998 | |
| 999 | ret = request_threaded_irq(irq, NULL, mdm_pblrdy_change, |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 1000 | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | |
| 1001 | IRQF_SHARED, |
| 1002 | "mdm pbl ready", mdev); |
Vamsi Krishna | c6dcd5e | 2012-05-09 15:38:01 -0700 | [diff] [blame] | 1003 | |
| 1004 | if (ret < 0) { |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 1005 | pr_err("%s: MDM2AP_PBL IRQ#%d request failed error=%d\n", |
Vamsi Krishna | c6dcd5e | 2012-05-09 15:38:01 -0700 | [diff] [blame] | 1006 | __func__, irq, ret); |
| 1007 | goto pblrdy_err; |
| 1008 | } |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 1009 | mdev->mdm_pblrdy_irq = irq; |
Vamsi Krishna | c6dcd5e | 2012-05-09 15:38:01 -0700 | [diff] [blame] | 1010 | } |
| 1011 | |
| 1012 | pblrdy_err: |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 1013 | /* |
| 1014 | * If AP2MDM_PMIC_PWR_EN gpio is used, pull it high. It remains |
| 1015 | * high until the whole phone is shut down. |
| 1016 | */ |
Ameya Thakur | e155ece | 2012-07-09 12:08:37 -0700 | [diff] [blame] | 1017 | if (GPIO_IS_VALID(mdm_drv->ap2mdm_pmic_pwr_en_gpio)) |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 1018 | gpio_direction_output(mdm_drv->ap2mdm_pmic_pwr_en_gpio, 1); |
| 1019 | |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 1020 | return 0; |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 1021 | |
| 1022 | fatal_err: |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 1023 | mdm_deconfigure_ipc(mdev); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 1024 | return ret; |
| 1025 | } |
| 1026 | |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 1027 | static int __devinit mdm_modem_probe(struct platform_device *pdev) |
| 1028 | { |
| 1029 | struct mdm_device *mdev = NULL; |
| 1030 | int ret = -1; |
| 1031 | |
| 1032 | mdev = kzalloc(sizeof(struct mdm_device), GFP_KERNEL); |
| 1033 | if (!mdev) { |
| 1034 | pr_err("%s: kzalloc fail.\n", __func__); |
| 1035 | ret = -ENOMEM; |
| 1036 | goto init_err; |
| 1037 | } |
| 1038 | |
Pavankumar Kondeti | 0161cf9 | 2013-02-12 18:10:21 +0530 | [diff] [blame] | 1039 | platform_set_drvdata(pdev, mdev); |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 1040 | mdm_modem_initialize_data(pdev, mdev); |
| 1041 | |
| 1042 | if (mdm_ops->debug_state_changed_cb) |
| 1043 | mdm_ops->debug_state_changed_cb(mdm_debug_mask); |
| 1044 | |
| 1045 | if (mdm_configure_ipc(mdev)) { |
| 1046 | pr_err("%s: mdm_configure_ipc failed, id = %d\n", |
| 1047 | __func__, mdev->mdm_data.device_id); |
| 1048 | goto init_err; |
| 1049 | } |
| 1050 | |
| 1051 | pr_debug("%s: Registering mdm id %d\n", __func__, |
| 1052 | mdev->mdm_data.device_id); |
| 1053 | ret = misc_register(&mdev->misc_device); |
| 1054 | if (ret) { |
| 1055 | pr_err("%s: failed registering mdm id %d, ret = %d\n", |
| 1056 | __func__, mdev->mdm_data.device_id, ret); |
| 1057 | mdm_deconfigure_ipc(mdev); |
| 1058 | goto init_err; |
| 1059 | } else { |
| 1060 | pr_err("%s: registered mdm id %d\n", |
| 1061 | __func__, mdev->mdm_data.device_id); |
| 1062 | |
| 1063 | mdm_device_list_add(mdev); |
| 1064 | INIT_DELAYED_WORK(&mdev->mdm2ap_status_check_work, |
| 1065 | mdm2ap_status_check); |
| 1066 | INIT_WORK(&mdev->mdm_status_work, mdm_status_fn); |
| 1067 | INIT_WORK(&mdev->sfr_reason_work, mdm_restart_reason_fn); |
| 1068 | |
| 1069 | /* Perform early powerup of the external modem in order to |
| 1070 | * allow tabla devices to be found. |
| 1071 | */ |
| 1072 | if (mdev->mdm_data.pdata->early_power_on) |
| 1073 | mdm_ops->power_on_mdm_cb(&mdev->mdm_data); |
| 1074 | } |
| 1075 | |
| 1076 | return ret; |
| 1077 | |
| 1078 | init_err: |
| 1079 | kfree(mdev); |
| 1080 | return ret; |
| 1081 | } |
| 1082 | |
| 1083 | static int __devexit mdm_modem_remove(struct platform_device *pdev) |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 1084 | { |
| 1085 | int ret; |
Pavankumar Kondeti | 0161cf9 | 2013-02-12 18:10:21 +0530 | [diff] [blame] | 1086 | struct mdm_device *mdev = platform_get_drvdata(pdev); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 1087 | |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 1088 | pr_debug("%s: removing device id %d\n", |
| 1089 | __func__, mdev->mdm_data.device_id); |
| 1090 | mdm_deconfigure_ipc(mdev); |
| 1091 | ret = misc_deregister(&mdev->misc_device); |
| 1092 | mdm_device_list_remove(mdev); |
| 1093 | kfree(mdev); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 1094 | return ret; |
| 1095 | } |
| 1096 | |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 1097 | static void mdm_modem_shutdown(struct platform_device *pdev) |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 1098 | { |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 1099 | struct mdm_modem_drv *mdm_drv; |
Pavankumar Kondeti | 0161cf9 | 2013-02-12 18:10:21 +0530 | [diff] [blame] | 1100 | struct mdm_device *mdev = platform_get_drvdata(pdev); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 1101 | |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 1102 | pr_debug("%s: shutting down device id %d\n", |
| 1103 | __func__, mdev->mdm_data.device_id); |
| 1104 | |
| 1105 | mdm_disable_irqs(mdev); |
| 1106 | mdm_drv = &mdev->mdm_data; |
| 1107 | mdm_ops->power_down_mdm_cb(mdm_drv); |
Ameya Thakur | e155ece | 2012-07-09 12:08:37 -0700 | [diff] [blame] | 1108 | if (GPIO_IS_VALID(mdm_drv->ap2mdm_pmic_pwr_en_gpio)) |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 1109 | gpio_direction_output(mdm_drv->ap2mdm_pmic_pwr_en_gpio, 0); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 1110 | } |
| 1111 | |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 1112 | static struct of_device_id mdm_match_table[] = { |
| 1113 | {.compatible = "qcom,mdm2_modem,mdm2_modem.1"}, |
| 1114 | {}, |
| 1115 | }; |
| 1116 | |
| 1117 | static struct platform_driver mdm_modem_driver = { |
| 1118 | .probe = mdm_modem_probe, |
| 1119 | .remove = __devexit_p(mdm_modem_remove), |
| 1120 | .shutdown = mdm_modem_shutdown, |
| 1121 | .driver = { |
| 1122 | .name = "mdm2_modem", |
| 1123 | .owner = THIS_MODULE, |
| 1124 | .of_match_table = mdm_match_table, |
| 1125 | }, |
| 1126 | }; |
| 1127 | |
| 1128 | static int __init mdm_modem_init(void) |
| 1129 | { |
| 1130 | int ret; |
| 1131 | |
| 1132 | ret = mdm_get_ops(&mdm_ops); |
| 1133 | if (ret) |
| 1134 | return ret; |
| 1135 | |
| 1136 | INIT_LIST_HEAD(&mdm_devices); |
| 1137 | mdm_debugfs_init(); |
| 1138 | return platform_driver_register(&mdm_modem_driver); |
| 1139 | } |
| 1140 | |
| 1141 | static void __exit mdm_modem_exit(void) |
| 1142 | { |
| 1143 | platform_driver_unregister(&mdm_modem_driver); |
| 1144 | } |
| 1145 | |
| 1146 | module_init(mdm_modem_init); |
| 1147 | module_exit(mdm_modem_exit); |
| 1148 | |
| 1149 | MODULE_LICENSE("GPL v2"); |
| 1150 | MODULE_DESCRIPTION("mdm modem driver"); |
| 1151 | MODULE_VERSION("2.0"); |
| 1152 | MODULE_ALIAS("mdm_modem"); |