Merge commit 'v2.6.39' into 20110526
[linux-2.6.git] / arch / arm / mach-mmp / include / mach / pxa168.h
1 #ifndef __ASM_MACH_PXA168_H
2 #define __ASM_MACH_PXA168_H
3
4 struct sys_timer;
5
6 extern struct sys_timer pxa168_timer;
7 extern void __init pxa168_init_irq(void);
8 extern void pxa168_clear_keypad_wakeup(void);
9
10 #include <linux/i2c.h>
11 #include <linux/i2c/pxa-i2c.h>
12 #include <mach/devices.h>
13 #include <plat/pxa3xx_nand.h>
14 #include <video/pxa168fb.h>
15 #include <plat/pxa27x_keypad.h>
16 #include <mach/cputype.h>
17
18 extern struct pxa_device_desc pxa168_device_uart1;
19 extern struct pxa_device_desc pxa168_device_uart2;
20 extern struct pxa_device_desc pxa168_device_twsi0;
21 extern struct pxa_device_desc pxa168_device_twsi1;
22 extern struct pxa_device_desc pxa168_device_pwm1;
23 extern struct pxa_device_desc pxa168_device_pwm2;
24 extern struct pxa_device_desc pxa168_device_pwm3;
25 extern struct pxa_device_desc pxa168_device_pwm4;
26 extern struct pxa_device_desc pxa168_device_ssp1;
27 extern struct pxa_device_desc pxa168_device_ssp2;
28 extern struct pxa_device_desc pxa168_device_ssp3;
29 extern struct pxa_device_desc pxa168_device_ssp4;
30 extern struct pxa_device_desc pxa168_device_ssp5;
31 extern struct pxa_device_desc pxa168_device_nand;
32 extern struct pxa_device_desc pxa168_device_fb;
33 extern struct pxa_device_desc pxa168_device_keypad;
34
35 static inline int pxa168_add_uart(int id)
36 {
37         struct pxa_device_desc *d = NULL;
38
39         switch (id) {
40         case 1: d = &pxa168_device_uart1; break;
41         case 2: d = &pxa168_device_uart2; break;
42         }
43
44         if (d == NULL)
45                 return -EINVAL;
46
47         return pxa_register_device(d, NULL, 0);
48 }
49
50 static inline int pxa168_add_twsi(int id, struct i2c_pxa_platform_data *data,
51                                   struct i2c_board_info *info, unsigned size)
52 {
53         struct pxa_device_desc *d = NULL;
54         int ret;
55
56         switch (id) {
57         case 0: d = &pxa168_device_twsi0; break;
58         case 1: d = &pxa168_device_twsi1; break;
59         default:
60                 return -EINVAL;
61         }
62
63         ret = i2c_register_board_info(id, info, size);
64         if (ret)
65                 return ret;
66
67         return pxa_register_device(d, data, sizeof(*data));
68 }
69
70 static inline int pxa168_add_pwm(int id)
71 {
72         struct pxa_device_desc *d = NULL;
73
74         switch (id) {
75         case 1: d = &pxa168_device_pwm1; break;
76         case 2: d = &pxa168_device_pwm2; break;
77         case 3: d = &pxa168_device_pwm3; break;
78         case 4: d = &pxa168_device_pwm4; break;
79         default:
80                 return -EINVAL;
81         }
82
83         return pxa_register_device(d, NULL, 0);
84 }
85
86 static inline int pxa168_add_ssp(int id)
87 {
88         struct pxa_device_desc *d = NULL;
89
90         switch (id) {
91         case 1: d = &pxa168_device_ssp1; break;
92         case 2: d = &pxa168_device_ssp2; break;
93         case 3: d = &pxa168_device_ssp3; break;
94         case 4: d = &pxa168_device_ssp4; break;
95         case 5: d = &pxa168_device_ssp5; break;
96         default:
97                 return -EINVAL;
98         }
99         return pxa_register_device(d, NULL, 0);
100 }
101
102 static inline int pxa168_add_nand(struct pxa3xx_nand_platform_data *info)
103 {
104         return pxa_register_device(&pxa168_device_nand, info, sizeof(*info));
105 }
106
107 static inline int pxa168_add_fb(struct pxa168fb_mach_info *mi)
108 {
109         return pxa_register_device(&pxa168_device_fb, mi, sizeof(*mi));
110 }
111
112 static inline int pxa168_add_keypad(struct pxa27x_keypad_platform_data *data)
113 {
114         if (cpu_is_pxa168())
115                 data->clear_wakeup_event = pxa168_clear_keypad_wakeup;
116
117         return pxa_register_device(&pxa168_device_keypad, data, sizeof(*data));
118 }
119
120 #endif /* __ASM_MACH_PXA168_H */