Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 31030985 authored by Tomi Valkeinen's avatar Tomi Valkeinen
Browse files

OMAPDSS: LS037V7DW01: handle gpios in panel driver



Move the GPIO handling from board file's platform callbacks to the panel
driver, which gets the gpios via platform data.

Signed-off-by: default avatarTomi Valkeinen <tomi.valkeinen@ti.com>
parent 7e930086
Loading
Loading
Loading
Loading
+60 −11
Original line number Original line Diff line number Diff line
@@ -23,11 +23,10 @@
#include <linux/fb.h>
#include <linux/fb.h>
#include <linux/err.h>
#include <linux/err.h>
#include <linux/slab.h>
#include <linux/slab.h>
#include <linux/gpio.h>


#include <video/omapdss.h>
#include <video/omapdss.h>

#include <video/omap-panel-data.h>
struct sharp_data {
};


static struct omap_video_timings sharp_ls_timings = {
static struct omap_video_timings sharp_ls_timings = {
	.x_res = 480,
	.x_res = 480,
@@ -50,31 +49,67 @@ static struct omap_video_timings sharp_ls_timings = {
	.sync_pclk_edge	= OMAPDSS_DRIVE_SIG_OPPOSITE_EDGES,
	.sync_pclk_edge	= OMAPDSS_DRIVE_SIG_OPPOSITE_EDGES,
};
};


static inline struct panel_sharp_ls037v7dw01_data
*get_panel_data(const struct omap_dss_device *dssdev)
{
	return (struct panel_sharp_ls037v7dw01_data *) dssdev->data;
}


static int sharp_ls_panel_probe(struct omap_dss_device *dssdev)
static int sharp_ls_panel_probe(struct omap_dss_device *dssdev)
{
{
	struct sharp_data *sd;
	struct panel_sharp_ls037v7dw01_data *pd = get_panel_data(dssdev);
	int r;

	if (!pd)
		return -EINVAL;


	dssdev->panel.timings = sharp_ls_timings;
	dssdev->panel.timings = sharp_ls_timings;


	sd = kzalloc(sizeof(*sd), GFP_KERNEL);
	if (gpio_is_valid(pd->mo_gpio)) {
	if (!sd)
		r = devm_gpio_request_one(&dssdev->dev, pd->mo_gpio,
		return -ENOMEM;
				GPIOF_OUT_INIT_LOW, "lcd MO");
		if (r)
			return r;
	}

	if (gpio_is_valid(pd->lr_gpio)) {
		r = devm_gpio_request_one(&dssdev->dev, pd->lr_gpio,
				GPIOF_OUT_INIT_HIGH, "lcd LR");
		if (r)
			return r;
	}

	if (gpio_is_valid(pd->ud_gpio)) {
		r = devm_gpio_request_one(&dssdev->dev, pd->ud_gpio,
				GPIOF_OUT_INIT_HIGH, "lcd UD");
		if (r)
			return r;
	}

	if (gpio_is_valid(pd->resb_gpio)) {
		r = devm_gpio_request_one(&dssdev->dev, pd->resb_gpio,
				GPIOF_OUT_INIT_LOW, "lcd RESB");
		if (r)
			return r;
	}


	dev_set_drvdata(&dssdev->dev, sd);
	if (gpio_is_valid(pd->ini_gpio)) {
		r = devm_gpio_request_one(&dssdev->dev, pd->ini_gpio,
				GPIOF_OUT_INIT_LOW, "lcd INI");
		if (r)
			return r;
	}


	return 0;
	return 0;
}
}


static void __exit sharp_ls_panel_remove(struct omap_dss_device *dssdev)
static void __exit sharp_ls_panel_remove(struct omap_dss_device *dssdev)
{
{
	struct sharp_data *sd = dev_get_drvdata(&dssdev->dev);

	kfree(sd);
}
}


static int sharp_ls_power_on(struct omap_dss_device *dssdev)
static int sharp_ls_power_on(struct omap_dss_device *dssdev)
{
{
	struct panel_sharp_ls037v7dw01_data *pd = get_panel_data(dssdev);
	int r = 0;
	int r = 0;


	if (dssdev->state == OMAP_DSS_DISPLAY_ACTIVE)
	if (dssdev->state == OMAP_DSS_DISPLAY_ACTIVE)
@@ -96,6 +131,12 @@ static int sharp_ls_power_on(struct omap_dss_device *dssdev)
			goto err1;
			goto err1;
	}
	}


	if (gpio_is_valid(pd->resb_gpio))
		gpio_set_value_cansleep(pd->resb_gpio, 1);

	if (gpio_is_valid(pd->ini_gpio))
		gpio_set_value_cansleep(pd->ini_gpio, 1);

	return 0;
	return 0;
err1:
err1:
	omapdss_dpi_display_disable(dssdev);
	omapdss_dpi_display_disable(dssdev);
@@ -105,9 +146,17 @@ err0:


static void sharp_ls_power_off(struct omap_dss_device *dssdev)
static void sharp_ls_power_off(struct omap_dss_device *dssdev)
{
{
	struct panel_sharp_ls037v7dw01_data *pd = get_panel_data(dssdev);

	if (dssdev->state != OMAP_DSS_DISPLAY_ACTIVE)
	if (dssdev->state != OMAP_DSS_DISPLAY_ACTIVE)
		return;
		return;


	if (gpio_is_valid(pd->ini_gpio))
		gpio_set_value_cansleep(pd->ini_gpio, 0);

	if (gpio_is_valid(pd->resb_gpio))
		gpio_set_value_cansleep(pd->resb_gpio, 0);

	if (dssdev->platform_disable)
	if (dssdev->platform_disable)
		dssdev->platform_disable(dssdev);
		dssdev->platform_disable(dssdev);