aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2016-11-15 18:39:55 -0500
committerDave Airlie <airlied@redhat.com>2016-11-15 18:39:55 -0500
commit4473904ccd7fc27b7e9e575c36dc709617a3eb85 (patch)
tree58be4542b362c7c498cbc7bb55aa5091f74374b1
parent1a3865d64a0d8151c7fe23f4b57a587615ccc5bb (diff)
parent47d7fbb32c57c8d1722a3e9bd21e501e80fd0741 (diff)
Merge tag 'sunxi-drm-for-4.10' of https://git.kernel.org/pub/scm/linux/kernel/git/mripard/linux into drm-next
sun4i-drm changes for 4.10 Support for the Allwinner A31 SoC display engine using the sun4i-drm driver. * tag 'sunxi-drm-for-4.10' of https://git.kernel.org/pub/scm/linux/kernel/git/mripard/linux: drm/sun4i: Add a few formats drm/sun4i: Add compatible strings for A31/A31s display pipelines drm/sun4i: Add compatible string for A31/A31s TCON (timing controller) drm/sun4i: tcon: Move SoC specific quirks to a DT matched data structure drm/sun4i: sun6i-drc: Support DRC on A31 and A31s
-rw-r--r--Documentation/devicetree/bindings/display/sunxi/sun4i-drm.txt10
-rw-r--r--drivers/gpu/drm/sun4i/sun4i_backend.c21
-rw-r--r--drivers/gpu/drm/sun4i/sun4i_drv.c5
-rw-r--r--drivers/gpu/drm/sun4i/sun4i_layer.c6
-rw-r--r--drivers/gpu/drm/sun4i/sun4i_tcon.c43
-rw-r--r--drivers/gpu/drm/sun4i/sun4i_tcon.h11
-rw-r--r--drivers/gpu/drm/sun4i/sun6i_drc.c2
7 files changed, 78 insertions, 20 deletions
diff --git a/Documentation/devicetree/bindings/display/sunxi/sun4i-drm.txt b/Documentation/devicetree/bindings/display/sunxi/sun4i-drm.txt
index b95696d748c7..b82c00449468 100644
--- a/Documentation/devicetree/bindings/display/sunxi/sun4i-drm.txt
+++ b/Documentation/devicetree/bindings/display/sunxi/sun4i-drm.txt
@@ -28,6 +28,8 @@ The TCON acts as a timing controller for RGB, LVDS and TV interfaces.
28Required properties: 28Required properties:
29 - compatible: value must be either: 29 - compatible: value must be either:
30 * allwinner,sun5i-a13-tcon 30 * allwinner,sun5i-a13-tcon
31 * allwinner,sun6i-a31-tcon
32 * allwinner,sun6i-a31s-tcon
31 * allwinner,sun8i-a33-tcon 33 * allwinner,sun8i-a33-tcon
32 - reg: base address and size of memory-mapped region 34 - reg: base address and size of memory-mapped region
33 - interrupts: interrupt associated to this IP 35 - interrupts: interrupt associated to this IP
@@ -50,7 +52,7 @@ Required properties:
50 second the block connected to the TCON channel 1 (usually the TV 52 second the block connected to the TCON channel 1 (usually the TV
51 encoder) 53 encoder)
52 54
53On the A13, there is one more clock required: 55On SoCs other than the A33, there is one more clock required:
54 - 'tcon-ch1': The clock driving the TCON channel 1 56 - 'tcon-ch1': The clock driving the TCON channel 1
55 57
56DRC 58DRC
@@ -64,6 +66,8 @@ adaptive backlight control.
64 66
65Required properties: 67Required properties:
66 - compatible: value must be one of: 68 - compatible: value must be one of:
69 * allwinner,sun6i-a31-drc
70 * allwinner,sun6i-a31s-drc
67 * allwinner,sun8i-a33-drc 71 * allwinner,sun8i-a33-drc
68 - reg: base address and size of the memory-mapped region. 72 - reg: base address and size of the memory-mapped region.
69 - interrupts: interrupt associated to this IP 73 - interrupts: interrupt associated to this IP
@@ -87,6 +91,7 @@ system.
87Required properties: 91Required properties:
88 - compatible: value must be one of: 92 - compatible: value must be one of:
89 * allwinner,sun5i-a13-display-backend 93 * allwinner,sun5i-a13-display-backend
94 * allwinner,sun6i-a31-display-backend
90 * allwinner,sun8i-a33-display-backend 95 * allwinner,sun8i-a33-display-backend
91 - reg: base address and size of the memory-mapped region. 96 - reg: base address and size of the memory-mapped region.
92 - clocks: phandles to the clocks feeding the frontend and backend 97 - clocks: phandles to the clocks feeding the frontend and backend
@@ -117,6 +122,7 @@ deinterlacing and color space conversion.
117Required properties: 122Required properties:
118 - compatible: value must be one of: 123 - compatible: value must be one of:
119 * allwinner,sun5i-a13-display-frontend 124 * allwinner,sun5i-a13-display-frontend
125 * allwinner,sun6i-a31-display-frontend
120 * allwinner,sun8i-a33-display-frontend 126 * allwinner,sun8i-a33-display-frontend
121 - reg: base address and size of the memory-mapped region. 127 - reg: base address and size of the memory-mapped region.
122 - interrupts: interrupt associated to this IP 128 - interrupts: interrupt associated to this IP
@@ -142,6 +148,8 @@ extra node.
142Required properties: 148Required properties:
143 - compatible: value must be one of: 149 - compatible: value must be one of:
144 * allwinner,sun5i-a13-display-engine 150 * allwinner,sun5i-a13-display-engine
151 * allwinner,sun6i-a31-display-engine
152 * allwinner,sun6i-a31s-display-engine
145 * allwinner,sun8i-a33-display-engine 153 * allwinner,sun8i-a33-display-engine
146 154
147 - allwinner,pipelines: list of phandle to the display engine 155 - allwinner,pipelines: list of phandle to the display engine
diff --git a/drivers/gpu/drm/sun4i/sun4i_backend.c b/drivers/gpu/drm/sun4i/sun4i_backend.c
index 32c0584e3c35..7eb2a965f83d 100644
--- a/drivers/gpu/drm/sun4i/sun4i_backend.c
+++ b/drivers/gpu/drm/sun4i/sun4i_backend.c
@@ -95,6 +95,22 @@ static int sun4i_backend_drm_format_to_layer(struct drm_plane *plane,
95 *mode = SUN4I_BACKEND_LAY_FBFMT_ARGB8888; 95 *mode = SUN4I_BACKEND_LAY_FBFMT_ARGB8888;
96 break; 96 break;
97 97
98 case DRM_FORMAT_ARGB4444:
99 *mode = SUN4I_BACKEND_LAY_FBFMT_ARGB4444;
100 break;
101
102 case DRM_FORMAT_ARGB1555:
103 *mode = SUN4I_BACKEND_LAY_FBFMT_ARGB1555;
104 break;
105
106 case DRM_FORMAT_RGBA5551:
107 *mode = SUN4I_BACKEND_LAY_FBFMT_RGBA5551;
108 break;
109
110 case DRM_FORMAT_RGBA4444:
111 *mode = SUN4I_BACKEND_LAY_FBFMT_RGBA4444;
112 break;
113
98 case DRM_FORMAT_XRGB8888: 114 case DRM_FORMAT_XRGB8888:
99 *mode = SUN4I_BACKEND_LAY_FBFMT_XRGB8888; 115 *mode = SUN4I_BACKEND_LAY_FBFMT_XRGB8888;
100 break; 116 break;
@@ -103,6 +119,10 @@ static int sun4i_backend_drm_format_to_layer(struct drm_plane *plane,
103 *mode = SUN4I_BACKEND_LAY_FBFMT_RGB888; 119 *mode = SUN4I_BACKEND_LAY_FBFMT_RGB888;
104 break; 120 break;
105 121
122 case DRM_FORMAT_RGB565:
123 *mode = SUN4I_BACKEND_LAY_FBFMT_RGB565;
124 break;
125
106 default: 126 default:
107 return -EINVAL; 127 return -EINVAL;
108 } 128 }
@@ -408,6 +428,7 @@ static int sun4i_backend_remove(struct platform_device *pdev)
408 428
409static const struct of_device_id sun4i_backend_of_table[] = { 429static const struct of_device_id sun4i_backend_of_table[] = {
410 { .compatible = "allwinner,sun5i-a13-display-backend" }, 430 { .compatible = "allwinner,sun5i-a13-display-backend" },
431 { .compatible = "allwinner,sun6i-a31-display-backend" },
411 { .compatible = "allwinner,sun8i-a33-display-backend" }, 432 { .compatible = "allwinner,sun8i-a33-display-backend" },
412 { } 433 { }
413}; 434};
diff --git a/drivers/gpu/drm/sun4i/sun4i_drv.c b/drivers/gpu/drm/sun4i/sun4i_drv.c
index aae723cd6d79..2891aa914cfa 100644
--- a/drivers/gpu/drm/sun4i/sun4i_drv.c
+++ b/drivers/gpu/drm/sun4i/sun4i_drv.c
@@ -200,12 +200,15 @@ static const struct component_master_ops sun4i_drv_master_ops = {
200static bool sun4i_drv_node_is_frontend(struct device_node *node) 200static bool sun4i_drv_node_is_frontend(struct device_node *node)
201{ 201{
202 return of_device_is_compatible(node, "allwinner,sun5i-a13-display-frontend") || 202 return of_device_is_compatible(node, "allwinner,sun5i-a13-display-frontend") ||
203 of_device_is_compatible(node, "allwinner,sun6i-a31-display-frontend") ||
203 of_device_is_compatible(node, "allwinner,sun8i-a33-display-frontend"); 204 of_device_is_compatible(node, "allwinner,sun8i-a33-display-frontend");
204} 205}
205 206
206static bool sun4i_drv_node_is_tcon(struct device_node *node) 207static bool sun4i_drv_node_is_tcon(struct device_node *node)
207{ 208{
208 return of_device_is_compatible(node, "allwinner,sun5i-a13-tcon") || 209 return of_device_is_compatible(node, "allwinner,sun5i-a13-tcon") ||
210 of_device_is_compatible(node, "allwinner,sun6i-a31-tcon") ||
211 of_device_is_compatible(node, "allwinner,sun6i-a31s-tcon") ||
209 of_device_is_compatible(node, "allwinner,sun8i-a33-tcon"); 212 of_device_is_compatible(node, "allwinner,sun8i-a33-tcon");
210} 213}
211 214
@@ -321,6 +324,8 @@ static int sun4i_drv_remove(struct platform_device *pdev)
321 324
322static const struct of_device_id sun4i_drv_of_table[] = { 325static const struct of_device_id sun4i_drv_of_table[] = {
323 { .compatible = "allwinner,sun5i-a13-display-engine" }, 326 { .compatible = "allwinner,sun5i-a13-display-engine" },
327 { .compatible = "allwinner,sun6i-a31-display-engine" },
328 { .compatible = "allwinner,sun6i-a31s-display-engine" },
324 { .compatible = "allwinner,sun8i-a33-display-engine" }, 329 { .compatible = "allwinner,sun8i-a33-display-engine" },
325 { } 330 { }
326}; 331};
diff --git a/drivers/gpu/drm/sun4i/sun4i_layer.c b/drivers/gpu/drm/sun4i/sun4i_layer.c
index f0035bf5efea..5d53c977bca5 100644
--- a/drivers/gpu/drm/sun4i/sun4i_layer.c
+++ b/drivers/gpu/drm/sun4i/sun4i_layer.c
@@ -73,12 +73,18 @@ static const struct drm_plane_funcs sun4i_backend_layer_funcs = {
73static const uint32_t sun4i_backend_layer_formats_primary[] = { 73static const uint32_t sun4i_backend_layer_formats_primary[] = {
74 DRM_FORMAT_ARGB8888, 74 DRM_FORMAT_ARGB8888,
75 DRM_FORMAT_RGB888, 75 DRM_FORMAT_RGB888,
76 DRM_FORMAT_RGB565,
76 DRM_FORMAT_XRGB8888, 77 DRM_FORMAT_XRGB8888,
77}; 78};
78 79
79static const uint32_t sun4i_backend_layer_formats_overlay[] = { 80static const uint32_t sun4i_backend_layer_formats_overlay[] = {
80 DRM_FORMAT_ARGB8888, 81 DRM_FORMAT_ARGB8888,
82 DRM_FORMAT_ARGB4444,
83 DRM_FORMAT_ARGB1555,
84 DRM_FORMAT_RGBA5551,
85 DRM_FORMAT_RGBA4444,
81 DRM_FORMAT_RGB888, 86 DRM_FORMAT_RGB888,
87 DRM_FORMAT_RGB565,
82 DRM_FORMAT_XRGB8888, 88 DRM_FORMAT_XRGB8888,
83}; 89};
84 90
diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.c b/drivers/gpu/drm/sun4i/sun4i_tcon.c
index cadacb517f95..c6afb2448655 100644
--- a/drivers/gpu/drm/sun4i/sun4i_tcon.c
+++ b/drivers/gpu/drm/sun4i/sun4i_tcon.c
@@ -20,6 +20,7 @@
20#include <linux/component.h> 20#include <linux/component.h>
21#include <linux/ioport.h> 21#include <linux/ioport.h>
22#include <linux/of_address.h> 22#include <linux/of_address.h>
23#include <linux/of_device.h>
23#include <linux/of_graph.h> 24#include <linux/of_graph.h>
24#include <linux/of_irq.h> 25#include <linux/of_irq.h>
25#include <linux/regmap.h> 26#include <linux/regmap.h>
@@ -62,7 +63,7 @@ void sun4i_tcon_channel_disable(struct sun4i_tcon *tcon, int channel)
62 return; 63 return;
63 } 64 }
64 65
65 WARN_ON(!tcon->has_channel_1); 66 WARN_ON(!tcon->quirks->has_channel_1);
66 regmap_update_bits(tcon->regs, SUN4I_TCON1_CTL_REG, 67 regmap_update_bits(tcon->regs, SUN4I_TCON1_CTL_REG,
67 SUN4I_TCON1_CTL_TCON_ENABLE, 0); 68 SUN4I_TCON1_CTL_TCON_ENABLE, 0);
68 clk_disable_unprepare(tcon->sclk1); 69 clk_disable_unprepare(tcon->sclk1);
@@ -80,7 +81,7 @@ void sun4i_tcon_channel_enable(struct sun4i_tcon *tcon, int channel)
80 return; 81 return;
81 } 82 }
82 83
83 WARN_ON(!tcon->has_channel_1); 84 WARN_ON(!tcon->quirks->has_channel_1);
84 regmap_update_bits(tcon->regs, SUN4I_TCON1_CTL_REG, 85 regmap_update_bits(tcon->regs, SUN4I_TCON1_CTL_REG,
85 SUN4I_TCON1_CTL_TCON_ENABLE, 86 SUN4I_TCON1_CTL_TCON_ENABLE,
86 SUN4I_TCON1_CTL_TCON_ENABLE); 87 SUN4I_TCON1_CTL_TCON_ENABLE);
@@ -202,7 +203,7 @@ void sun4i_tcon1_mode_set(struct sun4i_tcon *tcon,
202 u8 clk_delay; 203 u8 clk_delay;
203 u32 val; 204 u32 val;
204 205
205 WARN_ON(!tcon->has_channel_1); 206 WARN_ON(!tcon->quirks->has_channel_1);
206 207
207 /* Adjust clock delay */ 208 /* Adjust clock delay */
208 clk_delay = sun4i_tcon_get_clk_delay(mode, 1); 209 clk_delay = sun4i_tcon_get_clk_delay(mode, 1);
@@ -266,7 +267,7 @@ void sun4i_tcon1_mode_set(struct sun4i_tcon *tcon,
266 /* 267 /*
267 * FIXME: Undocumented bits 268 * FIXME: Undocumented bits
268 */ 269 */
269 if (tcon->has_mux) 270 if (tcon->quirks->has_unknown_mux)
270 regmap_write(tcon->regs, SUN4I_TCON_MUX_CTRL_REG, 1); 271 regmap_write(tcon->regs, SUN4I_TCON_MUX_CTRL_REG, 1);
271} 272}
272EXPORT_SYMBOL(sun4i_tcon1_mode_set); 273EXPORT_SYMBOL(sun4i_tcon1_mode_set);
@@ -327,7 +328,7 @@ static int sun4i_tcon_init_clocks(struct device *dev,
327 return PTR_ERR(tcon->sclk0); 328 return PTR_ERR(tcon->sclk0);
328 } 329 }
329 330
330 if (tcon->has_channel_1) { 331 if (tcon->quirks->has_channel_1) {
331 tcon->sclk1 = devm_clk_get(dev, "tcon-ch1"); 332 tcon->sclk1 = devm_clk_get(dev, "tcon-ch1");
332 if (IS_ERR(tcon->sclk1)) { 333 if (IS_ERR(tcon->sclk1)) {
333 dev_err(dev, "Couldn't get the TCON channel 1 clock\n"); 334 dev_err(dev, "Couldn't get the TCON channel 1 clock\n");
@@ -487,14 +488,7 @@ static int sun4i_tcon_bind(struct device *dev, struct device *master,
487 drv->tcon = tcon; 488 drv->tcon = tcon;
488 tcon->drm = drm; 489 tcon->drm = drm;
489 tcon->dev = dev; 490 tcon->dev = dev;
490 491 tcon->quirks = of_device_get_match_data(dev);
491 if (of_device_is_compatible(dev->of_node, "allwinner,sun5i-a13-tcon")) {
492 tcon->has_mux = true;
493 tcon->has_channel_1 = true;
494 } else {
495 tcon->has_mux = false;
496 tcon->has_channel_1 = false;
497 }
498 492
499 tcon->lcd_rst = devm_reset_control_get(dev, "lcd"); 493 tcon->lcd_rst = devm_reset_control_get(dev, "lcd");
500 if (IS_ERR(tcon->lcd_rst)) { 494 if (IS_ERR(tcon->lcd_rst)) {
@@ -588,9 +582,28 @@ static int sun4i_tcon_remove(struct platform_device *pdev)
588 return 0; 582 return 0;
589} 583}
590 584
585static const struct sun4i_tcon_quirks sun5i_a13_quirks = {
586 .has_unknown_mux = true,
587 .has_channel_1 = true,
588};
589
590static const struct sun4i_tcon_quirks sun6i_a31_quirks = {
591 .has_channel_1 = true,
592};
593
594static const struct sun4i_tcon_quirks sun6i_a31s_quirks = {
595 .has_channel_1 = true,
596};
597
598static const struct sun4i_tcon_quirks sun8i_a33_quirks = {
599 /* nothing is supported */
600};
601
591static const struct of_device_id sun4i_tcon_of_table[] = { 602static const struct of_device_id sun4i_tcon_of_table[] = {
592 { .compatible = "allwinner,sun5i-a13-tcon" }, 603 { .compatible = "allwinner,sun5i-a13-tcon", .data = &sun5i_a13_quirks },
593 { .compatible = "allwinner,sun8i-a33-tcon" }, 604 { .compatible = "allwinner,sun6i-a31-tcon", .data = &sun6i_a31_quirks },
605 { .compatible = "allwinner,sun6i-a31s-tcon", .data = &sun6i_a31s_quirks },
606 { .compatible = "allwinner,sun8i-a33-tcon", .data = &sun8i_a33_quirks },
594 { } 607 { }
595}; 608};
596MODULE_DEVICE_TABLE(of, sun4i_tcon_of_table); 609MODULE_DEVICE_TABLE(of, sun4i_tcon_of_table);
diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.h b/drivers/gpu/drm/sun4i/sun4i_tcon.h
index 12bd48925f4d..166064bafe2e 100644
--- a/drivers/gpu/drm/sun4i/sun4i_tcon.h
+++ b/drivers/gpu/drm/sun4i/sun4i_tcon.h
@@ -142,6 +142,11 @@
142 142
143#define SUN4I_TCON_MAX_CHANNELS 2 143#define SUN4I_TCON_MAX_CHANNELS 2
144 144
145struct sun4i_tcon_quirks {
146 bool has_unknown_mux; /* sun5i has undocumented mux */
147 bool has_channel_1; /* a33 does not have channel 1 */
148};
149
145struct sun4i_tcon { 150struct sun4i_tcon {
146 struct device *dev; 151 struct device *dev;
147 struct drm_device *drm; 152 struct drm_device *drm;
@@ -160,12 +165,10 @@ struct sun4i_tcon {
160 /* Reset control */ 165 /* Reset control */
161 struct reset_control *lcd_rst; 166 struct reset_control *lcd_rst;
162 167
163 /* Platform adjustments */
164 bool has_mux;
165
166 struct drm_panel *panel; 168 struct drm_panel *panel;
167 169
168 bool has_channel_1; 170 /* Platform adjustments */
171 const struct sun4i_tcon_quirks *quirks;
169}; 172};
170 173
171struct drm_bridge *sun4i_tcon_find_bridge(struct device_node *node); 174struct drm_bridge *sun4i_tcon_find_bridge(struct device_node *node);
diff --git a/drivers/gpu/drm/sun4i/sun6i_drc.c b/drivers/gpu/drm/sun4i/sun6i_drc.c
index bf6d846d8132..6ef707c5a719 100644
--- a/drivers/gpu/drm/sun4i/sun6i_drc.c
+++ b/drivers/gpu/drm/sun4i/sun6i_drc.c
@@ -98,6 +98,8 @@ static int sun6i_drc_remove(struct platform_device *pdev)
98} 98}
99 99
100static const struct of_device_id sun6i_drc_of_table[] = { 100static const struct of_device_id sun6i_drc_of_table[] = {
101 { .compatible = "allwinner,sun6i-a31-drc" },
102 { .compatible = "allwinner,sun6i-a31s-drc" },
101 { .compatible = "allwinner,sun8i-a33-drc" }, 103 { .compatible = "allwinner,sun8i-a33-drc" },
102 { } 104 { }
103}; 105};