From patchwork Fri Jan 11 15:19:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Rosin X-Patchwork-Id: 10761357 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 A09541580 for ; Sun, 13 Jan 2019 16:53:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8E5B82889E for ; Sun, 13 Jan 2019 16:53:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 82A2828995; Sun, 13 Jan 2019 16:53:24 +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 36AE02889E for ; Sun, 13 Jan 2019 16:53:24 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 634366E521; Sun, 13 Jan 2019 16:53:16 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70112.outbound.protection.outlook.com [40.107.7.112]) by gabe.freedesktop.org (Postfix) with ESMTPS id 73B326F766 for ; Fri, 11 Jan 2019 15:19:19 +0000 (UTC) Received: from AM6PR02MB4470.eurprd02.prod.outlook.com (20.177.191.218) by AM6PR02MB3735.eurprd02.prod.outlook.com (52.134.113.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1516.13; Fri, 11 Jan 2019 15:19:17 +0000 Received: from AM6PR02MB4470.eurprd02.prod.outlook.com ([fe80::e5f3:a239:2ec4:4453]) by AM6PR02MB4470.eurprd02.prod.outlook.com ([fe80::e5f3:a239:2ec4:4453%6]) with mapi id 15.20.1516.016; Fri, 11 Jan 2019 15:19:17 +0000 From: Peter Rosin To: "linux-kernel@vger.kernel.org" Subject: [PATCH v4 5/5] drm/bridge: lvds-encoder: add powerdown-gpios support Thread-Topic: [PATCH v4 5/5] drm/bridge: lvds-encoder: add powerdown-gpios support Thread-Index: AQHUqcEEETjnMRW/6keq9Pzr1i6FMg== Date: Fri, 11 Jan 2019 15:19:17 +0000 Message-ID: <20190111151843.11114-6-peda@axentia.se> References: <20190111151843.11114-1-peda@axentia.se> In-Reply-To: <20190111151843.11114-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: HE1PR07CA0035.eurprd07.prod.outlook.com (2603:10a6:7:66::21) To AM6PR02MB4470.eurprd02.prod.outlook.com (2603:10a6:20b:60::26) x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; AM6PR02MB3735; 6:1FrQwai4gvl2zrnbKqLlJK+HjqWmtivxgjuDebElDeglXPWTsREix8CuAX3rOS+G1tZJzJKf6zkH94SLZ6jZre3KhFNe7oVLpt34wHP/si1syGwa3uyj28Fcy17n53Kexg1wJvW2B95ZJBMIeMQ2m3sSQyy6WBoQZIRjOjR55Dmc8wgPOVIhB0PS3Yq3o0KlmCIoHmHFpFpttGGkiWkIfnOI/oVnTP5awRirHSVTlOk7gXOHqlEh/IN0+F/snaK1FNhNM70TAXY2eWWpRMVoAwcHyJ305iPqTDSad/qF+7c0UiOcaaL4pK42NgseLX9lkcTK6JA1JNLzCejAmduWT1QrhsHYreT4vW73YA3j2yE+/W6+zcMrVutNU2Bf6+xNybfVtfKev3Io3GjNRPDAcsgnszfSQI4520/zqkNWTWdpxsEn+DPxX1P800+J1hCk7AXRy+0cbbDDoFhY486/Og==; 5:ILar9w64CeYz/QDsYUCyIH7sKH1gjOFbJtDgZ6yLGvWzBSQ/Z4ESDmAOsdGlybISbbIx9OWLlZyaVeaalAp+PxF59tJ5YdKtCsqwLSnm9u8bH1JxRXTIk3J05xrHczI902T3zPhfafD8UnzpiGEop/+w1X2gAv5Pozp1L2lZFvDO5EsA/hJqTb5fQblkAu0n10oO+EPgVv1DxUesPpfRTg==; 7:gEuZJsU0BiBSoGWJ1eabQBXxBcTCiCh7F4zeLomqZHClPm9O+8Zqgi1rZHO6ToGSujGuIrt0pv5OZmqYlkxK0fIOmDd7cE8VvM0bsaHX5Q/hzKEcMpLmg/wi//mKrTS/7e3yMpo1k9WYQSf6QQvgGw== x-ms-office365-filtering-correlation-id: 0459a46b-9908-483e-2e63-08d677d826f8 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(7021145)(8989299)(4534185)(7022145)(4603075)(4627221)(201702281549075)(8990200)(7048125)(7024125)(7027125)(7023125)(5600109)(711020)(2017052603328)(7153060)(7193020); SRVR:AM6PR02MB3735; x-ms-traffictypediagnostic: AM6PR02MB3735: x-microsoft-antispam-prvs: x-forefront-prvs: 09144DB0F7 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(396003)(376002)(366004)(346002)(136003)(39830400003)(189003)(199004)(2501003)(1076003)(14454004)(99286004)(54906003)(508600001)(5640700003)(68736007)(6436002)(97736004)(2906002)(71190400001)(2351001)(106356001)(6486002)(316002)(105586002)(71200400001)(86362001)(386003)(6506007)(102836004)(66066001)(6116002)(52116002)(76176011)(3846002)(6512007)(53936002)(2616005)(11346002)(476003)(446003)(74482002)(8676002)(81156014)(81166006)(186003)(486006)(5024004)(256004)(26005)(50226002)(8936002)(14444005)(305945005)(7736002)(5660300001)(6916009)(25786009)(4326008)(36756003); DIR:OUT; SFP:1102; SCL:1; SRVR:AM6PR02MB3735; H:AM6PR02MB4470.eurprd02.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: axentia.se does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: mNV1DamDWVm7AH2/WvNgPu+ciYXqa0yztcF6t++JX8YwA5SIuShZwt/0ZBmBflzRQksjhgK+o7F4fl1kSt4wED9gLoaKbMcI+7DLBk4B9qjVBFjxpoXFu4yDxU71fxlN9MiT/27LpnB/bk7ojOq8ns963DCcEC81Delw1w3fUlbnnTE5zFYGYd5y28EpOTJJhTondY2RfBnbMyySQs0/FrARY6u1Gte7sVDBjheiQaRXcvKNzxzQyD+1pilmg4K9WxKR0yT+BUfqIn+0Ybvzs0Bccb0eKoiTHwf78NmG49rMy+jbp6JeGGKrOHi/YszBYCsuDaktUgQAmVGXUJwbDjcE3dGX9Jss9YndvhZTzZ4fPRSmL8sesD+5cTK2WmvQd0UcLoXKnEkRgyHLXNOvIlMvbyZYHZV4r1gRkuXFVoE= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: axentia.se X-MS-Exchange-CrossTenant-Network-Message-Id: 0459a46b-9908-483e-2e63-08d677d826f8 X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Jan 2019 15:19:16.3639 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 4ee68585-03e1-4785-942a-df9c1871a234 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR02MB3735 X-Mailman-Approved-At: Sun, 13 Jan 2019 16:52:57 +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 Reviewed-by: Andrzej Hajda --- 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 f6770e83d49d..36d8557bc097 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 *powerdown_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->powerdown_gpio) + gpiod_set_value_cansleep(lvds_encoder->powerdown_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->powerdown_gpio) + gpiod_set_value_cansleep(lvds_encoder->powerdown_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->powerdown_gpio = devm_gpiod_get_optional(dev, "powerdown", + GPIOD_OUT_HIGH); + if (IS_ERR(lvds_encoder->powerdown_gpio)) { + int err = PTR_ERR(lvds_encoder->powerdown_gpio); + + if (err != -EPROBE_DEFER) + dev_err(dev, "powerdown GPIO failure: %d\n", err); + return err; + } + /* Locate the panel DT node. */ port = of_graph_get_port_by_id(dev->of_node, 1); if (!port) {