From patchwork Fri Apr 26 13:18:06 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 2493831 Return-Path: X-Original-To: patchwork-davinci@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from bear.ext.ti.com (bear.ext.ti.com [192.94.94.41]) by patchwork1.kernel.org (Postfix) with ESMTP id AF8653FD40 for ; Fri, 26 Apr 2013 13:18:36 +0000 (UTC) Received: from dflxv15.itg.ti.com ([128.247.5.124]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id r3QDIZff028512 for ; Fri, 26 Apr 2013 08:18:35 -0500 Received: from DLEE70.ent.ti.com (dlee70.ent.ti.com [157.170.170.113]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id r3QDIZsJ010108 for ; Fri, 26 Apr 2013 08:18:35 -0500 Received: from dlelxv24.itg.ti.com (172.17.1.199) by DLEE70.ent.ti.com (157.170.170.113) with Microsoft SMTP Server id 14.2.342.3; Fri, 26 Apr 2013 08:18:35 -0500 Received: from linux.omap.com (dlelxs01.itg.ti.com [157.170.227.31]) by dlelxv24.itg.ti.com (8.13.8/8.13.8) with ESMTP id r3QDIZvn021164 for ; Fri, 26 Apr 2013 08:18:35 -0500 Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id 6834980627 for ; Fri, 26 Apr 2013 08:18:35 -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 8EB7380626 for ; Fri, 26 Apr 2013 08:18:25 -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 r3QDIPBl011063 for ; Fri, 26 Apr 2013 08:18:25 -0500 (CDT) Received: from mail6.bemta7.messagelabs.com (mail6.bemta7.messagelabs.com [216.82.255.55]) by white.ext.ti.com (8.13.7/8.13.7) with ESMTP id r3QDIOja028014 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 26 Apr 2013 08:18:24 -0500 Received: from [216.82.253.147:41853] by server-3.bemta-7.messagelabs.com id FB/70-12019-0AE7A715; Fri, 26 Apr 2013 13:18:24 +0000 X-Env-Sender: prabhakar.csengg@gmail.com X-Msg-Ref: server-5.tower-165.messagelabs.com!1366982302!13787699!1 X-Originating-IP: [209.85.160.49] X-StarScan-Received: X-StarScan-Version: 6.8.6.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 8992 invoked from network); 26 Apr 2013 13:18:22 -0000 Received: from mail-pb0-f49.google.com (HELO mail-pb0-f49.google.com) (209.85.160.49) by server-5.tower-165.messagelabs.com with RC4-SHA encrypted SMTP; 26 Apr 2013 13:18:22 -0000 Received: by mail-pb0-f49.google.com with SMTP id rp2so1141419pbb.22 for ; Fri, 26 Apr 2013 06:18:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer; bh=xWz8242Lfprww+HsqKawb0prHCxn6/ftVSiWAwWZAn4=; b=jhh0RRjZDu2bOiUtc7Mm5O9zT12jsqgvI8DviAFpgTwYzhaai+0Vb8+uG8oOK6qhza EWKGX2pTaNWIhI+F4ywxSkwgXV4fN85GDL9sWn0QZ6mmoJI2AOpu+HaBGR6Jw03MKpD9 mRvuCuaj/mInQ2vb3n+FlNutkxeiMjzk59nJXuNe37gk6Ea/tFaaEyAB2eK9KPYlNich cAwh5WWPKgaOY+e1HmEFsnTgLP3iWG0fuGU9MyP8u7rLteBGM8fwuhU94yYbO4NZqJch VJq0wx9Aei2pUohD/UoevlON5gMGdwQziYU6O32bt4qPrBhsQ1oU2WdusokqhVCApYGX /AJQ== X-Received: by 10.68.103.131 with SMTP id fw3mr57757507pbb.112.1366982302034; Fri, 26 Apr 2013 06:18:22 -0700 (PDT) Received: from localhost.localdomain ([59.98.240.173]) by mx.google.com with ESMTPSA id wz9sm11717473pbc.5.2013.04.26.06.18.14 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 26 Apr 2013 06:18:20 -0700 (PDT) From: Prabhakar Lad To: LMML Subject: [PATCH] media: i2c: adv7343: add OF support Date: Fri, 26 Apr 2013 18:48:06 +0530 Message-ID: <1366982286-22950-1-git-send-email-prabhakar.csengg@gmail.com> X-Mailer: git-send-email 1.7.4.1 CC: Rob Landley , , Mauro Carvalho Chehab , , , , Rob Herring , Grant Likely , Hans Verkuil , Laurent Pinchart , Sylwester Nawrocki , Sakari Ailus , Guennadi Liakhovetski 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 From: Lad, Prabhakar add OF support for the adv7343 driver. Signed-off-by: Lad, Prabhakar Cc: Hans Verkuil Cc: Laurent Pinchart Cc: Mauro Carvalho Chehab Cc: Guennadi Liakhovetski Cc: Sylwester Nawrocki Cc: Sakari Ailus Cc: Grant Likely Cc: Rob Herring Cc: Rob Landley Cc: devicetree-discuss@lists.ozlabs.org Cc: linux-doc@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: davinci-linux-open-source@linux.davincidsp.com --- .../devicetree/bindings/media/i2c/adv7343.txt | 69 ++++++++++++++++++ drivers/media/i2c/adv7343.c | 75 +++++++++++++++++++- 2 files changed, 142 insertions(+), 2 deletions(-) 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..8426f8d --- /dev/null +++ b/Documentation/devicetree/bindings/media/i2c/adv7343.txt @@ -0,0 +1,69 @@ +* 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. + +The ADV7343 have a 24-bit pixel input port that can be configured in a variety +of ways. SD video formats are supported over an SDR interface, and ED/HD video +formats are supported over SDR and DDR interfaces. Pixel data can be supplied +in either the YCrCb or RGB color spaces. + +Required Properties : +- compatible: Must be "ad,adv7343-encoder" + +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. +- ad-adv7343-power-mode-dac-2: power on/off DAC 2. +- ad-adv7343-power-mode-dac-3: power on/off DAC 3. +- ad-adv7343-power-mode-dac-4: power on/off DAC 4. +- ad-adv7343-power-mode-dac-5: power on/off DAC 5. +- ad-adv7343-power-mode-dac-6: power on/off DAC 6. +- 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-encoder"; + reg = <0x2a>; + + port { + adv7343_1: endpoint { + /* Active high (Defaults to false) */ + ad-adv7343-power-mode-sleep-mode; + /* Active high (Defaults to false) */ + ad-adv7343-power-mode-pll-ctrl; + /* Active high (Defaults to false) */ + ad-adv7343-power-mode-dac-1; + /* Active high (Defaults to false) */ + ad-adv7343-power-mode-dac-2; + /* Active high (Defaults to false) */ + ad-adv7343-power-mode-dac-3; + /* Active high (Defaults to false) */ + ad-adv7343-power-mode-dac-4; + /* Active high (Defaults to false) */ + ad-adv7343-power-mode-dac-5; + /* Active high (Defaults to false) */ + ad-adv7343-power-mode-dac-6; + /* Active high (Defaults to false) */ + ad-adv7343-sd-config-dac-out-1; + /* Active high (Defaults to false) */ + ad-adv7343-sd-config-dac-out-2 = <0>; + }; + }; + }; + ... +}; diff --git a/drivers/media/i2c/adv7343.c b/drivers/media/i2c/adv7343.c index 469e262..eb12d1a 100644 --- a/drivers/media/i2c/adv7343.c +++ b/drivers/media/i2c/adv7343.c @@ -25,12 +25,14 @@ #include #include #include +#include #include #include #include #include #include +#include #include "adv7343_regs.h" @@ -409,6 +411,75 @@ static int adv7343_initialize(struct v4l2_subdev *sd) return err; } +#if defined(CONFIG_OF) +static const struct of_device_id adv7343_of_match[] = { + {.compatible = "ad,adv7343-encoder", }, + {}, +}; +MODULE_DEVICE_TABLE(of, adv7343_of_match); + +static void adv7343_get_pdata(struct i2c_client *client, + struct adv7343_state *decoder) +{ + if (!client->dev.platform_data && client->dev.of_node) { + struct device_node *np; + struct adv7343_platform_data *pdata; + + np = v4l2_of_get_next_endpoint(client->dev.of_node, NULL); + if (!np) + return; + + pdata = devm_kzalloc(&client->dev, + sizeof(struct adv7343_platform_data), + GFP_KERNEL); + if (!pdata) { + pr_warn("adv7343 failed allocate memeory\n"); + return; + } + + 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"); + + decoder->pdata = pdata; + } +} +#else +#define adv7343_of_match NULL + +static void adv7343_get_pdata(struct i2c_client *client, + struct adv7343_state *decoder) +{ + decoder->pdata = client->dev.platform_data; +} +#endif + static int adv7343_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -426,8 +497,7 @@ static int adv7343_probe(struct i2c_client *client, if (state == NULL) return -ENOMEM; - /* Copy board specific information here */ - state->pdata = client->dev.platform_data; + adv7343_get_pdata(client, state); state->reg00 = 0x80; state->reg01 = 0x00; @@ -496,6 +566,7 @@ MODULE_DEVICE_TABLE(i2c, adv7343_id); static struct i2c_driver adv7343_driver = { .driver = { + .of_match_table = adv7343_of_match, .owner = THIS_MODULE, .name = "adv7343", },