void mot_system_power_off(void) { /* If there's external power, let's restart instead ... except for the case when phone was powered on with factory cable and thus has to stay powered off after Turn-Off TCMD INKVSSW-994 */ #ifdef CONFIG_REGULATOR_CPCAP #ifdef CONFIG_BOOTINFO if (cpcap_misc_is_ext_power() && !((bi_powerup_reason() & PWRUP_FACTORY_CABLE) && (bi_powerup_reason() != PWRUP_INVALID)) ) #else if (cpcap_misc_is_ext_power()) #endif { printk("External power detected- rebooting\r\n"); cpcap_misc_clear_power_handoff_info(); tegra_machine_restart(0,""); while(1); } #endif printk(KERN_ERR "%s(): Powering down system\n", __func__); /* Disable RTC alarms to prevent unwanted powerups */ class_for_each_device(rtc_class, NULL, NULL, disable_rtc_alarms); #ifdef CONFIG_REGULATOR_CPCAP /* Disable powercut detection before power off */ cpcap_disable_powercut(); #endif /* We need to set the WDI bit low to power down normally */ if (HWREV_TYPE_IS_PORTABLE(system_rev) && HWREV_REV(system_rev) >= HWREV_REV_1 && HWREV_REV(system_rev) <= HWREV_REV_1C ) { /* Olympus P1 */ gpio_request(TEGRA_GPIO_PT4, "P1 WDI"); gpio_direction_output(TEGRA_GPIO_PT4, 1); gpio_set_value(TEGRA_GPIO_PT4, 0); } else { /* Olympus Mortable, P0, P2 and later */ gpio_request(TEGRA_GPIO_PV7, "P2 WDI"); gpio_direction_output(TEGRA_GPIO_PV7, 1); gpio_set_value(TEGRA_GPIO_PV7, 0); } mdelay(500); printk("Power-off failed (Factory cable inserted?), rebooting\r\n"); tegra_machine_restart(0,""); }
void mot_system_power_off(void) { /* If there's external power, let's restart instead ... except for the case when phone was powered on with factory cable and thus has to stay powered off after Turn-Off TCMD INKVSSW-994 */ if (cpcap_misc_is_ext_power() && !((bi_powerup_reason() & PWRUP_FACTORY_CABLE) && (bi_powerup_reason() != PWRUP_INVALID)) ) { printk("External power detected- rebooting\r\n"); cpcap_misc_clear_power_handoff_info(); tegra_machine_restart(0,""); while(1); } printk(KERN_ERR "%s(): Powering down system\n", __func__); /* Disable RTC alarms to prevent unwanted powerups */ class_for_each_device(rtc_class, NULL, NULL, disable_rtc_alarms); /* Disable powercut detection before power off */ cpcap_disable_powercut(); /* We need to set the WDI bit low to power down normally */ if (machine_is_olympus()) { if (HWREV_TYPE_IS_PORTABLE(system_rev) && HWREV_REV(system_rev) >= HWREV_REV_1 && HWREV_REV(system_rev) <= HWREV_REV_1C ) { /* Olympus P1 */ gpio_request(TEGRA_GPIO_PT4, "P1 WDI"); gpio_direction_output(TEGRA_GPIO_PT4, 1); gpio_set_value(TEGRA_GPIO_PT4, 0); } else { /* Olympus Mortable, P0, P2 and later */ gpio_request(TEGRA_GPIO_PV7, "P2 WDI"); gpio_direction_output(TEGRA_GPIO_PV7, 1); gpio_set_value(TEGRA_GPIO_PV7, 0); } } else if (machine_is_etna()) { if ( HWREV_TYPE_IS_BRASSBOARD(system_rev) && HWREV_REV(system_rev) == HWREV_REV_1 ) { // Etna S1 gpio_request(TEGRA_GPIO_PK4, "S1 WDI"); gpio_direction_output(TEGRA_GPIO_PK4, 1); gpio_set_value(TEGRA_GPIO_PK4, 0); } else { // Etna S2, P1 and later gpio_request(TEGRA_GPIO_PT4, "S2 WDI"); gpio_direction_output(TEGRA_GPIO_PT4, 1); gpio_set_value(TEGRA_GPIO_PT4, 0); /* Etna P1B-P3C has a gate on WDI */ if ( machine_is_etna() && ( HWREV_TYPE_IS_PORTABLE(system_rev) && ( HWREV_REV(system_rev) >= HWREV_REV_1B && HWREV_REV(system_rev) < HWREV_REV_4 ))) cpcap_set_wdigate(0); } } else if (machine_is_tegra_daytona()) { gpio_request(TEGRA_GPIO_PV7, "P2 WDI"); gpio_direction_output(TEGRA_GPIO_PV7, 1); gpio_set_value(TEGRA_GPIO_PV7, 0); } else if (machine_is_sunfire()) { gpio_request(TEGRA_GPIO_PT4, "S2 WDI"); gpio_direction_output(TEGRA_GPIO_PT4, 1); gpio_set_value(TEGRA_GPIO_PT4, 0); cpcap_set_wdigate(0); } else { printk(KERN_ERR "Could not poweroff. Unkown hardware revision: 0x%x\n", system_rev); } mdelay(500); printk("Power-off failed (Factory cable inserted?), rebooting\r\n"); tegra_machine_restart(0,""); }