1
2
3
4
5
6
7
8
9
10
11
12
13
14
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>
23#include <linux/pda_power.h>
24#include <linux/pwm_backlight.h>
25#include <linux/gpio.h>
26#include <linux/wm97xx.h>
27#include <linux/power_supply.h>
28#include <linux/usb/gpio_vbus.h>
29
30#include <asm/mach-types.h>
31#include <asm/mach/arch.h>
32#include <asm/mach/map.h>
33
34#include <mach/pxa25x.h>
35#include <mach/audio.h>
36#include <mach/palmte2.h>
37#include <linux/platform_data/mmc-pxamci.h>
38#include <linux/platform_data/video-pxafb.h>
39#include <linux/platform_data/irda-pxaficp.h>
40#include <mach/udc.h>
41#include <linux/platform_data/asoc-palm27x.h>
42
43#include "generic.h"
44#include "devices.h"
45
46
47
48
49static unsigned long palmte2_pin_config[] __initdata = {
50
51 GPIO6_MMC_CLK,
52 GPIO8_MMC_CS0,
53 GPIO10_GPIO,
54 GPIO55_GPIO,
55 GPIO51_GPIO,
56
57
58 GPIO28_AC97_BITCLK,
59 GPIO29_AC97_SDATA_IN_0,
60 GPIO30_AC97_SDATA_OUT,
61 GPIO31_AC97_SYNC,
62
63
64 GPIO16_PWM0_OUT,
65
66
67 GPIO15_GPIO,
68 GPIO53_GPIO,
69
70
71 GPIO48_GPIO,
72 GPIO46_FICP_RXD,
73 GPIO47_FICP_TXD,
74
75
76 GPIOxx_LCD_TFT_16BPP,
77
78
79 GPIO5_GPIO,
80 GPIO7_GPIO,
81 GPIO11_GPIO,
82 GPIO13_GPIO,
83 GPIO14_GPIO,
84 GPIO19_GPIO,
85 GPIO20_GPIO,
86 GPIO21_GPIO,
87 GPIO22_GPIO,
88
89
90 GPIO1_RST,
91 GPIO4_GPIO,
92 GPIO9_GPIO,
93 GPIO15_GPIO,
94 GPIO37_GPIO,
95 GPIO56_GPIO,
96};
97
98
99
100
101static struct pxamci_platform_data palmte2_mci_platform_data = {
102 .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,
106};
107
108#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
109
110
111
112static struct gpio_keys_button palmte2_pxa_buttons[] = {
113 {KEY_F1, GPIO_NR_PALMTE2_KEY_CONTACTS, 1, "Contacts" },
114 {KEY_F2, GPIO_NR_PALMTE2_KEY_CALENDAR, 1, "Calendar" },
115 {KEY_F3, GPIO_NR_PALMTE2_KEY_TASKS, 1, "Tasks" },
116 {KEY_F4, GPIO_NR_PALMTE2_KEY_NOTES, 1, "Notes" },
117 {KEY_ENTER, GPIO_NR_PALMTE2_KEY_CENTER, 1, "Center" },
118 {KEY_LEFT, GPIO_NR_PALMTE2_KEY_LEFT, 1, "Left" },
119 {KEY_RIGHT, GPIO_NR_PALMTE2_KEY_RIGHT, 1, "Right" },
120 {KEY_DOWN, GPIO_NR_PALMTE2_KEY_DOWN, 1, "Down" },
121 {KEY_UP, GPIO_NR_PALMTE2_KEY_UP, 1, "Up" },
122};
123
124static struct gpio_keys_platform_data palmte2_pxa_keys_data = {
125 .buttons = palmte2_pxa_buttons,
126 .nbuttons = ARRAY_SIZE(palmte2_pxa_buttons),
127};
128
129static struct platform_device palmte2_pxa_keys = {
130 .name = "gpio-keys",
131 .id = -1,
132 .dev = {
133 .platform_data = &palmte2_pxa_keys_data,
134 },
135};
136#endif
137
138
139
140
141static struct gpio palmte_bl_gpios[] = {
142 { GPIO_NR_PALMTE2_BL_POWER, GPIOF_INIT_LOW, "Backlight power" },
143 { GPIO_NR_PALMTE2_LCD_POWER, GPIOF_INIT_LOW, "LCD power" },
144};
145
146static int palmte2_backlight_init(struct device *dev)
147{
148 return gpio_request_array(ARRAY_AND_SIZE(palmte_bl_gpios));
149}
150
151static int palmte2_backlight_notify(struct device *dev, int brightness)
152{
153 gpio_set_value(GPIO_NR_PALMTE2_BL_POWER, brightness);
154 gpio_set_value(GPIO_NR_PALMTE2_LCD_POWER, brightness);
155 return brightness;
156}
157
158static void palmte2_backlight_exit(struct device *dev)
159{
160 gpio_free_array(ARRAY_AND_SIZE(palmte_bl_gpios));
161}
162
163static struct platform_pwm_backlight_data palmte2_backlight_data = {
164 .pwm_id = 0,
165 .max_brightness = PALMTE2_MAX_INTENSITY,
166 .dft_brightness = PALMTE2_MAX_INTENSITY,
167 .pwm_period_ns = PALMTE2_PERIOD_NS,
168 .init = palmte2_backlight_init,
169 .notify = palmte2_backlight_notify,
170 .exit = palmte2_backlight_exit,
171};
172
173static struct platform_device palmte2_backlight = {
174 .name = "pwm-backlight",
175 .dev = {
176 .parent = &pxa25x_device_pwm0.dev,
177 .platform_data = &palmte2_backlight_data,
178 },
179};
180
181
182
183
184static struct pxaficp_platform_data palmte2_ficp_platform_data = {
185 .gpio_pwdown = GPIO_NR_PALMTE2_IR_DISABLE,
186 .transceiver_cap = IR_SIRMODE | IR_OFF,
187};
188
189
190
191
192static struct gpio_vbus_mach_info palmte2_udc_info = {
193 .gpio_vbus = GPIO_NR_PALMTE2_USB_DETECT_N,
194 .gpio_vbus_inverted = 1,
195 .gpio_pullup = GPIO_NR_PALMTE2_USB_PULLUP,
196};
197
198static struct platform_device palmte2_gpio_vbus = {
199 .name = "gpio-vbus",
200 .id = -1,
201 .dev = {
202 .platform_data = &palmte2_udc_info,
203 },
204};
205
206
207
208
209static int power_supply_init(struct device *dev)
210{
211 int ret;
212
213 ret = gpio_request(GPIO_NR_PALMTE2_POWER_DETECT, "CABLE_STATE_AC");
214 if (ret)
215 goto err1;
216 ret = gpio_direction_input(GPIO_NR_PALMTE2_POWER_DETECT);
217 if (ret)
218 goto err2;
219
220 return 0;
221
222err2:
223 gpio_free(GPIO_NR_PALMTE2_POWER_DETECT);
224err1:
225 return ret;
226}
227
228static int palmte2_is_ac_online(void)
229{
230 return gpio_get_value(GPIO_NR_PALMTE2_POWER_DETECT);
231}
232
233static void power_supply_exit(struct device *dev)
234{
235 gpio_free(GPIO_NR_PALMTE2_POWER_DETECT);
236}
237
238static char *palmte2_supplicants[] = {
239 "main-battery",
240};
241
242static struct pda_power_pdata power_supply_info = {
243 .init = power_supply_init,
244 .is_ac_online = palmte2_is_ac_online,
245 .exit = power_supply_exit,
246 .supplied_to = palmte2_supplicants,
247 .num_supplicants = ARRAY_SIZE(palmte2_supplicants),
248};
249
250static struct platform_device power_supply = {
251 .name = "pda-power",
252 .id = -1,
253 .dev = {
254 .platform_data = &power_supply_info,
255 },
256};
257
258
259
260
261static struct wm97xx_batt_pdata palmte2_batt_pdata = {
262 .batt_aux = WM97XX_AUX_ID3,
263 .temp_aux = WM97XX_AUX_ID2,
264 .charge_gpio = -1,
265 .max_voltage = PALMTE2_BAT_MAX_VOLTAGE,
266 .min_voltage = PALMTE2_BAT_MIN_VOLTAGE,
267 .batt_mult = 1000,
268 .batt_div = 414,
269 .temp_mult = 1,
270 .temp_div = 1,
271 .batt_tech = POWER_SUPPLY_TECHNOLOGY_LIPO,
272 .batt_name = "main-batt",
273};
274
275static struct wm97xx_pdata palmte2_wm97xx_pdata = {
276 .batt_pdata = &palmte2_batt_pdata,
277};
278
279static pxa2xx_audio_ops_t palmte2_ac97_pdata = {
280 .codec_pdata = { &palmte2_wm97xx_pdata, },
281};
282
283static struct palm27x_asoc_info palmte2_asoc_pdata = {
284 .jack_gpio = GPIO_NR_PALMTE2_EARPHONE_DETECT,
285};
286
287static struct platform_device palmte2_asoc = {
288 .name = "palm27x-asoc",
289 .id = -1,
290 .dev = {
291 .platform_data = &palmte2_asoc_pdata,
292 },
293};
294
295
296
297
298static struct pxafb_mode_info palmte2_lcd_modes[] = {
299{
300 .pixclock = 77757,
301 .xres = 320,
302 .yres = 320,
303 .bpp = 16,
304
305 .left_margin = 28,
306 .right_margin = 7,
307 .upper_margin = 7,
308 .lower_margin = 5,
309
310 .hsync_len = 4,
311 .vsync_len = 1,
312},
313};
314
315static struct pxafb_mach_info palmte2_lcd_screen = {
316 .modes = palmte2_lcd_modes,
317 .num_modes = ARRAY_SIZE(palmte2_lcd_modes),
318 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
319};
320
321
322
323
324static struct platform_device *devices[] __initdata = {
325#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
326 &palmte2_pxa_keys,
327#endif
328 &palmte2_backlight,
329 &power_supply,
330 &palmte2_asoc,
331 &palmte2_gpio_vbus,
332};
333
334
335static void __init palmte2_udc_init(void)
336{
337 if (!gpio_request(GPIO_NR_PALMTE2_USB_PULLUP, "UDC Vbus")) {
338 gpio_direction_output(GPIO_NR_PALMTE2_USB_PULLUP, 1);
339 gpio_free(GPIO_NR_PALMTE2_USB_PULLUP);
340 }
341}
342
343static void __init palmte2_init(void)
344{
345 pxa2xx_mfp_config(ARRAY_AND_SIZE(palmte2_pin_config));
346
347 pxa_set_ffuart_info(NULL);
348 pxa_set_btuart_info(NULL);
349 pxa_set_stuart_info(NULL);
350
351 pxa_set_fb_info(NULL, &palmte2_lcd_screen);
352 pxa_set_mci_info(&palmte2_mci_platform_data);
353 palmte2_udc_init();
354 pxa_set_ac97_info(&palmte2_ac97_pdata);
355 pxa_set_ficp_info(&palmte2_ficp_platform_data);
356
357 platform_add_devices(devices, ARRAY_SIZE(devices));
358}
359
360MACHINE_START(PALMTE2, "Palm Tungsten|E2")
361 .atag_offset = 0x100,
362 .map_io = pxa25x_map_io,
363 .nr_irqs = PXA_NR_IRQS,
364 .init_irq = pxa25x_init_irq,
365 .handle_irq = pxa25x_handle_irq,
366 .init_time = pxa_timer_init,
367 .init_machine = palmte2_init,
368 .restart = pxa_restart,
369MACHINE_END
370