From patchwork Tue Dec 15 10:45:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 11974403 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A5840C2BB48 for ; Tue, 15 Dec 2020 10:47:32 +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 5549620782 for ; Tue, 15 Dec 2020 10:47:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5549620782 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=ti.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 0C6E36E1D3; Tue, 15 Dec 2020 10:47:27 +0000 (UTC) Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) by gabe.freedesktop.org (Postfix) with ESMTPS id EDF026E1BD for ; Tue, 15 Dec 2020 10:47:22 +0000 (UTC) Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 0BFAlMhx010507 for ; Tue, 15 Dec 2020 04:47:22 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1608029242; bh=Be7BEzEGyAI04Gfy34kqjJUlQddas5ADhfnSvCOMAC8=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=fCHsBioZef3zNjXlzS6FmAeBPzjpKLU40QsqIMf5Qe2R+w/dj8gVPt0lF7ewPPLGG dDUqokN8sH6QLAL+oGMXhm1RYq6m6uRBcDQcuV3MCZotPmTvqQjKeooRXMUrMaZXHW Kq5x9q3o2I5T5T9r3xn1HxOpiqW3fhnuo/KdtYMs= Received: from DFLE102.ent.ti.com (dfle102.ent.ti.com [10.64.6.23]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 0BFAlMgZ022959 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Tue, 15 Dec 2020 04:47:22 -0600 Received: from DFLE112.ent.ti.com (10.64.6.33) by DFLE102.ent.ti.com (10.64.6.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3; Tue, 15 Dec 2020 04:47:22 -0600 Received: from fllv0040.itg.ti.com (10.64.41.20) by DFLE112.ent.ti.com (10.64.6.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3 via Frontend Transport; Tue, 15 Dec 2020 04:47:22 -0600 Received: from deskari.lan (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id 0BFAkwa8046467; Tue, 15 Dec 2020 04:47:21 -0600 From: Tomi Valkeinen To: Subject: [PATCH v6 22/84] drm/omap: panel-dsi-cm: use bulk regulator API Date: Tue, 15 Dec 2020 12:45:55 +0200 Message-ID: <20201215104657.802264-23-tomi.valkeinen@ti.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201215104657.802264-1-tomi.valkeinen@ti.com> References: <20201215104657.802264-1-tomi.valkeinen@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: tomi.valkeinen@ti.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Sebastian Reichel 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 Signed-off-by: Tomi Valkeinen Reviewed-by: Laurent Pinchart --- .../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 1f4d67566e75..8534d0633e37 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; @@ -556,28 +557,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(ARRAY_SIZE(ddata->supplies), 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); @@ -636,12 +625,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(ARRAY_SIZE(ddata->supplies), ddata->supplies); + if (r) + dev_err(&ddata->dsi->dev, "failed to disable supplies: %d\n", r); return r; } @@ -665,10 +652,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(ARRAY_SIZE(ddata->supplies), ddata->supplies); + if (r) + dev_err(&ddata->dsi->dev, "failed to disable supplies: %d\n", r); ddata->enabled = false; } @@ -972,21 +958,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, ARRAY_SIZE(ddata->supplies), + ddata->supplies); + if (err) + return err; backlight = devm_of_find_backlight(&dsi->dev); if (IS_ERR(backlight))