11da177e4SLinus Torvalds /* 21da177e4SLinus Torvalds * SA1100 Power Management Routines 31da177e4SLinus Torvalds * 41da177e4SLinus Torvalds * Copyright (c) 2001 Cliff Brake <cbrake@accelent.com> 51da177e4SLinus Torvalds * 61da177e4SLinus Torvalds * This program is free software; you can redistribute it and/or 71da177e4SLinus Torvalds * modify it under the terms of the GNU General Public License. 81da177e4SLinus Torvalds * 91da177e4SLinus Torvalds * History: 101da177e4SLinus Torvalds * 111da177e4SLinus Torvalds * 2001-02-06: Cliff Brake Initial code 121da177e4SLinus Torvalds * 131da177e4SLinus Torvalds * 2001-02-25: Sukjae Cho <sjcho@east.isi.edu> & 141da177e4SLinus Torvalds * Chester Kuo <chester@linux.org.tw> 151da177e4SLinus Torvalds * Save more value for the resume function! Support 161da177e4SLinus Torvalds * Bitsy/Assabet/Freebird board 171da177e4SLinus Torvalds * 182f82af08SNicolas Pitre * 2001-08-29: Nicolas Pitre <nico@fluxnic.net> 191da177e4SLinus Torvalds * Cleaned up, pushed platform dependent stuff 201da177e4SLinus Torvalds * in the platform specific files. 211da177e4SLinus Torvalds * 221da177e4SLinus Torvalds * 2002-05-27: Nicolas Pitre Killed sleep.h and the kmalloced save array. 231da177e4SLinus Torvalds * Storage is local on the stack now. 241da177e4SLinus Torvalds */ 251da177e4SLinus Torvalds #include <linux/init.h> 26*3169663aSRussell King #include <linux/io.h> 271da177e4SLinus Torvalds #include <linux/suspend.h> 281da177e4SLinus Torvalds #include <linux/errno.h> 291da177e4SLinus Torvalds #include <linux/time.h> 301da177e4SLinus Torvalds 31a09e64fbSRussell King #include <mach/hardware.h> 321da177e4SLinus Torvalds #include <asm/memory.h> 332c74a0ceSRussell King #include <asm/suspend.h> 341da177e4SLinus Torvalds #include <asm/mach/time.h> 351da177e4SLinus Torvalds 3629cb3cd2SRussell King extern int sa1100_finish_suspend(unsigned long); 371da177e4SLinus Torvalds 381da177e4SLinus Torvalds #define SAVE(x) sleep_save[SLEEP_SAVE_##x] = x 391da177e4SLinus Torvalds #define RESTORE(x) x = sleep_save[SLEEP_SAVE_##x] 401da177e4SLinus Torvalds 411da177e4SLinus Torvalds /* 421da177e4SLinus Torvalds * List of global SA11x0 peripheral registers to preserve. 431da177e4SLinus Torvalds * More ones like CP and general purpose register values are preserved 441da177e4SLinus Torvalds * on the stack and then the stack pointer is stored last in sleep.S. 451da177e4SLinus Torvalds */ 46649de51bSRobert Jarzmik enum { SLEEP_SAVE_GPDR, SLEEP_SAVE_GAFR, 471da177e4SLinus Torvalds SLEEP_SAVE_PPDR, SLEEP_SAVE_PPSR, SLEEP_SAVE_PPAR, SLEEP_SAVE_PSDR, 481da177e4SLinus Torvalds 491da177e4SLinus Torvalds SLEEP_SAVE_Ser1SDCR0, 501da177e4SLinus Torvalds 51649de51bSRobert Jarzmik SLEEP_SAVE_COUNT 521da177e4SLinus Torvalds }; 531da177e4SLinus Torvalds 541da177e4SLinus Torvalds 551da177e4SLinus Torvalds static int sa11x0_pm_enter(suspend_state_t state) 561da177e4SLinus Torvalds { 57649de51bSRobert Jarzmik unsigned long gpio, sleep_save[SLEEP_SAVE_COUNT]; 581da177e4SLinus Torvalds 591da177e4SLinus Torvalds gpio = GPLR; 601da177e4SLinus Torvalds 611da177e4SLinus Torvalds /* save vital registers */ 621da177e4SLinus Torvalds SAVE(GPDR); 631da177e4SLinus Torvalds SAVE(GAFR); 641da177e4SLinus Torvalds 651da177e4SLinus Torvalds SAVE(PPDR); 661da177e4SLinus Torvalds SAVE(PPSR); 671da177e4SLinus Torvalds SAVE(PPAR); 681da177e4SLinus Torvalds SAVE(PSDR); 691da177e4SLinus Torvalds 701da177e4SLinus Torvalds SAVE(Ser1SDCR0); 711da177e4SLinus Torvalds 721da177e4SLinus Torvalds /* Clear previous reset status */ 731da177e4SLinus Torvalds RCSR = RCSR_HWR | RCSR_SWR | RCSR_WDR | RCSR_SMR; 741da177e4SLinus Torvalds 751da177e4SLinus Torvalds /* set resume return address */ 7696c20015SRussell King PSPR = virt_to_phys(cpu_resume); 771da177e4SLinus Torvalds 781da177e4SLinus Torvalds /* go zzz */ 792c74a0ceSRussell King cpu_suspend(0, sa1100_finish_suspend); 801da177e4SLinus Torvalds 811da177e4SLinus Torvalds /* 821da177e4SLinus Torvalds * Ensure not to come back here if it wasn't intended 831da177e4SLinus Torvalds */ 841da177e4SLinus Torvalds PSPR = 0; 851da177e4SLinus Torvalds 861da177e4SLinus Torvalds /* 871da177e4SLinus Torvalds * Ensure interrupt sources are disabled; we will re-init 881da177e4SLinus Torvalds * the interrupt subsystem via the device manager. 891da177e4SLinus Torvalds */ 901da177e4SLinus Torvalds ICLR = 0; 911da177e4SLinus Torvalds ICCR = 1; 921da177e4SLinus Torvalds ICMR = 0; 931da177e4SLinus Torvalds 941da177e4SLinus Torvalds /* restore registers */ 951da177e4SLinus Torvalds RESTORE(GPDR); 961da177e4SLinus Torvalds RESTORE(GAFR); 971da177e4SLinus Torvalds 981da177e4SLinus Torvalds RESTORE(PPDR); 991da177e4SLinus Torvalds RESTORE(PPSR); 1001da177e4SLinus Torvalds RESTORE(PPAR); 1011da177e4SLinus Torvalds RESTORE(PSDR); 1021da177e4SLinus Torvalds 1031da177e4SLinus Torvalds RESTORE(Ser1SDCR0); 1041da177e4SLinus Torvalds 1051da177e4SLinus Torvalds GPSR = gpio; 1061da177e4SLinus Torvalds GPCR = ~gpio; 1071da177e4SLinus Torvalds 1081da177e4SLinus Torvalds /* 1091da177e4SLinus Torvalds * Clear the peripheral sleep-hold bit. 1101da177e4SLinus Torvalds */ 1111da177e4SLinus Torvalds PSSR = PSSR_PH; 1121da177e4SLinus Torvalds 1131da177e4SLinus Torvalds return 0; 1141da177e4SLinus Torvalds } 1151da177e4SLinus Torvalds 1162f55ac07SLionel Debroux static const struct platform_suspend_ops sa11x0_pm_ops = { 1171da177e4SLinus Torvalds .enter = sa11x0_pm_enter, 11826398a70SRafael J. Wysocki .valid = suspend_valid_only_mem, 1191da177e4SLinus Torvalds }; 1201da177e4SLinus Torvalds 1217fea1ba5SShawn Guo int __init sa11x0_pm_init(void) 1221da177e4SLinus Torvalds { 12326398a70SRafael J. Wysocki suspend_set_ops(&sa11x0_pm_ops); 1241da177e4SLinus Torvalds return 0; 1251da177e4SLinus Torvalds } 126