From patchwork Tue Nov 27 13:21:49 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 1811091 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id B87883FC54 for ; Tue, 27 Nov 2012 13:25:01 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TdL72-00009h-Nm; Tue, 27 Nov 2012 13:22:08 +0000 Received: from tx2ehsobe004.messaging.microsoft.com ([65.55.88.14] helo=tx2outboundpool.messaging.microsoft.com) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TdL6y-00008n-Lu for linux-arm-kernel@lists.infradead.org; Tue, 27 Nov 2012 13:22:06 +0000 Received: from mail14-tx2-R.bigfish.com (10.9.14.246) by TX2EHSOBE012.bigfish.com (10.9.40.32) with Microsoft SMTP Server id 14.1.225.23; Tue, 27 Nov 2012 13:22:00 +0000 Received: from mail14-tx2 (localhost [127.0.0.1]) by mail14-tx2-R.bigfish.com (Postfix) with ESMTP id 26C731601A4; Tue, 27 Nov 2012 13:22:00 +0000 (UTC) X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI X-SpamScore: 0 X-BigFish: VS0(zzzz1de0h1202h1d1ah1d2ahzz8275bhz2dh2a8h668h839hd24he5bhf0ah1288h12a5h12a9h12bdh12e5h137ah139eh13b6h1441h1504h1537h162dh1631h1155h) Received: from mail14-tx2 (localhost.localdomain [127.0.0.1]) by mail14-tx2 (MessageSwitch) id 1354022518927520_23953; Tue, 27 Nov 2012 13:21:58 +0000 (UTC) Received: from TX2EHSMHS014.bigfish.com (unknown [10.9.14.245]) by mail14-tx2.bigfish.com (Postfix) with ESMTP id DCAA71800E9; Tue, 27 Nov 2012 13:21:58 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by TX2EHSMHS014.bigfish.com (10.9.99.114) with Microsoft SMTP Server (TLS) id 14.1.225.23; Tue, 27 Nov 2012 13:21:58 +0000 Received: from az84smr01.freescale.net (10.64.34.197) by 039-SN1MMR1-004.039d.mgd.msft.net (10.84.1.14) with Microsoft SMTP Server (TLS) id 14.2.318.3; Tue, 27 Nov 2012 13:21:58 +0000 Received: from fabio-Latitude-E6410.am.freescale.net ([10.29.240.147]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id qARDLppw010652; Tue, 27 Nov 2012 06:21:51 -0700 From: Fabio Estevam To: Subject: [PATCH] ARM: mx25_3ds: Add camera support Date: Tue, 27 Nov 2012 11:21:49 -0200 Message-ID: <1354022509-20505-1-git-send-email-fabio.estevam@freescale.com> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 X-OriginatorOrg: freescale.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20121127_082204_848466_A9623C1B X-CRM114-Status: GOOD ( 15.07 ) X-Spam-Score: -4.2 (----) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-4.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [65.55.88.14 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Fabio Estevam , javier.martin@vista-silicon.com, linux-arm-kernel@lists.infradead.org, g.liakhovetski@gmx.de X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org mx25_3ds board has a OV2640 camera sensor. Add support for it. Signed-off-by: Fabio Estevam --- arch/arm/mach-imx/mach-mx25_3ds.c | 85 +++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/arch/arm/mach-imx/mach-mx25_3ds.c b/arch/arm/mach-imx/mach-mx25_3ds.c index b1b03aa..ae25f01 100644 --- a/arch/arm/mach-imx/mach-mx25_3ds.c +++ b/arch/arm/mach-imx/mach-mx25_3ds.c @@ -37,6 +37,8 @@ #include #include +#include + #include "common.h" #include "devices-imx25.h" #include "hardware.h" @@ -115,12 +117,85 @@ static iomux_v3_cfg_t mx25pdk_pads[] = { MX25_PAD_GPIO_A__CAN1_TX, MX25_PAD_GPIO_B__CAN1_RX, MX25_PAD_D14__GPIO_4_6, /* CAN_PWDN */ + + /* CSI */ + MX25_PAD_CSI_D2__CSI_D2, + MX25_PAD_CSI_D3__CSI_D3, + MX25_PAD_CSI_D4__CSI_D4, + MX25_PAD_CSI_D5__CSI_D5, + MX25_PAD_CSI_D6__CSI_D6, + MX25_PAD_CSI_D7__CSI_D7, + MX25_PAD_CSI_D8__CSI_D8, + MX25_PAD_CSI_D9__CSI_D9, + MX25_PAD_CSI_HSYNC__CSI_HSYNC, + MX25_PAD_CSI_MCLK__CSI_MCLK, + MX25_PAD_CSI_PIXCLK__CSI_PIXCLK, + MX25_PAD_CSI_VSYNC__CSI_VSYNC, + MX25_PAD_A19__GPIO_2_5, /* CSI_PWDN */ + MX25_PAD_A20__GPIO_2_6, /* CMOS_RESET_B */ +}; + +#define MX25_3DS_GPIO_CAMERA_PW IMX_GPIO_NR(2, 5) +#define MX25_3DS_GPIO_CAMERA_RST IMX_GPIO_NR(2, 6) + +static struct gpio mx25_3ds_camera_gpios[] = { + { MX25_3DS_GPIO_CAMERA_PW, GPIOF_OUT_INIT_HIGH, "camera-power" }, + { MX25_3DS_GPIO_CAMERA_RST, GPIOF_OUT_INIT_HIGH, "camera-reset" }, +}; + +static const struct mx2_camera_platform_data mx25pdk_camera_pdata = { + .flags = MX2_CAMERA_HSYNC_HIGH | + MX2_CAMERA_GATED_CLOCK | + MX2_CAMERA_PCLK_SAMPLE_RISING, + .clk = 13000000, }; static const struct fec_platform_data mx25_fec_pdata __initconst = { .phy = PHY_INTERFACE_MODE_RMII, }; +static int mx25_3ds_camera_power(struct device *dev, int on) +{ + gpio_set_value(MX25_3DS_GPIO_CAMERA_PW, on ? 0 : 1); + + if (!on) + goto out; + + /* If enabled, give a reset impulse */ + gpio_set_value(MX25_3DS_GPIO_CAMERA_RST, 0); + msleep(20); + gpio_set_value(MX25_3DS_GPIO_CAMERA_RST, 1); + msleep(100); + +out: + return 0; +} + +static struct i2c_board_info mx25_3ds_i2c_camera = { + I2C_BOARD_INFO("ov2640", 0x30), +}; + +static struct soc_camera_link iclink_ov2640 = { + .bus_id = 0, + .board_info = &mx25_3ds_i2c_camera, + .i2c_adapter_id = 0, + .power = mx25_3ds_camera_power, + .regulators = NULL, + .num_regulators = 0, +}; + +static struct platform_device mx25_3ds_ov2640 = { + .name = "soc-camera-pdrv", + .id = 0, + .dev = { + .platform_data = &iclink_ov2640, + }, +}; + +static struct platform_device *devices[] __initdata = { + &mx25_3ds_ov2640, +}; + #define FEC_ENABLE_GPIO IMX_GPIO_NR(2, 3) #define FEC_RESET_B_GPIO IMX_GPIO_NR(4, 8) @@ -250,6 +325,16 @@ static void __init mx25pdk_init(void) gpio_request_one(MX25PDK_CAN_PWDN, GPIOF_OUT_INIT_LOW, "can-pwdn"); imx25_add_flexcan0(NULL); + + platform_add_devices(devices, ARRAY_SIZE(devices)); + + /* CSI */ + if (gpio_request_array(mx25_3ds_camera_gpios, + ARRAY_SIZE(mx25_3ds_camera_gpios))) { + pr_err("Failed to request camera gpios"); + iclink_ov2640.power = NULL; + } else + imx25_add_mx2_camera(&mx25pdk_camera_pdata); } static void __init mx25pdk_timer_init(void)