Exemplo n.º 1
0
static void  mdm_hsic_ready_fn(struct work_struct *work)
{
	int value = gpio_get_value(mdm_drv->mdm2ap_hsic_ready_gpio);

	pr_debug("%s: status:%d\n", __func__, value);

	//++SSD_RIL: Mars_Lin@20120606: Check 1st status.
	if ( value == 1 && get_hsic_ready_1st_hi == 0 ) {
		get_hsic_ready_1st_hi = 1;
		pr_info("%s: get_hsic_ready_1st_hi = 1\n", __func__);
	}

	if ( get_hsic_ready_1st_hi == 0 ) {
		pr_info("%s: get_hsic_ready_1st_hi == 0\n", __func__);
		return;
	}
	//--SSD_RIL

	if (value == 0) {
#if 0
		pr_info("%s: get HSIC low\n", __func__);
		pr_info("mdm_hsic_ready: unregister:tegra_ehci2_device\n");
		mdm_peripheral_disconnect(mdm_drv);
		pr_info("mdm_hsic_ready: register:tegra_ehci2_device\n");
		mdm_peripheral_connect(mdm_drv);
		//TEGRA_GPIO_PC6
		gpio_direction_output(mdm_drv->ap2mdm_wakeup_gpio, 1);
		tegra_gpio_enable(mdm_drv->ap2mdm_wakeup_gpio);
		gpio_set_value(mdm_drv->ap2mdm_wakeup_gpio, 1);
#endif
	}
}
Exemplo n.º 2
0
static void power_down_mdm(struct mdm_modem_drv *mdm_drv)
{
	int i;

	pr_err("%s\n", __func__);
	for (i = MDM_MODEM_TIMEOUT; i > 0; i -= MDM_MODEM_DELTA) {
		/* pet_watchdog(); */
		msleep(MDM_MODEM_DELTA);
		if (gpio_get_value(mdm_drv->mdm2ap_status_gpio) == 0)
			break;
	}
	if (i <= 0) {
		pr_err("%s: MDM2AP_STATUS never went low.\n",
			 __func__);
		gpio_direction_output(mdm_drv->ap2mdm_pmic_reset_n_gpio, 0);

		for (i = MDM_HOLD_TIME; i > 0; i -= MDM_MODEM_DELTA) {
			/* pet_watchdog(); */
			msleep(MDM_MODEM_DELTA);
		}
	}
	if (mdm_drv->ap2mdm_kpdpwr_n_gpio > 0)
		gpio_direction_output(mdm_drv->ap2mdm_kpdpwr_n_gpio, 0);
	mdm_peripheral_disconnect(mdm_drv);
}
Exemplo n.º 3
0
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_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_down_common(struct mdm_modem_drv *mdm_drv)
{
	int i;
	int soft_reset_direction =
		mdm_drv->pdata->soft_reset_inverted ? 1 : 0;

	mdm_peripheral_disconnect(mdm_drv);

	/* Wait for the modem to complete its power down actions. */
	for (i = 20; i > 0; i--) {
		if (gpio_get_value(mdm_drv->mdm2ap_status_gpio) == 0) {
			if (mdm_debug_mask & MDM_DEBUG_MASK_SHDN_LOG)
				pr_info("%s: mdm2ap_status went low, i = %d\n",
					__func__, i);
			break;
		}
		msleep(100);
	}
	if (i == 0) {
		pr_err("%s: MDM2AP_STATUS never went low. Doing a hard reset\n",
			   __func__);
		gpio_direction_output(mdm_drv->ap2mdm_soft_reset_gpio,
					soft_reset_direction);
		/*
		* Currently, there is a debounce timer on the charm PMIC. It is
		* necessary to hold the PMIC RESET low for ~3.5 seconds
		* for the reset to fully take place. Sleep here to ensure the
		* reset has occured before the function exits.
		*/
		msleep(4000);
	}
}
Exemplo n.º 6
0
Arquivo: mdm2.c Projeto: Arvoreen/ATnT
static void mdm_status_changed(struct mdm_modem_drv *mdm_drv, int value)
{
	pr_debug("%s: value:%d\n", __func__, value);

	if (value && mdm_drv->mdm_ready) {//Sophia:0510-check if MD ready
		/*
		msleep(2000);
		pr_info("mdm_status_changed: unregister:tegra_ehci2_device\n");
		mdm_peripheral_disconnect(mdm_drv);		
		pr_info("mdm_status_changed: register:tegra_ehci2_device\n");
		mdm_peripheral_connect(mdm_drv);
		gpio_direction_output(TEGRA_GPIO_PC6, 1);   //TEGRA_GPIO_PC6
		tegra_gpio_enable(TEGRA_GPIO_PC6);
		gpio_set_value(TEGRA_GPIO_PC6, 1);
		*/

		pr_info("mdm_status_changed: unregister:tegra_ehci2_device\n");
		mdm_peripheral_disconnect(mdm_drv);
		pr_info("mdm_status_changed: register:tegra_ehci2_device\n");
		pr_info("mdm_status_changed: +mdm_peripheral_connect\n");
		mdm_peripheral_connect(mdm_drv);
		pr_info("mdm_status_changed: -mdm_peripheral_connect\n");
		//TEGRA_GPIO_PC6
		gpio_direction_output(mdm_drv->ap2mdm_wakeup_gpio, 1);
		tegra_gpio_enable(mdm_drv->ap2mdm_wakeup_gpio);
		gpio_set_value(mdm_drv->ap2mdm_wakeup_gpio, 1);

		/* HTC added start */
		mdm9k_status = 1;
		/* HTC added end */
	}
}
Exemplo n.º 7
0
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);
}
Exemplo n.º 8
0
static void mdm_power_down_common(struct mdm_modem_drv *mdm_drv)
{
	int i;
	int soft_reset_direction =
		mdm_drv->pdata->soft_reset_inverted ? 1 : 0;

	mdm_peripheral_disconnect(mdm_drv);

	/* Wait for the modem to complete its power down actions. */
	for (i = 20; i > 0; i--) {
		if (gpio_get_value(mdm_drv->mdm2ap_status_gpio) == 0)
			break;
		msleep(100);
	}
	if ((i == 0) || ((ftm_mode == 1) || (baseband_mode == 1))) {
		if (i == 0)
			pr_err("%s: MDM2AP_STATUS never went low. Doing a hard reset\n", __func__);
		else
			pr_err("%s in %s_mode, force modem reset\n", __func__, ftm_mode == 1 ? "ftm":"charge");
		mutex_lock(&shutdown_lock);
		gpio_direction_output(mdm_drv->ap2mdm_soft_reset_gpio,
					soft_reset_direction);
		mdm_drv->ap2mdm_soft_reset_gpio = 0;
		mutex_unlock(&shutdown_lock);
		/*
		* Currently, there is a debounce timer on the charm PMIC. It is
		* necessary to hold the PMIC RESET low for ~3.5 seconds
		* for the reset to fully take place. Sleep here to ensure the
		* reset has occured before the function exits.
		*/
		msleep(4000);
	}
}
Exemplo n.º 9
0
static void mdm_do_first_power_on(struct mdm_modem_drv *mdm_drv)
{
	int soft_reset_direction =
		mdm_drv->pdata->soft_reset_inverted ? 0 : 1;

	if (power_on_count != 1) {
		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 the device has a kpd pwr gpio then toggle it. */
	if (mdm_drv->ap2mdm_kpdpwr_n_gpio > 0) {
		/* 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);
	}

	/* De-assert the soft reset line. */
	pr_debug("%s: De-asserting soft reset gpio\n", __func__);
	gpio_direction_output(mdm_drv->ap2mdm_soft_reset_gpio,
						  soft_reset_direction);

	mdm_peripheral_connect(mdm_drv);
	msleep(200);
}
Exemplo n.º 10
0
static void mdm_power_down_common(struct mdm_modem_drv *mdm_drv)
{
	int soft_reset_direction =
		mdm_drv->pdata->soft_reset_inverted ? 1 : 0;

	gpio_direction_output(mdm_drv->ap2mdm_soft_reset_gpio,
				soft_reset_direction);
	mdm_peripheral_disconnect(mdm_drv);
}
Exemplo n.º 11
0
static void mdm_status_changed(struct mdm_modem_drv *mdm_drv, int value)
{
    pr_info("%s: MDM2AP_STATUS_GPIO changed to %d\n", __func__, value);

    if (value) {
        mdm_peripheral_disconnect(mdm_drv);
        mdm_peripheral_connect(mdm_drv);
        gpio_direction_output(mdm_drv->ap2mdm_wakeup_gpio, 1);
    }
}
Exemplo n.º 12
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_power_down_common(struct mdm_modem_drv *mdm_drv)
{
	int i;
	int soft_reset_direction =
		mdm_drv->pdata->soft_reset_inverted ? 1 : 0;

	if (mdm_debug_mask & MDM_DEBUG_MASK_SHDN_LOG)
		pr_info("%s: Start mdm power down\n", __func__);

	mdm_peripheral_disconnect(mdm_drv);

	/* Wait for the modem to complete its power down actions. */
	for (i = 20; i > 0; i--) {
		if (gpio_get_value(mdm_drv->mdm2ap_status_gpio) == 0) {
			if (mdm_debug_mask & MDM_DEBUG_MASK_SHDN_LOG)
				pr_info("%s: mdm2ap_status went low, i = %d\n",
					__func__, i);
			break;
		}
		msleep(100);
	}

	if (i != 0) {
		pr_err("%s: MDM2AP_STATUS went low successfully.\n", __func__);
		return;
	}

	/* Shutdown the MDM9K gracefully.
	 * It seems that the MDM9K does not shutdown properly
	 * with shutdown command sent by system monitor via HSIC channel.
	 * The GPIO_27 of APQ named AP2MDM_PON_RESET_N is connected
	 * to PON_TRIG of PMIC8018 and PS_HOLD of PMIC8018 with a diode and
	 * a registor. So if GPIO_27 is pulled low the PS_HOLD input of
	 * PMIC8018 is low. The full powerdown sequence will be executed.*/

	pr_err("%s: MDM2AP_STATUS never went low. Doing a hard reset\n",
			__func__);
	pr_info("Hold PS_HOLD of MDM9K low for the reset to fully take place.\n");

	/* Q : Why we should hold the PS_HOLD low of PMIC 8018 for 1500ms?
	 * A : To overcome WDOG, we must hold PS_HOLD low for longer than the
	 * t(pshold) timer. This timer is 300ms MAX. To overcome SMPL, we must
	 * hold PS_HOLD low for longer thatn the SMPL timer setting. Since the
	 * SMPL timer is 1000ms which is greater thant the maximum t(pshold)
	 * timer, we just need to hold PS_HOLD low for longer than the SMPL
	 * timer to shut down the device with WDOG and SMPL.
	 * We added 500ms duration for margin of safety.
	 */
	gpio_direction_output(mdm_drv->ap2mdm_soft_reset_gpio,
				soft_reset_direction);
	msleep(1500);

}
Exemplo n.º 14
0
static void mdm_status_changed(struct mdm_modem_drv *mdm_drv, int value)
{
	pr_debug("%s: value:%d\n", __func__, value);

	pr_err("%s: ap2mdm_status = %d\n", __func__,
				gpio_get_value(mdm_drv->ap2mdm_status_gpio));
	if (value) {
		mdm_peripheral_disconnect(mdm_drv);
		mdm_peripheral_connect(mdm_drv);
		gpio_direction_output(mdm_drv->ap2mdm_wakeup_gpio, 1);
	}
}
Exemplo n.º 15
0
static void power_on_mdm(struct mdm_modem_drv *mdm_drv)
{
	int hsic_ready_timeout_ms = 100;

	power_on_count++;

	if (power_on_count == 2)
		return;

	mdm_peripheral_disconnect(mdm_drv);

	gpio_direction_output(mdm_drv->ap2mdm_status_gpio, 0);

	gpio_direction_output(mdm_drv->ap2mdm_wakeup_gpio, 0);

	
	pr_debug("Pulling RESET gpio low\n");
	gpio_direction_output(mdm_drv->ap2mdm_pmic_reset_n_gpio, 0);

	usleep_range(5000, 10000);

	
	pr_debug("%s: Pulling RESET gpio high\n", __func__);
	gpio_direction_output(mdm_drv->ap2mdm_pmic_reset_n_gpio, 1);

	msleep(40);

	gpio_direction_output(mdm_drv->ap2mdm_status_gpio, 1);

	while (!gpio_get_value(mdm_drv->mdm2ap_hsic_ready_gpio) && hsic_ready_timeout_ms>0) {
		msleep(10);
		hsic_ready_timeout_ms -= 10;
		pr_info("%s: waiting for MDM HSIC READY signal.\r\n", __func__);
	};
	if (!gpio_get_value(mdm_drv->mdm2ap_hsic_ready_gpio))
		pr_err("%s: MDM HSIC READY timeout!\r\n", __func__);

	mdm_peripheral_connect(mdm_drv);

	usleep(1000);

	if (power_on_count == 1) {
		if (mdm_drv->ap2mdm_kpdpwr_n_gpio > 0) {
			pr_debug("%s: Powering on mdm modem\n", __func__);
			gpio_direction_output(mdm_drv->ap2mdm_kpdpwr_n_gpio, 1);
			usleep(1000);
		}
	}

	msleep(200);
}
Exemplo n.º 16
0
static void power_on_mdm(struct mdm_modem_drv *mdm_drv)
{
	power_on_count++;

	pr_err("%s: power count %d\n", __func__, power_on_count);
	/* this gpio will be used to indicate apq readiness,
	 * de-assert it now so that it can asserted later
	 */
	gpio_direction_output(mdm_drv->ap2mdm_wakeup_gpio, 0);

	/* The second attempt to power-on the mdm is the first attempt
	 * from user space, but we're already powered on. Ignore this.
	 * Subsequent attempts are from SSR or if something failed, in
	 * which case we must always reset the modem.
	 */
	if (power_on_count == 2)
		return;

	mdm_peripheral_disconnect(mdm_drv);

	/* Pull RESET gpio low and wait for it to settle. */
	pr_info("Pulling RESET gpio low\n");
	gpio_direction_output(mdm_drv->ap2mdm_pmic_reset_n_gpio, 0);
	usleep_range(5000, 10000);

	/* Deassert RESET first and wait for ir to settle. */
	pr_info("%s: Pulling RESET gpio high\n", __func__);
	gpio_direction_output(mdm_drv->ap2mdm_pmic_reset_n_gpio, 1);
	msleep(20);

	/* Pull PWR gpio high and wait for it to settle, but only
	 * the first time the mdm is powered up.
	 * Some targets do not use ap2mdm_kpdpwr_n_gpio.
	 */
	if (power_on_count == 1) {
		if (mdm_drv->ap2mdm_kpdpwr_n_gpio > 0) {
			pr_debug("%s: Powering on mdm modem\n", __func__);
			gpio_direction_output(mdm_drv->ap2mdm_kpdpwr_n_gpio, 1);
			usleep_range(1000, 1000);
		}
	}

#ifdef CONFIG_ARCH_EXYNOS
	gpio_direction_output(mdm_drv->ap2mdm_status_gpio, 1);
#endif
	mdm_peripheral_connect(mdm_drv);

	msleep(200);
}
Exemplo n.º 17
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 (mdm_drv->ap2mdm_wakeup_gpio > 0) {
			if (gpio_get_value(mdm_drv->ap2mdm_wakeup_gpio)) {
				gpio_set_value(mdm_drv->ap2mdm_wakeup_gpio, 0);
				mdelay(5);
			}
			gpio_direction_output(mdm_drv->ap2mdm_wakeup_gpio, 1);
		}
	}
}
Exemplo n.º 18
0
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);
	}
}
Exemplo n.º 19
0
static void mdm_do_soft_power_on(struct mdm_modem_drv *mdm_drv)
{
	int soft_reset_direction =
		mdm_drv->pdata->soft_reset_inverted ? 0 : 1;

	/* De-assert the soft reset line. */
	pr_err("%s: soft resetting mdm modem\n", __func__);

	mdm_peripheral_disconnect(mdm_drv);

	gpio_direction_output(mdm_drv->ap2mdm_soft_reset_gpio,
		soft_reset_direction == 1 ? 0 : 1);
	usleep_range(5000, 10000);
	gpio_direction_output(mdm_drv->ap2mdm_soft_reset_gpio,
		soft_reset_direction == 1 ? 1 : 0);

	mdm_peripheral_connect(mdm_drv);
	msleep(200);
}
Exemplo n.º 20
0
static void mdm_power_down_common(struct mdm_modem_drv *mdm_drv)
{
	int i = 0;
	int soft_reset_direction =
		mdm_drv->pdata->soft_reset_inverted ? 1 : 0;

	mdm_peripheral_disconnect(mdm_drv);

#if 0	// because we don't use the graceful shutdown function, we don't need this checking
	/* Wait for the modem to complete its power down actions. */
	for (i = 20; i > 0; i--) {
		if (gpio_get_value(MDM_GPIO(MDM2AP_STATUS)) == 0) {
			if (mdm_debug_mask & MDM_DEBUG_MASK_SHDN_LOG)
				pr_debug("%s:id %d: mdm2ap_statuswent low, i=%d\n",
				__func__, mdm_drv->device_id, i);
			break;
		}
		msleep(100);
	}
#endif

	/* Assert the soft reset line whether mdm2ap_status went low or not */
	gpio_direction_output(MDM_GPIO(AP2MDM_SOFT_RESET), soft_reset_direction);
	if (i == 0) {
		pr_debug("%s:id %d: MDM2AP_STATUS never went low. Doing a hard reset\n",
			__func__, mdm_drv->device_id);
		gpio_direction_output(MDM_GPIO(AP2MDM_SOFT_RESET), soft_reset_direction);
	}
	/*
	* Currently, there is a debounce timer on the charm PMIC. It is
	* necessary to hold the PMIC RESET low for ~3.5 seconds
	* for the reset to fully take place. Sleep here to ensure the
	* reset has occured before the function exits.
	*/
	msleep(4000);
}
Exemplo n.º 21
0
static void mdm_power_down_common(struct mdm_modem_drv *mdm_drv)
{
	mdm_peripheral_disconnect(mdm_drv);
}
Exemplo n.º 22
0
Arquivo: mdm2.c Projeto: Arvoreen/ATnT
static void power_on_mdm(struct mdm_modem_drv *mdm_drv)
{
	int mfg_mode;
	pr_info("+power_on_mdm\n");

	mfg_mode = board_mfg_mode();

	if (mfg_mode == BOARD_MFG_MODE_OFFMODE_CHARGING) {
		pr_info("-power_on_mdm: offmode charging\n");
		return;
	}

	if (first_power_on) {
		pr_info("+power_on_mdm:add tegra_ehci2_device\n");
		platform_device_register(&tegra_ehci2_device);
	}
	else {
		pr_info("+power_on_mdm:mdm_peripheral_disconnect\n");
		mdm_peripheral_disconnect(mdm_drv);
		pr_info("+power_on_mdm:mdm_peripheral_connect\n");
		mdm_peripheral_connect(mdm_drv);
	}

	//++SSD_RIL: Mars_Lin@20120606: Print related GPIO setting
	mdm2_dump_mdm_related_gpio( mdm_drv, "Before power on" );
	//--SSD_RIL

	gpio_direction_output(mdm_drv->ap2mdm_wakeup_gpio, 0);
	tegra_gpio_enable(mdm_drv->ap2mdm_wakeup_gpio);
	gpio_set_value(mdm_drv->ap2mdm_wakeup_gpio, 0);

	//++SSD_RIL: Mars_Lin@20120606:Change J0 to TEGRA_PUPD_PULL_DOWN
	tegra_pinmux_set_pullupdown(gpio_to_pingroup[mdm_drv->mdm2ap_hsic_ready_gpio], TEGRA_PUPD_PULL_DOWN);
	//--SSD_RIL

	//++SSD_RIL: Mars_Lin@20120709: Set mdm_ready to 0 before power on mdm
	mdm_drv->mdm_ready = 0;
	//--SSD_RIL

	/* Pull RESET gpio low and wait for it to settle. */
	pr_info("%s: Pulling RESET gpio low\n", __func__);

	gpio_direction_output(mdm_drv->ap2mdm_pmic_reset_n_gpio, 0);	//TEGRA_GPIO_PP7
	tegra_gpio_enable(mdm_drv->ap2mdm_pmic_reset_n_gpio);
	gpio_set_value(mdm_drv->ap2mdm_pmic_reset_n_gpio, 0);

	usleep_range(5000, 10000);

	/* Deassert RESET first and wait for it to settle. */
	pr_info("%s: Pulling RESET gpio high\n", __func__);

	gpio_direction_output(mdm_drv->ap2mdm_pmic_reset_n_gpio, 1);
	tegra_gpio_enable(mdm_drv->ap2mdm_pmic_reset_n_gpio);
	gpio_set_value(mdm_drv->ap2mdm_pmic_reset_n_gpio, 1);

	msleep(40);

	//++SSD_RIL:20120705: pull ap2mdm_status GPIO to high
	gpio_direction_output(mdm_drv->ap2mdm_status_gpio, 1);
	//--SSD_RIL

	//++SSD_RIL: Mars_Lin@20120608: enable irq after power on mdm
	mdm_common_enable_irq(mdm_drv, MDM_MODEM_IRQ_ENABLE);
	//--SSD_RIL

	//++SSD_RIL: Mars_Lin@20120606:Change J0 to NO_PULL
	tegra_pinmux_set_pullupdown(gpio_to_pingroup[mdm_drv->mdm2ap_hsic_ready_gpio], TEGRA_PUPD_NORMAL);
	//--SSD_RIL

	msleep(40);

	/* Pull PWR gpio high and wait for it to settle, but only
	 * the first time the mdm is powered up.
	 * Some targets do not use ap2mdm_kpdpwr_n_gpio.
	 */
	if (first_power_on) {
		if (mdm_drv->ap2mdm_kpdpwr_n_gpio > 0) {
			int ret2;

			pr_info("%s: Powering on mdm modem:mdm_drv->ap2mdm_kpdpwr_n_gpio = (%d)\n", __func__,mdm_drv->ap2mdm_kpdpwr_n_gpio);
			ret2 = gpio_direction_output(mdm_drv->ap2mdm_kpdpwr_n_gpio, 1);
			if (ret2 < 0) {
				pr_err("%s: gpio_direction_output failed %d\n", __func__, ret2);
				gpio_free(mdm_drv->ap2mdm_kpdpwr_n_gpio);
				return;
			}
			tegra_gpio_enable(mdm_drv->ap2mdm_kpdpwr_n_gpio);
			gpio_set_value(mdm_drv->ap2mdm_kpdpwr_n_gpio, 1);

			udelay(1000);
		}
		first_power_on = 0;
	} else {
		//pr_info("+power_on_mdm:mdm_peripheral_connect\n");
		//mdm_peripheral_connect(mdm_drv);
	}
	msleep(200);
	pr_info("-power_on_mdm\n");
}
Exemplo n.º 23
0
static void power_on_mdm(struct mdm_modem_drv *mdm_drv)
{
	int hsic_ready_timeout_ms = 100;

	power_on_count++;

	/* The second attempt to power-on the mdm is the first attempt
	 * from user space, but we're already powered on. Ignore this.
	 * Subsequent attempts are from SSR or if something failed, in
	 * which case we must always reset the modem.
	 */
	if (power_on_count == 2)
		return;

	mdm_peripheral_disconnect(mdm_drv);

	/* Leakege might cause abnormal MDM status.
	   Output ap2mdm_status low to avoid leakege. */
	gpio_direction_output(mdm_drv->ap2mdm_status_gpio, 0);

	/* this gpio will be used to indicate apq readiness,
	 * de-assert it now so that it can asserted later
	 */
	gpio_direction_output(mdm_drv->ap2mdm_wakeup_gpio, 0);

	/* Pull RESET gpio low and wait for it to settle. */
	pr_debug("Pulling RESET gpio low\n");
	gpio_direction_output(mdm_drv->ap2mdm_pmic_reset_n_gpio, 0);

	usleep_range(5000, 10000);

	/* Deassert RESET first and wait for it to settle. */
	pr_debug("%s: Pulling RESET gpio high\n", __func__);
	gpio_direction_output(mdm_drv->ap2mdm_pmic_reset_n_gpio, 1);

	msleep(40);

	/* re-enable ap2mdm_status after mdm is ready.
	 *According to HW measurement, mdm takes abort 50ms to enter PBL
	 */
	gpio_direction_output(mdm_drv->ap2mdm_status_gpio, 1);

	/* QCT workaround: Keep the host HSIC in reset until the MDM9x15M has
           come out of reset. QCT has defined GPIO79(HSIC_DEVICE_READY) in
           the primany boot loader(PBL) to hold the host HSIC reset.
           HSIC_DEVUCE_READY will go high when the MDM9x15M device has powered
           up and is ready for HSIC enumeration. */
	while (!gpio_get_value(mdm_drv->mdm2ap_hsic_ready_gpio) && hsic_ready_timeout_ms>0) {
		msleep(10);
		hsic_ready_timeout_ms -= 10;
		pr_info("%s: waiting for MDM HSIC READY signal.\r\n", __func__);
	};
	if (!gpio_get_value(mdm_drv->mdm2ap_hsic_ready_gpio))
		pr_err("%s: MDM HSIC READY timeout!\r\n", __func__);

	mdm_peripheral_connect(mdm_drv);

	usleep(1000);

	/* Pull PWR gpio high and wait for it to settle, but only
	 * the first time the mdm is powered up.
	 * Some targets do not use ap2mdm_kpdpwr_n_gpio.
	 */
	if (power_on_count == 1) {
		if (mdm_drv->ap2mdm_kpdpwr_n_gpio > 0) {
			pr_debug("%s: Powering on mdm modem\n", __func__);
			gpio_direction_output(mdm_drv->ap2mdm_kpdpwr_n_gpio, 1);
			usleep(1000);
		}
	}

	msleep(200);
}
Exemplo n.º 24
0
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);
}
Exemplo n.º 25
0
static void mdm_do_first_power_on(struct mdm_modem_drv *mdm_drv)
{
	int i;
	int pblrdy;

	if (power_on_count != 1) {
		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__);
	gpio_direction_output(mdm_drv->ap2mdm_wakeup_gpio, 0);
	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 (mdm_drv->ap2mdm_kpdpwr_n_gpio > 0) {
		/* 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);
	}

	/* first power charged after 10ms */
	usleep_range(10000, 15000);
	gpio_direction_output(mdm_drv->ap2mdm_status_gpio, 1);

#ifdef CONFIG_HSIC_EURONLY_APPLY
	for (i = 0; i  < MDM_PBLRDY_CNT; i++) {
		pblrdy = gpio_get_value(mdm_drv->mdm2ap_pblrdy);
		if (pblrdy)
			break;
		usleep_range(5000, 5000);
	}

	pr_err("%s: i:%d\n", __func__, i);
#else
	if (!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);
#endif

start_mdm_peripheral:
	mdm_peripheral_connect(mdm_drv);
	msleep(200);
}
Exemplo n.º 26
0
static void normal_boot_done(struct mdm_modem_drv *mdm_drv)
{
	pr_err("%s\n", __func__);
	mdm_peripheral_disconnect(mdm_drv);
}