static void power_down(suspend_disk_method_t mode) { unsigned long flags; int error = 0; local_irq_save(flags); switch(mode) { case PM_DISK_PLATFORM: device_power_down(PM_SUSPEND_DISK); error = pm_ops->enter(PM_SUSPEND_DISK); break; case PM_DISK_SHUTDOWN: printk("Powering off system\n"); device_shutdown(); machine_power_off(); break; case PM_DISK_REBOOT: device_shutdown(); machine_restart(NULL); break; } machine_halt(); /* Valid image is on the disk, if we continue we risk serious data corruption after resume. */ printk(KERN_CRIT "Please power me down manually\n"); while(1); }
static irqreturn_t dsmg600_reset_handler(int irq, void *dev_id) { /* This is the paper-clip reset, it shuts the machine down directly. */ machine_power_off(); return IRQ_HANDLED; }
static int pcwd_get_status(int *status) { int card_status; *status=0; spin_lock(&io_lock); if (revision == PCWD_REVISION_A) /* Rev A cards return status information from * the base register, which is used for the * temperature in other cards. */ card_status = inb(current_readport); else { /* Rev C cards return card status in the base * address + 1 register. And use different bits * to indicate a card initiated reset, and an * over-temperature condition. And the reboot * status can be reset. */ card_status = inb(current_readport + 1); } spin_unlock(&io_lock); if (revision == PCWD_REVISION_A) { if (card_status & WD_WDRST) *status |= WDIOF_CARDRESET; if (card_status & WD_T110) { *status |= WDIOF_OVERHEAT; if (temp_panic) { printk (KERN_INFO PFX "Temperature overheat trip!\n"); machine_power_off(); } } } else { if (card_status & WD_REVC_WTRP) *status |= WDIOF_CARDRESET; if (card_status & WD_REVC_TTRP) { *status |= WDIOF_OVERHEAT; if (temp_panic) { printk (KERN_INFO PFX "Temperature overheat trip!\n"); machine_power_off(); } } } return 0; }
static irqreturn_t nslu2_reset_handler(int irq, void *dev_id) { /* */ machine_power_off(); return IRQ_HANDLED; }
static void deferred_poweroff(void *dummy) { extern int cad_pid; /* from kernel/sys.c */ if (kill_proc(cad_pid, SIGINT, 1)) { /* just in case killing init process failed */ machine_power_off(); } }
/** * kernel_power_off - power_off the system * * Shutdown everything and perform a clean system power_off. */ void kernel_power_off(void) { kernel_shutdown_prepare(SYSTEM_POWER_OFF); if (pm_power_off_prepare) pm_power_off_prepare(); disable_nonboot_cpus(); sysdev_shutdown(); printk(KERN_EMERG "Power down.\n"); machine_power_off(); }
/****************************************************************************** * * * BOOL cmdHalt(char *args, int subClass) * * * ******************************************************************************* * * Powers computer off * ******************************************************************************/ BOOL cmdHalt(char *args, int subClass) { // Use APM power off: machine_power_off(); // If that fails, we hboot-it machine_restart(NULL); return( TRUE ); }
/** * kernel_power_off - power_off the system * * Shutdown everything and perform a clean system power_off. */ void kernel_power_off(void) { kernel_shutdown_prepare(SYSTEM_POWER_OFF); if (pm_power_off_prepare) pm_power_off_prepare(); migrate_to_reboot_cpu(); syscore_shutdown(); pr_emerg("Power down\n"); kmsg_dump(KMSG_DUMP_POWEROFF); machine_power_off(); }
/** * @Copyright (C) Anyka 2012 * @brief quickly power off system * @author Gao wangsheng * @email [email protected] * @date 2012-11-2 * @param[out] void * @param[in] *battery * @return void */ static void check_machine_power_off(struct ak_bat *battery) { struct ak_bat_mach_info *info = get_bat_platform_data(battery); if ((poweroff_enable == info->bat_mach_info.power_off) && (POWER_SUPPLY_STATUS_DISCHARGING == battery->status) && (battery->voltage <= info->bat_mach_info.min_voltage)) { printk("battery:voltage=%d,machine power off immediately!\n",battery->voltage); machine_power_off(); } }
static int mtk_cl_kshutdown_set_cur_state(struct thermal_cooling_device *cdev, unsigned long state) { /* mtk_cooler_kshutdown_dprintk("mtk_cl_kshutdown_set_cur_state() %s %d\n", cdev->type, state); */ #if 1 *((unsigned long *)cdev->devdata) = state; #else cl_kshutdown_state[(int)cdev->type[16]] = state; #endif if (1 == state) { mtk_cooler_kshutdown_dprintk("%s %s invokes machine_power_off\n", __func__, cdev->type); machine_power_off(); } return 0; }
static inline void power_button(void) { if (has_paniced) return; if (shuting_down || kill_proc(1, SIGINT, 1)) { /* No init process or button pressed twice. */ machine_power_off(); } shuting_down = 1; blink_timer.data = POWERDOWN_FREQ; blink_timeout(POWERDOWN_FREQ); init_timer(&power_timer); power_timer.function = power_timeout; power_timer.expires = jiffies + POWERDOWN_TIMEOUT * HZ; add_timer(&power_timer); }
static irqreturn_t n2pb_handler (int irq, void *dev_id, struct pt_regs *regs) { void *ret; wake_up(&n2pb_waitq); remove_proc_entry(PWR_OFF_STR, NULL); //no parent n2_buzz(N2_BEEP_PITCH_MED, N2_BEEP_DUR_MED); ret = create_proc_entry(PWR_OFF_STR, 0, NULL); nslu2_io_debug((KERN_DEBUG "cpe ret = %p\n", ret)); // WARNING: This is RUDE...it unconditionally pulls the power plug. // Your data will be at risk...since this is just a test system // I am leaving it enabled...eventually userland needs to get the // message, do an orderly shutdown and use an ioctl or something in // /proc/powerdowm to actually have us pull the plug. machine_power_off(); return IRQ_HANDLED; }
static void suspend_power_down(void) { extern int C_A_D; C_A_D = 0; printk(KERN_EMERG "%s%s Trying to power down.\n", name_suspend, TEST_SWSUSP ? "Disable TEST_SWSUSP. NOT ": ""); #ifdef CONFIG_VT PRINTK(KERN_EMERG "shift_state: %04x\n", shift_state); mdelay(1000); if (TEST_SWSUSP ^ (!!(shift_state & (1 << KG_CTRL)))) machine_restart(NULL); else #endif { device_shutdown(); machine_power_off(); } printk(KERN_EMERG "%sProbably not capable for powerdown. System halted.\n", name_suspend); machine_halt(); while (1); /* NOTREACHED */ }
int32_t pm8xxx_adc_scale_batt_therm(int32_t adc_code, const struct pm8xxx_adc_properties *adc_properties, const struct pm8xxx_adc_chan_properties *chan_properties, struct pm8xxx_adc_chan_result *adc_chan_result) { int64_t bat_voltage = 0; struct pm8xxx_adc_map_pt *adc_map = NULL; uint32_t adc_map_array_size; unsigned int phaseid = 0; bat_voltage = pm8xxx_adc_scale_ratiometric_calib(adc_code, adc_properties, chan_properties); ext_bat_voltage = bat_voltage; if (ext_bat_voltage > 1700) { pr_err("[chg %s %d]ERROR!! Battery removed %lld", __func__, __LINE__, ext_bat_voltage); machine_power_off(); } if (phaseid == 0) phaseid = fih_get_product_phase(); if (phaseid <= PHASE_SP) { adc_map = adcmap_btm_threshold; adc_map_array_size = ARRAY_SIZE(adcmap_btm_threshold); } else { adc_map = adcmap_btm_threshold_pre_ap; adc_map_array_size = ARRAY_SIZE(adcmap_btm_threshold_pre_ap); } return pm8xxx_adc_map_batt_therm( adc_map, adc_map_array_size, bat_voltage, &adc_chan_result->physical); }
static int power_down(u32 mode) { unsigned long flags; int error = 0; local_irq_save(flags); device_power_down(PM_SUSPEND_DISK); switch(mode) { case PM_DISK_PLATFORM: error = pm_ops->enter(PM_SUSPEND_DISK); break; case PM_DISK_SHUTDOWN: printk("Powering off system\n"); machine_power_off(); break; case PM_DISK_REBOOT: machine_restart(NULL); break; } machine_halt(); device_power_up(); local_irq_restore(flags); return 0; }
void kernel_power_off(void) { kernel_power_off_prepare(); printk(KERN_EMERG "Power down.\n"); machine_power_off(); }
/* * Reboot system call: for obvious reasons only root may call it, * and even root needs to set up some magic numbers in the registers * so that some mistake won't make this reboot the whole machine. * You can also set the meaning of the ctrl-alt-del-key here. * * reboot doesn't sync: do that yourself before calling this. */ asmlinkage long sys_reboot(int magic1, int magic2, unsigned int cmd, void * arg) { char buffer[256]; /* We only trust the superuser with rebooting the system. */ if (!capable(CAP_SYS_BOOT)) return -EPERM; /* For safety, we require "magic" arguments. */ if (magic1 != LINUX_REBOOT_MAGIC1 || (magic2 != LINUX_REBOOT_MAGIC2 && magic2 != LINUX_REBOOT_MAGIC2A && magic2 != LINUX_REBOOT_MAGIC2B)) return -EINVAL; lock_kernel(); switch (cmd) { case LINUX_REBOOT_CMD_RESTART: notifier_call_chain(&reboot_notifier_list, SYS_RESTART, NULL); printk(KERN_EMERG "Restarting system.\n"); machine_restart(NULL); break; case LINUX_REBOOT_CMD_CAD_ON: C_A_D = 1; break; case LINUX_REBOOT_CMD_CAD_OFF: C_A_D = 0; break; case LINUX_REBOOT_CMD_HALT: notifier_call_chain(&reboot_notifier_list, SYS_HALT, NULL); printk(KERN_EMERG "System halted.\n"); machine_halt(); do_exit(0); break; case LINUX_REBOOT_CMD_POWER_OFF: notifier_call_chain(&reboot_notifier_list, SYS_POWER_OFF, NULL); printk(KERN_EMERG "Power down.\n"); machine_power_off(); do_exit(0); break; case LINUX_REBOOT_CMD_RESTART2: if (strncpy_from_user(&buffer[0], (char *)arg, sizeof(buffer) - 1) < 0) { unlock_kernel(); return -EFAULT; } buffer[sizeof(buffer) - 1] = '\0'; notifier_call_chain(&reboot_notifier_list, SYS_RESTART, buffer); printk(KERN_EMERG "Restarting system with command '%s'.\n", buffer); machine_restart(buffer); break; default: unlock_kernel(); return -EINVAL; } unlock_kernel(); return 0; }
/* XXX How to pass the reboot command to the firmware??? */ void machine_restart(char *command) { if (shuting_down) machine_power_off(); ArcReboot(); }
static irqreturn_t dt2_power_handler(int irq, void *dev_id) { printk(KERN_INFO "Shutting down system.\n"); machine_power_off(); return IRQ_HANDLED; }
void machine_halt(void) { if (shuting_down) machine_power_off(); ArcEnterInteractiveMode(); }
/* * Reboot system call: for obvious reasons only root may call it, * and even root needs to set up some magic numbers in the registers * so that some mistake won't make this reboot the whole machine. * You can also set the meaning of the ctrl-alt-del-key here. * * reboot doesn't sync: do that yourself before calling this. */ asmlinkage long sys_reboot(int magic1, int magic2, unsigned int cmd, void * arg) { char buffer[256]; /* We only trust the superuser with rebooting the system. */ if (!capable(CAP_SYS_BOOT)) return -EPERM; /* For safety, we require "magic" arguments. */ if (magic1 != LINUX_REBOOT_MAGIC1 || (magic2 != LINUX_REBOOT_MAGIC2 && magic2 != LINUX_REBOOT_MAGIC2A && magic2 != LINUX_REBOOT_MAGIC2B)) return -EINVAL; #ifdef CONFIG_ARCH_EZXBASE /* must be sync with include/linux/moto_accy.h */ #define ACCS_REBOOT (1 << MOTO_ACCY_TYPE_CHARGER_MID | \ 1 << MOTO_ACCY_TYPE_CHARGER_MID_MPX | \ 1 << MOTO_ACCY_TYPE_CHARGER_FAST | \ 1 << MOTO_ACCY_TYPE_CHARGER_FAST_MPX | \ 1 << MOTO_ACCY_TYPE_CHARGER_FAST_3G | \ 1 << MOTO_ACCY_TYPE_CARKIT_MID | \ 1 << MOTO_ACCY_TYPE_CARKIT_FAST | \ 1 << MOTO_ACCY_TYPE_CARKIT_SMART) #define FACTORY_REBOOT (1 << MOTO_ACCY_TYPE_CABLE_FACTORY) MOTO_ACCY_MASK_T mask = (MOTO_ACCY_MASK_T)moto_accy_get_all_devices(); if (LINUX_REBOOT_CMD_RESTART == cmd) { if (mask & FACTORY_REBOOT) { *(unsigned long *)(phys_to_virt(FLAG_ADDR)) = FACTORY_REBOOT_FLAG; } else { *(unsigned long *)(phys_to_virt(FLAG_ADDR)) = APP_REBOOT_FLAG; } } if (LINUX_REBOOT_CMD_POWER_OFF == cmd) { if (mask & ACCS_REBOOT) { *(unsigned long *)(phys_to_virt(FLAG_ADDR)) = CHARGE_FLAG; cmd = LINUX_REBOOT_CMD_RESTART; printk(KERN_EMERG "Change to reboot mode.\n"); } } #endif lock_kernel(); switch (cmd) { case LINUX_REBOOT_CMD_RESTART: notifier_call_chain(&reboot_notifier_list, SYS_RESTART, NULL); #ifdef CONFIG_KFI kfi_dump_log(NULL); #endif printk(KERN_EMERG "Restarting system.\n"); machine_restart(NULL); break; case LINUX_REBOOT_CMD_CAD_ON: C_A_D = 1; break; case LINUX_REBOOT_CMD_CAD_OFF: C_A_D = 0; break; case LINUX_REBOOT_CMD_HALT: notifier_call_chain(&reboot_notifier_list, SYS_HALT, NULL); #ifdef CONFIG_KFI kfi_dump_log(NULL); #endif printk(KERN_EMERG "System halted.\n"); machine_halt(); do_exit(0); break; case LINUX_REBOOT_CMD_POWER_OFF: notifier_call_chain(&reboot_notifier_list, SYS_POWER_OFF, NULL); #ifdef CONFIG_KFI kfi_dump_log(NULL); #endif printk(KERN_EMERG "Power down.\n"); machine_power_off(); do_exit(0); break; case LINUX_REBOOT_CMD_RESTART2: if (strncpy_from_user(&buffer[0], (char *)arg, sizeof(buffer) - 1) < 0) { unlock_kernel(); return -EFAULT; } buffer[sizeof(buffer) - 1] = '\0'; notifier_call_chain(&reboot_notifier_list, SYS_RESTART, buffer); printk(KERN_EMERG "Restarting system with command '%s'.\n", buffer); #ifdef CONFIG_KFI kfi_dump_log(NULL); #endif machine_restart(buffer); break; default: unlock_kernel(); return -EINVAL; } unlock_kernel(); return 0; }
static void power_timeout(unsigned long data) { machine_power_off(); }
void machine_halt(void) { machine_power_off(); }
/** * kernel_power_off - power_off the system * * Shutdown everything and perform a clean system power_off. */ void kernel_power_off(void) { kernel_shutdown_prepare(SYSTEM_POWER_OFF); printk(KERN_EMERG "Power down.\n"); machine_power_off(); }
static int cpu_check_overtemp(s32 temp) { int new_state = 0; s32 t_avg, t_old; static bool first = true; /* First check for immediate overtemps */ if (temp >= (cpu_all_tmax + LOW_OVER_IMMEDIATE)) { new_state |= FAILURE_LOW_OVERTEMP; if ((failure_state & FAILURE_LOW_OVERTEMP) == 0) printk(KERN_ERR "windfarm: Overtemp due to immediate CPU" " temperature !\n"); } if (temp >= (cpu_all_tmax + HIGH_OVER_IMMEDIATE)) { new_state |= FAILURE_HIGH_OVERTEMP; if ((failure_state & FAILURE_HIGH_OVERTEMP) == 0) printk(KERN_ERR "windfarm: Critical overtemp due to" " immediate CPU temperature !\n"); } /* * The first time around, initialize the array with the first * temperature reading */ if (first) { int i; cpu_thist_total = 0; for (i = 0; i < CPU_TEMP_HIST_SIZE; i++) { cpu_thist[i] = temp; cpu_thist_total += temp; } first = false; } /* * We calculate a history of max temperatures and use that for the * overtemp management */ t_old = cpu_thist[cpu_thist_pt]; cpu_thist[cpu_thist_pt] = temp; cpu_thist_pt = (cpu_thist_pt + 1) % CPU_TEMP_HIST_SIZE; cpu_thist_total -= t_old; cpu_thist_total += temp; t_avg = cpu_thist_total / CPU_TEMP_HIST_SIZE; DBG_LOTS(" t_avg = %d.%03d (out: %d.%03d, in: %d.%03d)\n", FIX32TOPRINT(t_avg), FIX32TOPRINT(t_old), FIX32TOPRINT(temp)); /* Now check for average overtemps */ if (t_avg >= (cpu_all_tmax + LOW_OVER_AVERAGE)) { new_state |= FAILURE_LOW_OVERTEMP; if ((failure_state & FAILURE_LOW_OVERTEMP) == 0) printk(KERN_ERR "windfarm: Overtemp due to average CPU" " temperature !\n"); } if (t_avg >= (cpu_all_tmax + HIGH_OVER_AVERAGE)) { new_state |= FAILURE_HIGH_OVERTEMP; if ((failure_state & FAILURE_HIGH_OVERTEMP) == 0) printk(KERN_ERR "windfarm: Critical overtemp due to" " average CPU temperature !\n"); } /* Now handle overtemp conditions. We don't currently use the windfarm * overtemp handling core as it's not fully suited to the needs of those * new machine. This will be fixed later. */ if (new_state) { /* High overtemp -> immediate shutdown */ if (new_state & FAILURE_HIGH_OVERTEMP) machine_power_off(); if ((failure_state & new_state) != new_state) cpu_max_all_fans(); failure_state |= new_state; } else if ((failure_state & FAILURE_LOW_OVERTEMP) && (temp < (cpu_all_tmax + LOW_OVER_CLEAR))) { printk(KERN_ERR "windfarm: Overtemp condition cleared !\n"); failure_state &= ~FAILURE_LOW_OVERTEMP; } return failure_state & (FAILURE_LOW_OVERTEMP | FAILURE_HIGH_OVERTEMP); }