blob: d18d7e88d5118101a5b9fb49e7611f492180014a [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;
Maxime Ripard9026e0d2015-10-29 09:36:23 +0100212 u32 lo_paddr, hi_paddr;
213 dma_addr_t paddr;
Maxime Ripard9026e0d2015-10-29 09:36:23 +0100214
Chen-Yu Tsaicff21922017-10-14 12:02:48 +0800215 /* Get the start of the displayed memory */
216 paddr = drm_fb_cma_get_gem_addr(fb, state, 0);
Arnd Bergmannf1b78f02016-05-03 17:23:28 +0200217 DRM_DEBUG_DRIVER("Setting buffer address to %pad\n", &paddr);
Maxime Ripard9026e0d2015-10-29 09:36:23 +0100218
Chen-Yu Tsai46908032017-10-17 12:23:47 +0800219 /*
220 * backend DMA accesses DRAM directly, bypassing the system
221 * bus. As such, the address range is different and the buffer
222 * address needs to be corrected.
223 */
224 paddr -= PHYS_OFFSET;
225
Maxime Ripard9026e0d2015-10-29 09:36:23 +0100226 /* Write the 32 lower bits of the address (in bits) */
227 lo_paddr = paddr << 3;
228 DRM_DEBUG_DRIVER("Setting address lower bits to 0x%x\n", lo_paddr);
Icenowy Zheng87969332017-05-17 22:47:17 +0800229 regmap_write(backend->engine.regs,
230 SUN4I_BACKEND_LAYFB_L32ADD_REG(layer),
Maxime Ripard9026e0d2015-10-29 09:36:23 +0100231 lo_paddr);
232
233 /* And the upper bits */
234 hi_paddr = paddr >> 29;
235 DRM_DEBUG_DRIVER("Setting address high bits to 0x%x\n", hi_paddr);
Icenowy Zheng87969332017-05-17 22:47:17 +0800236 regmap_update_bits(backend->engine.regs, SUN4I_BACKEND_LAYFB_H4ADD_REG,
Maxime Ripard9026e0d2015-10-29 09:36:23 +0100237 SUN4I_BACKEND_LAYFB_H4ADD_MSK(layer),
238 SUN4I_BACKEND_LAYFB_H4ADD(layer, hi_paddr));
239
240 return 0;
241}
Maxime Ripard9026e0d2015-10-29 09:36:23 +0100242
Maxime Ripard440d2c72016-09-06 15:23:03 +0200243static int sun4i_backend_init_sat(struct device *dev) {
244 struct sun4i_backend *backend = dev_get_drvdata(dev);
245 int ret;
246
247 backend->sat_reset = devm_reset_control_get(dev, "sat");
248 if (IS_ERR(backend->sat_reset)) {
249 dev_err(dev, "Couldn't get the SAT reset line\n");
250 return PTR_ERR(backend->sat_reset);
251 }
252
253 ret = reset_control_deassert(backend->sat_reset);
254 if (ret) {
255 dev_err(dev, "Couldn't deassert the SAT reset line\n");
256 return ret;
257 }
258
259 backend->sat_clk = devm_clk_get(dev, "sat");
260 if (IS_ERR(backend->sat_clk)) {
261 dev_err(dev, "Couldn't get our SAT clock\n");
262 ret = PTR_ERR(backend->sat_clk);
263 goto err_assert_reset;
264 }
265
266 ret = clk_prepare_enable(backend->sat_clk);
267 if (ret) {
268 dev_err(dev, "Couldn't enable the SAT clock\n");
269 return ret;
270 }
271
272 return 0;
273
274err_assert_reset:
275 reset_control_assert(backend->sat_reset);
276 return ret;
277}
278
279static int sun4i_backend_free_sat(struct device *dev) {
280 struct sun4i_backend *backend = dev_get_drvdata(dev);
281
282 clk_disable_unprepare(backend->sat_clk);
283 reset_control_assert(backend->sat_reset);
284
285 return 0;
286}
287
Chen-Yu Tsaida3a1c32017-04-21 16:38:52 +0800288/*
289 * The display backend can take video output from the display frontend, or
290 * the display enhancement unit on the A80, as input for one it its layers.
291 * This relationship within the display pipeline is encoded in the device
292 * tree with of_graph, and we use it here to figure out which backend, if
293 * there are 2 or more, we are currently probing. The number would be in
294 * the "reg" property of the upstream output port endpoint.
295 */
296static int sun4i_backend_of_get_id(struct device_node *node)
297{
298 struct device_node *port, *ep;
299 int ret = -EINVAL;
300
301 /* input is port 0 */
302 port = of_graph_get_port_by_id(node, 0);
303 if (!port)
304 return -EINVAL;
305
306 /* try finding an upstream endpoint */
307 for_each_available_child_of_node(port, ep) {
308 struct device_node *remote;
309 u32 reg;
310
Kuninori Morimoto0bd46d72017-08-10 04:36:43 +0000311 remote = of_graph_get_remote_endpoint(ep);
Chen-Yu Tsaida3a1c32017-04-21 16:38:52 +0800312 if (!remote)
313 continue;
314
315 ret = of_property_read_u32(remote, "reg", &reg);
316 if (ret)
317 continue;
318
319 ret = reg;
320 }
321
322 of_node_put(port);
323
324 return ret;
325}
326
Icenowy Zheng87969332017-05-17 22:47:17 +0800327static const struct sunxi_engine_ops sun4i_backend_engine_ops = {
328 .commit = sun4i_backend_commit,
329 .layers_init = sun4i_layers_init,
330 .apply_color_correction = sun4i_backend_apply_color_correction,
331 .disable_color_correction = sun4i_backend_disable_color_correction,
332};
333
Maxime Ripard9026e0d2015-10-29 09:36:23 +0100334static struct regmap_config sun4i_backend_regmap_config = {
335 .reg_bits = 32,
336 .val_bits = 32,
337 .reg_stride = 4,
338 .max_register = 0x5800,
339};
340
341static int sun4i_backend_bind(struct device *dev, struct device *master,
342 void *data)
343{
344 struct platform_device *pdev = to_platform_device(dev);
345 struct drm_device *drm = data;
346 struct sun4i_drv *drv = drm->dev_private;
347 struct sun4i_backend *backend;
348 struct resource *res;
349 void __iomem *regs;
350 int i, ret;
351
352 backend = devm_kzalloc(dev, sizeof(*backend), GFP_KERNEL);
353 if (!backend)
354 return -ENOMEM;
355 dev_set_drvdata(dev, backend);
Maxime Ripard9026e0d2015-10-29 09:36:23 +0100356
Icenowy Zheng87969332017-05-17 22:47:17 +0800357 backend->engine.node = dev->of_node;
358 backend->engine.ops = &sun4i_backend_engine_ops;
359 backend->engine.id = sun4i_backend_of_get_id(dev->of_node);
360 if (backend->engine.id < 0)
361 return backend->engine.id;
Chen-Yu Tsaida3a1c32017-04-21 16:38:52 +0800362
Maxime Ripard9026e0d2015-10-29 09:36:23 +0100363 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
364 regs = devm_ioremap_resource(dev, res);
Wei Yongjun9a8aa932016-09-15 03:25:58 +0000365 if (IS_ERR(regs))
Maxime Ripard9026e0d2015-10-29 09:36:23 +0100366 return PTR_ERR(regs);
Maxime Ripard9026e0d2015-10-29 09:36:23 +0100367
Maxime Ripard9026e0d2015-10-29 09:36:23 +0100368 backend->reset = devm_reset_control_get(dev, NULL);
369 if (IS_ERR(backend->reset)) {
370 dev_err(dev, "Couldn't get our reset line\n");
371 return PTR_ERR(backend->reset);
372 }
373
374 ret = reset_control_deassert(backend->reset);
375 if (ret) {
376 dev_err(dev, "Couldn't deassert our reset line\n");
377 return ret;
378 }
379
380 backend->bus_clk = devm_clk_get(dev, "ahb");
381 if (IS_ERR(backend->bus_clk)) {
382 dev_err(dev, "Couldn't get the backend bus clock\n");
383 ret = PTR_ERR(backend->bus_clk);
384 goto err_assert_reset;
385 }
386 clk_prepare_enable(backend->bus_clk);
387
388 backend->mod_clk = devm_clk_get(dev, "mod");
389 if (IS_ERR(backend->mod_clk)) {
390 dev_err(dev, "Couldn't get the backend module clock\n");
391 ret = PTR_ERR(backend->mod_clk);
392 goto err_disable_bus_clk;
393 }
394 clk_prepare_enable(backend->mod_clk);
395
396 backend->ram_clk = devm_clk_get(dev, "ram");
397 if (IS_ERR(backend->ram_clk)) {
398 dev_err(dev, "Couldn't get the backend RAM clock\n");
399 ret = PTR_ERR(backend->ram_clk);
400 goto err_disable_mod_clk;
401 }
402 clk_prepare_enable(backend->ram_clk);
403
Maxime Ripard440d2c72016-09-06 15:23:03 +0200404 if (of_device_is_compatible(dev->of_node,
405 "allwinner,sun8i-a33-display-backend")) {
406 ret = sun4i_backend_init_sat(dev);
407 if (ret) {
408 dev_err(dev, "Couldn't init SAT resources\n");
409 goto err_disable_ram_clk;
410 }
411 }
412
Chen-Yu Tsai82702492017-10-14 12:02:47 +0800413 backend->engine.regs = devm_regmap_init_mmio(dev, regs,
414 &sun4i_backend_regmap_config);
415 if (IS_ERR(backend->engine.regs)) {
416 dev_err(dev, "Couldn't create the backend regmap\n");
417 return PTR_ERR(backend->engine.regs);
418 }
419
Icenowy Zheng87969332017-05-17 22:47:17 +0800420 list_add_tail(&backend->engine.list, &drv->engine_list);
Chen-Yu Tsai80a58242017-04-21 16:38:50 +0800421
Chen-Yu Tsai936598d2017-10-14 12:02:49 +0800422 /*
423 * Many of the backend's layer configuration registers have
424 * undefined default values. This poses a risk as we use
425 * regmap_update_bits in some places, and don't overwrite
426 * the whole register.
427 *
428 * Clear the registers here to have something predictable.
429 */
Maxime Ripard9026e0d2015-10-29 09:36:23 +0100430 for (i = 0x800; i < 0x1000; i += 4)
Icenowy Zheng87969332017-05-17 22:47:17 +0800431 regmap_write(backend->engine.regs, i, 0);
Maxime Ripard9026e0d2015-10-29 09:36:23 +0100432
433 /* Disable registers autoloading */
Icenowy Zheng87969332017-05-17 22:47:17 +0800434 regmap_write(backend->engine.regs, SUN4I_BACKEND_REGBUFFCTL_REG,
Maxime Ripard9026e0d2015-10-29 09:36:23 +0100435 SUN4I_BACKEND_REGBUFFCTL_AUTOLOAD_DIS);
436
437 /* Enable the backend */
Icenowy Zheng87969332017-05-17 22:47:17 +0800438 regmap_write(backend->engine.regs, SUN4I_BACKEND_MODCTL_REG,
Maxime Ripard9026e0d2015-10-29 09:36:23 +0100439 SUN4I_BACKEND_MODCTL_DEBE_EN |
440 SUN4I_BACKEND_MODCTL_START_CTL);
441
442 return 0;
443
Maxime Ripard440d2c72016-09-06 15:23:03 +0200444err_disable_ram_clk:
445 clk_disable_unprepare(backend->ram_clk);
Maxime Ripard9026e0d2015-10-29 09:36:23 +0100446err_disable_mod_clk:
447 clk_disable_unprepare(backend->mod_clk);
448err_disable_bus_clk:
449 clk_disable_unprepare(backend->bus_clk);
450err_assert_reset:
451 reset_control_assert(backend->reset);
452 return ret;
453}
454
455static void sun4i_backend_unbind(struct device *dev, struct device *master,
456 void *data)
457{
458 struct sun4i_backend *backend = dev_get_drvdata(dev);
459
Icenowy Zheng87969332017-05-17 22:47:17 +0800460 list_del(&backend->engine.list);
Chen-Yu Tsai80a58242017-04-21 16:38:50 +0800461
Maxime Ripard440d2c72016-09-06 15:23:03 +0200462 if (of_device_is_compatible(dev->of_node,
463 "allwinner,sun8i-a33-display-backend"))
464 sun4i_backend_free_sat(dev);
465
Maxime Ripard9026e0d2015-10-29 09:36:23 +0100466 clk_disable_unprepare(backend->ram_clk);
467 clk_disable_unprepare(backend->mod_clk);
468 clk_disable_unprepare(backend->bus_clk);
469 reset_control_assert(backend->reset);
470}
471
Julia Lawalldfeb6932016-11-12 18:19:58 +0100472static const struct component_ops sun4i_backend_ops = {
Maxime Ripard9026e0d2015-10-29 09:36:23 +0100473 .bind = sun4i_backend_bind,
474 .unbind = sun4i_backend_unbind,
475};
476
477static int sun4i_backend_probe(struct platform_device *pdev)
478{
479 return component_add(&pdev->dev, &sun4i_backend_ops);
480}
481
482static int sun4i_backend_remove(struct platform_device *pdev)
483{
484 component_del(&pdev->dev, &sun4i_backend_ops);
485
486 return 0;
487}
488
489static const struct of_device_id sun4i_backend_of_table[] = {
490 { .compatible = "allwinner,sun5i-a13-display-backend" },
Chen-Yu Tsai49c440e2016-10-20 11:43:41 +0800491 { .compatible = "allwinner,sun6i-a31-display-backend" },
Maxime Ripard4a408f12016-01-07 12:32:25 +0100492 { .compatible = "allwinner,sun8i-a33-display-backend" },
Maxime Ripard9026e0d2015-10-29 09:36:23 +0100493 { }
494};
495MODULE_DEVICE_TABLE(of, sun4i_backend_of_table);
496
497static struct platform_driver sun4i_backend_platform_driver = {
498 .probe = sun4i_backend_probe,
499 .remove = sun4i_backend_remove,
500 .driver = {
501 .name = "sun4i-backend",
502 .of_match_table = sun4i_backend_of_table,
503 },
504};
505module_platform_driver(sun4i_backend_platform_driver);
506
507MODULE_AUTHOR("Maxime Ripard <maxime.ripard@free-electrons.com>");
508MODULE_DESCRIPTION("Allwinner A10 Display Backend Driver");
509MODULE_LICENSE("GPL");