[ARM] pxa/cm-x300: add ac97 controller registration
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / arch / arm / mach-pxa / cm-x300.c
blob8726dc7c73a68f1fc4890462509cfdaa5f5f9c75
1 /*
2 * linux/arch/arm/mach-pxa/cm-x300.c
4 * Support for the CompuLab CM-X300 modules
6 * Copyright (C) 2008 CompuLab Ltd.
8 * Mike Rapoport <mike@compulab.co.il>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
15 #include <linux/module.h>
16 #include <linux/kernel.h>
17 #include <linux/interrupt.h>
18 #include <linux/init.h>
19 #include <linux/platform_device.h>
21 #include <linux/gpio.h>
22 #include <linux/dm9000.h>
23 #include <linux/leds.h>
24 #include <linux/rtc-v3020.h>
26 #include <linux/i2c.h>
27 #include <linux/i2c/pca953x.h>
29 #include <linux/spi/spi.h>
30 #include <linux/spi/spi_gpio.h>
31 #include <linux/spi/tdo24m.h>
33 #include <asm/mach-types.h>
34 #include <asm/mach/arch.h>
35 #include <asm/setup.h>
37 #include <mach/pxa300.h>
38 #include <mach/pxafb.h>
39 #include <mach/mmc.h>
40 #include <mach/ohci.h>
41 #include <plat/i2c.h>
42 #include <plat/pxa3xx_nand.h>
43 #include <mach/audio.h>
45 #include <asm/mach/map.h>
47 #include "generic.h"
49 #define CM_X300_ETH_PHYS 0x08000010
51 #define GPIO82_MMC_IRQ (82)
52 #define GPIO85_MMC_WP (85)
54 #define CM_X300_MMC_IRQ IRQ_GPIO(GPIO82_MMC_IRQ)
56 #define GPIO95_RTC_CS (95)
57 #define GPIO96_RTC_WR (96)
58 #define GPIO97_RTC_RD (97)
59 #define GPIO98_RTC_IO (98)
61 static mfp_cfg_t cm_x300_mfp_cfg[] __initdata = {
62 /* LCD */
63 GPIO54_LCD_LDD_0,
64 GPIO55_LCD_LDD_1,
65 GPIO56_LCD_LDD_2,
66 GPIO57_LCD_LDD_3,
67 GPIO58_LCD_LDD_4,
68 GPIO59_LCD_LDD_5,
69 GPIO60_LCD_LDD_6,
70 GPIO61_LCD_LDD_7,
71 GPIO62_LCD_LDD_8,
72 GPIO63_LCD_LDD_9,
73 GPIO64_LCD_LDD_10,
74 GPIO65_LCD_LDD_11,
75 GPIO66_LCD_LDD_12,
76 GPIO67_LCD_LDD_13,
77 GPIO68_LCD_LDD_14,
78 GPIO69_LCD_LDD_15,
79 GPIO72_LCD_FCLK,
80 GPIO73_LCD_LCLK,
81 GPIO74_LCD_PCLK,
82 GPIO75_LCD_BIAS,
84 /* BTUART */
85 GPIO111_UART2_RTS,
86 GPIO112_UART2_RXD | MFP_LPM_EDGE_FALL,
87 GPIO113_UART2_TXD,
88 GPIO114_UART2_CTS | MFP_LPM_EDGE_BOTH,
90 /* STUART */
91 GPIO109_UART3_TXD,
92 GPIO110_UART3_RXD | MFP_LPM_EDGE_FALL,
94 /* AC97 */
95 GPIO23_AC97_nACRESET,
96 GPIO24_AC97_SYSCLK,
97 GPIO29_AC97_BITCLK,
98 GPIO25_AC97_SDATA_IN_0,
99 GPIO27_AC97_SDATA_OUT,
100 GPIO28_AC97_SYNC,
102 /* Keypad */
103 GPIO115_KP_MKIN_0 | MFP_LPM_EDGE_BOTH,
104 GPIO116_KP_MKIN_1 | MFP_LPM_EDGE_BOTH,
105 GPIO117_KP_MKIN_2 | MFP_LPM_EDGE_BOTH,
106 GPIO118_KP_MKIN_3 | MFP_LPM_EDGE_BOTH,
107 GPIO119_KP_MKIN_4 | MFP_LPM_EDGE_BOTH,
108 GPIO120_KP_MKIN_5 | MFP_LPM_EDGE_BOTH,
109 GPIO2_2_KP_MKIN_6 | MFP_LPM_EDGE_BOTH,
110 GPIO3_2_KP_MKIN_7 | MFP_LPM_EDGE_BOTH,
111 GPIO121_KP_MKOUT_0,
112 GPIO122_KP_MKOUT_1,
113 GPIO123_KP_MKOUT_2,
114 GPIO124_KP_MKOUT_3,
115 GPIO125_KP_MKOUT_4,
116 GPIO4_2_KP_MKOUT_5,
118 /* MMC1 */
119 GPIO3_MMC1_DAT0,
120 GPIO4_MMC1_DAT1 | MFP_LPM_EDGE_BOTH,
121 GPIO5_MMC1_DAT2,
122 GPIO6_MMC1_DAT3,
123 GPIO7_MMC1_CLK,
124 GPIO8_MMC1_CMD, /* CMD0 for slot 0 */
126 /* MMC2 */
127 GPIO9_MMC2_DAT0,
128 GPIO10_MMC2_DAT1 | MFP_LPM_EDGE_BOTH,
129 GPIO11_MMC2_DAT2,
130 GPIO12_MMC2_DAT3,
131 GPIO13_MMC2_CLK,
132 GPIO14_MMC2_CMD,
134 /* FFUART */
135 GPIO30_UART1_RXD | MFP_LPM_EDGE_FALL,
136 GPIO31_UART1_TXD,
137 GPIO32_UART1_CTS,
138 GPIO37_UART1_RTS,
139 GPIO33_UART1_DCD,
140 GPIO34_UART1_DSR | MFP_LPM_EDGE_FALL,
141 GPIO35_UART1_RI,
142 GPIO36_UART1_DTR,
144 /* GPIOs */
145 GPIO82_GPIO | MFP_PULL_HIGH, /* MMC CD */
146 GPIO85_GPIO, /* MMC WP */
147 GPIO99_GPIO, /* Ethernet IRQ */
149 /* RTC GPIOs */
150 GPIO95_GPIO, /* RTC CS */
151 GPIO96_GPIO, /* RTC WR */
152 GPIO97_GPIO, /* RTC RD */
153 GPIO98_GPIO, /* RTC IO */
155 /* Standard I2C */
156 GPIO21_I2C_SCL,
157 GPIO22_I2C_SDA,
160 static mfp_cfg_t cm_x300_rev_lt130_mfp_cfg[] __initdata = {
161 /* GPIOs */
162 GPIO79_GPIO, /* LED */
163 GPIO77_GPIO, /* WiFi reset */
164 GPIO78_GPIO, /* BT reset */
167 static mfp_cfg_t cm_x300_rev_ge130_mfp_cfg[] __initdata = {
168 /* GPIOs */
169 GPIO76_GPIO, /* LED */
170 GPIO71_GPIO, /* WiFi reset */
171 GPIO70_GPIO, /* BT reset */
174 #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
175 static struct resource dm9000_resources[] = {
176 [0] = {
177 .start = CM_X300_ETH_PHYS,
178 .end = CM_X300_ETH_PHYS + 0x3,
179 .flags = IORESOURCE_MEM,
181 [1] = {
182 .start = CM_X300_ETH_PHYS + 0x4,
183 .end = CM_X300_ETH_PHYS + 0x4 + 500,
184 .flags = IORESOURCE_MEM,
186 [2] = {
187 .start = IRQ_GPIO(mfp_to_gpio(MFP_PIN_GPIO99)),
188 .end = IRQ_GPIO(mfp_to_gpio(MFP_PIN_GPIO99)),
189 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
193 static struct dm9000_plat_data cm_x300_dm9000_platdata = {
194 .flags = DM9000_PLATF_16BITONLY | DM9000_PLATF_NO_EEPROM,
197 static struct platform_device dm9000_device = {
198 .name = "dm9000",
199 .id = 0,
200 .num_resources = ARRAY_SIZE(dm9000_resources),
201 .resource = dm9000_resources,
202 .dev = {
203 .platform_data = &cm_x300_dm9000_platdata,
208 static void __init cm_x300_init_dm9000(void)
210 platform_device_register(&dm9000_device);
212 #else
213 static inline void cm_x300_init_dm9000(void) {}
214 #endif
216 /* LCD */
217 #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
218 static struct pxafb_mode_info cm_x300_lcd_modes[] = {
219 [0] = {
220 .pixclock = 38250,
221 .bpp = 16,
222 .xres = 480,
223 .yres = 640,
224 .hsync_len = 8,
225 .vsync_len = 2,
226 .left_margin = 8,
227 .upper_margin = 2,
228 .right_margin = 24,
229 .lower_margin = 4,
230 .cmap_greyscale = 0,
232 [1] = {
233 .pixclock = 153800,
234 .bpp = 16,
235 .xres = 240,
236 .yres = 320,
237 .hsync_len = 8,
238 .vsync_len = 2,
239 .left_margin = 8,
240 .upper_margin = 2,
241 .right_margin = 88,
242 .lower_margin = 2,
243 .cmap_greyscale = 0,
247 static struct pxafb_mach_info cm_x300_lcd = {
248 .modes = cm_x300_lcd_modes,
249 .num_modes = ARRAY_SIZE(cm_x300_lcd_modes),
250 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
253 static void __init cm_x300_init_lcd(void)
255 set_pxa_fb_info(&cm_x300_lcd);
257 #else
258 static inline void cm_x300_init_lcd(void) {}
259 #endif
261 #if defined(CONFIG_SPI_GPIO) || defined(CONFIG_SPI_GPIO_MODULE)
262 #define GPIO_LCD_BASE (144)
263 #define GPIO_LCD_DIN (GPIO_LCD_BASE + 8) /* aux_gpio3_0 */
264 #define GPIO_LCD_DOUT (GPIO_LCD_BASE + 9) /* aux_gpio3_1 */
265 #define GPIO_LCD_SCL (GPIO_LCD_BASE + 10) /* aux_gpio3_2 */
266 #define GPIO_LCD_CS (GPIO_LCD_BASE + 11) /* aux_gpio3_3 */
267 #define LCD_SPI_BUS_NUM (1)
269 static struct spi_gpio_platform_data cm_x300_spi_gpio_pdata = {
270 .sck = GPIO_LCD_SCL,
271 .mosi = GPIO_LCD_DIN,
272 .miso = GPIO_LCD_DOUT,
273 .num_chipselect = 1,
276 static struct platform_device cm_x300_spi_gpio = {
277 .name = "spi_gpio",
278 .id = LCD_SPI_BUS_NUM,
279 .dev = {
280 .platform_data = &cm_x300_spi_gpio_pdata,
284 static struct tdo24m_platform_data cm_x300_tdo24m_pdata = {
285 .model = TDO35S,
288 static struct spi_board_info cm_x300_spi_devices[] __initdata = {
290 .modalias = "tdo24m",
291 .max_speed_hz = 1000000,
292 .bus_num = LCD_SPI_BUS_NUM,
293 .chip_select = 0,
294 .controller_data = (void *) GPIO_LCD_CS,
295 .platform_data = &cm_x300_tdo24m_pdata,
299 static void __init cm_x300_init_spi(void)
301 spi_register_board_info(cm_x300_spi_devices,
302 ARRAY_SIZE(cm_x300_spi_devices));
303 platform_device_register(&cm_x300_spi_gpio);
305 #else
306 static inline void cm_x300_init_spi(void) {}
307 #endif
309 #if defined(CONFIG_SND_PXA2XX_LIB_AC97)
310 static void __init cm_x300_init_ac97(void)
312 pxa_set_ac97_info(NULL);
314 #else
315 static inline void cm_x300_init_ac97(void) {}
316 #endif
318 #if defined(CONFIG_MTD_NAND_PXA3xx) || defined(CONFIG_MTD_NAND_PXA3xx_MODULE)
319 static struct mtd_partition cm_x300_nand_partitions[] = {
320 [0] = {
321 .name = "OBM",
322 .offset = 0,
323 .size = SZ_256K,
324 .mask_flags = MTD_WRITEABLE, /* force read-only */
326 [1] = {
327 .name = "U-Boot",
328 .offset = MTDPART_OFS_APPEND,
329 .size = SZ_256K,
330 .mask_flags = MTD_WRITEABLE, /* force read-only */
332 [2] = {
333 .name = "Environment",
334 .offset = MTDPART_OFS_APPEND,
335 .size = SZ_256K,
337 [3] = {
338 .name = "reserved",
339 .offset = MTDPART_OFS_APPEND,
340 .size = SZ_256K + SZ_1M,
341 .mask_flags = MTD_WRITEABLE, /* force read-only */
343 [4] = {
344 .name = "kernel",
345 .offset = MTDPART_OFS_APPEND,
346 .size = SZ_4M,
348 [5] = {
349 .name = "fs",
350 .offset = MTDPART_OFS_APPEND,
351 .size = MTDPART_SIZ_FULL,
355 static struct pxa3xx_nand_platform_data cm_x300_nand_info = {
356 .enable_arbiter = 1,
357 .keep_config = 1,
358 .parts = cm_x300_nand_partitions,
359 .nr_parts = ARRAY_SIZE(cm_x300_nand_partitions),
362 static void __init cm_x300_init_nand(void)
364 pxa3xx_set_nand_info(&cm_x300_nand_info);
366 #else
367 static inline void cm_x300_init_nand(void) {}
368 #endif
370 #if defined(CONFIG_MMC) || defined(CONFIG_MMC_MODULE)
371 static struct pxamci_platform_data cm_x300_mci_platform_data = {
372 .detect_delay = 20,
373 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
374 .gpio_card_detect = GPIO82_MMC_IRQ,
375 .gpio_card_ro = GPIO85_MMC_WP,
376 .gpio_power = -1,
379 /* The second MMC slot of CM-X300 is hardwired to Libertas card and has
380 no detection/ro pins */
381 static int cm_x300_mci2_init(struct device *dev,
382 irq_handler_t cm_x300_detect_int,
383 void *data)
385 return 0;
388 static void cm_x300_mci2_exit(struct device *dev, void *data)
392 static struct pxamci_platform_data cm_x300_mci2_platform_data = {
393 .detect_delay = 20,
394 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
395 .init = cm_x300_mci2_init,
396 .exit = cm_x300_mci2_exit,
397 .gpio_card_detect = -1,
398 .gpio_card_ro = -1,
399 .gpio_power = -1,
402 static void __init cm_x300_init_mmc(void)
404 pxa_set_mci_info(&cm_x300_mci_platform_data);
405 pxa3xx_set_mci2_info(&cm_x300_mci2_platform_data);
407 #else
408 static inline void cm_x300_init_mmc(void) {}
409 #endif
411 #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
412 static struct pxaohci_platform_data cm_x300_ohci_platform_data = {
413 .port_mode = PMM_PERPORT_MODE,
414 .flags = ENABLE_PORT1 | ENABLE_PORT2 | POWER_CONTROL_LOW,
417 static void __init cm_x300_init_ohci(void)
419 pxa_set_ohci_info(&cm_x300_ohci_platform_data);
421 #else
422 static inline void cm_x300_init_ohci(void) {}
423 #endif
425 #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
426 static struct gpio_led cm_x300_leds[] = {
427 [0] = {
428 .name = "cm-x300:green",
429 .default_trigger = "heartbeat",
430 .active_low = 1,
434 static struct gpio_led_platform_data cm_x300_gpio_led_pdata = {
435 .num_leds = ARRAY_SIZE(cm_x300_leds),
436 .leds = cm_x300_leds,
439 static struct platform_device cm_x300_led_device = {
440 .name = "leds-gpio",
441 .id = -1,
442 .dev = {
443 .platform_data = &cm_x300_gpio_led_pdata,
447 static void __init cm_x300_init_leds(void)
449 if (system_rev < 130)
450 cm_x300_leds[0].gpio = 79;
451 else
452 cm_x300_leds[0].gpio = 76;
454 platform_device_register(&cm_x300_led_device);
456 #else
457 static inline void cm_x300_init_leds(void) {}
458 #endif
460 #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
461 /* PCA9555 */
462 static struct pca953x_platform_data cm_x300_gpio_ext_pdata_0 = {
463 .gpio_base = 128,
466 static struct pca953x_platform_data cm_x300_gpio_ext_pdata_1 = {
467 .gpio_base = 144,
470 static struct i2c_board_info cm_x300_gpio_ext_info[] = {
471 [0] = {
472 I2C_BOARD_INFO("pca9555", 0x24),
473 .platform_data = &cm_x300_gpio_ext_pdata_0,
475 [1] = {
476 I2C_BOARD_INFO("pca9555", 0x25),
477 .platform_data = &cm_x300_gpio_ext_pdata_1,
481 static void __init cm_x300_init_i2c(void)
483 pxa_set_i2c_info(NULL);
484 i2c_register_board_info(0, cm_x300_gpio_ext_info,
485 ARRAY_SIZE(cm_x300_gpio_ext_info));
487 #else
488 static inline void cm_x300_init_i2c(void) {}
489 #endif
491 #if defined(CONFIG_RTC_DRV_V3020) || defined(CONFIG_RTC_DRV_V3020_MODULE)
492 struct v3020_platform_data cm_x300_v3020_pdata = {
493 .use_gpio = 1,
494 .gpio_cs = GPIO95_RTC_CS,
495 .gpio_wr = GPIO96_RTC_WR,
496 .gpio_rd = GPIO97_RTC_RD,
497 .gpio_io = GPIO98_RTC_IO,
500 static struct platform_device cm_x300_rtc_device = {
501 .name = "v3020",
502 .id = -1,
503 .dev = {
504 .platform_data = &cm_x300_v3020_pdata,
508 static void __init cm_x300_init_rtc(void)
510 platform_device_register(&cm_x300_rtc_device);
512 #else
513 static inline void cm_x300_init_rtc(void) {}
514 #endif
516 static void __init cm_x300_init_mfp(void)
518 /* board-processor specific GPIO initialization */
519 pxa3xx_mfp_config(ARRAY_AND_SIZE(cm_x300_mfp_cfg));
521 if (system_rev < 130)
522 pxa3xx_mfp_config(ARRAY_AND_SIZE(cm_x300_rev_lt130_mfp_cfg));
523 else
524 pxa3xx_mfp_config(ARRAY_AND_SIZE(cm_x300_rev_ge130_mfp_cfg));
527 static void __init cm_x300_init(void)
529 cm_x300_init_mfp();
531 pxa_set_ffuart_info(NULL);
532 pxa_set_btuart_info(NULL);
533 pxa_set_stuart_info(NULL);
535 cm_x300_init_dm9000();
536 cm_x300_init_lcd();
537 cm_x300_init_ohci();
538 cm_x300_init_mmc();
539 cm_x300_init_nand();
540 cm_x300_init_leds();
541 cm_x300_init_i2c();
542 cm_x300_init_spi();
543 cm_x300_init_rtc();
544 cm_x300_init_ac97();
547 static void __init cm_x300_fixup(struct machine_desc *mdesc, struct tag *tags,
548 char **cmdline, struct meminfo *mi)
550 mi->nr_banks = 2;
551 mi->bank[0].start = 0xa0000000;
552 mi->bank[0].node = 0;
553 mi->bank[0].size = (64*1024*1024);
554 mi->bank[1].start = 0xc0000000;
555 mi->bank[1].node = 0;
556 mi->bank[1].size = (64*1024*1024);
559 MACHINE_START(CM_X300, "CM-X300 module")
560 .phys_io = 0x40000000,
561 .boot_params = 0xa0000100,
562 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
563 .map_io = pxa_map_io,
564 .init_irq = pxa3xx_init_irq,
565 .timer = &pxa_timer,
566 .init_machine = cm_x300_init,
567 .fixup = cm_x300_fixup,
568 MACHINE_END