static int pm_do_sleep(ctl_table * ctl, int write, struct file *file, void *buffer, size_t * len) { int retval = 0; #ifdef SLEEP_TEST_TIMEOUT #define TMPBUFLEN2 16 char buf[TMPBUFLEN2], *p; #endif if (!write) { *len = 0; } else { #ifdef SLEEP_TEST_TIMEOUT if (*len > TMPBUFLEN2 - 1) { return -EFAULT; } if (copy_from_user(buf, buffer, *len)) { return -EFAULT; } buf[*len] = 0; p = buf; sleep_ticks = simple_strtoul(p, &p, 0); #endif retval = pm_send_all(PM_SUSPEND, (void *) 2); if (retval) return retval; au_sleep(); retval = pm_send_all(PM_RESUME, (void *) 0); } return retval; }
void au1000_halt(void) { #if defined(CONFIG_MIPS_PB1550) /* power off system */ printk("\n** Powering off Pb1550\n"); au_writew(au_readw(0xAF00001C) | (3<<14), 0xAF00001C); au_sync(); while(1); /* should not get here */ #endif printk(KERN_NOTICE "\n** You can safely turn off the power\n"); #ifdef CONFIG_MIPS_MIRAGE au_writel((1 << 26) | (1 << 10), GPIO2_OUTPUT); #endif #ifdef CONFIG_PM au_sleep(); /* should not get here */ printk(KERN_ERR "Unable to put cpu in sleep mode\n"); while(1); #else while (1) __asm__(".set\tmips3\n\t" "wait\n\t" ".set\tmips0"); #endif }
static int db1x_pm_enter(suspend_state_t state) { /* enable GPIO based wakeup */ au_writel(1, SYS_PININPUTEN); /* clear and setup wake cause and source */ au_writel(0, SYS_WAKEMSK); au_sync(); au_writel(0, SYS_WAKESRC); au_sync(); au_writel(db1x_pm_wakemsk, SYS_WAKEMSK); au_sync(); /* setup 1Hz-timer-based wakeup: wait for reg access */ while (au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_M20) asm volatile ("nop"); au_writel(au_readl(SYS_TOYREAD) + db1x_pm_sleep_secs, SYS_TOYMATCH2); au_sync(); /* wait for value to really hit the register */ while (au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_M20) asm volatile ("nop"); /* ...and now the sandman can come! */ au_sleep(); return 0; }
static int db1x_pm_enter(suspend_state_t state) { unsigned short bcsrs[16]; int i, j, hasint; /* save CPLD regs */ hasint = bcsr_read(BCSR_WHOAMI); hasint = BCSR_WHOAMI_BOARD(hasint) >= BCSR_WHOAMI_DB1200; j = (hasint) ? BCSR_MASKSET : BCSR_SYSTEM; for (i = BCSR_STATUS; i <= j; i++) bcsrs[i] = bcsr_read(i); /* shut off hexleds */ bcsr_write(BCSR_HEXCLEAR, 3); /* enable GPIO based wakeup */ alchemy_gpio1_input_enable(); /* clear and setup wake cause and source */ alchemy_wrsys(0, AU1000_SYS_WAKEMSK); alchemy_wrsys(0, AU1000_SYS_WAKESRC); alchemy_wrsys(db1x_pm_wakemsk, AU1000_SYS_WAKEMSK); /* setup 1Hz-timer-based wakeup: wait for reg access */ while (alchemy_rdsys(AU1000_SYS_CNTRCTRL) & SYS_CNTRL_M20) asm volatile ("nop"); alchemy_wrsys(alchemy_rdsys(AU1000_SYS_TOYREAD) + db1x_pm_sleep_secs, AU1000_SYS_TOYMATCH2); /* wait for value to really hit the register */ while (alchemy_rdsys(AU1000_SYS_CNTRCTRL) & SYS_CNTRL_M20) asm volatile ("nop"); /* ...and now the sandman can come! */ au_sleep(); /* restore CPLD regs */ for (i = BCSR_STATUS; i <= BCSR_SYSTEM; i++) bcsr_write(i, bcsrs[i]); /* restore CPLD int registers */ if (hasint) { bcsr_write(BCSR_INTCLR, 0xffff); bcsr_write(BCSR_MASKCLR, 0xffff); bcsr_write(BCSR_INTSTAT, 0xffff); bcsr_write(BCSR_INTSET, bcsrs[BCSR_INTSET]); bcsr_write(BCSR_MASKSET, bcsrs[BCSR_MASKSET]); } /* light up hexleds */ bcsr_write(BCSR_HEXCLEAR, 0); return 0; }
void au1000_halt(void) { printk(KERN_NOTICE "\n** You can safely turn off the power\n"); #ifdef CONFIG_PM au_sleep(); /* should not get here */ printk(KERN_ERR "Unable to put cpu in sleep mode\n"); while(1); #else while (1) __asm__(".set\tmips3\n\t" "wait\n\t" ".set\tmips0"); #endif }