@@ -14,6 +14,8 @@
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/slab.h>
+#include <linux/of.h>
+#include <linux/of_videomode.h>
#include <video/display.h>
#include <video/panel-dpi.h>
@@ -98,20 +100,60 @@ static int panel_dpi_remove(struct platform_device *pdev)
return 0;
}
-static int __devinit panel_dpi_probe(struct platform_device *pdev)
+static int __devinit panel_dpi_parse_dt(struct device *dev,
+ struct panel_dpi *panel)
{
- const struct panel_dpi_platform_data *pdata = pdev->dev.platform_data;
- struct panel_dpi *panel;
+ struct device_node *np = dev->of_node;
+ struct panel_dpi_platform_data *pdata;
+ struct videomode *vm;
+ u32 width, height;
int ret;
+ if (!np)
+ return -ENODEV;
+
+ pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
if (pdata == NULL)
+ return -ENOMEM;
+
+ vm = devm_kzalloc(dev, sizeof(*vm), GFP_KERNEL);
+ if (vm == NULL)
+ return -ENOMEM;
+
+ ret = of_get_videomode(np, vm, 0);
+ if (ret < 0)
return -ENODEV;
+ of_property_read_u32(np, "width", &width);
+ of_property_read_u32(np, "height", &height);
+
+ pdata->mode = vm;
+ pdata->width = width;
+ pdata->height = height;
+ panel->pdata = pdata;
+
+ return 0;
+}
+
+static int __devinit panel_dpi_probe(struct platform_device *pdev)
+{
+ const struct panel_dpi_platform_data *pdata = pdev->dev.platform_data;
+ struct panel_dpi *panel;
+ int ret;
+
panel = kzalloc(sizeof(*panel), GFP_KERNEL);
if (panel == NULL)
return -ENOMEM;
- panel->pdata = pdata;
+ if (pdata) {
+ panel->pdata = pdata;
+ } else {
+ ret = panel_dpi_parse_dt(&pdev->dev, panel);
+ if (ret < 0) {
+ kfree(panel);
+ return ret;
+ }
+ }
panel->entity.dev = &pdev->dev;
panel->entity.release = panel_dpi_release;
panel->entity.ops.ctrl = &panel_dpi_control_ops;
@@ -130,11 +172,17 @@ static int __devinit panel_dpi_probe(struct platform_device *pdev)
static const struct dev_pm_ops panel_dpi_dev_pm_ops = {
};
+static const struct of_device_id panel_dpi_dt_ids[] = {
+ { .compatible = "dpi-panel", },
+ { }
+};
+
static struct platform_driver panel_dpi_driver = {
.probe = panel_dpi_probe,
.remove = panel_dpi_remove,
.driver = {
.name = "panel_dpi",
+ .of_match_table = panel_dpi_dt_ids,
.owner = THIS_MODULE,
.pm = &panel_dpi_dev_pm_ops,
},