From patchwork Tue Mar 18 11:19:54 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josh Wu X-Patchwork-Id: 3848061 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 12C1B9F369 for ; Tue, 18 Mar 2014 11:25:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E471520397 for ; Tue, 18 Mar 2014 11:25:51 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C06E220396 for ; Tue, 18 Mar 2014 11:25:50 +0000 (UTC) Received: from merlin.infradead.org ([205.233.59.134]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WPs9T-0008VO-8r; Tue, 18 Mar 2014 11:25:47 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WPs9R-0006wT-9K; Tue, 18 Mar 2014 11:25:45 +0000 Received: from nasmtp01.atmel.com ([192.199.1.246] helo=DVREDG02.corp.atmel.com) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WPs9N-0006vN-KS for linux-arm-kernel@lists.infradead.org; Tue, 18 Mar 2014 11:25:42 +0000 Received: from apsmtp01.atmel.com (10.168.254.30) by DVREDG02.corp.atmel.com (10.42.103.31) with Microsoft SMTP Server (TLS) id 14.2.347.0; Tue, 18 Mar 2014 05:25:17 -0600 Received: from shaarm01.corp.atmel.com (10.168.254.13) by apsmtp01.corp.atmel.com (10.168.254.30) with Microsoft SMTP Server id 14.2.347.0; Tue, 18 Mar 2014 19:32:14 +0800 From: Josh Wu To: Subject: [PATCH 3/3] [media] atmel-isi: add primary DT support Date: Tue, 18 Mar 2014 19:19:54 +0800 Message-ID: <1395141594-6065-1-git-send-email-josh.wu@atmel.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1395141238-5948-1-git-send-email-josh.wu@atmel.com> References: <1395141238-5948-1-git-send-email-josh.wu@atmel.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140318_072541_832635_92EE9C94 X-CRM114-Status: GOOD ( 18.95 ) X-Spam-Score: -1.9 (-) Cc: mark.rutland@arm.com, devicetree@vger.kernel.org, pawel.moll@arm.com, ijc+devicetree@hellion.org.uk, nicolas.ferre@atmel.com, Josh Wu , robh+dt@kernel.org, rob@landley.net, galak@codeaurora.org, grant.likely@linaro.org, linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org, m.chehab@samsung.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch add the DT support for Atmel ISI driver. It use the same v4l2 DT interface that defined in video-interfaces.txt. Signed-off-by: Josh Wu Cc: devicetree@vger.kernel.org --- .../devicetree/bindings/media/atmel-isi.txt | 51 ++++++++++++++++++++ drivers/media/platform/soc_camera/atmel-isi.c | 33 ++++++++++++- 2 files changed, 82 insertions(+), 2 deletions(-) create mode 100644 Documentation/devicetree/bindings/media/atmel-isi.txt diff --git a/Documentation/devicetree/bindings/media/atmel-isi.txt b/Documentation/devicetree/bindings/media/atmel-isi.txt new file mode 100644 index 0000000..07f00eb --- /dev/null +++ b/Documentation/devicetree/bindings/media/atmel-isi.txt @@ -0,0 +1,51 @@ +Atmel Image Sensor Interface (ISI) SoC Camera Subsystem +---------------------------------------------- + +Required properties: +- compatible: must be "atmel,at91sam9g45-isi" +- reg: physical base address and length of the registers set for the device; +- interrupts: should contain IRQ line for the ISI; +- clocks: list of clock specifiers, corresponding to entries in + the clock-names property; +- clock-names: must contain "isi_clk", which is the isi peripherial clock. + "isi_mck" is optinal, it is the master clock output to sensor. + +Optional properties: +- atmel,isi-disable-preview: a boolean property to disable the preview channel; + +Example: + isi: isi@f0034000 { + compatible = "atmel,at91sam9g45-isi"; + reg = <0xf0034000 0x4000>; + interrupts = <37 IRQ_TYPE_LEVEL_HIGH 5>; + + clocks = <&isi_clk>, <&pck1>; + clock-names = "isi_clk", "isi_mck"; + + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_isi &pinctrl_pck1_as_isi_mck>; + + port { + #address-cells = <1>; + #size-cells = <0>; + + isi_0: endpoint { + remote-endpoint = <&ov2640_0>; + }; + }; + }; + + i2c1: i2c@f0018000 { + ov2640: camera@0x30 { + compatible = "omnivision,ov2640"; + reg = <0x30>; + + port { + ov2640_0: endpoint { + remote-endpoint = <&isi_0>; + bus-width = <8>; + }; + }; + }; + }; + diff --git a/drivers/media/platform/soc_camera/atmel-isi.c b/drivers/media/platform/soc_camera/atmel-isi.c index 93bf1cb..1822129 100644 --- a/drivers/media/platform/soc_camera/atmel-isi.c +++ b/drivers/media/platform/soc_camera/atmel-isi.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -33,6 +34,7 @@ #define VID_LIMIT_BYTES (16 * 1024 * 1024) #define MIN_FRAME_RATE 15 #define FRAME_INTERVAL_MILLI_SEC (1000 / MIN_FRAME_RATE) +#define ISI_DEFAULT_MCLK_FREQ 25000000 /* Frame buffer descriptor */ struct fbd { @@ -878,6 +880,22 @@ static int atmel_isi_remove(struct platform_device *pdev) return 0; } +static int atmel_isi_probe_dt(struct atmel_isi *isi, + struct platform_device *pdev) +{ + struct device_node *node = pdev->dev.of_node; + + isi->pdata.full_mode = !of_property_read_bool(node, + "atmel,isi-disable-preview"); + + /* Default settings for ISI */ + isi->pdata.mck_hz = ISI_DEFAULT_MCLK_FREQ; + isi->pdata.frate = ISI_CFG1_FRATE_CAPTURE_ALL; + isi->pdata.data_width_flags = ISI_DATAWIDTH_8 | ISI_DATAWIDTH_10; + + return 0; +} + static int atmel_isi_probe(struct platform_device *pdev) { unsigned int irq; @@ -889,7 +907,7 @@ static int atmel_isi_probe(struct platform_device *pdev) struct isi_platform_data *pdata; pdata = dev->platform_data; - if (!pdata || !pdata->data_width_flags) { + if ((!pdata || !pdata->data_width_flags) && !pdev->dev.of_node) { dev_err(&pdev->dev, "No config available for Atmel ISI\n"); return -EINVAL; @@ -905,7 +923,11 @@ static int atmel_isi_probe(struct platform_device *pdev) if (IS_ERR(isi->pclk)) return PTR_ERR(isi->pclk); - memcpy(&isi->pdata, pdata, sizeof(struct isi_platform_data)); + if (pdata) + memcpy(&isi->pdata, pdata, sizeof(struct isi_platform_data)); + else /* dt probe */ + atmel_isi_probe_dt(isi, pdev); + isi->active = NULL; spin_lock_init(&isi->lock); INIT_LIST_HEAD(&isi->video_buffer_list); @@ -1007,11 +1029,18 @@ err_alloc_ctx: return ret; } +static const struct of_device_id atmel_isi_of_match[] = { + { .compatible = "atmel,at91sam9g45-isi" }, + { } +}; +MODULE_DEVICE_TABLE(of, atmel_isi_of_match); + static struct platform_driver atmel_isi_driver = { .remove = atmel_isi_remove, .driver = { .name = "atmel_isi", .owner = THIS_MODULE, + .of_match_table = atmel_isi_of_match, }, };