m68knommu: move ColdFire pit.c to its own coldfire directory
[wrt350n-kernel.git] / arch / arm / mach-omap1 / board-palmz71.c
bloba9a0f6610c3deef2427ee72f6b80ae7c1885c53e
1 /*
2 * linux/arch/arm/mach-omap1/board-palmz71.c
4 * Modified from board-generic.c
6 * Support for the Palm Zire71 PDA.
8 * Original version : Laurent Gonzalez
10 * Modified for zire71 : Marek Vasut
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.
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>
29 #include <asm/hardware.h>
30 #include <asm/mach-types.h>
31 #include <asm/mach/arch.h>
32 #include <asm/mach/map.h>
33 #include <asm/mach/flash.h>
35 #include <asm/arch/mcbsp.h>
36 #include <asm/arch/gpio.h>
37 #include <asm/arch/mux.h>
38 #include <asm/arch/usb.h>
39 #include <asm/arch/dma.h>
40 #include <asm/arch/tc.h>
41 #include <asm/arch/board.h>
42 #include <asm/arch/irda.h>
43 #include <asm/arch/keypad.h>
44 #include <asm/arch/common.h>
45 #include <asm/arch/omap-alsa.h>
47 #include <linux/spi/spi.h>
48 #include <linux/spi/ads7846.h>
50 static void __init
51 omap_palmz71_init_irq(void)
53 omap1_init_common_hw();
54 omap_init_irq();
55 omap_gpio_init();
58 static int palmz71_keymap[] = {
59 KEY(0, 0, KEY_F1),
60 KEY(0, 1, KEY_F2),
61 KEY(0, 2, KEY_F3),
62 KEY(0, 3, KEY_F4),
63 KEY(0, 4, KEY_POWER),
64 KEY(1, 0, KEY_LEFT),
65 KEY(1, 1, KEY_DOWN),
66 KEY(1, 2, KEY_UP),
67 KEY(1, 3, KEY_RIGHT),
68 KEY(1, 4, KEY_CENTER),
69 KEY(2, 0, KEY_CAMERA),
73 static struct omap_kp_platform_data palmz71_kp_data = {
74 .rows = 8,
75 .cols = 8,
76 .keymap = palmz71_keymap,
77 .rep = 1,
78 .delay = 80,
81 static struct resource palmz71_kp_resources[] = {
82 [0] = {
83 .start = INT_KEYBOARD,
84 .end = INT_KEYBOARD,
85 .flags = IORESOURCE_IRQ,
89 static struct platform_device palmz71_kp_device = {
90 .name = "omap-keypad",
91 .id = -1,
92 .dev = {
93 .platform_data = &palmz71_kp_data,
95 .num_resources = ARRAY_SIZE(palmz71_kp_resources),
96 .resource = palmz71_kp_resources,
99 static struct mtd_partition palmz71_rom_partitions[] = {
100 /* PalmOS "Small ROM", contains the bootloader and the debugger */
102 .name = "smallrom",
103 .offset = 0,
104 .size = 0xa000,
105 .mask_flags = MTD_WRITEABLE,
107 /* PalmOS "Big ROM", a filesystem with all the OS code and data */
109 .name = "bigrom",
110 .offset = SZ_128K,
112 * 0x5f0000 bytes big in the multi-language ("EFIGS") version,
113 * 0x7b0000 bytes in the English-only ("enUS") version.
115 .size = 0x7b0000,
116 .mask_flags = MTD_WRITEABLE,
120 static struct flash_platform_data palmz71_rom_data = {
121 .map_name = "map_rom",
122 .name = "onboardrom",
123 .width = 2,
124 .parts = palmz71_rom_partitions,
125 .nr_parts = ARRAY_SIZE(palmz71_rom_partitions),
128 static struct resource palmz71_rom_resource = {
129 .start = OMAP_CS0_PHYS,
130 .end = OMAP_CS0_PHYS + SZ_8M - 1,
131 .flags = IORESOURCE_MEM,
134 static struct platform_device palmz71_rom_device = {
135 .name = "omapflash",
136 .id = -1,
137 .dev = {
138 .platform_data = &palmz71_rom_data,
140 .num_resources = 1,
141 .resource = &palmz71_rom_resource,
144 static struct platform_device palmz71_lcd_device = {
145 .name = "lcd_palmz71",
146 .id = -1,
149 static struct omap_irda_config palmz71_irda_config = {
150 .transceiver_cap = IR_SIRMODE,
151 .rx_channel = OMAP_DMA_UART3_RX,
152 .tx_channel = OMAP_DMA_UART3_TX,
153 .dest_start = UART3_THR,
154 .src_start = UART3_RHR,
155 .tx_trigger = 0,
156 .rx_trigger = 0,
159 static struct resource palmz71_irda_resources[] = {
160 [0] = {
161 .start = INT_UART3,
162 .end = INT_UART3,
163 .flags = IORESOURCE_IRQ,
167 static struct platform_device palmz71_irda_device = {
168 .name = "omapirda",
169 .id = -1,
170 .dev = {
171 .platform_data = &palmz71_irda_config,
173 .num_resources = ARRAY_SIZE(palmz71_irda_resources),
174 .resource = palmz71_irda_resources,
177 static struct platform_device palmz71_spi_device = {
178 .name = "spi_palmz71",
179 .id = -1,
182 #define DEFAULT_BITPERSAMPLE 16
184 static struct omap_mcbsp_reg_cfg mcbsp_regs = {
185 .spcr2 = FREE | FRST | GRST | XRST | XINTM(3),
186 .spcr1 = RINTM(3) | RRST,
187 .rcr2 = RPHASE | RFRLEN2(OMAP_MCBSP_WORD_8) |
188 RWDLEN2(OMAP_MCBSP_WORD_16) | RDATDLY(0),
189 .rcr1 = RFRLEN1(OMAP_MCBSP_WORD_8) | RWDLEN1(OMAP_MCBSP_WORD_16),
190 .xcr2 = XPHASE | XFRLEN2(OMAP_MCBSP_WORD_8) |
191 XWDLEN2(OMAP_MCBSP_WORD_16) | XDATDLY(0) | XFIG,
192 .xcr1 = XFRLEN1(OMAP_MCBSP_WORD_8) | XWDLEN1(OMAP_MCBSP_WORD_16),
193 .srgr1 = FWID(DEFAULT_BITPERSAMPLE - 1),
194 .srgr2 = GSYNC | CLKSP | FSGM | FPER(DEFAULT_BITPERSAMPLE * 2 - 1),
195 .pcr0 = CLKXP | CLKRP, /* mcbsp: slave */
198 static struct omap_alsa_codec_config alsa_config = {
199 .name = "PalmZ71 AIC23",
200 .mcbsp_regs_alsa = &mcbsp_regs,
201 .codec_configure_dev = NULL, /* aic23_configure */
202 .codec_set_samplerate = NULL, /* aic23_set_samplerate */
203 .codec_clock_setup = NULL, /* aic23_clock_setup */
204 .codec_clock_on = NULL, /* aic23_clock_on */
205 .codec_clock_off = NULL, /* aic23_clock_off */
206 .get_default_samplerate = NULL, /* aic23_get_default_samplerate */
209 static struct platform_device palmz71_mcbsp1_device = {
210 .name = "omap_alsa_mcbsp",
211 .id = 1,
212 .dev = {
213 .platform_data = &alsa_config,
217 static struct omap_backlight_config palmz71_backlight_config = {
218 .default_intensity = 0xa0,
221 static struct platform_device palmz71_backlight_device = {
222 .name = "omap-bl",
223 .id = -1,
224 .dev = {
225 .platform_data = &palmz71_backlight_config,
229 static struct platform_device *devices[] __initdata = {
230 &palmz71_rom_device,
231 &palmz71_kp_device,
232 &palmz71_mcbsp1_device,
233 &palmz71_lcd_device,
234 &palmz71_irda_device,
235 &palmz71_spi_device,
236 &palmz71_backlight_device,
239 static int
240 palmz71_get_pendown_state(void)
242 return !omap_get_gpio_datain(PALMZ71_PENIRQ_GPIO);
245 static const struct ads7846_platform_data palmz71_ts_info = {
246 .model = 7846,
247 .vref_delay_usecs = 100, /* internal, no capacitor */
248 .x_plate_ohms = 419,
249 .y_plate_ohms = 486,
250 .get_pendown_state = palmz71_get_pendown_state,
253 static struct spi_board_info __initdata palmz71_boardinfo[] = { {
254 /* MicroWire (bus 2) CS0 has an ads7846e */
255 .modalias = "ads7846",
256 .platform_data = &palmz71_ts_info,
257 .irq = OMAP_GPIO_IRQ(PALMZ71_PENIRQ_GPIO),
258 .max_speed_hz = 120000 /* max sample rate at 3V */
259 * 26 /* command + data + overhead */,
260 .bus_num = 2,
261 .chip_select = 0,
262 } };
264 static struct omap_usb_config palmz71_usb_config __initdata = {
265 .register_dev = 1, /* Mini-B only receptacle */
266 .hmc_mode = 0,
267 .pins[0] = 2,
270 static struct omap_mmc_config palmz71_mmc_config __initdata = {
271 .mmc[0] = {
272 .enabled = 1,
273 .wire4 = 0,
274 .wp_pin = PALMZ71_MMC_WP_GPIO,
275 .power_pin = -1,
276 .switch_pin = PALMZ71_MMC_IN_GPIO,
280 static struct omap_lcd_config palmz71_lcd_config __initdata = {
281 .ctrl_name = "internal",
284 static struct omap_uart_config palmz71_uart_config __initdata = {
285 .enabled_uarts = (1 << 0) | (1 << 1) | (0 << 2),
288 static struct omap_board_config_kernel palmz71_config[] = {
289 {OMAP_TAG_USB, &palmz71_usb_config},
290 {OMAP_TAG_MMC, &palmz71_mmc_config},
291 {OMAP_TAG_LCD, &palmz71_lcd_config},
292 {OMAP_TAG_UART, &palmz71_uart_config},
295 static irqreturn_t
296 palmz71_powercable(int irq, void *dev_id)
298 if (omap_get_gpio_datain(PALMZ71_USBDETECT_GPIO)) {
299 printk(KERN_INFO "PM: Power cable connected\n");
300 set_irq_type(OMAP_GPIO_IRQ(PALMZ71_USBDETECT_GPIO),
301 IRQT_FALLING);
302 } else {
303 printk(KERN_INFO "PM: Power cable disconnected\n");
304 set_irq_type(OMAP_GPIO_IRQ(PALMZ71_USBDETECT_GPIO),
305 IRQT_RISING);
307 return IRQ_HANDLED;
310 static void __init
311 omap_mpu_wdt_mode(int mode)
313 if (mode)
314 omap_writew(0x8000, OMAP_WDT_TIMER_MODE);
315 else {
316 omap_writew(0x00f5, OMAP_WDT_TIMER_MODE);
317 omap_writew(0x00a0, OMAP_WDT_TIMER_MODE);
321 static void __init
322 palmz71_gpio_setup(int early)
324 if (early) {
325 /* Only set GPIO1 so we have a working serial */
326 omap_set_gpio_dataout(1, 1);
327 omap_set_gpio_direction(1, 0);
328 } else {
329 /* Set MMC/SD host WP pin as input */
330 if (omap_request_gpio(PALMZ71_MMC_WP_GPIO)) {
331 printk(KERN_ERR "Could not reserve WP GPIO!\n");
332 return;
334 omap_set_gpio_direction(PALMZ71_MMC_WP_GPIO, 1);
336 /* Monitor the Power-cable-connected signal */
337 if (omap_request_gpio(PALMZ71_USBDETECT_GPIO)) {
338 printk(KERN_ERR
339 "Could not reserve cable signal GPIO!\n");
340 return;
342 omap_set_gpio_direction(PALMZ71_USBDETECT_GPIO, 1);
343 if (request_irq(OMAP_GPIO_IRQ(PALMZ71_USBDETECT_GPIO),
344 palmz71_powercable, IRQF_SAMPLE_RANDOM,
345 "palmz71-cable", 0))
346 printk(KERN_ERR
347 "IRQ request for power cable failed!\n");
348 palmz71_powercable(OMAP_GPIO_IRQ(PALMZ71_USBDETECT_GPIO), 0);
352 static void __init
353 omap_palmz71_init(void)
355 palmz71_gpio_setup(1);
356 omap_mpu_wdt_mode(0);
358 omap_board_config = palmz71_config;
359 omap_board_config_size = ARRAY_SIZE(palmz71_config);
361 platform_add_devices(devices, ARRAY_SIZE(devices));
363 spi_register_board_info(palmz71_boardinfo,
364 ARRAY_SIZE(palmz71_boardinfo));
365 omap_serial_init();
366 palmz71_gpio_setup(0);
369 static void __init
370 omap_palmz71_map_io(void)
372 omap1_map_common_io();
375 MACHINE_START(OMAP_PALMZ71, "OMAP310 based Palm Zire71")
376 .phys_io = 0xfff00000,
377 .io_pg_offst = ((0xfef00000) >> 18) & 0xfffc,
378 .boot_params = 0x10000100,.map_io = omap_palmz71_map_io,
379 .init_irq = omap_palmz71_init_irq,
380 .init_machine = omap_palmz71_init,
381 .timer = &omap_timer,
382 MACHINE_END