diff options
author | Russell King <rmk+kernel@arm.linux.org.uk> | 2010-08-09 09:09:29 -0400 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2010-08-09 09:09:29 -0400 |
commit | 054d5c9238f3c577ad51195c3ee7803613f322cc (patch) | |
tree | ff7d9f5c0e0ddf14230ba28f28ef69a2c0a0debf /arch/arm/mach-pxa/palm27x.c | |
parent | 11e4afb49b7fa1fc8e1ffd850c1806dd86a08204 (diff) | |
parent | 2192482ee5ce5d5d4a6cec0c351b2d3a744606eb (diff) |
Merge branch 'devel-stable' into devel
Diffstat (limited to 'arch/arm/mach-pxa/palm27x.c')
-rw-r--r-- | arch/arm/mach-pxa/palm27x.c | 477 |
1 files changed, 477 insertions, 0 deletions
diff --git a/arch/arm/mach-pxa/palm27x.c b/arch/arm/mach-pxa/palm27x.c new file mode 100644 index 000000000000..77ad6d34ab5b --- /dev/null +++ b/arch/arm/mach-pxa/palm27x.c | |||
@@ -0,0 +1,477 @@ | |||
1 | /* | ||
2 | * Common code for Palm LD, T5, TX, Z72 | ||
3 | * | ||
4 | * Copyright (C) 2010 | ||
5 | * Marek Vasut <marek.vasut@gmail.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License version 2 as | ||
9 | * published by the Free Software Foundation. | ||
10 | * | ||
11 | */ | ||
12 | |||
13 | #include <linux/platform_device.h> | ||
14 | #include <linux/delay.h> | ||
15 | #include <linux/irq.h> | ||
16 | #include <linux/gpio_keys.h> | ||
17 | #include <linux/input.h> | ||
18 | #include <linux/pda_power.h> | ||
19 | #include <linux/pwm_backlight.h> | ||
20 | #include <linux/gpio.h> | ||
21 | #include <linux/wm97xx.h> | ||
22 | #include <linux/power_supply.h> | ||
23 | #include <linux/usb/gpio_vbus.h> | ||
24 | #include <linux/regulator/max1586.h> | ||
25 | |||
26 | #include <asm/mach-types.h> | ||
27 | #include <asm/mach/arch.h> | ||
28 | #include <asm/mach/map.h> | ||
29 | |||
30 | #include <mach/pxa27x.h> | ||
31 | #include <mach/audio.h> | ||
32 | #include <mach/mmc.h> | ||
33 | #include <mach/pxafb.h> | ||
34 | #include <mach/irda.h> | ||
35 | #include <mach/udc.h> | ||
36 | #include <mach/palmasoc.h> | ||
37 | #include <mach/palm27x.h> | ||
38 | |||
39 | #include <plat/i2c.h> | ||
40 | |||
41 | #include "generic.h" | ||
42 | #include "devices.h" | ||
43 | |||
44 | /****************************************************************************** | ||
45 | * SD/MMC card controller | ||
46 | ******************************************************************************/ | ||
47 | #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE) | ||
48 | static struct pxamci_platform_data palm27x_mci_platform_data = { | ||
49 | .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, | ||
50 | .detect_delay_ms = 200, | ||
51 | }; | ||
52 | |||
53 | void __init palm27x_mmc_init(int detect, int ro, int power, | ||
54 | int power_inverted) | ||
55 | { | ||
56 | palm27x_mci_platform_data.gpio_card_detect = detect; | ||
57 | palm27x_mci_platform_data.gpio_card_ro = ro; | ||
58 | palm27x_mci_platform_data.gpio_power = power; | ||
59 | palm27x_mci_platform_data.gpio_power_invert = power_inverted; | ||
60 | |||
61 | pxa_set_mci_info(&palm27x_mci_platform_data); | ||
62 | } | ||
63 | #endif | ||
64 | |||
65 | /****************************************************************************** | ||
66 | * Power management - standby | ||
67 | ******************************************************************************/ | ||
68 | #if defined(CONFIG_SUSPEND) | ||
69 | void __init palm27x_pm_init(unsigned long str_base) | ||
70 | { | ||
71 | static const unsigned long resume[] = { | ||
72 | 0xe3a00101, /* mov r0, #0x40000000 */ | ||
73 | 0xe380060f, /* orr r0, r0, #0x00f00000 */ | ||
74 | 0xe590f008, /* ldr pc, [r0, #0x08] */ | ||
75 | }; | ||
76 | |||
77 | /* | ||
78 | * Copy the bootloader. | ||
79 | * NOTE: PalmZ72 uses a different wakeup method! | ||
80 | */ | ||
81 | memcpy(phys_to_virt(str_base), resume, sizeof(resume)); | ||
82 | } | ||
83 | #endif | ||
84 | |||
85 | /****************************************************************************** | ||
86 | * Framebuffer | ||
87 | ******************************************************************************/ | ||
88 | #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE) | ||
89 | struct pxafb_mode_info palm_320x480_lcd_mode = { | ||
90 | .pixclock = 57692, | ||
91 | .xres = 320, | ||
92 | .yres = 480, | ||
93 | .bpp = 16, | ||
94 | |||
95 | .left_margin = 32, | ||
96 | .right_margin = 1, | ||
97 | .upper_margin = 7, | ||
98 | .lower_margin = 1, | ||
99 | |||
100 | .hsync_len = 4, | ||
101 | .vsync_len = 1, | ||
102 | }; | ||
103 | |||
104 | struct pxafb_mode_info palm_320x320_lcd_mode = { | ||
105 | .pixclock = 115384, | ||
106 | .xres = 320, | ||
107 | .yres = 320, | ||
108 | .bpp = 16, | ||
109 | |||
110 | .left_margin = 27, | ||
111 | .right_margin = 7, | ||
112 | .upper_margin = 7, | ||
113 | .lower_margin = 8, | ||
114 | |||
115 | .hsync_len = 6, | ||
116 | .vsync_len = 1, | ||
117 | }; | ||
118 | |||
119 | struct pxafb_mode_info palm_320x320_new_lcd_mode = { | ||
120 | .pixclock = 86538, | ||
121 | .xres = 320, | ||
122 | .yres = 320, | ||
123 | .bpp = 16, | ||
124 | |||
125 | .left_margin = 20, | ||
126 | .right_margin = 8, | ||
127 | .upper_margin = 8, | ||
128 | .lower_margin = 5, | ||
129 | |||
130 | .hsync_len = 4, | ||
131 | .vsync_len = 1, | ||
132 | }; | ||
133 | |||
134 | static struct pxafb_mach_info palm27x_lcd_screen = { | ||
135 | .num_modes = 1, | ||
136 | .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL, | ||
137 | }; | ||
138 | |||
139 | static int palm27x_lcd_power; | ||
140 | static void palm27x_lcd_ctl(int on, struct fb_var_screeninfo *info) | ||
141 | { | ||
142 | gpio_set_value(palm27x_lcd_power, on); | ||
143 | } | ||
144 | |||
145 | void __init palm27x_lcd_init(int power, struct pxafb_mode_info *mode) | ||
146 | { | ||
147 | palm27x_lcd_screen.modes = mode; | ||
148 | |||
149 | if (gpio_is_valid(power)) { | ||
150 | if (!gpio_request(power, "LCD power")) { | ||
151 | pr_err("Palm27x: failed to claim lcd power gpio!\n"); | ||
152 | return; | ||
153 | } | ||
154 | if (!gpio_direction_output(power, 1)) { | ||
155 | pr_err("Palm27x: lcd power configuration failed!\n"); | ||
156 | return; | ||
157 | } | ||
158 | palm27x_lcd_power = power; | ||
159 | palm27x_lcd_screen.pxafb_lcd_power = palm27x_lcd_ctl; | ||
160 | } | ||
161 | |||
162 | set_pxa_fb_info(&palm27x_lcd_screen); | ||
163 | } | ||
164 | #endif | ||
165 | |||
166 | /****************************************************************************** | ||
167 | * USB Gadget | ||
168 | ******************************************************************************/ | ||
169 | #if defined(CONFIG_USB_GADGET_PXA27X) || \ | ||
170 | defined(CONFIG_USB_GADGET_PXA27X_MODULE) | ||
171 | static struct gpio_vbus_mach_info palm27x_udc_info = { | ||
172 | .gpio_vbus_inverted = 1, | ||
173 | }; | ||
174 | |||
175 | static struct platform_device palm27x_gpio_vbus = { | ||
176 | .name = "gpio-vbus", | ||
177 | .id = -1, | ||
178 | .dev = { | ||
179 | .platform_data = &palm27x_udc_info, | ||
180 | }, | ||
181 | }; | ||
182 | |||
183 | void __init palm27x_udc_init(int vbus, int pullup, int vbus_inverted) | ||
184 | { | ||
185 | palm27x_udc_info.gpio_vbus = vbus; | ||
186 | palm27x_udc_info.gpio_pullup = pullup; | ||
187 | |||
188 | palm27x_udc_info.gpio_vbus_inverted = vbus_inverted; | ||
189 | |||
190 | if (!gpio_request(pullup, "USB Pullup")) { | ||
191 | gpio_direction_output(pullup, | ||
192 | palm27x_udc_info.gpio_vbus_inverted); | ||
193 | gpio_free(pullup); | ||
194 | } else | ||
195 | return; | ||
196 | |||
197 | platform_device_register(&palm27x_gpio_vbus); | ||
198 | } | ||
199 | #endif | ||
200 | |||
201 | /****************************************************************************** | ||
202 | * IrDA | ||
203 | ******************************************************************************/ | ||
204 | #if defined(CONFIG_IRDA) || defined(CONFIG_IRDA_MODULE) | ||
205 | static struct pxaficp_platform_data palm27x_ficp_platform_data = { | ||
206 | .transceiver_cap = IR_SIRMODE | IR_OFF, | ||
207 | }; | ||
208 | |||
209 | void __init palm27x_irda_init(int pwdn) | ||
210 | { | ||
211 | palm27x_ficp_platform_data.gpio_pwdown = pwdn; | ||
212 | pxa_set_ficp_info(&palm27x_ficp_platform_data); | ||
213 | } | ||
214 | #endif | ||
215 | |||
216 | /****************************************************************************** | ||
217 | * WM97xx audio, battery | ||
218 | ******************************************************************************/ | ||
219 | #if defined(CONFIG_TOUCHSCREEN_WM97XX) || \ | ||
220 | defined(CONFIG_TOUCHSCREEN_WM97XX_MODULE) | ||
221 | static struct wm97xx_batt_pdata palm27x_batt_pdata = { | ||
222 | .batt_aux = WM97XX_AUX_ID3, | ||
223 | .temp_aux = WM97XX_AUX_ID2, | ||
224 | .charge_gpio = -1, | ||
225 | .batt_mult = 1000, | ||
226 | .batt_div = 414, | ||
227 | .temp_mult = 1, | ||
228 | .temp_div = 1, | ||
229 | .batt_tech = POWER_SUPPLY_TECHNOLOGY_LIPO, | ||
230 | .batt_name = "main-batt", | ||
231 | }; | ||
232 | |||
233 | static struct wm97xx_pdata palm27x_wm97xx_pdata = { | ||
234 | .batt_pdata = &palm27x_batt_pdata, | ||
235 | }; | ||
236 | |||
237 | static pxa2xx_audio_ops_t palm27x_ac97_pdata = { | ||
238 | .codec_pdata = { &palm27x_wm97xx_pdata, }, | ||
239 | }; | ||
240 | |||
241 | static struct palm27x_asoc_info palm27x_asoc_pdata = { | ||
242 | .jack_gpio = -1, | ||
243 | }; | ||
244 | |||
245 | static struct platform_device palm27x_asoc = { | ||
246 | .name = "palm27x-asoc", | ||
247 | .id = -1, | ||
248 | .dev = { | ||
249 | .platform_data = &palm27x_asoc_pdata, | ||
250 | }, | ||
251 | }; | ||
252 | |||
253 | void __init palm27x_ac97_init(int minv, int maxv, int jack, int reset) | ||
254 | { | ||
255 | palm27x_ac97_pdata.reset_gpio = reset; | ||
256 | palm27x_asoc_pdata.jack_gpio = jack; | ||
257 | |||
258 | if (minv < 0 || maxv < 0) { | ||
259 | palm27x_ac97_pdata.codec_pdata[0] = NULL; | ||
260 | pxa_set_ac97_info(&palm27x_ac97_pdata); | ||
261 | } else { | ||
262 | palm27x_batt_pdata.min_voltage = minv, | ||
263 | palm27x_batt_pdata.max_voltage = maxv, | ||
264 | |||
265 | pxa_set_ac97_info(&palm27x_ac97_pdata); | ||
266 | platform_device_register(&palm27x_asoc); | ||
267 | } | ||
268 | } | ||
269 | #endif | ||
270 | |||
271 | /****************************************************************************** | ||
272 | * Backlight | ||
273 | ******************************************************************************/ | ||
274 | #if defined(CONFIG_BACKLIGHT_PWM) || defined(CONFIG_BACKLIGHT_PWM_MODULE) | ||
275 | static int palm_bl_power; | ||
276 | static int palm_lcd_power; | ||
277 | |||
278 | static int palm27x_backlight_init(struct device *dev) | ||
279 | { | ||
280 | int ret; | ||
281 | |||
282 | ret = gpio_request(palm_bl_power, "BL POWER"); | ||
283 | if (ret) | ||
284 | goto err; | ||
285 | ret = gpio_direction_output(palm_bl_power, 0); | ||
286 | if (ret) | ||
287 | goto err2; | ||
288 | |||
289 | if (gpio_is_valid(palm_lcd_power)) { | ||
290 | ret = gpio_request(palm_lcd_power, "LCD POWER"); | ||
291 | if (ret) | ||
292 | goto err2; | ||
293 | ret = gpio_direction_output(palm_lcd_power, 0); | ||
294 | if (ret) | ||
295 | goto err3; | ||
296 | } | ||
297 | |||
298 | return 0; | ||
299 | err3: | ||
300 | gpio_free(palm_lcd_power); | ||
301 | err2: | ||
302 | gpio_free(palm_bl_power); | ||
303 | err: | ||
304 | return ret; | ||
305 | } | ||
306 | |||
307 | static int palm27x_backlight_notify(struct device *dev, int brightness) | ||
308 | { | ||
309 | gpio_set_value(palm_bl_power, brightness); | ||
310 | if (gpio_is_valid(palm_lcd_power)) | ||
311 | gpio_set_value(palm_lcd_power, brightness); | ||
312 | return brightness; | ||
313 | } | ||
314 | |||
315 | static void palm27x_backlight_exit(struct device *dev) | ||
316 | { | ||
317 | gpio_free(palm_bl_power); | ||
318 | if (gpio_is_valid(palm_lcd_power)) | ||
319 | gpio_free(palm_lcd_power); | ||
320 | } | ||
321 | |||
322 | static struct platform_pwm_backlight_data palm27x_backlight_data = { | ||
323 | .pwm_id = 0, | ||
324 | .max_brightness = 0xfe, | ||
325 | .dft_brightness = 0x7e, | ||
326 | .pwm_period_ns = 3500, | ||
327 | .init = palm27x_backlight_init, | ||
328 | .notify = palm27x_backlight_notify, | ||
329 | .exit = palm27x_backlight_exit, | ||
330 | }; | ||
331 | |||
332 | static struct platform_device palm27x_backlight = { | ||
333 | .name = "pwm-backlight", | ||
334 | .dev = { | ||
335 | .parent = &pxa27x_device_pwm0.dev, | ||
336 | .platform_data = &palm27x_backlight_data, | ||
337 | }, | ||
338 | }; | ||
339 | |||
340 | void __init palm27x_pwm_init(int bl, int lcd) | ||
341 | { | ||
342 | palm_bl_power = bl; | ||
343 | palm_lcd_power = lcd; | ||
344 | platform_device_register(&palm27x_backlight); | ||
345 | } | ||
346 | #endif | ||
347 | |||
348 | /****************************************************************************** | ||
349 | * Power supply | ||
350 | ******************************************************************************/ | ||
351 | #if defined(CONFIG_PDA_POWER) || defined(CONFIG_PDA_POWER_MODULE) | ||
352 | static int palm_ac_state; | ||
353 | static int palm_usb_state; | ||
354 | |||
355 | static int palm27x_power_supply_init(struct device *dev) | ||
356 | { | ||
357 | int ret; | ||
358 | |||
359 | ret = gpio_request(palm_ac_state, "AC state"); | ||
360 | if (ret) | ||
361 | goto err1; | ||
362 | ret = gpio_direction_input(palm_ac_state); | ||
363 | if (ret) | ||
364 | goto err2; | ||
365 | |||
366 | if (gpio_is_valid(palm_usb_state)) { | ||
367 | ret = gpio_request(palm_usb_state, "USB state"); | ||
368 | if (ret) | ||
369 | goto err2; | ||
370 | ret = gpio_direction_input(palm_usb_state); | ||
371 | if (ret) | ||
372 | goto err3; | ||
373 | } | ||
374 | |||
375 | return 0; | ||
376 | err3: | ||
377 | gpio_free(palm_usb_state); | ||
378 | err2: | ||
379 | gpio_free(palm_ac_state); | ||
380 | err1: | ||
381 | return ret; | ||
382 | } | ||
383 | |||
384 | static void palm27x_power_supply_exit(struct device *dev) | ||
385 | { | ||
386 | gpio_free(palm_usb_state); | ||
387 | gpio_free(palm_ac_state); | ||
388 | } | ||
389 | |||
390 | static int palm27x_is_ac_online(void) | ||
391 | { | ||
392 | return gpio_get_value(palm_ac_state); | ||
393 | } | ||
394 | |||
395 | static int palm27x_is_usb_online(void) | ||
396 | { | ||
397 | return !gpio_get_value(palm_usb_state); | ||
398 | } | ||
399 | static char *palm27x_supplicants[] = { | ||
400 | "main-battery", | ||
401 | }; | ||
402 | |||
403 | static struct pda_power_pdata palm27x_ps_info = { | ||
404 | .init = palm27x_power_supply_init, | ||
405 | .exit = palm27x_power_supply_exit, | ||
406 | .is_ac_online = palm27x_is_ac_online, | ||
407 | .is_usb_online = palm27x_is_usb_online, | ||
408 | .supplied_to = palm27x_supplicants, | ||
409 | .num_supplicants = ARRAY_SIZE(palm27x_supplicants), | ||
410 | }; | ||
411 | |||
412 | static struct platform_device palm27x_power_supply = { | ||
413 | .name = "pda-power", | ||
414 | .id = -1, | ||
415 | .dev = { | ||
416 | .platform_data = &palm27x_ps_info, | ||
417 | }, | ||
418 | }; | ||
419 | |||
420 | void __init palm27x_power_init(int ac, int usb) | ||
421 | { | ||
422 | palm_ac_state = ac; | ||
423 | palm_usb_state = usb; | ||
424 | platform_device_register(&palm27x_power_supply); | ||
425 | } | ||
426 | #endif | ||
427 | |||
428 | /****************************************************************************** | ||
429 | * Core power regulator | ||
430 | ******************************************************************************/ | ||
431 | #if defined(CONFIG_REGULATOR_MAX1586) || \ | ||
432 | defined(CONFIG_REGULATOR_MAX1586_MODULE) | ||
433 | static struct regulator_consumer_supply palm27x_max1587a_consumers[] = { | ||
434 | { | ||
435 | .supply = "vcc_core", | ||
436 | } | ||
437 | }; | ||
438 | |||
439 | static struct regulator_init_data palm27x_max1587a_v3_info = { | ||
440 | .constraints = { | ||
441 | .name = "vcc_core range", | ||
442 | .min_uV = 900000, | ||
443 | .max_uV = 1705000, | ||
444 | .always_on = 1, | ||
445 | .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE, | ||
446 | }, | ||
447 | .consumer_supplies = palm27x_max1587a_consumers, | ||
448 | .num_consumer_supplies = ARRAY_SIZE(palm27x_max1587a_consumers), | ||
449 | }; | ||
450 | |||
451 | static struct max1586_subdev_data palm27x_max1587a_subdevs[] = { | ||
452 | { | ||
453 | .name = "vcc_core", | ||
454 | .id = MAX1586_V3, | ||
455 | .platform_data = &palm27x_max1587a_v3_info, | ||
456 | } | ||
457 | }; | ||
458 | |||
459 | static struct max1586_platform_data palm27x_max1587a_info = { | ||
460 | .subdevs = palm27x_max1587a_subdevs, | ||
461 | .num_subdevs = ARRAY_SIZE(palm27x_max1587a_subdevs), | ||
462 | .v3_gain = MAX1586_GAIN_R24_3k32, /* 730..1550 mV */ | ||
463 | }; | ||
464 | |||
465 | static struct i2c_board_info __initdata palm27x_pi2c_board_info[] = { | ||
466 | { | ||
467 | I2C_BOARD_INFO("max1586", 0x14), | ||
468 | .platform_data = &palm27x_max1587a_info, | ||
469 | }, | ||
470 | }; | ||
471 | |||
472 | void __init palm27x_pmic_init(void) | ||
473 | { | ||
474 | i2c_register_board_info(1, ARRAY_AND_SIZE(palm27x_pi2c_board_info)); | ||
475 | pxa27x_set_i2c_power_info(NULL); | ||
476 | } | ||
477 | #endif | ||