]>
Commit | Line | Data |
---|---|---|
ec70e8af MV |
1 | /* |
2 | * linux/arch/arm/mach-omap1/board-palmz71.c | |
3 | * | |
4 | * Modified from board-generic.c | |
5 | * | |
6 | * Support for the Palm Zire71 PDA. | |
7 | * | |
8 | * Original version : Laurent Gonzalez | |
9 | * | |
10 | * Modified for zire71 : Marek Vasut | |
11 | * | |
12 | * This program is free software; you can redistribute it and/or modify | |
13 | * it under the terms of the GNU General Public License version 2 as | |
14 | * published by the Free Software Foundation. | |
15 | */ | |
16 | ||
17 | #include <linux/delay.h> | |
18 | #include <linux/kernel.h> | |
19 | #include <linux/init.h> | |
20 | #include <linux/platform_device.h> | |
21 | #include <linux/notifier.h> | |
22 | #include <linux/clk.h> | |
23 | #include <linux/irq.h> | |
24 | #include <linux/input.h> | |
25 | #include <linux/interrupt.h> | |
26 | #include <linux/mtd/mtd.h> | |
27 | #include <linux/mtd/partitions.h> | |
28 | ||
a09e64fb | 29 | #include <mach/hardware.h> |
ec70e8af MV |
30 | #include <asm/mach-types.h> |
31 | #include <asm/mach/arch.h> | |
32 | #include <asm/mach/map.h> | |
33 | #include <asm/mach/flash.h> | |
34 | ||
a09e64fb RK |
35 | #include <mach/gpio.h> |
36 | #include <mach/mux.h> | |
37 | #include <mach/usb.h> | |
38 | #include <mach/dma.h> | |
39 | #include <mach/tc.h> | |
40 | #include <mach/board.h> | |
41 | #include <mach/irda.h> | |
42 | #include <mach/keypad.h> | |
43 | #include <mach/common.h> | |
44 | #include <mach/omap-alsa.h> | |
ec70e8af | 45 | |
ec70e8af MV |
46 | #include <linux/spi/spi.h> |
47 | #include <linux/spi/ads7846.h> | |
48 | ||
49 | static void __init | |
50 | omap_palmz71_init_irq(void) | |
51 | { | |
52 | omap1_init_common_hw(); | |
53 | omap_init_irq(); | |
54 | omap_gpio_init(); | |
55 | } | |
56 | ||
57 | static int palmz71_keymap[] = { | |
58 | KEY(0, 0, KEY_F1), | |
59 | KEY(0, 1, KEY_F2), | |
60 | KEY(0, 2, KEY_F3), | |
61 | KEY(0, 3, KEY_F4), | |
62 | KEY(0, 4, KEY_POWER), | |
63 | KEY(1, 0, KEY_LEFT), | |
64 | KEY(1, 1, KEY_DOWN), | |
65 | KEY(1, 2, KEY_UP), | |
66 | KEY(1, 3, KEY_RIGHT), | |
ec44dfa8 | 67 | KEY(1, 4, KEY_ENTER), |
ec70e8af MV |
68 | KEY(2, 0, KEY_CAMERA), |
69 | 0, | |
70 | }; | |
71 | ||
72 | static struct omap_kp_platform_data palmz71_kp_data = { | |
73 | .rows = 8, | |
74 | .cols = 8, | |
75 | .keymap = palmz71_keymap, | |
76 | .rep = 1, | |
77 | .delay = 80, | |
78 | }; | |
79 | ||
80 | static struct resource palmz71_kp_resources[] = { | |
81 | [0] = { | |
82 | .start = INT_KEYBOARD, | |
83 | .end = INT_KEYBOARD, | |
84 | .flags = IORESOURCE_IRQ, | |
85 | }, | |
86 | }; | |
87 | ||
88 | static struct platform_device palmz71_kp_device = { | |
89 | .name = "omap-keypad", | |
90 | .id = -1, | |
91 | .dev = { | |
92 | .platform_data = &palmz71_kp_data, | |
93 | }, | |
94 | .num_resources = ARRAY_SIZE(palmz71_kp_resources), | |
95 | .resource = palmz71_kp_resources, | |
96 | }; | |
97 | ||
98 | static struct mtd_partition palmz71_rom_partitions[] = { | |
99 | /* PalmOS "Small ROM", contains the bootloader and the debugger */ | |
100 | { | |
101 | .name = "smallrom", | |
102 | .offset = 0, | |
103 | .size = 0xa000, | |
104 | .mask_flags = MTD_WRITEABLE, | |
105 | }, | |
106 | /* PalmOS "Big ROM", a filesystem with all the OS code and data */ | |
107 | { | |
108 | .name = "bigrom", | |
109 | .offset = SZ_128K, | |
110 | /* | |
111 | * 0x5f0000 bytes big in the multi-language ("EFIGS") version, | |
112 | * 0x7b0000 bytes in the English-only ("enUS") version. | |
113 | */ | |
114 | .size = 0x7b0000, | |
115 | .mask_flags = MTD_WRITEABLE, | |
116 | }, | |
117 | }; | |
118 | ||
119 | static struct flash_platform_data palmz71_rom_data = { | |
120 | .map_name = "map_rom", | |
121 | .name = "onboardrom", | |
122 | .width = 2, | |
123 | .parts = palmz71_rom_partitions, | |
124 | .nr_parts = ARRAY_SIZE(palmz71_rom_partitions), | |
125 | }; | |
126 | ||
127 | static struct resource palmz71_rom_resource = { | |
128 | .start = OMAP_CS0_PHYS, | |
129 | .end = OMAP_CS0_PHYS + SZ_8M - 1, | |
130 | .flags = IORESOURCE_MEM, | |
131 | }; | |
132 | ||
133 | static struct platform_device palmz71_rom_device = { | |
134 | .name = "omapflash", | |
135 | .id = -1, | |
136 | .dev = { | |
137 | .platform_data = &palmz71_rom_data, | |
138 | }, | |
139 | .num_resources = 1, | |
140 | .resource = &palmz71_rom_resource, | |
141 | }; | |
142 | ||
143 | static struct platform_device palmz71_lcd_device = { | |
144 | .name = "lcd_palmz71", | |
145 | .id = -1, | |
146 | }; | |
147 | ||
148 | static struct omap_irda_config palmz71_irda_config = { | |
149 | .transceiver_cap = IR_SIRMODE, | |
150 | .rx_channel = OMAP_DMA_UART3_RX, | |
151 | .tx_channel = OMAP_DMA_UART3_TX, | |
152 | .dest_start = UART3_THR, | |
153 | .src_start = UART3_RHR, | |
154 | .tx_trigger = 0, | |
155 | .rx_trigger = 0, | |
156 | }; | |
157 | ||
158 | static struct resource palmz71_irda_resources[] = { | |
159 | [0] = { | |
160 | .start = INT_UART3, | |
161 | .end = INT_UART3, | |
162 | .flags = IORESOURCE_IRQ, | |
163 | }, | |
164 | }; | |
165 | ||
166 | static struct platform_device palmz71_irda_device = { | |
167 | .name = "omapirda", | |
168 | .id = -1, | |
169 | .dev = { | |
170 | .platform_data = &palmz71_irda_config, | |
171 | }, | |
172 | .num_resources = ARRAY_SIZE(palmz71_irda_resources), | |
173 | .resource = palmz71_irda_resources, | |
174 | }; | |
175 | ||
176 | static struct platform_device palmz71_spi_device = { | |
177 | .name = "spi_palmz71", | |
178 | .id = -1, | |
179 | }; | |
180 | ||
ec70e8af MV |
181 | static struct omap_backlight_config palmz71_backlight_config = { |
182 | .default_intensity = 0xa0, | |
183 | }; | |
184 | ||
185 | static struct platform_device palmz71_backlight_device = { | |
186 | .name = "omap-bl", | |
187 | .id = -1, | |
188 | .dev = { | |
189 | .platform_data = &palmz71_backlight_config, | |
190 | }, | |
191 | }; | |
192 | ||
193 | static struct platform_device *devices[] __initdata = { | |
194 | &palmz71_rom_device, | |
195 | &palmz71_kp_device, | |
ec70e8af MV |
196 | &palmz71_lcd_device, |
197 | &palmz71_irda_device, | |
198 | &palmz71_spi_device, | |
199 | &palmz71_backlight_device, | |
200 | }; | |
201 | ||
202 | static int | |
203 | palmz71_get_pendown_state(void) | |
204 | { | |
0b84b5ca | 205 | return !gpio_get_value(PALMZ71_PENIRQ_GPIO); |
ec70e8af MV |
206 | } |
207 | ||
208 | static const struct ads7846_platform_data palmz71_ts_info = { | |
209 | .model = 7846, | |
210 | .vref_delay_usecs = 100, /* internal, no capacitor */ | |
211 | .x_plate_ohms = 419, | |
212 | .y_plate_ohms = 486, | |
213 | .get_pendown_state = palmz71_get_pendown_state, | |
214 | }; | |
215 | ||
216 | static struct spi_board_info __initdata palmz71_boardinfo[] = { { | |
217 | /* MicroWire (bus 2) CS0 has an ads7846e */ | |
218 | .modalias = "ads7846", | |
219 | .platform_data = &palmz71_ts_info, | |
220 | .irq = OMAP_GPIO_IRQ(PALMZ71_PENIRQ_GPIO), | |
221 | .max_speed_hz = 120000 /* max sample rate at 3V */ | |
222 | * 26 /* command + data + overhead */, | |
223 | .bus_num = 2, | |
224 | .chip_select = 0, | |
225 | } }; | |
226 | ||
227 | static struct omap_usb_config palmz71_usb_config __initdata = { | |
228 | .register_dev = 1, /* Mini-B only receptacle */ | |
229 | .hmc_mode = 0, | |
230 | .pins[0] = 2, | |
231 | }; | |
232 | ||
ec70e8af MV |
233 | static struct omap_lcd_config palmz71_lcd_config __initdata = { |
234 | .ctrl_name = "internal", | |
235 | }; | |
236 | ||
237 | static struct omap_uart_config palmz71_uart_config __initdata = { | |
238 | .enabled_uarts = (1 << 0) | (1 << 1) | (0 << 2), | |
239 | }; | |
240 | ||
e27a93a9 | 241 | static struct omap_board_config_kernel palmz71_config[] __initdata = { |
ec70e8af | 242 | {OMAP_TAG_USB, &palmz71_usb_config}, |
ec70e8af MV |
243 | {OMAP_TAG_LCD, &palmz71_lcd_config}, |
244 | {OMAP_TAG_UART, &palmz71_uart_config}, | |
245 | }; | |
246 | ||
247 | static irqreturn_t | |
248 | palmz71_powercable(int irq, void *dev_id) | |
249 | { | |
0b84b5ca | 250 | if (gpio_get_value(PALMZ71_USBDETECT_GPIO)) { |
ec70e8af | 251 | printk(KERN_INFO "PM: Power cable connected\n"); |
15f74b03 | 252 | set_irq_type(gpio_to_irq(PALMZ71_USBDETECT_GPIO), |
6cab4860 | 253 | IRQ_TYPE_EDGE_FALLING); |
ec70e8af MV |
254 | } else { |
255 | printk(KERN_INFO "PM: Power cable disconnected\n"); | |
15f74b03 | 256 | set_irq_type(gpio_to_irq(PALMZ71_USBDETECT_GPIO), |
6cab4860 | 257 | IRQ_TYPE_EDGE_RISING); |
ec70e8af MV |
258 | } |
259 | return IRQ_HANDLED; | |
260 | } | |
261 | ||
262 | static void __init | |
263 | omap_mpu_wdt_mode(int mode) | |
264 | { | |
265 | if (mode) | |
266 | omap_writew(0x8000, OMAP_WDT_TIMER_MODE); | |
267 | else { | |
268 | omap_writew(0x00f5, OMAP_WDT_TIMER_MODE); | |
269 | omap_writew(0x00a0, OMAP_WDT_TIMER_MODE); | |
270 | } | |
271 | } | |
272 | ||
273 | static void __init | |
274 | palmz71_gpio_setup(int early) | |
275 | { | |
276 | if (early) { | |
277 | /* Only set GPIO1 so we have a working serial */ | |
e918edf7 | 278 | gpio_direction_output(1, 1); |
ec70e8af MV |
279 | } else { |
280 | /* Set MMC/SD host WP pin as input */ | |
f2d18fea | 281 | if (gpio_request(PALMZ71_MMC_WP_GPIO, "MMC WP") < 0) { |
ec70e8af MV |
282 | printk(KERN_ERR "Could not reserve WP GPIO!\n"); |
283 | return; | |
284 | } | |
40e3925b | 285 | gpio_direction_input(PALMZ71_MMC_WP_GPIO); |
ec70e8af MV |
286 | |
287 | /* Monitor the Power-cable-connected signal */ | |
f2d18fea | 288 | if (gpio_request(PALMZ71_USBDETECT_GPIO, "USB detect") < 0) { |
ec70e8af MV |
289 | printk(KERN_ERR |
290 | "Could not reserve cable signal GPIO!\n"); | |
291 | return; | |
292 | } | |
40e3925b | 293 | gpio_direction_input(PALMZ71_USBDETECT_GPIO); |
15f74b03 | 294 | if (request_irq(gpio_to_irq(PALMZ71_USBDETECT_GPIO), |
ec70e8af MV |
295 | palmz71_powercable, IRQF_SAMPLE_RANDOM, |
296 | "palmz71-cable", 0)) | |
297 | printk(KERN_ERR | |
298 | "IRQ request for power cable failed!\n"); | |
15f74b03 | 299 | palmz71_powercable(gpio_to_irq(PALMZ71_USBDETECT_GPIO), 0); |
ec70e8af MV |
300 | } |
301 | } | |
302 | ||
303 | static void __init | |
304 | omap_palmz71_init(void) | |
305 | { | |
306 | palmz71_gpio_setup(1); | |
307 | omap_mpu_wdt_mode(0); | |
308 | ||
309 | omap_board_config = palmz71_config; | |
310 | omap_board_config_size = ARRAY_SIZE(palmz71_config); | |
311 | ||
312 | platform_add_devices(devices, ARRAY_SIZE(devices)); | |
313 | ||
314 | spi_register_board_info(palmz71_boardinfo, | |
315 | ARRAY_SIZE(palmz71_boardinfo)); | |
316 | omap_serial_init(); | |
1ed16a86 | 317 | omap_register_i2c_bus(1, 100, NULL, 0); |
ec70e8af MV |
318 | palmz71_gpio_setup(0); |
319 | } | |
320 | ||
321 | static void __init | |
322 | omap_palmz71_map_io(void) | |
323 | { | |
324 | omap1_map_common_io(); | |
325 | } | |
326 | ||
327 | MACHINE_START(OMAP_PALMZ71, "OMAP310 based Palm Zire71") | |
328 | .phys_io = 0xfff00000, | |
329 | .io_pg_offst = ((0xfef00000) >> 18) & 0xfffc, | |
330 | .boot_params = 0x10000100,.map_io = omap_palmz71_map_io, | |
331 | .init_irq = omap_palmz71_init_irq, | |
332 | .init_machine = omap_palmz71_init, | |
333 | .timer = &omap_timer, | |
334 | MACHINE_END |