diff options
Diffstat (limited to 'linux/arch/arm/mach-pxa/pcm990-baseboard.c')
-rw-r--r-- | linux/arch/arm/mach-pxa/pcm990-baseboard.c | 87 |
1 files changed, 56 insertions, 31 deletions
diff --git a/linux/arch/arm/mach-pxa/pcm990-baseboard.c b/linux/arch/arm/mach-pxa/pcm990-baseboard.c index 0d8acfc2d..01791d74e 100644 --- a/linux/arch/arm/mach-pxa/pcm990-baseboard.c +++ b/linux/arch/arm/mach-pxa/pcm990-baseboard.c @@ -22,40 +22,21 @@ #include <linux/irq.h> #include <linux/platform_device.h> -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 27) -#include <linux/ide.h> -#endif #include <linux/i2c.h> #include <linux/pwm_backlight.h> #include <media/soc_camera.h> #include <asm/gpio.h> -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 27) -#include <asm/arch/i2c.h> -#include <asm/arch/camera.h> -#else -#include <mach/i2c.h> +#include <plat/i2c.h> #include <mach/camera.h> -#endif #include <asm/mach/map.h> -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 27) -#include <asm/arch/pxa-regs.h> -#include <asm/arch/audio.h> -#include <asm/arch/mmc.h> -#include <asm/arch/ohci.h> -#include <asm/arch/pcm990_baseboard.h> -#include <asm/arch/pxafb.h> -#include <asm/arch/mfp-pxa27x.h> -#else -#include <mach/pxa-regs.h> +#include <mach/pxa27x.h> #include <mach/audio.h> #include <mach/mmc.h> #include <mach/ohci.h> #include <mach/pcm990_baseboard.h> #include <mach/pxafb.h> -#include <mach/mfp-pxa27x.h> -#endif #include "devices.h" #include "generic.h" @@ -396,17 +377,61 @@ struct pxacamera_platform_data pcm990_pxacamera_platform_data = { #include <linux/i2c/pca953x.h> static struct pca953x_platform_data pca9536_data = { - .gpio_base = NR_BUILTIN_GPIO + 1, + .gpio_base = NR_BUILTIN_GPIO, }; -static struct soc_camera_link iclink[] = { - { - .bus_id = 0, /* Must match with the camera ID above */ - .gpio = NR_BUILTIN_GPIO + 1, - }, { - .bus_id = 0, /* Must match with the camera ID above */ - .gpio = -ENXIO, +static int gpio_bus_switch = -EINVAL; + +static int pcm990_camera_set_bus_param(struct soc_camera_link *link, + unsigned long flags) +{ + if (gpio_bus_switch < 0) { + if (flags == SOCAM_DATAWIDTH_10) + return 0; + else + return -EINVAL; } + + if (flags & SOCAM_DATAWIDTH_8) + gpio_set_value(gpio_bus_switch, 1); + else + gpio_set_value(gpio_bus_switch, 0); + + return 0; +} + +static unsigned long pcm990_camera_query_bus_param(struct soc_camera_link *link) +{ + int ret; + + if (gpio_bus_switch < 0) { + ret = gpio_request(NR_BUILTIN_GPIO, "camera"); + if (!ret) { + gpio_bus_switch = NR_BUILTIN_GPIO; + gpio_direction_output(gpio_bus_switch, 0); + } + } + + if (gpio_bus_switch >= 0) + return SOCAM_DATAWIDTH_8 | SOCAM_DATAWIDTH_10; + else + return SOCAM_DATAWIDTH_10; +} + +static void pcm990_camera_free_bus(struct soc_camera_link *link) +{ + if (gpio_bus_switch < 0) + return; + + gpio_free(gpio_bus_switch); + gpio_bus_switch = -EINVAL; +} + +static struct soc_camera_link iclink = { + .bus_id = 0, /* Must match with the camera ID above */ + .query_bus_param = pcm990_camera_query_bus_param, + .set_bus_param = pcm990_camera_set_bus_param, + .free_bus = pcm990_camera_free_bus, }; /* Board I2C devices. */ @@ -417,10 +442,10 @@ static struct i2c_board_info __initdata pcm990_i2c_devices[] = { .platform_data = &pca9536_data, }, { I2C_BOARD_INFO("mt9v022", 0x48), - .platform_data = &iclink[0], /* With extender */ + .platform_data = &iclink, /* With extender */ }, { I2C_BOARD_INFO("mt9m001", 0x5d), - .platform_data = &iclink[0], /* With extender */ + .platform_data = &iclink, /* With extender */ }, }; #endif /* CONFIG_VIDEO_PXA27x ||CONFIG_VIDEO_PXA27x_MODULE */ |