blob: 62f0ded706815dd6889608252c7ff702ba708ca0 [file] [log] [blame]
Thomas Gleixner2025cf92019-05-29 07:18:02 -07001// SPDX-License-Identifier: GPL-2.0-only
Stephen Warren26549c82013-05-24 15:55:13 -07002/*
3 * Simplest possible simple frame-buffer driver, as a platform device
4 *
5 * Copyright (c) 2013, Stephen Warren
6 *
7 * Based on q40fb.c, which was:
8 * Copyright (C) 2001 Richard Zidlicky <rz@linux-m68k.org>
9 *
10 * Also based on offb.c, which was:
11 * Copyright (C) 1997 Geert Uytterhoeven
12 * Copyright (C) 1996 Paul Mackerras
Stephen Warren26549c82013-05-24 15:55:13 -070013 */
14
15#include <linux/errno.h>
16#include <linux/fb.h>
17#include <linux/io.h>
18#include <linux/module.h>
David Herrmann5ef76da62013-08-02 14:05:20 +020019#include <linux/platform_data/simplefb.h>
Stephen Warren26549c82013-05-24 15:55:13 -070020#include <linux/platform_device.h>
Stephen Boydd49c6992015-06-19 15:00:46 -070021#include <linux/clk.h>
Chen-Yu Tsai814740e2015-11-17 12:31:03 +080022#include <linux/of.h>
Geert Uytterhoevendb3b4fd2018-07-03 17:43:09 +020023#include <linux/of_clk.h>
Hans de Goede89c95002014-11-14 13:26:53 +010024#include <linux/of_platform.h>
Chen-Yu Tsai814740e2015-11-17 12:31:03 +080025#include <linux/parser.h>
26#include <linux/regulator/consumer.h>
Stephen Warren26549c82013-05-24 15:55:13 -070027
Julia Lawallca9384c2016-09-11 17:17:20 +020028static const struct fb_fix_screeninfo simplefb_fix = {
Stephen Warren26549c82013-05-24 15:55:13 -070029 .id = "simple",
30 .type = FB_TYPE_PACKED_PIXELS,
31 .visual = FB_VISUAL_TRUECOLOR,
32 .accel = FB_ACCEL_NONE,
33};
34
Julia Lawallca9384c2016-09-11 17:17:20 +020035static const struct fb_var_screeninfo simplefb_var = {
Stephen Warren26549c82013-05-24 15:55:13 -070036 .height = -1,
37 .width = -1,
38 .activate = FB_ACTIVATE_NOW,
39 .vmode = FB_VMODE_NONINTERLACED,
40};
41
Luc Verhaegen1270be42014-11-14 13:26:48 +010042#define PSEUDO_PALETTE_SIZE 16
43
Stephen Warren26549c82013-05-24 15:55:13 -070044static int simplefb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
45 u_int transp, struct fb_info *info)
46{
47 u32 *pal = info->pseudo_palette;
48 u32 cr = red >> (16 - info->var.red.length);
49 u32 cg = green >> (16 - info->var.green.length);
50 u32 cb = blue >> (16 - info->var.blue.length);
51 u32 value;
52
Luc Verhaegen1270be42014-11-14 13:26:48 +010053 if (regno >= PSEUDO_PALETTE_SIZE)
Stephen Warren26549c82013-05-24 15:55:13 -070054 return -EINVAL;
55
56 value = (cr << info->var.red.offset) |
57 (cg << info->var.green.offset) |
58 (cb << info->var.blue.offset);
59 if (info->var.transp.length > 0) {
60 u32 mask = (1 << info->var.transp.length) - 1;
61 mask <<= info->var.transp.offset;
62 value |= mask;
63 }
64 pal[regno] = value;
65
66 return 0;
67}
68
Chen-Yu Tsai7c9806e2016-09-07 17:09:19 +080069struct simplefb_par;
70static void simplefb_clocks_destroy(struct simplefb_par *par);
71static void simplefb_regulators_destroy(struct simplefb_par *par);
72
David Herrmann498f6d32013-10-02 16:58:38 +020073static void simplefb_destroy(struct fb_info *info)
74{
Chen-Yu Tsai7c9806e2016-09-07 17:09:19 +080075 simplefb_regulators_destroy(info->par);
76 simplefb_clocks_destroy(info->par);
David Herrmann498f6d32013-10-02 16:58:38 +020077 if (info->screen_base)
78 iounmap(info->screen_base);
79}
80
Jani Nikula8a48ac332019-12-03 18:38:50 +020081static const struct fb_ops simplefb_ops = {
Stephen Warren26549c82013-05-24 15:55:13 -070082 .owner = THIS_MODULE,
David Herrmann498f6d32013-10-02 16:58:38 +020083 .fb_destroy = simplefb_destroy,
Stephen Warren26549c82013-05-24 15:55:13 -070084 .fb_setcolreg = simplefb_setcolreg,
85 .fb_fillrect = cfb_fillrect,
86 .fb_copyarea = cfb_copyarea,
87 .fb_imageblit = cfb_imageblit,
88};
89
David Herrmann5ef76da62013-08-02 14:05:20 +020090static struct simplefb_format simplefb_formats[] = SIMPLEFB_FORMATS;
Stephen Warren26549c82013-05-24 15:55:13 -070091
92struct simplefb_params {
93 u32 width;
94 u32 height;
95 u32 stride;
96 struct simplefb_format *format;
97};
98
99static int simplefb_parse_dt(struct platform_device *pdev,
100 struct simplefb_params *params)
101{
102 struct device_node *np = pdev->dev.of_node;
103 int ret;
104 const char *format;
105 int i;
106
107 ret = of_property_read_u32(np, "width", &params->width);
108 if (ret) {
109 dev_err(&pdev->dev, "Can't parse width property\n");
110 return ret;
111 }
112
113 ret = of_property_read_u32(np, "height", &params->height);
114 if (ret) {
115 dev_err(&pdev->dev, "Can't parse height property\n");
116 return ret;
117 }
118
119 ret = of_property_read_u32(np, "stride", &params->stride);
120 if (ret) {
121 dev_err(&pdev->dev, "Can't parse stride property\n");
122 return ret;
123 }
124
125 ret = of_property_read_string(np, "format", &format);
126 if (ret) {
127 dev_err(&pdev->dev, "Can't parse format property\n");
128 return ret;
129 }
130 params->format = NULL;
131 for (i = 0; i < ARRAY_SIZE(simplefb_formats); i++) {
132 if (strcmp(format, simplefb_formats[i].name))
133 continue;
134 params->format = &simplefb_formats[i];
135 break;
136 }
137 if (!params->format) {
138 dev_err(&pdev->dev, "Invalid format value\n");
139 return -EINVAL;
140 }
141
142 return 0;
143}
144
David Herrmann5ef76da62013-08-02 14:05:20 +0200145static int simplefb_parse_pd(struct platform_device *pdev,
146 struct simplefb_params *params)
147{
Jingoo Han129f1be2013-09-17 14:11:04 +0900148 struct simplefb_platform_data *pd = dev_get_platdata(&pdev->dev);
David Herrmann5ef76da62013-08-02 14:05:20 +0200149 int i;
150
151 params->width = pd->width;
152 params->height = pd->height;
153 params->stride = pd->stride;
154
155 params->format = NULL;
156 for (i = 0; i < ARRAY_SIZE(simplefb_formats); i++) {
157 if (strcmp(pd->format, simplefb_formats[i].name))
158 continue;
159
160 params->format = &simplefb_formats[i];
161 break;
162 }
163
164 if (!params->format) {
165 dev_err(&pdev->dev, "Invalid format value\n");
166 return -EINVAL;
167 }
168
169 return 0;
170}
171
Luc Verhaegen1270be42014-11-14 13:26:48 +0100172struct simplefb_par {
173 u32 palette[PSEUDO_PALETTE_SIZE];
Hans de Goede82847312014-11-25 12:13:30 +0100174#if defined CONFIG_OF && defined CONFIG_COMMON_CLK
Hans de Goedea3accfd2017-01-11 17:09:50 +0100175 bool clks_enabled;
Stephen Boyd2cd82d02016-02-22 11:14:25 -0800176 unsigned int clk_count;
Luc Verhaegenfc219bf2014-11-14 13:26:50 +0100177 struct clk **clks;
178#endif
Chen-Yu Tsai814740e2015-11-17 12:31:03 +0800179#if defined CONFIG_OF && defined CONFIG_REGULATOR
Hans de Goedea3accfd2017-01-11 17:09:50 +0100180 bool regulators_enabled;
Chen-Yu Tsai814740e2015-11-17 12:31:03 +0800181 u32 regulator_count;
182 struct regulator **regulators;
183#endif
Luc Verhaegen1270be42014-11-14 13:26:48 +0100184};
185
Hans de Goede82847312014-11-25 12:13:30 +0100186#if defined CONFIG_OF && defined CONFIG_COMMON_CLK
Luc Verhaegenfc219bf2014-11-14 13:26:50 +0100187/*
188 * Clock handling code.
189 *
190 * Here we handle the clocks property of our "simple-framebuffer" dt node.
191 * This is necessary so that we can make sure that any clocks needed by
192 * the display engine that the bootloader set up for us (and for which it
193 * provided a simplefb dt node), stay up, for the life of the simplefb
194 * driver.
195 *
196 * When the driver unloads, we cleanly disable, and then release the clocks.
197 *
198 * We only complain about errors here, no action is taken as the most likely
199 * error can only happen due to a mismatch between the bootloader which set
200 * up simplefb, and the clock definitions in the device tree. Chances are
201 * that there are no adverse effects, and if there are, a clean teardown of
202 * the fb probe will not help us much either. So just complain and carry on,
203 * and hope that the user actually gets a working fb at the end of things.
204 */
Hans de Goedea3accfd2017-01-11 17:09:50 +0100205static int simplefb_clocks_get(struct simplefb_par *par,
206 struct platform_device *pdev)
Luc Verhaegenfc219bf2014-11-14 13:26:50 +0100207{
208 struct device_node *np = pdev->dev.of_node;
209 struct clk *clock;
Hans de Goedea3accfd2017-01-11 17:09:50 +0100210 int i;
Luc Verhaegenfc219bf2014-11-14 13:26:50 +0100211
212 if (dev_get_platdata(&pdev->dev) || !np)
213 return 0;
214
215 par->clk_count = of_clk_get_parent_count(np);
Stephen Boyd2cd82d02016-02-22 11:14:25 -0800216 if (!par->clk_count)
Luc Verhaegenfc219bf2014-11-14 13:26:50 +0100217 return 0;
218
219 par->clks = kcalloc(par->clk_count, sizeof(struct clk *), GFP_KERNEL);
220 if (!par->clks)
221 return -ENOMEM;
222
223 for (i = 0; i < par->clk_count; i++) {
224 clock = of_clk_get(np, i);
225 if (IS_ERR(clock)) {
226 if (PTR_ERR(clock) == -EPROBE_DEFER) {
227 while (--i >= 0) {
228 if (par->clks[i])
229 clk_put(par->clks[i]);
230 }
231 kfree(par->clks);
232 return -EPROBE_DEFER;
233 }
234 dev_err(&pdev->dev, "%s: clock %d not found: %ld\n",
235 __func__, i, PTR_ERR(clock));
236 continue;
237 }
238 par->clks[i] = clock;
239 }
240
Hans de Goedea3accfd2017-01-11 17:09:50 +0100241 return 0;
242}
243
244static void simplefb_clocks_enable(struct simplefb_par *par,
245 struct platform_device *pdev)
246{
247 int i, ret;
248
Luc Verhaegenfc219bf2014-11-14 13:26:50 +0100249 for (i = 0; i < par->clk_count; i++) {
250 if (par->clks[i]) {
251 ret = clk_prepare_enable(par->clks[i]);
252 if (ret) {
253 dev_err(&pdev->dev,
254 "%s: failed to enable clock %d: %d\n",
255 __func__, i, ret);
256 clk_put(par->clks[i]);
257 par->clks[i] = NULL;
258 }
259 }
260 }
Hans de Goedea3accfd2017-01-11 17:09:50 +0100261 par->clks_enabled = true;
Luc Verhaegenfc219bf2014-11-14 13:26:50 +0100262}
263
264static void simplefb_clocks_destroy(struct simplefb_par *par)
265{
266 int i;
267
268 if (!par->clks)
269 return;
270
271 for (i = 0; i < par->clk_count; i++) {
272 if (par->clks[i]) {
Hans de Goedea3accfd2017-01-11 17:09:50 +0100273 if (par->clks_enabled)
274 clk_disable_unprepare(par->clks[i]);
Luc Verhaegenfc219bf2014-11-14 13:26:50 +0100275 clk_put(par->clks[i]);
276 }
277 }
278
279 kfree(par->clks);
280}
281#else
Hans de Goedea3accfd2017-01-11 17:09:50 +0100282static int simplefb_clocks_get(struct simplefb_par *par,
Luc Verhaegenfc219bf2014-11-14 13:26:50 +0100283 struct platform_device *pdev) { return 0; }
Hans de Goedea3accfd2017-01-11 17:09:50 +0100284static void simplefb_clocks_enable(struct simplefb_par *par,
285 struct platform_device *pdev) { }
Luc Verhaegenfc219bf2014-11-14 13:26:50 +0100286static void simplefb_clocks_destroy(struct simplefb_par *par) { }
287#endif
288
Chen-Yu Tsai814740e2015-11-17 12:31:03 +0800289#if defined CONFIG_OF && defined CONFIG_REGULATOR
290
291#define SUPPLY_SUFFIX "-supply"
292
293/*
294 * Regulator handling code.
295 *
296 * Here we handle the num-supplies and vin*-supply properties of our
297 * "simple-framebuffer" dt node. This is necessary so that we can make sure
298 * that any regulators needed by the display hardware that the bootloader
299 * set up for us (and for which it provided a simplefb dt node), stay up,
300 * for the life of the simplefb driver.
301 *
302 * When the driver unloads, we cleanly disable, and then release the
303 * regulators.
304 *
305 * We only complain about errors here, no action is taken as the most likely
306 * error can only happen due to a mismatch between the bootloader which set
307 * up simplefb, and the regulator definitions in the device tree. Chances are
308 * that there are no adverse effects, and if there are, a clean teardown of
309 * the fb probe will not help us much either. So just complain and carry on,
310 * and hope that the user actually gets a working fb at the end of things.
311 */
Hans de Goedea3accfd2017-01-11 17:09:50 +0100312static int simplefb_regulators_get(struct simplefb_par *par,
313 struct platform_device *pdev)
Chen-Yu Tsai814740e2015-11-17 12:31:03 +0800314{
315 struct device_node *np = pdev->dev.of_node;
316 struct property *prop;
317 struct regulator *regulator;
318 const char *p;
Hans de Goedea3accfd2017-01-11 17:09:50 +0100319 int count = 0, i = 0;
Chen-Yu Tsai814740e2015-11-17 12:31:03 +0800320
321 if (dev_get_platdata(&pdev->dev) || !np)
322 return 0;
323
324 /* Count the number of regulator supplies */
325 for_each_property_of_node(np, prop) {
326 p = strstr(prop->name, SUPPLY_SUFFIX);
327 if (p && p != prop->name)
328 count++;
329 }
330
331 if (!count)
332 return 0;
333
334 par->regulators = devm_kcalloc(&pdev->dev, count,
335 sizeof(struct regulator *), GFP_KERNEL);
336 if (!par->regulators)
337 return -ENOMEM;
338
339 /* Get all the regulators */
340 for_each_property_of_node(np, prop) {
341 char name[32]; /* 32 is max size of property name */
342
343 p = strstr(prop->name, SUPPLY_SUFFIX);
344 if (!p || p == prop->name)
345 continue;
346
347 strlcpy(name, prop->name,
348 strlen(prop->name) - strlen(SUPPLY_SUFFIX) + 1);
349 regulator = devm_regulator_get_optional(&pdev->dev, name);
350 if (IS_ERR(regulator)) {
351 if (PTR_ERR(regulator) == -EPROBE_DEFER)
352 return -EPROBE_DEFER;
353 dev_err(&pdev->dev, "regulator %s not found: %ld\n",
354 name, PTR_ERR(regulator));
355 continue;
356 }
357 par->regulators[i++] = regulator;
358 }
359 par->regulator_count = i;
360
Hans de Goedea3accfd2017-01-11 17:09:50 +0100361 return 0;
362}
363
364static void simplefb_regulators_enable(struct simplefb_par *par,
365 struct platform_device *pdev)
366{
367 int i, ret;
368
Chen-Yu Tsai814740e2015-11-17 12:31:03 +0800369 /* Enable all the regulators */
370 for (i = 0; i < par->regulator_count; i++) {
371 ret = regulator_enable(par->regulators[i]);
372 if (ret) {
373 dev_err(&pdev->dev,
374 "failed to enable regulator %d: %d\n",
375 i, ret);
376 devm_regulator_put(par->regulators[i]);
377 par->regulators[i] = NULL;
378 }
379 }
Hans de Goedea3accfd2017-01-11 17:09:50 +0100380 par->regulators_enabled = true;
Chen-Yu Tsai814740e2015-11-17 12:31:03 +0800381}
382
383static void simplefb_regulators_destroy(struct simplefb_par *par)
384{
385 int i;
386
Hans de Goedea3accfd2017-01-11 17:09:50 +0100387 if (!par->regulators || !par->regulators_enabled)
Chen-Yu Tsai814740e2015-11-17 12:31:03 +0800388 return;
389
390 for (i = 0; i < par->regulator_count; i++)
391 if (par->regulators[i])
392 regulator_disable(par->regulators[i]);
393}
394#else
Hans de Goedea3accfd2017-01-11 17:09:50 +0100395static int simplefb_regulators_get(struct simplefb_par *par,
Chen-Yu Tsai814740e2015-11-17 12:31:03 +0800396 struct platform_device *pdev) { return 0; }
Hans de Goedea3accfd2017-01-11 17:09:50 +0100397static void simplefb_regulators_enable(struct simplefb_par *par,
398 struct platform_device *pdev) { }
Chen-Yu Tsai814740e2015-11-17 12:31:03 +0800399static void simplefb_regulators_destroy(struct simplefb_par *par) { }
400#endif
401
Stephen Warren26549c82013-05-24 15:55:13 -0700402static int simplefb_probe(struct platform_device *pdev)
403{
404 int ret;
405 struct simplefb_params params;
406 struct fb_info *info;
Luc Verhaegen1270be42014-11-14 13:26:48 +0100407 struct simplefb_par *par;
Stephen Warren26549c82013-05-24 15:55:13 -0700408 struct resource *mem;
409
410 if (fb_get_options("simplefb", NULL))
411 return -ENODEV;
412
David Herrmann5ef76da62013-08-02 14:05:20 +0200413 ret = -ENODEV;
Jingoo Han129f1be2013-09-17 14:11:04 +0900414 if (dev_get_platdata(&pdev->dev))
David Herrmann5ef76da62013-08-02 14:05:20 +0200415 ret = simplefb_parse_pd(pdev, &params);
416 else if (pdev->dev.of_node)
417 ret = simplefb_parse_dt(pdev, &params);
418
Stephen Warren26549c82013-05-24 15:55:13 -0700419 if (ret)
420 return ret;
421
422 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
423 if (!mem) {
424 dev_err(&pdev->dev, "No memory resource\n");
425 return -EINVAL;
426 }
427
Luc Verhaegen1270be42014-11-14 13:26:48 +0100428 info = framebuffer_alloc(sizeof(struct simplefb_par), &pdev->dev);
Stephen Warren26549c82013-05-24 15:55:13 -0700429 if (!info)
430 return -ENOMEM;
431 platform_set_drvdata(pdev, info);
432
Luc Verhaegen1270be42014-11-14 13:26:48 +0100433 par = info->par;
434
Stephen Warren26549c82013-05-24 15:55:13 -0700435 info->fix = simplefb_fix;
436 info->fix.smem_start = mem->start;
437 info->fix.smem_len = resource_size(mem);
438 info->fix.line_length = params.stride;
439
440 info->var = simplefb_var;
441 info->var.xres = params.width;
442 info->var.yres = params.height;
443 info->var.xres_virtual = params.width;
444 info->var.yres_virtual = params.height;
445 info->var.bits_per_pixel = params.format->bits_per_pixel;
446 info->var.red = params.format->red;
447 info->var.green = params.format->green;
448 info->var.blue = params.format->blue;
449 info->var.transp = params.format->transp;
450
David Herrmanndf0960a2013-08-02 14:05:21 +0200451 info->apertures = alloc_apertures(1);
452 if (!info->apertures) {
Luc Verhaegenbf2fda12014-11-14 13:26:49 +0100453 ret = -ENOMEM;
454 goto error_fb_release;
David Herrmanndf0960a2013-08-02 14:05:21 +0200455 }
456 info->apertures->ranges[0].base = info->fix.smem_start;
457 info->apertures->ranges[0].size = info->fix.smem_len;
458
Stephen Warren26549c82013-05-24 15:55:13 -0700459 info->fbops = &simplefb_ops;
David Herrmanndf0960a2013-08-02 14:05:21 +0200460 info->flags = FBINFO_DEFAULT | FBINFO_MISC_FIRMWARE;
David Herrmann9e210be2013-10-02 16:58:39 +0200461 info->screen_base = ioremap_wc(info->fix.smem_start,
462 info->fix.smem_len);
Stephen Warren26549c82013-05-24 15:55:13 -0700463 if (!info->screen_base) {
Luc Verhaegenbf2fda12014-11-14 13:26:49 +0100464 ret = -ENOMEM;
465 goto error_fb_release;
Stephen Warren26549c82013-05-24 15:55:13 -0700466 }
Luc Verhaegen1270be42014-11-14 13:26:48 +0100467 info->pseudo_palette = par->palette;
Stephen Warren26549c82013-05-24 15:55:13 -0700468
Hans de Goedea3accfd2017-01-11 17:09:50 +0100469 ret = simplefb_clocks_get(par, pdev);
Luc Verhaegenfc219bf2014-11-14 13:26:50 +0100470 if (ret < 0)
471 goto error_unmap;
472
Hans de Goedea3accfd2017-01-11 17:09:50 +0100473 ret = simplefb_regulators_get(par, pdev);
Chen-Yu Tsai814740e2015-11-17 12:31:03 +0800474 if (ret < 0)
475 goto error_clocks;
476
Hans de Goedea3accfd2017-01-11 17:09:50 +0100477 simplefb_clocks_enable(par, pdev);
478 simplefb_regulators_enable(par, pdev);
479
Peter Robinson5269a612020-12-28 18:39:34 +0000480 dev_info(&pdev->dev, "framebuffer at 0x%lx, 0x%x bytes\n",
481 info->fix.smem_start, info->fix.smem_len);
Tom Gundersen9f192a92013-09-07 16:08:35 +0200482 dev_info(&pdev->dev, "format=%s, mode=%dx%dx%d, linelength=%d\n",
483 params.format->name,
484 info->var.xres, info->var.yres,
485 info->var.bits_per_pixel, info->fix.line_length);
486
Stephen Warren26549c82013-05-24 15:55:13 -0700487 ret = register_framebuffer(info);
488 if (ret < 0) {
489 dev_err(&pdev->dev, "Unable to register simplefb: %d\n", ret);
Chen-Yu Tsai814740e2015-11-17 12:31:03 +0800490 goto error_regulators;
Stephen Warren26549c82013-05-24 15:55:13 -0700491 }
492
493 dev_info(&pdev->dev, "fb%d: simplefb registered!\n", info->node);
494
495 return 0;
Luc Verhaegenbf2fda12014-11-14 13:26:49 +0100496
Chen-Yu Tsai814740e2015-11-17 12:31:03 +0800497error_regulators:
498 simplefb_regulators_destroy(par);
Luc Verhaegenfc219bf2014-11-14 13:26:50 +0100499error_clocks:
500 simplefb_clocks_destroy(par);
Luc Verhaegenbf2fda12014-11-14 13:26:49 +0100501error_unmap:
502 iounmap(info->screen_base);
503error_fb_release:
504 framebuffer_release(info);
505 return ret;
Stephen Warren26549c82013-05-24 15:55:13 -0700506}
507
508static int simplefb_remove(struct platform_device *pdev)
509{
510 struct fb_info *info = platform_get_drvdata(pdev);
511
512 unregister_framebuffer(info);
Stephen Warren26549c82013-05-24 15:55:13 -0700513 framebuffer_release(info);
514
515 return 0;
516}
517
518static const struct of_device_id simplefb_of_match[] = {
519 { .compatible = "simple-framebuffer", },
520 { },
521};
522MODULE_DEVICE_TABLE(of, simplefb_of_match);
523
524static struct platform_driver simplefb_driver = {
525 .driver = {
526 .name = "simple-framebuffer",
Stephen Warren26549c82013-05-24 15:55:13 -0700527 .of_match_table = simplefb_of_match,
528 },
529 .probe = simplefb_probe,
530 .remove = simplefb_remove,
531};
Hans de Goede89c95002014-11-14 13:26:53 +0100532
533static int __init simplefb_init(void)
534{
535 int ret;
536 struct device_node *np;
537
538 ret = platform_driver_register(&simplefb_driver);
539 if (ret)
540 return ret;
541
Hans de Goeded9e02012015-01-05 09:15:16 +0100542 if (IS_ENABLED(CONFIG_OF_ADDRESS) && of_chosen) {
Hans de Goede89c95002014-11-14 13:26:53 +0100543 for_each_child_of_node(of_chosen, np) {
544 if (of_device_is_compatible(np, "simple-framebuffer"))
545 of_platform_device_create(np, NULL, NULL);
546 }
547 }
548
549 return 0;
550}
551
Hans de Goede0c5b2402014-11-14 13:26:55 +0100552fs_initcall(simplefb_init);
Stephen Warren26549c82013-05-24 15:55:13 -0700553
554MODULE_AUTHOR("Stephen Warren <swarren@wwwdotorg.org>");
555MODULE_DESCRIPTION("Simple framebuffer driver");
556MODULE_LICENSE("GPL v2");