1 diff -NurbwB linux-2.6.17/arch/arm/mach-pxa/pm.c linux-2.6.17-patched/arch/arm/mach-pxa/pm.c
2 --- linux-2.6.17/arch/arm/mach-pxa/pm.c 2006-06-17 18:49:35.000000000 -0700
3 +++ linux-2.6.17-patched/arch/arm/mach-pxa/pm.c 2006-09-11 10:58:41.000000000 -0700
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License.
9 #include <linux/config.h>
10 #include <linux/init.h>
11 -#include <linux/module.h>
12 -#include <linux/suspend.h>
13 +#include <linux/pm.h>
14 +#include <linux/slab.h>
15 +#include <linux/sched.h>
16 +#include <linux/interrupt.h>
17 +#include <linux/sysctl.h>
18 #include <linux/errno.h>
19 -#include <linux/time.h>
21 #include <asm/hardware.h>
22 #include <asm/memory.h>
23 #include <asm/system.h>
24 -#include <asm/arch/pm.h>
25 +#include <asm/leds.h>
26 +#include <asm/uaccess.h>
27 #include <asm/arch/pxa-regs.h>
28 #include <asm/arch/lubbock.h>
29 #include <asm/mach/time.h>
32 +#include <linux/module.h>
35 +#include <linux/delay.h>
44 +extern void pxa_cpu_suspend(void);
45 +extern void pxa_cpu_resume(void);
48 +/*Angelia Additions */
50 +EXPORT_SYMBOL(pm_pwronoff);
51 +EXPORT_SYMBOL(pm_pedr);
54 #define SAVE(x) sleep_save[SLEEP_SAVE_##x] = x
55 #define RESTORE(x) x = sleep_save[SLEEP_SAVE_##x]
57 -#define RESTORE_GPLEVEL(n) do { \
58 - GPSR##n = sleep_save[SLEEP_SAVE_GPLR##n]; \
59 - GPCR##n = ~sleep_save[SLEEP_SAVE_GPLR##n]; \
63 * List of global PXA peripheral registers to preserve.
64 * More ones like CP and general purpose register values are preserved
67 enum { SLEEP_SAVE_START = 0,
69 - SLEEP_SAVE_GPLR0, SLEEP_SAVE_GPLR1, SLEEP_SAVE_GPLR2, SLEEP_SAVE_GPLR3,
70 - SLEEP_SAVE_GPDR0, SLEEP_SAVE_GPDR1, SLEEP_SAVE_GPDR2, SLEEP_SAVE_GPDR3,
71 - SLEEP_SAVE_GRER0, SLEEP_SAVE_GRER1, SLEEP_SAVE_GRER2, SLEEP_SAVE_GRER3,
72 - SLEEP_SAVE_GFER0, SLEEP_SAVE_GFER1, SLEEP_SAVE_GFER2, SLEEP_SAVE_GFER3,
73 - SLEEP_SAVE_PGSR0, SLEEP_SAVE_PGSR1, SLEEP_SAVE_PGSR2, SLEEP_SAVE_PGSR3,
75 - SLEEP_SAVE_GAFR0_L, SLEEP_SAVE_GAFR0_U,
76 - SLEEP_SAVE_GAFR1_L, SLEEP_SAVE_GAFR1_U,
77 - SLEEP_SAVE_GAFR2_L, SLEEP_SAVE_GAFR2_U,
78 - SLEEP_SAVE_GAFR3_L, SLEEP_SAVE_GAFR3_U,
79 + SLEEP_SAVE_OSCR, SLEEP_SAVE_OIER,
80 + SLEEP_SAVE_OSMR0, SLEEP_SAVE_OSMR1, SLEEP_SAVE_OSMR2, SLEEP_SAVE_OSMR3,
83 + SLEEP_SAVE_GPDR0, SLEEP_SAVE_GPDR1, SLEEP_SAVE_GPDR2,
84 + SLEEP_SAVE_GRER0, SLEEP_SAVE_GRER1, SLEEP_SAVE_GRER2,
85 + SLEEP_SAVE_GFER0, SLEEP_SAVE_GFER1, SLEEP_SAVE_GFER2,
86 + SLEEP_SAVE_GAFR0_L, SLEEP_SAVE_GAFR1_L, SLEEP_SAVE_GAFR2_L,
87 + SLEEP_SAVE_GAFR0_U, SLEEP_SAVE_GAFR1_U, SLEEP_SAVE_GAFR2_U,
89 + SLEEP_SAVE_FFIER, SLEEP_SAVE_FFLCR, SLEEP_SAVE_FFMCR,
90 + SLEEP_SAVE_FFSPR, SLEEP_SAVE_FFISR,
91 + SLEEP_SAVE_FFDLL, SLEEP_SAVE_FFDLH,SLEEP_SAVE_FFFCR,
93 + SLEEP_SAVE_STIER, SLEEP_SAVE_STLCR, SLEEP_SAVE_STMCR,
94 + SLEEP_SAVE_STSPR, SLEEP_SAVE_STISR,
95 + SLEEP_SAVE_STDLL, SLEEP_SAVE_STDLH,
97 + SLEEP_SAVE_BTIER, SLEEP_SAVE_BTLCR, SLEEP_SAVE_BTMCR,
98 + SLEEP_SAVE_BTSPR, SLEEP_SAVE_BTISR,
99 + SLEEP_SAVE_BTDLL, SLEEP_SAVE_BTDLH,
104 -#ifdef CONFIG_PXA27x
106 - SLEEP_SAVE_PWER, SLEEP_SAVE_PCFR, SLEEP_SAVE_PRER,
107 - SLEEP_SAVE_PFER, SLEEP_SAVE_PKWR,
109 + SLEEP_SAVE_LCCR0, SLEEP_SAVE_LCCR1, SLEEP_SAVE_LCCR2,SLEEP_SAVE_LCCR3,
110 + SLEEP_SAVE_TMEDCR, SLEEP_SAVE_FDADR0, SLEEP_SAVE_FSADR0,SLEEP_SAVE_FIDR0,SLEEP_SAVE_FDADR1,
113 + SLEEP_SAVE_NSSCR0,SLEEP_SAVE_NSSCR1,SLEEP_SAVE_NSSSR,SLEEP_SAVE_NSSITR,SLEEP_SAVE_NSSDR,
114 + SLEEP_SAVE_NSSTO,SLEEP_SAVE_NSSPSP,
128 -int pxa_pm_enter(suspend_state_t state)
129 +int pm_do_suspend(void)
131 unsigned long sleep_save[SLEEP_SAVE_SIZE];
132 unsigned long checksum = 0;
133 - struct timespec delta, rtc;
135 + int valbefore,valafter,valafter1;
136 + int gpsr0,gpsr1,gpsr2;
137 extern void pxa_cpu_pm_enter(suspend_state_t state);
139 -#ifdef CONFIG_IWMMXT
140 - /* force any iWMMXt context to ram **/
141 - iwmmxt_task_disable(NULL);
143 + // YoKu 16Feb06 GPIO Changed ----->
145 + PGSR2 |= GPIO_bit(78);
146 +/* if(GPLR2 & GPIO_bit(78)) // LCD Reset Pin
147 + PGSR2 |= GPIO_bit(78);
149 + PGSR2 &= ~GPIO_bit(78); */
150 + GPDR0 &= ~GPIO_bit(0);
151 + GPDR0 &= ~GPIO_bit(1);
152 + GPDR0 &= ~GPIO_bit(3); //Tushar: 20 apr GPIO3 configured as input
153 + GPDR0 &= ~GPIO_bit(2);
154 +// GPDR0 &= ~GPIO_bit(5);
155 +// GPDR0 &= ~GPIO_bit(6);
156 +// GPDR0 &= ~GPIO_bit(7);
157 +// GPDR0 &= ~GPIO_bit(8);
160 +// KeyCol pin Status in sleep mode
161 + PGSR0 &= ~GPIO_bit(9); //19
162 + PGSR0 &= ~GPIO_bit(10); //20
163 + PGSR0 &= ~GPIO_bit(11); //21
164 + PGSR0 &= ~GPIO_bit(12); //22
165 + PGSR0 &= ~GPIO_bit(13); //23
166 + PGSR0 &= ~GPIO_bit(14); //24
168 + printk("KER_PM: Setting up wakeup sources 26May06\n");
171 + //printk("KER_PM: Uncommented key pad wakeup sources\n");
172 + PWER |= GPIO_bit(5); //11
173 + PWER |= GPIO_bit(6); //12
174 + PWER |= GPIO_bit(7); //13
175 + PWER |= GPIO_bit(8); //14
176 + PFER |= GPIO_bit(5); //11
177 + PFER |= GPIO_bit(6); //12
178 + PFER |= GPIO_bit(7); //13
179 + PFER |= GPIO_bit(8); //14
180 + PRER |= GPIO_bit(5); //11
181 + PRER |= GPIO_bit(6); //12
182 + PRER |= GPIO_bit(7); //13
183 + PRER |= GPIO_bit(8); //14
186 + PWER |= GPIO_bit(3); //6
187 + PFER |= GPIO_bit(3); //6
188 + PRER |= GPIO_bit(3); //6
191 + PWER |= GPIO_bit(2); //4
192 + PFER |= GPIO_bit(2); //4
193 + PRER |= GPIO_bit(2); //4
196 + PWER |= GPIO_bit(0); //0
197 + PFER |= GPIO_bit(0); //0
198 + PRER |= GPIO_bit(0); //0
199 + // anup prashant : for gsm reset problem 19 may 2006
200 + //GPDR0 |= GPIO_bit(18); YoKu Commented this line, GPIO18 should be i/p pin to avoid GSM Reset pulse
201 + PGSR0 |= GPIO_bit(18); // GSM reset pin
202 + PGSR0 |= GPIO_bit(0); //
203 + PGSR1 |= GPIO_bit(38); // commneted .18 apr
207 + // When exiting from sleep mode, 10us Low pulse comes on GSM Reset and Pwr pin
208 + // to avoid this configure GPIO 18,80 as input pins before going to sleep mode
209 + GPDR0 &= ~GPIO_bit(18);
210 + //GPDR2 &= ~GPIO_bit(80);
216 + local_irq_disable();
218 + local_fiq_disable();
219 + leds_event(led_stop);
221 + /* Put Current time into RCNR */
222 + RCNR = xtime.tv_sec;
224 - /* preserve current time */
227 - save_time_delta(&delta, &rtc);
228 + printk("11May2006 KERR: pgsr0=0x%08x pgsr1=0x%08x pgsr2= 0x%08x\n",PGSR0,PGSR1,PGSR2);
229 + printk("KER_PM_DELAY: SSCR Going to Sleep at RCNR =%d\n\n\n\n\n\n",RCNR);
232 + * Temporary solution. This won't be necessary once
233 + * we move pxa support into the serial driver
237 + // Anup : commented for power saving mode problem
238 + printk("\nPM: Why doesnt it prnt?? 26May06\n");
239 + printk("\nPM : GSM Sleep Mode enabled");
242 + FFMCR &= ~UART_RTS;
245 + FFMCR &= ~UART_DTR ;
250 + // Anup : Do not check here
253 + printk("\nPM : Modem Control Register = %x " , FFMCR);
254 + while( FFMSR & 0x00000020)
256 + printk("\nPM : FFFSR = %x " , FFMSR);
262 +// NSSCR0 &= 0xFFFFFF7F;
263 +// printk("\nPM: NSSCR0 = %x" ,NSSCR0 );
296 + /* save vital registers */
304 - SAVE(GPLR0); SAVE(GPLR1); SAVE(GPLR2);
305 SAVE(GPDR0); SAVE(GPDR1); SAVE(GPDR2);
306 SAVE(GRER0); SAVE(GRER1); SAVE(GRER2);
307 SAVE(GFER0); SAVE(GFER1); SAVE(GFER2);
308 - SAVE(PGSR0); SAVE(PGSR1); SAVE(PGSR2);
310 SAVE(GAFR0_L); SAVE(GAFR0_U);
311 SAVE(GAFR1_L); SAVE(GAFR1_U);
312 SAVE(GAFR2_L); SAVE(GAFR2_U);
314 -#ifdef CONFIG_PXA27x
316 - SAVE(GPLR3); SAVE(GPDR3); SAVE(GRER3); SAVE(GFER3); SAVE(PGSR3);
317 - SAVE(GAFR3_L); SAVE(GAFR3_U);
318 - SAVE(PWER); SAVE(PCFR); SAVE(PRER);
319 - SAVE(PFER); SAVE(PKWR);
321 + // YoKu 23Feb06 Added To save LCD Registers, updated by kirti 24Feb06 ----->
322 + SAVE(LCCR0); SAVE(LCCR1); SAVE(LCCR2); SAVE(LCCR3);
325 + LCSR = 0xffffffff; /* Clear LCD Status Register */
327 +// LCCR0 &= ~LCCR0_LDM; /* Enable LCD Disable Done Interrupt */
328 +// LCCR0 |= LCCR0_DIS; /* Disable LCD Controller */
333 +// LCCR0 &= ~LCCR0_LDM; /* Enable LCD Disable Done Interrupt */
334 +// LCCR0 |= LCCR0_DIS; /* Disable LCD Controller */
344 + // Anup : For Wifi power saving mode 2 May 2006
345 + SAVE(NSSCR0);SAVE(NSSCR1);SAVE(NSSSR);SAVE(NSSITR);SAVE(NSSDR);SAVE(NSSTO);
347 + printk("\nMY favourite mode in life.......sleep.....\n");
350 /* Note: wake up source are set up in each machine specific files */
352 + /*Changes to keep the right sim selected */
357 + /*Sim 1 selected */
358 + // YoKu GPIOs Changed ----->
359 + if( (GPLR0 & GPIO_bit(21)) && !(GPLR0 & GPIO_bit(22)) ) // 62,63
361 + PGSR0 |= GPIO_bit(21) ; //62
362 + PGSR0 &= ~GPIO_bit(22) ; //63
364 + else if (!(GPLR0 & GPIO_bit(21)) && (GPLR0 & GPIO_bit(22)) ) // 62,63
366 + PGSR0 |= GPIO_bit(22) ; //63
367 + PGSR0 &= ~GPIO_bit(21) ; //62
371 /* clear GPIO transition detect bits */
372 GEDR0 = GEDR0; GEDR1 = GEDR1; GEDR2 = GEDR2;
373 -#ifdef CONFIG_PXA27x
377 /* Clear sleep reset status */
380 + /* set resume return address */
381 + PSPR = virt_to_phys(pxa_cpu_resume);
383 /* before sleeping, calculate and save a checksum */
384 for (i = 0; i < SLEEP_SAVE_SIZE - 1; i++)
385 checksum += sleep_save[i];
386 sleep_save[SLEEP_SAVE_CKSUM] = checksum;
388 - /* *** go zzz *** */
389 - pxa_cpu_pm_enter(state);
390 + PGSR0 |= GPIO_bit(15); //sidd for wake from Sleep 15, YoKu Comented ?? GPIO15 was ChipSelect
391 + PGSR2 |= GPIO_bit(80); //sidd for GSM Engine 69, YoKu GPIO Changed Anup :commented
393 + PGSR1 &= ~GPIO_bit(33); //Tushar: BT Codec Power Down
395 + PGSR0 &= ~GPIO_bit(23); //Tushar: BGW200 Regulator OFF
397 +// GPDR1 |= GPIO_bit(49); //Tushar: LCD Serial Data in changed to O/P
399 +// PGSR1 &= ~GPIO_bit(48);//Tushar: LCD Serial Pins
401 +// PGSR1 &= ~GPIO_bit(49);
403 +// PGSR1 &= ~GPIO_bit(50);
405 +// PGSR1 |= GPIO_bit(51);
407 +// PGSR1 &= 0x03FFFFFF;//Tushar: 24apr LCD datalines
408 +// PGSR2 &= 0xFFFFFC00;
410 + PGSR0 &= ~GPIO_bit(24); //Tushar: Mux Control Signals
412 + PGSR0 &= ~GPIO_bit(25);
414 + PGSR0 &= ~GPIO_bit(26);
416 + PGSR0 &= ~GPIO_bit(27);
418 + // GPDR0 |= GPIO_bit(17); //Tushar: unused GPIOs 19apr
419 + // GPCR0 |= GPIO_bit(17);
420 + PGSR0 &= ~GPIO_bit(17);
422 +// GPDR1 |= GPIO_bit(56); //Tushar: unused GPIOs 19apr
423 + // GPCR1 |= GPIO_bit(56);
424 + PGSR1 &= ~GPIO_bit(56);
426 +// GPDR2 |= GPIO_bit(79);//Tushar: unused GPIOs 19apr
427 +// GPCR2 |= GPIO_bit(79);
428 + PGSR2 &= ~GPIO_bit(79);
430 +// GPDR1 |= 0x03F00000;//Tushar: unused GPIOs 19apr
431 +// GPCR1 |= 0x03F00000;
432 + PGSR1 &= 0xFC0FFFFF;
435 + GPDR0 |= GPIO_bit(19);//Tushar: SIM Present Inputs configured as outputs
436 + GPDR0 |= GPIO_bit(20);
437 + PGSR0 &= ~GPIO_bit(19);
438 + PGSR0 &= ~GPIO_bit(20);
441 +//Tushar: 25apr FFRTS FFDTR & FFTXD
443 + PGSR1 |= GPIO_bit(39);
444 + PGSR1 |= GPIO_bit(40);
445 + PGSR1 |= GPIO_bit(41);
447 + PGSR2 &= GPIO_bit(81); //Tushar: 24apr NSSP pins
448 + PGSR2 &= GPIO_bit(82);
449 + PGSR2 &= GPIO_bit(83);
451 + PGSR2 |= GPIO_bit(74);
452 + PGSR2 |= GPIO_bit(75);
453 + PGSR2 |= GPIO_bit(76);
454 + PGSR2 |= GPIO_bit(77);
458 + /* We are here bcos of pressing of on off switch
459 + We wake up now only on pwr switch */
460 + printk("Anup: Before sleeping \n");
462 + PGSR0 &= ~GPIO_bit(23); //7 YoKu GPIO Changed
463 + //PGSR2 &= ~GPIO_bit(64); //64 YoKu Commented in PWG500 64,7 was WifiReg, IN PWG600 it is 23
465 + PGSR2 &= ~GPIO_bit(80); //69 YoKu GPIO Changed Anup : commnented
466 + PWER = 0x0004; // YoKu Changed from 0x10 to 0x04 (i.e GPIO 4 -> 2)
471 +// 11May2006 To reduce Power Off current from 7mA to 4mA
472 + GPDR0 |= GPIO_bit(16); // BTReset o/p Low
473 + PGSR0 &= ~GPIO_bit(16);
475 + GPDR1 |= GPIO_bit(33); // nMEC/nPDI o/p Low
476 + PGSR1 &= ~GPIO_bit(33);
478 + GPDR1 |= GPIO_bit(45); // BTRTS o/p High
479 + PGSR1 |= GPIO_bit(45);
482 + GPDR1 |= GPIO_bit(43); // BTTXD o/p High
483 + PGSR1 |= GPIO_bit(43);
485 + GPDR1 &= ~GPIO_bit(42); // BTRXD i/p
486 + GPDR1 &= ~GPIO_bit(44); // BTCTS i/p
489 + PSPR = virt_to_phys(pxa_cpu_resume); // YoKu 29July05 to Resume from where u left, Original PSPR = 0
492 + valbefore = GPLR0 & (GPIO_bit(21) | GPIO_bit(22)) ; // 62,63 YoKu GPIO Changed
494 + //printk("Anup: Before sleeping gpsr0=0x%08x gpsr1=0x%08x gpsr2= 0x%08x\n",gpsr0,gpsr1,gpsr2);
495 + //kirti pxa_cpu_suspend();
496 + //printk("KER_PM: Going to sleep zzzzzzzzz\n");
498 +// OSCC |= OSCC_OON; //Tushar: 18 apr. enable 32.768KHz Oscillator
500 +// PCFR |= PCFR_OPDE; //Tushar: 18 apr. disable 3.6864MHz oscillator
502 + pxa_cpu_pm_enter(PM_SUSPEND_MEM);
508 + //FFMCR |= UART_DTR ;
511 /* after sleeping, validate the checksum */
513 for (i = 0; i < SLEEP_SAVE_SIZE - 1; i++)
514 @@ -141,39 +464,63 @@
516 for (i = 0; i < SLEEP_SAVE_SIZE - 1; i++)
517 checksum += sleep_save[i];
519 /* if invalid, display message and wait for a hardware reset */
520 - if (checksum != sleep_save[SLEEP_SAVE_CKSUM]) {
521 + if (checksum != sleep_save[SLEEP_SAVE_CKSUM])
523 #ifdef CONFIG_ARCH_LUBBOCK
524 LUB_HEXLED = 0xbadbadc5;
527 - pxa_cpu_pm_enter(state);
529 + printk("\n\n\nKERN_PM: CRC Error!!! after wakeup\n\n\n"); // YoKu 25May06
534 + valafter = GPLR0 & (GPIO_bit(21) | GPIO_bit(22)) ; //62,63 YoKu GPIO Changed
537 /* ensure not to come back here if it wasn't intended */
540 + /*printk("YoKu: gafr0_L=0x%08x gafr0_U=0x%08x\n",GAFR0_L,GAFR0_U);
541 + printk(" gafr1_L= 0x%08x gafr1_U= 0x%08x\n",GAFR1_L,GAFR1_U);
542 + printk(" gafr2_L= 0x%08x gafr2_U= 0x%08x\n",GAFR2_L,GAFR2_U); */
543 /* restore registers */
544 - RESTORE_GPLEVEL(0); RESTORE_GPLEVEL(1); RESTORE_GPLEVEL(2);
545 RESTORE(GPDR0); RESTORE(GPDR1); RESTORE(GPDR2);
546 + RESTORE(GRER0); RESTORE(GRER1); RESTORE(GRER2);
547 + RESTORE(GFER0); RESTORE(GFER1); RESTORE(GFER2);
548 RESTORE(GAFR0_L); RESTORE(GAFR0_U);
549 RESTORE(GAFR1_L); RESTORE(GAFR1_U);
550 RESTORE(GAFR2_L); RESTORE(GAFR2_U);
551 - RESTORE(GRER0); RESTORE(GRER1); RESTORE(GRER2);
552 - RESTORE(GFER0); RESTORE(GFER1); RESTORE(GFER2);
553 - RESTORE(PGSR0); RESTORE(PGSR1); RESTORE(PGSR2);
555 -#ifdef CONFIG_PXA27x
557 - RESTORE_GPLEVEL(3); RESTORE(GPDR3);
558 - RESTORE(GAFR3_L); RESTORE(GAFR3_U);
559 - RESTORE(GRER3); RESTORE(GFER3); RESTORE(PGSR3);
560 - RESTORE(PWER); RESTORE(PCFR); RESTORE(PRER);
561 - RESTORE(PFER); RESTORE(PKWR);
564 - PSSR = PSSR_RDH | PSSR_PH;
565 + // Anup : For Wifi power saving mode 2 May 2006
566 + RESTORE(NSSCR0);RESTORE(NSSCR1);RESTORE(NSSSR);RESTORE(NSSITR);RESTORE(NSSDR);RESTORE(NSSTO);
574 + // Anup : check values of these registers
575 +// printk("YoKu: gpsr0=0x%08x gpsr1=0x%08x gpsr2= 0x%08x\n",gpsr0,gpsr1,gpsr2);
594 @@ -181,62 +528,181 @@
600 + * Temporary solution. This won't be necessary once
601 + * we move pxa support into the serial driver.
602 + * Restore the FF UART.
638 + // YoKu 23Feb06 Added To save LCD Registers, updated by kirti 24Feb06 ----->
639 + RESTORE(LCCR3); RESTORE(LCCR2); RESTORE(LCCR1);
640 + LCCR0=RESTORE(LCCR0) & ~LCCR0_ENB;
641 + RESTORE(FDADR0); RESTORE(FDADR1);
642 + LCCR0 |= LCCR0_ENB;
646 /* restore current time */
648 - restore_time_delta(&delta, &rtc);
649 + xtime.tv_sec = RCNR;
651 + valafter1 = GPLR0 & (GPIO_bit(21) | GPIO_bit(22)) ; //62,63 YoKu GPIO Changed
653 +// SSCR0 &=0xFFFFFFFF;
654 +// printk("\nPM : val of SSCR0 = %x " , SSCR0);
656 + printk("KER_PM: Resumed at RCNR = %d RTSR= %x\n",RCNR,RTSR);
658 + printk("YoKu: pgsr0=0x%08x pgsr1=0x%08x pgsr2= 0x%08x\n",PGSR0,PGSR1,PGSR2);
660 + OSMR0 = 0; /* set initial match at 0 */
661 + OSSR = 0xf; /* clear status on all timers */
662 + OIER |= OIER_E0; /* enable match on timer 0 to cause interrupts */
663 + OSCR = 0; /* initialize free-running timer, force first match */
665 + leds_event(led_start);
667 + // call i2c reset here---->
669 + ISR = 0x7FF; //I2C_ISR_INIT;
672 + ISAR = 0x32;//i2c->slave_addr;
674 + /* set control register values */
675 + ICR = (ICR_BEIE | ICR_IRFIE | ICR_ITEIE | ICR_GCD | ICR_SCLE);//I2C_ICR_INIT;
682 + local_irq_enable();
685 - printk(KERN_DEBUG "*** made it back from resume\n");
691 -EXPORT_SYMBOL_GPL(pxa_pm_enter);
693 unsigned long sleep_phys_sp(void *sp)
695 return virt_to_phys(sp);
698 +#ifdef CONFIG_SYSCTL
700 - * Called after processes are frozen, but before we shut down devices.
701 + * ARGH! ACPI people defined CTL_ACPI in linux/acpi.h rather than
704 + * This means our interface here won't survive long - it needs a new
705 + * interface. Quick hack to get this working - use sysctl id 9999.
707 -int pxa_pm_prepare(suspend_state_t state)
709 - extern int pxa_cpu_pm_prepare(suspend_state_t state);
710 +#warning ACPI broke the kernel, this interface needs to be fixed up.
711 +#define CTL_ACPI 9999
712 +#define ACPI_S1_SLP_TYP 19
714 - return pxa_cpu_pm_prepare(state);
716 + * Send us to sleep.
718 +static int sysctl_pm_do_suspend(ctl_table *ctl, int write, struct file *filp,
719 + void *buffer, size_t *lenp)
722 + unsigned i , clock ;
726 + unsigned int sleepsec;
727 + int len,left = *lenp;
730 + if (left > sizeof(buf))
731 + left = sizeof(buf);
732 + if (!copy_from_user(buf, buffer, left))
734 + buf[sizeof(buf) - 1] = '\0';
735 + sleepsec = simple_strtoul(buf, &p, 0);
736 + printk("\nSleeping %d Pwronoff=%x RCNR=%d\n",sleepsec,pm_pwronoff,RCNR);
737 + printk("\nPWER %x PFER=%x PRER=%x\n",PWER,PFER,PRER);
738 + RTAR = xtime.tv_sec + sleepsec;
739 + printk("\nRTAR=%d \n",RTAR);
742 + retval = pm_do_suspend();
743 + clock = get_memclk_frequency_10khz();
747 -EXPORT_SYMBOL_GPL(pxa_pm_prepare);
750 - * Called after devices are re-setup, but before processes are thawed.
751 +static struct ctl_table pm_table[] =
753 + {ACPI_S1_SLP_TYP, "suspend", NULL, 0, 0600, NULL, (proc_handler *)&sysctl_pm_do_suspend},
757 -int pxa_pm_finish(suspend_state_t state)
758 +static struct ctl_table pm_table[] =
762 + ctl_name: ACPI_S1_SLP_TYP,
763 + procname: "suspend",
765 + proc_handler: (proc_handler *)&sysctl_pm_do_suspend,
772 -EXPORT_SYMBOL_GPL(pxa_pm_finish);
773 +static struct ctl_table pm_dir_table[] =
775 + {CTL_ACPI, "pm", NULL, 0, 0555, pm_table},
780 - * Set to PM_DISK_FIRMWARE so we can quickly veto suspend-to-disk.
781 + * Initialize power interface
783 -static struct pm_ops pxa_pm_ops = {
784 - .pm_disk_mode = PM_DISK_FIRMWARE,
785 - .prepare = pxa_pm_prepare,
786 - .enter = pxa_pm_enter,
787 - .finish = pxa_pm_finish,
790 -static int __init pxa_pm_init(void)
791 +static int __init pm_init(void)
793 - pm_set_ops(&pxa_pm_ops);
794 + register_sysctl_table(pm_dir_table, 1);
795 + /*Adi: Adjust for clock value to RTC
796 + RTTR = RTC clk - 1*/
802 -device_initcall(pxa_pm_init);
803 +__initcall(pm_init);
806 diff -NurbwB linux-2.6.17/arch/arm/mach-pxa/sleep.S linux-2.6.17-patched/arch/arm/mach-pxa/sleep.S
807 --- linux-2.6.17/arch/arm/mach-pxa/sleep.S 2006-06-17 18:49:35.000000000 -0700
808 +++ linux-2.6.17-patched/arch/arm/mach-pxa/sleep.S 2006-09-11 13:07:05.000000000 -0700
812 @ enable SDRAM self-refresh mode
813 - orr r5, r5, #MDREFR_SLFRSH
814 + orr r5, r5, #(MDREFR_SLFRSH | MDREFR_APD)
817 @ set SDCLKx divide-by-2 bits (this is part of a workaround for Errata 50)
818 diff -NurbwB linux-2.6.17/include/asm-arm/arch-pxa/pxa-regs.h linux-2.6.17-patched/include/asm-arm/arch-pxa/pxa-regs.h
819 --- linux-2.6.17/include/asm-arm/arch-pxa/pxa-regs.h 2006-06-17 18:49:35.000000000 -0700
820 +++ linux-2.6.17-patched/include/asm-arm/arch-pxa/pxa-regs.h 2006-09-11 11:04:36.000000000 -0700
821 @@ -1748,6 +1748,15 @@
822 #define SSTO_P(x) (*(((x) == 1) ? &SSTO_P1 : ((x) == 2) ? &SSTO_P2 : ((x) == 3) ? &SSTO_P3 : NULL))
823 #define SSPSP_P(x) (*(((x) == 1) ? &SSPSP_P1 : ((x) == 2) ? &SSPSP_P2 : ((x) == 3) ? &SSPSP_P3 : NULL))
825 +#define NSSCR0 __REG(0x41400000) /* SSP Port 1 Control Register 0 */
826 +#define NSSCR1 __REG(0x41400004) /* SSP Port 1 Control Register 1 */
827 +#define NSSSR __REG(0x41400008) /* SSP Port 1 Status Register */
828 +#define NSSITR __REG(0x4140000C) /* SSP Port 1 Interrupt Test Register */
829 +#define NSSDR __REG(0x41400010) /* (Write / Read) SSP Port 1 Data Write Register/SSP Data Read Register */
830 +#define NSSTO __REG(0x41400028) /* SSP Port 1 Time Out Register */
831 +#define NSSPSP __REG(0x4140002C) /* SSP Port 1 Programmable Serial Port Register */
835 * MultiMediaCard (MMC) controller
837 diff -NurbwB linux-2.6.17/kernel/power/main.c linux-2.6.17-patched/kernel/power/main.c
838 --- linux-2.6.17/kernel/power/main.c 2006-06-17 18:49:35.000000000 -0700
839 +++ linux-2.6.17-patched/kernel/power/main.c 2006-09-11 12:59:20.000000000 -0700
845 if (freeze_processes()) {
851 if ((free_pages = nr_free_pages()) < FREE_PAGE_NUMBER) {
852 pr_debug("PM: free some memory\n");
853 @@ -110,12 +112,15 @@
855 local_irq_save(flags);
858 if ((error = device_power_down(PMSG_SUSPEND))) {
859 printk(KERN_ERR "Some devices failed to power down\n");
864 error = pm_ops->enter(state);
866 + //device_power_up();
868 local_irq_restore(flags);