blob: cf480218daa509bacb90daf4f83b7f22c2b23511 [file] [log] [blame]
Maxime Ripard9026e0d2015-10-29 09:36:23 +01001/*
2 * Copyright (C) 2015 Free Electrons
3 * Copyright (C) 2015 NextThing Co
4 *
5 * Maxime Ripard <maxime.ripard@free-electrons.com>
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of
10 * the License, or (at your option) any later version.
11 */
12
13#include <drm/drmP.h>
14#include <drm/drm_atomic_helper.h>
15#include <drm/drm_crtc.h>
16#include <drm/drm_crtc_helper.h>
17#include <drm/drm_fb_cma_helper.h>
18#include <drm/drm_gem_cma_helper.h>
19#include <drm/drm_plane_helper.h>
20
21#include <linux/component.h>
Chen-Yu Tsai80a58242017-04-21 16:38:50 +080022#include <linux/list.h>
Chen-Yu Tsaida3a1c32017-04-21 16:38:52 +080023#include <linux/of_graph.h>
Maxime Ripard9026e0d2015-10-29 09:36:23 +010024#include <linux/reset.h>
25
26#include "sun4i_backend.h"
27#include "sun4i_drv.h"
Icenowy Zheng87969332017-05-17 22:47:17 +080028#include "sun4i_layer.h"
29#include "sunxi_engine.h"
Maxime Ripard9026e0d2015-10-29 09:36:23 +010030
Chen-Yu Tsaia6fbffb2017-02-23 16:05:33 +080031static const u32 sunxi_rgb2yuv_coef[12] = {
Maxime Ripard9026e0d2015-10-29 09:36:23 +010032 0x00000107, 0x00000204, 0x00000064, 0x00000108,
33 0x00003f69, 0x00003ed6, 0x000001c1, 0x00000808,
34 0x000001c1, 0x00003e88, 0x00003fb8, 0x00000808
35};
36
Icenowy Zheng87969332017-05-17 22:47:17 +080037static void sun4i_backend_apply_color_correction(struct sunxi_engine *engine)
Maxime Ripard9026e0d2015-10-29 09:36:23 +010038{
39 int i;
40
41 DRM_DEBUG_DRIVER("Applying RGB to YUV color correction\n");
42
43 /* Set color correction */
Icenowy Zheng87969332017-05-17 22:47:17 +080044 regmap_write(engine->regs, SUN4I_BACKEND_OCCTL_REG,
Maxime Ripard9026e0d2015-10-29 09:36:23 +010045 SUN4I_BACKEND_OCCTL_ENABLE);
46
47 for (i = 0; i < 12; i++)
Icenowy Zheng87969332017-05-17 22:47:17 +080048 regmap_write(engine->regs, SUN4I_BACKEND_OCRCOEF_REG(i),
Maxime Ripard9026e0d2015-10-29 09:36:23 +010049 sunxi_rgb2yuv_coef[i]);
50}
Maxime Ripard9026e0d2015-10-29 09:36:23 +010051
Icenowy Zheng87969332017-05-17 22:47:17 +080052static void sun4i_backend_disable_color_correction(struct sunxi_engine *engine)
Maxime Ripard9026e0d2015-10-29 09:36:23 +010053{
54 DRM_DEBUG_DRIVER("Disabling color correction\n");
55
56 /* Disable color correction */
Icenowy Zheng87969332017-05-17 22:47:17 +080057 regmap_update_bits(engine->regs, SUN4I_BACKEND_OCCTL_REG,
Maxime Ripard9026e0d2015-10-29 09:36:23 +010058 SUN4I_BACKEND_OCCTL_ENABLE, 0);
59}
Maxime Ripard9026e0d2015-10-29 09:36:23 +010060
Icenowy Zheng87969332017-05-17 22:47:17 +080061static void sun4i_backend_commit(struct sunxi_engine *engine)
Maxime Ripard9026e0d2015-10-29 09:36:23 +010062{
63 DRM_DEBUG_DRIVER("Committing changes\n");
64
Icenowy Zheng87969332017-05-17 22:47:17 +080065 regmap_write(engine->regs, SUN4I_BACKEND_REGBUFFCTL_REG,
Maxime Ripard9026e0d2015-10-29 09:36:23 +010066 SUN4I_BACKEND_REGBUFFCTL_AUTOLOAD_DIS |
67 SUN4I_BACKEND_REGBUFFCTL_LOADCTL);
68}
Maxime Ripard9026e0d2015-10-29 09:36:23 +010069
70void sun4i_backend_layer_enable(struct sun4i_backend *backend,
71 int layer, bool enable)
72{
73 u32 val;
74
Chen-Yu Tsaicf80aee2017-04-25 23:25:05 +080075 DRM_DEBUG_DRIVER("%sabling layer %d\n", enable ? "En" : "Dis",
76 layer);
Maxime Ripard9026e0d2015-10-29 09:36:23 +010077
78 if (enable)
79 val = SUN4I_BACKEND_MODCTL_LAY_EN(layer);
80 else
81 val = 0;
82
Icenowy Zheng87969332017-05-17 22:47:17 +080083 regmap_update_bits(backend->engine.regs, SUN4I_BACKEND_MODCTL_REG,
Maxime Ripard9026e0d2015-10-29 09:36:23 +010084 SUN4I_BACKEND_MODCTL_LAY_EN(layer), val);
85}
Maxime Ripard9026e0d2015-10-29 09:36:23 +010086
Maxime Ripardc222f392016-09-19 22:17:50 +020087static int sun4i_backend_drm_format_to_layer(struct drm_plane *plane,
88 u32 format, u32 *mode)
Maxime Ripard9026e0d2015-10-29 09:36:23 +010089{
Maxime Ripardc222f392016-09-19 22:17:50 +020090 if ((plane->type == DRM_PLANE_TYPE_PRIMARY) &&
91 (format == DRM_FORMAT_ARGB8888))
92 format = DRM_FORMAT_XRGB8888;
93
Maxime Ripard9026e0d2015-10-29 09:36:23 +010094 switch (format) {
95 case DRM_FORMAT_ARGB8888:
96 *mode = SUN4I_BACKEND_LAY_FBFMT_ARGB8888;
97 break;
98
Maxime Ripard47d7fbb2016-10-18 10:46:14 +020099 case DRM_FORMAT_ARGB4444:
100 *mode = SUN4I_BACKEND_LAY_FBFMT_ARGB4444;
101 break;
102
103 case DRM_FORMAT_ARGB1555:
104 *mode = SUN4I_BACKEND_LAY_FBFMT_ARGB1555;
105 break;
106
107 case DRM_FORMAT_RGBA5551:
108 *mode = SUN4I_BACKEND_LAY_FBFMT_RGBA5551;
109 break;
110
111 case DRM_FORMAT_RGBA4444:
112 *mode = SUN4I_BACKEND_LAY_FBFMT_RGBA4444;
113 break;
114
Maxime Ripard9026e0d2015-10-29 09:36:23 +0100115 case DRM_FORMAT_XRGB8888:
116 *mode = SUN4I_BACKEND_LAY_FBFMT_XRGB8888;
117 break;
118
119 case DRM_FORMAT_RGB888:
120 *mode = SUN4I_BACKEND_LAY_FBFMT_RGB888;
121 break;
122
Maxime Ripard47d7fbb2016-10-18 10:46:14 +0200123 case DRM_FORMAT_RGB565:
124 *mode = SUN4I_BACKEND_LAY_FBFMT_RGB565;
125 break;
126
Maxime Ripard9026e0d2015-10-29 09:36:23 +0100127 default:
128 return -EINVAL;
129 }
130
131 return 0;
132}
133
134int sun4i_backend_update_layer_coord(struct sun4i_backend *backend,
135 int layer, struct drm_plane *plane)
136{
137 struct drm_plane_state *state = plane->state;
138 struct drm_framebuffer *fb = state->fb;
139
140 DRM_DEBUG_DRIVER("Updating layer %d\n", layer);
141
142 if (plane->type == DRM_PLANE_TYPE_PRIMARY) {
143 DRM_DEBUG_DRIVER("Primary layer, updating global size W: %u H: %u\n",
144 state->crtc_w, state->crtc_h);
Icenowy Zheng87969332017-05-17 22:47:17 +0800145 regmap_write(backend->engine.regs, SUN4I_BACKEND_DISSIZE_REG,
Maxime Ripard9026e0d2015-10-29 09:36:23 +0100146 SUN4I_BACKEND_DISSIZE(state->crtc_w,
147 state->crtc_h));
148 }
149
150 /* Set the line width */
151 DRM_DEBUG_DRIVER("Layer line width: %d bits\n", fb->pitches[0] * 8);
Icenowy Zheng87969332017-05-17 22:47:17 +0800152 regmap_write(backend->engine.regs,
153 SUN4I_BACKEND_LAYLINEWIDTH_REG(layer),
Maxime Ripard9026e0d2015-10-29 09:36:23 +0100154 fb->pitches[0] * 8);
155
156 /* Set height and width */
157 DRM_DEBUG_DRIVER("Layer size W: %u H: %u\n",
158 state->crtc_w, state->crtc_h);
Icenowy Zheng87969332017-05-17 22:47:17 +0800159 regmap_write(backend->engine.regs, SUN4I_BACKEND_LAYSIZE_REG(layer),
Maxime Ripard9026e0d2015-10-29 09:36:23 +0100160 SUN4I_BACKEND_LAYSIZE(state->crtc_w,
161 state->crtc_h));
162
163 /* Set base coordinates */
164 DRM_DEBUG_DRIVER("Layer coordinates X: %d Y: %d\n",
165 state->crtc_x, state->crtc_y);
Icenowy Zheng87969332017-05-17 22:47:17 +0800166 regmap_write(backend->engine.regs, SUN4I_BACKEND_LAYCOOR_REG(layer),
Maxime Ripard9026e0d2015-10-29 09:36:23 +0100167 SUN4I_BACKEND_LAYCOOR(state->crtc_x,
168 state->crtc_y));
169
170 return 0;
171}
Maxime Ripard9026e0d2015-10-29 09:36:23 +0100172
173int sun4i_backend_update_layer_formats(struct sun4i_backend *backend,
174 int layer, struct drm_plane *plane)
175{
176 struct drm_plane_state *state = plane->state;
177 struct drm_framebuffer *fb = state->fb;
178 bool interlaced = false;
179 u32 val;
180 int ret;
181
182 if (plane->state->crtc)
183 interlaced = plane->state->crtc->state->adjusted_mode.flags
184 & DRM_MODE_FLAG_INTERLACE;
185
Icenowy Zheng87969332017-05-17 22:47:17 +0800186 regmap_update_bits(backend->engine.regs, SUN4I_BACKEND_MODCTL_REG,
Maxime Ripard9026e0d2015-10-29 09:36:23 +0100187 SUN4I_BACKEND_MODCTL_ITLMOD_EN,
188 interlaced ? SUN4I_BACKEND_MODCTL_ITLMOD_EN : 0);
189
190 DRM_DEBUG_DRIVER("Switching display backend interlaced mode %s\n",
191 interlaced ? "on" : "off");
192
Ville Syrjälä438b74a2016-12-14 23:32:55 +0200193 ret = sun4i_backend_drm_format_to_layer(plane, fb->format->format,
194 &val);
Maxime Ripard9026e0d2015-10-29 09:36:23 +0100195 if (ret) {
196 DRM_DEBUG_DRIVER("Invalid format\n");
Christophe JAILLET0f0861e2016-11-18 19:18:47 +0100197 return ret;
Maxime Ripard9026e0d2015-10-29 09:36:23 +0100198 }
199
Icenowy Zheng87969332017-05-17 22:47:17 +0800200 regmap_update_bits(backend->engine.regs,
201 SUN4I_BACKEND_ATTCTL_REG1(layer),
Maxime Ripard9026e0d2015-10-29 09:36:23 +0100202 SUN4I_BACKEND_ATTCTL_REG1_LAY_FBFMT, val);
203
204 return 0;
205}
Maxime Ripard9026e0d2015-10-29 09:36:23 +0100206
207int sun4i_backend_update_layer_buffer(struct sun4i_backend *backend,
208 int layer, struct drm_plane *plane)
209{
210 struct drm_plane_state *state = plane->state;
211 struct drm_framebuffer *fb = state->fb;
212 struct drm_gem_cma_object *gem;
213 u32 lo_paddr, hi_paddr;
214 dma_addr_t paddr;
215 int bpp;
216
217 /* Get the physical address of the buffer in memory */
218 gem = drm_fb_cma_get_gem_obj(fb, 0);
219
Arnd Bergmannf1b78f02016-05-03 17:23:28 +0200220 DRM_DEBUG_DRIVER("Using GEM @ %pad\n", &gem->paddr);
Maxime Ripard9026e0d2015-10-29 09:36:23 +0100221
222 /* Compute the start of the displayed memory */
Ville Syrjälä353c8592016-12-14 23:30:57 +0200223 bpp = fb->format->cpp[0];
Maxime Ripard9026e0d2015-10-29 09:36:23 +0100224 paddr = gem->paddr + fb->offsets[0];
225 paddr += (state->src_x >> 16) * bpp;
226 paddr += (state->src_y >> 16) * fb->pitches[0];
227
Arnd Bergmannf1b78f02016-05-03 17:23:28 +0200228 DRM_DEBUG_DRIVER("Setting buffer address to %pad\n", &paddr);
Maxime Ripard9026e0d2015-10-29 09:36:23 +0100229
230 /* Write the 32 lower bits of the address (in bits) */
231 lo_paddr = paddr << 3;
232 DRM_DEBUG_DRIVER("Setting address lower bits to 0x%x\n", lo_paddr);
Icenowy Zheng87969332017-05-17 22:47:17 +0800233 regmap_write(backend->engine.regs,
234 SUN4I_BACKEND_LAYFB_L32ADD_REG(layer),
Maxime Ripard9026e0d2015-10-29 09:36:23 +0100235 lo_paddr);
236
237 /* And the upper bits */
238 hi_paddr = paddr >> 29;
239 DRM_DEBUG_DRIVER("Setting address high bits to 0x%x\n", hi_paddr);
Icenowy Zheng87969332017-05-17 22:47:17 +0800240 regmap_update_bits(backend->engine.regs, SUN4I_BACKEND_LAYFB_H4ADD_REG,
Maxime Ripard9026e0d2015-10-29 09:36:23 +0100241 SUN4I_BACKEND_LAYFB_H4ADD_MSK(layer),
242 SUN4I_BACKEND_LAYFB_H4ADD(layer, hi_paddr));
243
244 return 0;
245}
Maxime Ripard9026e0d2015-10-29 09:36:23 +0100246
Maxime Ripard440d2c72016-09-06 15:23:03 +0200247static int sun4i_backend_init_sat(struct device *dev) {
248 struct sun4i_backend *backend = dev_get_drvdata(dev);
249 int ret;
250
251 backend->sat_reset = devm_reset_control_get(dev, "sat");
252 if (IS_ERR(backend->sat_reset)) {
253 dev_err(dev, "Couldn't get the SAT reset line\n");
254 return PTR_ERR(backend->sat_reset);
255 }
256
257 ret = reset_control_deassert(backend->sat_reset);
258 if (ret) {
259 dev_err(dev, "Couldn't deassert the SAT reset line\n");
260 return ret;
261 }
262
263 backend->sat_clk = devm_clk_get(dev, "sat");
264 if (IS_ERR(backend->sat_clk)) {
265 dev_err(dev, "Couldn't get our SAT clock\n");
266 ret = PTR_ERR(backend->sat_clk);
267 goto err_assert_reset;
268 }
269
270 ret = clk_prepare_enable(backend->sat_clk);
271 if (ret) {
272 dev_err(dev, "Couldn't enable the SAT clock\n");
273 return ret;
274 }
275
276 return 0;
277
278err_assert_reset:
279 reset_control_assert(backend->sat_reset);
280 return ret;
281}
282
283static int sun4i_backend_free_sat(struct device *dev) {
284 struct sun4i_backend *backend = dev_get_drvdata(dev);
285
286 clk_disable_unprepare(backend->sat_clk);
287 reset_control_assert(backend->sat_reset);
288
289 return 0;
290}
291
Chen-Yu Tsaida3a1c32017-04-21 16:38:52 +0800292/*
293 * The display backend can take video output from the display frontend, or
294 * the display enhancement unit on the A80, as input for one it its layers.
295 * This relationship within the display pipeline is encoded in the device
296 * tree with of_graph, and we use it here to figure out which backend, if
297 * there are 2 or more, we are currently probing. The number would be in
298 * the "reg" property of the upstream output port endpoint.
299 */
300static int sun4i_backend_of_get_id(struct device_node *node)
301{
302 struct device_node *port, *ep;
303 int ret = -EINVAL;
304
305 /* input is port 0 */
306 port = of_graph_get_port_by_id(node, 0);
307 if (!port)
308 return -EINVAL;
309
310 /* try finding an upstream endpoint */
311 for_each_available_child_of_node(port, ep) {
312 struct device_node *remote;
313 u32 reg;
314
315 remote = of_parse_phandle(ep, "remote-endpoint", 0);
316 if (!remote)
317 continue;
318
319 ret = of_property_read_u32(remote, "reg", &reg);
320 if (ret)
321 continue;
322
323 ret = reg;
324 }
325
326 of_node_put(port);
327
328 return ret;
329}
330
Icenowy Zheng87969332017-05-17 22:47:17 +0800331static const struct sunxi_engine_ops sun4i_backend_engine_ops = {
332 .commit = sun4i_backend_commit,
333 .layers_init = sun4i_layers_init,
334 .apply_color_correction = sun4i_backend_apply_color_correction,
335 .disable_color_correction = sun4i_backend_disable_color_correction,
336};
337
Maxime Ripard9026e0d2015-10-29 09:36:23 +0100338static struct regmap_config sun4i_backend_regmap_config = {
339 .reg_bits = 32,
340 .val_bits = 32,
341 .reg_stride = 4,
342 .max_register = 0x5800,
343};
344
345static int sun4i_backend_bind(struct device *dev, struct device *master,
346 void *data)
347{
348 struct platform_device *pdev = to_platform_device(dev);
349 struct drm_device *drm = data;
350 struct sun4i_drv *drv = drm->dev_private;
351 struct sun4i_backend *backend;
352 struct resource *res;
353 void __iomem *regs;
354 int i, ret;
355
356 backend = devm_kzalloc(dev, sizeof(*backend), GFP_KERNEL);
357 if (!backend)
358 return -ENOMEM;
359 dev_set_drvdata(dev, backend);
Maxime Ripard9026e0d2015-10-29 09:36:23 +0100360
Icenowy Zheng87969332017-05-17 22:47:17 +0800361 backend->engine.node = dev->of_node;
362 backend->engine.ops = &sun4i_backend_engine_ops;
363 backend->engine.id = sun4i_backend_of_get_id(dev->of_node);
364 if (backend->engine.id < 0)
365 return backend->engine.id;
Chen-Yu Tsaida3a1c32017-04-21 16:38:52 +0800366
Maxime Ripard9026e0d2015-10-29 09:36:23 +0100367 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
368 regs = devm_ioremap_resource(dev, res);
Wei Yongjun9a8aa932016-09-15 03:25:58 +0000369 if (IS_ERR(regs))
Maxime Ripard9026e0d2015-10-29 09:36:23 +0100370 return PTR_ERR(regs);
Maxime Ripard9026e0d2015-10-29 09:36:23 +0100371
Icenowy Zheng87969332017-05-17 22:47:17 +0800372 backend->engine.regs = devm_regmap_init_mmio(dev, regs,
373 &sun4i_backend_regmap_config);
374 if (IS_ERR(backend->engine.regs)) {
Chen-Yu Tsaifdde6e72017-04-21 16:38:51 +0800375 dev_err(dev, "Couldn't create the backend regmap\n");
Icenowy Zheng87969332017-05-17 22:47:17 +0800376 return PTR_ERR(backend->engine.regs);
Maxime Ripard9026e0d2015-10-29 09:36:23 +0100377 }
378
379 backend->reset = devm_reset_control_get(dev, NULL);
380 if (IS_ERR(backend->reset)) {
381 dev_err(dev, "Couldn't get our reset line\n");
382 return PTR_ERR(backend->reset);
383 }
384
385 ret = reset_control_deassert(backend->reset);
386 if (ret) {
387 dev_err(dev, "Couldn't deassert our reset line\n");
388 return ret;
389 }
390
391 backend->bus_clk = devm_clk_get(dev, "ahb");
392 if (IS_ERR(backend->bus_clk)) {
393 dev_err(dev, "Couldn't get the backend bus clock\n");
394 ret = PTR_ERR(backend->bus_clk);
395 goto err_assert_reset;
396 }
397 clk_prepare_enable(backend->bus_clk);
398
399 backend->mod_clk = devm_clk_get(dev, "mod");
400 if (IS_ERR(backend->mod_clk)) {
401 dev_err(dev, "Couldn't get the backend module clock\n");
402 ret = PTR_ERR(backend->mod_clk);
403 goto err_disable_bus_clk;
404 }
405 clk_prepare_enable(backend->mod_clk);
406
407 backend->ram_clk = devm_clk_get(dev, "ram");
408 if (IS_ERR(backend->ram_clk)) {
409 dev_err(dev, "Couldn't get the backend RAM clock\n");
410 ret = PTR_ERR(backend->ram_clk);
411 goto err_disable_mod_clk;
412 }
413 clk_prepare_enable(backend->ram_clk);
414
Maxime Ripard440d2c72016-09-06 15:23:03 +0200415 if (of_device_is_compatible(dev->of_node,
416 "allwinner,sun8i-a33-display-backend")) {
417 ret = sun4i_backend_init_sat(dev);
418 if (ret) {
419 dev_err(dev, "Couldn't init SAT resources\n");
420 goto err_disable_ram_clk;
421 }
422 }
423
Icenowy Zheng87969332017-05-17 22:47:17 +0800424 list_add_tail(&backend->engine.list, &drv->engine_list);
Chen-Yu Tsai80a58242017-04-21 16:38:50 +0800425
Maxime Ripard9026e0d2015-10-29 09:36:23 +0100426 /* Reset the registers */
427 for (i = 0x800; i < 0x1000; i += 4)
Icenowy Zheng87969332017-05-17 22:47:17 +0800428 regmap_write(backend->engine.regs, i, 0);
Maxime Ripard9026e0d2015-10-29 09:36:23 +0100429
430 /* Disable registers autoloading */
Icenowy Zheng87969332017-05-17 22:47:17 +0800431 regmap_write(backend->engine.regs, SUN4I_BACKEND_REGBUFFCTL_REG,
Maxime Ripard9026e0d2015-10-29 09:36:23 +0100432 SUN4I_BACKEND_REGBUFFCTL_AUTOLOAD_DIS);
433
434 /* Enable the backend */
Icenowy Zheng87969332017-05-17 22:47:17 +0800435 regmap_write(backend->engine.regs, SUN4I_BACKEND_MODCTL_REG,
Maxime Ripard9026e0d2015-10-29 09:36:23 +0100436 SUN4I_BACKEND_MODCTL_DEBE_EN |
437 SUN4I_BACKEND_MODCTL_START_CTL);
438
439 return 0;
440
Maxime Ripard440d2c72016-09-06 15:23:03 +0200441err_disable_ram_clk:
442 clk_disable_unprepare(backend->ram_clk);
Maxime Ripard9026e0d2015-10-29 09:36:23 +0100443err_disable_mod_clk:
444 clk_disable_unprepare(backend->mod_clk);
445err_disable_bus_clk:
446 clk_disable_unprepare(backend->bus_clk);
447err_assert_reset:
448 reset_control_assert(backend->reset);
449 return ret;
450}
451
452static void sun4i_backend_unbind(struct device *dev, struct device *master,
453 void *data)
454{
455 struct sun4i_backend *backend = dev_get_drvdata(dev);
456
Icenowy Zheng87969332017-05-17 22:47:17 +0800457 list_del(&backend->engine.list);
Chen-Yu Tsai80a58242017-04-21 16:38:50 +0800458
Maxime Ripard440d2c72016-09-06 15:23:03 +0200459 if (of_device_is_compatible(dev->of_node,
460 "allwinner,sun8i-a33-display-backend"))
461 sun4i_backend_free_sat(dev);
462
Maxime Ripard9026e0d2015-10-29 09:36:23 +0100463 clk_disable_unprepare(backend->ram_clk);
464 clk_disable_unprepare(backend->mod_clk);
465 clk_disable_unprepare(backend->bus_clk);
466 reset_control_assert(backend->reset);
467}
468
Julia Lawalldfeb6932016-11-12 18:19:58 +0100469static const struct component_ops sun4i_backend_ops = {
Maxime Ripard9026e0d2015-10-29 09:36:23 +0100470 .bind = sun4i_backend_bind,
471 .unbind = sun4i_backend_unbind,
472};
473
474static int sun4i_backend_probe(struct platform_device *pdev)
475{
476 return component_add(&pdev->dev, &sun4i_backend_ops);
477}
478
479static int sun4i_backend_remove(struct platform_device *pdev)
480{
481 component_del(&pdev->dev, &sun4i_backend_ops);
482
483 return 0;
484}
485
486static const struct of_device_id sun4i_backend_of_table[] = {
487 { .compatible = "allwinner,sun5i-a13-display-backend" },
Chen-Yu Tsai49c440e2016-10-20 11:43:41 +0800488 { .compatible = "allwinner,sun6i-a31-display-backend" },
Maxime Ripard4a408f12016-01-07 12:32:25 +0100489 { .compatible = "allwinner,sun8i-a33-display-backend" },
Maxime Ripard9026e0d2015-10-29 09:36:23 +0100490 { }
491};
492MODULE_DEVICE_TABLE(of, sun4i_backend_of_table);
493
494static struct platform_driver sun4i_backend_platform_driver = {
495 .probe = sun4i_backend_probe,
496 .remove = sun4i_backend_remove,
497 .driver = {
498 .name = "sun4i-backend",
499 .of_match_table = sun4i_backend_of_table,
500 },
501};
502module_platform_driver(sun4i_backend_platform_driver);
503
504MODULE_AUTHOR("Maxime Ripard <maxime.ripard@free-electrons.com>");
505MODULE_DESCRIPTION("Allwinner A10 Display Backend Driver");
506MODULE_LICENSE("GPL");