From patchwork Sat Jul 13 11:12:39 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 2827151 Return-Path: X-Original-To: patchwork-davinci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 74A11C0AB2 for ; Sat, 13 Jul 2013 11:13:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4FDEA20127 for ; Sat, 13 Jul 2013 11:13:06 +0000 (UTC) Received: from comal.ext.ti.com (comal.ext.ti.com [198.47.26.152]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1069E20125 for ; Sat, 13 Jul 2013 11:13:05 +0000 (UTC) Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id r6DBD4n9017084 for ; Sat, 13 Jul 2013 06:13:04 -0500 Received: from DLEE70.ent.ti.com (dlee70.ent.ti.com [157.170.170.113]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id r6DBD4bX032396 for ; Sat, 13 Jul 2013 06:13:04 -0500 Received: from dlelxv23.itg.ti.com (172.17.1.198) by DLEE70.ent.ti.com (157.170.170.113) with Microsoft SMTP Server id 14.2.342.3; Sat, 13 Jul 2013 06:13:04 -0500 Received: from linux.omap.com (dlelxs01.itg.ti.com [157.170.227.31]) by dlelxv23.itg.ti.com (8.13.8/8.13.8) with ESMTP id r6DBD4IG026069 for ; Sat, 13 Jul 2013 06:13:04 -0500 Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id 1F6E480627 for ; Sat, 13 Jul 2013 06:13:04 -0500 (CDT) X-Original-To: davinci-linux-open-source@linux.davincidsp.com Delivered-To: davinci-linux-open-source@linux.davincidsp.com Received: from dflp53.itg.ti.com (dflp53.itg.ti.com [128.247.5.6]) by linux.omap.com (Postfix) with ESMTP id 2821680626 for ; Sat, 13 Jul 2013 06:12:55 -0500 (CDT) Received: from white.ext.ti.com (white.ext.ti.com [192.94.93.38]) by dflp53.itg.ti.com (8.13.8/8.13.8) with ESMTP id r6DBCtwI009450 for ; Sat, 13 Jul 2013 06:12:55 -0500 (CDT) Received: from mail6.bemta12.messagelabs.com (mail6.bemta12.messagelabs.com [216.82.250.247]) by white.ext.ti.com (8.13.7/8.13.7) with ESMTP id r6DBCsGv016720 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sat, 13 Jul 2013 06:12:54 -0500 Received: from [216.82.250.51:52384] by server-10.bemta-12.messagelabs.com id 7C/1F-14756-63631E15; Sat, 13 Jul 2013 11:12:54 +0000 X-Env-Sender: prabhakar.csengg@gmail.com X-Msg-Ref: server-4.tower-108.messagelabs.com!1373713972!12742276!1 X-Originating-IP: [209.85.220.52] X-SpamReason: No, hits=0.7 required=7.0 tests=BODY_RANDOM_LONG, ML_RADAR_SPEW_LINKS_14,RCVD_ILLEGAL_IP,spamassassin: X-StarScan-Received: X-StarScan-Version: 6.9.9; banners=-,-,- X-VirusChecked: Checked Received: (qmail 24628 invoked from network); 13 Jul 2013 11:12:53 -0000 Received: from mail-pa0-f52.google.com (HELO mail-pa0-f52.google.com) (209.85.220.52) by server-4.tower-108.messagelabs.com with RC4-SHA encrypted SMTP; 13 Jul 2013 11:12:53 -0000 Received: by mail-pa0-f52.google.com with SMTP id kq13so9726929pab.25 for ; Sat, 13 Jul 2013 04:12:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer; bh=QAf/3ZiYRk3qaW9ClkbhweTpwWPJHSP5MyLScqtW7Ss=; b=wdLnNXxzGW+CIciF1kpjSy+yUAa1zxr8lC5YtXzqMLgq3CH3mjHOlQhl1tQITsJ1h7 TgEqrJPaEDQFwiCc0ZeXPh3aZc8atvLUNDkUBMMDvfOF0chvbFddGNfRYOHhN6y+CGRw 3sZ7SNzo1I3RZ/ns9MbjJPij0cppbOrB8hfpGcLT2ILGyhnI9vJpSxEFIZlMGsJaB0H6 NPKRsk8/wMiX7emNtP2I03U6BfHI+PxspXWYhVSn3agnCbAv+z6Nx7ROw1J+E9/TB6G5 Oqzm6KD2Cmli1+LKJeLPkODA8/cqNFDbNnlK5Tz2sjetQf9QmtCZL+g6AW2xk88FNuAW K2mA== X-Received: by 10.68.241.198 with SMTP id wk6mr30299400pbc.165.1373713972221; Sat, 13 Jul 2013 04:12:52 -0700 (PDT) Received: from localhost.localdomain ([1.23.213.247]) by mx.google.com with ESMTPSA id pq1sm7240965pbb.26.2013.07.13.04.12.48 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 13 Jul 2013 04:12:51 -0700 (PDT) From: Prabhakar Lad To: LMML Subject: [PATCH v2] media: i2c: adv7343: add OF support Date: Sat, 13 Jul 2013 16:42:39 +0530 Message-ID: <1373713959-31066-1-git-send-email-prabhakar.csengg@gmail.com> X-Mailer: git-send-email 1.7.9.5 CC: , DLOS , LKML , LDOC X-BeenThere: davinci-linux-open-source@linux.davincidsp.com X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: Errors-To: davinci-linux-open-source-bounces+patchwork-davinci=patchwork.kernel.org@linux.davincidsp.com X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham 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 From: "Lad, Prabhakar" add OF support for the adv7343 driver. Signed-off-by: Lad, Prabhakar --- Changes for v2: 1: Fixed naming of properties. .../devicetree/bindings/media/i2c/adv7343.txt | 54 ++++++++++++++++ drivers/media/i2c/adv7343.c | 65 +++++++++++++++++++- 2 files changed, 118 insertions(+), 1 deletion(-) create mode 100644 Documentation/devicetree/bindings/media/i2c/adv7343.txt diff --git a/Documentation/devicetree/bindings/media/i2c/adv7343.txt b/Documentation/devicetree/bindings/media/i2c/adv7343.txt new file mode 100644 index 0000000..1d2e854 --- /dev/null +++ b/Documentation/devicetree/bindings/media/i2c/adv7343.txt @@ -0,0 +1,54 @@ +* Analog Devices adv7343 video encoder + +The ADV7343 are high speed, digital-to-analog video encoders in a 64-lead LQFP +package. Six high speed, 3.3 V, 11-bit video DACs provide support for composite +(CVBS), S-Video (Y-C), and component (YPrPb/RGB) analog outputs in standard +definition (SD), enhanced definition (ED), or high definition (HD) video +formats. + +Required Properties : +- compatible: Must be "ad,adv7343" + +Optional Properties : +- ad,adv7343-power-mode-sleep-mode: on enable the current consumption is + reduced to micro ampere level. All DACs and + the internal PLL circuit are disabled. +- ad,adv7343-power-mode-pll-ctrl: PLL and oversampling control. This control + allows internal PLL 1 circuit to be powered + down and the oversampling to beswitched off. +- ad,adv7343-power-mode-dac-1: power on/off DAC 1, 0 = OFF and 1 = ON. +- ad,adv7343-power-mode-dac-2: power on/off DAC 2, 0 = OFF and 1 = ON. +- ad,adv7343-power-mode-dac-3: power on/off DAC 3, 0 = OFF and 1 = ON. +- ad,adv7343-power-mode-dac-4: power on/off DAC 4, 0 = OFF and 1 = ON. +- ad,adv7343-power-mode-dac-5: power on/off DAC 5, 0 = OFF and 1 = ON. +- ad,adv7343-power-mode-dac-6: power on/off DAC 6, 0 = OFF and 1 = ON. +- ad,adv7343-sd-config-dac-out-1: Configure SD DAC Output 1. +- ad,adv7343-sd-config-dac-out-2: Configure SD DAC Output 2. + +Example: + +i2c0@1c22000 { + ... + ... + + adv7343@2a { + compatible = "ad,adv7343"; + reg = <0x2a>; + + port { + adv7343_1: endpoint { + ad,adv7343-power-mode-sleep-mode; + ad,adv7343-power-mode-pll-ctrl; + ad,adv7343-power-mode-dac-1; + ad,adv7343-power-mode-dac-2; + ad,adv7343-power-mode-dac-3; + ad,adv7343-power-mode-dac-4; + ad,adv7343-power-mode-dac-5; + ad,adv7343-power-mode-dac-6; + ad,adv7343-sd-config-dac-out-1; + ad,adv7343-sd-config-dac-out-2; + }; + }; + }; + ... +}; diff --git a/drivers/media/i2c/adv7343.c b/drivers/media/i2c/adv7343.c index 7606218..22ee6f4 100644 --- a/drivers/media/i2c/adv7343.c +++ b/drivers/media/i2c/adv7343.c @@ -29,6 +29,7 @@ #include #include #include +#include #include "adv7343_regs.h" @@ -398,6 +399,59 @@ static int adv7343_initialize(struct v4l2_subdev *sd) return err; } +static struct adv7343_platform_data * +adv7343_get_pdata(struct i2c_client *client) +{ + struct adv7343_platform_data *pdata; + struct device_node *np; + + if (!IS_ENABLED(CONFIG_OF) || !client->dev.of_node) + return client->dev.platform_data; + + np = v4l2_of_get_next_endpoint(client->dev.of_node, NULL); + if (!np) + return NULL; + + pdata = devm_kzalloc(&client->dev, sizeof(struct adv7343_platform_data), + GFP_KERNEL); + if (!pdata) + goto done; + + pdata->mode_config.sleep_mode = + of_property_read_bool(np, "ad,adv7343-power-mode-sleep-mode"); + + pdata->mode_config.pll_control = + of_property_read_bool(np, "ad,adv7343-power-mode-pll-ctrl"); + + pdata->mode_config.dac_1 = + of_property_read_bool(np, "ad,adv7343-power-mode-dac-1"); + + pdata->mode_config.dac_2 = + of_property_read_bool(np, "ad,adv7343-power-mode-dac-2"); + + pdata->mode_config.dac_3 = + of_property_read_bool(np, "ad,adv7343-power-mode-dac-3"); + + pdata->mode_config.dac_4 = + of_property_read_bool(np, "ad,adv7343-power-mode-dac-4"); + + pdata->mode_config.dac_5 = + of_property_read_bool(np, "ad,adv7343-power-mode-dac-5"); + + pdata->mode_config.dac_6 = + of_property_read_bool(np, "ad,adv7343-power-mode-dac-6"); + + pdata->sd_config.sd_dac_out1 = + of_property_read_bool(np, "ad,adv7343-sd-config-dac-out-1"); + + pdata->sd_config.sd_dac_out2 = + of_property_read_bool(np, "ad,adv7343-sd-config-dac-out-2"); + +done: + of_node_put(np); + return pdata; +} + static int adv7343_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -416,7 +470,7 @@ static int adv7343_probe(struct i2c_client *client, return -ENOMEM; /* Copy board specific information here */ - state->pdata = client->dev.platform_data; + state->pdata = adv7343_get_pdata(client); state->reg00 = 0x80; state->reg01 = 0x00; @@ -476,8 +530,17 @@ static const struct i2c_device_id adv7343_id[] = { MODULE_DEVICE_TABLE(i2c, adv7343_id); +#if IS_ENABLED(CONFIG_OF) +static const struct of_device_id adv7343_of_match[] = { + {.compatible = "ad,adv7343", }, + { /* sentinel */ }, +}; +MODULE_DEVICE_TABLE(of, adv7343_of_match); +#endif + static struct i2c_driver adv7343_driver = { .driver = { + .of_match_table = of_match_ptr(adv7343_of_match), .owner = THIS_MODULE, .name = "adv7343", },