From patchwork Wed Aug 28 15:55:57 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sylwester Nawrocki/Kernel \\(PLT\\) /SRPOL/Staff Engineer/Samsung Electronics" X-Patchwork-Id: 2850877 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 00F5C9F485 for ; Wed, 28 Aug 2013 16:00:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C168E2016C for ; Wed, 28 Aug 2013 16:00:18 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6BAF02015A for ; Wed, 28 Aug 2013 16:00:17 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VEi98-0001LR-CR; Wed, 28 Aug 2013 15:59:02 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VEi8b-0001lR-5v; Wed, 28 Aug 2013 15:58:29 +0000 Received: from mailout1.samsung.com ([203.254.224.24]) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VEi7d-0001el-L8 for linux-arm-kernel@lists.infradead.org; Wed, 28 Aug 2013 15:57:31 +0000 Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MS9004EV0AX0NN0@mailout1.samsung.com> for linux-arm-kernel@lists.infradead.org; Thu, 29 Aug 2013 00:57:07 +0900 (KST) X-AuditID: cbfee61a-b7f7a6d00000235f-d8-521e1dd2d5bb Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 2E.39.09055.2DD1E125; Thu, 29 Aug 2013 00:57:06 +0900 (KST) Received: from amdc1344.digital.local ([106.116.147.32]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MS900LE309EAJB0@mmp1.samsung.com>; Thu, 29 Aug 2013 00:57:06 +0900 (KST) From: Sylwester Nawrocki To: linux-media@vger.kernel.org Subject: [PATCH v2 4/7] V4L: s5k6a3: Add support for asynchronous subdev registration Date: Wed, 28 Aug 2013 17:55:57 +0200 Message-id: <1377705360-12197-5-git-send-email-s.nawrocki@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1377705360-12197-1-git-send-email-s.nawrocki@samsung.com> References: <1377705360-12197-1-git-send-email-s.nawrocki@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrBLMWRmVeSWpSXmKPExsVy+t9jAd1LsnJBBgtfW1jcWneO1eLjqdus Fu83zmOyODX5GZPF2aY37BadE5ewW2x6fI3VomfDVlaLpxMuslkcftPOanFm/0o2i/UzXrM4 8Hh8+BjnMbtjJqvH4a8LWTzuXNvD5rF5Sb1H35ZVjB6fN8l5nPr6mT2AI4rLJiU1J7MstUjf LoEr4+26ZqaCG5IVUxrmMjcw3hfpYuTgkBAwkTixIbaLkRPIFJO4cG89WxcjF4eQwCJGiUlN ExghnA4miaaPC1hBqtgEDCV6j/YxgtgiAvIST3pvgHUwC2xgkri74h47SEJYIFxi9ct5zCA2 i4CqxLH1G5hAbF4BN4n32+6xQmxWkJgzyQbE5BRwl7hzQQKkQgio4tHtZrYJjLwLGBlWMYqm FiQXFCel5xrqFSfmFpfmpesl5+duYgSH5zOpHYwrGywOMQpwMCrx8Eb8lg0SYk0sK67MPcQo wcGsJML7W0QuSIg3JbGyKrUoP76oNCe1+BCjNAeLkjjvgVbrQCGB9MSS1OzU1ILUIpgsEwen VAOj+dXPKadjnMteW7cdvp49Mco91IRv3yb1swVMKmWsS+9xODqpuG/++ov1xvI3YjpBjAeT IqzTZQV++NxeZ526SDDtQfpk86cJL6uPfr5tEsOeo5Xx3Pdlp/bX6SkHvpfxC2ucyJjplF9a 0TNZv1RzUuetlQ0rlZ6Kc/ou2L/W5pxVg1JTRLYSS3FGoqEWc1FxIgCeE+u9SwIAAA== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130828_115729_926358_EB3FDFA7 X-CRM114-Status: GOOD ( 14.02 ) X-Spam-Score: -9.4 (---------) Cc: linux-arm-kernel@lists.infradead.org, mturquette@linaro.org, t.figa@samsung.com, hverkuil@xs4all.nl, a.hajda@samsung.com, kyungmin.park@samsung.com, sakari.ailus@iki.fi, laurent.pinchart@ideasonboard.com, Sylwester Nawrocki , g.liakhovetski@gmx.de, arun.kk@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: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 converts the driver to use v4l2 asynchronous subdev registration API an the clock API to control the external master clock directly. Signed-off-by: Sylwester Nawrocki Signed-off-by: Kyungmin Park --- drivers/media/i2c/s5k6a3.c | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/drivers/media/i2c/s5k6a3.c b/drivers/media/i2c/s5k6a3.c index ba86e24..f65a4f8 100644 --- a/drivers/media/i2c/s5k6a3.c +++ b/drivers/media/i2c/s5k6a3.c @@ -34,6 +34,7 @@ #define S5K6A3_DEFAULT_HEIGHT 732 #define S5K6A3_DRV_NAME "S5K6A3" +#define S5K6A3_CLK_NAME "extclk" #define S5K6A3_DEFAULT_CLK_FREQ 24000000U #define S5K6A3_NUM_SUPPLIES 2 @@ -56,6 +57,7 @@ struct s5k6a3 { int gpio_reset; struct mutex lock; struct v4l2_mbus_framefmt format; + struct clk *clock; u32 clock_frequency; }; @@ -181,19 +183,25 @@ static int s5k6a3_s_power(struct v4l2_subdev *sd, int on) { struct s5k6a3 *sensor = sd_to_s5k6a3(sd); int gpio = sensor->gpio_reset; - int ret; + int ret = 0; if (on) { + ret = clk_set_rate(sensor->clock, sensor->clock_frequency); + if (ret < 0) + return ret; + ret = pm_runtime_get(sensor->dev); if (ret < 0) return ret; ret = regulator_bulk_enable(S5K6A3_NUM_SUPPLIES, sensor->supplies); - if (ret < 0) { - pm_runtime_put(sensor->dev); - return ret; - } + if (ret < 0) + goto rpm_put; + + ret = clk_prepare_enable(sensor->clock); + if (ret < 0) + goto reg_dis; if (gpio_is_valid(gpio)) { gpio_set_value(gpio, 1); @@ -209,10 +217,12 @@ static int s5k6a3_s_power(struct v4l2_subdev *sd, int on) if (gpio_is_valid(gpio)) gpio_set_value(gpio, 0); - ret = regulator_bulk_disable(S5K6A3_NUM_SUPPLIES, - sensor->supplies); - if (!ret) - pm_runtime_put(sensor->dev); + clk_disable_unprepare(sensor->clock); +reg_dis: + regulator_bulk_disable(S5K6A3_NUM_SUPPLIES, + sensor->supplies); +rpm_put: + pm_runtime_put(sensor->dev); } return ret; } @@ -240,6 +250,7 @@ static int s5k6a3_probe(struct i2c_client *client, mutex_init(&sensor->lock); sensor->gpio_reset = -EINVAL; + sensor->clock = ERR_PTR(-EINVAL); sensor->dev = dev; gpio = of_get_gpio_flags(dev->of_node, 0, NULL); @@ -266,6 +277,10 @@ static int s5k6a3_probe(struct i2c_client *client, if (ret < 0) return ret; + sensor->clock = devm_clk_get(dev, S5K6A3_CLK_NAME); + if (IS_ERR(sensor->clock)) + return -EPROBE_DEFER; + sd = &sensor->subdev; v4l2_i2c_subdev_init(sd, client, &s5k6a3_subdev_ops); sensor->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; @@ -282,7 +297,7 @@ static int s5k6a3_probe(struct i2c_client *client, pm_runtime_no_callbacks(dev); pm_runtime_enable(dev); - return 0; + return v4l2_async_register_subdev(sd); } static int s5k6a3_remove(struct i2c_client *client) @@ -290,6 +305,7 @@ static int s5k6a3_remove(struct i2c_client *client) struct v4l2_subdev *sd = i2c_get_clientdata(client); pm_runtime_disable(&client->dev); + v4l2_async_unregister_subdev(sd); media_entity_cleanup(&sd->entity); return 0; }