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