| Duy Truong | e833aca | 2013-02-12 13:35:08 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2011-2012, 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 | ffd21b0 | 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 | ffd21b0 | 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 | ffd21b0 | 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 | ffd21b0 | 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 | ffd21b0 | 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 | ffd21b0 | 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 | ffd21b0 | 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 | ffd21b0 | 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 | |
| Devin Kim | 803bb63 | 2012-08-30 02:54: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--) { |
| agathon.jung | b0c0c6d | 2012-09-26 11:36:51 -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 | ffd21b0 | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 114 | pr_info("%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; |
| agathon.jung | b0c0c6d | 2012-09-26 11:36:51 -0700 | [diff] [blame] | 117 | } |
| Joel King | 733377c | 2012-06-20 13:07:38 -0700 | [diff] [blame] | 118 | msleep(100); |
| 119 | } |
| Taniya Das | 70a64b4 | 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, |
| Joel King | 733377c | 2012-06-20 13:07:38 -0700 | [diff] [blame] | 123 | soft_reset_direction); |
| Taniya Das | 70a64b4 | 2012-12-11 10:23:33 +0530 | [diff] [blame] | 124 | if (i == 0) { |
| 125 | pr_err("%s: MDM2AP_STATUS never went low. Doing a hard reset\n", |
| 126 | __func__); |
| Joel King | 733377c | 2012-06-20 13:07:38 -0700 | [diff] [blame] | 127 | /* |
| 128 | * Currently, there is a debounce timer on the charm PMIC. It is |
| 129 | * necessary to hold the PMIC RESET low for ~3.5 seconds |
| 130 | * for the reset to fully take place. Sleep here to ensure the |
| 131 | * reset has occured before the function exits. |
| 132 | */ |
| 133 | msleep(4000); |
| 134 | } |
| Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 135 | } |
| 136 | |
| 137 | static void mdm_do_first_power_on(struct mdm_modem_drv *mdm_drv) |
| 138 | { |
| Vamsi Krishna | c6dcd5e | 2012-05-09 15:38:01 -0700 | [diff] [blame] | 139 | int i; |
| 140 | int pblrdy; |
| Joel King | 68cb546 | 2013-03-15 12:54:33 -0700 | [diff] [blame] | 141 | int kpd_direction_assert = 1, |
| 142 | kpd_direction_de_assert = 0; |
| 143 | |
| 144 | if (mdm_drv->pdata->kpd_not_inverted) { |
| 145 | kpd_direction_assert = 0; |
| 146 | kpd_direction_de_assert = 1; |
| 147 | } |
| 148 | |
| Ameya Thakur | ffd21b0 | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 149 | if (mdm_drv->power_on_count != 1) { |
| 150 | pr_err("%s:id %d: Calling fn when power_on_count != 1\n", |
| 151 | __func__, mdm_drv->device_id); |
| Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 152 | return; |
| 153 | } |
| 154 | |
| Ameya Thakur | ffd21b0 | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 155 | pr_err("%s:id %d: Powering on modem for the first time\n", |
| 156 | __func__, mdm_drv->device_id); |
| Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 157 | mdm_peripheral_disconnect(mdm_drv); |
| 158 | |
| Joel King | 733377c | 2012-06-20 13:07:38 -0700 | [diff] [blame] | 159 | /* If this is the first power-up after a panic, the modem may still |
| 160 | * be in a power-on state, in which case we need to toggle the gpio |
| 161 | * instead of just de-asserting it. No harm done if the modem was |
| 162 | * powered down. |
| 163 | */ |
| Joel King | 68cb546 | 2013-03-15 12:54:33 -0700 | [diff] [blame] | 164 | if (!mdm_drv->pdata->no_reset_on_first_powerup) |
| 165 | mdm_toggle_soft_reset(mdm_drv); |
| 166 | |
| Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 167 | /* If the device has a kpd pwr gpio then toggle it. */ |
| Ameya Thakur | e155ece | 2012-07-09 12:08:37 -0700 | [diff] [blame] | 168 | if (GPIO_IS_VALID(mdm_drv->ap2mdm_kpdpwr_n_gpio)) { |
| Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 169 | /* Pull AP2MDM_KPDPWR gpio high and wait for PS_HOLD to settle, |
| 170 | * then pull it back low. |
| 171 | */ |
| Taniya Das | 51d8066 | 2013-01-21 15:14:15 +0530 | [diff] [blame] | 172 | pr_debug("%s: Pulling AP2MDM_KPDPWR gpio high\n", __func__); |
| 173 | gpio_direction_output(mdm_drv->ap2mdm_kpdpwr_n_gpio, 1); |
| 174 | gpio_direction_output(mdm_drv->ap2mdm_status_gpio, 1); |
| Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 175 | msleep(1000); |
| Taniya Das | 51d8066 | 2013-01-21 15:14:15 +0530 | [diff] [blame] | 176 | gpio_direction_output(mdm_drv->ap2mdm_kpdpwr_n_gpio, 0); |
| 177 | } else |
| 178 | gpio_direction_output(mdm_drv->ap2mdm_status_gpio, 1); |
| Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 179 | |
| Ameya Thakur | e155ece | 2012-07-09 12:08:37 -0700 | [diff] [blame] | 180 | if (!GPIO_IS_VALID(mdm_drv->mdm2ap_pblrdy)) |
| Vamsi Krishna | c6dcd5e | 2012-05-09 15:38:01 -0700 | [diff] [blame] | 181 | goto start_mdm_peripheral; |
| Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 182 | |
| Vamsi Krishna | c6dcd5e | 2012-05-09 15:38:01 -0700 | [diff] [blame] | 183 | for (i = 0; i < MDM_PBLRDY_CNT; i++) { |
| 184 | pblrdy = gpio_get_value(mdm_drv->mdm2ap_pblrdy); |
| 185 | if (pblrdy) |
| 186 | break; |
| 187 | usleep_range(5000, 5000); |
| 188 | } |
| Ameya Thakur | ffd21b0 | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 189 | pr_debug("%s: id %d: pblrdy i:%d\n", __func__, |
| 190 | mdm_drv->device_id, i); |
| Vamsi Krishna | c6dcd5e | 2012-05-09 15:38:01 -0700 | [diff] [blame] | 191 | |
| 192 | start_mdm_peripheral: |
| Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 193 | mdm_peripheral_connect(mdm_drv); |
| 194 | msleep(200); |
| 195 | } |
| 196 | |
| 197 | static void mdm_do_soft_power_on(struct mdm_modem_drv *mdm_drv) |
| 198 | { |
| Vamsi Krishna | c6dcd5e | 2012-05-09 15:38:01 -0700 | [diff] [blame] | 199 | int i; |
| 200 | int pblrdy; |
| Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 201 | |
| Ameya Thakur | ffd21b0 | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 202 | pr_err("%s: id %d: soft resetting mdm modem\n", |
| 203 | __func__, mdm_drv->device_id); |
| Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 204 | mdm_peripheral_disconnect(mdm_drv); |
| Joel King | 733377c | 2012-06-20 13:07:38 -0700 | [diff] [blame] | 205 | mdm_toggle_soft_reset(mdm_drv); |
| Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 206 | |
| Ameya Thakur | e155ece | 2012-07-09 12:08:37 -0700 | [diff] [blame] | 207 | if (!GPIO_IS_VALID(mdm_drv->mdm2ap_pblrdy)) |
| Vamsi Krishna | c6dcd5e | 2012-05-09 15:38:01 -0700 | [diff] [blame] | 208 | goto start_mdm_peripheral; |
| 209 | |
| 210 | for (i = 0; i < MDM_PBLRDY_CNT; i++) { |
| 211 | pblrdy = gpio_get_value(mdm_drv->mdm2ap_pblrdy); |
| 212 | if (pblrdy) |
| 213 | break; |
| 214 | usleep_range(5000, 5000); |
| 215 | } |
| 216 | |
| Ameya Thakur | ffd21b0 | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 217 | pr_debug("%s: id %d: pblrdy i:%d\n", __func__, |
| 218 | mdm_drv->device_id, i); |
| Vamsi Krishna | c6dcd5e | 2012-05-09 15:38:01 -0700 | [diff] [blame] | 219 | |
| 220 | start_mdm_peripheral: |
| Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 221 | mdm_peripheral_connect(mdm_drv); |
| 222 | msleep(200); |
| 223 | } |
| 224 | |
| 225 | static void mdm_power_on_common(struct mdm_modem_drv *mdm_drv) |
| Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 226 | { |
| Ameya Thakur | ffd21b0 | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 227 | mdm_drv->power_on_count++; |
| Joel King | 3da02a9 | 2012-03-20 10:55:52 -0700 | [diff] [blame] | 228 | |
| Vamsi Krishna | 9e307cd | 2012-04-11 13:15:36 -0700 | [diff] [blame] | 229 | /* this gpio will be used to indicate apq readiness, |
| Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 230 | * de-assert it now so that it can be asserted later. |
| 231 | * May not be used. |
| Vamsi Krishna | 9e307cd | 2012-04-11 13:15:36 -0700 | [diff] [blame] | 232 | */ |
| Ameya Thakur | e155ece | 2012-07-09 12:08:37 -0700 | [diff] [blame] | 233 | if (GPIO_IS_VALID(mdm_drv->ap2mdm_wakeup_gpio)) |
| Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 234 | gpio_direction_output(mdm_drv->ap2mdm_wakeup_gpio, 0); |
| Vamsi Krishna | 9e307cd | 2012-04-11 13:15:36 -0700 | [diff] [blame] | 235 | |
| Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 236 | /* |
| 237 | * If we did an "early power on" then ignore the very next |
| 238 | * power-on request because it would the be first request from |
| 239 | * user space but we're already powered on. Ignore it. |
| Joel King | 3da02a9 | 2012-03-20 10:55:52 -0700 | [diff] [blame] | 240 | */ |
| Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 241 | if (mdm_drv->pdata->early_power_on && |
| Ameya Thakur | ffd21b0 | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 242 | (mdm_drv->power_on_count == 2)) |
| Joel King | 3da02a9 | 2012-03-20 10:55:52 -0700 | [diff] [blame] | 243 | return; |
| 244 | |
| Ameya Thakur | ffd21b0 | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 245 | if (mdm_drv->power_on_count == 1) |
| Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 246 | mdm_do_first_power_on(mdm_drv); |
| 247 | else |
| 248 | mdm_do_soft_power_on(mdm_drv); |
| Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 249 | } |
| 250 | |
| Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 251 | static void debug_state_changed(int value) |
| 252 | { |
| Joel King | 96c96dc | 2012-07-30 09:06:15 -0700 | [diff] [blame] | 253 | mdm_debug_mask = value; |
| Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 254 | } |
| 255 | |
| Joel King | d8052c0 | 2012-02-03 12:33:31 -0800 | [diff] [blame] | 256 | 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] | 257 | { |
| Ameya Thakur | ffd21b0 | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 258 | pr_debug("%s: id %d: value:%d\n", __func__, |
| 259 | value, mdm_drv->device_id); |
| Vamsi Krishna | 3392563 | 2011-12-13 15:43:09 -0800 | [diff] [blame] | 260 | |
| 261 | if (value) { |
| Joel King | d8052c0 | 2012-02-03 12:33:31 -0800 | [diff] [blame] | 262 | mdm_peripheral_disconnect(mdm_drv); |
| 263 | mdm_peripheral_connect(mdm_drv); |
| Ameya Thakur | e155ece | 2012-07-09 12:08:37 -0700 | [diff] [blame] | 264 | if (GPIO_IS_VALID(mdm_drv->ap2mdm_wakeup_gpio)) |
| Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 265 | gpio_direction_output(mdm_drv->ap2mdm_wakeup_gpio, 1); |
| Vamsi Krishna | 3392563 | 2011-12-13 15:43:09 -0800 | [diff] [blame] | 266 | } |
| 267 | } |
| 268 | |
| Ameya Thakur | 43248fd | 2012-07-10 18:50:52 -0700 | [diff] [blame] | 269 | static void mdm_image_upgrade(struct mdm_modem_drv *mdm_drv, int type) |
| 270 | { |
| 271 | switch (type) { |
| 272 | case APQ_CONTROLLED_UPGRADE: |
| Ameya Thakur | ffd21b0 | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 273 | pr_debug("%s: id %d: APQ 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 | mdm_toggle_soft_reset(mdm_drv); |
| 277 | break; |
| 278 | case MDM_CONTROLLED_UPGRADE: |
| Ameya Thakur | ffd21b0 | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 279 | pr_debug("%s: id %d: MDM controlled modem image upgrade\n", |
| 280 | __func__, mdm_drv->device_id); |
| 281 | atomic_set(&mdm_drv->mdm_ready, 0); |
| Ameya Thakur | 43248fd | 2012-07-10 18:50:52 -0700 | [diff] [blame] | 282 | /* |
| 283 | * If we have no image currently present on the modem, then we |
| 284 | * would be in PBL, in which case the status gpio would not go |
| 285 | * high. |
| 286 | */ |
| 287 | mdm_drv->disable_status_check = 1; |
| Ameya Thakur | e155ece | 2012-07-09 12:08:37 -0700 | [diff] [blame] | 288 | if (GPIO_IS_VALID(mdm_drv->usb_switch_gpio)) { |
| Ameya Thakur | ffd21b0 | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 289 | pr_info("%s: id %d: Switching usb control to MDM\n", |
| 290 | __func__, mdm_drv->device_id); |
| Ameya Thakur | 43248fd | 2012-07-10 18:50:52 -0700 | [diff] [blame] | 291 | gpio_direction_output(mdm_drv->usb_switch_gpio, 1); |
| 292 | } else |
| Ameya Thakur | ffd21b0 | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 293 | pr_err("%s: id %d: usb switch gpio unavailable\n", |
| 294 | __func__, mdm_drv->device_id); |
| Ameya Thakur | 43248fd | 2012-07-10 18:50:52 -0700 | [diff] [blame] | 295 | break; |
| 296 | default: |
| Ameya Thakur | ffd21b0 | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 297 | pr_err("%s: id %d: invalid upgrade type\n", |
| 298 | __func__, mdm_drv->device_id); |
| Ameya Thakur | 43248fd | 2012-07-10 18:50:52 -0700 | [diff] [blame] | 299 | } |
| 300 | } |
| Ameya Thakur | ffd21b0 | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 301 | |
| Joel King | e9cd527 | 2012-01-28 12:48:59 -0800 | [diff] [blame] | 302 | static struct mdm_ops mdm_cb = { |
| Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 303 | .power_on_mdm_cb = mdm_power_on_common, |
| 304 | .reset_mdm_cb = mdm_power_on_common, |
| Joel King | a7a7b9a | 2012-06-28 13:35:28 -0700 | [diff] [blame] | 305 | .atomic_reset_mdm_cb = mdm_atomic_soft_reset, |
| Joel King | e92eb87 | 2012-05-06 09:30:24 -0700 | [diff] [blame] | 306 | .power_down_mdm_cb = mdm_power_down_common, |
| Joel King | e9cd527 | 2012-01-28 12:48:59 -0800 | [diff] [blame] | 307 | .debug_state_changed_cb = debug_state_changed, |
| 308 | .status_cb = mdm_status_changed, |
| Ameya Thakur | 43248fd | 2012-07-10 18:50:52 -0700 | [diff] [blame] | 309 | .image_upgrade_cb = mdm_image_upgrade, |
| Joel King | e9cd527 | 2012-01-28 12:48:59 -0800 | [diff] [blame] | 310 | }; |
| 311 | |
| Ameya Thakur | ffd21b0 | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 312 | int mdm_get_ops(struct mdm_ops **mdm_ops) |
| Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 313 | { |
| Ameya Thakur | ffd21b0 | 2013-01-30 11:33:22 -0800 | [diff] [blame] | 314 | *mdm_ops = &mdm_cb; |
| 315 | return 0; |
| Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 316 | } |
| 317 | |
| Joel King | b6f0f61 | 2011-11-01 16:59:14 -0700 | [diff] [blame] | 318 | |