Javier Martin | 3b161e5 | 2010-07-30 10:06:01 +0200 | [diff] [blame] | 1 | /* |
| 2 | * mach-imx27_visstrim_m10.c |
| 3 | * |
| 4 | * Copyright 2010 Javier Martin <javier.martin@vista-silicon.com> |
| 5 | * |
| 6 | * Based on mach-pcm038.c, mach-pca100.c, mach-mx27ads.c and others. |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; either version 2 of the License, or |
| 11 | * (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
| 21 | * MA 02110-1301, USA. |
| 22 | */ |
| 23 | |
| 24 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
| 25 | |
| 26 | #include <linux/platform_device.h> |
| 27 | #include <linux/mtd/physmap.h> |
| 28 | #include <linux/i2c.h> |
| 29 | #include <linux/i2c/pca953x.h> |
Javier Martin | 3b161e5 | 2010-07-30 10:06:01 +0200 | [diff] [blame] | 30 | #include <linux/input.h> |
| 31 | #include <linux/gpio.h> |
Sascha Hauer | 4bd597b | 2011-01-03 11:30:28 +0100 | [diff] [blame] | 32 | #include <linux/delay.h> |
Javier Martin | f52f5a5 | 2012-02-28 17:31:51 +0100 | [diff] [blame] | 33 | #include <linux/dma-mapping.h> |
Javier Martin | acb6464 | 2012-02-29 13:17:33 +0100 | [diff] [blame] | 34 | #include <linux/leds.h> |
Shawn Guo | d41789b | 2012-09-17 13:34:31 +0800 | [diff] [blame] | 35 | #include <linux/platform_data/asoc-mx27vis.h> |
Javier Martin | f52f5a5 | 2012-02-28 17:31:51 +0100 | [diff] [blame] | 36 | #include <media/soc_camera.h> |
Javier Martin | c86566b | 2011-06-07 17:37:18 +0200 | [diff] [blame] | 37 | #include <sound/tlv320aic32x4.h> |
Javier Martin | 3b161e5 | 2010-07-30 10:06:01 +0200 | [diff] [blame] | 38 | #include <asm/mach-types.h> |
| 39 | #include <asm/mach/arch.h> |
| 40 | #include <asm/mach/time.h> |
Fabio Estevam | 396c89b | 2012-06-25 01:17:02 -0300 | [diff] [blame] | 41 | #include <asm/system_info.h> |
Javier Martin | b6c14dc | 2012-07-26 05:54:19 -0300 | [diff] [blame] | 42 | #include <asm/memblock.h> |
Javier Martin | 3b161e5 | 2010-07-30 10:06:01 +0200 | [diff] [blame] | 43 | |
Shawn Guo | e337247 | 2012-09-13 21:01:00 +0800 | [diff] [blame] | 44 | #include "common.h" |
Javier Martin | 3b161e5 | 2010-07-30 10:06:01 +0200 | [diff] [blame] | 45 | #include "devices-imx27.h" |
Shawn Guo | 50f2de6 | 2012-09-14 14:14:45 +0800 | [diff] [blame] | 46 | #include "hardware.h" |
Shawn Guo | 267dd34 | 2012-09-13 13:26:00 +0800 | [diff] [blame] | 47 | #include "iomux-mx27.h" |
Javier Martin | 3b161e5 | 2010-07-30 10:06:01 +0200 | [diff] [blame] | 48 | |
Javier Martin | f52f5a5 | 2012-02-28 17:31:51 +0100 | [diff] [blame] | 49 | #define TVP5150_RSTN (GPIO_PORTC + 18) |
| 50 | #define TVP5150_PWDN (GPIO_PORTC + 19) |
Javier Martin | 3b161e5 | 2010-07-30 10:06:01 +0200 | [diff] [blame] | 51 | #define OTG_PHY_CS_GPIO (GPIO_PORTF + 17) |
Shawn Guo | 438196c | 2011-12-05 10:12:28 +0800 | [diff] [blame] | 52 | #define SDHC1_IRQ_GPIO IMX_GPIO_NR(2, 25) |
Javier Martin | 3b161e5 | 2010-07-30 10:06:01 +0200 | [diff] [blame] | 53 | |
Javier Martin | 038bdf6 | 2012-08-20 12:13:01 +0200 | [diff] [blame] | 54 | #define VERSION_MASK 0x7 |
| 55 | #define MOTHERBOARD_SHIFT 4 |
| 56 | #define EXPBOARD_SHIFT 0 |
| 57 | |
Javier Martin | 435ca24 | 2012-04-10 11:26:59 +0200 | [diff] [blame] | 58 | #define MOTHERBOARD_BIT2 (GPIO_PORTD + 31) |
| 59 | #define MOTHERBOARD_BIT1 (GPIO_PORTD + 30) |
| 60 | #define MOTHERBOARD_BIT0 (GPIO_PORTD + 29) |
| 61 | |
| 62 | #define EXPBOARD_BIT2 (GPIO_PORTD + 25) |
| 63 | #define EXPBOARD_BIT1 (GPIO_PORTD + 27) |
| 64 | #define EXPBOARD_BIT0 (GPIO_PORTD + 28) |
| 65 | |
Shawn Guo | d41789b | 2012-09-17 13:34:31 +0800 | [diff] [blame] | 66 | #define AMP_GAIN_0 (GPIO_PORTF + 9) |
| 67 | #define AMP_GAIN_1 (GPIO_PORTF + 8) |
| 68 | #define AMP_MUTE_SDL (GPIO_PORTE + 5) |
| 69 | #define AMP_MUTE_SDR (GPIO_PORTF + 7) |
| 70 | |
Uwe Kleine-König | 6c80ee5 | 2010-09-28 21:53:31 +0200 | [diff] [blame] | 71 | static const int visstrim_m10_pins[] __initconst = { |
Javier Martin | 3b161e5 | 2010-07-30 10:06:01 +0200 | [diff] [blame] | 72 | /* UART1 (console) */ |
| 73 | PE12_PF_UART1_TXD, |
| 74 | PE13_PF_UART1_RXD, |
| 75 | PE14_PF_UART1_CTS, |
| 76 | PE15_PF_UART1_RTS, |
| 77 | /* FEC */ |
| 78 | PD0_AIN_FEC_TXD0, |
| 79 | PD1_AIN_FEC_TXD1, |
| 80 | PD2_AIN_FEC_TXD2, |
| 81 | PD3_AIN_FEC_TXD3, |
| 82 | PD4_AOUT_FEC_RX_ER, |
| 83 | PD5_AOUT_FEC_RXD1, |
| 84 | PD6_AOUT_FEC_RXD2, |
| 85 | PD7_AOUT_FEC_RXD3, |
| 86 | PD8_AF_FEC_MDIO, |
| 87 | PD9_AIN_FEC_MDC, |
| 88 | PD10_AOUT_FEC_CRS, |
| 89 | PD11_AOUT_FEC_TX_CLK, |
| 90 | PD12_AOUT_FEC_RXD0, |
| 91 | PD13_AOUT_FEC_RX_DV, |
| 92 | PD14_AOUT_FEC_RX_CLK, |
| 93 | PD15_AOUT_FEC_COL, |
| 94 | PD16_AIN_FEC_TX_ER, |
| 95 | PF23_AIN_FEC_TX_EN, |
Javier Martin | a5e2051 | 2011-03-01 15:02:08 +0100 | [diff] [blame] | 96 | /* SSI1 */ |
| 97 | PC20_PF_SSI1_FS, |
| 98 | PC21_PF_SSI1_RXD, |
| 99 | PC22_PF_SSI1_TXD, |
| 100 | PC23_PF_SSI1_CLK, |
Javier Martin | 3b161e5 | 2010-07-30 10:06:01 +0200 | [diff] [blame] | 101 | /* SDHC1 */ |
| 102 | PE18_PF_SD1_D0, |
| 103 | PE19_PF_SD1_D1, |
| 104 | PE20_PF_SD1_D2, |
| 105 | PE21_PF_SD1_D3, |
| 106 | PE22_PF_SD1_CMD, |
| 107 | PE23_PF_SD1_CLK, |
| 108 | /* Both I2Cs */ |
| 109 | PD17_PF_I2C_DATA, |
| 110 | PD18_PF_I2C_CLK, |
| 111 | PC5_PF_I2C2_SDA, |
| 112 | PC6_PF_I2C2_SCL, |
| 113 | /* USB OTG */ |
| 114 | OTG_PHY_CS_GPIO | GPIO_GPIO | GPIO_OUT, |
| 115 | PC9_PF_USBOTG_DATA0, |
| 116 | PC11_PF_USBOTG_DATA1, |
| 117 | PC10_PF_USBOTG_DATA2, |
| 118 | PC13_PF_USBOTG_DATA3, |
| 119 | PC12_PF_USBOTG_DATA4, |
| 120 | PC7_PF_USBOTG_DATA5, |
| 121 | PC8_PF_USBOTG_DATA6, |
| 122 | PE25_PF_USBOTG_DATA7, |
| 123 | PE24_PF_USBOTG_CLK, |
| 124 | PE2_PF_USBOTG_DIR, |
| 125 | PE0_PF_USBOTG_NXT, |
| 126 | PE1_PF_USBOTG_STP, |
| 127 | PB23_PF_USB_PWR, |
| 128 | PB24_PF_USB_OC, |
Javier Martin | f52f5a5 | 2012-02-28 17:31:51 +0100 | [diff] [blame] | 129 | /* CSI */ |
Javier Martin | 18847b4 | 2012-06-01 09:45:33 +0200 | [diff] [blame] | 130 | TVP5150_RSTN | GPIO_GPIO | GPIO_OUT, |
| 131 | TVP5150_PWDN | GPIO_GPIO | GPIO_OUT, |
Javier Martin | f52f5a5 | 2012-02-28 17:31:51 +0100 | [diff] [blame] | 132 | PB10_PF_CSI_D0, |
| 133 | PB11_PF_CSI_D1, |
| 134 | PB12_PF_CSI_D2, |
| 135 | PB13_PF_CSI_D3, |
| 136 | PB14_PF_CSI_D4, |
| 137 | PB15_PF_CSI_MCLK, |
| 138 | PB16_PF_CSI_PIXCLK, |
| 139 | PB17_PF_CSI_D5, |
| 140 | PB18_PF_CSI_D6, |
| 141 | PB19_PF_CSI_D7, |
| 142 | PB20_PF_CSI_VSYNC, |
| 143 | PB21_PF_CSI_HSYNC, |
Javier Martin | 435ca24 | 2012-04-10 11:26:59 +0200 | [diff] [blame] | 144 | /* mother board version */ |
| 145 | MOTHERBOARD_BIT2 | GPIO_GPIO | GPIO_IN | GPIO_PUEN, |
| 146 | MOTHERBOARD_BIT1 | GPIO_GPIO | GPIO_IN | GPIO_PUEN, |
| 147 | MOTHERBOARD_BIT0 | GPIO_GPIO | GPIO_IN | GPIO_PUEN, |
| 148 | /* expansion board version */ |
| 149 | EXPBOARD_BIT2 | GPIO_GPIO | GPIO_IN | GPIO_PUEN, |
| 150 | EXPBOARD_BIT1 | GPIO_GPIO | GPIO_IN | GPIO_PUEN, |
| 151 | EXPBOARD_BIT0 | GPIO_GPIO | GPIO_IN | GPIO_PUEN, |
Shawn Guo | d41789b | 2012-09-17 13:34:31 +0800 | [diff] [blame] | 152 | /* Audio AMP control */ |
| 153 | AMP_GAIN_0 | GPIO_GPIO | GPIO_OUT, |
| 154 | AMP_GAIN_1 | GPIO_GPIO | GPIO_OUT, |
| 155 | AMP_MUTE_SDL | GPIO_GPIO | GPIO_OUT, |
| 156 | AMP_MUTE_SDR | GPIO_GPIO | GPIO_OUT, |
Javier Martin | 435ca24 | 2012-04-10 11:26:59 +0200 | [diff] [blame] | 157 | }; |
| 158 | |
| 159 | static struct gpio visstrim_m10_version_gpios[] = { |
| 160 | { EXPBOARD_BIT0, GPIOF_IN, "exp-version-0" }, |
| 161 | { EXPBOARD_BIT1, GPIOF_IN, "exp-version-1" }, |
| 162 | { EXPBOARD_BIT2, GPIOF_IN, "exp-version-2" }, |
| 163 | { MOTHERBOARD_BIT0, GPIOF_IN, "mother-version-0" }, |
| 164 | { MOTHERBOARD_BIT1, GPIOF_IN, "mother-version-1" }, |
| 165 | { MOTHERBOARD_BIT2, GPIOF_IN, "mother-version-2" }, |
Javier Martin | 3b161e5 | 2010-07-30 10:06:01 +0200 | [diff] [blame] | 166 | }; |
| 167 | |
Javier Martin | 18847b4 | 2012-06-01 09:45:33 +0200 | [diff] [blame] | 168 | static const struct gpio visstrim_m10_gpios[] __initconst = { |
| 169 | { |
| 170 | .gpio = TVP5150_RSTN, |
| 171 | .flags = GPIOF_DIR_OUT | GPIOF_INIT_HIGH, |
| 172 | .label = "tvp5150_rstn", |
| 173 | }, |
| 174 | { |
| 175 | .gpio = TVP5150_PWDN, |
| 176 | .flags = GPIOF_DIR_OUT | GPIOF_INIT_LOW, |
| 177 | .label = "tvp5150_pwdn", |
| 178 | }, |
| 179 | { |
| 180 | .gpio = OTG_PHY_CS_GPIO, |
| 181 | .flags = GPIOF_DIR_OUT | GPIOF_INIT_LOW, |
| 182 | .label = "usbotg_cs", |
| 183 | }, |
Shawn Guo | d41789b | 2012-09-17 13:34:31 +0800 | [diff] [blame] | 184 | { |
| 185 | .gpio = AMP_GAIN_0, |
| 186 | .flags = GPIOF_DIR_OUT, |
| 187 | .label = "amp-gain-0", |
| 188 | }, |
| 189 | { |
| 190 | .gpio = AMP_GAIN_1, |
| 191 | .flags = GPIOF_DIR_OUT, |
| 192 | .label = "amp-gain-1", |
| 193 | }, |
| 194 | { |
| 195 | .gpio = AMP_MUTE_SDL, |
| 196 | .flags = GPIOF_DIR_OUT, |
| 197 | .label = "amp-mute-sdl", |
| 198 | }, |
| 199 | { |
| 200 | .gpio = AMP_MUTE_SDR, |
| 201 | .flags = GPIOF_DIR_OUT, |
| 202 | .label = "amp-mute-sdr", |
| 203 | }, |
Javier Martin | 18847b4 | 2012-06-01 09:45:33 +0200 | [diff] [blame] | 204 | }; |
| 205 | |
Javier Martin | f52f5a5 | 2012-02-28 17:31:51 +0100 | [diff] [blame] | 206 | /* Camera */ |
| 207 | static int visstrim_camera_power(struct device *dev, int on) |
| 208 | { |
| 209 | gpio_set_value(TVP5150_PWDN, on); |
| 210 | |
| 211 | return 0; |
| 212 | }; |
| 213 | |
| 214 | static int visstrim_camera_reset(struct device *dev) |
| 215 | { |
| 216 | gpio_set_value(TVP5150_RSTN, 0); |
| 217 | ndelay(500); |
| 218 | gpio_set_value(TVP5150_RSTN, 1); |
| 219 | |
| 220 | return 0; |
| 221 | }; |
| 222 | |
| 223 | static struct i2c_board_info visstrim_i2c_camera = { |
| 224 | I2C_BOARD_INFO("tvp5150", 0x5d), |
| 225 | }; |
| 226 | |
| 227 | static struct soc_camera_link iclink_tvp5150 = { |
| 228 | .bus_id = 0, |
| 229 | .board_info = &visstrim_i2c_camera, |
| 230 | .i2c_adapter_id = 0, |
| 231 | .power = visstrim_camera_power, |
| 232 | .reset = visstrim_camera_reset, |
| 233 | }; |
| 234 | |
| 235 | static struct mx2_camera_platform_data visstrim_camera = { |
| 236 | .flags = MX2_CAMERA_CCIR | MX2_CAMERA_CCIR_INTERLACE | |
Javier Martin | 5ff203b | 2012-03-26 09:17:47 -0300 | [diff] [blame] | 237 | MX2_CAMERA_PCLK_SAMPLE_RISING, |
Javier Martin | f52f5a5 | 2012-02-28 17:31:51 +0100 | [diff] [blame] | 238 | .clk = 100000, |
| 239 | }; |
| 240 | |
| 241 | static phys_addr_t mx2_camera_base __initdata; |
| 242 | #define MX2_CAMERA_BUF_SIZE SZ_8M |
| 243 | |
Javier Martin | 038bdf6 | 2012-08-20 12:13:01 +0200 | [diff] [blame] | 244 | static void __init visstrim_analog_camera_init(void) |
Javier Martin | f52f5a5 | 2012-02-28 17:31:51 +0100 | [diff] [blame] | 245 | { |
| 246 | struct platform_device *pdev; |
| 247 | int dma; |
| 248 | |
Javier Martin | f52f5a5 | 2012-02-28 17:31:51 +0100 | [diff] [blame] | 249 | gpio_set_value(TVP5150_PWDN, 1); |
| 250 | ndelay(1); |
| 251 | gpio_set_value(TVP5150_RSTN, 0); |
| 252 | ndelay(500); |
| 253 | gpio_set_value(TVP5150_RSTN, 1); |
| 254 | ndelay(200000); |
| 255 | |
| 256 | pdev = imx27_add_mx2_camera(&visstrim_camera); |
| 257 | if (IS_ERR(pdev)) |
| 258 | return; |
| 259 | |
| 260 | dma = dma_declare_coherent_memory(&pdev->dev, |
| 261 | mx2_camera_base, mx2_camera_base, |
| 262 | MX2_CAMERA_BUF_SIZE, |
| 263 | DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE); |
| 264 | if (!(dma & DMA_MEMORY_MAP)) |
| 265 | return; |
| 266 | } |
| 267 | |
| 268 | static void __init visstrim_reserve(void) |
| 269 | { |
| 270 | /* reserve 4 MiB for mx2-camera */ |
Javier Martin | 062a15c | 2012-07-26 05:57:30 -0300 | [diff] [blame] | 271 | mx2_camera_base = arm_memblock_steal(3 * MX2_CAMERA_BUF_SIZE, |
Javier Martin | f52f5a5 | 2012-02-28 17:31:51 +0100 | [diff] [blame] | 272 | MX2_CAMERA_BUF_SIZE); |
Javier Martin | f52f5a5 | 2012-02-28 17:31:51 +0100 | [diff] [blame] | 273 | } |
| 274 | |
Javier Martin | 3b161e5 | 2010-07-30 10:06:01 +0200 | [diff] [blame] | 275 | /* GPIOs used as events for applications */ |
| 276 | static struct gpio_keys_button visstrim_gpio_keys[] = { |
| 277 | { |
| 278 | .type = EV_KEY, |
| 279 | .code = KEY_RESTART, |
| 280 | .gpio = (GPIO_PORTC + 15), |
| 281 | .desc = "Default config", |
| 282 | .active_low = 0, |
| 283 | .wakeup = 1, |
| 284 | }, |
| 285 | { |
| 286 | .type = EV_KEY, |
| 287 | .code = KEY_RECORD, |
| 288 | .gpio = (GPIO_PORTF + 14), |
| 289 | .desc = "Record", |
| 290 | .active_low = 0, |
| 291 | .wakeup = 1, |
| 292 | }, |
| 293 | { |
| 294 | .type = EV_KEY, |
| 295 | .code = KEY_STOP, |
| 296 | .gpio = (GPIO_PORTF + 13), |
| 297 | .desc = "Stop", |
| 298 | .active_low = 0, |
| 299 | .wakeup = 1, |
| 300 | } |
| 301 | }; |
| 302 | |
Uwe Kleine-König | 5309498 | 2011-02-28 18:04:33 +0100 | [diff] [blame] | 303 | static const struct gpio_keys_platform_data |
| 304 | visstrim_gpio_keys_platform_data __initconst = { |
Javier Martin | 3b161e5 | 2010-07-30 10:06:01 +0200 | [diff] [blame] | 305 | .buttons = visstrim_gpio_keys, |
| 306 | .nbuttons = ARRAY_SIZE(visstrim_gpio_keys), |
| 307 | }; |
| 308 | |
Javier Martin | acb6464 | 2012-02-29 13:17:33 +0100 | [diff] [blame] | 309 | /* led */ |
| 310 | static const struct gpio_led visstrim_m10_leds[] __initconst = { |
| 311 | { |
| 312 | .name = "visstrim:ld0", |
| 313 | .default_trigger = "nand-disk", |
| 314 | .gpio = (GPIO_PORTC + 29), |
| 315 | }, |
| 316 | { |
| 317 | .name = "visstrim:ld1", |
| 318 | .default_trigger = "nand-disk", |
| 319 | .gpio = (GPIO_PORTC + 24), |
| 320 | }, |
| 321 | { |
| 322 | .name = "visstrim:ld2", |
| 323 | .default_trigger = "nand-disk", |
| 324 | .gpio = (GPIO_PORTC + 28), |
| 325 | }, |
| 326 | { |
| 327 | .name = "visstrim:ld3", |
| 328 | .default_trigger = "nand-disk", |
| 329 | .gpio = (GPIO_PORTC + 25), |
| 330 | }, |
| 331 | }; |
| 332 | |
| 333 | static const struct gpio_led_platform_data visstrim_m10_led_data __initconst = { |
| 334 | .leds = visstrim_m10_leds, |
| 335 | .num_leds = ARRAY_SIZE(visstrim_m10_leds), |
| 336 | }; |
| 337 | |
Javier Martin | 3b161e5 | 2010-07-30 10:06:01 +0200 | [diff] [blame] | 338 | /* Visstrim_SM10 has a microSD slot connected to sdhc1 */ |
| 339 | static int visstrim_m10_sdhc1_init(struct device *dev, |
| 340 | irq_handler_t detect_irq, void *data) |
| 341 | { |
| 342 | int ret; |
| 343 | |
Shawn Guo | 438196c | 2011-12-05 10:12:28 +0800 | [diff] [blame] | 344 | ret = request_irq(gpio_to_irq(SDHC1_IRQ_GPIO), detect_irq, |
| 345 | IRQF_TRIGGER_FALLING, "mmc-detect", data); |
Javier Martin | 3b161e5 | 2010-07-30 10:06:01 +0200 | [diff] [blame] | 346 | return ret; |
| 347 | } |
| 348 | |
| 349 | static void visstrim_m10_sdhc1_exit(struct device *dev, void *data) |
| 350 | { |
Shawn Guo | 438196c | 2011-12-05 10:12:28 +0800 | [diff] [blame] | 351 | free_irq(gpio_to_irq(SDHC1_IRQ_GPIO), data); |
Javier Martin | 3b161e5 | 2010-07-30 10:06:01 +0200 | [diff] [blame] | 352 | } |
| 353 | |
Uwe Kleine-König | 9d3d945 | 2010-11-05 17:26:09 +0100 | [diff] [blame] | 354 | static const struct imxmmc_platform_data visstrim_m10_sdhc_pdata __initconst = { |
Javier Martin | 3b161e5 | 2010-07-30 10:06:01 +0200 | [diff] [blame] | 355 | .init = visstrim_m10_sdhc1_init, |
| 356 | .exit = visstrim_m10_sdhc1_exit, |
| 357 | }; |
| 358 | |
| 359 | /* Visstrim_SM10 NOR flash */ |
| 360 | static struct physmap_flash_data visstrim_m10_flash_data = { |
| 361 | .width = 2, |
| 362 | }; |
| 363 | |
| 364 | static struct resource visstrim_m10_flash_resource = { |
| 365 | .start = 0xc0000000, |
| 366 | .end = 0xc0000000 + SZ_64M - 1, |
| 367 | .flags = IORESOURCE_MEM, |
| 368 | }; |
| 369 | |
| 370 | static struct platform_device visstrim_m10_nor_mtd_device = { |
| 371 | .name = "physmap-flash", |
| 372 | .id = 0, |
| 373 | .dev = { |
| 374 | .platform_data = &visstrim_m10_flash_data, |
| 375 | }, |
| 376 | .num_resources = 1, |
| 377 | .resource = &visstrim_m10_flash_resource, |
| 378 | }; |
| 379 | |
| 380 | static struct platform_device *platform_devices[] __initdata = { |
Javier Martin | 3b161e5 | 2010-07-30 10:06:01 +0200 | [diff] [blame] | 381 | &visstrim_m10_nor_mtd_device, |
Javier Martin | 3b161e5 | 2010-07-30 10:06:01 +0200 | [diff] [blame] | 382 | }; |
| 383 | |
| 384 | /* Visstrim_M10 uses UART0 as console */ |
| 385 | static const struct imxuart_platform_data uart_pdata __initconst = { |
| 386 | .flags = IMXUART_HAVE_RTSCTS, |
| 387 | }; |
| 388 | |
| 389 | /* I2C */ |
| 390 | static const struct imxi2c_platform_data visstrim_m10_i2c_data __initconst = { |
| 391 | .bitrate = 100000, |
| 392 | }; |
| 393 | |
| 394 | static struct pca953x_platform_data visstrim_m10_pca9555_pdata = { |
| 395 | .gpio_base = 240, /* After MX27 internal GPIOs */ |
| 396 | .invert = 0, |
| 397 | }; |
| 398 | |
Javier Martin | c86566b | 2011-06-07 17:37:18 +0200 | [diff] [blame] | 399 | static struct aic32x4_pdata visstrim_m10_aic32x4_pdata = { |
| 400 | .power_cfg = AIC32X4_PWR_MICBIAS_2075_LDOIN | |
| 401 | AIC32X4_PWR_AVDD_DVDD_WEAK_DISABLE | |
| 402 | AIC32X4_PWR_AIC32X4_LDO_ENABLE | |
| 403 | AIC32X4_PWR_CMMODE_LDOIN_RANGE_18_36 | |
| 404 | AIC32X4_PWR_CMMODE_HP_LDOIN_POWERED, |
| 405 | .micpga_routing = AIC32X4_MICPGA_ROUTE_LMIC_IN2R_10K | |
| 406 | AIC32X4_MICPGA_ROUTE_RMIC_IN1L_10K, |
| 407 | .swapdacs = false, |
| 408 | }; |
| 409 | |
Javier Martin | 3b161e5 | 2010-07-30 10:06:01 +0200 | [diff] [blame] | 410 | static struct i2c_board_info visstrim_m10_i2c_devices[] = { |
| 411 | { |
| 412 | I2C_BOARD_INFO("pca9555", 0x20), |
| 413 | .platform_data = &visstrim_m10_pca9555_pdata, |
| 414 | }, |
Javier Martin | a5e2051 | 2011-03-01 15:02:08 +0100 | [diff] [blame] | 415 | { |
| 416 | I2C_BOARD_INFO("tlv320aic32x4", 0x18), |
Javier Martin | c86566b | 2011-06-07 17:37:18 +0200 | [diff] [blame] | 417 | .platform_data = &visstrim_m10_aic32x4_pdata, |
Javier Martin | 257b49c | 2012-02-28 11:16:59 +0100 | [diff] [blame] | 418 | }, |
| 419 | { |
| 420 | I2C_BOARD_INFO("m41t00", 0x68), |
Javier Martin | a5e2051 | 2011-03-01 15:02:08 +0100 | [diff] [blame] | 421 | } |
Javier Martin | 3b161e5 | 2010-07-30 10:06:01 +0200 | [diff] [blame] | 422 | }; |
| 423 | |
| 424 | /* USB OTG */ |
| 425 | static int otg_phy_init(struct platform_device *pdev) |
| 426 | { |
Sascha Hauer | 4bd597b | 2011-01-03 11:30:28 +0100 | [diff] [blame] | 427 | return mx27_initialize_usb_hw(pdev->id, MXC_EHCI_POWER_PINS_ENABLED); |
Javier Martin | 3b161e5 | 2010-07-30 10:06:01 +0200 | [diff] [blame] | 428 | } |
| 429 | |
Uwe Kleine-König | 2eb42d5 | 2010-11-05 18:52:09 +0100 | [diff] [blame] | 430 | static const struct mxc_usbh_platform_data |
| 431 | visstrim_m10_usbotg_pdata __initconst = { |
Javier Martin | 3b161e5 | 2010-07-30 10:06:01 +0200 | [diff] [blame] | 432 | .init = otg_phy_init, |
| 433 | .portsc = MXC_EHCI_MODE_ULPI | MXC_EHCI_UTMI_8BIT, |
Javier Martin | 3b161e5 | 2010-07-30 10:06:01 +0200 | [diff] [blame] | 434 | }; |
| 435 | |
Javier Martin | a5e2051 | 2011-03-01 15:02:08 +0100 | [diff] [blame] | 436 | /* SSI */ |
| 437 | static const struct imx_ssi_platform_data visstrim_m10_ssi_pdata __initconst = { |
| 438 | .flags = IMX_SSI_DMA | IMX_SSI_SYN, |
| 439 | }; |
| 440 | |
Javier Martin | b6c14dc | 2012-07-26 05:54:19 -0300 | [diff] [blame] | 441 | /* coda */ |
| 442 | |
| 443 | static void __init visstrim_coda_init(void) |
| 444 | { |
| 445 | struct platform_device *pdev; |
| 446 | int dma; |
| 447 | |
| 448 | pdev = imx27_add_coda(); |
| 449 | dma = dma_declare_coherent_memory(&pdev->dev, |
| 450 | mx2_camera_base + MX2_CAMERA_BUF_SIZE, |
| 451 | mx2_camera_base + MX2_CAMERA_BUF_SIZE, |
| 452 | MX2_CAMERA_BUF_SIZE, |
| 453 | DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE); |
| 454 | if (!(dma & DMA_MEMORY_MAP)) |
| 455 | return; |
| 456 | } |
| 457 | |
Javier Martin | 062a15c | 2012-07-26 05:57:30 -0300 | [diff] [blame] | 458 | /* DMA deinterlace */ |
| 459 | static struct platform_device visstrim_deinterlace = { |
| 460 | .name = "m2m-deinterlace", |
| 461 | .id = 0, |
| 462 | }; |
| 463 | |
| 464 | static void __init visstrim_deinterlace_init(void) |
| 465 | { |
| 466 | int ret = -ENOMEM; |
| 467 | struct platform_device *pdev = &visstrim_deinterlace; |
| 468 | int dma; |
| 469 | |
| 470 | ret = platform_device_register(pdev); |
| 471 | |
| 472 | dma = dma_declare_coherent_memory(&pdev->dev, |
| 473 | mx2_camera_base + 2 * MX2_CAMERA_BUF_SIZE, |
| 474 | mx2_camera_base + 2 * MX2_CAMERA_BUF_SIZE, |
| 475 | MX2_CAMERA_BUF_SIZE, |
| 476 | DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE); |
| 477 | if (!(dma & DMA_MEMORY_MAP)) |
| 478 | return; |
| 479 | } |
| 480 | |
Javier Martin | 038bdf6 | 2012-08-20 12:13:01 +0200 | [diff] [blame] | 481 | /* Emma-PrP for format conversion */ |
| 482 | static void __init visstrim_emmaprp_init(void) |
| 483 | { |
| 484 | struct platform_device *pdev; |
| 485 | int dma; |
| 486 | |
| 487 | pdev = imx27_add_mx2_emmaprp(); |
| 488 | if (IS_ERR(pdev)) |
| 489 | return; |
| 490 | |
| 491 | /* |
| 492 | * Use the same memory area as the analog camera since both |
| 493 | * devices are, by nature, exclusive. |
| 494 | */ |
| 495 | dma = dma_declare_coherent_memory(&pdev->dev, |
| 496 | mx2_camera_base, mx2_camera_base, |
| 497 | MX2_CAMERA_BUF_SIZE, |
| 498 | DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE); |
| 499 | if (!(dma & DMA_MEMORY_MAP)) |
| 500 | pr_err("Failed to declare memory for emmaprp\n"); |
| 501 | } |
Javier Martin | 062a15c | 2012-07-26 05:57:30 -0300 | [diff] [blame] | 502 | |
Shawn Guo | d41789b | 2012-09-17 13:34:31 +0800 | [diff] [blame] | 503 | /* Audio */ |
| 504 | static const struct snd_mx27vis_platform_data snd_mx27vis_pdata __initconst = { |
| 505 | .amp_gain0_gpio = AMP_GAIN_0, |
| 506 | .amp_gain1_gpio = AMP_GAIN_1, |
| 507 | .amp_mutel_gpio = AMP_MUTE_SDL, |
| 508 | .amp_muter_gpio = AMP_MUTE_SDR, |
| 509 | }; |
| 510 | |
Javier Martin | 435ca24 | 2012-04-10 11:26:59 +0200 | [diff] [blame] | 511 | static void __init visstrim_m10_revision(void) |
| 512 | { |
| 513 | int exp_version = 0; |
| 514 | int mo_version = 0; |
| 515 | int ret; |
| 516 | |
| 517 | ret = gpio_request_array(visstrim_m10_version_gpios, |
| 518 | ARRAY_SIZE(visstrim_m10_version_gpios)); |
| 519 | if (ret) { |
| 520 | pr_err("Failed to request version gpios"); |
| 521 | return; |
| 522 | } |
| 523 | |
| 524 | /* Get expansion board version (negative logic) */ |
| 525 | exp_version |= !gpio_get_value(EXPBOARD_BIT2) << 2; |
| 526 | exp_version |= !gpio_get_value(EXPBOARD_BIT1) << 1; |
| 527 | exp_version |= !gpio_get_value(EXPBOARD_BIT0); |
| 528 | |
| 529 | /* Get mother board version (negative logic) */ |
| 530 | mo_version |= !gpio_get_value(MOTHERBOARD_BIT2) << 2; |
| 531 | mo_version |= !gpio_get_value(MOTHERBOARD_BIT1) << 1; |
| 532 | mo_version |= !gpio_get_value(MOTHERBOARD_BIT0); |
| 533 | |
| 534 | system_rev = 0x27000; |
Javier Martin | 038bdf6 | 2012-08-20 12:13:01 +0200 | [diff] [blame] | 535 | system_rev |= (mo_version << MOTHERBOARD_SHIFT); |
| 536 | system_rev |= (exp_version << EXPBOARD_SHIFT); |
Javier Martin | 435ca24 | 2012-04-10 11:26:59 +0200 | [diff] [blame] | 537 | } |
| 538 | |
Javier Martin | 3b161e5 | 2010-07-30 10:06:01 +0200 | [diff] [blame] | 539 | static void __init visstrim_m10_board_init(void) |
| 540 | { |
| 541 | int ret; |
Javier Martin | 038bdf6 | 2012-08-20 12:13:01 +0200 | [diff] [blame] | 542 | int mo_version; |
Javier Martin | 3b161e5 | 2010-07-30 10:06:01 +0200 | [diff] [blame] | 543 | |
Shawn Guo | b78d8e5 | 2011-06-06 00:07:55 +0800 | [diff] [blame] | 544 | imx27_soc_init(); |
Javier Martin | 435ca24 | 2012-04-10 11:26:59 +0200 | [diff] [blame] | 545 | visstrim_m10_revision(); |
Shawn Guo | b78d8e5 | 2011-06-06 00:07:55 +0800 | [diff] [blame] | 546 | |
Javier Martin | 3b161e5 | 2010-07-30 10:06:01 +0200 | [diff] [blame] | 547 | ret = mxc_gpio_setup_multiple_pins(visstrim_m10_pins, |
| 548 | ARRAY_SIZE(visstrim_m10_pins), "VISSTRIM_M10"); |
| 549 | if (ret) |
| 550 | pr_err("Failed to setup pins (%d)\n", ret); |
| 551 | |
Javier Martin | 18847b4 | 2012-06-01 09:45:33 +0200 | [diff] [blame] | 552 | ret = gpio_request_array(visstrim_m10_gpios, |
| 553 | ARRAY_SIZE(visstrim_m10_gpios)); |
| 554 | if (ret) |
| 555 | pr_err("Failed to request gpios (%d)\n", ret); |
| 556 | |
Javier Martin | a5e2051 | 2011-03-01 15:02:08 +0100 | [diff] [blame] | 557 | imx27_add_imx_ssi(0, &visstrim_m10_ssi_pdata); |
Javier Martin | 3b161e5 | 2010-07-30 10:06:01 +0200 | [diff] [blame] | 558 | imx27_add_imx_uart0(&uart_pdata); |
| 559 | |
Uwe Kleine-König | 77a406d | 2010-08-25 12:19:50 +0200 | [diff] [blame] | 560 | imx27_add_imx_i2c(0, &visstrim_m10_i2c_data); |
| 561 | imx27_add_imx_i2c(1, &visstrim_m10_i2c_data); |
Javier Martin | baa1dee | 2012-02-28 17:31:49 +0100 | [diff] [blame] | 562 | i2c_register_board_info(0, visstrim_m10_i2c_devices, |
| 563 | ARRAY_SIZE(visstrim_m10_i2c_devices)); |
| 564 | |
Uwe Kleine-König | 9d3d945 | 2010-11-05 17:26:09 +0100 | [diff] [blame] | 565 | imx27_add_mxc_mmc(0, &visstrim_m10_sdhc_pdata); |
Uwe Kleine-König | 2eb42d5 | 2010-11-05 18:52:09 +0100 | [diff] [blame] | 566 | imx27_add_mxc_ehci_otg(&visstrim_m10_usbotg_pdata); |
Uwe Kleine-König | 6bd96f3 | 2010-10-06 12:00:18 +0200 | [diff] [blame] | 567 | imx27_add_fec(NULL); |
Uwe Kleine-König | 5309498 | 2011-02-28 18:04:33 +0100 | [diff] [blame] | 568 | imx_add_gpio_keys(&visstrim_gpio_keys_platform_data); |
Javier Martin | 3b161e5 | 2010-07-30 10:06:01 +0200 | [diff] [blame] | 569 | platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices)); |
Shawn Guo | d41789b | 2012-09-17 13:34:31 +0800 | [diff] [blame] | 570 | imx_add_platform_device("mx27vis", 0, NULL, 0, &snd_mx27vis_pdata, |
| 571 | sizeof(snd_mx27vis_pdata)); |
Javier Martin | f52f5a5 | 2012-02-28 17:31:51 +0100 | [diff] [blame] | 572 | platform_device_register_resndata(NULL, "soc-camera-pdrv", 0, NULL, 0, |
| 573 | &iclink_tvp5150, sizeof(iclink_tvp5150)); |
Javier Martin | acb6464 | 2012-02-29 13:17:33 +0100 | [diff] [blame] | 574 | gpio_led_register_device(0, &visstrim_m10_led_data); |
Javier Martin | 038bdf6 | 2012-08-20 12:13:01 +0200 | [diff] [blame] | 575 | |
| 576 | /* Use mother board version to decide what video devices we shall use */ |
| 577 | mo_version = (system_rev >> MOTHERBOARD_SHIFT) & VERSION_MASK; |
| 578 | if (mo_version & 0x1) { |
| 579 | visstrim_emmaprp_init(); |
| 580 | |
| 581 | /* |
| 582 | * Despite not being used, tvp5150 must be |
| 583 | * powered on to avoid I2C problems. To minimize |
| 584 | * power consupmtion keep reset enabled. |
| 585 | */ |
| 586 | gpio_set_value(TVP5150_PWDN, 1); |
| 587 | ndelay(1); |
| 588 | gpio_set_value(TVP5150_RSTN, 0); |
| 589 | } else { |
| 590 | visstrim_deinterlace_init(); |
| 591 | visstrim_analog_camera_init(); |
| 592 | } |
Javier Martin | b6c14dc | 2012-07-26 05:54:19 -0300 | [diff] [blame] | 593 | visstrim_coda_init(); |
Javier Martin | 3b161e5 | 2010-07-30 10:06:01 +0200 | [diff] [blame] | 594 | } |
| 595 | |
| 596 | static void __init visstrim_m10_timer_init(void) |
| 597 | { |
| 598 | mx27_clocks_init((unsigned long)25000000); |
| 599 | } |
| 600 | |
Javier Martin | 3b161e5 | 2010-07-30 10:06:01 +0200 | [diff] [blame] | 601 | MACHINE_START(IMX27_VISSTRIM_M10, "Vista Silicon Visstrim_M10") |
Nicolas Pitre | dc8f190 | 2011-07-05 22:38:12 -0400 | [diff] [blame] | 602 | .atag_offset = 0x100, |
Javier Martin | f52f5a5 | 2012-02-28 17:31:51 +0100 | [diff] [blame] | 603 | .reserve = visstrim_reserve, |
Uwe Kleine-König | 3dac219 | 2011-02-07 16:35:19 +0100 | [diff] [blame] | 604 | .map_io = mx27_map_io, |
| 605 | .init_early = imx27_init_early, |
| 606 | .init_irq = mx27_init_irq, |
Sascha Hauer | ffa2ea3 | 2011-09-20 14:31:24 +0200 | [diff] [blame] | 607 | .handle_irq = imx27_handle_irq, |
Stephen Warren | 6bb27d7 | 2012-11-08 12:40:59 -0700 | [diff] [blame] | 608 | .init_time = visstrim_m10_timer_init, |
Uwe Kleine-König | 3dac219 | 2011-02-07 16:35:19 +0100 | [diff] [blame] | 609 | .init_machine = visstrim_m10_board_init, |
Russell King | 65ea788 | 2011-11-06 17:12:08 +0000 | [diff] [blame] | 610 | .restart = mxc_restart, |
Javier Martin | 3b161e5 | 2010-07-30 10:06:01 +0200 | [diff] [blame] | 611 | MACHINE_END |