2 * TFP410 DPI-to-DVI encoder driver
4 * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
5 * Author: Tomi Valkeinen <tomi.valkeinen@ti.com>
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 as published by
9 * the Free Software Foundation.
12 #include <linux/gpio/consumer.h>
13 #include <linux/module.h>
14 #include <linux/platform_device.h>
15 #include <linux/slab.h>
17 #include "../dss/omapdss.h"
19 struct panel_drv_data {
20 struct omap_dss_device dssdev;
22 struct gpio_desc *pd_gpio;
25 #define to_panel_data(x) container_of(x, struct panel_drv_data, dssdev)
27 static int tfp410_connect(struct omap_dss_device *src,
28 struct omap_dss_device *dst)
30 return omapdss_device_connect(dst->dss, dst, dst->next);
33 static void tfp410_disconnect(struct omap_dss_device *src,
34 struct omap_dss_device *dst)
36 omapdss_device_disconnect(dst, dst->next);
39 static void tfp410_enable(struct omap_dss_device *dssdev)
41 struct panel_drv_data *ddata = to_panel_data(dssdev);
44 gpiod_set_value_cansleep(ddata->pd_gpio, 0);
47 static void tfp410_disable(struct omap_dss_device *dssdev)
49 struct panel_drv_data *ddata = to_panel_data(dssdev);
52 gpiod_set_value_cansleep(ddata->pd_gpio, 0);
55 static const struct omap_dss_device_ops tfp410_ops = {
56 .connect = tfp410_connect,
57 .disconnect = tfp410_disconnect,
58 .enable = tfp410_enable,
59 .disable = tfp410_disable,
62 static int tfp410_probe(struct platform_device *pdev)
64 struct panel_drv_data *ddata;
65 struct omap_dss_device *dssdev;
66 struct gpio_desc *gpio;
68 ddata = devm_kzalloc(&pdev->dev, sizeof(*ddata), GFP_KERNEL);
72 platform_set_drvdata(pdev, ddata);
75 gpio = devm_gpiod_get_optional(&pdev->dev, "powerdown", GPIOD_OUT_HIGH);
77 dev_err(&pdev->dev, "failed to parse powerdown gpio\n");
81 ddata->pd_gpio = gpio;
83 dssdev = &ddata->dssdev;
84 dssdev->ops = &tfp410_ops;
85 dssdev->dev = &pdev->dev;
86 dssdev->type = OMAP_DISPLAY_TYPE_DPI;
87 dssdev->owner = THIS_MODULE;
88 dssdev->of_ports = BIT(1) | BIT(0);
89 dssdev->bus_flags = DRM_BUS_FLAG_DE_HIGH | DRM_BUS_FLAG_SYNC_POSEDGE
90 | DRM_BUS_FLAG_PIXDATA_POSEDGE;
92 dssdev->next = omapdss_of_find_connected_device(pdev->dev.of_node, 1);
93 if (IS_ERR(dssdev->next)) {
94 if (PTR_ERR(dssdev->next) != -EPROBE_DEFER)
95 dev_err(&pdev->dev, "failed to find video sink\n");
96 return PTR_ERR(dssdev->next);
99 omapdss_device_register(dssdev);
104 static int __exit tfp410_remove(struct platform_device *pdev)
106 struct panel_drv_data *ddata = platform_get_drvdata(pdev);
107 struct omap_dss_device *dssdev = &ddata->dssdev;
110 omapdss_device_put(dssdev->next);
111 omapdss_device_unregister(&ddata->dssdev);
113 tfp410_disable(dssdev);
118 static const struct of_device_id tfp410_of_match[] = {
119 { .compatible = "omapdss,ti,tfp410", },
123 MODULE_DEVICE_TABLE(of, tfp410_of_match);
125 static struct platform_driver tfp410_driver = {
126 .probe = tfp410_probe,
127 .remove = __exit_p(tfp410_remove),
130 .of_match_table = tfp410_of_match,
131 .suppress_bind_attrs = true,
135 module_platform_driver(tfp410_driver);
137 MODULE_AUTHOR("Tomi Valkeinen <tomi.valkeinen@ti.com>");
138 MODULE_DESCRIPTION("TFP410 DPI to DVI encoder driver");
139 MODULE_LICENSE("GPL");