0009-drm-omap-panel-dsi-cm-add-regulator-support.patch (3341B)
1 From 594f7f466237d32323f63c04e92f7ce7be2f2a4f Mon Sep 17 00:00:00 2001 2 From: Sebastian Reichel <sebastian.reichel@collabora.co.uk> 3 Date: Mon, 24 Jul 2017 19:33:06 +0200 4 Subject: [PATCH 09/17] drm/omap: panel-dsi-cm: add regulator support 5 6 Add support for regulators used by panels found inside 7 of the Nokia N950, N9 and Motorola Droid 4. 8 9 Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk> 10 --- 11 drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c | 57 +++++++++++++++++++++++-- 12 1 file changed, 53 insertions(+), 4 deletions(-) 13 14 diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 15 index 905b717..b98ea9e 100644 16 --- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 17 +++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 18 @@ -23,6 +23,7 @@ 19 #include <linux/workqueue.h> 20 #include <linux/of_device.h> 21 #include <linux/of_gpio.h> 22 +#include <linux/regulator/consumer.h> 23 24 #include <video/mipi_display.h> 25 #include <video/of_display_timing.h> 26 @@ -60,6 +61,9 @@ struct panel_drv_data { 27 int reset_gpio; 28 int ext_te_gpio; 29 30 + struct regulator *vpnl; 31 + struct regulator *vddi; 32 + 33 bool use_dsi_backlight; 34 35 struct omap_dsi_pin_config pin_config; 36 @@ -590,25 +594,43 @@ static int dsicm_power_on(struct panel_drv_data *ddata) 37 .lp_clk_max = 10000000, 38 }; 39 40 + if (ddata->vpnl) { 41 + r = regulator_enable(ddata->vpnl); 42 + if (r) { 43 + dev_err(&ddata->pdev->dev, 44 + "failed to enable VPNL: %d\n", r); 45 + return r; 46 + } 47 + } 48 + 49 + if (ddata->vddi) { 50 + r = regulator_enable(ddata->vddi); 51 + if (r) { 52 + dev_err(&ddata->pdev->dev, 53 + "failed to enable VDDI: %d\n", r); 54 + goto err_vpnl; 55 + } 56 + } 57 + 58 if (ddata->pin_config.num_pins > 0) { 59 r = in->ops.dsi->configure_pins(in, &ddata->pin_config); 60 if (r) { 61 dev_err(&ddata->pdev->dev, 62 "failed to configure DSI pins\n"); 63 - goto err0; 64 + goto err_vddi; 65 } 66 } 67 68 r = in->ops.dsi->set_config(in, &dsi_config); 69 if (r) { 70 dev_err(&ddata->pdev->dev, "failed to configure DSI\n"); 71 - goto err0; 72 + goto err_vddi; 73 } 74 75 r = in->ops.dsi->enable(in); 76 if (r) { 77 dev_err(&ddata->pdev->dev, "failed to enable DSI\n"); 78 - goto err0; 79 + goto err_vddi; 80 } 81 82 dsicm_hw_reset(ddata); 83 @@ -666,7 +688,13 @@ static int dsicm_power_on(struct panel_drv_data *ddata) 84 dsicm_hw_reset(ddata); 85 86 in->ops.dsi->disable(in, true, false); 87 -err0: 88 +err_vddi: 89 + if (ddata->vddi) 90 + regulator_disable(ddata->vddi); 91 +err_vpnl: 92 + if (ddata->vpnl) 93 + regulator_disable(ddata->vpnl); 94 + 95 return r; 96 } 97 98 @@ -689,6 +717,11 @@ static void dsicm_power_off(struct panel_drv_data *ddata) 99 100 in->ops.dsi->disable(in, true, false); 101 102 + if (ddata->vddi) 103 + regulator_disable(ddata->vddi); 104 + if (ddata->vpnl) 105 + regulator_disable(ddata->vpnl); 106 + 107 ddata->enabled = 0; 108 } 109 110 @@ -1189,6 +1222,22 @@ static int dsicm_probe_of(struct platform_device *pdev) 111 return PTR_ERR(in); 112 } 113 114 + ddata->vpnl = devm_regulator_get_optional(&pdev->dev, "vpnl"); 115 + if (IS_ERR(ddata->vpnl)) { 116 + err = PTR_ERR(ddata->vpnl); 117 + if (err == -EPROBE_DEFER) 118 + return err; 119 + ddata->vpnl = NULL; 120 + } 121 + 122 + ddata->vddi = devm_regulator_get_optional(&pdev->dev, "vddi"); 123 + if (IS_ERR(ddata->vddi)) { 124 + err = PTR_ERR(ddata->vddi); 125 + if (err == -EPROBE_DEFER) 126 + return err; 127 + ddata->vddi = NULL; 128 + } 129 + 130 ddata->in = in; 131 132 /* TODO: ulps, backlight */ 133 -- 134 2.1.4 135