]>
Commit | Line | Data |
---|---|---|
559d6701 TV |
1 | /* |
2 | * linux/drivers/video/omap2/dss/core.c | |
3 | * | |
4 | * Copyright (C) 2009 Nokia Corporation | |
5 | * Author: Tomi Valkeinen <tomi.valkeinen@nokia.com> | |
6 | * | |
7 | * Some code and ideas taken from drivers/video/omap/ driver | |
8 | * by Imre Deak. | |
9 | * | |
10 | * This program is free software; you can redistribute it and/or modify it | |
11 | * under the terms of the GNU General Public License version 2 as published by | |
12 | * the Free Software Foundation. | |
13 | * | |
14 | * This program is distributed in the hope that it will be useful, but WITHOUT | |
15 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
16 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
17 | * more details. | |
18 | * | |
19 | * You should have received a copy of the GNU General Public License along with | |
20 | * this program. If not, see <http://www.gnu.org/licenses/>. | |
21 | */ | |
22 | ||
23 | #define DSS_SUBSYS_NAME "CORE" | |
24 | ||
25 | #include <linux/kernel.h> | |
26 | #include <linux/module.h> | |
27 | #include <linux/clk.h> | |
28 | #include <linux/err.h> | |
29 | #include <linux/platform_device.h> | |
30 | #include <linux/seq_file.h> | |
31 | #include <linux/debugfs.h> | |
32 | #include <linux/io.h> | |
33 | #include <linux/device.h> | |
8a2cfea8 | 34 | #include <linux/regulator/consumer.h> |
736f29cd | 35 | #include <linux/suspend.h> |
5274484b | 36 | #include <linux/slab.h> |
559d6701 | 37 | |
a0b38cc4 | 38 | #include <video/omapdss.h> |
559d6701 TV |
39 | |
40 | #include "dss.h" | |
a0acb557 | 41 | #include "dss_features.h" |
559d6701 TV |
42 | |
43 | static struct { | |
44 | struct platform_device *pdev; | |
8a2cfea8 TV |
45 | |
46 | struct regulator *vdds_dsi_reg; | |
47 | struct regulator *vdds_sdi_reg; | |
c018c673 TV |
48 | |
49 | const char *default_display_name; | |
559d6701 TV |
50 | } core; |
51 | ||
559d6701 TV |
52 | static char *def_disp_name; |
53 | module_param_named(def_disp, def_disp_name, charp, 0); | |
ac425ed5 | 54 | MODULE_PARM_DESC(def_disp, "default display name"); |
559d6701 | 55 | |
591a0ac7 TV |
56 | static bool dss_initialized; |
57 | ||
2bbcce5e | 58 | const char *omapdss_get_default_display_name(void) |
6a03fca9 TV |
59 | { |
60 | return core.default_display_name; | |
61 | } | |
2bbcce5e | 62 | EXPORT_SYMBOL(omapdss_get_default_display_name); |
6a03fca9 | 63 | |
b2c7d54f TV |
64 | enum omapdss_version omapdss_get_version(void) |
65 | { | |
66 | struct omap_dss_board_info *pdata = core.pdev->dev.platform_data; | |
67 | return pdata->version; | |
68 | } | |
69 | EXPORT_SYMBOL(omapdss_get_version); | |
70 | ||
591a0ac7 TV |
71 | bool omapdss_is_initialized(void) |
72 | { | |
73 | return dss_initialized; | |
74 | } | |
75 | EXPORT_SYMBOL(omapdss_is_initialized); | |
76 | ||
8f46efad TV |
77 | struct platform_device *dss_get_core_pdev(void) |
78 | { | |
79 | return core.pdev; | |
80 | } | |
81 | ||
8a2cfea8 TV |
82 | /* REGULATORS */ |
83 | ||
84 | struct regulator *dss_get_vdds_dsi(void) | |
85 | { | |
86 | struct regulator *reg; | |
87 | ||
88 | if (core.vdds_dsi_reg != NULL) | |
89 | return core.vdds_dsi_reg; | |
90 | ||
51930bba | 91 | reg = devm_regulator_get(&core.pdev->dev, "vdds_dsi"); |
8a2cfea8 TV |
92 | if (!IS_ERR(reg)) |
93 | core.vdds_dsi_reg = reg; | |
94 | ||
95 | return reg; | |
96 | } | |
97 | ||
98 | struct regulator *dss_get_vdds_sdi(void) | |
99 | { | |
100 | struct regulator *reg; | |
101 | ||
102 | if (core.vdds_sdi_reg != NULL) | |
103 | return core.vdds_sdi_reg; | |
104 | ||
51930bba | 105 | reg = devm_regulator_get(&core.pdev->dev, "vdds_sdi"); |
8a2cfea8 TV |
106 | if (!IS_ERR(reg)) |
107 | core.vdds_sdi_reg = reg; | |
108 | ||
109 | return reg; | |
110 | } | |
111 | ||
00928eaf TV |
112 | int dss_dsi_enable_pads(int dsi_id, unsigned lane_mask) |
113 | { | |
114 | struct omap_dss_board_info *board_data = core.pdev->dev.platform_data; | |
115 | ||
116 | if (!board_data->dsi_enable_pads) | |
117 | return -ENOENT; | |
118 | ||
119 | return board_data->dsi_enable_pads(dsi_id, lane_mask); | |
120 | } | |
121 | ||
122 | void dss_dsi_disable_pads(int dsi_id, unsigned lane_mask) | |
123 | { | |
124 | struct omap_dss_board_info *board_data = core.pdev->dev.platform_data; | |
125 | ||
da6c5687 | 126 | if (!board_data->dsi_disable_pads) |
00928eaf TV |
127 | return; |
128 | ||
129 | return board_data->dsi_disable_pads(dsi_id, lane_mask); | |
130 | } | |
131 | ||
a8081d31 TV |
132 | int dss_set_min_bus_tput(struct device *dev, unsigned long tput) |
133 | { | |
134 | struct omap_dss_board_info *pdata = core.pdev->dev.platform_data; | |
135 | ||
136 | if (pdata->set_min_bus_tput) | |
137 | return pdata->set_min_bus_tput(dev, tput); | |
138 | else | |
139 | return 0; | |
140 | } | |
141 | ||
1b3bcb33 | 142 | #if defined(CONFIG_OMAP2_DSS_DEBUGFS) |
559d6701 TV |
143 | static int dss_debug_show(struct seq_file *s, void *unused) |
144 | { | |
145 | void (*func)(struct seq_file *) = s->private; | |
146 | func(s); | |
147 | return 0; | |
148 | } | |
149 | ||
150 | static int dss_debug_open(struct inode *inode, struct file *file) | |
151 | { | |
152 | return single_open(file, dss_debug_show, inode->i_private); | |
153 | } | |
154 | ||
155 | static const struct file_operations dss_debug_fops = { | |
156 | .open = dss_debug_open, | |
157 | .read = seq_read, | |
158 | .llseek = seq_lseek, | |
159 | .release = single_release, | |
160 | }; | |
161 | ||
162 | static struct dentry *dss_debugfs_dir; | |
163 | ||
164 | static int dss_initialize_debugfs(void) | |
165 | { | |
166 | dss_debugfs_dir = debugfs_create_dir("omapdss", NULL); | |
167 | if (IS_ERR(dss_debugfs_dir)) { | |
168 | int err = PTR_ERR(dss_debugfs_dir); | |
169 | dss_debugfs_dir = NULL; | |
170 | return err; | |
171 | } | |
172 | ||
173 | debugfs_create_file("clk", S_IRUGO, dss_debugfs_dir, | |
174 | &dss_debug_dump_clocks, &dss_debug_fops); | |
175 | ||
559d6701 TV |
176 | return 0; |
177 | } | |
178 | ||
179 | static void dss_uninitialize_debugfs(void) | |
180 | { | |
181 | if (dss_debugfs_dir) | |
182 | debugfs_remove_recursive(dss_debugfs_dir); | |
183 | } | |
e40402cf TV |
184 | |
185 | int dss_debugfs_create_file(const char *name, void (*write)(struct seq_file *)) | |
186 | { | |
187 | struct dentry *d; | |
188 | ||
189 | d = debugfs_create_file(name, S_IRUGO, dss_debugfs_dir, | |
190 | write, &dss_debug_fops); | |
191 | ||
48c2169f | 192 | return PTR_RET(d); |
e40402cf | 193 | } |
1b3bcb33 | 194 | #else /* CONFIG_OMAP2_DSS_DEBUGFS */ |
368a148e JN |
195 | static inline int dss_initialize_debugfs(void) |
196 | { | |
197 | return 0; | |
198 | } | |
199 | static inline void dss_uninitialize_debugfs(void) | |
200 | { | |
201 | } | |
0e9a126e | 202 | int dss_debugfs_create_file(const char *name, void (*write)(struct seq_file *)) |
e40402cf TV |
203 | { |
204 | return 0; | |
205 | } | |
1b3bcb33 | 206 | #endif /* CONFIG_OMAP2_DSS_DEBUGFS */ |
559d6701 TV |
207 | |
208 | /* PLATFORM DEVICE */ | |
736f29cd TV |
209 | static int omap_dss_pm_notif(struct notifier_block *b, unsigned long v, void *d) |
210 | { | |
211 | DSSDBG("pm notif %lu\n", v); | |
212 | ||
213 | switch (v) { | |
214 | case PM_SUSPEND_PREPARE: | |
215 | DSSDBG("suspending displays\n"); | |
216 | return dss_suspend_all_devices(); | |
217 | ||
218 | case PM_POST_SUSPEND: | |
219 | DSSDBG("resuming displays\n"); | |
220 | return dss_resume_all_devices(); | |
221 | ||
222 | default: | |
223 | return 0; | |
224 | } | |
225 | } | |
226 | ||
227 | static struct notifier_block omap_dss_pm_notif_block = { | |
228 | .notifier_call = omap_dss_pm_notif, | |
229 | }; | |
230 | ||
6e7e8f06 | 231 | static int __init omap_dss_probe(struct platform_device *pdev) |
559d6701 TV |
232 | { |
233 | struct omap_dss_board_info *pdata = pdev->dev.platform_data; | |
559d6701 | 234 | int r; |
559d6701 TV |
235 | |
236 | core.pdev = pdev; | |
237 | ||
b2c7d54f | 238 | dss_features_init(omapdss_get_version()); |
a0acb557 | 239 | |
559d6701 TV |
240 | r = dss_initialize_debugfs(); |
241 | if (r) | |
fce064cb | 242 | goto err_debugfs; |
559d6701 | 243 | |
c018c673 TV |
244 | if (def_disp_name) |
245 | core.default_display_name = def_disp_name; | |
0a200126 TV |
246 | else if (pdata->default_display_name) |
247 | core.default_display_name = pdata->default_display_name; | |
c018c673 TV |
248 | else if (pdata->default_device) |
249 | core.default_display_name = pdata->default_device->name; | |
250 | ||
736f29cd TV |
251 | register_pm_notifier(&omap_dss_pm_notif_block); |
252 | ||
559d6701 TV |
253 | return 0; |
254 | ||
fce064cb | 255 | err_debugfs: |
fce064cb | 256 | |
559d6701 TV |
257 | return r; |
258 | } | |
259 | ||
260 | static int omap_dss_remove(struct platform_device *pdev) | |
261 | { | |
736f29cd TV |
262 | unregister_pm_notifier(&omap_dss_pm_notif_block); |
263 | ||
559d6701 | 264 | dss_uninitialize_debugfs(); |
559d6701 | 265 | |
559d6701 TV |
266 | return 0; |
267 | } | |
268 | ||
269 | static void omap_dss_shutdown(struct platform_device *pdev) | |
270 | { | |
271 | DSSDBG("shutdown\n"); | |
272 | dss_disable_all_devices(); | |
273 | } | |
274 | ||
559d6701 | 275 | static struct platform_driver omap_dss_driver = { |
559d6701 TV |
276 | .remove = omap_dss_remove, |
277 | .shutdown = omap_dss_shutdown, | |
559d6701 TV |
278 | .driver = { |
279 | .name = "omapdss", | |
280 | .owner = THIS_MODULE, | |
281 | }, | |
282 | }; | |
283 | ||
284 | /* BUS */ | |
285 | static int dss_bus_match(struct device *dev, struct device_driver *driver) | |
286 | { | |
287 | struct omap_dss_device *dssdev = to_dss_device(dev); | |
288 | ||
289 | DSSDBG("bus_match. dev %s/%s, drv %s\n", | |
290 | dev_name(dev), dssdev->driver_name, driver->name); | |
291 | ||
292 | return strcmp(dssdev->driver_name, driver->name) == 0; | |
293 | } | |
294 | ||
559d6701 TV |
295 | static struct bus_type dss_bus_type = { |
296 | .name = "omapdss", | |
297 | .match = dss_bus_match, | |
559d6701 TV |
298 | }; |
299 | ||
300 | static void dss_bus_release(struct device *dev) | |
301 | { | |
302 | DSSDBG("bus_release\n"); | |
303 | } | |
304 | ||
305 | static struct device dss_bus = { | |
306 | .release = dss_bus_release, | |
307 | }; | |
308 | ||
309 | struct bus_type *dss_get_bus(void) | |
310 | { | |
311 | return &dss_bus_type; | |
312 | } | |
313 | ||
314 | /* DRIVER */ | |
315 | static int dss_driver_probe(struct device *dev) | |
316 | { | |
317 | int r; | |
318 | struct omap_dss_driver *dssdrv = to_dss_driver(dev->driver); | |
319 | struct omap_dss_device *dssdev = to_dss_device(dev); | |
559d6701 TV |
320 | |
321 | DSSDBG("driver_probe: dev %s/%s, drv %s\n", | |
322 | dev_name(dev), dssdev->driver_name, | |
323 | dssdrv->driver.name); | |
324 | ||
559d6701 TV |
325 | r = dssdrv->probe(dssdev); |
326 | ||
327 | if (r) { | |
328 | DSSERR("driver probe failed: %d\n", r); | |
329 | return r; | |
330 | } | |
331 | ||
332 | DSSDBG("probe done for device %s\n", dev_name(dev)); | |
333 | ||
334 | dssdev->driver = dssdrv; | |
335 | ||
336 | return 0; | |
337 | } | |
338 | ||
339 | static int dss_driver_remove(struct device *dev) | |
340 | { | |
341 | struct omap_dss_driver *dssdrv = to_dss_driver(dev->driver); | |
342 | struct omap_dss_device *dssdev = to_dss_device(dev); | |
343 | ||
344 | DSSDBG("driver_remove: dev %s/%s\n", dev_name(dev), | |
345 | dssdev->driver_name); | |
346 | ||
347 | dssdrv->remove(dssdev); | |
348 | ||
559d6701 TV |
349 | dssdev->driver = NULL; |
350 | ||
351 | return 0; | |
352 | } | |
353 | ||
a7e71e7f TV |
354 | static int omapdss_default_connect(struct omap_dss_device *dssdev) |
355 | { | |
356 | struct omap_dss_output *out; | |
357 | struct omap_overlay_manager *mgr; | |
358 | int r; | |
359 | ||
360 | out = dssdev->output; | |
361 | ||
362 | if (out == NULL) | |
363 | return -ENODEV; | |
364 | ||
365 | mgr = omap_dss_get_overlay_manager(out->dispc_channel); | |
366 | if (!mgr) | |
367 | return -ENODEV; | |
368 | ||
369 | r = dss_mgr_connect(mgr, out); | |
370 | if (r) | |
371 | return r; | |
372 | ||
373 | return 0; | |
374 | } | |
375 | ||
376 | static void omapdss_default_disconnect(struct omap_dss_device *dssdev) | |
377 | { | |
378 | struct omap_dss_output *out; | |
379 | struct omap_overlay_manager *mgr; | |
380 | ||
381 | out = dssdev->output; | |
382 | ||
383 | if (out == NULL) | |
384 | return; | |
385 | ||
386 | mgr = out->manager; | |
387 | ||
388 | if (mgr == NULL) | |
389 | return; | |
390 | ||
391 | dss_mgr_disconnect(mgr, out); | |
392 | } | |
393 | ||
559d6701 TV |
394 | int omap_dss_register_driver(struct omap_dss_driver *dssdriver) |
395 | { | |
396 | dssdriver->driver.bus = &dss_bus_type; | |
397 | dssdriver->driver.probe = dss_driver_probe; | |
398 | dssdriver->driver.remove = dss_driver_remove; | |
96adcece TV |
399 | |
400 | if (dssdriver->get_resolution == NULL) | |
401 | dssdriver->get_resolution = omapdss_default_get_resolution; | |
a2699504 TV |
402 | if (dssdriver->get_recommended_bpp == NULL) |
403 | dssdriver->get_recommended_bpp = | |
404 | omapdss_default_get_recommended_bpp; | |
4b6430fc GI |
405 | if (dssdriver->get_timings == NULL) |
406 | dssdriver->get_timings = omapdss_default_get_timings; | |
a7e71e7f TV |
407 | if (dssdriver->connect == NULL) |
408 | dssdriver->connect = omapdss_default_connect; | |
409 | if (dssdriver->disconnect == NULL) | |
410 | dssdriver->disconnect = omapdss_default_disconnect; | |
96adcece | 411 | |
559d6701 TV |
412 | return driver_register(&dssdriver->driver); |
413 | } | |
414 | EXPORT_SYMBOL(omap_dss_register_driver); | |
415 | ||
416 | void omap_dss_unregister_driver(struct omap_dss_driver *dssdriver) | |
417 | { | |
418 | driver_unregister(&dssdriver->driver); | |
419 | } | |
420 | EXPORT_SYMBOL(omap_dss_unregister_driver); | |
421 | ||
422 | /* DEVICE */ | |
559d6701 TV |
423 | |
424 | static void omap_dss_dev_release(struct device *dev) | |
425 | { | |
5274484b TV |
426 | struct omap_dss_device *dssdev = to_dss_device(dev); |
427 | kfree(dssdev); | |
559d6701 TV |
428 | } |
429 | ||
8768a52f TV |
430 | static int disp_num_counter; |
431 | ||
5274484b | 432 | struct omap_dss_device *dss_alloc_and_init_device(struct device *parent) |
559d6701 | 433 | { |
5274484b TV |
434 | struct omap_dss_device *dssdev; |
435 | ||
436 | dssdev = kzalloc(sizeof(*dssdev), GFP_KERNEL); | |
437 | if (!dssdev) | |
438 | return NULL; | |
8768a52f | 439 | |
ecc8b370 TV |
440 | dssdev->old_dev.bus = &dss_bus_type; |
441 | dssdev->old_dev.parent = parent; | |
442 | dssdev->old_dev.release = omap_dss_dev_release; | |
443 | dev_set_name(&dssdev->old_dev, "display%d", disp_num_counter++); | |
5274484b | 444 | |
ecc8b370 | 445 | device_initialize(&dssdev->old_dev); |
5274484b TV |
446 | |
447 | return dssdev; | |
559d6701 TV |
448 | } |
449 | ||
5274484b TV |
450 | int dss_add_device(struct omap_dss_device *dssdev) |
451 | { | |
ecc8b370 TV |
452 | dssdev->dev = &dssdev->old_dev; |
453 | ||
2e7e3dc7 | 454 | omapdss_register_display(dssdev); |
ecc8b370 | 455 | return device_add(&dssdev->old_dev); |
5274484b TV |
456 | } |
457 | ||
458 | void dss_put_device(struct omap_dss_device *dssdev) | |
459 | { | |
ecc8b370 | 460 | put_device(&dssdev->old_dev); |
5274484b TV |
461 | } |
462 | ||
463 | void dss_unregister_device(struct omap_dss_device *dssdev) | |
559d6701 | 464 | { |
ecc8b370 | 465 | device_unregister(&dssdev->old_dev); |
2e7e3dc7 | 466 | omapdss_unregister_display(dssdev); |
559d6701 TV |
467 | } |
468 | ||
35deca3d TV |
469 | static int dss_unregister_dss_dev(struct device *dev, void *data) |
470 | { | |
471 | struct omap_dss_device *dssdev = to_dss_device(dev); | |
5274484b | 472 | dss_unregister_device(dssdev); |
35deca3d TV |
473 | return 0; |
474 | } | |
475 | ||
5274484b | 476 | void dss_unregister_child_devices(struct device *parent) |
35deca3d TV |
477 | { |
478 | device_for_each_child(parent, NULL, dss_unregister_dss_dev); | |
479 | } | |
480 | ||
5274484b TV |
481 | void dss_copy_device_pdata(struct omap_dss_device *dst, |
482 | const struct omap_dss_device *src) | |
483 | { | |
484 | u8 *d = (u8 *)dst; | |
485 | u8 *s = (u8 *)src; | |
486 | size_t dsize = sizeof(struct device); | |
487 | ||
488 | memcpy(d + dsize, s + dsize, sizeof(struct omap_dss_device) - dsize); | |
489 | } | |
490 | ||
559d6701 | 491 | /* BUS */ |
6e7e8f06 | 492 | static int __init omap_dss_bus_register(void) |
559d6701 TV |
493 | { |
494 | int r; | |
495 | ||
496 | r = bus_register(&dss_bus_type); | |
497 | if (r) { | |
498 | DSSERR("bus register failed\n"); | |
499 | return r; | |
500 | } | |
501 | ||
502 | dev_set_name(&dss_bus, "omapdss"); | |
503 | r = device_register(&dss_bus); | |
504 | if (r) { | |
505 | DSSERR("bus driver register failed\n"); | |
506 | bus_unregister(&dss_bus_type); | |
507 | return r; | |
508 | } | |
509 | ||
510 | return 0; | |
511 | } | |
512 | ||
513 | /* INIT */ | |
461395c4 | 514 | static int (*dss_output_drv_reg_funcs[])(void) __initdata = { |
046bc575 TV |
515 | #ifdef CONFIG_OMAP2_DSS_DSI |
516 | dsi_init_platform_driver, | |
517 | #endif | |
461395c4 TV |
518 | #ifdef CONFIG_OMAP2_DSS_DPI |
519 | dpi_init_platform_driver, | |
520 | #endif | |
521 | #ifdef CONFIG_OMAP2_DSS_SDI | |
522 | sdi_init_platform_driver, | |
523 | #endif | |
524 | #ifdef CONFIG_OMAP2_DSS_RFBI | |
525 | rfbi_init_platform_driver, | |
526 | #endif | |
527 | #ifdef CONFIG_OMAP2_DSS_VENC | |
528 | venc_init_platform_driver, | |
529 | #endif | |
461395c4 TV |
530 | #ifdef CONFIG_OMAP4_DSS_HDMI |
531 | hdmi_init_platform_driver, | |
532 | #endif | |
533 | }; | |
534 | ||
535 | static void (*dss_output_drv_unreg_funcs[])(void) __exitdata = { | |
046bc575 TV |
536 | #ifdef CONFIG_OMAP2_DSS_DSI |
537 | dsi_uninit_platform_driver, | |
538 | #endif | |
461395c4 TV |
539 | #ifdef CONFIG_OMAP2_DSS_DPI |
540 | dpi_uninit_platform_driver, | |
541 | #endif | |
542 | #ifdef CONFIG_OMAP2_DSS_SDI | |
543 | sdi_uninit_platform_driver, | |
544 | #endif | |
545 | #ifdef CONFIG_OMAP2_DSS_RFBI | |
546 | rfbi_uninit_platform_driver, | |
547 | #endif | |
548 | #ifdef CONFIG_OMAP2_DSS_VENC | |
549 | venc_uninit_platform_driver, | |
550 | #endif | |
461395c4 TV |
551 | #ifdef CONFIG_OMAP4_DSS_HDMI |
552 | hdmi_uninit_platform_driver, | |
553 | #endif | |
554 | }; | |
555 | ||
556 | static bool dss_output_drv_loaded[ARRAY_SIZE(dss_output_drv_reg_funcs)]; | |
559d6701 | 557 | |
dc7e57fa TV |
558 | static int __init omap_dss_register_drivers(void) |
559 | { | |
560 | int r; | |
461395c4 | 561 | int i; |
dc7e57fa | 562 | |
11436e1d | 563 | r = platform_driver_probe(&omap_dss_driver, omap_dss_probe); |
dc7e57fa TV |
564 | if (r) |
565 | return r; | |
566 | ||
567 | r = dss_init_platform_driver(); | |
568 | if (r) { | |
569 | DSSERR("Failed to initialize DSS platform driver\n"); | |
570 | goto err_dss; | |
571 | } | |
572 | ||
573 | r = dispc_init_platform_driver(); | |
574 | if (r) { | |
575 | DSSERR("Failed to initialize dispc platform driver\n"); | |
576 | goto err_dispc; | |
577 | } | |
578 | ||
461395c4 TV |
579 | /* |
580 | * It's ok if the output-driver register fails. It happens, for example, | |
581 | * when there is no output-device (e.g. SDI for OMAP4). | |
582 | */ | |
583 | for (i = 0; i < ARRAY_SIZE(dss_output_drv_reg_funcs); ++i) { | |
584 | r = dss_output_drv_reg_funcs[i](); | |
585 | if (r == 0) | |
586 | dss_output_drv_loaded[i] = true; | |
dc7e57fa TV |
587 | } |
588 | ||
589 | return 0; | |
590 | ||
dc7e57fa TV |
591 | err_dispc: |
592 | dss_uninit_platform_driver(); | |
593 | err_dss: | |
594 | platform_driver_unregister(&omap_dss_driver); | |
595 | ||
596 | return r; | |
597 | } | |
598 | ||
599 | static void __exit omap_dss_unregister_drivers(void) | |
600 | { | |
461395c4 TV |
601 | int i; |
602 | ||
603 | for (i = 0; i < ARRAY_SIZE(dss_output_drv_unreg_funcs); ++i) { | |
604 | if (dss_output_drv_loaded[i]) | |
605 | dss_output_drv_unreg_funcs[i](); | |
606 | } | |
607 | ||
dc7e57fa TV |
608 | dispc_uninit_platform_driver(); |
609 | dss_uninit_platform_driver(); | |
610 | ||
611 | platform_driver_unregister(&omap_dss_driver); | |
612 | } | |
613 | ||
559d6701 TV |
614 | #ifdef CONFIG_OMAP2_DSS_MODULE |
615 | static void omap_dss_bus_unregister(void) | |
616 | { | |
617 | device_unregister(&dss_bus); | |
618 | ||
619 | bus_unregister(&dss_bus_type); | |
620 | } | |
621 | ||
622 | static int __init omap_dss_init(void) | |
623 | { | |
624 | int r; | |
625 | ||
626 | r = omap_dss_bus_register(); | |
627 | if (r) | |
628 | return r; | |
629 | ||
dc7e57fa | 630 | r = omap_dss_register_drivers(); |
559d6701 TV |
631 | if (r) { |
632 | omap_dss_bus_unregister(); | |
633 | return r; | |
634 | } | |
635 | ||
591a0ac7 TV |
636 | dss_initialized = true; |
637 | ||
559d6701 TV |
638 | return 0; |
639 | } | |
640 | ||
641 | static void __exit omap_dss_exit(void) | |
642 | { | |
dc7e57fa | 643 | omap_dss_unregister_drivers(); |
559d6701 TV |
644 | |
645 | omap_dss_bus_unregister(); | |
646 | } | |
647 | ||
648 | module_init(omap_dss_init); | |
649 | module_exit(omap_dss_exit); | |
650 | #else | |
651 | static int __init omap_dss_init(void) | |
652 | { | |
653 | return omap_dss_bus_register(); | |
654 | } | |
655 | ||
656 | static int __init omap_dss_init2(void) | |
657 | { | |
591a0ac7 TV |
658 | int r; |
659 | ||
660 | r = omap_dss_register_drivers(); | |
661 | if (r) | |
662 | return r; | |
663 | ||
664 | dss_initialized = true; | |
665 | ||
666 | return 0; | |
559d6701 TV |
667 | } |
668 | ||
669 | core_initcall(omap_dss_init); | |
670 | device_initcall(omap_dss_init2); | |
671 | #endif | |
672 | ||
673 | MODULE_AUTHOR("Tomi Valkeinen <tomi.valkeinen@nokia.com>"); | |
674 | MODULE_DESCRIPTION("OMAP2/3 Display Subsystem"); | |
675 | MODULE_LICENSE("GPL v2"); | |
676 |