From patchwork Sun May 26 13:55:33 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 2616031 Return-Path: X-Original-To: patchwork-davinci@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from comal.ext.ti.com (comal.ext.ti.com [198.47.26.152]) by patchwork2.kernel.org (Postfix) with ESMTP id 2989DDFB79 for ; Sun, 26 May 2013 13:57:59 +0000 (UTC) Received: from dflxv15.itg.ti.com ([128.247.5.124]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id r4QDuENC006417; Sun, 26 May 2013 08:56:14 -0500 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id r4QDuDib018778; Sun, 26 May 2013 08:56:13 -0500 Received: from dlelxv24.itg.ti.com (172.17.1.199) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.2.342.3; Sun, 26 May 2013 08:56:13 -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 r4QDuD00018642; Sun, 26 May 2013 08:56:13 -0500 Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id C7FEE80627; Sun, 26 May 2013 08:56:12 -0500 (CDT) X-Original-To: davinci-linux-open-source@linux.davincidsp.com Delivered-To: davinci-linux-open-source@linux.davincidsp.com Received: from dflp52.itg.ti.com (dflp52.itg.ti.com [128.247.22.96]) by linux.omap.com (Postfix) with ESMTP id 1F24D80626 for ; Sun, 26 May 2013 08:56:10 -0500 (CDT) Received: from red.ext.ti.com (red.ext.ti.com [192.94.93.37]) by dflp52.itg.ti.com (8.13.7/8.13.8) with ESMTP id r4QDu9gQ019715 for ; Sun, 26 May 2013 08:56:09 -0500 (CDT) Received: from mail6.bemta8.messagelabs.com (mail6.bemta8.messagelabs.com [216.82.243.55]) by red.ext.ti.com (8.13.7/8.13.7) with ESMTP id r4QDu8js031338 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sun, 26 May 2013 08:56:09 -0500 Received: from [216.82.242.147:14569] by server-13.bemta-8.messagelabs.com id 48/70-15464-87412A15; Sun, 26 May 2013 13:56:08 +0000 X-Env-Sender: prabhakar.csengg@gmail.com X-Msg-Ref: server-11.tower-95.messagelabs.com!1369576566!23500250!1 X-Originating-IP: [209.85.160.53] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG, ML_RADAR_SPEW_LINKS_14,spamassassin: X-StarScan-Received: X-StarScan-Version: 6.8.6.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 22745 invoked from network); 26 May 2013 13:56:07 -0000 Received: from mail-pb0-f53.google.com (HELO mail-pb0-f53.google.com) (209.85.160.53) by server-11.tower-95.messagelabs.com with RC4-SHA encrypted SMTP; 26 May 2013 13:56:07 -0000 Received: by mail-pb0-f53.google.com with SMTP id un4so5848016pbc.26 for ; Sun, 26 May 2013 06:56:06 -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=4jAPYA3fDobvIx1h9PzRg5qbVI/6fw6ew714rZe/H6g=; b=W9Rm5+eb69WliMcdHOBODTWoFBEXxuzXC2WVN214TOYF33s7YXdv61MaP1J7PTaq1L z1k57NYdL6CFoc2Xk3ERFyHCf4NrXn9mglxtEJtif3Bvr759Aaer37MUsdjMP+kNCZB1 06vGwiAR05ce4TxrUe2B9D4l0OeDCm4GFszV5FP18wU0bVfcpMGEgUG7xaigVswxXXII 8hBotgjf+orY1d8r28feKeSppsM8lm0bJQpYWK380lxQYSDY7gyforrOKYG+moqOwJE+ AlvaNHDPELG+BDDYB3FcF+Dj0QsRjyUqy0o8qw6FGJid9Qxom3VXPy4oIrNvmzFf+Qkb sscA== X-Received: by 10.66.11.164 with SMTP id r4mr25970786pab.221.1369576566180; Sun, 26 May 2013 06:56:06 -0700 (PDT) Received: from localhost.localdomain ([112.79.40.196]) by mx.google.com with ESMTPSA id pb5sm24083096pbc.29.2013.05.26.06.55.48 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Sun, 26 May 2013 06:56:04 -0700 (PDT) From: Prabhakar Lad To: Hans Verkuil , Mauro Carvalho Chehab , LMML , Laurent Pinchart Subject: [PATCH] media: i2c: ths7303: add OF support Date: Sun, 26 May 2013 19:25:33 +0530 Message-ID: <1369576533-11277-1-git-send-email-prabhakar.csengg@gmail.com> X-Mailer: git-send-email 1.7.0.4 CC: Rob Landley , DLOS , Mauro Carvalho Chehab , , , LKML , 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@linux.davincidsp.com From: Lad, Prabhakar add OF support for the ths7303 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/ths73x3.txt | 50 ++++++++++++++++++++ drivers/media/i2c/ths7303.c | 40 +++++++++++++++- 2 files changed, 89 insertions(+), 1 deletions(-) create mode 100644 Documentation/devicetree/bindings/media/i2c/ths73x3.txt diff --git a/Documentation/devicetree/bindings/media/i2c/ths73x3.txt b/Documentation/devicetree/bindings/media/i2c/ths73x3.txt new file mode 100644 index 0000000..62f63e8 --- /dev/null +++ b/Documentation/devicetree/bindings/media/i2c/ths73x3.txt @@ -0,0 +1,50 @@ +* Texas Instruments THS7303/THS7353 video amplifier + +The THS7303/THS7353 device is a low power 3-channel integrated video buffer +which can be configured individually via i2c for all the functions which makes +it flexible for any application. It incorporates a selectable fifth-order +Butterworth filter to eliminate data converter images. + +Required Properties : +- compatible : value should be either one among the following + (a) "ti,ths7303" for ths7303 video amplifier. + (b) "ti,ths7353" for ths7353 video amplifier. + +- ti,ths73x3-ch1-bias: Bias value for channel 1. + +- ti,ths73x3-ch2-bias: Bias value for channel 2. + +- ti,ths73x3-ch3-bias: Bias value for channel 3. + +Bias values for channel-1/2/3 can be following (values default to zero):- + - 0: Disable Channel - Conserves Power + - 1: Channel On - Mute Function - No Output + - 2: Channel On - DC Bias Select + - 3: Channel On - DC Bias + 250 mV Offset Select + - 4: Channel On - AC Bias Select + - 5: Channel On - Sync Tip Clam with low bias + - 6: Channel On - Sync Tip Clam with mid bias + - 7: Channel On - Sync Tip Clam with high bias + +For further reading of port node refer Documentation/devicetree/bindings/media/ +video-interfaces.txt. + +Example: + + i2c0@1c22000 { + ... + ... + ths7303@2c { + compatible = "ti,ths7303"; + reg = <0x2c>; + + port { + ths7303_1: endpoint { + ti,ths73x3-ch1-bias = <3>; + ti,ths73x3-ch2-bias = <3>; + ti,ths73x3-ch3-bias = <3>; + }; + }; + }; + ... + }; diff --git a/drivers/media/i2c/ths7303.c b/drivers/media/i2c/ths7303.c index b954195..b218b0f 100644 --- a/drivers/media/i2c/ths7303.c +++ b/drivers/media/i2c/ths7303.c @@ -28,6 +28,7 @@ #include #include #include +#include #define THS7303_CHANNEL_1 1 #define THS7303_CHANNEL_2 2 @@ -349,10 +350,37 @@ static const struct v4l2_subdev_ops ths7303_ops = { .video = &ths7303_video_ops, }; +static struct ths7303_platform_data * +ths7303_get_pdata(struct i2c_client *client) +{ + struct ths7303_platform_data *pdata; + struct device_node *endpoint; + + if (!IS_ENABLED(CONFIG_OF) || !client->dev.of_node) + return client->dev.platform_data; + + endpoint = v4l2_of_get_next_endpoint(client->dev.of_node, NULL); + if (!endpoint) + return NULL; + + pdata = devm_kzalloc(&client->dev, sizeof(*pdata), GFP_KERNEL); + if (!pdata) + goto done; + + of_property_read_u8(endpoint, "ti,ths73x3-ch1-bias", &pdata->ch_1); + of_property_read_u8(endpoint, "ti,ths73x3-ch2-bias", &pdata->ch_2); + of_property_read_u8(endpoint, "ti,ths73x3-ch3-bias", &pdata->ch_3); + +done: + of_node_put(endpoint); + + return pdata; +} + static int ths7303_probe(struct i2c_client *client, const struct i2c_device_id *id) { - struct ths7303_platform_data *pdata = client->dev.platform_data; + struct ths7303_platform_data *pdata = ths7303_get_pdata(client); struct ths7303_state *state; struct v4l2_subdev *sd; @@ -405,8 +433,18 @@ static const struct i2c_device_id ths7303_id[] = { MODULE_DEVICE_TABLE(i2c, ths7303_id); +#if IS_ENABLED(CONFIG_OF) +static const struct of_device_id ths73x3_of_match[] = { + { .compatible = "ti,ths7303", }, + { .compatible = "ti,ths7353", }, + { /* sentinel */ }, +}; +MODULE_DEVICE_TABLE(of, ths73x3_of_match); +#endif + static struct i2c_driver ths7303_driver = { .driver = { + .of_match_table = of_match_ptr(ths73x3_of_match), .owner = THIS_MODULE, .name = "ths73x3", },