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/da8xx-fb.c | 66 +++++++++++++++++++-
33 2 files changed, 105 insertions(+), 3 deletions(-)
34 create mode 100644 Documentation/devicetree/bindings/video/da8xx-fb.txt
36 diff --git a/Documentation/devicetree/bindings/video/da8xx-fb.txt b/Documentation/devicetree/bindings/video/da8xx-fb.txt
38 index 0000000..d86afe7
40 +++ b/Documentation/devicetree/bindings/video/da8xx-fb.txt
42 +TI LCD Controller on DA830/DA850/AM335x SoC's
46 + DA830, DA850 - "ti,da8xx-tilcdc"
47 + AM335x SoC's - "ti,am33xx-tilcdc"
48 +- reg: Address range of lcdc register set
49 +- interrupts: lcdc interrupt
50 +- display-timings: typical videomode of lcd panel, represented as child.
51 + Refer Documentation/devicetree/bindings/video/display-timing.txt for
52 + display timing binding details. If multiple videomodes are mentioned
53 + in display timings node, typical videomode has to be mentioned as the
54 + native mode or it has to be first child (driver cares only for native
57 +Recommended properties:
58 +- ti,hwmods: Name of the hwmod associated to the LCDC
60 +Example for am335x SoC's:
63 + compatible = "ti,am33xx-tilcdc";
64 + reg = <0x4830e000 0x1000>;
70 + clock-frequency = <30000000>;
73 + hfront-porch = <39>;
77 + vfront-porch = <13>;
84 diff --git a/drivers/video/da8xx-fb.c b/drivers/video/da8xx-fb.c
85 index e030e17..74cc2dc 100644
86 --- a/drivers/video/da8xx-fb.c
87 +++ b/drivers/video/da8xx-fb.c
89 #include <linux/slab.h>
90 #include <linux/delay.h>
91 #include <linux/lcm.h>
92 +#include <video/of_display_timing.h>
93 #include <video/da8xx-fb.h>
94 #include <asm/div64.h>
96 @@ -1312,12 +1313,54 @@ static struct fb_ops da8xx_fb_ops = {
97 .fb_blank = cfb_blank,
100 +static struct lcd_ctrl_config *da8xx_fb_create_cfg(struct platform_device *dev)
102 + struct lcd_ctrl_config *cfg;
104 + cfg = devm_kzalloc(&dev->dev, sizeof(struct fb_videomode), GFP_KERNEL);
108 + /* default values */
110 + if (lcd_revision == LCD_VERSION_1)
116 + * For panels so far used with this LCDC, below statement is sufficient.
117 + * For new panels, if required, struct lcd_ctrl_cfg fields to be updated
118 + * with additional/modified values. Those values would have to be then
119 + * obtained from dt(requiring new dt bindings).
122 + cfg->panel_shade = COLOR_ACTIVE;
127 static struct fb_videomode *da8xx_fb_get_videomode(struct platform_device *dev)
129 struct da8xx_lcdc_platform_data *fb_pdata = dev->dev.platform_data;
130 struct fb_videomode *lcdc_info;
131 + struct device_node *np = dev->dev.of_node;
135 + lcdc_info = devm_kzalloc(&dev->dev,
136 + sizeof(struct fb_videomode),
141 + if (of_get_fb_videomode(np, lcdc_info, OF_USE_NATIVE_MODE)) {
142 + dev_err(&dev->dev, "timings not available in DT\n");
148 for (i = 0, lcdc_info = known_lcd_panels;
149 i < ARRAY_SIZE(known_lcd_panels); i++, lcdc_info++) {
150 if (strcmp(fb_pdata->type, lcdc_info->name) == 0)
151 @@ -1346,7 +1389,7 @@ static int fb_probe(struct platform_device *device)
155 - if (fb_pdata == NULL) {
156 + if (fb_pdata == NULL && !device->dev.of_node) {
157 dev_err(&device->dev, "Can not get platform data\n");
160 @@ -1386,7 +1429,10 @@ static int fb_probe(struct platform_device *device)
164 - lcd_cfg = (struct lcd_ctrl_config *)fb_pdata->controller_data;
165 + if (device->dev.of_node)
166 + lcd_cfg = da8xx_fb_create_cfg(device);
168 + lcd_cfg = fb_pdata->controller_data;
172 @@ -1405,7 +1451,7 @@ static int fb_probe(struct platform_device *device)
173 par->dev = &device->dev;
174 par->lcdc_clk = tmp_lcdc_clk;
175 par->lcdc_clk_rate = clk_get_rate(par->lcdc_clk);
176 - if (fb_pdata->panel_power_ctrl) {
177 + if (fb_pdata && fb_pdata->panel_power_ctrl) {
178 par->panel_power_ctrl = fb_pdata->panel_power_ctrl;
179 par->panel_power_ctrl(1);
181 @@ -1653,6 +1699,19 @@ static int fb_resume(struct platform_device *dev)
182 #define fb_resume NULL
185 +#if IS_ENABLED(CONFIG_OF)
186 +static const struct of_device_id da8xx_fb_of_match[] = {
188 + * this driver supports version 1 and version 2 of the
189 + * Texas Instruments lcd controller (lcdc) hardware block
191 + {.compatible = "ti,da8xx-tilcdc", },
192 + {.compatible = "ti,am33xx-tilcdc", },
195 +MODULE_DEVICE_TABLE(of, da8xx_fb_of_match);
198 static struct platform_driver da8xx_fb_driver = {
201 @@ -1661,6 +1720,7 @@ static struct platform_driver da8xx_fb_driver = {
204 .owner = THIS_MODULE,
205 + .of_match_table = of_match_ptr(da8xx_fb_of_match),