Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [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> |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 31 | #include <linux/clk.h> |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 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> |
| 39 | #include <linux/msm_charm.h> |
| 40 | #include "msm_watchdog.h" |
| 41 | #include "devices.h" |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 42 | #include "clock.h" |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 43 | #include "mdm_private.h" |
Vamsi Krishna | c6dcd5e | 2012-05-09 15:38:01 -0700 | [diff] [blame] | 44 | #define MDM_PBLRDY_CNT 20 |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 45 | |
Joel King | 96c96dc | 2012-07-30 09:06:15 -0700 | [diff] [blame] | 46 | static int mdm_debug_mask; |
Joel King | d8052c0 | 2012-02-03 12:33:31 -0800 | [diff] [blame] | 47 | |
| 48 | static void mdm_peripheral_connect(struct mdm_modem_drv *mdm_drv) |
| 49 | { |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 50 | if (!mdm_drv->pdata->peripheral_platform_device) |
| 51 | return; |
| 52 | |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 53 | mutex_lock(&mdm_drv->peripheral_status_lock); |
| 54 | if (mdm_drv->peripheral_status) |
Joel King | d8052c0 | 2012-02-03 12:33:31 -0800 | [diff] [blame] | 55 | goto out; |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 56 | platform_device_add(mdm_drv->pdata->peripheral_platform_device); |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 57 | mdm_drv->peripheral_status = 1; |
Joel King | d8052c0 | 2012-02-03 12:33:31 -0800 | [diff] [blame] | 58 | out: |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 59 | mutex_unlock(&mdm_drv->peripheral_status_lock); |
Joel King | d8052c0 | 2012-02-03 12:33:31 -0800 | [diff] [blame] | 60 | } |
| 61 | |
| 62 | static void mdm_peripheral_disconnect(struct mdm_modem_drv *mdm_drv) |
| 63 | { |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 64 | if (!mdm_drv->pdata->peripheral_platform_device) |
| 65 | return; |
| 66 | |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 67 | mutex_lock(&mdm_drv->peripheral_status_lock); |
| 68 | if (!mdm_drv->peripheral_status) |
Joel King | d8052c0 | 2012-02-03 12:33:31 -0800 | [diff] [blame] | 69 | goto out; |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 70 | platform_device_del(mdm_drv->pdata->peripheral_platform_device); |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 71 | mdm_drv->peripheral_status = 0; |
Joel King | d8052c0 | 2012-02-03 12:33:31 -0800 | [diff] [blame] | 72 | out: |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 73 | mutex_unlock(&mdm_drv->peripheral_status_lock); |
Joel King | d8052c0 | 2012-02-03 12:33:31 -0800 | [diff] [blame] | 74 | } |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 75 | |
Joel King | a7a7b9a | 2012-06-28 13:35:28 -0700 | [diff] [blame] | 76 | /* This function can be called from atomic context. */ |
Joel King | 733377c | 2012-06-20 13:07:38 -0700 | [diff] [blame] | 77 | static void mdm_toggle_soft_reset(struct mdm_modem_drv *mdm_drv) |
| 78 | { |
| 79 | int soft_reset_direction_assert = 0, |
| 80 | soft_reset_direction_de_assert = 1; |
| 81 | |
| 82 | if (mdm_drv->pdata->soft_reset_inverted) { |
| 83 | soft_reset_direction_assert = 1; |
| 84 | soft_reset_direction_de_assert = 0; |
| 85 | } |
| 86 | gpio_direction_output(mdm_drv->ap2mdm_soft_reset_gpio, |
| 87 | soft_reset_direction_assert); |
Joel King | a7a7b9a | 2012-06-28 13:35:28 -0700 | [diff] [blame] | 88 | /* Use mdelay because this function can be called from atomic |
| 89 | * context. |
| 90 | */ |
| 91 | mdelay(10); |
Joel King | 733377c | 2012-06-20 13:07:38 -0700 | [diff] [blame] | 92 | gpio_direction_output(mdm_drv->ap2mdm_soft_reset_gpio, |
| 93 | soft_reset_direction_de_assert); |
| 94 | } |
| 95 | |
Joel King | a7a7b9a | 2012-06-28 13:35:28 -0700 | [diff] [blame] | 96 | /* This function can be called from atomic context. */ |
| 97 | static void mdm_atomic_soft_reset(struct mdm_modem_drv *mdm_drv) |
| 98 | { |
| 99 | mdm_toggle_soft_reset(mdm_drv); |
| 100 | } |
| 101 | |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 102 | static void mdm_power_down_common(struct mdm_modem_drv *mdm_drv) |
| 103 | { |
Joel King | 733377c | 2012-06-20 13:07:38 -0700 | [diff] [blame] | 104 | int i; |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 105 | int soft_reset_direction = |
| 106 | mdm_drv->pdata->soft_reset_inverted ? 1 : 0; |
| 107 | |
Hemant Kumar | 069f643 | 2012-08-22 18:30:19 -0700 | [diff] [blame] | 108 | mdm_peripheral_disconnect(mdm_drv); |
| 109 | |
Joel King | 733377c | 2012-06-20 13:07:38 -0700 | [diff] [blame] | 110 | /* Wait for the modem to complete its power down actions. */ |
| 111 | for (i = 20; i > 0; i--) { |
Joel King | bf3e4b5 | 2012-09-26 09:10:34 -0700 | [diff] [blame] | 112 | if (gpio_get_value(mdm_drv->mdm2ap_status_gpio) == 0) { |
| 113 | if (mdm_debug_mask & MDM_DEBUG_MASK_SHDN_LOG) |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 114 | pr_debug("%s:id %d: mdm2ap_statuswent low, i=%d\n", |
| 115 | __func__, mdm_drv->device_id, i); |
Joel King | 733377c | 2012-06-20 13:07:38 -0700 | [diff] [blame] | 116 | break; |
Joel King | bf3e4b5 | 2012-09-26 09:10:34 -0700 | [diff] [blame] | 117 | } |
Joel King | 733377c | 2012-06-20 13:07:38 -0700 | [diff] [blame] | 118 | msleep(100); |
| 119 | } |
Taniya Das | 835e28f | 2012-12-11 10:23:33 +0530 | [diff] [blame] | 120 | |
| 121 | /* Assert the soft reset line whether mdm2ap_status went low or not */ |
| 122 | gpio_direction_output(mdm_drv->ap2mdm_soft_reset_gpio, |
| 123 | soft_reset_direction); |
Joel King | 733377c | 2012-06-20 13:07:38 -0700 | [diff] [blame] | 124 | if (i == 0) { |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 125 | pr_debug("%s:id %d: MDM2AP_STATUS never went low. Doing a hard reset\n", |
| 126 | __func__, mdm_drv->device_id); |
| 127 | gpio_direction_output(mdm_drv->ap2mdm_soft_reset_gpio, |
| 128 | soft_reset_direction); |
Joel King | 733377c | 2012-06-20 13:07:38 -0700 | [diff] [blame] | 129 | /* |
| 130 | * Currently, there is a debounce timer on the charm PMIC. It is |
| 131 | * necessary to hold the PMIC RESET low for ~3.5 seconds |
| 132 | * for the reset to fully take place. Sleep here to ensure the |
| 133 | * reset has occured before the function exits. |
| 134 | */ |
| 135 | msleep(4000); |
| 136 | } |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 137 | } |
| 138 | |
| 139 | static void mdm_do_first_power_on(struct mdm_modem_drv *mdm_drv) |
| 140 | { |
Vamsi Krishna | c6dcd5e | 2012-05-09 15:38:01 -0700 | [diff] [blame] | 141 | int i; |
| 142 | int pblrdy; |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 143 | if (mdm_drv->power_on_count != 1) { |
| 144 | pr_debug("%s:id %d: Calling fn when power_on_count != 1\n", |
| 145 | __func__, mdm_drv->device_id); |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 146 | return; |
| 147 | } |
| 148 | |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 149 | pr_debug("%s:id %d: Powering on modem for the first time\n", |
| 150 | __func__, mdm_drv->device_id); |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 151 | mdm_peripheral_disconnect(mdm_drv); |
| 152 | |
Joel King | 733377c | 2012-06-20 13:07:38 -0700 | [diff] [blame] | 153 | /* If this is the first power-up after a panic, the modem may still |
| 154 | * be in a power-on state, in which case we need to toggle the gpio |
| 155 | * instead of just de-asserting it. No harm done if the modem was |
| 156 | * powered down. |
| 157 | */ |
| 158 | mdm_toggle_soft_reset(mdm_drv); |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 159 | /* If the device has a kpd pwr gpio then toggle it. */ |
Ameya Thakur | e155ece | 2012-07-09 12:08:37 -0700 | [diff] [blame] | 160 | if (GPIO_IS_VALID(mdm_drv->ap2mdm_kpdpwr_n_gpio)) { |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 161 | /* Pull AP2MDM_KPDPWR gpio high and wait for PS_HOLD to settle, |
| 162 | * then pull it back low. |
| 163 | */ |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 164 | pr_debug("%s:id %d: Pulling AP2MDM_KPDPWR gpio high\n", |
| 165 | __func__, mdm_drv->device_id); |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 166 | gpio_direction_output(mdm_drv->ap2mdm_kpdpwr_n_gpio, 1); |
Taniya Das | a1a14a9 | 2013-01-21 15:14:15 +0530 | [diff] [blame] | 167 | gpio_direction_output(mdm_drv->ap2mdm_status_gpio, 1); |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 168 | msleep(1000); |
| 169 | gpio_direction_output(mdm_drv->ap2mdm_kpdpwr_n_gpio, 0); |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 170 | } else { |
Taniya Das | a1a14a9 | 2013-01-21 15:14:15 +0530 | [diff] [blame] | 171 | gpio_direction_output(mdm_drv->ap2mdm_status_gpio, 1); |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 172 | } |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 173 | |
Ameya Thakur | e155ece | 2012-07-09 12:08:37 -0700 | [diff] [blame] | 174 | if (!GPIO_IS_VALID(mdm_drv->mdm2ap_pblrdy)) |
Vamsi Krishna | c6dcd5e | 2012-05-09 15:38:01 -0700 | [diff] [blame] | 175 | goto start_mdm_peripheral; |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 176 | |
Vamsi Krishna | c6dcd5e | 2012-05-09 15:38:01 -0700 | [diff] [blame] | 177 | for (i = 0; i < MDM_PBLRDY_CNT; i++) { |
| 178 | pblrdy = gpio_get_value(mdm_drv->mdm2ap_pblrdy); |
| 179 | if (pblrdy) |
| 180 | break; |
| 181 | usleep_range(5000, 5000); |
| 182 | } |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 183 | pr_debug("%s: id %d: pblrdy i:%d\n", __func__, |
| 184 | mdm_drv->device_id, i); |
Vamsi Krishna | c6dcd5e | 2012-05-09 15:38:01 -0700 | [diff] [blame] | 185 | |
| 186 | start_mdm_peripheral: |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 187 | mdm_peripheral_connect(mdm_drv); |
| 188 | msleep(200); |
| 189 | } |
| 190 | |
| 191 | static void mdm_do_soft_power_on(struct mdm_modem_drv *mdm_drv) |
| 192 | { |
Vamsi Krishna | c6dcd5e | 2012-05-09 15:38:01 -0700 | [diff] [blame] | 193 | int i; |
| 194 | int pblrdy; |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 195 | |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 196 | pr_debug("%s: id %d: soft resetting mdm modem\n", |
| 197 | __func__, mdm_drv->device_id); |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 198 | mdm_peripheral_disconnect(mdm_drv); |
Joel King | 733377c | 2012-06-20 13:07:38 -0700 | [diff] [blame] | 199 | mdm_toggle_soft_reset(mdm_drv); |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 200 | |
Ameya Thakur | e155ece | 2012-07-09 12:08:37 -0700 | [diff] [blame] | 201 | if (!GPIO_IS_VALID(mdm_drv->mdm2ap_pblrdy)) |
Vamsi Krishna | c6dcd5e | 2012-05-09 15:38:01 -0700 | [diff] [blame] | 202 | goto start_mdm_peripheral; |
| 203 | |
| 204 | for (i = 0; i < MDM_PBLRDY_CNT; i++) { |
| 205 | pblrdy = gpio_get_value(mdm_drv->mdm2ap_pblrdy); |
| 206 | if (pblrdy) |
| 207 | break; |
| 208 | usleep_range(5000, 5000); |
| 209 | } |
| 210 | |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 211 | pr_debug("%s: id %d: pblrdy i:%d\n", __func__, |
| 212 | mdm_drv->device_id, i); |
Vamsi Krishna | c6dcd5e | 2012-05-09 15:38:01 -0700 | [diff] [blame] | 213 | |
| 214 | start_mdm_peripheral: |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 215 | mdm_peripheral_connect(mdm_drv); |
| 216 | msleep(200); |
| 217 | } |
| 218 | |
| 219 | static void mdm_power_on_common(struct mdm_modem_drv *mdm_drv) |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 220 | { |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 221 | mdm_drv->power_on_count++; |
Joel King | 3da02a9 | 2012-03-20 10:55:52 -0700 | [diff] [blame] | 222 | |
Vamsi Krishna | 9e307cd | 2012-04-11 13:15:36 -0700 | [diff] [blame] | 223 | /* this gpio will be used to indicate apq readiness, |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 224 | * de-assert it now so that it can be asserted later. |
| 225 | * May not be used. |
Vamsi Krishna | 9e307cd | 2012-04-11 13:15:36 -0700 | [diff] [blame] | 226 | */ |
Ameya Thakur | e155ece | 2012-07-09 12:08:37 -0700 | [diff] [blame] | 227 | if (GPIO_IS_VALID(mdm_drv->ap2mdm_wakeup_gpio)) |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 228 | gpio_direction_output(mdm_drv->ap2mdm_wakeup_gpio, 0); |
Vamsi Krishna | 9e307cd | 2012-04-11 13:15:36 -0700 | [diff] [blame] | 229 | |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 230 | /* |
| 231 | * If we did an "early power on" then ignore the very next |
| 232 | * power-on request because it would the be first request from |
| 233 | * user space but we're already powered on. Ignore it. |
Joel King | 3da02a9 | 2012-03-20 10:55:52 -0700 | [diff] [blame] | 234 | */ |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 235 | if (mdm_drv->pdata->early_power_on && |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 236 | (mdm_drv->power_on_count == 2)) |
Joel King | 3da02a9 | 2012-03-20 10:55:52 -0700 | [diff] [blame] | 237 | return; |
| 238 | |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 239 | if (mdm_drv->power_on_count == 1) |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 240 | mdm_do_first_power_on(mdm_drv); |
| 241 | else |
| 242 | mdm_do_soft_power_on(mdm_drv); |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 243 | } |
| 244 | |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 245 | static void debug_state_changed(int value) |
| 246 | { |
Joel King | 96c96dc | 2012-07-30 09:06:15 -0700 | [diff] [blame] | 247 | mdm_debug_mask = value; |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 248 | } |
| 249 | |
Joel King | d8052c0 | 2012-02-03 12:33:31 -0800 | [diff] [blame] | 250 | static void mdm_status_changed(struct mdm_modem_drv *mdm_drv, int value) |
Vamsi Krishna | 3392563 | 2011-12-13 15:43:09 -0800 | [diff] [blame] | 251 | { |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 252 | pr_debug("%s: id %d: value:%d\n", __func__, |
| 253 | value, mdm_drv->device_id); |
Vamsi Krishna | 3392563 | 2011-12-13 15:43:09 -0800 | [diff] [blame] | 254 | |
| 255 | if (value) { |
Joel King | d8052c0 | 2012-02-03 12:33:31 -0800 | [diff] [blame] | 256 | mdm_peripheral_disconnect(mdm_drv); |
| 257 | mdm_peripheral_connect(mdm_drv); |
Ameya Thakur | e155ece | 2012-07-09 12:08:37 -0700 | [diff] [blame] | 258 | if (GPIO_IS_VALID(mdm_drv->ap2mdm_wakeup_gpio)) |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 259 | gpio_direction_output(mdm_drv->ap2mdm_wakeup_gpio, 1); |
Vamsi Krishna | 3392563 | 2011-12-13 15:43:09 -0800 | [diff] [blame] | 260 | } |
| 261 | } |
| 262 | |
Ameya Thakur | 43248fd | 2012-07-10 18:50:52 -0700 | [diff] [blame] | 263 | static void mdm_image_upgrade(struct mdm_modem_drv *mdm_drv, int type) |
| 264 | { |
| 265 | switch (type) { |
| 266 | case APQ_CONTROLLED_UPGRADE: |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 267 | pr_debug("%s: id %d: APQ controlled modem image upgrade\n", |
| 268 | __func__, mdm_drv->device_id); |
| 269 | atomic_set(&mdm_drv->mdm_ready, 0); |
Ameya Thakur | 43248fd | 2012-07-10 18:50:52 -0700 | [diff] [blame] | 270 | mdm_toggle_soft_reset(mdm_drv); |
| 271 | break; |
| 272 | case MDM_CONTROLLED_UPGRADE: |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 273 | pr_debug("%s: id %d: MDM controlled modem image upgrade\n", |
| 274 | __func__, mdm_drv->device_id); |
| 275 | atomic_set(&mdm_drv->mdm_ready, 0); |
Ameya Thakur | 43248fd | 2012-07-10 18:50:52 -0700 | [diff] [blame] | 276 | /* |
| 277 | * If we have no image currently present on the modem, then we |
| 278 | * would be in PBL, in which case the status gpio would not go |
| 279 | * high. |
| 280 | */ |
| 281 | mdm_drv->disable_status_check = 1; |
Ameya Thakur | e155ece | 2012-07-09 12:08:37 -0700 | [diff] [blame] | 282 | if (GPIO_IS_VALID(mdm_drv->usb_switch_gpio)) { |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 283 | pr_debug("%s: id %d: Switching usb control to MDM\n", |
| 284 | __func__, mdm_drv->device_id); |
Ameya Thakur | 43248fd | 2012-07-10 18:50:52 -0700 | [diff] [blame] | 285 | gpio_direction_output(mdm_drv->usb_switch_gpio, 1); |
| 286 | } else |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 287 | pr_err("%s: id %d: usb switch gpio unavailable\n", |
| 288 | __func__, mdm_drv->device_id); |
Ameya Thakur | 43248fd | 2012-07-10 18:50:52 -0700 | [diff] [blame] | 289 | break; |
| 290 | default: |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 291 | pr_err("%s: id %d: invalid upgrade type\n", |
| 292 | __func__, mdm_drv->device_id); |
Ameya Thakur | 43248fd | 2012-07-10 18:50:52 -0700 | [diff] [blame] | 293 | } |
| 294 | } |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 295 | |
Joel King | e9cd527 | 2012-01-28 12:48:59 -0800 | [diff] [blame] | 296 | static struct mdm_ops mdm_cb = { |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 297 | .power_on_mdm_cb = mdm_power_on_common, |
| 298 | .reset_mdm_cb = mdm_power_on_common, |
Joel King | a7a7b9a | 2012-06-28 13:35:28 -0700 | [diff] [blame] | 299 | .atomic_reset_mdm_cb = mdm_atomic_soft_reset, |
Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 300 | .power_down_mdm_cb = mdm_power_down_common, |
Joel King | e9cd527 | 2012-01-28 12:48:59 -0800 | [diff] [blame] | 301 | .debug_state_changed_cb = debug_state_changed, |
| 302 | .status_cb = mdm_status_changed, |
Ameya Thakur | 43248fd | 2012-07-10 18:50:52 -0700 | [diff] [blame] | 303 | .image_upgrade_cb = mdm_image_upgrade, |
Joel King | e9cd527 | 2012-01-28 12:48:59 -0800 | [diff] [blame] | 304 | }; |
| 305 | |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 306 | int mdm_get_ops(struct mdm_ops **mdm_ops) |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 307 | { |
Ameya Thakur | 552e58a | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 308 | *mdm_ops = &mdm_cb; |
| 309 | return 0; |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 310 | } |
| 311 | |
Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 312 | |