Commit | Line | Data |
---|---|---|
dc563b4f MV |
1 | /* |
2 | * linux/arch/arm/mach-omap1/board-palmtt.c | |
3 | * | |
4 | * Modified from board-palmtt2.c | |
5 | * | |
6 | * Modified and amended for Palm Tungsten|T | |
7 | * by Marek Vasut <marek.vasut@gmail.com> | |
8 | * | |
9 | * This program is free software; you can redistribute it and/or modify | |
10 | * it under the terms of the GNU General Public License version 2 as | |
11 | * published by the Free Software Foundation. | |
12 | */ | |
13 | ||
14 | #include <linux/delay.h> | |
2f8163ba | 15 | #include <linux/gpio.h> |
dc563b4f MV |
16 | #include <linux/kernel.h> |
17 | #include <linux/init.h> | |
18 | #include <linux/platform_device.h> | |
19 | #include <linux/notifier.h> | |
20 | #include <linux/clk.h> | |
21 | #include <linux/input.h> | |
22 | #include <linux/interrupt.h> | |
23 | #include <linux/mtd/mtd.h> | |
24 | #include <linux/mtd/partitions.h> | |
561b036a | 25 | #include <linux/mtd/physmap.h> |
dc563b4f | 26 | #include <linux/leds.h> |
ddba6c7f | 27 | #include <linux/omapfb.h> |
2e3ee9f4 TL |
28 | #include <linux/spi/spi.h> |
29 | #include <linux/spi/ads7846.h> | |
cc012729 | 30 | #include <linux/platform_data/omap1_bl.h> |
a8f7445c | 31 | #include <linux/platform_data/leds-omap.h> |
dc563b4f | 32 | |
dc563b4f MV |
33 | #include <asm/mach-types.h> |
34 | #include <asm/mach/arch.h> | |
35 | #include <asm/mach/map.h> | |
dc563b4f | 36 | |
100f9638 | 37 | #include "flash.h" |
70c494c3 | 38 | #include <mach/mux.h> |
45c3eb7d | 39 | #include <linux/omap-dma.h> |
54b693d4 | 40 | #include <mach/tc.h> |
2203747c | 41 | #include <linux/platform_data/keypad-omap.h> |
dc563b4f | 42 | |
2e3ee9f4 | 43 | #include <mach/hardware.h> |
b924b204 | 44 | #include <mach/usb.h> |
2e3ee9f4 TL |
45 | |
46 | #include "common.h" | |
dc563b4f | 47 | |
b2830810 TL |
48 | #define PALMTT_USBDETECT_GPIO 0 |
49 | #define PALMTT_CABLE_GPIO 1 | |
50 | #define PALMTT_LED_GPIO 3 | |
51 | #define PALMTT_PENIRQ_GPIO 6 | |
52 | #define PALMTT_MMC_WP_GPIO 8 | |
53 | #define PALMTT_HDQ_GPIO 11 | |
54 | ||
da1f026b | 55 | static const unsigned int palmtt_keymap[] = { |
dc563b4f | 56 | KEY(0, 0, KEY_ESC), |
da1f026b JK |
57 | KEY(1, 0, KEY_SPACE), |
58 | KEY(2, 0, KEY_LEFTCTRL), | |
59 | KEY(3, 0, KEY_TAB), | |
60 | KEY(4, 0, KEY_ENTER), | |
61 | KEY(0, 1, KEY_LEFT), | |
dc563b4f | 62 | KEY(1, 1, KEY_DOWN), |
da1f026b JK |
63 | KEY(2, 1, KEY_UP), |
64 | KEY(3, 1, KEY_RIGHT), | |
65 | KEY(0, 2, KEY_SLEEP), | |
66 | KEY(4, 2, KEY_Y), | |
dc563b4f MV |
67 | }; |
68 | ||
69 | static struct mtd_partition palmtt_partitions[] = { | |
70 | { | |
71 | .name = "write8k", | |
72 | .offset = 0, | |
73 | .size = SZ_8K, | |
74 | .mask_flags = 0, | |
75 | }, | |
76 | { | |
77 | .name = "PalmOS-BootLoader(ro)", | |
78 | .offset = SZ_8K, | |
79 | .size = 7 * SZ_8K, | |
80 | .mask_flags = MTD_WRITEABLE, | |
81 | }, | |
82 | { | |
83 | .name = "u-boot", | |
84 | .offset = MTDPART_OFS_APPEND, | |
85 | .size = 8 * SZ_8K, | |
86 | .mask_flags = 0, | |
87 | }, | |
88 | { | |
89 | .name = "PalmOS-FS(ro)", | |
90 | .offset = MTDPART_OFS_APPEND, | |
91 | .size = 7 * SZ_1M + 4 * SZ_64K - 16 * SZ_8K, | |
92 | .mask_flags = MTD_WRITEABLE, | |
93 | }, | |
94 | { | |
95 | .name = "u-boot(rez)", | |
96 | .offset = MTDPART_OFS_APPEND, | |
97 | .size = SZ_128K, | |
98 | .mask_flags = 0 | |
99 | }, | |
100 | { | |
101 | .name = "empty", | |
102 | .offset = MTDPART_OFS_APPEND, | |
103 | .size = MTDPART_SIZ_FULL, | |
104 | .mask_flags = 0 | |
105 | } | |
106 | }; | |
107 | ||
561b036a | 108 | static struct physmap_flash_data palmtt_flash_data = { |
dc563b4f | 109 | .width = 2, |
561b036a | 110 | .set_vpp = omap1_set_vpp, |
dc563b4f MV |
111 | .parts = palmtt_partitions, |
112 | .nr_parts = ARRAY_SIZE(palmtt_partitions), | |
113 | }; | |
114 | ||
115 | static struct resource palmtt_flash_resource = { | |
116 | .start = OMAP_CS0_PHYS, | |
117 | .end = OMAP_CS0_PHYS + SZ_8M - 1, | |
118 | .flags = IORESOURCE_MEM, | |
119 | }; | |
120 | ||
121 | static struct platform_device palmtt_flash_device = { | |
561b036a | 122 | .name = "physmap-flash", |
dc563b4f MV |
123 | .id = 0, |
124 | .dev = { | |
125 | .platform_data = &palmtt_flash_data, | |
126 | }, | |
127 | .num_resources = 1, | |
128 | .resource = &palmtt_flash_resource, | |
129 | }; | |
130 | ||
dc563b4f MV |
131 | static struct resource palmtt_kp_resources[] = { |
132 | [0] = { | |
133 | .start = INT_KEYBOARD, | |
134 | .end = INT_KEYBOARD, | |
135 | .flags = IORESOURCE_IRQ, | |
136 | }, | |
137 | }; | |
138 | ||
da1f026b JK |
139 | static const struct matrix_keymap_data palmtt_keymap_data = { |
140 | .keymap = palmtt_keymap, | |
141 | .keymap_size = ARRAY_SIZE(palmtt_keymap), | |
142 | }; | |
143 | ||
dc563b4f MV |
144 | static struct omap_kp_platform_data palmtt_kp_data = { |
145 | .rows = 6, | |
146 | .cols = 3, | |
da1f026b | 147 | .keymap_data = &palmtt_keymap_data, |
dc563b4f MV |
148 | }; |
149 | ||
150 | static struct platform_device palmtt_kp_device = { | |
151 | .name = "omap-keypad", | |
152 | .id = -1, | |
153 | .dev = { | |
154 | .platform_data = &palmtt_kp_data, | |
155 | }, | |
156 | .num_resources = ARRAY_SIZE(palmtt_kp_resources), | |
157 | .resource = palmtt_kp_resources, | |
158 | }; | |
159 | ||
160 | static struct platform_device palmtt_lcd_device = { | |
161 | .name = "lcd_palmtt", | |
162 | .id = -1, | |
163 | }; | |
dc563b4f MV |
164 | |
165 | static struct platform_device palmtt_spi_device = { | |
166 | .name = "spi_palmtt", | |
167 | .id = -1, | |
168 | }; | |
169 | ||
170 | static struct omap_backlight_config palmtt_backlight_config = { | |
171 | .default_intensity = 0xa0, | |
172 | }; | |
173 | ||
174 | static struct platform_device palmtt_backlight_device = { | |
175 | .name = "omap-bl", | |
176 | .id = -1, | |
177 | .dev = { | |
178 | .platform_data= &palmtt_backlight_config, | |
179 | }, | |
180 | }; | |
181 | ||
182 | static struct omap_led_config palmtt_led_config[] = { | |
183 | { | |
184 | .cdev = { | |
185 | .name = "palmtt:led0", | |
186 | }, | |
187 | .gpio = PALMTT_LED_GPIO, | |
188 | }, | |
189 | }; | |
190 | ||
191 | static struct omap_led_platform_data palmtt_led_data = { | |
192 | .nr_leds = ARRAY_SIZE(palmtt_led_config), | |
193 | .leds = palmtt_led_config, | |
194 | }; | |
195 | ||
196 | static struct platform_device palmtt_led_device = { | |
197 | .name = "omap-led", | |
198 | .id = -1, | |
199 | .dev = { | |
200 | .platform_data = &palmtt_led_data, | |
201 | }, | |
202 | }; | |
203 | ||
204 | static struct platform_device *palmtt_devices[] __initdata = { | |
205 | &palmtt_flash_device, | |
dc563b4f MV |
206 | &palmtt_kp_device, |
207 | &palmtt_lcd_device, | |
dc563b4f MV |
208 | &palmtt_spi_device, |
209 | &palmtt_backlight_device, | |
210 | &palmtt_led_device, | |
211 | }; | |
212 | ||
213 | static int palmtt_get_pendown_state(void) | |
214 | { | |
0b84b5ca | 215 | return !gpio_get_value(6); |
dc563b4f MV |
216 | } |
217 | ||
218 | static const struct ads7846_platform_data palmtt_ts_info = { | |
219 | .model = 7846, | |
220 | .vref_delay_usecs = 100, /* internal, no capacitor */ | |
221 | .x_plate_ohms = 419, | |
222 | .y_plate_ohms = 486, | |
223 | .get_pendown_state = palmtt_get_pendown_state, | |
224 | }; | |
225 | ||
226 | static struct spi_board_info __initdata palmtt_boardinfo[] = { | |
227 | { | |
228 | /* MicroWire (bus 2) CS0 has an ads7846e */ | |
229 | .modalias = "ads7846", | |
230 | .platform_data = &palmtt_ts_info, | |
dc563b4f MV |
231 | .max_speed_hz = 120000 /* max sample rate at 3V */ |
232 | * 26 /* command + data + overhead */, | |
233 | .bus_num = 2, | |
234 | .chip_select = 0, | |
235 | } | |
236 | }; | |
237 | ||
dc563b4f MV |
238 | static struct omap_usb_config palmtt_usb_config __initdata = { |
239 | .register_dev = 1, | |
240 | .hmc_mode = 0, | |
241 | .pins[0] = 2, | |
242 | }; | |
243 | ||
244 | static struct omap_lcd_config palmtt_lcd_config __initdata = { | |
245 | .ctrl_name = "internal", | |
246 | }; | |
247 | ||
dc563b4f MV |
248 | static void __init omap_mpu_wdt_mode(int mode) { |
249 | if (mode) | |
250 | omap_writew(0x8000, OMAP_WDT_TIMER_MODE); | |
251 | else { | |
252 | omap_writew(0x00f5, OMAP_WDT_TIMER_MODE); | |
253 | omap_writew(0x00a0, OMAP_WDT_TIMER_MODE); | |
254 | } | |
255 | } | |
256 | ||
257 | static void __init omap_palmtt_init(void) | |
258 | { | |
c33da3a8 JK |
259 | /* mux pins for uarts */ |
260 | omap_cfg_reg(UART1_TX); | |
261 | omap_cfg_reg(UART1_RTS); | |
262 | omap_cfg_reg(UART2_TX); | |
263 | omap_cfg_reg(UART2_RTS); | |
264 | omap_cfg_reg(UART3_TX); | |
265 | omap_cfg_reg(UART3_RX); | |
266 | ||
dc563b4f MV |
267 | omap_mpu_wdt_mode(0); |
268 | ||
dc563b4f MV |
269 | platform_add_devices(palmtt_devices, ARRAY_SIZE(palmtt_devices)); |
270 | ||
46a0a540 | 271 | palmtt_boardinfo[0].irq = gpio_to_irq(6); |
dc563b4f MV |
272 | spi_register_board_info(palmtt_boardinfo,ARRAY_SIZE(palmtt_boardinfo)); |
273 | omap_serial_init(); | |
dd0cdd88 | 274 | omap1_usb_init(&palmtt_usb_config); |
1ed16a86 | 275 | omap_register_i2c_bus(1, 100, NULL, 0); |
ddba6c7f TV |
276 | |
277 | omapfb_set_lcd_config(&palmtt_lcd_config); | |
dc563b4f MV |
278 | } |
279 | ||
dc563b4f | 280 | MACHINE_START(OMAP_PALMTT, "OMAP1510 based Palm Tungsten|T") |
246e389d | 281 | .atag_offset = 0x100, |
7b88e62f TL |
282 | .map_io = omap15xx_map_io, |
283 | .init_early = omap1_init_early, | |
7b88e62f | 284 | .init_irq = omap1_init_irq, |
b694331c | 285 | .handle_irq = omap1_handle_irq, |
dc563b4f | 286 | .init_machine = omap_palmtt_init, |
82c3bd03 | 287 | .init_late = omap1_init_late, |
6bb27d73 | 288 | .init_time = omap1_timer_init, |
baa95883 | 289 | .restart = omap1_restart, |
dc563b4f | 290 | MACHINE_END |