From patchwork Sun Nov 17 02:40:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Reichel X-Patchwork-Id: 11248127 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4427914DB for ; Sun, 17 Nov 2019 11:45:20 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2C51E20730 for ; Sun, 17 Nov 2019 11:45:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2C51E20730 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=collabora.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9587F6E2EA; Sun, 17 Nov 2019 11:44:40 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by gabe.freedesktop.org (Postfix) with ESMTPS id BF5786E283 for ; Sun, 17 Nov 2019 07:11:03 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: sre) with ESMTPSA id 5BE1D28FCB0 Received: by earth.universe (Postfix, from userid 1000) id 09AAD3C0CA2; Sun, 17 Nov 2019 03:41:40 +0100 (CET) From: Sebastian Reichel To: Sebastian Reichel , Laurent Pinchart , Tomi Valkeinen Subject: [RFCv1 22/42] drm/omap: panel-dsi-cm: use bulk regulator API Date: Sun, 17 Nov 2019 03:40:08 +0100 Message-Id: <20191117024028.2233-23-sebastian.reichel@collabora.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191117024028.2233-1-sebastian.reichel@collabora.com> References: <20191117024028.2233-1-sebastian.reichel@collabora.com> MIME-Version: 1.0 X-Mailman-Approved-At: Sun, 17 Nov 2019 11:44:18 +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: kernel@collabora.com, Tony Lindgren , "H. Nikolaus Schaller" , Merlijn Wajer , Sebastian Reichel , dri-devel@lists.freedesktop.org, linux-omap@vger.kernel.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Use bulk regulator API to simplify the code. This also switches from _optional variant to normal variant, which will provide a dummy regulator (i.e. if some always-enabled regulator is not described in DT). Signed-off-by: Sebastian Reichel --- .../gpu/drm/omapdrm/displays/panel-dsi-cm.c | 65 ++++++------------- 1 file changed, 21 insertions(+), 44 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c index e4120d484f4c..170cbc78fbef 100644 --- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c +++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c @@ -32,6 +32,8 @@ #define DCS_GET_ID2 0xdb #define DCS_GET_ID3 0xdc +#define DCS_REGULATOR_SUPPLY_NUM 2 + struct panel_drv_data { struct mipi_dsi_device *dsi; @@ -54,8 +56,7 @@ struct panel_drv_data { struct gpio_desc *reset_gpio; struct gpio_desc *ext_te_gpio; - struct regulator *vpnl; - struct regulator *vddi; + struct regulator_bulk_data supplies[DCS_REGULATOR_SUPPLY_NUM]; bool use_dsi_backlight; @@ -557,28 +558,16 @@ static int dsicm_power_on(struct panel_drv_data *ddata) .lp_clk_max = 10000000, }; - if (ddata->vpnl) { - r = regulator_enable(ddata->vpnl); - if (r) { - dev_err(&ddata->dsi->dev, - "failed to enable VPNL: %d\n", r); - return r; - } - } - - if (ddata->vddi) { - r = regulator_enable(ddata->vddi); - if (r) { - dev_err(&ddata->dsi->dev, - "failed to enable VDDI: %d\n", r); - goto err_vpnl; - } + r = regulator_bulk_enable(DCS_REGULATOR_SUPPLY_NUM, ddata->supplies); + if (r) { + dev_err(&ddata->dsi->dev, "failed to enable supplies: %d\n", r); + return r; } r = src->ops->dsi.set_config(src, &dsi_config); if (r) { dev_err(&ddata->dsi->dev, "failed to configure DSI\n"); - goto err_vddi; + goto err_regulators; } src->ops->enable(src); @@ -637,12 +626,10 @@ static int dsicm_power_on(struct panel_drv_data *ddata) dsicm_hw_reset(ddata); src->ops->dsi.disable(src, true, false); -err_vddi: - if (ddata->vddi) - regulator_disable(ddata->vddi); -err_vpnl: - if (ddata->vpnl) - regulator_disable(ddata->vpnl); +err_regulators: + r = regulator_bulk_disable(DCS_REGULATOR_SUPPLY_NUM, ddata->supplies); + if (r) + dev_err(&ddata->dsi->dev, "failed to disable supplies: %d\n", r); return r; } @@ -666,10 +653,9 @@ static void dsicm_power_off(struct panel_drv_data *ddata) src->ops->dsi.disable(src, true, false); - if (ddata->vddi) - regulator_disable(ddata->vddi); - if (ddata->vpnl) - regulator_disable(ddata->vpnl); + r = regulator_bulk_disable(DCS_REGULATOR_SUPPLY_NUM, ddata->supplies); + if (r) + dev_err(&ddata->dsi->dev, "failed to disable supplies: %d\n", r); ddata->enabled = 0; } @@ -973,21 +959,12 @@ static int dsicm_probe_of(struct mipi_dsi_device *dsi) ddata->height_mm = 0; of_property_read_u32(node, "height-mm", &ddata->height_mm); - ddata->vpnl = devm_regulator_get_optional(&dsi->dev, "vpnl"); - if (IS_ERR(ddata->vpnl)) { - err = PTR_ERR(ddata->vpnl); - if (err == -EPROBE_DEFER) - return err; - ddata->vpnl = NULL; - } - - ddata->vddi = devm_regulator_get_optional(&dsi->dev, "vddi"); - if (IS_ERR(ddata->vddi)) { - err = PTR_ERR(ddata->vddi); - if (err == -EPROBE_DEFER) - return err; - ddata->vddi = NULL; - } + ddata->supplies[0].supply = "vpnl"; + ddata->supplies[1].supply = "vddi"; + err = devm_regulator_bulk_get(&dsi->dev, DCS_REGULATOR_SUPPLY_NUM, + ddata->supplies); + if (err) + return err; backlight = of_parse_phandle(node, "backlight", 0); if (backlight) {