]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/arm/mach-omap1/board-palmz71.c
ARM: OMAP: Clean-up MMC device init
[linux-2.6-omap-h63xx.git] / arch / arm / mach-omap1 / board-palmz71.c
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
29 #include <mach/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>
34
35 #include <mach/mcbsp.h>
36 #include <mach/gpio.h>
37 #include <mach/mux.h>
38 #include <mach/usb.h>
39 #include <mach/dma.h>
40 #include <mach/tc.h>
41 #include <mach/board.h>
42 #include <mach/irda.h>
43 #include <mach/keypad.h>
44 #include <mach/common.h>
45 #include <mach/omap-alsa.h>
46 #include <mach/mmc.h>
47
48 #include <linux/spi/spi.h>
49 #include <linux/spi/ads7846.h>
50
51 static void __init
52 omap_palmz71_init_irq(void)
53 {
54         omap1_init_common_hw();
55         omap_init_irq();
56         omap_gpio_init();
57 }
58
59 static int palmz71_keymap[] = {
60         KEY(0, 0, KEY_F1),
61         KEY(0, 1, KEY_F2),
62         KEY(0, 2, KEY_F3),
63         KEY(0, 3, KEY_F4),
64         KEY(0, 4, KEY_POWER),
65         KEY(1, 0, KEY_LEFT),
66         KEY(1, 1, KEY_DOWN),
67         KEY(1, 2, KEY_UP),
68         KEY(1, 3, KEY_RIGHT),
69         KEY(1, 4, KEY_ENTER),
70         KEY(2, 0, KEY_CAMERA),
71         0,
72 };
73
74 static struct omap_kp_platform_data palmz71_kp_data = {
75         .rows   = 8,
76         .cols   = 8,
77         .keymap = palmz71_keymap,
78         .rep    = 1,
79         .delay  = 80,
80 };
81
82 static struct resource palmz71_kp_resources[] = {
83         [0] = {
84                 .start  = INT_KEYBOARD,
85                 .end    = INT_KEYBOARD,
86                 .flags  = IORESOURCE_IRQ,
87         },
88 };
89
90 static struct platform_device palmz71_kp_device = {
91         .name   = "omap-keypad",
92         .id     = -1,
93         .dev    = {
94                 .platform_data = &palmz71_kp_data,
95         },
96         .num_resources  = ARRAY_SIZE(palmz71_kp_resources),
97         .resource       = palmz71_kp_resources,
98 };
99
100 static struct mtd_partition palmz71_rom_partitions[] = {
101         /* PalmOS "Small ROM", contains the bootloader and the debugger */
102         {
103                 .name           = "smallrom",
104                 .offset         = 0,
105                 .size           = 0xa000,
106                 .mask_flags     = MTD_WRITEABLE,
107         },
108         /* PalmOS "Big ROM", a filesystem with all the OS code and data */
109         {
110                 .name   = "bigrom",
111                 .offset = SZ_128K,
112                 /*
113                  * 0x5f0000 bytes big in the multi-language ("EFIGS") version,
114                  * 0x7b0000 bytes in the English-only ("enUS") version.
115                  */
116                 .size           = 0x7b0000,
117                 .mask_flags     = MTD_WRITEABLE,
118         },
119 };
120
121 static struct flash_platform_data palmz71_rom_data = {
122         .map_name       = "map_rom",
123         .name           = "onboardrom",
124         .width          = 2,
125         .parts          = palmz71_rom_partitions,
126         .nr_parts       = ARRAY_SIZE(palmz71_rom_partitions),
127 };
128
129 static struct resource palmz71_rom_resource = {
130         .start  = OMAP_CS0_PHYS,
131         .end    = OMAP_CS0_PHYS + SZ_8M - 1,
132         .flags  = IORESOURCE_MEM,
133 };
134
135 static struct platform_device palmz71_rom_device = {
136         .name   = "omapflash",
137         .id     = -1,
138         .dev = {
139                 .platform_data = &palmz71_rom_data,
140         },
141         .num_resources  = 1,
142         .resource       = &palmz71_rom_resource,
143 };
144
145 static struct platform_device palmz71_lcd_device = {
146         .name   = "lcd_palmz71",
147         .id     = -1,
148 };
149
150 static struct omap_irda_config palmz71_irda_config = {
151         .transceiver_cap        = IR_SIRMODE,
152         .rx_channel             = OMAP_DMA_UART3_RX,
153         .tx_channel             = OMAP_DMA_UART3_TX,
154         .dest_start             = UART3_THR,
155         .src_start              = UART3_RHR,
156         .tx_trigger             = 0,
157         .rx_trigger             = 0,
158 };
159
160 static struct resource palmz71_irda_resources[] = {
161         [0] = {
162                 .start  = INT_UART3,
163                 .end    = INT_UART3,
164                 .flags  = IORESOURCE_IRQ,
165         },
166 };
167
168 static struct platform_device palmz71_irda_device = {
169         .name   = "omapirda",
170         .id     = -1,
171         .dev = {
172                 .platform_data = &palmz71_irda_config,
173         },
174         .num_resources  = ARRAY_SIZE(palmz71_irda_resources),
175         .resource       = palmz71_irda_resources,
176 };
177
178 static struct platform_device palmz71_spi_device = {
179         .name   = "spi_palmz71",
180         .id     = -1,
181 };
182
183 #define DEFAULT_BITPERSAMPLE 16
184
185 static struct omap_mcbsp_reg_cfg mcbsp_regs = {
186         .spcr2  = FREE | FRST | GRST | XRST | XINTM(3),
187         .spcr1  = RINTM(3) | RRST,
188         .rcr2   = RPHASE | RFRLEN2(OMAP_MCBSP_WORD_8) |
189                         RWDLEN2(OMAP_MCBSP_WORD_16) | RDATDLY(0),
190         .rcr1   = RFRLEN1(OMAP_MCBSP_WORD_8) | RWDLEN1(OMAP_MCBSP_WORD_16),
191         .xcr2   = XPHASE | XFRLEN2(OMAP_MCBSP_WORD_8) |
192                         XWDLEN2(OMAP_MCBSP_WORD_16) | XDATDLY(0) | XFIG,
193         .xcr1   = XFRLEN1(OMAP_MCBSP_WORD_8) | XWDLEN1(OMAP_MCBSP_WORD_16),
194         .srgr1  = FWID(DEFAULT_BITPERSAMPLE - 1),
195         .srgr2  = GSYNC | CLKSP | FSGM | FPER(DEFAULT_BITPERSAMPLE * 2 - 1),
196         .pcr0   = CLKXP | CLKRP,        /* mcbsp: slave */
197 };
198
199 static struct omap_alsa_codec_config alsa_config = {
200         .name                   = "PalmZ71 AIC23",
201         .mcbsp_regs_alsa        = &mcbsp_regs,
202         .codec_configure_dev    = NULL, /* aic23_configure */
203         .codec_set_samplerate   = NULL, /* aic23_set_samplerate */
204         .codec_clock_setup      = NULL, /* aic23_clock_setup */
205         .codec_clock_on         = NULL, /* aic23_clock_on */
206         .codec_clock_off        = NULL, /* aic23_clock_off */
207         .get_default_samplerate = NULL, /* aic23_get_default_samplerate */
208 };
209
210 static struct platform_device palmz71_mcbsp1_device = {
211         .name   = "omap_alsa_mcbsp",
212         .id     = 1,
213         .dev = {
214                 .platform_data = &alsa_config,
215         },
216 };
217
218 static struct omap_backlight_config palmz71_backlight_config = {
219         .default_intensity      = 0xa0,
220 };
221
222 static struct platform_device palmz71_backlight_device = {
223         .name   = "omap-bl",
224         .id     = -1,
225         .dev    = {
226                 .platform_data = &palmz71_backlight_config,
227         },
228 };
229
230 static struct platform_device *devices[] __initdata = {
231         &palmz71_rom_device,
232         &palmz71_kp_device,
233         &palmz71_mcbsp1_device,
234         &palmz71_lcd_device,
235         &palmz71_irda_device,
236         &palmz71_spi_device,
237         &palmz71_backlight_device,
238 };
239
240 static int
241 palmz71_get_pendown_state(void)
242 {
243         return !omap_get_gpio_datain(PALMZ71_PENIRQ_GPIO);
244 }
245
246 static const struct ads7846_platform_data palmz71_ts_info = {
247         .model                  = 7846,
248         .vref_delay_usecs       = 100,  /* internal, no capacitor */
249         .x_plate_ohms           = 419,
250         .y_plate_ohms           = 486,
251         .get_pendown_state      = palmz71_get_pendown_state,
252 };
253
254 static struct spi_board_info __initdata palmz71_boardinfo[] = { {
255         /* MicroWire (bus 2) CS0 has an ads7846e */
256         .modalias       = "ads7846",
257         .platform_data  = &palmz71_ts_info,
258         .irq            = OMAP_GPIO_IRQ(PALMZ71_PENIRQ_GPIO),
259         .max_speed_hz   = 120000        /* max sample rate at 3V */
260                                 * 26    /* command + data + overhead */,
261         .bus_num        = 2,
262         .chip_select    = 0,
263 } };
264
265 static struct omap_usb_config palmz71_usb_config __initdata = {
266         .register_dev   = 1,    /* Mini-B only receptacle */
267         .hmc_mode       = 0,
268         .pins[0]        = 2,
269 };
270
271 static struct omap_mmc_platform_data palmz71_mmc_data = {
272         .nr_slots                       = 1,
273         .slots[0]       = {
274                 .enabled                = 1,
275                 .wire4                  = 0,
276                 .wp_pin                 = PALMZ71_MMC_WP_GPIO,
277                 .power_pin              = -1,
278                 .switch_pin             = PALMZ71_MMC_IN_GPIO,
279                 .name                   = "mmcblk",
280         },
281 };
282
283 static struct omap_lcd_config palmz71_lcd_config __initdata = {
284         .ctrl_name = "internal",
285 };
286
287 static struct omap_uart_config palmz71_uart_config __initdata = {
288         .enabled_uarts = (1 << 0) | (1 << 1) | (0 << 2),
289 };
290
291 static struct omap_board_config_kernel palmz71_config[] __initdata = {
292         {OMAP_TAG_USB,  &palmz71_usb_config},
293         {OMAP_TAG_LCD,  &palmz71_lcd_config},
294         {OMAP_TAG_UART, &palmz71_uart_config},
295 };
296
297 static irqreturn_t
298 palmz71_powercable(int irq, void *dev_id)
299 {
300         if (omap_get_gpio_datain(PALMZ71_USBDETECT_GPIO)) {
301                 printk(KERN_INFO "PM: Power cable connected\n");
302                 set_irq_type(OMAP_GPIO_IRQ(PALMZ71_USBDETECT_GPIO),
303                                 IRQ_TYPE_EDGE_FALLING);
304         } else {
305                 printk(KERN_INFO "PM: Power cable disconnected\n");
306                 set_irq_type(OMAP_GPIO_IRQ(PALMZ71_USBDETECT_GPIO),
307                                 IRQ_TYPE_EDGE_RISING);
308         }
309         return IRQ_HANDLED;
310 }
311
312 static void __init
313 omap_mpu_wdt_mode(int mode)
314 {
315         if (mode)
316                 omap_writew(0x8000, OMAP_WDT_TIMER_MODE);
317         else {
318                 omap_writew(0x00f5, OMAP_WDT_TIMER_MODE);
319                 omap_writew(0x00a0, OMAP_WDT_TIMER_MODE);
320         }
321 }
322
323 static void __init
324 palmz71_gpio_setup(int early)
325 {
326         if (early) {
327                 /* Only set GPIO1 so we have a working serial */
328                 omap_set_gpio_dataout(1, 1);
329                 omap_set_gpio_direction(1, 0);
330         } else {
331                 /* Set MMC/SD host WP pin as input */
332                 if (omap_request_gpio(PALMZ71_MMC_WP_GPIO)) {
333                         printk(KERN_ERR "Could not reserve WP GPIO!\n");
334                         return;
335                 }
336                 omap_set_gpio_direction(PALMZ71_MMC_WP_GPIO, 1);
337
338                 /* Monitor the Power-cable-connected signal */
339                 if (omap_request_gpio(PALMZ71_USBDETECT_GPIO)) {
340                         printk(KERN_ERR
341                                 "Could not reserve cable signal GPIO!\n");
342                         return;
343                 }
344                 omap_set_gpio_direction(PALMZ71_USBDETECT_GPIO, 1);
345                 if (request_irq(OMAP_GPIO_IRQ(PALMZ71_USBDETECT_GPIO),
346                                 palmz71_powercable, IRQF_SAMPLE_RANDOM,
347                                 "palmz71-cable", 0))
348                         printk(KERN_ERR
349                                         "IRQ request for power cable failed!\n");
350                 palmz71_powercable(OMAP_GPIO_IRQ(PALMZ71_USBDETECT_GPIO), 0);
351         }
352 }
353
354 static void __init
355 omap_palmz71_init(void)
356 {
357         palmz71_gpio_setup(1);
358         omap_mpu_wdt_mode(0);
359
360         omap_board_config = palmz71_config;
361         omap_board_config_size = ARRAY_SIZE(palmz71_config);
362
363         platform_add_devices(devices, ARRAY_SIZE(devices));
364
365         spi_register_board_info(palmz71_boardinfo,
366                                 ARRAY_SIZE(palmz71_boardinfo));
367         omap_serial_init();
368         omap_register_i2c_bus(1, 100, NULL, 0);
369         palmz71_gpio_setup(0);
370         omap1_init_mmc(&palmz71_mmc_data);
371 }
372
373 static void __init
374 omap_palmz71_map_io(void)
375 {
376         omap1_map_common_io();
377 }
378
379 MACHINE_START(OMAP_PALMZ71, "OMAP310 based Palm Zire71")
380         .phys_io = 0xfff00000,
381         .io_pg_offst = ((0xfef00000) >> 18) & 0xfffc,
382         .boot_params = 0x10000100,.map_io = omap_palmz71_map_io,
383         .init_irq = omap_palmz71_init_irq,
384         .init_machine = omap_palmz71_init,
385         .timer = &omap_timer,
386 MACHINE_END