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