blob: 36b46141a28b09e30331335019f098fd1c2643a9 [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>
Thierry Redingf5a3b552015-10-05 10:49:51 +020024#include <linux/pwm.h>
Marek Vasut54088bf2009-03-24 00:29:29 +010025#include <linux/pwm_backlight.h>
26#include <linux/gpio.h>
Marek Vasut241cf472010-06-04 03:07:33 +020027#include <linux/wm97xx.h>
Marek Vasut8c8aa5f2009-03-24 21:23:39 +010028#include <linux/power_supply.h>
Marek Vasut8768dc92009-04-23 11:12:37 +020029#include <linux/usb/gpio_vbus.h>
Marek Vasut54088bf2009-03-24 00:29:29 +010030
31#include <asm/mach-types.h>
32#include <asm/mach/arch.h>
33#include <asm/mach/map.h>
34
Arnd Bergmann4c25c5d2015-01-30 10:45:33 +010035#include "pxa25x.h"
Marek Vasut54088bf2009-03-24 00:29:29 +010036#include <mach/audio.h>
Arnd Bergmann4c25c5d2015-01-30 10:45:33 +010037#include "palmte2.h"
Arnd Bergmann293b2da2012-08-24 15:16:48 +020038#include <linux/platform_data/mmc-pxamci.h>
39#include <linux/platform_data/video-pxafb.h>
40#include <linux/platform_data/irda-pxaficp.h>
Arnd Bergmann4c25c5d2015-01-30 10:45:33 +010041#include "udc.h"
Arnd Bergmann293b2da2012-08-24 15:16:48 +020042#include <linux/platform_data/asoc-palm27x.h>
Marek Vasut54088bf2009-03-24 00:29:29 +010043
44#include "generic.h"
45#include "devices.h"
46
47/******************************************************************************
48 * Pin configuration
49 ******************************************************************************/
50static unsigned long palmte2_pin_config[] __initdata = {
51 /* MMC */
52 GPIO6_MMC_CLK,
53 GPIO8_MMC_CS0,
54 GPIO10_GPIO, /* SD detect */
55 GPIO55_GPIO, /* SD power */
56 GPIO51_GPIO, /* SD r/o switch */
57
58 /* AC97 */
59 GPIO28_AC97_BITCLK,
60 GPIO29_AC97_SDATA_IN_0,
61 GPIO30_AC97_SDATA_OUT,
62 GPIO31_AC97_SYNC,
63
64 /* PWM */
65 GPIO16_PWM0_OUT,
66
Marek Vasut8c8aa5f2009-03-24 21:23:39 +010067 /* USB */
68 GPIO15_GPIO, /* usb detect */
69 GPIO53_GPIO, /* usb power */
70
71 /* IrDA */
72 GPIO48_GPIO, /* ir disable */
73 GPIO46_FICP_RXD,
74 GPIO47_FICP_TXD,
75
Marek Vasut54088bf2009-03-24 00:29:29 +010076 /* LCD */
Eric Miao07bae6c2010-01-04 11:25:10 +080077 GPIOxx_LCD_TFT_16BPP,
Marek Vasut54088bf2009-03-24 00:29:29 +010078
79 /* GPIO KEYS */
80 GPIO5_GPIO, /* notes */
81 GPIO7_GPIO, /* tasks */
82 GPIO11_GPIO, /* calendar */
83 GPIO13_GPIO, /* contacts */
84 GPIO14_GPIO, /* center */
85 GPIO19_GPIO, /* left */
86 GPIO20_GPIO, /* right */
87 GPIO21_GPIO, /* down */
88 GPIO22_GPIO, /* up */
89
90 /* MISC */
91 GPIO1_RST, /* reset */
Marek Vasut8c8aa5f2009-03-24 21:23:39 +010092 GPIO4_GPIO, /* Hotsync button */
93 GPIO9_GPIO, /* power detect */
Marek Vasut37330ef2009-04-23 11:27:11 +020094 GPIO15_GPIO, /* earphone detect */
Marek Vasut8c8aa5f2009-03-24 21:23:39 +010095 GPIO37_GPIO, /* LCD power */
96 GPIO56_GPIO, /* Backlight power */
Marek Vasut54088bf2009-03-24 00:29:29 +010097};
98
99/******************************************************************************
100 * SD/MMC card controller
101 ******************************************************************************/
Marek Vasut54088bf2009-03-24 00:29:29 +0100102static struct pxamci_platform_data palmte2_mci_platform_data = {
Robert Jarzmik7a648252009-07-06 22:16:42 +0200103 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
104 .gpio_card_detect = GPIO_NR_PALMTE2_SD_DETECT_N,
105 .gpio_card_ro = GPIO_NR_PALMTE2_SD_READONLY,
106 .gpio_power = GPIO_NR_PALMTE2_SD_POWER,
Marek Vasut54088bf2009-03-24 00:29:29 +0100107};
108
Arnd Bergmann30bda0e2012-04-30 16:05:28 +0000109#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
Marek Vasut54088bf2009-03-24 00:29:29 +0100110/******************************************************************************
111 * GPIO keys
112 ******************************************************************************/
113static struct gpio_keys_button palmte2_pxa_buttons[] = {
114 {KEY_F1, GPIO_NR_PALMTE2_KEY_CONTACTS, 1, "Contacts" },
115 {KEY_F2, GPIO_NR_PALMTE2_KEY_CALENDAR, 1, "Calendar" },
116 {KEY_F3, GPIO_NR_PALMTE2_KEY_TASKS, 1, "Tasks" },
117 {KEY_F4, GPIO_NR_PALMTE2_KEY_NOTES, 1, "Notes" },
118 {KEY_ENTER, GPIO_NR_PALMTE2_KEY_CENTER, 1, "Center" },
119 {KEY_LEFT, GPIO_NR_PALMTE2_KEY_LEFT, 1, "Left" },
120 {KEY_RIGHT, GPIO_NR_PALMTE2_KEY_RIGHT, 1, "Right" },
121 {KEY_DOWN, GPIO_NR_PALMTE2_KEY_DOWN, 1, "Down" },
122 {KEY_UP, GPIO_NR_PALMTE2_KEY_UP, 1, "Up" },
123};
124
125static struct gpio_keys_platform_data palmte2_pxa_keys_data = {
126 .buttons = palmte2_pxa_buttons,
127 .nbuttons = ARRAY_SIZE(palmte2_pxa_buttons),
128};
129
130static struct platform_device palmte2_pxa_keys = {
131 .name = "gpio-keys",
132 .id = -1,
133 .dev = {
134 .platform_data = &palmte2_pxa_keys_data,
135 },
136};
Arnd Bergmann30bda0e2012-04-30 16:05:28 +0000137#endif
Marek Vasut54088bf2009-03-24 00:29:29 +0100138
139/******************************************************************************
140 * Backlight
141 ******************************************************************************/
Thierry Redingf5a3b552015-10-05 10:49:51 +0200142static struct pwm_lookup palmte2_pwm_lookup[] = {
143 PWM_LOOKUP("pxa25x-pwm.0", 0, "pwm-backlight.0", NULL,
144 PALMTE2_PERIOD_NS, PWM_POLARITY_NORMAL),
145};
146
Marek Vasut7428fff2011-01-15 17:55:45 +0100147static struct gpio palmte_bl_gpios[] = {
148 { GPIO_NR_PALMTE2_BL_POWER, GPIOF_INIT_LOW, "Backlight power" },
149 { GPIO_NR_PALMTE2_LCD_POWER, GPIOF_INIT_LOW, "LCD power" },
150};
151
Marek Vasut8c8aa5f2009-03-24 21:23:39 +0100152static int palmte2_backlight_init(struct device *dev)
153{
Marek Vasut7428fff2011-01-15 17:55:45 +0100154 return gpio_request_array(ARRAY_AND_SIZE(palmte_bl_gpios));
Marek Vasut8c8aa5f2009-03-24 21:23:39 +0100155}
156
Eric Miao2d51a522010-01-04 11:42:01 +0800157static int palmte2_backlight_notify(struct device *dev, int brightness)
Marek Vasut8c8aa5f2009-03-24 21:23:39 +0100158{
159 gpio_set_value(GPIO_NR_PALMTE2_BL_POWER, brightness);
160 gpio_set_value(GPIO_NR_PALMTE2_LCD_POWER, brightness);
161 return brightness;
162}
163
164static void palmte2_backlight_exit(struct device *dev)
165{
Marek Vasut7428fff2011-01-15 17:55:45 +0100166 gpio_free_array(ARRAY_AND_SIZE(palmte_bl_gpios));
Marek Vasut8c8aa5f2009-03-24 21:23:39 +0100167}
168
Marek Vasut54088bf2009-03-24 00:29:29 +0100169static struct platform_pwm_backlight_data palmte2_backlight_data = {
Marek Vasut54088bf2009-03-24 00:29:29 +0100170 .max_brightness = PALMTE2_MAX_INTENSITY,
171 .dft_brightness = PALMTE2_MAX_INTENSITY,
Thierry Redingdb011202013-08-30 12:15:24 +0200172 .enable_gpio = -1,
Marek Vasut8c8aa5f2009-03-24 21:23:39 +0100173 .init = palmte2_backlight_init,
174 .notify = palmte2_backlight_notify,
175 .exit = palmte2_backlight_exit,
Marek Vasut54088bf2009-03-24 00:29:29 +0100176};
177
178static struct platform_device palmte2_backlight = {
179 .name = "pwm-backlight",
180 .dev = {
181 .parent = &pxa25x_device_pwm0.dev,
182 .platform_data = &palmte2_backlight_data,
183 },
184};
185
186/******************************************************************************
Marek Vasut8c8aa5f2009-03-24 21:23:39 +0100187 * IrDA
188 ******************************************************************************/
Marek Vasut8c8aa5f2009-03-24 21:23:39 +0100189static struct pxaficp_platform_data palmte2_ficp_platform_data = {
Marek Vasutc4bd0172009-07-17 12:50:43 +0200190 .gpio_pwdown = GPIO_NR_PALMTE2_IR_DISABLE,
191 .transceiver_cap = IR_SIRMODE | IR_OFF,
Marek Vasut8c8aa5f2009-03-24 21:23:39 +0100192};
193
194/******************************************************************************
195 * UDC
196 ******************************************************************************/
Marek Vasut8768dc92009-04-23 11:12:37 +0200197static struct gpio_vbus_mach_info palmte2_udc_info = {
Marek Vasut8c8aa5f2009-03-24 21:23:39 +0100198 .gpio_vbus = GPIO_NR_PALMTE2_USB_DETECT_N,
199 .gpio_vbus_inverted = 1,
200 .gpio_pullup = GPIO_NR_PALMTE2_USB_PULLUP,
Marek Vasut8768dc92009-04-23 11:12:37 +0200201};
202
203static struct platform_device palmte2_gpio_vbus = {
204 .name = "gpio-vbus",
205 .id = -1,
206 .dev = {
207 .platform_data = &palmte2_udc_info,
208 },
Marek Vasut8c8aa5f2009-03-24 21:23:39 +0100209};
210
211/******************************************************************************
212 * Power supply
213 ******************************************************************************/
214static int power_supply_init(struct device *dev)
215{
216 int ret;
217
218 ret = gpio_request(GPIO_NR_PALMTE2_POWER_DETECT, "CABLE_STATE_AC");
219 if (ret)
220 goto err1;
221 ret = gpio_direction_input(GPIO_NR_PALMTE2_POWER_DETECT);
222 if (ret)
223 goto err2;
224
225 return 0;
226
227err2:
228 gpio_free(GPIO_NR_PALMTE2_POWER_DETECT);
229err1:
230 return ret;
231}
232
233static int palmte2_is_ac_online(void)
234{
235 return gpio_get_value(GPIO_NR_PALMTE2_POWER_DETECT);
236}
237
238static void power_supply_exit(struct device *dev)
239{
240 gpio_free(GPIO_NR_PALMTE2_POWER_DETECT);
241}
242
243static char *palmte2_supplicants[] = {
244 "main-battery",
245};
246
247static struct pda_power_pdata power_supply_info = {
248 .init = power_supply_init,
249 .is_ac_online = palmte2_is_ac_online,
250 .exit = power_supply_exit,
251 .supplied_to = palmte2_supplicants,
252 .num_supplicants = ARRAY_SIZE(palmte2_supplicants),
253};
254
255static struct platform_device power_supply = {
256 .name = "pda-power",
257 .id = -1,
258 .dev = {
259 .platform_data = &power_supply_info,
260 },
261};
262
263/******************************************************************************
Marek Vasut241cf472010-06-04 03:07:33 +0200264 * WM97xx audio, battery
Marek Vasut8c8aa5f2009-03-24 21:23:39 +0100265 ******************************************************************************/
Marek Vasut241cf472010-06-04 03:07:33 +0200266static struct wm97xx_batt_pdata palmte2_batt_pdata = {
Marek Vasut8c8aa5f2009-03-24 21:23:39 +0100267 .batt_aux = WM97XX_AUX_ID3,
268 .temp_aux = WM97XX_AUX_ID2,
269 .charge_gpio = -1,
270 .max_voltage = PALMTE2_BAT_MAX_VOLTAGE,
271 .min_voltage = PALMTE2_BAT_MIN_VOLTAGE,
272 .batt_mult = 1000,
273 .batt_div = 414,
274 .temp_mult = 1,
275 .temp_div = 1,
276 .batt_tech = POWER_SUPPLY_TECHNOLOGY_LIPO,
277 .batt_name = "main-batt",
278};
279
Marek Vasut241cf472010-06-04 03:07:33 +0200280static struct wm97xx_pdata palmte2_wm97xx_pdata = {
281 .batt_pdata = &palmte2_batt_pdata,
282};
283
284static pxa2xx_audio_ops_t palmte2_ac97_pdata = {
285 .codec_pdata = { &palmte2_wm97xx_pdata, },
286};
287
Marek Vasut37330ef2009-04-23 11:27:11 +0200288static struct palm27x_asoc_info palmte2_asoc_pdata = {
289 .jack_gpio = GPIO_NR_PALMTE2_EARPHONE_DETECT,
290};
291
292static struct platform_device palmte2_asoc = {
293 .name = "palm27x-asoc",
294 .id = -1,
295 .dev = {
296 .platform_data = &palmte2_asoc_pdata,
297 },
298};
299
300/******************************************************************************
Marek Vasut54088bf2009-03-24 00:29:29 +0100301 * Framebuffer
302 ******************************************************************************/
303static struct pxafb_mode_info palmte2_lcd_modes[] = {
304{
305 .pixclock = 77757,
306 .xres = 320,
307 .yres = 320,
308 .bpp = 16,
309
310 .left_margin = 28,
311 .right_margin = 7,
312 .upper_margin = 7,
313 .lower_margin = 5,
314
315 .hsync_len = 4,
316 .vsync_len = 1,
317},
318};
319
320static struct pxafb_mach_info palmte2_lcd_screen = {
321 .modes = palmte2_lcd_modes,
322 .num_modes = ARRAY_SIZE(palmte2_lcd_modes),
323 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
324};
325
326/******************************************************************************
327 * Machine init
328 ******************************************************************************/
329static struct platform_device *devices[] __initdata = {
330#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
331 &palmte2_pxa_keys,
332#endif
333 &palmte2_backlight,
Marek Vasut8c8aa5f2009-03-24 21:23:39 +0100334 &power_supply,
Marek Vasut37330ef2009-04-23 11:27:11 +0200335 &palmte2_asoc,
Marek Vasut8768dc92009-04-23 11:12:37 +0200336 &palmte2_gpio_vbus,
Marek Vasut54088bf2009-03-24 00:29:29 +0100337};
338
Marek Vasut8c8aa5f2009-03-24 21:23:39 +0100339/* setup udc GPIOs initial state */
340static void __init palmte2_udc_init(void)
341{
342 if (!gpio_request(GPIO_NR_PALMTE2_USB_PULLUP, "UDC Vbus")) {
343 gpio_direction_output(GPIO_NR_PALMTE2_USB_PULLUP, 1);
344 gpio_free(GPIO_NR_PALMTE2_USB_PULLUP);
345 }
346}
347
Marek Vasut54088bf2009-03-24 00:29:29 +0100348static void __init palmte2_init(void)
349{
350 pxa2xx_mfp_config(ARRAY_AND_SIZE(palmte2_pin_config));
351
Russell Kingcc155c62009-11-09 13:34:08 +0800352 pxa_set_ffuart_info(NULL);
353 pxa_set_btuart_info(NULL);
354 pxa_set_stuart_info(NULL);
355
Russell King - ARM Linux4321e1a2011-02-15 15:37:30 +0800356 pxa_set_fb_info(NULL, &palmte2_lcd_screen);
Marek Vasut54088bf2009-03-24 00:29:29 +0100357 pxa_set_mci_info(&palmte2_mci_platform_data);
Marek Vasut8c8aa5f2009-03-24 21:23:39 +0100358 palmte2_udc_init();
Marek Vasut241cf472010-06-04 03:07:33 +0200359 pxa_set_ac97_info(&palmte2_ac97_pdata);
Marek Vasut8c8aa5f2009-03-24 21:23:39 +0100360 pxa_set_ficp_info(&palmte2_ficp_platform_data);
Marek Vasut54088bf2009-03-24 00:29:29 +0100361
Thierry Redingf5a3b552015-10-05 10:49:51 +0200362 pwm_add_table(palmte2_pwm_lookup, ARRAY_SIZE(palmte2_pwm_lookup));
Marek Vasut54088bf2009-03-24 00:29:29 +0100363 platform_add_devices(devices, ARRAY_SIZE(devices));
364}
365
366MACHINE_START(PALMTE2, "Palm Tungsten|E2")
Nicolas Pitre7375aba2011-07-05 22:38:15 -0400367 .atag_offset = 0x100,
Marek Vasut851982c2010-10-11 02:20:19 +0200368 .map_io = pxa25x_map_io,
Rob Herring4e611092012-01-03 16:53:48 -0600369 .nr_irqs = PXA_NR_IRQS,
Marek Vasut54088bf2009-03-24 00:29:29 +0100370 .init_irq = pxa25x_init_irq,
Eric Miao8a97ae22011-05-18 21:30:04 +0800371 .handle_irq = pxa25x_handle_irq,
Stephen Warren6bb27d72012-11-08 12:40:59 -0700372 .init_time = pxa_timer_init,
Russell King271a74f2011-11-04 14:15:53 +0000373 .init_machine = palmte2_init,
374 .restart = pxa_restart,
Marek Vasut54088bf2009-03-24 00:29:29 +0100375MACHINE_END