aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIcenowy Zheng <icenowy@aosc.io>2018-11-04 13:27:01 -0500
committerMaxime Ripard <maxime.ripard@bootlin.com>2018-11-05 05:49:06 -0500
commit10ead694f05c238878eda089f54aa3fad801bc72 (patch)
tree62983ffd2f46c5901500ad92bd0bdd8a5c4a7ab7
parentc96d62215fb540e2ae61de44cb7caf4db50958e3 (diff)
drm: sun4i: add quirks for TCON TOP
Some SoCs, such as H6, doesn't have a full-featured TCON TOP. Add quirks support for TCON TOP. Currently the presence of TCON_TV1 and DSI is controlled via the quirks structure. Acked-by: Maxime Ripard <maxime.ripard@bootlin.com> Signed-off-by: Icenowy Zheng <icenowy@aosc.io> [Fixed code style and removed unnecessary initialization] Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net> Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com> Link: https://patchwork.freedesktop.org/patch/msgid/20181104182705.18047-25-jernej.skrabec@siol.net
-rw-r--r--drivers/gpu/drm/sun4i/sun8i_tcon_top.c37
1 files changed, 28 insertions, 9 deletions
diff --git a/drivers/gpu/drm/sun4i/sun8i_tcon_top.c b/drivers/gpu/drm/sun4i/sun8i_tcon_top.c
index 37158548b447..e94e3fb1736b 100644
--- a/drivers/gpu/drm/sun4i/sun8i_tcon_top.c
+++ b/drivers/gpu/drm/sun4i/sun8i_tcon_top.c
@@ -9,11 +9,17 @@
9#include <linux/component.h> 9#include <linux/component.h>
10#include <linux/device.h> 10#include <linux/device.h>
11#include <linux/module.h> 11#include <linux/module.h>
12#include <linux/of_device.h>
12#include <linux/of_graph.h> 13#include <linux/of_graph.h>
13#include <linux/platform_device.h> 14#include <linux/platform_device.h>
14 15
15#include "sun8i_tcon_top.h" 16#include "sun8i_tcon_top.h"
16 17
18struct sun8i_tcon_top_quirks {
19 bool has_tcon_tv1;
20 bool has_dsi;
21};
22
17static bool sun8i_tcon_top_node_is_tcon_top(struct device_node *node) 23static bool sun8i_tcon_top_node_is_tcon_top(struct device_node *node)
18{ 24{
19 return !!of_match_node(sun8i_tcon_top_of_table, node); 25 return !!of_match_node(sun8i_tcon_top_of_table, node);
@@ -121,10 +127,13 @@ static int sun8i_tcon_top_bind(struct device *dev, struct device *master,
121 struct platform_device *pdev = to_platform_device(dev); 127 struct platform_device *pdev = to_platform_device(dev);
122 struct clk_hw_onecell_data *clk_data; 128 struct clk_hw_onecell_data *clk_data;
123 struct sun8i_tcon_top *tcon_top; 129 struct sun8i_tcon_top *tcon_top;
130 const struct sun8i_tcon_top_quirks *quirks;
124 struct resource *res; 131 struct resource *res;
125 void __iomem *regs; 132 void __iomem *regs;
126 int ret, i; 133 int ret, i;
127 134
135 quirks = of_device_get_match_data(&pdev->dev);
136
128 tcon_top = devm_kzalloc(dev, sizeof(*tcon_top), GFP_KERNEL); 137 tcon_top = devm_kzalloc(dev, sizeof(*tcon_top), GFP_KERNEL);
129 if (!tcon_top) 138 if (!tcon_top)
130 return -ENOMEM; 139 return -ENOMEM;
@@ -187,15 +196,17 @@ static int sun8i_tcon_top_bind(struct device *dev, struct device *master,
187 &tcon_top->reg_lock, 196 &tcon_top->reg_lock,
188 TCON_TOP_TCON_TV0_GATE, 0); 197 TCON_TOP_TCON_TV0_GATE, 0);
189 198
190 clk_data->hws[CLK_TCON_TOP_TV1] = 199 if (quirks->has_tcon_tv1)
191 sun8i_tcon_top_register_gate(dev, "tcon-tv1", regs, 200 clk_data->hws[CLK_TCON_TOP_TV1] =
192 &tcon_top->reg_lock, 201 sun8i_tcon_top_register_gate(dev, "tcon-tv1", regs,
193 TCON_TOP_TCON_TV1_GATE, 1); 202 &tcon_top->reg_lock,
203 TCON_TOP_TCON_TV1_GATE, 1);
194 204
195 clk_data->hws[CLK_TCON_TOP_DSI] = 205 if (quirks->has_dsi)
196 sun8i_tcon_top_register_gate(dev, "dsi", regs, 206 clk_data->hws[CLK_TCON_TOP_DSI] =
197 &tcon_top->reg_lock, 207 sun8i_tcon_top_register_gate(dev, "dsi", regs,
198 TCON_TOP_TCON_DSI_GATE, 2); 208 &tcon_top->reg_lock,
209 TCON_TOP_TCON_DSI_GATE, 2);
199 210
200 for (i = 0; i < CLK_NUM; i++) 211 for (i = 0; i < CLK_NUM; i++)
201 if (IS_ERR(clk_data->hws[i])) { 212 if (IS_ERR(clk_data->hws[i])) {
@@ -257,9 +268,17 @@ static int sun8i_tcon_top_remove(struct platform_device *pdev)
257 return 0; 268 return 0;
258} 269}
259 270
271const struct sun8i_tcon_top_quirks sun8i_r40_tcon_top_quirks = {
272 .has_tcon_tv1 = true,
273 .has_dsi = true,
274};
275
260/* sun4i_drv uses this list to check if a device node is a TCON TOP */ 276/* sun4i_drv uses this list to check if a device node is a TCON TOP */
261const struct of_device_id sun8i_tcon_top_of_table[] = { 277const struct of_device_id sun8i_tcon_top_of_table[] = {
262 { .compatible = "allwinner,sun8i-r40-tcon-top" }, 278 {
279 .compatible = "allwinner,sun8i-r40-tcon-top",
280 .data = &sun8i_r40_tcon_top_quirks
281 },
263 { /* sentinel */ } 282 { /* sentinel */ }
264}; 283};
265MODULE_DEVICE_TABLE(of, sun8i_tcon_top_of_table); 284MODULE_DEVICE_TABLE(of, sun8i_tcon_top_of_table);