static void mdm_do_first_power_on(struct mdm_modem_drv *mdm_drv) { int i; int pblrdy; int kpd_direction_assert = 1, kpd_direction_de_assert = 0; if (mdm_drv->pdata->kpd_not_inverted) { kpd_direction_assert = 0; kpd_direction_de_assert = 1; } if (mdm_drv->power_on_count != 1) { pr_err("%s:id %d: Calling fn when power_on_count != 1\n", __func__, mdm_drv->device_id); return; } pr_err("%s:id %d: Powering on modem for the first time\n", __func__, mdm_drv->device_id); mdm_peripheral_disconnect(mdm_drv); /* If this is the first power-up after a panic, the modem may still * be in a power-on state, in which case we need to toggle the gpio * instead of just de-asserting it. No harm done if the modem was * powered down. */ if (!mdm_drv->pdata->no_reset_on_first_powerup) mdm_toggle_soft_reset(mdm_drv); /* If the device has a kpd pwr gpio then toggle it. */ if (GPIO_IS_VALID(mdm_drv->ap2mdm_kpdpwr_n_gpio)) { /* Pull AP2MDM_KPDPWR gpio high and wait for PS_HOLD to settle, * then pull it back low. */ pr_debug("%s:id %d: Pulling AP2MDM_KPDPWR gpio high\n", __func__, mdm_drv->device_id); gpio_direction_output(mdm_drv->ap2mdm_kpdpwr_n_gpio, kpd_direction_assert); msleep(1000); gpio_direction_output(mdm_drv->ap2mdm_kpdpwr_n_gpio, kpd_direction_de_assert); } if (!GPIO_IS_VALID(mdm_drv->mdm2ap_pblrdy)) goto start_mdm_peripheral; for (i = 0; i < MDM_PBLRDY_CNT; i++) { pblrdy = gpio_get_value(mdm_drv->mdm2ap_pblrdy); if (pblrdy) break; usleep_range(5000, 5000); } pr_debug("%s: id %d: pblrdy i:%d\n", __func__, mdm_drv->device_id, i); start_mdm_peripheral: mdm_peripheral_connect(mdm_drv); msleep(200); }
static void mdm_image_upgrade(struct mdm_modem_drv *mdm_drv, int type) { switch (type) { case APQ_CONTROLLED_UPGRADE: pr_debug("%s APQ controlled modem image upgrade\n", __func__); mdm_drv->mdm_ready = 0; mdm_toggle_soft_reset(mdm_drv); break; case MDM_CONTROLLED_UPGRADE: pr_debug("%s MDM controlled modem image upgrade\n", __func__); mdm_drv->mdm_ready = 0; /* * If we have no image currently present on the modem, then we * would be in PBL, in which case the status gpio would not go * high. */ mdm_drv->disable_status_check = 1; if (GPIO_IS_VALID(mdm_drv->usb_switch_gpio)) { pr_info("%s Switching usb control to MDM\n", __func__); gpio_direction_output(mdm_drv->usb_switch_gpio, 1); } else pr_err("%s usb switch gpio unavailable\n", __func__); break; default: pr_err("%s invalid upgrade type\n", __func__); } }
static void mdm_power_on_common(struct mdm_modem_drv *mdm_drv) { power_on_count++; /* this gpio will be used to indicate apq readiness, * de-assert it now so that it can be asserted later. * May not be used. */ if (GPIO_IS_VALID(mdm_drv->ap2mdm_wakeup_gpio)) gpio_direction_output(mdm_drv->ap2mdm_wakeup_gpio, 0); if (power_on_count == 1) { if (mdm_is_charge_only) pr_info("%s: Skip first power on in charge-only mode.\n", __func__); else mdm_do_first_power_on(mdm_drv); } else if (power_on_count == 2) { if (mdm_is_charge_only) mdm_do_first_power_on(mdm_drv); else if (!mdm_drv->pdata->early_power_on) mdm_do_soft_power_on(mdm_drv); } else { mdm_do_soft_power_on(mdm_drv); } }
static void mdm_do_soft_power_on(struct mdm_modem_drv *mdm_drv) { int i; int pblrdy; pr_err("%s: soft resetting mdm modem\n", __func__); mdm_peripheral_disconnect(mdm_drv); mdm_toggle_soft_reset(mdm_drv); if (!GPIO_IS_VALID(mdm_drv->mdm2ap_pblrdy)) goto start_mdm_peripheral; for (i = 0; i < MDM_PBLRDY_CNT; i++) { pblrdy = gpio_get_value(mdm_drv->mdm2ap_pblrdy); if (pblrdy) break; usleep_range(5000, 5000); } pr_debug("%s: i:%d\n", __func__, i); start_mdm_peripheral: mdm_peripheral_connect(mdm_drv); msleep(200); }
static void mdm_power_on_common(struct mdm_modem_drv *mdm_drv) { mdm_drv->power_on_count++; /* this gpio will be used to indicate apq readiness, * de-assert it now so that it can be asserted later. * May not be used. */ if (GPIO_IS_VALID(mdm_drv->ap2mdm_wakeup_gpio)) gpio_direction_output(mdm_drv->ap2mdm_wakeup_gpio, 0); /* * If we did an "early power on" then ignore the very next * power-on request because it would the be first request from * user space but we're already powered on. Ignore it. */ if (mdm_drv->pdata->early_power_on && (mdm_drv->power_on_count == 2)) return; if (mdm_drv->power_on_count == 1) mdm_do_first_power_on(mdm_drv); else mdm_do_soft_power_on(mdm_drv); }
static void mdm_do_soft_power_on(struct mdm_modem_drv *mdm_drv) { #ifdef USE_MDM_MODEM int i; int pblrdy; #endif pr_err("%s: id %d: soft resetting mdm modem\n", __func__, mdm_drv->device_id); mdm_peripheral_disconnect(mdm_drv); mdm_toggle_soft_reset(mdm_drv); #ifdef USE_MDM_MODEM if (!GPIO_IS_VALID(MDM_GPIO(MDM2AP_PBLRDY))) goto start_mdm_peripheral; for (i = 0; i < MDM_PBLRDY_CNT; i++) { pblrdy = gpio_get_value(MDM_GPIO(MDM2AP_PBLRDY)); if (pblrdy) break; usleep_range(5000, 5000); } pr_info("%s: id %d: pblrdy i:%d\n", __func__, mdm_drv->device_id, i); start_mdm_peripheral: #endif mdm_peripheral_connect(mdm_drv); msleep(200); }
static void mdm_power_on_common(struct mdm_modem_drv *mdm_drv) { mdm_drv->power_on_count++; /* this gpio will be used to indicate apq readiness, * de-assert it now so that it can be asserted later. * May not be used. */ pr_err("%s \n", __func__); if (GPIO_IS_VALID(MDM_GPIO(AP2MDM_CHNLRDY))) gpio_direction_output(MDM_GPIO(AP2MDM_CHNLRDY), 0); /* * If we did an "early power on" then ignore the very next * power-on request because it would the be first request from * user space but we're already powered on. Ignore it. */ if (mdm_drv->pdata->early_power_on && (mdm_drv->power_on_count == 2)) return; if(poweroff_charging){ pr_debug("%s: do not power on in lpm\n", __func__); return; } if (mdm_drv->power_on_count == 1) mdm_do_first_power_on(mdm_drv); else mdm_do_soft_power_on(mdm_drv); }
static void mdm_image_upgrade(struct mdm_modem_drv *mdm_drv, int type) { switch (type) { case APQ_CONTROLLED_UPGRADE: pr_debug("%s: id %d: APQ controlled modem image upgrade\n", __func__, mdm_drv->device_id); atomic_set(&mdm_drv->mdm_ready, 0); mdm_toggle_soft_reset(mdm_drv); break; case MDM_CONTROLLED_UPGRADE: pr_debug("%s: id %d: MDM controlled modem image upgrade\n", __func__, mdm_drv->device_id); atomic_set(&mdm_drv->mdm_ready, 0); /* * If we have no image currently present on the modem, then we * would be in PBL, in which case the status gpio would not go * high. */ mdm_drv->disable_status_check = 1; if (GPIO_IS_VALID(MDM_GPIO(USB_SW))) { pr_debug("%s: id %d: Switching usb control to MDM\n", __func__, mdm_drv->device_id); gpio_direction_output(MDM_GPIO(USB_SW), 1); } else pr_err("%s: id %d: usb switch gpio unavailable\n", __func__, mdm_drv->device_id); break; default: pr_err("%s: id %d: invalid upgrade type\n", __func__, mdm_drv->device_id); } }
int get_qsc_wakeup_ack_gpio(void) { if( mdm_drv && GPIO_IS_VALID(mdm_drv->qsc2ap_wakeup_ack_gpio) ) return gpio_get_value(mdm_drv->qsc2ap_wakeup_ack_gpio); pr_err("%s: Can't get wakeup_ack gpio\n", __func__); return 0; }
static void mdm_status_changed(struct mdm_modem_drv *mdm_drv, int value) { pr_debug("%s: value:%d\n", __func__, value); if (value) { mdm_peripheral_disconnect(mdm_drv); mdm_peripheral_connect(mdm_drv); if (GPIO_IS_VALID(mdm_drv->ap2mdm_wakeup_gpio)) gpio_direction_output(mdm_drv->ap2mdm_wakeup_gpio, 1); } }
static void mdm_status_changed(struct mdm_modem_drv *mdm_drv, int value) { if (!mdm_drv->pdata->peripheral_platform_device) return; pr_debug("%s: id %d: value:%d\n", __func__, value, mdm_drv->device_id); if (value) { mdm_peripheral_disconnect(mdm_drv); msleep(100); mdm_peripheral_connect(mdm_drv); if (GPIO_IS_VALID(MDM_GPIO(AP2MDM_WAKEUP))) gpio_direction_output(MDM_GPIO(AP2MDM_WAKEUP), 1); } }
void trigger_qsc_fatal_err(const char *reason) { if( reason ) pr_err("%s: reason <%s", __func__, reason); else pr_err("%s: reason <%s", __func__, "NULL"); pr_err("%s: Trigger QSC err fatal.\n", __func__); if(!mdm_drv){ pr_err("%s: qsc driver is NULL.\n", __func__); return; } mdm_drv->mdm_ready = 0; if( mdm_drv && GPIO_IS_VALID(mdm_drv->ap2mdm_status_gpio) ) gpio_direction_output(mdm_drv->ap2mdm_status_gpio, 0); pr_err("%s: Trigger SSR to reset QSC.\n", __func__); queue_delayed_work(qsc_queue, &delayed_subsystem_restart_work, msecs_to_jiffies(500)); }
static void mdm_power_on_common(struct mdm_modem_drv *mdm_drv) { power_on_count++; /* this gpio will be used to indicate apq readiness, * de-assert it now so that it can be asserted later. * May not be used. */ if (GPIO_IS_VALID(mdm_drv->ap2mdm_wakeup_gpio)) gpio_direction_output(mdm_drv->ap2mdm_wakeup_gpio, 0); /* * If we did an "early power on" then ignore the very next * power-on request because it would the be first request from * user space but we're already powered on. Ignore it. */ if (mdm_drv->pdata->early_power_on && (power_on_count == 2)) return; #ifdef CONFIG_SONY_QSCFLASHING_UART4 /* * If we want to enter into edl mode, we should hard reboot the QSC, * so we use the mdm_do_first_power_on */ if (mdm_drv->mdm_edload_status == 1) { mdm_do_first_power_on(mdm_drv); power_on_count--; return; } #endif if (power_on_count == 1) mdm_do_first_power_on(mdm_drv); else mdm_do_soft_power_on(mdm_drv); }
static void mdm_do_first_power_on(struct mdm_modem_drv *mdm_drv) { #ifdef USE_MDM_MODEM int i; int pblrdy; #endif gpio_direction_output(MDM_GPIO(AP2MDM_SOFT_RESET), 0); gpio_direction_output(MDM_GPIO(AP2MDM_PMIC_PWR_EN), 1); msleep(10); if (mdm_drv->power_on_count != 1) { pr_debug("%s:id %d: Calling fn when power_on_count != 1\n", __func__, mdm_drv->device_id); return; } pr_err("%s \n", __func__); pr_err("%s:id %d: Powering on modem for the first time\n", __func__, mdm_drv->device_id); mdm_peripheral_disconnect(mdm_drv); /* If this is the first power-up after a panic, the modem may still * be in a power-on state, in which case we need to toggle the gpio * instead of just de-asserting it. No harm done if the modem was * powered down. */ if (!mdm_drv->pdata->no_reset_on_first_powerup) mdm_toggle_soft_reset(mdm_drv); /* If the device has a kpd pwr gpio then toggle it. */ if (GPIO_IS_VALID(MDM_GPIO(AP2MDM_KPDPWR))) { // HSLEE qsc en /* Pull AP2MDM_KPDPWR gpio high and wait for PS_HOLD to settle, * then pull it back low. */ pr_err("%s:id %d: Pulling AP2MDM_KPDPWR gpio high\n", __func__, mdm_drv->device_id); gpio_direction_output(MDM_GPIO(AP2MDM_KPDPWR), 1); //gpio_direction_output(MDM_GPIO(AP2MDM_STATUS), 1); msleep(1000); gpio_direction_output(MDM_GPIO(AP2MDM_KPDPWR), 0); }//else gpio_direction_output(MDM_GPIO(AP2MDM_STATUS), 1); msleep(5000); if (!gpio_get_value(MDM_GPIO(MDM2AP_STATUS))) { pr_err("%s: QSC failed. reboot\n", __func__); gpio_direction_output(MDM_GPIO(AP2MDM_STATUS), 0); gpio_direction_output(MDM_GPIO(AP2MDM_PMIC_PWR_EN), 0); msleep(5000); gpio_direction_output(MDM_GPIO(AP2MDM_PMIC_PWR_EN), 1); msleep(10); gpio_direction_output(MDM_GPIO(AP2MDM_KPDPWR), 1); msleep(1000); gpio_direction_output(MDM_GPIO(AP2MDM_KPDPWR), 0); gpio_direction_output(MDM_GPIO(AP2MDM_STATUS), 1); } /* check if qsc is in dload mode */ if (gpio_get_value(MDM_GPIO(MDM2AP_ERRFATAL))) { pr_err("%s: QSC is in dload. reset\n", __func__); gpio_direction_output(MDM_GPIO(AP2MDM_SOFT_RESET), 1); mdelay(10); gpio_direction_output(MDM_GPIO(AP2MDM_SOFT_RESET), 0); } #ifdef USE_MDM_MODEM if (!GPIO_IS_VALID(MDM_GPIO(MDM2AP_PBLRDY))) goto start_mdm_peripheral; for (i = 0; i < MDM_PBLRDY_CNT; i++) { pblrdy = gpio_get_value(MDM_GPIO(MDM2AP_PBLRDY)); if (pblrdy) break; usleep_range(5000, 5000); } pr_info("%s: id %d: pblrdy i:%d\n", __func__, mdm_drv->device_id, i); start_mdm_peripheral: #endif pr_err("%s %d\n", __func__,__LINE__); mdm_peripheral_connect(mdm_drv); msleep(200); }
static void mdm_do_first_power_on(struct mdm_modem_drv *mdm_drv) { int i; int pblrdy; #ifdef CONFIG_SONY_QSCFLASHING_UART4 if (power_on_count != 1 && mdm_drv->mdm_edload_status != 1) { #else if (power_on_count != 1) { #endif pr_err("%s: Calling fn when power_on_count != 1\n", __func__); return; } pr_err("%s: Powering on modem for the first time\n", __func__); mdm_peripheral_disconnect(mdm_drv); /* If this is the first power-up after a panic, the modem may still * be in a power-on state, in which case we need to toggle the gpio * instead of just de-asserting it. No harm done if the modem was * powered down. */ mdm_toggle_soft_reset(mdm_drv); /* If the device has a kpd pwr gpio then toggle it. */ if (GPIO_IS_VALID(mdm_drv->ap2mdm_kpdpwr_n_gpio)) { /* Pull AP2MDM_KPDPWR gpio high and wait for PS_HOLD to settle, * then pull it back low. */ pr_debug("%s: Pulling AP2MDM_KPDPWR gpio high\n", __func__); gpio_direction_output(mdm_drv->ap2mdm_kpdpwr_n_gpio, 1); msleep(1000); gpio_direction_output(mdm_drv->ap2mdm_kpdpwr_n_gpio, 0); } if (!GPIO_IS_VALID(mdm_drv->mdm2ap_pblrdy)) goto start_mdm_peripheral; for (i = 0; i < MDM_PBLRDY_CNT; i++) { pblrdy = gpio_get_value(mdm_drv->mdm2ap_pblrdy); if (pblrdy) break; usleep_range(5000, 5000); } pr_debug("%s: i:%d\n", __func__, i); start_mdm_peripheral: mdm_peripheral_connect(mdm_drv); msleep(200); } static void mdm_do_soft_power_on(struct mdm_modem_drv *mdm_drv) { int i; int pblrdy; pr_err("%s: soft resetting mdm modem\n", __func__); mdm_peripheral_disconnect(mdm_drv); mdm_toggle_soft_reset(mdm_drv); if (!GPIO_IS_VALID(mdm_drv->mdm2ap_pblrdy)) goto start_mdm_peripheral; for (i = 0; i < MDM_PBLRDY_CNT; i++) { pblrdy = gpio_get_value(mdm_drv->mdm2ap_pblrdy); if (pblrdy) break; usleep_range(5000, 5000); } pr_debug("%s: i:%d\n", __func__, i); start_mdm_peripheral: mdm_peripheral_connect(mdm_drv); msleep(200); }