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
,
110 TVP5150_RSTN
| GPIO_GPIO
| GPIO_OUT
,
111 TVP5150_PWDN
| GPIO_GPIO
| GPIO_OUT
,
126 static const struct gpio visstrim_m10_gpios
[] __initconst
= {
128 .gpio
= TVP5150_RSTN
,
129 .flags
= GPIOF_DIR_OUT
| GPIOF_INIT_HIGH
,
130 .label
= "tvp5150_rstn",
133 .gpio
= TVP5150_PWDN
,
134 .flags
= GPIOF_DIR_OUT
| GPIOF_INIT_LOW
,
135 .label
= "tvp5150_pwdn",
138 .gpio
= OTG_PHY_CS_GPIO
,
139 .flags
= GPIOF_DIR_OUT
| GPIOF_INIT_LOW
,
140 .label
= "usbotg_cs",
145 static int visstrim_camera_power(struct device
*dev
, int on
)
147 gpio_set_value(TVP5150_PWDN
, on
);
152 static int visstrim_camera_reset(struct device
*dev
)
154 gpio_set_value(TVP5150_RSTN
, 0);
156 gpio_set_value(TVP5150_RSTN
, 1);
161 static struct i2c_board_info visstrim_i2c_camera
= {
162 I2C_BOARD_INFO("tvp5150", 0x5d),
165 static struct soc_camera_link iclink_tvp5150
= {
167 .board_info
= &visstrim_i2c_camera
,
169 .power
= visstrim_camera_power
,
170 .reset
= visstrim_camera_reset
,
173 static struct mx2_camera_platform_data visstrim_camera
= {
174 .flags
= MX2_CAMERA_CCIR
| MX2_CAMERA_CCIR_INTERLACE
|
175 MX2_CAMERA_SWAP16
| MX2_CAMERA_PCLK_SAMPLE_RISING
,
179 static phys_addr_t mx2_camera_base __initdata
;
180 #define MX2_CAMERA_BUF_SIZE SZ_8M
182 static void __init
visstrim_camera_init(void)
184 struct platform_device
*pdev
;
187 gpio_set_value(TVP5150_PWDN
, 1);
189 gpio_set_value(TVP5150_RSTN
, 0);
191 gpio_set_value(TVP5150_RSTN
, 1);
194 pdev
= imx27_add_mx2_camera(&visstrim_camera
);
198 dma
= dma_declare_coherent_memory(&pdev
->dev
,
199 mx2_camera_base
, mx2_camera_base
,
201 DMA_MEMORY_MAP
| DMA_MEMORY_EXCLUSIVE
);
202 if (!(dma
& DMA_MEMORY_MAP
))
206 static void __init
visstrim_reserve(void)
208 /* reserve 4 MiB for mx2-camera */
209 mx2_camera_base
= memblock_alloc(MX2_CAMERA_BUF_SIZE
,
210 MX2_CAMERA_BUF_SIZE
);
211 memblock_free(mx2_camera_base
, MX2_CAMERA_BUF_SIZE
);
212 memblock_remove(mx2_camera_base
, MX2_CAMERA_BUF_SIZE
);
215 /* GPIOs used as events for applications */
216 static struct gpio_keys_button visstrim_gpio_keys
[] = {
220 .gpio
= (GPIO_PORTC
+ 15),
221 .desc
= "Default config",
228 .gpio
= (GPIO_PORTF
+ 14),
236 .gpio
= (GPIO_PORTF
+ 13),
243 static const struct gpio_keys_platform_data
244 visstrim_gpio_keys_platform_data __initconst
= {
245 .buttons
= visstrim_gpio_keys
,
246 .nbuttons
= ARRAY_SIZE(visstrim_gpio_keys
),
250 static const struct gpio_led visstrim_m10_leds
[] __initconst
= {
252 .name
= "visstrim:ld0",
253 .default_trigger
= "nand-disk",
254 .gpio
= (GPIO_PORTC
+ 29),
257 .name
= "visstrim:ld1",
258 .default_trigger
= "nand-disk",
259 .gpio
= (GPIO_PORTC
+ 24),
262 .name
= "visstrim:ld2",
263 .default_trigger
= "nand-disk",
264 .gpio
= (GPIO_PORTC
+ 28),
267 .name
= "visstrim:ld3",
268 .default_trigger
= "nand-disk",
269 .gpio
= (GPIO_PORTC
+ 25),
273 static const struct gpio_led_platform_data visstrim_m10_led_data __initconst
= {
274 .leds
= visstrim_m10_leds
,
275 .num_leds
= ARRAY_SIZE(visstrim_m10_leds
),
278 /* Visstrim_SM10 has a microSD slot connected to sdhc1 */
279 static int visstrim_m10_sdhc1_init(struct device
*dev
,
280 irq_handler_t detect_irq
, void *data
)
284 ret
= request_irq(SDHC1_IRQ
, detect_irq
, IRQF_TRIGGER_FALLING
,
289 static void visstrim_m10_sdhc1_exit(struct device
*dev
, void *data
)
291 free_irq(SDHC1_IRQ
, data
);
294 static const struct imxmmc_platform_data visstrim_m10_sdhc_pdata __initconst
= {
295 .init
= visstrim_m10_sdhc1_init
,
296 .exit
= visstrim_m10_sdhc1_exit
,
299 /* Visstrim_SM10 NOR flash */
300 static struct physmap_flash_data visstrim_m10_flash_data
= {
304 static struct resource visstrim_m10_flash_resource
= {
306 .end
= 0xc0000000 + SZ_64M
- 1,
307 .flags
= IORESOURCE_MEM
,
310 static struct platform_device visstrim_m10_nor_mtd_device
= {
311 .name
= "physmap-flash",
314 .platform_data
= &visstrim_m10_flash_data
,
317 .resource
= &visstrim_m10_flash_resource
,
320 static struct platform_device
*platform_devices
[] __initdata
= {
321 &visstrim_m10_nor_mtd_device
,
324 /* Visstrim_M10 uses UART0 as console */
325 static const struct imxuart_platform_data uart_pdata __initconst
= {
326 .flags
= IMXUART_HAVE_RTSCTS
,
330 static const struct imxi2c_platform_data visstrim_m10_i2c_data __initconst
= {
334 static struct pca953x_platform_data visstrim_m10_pca9555_pdata
= {
335 .gpio_base
= 240, /* After MX27 internal GPIOs */
339 static struct aic32x4_pdata visstrim_m10_aic32x4_pdata
= {
340 .power_cfg
= AIC32X4_PWR_MICBIAS_2075_LDOIN
|
341 AIC32X4_PWR_AVDD_DVDD_WEAK_DISABLE
|
342 AIC32X4_PWR_AIC32X4_LDO_ENABLE
|
343 AIC32X4_PWR_CMMODE_LDOIN_RANGE_18_36
|
344 AIC32X4_PWR_CMMODE_HP_LDOIN_POWERED
,
345 .micpga_routing
= AIC32X4_MICPGA_ROUTE_LMIC_IN2R_10K
|
346 AIC32X4_MICPGA_ROUTE_RMIC_IN1L_10K
,
350 static struct i2c_board_info visstrim_m10_i2c_devices
[] = {
352 I2C_BOARD_INFO("pca9555", 0x20),
353 .platform_data
= &visstrim_m10_pca9555_pdata
,
356 I2C_BOARD_INFO("tlv320aic32x4", 0x18),
357 .platform_data
= &visstrim_m10_aic32x4_pdata
,
360 I2C_BOARD_INFO("m41t00", 0x68),
365 static int otg_phy_init(struct platform_device
*pdev
)
367 return mx27_initialize_usb_hw(pdev
->id
, MXC_EHCI_POWER_PINS_ENABLED
);
370 static const struct mxc_usbh_platform_data
371 visstrim_m10_usbotg_pdata __initconst
= {
372 .init
= otg_phy_init
,
373 .portsc
= MXC_EHCI_MODE_ULPI
| MXC_EHCI_UTMI_8BIT
,
377 static const struct imx_ssi_platform_data visstrim_m10_ssi_pdata __initconst
= {
378 .flags
= IMX_SSI_DMA
| IMX_SSI_SYN
,
381 static void __init
visstrim_m10_board_init(void)
387 ret
= mxc_gpio_setup_multiple_pins(visstrim_m10_pins
,
388 ARRAY_SIZE(visstrim_m10_pins
), "VISSTRIM_M10");
390 pr_err("Failed to setup pins (%d)\n", ret
);
392 ret
= gpio_request_array(visstrim_m10_gpios
,
393 ARRAY_SIZE(visstrim_m10_gpios
));
395 pr_err("Failed to request gpios (%d)\n", ret
);
397 imx27_add_imx_ssi(0, &visstrim_m10_ssi_pdata
);
398 imx27_add_imx_uart0(&uart_pdata
);
400 imx27_add_imx_i2c(0, &visstrim_m10_i2c_data
);
401 imx27_add_imx_i2c(1, &visstrim_m10_i2c_data
);
402 i2c_register_board_info(0, visstrim_m10_i2c_devices
,
403 ARRAY_SIZE(visstrim_m10_i2c_devices
));
405 imx27_add_mxc_mmc(0, &visstrim_m10_sdhc_pdata
);
406 imx27_add_mxc_ehci_otg(&visstrim_m10_usbotg_pdata
);
408 imx_add_gpio_keys(&visstrim_gpio_keys_platform_data
);
409 platform_add_devices(platform_devices
, ARRAY_SIZE(platform_devices
));
410 imx_add_platform_device("mx27vis", 0, NULL
, 0, NULL
, 0);
411 platform_device_register_resndata(NULL
, "soc-camera-pdrv", 0, NULL
, 0,
412 &iclink_tvp5150
, sizeof(iclink_tvp5150
));
413 gpio_led_register_device(0, &visstrim_m10_led_data
);
414 visstrim_camera_init();
417 static void __init
visstrim_m10_timer_init(void)
419 mx27_clocks_init((unsigned long)25000000);
422 static struct sys_timer visstrim_m10_timer
= {
423 .init
= visstrim_m10_timer_init
,
426 MACHINE_START(IMX27_VISSTRIM_M10
, "Vista Silicon Visstrim_M10")
427 .atag_offset
= 0x100,
428 .reserve
= visstrim_reserve
,
429 .map_io
= mx27_map_io
,
430 .init_early
= imx27_init_early
,
431 .init_irq
= mx27_init_irq
,
432 .handle_irq
= imx27_handle_irq
,
433 .timer
= &visstrim_m10_timer
,
434 .init_machine
= visstrim_m10_board_init
,
435 .restart
= mxc_restart
,