blob: b09a9efeb77c9c0beb8718242c49ccdce3944593 [file] [log] [blame]
Marek Vasut54088bf2009-03-24 00:29:29 +01001/*
2 * Hardware definitions for Palm Tungsten|E2
3 *
4 * Author:
5 * Carlos Eduardo Medaglia Dyonisio <cadu@nerdfeliz.com>
6 *
7 * Rewrite for mainline:
8 * Marek Vasut <marek.vasut@gmail.com>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
13 *
14 * (find more info at www.hackndev.com)
15 *
16 */
17
18#include <linux/platform_device.h>
19#include <linux/delay.h>
20#include <linux/irq.h>
21#include <linux/gpio_keys.h>
22#include <linux/input.h>
Marek Vasut8c8aa5f2009-03-24 21:23:39 +010023#include <linux/pda_power.h>
Marek Vasut54088bf2009-03-24 00:29:29 +010024#include <linux/pwm_backlight.h>
25#include <linux/gpio.h>
Marek Vasut8c8aa5f2009-03-24 21:23:39 +010026#include <linux/wm97xx_batt.h>
27#include <linux/power_supply.h>
Marek Vasut8768dc92009-04-23 11:12:37 +020028#include <linux/usb/gpio_vbus.h>
Marek Vasut54088bf2009-03-24 00:29:29 +010029
30#include <asm/mach-types.h>
31#include <asm/mach/arch.h>
32#include <asm/mach/map.h>
33
34#include <mach/audio.h>
35#include <mach/palmte2.h>
36#include <mach/mmc.h>
37#include <mach/pxafb.h>
38#include <mach/mfp-pxa25x.h>
Marek Vasut8c8aa5f2009-03-24 21:23:39 +010039#include <mach/irda.h>
40#include <mach/udc.h>
Marek Vasut54088bf2009-03-24 00:29:29 +010041
42#include "generic.h"
43#include "devices.h"
44
45/******************************************************************************
46 * Pin configuration
47 ******************************************************************************/
48static unsigned long palmte2_pin_config[] __initdata = {
49 /* MMC */
50 GPIO6_MMC_CLK,
51 GPIO8_MMC_CS0,
52 GPIO10_GPIO, /* SD detect */
53 GPIO55_GPIO, /* SD power */
54 GPIO51_GPIO, /* SD r/o switch */
55
56 /* AC97 */
57 GPIO28_AC97_BITCLK,
58 GPIO29_AC97_SDATA_IN_0,
59 GPIO30_AC97_SDATA_OUT,
60 GPIO31_AC97_SYNC,
61
62 /* PWM */
63 GPIO16_PWM0_OUT,
64
Marek Vasut8c8aa5f2009-03-24 21:23:39 +010065 /* USB */
66 GPIO15_GPIO, /* usb detect */
67 GPIO53_GPIO, /* usb power */
68
69 /* IrDA */
70 GPIO48_GPIO, /* ir disable */
71 GPIO46_FICP_RXD,
72 GPIO47_FICP_TXD,
73
Marek Vasut54088bf2009-03-24 00:29:29 +010074 /* LCD */
75 GPIO58_LCD_LDD_0,
76 GPIO59_LCD_LDD_1,
77 GPIO60_LCD_LDD_2,
78 GPIO61_LCD_LDD_3,
79 GPIO62_LCD_LDD_4,
80 GPIO63_LCD_LDD_5,
81 GPIO64_LCD_LDD_6,
82 GPIO65_LCD_LDD_7,
83 GPIO66_LCD_LDD_8,
84 GPIO67_LCD_LDD_9,
85 GPIO68_LCD_LDD_10,
86 GPIO69_LCD_LDD_11,
87 GPIO70_LCD_LDD_12,
88 GPIO71_LCD_LDD_13,
89 GPIO72_LCD_LDD_14,
90 GPIO73_LCD_LDD_15,
91 GPIO74_LCD_FCLK,
92 GPIO75_LCD_LCLK,
93 GPIO76_LCD_PCLK,
Marek Vasut8c8aa5f2009-03-24 21:23:39 +010094 GPIO77_LCD_BIAS,
Marek Vasut54088bf2009-03-24 00:29:29 +010095
96 /* GPIO KEYS */
97 GPIO5_GPIO, /* notes */
98 GPIO7_GPIO, /* tasks */
99 GPIO11_GPIO, /* calendar */
100 GPIO13_GPIO, /* contacts */
101 GPIO14_GPIO, /* center */
102 GPIO19_GPIO, /* left */
103 GPIO20_GPIO, /* right */
104 GPIO21_GPIO, /* down */
105 GPIO22_GPIO, /* up */
106
107 /* MISC */
108 GPIO1_RST, /* reset */
Marek Vasut8c8aa5f2009-03-24 21:23:39 +0100109 GPIO4_GPIO, /* Hotsync button */
110 GPIO9_GPIO, /* power detect */
111 GPIO37_GPIO, /* LCD power */
112 GPIO56_GPIO, /* Backlight power */
Marek Vasut54088bf2009-03-24 00:29:29 +0100113};
114
115/******************************************************************************
116 * SD/MMC card controller
117 ******************************************************************************/
118static int palmte2_mci_init(struct device *dev,
119 irq_handler_t palmte2_detect_int, void *data)
120{
121 int err = 0;
122
123 /* Setup an interrupt for detecting card insert/remove events */
124 err = gpio_request(GPIO_NR_PALMTE2_SD_DETECT_N, "SD IRQ");
125 if (err)
126 goto err;
127 err = gpio_direction_input(GPIO_NR_PALMTE2_SD_DETECT_N);
128 if (err)
129 goto err2;
130 err = request_irq(gpio_to_irq(GPIO_NR_PALMTE2_SD_DETECT_N),
131 palmte2_detect_int, IRQF_DISABLED | IRQF_SAMPLE_RANDOM |
132 IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
133 "SD/MMC card detect", data);
134 if (err) {
135 printk(KERN_ERR "%s: cannot request SD/MMC card detect IRQ\n",
136 __func__);
137 goto err2;
138 }
139
140 err = gpio_request(GPIO_NR_PALMTE2_SD_POWER, "SD_POWER");
141 if (err)
142 goto err3;
143 err = gpio_direction_output(GPIO_NR_PALMTE2_SD_POWER, 0);
144 if (err)
145 goto err4;
146
147 err = gpio_request(GPIO_NR_PALMTE2_SD_READONLY, "SD_READONLY");
148 if (err)
149 goto err4;
150 err = gpio_direction_input(GPIO_NR_PALMTE2_SD_READONLY);
151 if (err)
152 goto err5;
153
154 printk(KERN_DEBUG "%s: irq registered\n", __func__);
155
156 return 0;
157
158err5:
159 gpio_free(GPIO_NR_PALMTE2_SD_READONLY);
160err4:
161 gpio_free(GPIO_NR_PALMTE2_SD_POWER);
162err3:
163 free_irq(gpio_to_irq(GPIO_NR_PALMTE2_SD_DETECT_N), data);
164err2:
165 gpio_free(GPIO_NR_PALMTE2_SD_DETECT_N);
166err:
167 return err;
168}
169
170static void palmte2_mci_exit(struct device *dev, void *data)
171{
172 gpio_free(GPIO_NR_PALMTE2_SD_READONLY);
173 gpio_free(GPIO_NR_PALMTE2_SD_POWER);
174 free_irq(gpio_to_irq(GPIO_NR_PALMTE2_SD_DETECT_N), data);
175 gpio_free(GPIO_NR_PALMTE2_SD_DETECT_N);
176}
177
178static void palmte2_mci_power(struct device *dev, unsigned int vdd)
179{
180 struct pxamci_platform_data *p_d = dev->platform_data;
181 gpio_set_value(GPIO_NR_PALMTE2_SD_POWER, p_d->ocr_mask & (1 << vdd));
182}
183
184static int palmte2_mci_get_ro(struct device *dev)
185{
186 return gpio_get_value(GPIO_NR_PALMTE2_SD_READONLY);
187}
188
189static struct pxamci_platform_data palmte2_mci_platform_data = {
190 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
191 .setpower = palmte2_mci_power,
192 .get_ro = palmte2_mci_get_ro,
193 .init = palmte2_mci_init,
194 .exit = palmte2_mci_exit,
195};
196
197/******************************************************************************
198 * GPIO keys
199 ******************************************************************************/
200static struct gpio_keys_button palmte2_pxa_buttons[] = {
201 {KEY_F1, GPIO_NR_PALMTE2_KEY_CONTACTS, 1, "Contacts" },
202 {KEY_F2, GPIO_NR_PALMTE2_KEY_CALENDAR, 1, "Calendar" },
203 {KEY_F3, GPIO_NR_PALMTE2_KEY_TASKS, 1, "Tasks" },
204 {KEY_F4, GPIO_NR_PALMTE2_KEY_NOTES, 1, "Notes" },
205 {KEY_ENTER, GPIO_NR_PALMTE2_KEY_CENTER, 1, "Center" },
206 {KEY_LEFT, GPIO_NR_PALMTE2_KEY_LEFT, 1, "Left" },
207 {KEY_RIGHT, GPIO_NR_PALMTE2_KEY_RIGHT, 1, "Right" },
208 {KEY_DOWN, GPIO_NR_PALMTE2_KEY_DOWN, 1, "Down" },
209 {KEY_UP, GPIO_NR_PALMTE2_KEY_UP, 1, "Up" },
210};
211
212static struct gpio_keys_platform_data palmte2_pxa_keys_data = {
213 .buttons = palmte2_pxa_buttons,
214 .nbuttons = ARRAY_SIZE(palmte2_pxa_buttons),
215};
216
217static struct platform_device palmte2_pxa_keys = {
218 .name = "gpio-keys",
219 .id = -1,
220 .dev = {
221 .platform_data = &palmte2_pxa_keys_data,
222 },
223};
224
225/******************************************************************************
226 * Backlight
227 ******************************************************************************/
Marek Vasut8c8aa5f2009-03-24 21:23:39 +0100228static int palmte2_backlight_init(struct device *dev)
229{
230 int ret;
231
232 ret = gpio_request(GPIO_NR_PALMTE2_BL_POWER, "BL POWER");
233 if (ret)
234 goto err;
235 ret = gpio_direction_output(GPIO_NR_PALMTE2_BL_POWER, 0);
236 if (ret)
237 goto err2;
238 ret = gpio_request(GPIO_NR_PALMTE2_LCD_POWER, "LCD POWER");
239 if (ret)
240 goto err2;
241 ret = gpio_direction_output(GPIO_NR_PALMTE2_LCD_POWER, 0);
242 if (ret)
243 goto err3;
244
245 return 0;
246err3:
247 gpio_free(GPIO_NR_PALMTE2_LCD_POWER);
248err2:
249 gpio_free(GPIO_NR_PALMTE2_BL_POWER);
250err:
251 return ret;
252}
253
254static int palmte2_backlight_notify(int brightness)
255{
256 gpio_set_value(GPIO_NR_PALMTE2_BL_POWER, brightness);
257 gpio_set_value(GPIO_NR_PALMTE2_LCD_POWER, brightness);
258 return brightness;
259}
260
261static void palmte2_backlight_exit(struct device *dev)
262{
263 gpio_free(GPIO_NR_PALMTE2_BL_POWER);
264 gpio_free(GPIO_NR_PALMTE2_LCD_POWER);
265}
266
Marek Vasut54088bf2009-03-24 00:29:29 +0100267static struct platform_pwm_backlight_data palmte2_backlight_data = {
268 .pwm_id = 0,
269 .max_brightness = PALMTE2_MAX_INTENSITY,
270 .dft_brightness = PALMTE2_MAX_INTENSITY,
271 .pwm_period_ns = PALMTE2_PERIOD_NS,
Marek Vasut8c8aa5f2009-03-24 21:23:39 +0100272 .init = palmte2_backlight_init,
273 .notify = palmte2_backlight_notify,
274 .exit = palmte2_backlight_exit,
Marek Vasut54088bf2009-03-24 00:29:29 +0100275};
276
277static struct platform_device palmte2_backlight = {
278 .name = "pwm-backlight",
279 .dev = {
280 .parent = &pxa25x_device_pwm0.dev,
281 .platform_data = &palmte2_backlight_data,
282 },
283};
284
285/******************************************************************************
Marek Vasut8c8aa5f2009-03-24 21:23:39 +0100286 * IrDA
287 ******************************************************************************/
288static int palmte2_irda_startup(struct device *dev)
289{
290 int err;
291 err = gpio_request(GPIO_NR_PALMTE2_IR_DISABLE, "IR DISABLE");
292 if (err)
293 goto err;
294 err = gpio_direction_output(GPIO_NR_PALMTE2_IR_DISABLE, 1);
295 if (err)
296 gpio_free(GPIO_NR_PALMTE2_IR_DISABLE);
297err:
298 return err;
299}
300
301static void palmte2_irda_shutdown(struct device *dev)
302{
303 gpio_free(GPIO_NR_PALMTE2_IR_DISABLE);
304}
305
306static void palmte2_irda_transceiver_mode(struct device *dev, int mode)
307{
308 gpio_set_value(GPIO_NR_PALMTE2_IR_DISABLE, mode & IR_OFF);
309 pxa2xx_transceiver_mode(dev, mode);
310}
311
312static struct pxaficp_platform_data palmte2_ficp_platform_data = {
313 .startup = palmte2_irda_startup,
314 .shutdown = palmte2_irda_shutdown,
315 .transceiver_cap = IR_SIRMODE | IR_FIRMODE | IR_OFF,
316 .transceiver_mode = palmte2_irda_transceiver_mode,
317};
318
319/******************************************************************************
320 * UDC
321 ******************************************************************************/
Marek Vasut8768dc92009-04-23 11:12:37 +0200322static struct gpio_vbus_mach_info palmte2_udc_info = {
Marek Vasut8c8aa5f2009-03-24 21:23:39 +0100323 .gpio_vbus = GPIO_NR_PALMTE2_USB_DETECT_N,
324 .gpio_vbus_inverted = 1,
325 .gpio_pullup = GPIO_NR_PALMTE2_USB_PULLUP,
Marek Vasut8768dc92009-04-23 11:12:37 +0200326};
327
328static struct platform_device palmte2_gpio_vbus = {
329 .name = "gpio-vbus",
330 .id = -1,
331 .dev = {
332 .platform_data = &palmte2_udc_info,
333 },
Marek Vasut8c8aa5f2009-03-24 21:23:39 +0100334};
335
336/******************************************************************************
337 * Power supply
338 ******************************************************************************/
339static int power_supply_init(struct device *dev)
340{
341 int ret;
342
343 ret = gpio_request(GPIO_NR_PALMTE2_POWER_DETECT, "CABLE_STATE_AC");
344 if (ret)
345 goto err1;
346 ret = gpio_direction_input(GPIO_NR_PALMTE2_POWER_DETECT);
347 if (ret)
348 goto err2;
349
350 return 0;
351
352err2:
353 gpio_free(GPIO_NR_PALMTE2_POWER_DETECT);
354err1:
355 return ret;
356}
357
358static int palmte2_is_ac_online(void)
359{
360 return gpio_get_value(GPIO_NR_PALMTE2_POWER_DETECT);
361}
362
363static void power_supply_exit(struct device *dev)
364{
365 gpio_free(GPIO_NR_PALMTE2_POWER_DETECT);
366}
367
368static char *palmte2_supplicants[] = {
369 "main-battery",
370};
371
372static struct pda_power_pdata power_supply_info = {
373 .init = power_supply_init,
374 .is_ac_online = palmte2_is_ac_online,
375 .exit = power_supply_exit,
376 .supplied_to = palmte2_supplicants,
377 .num_supplicants = ARRAY_SIZE(palmte2_supplicants),
378};
379
380static struct platform_device power_supply = {
381 .name = "pda-power",
382 .id = -1,
383 .dev = {
384 .platform_data = &power_supply_info,
385 },
386};
387
388/******************************************************************************
389 * WM97xx battery
390 ******************************************************************************/
391static struct wm97xx_batt_info wm97xx_batt_pdata = {
392 .batt_aux = WM97XX_AUX_ID3,
393 .temp_aux = WM97XX_AUX_ID2,
394 .charge_gpio = -1,
395 .max_voltage = PALMTE2_BAT_MAX_VOLTAGE,
396 .min_voltage = PALMTE2_BAT_MIN_VOLTAGE,
397 .batt_mult = 1000,
398 .batt_div = 414,
399 .temp_mult = 1,
400 .temp_div = 1,
401 .batt_tech = POWER_SUPPLY_TECHNOLOGY_LIPO,
402 .batt_name = "main-batt",
403};
404
405/******************************************************************************
Marek Vasut54088bf2009-03-24 00:29:29 +0100406 * Framebuffer
407 ******************************************************************************/
408static struct pxafb_mode_info palmte2_lcd_modes[] = {
409{
410 .pixclock = 77757,
411 .xres = 320,
412 .yres = 320,
413 .bpp = 16,
414
415 .left_margin = 28,
416 .right_margin = 7,
417 .upper_margin = 7,
418 .lower_margin = 5,
419
420 .hsync_len = 4,
421 .vsync_len = 1,
422},
423};
424
425static struct pxafb_mach_info palmte2_lcd_screen = {
426 .modes = palmte2_lcd_modes,
427 .num_modes = ARRAY_SIZE(palmte2_lcd_modes),
428 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
429};
430
431/******************************************************************************
432 * Machine init
433 ******************************************************************************/
434static struct platform_device *devices[] __initdata = {
435#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
436 &palmte2_pxa_keys,
437#endif
438 &palmte2_backlight,
Marek Vasut8c8aa5f2009-03-24 21:23:39 +0100439 &power_supply,
Marek Vasut8768dc92009-04-23 11:12:37 +0200440 &palmte2_gpio_vbus,
Marek Vasut54088bf2009-03-24 00:29:29 +0100441};
442
Marek Vasut8c8aa5f2009-03-24 21:23:39 +0100443/* setup udc GPIOs initial state */
444static void __init palmte2_udc_init(void)
445{
446 if (!gpio_request(GPIO_NR_PALMTE2_USB_PULLUP, "UDC Vbus")) {
447 gpio_direction_output(GPIO_NR_PALMTE2_USB_PULLUP, 1);
448 gpio_free(GPIO_NR_PALMTE2_USB_PULLUP);
449 }
450}
451
Marek Vasut54088bf2009-03-24 00:29:29 +0100452static void __init palmte2_init(void)
453{
454 pxa2xx_mfp_config(ARRAY_AND_SIZE(palmte2_pin_config));
455
456 set_pxa_fb_info(&palmte2_lcd_screen);
457 pxa_set_mci_info(&palmte2_mci_platform_data);
Marek Vasut8c8aa5f2009-03-24 21:23:39 +0100458 palmte2_udc_init();
Marek Vasut54088bf2009-03-24 00:29:29 +0100459 pxa_set_ac97_info(NULL);
Marek Vasut8c8aa5f2009-03-24 21:23:39 +0100460 pxa_set_ficp_info(&palmte2_ficp_platform_data);
461 wm97xx_bat_set_pdata(&wm97xx_batt_pdata);
Marek Vasut54088bf2009-03-24 00:29:29 +0100462
463 platform_add_devices(devices, ARRAY_SIZE(devices));
464}
465
466MACHINE_START(PALMTE2, "Palm Tungsten|E2")
467 .phys_io = 0x40000000,
468 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
469 .boot_params = 0xa0000100,
470 .map_io = pxa_map_io,
471 .init_irq = pxa25x_init_irq,
472 .timer = &pxa_timer,
473 .init_machine = palmte2_init
474MACHINE_END