sync hh.org
[hh.org.git] / arch / arm / mach-pxa / asus730 / a730_pm.c
blob8d51b116fe73395efde3e775a48f721c09d569d3
1 /*
2 * asus730 suspend/resume support based on code for asus716
4 * Use consistent with the GNU GPL is permitted, provided that this
5 * copyright notice is preserved in its entirety in all copies and
6 * derived works.
8 * Copyright (C) 2005 Michal Sroczynski
10 * 03 Apr 2006
11 * Serge Nikolaenko USB Host platform init
12 * Suspend preparations
15 #include <linux/kernel.h>
16 #include <linux/module.h>
17 #include <linux/device.h>
18 #include <linux/pm.h>
19 #include <linux/fb.h>
20 #include <linux/backlight.h>
21 #include <linux/lcd.h>
23 #include <asm/mach-types.h>
24 #include <asm/hardware.h>
25 #include <asm/arch/asus730-gpio.h>
26 #include <asm/arch/asus730-init.h>
27 #include <asm/arch/pxa-regs.h>
28 #include <asm/arch/pxa-pm_ll.h>
30 static u32 *addr_a1440000;
31 static u32 save_a1440000;
33 static u32 *addr_a1441000;
34 static u32 *addr_a1441004;
35 static u32 *addr_a1441008;
36 static u32 save_a1441000;
37 static u32 save_a1441004;
38 static u32 save_a1441008;
40 //extern int a730_bl_set_brightness(struct backlight_device *const bm, const int level);
41 //extern int a730_bl_get_brightness(struct backlight_device *const bm);
42 //extern int a730_bl_set_power(struct backlight_device *, int);
43 //extern int a730_lcd_set_power(struct lcd_device *, int);
45 extern void pca9535_write_output(u16);
46 extern void pca9535_init_chip(void);
48 typedef struct
50 int brightness;
51 } pm_save_data;
53 static void a730_pxa_ll_pm_suspend(unsigned long resume_addr)
55 save_a1440000 = *addr_a1440000;
56 save_a1441000 = *addr_a1441000;
57 save_a1441004 = *addr_a1441004;
58 save_a1441008 = *addr_a1441008;
60 *addr_a1440000 = 0xea0003fe; // b +0x1000
61 *addr_a1441000 = 0xe59f0000; // ldr r0, [pc, #0]
62 *addr_a1441004 = 0xe590f000; // ldr pc,[r0]
63 *addr_a1441008 = 0x40f00008; // data (PSPR addr)
65 return;
68 static void a730_pxa_ll_pm_resume(void)
70 *addr_a1440000 = save_a1440000;
71 *addr_a1441000 = save_a1441000;
72 *addr_a1441004 = save_a1441004;
73 *addr_a1441008 = save_a1441008;
76 static struct pxa_ll_pm_ops a730_ll_pm_ops = {
77 .suspend = a730_pxa_ll_pm_suspend,
78 .resume = a730_pxa_ll_pm_resume,
81 void a730_ll_pm_init(void) {
82 addr_a1440000 = phys_to_virt(0xa1440000);
83 addr_a1441000 = phys_to_virt(0xa1441000);
84 addr_a1441004 = phys_to_virt(0xa1441004);
85 addr_a1441008 = phys_to_virt(0xa1441008);
87 pxa_pm_set_ll_ops(&a730_ll_pm_ops);
88 // PWER = PWER_RTC | PWER_GPIO0 | PWER_GPIO1 | PWER_GPIO10 | PWER_GPIO12 | PWER_GPIO13 | 0x10000;
89 // PFER = PWER_GPIO12;
92 int a730_suspend(struct device *dev, pm_message_t state)
94 pm_save_data *save;
96 if (!dev->power.saved_state) dev->power.saved_state = kmalloc((sizeof(pm_save_data)), GFP_KERNEL);
97 if (!dev->power.saved_state) return -ENOMEM;
99 save = dev->power.saved_state;
101 return 0;
104 int a730_resume(struct device *dev)
106 if (dev->power.saved_state)
108 pm_save_data *save = dev->power.saved_state;
109 //a730_bl_set_brightness(NULL, save->brightness);
112 kfree(dev->power.saved_state);
113 dev->power.saved_state = NULL;
115 printk("PGSR0 0x%x - 0x%x\n", PGSR0, GPSRx_SleepValue);
116 printk("PGSR1 0x%x - 0x%x\n", PGSR1, GPSRy_SleepValue);
117 printk("PGSR2 0x%x - 0x%x\n", PGSR2, GPSRz_SleepValue);
119 printk("GAFR0_L 0x%x - 0x%x\n", GAFR0_L, GAFR0x_InitValue);
120 printk("GAFR0_U 0x%x - 0x%x\n", GAFR0_U, GAFR1x_InitValue);
121 printk("GAFR1_L 0x%x - 0x%x\n", GAFR1_L, GAFR0y_InitValue);
122 printk("GAFR1_U 0x%x - 0x%x\n", GAFR1_U, GAFR1y_InitValue);
123 printk("GAFR2_L 0x%x - 0x%x\n", GAFR2_L, GAFR0z_InitValue);
124 printk("GAFR2_U 0x%x - 0x%x\n", GAFR2_U, GAFR1z_InitValue);
126 printk("GPDR0 0x%x - 0x%x\n", GPDR0, GPDRx_InitValue);
127 printk("GPDR1 0x%x - 0x%x\n", GPDR1, GPDRy_InitValue);
128 printk("GPDR2 0x%x - 0x%x\n", GPDR2, GPDRz_InitValue);
130 printk("GPSR0 0x%x - 0x%x\n", GPSR0, GPSRx_InitValue);
131 printk("GPSR1 0x%x - 0x%x\n", GPSR1, GPSRy_InitValue);
132 printk("GPSR2 0x%x - 0x%x\n", GPSR2, GPSRz_InitValue);
134 printk("GPCR0 0x%x - 0x%x\n", GPCR0, ~GPSRx_InitValue);
135 printk("GPCR1 0x%x - 0x%x\n", GPCR1, ~GPSRy_InitValue);
136 printk("GPCR2 0x%x - 0x%x\n", GPCR2, ~GPSRz_InitValue);
138 return 0;