blob: 3f25014a136c2b2e6b4c9461116b2f5951d3e492 [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 Vasut241cf472010-06-04 03:07:33 +020026#include <linux/wm97xx.h>
Marek Vasut8c8aa5f2009-03-24 21:23:39 +010027#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 Vasut37330ef2009-04-23 11:27:11 +020041#include <mach/palmasoc.h>
Marek Vasut54088bf2009-03-24 00:29:29 +010042
43#include "generic.h"
44#include "devices.h"
45
46/******************************************************************************
47 * Pin configuration
48 ******************************************************************************/
49static unsigned long palmte2_pin_config[] __initdata = {
50 /* MMC */
51 GPIO6_MMC_CLK,
52 GPIO8_MMC_CS0,
53 GPIO10_GPIO, /* SD detect */
54 GPIO55_GPIO, /* SD power */
55 GPIO51_GPIO, /* SD r/o switch */
56
57 /* AC97 */
58 GPIO28_AC97_BITCLK,
59 GPIO29_AC97_SDATA_IN_0,
60 GPIO30_AC97_SDATA_OUT,
61 GPIO31_AC97_SYNC,
62
63 /* PWM */
64 GPIO16_PWM0_OUT,
65
Marek Vasut8c8aa5f2009-03-24 21:23:39 +010066 /* USB */
67 GPIO15_GPIO, /* usb detect */
68 GPIO53_GPIO, /* usb power */
69
70 /* IrDA */
71 GPIO48_GPIO, /* ir disable */
72 GPIO46_FICP_RXD,
73 GPIO47_FICP_TXD,
74
Marek Vasut54088bf2009-03-24 00:29:29 +010075 /* LCD */
Eric Miao07bae6c2010-01-04 11:25:10 +080076 GPIOxx_LCD_TFT_16BPP,
Marek Vasut54088bf2009-03-24 00:29:29 +010077
78 /* GPIO KEYS */
79 GPIO5_GPIO, /* notes */
80 GPIO7_GPIO, /* tasks */
81 GPIO11_GPIO, /* calendar */
82 GPIO13_GPIO, /* contacts */
83 GPIO14_GPIO, /* center */
84 GPIO19_GPIO, /* left */
85 GPIO20_GPIO, /* right */
86 GPIO21_GPIO, /* down */
87 GPIO22_GPIO, /* up */
88
89 /* MISC */
90 GPIO1_RST, /* reset */
Marek Vasut8c8aa5f2009-03-24 21:23:39 +010091 GPIO4_GPIO, /* Hotsync button */
92 GPIO9_GPIO, /* power detect */
Marek Vasut37330ef2009-04-23 11:27:11 +020093 GPIO15_GPIO, /* earphone detect */
Marek Vasut8c8aa5f2009-03-24 21:23:39 +010094 GPIO37_GPIO, /* LCD power */
95 GPIO56_GPIO, /* Backlight power */
Marek Vasut54088bf2009-03-24 00:29:29 +010096};
97
98/******************************************************************************
99 * SD/MMC card controller
100 ******************************************************************************/
Marek Vasut54088bf2009-03-24 00:29:29 +0100101static struct pxamci_platform_data palmte2_mci_platform_data = {
Robert Jarzmik7a648252009-07-06 22:16:42 +0200102 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
103 .gpio_card_detect = GPIO_NR_PALMTE2_SD_DETECT_N,
104 .gpio_card_ro = GPIO_NR_PALMTE2_SD_READONLY,
105 .gpio_power = GPIO_NR_PALMTE2_SD_POWER,
Marek Vasut54088bf2009-03-24 00:29:29 +0100106};
107
108/******************************************************************************
109 * GPIO keys
110 ******************************************************************************/
111static struct gpio_keys_button palmte2_pxa_buttons[] = {
112 {KEY_F1, GPIO_NR_PALMTE2_KEY_CONTACTS, 1, "Contacts" },
113 {KEY_F2, GPIO_NR_PALMTE2_KEY_CALENDAR, 1, "Calendar" },
114 {KEY_F3, GPIO_NR_PALMTE2_KEY_TASKS, 1, "Tasks" },
115 {KEY_F4, GPIO_NR_PALMTE2_KEY_NOTES, 1, "Notes" },
116 {KEY_ENTER, GPIO_NR_PALMTE2_KEY_CENTER, 1, "Center" },
117 {KEY_LEFT, GPIO_NR_PALMTE2_KEY_LEFT, 1, "Left" },
118 {KEY_RIGHT, GPIO_NR_PALMTE2_KEY_RIGHT, 1, "Right" },
119 {KEY_DOWN, GPIO_NR_PALMTE2_KEY_DOWN, 1, "Down" },
120 {KEY_UP, GPIO_NR_PALMTE2_KEY_UP, 1, "Up" },
121};
122
123static struct gpio_keys_platform_data palmte2_pxa_keys_data = {
124 .buttons = palmte2_pxa_buttons,
125 .nbuttons = ARRAY_SIZE(palmte2_pxa_buttons),
126};
127
128static struct platform_device palmte2_pxa_keys = {
129 .name = "gpio-keys",
130 .id = -1,
131 .dev = {
132 .platform_data = &palmte2_pxa_keys_data,
133 },
134};
135
136/******************************************************************************
137 * Backlight
138 ******************************************************************************/
Marek Vasut8c8aa5f2009-03-24 21:23:39 +0100139static int palmte2_backlight_init(struct device *dev)
140{
141 int ret;
142
143 ret = gpio_request(GPIO_NR_PALMTE2_BL_POWER, "BL POWER");
144 if (ret)
145 goto err;
146 ret = gpio_direction_output(GPIO_NR_PALMTE2_BL_POWER, 0);
147 if (ret)
148 goto err2;
149 ret = gpio_request(GPIO_NR_PALMTE2_LCD_POWER, "LCD POWER");
150 if (ret)
151 goto err2;
152 ret = gpio_direction_output(GPIO_NR_PALMTE2_LCD_POWER, 0);
153 if (ret)
154 goto err3;
155
156 return 0;
157err3:
158 gpio_free(GPIO_NR_PALMTE2_LCD_POWER);
159err2:
160 gpio_free(GPIO_NR_PALMTE2_BL_POWER);
161err:
162 return ret;
163}
164
Eric Miao2d51a522010-01-04 11:42:01 +0800165static int palmte2_backlight_notify(struct device *dev, int brightness)
Marek Vasut8c8aa5f2009-03-24 21:23:39 +0100166{
167 gpio_set_value(GPIO_NR_PALMTE2_BL_POWER, brightness);
168 gpio_set_value(GPIO_NR_PALMTE2_LCD_POWER, brightness);
169 return brightness;
170}
171
172static void palmte2_backlight_exit(struct device *dev)
173{
174 gpio_free(GPIO_NR_PALMTE2_BL_POWER);
175 gpio_free(GPIO_NR_PALMTE2_LCD_POWER);
176}
177
Marek Vasut54088bf2009-03-24 00:29:29 +0100178static struct platform_pwm_backlight_data palmte2_backlight_data = {
179 .pwm_id = 0,
180 .max_brightness = PALMTE2_MAX_INTENSITY,
181 .dft_brightness = PALMTE2_MAX_INTENSITY,
182 .pwm_period_ns = PALMTE2_PERIOD_NS,
Marek Vasut8c8aa5f2009-03-24 21:23:39 +0100183 .init = palmte2_backlight_init,
184 .notify = palmte2_backlight_notify,
185 .exit = palmte2_backlight_exit,
Marek Vasut54088bf2009-03-24 00:29:29 +0100186};
187
188static struct platform_device palmte2_backlight = {
189 .name = "pwm-backlight",
190 .dev = {
191 .parent = &pxa25x_device_pwm0.dev,
192 .platform_data = &palmte2_backlight_data,
193 },
194};
195
196/******************************************************************************
Marek Vasut8c8aa5f2009-03-24 21:23:39 +0100197 * IrDA
198 ******************************************************************************/
Marek Vasut8c8aa5f2009-03-24 21:23:39 +0100199static struct pxaficp_platform_data palmte2_ficp_platform_data = {
Marek Vasutc4bd0172009-07-17 12:50:43 +0200200 .gpio_pwdown = GPIO_NR_PALMTE2_IR_DISABLE,
201 .transceiver_cap = IR_SIRMODE | IR_OFF,
Marek Vasut8c8aa5f2009-03-24 21:23:39 +0100202};
203
204/******************************************************************************
205 * UDC
206 ******************************************************************************/
Marek Vasut8768dc92009-04-23 11:12:37 +0200207static struct gpio_vbus_mach_info palmte2_udc_info = {
Marek Vasut8c8aa5f2009-03-24 21:23:39 +0100208 .gpio_vbus = GPIO_NR_PALMTE2_USB_DETECT_N,
209 .gpio_vbus_inverted = 1,
210 .gpio_pullup = GPIO_NR_PALMTE2_USB_PULLUP,
Marek Vasut8768dc92009-04-23 11:12:37 +0200211};
212
213static struct platform_device palmte2_gpio_vbus = {
214 .name = "gpio-vbus",
215 .id = -1,
216 .dev = {
217 .platform_data = &palmte2_udc_info,
218 },
Marek Vasut8c8aa5f2009-03-24 21:23:39 +0100219};
220
221/******************************************************************************
222 * Power supply
223 ******************************************************************************/
224static int power_supply_init(struct device *dev)
225{
226 int ret;
227
228 ret = gpio_request(GPIO_NR_PALMTE2_POWER_DETECT, "CABLE_STATE_AC");
229 if (ret)
230 goto err1;
231 ret = gpio_direction_input(GPIO_NR_PALMTE2_POWER_DETECT);
232 if (ret)
233 goto err2;
234
235 return 0;
236
237err2:
238 gpio_free(GPIO_NR_PALMTE2_POWER_DETECT);
239err1:
240 return ret;
241}
242
243static int palmte2_is_ac_online(void)
244{
245 return gpio_get_value(GPIO_NR_PALMTE2_POWER_DETECT);
246}
247
248static void power_supply_exit(struct device *dev)
249{
250 gpio_free(GPIO_NR_PALMTE2_POWER_DETECT);
251}
252
253static char *palmte2_supplicants[] = {
254 "main-battery",
255};
256
257static struct pda_power_pdata power_supply_info = {
258 .init = power_supply_init,
259 .is_ac_online = palmte2_is_ac_online,
260 .exit = power_supply_exit,
261 .supplied_to = palmte2_supplicants,
262 .num_supplicants = ARRAY_SIZE(palmte2_supplicants),
263};
264
265static struct platform_device power_supply = {
266 .name = "pda-power",
267 .id = -1,
268 .dev = {
269 .platform_data = &power_supply_info,
270 },
271};
272
273/******************************************************************************
Marek Vasut241cf472010-06-04 03:07:33 +0200274 * WM97xx audio, battery
Marek Vasut8c8aa5f2009-03-24 21:23:39 +0100275 ******************************************************************************/
Marek Vasut241cf472010-06-04 03:07:33 +0200276static struct wm97xx_batt_pdata palmte2_batt_pdata = {
Marek Vasut8c8aa5f2009-03-24 21:23:39 +0100277 .batt_aux = WM97XX_AUX_ID3,
278 .temp_aux = WM97XX_AUX_ID2,
279 .charge_gpio = -1,
280 .max_voltage = PALMTE2_BAT_MAX_VOLTAGE,
281 .min_voltage = PALMTE2_BAT_MIN_VOLTAGE,
282 .batt_mult = 1000,
283 .batt_div = 414,
284 .temp_mult = 1,
285 .temp_div = 1,
286 .batt_tech = POWER_SUPPLY_TECHNOLOGY_LIPO,
287 .batt_name = "main-batt",
288};
289
Marek Vasut241cf472010-06-04 03:07:33 +0200290static struct wm97xx_pdata palmte2_wm97xx_pdata = {
291 .batt_pdata = &palmte2_batt_pdata,
292};
293
294static pxa2xx_audio_ops_t palmte2_ac97_pdata = {
295 .codec_pdata = { &palmte2_wm97xx_pdata, },
296};
297
Marek Vasut37330ef2009-04-23 11:27:11 +0200298static struct palm27x_asoc_info palmte2_asoc_pdata = {
299 .jack_gpio = GPIO_NR_PALMTE2_EARPHONE_DETECT,
300};
301
302static struct platform_device palmte2_asoc = {
303 .name = "palm27x-asoc",
304 .id = -1,
305 .dev = {
306 .platform_data = &palmte2_asoc_pdata,
307 },
308};
309
310/******************************************************************************
Marek Vasut54088bf2009-03-24 00:29:29 +0100311 * Framebuffer
312 ******************************************************************************/
313static struct pxafb_mode_info palmte2_lcd_modes[] = {
314{
315 .pixclock = 77757,
316 .xres = 320,
317 .yres = 320,
318 .bpp = 16,
319
320 .left_margin = 28,
321 .right_margin = 7,
322 .upper_margin = 7,
323 .lower_margin = 5,
324
325 .hsync_len = 4,
326 .vsync_len = 1,
327},
328};
329
330static struct pxafb_mach_info palmte2_lcd_screen = {
331 .modes = palmte2_lcd_modes,
332 .num_modes = ARRAY_SIZE(palmte2_lcd_modes),
333 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
334};
335
336/******************************************************************************
337 * Machine init
338 ******************************************************************************/
339static struct platform_device *devices[] __initdata = {
340#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
341 &palmte2_pxa_keys,
342#endif
343 &palmte2_backlight,
Marek Vasut8c8aa5f2009-03-24 21:23:39 +0100344 &power_supply,
Marek Vasut37330ef2009-04-23 11:27:11 +0200345 &palmte2_asoc,
Marek Vasut8768dc92009-04-23 11:12:37 +0200346 &palmte2_gpio_vbus,
Marek Vasut54088bf2009-03-24 00:29:29 +0100347};
348
Marek Vasut8c8aa5f2009-03-24 21:23:39 +0100349/* setup udc GPIOs initial state */
350static void __init palmte2_udc_init(void)
351{
352 if (!gpio_request(GPIO_NR_PALMTE2_USB_PULLUP, "UDC Vbus")) {
353 gpio_direction_output(GPIO_NR_PALMTE2_USB_PULLUP, 1);
354 gpio_free(GPIO_NR_PALMTE2_USB_PULLUP);
355 }
356}
357
Marek Vasut54088bf2009-03-24 00:29:29 +0100358static void __init palmte2_init(void)
359{
360 pxa2xx_mfp_config(ARRAY_AND_SIZE(palmte2_pin_config));
361
Russell Kingcc155c62009-11-09 13:34:08 +0800362 pxa_set_ffuart_info(NULL);
363 pxa_set_btuart_info(NULL);
364 pxa_set_stuart_info(NULL);
365
Marek Vasut54088bf2009-03-24 00:29:29 +0100366 set_pxa_fb_info(&palmte2_lcd_screen);
367 pxa_set_mci_info(&palmte2_mci_platform_data);
Marek Vasut8c8aa5f2009-03-24 21:23:39 +0100368 palmte2_udc_init();
Marek Vasut241cf472010-06-04 03:07:33 +0200369 pxa_set_ac97_info(&palmte2_ac97_pdata);
Marek Vasut8c8aa5f2009-03-24 21:23:39 +0100370 pxa_set_ficp_info(&palmte2_ficp_platform_data);
Marek Vasut54088bf2009-03-24 00:29:29 +0100371
372 platform_add_devices(devices, ARRAY_SIZE(devices));
373}
374
375MACHINE_START(PALMTE2, "Palm Tungsten|E2")
Marek Vasut54088bf2009-03-24 00:29:29 +0100376 .boot_params = 0xa0000100,
Marek Vasut851982c2010-10-11 02:20:19 +0200377 .map_io = pxa25x_map_io,
Marek Vasut54088bf2009-03-24 00:29:29 +0100378 .init_irq = pxa25x_init_irq,
379 .timer = &pxa_timer,
380 .init_machine = palmte2_init
381MACHINE_END