From patchwork Mon Aug 17 23:19:06 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: m-karicheri2@ti.com X-Patchwork-Id: 1513 Return-path: Envelope-to: mchehab@infradead.org Delivery-date: Mon, 17 Aug 2009 23:19:20 +0000 Received: from bombadil.infradead.org [18.85.46.34] by pedra.chehab.org with IMAP (fetchmail-6.3.6) for (single-drop); Mon, 17 Aug 2009 20:29:06 -0300 (BRT) Received: from vger.kernel.org ([209.132.176.167]) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1MdBTz-0000Xy-TS; Mon, 17 Aug 2009 23:19:20 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758230AbZHQXTN (ORCPT + 1 other); Mon, 17 Aug 2009 19:19:13 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1758259AbZHQXTN (ORCPT ); Mon, 17 Aug 2009 19:19:13 -0400 Received: from arroyo.ext.ti.com ([192.94.94.40]:37996 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758230AbZHQXTM (ORCPT ); Mon, 17 Aug 2009 19:19:12 -0400 Received: from dlep35.itg.ti.com ([157.170.170.118]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id n7HNJ8Ja007566; Mon, 17 Aug 2009 18:19:13 -0500 Received: from legion.dal.design.ti.com (localhost [127.0.0.1]) by dlep35.itg.ti.com (8.13.7/8.13.7) with ESMTP id n7HNJ7XB019276; Mon, 17 Aug 2009 18:19:07 -0500 (CDT) Received: from gt516km11.gt.design.ti.com (gt516km11.gt.design.ti.com [158.218.100.179]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id n7HNJ7Z04903; Mon, 17 Aug 2009 18:19:07 -0500 (CDT) Received: from gt516km11.gt.design.ti.com (localhost.localdomain [127.0.0.1]) by gt516km11.gt.design.ti.com (8.13.1/8.13.1) with ESMTP id n7HNJ6Ep032567; Mon, 17 Aug 2009 19:19:06 -0400 Received: (from a0868495@localhost) by gt516km11.gt.design.ti.com (8.13.1/8.13.1/Submit) id n7HNJ6P1032564; Mon, 17 Aug 2009 19:19:06 -0400 From: m-karicheri2@ti.com To: linux-media@vger.kernel.org Cc: davinci-linux-open-source@linux.davincidsp.com, hverkuil@xs4all.nl, khilman@deeprootsystems.com, Muralidharan Karicheri Subject: [PATCH 3/5 - v3] DaVinci: platform changes to support vpfe camera capture Signed-off-by: Muralidharan Karicheri Date: Mon, 17 Aug 2009 19:19:06 -0400 Message-Id: <1250551146-32543-1-git-send-email-m-karicheri2@ti.com> X-Mailer: git-send-email 1.6.0.4 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Muralidharan Karicheri Recreating the patch to apply cleanly and compile. There were no comments against v1 of this patch. So no change from v1/v2 of this patch Reviewed-by: Hans Verkuil Signed-off-by: Muralidharan Karicheri --- Applies to V4L-DVB linux-next repository arch/arm/mach-davinci/board-dm355-evm.c | 140 +++++++++++++++++++++++++++++- arch/arm/mach-davinci/board-dm644x-evm.c | 6 +- 2 files changed, 140 insertions(+), 6 deletions(-) diff --git a/arch/arm/mach-davinci/board-dm355-evm.c b/arch/arm/mach-davinci/board-dm355-evm.c index 605bf03..8f2842a 100644 --- a/arch/arm/mach-davinci/board-dm355-evm.c +++ b/arch/arm/mach-davinci/board-dm355-evm.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -136,14 +137,58 @@ static void dm355evm_mmcsd_gpios(unsigned gpio) dm355evm_mmc_gpios = gpio; } +#define PCA9543A_I2C_ADDR (0x73) + +static struct i2c_client *pca9543a; + +static int pca9543a_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + pca9543a = client; + return 0; +} + +static int pca9543a_remove(struct i2c_client *client) +{ + pca9543a = NULL; + return 0; +} + +static const struct i2c_device_id pca9543a_ids[] = { + { "PCA9543A", 0, }, + { /* end of list */ }, +}; + +/* This is for i2c driver for the MT9T031 header i2c switch */ +static struct i2c_driver pca9543a_driver = { + .driver.name = "PCA9543A", + .id_table = pca9543a_ids, + .probe = pca9543a_probe, + .remove = pca9543a_remove, +}; + static struct i2c_board_info dm355evm_i2c_info[] = { { I2C_BOARD_INFO("dm355evm_msp", 0x25), .platform_data = dm355evm_mmcsd_gpios, }, + { + I2C_BOARD_INFO("PCA9543A", 0x73), + }, /* { plus irq }, */ /* { I2C_BOARD_INFO("tlv320aic3x", 0x1b), }, */ }; +/* have_sensor() - Check if we have support for sensor interface */ +static inline int have_sensor(void) +{ +#if defined(CONFIG_SOC_CAMERA_MT9T031) || \ + defined(CONFIG_SOC_CAMERA_MT9T031_MODULE) + return 1; +#else + return 0; +#endif +} + static void __init evm_init_i2c(void) { davinci_init_i2c(&i2c_pdata); @@ -151,7 +196,8 @@ static void __init evm_init_i2c(void) gpio_request(5, "dm355evm_msp"); gpio_direction_input(5); dm355evm_i2c_info[0].irq = gpio_to_irq(5); - + if (have_sensor()) + i2c_add_driver(&pca9543a_driver); i2c_register_board_info(1, dm355evm_i2c_info, ARRAY_SIZE(dm355evm_i2c_info)); } @@ -180,6 +226,72 @@ static struct platform_device dm355evm_dm9000 = { .num_resources = ARRAY_SIZE(dm355evm_dm9000_rsrc), }; +/** + * dm355_enable_i2c_switch() - Enable/Disable I2C switch PCA9543A for sensor + * @en: enable/disbale flag + */ +static int dm355evm_enable_i2c_switch(int en) +{ + static char val = 1; + int status; + struct i2c_msg msg = { + .flags = 0, + .len = 1, + .buf = &val, + }; + + if (!en) + val = 0; + + if (!pca9543a) + return -ENXIO; + + msg.addr = pca9543a->addr; + /* turn i2c switch, pca9543a, on/off */ + status = i2c_transfer(pca9543a->adapter, &msg, 1); + return status; +} + +/** + * dm355evm_setup_video_input() - setup video data path and i2c + * @id: sub device id + */ +static int dm355evm_setup_video_input(enum vpfe_subdev_id id) +{ + int ret; + + switch (id) { + case VPFE_SUBDEV_MT9T031: + { + ret = dm355evm_msp_write(MSP_VIDEO_IMAGER, + DM355EVM_MSP_VIDEO_IN); + if (ret >= 0) + ret = dm355evm_enable_i2c_switch(1); + else + /* switch off i2c switch since we failed */ + ret = dm355evm_enable_i2c_switch(0); + break; + } + case VPFE_SUBDEV_TVP5146: + { + ret = dm355evm_msp_write(0, DM355EVM_MSP_VIDEO_IN); + break; + } + default: + return -EINVAL; + } + return (ret >= 0 ? 0 : ret); +} + +/* Input available at the mt9t031 */ +static struct v4l2_input mt9t031_inputs[] = { + { + .index = 0, + .name = "Camera", + .type = V4L2_INPUT_TYPE_CAMERA, + } +}; + static struct tvp514x_platform_data tvp5146_pdata = { .clk_polarity = 0, .hs_polarity = 1, @@ -203,7 +315,7 @@ static struct v4l2_input tvp5146_inputs[] = { }, }; -/* +/** * this is the route info for connecting each input to decoder * ouput that goes to vpfe. There is a one to one correspondence * with tvp5146_inputs @@ -221,8 +333,8 @@ static struct vpfe_route tvp5146_routes[] = { static struct vpfe_subdev_info vpfe_sub_devs[] = { { - .name = "tvp5146", - .grp_id = 0, + .module_name = TVP514X_MODULE_NAME, + .grp_id = VPFE_SUBDEV_TVP5146, .num_inputs = ARRAY_SIZE(tvp5146_inputs), .inputs = tvp5146_inputs, .routes = tvp5146_routes, @@ -236,6 +348,23 @@ static struct vpfe_subdev_info vpfe_sub_devs[] = { I2C_BOARD_INFO("tvp5146", 0x5d), .platform_data = &tvp5146_pdata, }, + }, + { + .module_name = "mt9t031", + .is_camera = 1, + .grp_id = VPFE_SUBDEV_MT9T031, + .num_inputs = ARRAY_SIZE(mt9t031_inputs), + .inputs = mt9t031_inputs, + .ccdc_if_params = { + .if_type = VPFE_RAW_BAYER, + .hdpol = VPFE_PINPOL_POSITIVE, + .vdpol = VPFE_PINPOL_POSITIVE, + }, + .board_info = { + I2C_BOARD_INFO("mt9t031", 0x5d), + /* this is for PCLK rising edge */ + .platform_data = (void *)1, + }, } }; @@ -244,6 +373,9 @@ static struct vpfe_config vpfe_cfg = { .sub_devs = vpfe_sub_devs, .card_name = "DM355 EVM", .ccdc = "DM355 CCDC", + .num_clocks = 2, + .clocks = {"vpss_master", "vpss_slave"}, + .setup_input = dm355evm_setup_video_input, }; static struct platform_device *davinci_evm_devices[] __initdata = { diff --git a/arch/arm/mach-davinci/board-dm644x-evm.c b/arch/arm/mach-davinci/board-dm644x-evm.c index 151a622..1679a24 100644 --- a/arch/arm/mach-davinci/board-dm644x-evm.c +++ b/arch/arm/mach-davinci/board-dm644x-evm.c @@ -237,8 +237,8 @@ static struct vpfe_route tvp5146_routes[] = { static struct vpfe_subdev_info vpfe_sub_devs[] = { { - .name = "tvp5146", - .grp_id = 0, + .module_name = TVP514X_MODULE_NAME, + .grp_id = VPFE_SUBDEV_TVP5146, .num_inputs = ARRAY_SIZE(tvp5146_inputs), .inputs = tvp5146_inputs, .routes = tvp5146_routes, @@ -260,6 +260,8 @@ static struct vpfe_config vpfe_cfg = { .sub_devs = vpfe_sub_devs, .card_name = "DM6446 EVM", .ccdc = "DM6446 CCDC", + .num_clocks = 2, + .clocks = {"vpss_master", "vpss_slave"}, }; static struct platform_device rtc_dev = {