static void ss222_mc_state_fsm(struct modem_ctl *mc) { struct link_device *ld = get_current_link(mc->iod); int cp_on = gpio_get_value(mc->gpio_cp_on); int cp_reset = gpio_get_value(mc->gpio_cp_reset); int cp_active = gpio_get_value(mc->gpio_phone_active); int old_state = mc->phone_state; int new_state = mc->phone_state; mif_err("old_state:%s cp_on:%d cp_reset:%d cp_active:%d\n", get_cp_state_str(old_state), cp_on, cp_reset, cp_active); if (cp_active) { if (!cp_on) { new_state = STATE_OFFLINE; ld->mode = LINK_MODE_OFFLINE; } else if (old_state == STATE_ONLINE) { new_state = STATE_CRASH_EXIT; ld->mode = LINK_MODE_ULOAD; } else { mif_err("don't care!!!\n"); } } if (old_state != new_state) { mif_err("new_state = %s\n", get_cp_state_str(new_state)); mc->bootd->modem_state_changed(mc->bootd, new_state); mc->iod->modem_state_changed(mc->iod, new_state); } }
static int cbp82_on(struct modem_ctl *mc) { int cp_on = gpio_get_value(mc->gpio_cp_on); int cp_off = gpio_get_value(mc->gpio_cp_off); int cp_reset = gpio_get_value(mc->gpio_cp_reset); int cp_active = gpio_get_value(mc->gpio_phone_active); mif_err("+++\n"); mif_err("phone_state:%s cp_on:%d cp_off:%d cp_reset:%d cp_active:%d\n", get_cp_state_str(mc->phone_state), cp_on, cp_off, cp_reset, cp_active); /* prevent sleep during bootloader downloading */ if (!wake_lock_active(&mc->mc_wake_lock)) wake_lock(&mc->mc_wake_lock); gpio_set_value(mc->gpio_cp_on, 0); gpio_set_value(mc->gpio_cp_off, 1); gpio_set_value(mc->gpio_cp_reset, 0); msleep(500); cp_on = gpio_get_value(mc->gpio_cp_on); cp_off = gpio_get_value(mc->gpio_cp_off); cp_reset = gpio_get_value(mc->gpio_cp_reset); cp_active = gpio_get_value(mc->gpio_phone_active); mif_err("phone_state:%s cp_on:%d cp_off:%d cp_reset:%d cp_active:%d\n", get_cp_state_str(mc->phone_state), cp_on, cp_off, cp_reset, cp_active); gpio_set_value(mc->gpio_cp_off, 0); gpio_set_value(mc->gpio_cp_on, 1); msleep(100); gpio_set_value(mc->gpio_cp_reset, 1); msleep(300); cp_on = gpio_get_value(mc->gpio_cp_on); cp_off = gpio_get_value(mc->gpio_cp_off); cp_reset = gpio_get_value(mc->gpio_cp_reset); cp_active = gpio_get_value(mc->gpio_phone_active); mif_err("phone_state:%s cp_on:%d cp_off:%d cp_reset:%d cp_active:%d\n", get_cp_state_str(mc->phone_state), cp_on, cp_off, cp_reset, cp_active); if (mc->gpio_pda_active) gpio_set_value(mc->gpio_pda_active, 1); if (mc->bootd) mc->bootd->modem_state_changed(mc->bootd, STATE_BOOTING); else mif_err("no mc->bootd\n"); mif_err("---\n"); return 0; }
static irqreturn_t phone_active_handler(int irq, void *arg) { struct modem_ctl *mc = (struct modem_ctl *)arg; int cp_on = gpio_get_value(mc->gpio_cp_on); int cp_reset = gpio_get_value(mc->gpio_cp_reset); int cp_active = gpio_get_value(mc->gpio_phone_active); int old_state = mc->phone_state; int new_state = mc->phone_state; mif_info("old_state:%s cp_on:%d cp_reset:%d cp_active:%d\n", get_cp_state_str(old_state), cp_on, cp_reset, cp_active); if (cp_reset && cp_active) { if (mc->phone_state == STATE_BOOTING) { new_state = STATE_ONLINE; mc->bootd->modem_state_changed(mc->bootd, new_state); } } else if (cp_reset && !cp_active) { if (mc->phone_state == STATE_ONLINE) { new_state = STATE_CRASH_EXIT; mc->bootd->modem_state_changed(mc->bootd, new_state); } } else { new_state = STATE_OFFLINE; if (mc->bootd && mc->bootd->modem_state_changed) mc->bootd->modem_state_changed(mc->bootd, new_state); } if (new_state != old_state) { mif_err("%s: phone_state changed (%s -> %s\n)", mc->name, get_cp_state_str(old_state), get_cp_state_str(new_state)); } return IRQ_HANDLED; }