arm-sdk

os build toolkit for various embedded devices
git clone https://git.parazyd.org/arm-sdk
Log | Files | Refs | Submodules | README | LICENSE

0012-drm-omap-panel-dsi-cm-switch-to-gpiod.patch (5416B)


      1 From d4b696beecee6b132c024e847dc54efee05f3ccc Mon Sep 17 00:00:00 2001
      2 From: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
      3 Date: Mon, 24 Jul 2017 19:33:09 +0200
      4 Subject: [PATCH 12/17] drm/omap: panel-dsi-cm: switch to gpiod
      5 
      6 Use the new descriptor based GPIO API instead of
      7 the legacy one, which results in cleaner code
      8 with less lines of code.
      9 
     10 Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
     11 ---
     12  drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c | 74 +++++++++----------------
     13  1 file changed, 27 insertions(+), 47 deletions(-)
     14 
     15 diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
     16 index d139bb7..996991d 100644
     17 --- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
     18 +++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
     19 @@ -22,7 +22,6 @@
     20  #include <linux/slab.h>
     21  #include <linux/workqueue.h>
     22  #include <linux/of_device.h>
     23 -#include <linux/of_gpio.h>
     24  #include <linux/regulator/consumer.h>
     25  
     26  #include <video/mipi_display.h>
     27 @@ -59,8 +58,8 @@ struct panel_drv_data {
     28  	unsigned long	hw_guard_wait;	/* max guard time in jiffies */
     29  
     30  	/* panel HW configuration from DT or platform data */
     31 -	int reset_gpio;
     32 -	int ext_te_gpio;
     33 +	struct gpio_desc *reset_gpio;
     34 +	struct gpio_desc *ext_te_gpio;
     35  
     36  	struct regulator *vpnl;
     37  	struct regulator *vddi;
     38 @@ -288,8 +287,8 @@ static int dsicm_enter_ulps(struct panel_drv_data *ddata)
     39  	if (r)
     40  		goto err;
     41  
     42 -	if (gpio_is_valid(ddata->ext_te_gpio))
     43 -		disable_irq(gpio_to_irq(ddata->ext_te_gpio));
     44 +	if (ddata->ext_te_gpio)
     45 +		disable_irq(gpiod_to_irq(ddata->ext_te_gpio));
     46  
     47  	in->ops.dsi->disable(in, false, true);
     48  
     49 @@ -330,8 +329,8 @@ static int dsicm_exit_ulps(struct panel_drv_data *ddata)
     50  		goto err2;
     51  	}
     52  
     53 -	if (gpio_is_valid(ddata->ext_te_gpio))
     54 -		enable_irq(gpio_to_irq(ddata->ext_te_gpio));
     55 +	if (ddata->ext_te_gpio)
     56 +		enable_irq(gpiod_to_irq(ddata->ext_te_gpio));
     57  
     58  	dsicm_queue_ulps_work(ddata);
     59  
     60 @@ -344,8 +343,8 @@ static int dsicm_exit_ulps(struct panel_drv_data *ddata)
     61  
     62  	r = dsicm_panel_reset(ddata);
     63  	if (!r) {
     64 -		if (gpio_is_valid(ddata->ext_te_gpio))
     65 -			enable_irq(gpio_to_irq(ddata->ext_te_gpio));
     66 +		if (ddata->ext_te_gpio)
     67 +			enable_irq(gpiod_to_irq(ddata->ext_te_gpio));
     68  		ddata->ulps_enabled = false;
     69  	}
     70  err1:
     71 @@ -591,16 +590,13 @@ static const struct attribute_group dsicm_attr_group = {
     72  
     73  static void dsicm_hw_reset(struct panel_drv_data *ddata)
     74  {
     75 -	if (!gpio_is_valid(ddata->reset_gpio))
     76 -		return;
     77 -
     78 -	gpio_set_value(ddata->reset_gpio, 1);
     79 +	gpiod_set_value(ddata->reset_gpio, 1);
     80  	udelay(10);
     81  	/* reset the panel */
     82 -	gpio_set_value(ddata->reset_gpio, 0);
     83 +	gpiod_set_value(ddata->reset_gpio, 0);
     84  	/* assert reset */
     85  	udelay(10);
     86 -	gpio_set_value(ddata->reset_gpio, 1);
     87 +	gpiod_set_value(ddata->reset_gpio, 1);
     88  	/* wait after releasing reset */
     89  	usleep_range(5000, 10000);
     90  }
     91 @@ -954,7 +950,7 @@ static int dsicm_update(struct omap_dss_device *dssdev,
     92  	if (r)
     93  		goto err;
     94  
     95 -	if (ddata->te_enabled && gpio_is_valid(ddata->ext_te_gpio)) {
     96 +	if (ddata->te_enabled && ddata->ext_te_gpio) {
     97  		schedule_delayed_work(&ddata->te_timeout_work,
     98  				msecs_to_jiffies(250));
     99  		atomic_set(&ddata->do_update, 1);
    100 @@ -1001,7 +997,7 @@ static int _dsicm_enable_te(struct panel_drv_data *ddata, bool enable)
    101  	else
    102  		r = dsicm_dcs_write_0(ddata, MIPI_DCS_SET_TEAR_OFF);
    103  
    104 -	if (!gpio_is_valid(ddata->ext_te_gpio))
    105 +	if (!ddata->ext_te_gpio)
    106  		in->ops.dsi->enable_te(in, enable);
    107  
    108  	/* possible panel bug */
    109 @@ -1229,21 +1225,21 @@ static int dsicm_probe_of(struct platform_device *pdev)
    110  	struct panel_drv_data *ddata = platform_get_drvdata(pdev);
    111  	struct omap_dss_device *in;
    112  	struct display_timing timing;
    113 -	int gpio, err;
    114 +	int err;
    115  
    116 -	gpio = of_get_named_gpio(node, "reset-gpios", 0);
    117 -	if (!gpio_is_valid(gpio)) {
    118 -		dev_err(&pdev->dev, "failed to parse reset gpio\n");
    119 -		return gpio;
    120 +	ddata->reset_gpio = devm_gpiod_get(&pdev->dev, "reset", GPIOD_OUT_LOW);
    121 +	if (IS_ERR(ddata->reset_gpio)) {
    122 +		err = PTR_ERR(ddata->reset_gpio);
    123 +		dev_err(&pdev->dev, "reset gpio request failed: %d", err);
    124 +		return err;
    125  	}
    126 -	ddata->reset_gpio = gpio;
    127  
    128 -	gpio = of_get_named_gpio(node, "te-gpios", 0);
    129 -	if (gpio_is_valid(gpio) || gpio == -ENOENT) {
    130 -		ddata->ext_te_gpio = gpio;
    131 -	} else {
    132 -		dev_err(&pdev->dev, "failed to parse TE gpio\n");
    133 -		return gpio;
    134 +	ddata->ext_te_gpio = devm_gpiod_get_optional(&pdev->dev, "te",
    135 +						     GPIOD_IN);
    136 +	if (IS_ERR(ddata->ext_te_gpio)) {
    137 +		err = PTR_ERR(ddata->ext_te_gpio);
    138 +		dev_err(&pdev->dev, "TE gpio request failed: %d", err);
    139 +		return err;
    140  	}
    141  
    142  	err = of_get_display_timing(node, "panel-timing", &timing);
    143 @@ -1353,24 +1349,8 @@ static int dsicm_probe(struct platform_device *pdev)
    144  
    145  	atomic_set(&ddata->do_update, 0);
    146  
    147 -	if (gpio_is_valid(ddata->reset_gpio)) {
    148 -		r = devm_gpio_request_one(dev, ddata->reset_gpio,
    149 -				GPIOF_OUT_INIT_LOW, "taal rst");
    150 -		if (r) {
    151 -			dev_err(dev, "failed to request reset gpio\n");
    152 -			goto err_reg;
    153 -		}
    154 -	}
    155 -
    156 -	if (gpio_is_valid(ddata->ext_te_gpio)) {
    157 -		r = devm_gpio_request_one(dev, ddata->ext_te_gpio,
    158 -				GPIOF_IN, "taal irq");
    159 -		if (r) {
    160 -			dev_err(dev, "GPIO request failed\n");
    161 -			goto err_reg;
    162 -		}
    163 -
    164 -		r = devm_request_irq(dev, gpio_to_irq(ddata->ext_te_gpio),
    165 +	if (ddata->ext_te_gpio) {
    166 +		r = devm_request_irq(dev, gpiod_to_irq(ddata->ext_te_gpio),
    167  				dsicm_te_isr,
    168  				IRQF_TRIGGER_RISING,
    169  				"taal vsync", ddata);
    170 -- 
    171 2.1.4
    172