From patchwork Tue Jan 20 16:38:49 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajay Kumar X-Patchwork-Id: 5671021 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B561F9F357 for ; Tue, 20 Jan 2015 16:56:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CA927203C1 for ; Tue, 20 Jan 2015 16:56:53 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (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 D77DE200D4 for ; Tue, 20 Jan 2015 16:56:52 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YDc3H-0007Ev-Dh; Tue, 20 Jan 2015 16:53:15 +0000 Received: from mailout1.samsung.com ([203.254.224.24]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YDbxd-0001pc-Da for linux-arm-kernel@lists.infradead.org; Tue, 20 Jan 2015 16:47:28 +0000 Received: from epcpsbgr3.samsung.com (u143.gpu120.samsung.co.kr [203.254.230.143]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NIH001VWIMHS370@mailout1.samsung.com> for linux-arm-kernel@lists.infradead.org; Wed, 21 Jan 2015 01:47:05 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [172.20.52.123]) by epcpsbgr3.samsung.com (EPCPMTA) with SMTP id BF.5E.18484.8868EB45; Wed, 21 Jan 2015 01:47:05 +0900 (KST) X-AuditID: cbfee68f-f791c6d000004834-b2-54be86888ed0 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 64.89.09430.8868EB45; Wed, 21 Jan 2015 01:47:04 +0900 (KST) Received: from chromebld-server.sisodomain.com ([107.108.73.106]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0NIH00K6NILOY370@mmp2.samsung.com>; Wed, 21 Jan 2015 01:47:04 +0900 (KST) From: Ajay Kumar To: dri-devel@lists.freedesktop.org, linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org Subject: [PATCH V9 08/14] drm/bridge: ptn3460: use gpiod interface Date: Tue, 20 Jan 2015 22:08:49 +0530 Message-id: <1421771935-31618-9-git-send-email-ajaykumar.rs@samsung.com> X-Mailer: git-send-email 2.2.0 In-reply-to: <1421771935-31618-1-git-send-email-ajaykumar.rs@samsung.com> References: <1421771935-31618-1-git-send-email-ajaykumar.rs@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpjkeLIzCtJLcpLzFFi42JZI2JSrdvZti/E4FEzs8WB9wdZLDa8Wchs sWztPxaLhQ/vMlvMP3KO1eLK1/dsFpPuT2CxuLzwEqtF74KrbBabHl9jtZhxfh+TxarDG9gt 5h7Mtfi5ax6LA5/H3m8LWDx2zrrL7rFgU6nH/e7jTB6bl9R79G1ZxejxeZNcAHsUl01Kak5m WWqRvl0CV8ako4eYCt6pVRw4v5q5gXG1QhcjJ4eEgInEpfb37BC2mMSFe+vZuhi5OIQEljJK HH94gaWLkQOs6MRfDoj4dEaJ/l+bGSGcCUwSlx5dYgLpZhPQltg2/SYLiC0i0MUose2gOkgR s8AfRonPv/YzgiSEBZwk7s1bDmazCKhKbHzxjhnE5hXwkPg+ZQYrxBlyEltuPQI7iVPAU2LH h6tgcSGgmsXrDzODDJUQuMcONPQ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1JrKxKLcqPLyrNSS0+ xGgKdNVEZinR5Hxg2sgriTc0NjE3NTa1NLEwMbNUEudVsm8LERJITyxJzU5NLUgtgulj4uCU amBckaSY9vKlVPb9sP1cH/v5z5YVxRtOalE/cLL9Zu0MmZKaUxcNU/sMp5Y6Z0QYnH/dFjUn PUziuNZMM+X3FUXzz5f9Pr887ND22o/LVrl+XaJ6OnF6CePebRLi7/kDylvuLdc6Hh2nHuzT P+dX/iv3X2cXRn+rld9z/wf7SxOBLXqlz0pfBJ5VYinOSDTUYi4qTgQAoFnpx+MCAAA= DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150120_084725_625088_7FB7759C X-CRM114-Status: GOOD ( 13.37 ) X-Spam-Score: -5.0 (-----) Cc: kgene.kim@samsung.com, seanpaul@google.com, daniel.vetter@ffwll.ch, jg1.han@samsung.com, inki.dae@samsung.com, thierry.reding@gmail.com, ajaynumb@gmail.com, bhushan.r@samsung.com, prashanth.g@samsung.com, Ajay Kumar X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 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=-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 Modify driver to support gpiod interface. Signed-off-by: Ajay Kumar Acked-by: Inki Dae Tested-by: Rahul Sharma Tested-by: Javier Martinez Canillas Tested-by: Gustavo Padovan Tested-by: Sjoerd Simons --- drivers/gpu/drm/bridge/ptn3460.c | 88 ++++++++++++++++---------------------- 1 file changed, 36 insertions(+), 52 deletions(-) diff --git a/drivers/gpu/drm/bridge/ptn3460.c b/drivers/gpu/drm/bridge/ptn3460.c index 9f800a1..826833e 100644 --- a/drivers/gpu/drm/bridge/ptn3460.c +++ b/drivers/gpu/drm/bridge/ptn3460.c @@ -42,8 +42,8 @@ struct ptn3460_bridge { struct drm_bridge bridge; struct edid *edid; struct drm_panel *panel; - int gpio_pd_n; - int gpio_rst_n; + struct gpio_desc *gpio_pd_n; + struct gpio_desc *gpio_rst_n; u32 edid_emulation; bool enabled; }; @@ -132,14 +132,11 @@ static void ptn3460_pre_enable(struct drm_bridge *bridge) if (ptn_bridge->enabled) return; - if (gpio_is_valid(ptn_bridge->gpio_pd_n)) - gpio_set_value(ptn_bridge->gpio_pd_n, 1); + gpiod_set_value(ptn_bridge->gpio_pd_n, 1); - if (gpio_is_valid(ptn_bridge->gpio_rst_n)) { - gpio_set_value(ptn_bridge->gpio_rst_n, 0); - usleep_range(10, 20); - gpio_set_value(ptn_bridge->gpio_rst_n, 1); - } + gpiod_set_value(ptn_bridge->gpio_rst_n, 0); + usleep_range(10, 20); + gpiod_set_value(ptn_bridge->gpio_rst_n, 1); if (drm_panel_prepare(ptn_bridge->panel)) { DRM_ERROR("failed to prepare panel\n"); @@ -184,11 +181,8 @@ static void ptn3460_disable(struct drm_bridge *bridge) return; } - if (gpio_is_valid(ptn_bridge->gpio_rst_n)) - gpio_set_value(ptn_bridge->gpio_rst_n, 1); - - if (gpio_is_valid(ptn_bridge->gpio_pd_n)) - gpio_set_value(ptn_bridge->gpio_pd_n, 0); + gpiod_set_value(ptn_bridge->gpio_rst_n, 1); + gpiod_set_value(ptn_bridge->gpio_pd_n, 0); } static void ptn3460_post_disable(struct drm_bridge *bridge) @@ -335,39 +329,41 @@ static int ptn3460_probe(struct i2c_client *client, } ptn_bridge->client = client; - ptn_bridge->gpio_pd_n = of_get_named_gpio(dev->of_node, - "powerdown-gpio", 0); - if (gpio_is_valid(ptn_bridge->gpio_pd_n)) { - ret = gpio_request_one(ptn_bridge->gpio_pd_n, - GPIOF_OUT_INIT_HIGH, "PTN3460_PD_N"); - if (ret) { - dev_err(dev, "Request powerdown-gpio failed (%d)\n", - ret); - return ret; - } + + ptn_bridge->gpio_pd_n = devm_gpiod_get(&client->dev, "powerdown"); + if (IS_ERR(ptn_bridge->gpio_pd_n)) { + ret = PTR_ERR(ptn_bridge->gpio_pd_n); + dev_err(dev, "cannot get gpio_pd_n %d\n", ret); + return ret; } - ptn_bridge->gpio_rst_n = of_get_named_gpio(dev->of_node, - "reset-gpio", 0); - if (gpio_is_valid(ptn_bridge->gpio_rst_n)) { - /* - * Request the reset pin low to avoid the bridge being - * initialized prematurely - */ - ret = gpio_request_one(ptn_bridge->gpio_rst_n, - GPIOF_OUT_INIT_LOW, "PTN3460_RST_N"); - if (ret) { - dev_err(dev, "Request reset-gpio failed (%d)\n", ret); - gpio_free(ptn_bridge->gpio_pd_n); - return ret; - } + ret = gpiod_direction_output(ptn_bridge->gpio_pd_n, 1); + if (ret) { + DRM_ERROR("cannot configure gpio_pd_n\n"); + return ret; + } + + ptn_bridge->gpio_rst_n = devm_gpiod_get(&client->dev, "reset"); + if (IS_ERR(ptn_bridge->gpio_rst_n)) { + ret = PTR_ERR(ptn_bridge->gpio_rst_n); + DRM_ERROR("cannot get gpio_rst_n %d\n", ret); + return ret; + } + /* + * Request the reset pin low to avoid the bridge being + * initialized prematurely + */ + ret = gpiod_direction_output(ptn_bridge->gpio_rst_n, 0); + if (ret) { + DRM_ERROR("cannot configure gpio_rst_n\n"); + return ret; } ret = of_property_read_u32(dev->of_node, "edid-emulation", &ptn_bridge->edid_emulation); if (ret) { dev_err(dev, "Can't read EDID emulation value\n"); - goto err; + return ret; } ptn_bridge->bridge.funcs = &ptn3460_bridge_funcs; @@ -375,19 +371,12 @@ static int ptn3460_probe(struct i2c_client *client, ret = drm_bridge_add(&ptn_bridge->bridge); if (ret) { DRM_ERROR("Failed to add bridge\n"); - goto err; + return ret; } i2c_set_clientdata(client, ptn_bridge); return 0; - -err: - if (gpio_is_valid(ptn_bridge->gpio_pd_n)) - gpio_free(ptn_bridge->gpio_pd_n); - if (gpio_is_valid(ptn_bridge->gpio_rst_n)) - gpio_free(ptn_bridge->gpio_rst_n); - return ret; } static int ptn3460_remove(struct i2c_client *client) @@ -396,11 +385,6 @@ static int ptn3460_remove(struct i2c_client *client) drm_bridge_remove(&ptn_bridge->bridge); - if (gpio_is_valid(ptn_bridge->gpio_pd_n)) - gpio_free(ptn_bridge->gpio_pd_n); - if (gpio_is_valid(ptn_bridge->gpio_rst_n)) - gpio_free(ptn_bridge->gpio_rst_n); - return 0; }