From patchwork Sat Nov 15 09:55:03 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajay Kumar X-Patchwork-Id: 5311201 Return-Path: X-Original-To: patchwork-linux-samsung-soc@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 84A5D9F440 for ; Sat, 15 Nov 2014 10:01:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 93CDB20123 for ; Sat, 15 Nov 2014 10:01:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 82A0D20121 for ; Sat, 15 Nov 2014 10:01:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752585AbaKOKBx (ORCPT ); Sat, 15 Nov 2014 05:01:53 -0500 Received: from mailout2.samsung.com ([203.254.224.25]:44657 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752412AbaKOKBw (ORCPT ); Sat, 15 Nov 2014 05:01:52 -0500 Received: from epcpsbgr3.samsung.com (u143.gpu120.samsung.co.kr [203.254.230.143]) by mailout2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NF20044XRV3OIA0@mailout2.samsung.com>; Sat, 15 Nov 2014 19:01:51 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [172.20.52.125]) by epcpsbgr3.samsung.com (EPCPMTA) with SMTP id E9.E1.18484.F8427645; Sat, 15 Nov 2014 19:01:51 +0900 (KST) X-AuditID: cbfee68f-f791c6d000004834-2f-5467248f9163 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id DE.3D.20081.F8427645; Sat, 15 Nov 2014 19:01:51 +0900 (KST) Received: from chromebld-server.sisodomain.com ([107.108.73.106]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0NF200LRLRTSF980@mmp1.samsung.com>; Sat, 15 Nov 2014 19:01:51 +0900 (KST) From: Ajay Kumar To: dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-samsung-soc@vger.kernel.org Cc: inki.dae@samsung.com, kgene.kim@samsung.com, seanpaul@google.com, thierry.reding@gmail.com, daniel.vetter@ffwll.ch, ajaynumb@gmail.com, bhushan.r@samsung.com, prashanth.g@samsung.com, Ajay Kumar Subject: [PATCH V8 08/14] drm/bridge: ptn3460: use gpiod interface Date: Sat, 15 Nov 2014 15:25:03 +0530 Message-id: <1416045309-13359-9-git-send-email-ajaykumar.rs@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1416045309-13359-1-git-send-email-ajaykumar.rs@samsung.com> References: <1416045309-13359-1-git-send-email-ajaykumar.rs@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpgkeLIzCtJLcpLzFFi42JZI2JSq9uvkh5icG63sMWB9wdZLDa8Wchs sWztPxaLhQ/vMlvMP3KO1eLK1/dsFpPuT2Cx6F1wlc1i0+NrrBYzzu9jslh1eAO7xdyDuRY/ d81jceD12PttAYvHzll32T0WbCr1uN99nMlj85J6j74tqxg9Pm+SC2CP4rJJSc3JLEst0rdL 4Mo4tmQpY8EFlYrpp+azNDAul+ti5OSQEDCRaPmykgXCFpO4cG89G4gtJLCUUWLTS98uRg6w msMLPLoYuYDCixglpt34wwrhTGCS2DGnhRGkgU1AW2Lb9JssIAkRgS5GifcHVrGDOMwCzxkl 5l3oAFshLOAk8X/BJ2YQm0VAVeLVzQ6wdbwCHhLL7y9mgVinIDFnkg1ImFPAU2L7x/ksEBd5 SKw9+I8NZKaEwDV2ib1Xd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fnxRaU5q8SFGU6Cj JjJLiSbnA5NFXkm8obGJuamxqaWJhYmZpZI474FW60AhgfTEktTs1NSC1CKYPiYOTqkGRlPr k2sLLLg7J6z6X5dbMFmS0dYgyptT8WK6cnzFgz5G9jvV7xcuPbTr2CYu49de07ie8GrN3vj7 pHzBjx0buz+/L+08UrS1iqXqYIwa8y7zRcv2L689z7Zhde+5mtOqOxMvCfbeKJNtjoxYEZzx W7+WM4ZlUmOmZEHrSwfZa5zRn00Up+ZIKrEUZyQaajEXFScCADQoQtreAgAA DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 --- 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; }