On Tuesday 26 March 2013 07:03 PM, Tomi Valkeinen wrote:
Convert TFP410 driver from omap_dss_driver to a platform driver. The
driver uses the new panel support from omapdss.
Signed-off-by: Tomi Valkeinen
---
drivers/video/omap2/displays/panel-tfp410.c | 205 +--
1 file changed, 128 insertions(+), 77 deletions(-)
diff --git a/drivers/video/omap2/displays/panel-tfp410.c
b/drivers/video/omap2/displays/panel-tfp410.c
index 8281baa..a225ea1 100644
--- a/drivers/video/omap2/displays/panel-tfp410.c
+++ b/drivers/video/omap2/displays/panel-tfp410.c
@@ -22,10 +22,13 @@
#include
#include
#include
+#include
#include
#include
+static struct omap_dss_driver tfp410_driver;
+
static const struct omap_video_timings tfp410_default_timings = {
.x_res = 640,
.y_res = 480,
@@ -48,121 +51,152 @@ static const struct omap_video_timings
tfp410_default_timings = {
};
struct panel_drv_data {
- struct omap_dss_device *dssdev;
+ struct omap_dss_device dssdev;
struct mutex lock;
+ const char *name;
+
int pd_gpio;
+ int data_lines;
+
+ struct omap_video_timings timings;
struct i2c_adapter *i2c_adapter;
};
-static int tfp410_power_on(struct omap_dss_device *dssdev)
+#define to_panel_data(x) container_of(x, struct panel_drv_data, dssdev)
+
+static int tfp410_probe_pdata(struct platform_device *pdev)
{
- struct panel_drv_data *ddata = dev_get_drvdata(&dssdev->dev);
- int r;
+ struct tfp410_platform_data *pdata = dev_get_platdata(&pdev->dev);
+ struct panel_drv_data *ddata = dev_get_drvdata(&pdev->dev);
+ int r, gpio, i2c_bus_num;
- if (dssdev->state == OMAP_DSS_DISPLAY_ACTIVE)
- return 0;
+ ddata->name = pdata->name;
- omapdss_dpi_set_timings(dssdev, &dssdev->panel.timings);
- omapdss_dpi_set_data_lines(dssdev, dssdev->phy.dpi.data_lines);
+ gpio = pdata->power_down_gpio;
- r = omapdss_dpi_display_enable(dssdev);
- if (r)
- goto err0;
+ if (gpio_is_valid(gpio)) {
+ r = devm_gpio_request_one(&pdev->dev, gpio,
+ GPIOF_OUT_INIT_LOW, "tfp410 pd");
+ if (r) {
+ dev_err(&pdev->dev, "Failed to request PD GPIO %d\n",
+ gpio);
+ return r;
+ }
- if (gpio_is_valid(ddata->pd_gpio))
- gpio_set_value_cansleep(ddata->pd_gpio, 1);
+ ddata->pd_gpio = gpio;
+ } else {
+ ddata->pd_gpio = -1;
+ }
- return 0;
-err0:
- return r;
-}
+ ddata->data_lines = pdata->data_lines;
-static void tfp410_power_off(struct omap_dss_device *dssdev)
-{
- struct panel_drv_data *ddata = dev_get_drvdata(&dssdev->dev);
+ i2c_bus_num = pdata->i2c_bus_num;
- if (dssdev->state != OMAP_DSS_DISPLAY_ACTIVE)
- return;
+ if (i2c_bus_num != -1) {
+ struct i2c_adapter *adapter;
- if (gpio_is_valid(ddata->pd_gpio))
- gpio_set_value_cansleep(ddata->pd_gpio, 0);
+ adapter = i2c_get_adapter(i2c_bus_num);
+ if (!adapter) {
+ dev_err(&pdev->dev,
+ "Failed to get I2C adapter, bus %d\n",
+ i2c_bus_num);
+ return -EINVAL;
+ }
- omapdss_dpi_display_disable(dssdev);
+ ddata->i2c_adapter = adapter;
+ }
+
+ return 0;
}
-static int tfp410_probe(struct omap_dss_device *dssdev)
+static int tfp410_probe(struct platform_device *pdev)
{
+ struct tfp410_platform_data *pdata = dev_get_platdata(&pdev->dev);
+ struct omap_dss_device *dssdev;
struct panel_drv_data *ddata;
int r;
- int i2c_bus_num;
- ddata = devm_kzalloc(&dssdev->dev, sizeof(*ddata), GFP_KERNEL);
+ ddata = devm_kzalloc(&pdev->dev, sizeof(*ddata), GFP_KERNEL);
if (!ddata)
return -ENOMEM;
- dssdev->panel.timings = tfp410_default_timings;
+ dev_set_drvdata(&pdev->dev, ddata);
- ddata->dssdev = dssdev;
mutex_init(&ddata->lock);
- if (dssdev->data) {
- struct tfp410_platform_data *pdata = dssdev->data;
-
- ddata->pd_gpio = pdata->power_down_gpio;
- i2c_bus_num = pdata->i2c_bus_num;
- } else {
- ddata->pd_gpio = -1;
- i2c_bus_num = -1;
- }
-
- if (gpio_is_valid(ddata->pd_gpio)) {
- r = devm_gpio_request_one(&dssdev->dev, ddata->pd_gpio,
- GPIOF_OUT_INIT_LOW, "tfp410 pd");
- if (r) {
- dev_err(&dssdev->dev, "Failed to request PD GPIO %d\n",
- ddata->pd_gpio);
+ if (pdata) {
+