From patchwork Wed May 2 15:15:47 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Aguirre Rodriguez, Sergio Alberto" X-Patchwork-Id: 10968 Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.72) (envelope-from ) id 1SPbIA-0004Cx-I2 for patchwork@linuxtv.org; Wed, 02 May 2012 17:16:34 +0200 X-tubIT-Incoming-IP: 209.132.180.67 Received: from vger.kernel.org ([209.132.180.67]) by mail.tu-berlin.de (exim-4.75/mailfrontend-4) with esmtp for id 1SPbI9-0004qS-BS; Wed, 02 May 2012 17:16:34 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755468Ab2EBPQ0 (ORCPT ); Wed, 2 May 2012 11:16:26 -0400 Received: from na3sys009aog136.obsmtp.com ([74.125.149.85]:42812 "EHLO na3sys009aog136.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754573Ab2EBPQY (ORCPT ); Wed, 2 May 2012 11:16:24 -0400 Received: from mail-ob0-f175.google.com ([209.85.214.175]) (using TLSv1) by na3sys009aob136.postini.com ([74.125.148.12]) with SMTP ID DSNKT6FPx/gP+ANP+TagPeCw6HeL56f/FgIu@postini.com; Wed, 02 May 2012 08:16:24 PDT Received: by obhx4 with SMTP id x4so1351991obh.34 for ; Wed, 02 May 2012 08:16:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=wU0+MApVhUkuq3MqhW34/C4xDJdLirtl0K1LKesMTaY=; b=WR1EqWBCvQwUb9GZMjZNLIFK9KClHtWvRAG1si1F+0ElZlEPP1DvLaMzX2wVhzN6MH 8BBhQWjHuF30IhscyX5Kl72yV50xqYSCkdFozkRI/PFSmFBRq5PKxeCOyX0+F67vwGnz LKkrYpbvf5kVsl3uO6ST+R1cL3WCXm2bu7CqaJ4A4eJXRrDkDEwQrpMezJbXuREG9Xd9 8nsBpfW8uTYzlw9SOqNfmcNlO7vmtOUqOddta4gJcZ2Hux/E4t/03KMNewHCL/DVoI9K 77BgbKLtL+z4A7eAKimF7hYA4mvos4lVld7mtg162B9V/JkaNF63lp0iYcY8sIZ8VzTn m99w== Received: by 10.182.167.40 with SMTP id zl8mr9908270obb.39.1335971783285; Wed, 02 May 2012 08:16:23 -0700 (PDT) Received: from localhost.localdomain (dragon.ti.com. [192.94.94.33]) by mx.google.com with ESMTPS id bd10sm2259391obb.15.2012.05.02.08.16.17 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 02 May 2012 08:16:20 -0700 (PDT) From: Sergio Aguirre To: linux-media@vger.kernel.org Cc: linux-omap@vger.kernel.org, Sergio Aguirre Subject: [PATCH v3 08/10] arm: omap4panda: Add support for omap4iss camera Date: Wed, 2 May 2012 10:15:47 -0500 Message-Id: <1335971749-21258-9-git-send-email-saaguirre@ti.com> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1335971749-21258-1-git-send-email-saaguirre@ti.com> References: <1335971749-21258-1-git-send-email-saaguirre@ti.com> X-Gm-Message-State: ALoCoQlcr+ygOKTB2JhUiUgYhrUYqyP/sx/0A6qlBGGYP/9P9T9wY8qTV60PncA4oVkEGUJvfPBG Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-PMX-Version: 5.6.1.2065439, Antispam-Engine: 2.7.2.376379, Antispam-Data: 2012.5.2.150327 X-PMX-Spam: Gauge=IIIIIIII, Probability=8%, Report=' MULTIPLE_RCPTS 0.1, HTML_00_01 0.05, HTML_00_10 0.05, BODY_SIZE_6000_6999 0, BODY_SIZE_7000_LESS 0, DATE_TZ_NA 0, DATE_TZ_NEG_0500 0, URI_ENDS_IN_HTML 0, __ANY_URI 0, __CP_MEDIA_BODY 0, __CP_URI_IN_BODY 0, __HAS_MSGID 0, __HAS_X_MAILER 0, __HAS_X_MAILING_LIST 0, __MIME_TEXT_ONLY 0, __MULTIPLE_RCPTS_CC_X2 0, __SANE_MSGID 0, __SUBJ_ALPHA_END 0, __TO_MALFORMED_2 0, __TO_NO_NAME 0, __URI_NO_WWW 0, __URI_NS ' This adds support for camera interface with the support for following sensors: - OV5640 - OV5650 Signed-off-by: Sergio Aguirre --- arch/arm/mach-omap2/Kconfig | 16 ++ arch/arm/mach-omap2/Makefile | 1 + arch/arm/mach-omap2/board-omap4panda-camera.c | 209 +++++++++++++++++++++++++ 3 files changed, 226 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-omap2/board-omap4panda-camera.c diff --git a/arch/arm/mach-omap2/Kconfig b/arch/arm/mach-omap2/Kconfig index 54645aa..4b267a6 100644 --- a/arch/arm/mach-omap2/Kconfig +++ b/arch/arm/mach-omap2/Kconfig @@ -359,6 +359,22 @@ config MACH_OMAP4_PANDA select OMAP_PACKAGE_CBS select REGULATOR_FIXED_VOLTAGE if REGULATOR +config MACH_OMAP4_PANDA_CAMERA_SUPPORT + bool "OMAP4 Panda Board Camera support" + depends on MACH_OMAP4_PANDA + select MEDIA_SUPPORT + select MEDIA_CONTROLLER + select VIDEO_DEV + select VIDEO_V4L2_SUBDEV_API + select V4L_PLATFORM_DRIVERS + select VIDEO_OMAP4 + select VIDEO_OV5640 + select VIDEO_OV5650 + help + Enable Camera HW support for PandaBoard. + This is for using the OMAP4 ISS CSI2A Camera sensor + interface. + config OMAP3_EMU bool "OMAP3 debugging peripherals" depends on ARCH_OMAP3 diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile index ebd8f63..e6724c4 100644 --- a/arch/arm/mach-omap2/Makefile +++ b/arch/arm/mach-omap2/Makefile @@ -240,6 +240,7 @@ obj-$(CONFIG_MACH_TI8148EVM) += board-ti8168evm.o # Platform specific device init code obj-$(CONFIG_MACH_OMAP_4430SDP_CAMERA_SUPPORT) += board-4430sdp-camera.o +obj-$(CONFIG_MACH_OMAP4_PANDA_CAMERA_SUPPORT) += board-omap4panda-camera.o omap-flash-$(CONFIG_MTD_NAND_OMAP2) := board-flash.o omap-flash-$(CONFIG_MTD_ONENAND_OMAP2) := board-flash.o diff --git a/arch/arm/mach-omap2/board-omap4panda-camera.c b/arch/arm/mach-omap2/board-omap4panda-camera.c new file mode 100644 index 0000000..a5f7863 --- /dev/null +++ b/arch/arm/mach-omap2/board-omap4panda-camera.c @@ -0,0 +1,209 @@ +#include +#include +#include + +#include +#include + +#include + +#include +#include + +#include "devices.h" +#include "../../../drivers/media/video/omap4iss/iss.h" + +#include "control.h" +#include "mux.h" + +#define PANDA_GPIO_CAM_PWRDN 45 +#define PANDA_GPIO_CAM_RESET 83 + +static struct clk *panda_cam_aux_clk; + +static int panda_ov_power(struct v4l2_subdev *subdev, int on) +{ + struct device *dev = subdev->v4l2_dev->dev; + + if (on) { + int ret; + + gpio_set_value(PANDA_GPIO_CAM_PWRDN, 0); + ret = clk_enable(panda_cam_aux_clk); + if (ret) { + dev_err(dev, + "Error in clk_enable() in %s(%d)\n", + __func__, on); + gpio_set_value(PANDA_GPIO_CAM_PWRDN, 1); + return ret; + } + mdelay(2); + } else { + clk_disable(panda_cam_aux_clk); + gpio_set_value(PANDA_GPIO_CAM_PWRDN, 1); + } + + return 0; +} + +#define OV5640_I2C_ADDRESS (0x3C) + +static struct ov5640_platform_data ov5640_platform_data = { + .s_power = panda_ov_power, +}; + +static struct i2c_board_info ov5640_camera_i2c_device = { + I2C_BOARD_INFO("ov5640", OV5640_I2C_ADDRESS), + .platform_data = &ov5640_platform_data, +}; + +#define OV5650_I2C_ADDRESS (0x36) + +static struct ov5650_platform_data ov5650_platform_data = { + .s_power = panda_ov_power, +}; + +static struct i2c_board_info ov5650_camera_i2c_device = { + I2C_BOARD_INFO("ov5650", OV5650_I2C_ADDRESS), + .platform_data = &ov5650_platform_data, +}; + +static struct iss_subdev_i2c_board_info ov5640_camera_subdevs[] = { + { + .board_info = &ov5640_camera_i2c_device, + .i2c_adapter_id = 3, + }, + { NULL, 0, }, +}; + +static struct iss_subdev_i2c_board_info ov5650_camera_subdevs[] = { + { + .board_info = &ov5650_camera_i2c_device, + .i2c_adapter_id = 3, + }, + { NULL, 0, }, +}; + +static struct iss_v4l2_subdevs_group panda_camera_subdevs[] = { + { + .subdevs = ov5640_camera_subdevs, + .interface = ISS_INTERFACE_CSI2A_PHY1, + .bus = { .csi2 = { + .lanecfg = { + .clk = { + .pol = 0, + .pos = 1, + }, + .data[0] = { + .pol = 0, + .pos = 2, + }, + }, + } }, + }, + { + .subdevs = ov5650_camera_subdevs, + .interface = ISS_INTERFACE_CSI2A_PHY1, + .bus = { .csi2 = { + .lanecfg = { + .clk = { + .pol = 0, + .pos = 1, + }, + .data[0] = { + .pol = 0, + .pos = 2, + }, + }, + } }, + }, + { }, +}; + +static void panda_omap4iss_set_constraints(struct iss_device *iss, bool enable) +{ + if (!iss) + return; + + /* FIXME: Look for something more precise as a good throughtput limit */ + omap_pm_set_min_bus_tput(iss->dev, OCP_INITIATOR_AGENT, + enable ? 800000 : -1); +} + +static struct iss_platform_data panda_iss_platform_data = { + .subdevs = panda_camera_subdevs, + .set_constraints = panda_omap4iss_set_constraints, +}; + + +static struct omap_device_pad omap4iss_pads[] = { + { + .name = "csi21_dx0.csi21_dx0", + .enable = OMAP_MUX_MODE0 | OMAP_INPUT_EN, + }, + { + .name = "csi21_dy0.csi21_dy0", + .enable = OMAP_MUX_MODE0 | OMAP_INPUT_EN, + }, + { + .name = "csi21_dx1.csi21_dx1", + .enable = OMAP_MUX_MODE0 | OMAP_INPUT_EN, + }, + { + .name = "csi21_dy1.csi21_dy1", + .enable = OMAP_MUX_MODE0 | OMAP_INPUT_EN, + }, + { + .name = "csi21_dx2.csi21_dx2", + .enable = OMAP_MUX_MODE0 | OMAP_INPUT_EN, + }, + { + .name = "csi21_dy2.csi21_dy2", + .enable = OMAP_MUX_MODE0 | OMAP_INPUT_EN, + }, +}; + +static struct omap_board_data omap4iss_data = { + .id = 1, + .pads = omap4iss_pads, + .pads_cnt = ARRAY_SIZE(omap4iss_pads), +}; + +static int __init panda_camera_init(void) +{ + if (!machine_is_omap4_panda()) + return 0; + + panda_cam_aux_clk = clk_get(NULL, "auxclk1_ck"); + if (IS_ERR(panda_cam_aux_clk)) { + printk(KERN_ERR "Unable to get auxclk1_ck\n"); + return -ENODEV; + } + + if (clk_set_rate(panda_cam_aux_clk, + clk_round_rate(panda_cam_aux_clk, 24000000))) + return -EINVAL; + + /* Select GPIO 45 */ + omap_mux_init_gpio(PANDA_GPIO_CAM_PWRDN, OMAP_PIN_OUTPUT); + + /* Select GPIO 83 */ + omap_mux_init_gpio(PANDA_GPIO_CAM_RESET, OMAP_PIN_OUTPUT); + + /* Init FREF_CLK1_OUT */ + omap_mux_init_signal("fref_clk1_out", OMAP_PIN_OUTPUT); + + if (gpio_request_one(PANDA_GPIO_CAM_PWRDN, GPIOF_OUT_INIT_HIGH, + "CAM_PWRDN")) + printk(KERN_WARNING "Cannot request GPIO %d\n", + PANDA_GPIO_CAM_PWRDN); + + if (gpio_request_one(PANDA_GPIO_CAM_RESET, GPIOF_OUT_INIT_HIGH, + "CAM_RESET")) + printk(KERN_WARNING "Cannot request GPIO %d\n", + PANDA_GPIO_CAM_RESET); + + omap4_init_camera(&panda_iss_platform_data, &omap4iss_data); + return 0; +} +late_initcall(panda_camera_init);