Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 1 | /* |
| 2 | * linux/arch/arm/mach-pxa/cm-x300.c |
| 3 | * |
| 4 | * Support for the CompuLab CM-X300 modules |
| 5 | * |
Igor Grinberg | 14fd9e0 | 2009-10-14 09:20:25 +0200 | [diff] [blame] | 6 | * Copyright (C) 2008,2009 CompuLab Ltd. |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 7 | * |
| 8 | * Mike Rapoport <mike@compulab.co.il> |
Igor Grinberg | 14fd9e0 | 2009-10-14 09:20:25 +0200 | [diff] [blame] | 9 | * Igor Grinberg <grinberg@compulab.co.il> |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 10 | * |
| 11 | * This program is free software; you can redistribute it and/or modify |
| 12 | * it under the terms of the GNU General Public License version 2 as |
| 13 | * published by the Free Software Foundation. |
| 14 | */ |
Igor Grinberg | 32de50e | 2011-05-09 14:41:48 +0300 | [diff] [blame] | 15 | #define pr_fmt(fmt) "%s: " fmt, __func__ |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 16 | |
| 17 | #include <linux/module.h> |
| 18 | #include <linux/kernel.h> |
| 19 | #include <linux/interrupt.h> |
| 20 | #include <linux/init.h> |
Igor Grinberg | b3d01da | 2009-10-14 09:20:21 +0200 | [diff] [blame] | 21 | #include <linux/delay.h> |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 22 | #include <linux/platform_device.h> |
Igor Grinberg | 1b43d8e | 2010-07-27 15:07:00 +0300 | [diff] [blame] | 23 | #include <linux/clk.h> |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 24 | |
| 25 | #include <linux/gpio.h> |
| 26 | #include <linux/dm9000.h> |
| 27 | #include <linux/leds.h> |
Mike Rapoport | 1858ced | 2009-06-04 10:44:52 +0300 | [diff] [blame] | 28 | #include <linux/rtc-v3020.h> |
Igor Grinberg | db20546 | 2009-11-10 14:18:41 +0200 | [diff] [blame] | 29 | #include <linux/pwm_backlight.h> |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 30 | |
| 31 | #include <linux/i2c.h> |
| 32 | #include <linux/i2c/pca953x.h> |
Sebastian Andrzej Siewior | b459396 | 2011-02-23 12:38:16 +0100 | [diff] [blame] | 33 | #include <linux/i2c/pxa-i2c.h> |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 34 | |
Igor Grinberg | 9c017ca | 2009-10-14 09:20:24 +0200 | [diff] [blame] | 35 | #include <linux/mfd/da903x.h> |
Igor Grinberg | d176d64 | 2010-03-09 11:43:51 +0200 | [diff] [blame] | 36 | #include <linux/regulator/machine.h> |
Igor Grinberg | 03ba7e0 | 2010-03-09 11:43:48 +0200 | [diff] [blame] | 37 | #include <linux/power_supply.h> |
| 38 | #include <linux/apm-emulation.h> |
Igor Grinberg | 9c017ca | 2009-10-14 09:20:24 +0200 | [diff] [blame] | 39 | |
Igor Grinberg | 83e560e | 2009-10-14 09:20:19 +0200 | [diff] [blame] | 40 | #include <linux/spi/spi.h> |
| 41 | #include <linux/spi/spi_gpio.h> |
| 42 | #include <linux/spi/tdo24m.h> |
| 43 | |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 44 | #include <asm/mach-types.h> |
| 45 | #include <asm/mach/arch.h> |
Mike Rapoport | b5a5c47 | 2009-06-04 10:44:54 +0300 | [diff] [blame] | 46 | #include <asm/setup.h> |
David Howells | 9f97da7 | 2012-03-28 18:30:01 +0100 | [diff] [blame] | 47 | #include <asm/system_info.h> |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 48 | |
Eric Miao | 51c6298 | 2009-01-02 23:17:22 +0800 | [diff] [blame] | 49 | #include <mach/pxa300.h> |
Igor Grinberg | edaa64c | 2009-10-14 09:20:23 +0200 | [diff] [blame] | 50 | #include <mach/pxa27x-udc.h> |
Arnd Bergmann | 293b2da | 2012-08-24 15:16:48 +0200 | [diff] [blame] | 51 | #include <linux/platform_data/video-pxafb.h> |
| 52 | #include <linux/platform_data/mmc-pxamci.h> |
| 53 | #include <linux/platform_data/usb-ohci-pxa27x.h> |
| 54 | #include <linux/platform_data/mtd-nand-pxa3xx.h> |
Igor Grinberg | 74e74de | 2009-10-14 09:20:20 +0200 | [diff] [blame] | 55 | #include <mach/audio.h> |
Arnd Bergmann | 293b2da | 2012-08-24 15:16:48 +0200 | [diff] [blame] | 56 | #include <linux/platform_data/usb-pxa3xx-ulpi.h> |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 57 | |
| 58 | #include <asm/mach/map.h> |
| 59 | |
| 60 | #include "generic.h" |
Igor Grinberg | db20546 | 2009-11-10 14:18:41 +0200 | [diff] [blame] | 61 | #include "devices.h" |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 62 | |
| 63 | #define CM_X300_ETH_PHYS 0x08000010 |
| 64 | |
Mike Rapoport | 0bff2fc | 2009-10-15 10:11:09 +0200 | [diff] [blame] | 65 | #define GPIO82_MMC_IRQ (82) |
| 66 | #define GPIO85_MMC_WP (85) |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 67 | |
Haojian Zhuang | 6384fda | 2011-10-10 14:21:08 +0800 | [diff] [blame] | 68 | #define CM_X300_MMC_IRQ PXA_GPIO_TO_IRQ(GPIO82_MMC_IRQ) |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 69 | |
Mike Rapoport | 1858ced | 2009-06-04 10:44:52 +0300 | [diff] [blame] | 70 | #define GPIO95_RTC_CS (95) |
| 71 | #define GPIO96_RTC_WR (96) |
| 72 | #define GPIO97_RTC_RD (97) |
| 73 | #define GPIO98_RTC_IO (98) |
| 74 | |
Igor Grinberg | 1b43d8e | 2010-07-27 15:07:00 +0300 | [diff] [blame] | 75 | #define GPIO_ULPI_PHY_RST (127) |
| 76 | |
Igor Grinberg | def8252 | 2009-10-14 09:20:22 +0200 | [diff] [blame] | 77 | static mfp_cfg_t cm_x3xx_mfp_cfg[] __initdata = { |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 78 | /* LCD */ |
| 79 | GPIO54_LCD_LDD_0, |
| 80 | GPIO55_LCD_LDD_1, |
| 81 | GPIO56_LCD_LDD_2, |
| 82 | GPIO57_LCD_LDD_3, |
| 83 | GPIO58_LCD_LDD_4, |
| 84 | GPIO59_LCD_LDD_5, |
| 85 | GPIO60_LCD_LDD_6, |
| 86 | GPIO61_LCD_LDD_7, |
| 87 | GPIO62_LCD_LDD_8, |
| 88 | GPIO63_LCD_LDD_9, |
| 89 | GPIO64_LCD_LDD_10, |
| 90 | GPIO65_LCD_LDD_11, |
| 91 | GPIO66_LCD_LDD_12, |
| 92 | GPIO67_LCD_LDD_13, |
| 93 | GPIO68_LCD_LDD_14, |
| 94 | GPIO69_LCD_LDD_15, |
| 95 | GPIO72_LCD_FCLK, |
| 96 | GPIO73_LCD_LCLK, |
| 97 | GPIO74_LCD_PCLK, |
| 98 | GPIO75_LCD_BIAS, |
| 99 | |
| 100 | /* BTUART */ |
| 101 | GPIO111_UART2_RTS, |
| 102 | GPIO112_UART2_RXD | MFP_LPM_EDGE_FALL, |
| 103 | GPIO113_UART2_TXD, |
| 104 | GPIO114_UART2_CTS | MFP_LPM_EDGE_BOTH, |
| 105 | |
| 106 | /* STUART */ |
| 107 | GPIO109_UART3_TXD, |
| 108 | GPIO110_UART3_RXD | MFP_LPM_EDGE_FALL, |
| 109 | |
| 110 | /* AC97 */ |
| 111 | GPIO23_AC97_nACRESET, |
| 112 | GPIO24_AC97_SYSCLK, |
| 113 | GPIO29_AC97_BITCLK, |
| 114 | GPIO25_AC97_SDATA_IN_0, |
| 115 | GPIO27_AC97_SDATA_OUT, |
| 116 | GPIO28_AC97_SYNC, |
| 117 | |
| 118 | /* Keypad */ |
| 119 | GPIO115_KP_MKIN_0 | MFP_LPM_EDGE_BOTH, |
| 120 | GPIO116_KP_MKIN_1 | MFP_LPM_EDGE_BOTH, |
| 121 | GPIO117_KP_MKIN_2 | MFP_LPM_EDGE_BOTH, |
| 122 | GPIO118_KP_MKIN_3 | MFP_LPM_EDGE_BOTH, |
| 123 | GPIO119_KP_MKIN_4 | MFP_LPM_EDGE_BOTH, |
| 124 | GPIO120_KP_MKIN_5 | MFP_LPM_EDGE_BOTH, |
| 125 | GPIO2_2_KP_MKIN_6 | MFP_LPM_EDGE_BOTH, |
| 126 | GPIO3_2_KP_MKIN_7 | MFP_LPM_EDGE_BOTH, |
| 127 | GPIO121_KP_MKOUT_0, |
| 128 | GPIO122_KP_MKOUT_1, |
| 129 | GPIO123_KP_MKOUT_2, |
| 130 | GPIO124_KP_MKOUT_3, |
| 131 | GPIO125_KP_MKOUT_4, |
| 132 | GPIO4_2_KP_MKOUT_5, |
| 133 | |
| 134 | /* MMC1 */ |
| 135 | GPIO3_MMC1_DAT0, |
| 136 | GPIO4_MMC1_DAT1 | MFP_LPM_EDGE_BOTH, |
| 137 | GPIO5_MMC1_DAT2, |
| 138 | GPIO6_MMC1_DAT3, |
| 139 | GPIO7_MMC1_CLK, |
| 140 | GPIO8_MMC1_CMD, /* CMD0 for slot 0 */ |
| 141 | |
| 142 | /* MMC2 */ |
| 143 | GPIO9_MMC2_DAT0, |
| 144 | GPIO10_MMC2_DAT1 | MFP_LPM_EDGE_BOTH, |
| 145 | GPIO11_MMC2_DAT2, |
| 146 | GPIO12_MMC2_DAT3, |
| 147 | GPIO13_MMC2_CLK, |
| 148 | GPIO14_MMC2_CMD, |
| 149 | |
| 150 | /* FFUART */ |
| 151 | GPIO30_UART1_RXD | MFP_LPM_EDGE_FALL, |
| 152 | GPIO31_UART1_TXD, |
| 153 | GPIO32_UART1_CTS, |
| 154 | GPIO37_UART1_RTS, |
| 155 | GPIO33_UART1_DCD, |
| 156 | GPIO34_UART1_DSR | MFP_LPM_EDGE_FALL, |
| 157 | GPIO35_UART1_RI, |
| 158 | GPIO36_UART1_DTR, |
| 159 | |
| 160 | /* GPIOs */ |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 161 | GPIO82_GPIO | MFP_PULL_HIGH, /* MMC CD */ |
| 162 | GPIO85_GPIO, /* MMC WP */ |
| 163 | GPIO99_GPIO, /* Ethernet IRQ */ |
Eric Miao | 6f584cf | 2008-11-28 16:00:24 +0800 | [diff] [blame] | 164 | |
Mike Rapoport | 1858ced | 2009-06-04 10:44:52 +0300 | [diff] [blame] | 165 | /* RTC GPIOs */ |
Igor Grinberg | 6c7b3ea | 2011-05-09 14:41:46 +0300 | [diff] [blame] | 166 | GPIO95_GPIO | MFP_LPM_DRIVE_HIGH, /* RTC CS */ |
| 167 | GPIO96_GPIO | MFP_LPM_DRIVE_HIGH, /* RTC WR */ |
| 168 | GPIO97_GPIO | MFP_LPM_DRIVE_HIGH, /* RTC RD */ |
| 169 | GPIO98_GPIO, /* RTC IO */ |
Mike Rapoport | 1858ced | 2009-06-04 10:44:52 +0300 | [diff] [blame] | 170 | |
Eric Miao | 6f584cf | 2008-11-28 16:00:24 +0800 | [diff] [blame] | 171 | /* Standard I2C */ |
| 172 | GPIO21_I2C_SCL, |
| 173 | GPIO22_I2C_SDA, |
Igor Grinberg | db20546 | 2009-11-10 14:18:41 +0200 | [diff] [blame] | 174 | |
| 175 | /* PWM Backlight */ |
| 176 | GPIO19_PWM2_OUT, |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 177 | }; |
| 178 | |
Igor Grinberg | def8252 | 2009-10-14 09:20:22 +0200 | [diff] [blame] | 179 | static mfp_cfg_t cm_x3xx_rev_lt130_mfp_cfg[] __initdata = { |
Igor Grinberg | 55052ea | 2009-10-14 09:20:18 +0200 | [diff] [blame] | 180 | /* GPIOs */ |
| 181 | GPIO79_GPIO, /* LED */ |
| 182 | GPIO77_GPIO, /* WiFi reset */ |
| 183 | GPIO78_GPIO, /* BT reset */ |
| 184 | }; |
| 185 | |
Igor Grinberg | def8252 | 2009-10-14 09:20:22 +0200 | [diff] [blame] | 186 | static mfp_cfg_t cm_x3xx_rev_ge130_mfp_cfg[] __initdata = { |
Igor Grinberg | 55052ea | 2009-10-14 09:20:18 +0200 | [diff] [blame] | 187 | /* GPIOs */ |
| 188 | GPIO76_GPIO, /* LED */ |
| 189 | GPIO71_GPIO, /* WiFi reset */ |
| 190 | GPIO70_GPIO, /* BT reset */ |
| 191 | }; |
| 192 | |
Igor Grinberg | def8252 | 2009-10-14 09:20:22 +0200 | [diff] [blame] | 193 | static mfp_cfg_t cm_x310_mfp_cfg[] __initdata = { |
| 194 | /* USB PORT 2 */ |
| 195 | ULPI_STP, |
| 196 | ULPI_NXT, |
| 197 | ULPI_DIR, |
| 198 | GPIO30_ULPI_DATA_OUT_0, |
| 199 | GPIO31_ULPI_DATA_OUT_1, |
| 200 | GPIO32_ULPI_DATA_OUT_2, |
| 201 | GPIO33_ULPI_DATA_OUT_3, |
| 202 | GPIO34_ULPI_DATA_OUT_4, |
| 203 | GPIO35_ULPI_DATA_OUT_5, |
| 204 | GPIO36_ULPI_DATA_OUT_6, |
| 205 | GPIO37_ULPI_DATA_OUT_7, |
| 206 | GPIO38_ULPI_CLK, |
| 207 | /* external PHY reset pin */ |
| 208 | GPIO127_GPIO, |
| 209 | |
| 210 | /* USB PORT 3 */ |
| 211 | GPIO77_USB_P3_1, |
| 212 | GPIO78_USB_P3_2, |
| 213 | GPIO79_USB_P3_3, |
| 214 | GPIO80_USB_P3_4, |
| 215 | GPIO81_USB_P3_5, |
| 216 | GPIO82_USB_P3_6, |
| 217 | GPIO0_2_USBH_PEN, |
| 218 | }; |
| 219 | |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 220 | #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE) |
| 221 | static struct resource dm9000_resources[] = { |
| 222 | [0] = { |
| 223 | .start = CM_X300_ETH_PHYS, |
| 224 | .end = CM_X300_ETH_PHYS + 0x3, |
| 225 | .flags = IORESOURCE_MEM, |
| 226 | }, |
| 227 | [1] = { |
| 228 | .start = CM_X300_ETH_PHYS + 0x4, |
| 229 | .end = CM_X300_ETH_PHYS + 0x4 + 500, |
| 230 | .flags = IORESOURCE_MEM, |
| 231 | }, |
| 232 | [2] = { |
Haojian Zhuang | 6384fda | 2011-10-10 14:21:08 +0800 | [diff] [blame] | 233 | .start = PXA_GPIO_TO_IRQ(mfp_to_gpio(MFP_PIN_GPIO99)), |
| 234 | .end = PXA_GPIO_TO_IRQ(mfp_to_gpio(MFP_PIN_GPIO99)), |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 235 | .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE, |
| 236 | } |
| 237 | }; |
| 238 | |
| 239 | static struct dm9000_plat_data cm_x300_dm9000_platdata = { |
Mike Rapoport | bff22c9 | 2009-02-23 18:01:12 +0200 | [diff] [blame] | 240 | .flags = DM9000_PLATF_16BITONLY | DM9000_PLATF_NO_EEPROM, |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 241 | }; |
| 242 | |
| 243 | static struct platform_device dm9000_device = { |
| 244 | .name = "dm9000", |
| 245 | .id = 0, |
| 246 | .num_resources = ARRAY_SIZE(dm9000_resources), |
| 247 | .resource = dm9000_resources, |
| 248 | .dev = { |
| 249 | .platform_data = &cm_x300_dm9000_platdata, |
| 250 | } |
| 251 | |
| 252 | }; |
| 253 | |
| 254 | static void __init cm_x300_init_dm9000(void) |
| 255 | { |
| 256 | platform_device_register(&dm9000_device); |
| 257 | } |
| 258 | #else |
| 259 | static inline void cm_x300_init_dm9000(void) {} |
| 260 | #endif |
| 261 | |
Igor Grinberg | 83e560e | 2009-10-14 09:20:19 +0200 | [diff] [blame] | 262 | /* LCD */ |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 263 | #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE) |
| 264 | static struct pxafb_mode_info cm_x300_lcd_modes[] = { |
| 265 | [0] = { |
Igor Grinberg | 83e560e | 2009-10-14 09:20:19 +0200 | [diff] [blame] | 266 | .pixclock = 38250, |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 267 | .bpp = 16, |
| 268 | .xres = 480, |
| 269 | .yres = 640, |
| 270 | .hsync_len = 8, |
| 271 | .vsync_len = 2, |
| 272 | .left_margin = 8, |
Igor Grinberg | 83e560e | 2009-10-14 09:20:19 +0200 | [diff] [blame] | 273 | .upper_margin = 2, |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 274 | .right_margin = 24, |
| 275 | .lower_margin = 4, |
| 276 | .cmap_greyscale = 0, |
| 277 | }, |
| 278 | [1] = { |
| 279 | .pixclock = 153800, |
| 280 | .bpp = 16, |
| 281 | .xres = 240, |
| 282 | .yres = 320, |
| 283 | .hsync_len = 8, |
| 284 | .vsync_len = 2, |
| 285 | .left_margin = 8, |
| 286 | .upper_margin = 2, |
| 287 | .right_margin = 88, |
| 288 | .lower_margin = 2, |
| 289 | .cmap_greyscale = 0, |
| 290 | }, |
| 291 | }; |
| 292 | |
| 293 | static struct pxafb_mach_info cm_x300_lcd = { |
| 294 | .modes = cm_x300_lcd_modes, |
Igor Grinberg | 83e560e | 2009-10-14 09:20:19 +0200 | [diff] [blame] | 295 | .num_modes = ARRAY_SIZE(cm_x300_lcd_modes), |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 296 | .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL, |
| 297 | }; |
| 298 | |
| 299 | static void __init cm_x300_init_lcd(void) |
| 300 | { |
Russell King - ARM Linux | 4321e1a | 2011-02-15 15:37:30 +0800 | [diff] [blame] | 301 | pxa_set_fb_info(NULL, &cm_x300_lcd); |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 302 | } |
| 303 | #else |
| 304 | static inline void cm_x300_init_lcd(void) {} |
| 305 | #endif |
| 306 | |
Igor Grinberg | db20546 | 2009-11-10 14:18:41 +0200 | [diff] [blame] | 307 | #if defined(CONFIG_BACKLIGHT_PWM) || defined(CONFIG_BACKLIGHT_PWM_MODULE) |
| 308 | static struct platform_pwm_backlight_data cm_x300_backlight_data = { |
| 309 | .pwm_id = 2, |
| 310 | .max_brightness = 100, |
| 311 | .dft_brightness = 100, |
| 312 | .pwm_period_ns = 10000, |
| 313 | }; |
| 314 | |
| 315 | static struct platform_device cm_x300_backlight_device = { |
| 316 | .name = "pwm-backlight", |
| 317 | .dev = { |
| 318 | .parent = &pxa27x_device_pwm0.dev, |
| 319 | .platform_data = &cm_x300_backlight_data, |
| 320 | }, |
| 321 | }; |
| 322 | |
| 323 | static void cm_x300_init_bl(void) |
| 324 | { |
| 325 | platform_device_register(&cm_x300_backlight_device); |
| 326 | } |
| 327 | #else |
| 328 | static inline void cm_x300_init_bl(void) {} |
| 329 | #endif |
| 330 | |
Igor Grinberg | 83e560e | 2009-10-14 09:20:19 +0200 | [diff] [blame] | 331 | #if defined(CONFIG_SPI_GPIO) || defined(CONFIG_SPI_GPIO_MODULE) |
| 332 | #define GPIO_LCD_BASE (144) |
| 333 | #define GPIO_LCD_DIN (GPIO_LCD_BASE + 8) /* aux_gpio3_0 */ |
| 334 | #define GPIO_LCD_DOUT (GPIO_LCD_BASE + 9) /* aux_gpio3_1 */ |
| 335 | #define GPIO_LCD_SCL (GPIO_LCD_BASE + 10) /* aux_gpio3_2 */ |
| 336 | #define GPIO_LCD_CS (GPIO_LCD_BASE + 11) /* aux_gpio3_3 */ |
| 337 | #define LCD_SPI_BUS_NUM (1) |
| 338 | |
| 339 | static struct spi_gpio_platform_data cm_x300_spi_gpio_pdata = { |
| 340 | .sck = GPIO_LCD_SCL, |
| 341 | .mosi = GPIO_LCD_DIN, |
| 342 | .miso = GPIO_LCD_DOUT, |
| 343 | .num_chipselect = 1, |
| 344 | }; |
| 345 | |
| 346 | static struct platform_device cm_x300_spi_gpio = { |
| 347 | .name = "spi_gpio", |
| 348 | .id = LCD_SPI_BUS_NUM, |
| 349 | .dev = { |
| 350 | .platform_data = &cm_x300_spi_gpio_pdata, |
| 351 | }, |
| 352 | }; |
| 353 | |
| 354 | static struct tdo24m_platform_data cm_x300_tdo24m_pdata = { |
| 355 | .model = TDO35S, |
| 356 | }; |
| 357 | |
| 358 | static struct spi_board_info cm_x300_spi_devices[] __initdata = { |
| 359 | { |
| 360 | .modalias = "tdo24m", |
| 361 | .max_speed_hz = 1000000, |
| 362 | .bus_num = LCD_SPI_BUS_NUM, |
| 363 | .chip_select = 0, |
| 364 | .controller_data = (void *) GPIO_LCD_CS, |
| 365 | .platform_data = &cm_x300_tdo24m_pdata, |
| 366 | }, |
| 367 | }; |
| 368 | |
| 369 | static void __init cm_x300_init_spi(void) |
| 370 | { |
| 371 | spi_register_board_info(cm_x300_spi_devices, |
| 372 | ARRAY_SIZE(cm_x300_spi_devices)); |
| 373 | platform_device_register(&cm_x300_spi_gpio); |
| 374 | } |
| 375 | #else |
| 376 | static inline void cm_x300_init_spi(void) {} |
| 377 | #endif |
| 378 | |
Igor Grinberg | 74e74de | 2009-10-14 09:20:20 +0200 | [diff] [blame] | 379 | #if defined(CONFIG_SND_PXA2XX_LIB_AC97) |
| 380 | static void __init cm_x300_init_ac97(void) |
| 381 | { |
| 382 | pxa_set_ac97_info(NULL); |
| 383 | } |
| 384 | #else |
| 385 | static inline void cm_x300_init_ac97(void) {} |
| 386 | #endif |
| 387 | |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 388 | #if defined(CONFIG_MTD_NAND_PXA3xx) || defined(CONFIG_MTD_NAND_PXA3xx_MODULE) |
| 389 | static struct mtd_partition cm_x300_nand_partitions[] = { |
| 390 | [0] = { |
| 391 | .name = "OBM", |
| 392 | .offset = 0, |
| 393 | .size = SZ_256K, |
| 394 | .mask_flags = MTD_WRITEABLE, /* force read-only */ |
| 395 | }, |
| 396 | [1] = { |
| 397 | .name = "U-Boot", |
| 398 | .offset = MTDPART_OFS_APPEND, |
| 399 | .size = SZ_256K, |
| 400 | .mask_flags = MTD_WRITEABLE, /* force read-only */ |
| 401 | }, |
| 402 | [2] = { |
| 403 | .name = "Environment", |
| 404 | .offset = MTDPART_OFS_APPEND, |
| 405 | .size = SZ_256K, |
| 406 | }, |
| 407 | [3] = { |
| 408 | .name = "reserved", |
| 409 | .offset = MTDPART_OFS_APPEND, |
| 410 | .size = SZ_256K + SZ_1M, |
| 411 | .mask_flags = MTD_WRITEABLE, /* force read-only */ |
| 412 | }, |
| 413 | [4] = { |
| 414 | .name = "kernel", |
| 415 | .offset = MTDPART_OFS_APPEND, |
| 416 | .size = SZ_4M, |
| 417 | }, |
| 418 | [5] = { |
| 419 | .name = "fs", |
| 420 | .offset = MTDPART_OFS_APPEND, |
| 421 | .size = MTDPART_SIZ_FULL, |
| 422 | }, |
| 423 | }; |
| 424 | |
| 425 | static struct pxa3xx_nand_platform_data cm_x300_nand_info = { |
| 426 | .enable_arbiter = 1, |
Mike Rapoport | b3992b6 | 2009-06-04 10:44:51 +0300 | [diff] [blame] | 427 | .keep_config = 1, |
Lei Wen | f3c8cfc | 2011-07-14 20:44:33 -0700 | [diff] [blame] | 428 | .num_cs = 1, |
| 429 | .parts[0] = cm_x300_nand_partitions, |
| 430 | .nr_parts[0] = ARRAY_SIZE(cm_x300_nand_partitions), |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 431 | }; |
| 432 | |
| 433 | static void __init cm_x300_init_nand(void) |
| 434 | { |
| 435 | pxa3xx_set_nand_info(&cm_x300_nand_info); |
| 436 | } |
| 437 | #else |
| 438 | static inline void cm_x300_init_nand(void) {} |
| 439 | #endif |
| 440 | |
| 441 | #if defined(CONFIG_MMC) || defined(CONFIG_MMC_MODULE) |
Mike Rapoport | 0bff2fc | 2009-10-15 10:11:09 +0200 | [diff] [blame] | 442 | static struct pxamci_platform_data cm_x300_mci_platform_data = { |
Eric Miao | f97cab2 | 2010-04-14 07:00:42 +0800 | [diff] [blame] | 443 | .detect_delay_ms = 200, |
Mike Rapoport | 0bff2fc | 2009-10-15 10:11:09 +0200 | [diff] [blame] | 444 | .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, |
| 445 | .gpio_card_detect = GPIO82_MMC_IRQ, |
| 446 | .gpio_card_ro = GPIO85_MMC_WP, |
| 447 | .gpio_power = -1, |
| 448 | }; |
| 449 | |
| 450 | /* The second MMC slot of CM-X300 is hardwired to Libertas card and has |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 451 | no detection/ro pins */ |
Mike Rapoport | 0bff2fc | 2009-10-15 10:11:09 +0200 | [diff] [blame] | 452 | static int cm_x300_mci2_init(struct device *dev, |
| 453 | irq_handler_t cm_x300_detect_int, |
| 454 | void *data) |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 455 | { |
| 456 | return 0; |
| 457 | } |
| 458 | |
Mike Rapoport | 0bff2fc | 2009-10-15 10:11:09 +0200 | [diff] [blame] | 459 | static void cm_x300_mci2_exit(struct device *dev, void *data) |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 460 | { |
| 461 | } |
| 462 | |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 463 | static struct pxamci_platform_data cm_x300_mci2_platform_data = { |
Eric Miao | f97cab2 | 2010-04-14 07:00:42 +0800 | [diff] [blame] | 464 | .detect_delay_ms = 200, |
Robert Jarzmik | 7a64825 | 2009-07-06 22:16:42 +0200 | [diff] [blame] | 465 | .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, |
Mike Rapoport | 0bff2fc | 2009-10-15 10:11:09 +0200 | [diff] [blame] | 466 | .init = cm_x300_mci2_init, |
| 467 | .exit = cm_x300_mci2_exit, |
| 468 | .gpio_card_detect = -1, |
| 469 | .gpio_card_ro = -1, |
Robert Jarzmik | 7a64825 | 2009-07-06 22:16:42 +0200 | [diff] [blame] | 470 | .gpio_power = -1, |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 471 | }; |
| 472 | |
| 473 | static void __init cm_x300_init_mmc(void) |
| 474 | { |
| 475 | pxa_set_mci_info(&cm_x300_mci_platform_data); |
| 476 | pxa3xx_set_mci2_info(&cm_x300_mci2_platform_data); |
| 477 | } |
| 478 | #else |
| 479 | static inline void cm_x300_init_mmc(void) {} |
| 480 | #endif |
| 481 | |
Igor Grinberg | 1b43d8e | 2010-07-27 15:07:00 +0300 | [diff] [blame] | 482 | #if defined(CONFIG_PXA310_ULPI) |
| 483 | static struct clk *pout_clk; |
| 484 | |
| 485 | static int cm_x300_ulpi_phy_reset(void) |
| 486 | { |
| 487 | int err; |
| 488 | |
| 489 | /* reset the PHY */ |
Igor Grinberg | 5a009df | 2011-05-09 14:41:47 +0300 | [diff] [blame] | 490 | err = gpio_request_one(GPIO_ULPI_PHY_RST, GPIOF_OUT_INIT_LOW, |
| 491 | "ulpi reset"); |
Igor Grinberg | 1b43d8e | 2010-07-27 15:07:00 +0300 | [diff] [blame] | 492 | if (err) { |
Igor Grinberg | 32de50e | 2011-05-09 14:41:48 +0300 | [diff] [blame] | 493 | pr_err("failed to request ULPI reset GPIO: %d\n", err); |
Igor Grinberg | 1b43d8e | 2010-07-27 15:07:00 +0300 | [diff] [blame] | 494 | return err; |
| 495 | } |
| 496 | |
Igor Grinberg | 1b43d8e | 2010-07-27 15:07:00 +0300 | [diff] [blame] | 497 | msleep(10); |
| 498 | gpio_set_value(GPIO_ULPI_PHY_RST, 1); |
| 499 | msleep(10); |
| 500 | |
| 501 | gpio_free(GPIO_ULPI_PHY_RST); |
| 502 | |
| 503 | return 0; |
| 504 | } |
| 505 | |
| 506 | static inline int cm_x300_u2d_init(struct device *dev) |
| 507 | { |
| 508 | int err = 0; |
| 509 | |
| 510 | if (cpu_is_pxa310()) { |
| 511 | /* CLK_POUT is connected to the ULPI PHY */ |
| 512 | pout_clk = clk_get(NULL, "CLK_POUT"); |
| 513 | if (IS_ERR(pout_clk)) { |
| 514 | err = PTR_ERR(pout_clk); |
Igor Grinberg | 32de50e | 2011-05-09 14:41:48 +0300 | [diff] [blame] | 515 | pr_err("failed to get CLK_POUT: %d\n", err); |
Igor Grinberg | 1b43d8e | 2010-07-27 15:07:00 +0300 | [diff] [blame] | 516 | return err; |
| 517 | } |
| 518 | clk_enable(pout_clk); |
| 519 | |
| 520 | err = cm_x300_ulpi_phy_reset(); |
| 521 | if (err) { |
| 522 | clk_disable(pout_clk); |
| 523 | clk_put(pout_clk); |
| 524 | } |
| 525 | } |
| 526 | |
| 527 | return err; |
| 528 | } |
| 529 | |
| 530 | static void cm_x300_u2d_exit(struct device *dev) |
| 531 | { |
| 532 | if (cpu_is_pxa310()) { |
| 533 | clk_disable(pout_clk); |
| 534 | clk_put(pout_clk); |
| 535 | } |
| 536 | } |
| 537 | |
| 538 | static struct pxa3xx_u2d_platform_data cm_x300_u2d_platform_data = { |
| 539 | .ulpi_mode = ULPI_SER_6PIN, |
| 540 | .init = cm_x300_u2d_init, |
| 541 | .exit = cm_x300_u2d_exit, |
| 542 | }; |
| 543 | |
| 544 | static void cm_x300_init_u2d(void) |
| 545 | { |
| 546 | pxa3xx_set_u2d_info(&cm_x300_u2d_platform_data); |
| 547 | } |
| 548 | #else |
| 549 | static inline void cm_x300_init_u2d(void) {} |
| 550 | #endif |
| 551 | |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 552 | #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) |
Igor Grinberg | edaa64c | 2009-10-14 09:20:23 +0200 | [diff] [blame] | 553 | static int cm_x300_ohci_init(struct device *dev) |
| 554 | { |
| 555 | if (cpu_is_pxa300()) |
| 556 | UP2OCR = UP2OCR_HXS |
| 557 | | UP2OCR_HXOE | UP2OCR_DMPDE | UP2OCR_DPPDE; |
| 558 | |
| 559 | return 0; |
| 560 | } |
| 561 | |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 562 | static struct pxaohci_platform_data cm_x300_ohci_platform_data = { |
| 563 | .port_mode = PMM_PERPORT_MODE, |
Igor Grinberg | edaa64c | 2009-10-14 09:20:23 +0200 | [diff] [blame] | 564 | .flags = ENABLE_PORT_ALL | POWER_CONTROL_LOW, |
| 565 | .init = cm_x300_ohci_init, |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 566 | }; |
Eric Miao | 097b533 | 2008-09-27 15:49:57 +0800 | [diff] [blame] | 567 | |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 568 | static void __init cm_x300_init_ohci(void) |
| 569 | { |
| 570 | pxa_set_ohci_info(&cm_x300_ohci_platform_data); |
| 571 | } |
| 572 | #else |
| 573 | static inline void cm_x300_init_ohci(void) {} |
| 574 | #endif |
| 575 | |
| 576 | #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE) |
| 577 | static struct gpio_led cm_x300_leds[] = { |
| 578 | [0] = { |
| 579 | .name = "cm-x300:green", |
| 580 | .default_trigger = "heartbeat", |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 581 | .active_low = 1, |
| 582 | }, |
| 583 | }; |
| 584 | |
| 585 | static struct gpio_led_platform_data cm_x300_gpio_led_pdata = { |
| 586 | .num_leds = ARRAY_SIZE(cm_x300_leds), |
| 587 | .leds = cm_x300_leds, |
| 588 | }; |
| 589 | |
| 590 | static struct platform_device cm_x300_led_device = { |
| 591 | .name = "leds-gpio", |
| 592 | .id = -1, |
| 593 | .dev = { |
| 594 | .platform_data = &cm_x300_gpio_led_pdata, |
| 595 | }, |
| 596 | }; |
| 597 | |
| 598 | static void __init cm_x300_init_leds(void) |
| 599 | { |
Igor Grinberg | 55052ea | 2009-10-14 09:20:18 +0200 | [diff] [blame] | 600 | if (system_rev < 130) |
| 601 | cm_x300_leds[0].gpio = 79; |
| 602 | else |
| 603 | cm_x300_leds[0].gpio = 76; |
| 604 | |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 605 | platform_device_register(&cm_x300_led_device); |
| 606 | } |
| 607 | #else |
| 608 | static inline void cm_x300_init_leds(void) {} |
| 609 | #endif |
| 610 | |
| 611 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) |
| 612 | /* PCA9555 */ |
| 613 | static struct pca953x_platform_data cm_x300_gpio_ext_pdata_0 = { |
| 614 | .gpio_base = 128, |
| 615 | }; |
| 616 | |
| 617 | static struct pca953x_platform_data cm_x300_gpio_ext_pdata_1 = { |
| 618 | .gpio_base = 144, |
| 619 | }; |
| 620 | |
| 621 | static struct i2c_board_info cm_x300_gpio_ext_info[] = { |
| 622 | [0] = { |
| 623 | I2C_BOARD_INFO("pca9555", 0x24), |
| 624 | .platform_data = &cm_x300_gpio_ext_pdata_0, |
| 625 | }, |
| 626 | [1] = { |
| 627 | I2C_BOARD_INFO("pca9555", 0x25), |
| 628 | .platform_data = &cm_x300_gpio_ext_pdata_1, |
| 629 | }, |
| 630 | }; |
| 631 | |
| 632 | static void __init cm_x300_init_i2c(void) |
| 633 | { |
| 634 | pxa_set_i2c_info(NULL); |
| 635 | i2c_register_board_info(0, cm_x300_gpio_ext_info, |
| 636 | ARRAY_SIZE(cm_x300_gpio_ext_info)); |
| 637 | } |
| 638 | #else |
| 639 | static inline void cm_x300_init_i2c(void) {} |
| 640 | #endif |
| 641 | |
Mike Rapoport | 1858ced | 2009-06-04 10:44:52 +0300 | [diff] [blame] | 642 | #if defined(CONFIG_RTC_DRV_V3020) || defined(CONFIG_RTC_DRV_V3020_MODULE) |
| 643 | struct v3020_platform_data cm_x300_v3020_pdata = { |
| 644 | .use_gpio = 1, |
| 645 | .gpio_cs = GPIO95_RTC_CS, |
| 646 | .gpio_wr = GPIO96_RTC_WR, |
| 647 | .gpio_rd = GPIO97_RTC_RD, |
| 648 | .gpio_io = GPIO98_RTC_IO, |
| 649 | }; |
| 650 | |
| 651 | static struct platform_device cm_x300_rtc_device = { |
| 652 | .name = "v3020", |
| 653 | .id = -1, |
| 654 | .dev = { |
| 655 | .platform_data = &cm_x300_v3020_pdata, |
| 656 | } |
| 657 | }; |
| 658 | |
| 659 | static void __init cm_x300_init_rtc(void) |
| 660 | { |
| 661 | platform_device_register(&cm_x300_rtc_device); |
| 662 | } |
| 663 | #else |
| 664 | static inline void cm_x300_init_rtc(void) {} |
| 665 | #endif |
| 666 | |
Igor Grinberg | 03ba7e0 | 2010-03-09 11:43:48 +0200 | [diff] [blame] | 667 | /* Battery */ |
| 668 | struct power_supply_info cm_x300_psy_info = { |
| 669 | .name = "battery", |
| 670 | .technology = POWER_SUPPLY_TECHNOLOGY_LIPO, |
| 671 | .voltage_max_design = 4200000, |
| 672 | .voltage_min_design = 3000000, |
| 673 | .use_for_apm = 1, |
| 674 | }; |
| 675 | |
| 676 | static void cm_x300_battery_low(void) |
| 677 | { |
| 678 | #if defined(CONFIG_APM_EMULATION) |
| 679 | apm_queue_event(APM_LOW_BATTERY); |
| 680 | #endif |
| 681 | } |
| 682 | |
| 683 | static void cm_x300_battery_critical(void) |
| 684 | { |
| 685 | #if defined(CONFIG_APM_EMULATION) |
| 686 | apm_queue_event(APM_CRITICAL_SUSPEND); |
| 687 | #endif |
| 688 | } |
| 689 | |
| 690 | struct da9030_battery_info cm_x300_battery_info = { |
| 691 | .battery_info = &cm_x300_psy_info, |
| 692 | |
| 693 | .charge_milliamp = 1000, |
| 694 | .charge_millivolt = 4200, |
| 695 | |
| 696 | .vbat_low = 3600, |
| 697 | .vbat_crit = 3400, |
| 698 | .vbat_charge_start = 4100, |
| 699 | .vbat_charge_stop = 4200, |
| 700 | .vbat_charge_restart = 4000, |
| 701 | |
| 702 | .vcharge_min = 3200, |
| 703 | .vcharge_max = 5500, |
| 704 | |
| 705 | .tbat_low = 197, |
| 706 | .tbat_high = 78, |
| 707 | .tbat_restart = 100, |
| 708 | |
| 709 | .batmon_interval = 0, |
| 710 | |
| 711 | .battery_low = cm_x300_battery_low, |
| 712 | .battery_critical = cm_x300_battery_critical, |
| 713 | }; |
| 714 | |
Igor Grinberg | d176d64 | 2010-03-09 11:43:51 +0200 | [diff] [blame] | 715 | static struct regulator_consumer_supply buck2_consumers[] = { |
Axel Lin | 0bf189a | 2012-05-08 16:25:10 +0800 | [diff] [blame] | 716 | REGULATOR_SUPPLY("vcc_core", NULL), |
Igor Grinberg | d176d64 | 2010-03-09 11:43:51 +0200 | [diff] [blame] | 717 | }; |
| 718 | |
| 719 | static struct regulator_init_data buck2_data = { |
| 720 | .constraints = { |
| 721 | .min_uV = 1375000, |
| 722 | .max_uV = 1375000, |
| 723 | .state_mem = { |
| 724 | .enabled = 0, |
| 725 | }, |
| 726 | .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE, |
| 727 | .apply_uV = 1, |
| 728 | }, |
| 729 | .num_consumer_supplies = ARRAY_SIZE(buck2_consumers), |
| 730 | .consumer_supplies = buck2_consumers, |
| 731 | }; |
| 732 | |
Igor Grinberg | 9c017ca | 2009-10-14 09:20:24 +0200 | [diff] [blame] | 733 | /* DA9030 */ |
| 734 | struct da903x_subdev_info cm_x300_da9030_subdevs[] = { |
| 735 | { |
Igor Grinberg | 03ba7e0 | 2010-03-09 11:43:48 +0200 | [diff] [blame] | 736 | .name = "da903x-battery", |
| 737 | .id = DA9030_ID_BAT, |
| 738 | .platform_data = &cm_x300_battery_info, |
| 739 | }, |
Igor Grinberg | d176d64 | 2010-03-09 11:43:51 +0200 | [diff] [blame] | 740 | { |
| 741 | .name = "da903x-regulator", |
| 742 | .id = DA9030_ID_BUCK2, |
| 743 | .platform_data = &buck2_data, |
| 744 | }, |
Igor Grinberg | 9c017ca | 2009-10-14 09:20:24 +0200 | [diff] [blame] | 745 | }; |
| 746 | |
| 747 | static struct da903x_platform_data cm_x300_da9030_info = { |
| 748 | .num_subdevs = ARRAY_SIZE(cm_x300_da9030_subdevs), |
| 749 | .subdevs = cm_x300_da9030_subdevs, |
| 750 | }; |
| 751 | |
| 752 | static struct i2c_board_info cm_x300_pmic_info = { |
| 753 | I2C_BOARD_INFO("da9030", 0x49), |
Igor Grinberg | e4e3097 | 2010-03-09 11:43:50 +0200 | [diff] [blame] | 754 | .irq = IRQ_WAKEUP0, |
Igor Grinberg | 9c017ca | 2009-10-14 09:20:24 +0200 | [diff] [blame] | 755 | .platform_data = &cm_x300_da9030_info, |
| 756 | }; |
| 757 | |
| 758 | static struct i2c_pxa_platform_data cm_x300_pwr_i2c_info = { |
| 759 | .use_pio = 1, |
| 760 | }; |
| 761 | |
| 762 | static void __init cm_x300_init_da9030(void) |
| 763 | { |
| 764 | pxa3xx_set_i2c_power_info(&cm_x300_pwr_i2c_info); |
| 765 | i2c_register_board_info(1, &cm_x300_pmic_info, 1); |
Thomas Gleixner | 6845664a | 2011-03-24 13:25:22 +0100 | [diff] [blame] | 766 | irq_set_irq_wake(IRQ_WAKEUP0, 1); |
Igor Grinberg | 9c017ca | 2009-10-14 09:20:24 +0200 | [diff] [blame] | 767 | } |
| 768 | |
Igor Grinberg | 5a009df | 2011-05-09 14:41:47 +0300 | [diff] [blame] | 769 | /* wi2wi gpio setting for system_rev >= 130 */ |
| 770 | static struct gpio cm_x300_wi2wi_gpios[] __initdata = { |
| 771 | { 71, GPIOF_OUT_INIT_HIGH, "wlan en" }, |
| 772 | { 70, GPIOF_OUT_INIT_HIGH, "bt reset" }, |
| 773 | }; |
| 774 | |
Igor Grinberg | b3d01da | 2009-10-14 09:20:21 +0200 | [diff] [blame] | 775 | static void __init cm_x300_init_wi2wi(void) |
| 776 | { |
Igor Grinberg | b3d01da | 2009-10-14 09:20:21 +0200 | [diff] [blame] | 777 | int err; |
| 778 | |
| 779 | if (system_rev < 130) { |
Igor Grinberg | 5a009df | 2011-05-09 14:41:47 +0300 | [diff] [blame] | 780 | cm_x300_wi2wi_gpios[0].gpio = 77; /* wlan en */ |
| 781 | cm_x300_wi2wi_gpios[1].gpio = 78; /* bt reset */ |
Igor Grinberg | b3d01da | 2009-10-14 09:20:21 +0200 | [diff] [blame] | 782 | } |
| 783 | |
| 784 | /* Libertas and CSR reset */ |
Igor Grinberg | 5a009df | 2011-05-09 14:41:47 +0300 | [diff] [blame] | 785 | err = gpio_request_array(ARRAY_AND_SIZE(cm_x300_wi2wi_gpios)); |
Igor Grinberg | b3d01da | 2009-10-14 09:20:21 +0200 | [diff] [blame] | 786 | if (err) { |
Igor Grinberg | 32de50e | 2011-05-09 14:41:48 +0300 | [diff] [blame] | 787 | pr_err("failed to request wifi/bt gpios: %d\n", err); |
Igor Grinberg | 5a009df | 2011-05-09 14:41:47 +0300 | [diff] [blame] | 788 | return; |
Igor Grinberg | b3d01da | 2009-10-14 09:20:21 +0200 | [diff] [blame] | 789 | } |
| 790 | |
Igor Grinberg | 5a009df | 2011-05-09 14:41:47 +0300 | [diff] [blame] | 791 | udelay(10); |
Axel Lin | 1a64200 | 2011-09-17 22:15:34 +0800 | [diff] [blame] | 792 | gpio_set_value(cm_x300_wi2wi_gpios[1].gpio, 0); |
Igor Grinberg | 5a009df | 2011-05-09 14:41:47 +0300 | [diff] [blame] | 793 | udelay(10); |
Axel Lin | 1a64200 | 2011-09-17 22:15:34 +0800 | [diff] [blame] | 794 | gpio_set_value(cm_x300_wi2wi_gpios[1].gpio, 1); |
Igor Grinberg | 5a009df | 2011-05-09 14:41:47 +0300 | [diff] [blame] | 795 | |
Axel Lin | 1a64200 | 2011-09-17 22:15:34 +0800 | [diff] [blame] | 796 | gpio_free_array(ARRAY_AND_SIZE(cm_x300_wi2wi_gpios)); |
Igor Grinberg | b3d01da | 2009-10-14 09:20:21 +0200 | [diff] [blame] | 797 | } |
| 798 | |
| 799 | /* MFP */ |
Igor Grinberg | 55052ea | 2009-10-14 09:20:18 +0200 | [diff] [blame] | 800 | static void __init cm_x300_init_mfp(void) |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 801 | { |
| 802 | /* board-processor specific GPIO initialization */ |
Igor Grinberg | def8252 | 2009-10-14 09:20:22 +0200 | [diff] [blame] | 803 | pxa3xx_mfp_config(ARRAY_AND_SIZE(cm_x3xx_mfp_cfg)); |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 804 | |
Igor Grinberg | 55052ea | 2009-10-14 09:20:18 +0200 | [diff] [blame] | 805 | if (system_rev < 130) |
Igor Grinberg | def8252 | 2009-10-14 09:20:22 +0200 | [diff] [blame] | 806 | pxa3xx_mfp_config(ARRAY_AND_SIZE(cm_x3xx_rev_lt130_mfp_cfg)); |
Igor Grinberg | 55052ea | 2009-10-14 09:20:18 +0200 | [diff] [blame] | 807 | else |
Igor Grinberg | def8252 | 2009-10-14 09:20:22 +0200 | [diff] [blame] | 808 | pxa3xx_mfp_config(ARRAY_AND_SIZE(cm_x3xx_rev_ge130_mfp_cfg)); |
| 809 | |
| 810 | if (cpu_is_pxa310()) |
| 811 | pxa3xx_mfp_config(ARRAY_AND_SIZE(cm_x310_mfp_cfg)); |
Igor Grinberg | 55052ea | 2009-10-14 09:20:18 +0200 | [diff] [blame] | 812 | } |
| 813 | |
| 814 | static void __init cm_x300_init(void) |
| 815 | { |
| 816 | cm_x300_init_mfp(); |
| 817 | |
Russell King | cc155c6 | 2009-11-09 13:34:08 +0800 | [diff] [blame] | 818 | pxa_set_btuart_info(NULL); |
| 819 | pxa_set_stuart_info(NULL); |
Igor Grinberg | a6cd7eb | 2010-07-20 10:58:52 +0300 | [diff] [blame] | 820 | if (cpu_is_pxa300()) |
| 821 | pxa_set_ffuart_info(NULL); |
Russell King | cc155c6 | 2009-11-09 13:34:08 +0800 | [diff] [blame] | 822 | |
Igor Grinberg | 9c017ca | 2009-10-14 09:20:24 +0200 | [diff] [blame] | 823 | cm_x300_init_da9030(); |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 824 | cm_x300_init_dm9000(); |
| 825 | cm_x300_init_lcd(); |
Igor Grinberg | 1b43d8e | 2010-07-27 15:07:00 +0300 | [diff] [blame] | 826 | cm_x300_init_u2d(); |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 827 | cm_x300_init_ohci(); |
| 828 | cm_x300_init_mmc(); |
| 829 | cm_x300_init_nand(); |
| 830 | cm_x300_init_leds(); |
| 831 | cm_x300_init_i2c(); |
Igor Grinberg | 83e560e | 2009-10-14 09:20:19 +0200 | [diff] [blame] | 832 | cm_x300_init_spi(); |
Mike Rapoport | 1858ced | 2009-06-04 10:44:52 +0300 | [diff] [blame] | 833 | cm_x300_init_rtc(); |
Igor Grinberg | 74e74de | 2009-10-14 09:20:20 +0200 | [diff] [blame] | 834 | cm_x300_init_ac97(); |
Igor Grinberg | b3d01da | 2009-10-14 09:20:21 +0200 | [diff] [blame] | 835 | cm_x300_init_wi2wi(); |
Igor Grinberg | db20546 | 2009-11-10 14:18:41 +0200 | [diff] [blame] | 836 | cm_x300_init_bl(); |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 837 | } |
| 838 | |
Russell King | 0744a3e | 2010-12-20 10:37:50 +0000 | [diff] [blame] | 839 | static void __init cm_x300_fixup(struct tag *tags, char **cmdline, |
| 840 | struct meminfo *mi) |
Mike Rapoport | b5a5c47 | 2009-06-04 10:44:54 +0300 | [diff] [blame] | 841 | { |
Igor Grinberg | 8188097 | 2010-03-09 11:43:52 +0200 | [diff] [blame] | 842 | /* Make sure that mi->bank[0].start = PHYS_ADDR */ |
| 843 | for (; tags->hdr.size; tags = tag_next(tags)) |
| 844 | if (tags->hdr.tag == ATAG_MEM && |
| 845 | tags->u.mem.start == 0x80000000) { |
| 846 | tags->u.mem.start = 0xa0000000; |
| 847 | break; |
| 848 | } |
Mike Rapoport | b5a5c47 | 2009-06-04 10:44:54 +0300 | [diff] [blame] | 849 | } |
| 850 | |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 851 | MACHINE_START(CM_X300, "CM-X300 module") |
Nicolas Pitre | 7375aba | 2011-07-05 22:38:15 -0400 | [diff] [blame] | 852 | .atag_offset = 0x100, |
Marek Vasut | 851982c | 2010-10-11 02:20:19 +0200 | [diff] [blame] | 853 | .map_io = pxa3xx_map_io, |
Rob Herring | 4e61109 | 2012-01-03 16:53:48 -0600 | [diff] [blame] | 854 | .nr_irqs = PXA_NR_IRQS, |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 855 | .init_irq = pxa3xx_init_irq, |
Eric Miao | 8a97ae2 | 2011-05-18 21:30:04 +0800 | [diff] [blame] | 856 | .handle_irq = pxa3xx_handle_irq, |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 857 | .timer = &pxa_timer, |
| 858 | .init_machine = cm_x300_init, |
Mike Rapoport | b5a5c47 | 2009-06-04 10:44:54 +0300 | [diff] [blame] | 859 | .fixup = cm_x300_fixup, |
Russell King | 271a74f | 2011-11-04 14:15:53 +0000 | [diff] [blame] | 860 | .restart = pxa_restart, |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 861 | MACHINE_END |