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