Fabio Estevam | ec9be0d | 2009-04-16 12:45:01 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2009 Freescale Semiconductor, Inc. All Rights Reserved. |
| 3 | * |
| 4 | * Author: Fabio Estevam <fabio.estevam@freescale.com> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 2 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
Fabio Estevam | ec9be0d | 2009-04-16 12:45:01 -0700 | [diff] [blame] | 15 | */ |
| 16 | |
Uwe Kleine-König | 8fdca37 | 2010-03-08 10:46:11 +0100 | [diff] [blame] | 17 | /* |
| 18 | * This machine is known as: |
| 19 | * - i.MX27 3-Stack Development System |
| 20 | * - i.MX27 Platform Development Kit (i.MX27 PDK) |
| 21 | */ |
| 22 | |
Fabio Estevam | ec9be0d | 2009-04-16 12:45:01 -0700 | [diff] [blame] | 23 | #include <linux/platform_device.h> |
| 24 | #include <linux/gpio.h> |
Rogerio Pimentel | b5ec73e | 2010-10-22 11:03:54 -0200 | [diff] [blame] | 25 | #include <linux/irq.h> |
Fabio Estevam | 96cf423 | 2010-12-22 12:25:31 -0200 | [diff] [blame] | 26 | #include <linux/usb/otg.h> |
| 27 | #include <linux/usb/ulpi.h> |
| 28 | #include <linux/delay.h> |
Fabio Estevam | c67a3e0 | 2011-01-03 11:16:39 -0200 | [diff] [blame] | 29 | #include <linux/mfd/mc13783.h> |
| 30 | #include <linux/spi/spi.h> |
| 31 | #include <linux/regulator/machine.h> |
Fabio Estevam | 1abcb4c | 2011-06-22 09:25:25 -0300 | [diff] [blame] | 32 | #include <linux/spi/l4f00242t03.h> |
Fabio Estevam | 96cf423 | 2010-12-22 12:25:31 -0200 | [diff] [blame] | 33 | |
Fabio Estevam | 4c11c28 | 2012-02-15 19:36:10 -0200 | [diff] [blame] | 34 | #include <media/soc_camera.h> |
| 35 | |
Fabio Estevam | ec9be0d | 2009-04-16 12:45:01 -0700 | [diff] [blame] | 36 | #include <asm/mach-types.h> |
| 37 | #include <asm/mach/arch.h> |
| 38 | #include <asm/mach/time.h> |
Fabio Estevam | ec9be0d | 2009-04-16 12:45:01 -0700 | [diff] [blame] | 39 | |
Shawn Guo | 3ed0bcb | 2012-09-13 09:37:49 +0800 | [diff] [blame] | 40 | #include "3ds_debugboard.h" |
Shawn Guo | e337247 | 2012-09-13 21:01:00 +0800 | [diff] [blame] | 41 | #include "common.h" |
Uwe Kleine-König | d5dac4a | 2010-06-23 09:36:01 +0200 | [diff] [blame] | 42 | #include "devices-imx27.h" |
Shawn Guo | 50f2de6 | 2012-09-14 14:14:45 +0800 | [diff] [blame] | 43 | #include "hardware.h" |
Shawn Guo | 267dd34 | 2012-09-13 13:26:00 +0800 | [diff] [blame] | 44 | #include "iomux-mx27.h" |
Shawn Guo | 39ef634 | 2012-09-13 21:46:09 +0800 | [diff] [blame] | 45 | #include "ulpi.h" |
Fabio Estevam | ec9be0d | 2009-04-16 12:45:01 -0700 | [diff] [blame] | 46 | |
Fabio Estevam | 98618cf | 2011-06-22 09:25:23 -0300 | [diff] [blame] | 47 | #define SD1_EN_GPIO IMX_GPIO_NR(2, 25) |
| 48 | #define OTG_PHY_RESET_GPIO IMX_GPIO_NR(2, 23) |
| 49 | #define SPI2_SS0 IMX_GPIO_NR(4, 21) |
Fabio Estevam | aec250d | 2011-06-22 09:25:24 -0300 | [diff] [blame] | 50 | #define PMIC_INT IMX_GPIO_NR(3, 14) |
Fabio Estevam | 1abcb4c | 2011-06-22 09:25:25 -0300 | [diff] [blame] | 51 | #define SPI1_SS0 IMX_GPIO_NR(4, 28) |
Fabio Estevam | c084473d | 2011-06-22 09:25:27 -0300 | [diff] [blame] | 52 | #define SD1_CD IMX_GPIO_NR(2, 26) |
Fabio Estevam | 1abcb4c | 2011-06-22 09:25:25 -0300 | [diff] [blame] | 53 | #define LCD_RESET IMX_GPIO_NR(1, 3) |
| 54 | #define LCD_ENABLE IMX_GPIO_NR(1, 31) |
Fabio Estevam | 4c11c28 | 2012-02-15 19:36:10 -0200 | [diff] [blame] | 55 | #define CSI_PWRDWN IMX_GPIO_NR(4, 19) |
| 56 | #define CSI_RESET IMX_GPIO_NR(3, 6) |
Rogerio Pimentel | b5ec73e | 2010-10-22 11:03:54 -0200 | [diff] [blame] | 57 | |
Uwe Kleine-König | 6c80ee5 | 2010-09-28 21:53:31 +0200 | [diff] [blame] | 58 | static const int mx27pdk_pins[] __initconst = { |
Fabio Estevam | ec9be0d | 2009-04-16 12:45:01 -0700 | [diff] [blame] | 59 | /* UART1 */ |
| 60 | PE12_PF_UART1_TXD, |
| 61 | PE13_PF_UART1_RXD, |
| 62 | PE14_PF_UART1_CTS, |
| 63 | PE15_PF_UART1_RTS, |
| 64 | /* FEC */ |
| 65 | PD0_AIN_FEC_TXD0, |
| 66 | PD1_AIN_FEC_TXD1, |
| 67 | PD2_AIN_FEC_TXD2, |
| 68 | PD3_AIN_FEC_TXD3, |
| 69 | PD4_AOUT_FEC_RX_ER, |
| 70 | PD5_AOUT_FEC_RXD1, |
| 71 | PD6_AOUT_FEC_RXD2, |
| 72 | PD7_AOUT_FEC_RXD3, |
| 73 | PD8_AF_FEC_MDIO, |
| 74 | PD9_AIN_FEC_MDC, |
| 75 | PD10_AOUT_FEC_CRS, |
| 76 | PD11_AOUT_FEC_TX_CLK, |
| 77 | PD12_AOUT_FEC_RXD0, |
| 78 | PD13_AOUT_FEC_RX_DV, |
| 79 | PD14_AOUT_FEC_RX_CLK, |
| 80 | PD15_AOUT_FEC_COL, |
| 81 | PD16_AIN_FEC_TX_ER, |
| 82 | PF23_AIN_FEC_TX_EN, |
Rogerio Pimentel | b5ec73e | 2010-10-22 11:03:54 -0200 | [diff] [blame] | 83 | /* SDHC1 */ |
| 84 | PE18_PF_SD1_D0, |
| 85 | PE19_PF_SD1_D1, |
| 86 | PE20_PF_SD1_D2, |
| 87 | PE21_PF_SD1_D3, |
| 88 | PE22_PF_SD1_CMD, |
| 89 | PE23_PF_SD1_CLK, |
| 90 | SD1_EN_GPIO | GPIO_GPIO | GPIO_OUT, |
Fabio Estevam | 96cf423 | 2010-12-22 12:25:31 -0200 | [diff] [blame] | 91 | /* OTG */ |
| 92 | OTG_PHY_RESET_GPIO | GPIO_GPIO | GPIO_OUT, |
| 93 | PC7_PF_USBOTG_DATA5, |
| 94 | PC8_PF_USBOTG_DATA6, |
| 95 | PC9_PF_USBOTG_DATA0, |
| 96 | PC10_PF_USBOTG_DATA2, |
| 97 | PC11_PF_USBOTG_DATA1, |
| 98 | PC12_PF_USBOTG_DATA4, |
| 99 | PC13_PF_USBOTG_DATA3, |
| 100 | PE0_PF_USBOTG_NXT, |
| 101 | PE1_PF_USBOTG_STP, |
| 102 | PE2_PF_USBOTG_DIR, |
| 103 | PE24_PF_USBOTG_CLK, |
| 104 | PE25_PF_USBOTG_DATA7, |
Fabio Estevam | 1abcb4c | 2011-06-22 09:25:25 -0300 | [diff] [blame] | 105 | /* CSPI1 */ |
| 106 | PD31_PF_CSPI1_MOSI, |
| 107 | PD30_PF_CSPI1_MISO, |
| 108 | PD29_PF_CSPI1_SCLK, |
| 109 | PD25_PF_CSPI1_RDY, |
| 110 | SPI1_SS0 | GPIO_GPIO | GPIO_OUT, |
Fabio Estevam | c67a3e0 | 2011-01-03 11:16:39 -0200 | [diff] [blame] | 111 | /* CSPI2 */ |
| 112 | PD22_PF_CSPI2_SCLK, |
| 113 | PD23_PF_CSPI2_MISO, |
| 114 | PD24_PF_CSPI2_MOSI, |
Fabio Estevam | aec250d | 2011-06-22 09:25:24 -0300 | [diff] [blame] | 115 | SPI2_SS0 | GPIO_GPIO | GPIO_OUT, |
Fabio Estevam | 5885f03 | 2011-03-01 16:59:46 -0300 | [diff] [blame] | 116 | /* I2C1 */ |
| 117 | PD17_PF_I2C_DATA, |
| 118 | PD18_PF_I2C_CLK, |
Fabio Estevam | aec250d | 2011-06-22 09:25:24 -0300 | [diff] [blame] | 119 | /* PMIC INT */ |
| 120 | PMIC_INT | GPIO_GPIO | GPIO_IN, |
Fabio Estevam | 1abcb4c | 2011-06-22 09:25:25 -0300 | [diff] [blame] | 121 | /* LCD */ |
| 122 | PA5_PF_LSCLK, |
| 123 | PA6_PF_LD0, |
| 124 | PA7_PF_LD1, |
| 125 | PA8_PF_LD2, |
| 126 | PA9_PF_LD3, |
| 127 | PA10_PF_LD4, |
| 128 | PA11_PF_LD5, |
| 129 | PA12_PF_LD6, |
| 130 | PA13_PF_LD7, |
| 131 | PA14_PF_LD8, |
| 132 | PA15_PF_LD9, |
| 133 | PA16_PF_LD10, |
| 134 | PA17_PF_LD11, |
| 135 | PA18_PF_LD12, |
| 136 | PA19_PF_LD13, |
| 137 | PA20_PF_LD14, |
| 138 | PA21_PF_LD15, |
| 139 | PA22_PF_LD16, |
| 140 | PA23_PF_LD17, |
| 141 | PA28_PF_HSYNC, |
| 142 | PA29_PF_VSYNC, |
| 143 | PA30_PF_CONTRAST, |
| 144 | LCD_ENABLE | GPIO_GPIO | GPIO_OUT, |
| 145 | LCD_RESET | GPIO_GPIO | GPIO_OUT, |
Fabio Estevam | 4c11c28 | 2012-02-15 19:36:10 -0200 | [diff] [blame] | 146 | /* CSI */ |
| 147 | PB10_PF_CSI_D0, |
| 148 | PB11_PF_CSI_D1, |
| 149 | PB12_PF_CSI_D2, |
| 150 | PB13_PF_CSI_D3, |
| 151 | PB14_PF_CSI_D4, |
| 152 | PB15_PF_CSI_MCLK, |
| 153 | PB16_PF_CSI_PIXCLK, |
| 154 | PB17_PF_CSI_D5, |
| 155 | PB18_PF_CSI_D6, |
| 156 | PB19_PF_CSI_D7, |
| 157 | PB20_PF_CSI_VSYNC, |
| 158 | PB21_PF_CSI_HSYNC, |
| 159 | CSI_PWRDWN | GPIO_GPIO | GPIO_OUT, |
| 160 | CSI_RESET | GPIO_GPIO | GPIO_OUT, |
Fabio Estevam | 688b5cb | 2012-07-03 15:44:57 -0300 | [diff] [blame] | 161 | /* SSI4 */ |
| 162 | PC16_PF_SSI4_FS, |
| 163 | PC17_PF_SSI4_RXD, |
| 164 | PC18_PF_SSI4_TXD, |
| 165 | PC19_PF_SSI4_CLK, |
Fabio Estevam | 4c11c28 | 2012-02-15 19:36:10 -0200 | [diff] [blame] | 166 | }; |
| 167 | |
| 168 | static struct gpio mx27_3ds_camera_gpios[] = { |
| 169 | { CSI_PWRDWN, GPIOF_OUT_INIT_HIGH, "camera-power" }, |
| 170 | { CSI_RESET, GPIOF_OUT_INIT_HIGH, "camera-reset" }, |
Fabio Estevam | ec9be0d | 2009-04-16 12:45:01 -0700 | [diff] [blame] | 171 | }; |
| 172 | |
Uwe Kleine-König | d5dac4a | 2010-06-23 09:36:01 +0200 | [diff] [blame] | 173 | static const struct imxuart_platform_data uart_pdata __initconst = { |
Fabio Estevam | ec9be0d | 2009-04-16 12:45:01 -0700 | [diff] [blame] | 174 | .flags = IMXUART_HAVE_RTSCTS, |
| 175 | }; |
| 176 | |
Rogerio Pimentel | 3fac6cf | 2010-06-25 10:31:33 -0300 | [diff] [blame] | 177 | /* |
| 178 | * Matrix keyboard |
| 179 | */ |
| 180 | |
| 181 | static const uint32_t mx27_3ds_keymap[] = { |
| 182 | KEY(0, 0, KEY_UP), |
| 183 | KEY(0, 1, KEY_DOWN), |
| 184 | KEY(1, 0, KEY_RIGHT), |
| 185 | KEY(1, 1, KEY_LEFT), |
| 186 | KEY(1, 2, KEY_ENTER), |
| 187 | KEY(2, 0, KEY_F6), |
| 188 | KEY(2, 1, KEY_F8), |
| 189 | KEY(2, 2, KEY_F9), |
| 190 | KEY(2, 3, KEY_F10), |
| 191 | }; |
| 192 | |
Uwe Kleine-König | 3f88014 | 2010-11-10 09:58:56 +0100 | [diff] [blame] | 193 | static const struct matrix_keymap_data mx27_3ds_keymap_data __initconst = { |
Rogerio Pimentel | 3fac6cf | 2010-06-25 10:31:33 -0300 | [diff] [blame] | 194 | .keymap = mx27_3ds_keymap, |
| 195 | .keymap_size = ARRAY_SIZE(mx27_3ds_keymap), |
| 196 | }; |
| 197 | |
Rogerio Pimentel | b5ec73e | 2010-10-22 11:03:54 -0200 | [diff] [blame] | 198 | static int mx27_3ds_sdhc1_init(struct device *dev, irq_handler_t detect_irq, |
| 199 | void *data) |
| 200 | { |
Fabio Estevam | c084473d | 2011-06-22 09:25:27 -0300 | [diff] [blame] | 201 | return request_irq(gpio_to_irq(SD1_CD), detect_irq, |
| 202 | IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING, "sdhc1-card-detect", data); |
Rogerio Pimentel | b5ec73e | 2010-10-22 11:03:54 -0200 | [diff] [blame] | 203 | } |
| 204 | |
| 205 | static void mx27_3ds_sdhc1_exit(struct device *dev, void *data) |
| 206 | { |
Fabio Estevam | c084473d | 2011-06-22 09:25:27 -0300 | [diff] [blame] | 207 | free_irq(gpio_to_irq(SD1_CD), data); |
Rogerio Pimentel | b5ec73e | 2010-10-22 11:03:54 -0200 | [diff] [blame] | 208 | } |
| 209 | |
Uwe Kleine-König | 9d3d945 | 2010-11-05 17:26:09 +0100 | [diff] [blame] | 210 | static const struct imxmmc_platform_data sdhc1_pdata __initconst = { |
Rogerio Pimentel | b5ec73e | 2010-10-22 11:03:54 -0200 | [diff] [blame] | 211 | .init = mx27_3ds_sdhc1_init, |
| 212 | .exit = mx27_3ds_sdhc1_exit, |
| 213 | }; |
| 214 | |
| 215 | static void mx27_3ds_sdhc1_enable_level_translator(void) |
| 216 | { |
| 217 | /* Turn on TXB0108 OE pin */ |
| 218 | gpio_request(SD1_EN_GPIO, "sd1_enable"); |
| 219 | gpio_direction_output(SD1_EN_GPIO, 1); |
| 220 | } |
| 221 | |
Fabio Estevam | 96cf423 | 2010-12-22 12:25:31 -0200 | [diff] [blame] | 222 | |
| 223 | static int otg_phy_init(void) |
| 224 | { |
| 225 | gpio_request(OTG_PHY_RESET_GPIO, "usb-otg-reset"); |
| 226 | gpio_direction_output(OTG_PHY_RESET_GPIO, 0); |
| 227 | mdelay(1); |
| 228 | gpio_set_value(OTG_PHY_RESET_GPIO, 1); |
| 229 | return 0; |
| 230 | } |
| 231 | |
Sascha Hauer | 4bd597b | 2011-01-03 11:30:28 +0100 | [diff] [blame] | 232 | static int mx27_3ds_otg_init(struct platform_device *pdev) |
| 233 | { |
| 234 | return mx27_initialize_usb_hw(pdev->id, MXC_EHCI_INTERFACE_DIFF_UNI); |
| 235 | } |
Fabio Estevam | 96cf423 | 2010-12-22 12:25:31 -0200 | [diff] [blame] | 236 | |
| 237 | static struct mxc_usbh_platform_data otg_pdata __initdata = { |
Sascha Hauer | 4bd597b | 2011-01-03 11:30:28 +0100 | [diff] [blame] | 238 | .init = mx27_3ds_otg_init, |
Fabio Estevam | 96cf423 | 2010-12-22 12:25:31 -0200 | [diff] [blame] | 239 | .portsc = MXC_EHCI_MODE_ULPI, |
Fabio Estevam | 96cf423 | 2010-12-22 12:25:31 -0200 | [diff] [blame] | 240 | }; |
Fabio Estevam | 96cf423 | 2010-12-22 12:25:31 -0200 | [diff] [blame] | 241 | |
| 242 | static const struct fsl_usb2_platform_data otg_device_pdata __initconst = { |
| 243 | .operating_mode = FSL_USB2_DR_DEVICE, |
| 244 | .phy_mode = FSL_USB2_PHY_ULPI, |
| 245 | }; |
| 246 | |
Benoît Thébaudeau | 33a264d | 2012-06-12 19:46:43 +0200 | [diff] [blame] | 247 | static bool otg_mode_host __initdata; |
Fabio Estevam | 96cf423 | 2010-12-22 12:25:31 -0200 | [diff] [blame] | 248 | |
| 249 | static int __init mx27_3ds_otg_mode(char *options) |
| 250 | { |
| 251 | if (!strcmp(options, "host")) |
Benoît Thébaudeau | 33a264d | 2012-06-12 19:46:43 +0200 | [diff] [blame] | 252 | otg_mode_host = true; |
Fabio Estevam | 96cf423 | 2010-12-22 12:25:31 -0200 | [diff] [blame] | 253 | else if (!strcmp(options, "device")) |
Benoît Thébaudeau | 33a264d | 2012-06-12 19:46:43 +0200 | [diff] [blame] | 254 | otg_mode_host = false; |
Fabio Estevam | 96cf423 | 2010-12-22 12:25:31 -0200 | [diff] [blame] | 255 | else |
| 256 | pr_info("otg_mode neither \"host\" nor \"device\". " |
| 257 | "Defaulting to device\n"); |
Benoît Thébaudeau | 33a264d | 2012-06-12 19:46:43 +0200 | [diff] [blame] | 258 | return 1; |
Fabio Estevam | 96cf423 | 2010-12-22 12:25:31 -0200 | [diff] [blame] | 259 | } |
| 260 | __setup("otg_mode=", mx27_3ds_otg_mode); |
| 261 | |
Fabio Estevam | c67a3e0 | 2011-01-03 11:16:39 -0200 | [diff] [blame] | 262 | /* Regulators */ |
Fabio Estevam | aec250d | 2011-06-22 09:25:24 -0300 | [diff] [blame] | 263 | static struct regulator_init_data gpo_init = { |
| 264 | .constraints = { |
| 265 | .boot_on = 1, |
| 266 | .always_on = 1, |
| 267 | } |
| 268 | }; |
| 269 | |
Fabio Estevam | c67a3e0 | 2011-01-03 11:16:39 -0200 | [diff] [blame] | 270 | static struct regulator_consumer_supply vmmc1_consumers[] = { |
Mark Brown | 0556dc3 | 2011-10-31 17:11:48 -0700 | [diff] [blame] | 271 | REGULATOR_SUPPLY("vcore", "spi0.0"), |
Fabio Estevam | 4c11c28 | 2012-02-15 19:36:10 -0200 | [diff] [blame] | 272 | REGULATOR_SUPPLY("cmos_2v8", "soc-camera-pdrv.0"), |
Fabio Estevam | c67a3e0 | 2011-01-03 11:16:39 -0200 | [diff] [blame] | 273 | }; |
| 274 | |
| 275 | static struct regulator_init_data vmmc1_init = { |
| 276 | .constraints = { |
| 277 | .min_uV = 2800000, |
| 278 | .max_uV = 2800000, |
Fabio Estevam | aec250d | 2011-06-22 09:25:24 -0300 | [diff] [blame] | 279 | .apply_uV = 1, |
| 280 | .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE | |
| 281 | REGULATOR_CHANGE_STATUS, |
Fabio Estevam | c67a3e0 | 2011-01-03 11:16:39 -0200 | [diff] [blame] | 282 | }, |
| 283 | .num_consumer_supplies = ARRAY_SIZE(vmmc1_consumers), |
| 284 | .consumer_supplies = vmmc1_consumers, |
| 285 | }; |
| 286 | |
| 287 | static struct regulator_consumer_supply vgen_consumers[] = { |
Mark Brown | 0556dc3 | 2011-10-31 17:11:48 -0700 | [diff] [blame] | 288 | REGULATOR_SUPPLY("vdd", "spi0.0"), |
Fabio Estevam | c67a3e0 | 2011-01-03 11:16:39 -0200 | [diff] [blame] | 289 | }; |
| 290 | |
| 291 | static struct regulator_init_data vgen_init = { |
| 292 | .constraints = { |
| 293 | .min_uV = 1800000, |
| 294 | .max_uV = 1800000, |
| 295 | .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE, |
| 296 | }, |
| 297 | .num_consumer_supplies = ARRAY_SIZE(vgen_consumers), |
| 298 | .consumer_supplies = vgen_consumers, |
| 299 | }; |
| 300 | |
Fabio Estevam | 4c11c28 | 2012-02-15 19:36:10 -0200 | [diff] [blame] | 301 | static struct regulator_consumer_supply vvib_consumers[] = { |
| 302 | REGULATOR_SUPPLY("cmos_vcore", "soc-camera-pdrv.0"), |
| 303 | }; |
| 304 | |
| 305 | static struct regulator_init_data vvib_init = { |
| 306 | .constraints = { |
| 307 | .min_uV = 1300000, |
| 308 | .max_uV = 1300000, |
| 309 | .apply_uV = 1, |
| 310 | .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE | |
| 311 | REGULATOR_CHANGE_STATUS, |
| 312 | }, |
| 313 | .num_consumer_supplies = ARRAY_SIZE(vvib_consumers), |
| 314 | .consumer_supplies = vvib_consumers, |
| 315 | }; |
| 316 | |
David Jander | 5836372 | 2011-02-10 10:59:44 +0100 | [diff] [blame] | 317 | static struct mc13xxx_regulator_init_data mx27_3ds_regulators[] = { |
Fabio Estevam | c67a3e0 | 2011-01-03 11:16:39 -0200 | [diff] [blame] | 318 | { |
Sascha Hauer | 074cee9 | 2011-01-07 17:07:22 +0100 | [diff] [blame] | 319 | .id = MC13783_REG_VMMC1, |
Fabio Estevam | c67a3e0 | 2011-01-03 11:16:39 -0200 | [diff] [blame] | 320 | .init_data = &vmmc1_init, |
| 321 | }, { |
Sascha Hauer | 074cee9 | 2011-01-07 17:07:22 +0100 | [diff] [blame] | 322 | .id = MC13783_REG_VGEN, |
Fabio Estevam | c67a3e0 | 2011-01-03 11:16:39 -0200 | [diff] [blame] | 323 | .init_data = &vgen_init, |
Fabio Estevam | aec250d | 2011-06-22 09:25:24 -0300 | [diff] [blame] | 324 | }, { |
| 325 | .id = MC13783_REG_GPO1, /* Turn on 1.8V */ |
| 326 | .init_data = &gpo_init, |
| 327 | }, { |
| 328 | .id = MC13783_REG_GPO3, /* Turn on 3.3V */ |
| 329 | .init_data = &gpo_init, |
Fabio Estevam | 4c11c28 | 2012-02-15 19:36:10 -0200 | [diff] [blame] | 330 | }, { |
| 331 | .id = MC13783_REG_VVIB, /* Power OV2640 */ |
| 332 | .init_data = &vvib_init, |
Fabio Estevam | c67a3e0 | 2011-01-03 11:16:39 -0200 | [diff] [blame] | 333 | }, |
| 334 | }; |
| 335 | |
| 336 | /* MC13783 */ |
Fabio Estevam | 688b5cb | 2012-07-03 15:44:57 -0300 | [diff] [blame] | 337 | static struct mc13xxx_codec_platform_data mx27_3ds_codec = { |
| 338 | .dac_ssi_port = MC13783_SSI1_PORT, |
| 339 | .adc_ssi_port = MC13783_SSI1_PORT, |
| 340 | }; |
| 341 | |
Andres Salomon | 4ec1b54 | 2011-02-17 19:07:23 -0800 | [diff] [blame] | 342 | static struct mc13xxx_platform_data mc13783_pdata = { |
| 343 | .regulators = { |
| 344 | .regulators = mx27_3ds_regulators, |
| 345 | .num_regulators = ARRAY_SIZE(mx27_3ds_regulators), |
| 346 | |
| 347 | }, |
Fabio Estevam | 688b5cb | 2012-07-03 15:44:57 -0300 | [diff] [blame] | 348 | .flags = MC13XXX_USE_TOUCHSCREEN | MC13XXX_USE_RTC | |
| 349 | MC13XXX_USE_CODEC, |
| 350 | .codec = &mx27_3ds_codec, |
| 351 | }; |
| 352 | |
| 353 | static struct imx_ssi_platform_data mx27_3ds_ssi_pdata = { |
| 354 | .flags = IMX_SSI_DMA | IMX_SSI_NET, |
Fabio Estevam | c67a3e0 | 2011-01-03 11:16:39 -0200 | [diff] [blame] | 355 | }; |
| 356 | |
| 357 | /* SPI */ |
Fabio Estevam | 1abcb4c | 2011-06-22 09:25:25 -0300 | [diff] [blame] | 358 | static int spi1_chipselect[] = {SPI1_SS0}; |
| 359 | |
| 360 | static const struct spi_imx_master spi1_pdata __initconst = { |
| 361 | .chipselect = spi1_chipselect, |
| 362 | .num_chipselect = ARRAY_SIZE(spi1_chipselect), |
| 363 | }; |
| 364 | |
Fabio Estevam | 6d2385a | 2011-06-22 09:25:28 -0300 | [diff] [blame] | 365 | static int spi2_chipselect[] = {SPI2_SS0}; |
Fabio Estevam | c67a3e0 | 2011-01-03 11:16:39 -0200 | [diff] [blame] | 366 | |
| 367 | static const struct spi_imx_master spi2_pdata __initconst = { |
Fabio Estevam | 6d2385a | 2011-06-22 09:25:28 -0300 | [diff] [blame] | 368 | .chipselect = spi2_chipselect, |
| 369 | .num_chipselect = ARRAY_SIZE(spi2_chipselect), |
Fabio Estevam | c67a3e0 | 2011-01-03 11:16:39 -0200 | [diff] [blame] | 370 | }; |
| 371 | |
Fabio Estevam | 4c11c28 | 2012-02-15 19:36:10 -0200 | [diff] [blame] | 372 | static int mx27_3ds_camera_power(struct device *dev, int on) |
| 373 | { |
| 374 | /* enable or disable the camera */ |
| 375 | pr_debug("%s: %s the camera\n", __func__, on ? "ENABLE" : "DISABLE"); |
| 376 | gpio_set_value(CSI_PWRDWN, on ? 0 : 1); |
| 377 | |
| 378 | if (!on) |
| 379 | goto out; |
| 380 | |
| 381 | /* If enabled, give a reset impulse */ |
| 382 | gpio_set_value(CSI_RESET, 0); |
| 383 | msleep(20); |
| 384 | gpio_set_value(CSI_RESET, 1); |
| 385 | msleep(100); |
| 386 | |
| 387 | out: |
| 388 | return 0; |
| 389 | } |
| 390 | |
| 391 | static struct i2c_board_info mx27_3ds_i2c_camera = { |
| 392 | I2C_BOARD_INFO("ov2640", 0x30), |
| 393 | }; |
| 394 | |
| 395 | static struct regulator_bulk_data mx27_3ds_camera_regs[] = { |
| 396 | { .supply = "cmos_vcore" }, |
| 397 | { .supply = "cmos_2v8" }, |
| 398 | }; |
| 399 | |
| 400 | static struct soc_camera_link iclink_ov2640 = { |
| 401 | .bus_id = 0, |
| 402 | .board_info = &mx27_3ds_i2c_camera, |
| 403 | .i2c_adapter_id = 0, |
| 404 | .power = mx27_3ds_camera_power, |
| 405 | .regulators = mx27_3ds_camera_regs, |
| 406 | .num_regulators = ARRAY_SIZE(mx27_3ds_camera_regs), |
| 407 | }; |
| 408 | |
| 409 | static struct platform_device mx27_3ds_ov2640 = { |
| 410 | .name = "soc-camera-pdrv", |
| 411 | .id = 0, |
| 412 | .dev = { |
| 413 | .platform_data = &iclink_ov2640, |
| 414 | }, |
| 415 | }; |
| 416 | |
Fabio Estevam | 1abcb4c | 2011-06-22 09:25:25 -0300 | [diff] [blame] | 417 | static struct imx_fb_videomode mx27_3ds_modes[] = { |
| 418 | { /* 480x640 @ 60 Hz */ |
| 419 | .mode = { |
| 420 | .name = "Epson-VGA", |
| 421 | .refresh = 60, |
| 422 | .xres = 480, |
| 423 | .yres = 640, |
| 424 | .pixclock = 41701, |
| 425 | .left_margin = 20, |
| 426 | .right_margin = 41, |
| 427 | .upper_margin = 10, |
| 428 | .lower_margin = 5, |
| 429 | .hsync_len = 20, |
| 430 | .vsync_len = 10, |
| 431 | .sync = FB_SYNC_OE_ACT_HIGH | |
| 432 | FB_SYNC_CLK_INVERT, |
| 433 | .vmode = FB_VMODE_NONINTERLACED, |
| 434 | .flag = 0, |
| 435 | }, |
| 436 | .bpp = 16, |
| 437 | .pcr = 0xFAC08B82, |
| 438 | }, |
| 439 | }; |
| 440 | |
| 441 | static const struct imx_fb_platform_data mx27_3ds_fb_data __initconst = { |
| 442 | .mode = mx27_3ds_modes, |
| 443 | .num_modes = ARRAY_SIZE(mx27_3ds_modes), |
| 444 | .pwmr = 0x00A903FF, |
| 445 | .lscr1 = 0x00120300, |
| 446 | .dmacr = 0x00020010, |
| 447 | }; |
| 448 | |
| 449 | /* LCD */ |
| 450 | static struct l4f00242t03_pdata mx27_3ds_lcd_pdata = { |
| 451 | .reset_gpio = LCD_RESET, |
| 452 | .data_enable_gpio = LCD_ENABLE, |
Fabio Estevam | 1abcb4c | 2011-06-22 09:25:25 -0300 | [diff] [blame] | 453 | }; |
| 454 | |
Fabio Estevam | c67a3e0 | 2011-01-03 11:16:39 -0200 | [diff] [blame] | 455 | static struct spi_board_info mx27_3ds_spi_devs[] __initdata = { |
| 456 | { |
| 457 | .modalias = "mc13783", |
| 458 | .max_speed_hz = 1000000, |
| 459 | .bus_num = 1, |
| 460 | .chip_select = 0, /* SS0 */ |
| 461 | .platform_data = &mc13783_pdata, |
Shawn Guo | 84715dd | 2011-12-02 15:31:11 +0800 | [diff] [blame] | 462 | /* irq number is run-time assigned */ |
Fabio Estevam | c67a3e0 | 2011-01-03 11:16:39 -0200 | [diff] [blame] | 463 | .mode = SPI_CS_HIGH, |
Fabio Estevam | 1abcb4c | 2011-06-22 09:25:25 -0300 | [diff] [blame] | 464 | }, { |
| 465 | .modalias = "l4f00242t03", |
| 466 | .max_speed_hz = 5000000, |
| 467 | .bus_num = 0, |
| 468 | .chip_select = 0, /* SS0 */ |
| 469 | .platform_data = &mx27_3ds_lcd_pdata, |
Fabio Estevam | c67a3e0 | 2011-01-03 11:16:39 -0200 | [diff] [blame] | 470 | }, |
| 471 | }; |
| 472 | |
Fabio Estevam | 4c11c28 | 2012-02-15 19:36:10 -0200 | [diff] [blame] | 473 | static struct platform_device *devices[] __initdata = { |
| 474 | &mx27_3ds_ov2640, |
| 475 | }; |
| 476 | |
| 477 | static const struct mx2_camera_platform_data mx27_3ds_cam_pdata __initconst = { |
| 478 | .clk = 26000000, |
| 479 | }; |
| 480 | |
Fabio Estevam | 5885f03 | 2011-03-01 16:59:46 -0300 | [diff] [blame] | 481 | static const struct imxi2c_platform_data mx27_3ds_i2c0_data __initconst = { |
| 482 | .bitrate = 100000, |
| 483 | }; |
Fabio Estevam | 96cf423 | 2010-12-22 12:25:31 -0200 | [diff] [blame] | 484 | |
Fabio Estevam | ec9be0d | 2009-04-16 12:45:01 -0700 | [diff] [blame] | 485 | static void __init mx27pdk_init(void) |
| 486 | { |
Fabio Estevam | 4c11c28 | 2012-02-15 19:36:10 -0200 | [diff] [blame] | 487 | int ret; |
Shawn Guo | b78d8e5 | 2011-06-06 00:07:55 +0800 | [diff] [blame] | 488 | imx27_soc_init(); |
| 489 | |
Fabio Estevam | ec9be0d | 2009-04-16 12:45:01 -0700 | [diff] [blame] | 490 | mxc_gpio_setup_multiple_pins(mx27pdk_pins, ARRAY_SIZE(mx27pdk_pins), |
| 491 | "mx27pdk"); |
Rogerio Pimentel | b5ec73e | 2010-10-22 11:03:54 -0200 | [diff] [blame] | 492 | mx27_3ds_sdhc1_enable_level_translator(); |
Uwe Kleine-König | d5dac4a | 2010-06-23 09:36:01 +0200 | [diff] [blame] | 493 | imx27_add_imx_uart0(&uart_pdata); |
Uwe Kleine-König | 6bd96f3 | 2010-10-06 12:00:18 +0200 | [diff] [blame] | 494 | imx27_add_fec(NULL); |
Uwe Kleine-König | 3f88014 | 2010-11-10 09:58:56 +0100 | [diff] [blame] | 495 | imx27_add_imx_keypad(&mx27_3ds_keymap_data); |
Uwe Kleine-König | 9d3d945 | 2010-11-05 17:26:09 +0100 | [diff] [blame] | 496 | imx27_add_mxc_mmc(0, &sdhc1_pdata); |
Benoît Thébaudeau | bec31a8 | 2012-07-04 16:35:54 +0200 | [diff] [blame] | 497 | imx27_add_imx2_wdt(); |
Fabio Estevam | 96cf423 | 2010-12-22 12:25:31 -0200 | [diff] [blame] | 498 | otg_phy_init(); |
Fabio Estevam | 96cf423 | 2010-12-22 12:25:31 -0200 | [diff] [blame] | 499 | |
Sascha Hauer | 48f6b09 | 2011-03-02 09:27:42 +0100 | [diff] [blame] | 500 | if (otg_mode_host) { |
| 501 | otg_pdata.otg = imx_otg_ulpi_create(ULPI_OTG_DRVVBUS | |
| 502 | ULPI_OTG_DRVVBUS_EXT); |
| 503 | |
| 504 | if (otg_pdata.otg) |
| 505 | imx27_add_mxc_ehci_otg(&otg_pdata); |
Fabio Estevam | 96cf423 | 2010-12-22 12:25:31 -0200 | [diff] [blame] | 506 | } |
Sascha Hauer | 48f6b09 | 2011-03-02 09:27:42 +0100 | [diff] [blame] | 507 | |
Fabio Estevam | 96cf423 | 2010-12-22 12:25:31 -0200 | [diff] [blame] | 508 | if (!otg_mode_host) |
| 509 | imx27_add_fsl_usb2_udc(&otg_device_pdata); |
| 510 | |
Fabio Estevam | c67a3e0 | 2011-01-03 11:16:39 -0200 | [diff] [blame] | 511 | imx27_add_spi_imx1(&spi2_pdata); |
Fabio Estevam | 1abcb4c | 2011-06-22 09:25:25 -0300 | [diff] [blame] | 512 | imx27_add_spi_imx0(&spi1_pdata); |
Shawn Guo | 84715dd | 2011-12-02 15:31:11 +0800 | [diff] [blame] | 513 | mx27_3ds_spi_devs[0].irq = gpio_to_irq(PMIC_INT); |
Fabio Estevam | c67a3e0 | 2011-01-03 11:16:39 -0200 | [diff] [blame] | 514 | spi_register_board_info(mx27_3ds_spi_devs, |
| 515 | ARRAY_SIZE(mx27_3ds_spi_devs)); |
Fabio Estevam | 92cb33f | 2011-01-10 18:17:37 -0200 | [diff] [blame] | 516 | |
Shawn Guo | ed4a7fb | 2012-06-13 15:58:08 +0800 | [diff] [blame] | 517 | if (mxc_expio_init(MX27_CS5_BASE_ADDR, IMX_GPIO_NR(3, 28))) |
Fabio Estevam | 92cb33f | 2011-01-10 18:17:37 -0200 | [diff] [blame] | 518 | pr_warn("Init of the debugboard failed, all devices on the debugboard are unusable.\n"); |
Fabio Estevam | 5885f03 | 2011-03-01 16:59:46 -0300 | [diff] [blame] | 519 | imx27_add_imx_i2c(0, &mx27_3ds_i2c0_data); |
Fabio Estevam | 4c11c28 | 2012-02-15 19:36:10 -0200 | [diff] [blame] | 520 | platform_add_devices(devices, ARRAY_SIZE(devices)); |
Fabio Estevam | 1abcb4c | 2011-06-22 09:25:25 -0300 | [diff] [blame] | 521 | imx27_add_imx_fb(&mx27_3ds_fb_data); |
Fabio Estevam | 4c11c28 | 2012-02-15 19:36:10 -0200 | [diff] [blame] | 522 | |
| 523 | ret = gpio_request_array(mx27_3ds_camera_gpios, |
| 524 | ARRAY_SIZE(mx27_3ds_camera_gpios)); |
| 525 | if (ret) { |
| 526 | pr_err("Failed to request camera gpios"); |
| 527 | iclink_ov2640.power = NULL; |
| 528 | } |
| 529 | |
| 530 | imx27_add_mx2_camera(&mx27_3ds_cam_pdata); |
Fabio Estevam | 688b5cb | 2012-07-03 15:44:57 -0300 | [diff] [blame] | 531 | imx27_add_imx_ssi(0, &mx27_3ds_ssi_pdata); |
| 532 | |
| 533 | imx_add_platform_device("imx_mc13783", 0, NULL, 0, NULL, 0); |
Fabio Estevam | ec9be0d | 2009-04-16 12:45:01 -0700 | [diff] [blame] | 534 | } |
| 535 | |
| 536 | static void __init mx27pdk_timer_init(void) |
| 537 | { |
| 538 | mx27_clocks_init(26000000); |
| 539 | } |
| 540 | |
Fabio Estevam | ec9be0d | 2009-04-16 12:45:01 -0700 | [diff] [blame] | 541 | MACHINE_START(MX27_3DS, "Freescale MX27PDK") |
| 542 | /* maintainer: Freescale Semiconductor, Inc. */ |
Nicolas Pitre | dc8f190 | 2011-07-05 22:38:12 -0400 | [diff] [blame] | 543 | .atag_offset = 0x100, |
Uwe Kleine-König | 3dac219 | 2011-02-07 16:35:19 +0100 | [diff] [blame] | 544 | .map_io = mx27_map_io, |
| 545 | .init_early = imx27_init_early, |
| 546 | .init_irq = mx27_init_irq, |
Sascha Hauer | ffa2ea3 | 2011-09-20 14:31:24 +0200 | [diff] [blame] | 547 | .handle_irq = imx27_handle_irq, |
Stephen Warren | 6bb27d7 | 2012-11-08 12:40:59 -0700 | [diff] [blame] | 548 | .init_time = mx27pdk_timer_init, |
Uwe Kleine-König | 3dac219 | 2011-02-07 16:35:19 +0100 | [diff] [blame] | 549 | .init_machine = mx27pdk_init, |
Russell King | 65ea788 | 2011-11-06 17:12:08 +0000 | [diff] [blame] | 550 | .restart = mxc_restart, |
Fabio Estevam | ec9be0d | 2009-04-16 12:45:01 -0700 | [diff] [blame] | 551 | MACHINE_END |