From e93d7a73b0e4e11cc44d866269738da7f2717bd4 Mon Sep 17 00:00:00 2001 From: Luotao Fu Date: Tue, 19 May 2009 13:40:28 +0200 Subject: mx31: add mt9m001 and mt9v022 CMOS camera to PCM037 board Signed-off-by: Luotao Fu Signed-off-by: Sascha Hauer --- arch/arm/mach-mx3/pcm037.c | 62 ++++++++++++++++++++++++++++++++--- arch/arm/plat-mxc/include/mach/mx3x.h | 3 -- 2 files changed, 57 insertions(+), 8 deletions(-) diff --git a/arch/arm/mach-mx3/pcm037.c b/arch/arm/mach-mx3/pcm037.c index f7a870382fc..8dadbc8ade3 100644 --- a/arch/arm/mach-mx3/pcm037.c +++ b/arch/arm/mach-mx3/pcm037.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -280,16 +281,67 @@ static int pcm037_camera_power(struct device *dev, int on) gpio_set_value(IOMUX_TO_GPIO(MX31_PIN_CSI_D5), !on); return 0; } +/* count of GPIOs that are occupied by the CPU itself */ +#define MAX_INTERNAL_GPIO 96 +static int gpio_bus_switch; -static struct soc_camera_link iclink = { - .bus_id = 0, /* Must match with the camera ID */ - .power = pcm037_camera_power, +static unsigned long pcm037_camera_query_bus_param(struct soc_camera_link *link) +{ + int ret; + + if (!gpio_bus_switch) { + ret = gpio_request(MAX_INTERNAL_GPIO, "camera"); + if (!ret) { + gpio_bus_switch = MAX_INTERNAL_GPIO; + gpio_direction_output(gpio_bus_switch, 0); + } else + gpio_bus_switch = -EINVAL; + } + + return SOCAM_DATAWIDTH_10; +} + +static int pcm037_camera_set_bus_param(struct soc_camera_link *link, + unsigned long flags) +{ + return 0; +} + +static struct soc_camera_link iclink[] = { + { + .bus_id = 0, /* Must match with the camera ID */ + .query_bus_param = pcm037_camera_query_bus_param, + .set_bus_param = pcm037_camera_set_bus_param, + .power = pcm037_camera_power, + + }, { + .bus_id = 0, /* Must match with the camera ID */ + .query_bus_param = pcm037_camera_query_bus_param, + .set_bus_param = pcm037_camera_set_bus_param, + .power = pcm037_camera_power, + .flags = SOCAM_SENSOR_INVERT_PCLK, + } +}; + +/* count of GPIOs that are occupied by the CPU itself */ +#define MAX_INTERNAL_GPIO 96 + +static struct pca953x_platform_data pca9536_data = { + .gpio_base = MAX_INTERNAL_GPIO, }; static struct i2c_board_info pcm037_i2c_2_devices[] = { { - I2C_BOARD_INFO("mt9t031", 0x5d), - .platform_data = &iclink, + /* Must initialize before the camera(s) */ + I2C_BOARD_INFO("pca953x", 0x41), + .type = "pca9536", + .platform_data = &pca9536_data, + }, { + I2C_BOARD_INFO("mt9m001", 0x5d), + .platform_data = &iclink[0], + }, { + I2C_BOARD_INFO("mt9v022", 0x48), + .platform_data = &iclink[1], /* mt9v022 needs pclk inversion*/ }, }; diff --git a/arch/arm/plat-mxc/include/mach/mx3x.h b/arch/arm/plat-mxc/include/mach/mx3x.h index 3878c6085d5..c9fc99f4e1c 100644 --- a/arch/arm/plat-mxc/include/mach/mx3x.h +++ b/arch/arm/plat-mxc/include/mach/mx3x.h @@ -273,9 +273,6 @@ /* Mandatory defines used globally */ -/* this CPU supports up to 96 GPIOs */ -#define ARCH_NR_GPIOS 96 - #if !defined(__ASSEMBLY__) && !defined(__MXC_BOOT_UNCOMPRESS) extern unsigned int system_rev; -- cgit v1.2.3