drm/sun4i: sun6i_mipi_dsi: Add VCC-DSI regulator support
authorJagan Teki <jagan@amarulasolutions.com>
Thu, 3 Oct 2019 06:45:25 +0000 (12:15 +0530)
committerMaxime Ripard <mripard@kernel.org>
Thu, 3 Oct 2019 11:48:43 +0000 (13:48 +0200)
Allwinner MIPI DSI controllers are supplied with SoC
DSI power rails via VCC-DSI pin.

Add support for this supply pin by adding voltage
regulator handling code to MIPI DSI driver.

Tested-by: Merlijn Wajer <merlijn@wizzup.org>
Reviewed-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
Signed-off-by: Maxime Ripard <mripard@kernel.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20191003064527.15128-6-jagan@amarulasolutions.com
drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c
drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h

index 472f739..1f63234 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
 #include <linux/regmap.h>
+#include <linux/regulator/consumer.h>
 #include <linux/reset.h>
 #include <linux/slab.h>
 
@@ -1099,6 +1100,12 @@ static int sun6i_dsi_probe(struct platform_device *pdev)
                return PTR_ERR(base);
        }
 
+       dsi->regulator = devm_regulator_get(dev, "vcc-dsi");
+       if (IS_ERR(dsi->regulator)) {
+               dev_err(dev, "Couldn't get VCC-DSI supply\n");
+               return PTR_ERR(dsi->regulator);
+       }
+
        dsi->regs = devm_regmap_init_mmio_clk(dev, "bus", base,
                                              &sun6i_dsi_regmap_config);
        if (IS_ERR(dsi->regs)) {
@@ -1172,6 +1179,13 @@ static int sun6i_dsi_remove(struct platform_device *pdev)
 static int __maybe_unused sun6i_dsi_runtime_resume(struct device *dev)
 {
        struct sun6i_dsi *dsi = dev_get_drvdata(dev);
+       int err;
+
+       err = regulator_enable(dsi->regulator);
+       if (err) {
+               dev_err(dsi->dev, "failed to enable VCC-DSI supply: %d\n", err);
+               return err;
+       }
 
        reset_control_deassert(dsi->reset);
        clk_prepare_enable(dsi->mod_clk);
@@ -1204,6 +1218,7 @@ static int __maybe_unused sun6i_dsi_runtime_suspend(struct device *dev)
 
        clk_disable_unprepare(dsi->mod_clk);
        reset_control_assert(dsi->reset);
+       regulator_disable(dsi->regulator);
 
        return 0;
 }
index 5c3ad5b..3f4846f 100644 (file)
@@ -23,6 +23,7 @@ struct sun6i_dsi {
        struct clk              *bus_clk;
        struct clk              *mod_clk;
        struct regmap           *regs;
+       struct regulator        *regulator;
        struct reset_control    *reset;
        struct phy              *dphy;