2 * mach-imx27_visstrim_m10.c
4 * Copyright 2010 Javier Martin <javier.martin@vista-silicon.com>
6 * Based on mach-pcm038.c, mach-pca100.c, mach-mx27ads.c and others.
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.
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.
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,
24 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
26 #include <linux/platform_device.h>
27 #include <linux/mtd/physmap.h>
28 #include <linux/i2c.h>
29 #include <linux/i2c/pca953x.h>
30 #include <linux/input.h>
31 #include <linux/gpio.h>
32 #include <linux/delay.h>
33 #include <linux/dma-mapping.h>
34 #include <linux/leds.h>
35 #include <linux/memblock.h>
36 #include <media/soc_camera.h>
37 #include <sound/tlv320aic32x4.h>
38 #include <asm/mach-types.h>
39 #include <asm/mach/arch.h>
40 #include <asm/mach/time.h>
41 #include <mach/common.h>
42 #include <mach/iomux-mx27.h>
44 #include "devices-imx27.h"
46 #define TVP5150_RSTN (GPIO_PORTC + 18)
47 #define TVP5150_PWDN (GPIO_PORTC + 19)
48 #define OTG_PHY_CS_GPIO (GPIO_PORTF + 17)
49 #define SDHC1_IRQ IRQ_GPIOB(25)
51 static const int visstrim_m10_pins
[] __initconst
= {
94 OTG_PHY_CS_GPIO
| GPIO_GPIO
| GPIO_OUT
,
102 PE25_PF_USBOTG_DATA7
,
125 static int visstrim_camera_power(struct device
*dev
, int on
)
127 gpio_set_value(TVP5150_PWDN
, on
);
132 static int visstrim_camera_reset(struct device
*dev
)
134 gpio_set_value(TVP5150_RSTN
, 0);
136 gpio_set_value(TVP5150_RSTN
, 1);
141 static struct i2c_board_info visstrim_i2c_camera
= {
142 I2C_BOARD_INFO("tvp5150", 0x5d),
145 static struct soc_camera_link iclink_tvp5150
= {
147 .board_info
= &visstrim_i2c_camera
,
149 .power
= visstrim_camera_power
,
150 .reset
= visstrim_camera_reset
,
153 static struct mx2_camera_platform_data visstrim_camera
= {
154 .flags
= MX2_CAMERA_CCIR
| MX2_CAMERA_CCIR_INTERLACE
|
155 MX2_CAMERA_SWAP16
| MX2_CAMERA_PCLK_SAMPLE_RISING
,
159 static phys_addr_t mx2_camera_base __initdata
;
160 #define MX2_CAMERA_BUF_SIZE SZ_8M
162 static void __init
visstrim_camera_init(void)
164 struct platform_device
*pdev
;
167 /* Initialize tvp5150 gpios */
168 mxc_gpio_mode(TVP5150_RSTN
| GPIO_GPIO
| GPIO_OUT
);
169 mxc_gpio_mode(TVP5150_PWDN
| GPIO_GPIO
| GPIO_OUT
);
170 gpio_set_value(TVP5150_RSTN
, 1);
171 gpio_set_value(TVP5150_PWDN
, 0);
174 gpio_set_value(TVP5150_PWDN
, 1);
176 gpio_set_value(TVP5150_RSTN
, 0);
178 gpio_set_value(TVP5150_RSTN
, 1);
181 pdev
= imx27_add_mx2_camera(&visstrim_camera
);
185 dma
= dma_declare_coherent_memory(&pdev
->dev
,
186 mx2_camera_base
, mx2_camera_base
,
188 DMA_MEMORY_MAP
| DMA_MEMORY_EXCLUSIVE
);
189 if (!(dma
& DMA_MEMORY_MAP
))
193 static void __init
visstrim_reserve(void)
195 /* reserve 4 MiB for mx2-camera */
196 mx2_camera_base
= memblock_alloc(MX2_CAMERA_BUF_SIZE
,
197 MX2_CAMERA_BUF_SIZE
);
198 memblock_free(mx2_camera_base
, MX2_CAMERA_BUF_SIZE
);
199 memblock_remove(mx2_camera_base
, MX2_CAMERA_BUF_SIZE
);
202 /* GPIOs used as events for applications */
203 static struct gpio_keys_button visstrim_gpio_keys
[] = {
207 .gpio
= (GPIO_PORTC
+ 15),
208 .desc
= "Default config",
215 .gpio
= (GPIO_PORTF
+ 14),
223 .gpio
= (GPIO_PORTF
+ 13),
230 static const struct gpio_keys_platform_data
231 visstrim_gpio_keys_platform_data __initconst
= {
232 .buttons
= visstrim_gpio_keys
,
233 .nbuttons
= ARRAY_SIZE(visstrim_gpio_keys
),
237 static const struct gpio_led visstrim_m10_leds
[] __initconst
= {
239 .name
= "visstrim:ld0",
240 .default_trigger
= "nand-disk",
241 .gpio
= (GPIO_PORTC
+ 29),
244 .name
= "visstrim:ld1",
245 .default_trigger
= "nand-disk",
246 .gpio
= (GPIO_PORTC
+ 24),
249 .name
= "visstrim:ld2",
250 .default_trigger
= "nand-disk",
251 .gpio
= (GPIO_PORTC
+ 28),
254 .name
= "visstrim:ld3",
255 .default_trigger
= "nand-disk",
256 .gpio
= (GPIO_PORTC
+ 25),
260 static const struct gpio_led_platform_data visstrim_m10_led_data __initconst
= {
261 .leds
= visstrim_m10_leds
,
262 .num_leds
= ARRAY_SIZE(visstrim_m10_leds
),
265 /* Visstrim_SM10 has a microSD slot connected to sdhc1 */
266 static int visstrim_m10_sdhc1_init(struct device
*dev
,
267 irq_handler_t detect_irq
, void *data
)
271 ret
= request_irq(SDHC1_IRQ
, detect_irq
, IRQF_TRIGGER_FALLING
,
276 static void visstrim_m10_sdhc1_exit(struct device
*dev
, void *data
)
278 free_irq(SDHC1_IRQ
, data
);
281 static const struct imxmmc_platform_data visstrim_m10_sdhc_pdata __initconst
= {
282 .init
= visstrim_m10_sdhc1_init
,
283 .exit
= visstrim_m10_sdhc1_exit
,
286 /* Visstrim_SM10 NOR flash */
287 static struct physmap_flash_data visstrim_m10_flash_data
= {
291 static struct resource visstrim_m10_flash_resource
= {
293 .end
= 0xc0000000 + SZ_64M
- 1,
294 .flags
= IORESOURCE_MEM
,
297 static struct platform_device visstrim_m10_nor_mtd_device
= {
298 .name
= "physmap-flash",
301 .platform_data
= &visstrim_m10_flash_data
,
304 .resource
= &visstrim_m10_flash_resource
,
307 static struct platform_device
*platform_devices
[] __initdata
= {
308 &visstrim_m10_nor_mtd_device
,
311 /* Visstrim_M10 uses UART0 as console */
312 static const struct imxuart_platform_data uart_pdata __initconst
= {
313 .flags
= IMXUART_HAVE_RTSCTS
,
317 static const struct imxi2c_platform_data visstrim_m10_i2c_data __initconst
= {
321 static struct pca953x_platform_data visstrim_m10_pca9555_pdata
= {
322 .gpio_base
= 240, /* After MX27 internal GPIOs */
326 static struct aic32x4_pdata visstrim_m10_aic32x4_pdata
= {
327 .power_cfg
= AIC32X4_PWR_MICBIAS_2075_LDOIN
|
328 AIC32X4_PWR_AVDD_DVDD_WEAK_DISABLE
|
329 AIC32X4_PWR_AIC32X4_LDO_ENABLE
|
330 AIC32X4_PWR_CMMODE_LDOIN_RANGE_18_36
|
331 AIC32X4_PWR_CMMODE_HP_LDOIN_POWERED
,
332 .micpga_routing
= AIC32X4_MICPGA_ROUTE_LMIC_IN2R_10K
|
333 AIC32X4_MICPGA_ROUTE_RMIC_IN1L_10K
,
337 static struct i2c_board_info visstrim_m10_i2c_devices
[] = {
339 I2C_BOARD_INFO("pca9555", 0x20),
340 .platform_data
= &visstrim_m10_pca9555_pdata
,
343 I2C_BOARD_INFO("tlv320aic32x4", 0x18),
344 .platform_data
= &visstrim_m10_aic32x4_pdata
,
347 I2C_BOARD_INFO("m41t00", 0x68),
352 static int otg_phy_init(struct platform_device
*pdev
)
354 gpio_set_value(OTG_PHY_CS_GPIO
, 0);
358 return mx27_initialize_usb_hw(pdev
->id
, MXC_EHCI_POWER_PINS_ENABLED
);
361 static const struct mxc_usbh_platform_data
362 visstrim_m10_usbotg_pdata __initconst
= {
363 .init
= otg_phy_init
,
364 .portsc
= MXC_EHCI_MODE_ULPI
| MXC_EHCI_UTMI_8BIT
,
368 static const struct imx_ssi_platform_data visstrim_m10_ssi_pdata __initconst
= {
369 .flags
= IMX_SSI_DMA
| IMX_SSI_SYN
,
372 static void __init
visstrim_m10_board_init(void)
378 ret
= mxc_gpio_setup_multiple_pins(visstrim_m10_pins
,
379 ARRAY_SIZE(visstrim_m10_pins
), "VISSTRIM_M10");
381 pr_err("Failed to setup pins (%d)\n", ret
);
383 imx27_add_imx_ssi(0, &visstrim_m10_ssi_pdata
);
384 imx27_add_imx_uart0(&uart_pdata
);
386 imx27_add_imx_i2c(0, &visstrim_m10_i2c_data
);
387 imx27_add_imx_i2c(1, &visstrim_m10_i2c_data
);
388 i2c_register_board_info(0, visstrim_m10_i2c_devices
,
389 ARRAY_SIZE(visstrim_m10_i2c_devices
));
391 imx27_add_mxc_mmc(0, &visstrim_m10_sdhc_pdata
);
392 imx27_add_mxc_ehci_otg(&visstrim_m10_usbotg_pdata
);
394 imx_add_gpio_keys(&visstrim_gpio_keys_platform_data
);
395 platform_add_devices(platform_devices
, ARRAY_SIZE(platform_devices
));
396 imx_add_platform_device("mx27vis", 0, NULL
, 0, NULL
, 0);
397 platform_device_register_resndata(NULL
, "soc-camera-pdrv", 0, NULL
, 0,
398 &iclink_tvp5150
, sizeof(iclink_tvp5150
));
399 gpio_led_register_device(0, &visstrim_m10_led_data
);
400 visstrim_camera_init();
403 static void __init
visstrim_m10_timer_init(void)
405 mx27_clocks_init((unsigned long)25000000);
408 static struct sys_timer visstrim_m10_timer
= {
409 .init
= visstrim_m10_timer_init
,
412 MACHINE_START(IMX27_VISSTRIM_M10
, "Vista Silicon Visstrim_M10")
413 .atag_offset
= 0x100,
414 .reserve
= visstrim_reserve
,
415 .map_io
= mx27_map_io
,
416 .init_early
= imx27_init_early
,
417 .init_irq
= mx27_init_irq
,
418 .handle_irq
= imx27_handle_irq
,
419 .timer
= &visstrim_m10_timer
,
420 .init_machine
= visstrim_m10_board_init
,
421 .restart
= mxc_restart
,