1 From 884d3962ef4787c8cf0b8a7a673531c623d1dff8 Mon Sep 17 00:00:00 2001
2 From: Darren Etheridge <detheridge@ti.com>
3 Date: Fri, 2 Aug 2013 15:35:36 -0500
4 Subject: [PATCH 334/752] video: da8xx-fb: adding dt support
6 Enhancing driver to enable probe triggered by a corresponding dt entry.
8 Add da8xx-fb.txt documentation to devicetree section.
10 Obtain fb_videomode details for the connected lcd panel using the
11 display timing details present in DT.
13 Ensure that platform data is present before checking whether platform
14 callback is present (the one used to control backlight). So far this
15 was not an issue as driver was purely non-DT triggered, but now DT
16 support has been added this check must be performed.
18 v2: squashing multiple commits from Afzal Mohammed (afzal@ti.com)
19 v3: remove superfluous cast
20 v4: expose both ti,am3352-lcdc and ti,da830-lcdc for .compatible
21 as driver can use enhanced features of all version of the
23 v5: addressed review comments from Prabhakar Lad
24 v6: Changed the .compatible naming to match the existing drm bindings
26 v7: clarify which compatible to use in the documentation for DA850
28 Acked-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
29 Signed-off-by: Darren Etheridge <detheridge@ti.com>
31 .../devicetree/bindings/video/da8xx-fb.txt | 42 +++++++++++++
32 drivers/video/fbdev/da8xx-fb.c | 66 +++++++++++++++++++-
33 2 files changed, 105 insertions(+), 3 deletions(-)
34 create mode 100644 Documentation/devicetree/bindings/video/da8xx-fb.txt
37 +++ b/Documentation/devicetree/bindings/video/da8xx-fb.txt
39 +TI LCD Controller on DA830/DA850/AM335x SoC's
43 + DA830, DA850 - "ti,da8xx-tilcdc"
44 + AM335x SoC's - "ti,am33xx-tilcdc"
45 +- reg: Address range of lcdc register set
46 +- interrupts: lcdc interrupt
47 +- display-timings: typical videomode of lcd panel, represented as child.
48 + Refer Documentation/devicetree/bindings/video/display-timing.txt for
49 + display timing binding details. If multiple videomodes are mentioned
50 + in display timings node, typical videomode has to be mentioned as the
51 + native mode or it has to be first child (driver cares only for native
54 +Recommended properties:
55 +- ti,hwmods: Name of the hwmod associated to the LCDC
57 +Example for am335x SoC's:
60 + compatible = "ti,am33xx-tilcdc";
61 + reg = <0x4830e000 0x1000>;
67 + clock-frequency = <30000000>;
70 + hfront-porch = <39>;
74 + vfront-porch = <13>;
81 --- a/drivers/video/fbdev/da8xx-fb.c
82 +++ b/drivers/video/fbdev/da8xx-fb.c
84 #include <linux/slab.h>
85 #include <linux/delay.h>
86 #include <linux/lcm.h>
87 +#include <video/of_display_timing.h>
88 #include <video/da8xx-fb.h>
89 #include <asm/div64.h>
91 @@ -1317,12 +1318,54 @@ static struct fb_ops da8xx_fb_ops = {
92 .fb_blank = cfb_blank,
95 +static struct lcd_ctrl_config *da8xx_fb_create_cfg(struct platform_device *dev)
97 + struct lcd_ctrl_config *cfg;
99 + cfg = devm_kzalloc(&dev->dev, sizeof(struct fb_videomode), GFP_KERNEL);
103 + /* default values */
105 + if (lcd_revision == LCD_VERSION_1)
111 + * For panels so far used with this LCDC, below statement is sufficient.
112 + * For new panels, if required, struct lcd_ctrl_cfg fields to be updated
113 + * with additional/modified values. Those values would have to be then
114 + * obtained from dt(requiring new dt bindings).
117 + cfg->panel_shade = COLOR_ACTIVE;
122 static struct fb_videomode *da8xx_fb_get_videomode(struct platform_device *dev)
124 struct da8xx_lcdc_platform_data *fb_pdata = dev_get_platdata(&dev->dev);
125 struct fb_videomode *lcdc_info;
126 + struct device_node *np = dev->dev.of_node;
130 + lcdc_info = devm_kzalloc(&dev->dev,
131 + sizeof(struct fb_videomode),
136 + if (of_get_fb_videomode(np, lcdc_info, OF_USE_NATIVE_MODE)) {
137 + dev_err(&dev->dev, "timings not available in DT\n");
143 for (i = 0, lcdc_info = known_lcd_panels;
144 i < ARRAY_SIZE(known_lcd_panels); i++, lcdc_info++) {
145 if (strcmp(fb_pdata->type, lcdc_info->name) == 0)
146 @@ -1351,7 +1394,7 @@ static int fb_probe(struct platform_devi
150 - if (fb_pdata == NULL) {
151 + if (fb_pdata == NULL && !device->dev.of_node) {
152 dev_err(&device->dev, "Can not get platform data\n");
155 @@ -1391,7 +1434,10 @@ static int fb_probe(struct platform_devi
159 - lcd_cfg = (struct lcd_ctrl_config *)fb_pdata->controller_data;
160 + if (device->dev.of_node)
161 + lcd_cfg = da8xx_fb_create_cfg(device);
163 + lcd_cfg = fb_pdata->controller_data;
167 @@ -1410,7 +1456,7 @@ static int fb_probe(struct platform_devi
168 par->dev = &device->dev;
169 par->lcdc_clk = tmp_lcdc_clk;
170 par->lcdc_clk_rate = clk_get_rate(par->lcdc_clk);
171 - if (fb_pdata->panel_power_ctrl) {
172 + if (fb_pdata && fb_pdata->panel_power_ctrl) {
173 par->panel_power_ctrl = fb_pdata->panel_power_ctrl;
174 par->panel_power_ctrl(1);
176 @@ -1654,12 +1700,26 @@ static int fb_resume(struct device *dev)
178 static SIMPLE_DEV_PM_OPS(fb_pm_ops, fb_suspend, fb_resume);
180 +#if IS_ENABLED(CONFIG_OF)
181 +static const struct of_device_id da8xx_fb_of_match[] = {
183 + * this driver supports version 1 and version 2 of the
184 + * Texas Instruments lcd controller (lcdc) hardware block
186 + {.compatible = "ti,da8xx-tilcdc", },
187 + {.compatible = "ti,am33xx-tilcdc", },
190 +MODULE_DEVICE_TABLE(of, da8xx_fb_of_match);
193 static struct platform_driver da8xx_fb_driver = {
198 .owner = THIS_MODULE,
199 + .of_match_table = of_match_ptr(da8xx_fb_of_match),