hugetlb, rmap: fix confusing page locking in hugetlb_cow()
[linux-2.6.git] / arch / arm / mach-pxa / palmtc.c
blobce1104d1bc17862834f92473cbe304070e996457
1 /*
2 * linux/arch/arm/mach-pxa/palmtc.c
4 * Support for the Palm Tungsten|C
6 * Author: Marek Vasut <marek.vasut@gmail.com>
8 * Based on work of:
9 * Petr Blaha <p3t3@centrum.cz>
10 * Chetan S. Kumar <shivakumar.chetan@gmail.com>
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2 as
14 * published by the Free Software Foundation.
17 #include <linux/platform_device.h>
18 #include <linux/delay.h>
19 #include <linux/irq.h>
20 #include <linux/input.h>
21 #include <linux/pwm_backlight.h>
22 #include <linux/gpio.h>
23 #include <linux/input/matrix_keypad.h>
24 #include <linux/ucb1400.h>
25 #include <linux/power_supply.h>
26 #include <linux/gpio_keys.h>
27 #include <linux/mtd/physmap.h>
29 #include <asm/mach-types.h>
30 #include <asm/mach/arch.h>
31 #include <asm/mach/map.h>
33 #include <mach/audio.h>
34 #include <mach/palmtc.h>
35 #include <mach/mmc.h>
36 #include <mach/pxafb.h>
37 #include <mach/mfp-pxa25x.h>
38 #include <mach/irda.h>
39 #include <mach/udc.h>
40 #include <mach/pxa2xx-regs.h>
42 #include "generic.h"
43 #include "devices.h"
45 /******************************************************************************
46 * Pin configuration
47 ******************************************************************************/
48 static unsigned long palmtc_pin_config[] __initdata = {
49 /* MMC */
50 GPIO6_MMC_CLK,
51 GPIO8_MMC_CS0,
52 GPIO12_GPIO, /* detect */
53 GPIO32_GPIO, /* power */
54 GPIO54_GPIO, /* r/o switch */
56 /* PCMCIA */
57 GPIO52_nPCE_1,
58 GPIO53_nPCE_2,
59 GPIO50_nPIOR,
60 GPIO51_nPIOW,
61 GPIO49_nPWE,
62 GPIO48_nPOE,
63 GPIO52_nPCE_1,
64 GPIO53_nPCE_2,
65 GPIO57_nIOIS16,
66 GPIO56_nPWAIT,
68 /* AC97 */
69 GPIO28_AC97_BITCLK,
70 GPIO29_AC97_SDATA_IN_0,
71 GPIO30_AC97_SDATA_OUT,
72 GPIO31_AC97_SYNC,
74 /* IrDA */
75 GPIO45_GPIO, /* ir disable */
76 GPIO46_FICP_RXD,
77 GPIO47_FICP_TXD,
79 /* PWM */
80 GPIO17_PWM1_OUT,
82 /* USB */
83 GPIO4_GPIO, /* detect */
84 GPIO36_GPIO, /* pullup */
86 /* LCD */
87 GPIOxx_LCD_TFT_16BPP,
89 /* MATRIX KEYPAD */
90 GPIO0_GPIO | WAKEUP_ON_EDGE_BOTH, /* in 0 */
91 GPIO9_GPIO | WAKEUP_ON_EDGE_BOTH, /* in 1 */
92 GPIO10_GPIO | WAKEUP_ON_EDGE_BOTH, /* in 2 */
93 GPIO11_GPIO | WAKEUP_ON_EDGE_BOTH, /* in 3 */
94 GPIO18_GPIO | MFP_LPM_DRIVE_LOW, /* out 0 */
95 GPIO19_GPIO | MFP_LPM_DRIVE_LOW, /* out 1 */
96 GPIO20_GPIO | MFP_LPM_DRIVE_LOW, /* out 2 */
97 GPIO21_GPIO | MFP_LPM_DRIVE_LOW, /* out 3 */
98 GPIO22_GPIO | MFP_LPM_DRIVE_LOW, /* out 4 */
99 GPIO23_GPIO | MFP_LPM_DRIVE_LOW, /* out 5 */
100 GPIO24_GPIO | MFP_LPM_DRIVE_LOW, /* out 6 */
101 GPIO25_GPIO | MFP_LPM_DRIVE_LOW, /* out 7 */
102 GPIO26_GPIO | MFP_LPM_DRIVE_LOW, /* out 8 */
103 GPIO27_GPIO | MFP_LPM_DRIVE_LOW, /* out 9 */
104 GPIO79_GPIO | MFP_LPM_DRIVE_LOW, /* out 10 */
105 GPIO80_GPIO | MFP_LPM_DRIVE_LOW, /* out 11 */
107 /* PXA GPIO KEYS */
108 GPIO7_GPIO | WAKEUP_ON_EDGE_BOTH, /* hotsync button on cradle */
110 /* MISC */
111 GPIO1_RST, /* reset */
112 GPIO2_GPIO, /* earphone detect */
113 GPIO16_GPIO, /* backlight switch */
116 /******************************************************************************
117 * SD/MMC card controller
118 ******************************************************************************/
119 static struct pxamci_platform_data palmtc_mci_platform_data = {
120 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
121 .gpio_power = GPIO_NR_PALMTC_SD_POWER,
122 .gpio_card_ro = GPIO_NR_PALMTC_SD_READONLY,
123 .gpio_card_detect = GPIO_NR_PALMTC_SD_DETECT_N,
124 .detect_delay_ms = 200,
127 /******************************************************************************
128 * GPIO keys
129 ******************************************************************************/
130 static struct gpio_keys_button palmtc_pxa_buttons[] = {
131 {KEY_F8, GPIO_NR_PALMTC_HOTSYNC_BUTTON, 1, "HotSync Button", EV_KEY, 1},
134 static struct gpio_keys_platform_data palmtc_pxa_keys_data = {
135 .buttons = palmtc_pxa_buttons,
136 .nbuttons = ARRAY_SIZE(palmtc_pxa_buttons),
139 static struct platform_device palmtc_pxa_keys = {
140 .name = "gpio-keys",
141 .id = -1,
142 .dev = {
143 .platform_data = &palmtc_pxa_keys_data,
147 /******************************************************************************
148 * Backlight
149 ******************************************************************************/
150 static int palmtc_backlight_init(struct device *dev)
152 int ret;
154 ret = gpio_request(GPIO_NR_PALMTC_BL_POWER, "BL POWER");
155 if (ret)
156 goto err;
157 ret = gpio_direction_output(GPIO_NR_PALMTC_BL_POWER, 1);
158 if (ret)
159 goto err2;
161 return 0;
163 err2:
164 gpio_free(GPIO_NR_PALMTC_BL_POWER);
165 err:
166 return ret;
169 static int palmtc_backlight_notify(struct device *dev, int brightness)
171 /* backlight is on when GPIO16 AF0 is high */
172 gpio_set_value(GPIO_NR_PALMTC_BL_POWER, brightness);
173 return brightness;
176 static void palmtc_backlight_exit(struct device *dev)
178 gpio_free(GPIO_NR_PALMTC_BL_POWER);
181 static struct platform_pwm_backlight_data palmtc_backlight_data = {
182 .pwm_id = 1,
183 .max_brightness = PALMTC_MAX_INTENSITY,
184 .dft_brightness = PALMTC_MAX_INTENSITY,
185 .pwm_period_ns = PALMTC_PERIOD_NS,
186 .init = palmtc_backlight_init,
187 .notify = palmtc_backlight_notify,
188 .exit = palmtc_backlight_exit,
191 static struct platform_device palmtc_backlight = {
192 .name = "pwm-backlight",
193 .dev = {
194 .parent = &pxa25x_device_pwm1.dev,
195 .platform_data = &palmtc_backlight_data,
199 /******************************************************************************
200 * IrDA
201 ******************************************************************************/
202 static struct pxaficp_platform_data palmtc_ficp_platform_data = {
203 .gpio_pwdown = GPIO_NR_PALMTC_IR_DISABLE,
204 .transceiver_cap = IR_SIRMODE | IR_OFF,
207 /******************************************************************************
208 * Keyboard
209 ******************************************************************************/
210 static const uint32_t palmtc_matrix_keys[] = {
211 KEY(0, 0, KEY_F1),
212 KEY(0, 1, KEY_X),
213 KEY(0, 2, KEY_POWER),
214 KEY(0, 3, KEY_TAB),
215 KEY(0, 4, KEY_A),
216 KEY(0, 5, KEY_Q),
217 KEY(0, 6, KEY_LEFTSHIFT),
218 KEY(0, 7, KEY_Z),
219 KEY(0, 8, KEY_S),
220 KEY(0, 9, KEY_W),
221 KEY(0, 10, KEY_E),
222 KEY(0, 11, KEY_UP),
224 KEY(1, 0, KEY_F2),
225 KEY(1, 1, KEY_DOWN),
226 KEY(1, 3, KEY_D),
227 KEY(1, 4, KEY_C),
228 KEY(1, 5, KEY_F),
229 KEY(1, 6, KEY_R),
230 KEY(1, 7, KEY_SPACE),
231 KEY(1, 8, KEY_V),
232 KEY(1, 9, KEY_G),
233 KEY(1, 10, KEY_T),
234 KEY(1, 11, KEY_LEFT),
236 KEY(2, 0, KEY_F3),
237 KEY(2, 1, KEY_LEFTCTRL),
238 KEY(2, 3, KEY_H),
239 KEY(2, 4, KEY_Y),
240 KEY(2, 5, KEY_N),
241 KEY(2, 6, KEY_J),
242 KEY(2, 7, KEY_U),
243 KEY(2, 8, KEY_M),
244 KEY(2, 9, KEY_K),
245 KEY(2, 10, KEY_I),
246 KEY(2, 11, KEY_RIGHT),
248 KEY(3, 0, KEY_F4),
249 KEY(3, 1, KEY_ENTER),
250 KEY(3, 3, KEY_DOT),
251 KEY(3, 4, KEY_L),
252 KEY(3, 5, KEY_O),
253 KEY(3, 6, KEY_LEFTALT),
254 KEY(3, 7, KEY_ENTER),
255 KEY(3, 8, KEY_BACKSPACE),
256 KEY(3, 9, KEY_P),
257 KEY(3, 10, KEY_B),
258 KEY(3, 11, KEY_FN),
261 const struct matrix_keymap_data palmtc_keymap_data = {
262 .keymap = palmtc_matrix_keys,
263 .keymap_size = ARRAY_SIZE(palmtc_matrix_keys),
266 static const unsigned int palmtc_keypad_row_gpios[] = {
267 0, 9, 10, 11
270 static const unsigned int palmtc_keypad_col_gpios[] = {
271 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 79, 80
274 static struct matrix_keypad_platform_data palmtc_keypad_platform_data = {
275 .keymap_data = &palmtc_keymap_data,
276 .row_gpios = palmtc_keypad_row_gpios,
277 .num_row_gpios = ARRAY_SIZE(palmtc_keypad_row_gpios),
278 .col_gpios = palmtc_keypad_col_gpios,
279 .num_col_gpios = ARRAY_SIZE(palmtc_keypad_col_gpios),
280 .active_low = 1,
282 .debounce_ms = 20,
283 .col_scan_delay_us = 5,
286 static struct platform_device palmtc_keyboard = {
287 .name = "matrix-keypad",
288 .id = -1,
289 .dev = {
290 .platform_data = &palmtc_keypad_platform_data,
294 /******************************************************************************
295 * UDC
296 ******************************************************************************/
297 static struct pxa2xx_udc_mach_info palmtc_udc_info __initdata = {
298 .gpio_vbus = GPIO_NR_PALMTC_USB_DETECT_N,
299 .gpio_vbus_inverted = 1,
300 .gpio_pullup = GPIO_NR_PALMTC_USB_POWER,
303 /******************************************************************************
304 * Touchscreen / Battery / GPIO-extender
305 ******************************************************************************/
306 static struct platform_device palmtc_ucb1400_core = {
307 .name = "ucb1400_core",
308 .id = -1,
311 /******************************************************************************
312 * NOR Flash
313 ******************************************************************************/
314 static struct resource palmtc_flash_resource = {
315 .start = PXA_CS0_PHYS,
316 .end = PXA_CS0_PHYS + SZ_16M - 1,
317 .flags = IORESOURCE_MEM,
320 static struct mtd_partition palmtc_flash_parts[] = {
322 .name = "U-Boot Bootloader",
323 .offset = 0x0,
324 .size = 0x40000,
327 .name = "Linux Kernel",
328 .offset = 0x40000,
329 .size = 0x2c0000,
332 .name = "Filesystem",
333 .offset = 0x300000,
334 .size = 0xcc0000,
337 .name = "U-Boot Environment",
338 .offset = 0xfc0000,
339 .size = MTDPART_SIZ_FULL,
343 static struct physmap_flash_data palmtc_flash_data = {
344 .width = 4,
345 .parts = palmtc_flash_parts,
346 .nr_parts = ARRAY_SIZE(palmtc_flash_parts),
349 static struct platform_device palmtc_flash = {
350 .name = "physmap-flash",
351 .id = -1,
352 .resource = &palmtc_flash_resource,
353 .num_resources = 1,
354 .dev = {
355 .platform_data = &palmtc_flash_data,
359 /******************************************************************************
360 * Framebuffer
361 ******************************************************************************/
362 static struct pxafb_mode_info palmtc_lcd_modes[] = {
364 .pixclock = 115384,
365 .xres = 320,
366 .yres = 320,
367 .bpp = 16,
369 .left_margin = 27,
370 .right_margin = 7,
371 .upper_margin = 7,
372 .lower_margin = 8,
374 .hsync_len = 6,
375 .vsync_len = 1,
379 static struct pxafb_mach_info palmtc_lcd_screen = {
380 .modes = palmtc_lcd_modes,
381 .num_modes = ARRAY_SIZE(palmtc_lcd_modes),
382 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
385 /******************************************************************************
386 * Machine init
387 ******************************************************************************/
388 static struct platform_device *devices[] __initdata = {
389 &palmtc_backlight,
390 &palmtc_ucb1400_core,
391 &palmtc_keyboard,
392 &palmtc_pxa_keys,
393 &palmtc_flash,
396 static void __init palmtc_init(void)
398 pxa2xx_mfp_config(ARRAY_AND_SIZE(palmtc_pin_config));
400 pxa_set_ffuart_info(NULL);
401 pxa_set_btuart_info(NULL);
402 pxa_set_stuart_info(NULL);
403 pxa_set_hwuart_info(NULL);
405 set_pxa_fb_info(&palmtc_lcd_screen);
406 pxa_set_mci_info(&palmtc_mci_platform_data);
407 pxa_set_udc_info(&palmtc_udc_info);
408 pxa_set_ac97_info(NULL);
409 pxa_set_ficp_info(&palmtc_ficp_platform_data);
411 platform_add_devices(devices, ARRAY_SIZE(devices));
414 MACHINE_START(PALMTC, "Palm Tungsten|C")
415 .phys_io = 0x40000000,
416 .boot_params = 0xa0000100,
417 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
418 .map_io = pxa_map_io,
419 .init_irq = pxa25x_init_irq,
420 .timer = &pxa_timer,
421 .init_machine = palmtc_init
422 MACHINE_END