static void ss222_mc_state_fsm(struct modem_ctl *mc)
{
	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);
	enum modem_state old_state = mc->phone_state;
	enum modem_state new_state = mc->phone_state;

	mif_err("old_state:%s cp_on:%d cp_reset:%d cp_active:%d\n",
		cp_state_str(old_state), cp_on, cp_reset, cp_active);

	if (cp_active) {
		if (!cp_on)
			new_state = STATE_OFFLINE;
		else if (old_state == STATE_ONLINE)
			new_state = STATE_CRASH_EXIT;
		else
			mif_err("don't care!!!\n");
	}

	if (old_state != new_state) {
		mif_err("new_state = %s\n", cp_state_str(new_state));
		mc->bootd->modem_state_changed(mc->bootd, new_state);
		mc->iod->modem_state_changed(mc->iod, new_state);
	}
}
Esempio n. 2
0
static void 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);
	enum modem_state old_state = mc->phone_state;
	enum modem_state new_state = mc->phone_state;

	mif_err("old_state:%s cp_on:%d cp_reset:%d cp_active:%d\n",
		cp_state_str(old_state), cp_on, cp_reset, cp_active);

	if (cp_active) {
		if (!cp_on)
			new_state = STATE_OFFLINE;
		else if (old_state == STATE_ONLINE)
			new_state = STATE_CRASH_EXIT;
		else
			mif_err("don't care!!!\n");
	}

	if (new_state != old_state) {
		/* Change the modem state for RIL */
		mc->iod->modem_state_changed(mc->iod, new_state);

		if (new_state == STATE_CRASH_EXIT) {
			if (ld->close_tx)
				ld->close_tx(ld);
		}

		/* Change the modem state for CBD */
		mc->bootd->modem_state_changed(mc->bootd, new_state);
	}
}