001-pm.patch 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869
  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
  4. @@ -10,35 +10,50 @@
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License.
  7. */
  8. +
  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>
  20. #include <asm/hardware.h>
  21. #include <asm/memory.h>
  22. #include <asm/system.h>
  23. -#include <asm/arch/pm.h>
  24. +#include <asm/leds.h>
  25. +#include <asm/uaccess.h>
  26. #include <asm/arch/pxa-regs.h>
  27. #include <asm/arch/lubbock.h>
  28. #include <asm/mach/time.h>
  29. +/**/
  30. +#include <linux/module.h>
  31. +/**/
  32. +//kirti
  33. +#include <linux/delay.h>
  34. +//kirti~
  35. /*
  36. * Debug macros
  37. */
  38. -#undef DEBUG
  39. +#define DEBUG
  40. +
  41. +extern void pxa_cpu_suspend(void);
  42. +extern void pxa_cpu_resume(void);
  43. +
  44. +int pm_pwronoff;
  45. +/*Angelia Additions */
  46. +int pm_pedr=0;
  47. +EXPORT_SYMBOL(pm_pwronoff);
  48. +EXPORT_SYMBOL(pm_pedr);
  49. +
  50. #define SAVE(x) sleep_save[SLEEP_SAVE_##x] = x
  51. #define RESTORE(x) x = sleep_save[SLEEP_SAVE_##x]
  52. -#define RESTORE_GPLEVEL(n) do { \
  53. - GPSR##n = sleep_save[SLEEP_SAVE_GPLR##n]; \
  54. - GPCR##n = ~sleep_save[SLEEP_SAVE_GPLR##n]; \
  55. -} while (0)
  56. -
  57. /*
  58. * List of global PXA peripheral registers to preserve.
  59. * More ones like CP and general purpose register values are preserved
  60. @@ -46,97 +61,405 @@
  61. */
  62. enum { SLEEP_SAVE_START = 0,
  63. - SLEEP_SAVE_GPLR0, SLEEP_SAVE_GPLR1, SLEEP_SAVE_GPLR2, SLEEP_SAVE_GPLR3,
  64. - SLEEP_SAVE_GPDR0, SLEEP_SAVE_GPDR1, SLEEP_SAVE_GPDR2, SLEEP_SAVE_GPDR3,
  65. - SLEEP_SAVE_GRER0, SLEEP_SAVE_GRER1, SLEEP_SAVE_GRER2, SLEEP_SAVE_GRER3,
  66. - SLEEP_SAVE_GFER0, SLEEP_SAVE_GFER1, SLEEP_SAVE_GFER2, SLEEP_SAVE_GFER3,
  67. - SLEEP_SAVE_PGSR0, SLEEP_SAVE_PGSR1, SLEEP_SAVE_PGSR2, SLEEP_SAVE_PGSR3,
  68. -
  69. - SLEEP_SAVE_GAFR0_L, SLEEP_SAVE_GAFR0_U,
  70. - SLEEP_SAVE_GAFR1_L, SLEEP_SAVE_GAFR1_U,
  71. - SLEEP_SAVE_GAFR2_L, SLEEP_SAVE_GAFR2_U,
  72. - SLEEP_SAVE_GAFR3_L, SLEEP_SAVE_GAFR3_U,
  73. + SLEEP_SAVE_OSCR, SLEEP_SAVE_OIER,
  74. + SLEEP_SAVE_OSMR0, SLEEP_SAVE_OSMR1, SLEEP_SAVE_OSMR2, SLEEP_SAVE_OSMR3,
  75. - SLEEP_SAVE_PSTR,
  76. + SLEEP_SAVE_GPDR0, SLEEP_SAVE_GPDR1, SLEEP_SAVE_GPDR2,
  77. + SLEEP_SAVE_GRER0, SLEEP_SAVE_GRER1, SLEEP_SAVE_GRER2,
  78. + SLEEP_SAVE_GFER0, SLEEP_SAVE_GFER1, SLEEP_SAVE_GFER2,
  79. + SLEEP_SAVE_GAFR0_L, SLEEP_SAVE_GAFR1_L, SLEEP_SAVE_GAFR2_L,
  80. + SLEEP_SAVE_GAFR0_U, SLEEP_SAVE_GAFR1_U, SLEEP_SAVE_GAFR2_U,
  81. +
  82. + SLEEP_SAVE_FFIER, SLEEP_SAVE_FFLCR, SLEEP_SAVE_FFMCR,
  83. + SLEEP_SAVE_FFSPR, SLEEP_SAVE_FFISR,
  84. + SLEEP_SAVE_FFDLL, SLEEP_SAVE_FFDLH,SLEEP_SAVE_FFFCR,
  85. +
  86. + SLEEP_SAVE_STIER, SLEEP_SAVE_STLCR, SLEEP_SAVE_STMCR,
  87. + SLEEP_SAVE_STSPR, SLEEP_SAVE_STISR,
  88. + SLEEP_SAVE_STDLL, SLEEP_SAVE_STDLH,
  89. +
  90. + SLEEP_SAVE_BTIER, SLEEP_SAVE_BTLCR, SLEEP_SAVE_BTMCR,
  91. + SLEEP_SAVE_BTSPR, SLEEP_SAVE_BTISR,
  92. + SLEEP_SAVE_BTDLL, SLEEP_SAVE_BTDLH,
  93. SLEEP_SAVE_ICMR,
  94. SLEEP_SAVE_CKEN,
  95. -#ifdef CONFIG_PXA27x
  96. - SLEEP_SAVE_MDREFR,
  97. - SLEEP_SAVE_PWER, SLEEP_SAVE_PCFR, SLEEP_SAVE_PRER,
  98. - SLEEP_SAVE_PFER, SLEEP_SAVE_PKWR,
  99. -#endif
  100. + SLEEP_SAVE_LCCR0, SLEEP_SAVE_LCCR1, SLEEP_SAVE_LCCR2,SLEEP_SAVE_LCCR3,
  101. + SLEEP_SAVE_TMEDCR, SLEEP_SAVE_FDADR0, SLEEP_SAVE_FSADR0,SLEEP_SAVE_FIDR0,SLEEP_SAVE_FDADR1,
  102. + SLEEP_SAVE_LDCMD0,
  103. +
  104. + SLEEP_SAVE_NSSCR0,SLEEP_SAVE_NSSCR1,SLEEP_SAVE_NSSSR,SLEEP_SAVE_NSSITR,SLEEP_SAVE_NSSDR,
  105. + SLEEP_SAVE_NSSTO,SLEEP_SAVE_NSSPSP,
  106. - SLEEP_SAVE_CKSUM,
  107. + SLEEP_SAVE_CKSUM,
  108. SLEEP_SAVE_SIZE
  109. };
  110. +/**/
  111. +#define UART_DTR 1
  112. +#define UART_RTS 2
  113. +
  114. +/**/
  115. -int pxa_pm_enter(suspend_state_t state)
  116. +int pm_do_suspend(void)
  117. {
  118. unsigned long sleep_save[SLEEP_SAVE_SIZE];
  119. unsigned long checksum = 0;
  120. - struct timespec delta, rtc;
  121. int i;
  122. + int valbefore,valafter,valafter1;
  123. + int gpsr0,gpsr1,gpsr2;
  124. extern void pxa_cpu_pm_enter(suspend_state_t state);
  125. -#ifdef CONFIG_IWMMXT
  126. - /* force any iWMMXt context to ram **/
  127. - iwmmxt_task_disable(NULL);
  128. -#endif
  129. + // YoKu 16Feb06 GPIO Changed ----->
  130. +
  131. + PGSR2 |= GPIO_bit(78);
  132. +/* if(GPLR2 & GPIO_bit(78)) // LCD Reset Pin
  133. + PGSR2 |= GPIO_bit(78);
  134. + else
  135. + PGSR2 &= ~GPIO_bit(78); */
  136. + GPDR0 &= ~GPIO_bit(0);
  137. + GPDR0 &= ~GPIO_bit(1);
  138. + GPDR0 &= ~GPIO_bit(3); //Tushar: 20 apr GPIO3 configured as input
  139. + GPDR0 &= ~GPIO_bit(2);
  140. +// GPDR0 &= ~GPIO_bit(5);
  141. +// GPDR0 &= ~GPIO_bit(6);
  142. +// GPDR0 &= ~GPIO_bit(7);
  143. +// GPDR0 &= ~GPIO_bit(8);
  144. +
  145. +
  146. +// KeyCol pin Status in sleep mode
  147. + PGSR0 &= ~GPIO_bit(9); //19
  148. + PGSR0 &= ~GPIO_bit(10); //20
  149. + PGSR0 &= ~GPIO_bit(11); //21
  150. + PGSR0 &= ~GPIO_bit(12); //22
  151. + PGSR0 &= ~GPIO_bit(13); //23
  152. + PGSR0 &= ~GPIO_bit(14); //24
  153. +
  154. + printk("KER_PM: Setting up wakeup sources 26May06\n");
  155. +
  156. + // KeyPad
  157. + //printk("KER_PM: Uncommented key pad wakeup sources\n");
  158. + PWER |= GPIO_bit(5); //11
  159. + PWER |= GPIO_bit(6); //12
  160. + PWER |= GPIO_bit(7); //13
  161. + PWER |= GPIO_bit(8); //14
  162. + PFER |= GPIO_bit(5); //11
  163. + PFER |= GPIO_bit(6); //12
  164. + PFER |= GPIO_bit(7); //13
  165. + PFER |= GPIO_bit(8); //14
  166. + PRER |= GPIO_bit(5); //11
  167. + PRER |= GPIO_bit(6); //12
  168. + PRER |= GPIO_bit(7); //13
  169. + PRER |= GPIO_bit(8); //14
  170. +
  171. + // USB
  172. + PWER |= GPIO_bit(3); //6
  173. + PFER |= GPIO_bit(3); //6
  174. + PRER |= GPIO_bit(3); //6
  175. +
  176. + // PMU
  177. + PWER |= GPIO_bit(2); //4
  178. + PFER |= GPIO_bit(2); //4
  179. + PRER |= GPIO_bit(2); //4
  180. +
  181. + // Anup : GSM RI
  182. + PWER |= GPIO_bit(0); //0
  183. + PFER |= GPIO_bit(0); //0
  184. + PRER |= GPIO_bit(0); //0
  185. + // anup prashant : for gsm reset problem 19 may 2006
  186. + //GPDR0 |= GPIO_bit(18); YoKu Commented this line, GPIO18 should be i/p pin to avoid GSM Reset pulse
  187. + PGSR0 |= GPIO_bit(18); // GSM reset pin
  188. + PGSR0 |= GPIO_bit(0); //
  189. + PGSR1 |= GPIO_bit(38); // commneted .18 apr
  190. + // <----- YoKu
  191. +
  192. + // YoKu ----->
  193. + // When exiting from sleep mode, 10us Low pulse comes on GSM Reset and Pwr pin
  194. + // to avoid this configure GPIO 18,80 as input pins before going to sleep mode
  195. + GPDR0 &= ~GPIO_bit(18);
  196. + //GPDR2 &= ~GPIO_bit(80);
  197. + // <----- YoKu
  198. +
  199. + //kirti for RTC
  200. + PWER |= PWER_RTC;
  201. + //kirti cli();
  202. + local_irq_disable();
  203. + //kirti clf();
  204. + local_fiq_disable();
  205. + leds_event(led_stop);
  206. +
  207. + /* Put Current time into RCNR */
  208. + RCNR = xtime.tv_sec;
  209. - /* preserve current time */
  210. - rtc.tv_sec = RCNR;
  211. - rtc.tv_nsec = 0;
  212. - save_time_delta(&delta, &rtc);
  213. + printk("11May2006 KERR: pgsr0=0x%08x pgsr1=0x%08x pgsr2= 0x%08x\n",PGSR0,PGSR1,PGSR2);
  214. + printk("KER_PM_DELAY: SSCR Going to Sleep at RCNR =%d\n\n\n\n\n\n",RCNR);
  215. +
  216. + /*
  217. + * Temporary solution. This won't be necessary once
  218. + * we move pxa support into the serial driver
  219. + * Save the FF UART
  220. + */
  221. +
  222. + // Anup : commented for power saving mode problem
  223. + printk("\nPM: Why doesnt it prnt?? 26May06\n");
  224. + printk("\nPM : GSM Sleep Mode enabled");
  225. +
  226. +
  227. + FFMCR &= ~UART_RTS;
  228. + udelay(2000);
  229. + udelay(2000);
  230. + FFMCR &= ~UART_DTR ;
  231. + udelay(2000);
  232. +
  233. + udelay(2000);
  234. + // rupali
  235. + // Anup : Do not check here
  236. +/* if(!pm_pwronoff)
  237. + {
  238. + printk("\nPM : Modem Control Register = %x " , FFMCR);
  239. + while( FFMSR & 0x00000020)
  240. + {
  241. + printk("\nPM : FFFSR = %x " , FFMSR);
  242. + }
  243. + } */
  244. + udelay(2000);
  245. +
  246. +//Tushar: 19 apr
  247. +// NSSCR0 &= 0xFFFFFF7F;
  248. +// printk("\nPM: NSSCR0 = %x" ,NSSCR0 );
  249. +
  250. + SAVE(FFIER);
  251. + SAVE(FFLCR);
  252. + SAVE(FFMCR);
  253. + SAVE(FFSPR);
  254. + SAVE(FFISR);
  255. + FFLCR |= 0x80;
  256. + SAVE(FFDLL);
  257. + SAVE(FFDLH);
  258. + SAVE(FFFCR);
  259. + FFLCR &= 0xef;
  260. +
  261. + SAVE(STIER);
  262. + SAVE(STLCR);
  263. + SAVE(STMCR);
  264. + SAVE(STSPR);
  265. + SAVE(STISR);
  266. + STLCR |= 0x80;
  267. + SAVE(STDLL);
  268. + SAVE(STDLH);
  269. + STLCR &= 0xef;
  270. +
  271. + SAVE(BTIER);
  272. + SAVE(BTLCR);
  273. + SAVE(BTMCR);
  274. + SAVE(BTSPR);
  275. + SAVE(BTISR);
  276. + BTLCR |= 0x80;
  277. + SAVE(BTDLL);
  278. + SAVE(BTDLH);
  279. + BTLCR &= 0xef;
  280. +
  281. + /* save vital registers */
  282. + SAVE(OSCR);
  283. + SAVE(OSMR0);
  284. + SAVE(OSMR1);
  285. + SAVE(OSMR2);
  286. + SAVE(OSMR3);
  287. + SAVE(OIER);
  288. - SAVE(GPLR0); SAVE(GPLR1); SAVE(GPLR2);
  289. SAVE(GPDR0); SAVE(GPDR1); SAVE(GPDR2);
  290. SAVE(GRER0); SAVE(GRER1); SAVE(GRER2);
  291. SAVE(GFER0); SAVE(GFER1); SAVE(GFER2);
  292. - SAVE(PGSR0); SAVE(PGSR1); SAVE(PGSR2);
  293. -
  294. SAVE(GAFR0_L); SAVE(GAFR0_U);
  295. SAVE(GAFR1_L); SAVE(GAFR1_U);
  296. SAVE(GAFR2_L); SAVE(GAFR2_U);
  297. -#ifdef CONFIG_PXA27x
  298. - SAVE(MDREFR);
  299. - SAVE(GPLR3); SAVE(GPDR3); SAVE(GRER3); SAVE(GFER3); SAVE(PGSR3);
  300. - SAVE(GAFR3_L); SAVE(GAFR3_U);
  301. - SAVE(PWER); SAVE(PCFR); SAVE(PRER);
  302. - SAVE(PFER); SAVE(PKWR);
  303. -#endif
  304. + // YoKu 23Feb06 Added To save LCD Registers, updated by kirti 24Feb06 ----->
  305. + SAVE(LCCR0); SAVE(LCCR1); SAVE(LCCR2); SAVE(LCCR3);
  306. + SAVE(FDADR0);
  307. + SAVE(FDADR1);
  308. + LCSR = 0xffffffff; /* Clear LCD Status Register */
  309. +
  310. +// LCCR0 &= ~LCCR0_LDM; /* Enable LCD Disable Done Interrupt */
  311. +// LCCR0 |= LCCR0_DIS; /* Disable LCD Controller */
  312. +
  313. + SAVE(LDCMD0);
  314. + // <----- YoKu
  315. +
  316. +// LCCR0 &= ~LCCR0_LDM; /* Enable LCD Disable Done Interrupt */
  317. +// LCCR0 |= LCCR0_DIS; /* Disable LCD Controller */
  318. +
  319. SAVE(ICMR);
  320. ICMR = 0;
  321. SAVE(CKEN);
  322. - SAVE(PSTR);
  323. + CKEN = 0;
  324. +
  325. + // Anup : For Wifi power saving mode 2 May 2006
  326. + SAVE(NSSCR0);SAVE(NSSCR1);SAVE(NSSSR);SAVE(NSSITR);SAVE(NSSDR);SAVE(NSSTO);
  327. + SAVE(NSSPSP);
  328. + printk("\nMY favourite mode in life.......sleep.....\n");
  329. +
  330. /* Note: wake up source are set up in each machine specific files */
  331. + /*Changes to keep the right sim selected */
  332. + gpsr0 = GPLR0;
  333. + gpsr1 = GPLR1;
  334. + gpsr2 = GPLR2;
  335. +
  336. + /*Sim 1 selected */
  337. + // YoKu GPIOs Changed ----->
  338. + if( (GPLR0 & GPIO_bit(21)) && !(GPLR0 & GPIO_bit(22)) ) // 62,63
  339. + {
  340. + PGSR0 |= GPIO_bit(21) ; //62
  341. + PGSR0 &= ~GPIO_bit(22) ; //63
  342. + }
  343. + else if (!(GPLR0 & GPIO_bit(21)) && (GPLR0 & GPIO_bit(22)) ) // 62,63
  344. + {
  345. + PGSR0 |= GPIO_bit(22) ; //63
  346. + PGSR0 &= ~GPIO_bit(21) ; //62
  347. + } /* sim 2*/
  348. + // <----- YoKu
  349. +
  350. /* clear GPIO transition detect bits */
  351. GEDR0 = GEDR0; GEDR1 = GEDR1; GEDR2 = GEDR2;
  352. -#ifdef CONFIG_PXA27x
  353. - GEDR3 = GEDR3;
  354. -#endif
  355. /* Clear sleep reset status */
  356. RCSR = RCSR_SMR;
  357. + /* set resume return address */
  358. + PSPR = virt_to_phys(pxa_cpu_resume);
  359. +
  360. /* before sleeping, calculate and save a checksum */
  361. for (i = 0; i < SLEEP_SAVE_SIZE - 1; i++)
  362. checksum += sleep_save[i];
  363. sleep_save[SLEEP_SAVE_CKSUM] = checksum;
  364. - /* *** go zzz *** */
  365. - pxa_cpu_pm_enter(state);
  366. + PGSR0 |= GPIO_bit(15); //sidd for wake from Sleep 15, YoKu Comented ?? GPIO15 was ChipSelect
  367. + PGSR2 |= GPIO_bit(80); //sidd for GSM Engine 69, YoKu GPIO Changed Anup :commented
  368. +
  369. + PGSR1 &= ~GPIO_bit(33); //Tushar: BT Codec Power Down
  370. +
  371. + PGSR0 &= ~GPIO_bit(23); //Tushar: BGW200 Regulator OFF
  372. +
  373. +// GPDR1 |= GPIO_bit(49); //Tushar: LCD Serial Data in changed to O/P
  374. +
  375. +// PGSR1 &= ~GPIO_bit(48);//Tushar: LCD Serial Pins
  376. +
  377. +// PGSR1 &= ~GPIO_bit(49);
  378. +
  379. +// PGSR1 &= ~GPIO_bit(50);
  380. +
  381. +// PGSR1 |= GPIO_bit(51);
  382. +
  383. +// PGSR1 &= 0x03FFFFFF;//Tushar: 24apr LCD datalines
  384. +// PGSR2 &= 0xFFFFFC00;
  385. +
  386. + PGSR0 &= ~GPIO_bit(24); //Tushar: Mux Control Signals
  387. +
  388. + PGSR0 &= ~GPIO_bit(25);
  389. +
  390. + PGSR0 &= ~GPIO_bit(26);
  391. +
  392. + PGSR0 &= ~GPIO_bit(27);
  393. +
  394. + // GPDR0 |= GPIO_bit(17); //Tushar: unused GPIOs 19apr
  395. + // GPCR0 |= GPIO_bit(17);
  396. + PGSR0 &= ~GPIO_bit(17);
  397. +
  398. +// GPDR1 |= GPIO_bit(56); //Tushar: unused GPIOs 19apr
  399. + // GPCR1 |= GPIO_bit(56);
  400. + PGSR1 &= ~GPIO_bit(56);
  401. +
  402. +// GPDR2 |= GPIO_bit(79);//Tushar: unused GPIOs 19apr
  403. +// GPCR2 |= GPIO_bit(79);
  404. + PGSR2 &= ~GPIO_bit(79);
  405. +
  406. +// GPDR1 |= 0x03F00000;//Tushar: unused GPIOs 19apr
  407. +// GPCR1 |= 0x03F00000;
  408. + PGSR1 &= 0xFC0FFFFF;
  409. +
  410. +
  411. + GPDR0 |= GPIO_bit(19);//Tushar: SIM Present Inputs configured as outputs
  412. + GPDR0 |= GPIO_bit(20);
  413. + PGSR0 &= ~GPIO_bit(19);
  414. + PGSR0 &= ~GPIO_bit(20);
  415. +
  416. +
  417. +//Tushar: 25apr FFRTS FFDTR & FFTXD
  418. +
  419. + PGSR1 |= GPIO_bit(39);
  420. + PGSR1 |= GPIO_bit(40);
  421. + PGSR1 |= GPIO_bit(41);
  422. +/*
  423. + PGSR2 &= GPIO_bit(81); //Tushar: 24apr NSSP pins
  424. + PGSR2 &= GPIO_bit(82);
  425. + PGSR2 &= GPIO_bit(83);
  426. +
  427. + PGSR2 |= GPIO_bit(74);
  428. + PGSR2 |= GPIO_bit(75);
  429. + PGSR2 |= GPIO_bit(76);
  430. + PGSR2 |= GPIO_bit(77);
  431. +*/
  432. + if(pm_pwronoff)
  433. + {
  434. + /* We are here bcos of pressing of on off switch
  435. + We wake up now only on pwr switch */
  436. + printk("Anup: Before sleeping \n");
  437. + pm_pwronoff = 0;
  438. + PGSR0 &= ~GPIO_bit(23); //7 YoKu GPIO Changed
  439. + //PGSR2 &= ~GPIO_bit(64); //64 YoKu Commented in PWG500 64,7 was WifiReg, IN PWG600 it is 23
  440. +
  441. + PGSR2 &= ~GPIO_bit(80); //69 YoKu GPIO Changed Anup : commnented
  442. + PWER = 0x0004; // YoKu Changed from 0x10 to 0x04 (i.e GPIO 4 -> 2)
  443. + PFER = 0x0004;
  444. + PRER = 0x0004;
  445. +
  446. +// YoKu ---->
  447. +// 11May2006 To reduce Power Off current from 7mA to 4mA
  448. + GPDR0 |= GPIO_bit(16); // BTReset o/p Low
  449. + PGSR0 &= ~GPIO_bit(16);
  450. +
  451. + GPDR1 |= GPIO_bit(33); // nMEC/nPDI o/p Low
  452. + PGSR1 &= ~GPIO_bit(33);
  453. +
  454. + GPDR1 |= GPIO_bit(45); // BTRTS o/p High
  455. + PGSR1 |= GPIO_bit(45);
  456. +
  457. +
  458. + GPDR1 |= GPIO_bit(43); // BTTXD o/p High
  459. + PGSR1 |= GPIO_bit(43);
  460. +
  461. + GPDR1 &= ~GPIO_bit(42); // BTRXD i/p
  462. + GPDR1 &= ~GPIO_bit(44); // BTCTS i/p
  463. +// <---- YoKu
  464. +
  465. + PSPR = virt_to_phys(pxa_cpu_resume); // YoKu 29July05 to Resume from where u left, Original PSPR = 0
  466. + }
  467. +
  468. + valbefore = GPLR0 & (GPIO_bit(21) | GPIO_bit(22)) ; // 62,63 YoKu GPIO Changed
  469. +
  470. + //printk("Anup: Before sleeping gpsr0=0x%08x gpsr1=0x%08x gpsr2= 0x%08x\n",gpsr0,gpsr1,gpsr2);
  471. + //kirti pxa_cpu_suspend();
  472. + //printk("KER_PM: Going to sleep zzzzzzzzz\n");
  473. +
  474. +// OSCC |= OSCC_OON; //Tushar: 18 apr. enable 32.768KHz Oscillator
  475. +
  476. +// PCFR |= PCFR_OPDE; //Tushar: 18 apr. disable 3.6864MHz oscillator
  477. +
  478. + pxa_cpu_pm_enter(PM_SUSPEND_MEM);
  479. cpu_init();
  480. + //kirti~
  481. + /**/
  482. + //FFMCR |= UART_DTR ;
  483. + /**/
  484. +
  485. /* after sleeping, validate the checksum */
  486. checksum = 0;
  487. for (i = 0; i < SLEEP_SAVE_SIZE - 1; i++)
  488. @@ -141,39 +464,63 @@
  489. checksum = 0;
  490. for (i = 0; i < SLEEP_SAVE_SIZE - 1; i++)
  491. checksum += sleep_save[i];
  492. -
  493. /* if invalid, display message and wait for a hardware reset */
  494. - if (checksum != sleep_save[SLEEP_SAVE_CKSUM]) {
  495. + if (checksum != sleep_save[SLEEP_SAVE_CKSUM])
  496. + {
  497. #ifdef CONFIG_ARCH_LUBBOCK
  498. LUB_HEXLED = 0xbadbadc5;
  499. #endif
  500. while (1)
  501. - pxa_cpu_pm_enter(state);
  502. + {
  503. + printk("\n\n\nKERN_PM: CRC Error!!! after wakeup\n\n\n"); // YoKu 25May06
  504. +
  505. }
  506. + }
  507. + valafter = GPLR0 & (GPIO_bit(21) | GPIO_bit(22)) ; //62,63 YoKu GPIO Changed
  508. + pm_pedr = PEDR ;
  509. +
  510. /* ensure not to come back here if it wasn't intended */
  511. PSPR = 0;
  512. + /*printk("YoKu: gafr0_L=0x%08x gafr0_U=0x%08x\n",GAFR0_L,GAFR0_U);
  513. + printk(" gafr1_L= 0x%08x gafr1_U= 0x%08x\n",GAFR1_L,GAFR1_U);
  514. + printk(" gafr2_L= 0x%08x gafr2_U= 0x%08x\n",GAFR2_L,GAFR2_U); */
  515. /* restore registers */
  516. - RESTORE_GPLEVEL(0); RESTORE_GPLEVEL(1); RESTORE_GPLEVEL(2);
  517. RESTORE(GPDR0); RESTORE(GPDR1); RESTORE(GPDR2);
  518. + RESTORE(GRER0); RESTORE(GRER1); RESTORE(GRER2);
  519. + RESTORE(GFER0); RESTORE(GFER1); RESTORE(GFER2);
  520. RESTORE(GAFR0_L); RESTORE(GAFR0_U);
  521. RESTORE(GAFR1_L); RESTORE(GAFR1_U);
  522. RESTORE(GAFR2_L); RESTORE(GAFR2_U);
  523. - RESTORE(GRER0); RESTORE(GRER1); RESTORE(GRER2);
  524. - RESTORE(GFER0); RESTORE(GFER1); RESTORE(GFER2);
  525. - RESTORE(PGSR0); RESTORE(PGSR1); RESTORE(PGSR2);
  526. -#ifdef CONFIG_PXA27x
  527. - RESTORE(MDREFR);
  528. - RESTORE_GPLEVEL(3); RESTORE(GPDR3);
  529. - RESTORE(GAFR3_L); RESTORE(GAFR3_U);
  530. - RESTORE(GRER3); RESTORE(GFER3); RESTORE(PGSR3);
  531. - RESTORE(PWER); RESTORE(PCFR); RESTORE(PRER);
  532. - RESTORE(PFER); RESTORE(PKWR);
  533. -#endif
  534. - PSSR = PSSR_RDH | PSSR_PH;
  535. + // Anup : For Wifi power saving mode 2 May 2006
  536. + RESTORE(NSSCR0);RESTORE(NSSCR1);RESTORE(NSSSR);RESTORE(NSSITR);RESTORE(NSSDR);RESTORE(NSSTO);
  537. + RESTORE(NSSPSP);
  538. +
  539. + // PSSR = PSSR_PH;
  540. + GPSR0 = gpsr0;
  541. + GPSR1 = gpsr1;
  542. + GPSR2 = gpsr2;
  543. +
  544. + // Anup : check values of these registers
  545. +// printk("YoKu: gpsr0=0x%08x gpsr1=0x%08x gpsr2= 0x%08x\n",gpsr0,gpsr1,gpsr2);
  546. + //sidd
  547. +
  548. + GPCR0 |= ~gpsr0;
  549. + GPCR1 |= ~gpsr1;
  550. + GPCR2 |= ~gpsr2;
  551. +
  552. +
  553. + PSSR = ~PSSR_PH;
  554. +
  555. + RESTORE(OSMR0);
  556. + RESTORE(OSMR1);
  557. + RESTORE(OSMR2);
  558. + RESTORE(OSMR3);
  559. + RESTORE(OSCR);
  560. + RESTORE(OIER);
  561. RESTORE(CKEN);
  562. @@ -181,62 +528,181 @@
  563. ICCR = 1;
  564. RESTORE(ICMR);
  565. - RESTORE(PSTR);
  566. + /*
  567. + * Temporary solution. This won't be necessary once
  568. + * we move pxa support into the serial driver.
  569. + * Restore the FF UART.
  570. + */
  571. + RESTORE(BTMCR);
  572. + RESTORE(BTSPR);
  573. + RESTORE(BTLCR);
  574. + BTLCR |= 0x80;
  575. + RESTORE(BTDLH);
  576. + RESTORE(BTDLL);
  577. + RESTORE(BTLCR);
  578. + RESTORE(BTISR);
  579. + BTFCR = 0xc7;
  580. + RESTORE(BTIER);
  581. +
  582. + RESTORE(STMCR);
  583. + RESTORE(STSPR);
  584. + RESTORE(STLCR);
  585. + STLCR |= 0x80;
  586. + RESTORE(STDLH);
  587. + RESTORE(STDLL);
  588. + RESTORE(STLCR);
  589. + RESTORE(STISR);
  590. + STFCR = 0xc7;
  591. + RESTORE(STIER);
  592. +
  593. + RESTORE(FFMCR);
  594. + RESTORE(FFSPR);
  595. + RESTORE(FFLCR);
  596. + FFLCR |= 0x80;
  597. + RESTORE(FFDLH);
  598. + RESTORE(FFDLL);
  599. + RESTORE(FFLCR);
  600. + RESTORE(FFISR);
  601. + RESTORE(FFFCR);
  602. + FFFCR = 0xc7;
  603. + RESTORE(FFIER);
  604. +
  605. + // YoKu 23Feb06 Added To save LCD Registers, updated by kirti 24Feb06 ----->
  606. + RESTORE(LCCR3); RESTORE(LCCR2); RESTORE(LCCR1);
  607. + LCCR0=RESTORE(LCCR0) & ~LCCR0_ENB;
  608. + RESTORE(FDADR0); RESTORE(FDADR1);
  609. + LCCR0 |= LCCR0_ENB;
  610. +
  611. + // <----- YoKu
  612. /* restore current time */
  613. - rtc.tv_sec = RCNR;
  614. - restore_time_delta(&delta, &rtc);
  615. + xtime.tv_sec = RCNR;
  616. +
  617. + valafter1 = GPLR0 & (GPIO_bit(21) | GPIO_bit(22)) ; //62,63 YoKu GPIO Changed
  618. +
  619. +// SSCR0 &=0xFFFFFFFF;
  620. +// printk("\nPM : val of SSCR0 = %x " , SSCR0);
  621. +
  622. + printk("KER_PM: Resumed at RCNR = %d RTSR= %x\n",RCNR,RTSR);
  623. +
  624. + printk("YoKu: pgsr0=0x%08x pgsr1=0x%08x pgsr2= 0x%08x\n",PGSR0,PGSR1,PGSR2);
  625. +
  626. + OSMR0 = 0; /* set initial match at 0 */
  627. + OSSR = 0xf; /* clear status on all timers */
  628. + OIER |= OIER_E0; /* enable match on timer 0 to cause interrupts */
  629. + OSCR = 0; /* initialize free-running timer, force first match */
  630. +
  631. + leds_event(led_start);
  632. + //kirti sti();
  633. + // call i2c reset here---->
  634. + ICR = ICR_UR;
  635. + ISR = 0x7FF; //I2C_ISR_INIT;
  636. + ICR &= ~ICR_UR;
  637. +
  638. + ISAR = 0x32;//i2c->slave_addr;
  639. +
  640. + /* set control register values */
  641. + ICR = (ICR_BEIE | ICR_IRFIE | ICR_ITEIE | ICR_GCD | ICR_SCLE);//I2C_ICR_INIT;
  642. +
  643. + /* enable unit */
  644. + ICR |= ICR_IUE;
  645. + udelay(100);
  646. + //<-----
  647. +
  648. + local_irq_enable();
  649. -#ifdef DEBUG
  650. - printk(KERN_DEBUG "*** made it back from resume\n");
  651. -#endif
  652. return 0;
  653. }
  654. -EXPORT_SYMBOL_GPL(pxa_pm_enter);
  655. -
  656. unsigned long sleep_phys_sp(void *sp)
  657. {
  658. return virt_to_phys(sp);
  659. }
  660. +#ifdef CONFIG_SYSCTL
  661. /*
  662. - * Called after processes are frozen, but before we shut down devices.
  663. + * ARGH! ACPI people defined CTL_ACPI in linux/acpi.h rather than
  664. + * linux/sysctl.h.
  665. + *
  666. + * This means our interface here won't survive long - it needs a new
  667. + * interface. Quick hack to get this working - use sysctl id 9999.
  668. */
  669. -int pxa_pm_prepare(suspend_state_t state)
  670. -{
  671. - extern int pxa_cpu_pm_prepare(suspend_state_t state);
  672. +#warning ACPI broke the kernel, this interface needs to be fixed up.
  673. +#define CTL_ACPI 9999
  674. +#define ACPI_S1_SLP_TYP 19
  675. - return pxa_cpu_pm_prepare(state);
  676. +/*
  677. + * Send us to sleep.
  678. + */
  679. +static int sysctl_pm_do_suspend(ctl_table *ctl, int write, struct file *filp,
  680. + void *buffer, size_t *lenp)
  681. +{
  682. + int retval=0;
  683. + unsigned i , clock ;
  684. + if (write)
  685. + {
  686. + char buf[16], *p;
  687. + unsigned int sleepsec;
  688. + int len,left = *lenp;
  689. +
  690. + len = left;
  691. + if (left > sizeof(buf))
  692. + left = sizeof(buf);
  693. + if (!copy_from_user(buf, buffer, left))
  694. + {
  695. + buf[sizeof(buf) - 1] = '\0';
  696. + sleepsec = simple_strtoul(buf, &p, 0);
  697. + printk("\nSleeping %d Pwronoff=%x RCNR=%d\n",sleepsec,pm_pwronoff,RCNR);
  698. + printk("\nPWER %x PFER=%x PRER=%x\n",PWER,PFER,PRER);
  699. + RTAR = xtime.tv_sec + sleepsec;
  700. + printk("\nRTAR=%d \n",RTAR);
  701. + }
  702. + }
  703. + retval = pm_do_suspend();
  704. + clock = get_memclk_frequency_10khz();
  705. + return retval;
  706. }
  707. -
  708. -EXPORT_SYMBOL_GPL(pxa_pm_prepare);
  709. /*
  710. - * Called after devices are re-setup, but before processes are thawed.
  711. +static struct ctl_table pm_table[] =
  712. +{
  713. + {ACPI_S1_SLP_TYP, "suspend", NULL, 0, 0600, NULL, (proc_handler *)&sysctl_pm_do_suspend},
  714. + {0}
  715. +};
  716. */
  717. -int pxa_pm_finish(suspend_state_t state)
  718. +static struct ctl_table pm_table[] =
  719. {
  720. - return 0;
  721. + {
  722. + ctl_name: ACPI_S1_SLP_TYP,
  723. + procname: "suspend",
  724. + mode: 0600,
  725. + proc_handler: (proc_handler *)&sysctl_pm_do_suspend,
  726. + },
  727. + {
  728. + ctl_name: 0
  729. }
  730. +};
  731. -EXPORT_SYMBOL_GPL(pxa_pm_finish);
  732. +static struct ctl_table pm_dir_table[] =
  733. +{
  734. + {CTL_ACPI, "pm", NULL, 0, 0555, pm_table},
  735. + {0}
  736. +};
  737. /*
  738. - * Set to PM_DISK_FIRMWARE so we can quickly veto suspend-to-disk.
  739. + * Initialize power interface
  740. */
  741. -static struct pm_ops pxa_pm_ops = {
  742. - .pm_disk_mode = PM_DISK_FIRMWARE,
  743. - .prepare = pxa_pm_prepare,
  744. - .enter = pxa_pm_enter,
  745. - .finish = pxa_pm_finish,
  746. -};
  747. -
  748. -static int __init pxa_pm_init(void)
  749. +static int __init pm_init(void)
  750. {
  751. - pm_set_ops(&pxa_pm_ops);
  752. + register_sysctl_table(pm_dir_table, 1);
  753. + /*Adi: Adjust for clock value to RTC
  754. + RTTR = RTC clk - 1*/
  755. + RTTR = 32913;
  756. +
  757. return 0;
  758. }
  759. -device_initcall(pxa_pm_init);
  760. +__initcall(pm_init);
  761. +
  762. +#endif
  763. diff -NurbwB linux-2.6.17/arch/arm/mach-pxa/sleep.S linux-2.6.17-patched/arch/arm/mach-pxa/sleep.S
  764. --- linux-2.6.17/arch/arm/mach-pxa/sleep.S 2006-06-17 18:49:35.000000000 -0700
  765. +++ linux-2.6.17-patched/arch/arm/mach-pxa/sleep.S 2006-09-11 13:07:05.000000000 -0700
  766. @@ -79,7 +79,7 @@
  767. ldr r5, [r4]
  768. @ enable SDRAM self-refresh mode
  769. - orr r5, r5, #MDREFR_SLFRSH
  770. + orr r5, r5, #(MDREFR_SLFRSH | MDREFR_APD)
  771. #ifdef CONFIG_PXA27x
  772. @ set SDCLKx divide-by-2 bits (this is part of a workaround for Errata 50)
  773. 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
  774. --- linux-2.6.17/include/asm-arm/arch-pxa/pxa-regs.h 2006-06-17 18:49:35.000000000 -0700
  775. +++ linux-2.6.17-patched/include/asm-arm/arch-pxa/pxa-regs.h 2006-09-11 11:04:36.000000000 -0700
  776. @@ -1748,6 +1748,15 @@
  777. #define SSTO_P(x) (*(((x) == 1) ? &SSTO_P1 : ((x) == 2) ? &SSTO_P2 : ((x) == 3) ? &SSTO_P3 : NULL))
  778. #define SSPSP_P(x) (*(((x) == 1) ? &SSPSP_P1 : ((x) == 2) ? &SSPSP_P2 : ((x) == 3) ? &SSPSP_P3 : NULL))
  779. +#define NSSCR0 __REG(0x41400000) /* SSP Port 1 Control Register 0 */
  780. +#define NSSCR1 __REG(0x41400004) /* SSP Port 1 Control Register 1 */
  781. +#define NSSSR __REG(0x41400008) /* SSP Port 1 Status Register */
  782. +#define NSSITR __REG(0x4140000C) /* SSP Port 1 Interrupt Test Register */
  783. +#define NSSDR __REG(0x41400010) /* (Write / Read) SSP Port 1 Data Write Register/SSP Data Read Register */
  784. +#define NSSTO __REG(0x41400028) /* SSP Port 1 Time Out Register */
  785. +#define NSSPSP __REG(0x4140002C) /* SSP Port 1 Programmable Serial Port Register */
  786. +
  787. +
  788. /*
  789. * MultiMediaCard (MMC) controller
  790. */
  791. diff -NurbwB linux-2.6.17/kernel/power/main.c linux-2.6.17-patched/kernel/power/main.c
  792. --- linux-2.6.17/kernel/power/main.c 2006-06-17 18:49:35.000000000 -0700
  793. +++ linux-2.6.17-patched/kernel/power/main.c 2006-09-11 12:59:20.000000000 -0700
  794. @@ -66,10 +66,12 @@
  795. goto Enable_cpu;
  796. }
  797. + /*
  798. if (freeze_processes()) {
  799. error = -EAGAIN;
  800. goto Thaw;
  801. }
  802. + */
  803. if ((free_pages = nr_free_pages()) < FREE_PAGE_NUMBER) {
  804. pr_debug("PM: free some memory\n");
  805. @@ -110,12 +112,15 @@
  806. local_irq_save(flags);
  807. + /*
  808. if ((error = device_power_down(PMSG_SUSPEND))) {
  809. printk(KERN_ERR "Some devices failed to power down\n");
  810. goto Done;
  811. }
  812. + */
  813. +
  814. error = pm_ops->enter(state);
  815. - device_power_up();
  816. + //device_power_up();
  817. Done:
  818. local_irq_restore(flags);
  819. return error;