From patchwork Tue Dec 18 23:19:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Rosin X-Patchwork-Id: 10736897 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8A0CD6C2 for ; Wed, 19 Dec 2018 08:41:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7BCF82AEB3 for ; Wed, 19 Dec 2018 08:41:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7A3452AEDF; Wed, 19 Dec 2018 08:41:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EF5CF2AEB3 for ; Wed, 19 Dec 2018 08:41:44 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3A7016EE42; Wed, 19 Dec 2018 08:41:30 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-ve1eur03on0700.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe09::700]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1DACF6E033 for ; Tue, 18 Dec 2018 23:19:38 +0000 (UTC) Received: from VI1PR02MB5119.eurprd02.prod.outlook.com (20.178.13.204) by VI1PR02MB1293.eurprd02.prod.outlook.com (10.165.231.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1425.22; Tue, 18 Dec 2018 23:19:34 +0000 Received: from VI1PR02MB5119.eurprd02.prod.outlook.com ([fe80::11d9:9fe:f412:46a8]) by VI1PR02MB5119.eurprd02.prod.outlook.com ([fe80::11d9:9fe:f412:46a8%5]) with mapi id 15.20.1446.015; Tue, 18 Dec 2018 23:19:34 +0000 From: Peter Rosin To: "linux-kernel@vger.kernel.org" Subject: [PATCH 3/3] drm/bridge: add pwdn-gpios support to the lvds-encoder Thread-Topic: [PATCH 3/3] drm/bridge: add pwdn-gpios support to the lvds-encoder Thread-Index: AQHUlygj+VZIUCB5IkOlsrsBprD/VQ== Date: Tue, 18 Dec 2018 23:19:34 +0000 Message-ID: <20181218231850.3572-4-peda@axentia.se> References: <20181218231850.3572-1-peda@axentia.se> In-Reply-To: <20181218231850.3572-1-peda@axentia.se> Accept-Language: en-US, sv-SE Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.11.0 x-originating-ip: [85.226.244.23] x-clientproxiedby: HE1PR0502CA0005.eurprd05.prod.outlook.com (2603:10a6:3:e3::15) To VI1PR02MB5119.eurprd02.prod.outlook.com (2603:10a6:803:b7::12) x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; VI1PR02MB1293; 6:D4WtamXi4NPljBFaxKKAp9pOc6S40rcCWajJo3XlxJvR70Yx2S5omHfybAsYEC5T06xHfjBJdslR03E9gVrUrb2baRAXex0VP13WnQv8yK0qKw2+N4+NLacRAKVywoSauj1UHaUYuRlKdfNMfB5hWOZVyJHaMp51alNs1U50DsCpczhI+e8nltEie49g3jPpW+z+Fe4yXahmp7uPGl1KamfRkOJf70s0JzA3Oxb5x8QKzRLsWwirHbTQxCCER6IFqUyNM2iwjwBYoQtfrjSrjrOTonEbBgcma78e+g+26y8t7qJZTLFS5AlxulgdlfZCi3bqkhP6yOyxmZ17Q4SoTJWzRHC7bNLq38DfjsUUgQQQOEP8RLfFDEByvfSgjCEVyFv2+dN8t+DYWohPAjKDcioJSyVNWavgR7g8QIjCfZ6b7XdLYNB0iHaTkRnZlJ8+0HTJh6I8wW/F7oCJCFDP5YBCPUpAy6vtXk0GF7X92SY=; 5:wEiw05adye2jDsGtkPE557SxE+kcBgjiD7z9bCyeZVn6/DUySdvxGF0aZCNOwGNO87d4Tt5CKJ/7gstMskX+naupCod7gdXK6NhS8pGM4z5kWYo0QhreIi3dH9NA6Vx4TiK8PeebLfbkmnfcMjgvCWzZDepQDOm3s/PnLNJpXT4=; 7:8gjJ+NRRmLkIxWScHNhR75HLjMEduId8ojSXsMSQ0s4TNfSyjndYaV2SPJIZD/LihsIt67JDjILFpFoXWWxAy9AO2WQS/+IL/uyBV8TukUxkZZIyWruc1wNtStPyj+cwt9o0kWN2XujpYbrL8A4shQ== x-ms-office365-filtering-correlation-id: 15480188-0f26-468e-ebf4-08d6653f457d x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(7021145)(8989299)(4534185)(7022145)(4603075)(4627221)(201702281549075)(8990200)(7048125)(7024125)(7027125)(7023125)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:VI1PR02MB1293; x-ms-traffictypediagnostic: VI1PR02MB1293: x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(3230021)(999002)(6040522)(2401047)(8121501046)(5005006)(10201501046)(3002001)(3231475)(944501520)(52105112)(93006095)(93001095)(148016)(149066)(150057)(6041310)(20161123562045)(20161123560045)(20161123564045)(20161123558120)(2016111802025)(6043046)(201708071742011)(7699051)(76991095); SRVR:VI1PR02MB1293; BCL:0; PCL:0; RULEID:; SRVR:VI1PR02MB1293; x-forefront-prvs: 08902E536D x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(366004)(346002)(136003)(396003)(39830400003)(376002)(199004)(189003)(2351001)(305945005)(2906002)(105586002)(106356001)(7736002)(71190400001)(486006)(71200400001)(66066001)(54906003)(446003)(14454004)(50226002)(508600001)(5660300001)(81156014)(6512007)(8936002)(25786009)(476003)(11346002)(575784001)(6916009)(86362001)(53936002)(386003)(26005)(52116002)(102836004)(256004)(1076003)(8676002)(81166006)(2616005)(14444005)(68736007)(5024004)(6506007)(186003)(4326008)(36756003)(5640700003)(316002)(6486002)(6436002)(74482002)(76176011)(99286004)(3846002)(97736004)(6116002)(2501003); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR02MB1293; H:VI1PR02MB5119.eurprd02.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: axentia.se does not designate permitted sender hosts) x-microsoft-antispam-message-info: oxbD86KgeJGblCmVuTKrPyKOlcXld9QIrLTndUsRu3jzK2uK9qpCVowVtqjxXIO3BGqefEHe5EALlyhX09VHmE7P6A3c4Dj5G5ck+05w6m121F5ROQ7kYJQ9WG6gWYz2dGu9ncm8HOrNTJ8mw4+D5leu/GOXcXmwLvOsrDlOwTWjAYC2gqmtKW9sZrJ3YxnlzHdhoKireitN9hVX33yQURPAMKMp3lz6cXWaQpUWF6BZyZ5rrEft9lL8N2BjJg8yRslvzg2eAoyNXzXwLE+qcN4IlPsNUiJh68JZw1lDzo9pU2N9cBva85QUJamkB4js spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: axentia.se X-MS-Exchange-CrossTenant-Network-Message-Id: 15480188-0f26-468e-ebf4-08d6653f457d X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Dec 2018 23:19:34.6001 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 4ee68585-03e1-4785-942a-df9c1871a234 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR02MB1293 X-Mailman-Approved-At: Wed, 19 Dec 2018 08:40:40 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , "devicetree@vger.kernel.org" , David Airlie , "dri-devel@lists.freedesktop.org" , Rob Herring , Laurent Pinchart , Peter Rosin Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Optionally power down the LVDS-encoder when it is not in use. Signed-off-by: Peter Rosin --- drivers/gpu/drm/bridge/lvds-encoder.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/drivers/gpu/drm/bridge/lvds-encoder.c b/drivers/gpu/drm/bridge/lvds-encoder.c index 75b0d3f6e4de..43d584a6a6b9 100644 --- a/drivers/gpu/drm/bridge/lvds-encoder.c +++ b/drivers/gpu/drm/bridge/lvds-encoder.c @@ -11,11 +11,13 @@ #include #include +#include #include struct lvds_encoder { struct drm_bridge bridge; struct drm_bridge *panel_bridge; + struct gpio_desc *pwdn_gpio; }; static int lvds_encoder_attach(struct drm_bridge *bridge) @@ -28,8 +30,30 @@ static int lvds_encoder_attach(struct drm_bridge *bridge) bridge); } +static void lvds_encoder_enable(struct drm_bridge *bridge) +{ + struct lvds_encoder *lvds_encoder = container_of(bridge, + struct lvds_encoder, + bridge); + + if (lvds_encoder->pwdn_gpio) + gpiod_set_value_cansleep(lvds_encoder->pwdn_gpio, 0); +} + +static void lvds_encoder_disable(struct drm_bridge *bridge) +{ + struct lvds_encoder *lvds_encoder = container_of(bridge, + struct lvds_encoder, + bridge); + + if (lvds_encoder->pwdn_gpio) + gpiod_set_value_cansleep(lvds_encoder->pwdn_gpio, 1); +} + static struct drm_bridge_funcs funcs = { .attach = lvds_encoder_attach, + .enable = lvds_encoder_enable, + .disable = lvds_encoder_disable, }; static int lvds_encoder_probe(struct platform_device *pdev) @@ -45,6 +69,16 @@ static int lvds_encoder_probe(struct platform_device *pdev) if (!lvds_encoder) return -ENOMEM; + lvds_encoder->pwdn_gpio = devm_gpiod_get_optional(&pdev->dev, "pwdn", + GPIOD_OUT_HIGH); + if (IS_ERR(lvds_encoder->pwdn_gpio)) { + int err = PTR_ERR(lvds_encoder->pwdn_gpio); + + if (err != -EPROBE_DEFER) + dev_err(&pdev->dev, "pwdn GPIO failure: %d\n", err); + return err; + } + /* Locate the panel DT node. */ port = of_graph_get_port_by_id(pdev->dev.of_node, 1); if (!port) {