diff options
author | Archit Taneja <archit@ti.com> | 2014-06-01 03:17:44 -0400 |
---|---|---|
committer | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2014-11-12 06:39:52 -0500 |
commit | 2ac6a1aae8f038662b09f2755827dfbe9456894d (patch) | |
tree | 06e3b3f29d078a98cb66f35cd10394a9f5f2ad27 /drivers/video | |
parent | 630d2d0de6b113748ce08d5f69e094eeed24accc (diff) |
OMAPDSS: DPI: Allocate driver data
Allocate driver data(dpi_data) for each DPI instance. It's allocated in
omap_dpi_probe() when DT isn't used, and in dpi_init_port() when DT is used.
The dpi_data struct instance is no longer global. In the case of DPI ops, it's
retrieved from dpi_get_data_from_dssdev(). 'dssdev' passed by the connected
encoder/panel driver is a pointer to the 'output' member in dpi_data, and thus
can be used to get the DPI instance's driver data. In the case of probe/ini_port
functions, it's set as DPI/DSS device's private data embedded in the
platform_device struct.
Having dpi_data as private data of the platform device will not work for
multiple DPI instances in the DT case. This is because there is no corresponding
platform_device for DPI or SDI, they exist only as ports under the parent DSS
platform_device in the DT case. The DPI port's private data('data' member in
device_node struct) will later be used to store dpi_data.
Signed-off-by: Archit Taneja <archit@ti.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Diffstat (limited to 'drivers/video')
-rw-r--r-- | drivers/video/fbdev/omap2/dss/dpi.c | 46 | ||||
-rw-r--r-- | drivers/video/fbdev/omap2/dss/dss.c | 6 | ||||
-rw-r--r-- | drivers/video/fbdev/omap2/dss/dss.h | 2 |
3 files changed, 36 insertions, 18 deletions
diff --git a/drivers/video/fbdev/omap2/dss/dpi.c b/drivers/video/fbdev/omap2/dss/dpi.c index 35285d8395b5..c9face608b2a 100644 --- a/drivers/video/fbdev/omap2/dss/dpi.c +++ b/drivers/video/fbdev/omap2/dss/dpi.c | |||
@@ -54,7 +54,15 @@ struct dpi_data { | |||
54 | bool port_initialized; | 54 | bool port_initialized; |
55 | }; | 55 | }; |
56 | 56 | ||
57 | static struct dpi_data dpi_data; | 57 | static struct dpi_data *dpi_get_data_from_dssdev(struct omap_dss_device *dssdev) |
58 | { | ||
59 | return container_of(dssdev, struct dpi_data, output); | ||
60 | } | ||
61 | |||
62 | static struct dpi_data *dpi_get_data_from_pdev(struct platform_device *pdev) | ||
63 | { | ||
64 | return dev_get_drvdata(&pdev->dev); | ||
65 | } | ||
58 | 66 | ||
59 | static struct platform_device *dpi_get_dsidev(enum omap_channel channel) | 67 | static struct platform_device *dpi_get_dsidev(enum omap_channel channel) |
60 | { | 68 | { |
@@ -359,7 +367,7 @@ static void dpi_config_lcd_manager(struct dpi_data *dpi) | |||
359 | 367 | ||
360 | static int dpi_display_enable(struct omap_dss_device *dssdev) | 368 | static int dpi_display_enable(struct omap_dss_device *dssdev) |
361 | { | 369 | { |
362 | struct dpi_data *dpi = &dpi_data; | 370 | struct dpi_data *dpi = dpi_get_data_from_dssdev(dssdev); |
363 | struct omap_dss_device *out = &dpi->output; | 371 | struct omap_dss_device *out = &dpi->output; |
364 | int r; | 372 | int r; |
365 | 373 | ||
@@ -439,7 +447,7 @@ err_no_reg: | |||
439 | 447 | ||
440 | static void dpi_display_disable(struct omap_dss_device *dssdev) | 448 | static void dpi_display_disable(struct omap_dss_device *dssdev) |
441 | { | 449 | { |
442 | struct dpi_data *dpi = &dpi_data; | 450 | struct dpi_data *dpi = dpi_get_data_from_dssdev(dssdev); |
443 | struct omap_overlay_manager *mgr = dpi->output.manager; | 451 | struct omap_overlay_manager *mgr = dpi->output.manager; |
444 | 452 | ||
445 | mutex_lock(&dpi->lock); | 453 | mutex_lock(&dpi->lock); |
@@ -463,7 +471,7 @@ static void dpi_display_disable(struct omap_dss_device *dssdev) | |||
463 | static void dpi_set_timings(struct omap_dss_device *dssdev, | 471 | static void dpi_set_timings(struct omap_dss_device *dssdev, |
464 | struct omap_video_timings *timings) | 472 | struct omap_video_timings *timings) |
465 | { | 473 | { |
466 | struct dpi_data *dpi = &dpi_data; | 474 | struct dpi_data *dpi = dpi_get_data_from_dssdev(dssdev); |
467 | 475 | ||
468 | DSSDBG("dpi_set_timings\n"); | 476 | DSSDBG("dpi_set_timings\n"); |
469 | 477 | ||
@@ -477,7 +485,7 @@ static void dpi_set_timings(struct omap_dss_device *dssdev, | |||
477 | static void dpi_get_timings(struct omap_dss_device *dssdev, | 485 | static void dpi_get_timings(struct omap_dss_device *dssdev, |
478 | struct omap_video_timings *timings) | 486 | struct omap_video_timings *timings) |
479 | { | 487 | { |
480 | struct dpi_data *dpi = &dpi_data; | 488 | struct dpi_data *dpi = dpi_get_data_from_dssdev(dssdev); |
481 | 489 | ||
482 | mutex_lock(&dpi->lock); | 490 | mutex_lock(&dpi->lock); |
483 | 491 | ||
@@ -489,7 +497,7 @@ static void dpi_get_timings(struct omap_dss_device *dssdev, | |||
489 | static int dpi_check_timings(struct omap_dss_device *dssdev, | 497 | static int dpi_check_timings(struct omap_dss_device *dssdev, |
490 | struct omap_video_timings *timings) | 498 | struct omap_video_timings *timings) |
491 | { | 499 | { |
492 | struct dpi_data *dpi = &dpi_data; | 500 | struct dpi_data *dpi = dpi_get_data_from_dssdev(dssdev); |
493 | struct omap_overlay_manager *mgr = dpi->output.manager; | 501 | struct omap_overlay_manager *mgr = dpi->output.manager; |
494 | int lck_div, pck_div; | 502 | int lck_div, pck_div; |
495 | unsigned long fck; | 503 | unsigned long fck; |
@@ -529,7 +537,7 @@ static int dpi_check_timings(struct omap_dss_device *dssdev, | |||
529 | 537 | ||
530 | static void dpi_set_data_lines(struct omap_dss_device *dssdev, int data_lines) | 538 | static void dpi_set_data_lines(struct omap_dss_device *dssdev, int data_lines) |
531 | { | 539 | { |
532 | struct dpi_data *dpi = &dpi_data; | 540 | struct dpi_data *dpi = dpi_get_data_from_dssdev(dssdev); |
533 | 541 | ||
534 | mutex_lock(&dpi->lock); | 542 | mutex_lock(&dpi->lock); |
535 | 543 | ||
@@ -635,7 +643,7 @@ static enum omap_channel dpi_get_channel(void) | |||
635 | static int dpi_connect(struct omap_dss_device *dssdev, | 643 | static int dpi_connect(struct omap_dss_device *dssdev, |
636 | struct omap_dss_device *dst) | 644 | struct omap_dss_device *dst) |
637 | { | 645 | { |
638 | struct dpi_data *dpi = &dpi_data; | 646 | struct dpi_data *dpi = dpi_get_data_from_dssdev(dssdev); |
639 | struct omap_overlay_manager *mgr; | 647 | struct omap_overlay_manager *mgr; |
640 | int r; | 648 | int r; |
641 | 649 | ||
@@ -694,7 +702,7 @@ static const struct omapdss_dpi_ops dpi_ops = { | |||
694 | 702 | ||
695 | static void dpi_init_output(struct platform_device *pdev) | 703 | static void dpi_init_output(struct platform_device *pdev) |
696 | { | 704 | { |
697 | struct dpi_data *dpi = &dpi_data; | 705 | struct dpi_data *dpi = dpi_get_data_from_pdev(pdev); |
698 | struct omap_dss_device *out = &dpi->output; | 706 | struct omap_dss_device *out = &dpi->output; |
699 | 707 | ||
700 | out->dev = &pdev->dev; | 708 | out->dev = &pdev->dev; |
@@ -710,7 +718,7 @@ static void dpi_init_output(struct platform_device *pdev) | |||
710 | 718 | ||
711 | static void __exit dpi_uninit_output(struct platform_device *pdev) | 719 | static void __exit dpi_uninit_output(struct platform_device *pdev) |
712 | { | 720 | { |
713 | struct dpi_data *dpi = &dpi_data; | 721 | struct dpi_data *dpi = dpi_get_data_from_pdev(pdev); |
714 | struct omap_dss_device *out = &dpi->output; | 722 | struct omap_dss_device *out = &dpi->output; |
715 | 723 | ||
716 | omapdss_unregister_output(out); | 724 | omapdss_unregister_output(out); |
@@ -718,7 +726,11 @@ static void __exit dpi_uninit_output(struct platform_device *pdev) | |||
718 | 726 | ||
719 | static int omap_dpi_probe(struct platform_device *pdev) | 727 | static int omap_dpi_probe(struct platform_device *pdev) |
720 | { | 728 | { |
721 | struct dpi_data *dpi = &dpi_data; | 729 | struct dpi_data *dpi; |
730 | |||
731 | dpi = devm_kzalloc(&pdev->dev, sizeof(*dpi), GFP_KERNEL); | ||
732 | if (!dpi) | ||
733 | return -ENOMEM; | ||
722 | 734 | ||
723 | dpi->pdev = pdev; | 735 | dpi->pdev = pdev; |
724 | 736 | ||
@@ -760,11 +772,15 @@ void __exit dpi_uninit_platform_driver(void) | |||
760 | 772 | ||
761 | int __init dpi_init_port(struct platform_device *pdev, struct device_node *port) | 773 | int __init dpi_init_port(struct platform_device *pdev, struct device_node *port) |
762 | { | 774 | { |
763 | struct dpi_data *dpi = &dpi_data; | 775 | struct dpi_data *dpi; |
764 | struct device_node *ep; | 776 | struct device_node *ep; |
765 | u32 datalines; | 777 | u32 datalines; |
766 | int r; | 778 | int r; |
767 | 779 | ||
780 | dpi = devm_kzalloc(&pdev->dev, sizeof(*dpi), GFP_KERNEL); | ||
781 | if (!dpi) | ||
782 | return -ENOMEM; | ||
783 | |||
768 | ep = omapdss_of_get_next_endpoint(port, NULL); | 784 | ep = omapdss_of_get_next_endpoint(port, NULL); |
769 | if (!ep) | 785 | if (!ep) |
770 | return 0; | 786 | return 0; |
@@ -787,6 +803,8 @@ int __init dpi_init_port(struct platform_device *pdev, struct device_node *port) | |||
787 | 803 | ||
788 | dpi->port_initialized = true; | 804 | dpi->port_initialized = true; |
789 | 805 | ||
806 | dev_set_drvdata(&pdev->dev, dpi); | ||
807 | |||
790 | return 0; | 808 | return 0; |
791 | 809 | ||
792 | err_datalines: | 810 | err_datalines: |
@@ -795,9 +813,9 @@ err_datalines: | |||
795 | return r; | 813 | return r; |
796 | } | 814 | } |
797 | 815 | ||
798 | void __exit dpi_uninit_port(void) | 816 | void __exit dpi_uninit_port(struct platform_device *pdev) |
799 | { | 817 | { |
800 | struct dpi_data *dpi = &dpi_data; | 818 | struct dpi_data *dpi = dpi_get_data_from_pdev(pdev); |
801 | 819 | ||
802 | if (!dpi->port_initialized) | 820 | if (!dpi->port_initialized) |
803 | return; | 821 | return; |
diff --git a/drivers/video/fbdev/omap2/dss/dss.c b/drivers/video/fbdev/omap2/dss/dss.c index 14bcd6c43f72..8a4a6d2d1edf 100644 --- a/drivers/video/fbdev/omap2/dss/dss.c +++ b/drivers/video/fbdev/omap2/dss/dss.c | |||
@@ -820,10 +820,10 @@ static int __init dss_init_ports(struct platform_device *pdev) | |||
820 | return 0; | 820 | return 0; |
821 | } | 821 | } |
822 | 822 | ||
823 | static void __exit dss_uninit_ports(void) | 823 | static void __exit dss_uninit_ports(struct platform_device *pdev) |
824 | { | 824 | { |
825 | #ifdef CONFIG_OMAP2_DSS_DPI | 825 | #ifdef CONFIG_OMAP2_DSS_DPI |
826 | dpi_uninit_port(); | 826 | dpi_uninit_port(pdev); |
827 | #endif | 827 | #endif |
828 | 828 | ||
829 | #ifdef CONFIG_OMAP2_DSS_SDI | 829 | #ifdef CONFIG_OMAP2_DSS_SDI |
@@ -910,7 +910,7 @@ err_setup_clocks: | |||
910 | 910 | ||
911 | static int __exit omap_dsshw_remove(struct platform_device *pdev) | 911 | static int __exit omap_dsshw_remove(struct platform_device *pdev) |
912 | { | 912 | { |
913 | dss_uninit_ports(); | 913 | dss_uninit_ports(pdev); |
914 | 914 | ||
915 | pm_runtime_disable(&pdev->dev); | 915 | pm_runtime_disable(&pdev->dev); |
916 | 916 | ||
diff --git a/drivers/video/fbdev/omap2/dss/dss.h b/drivers/video/fbdev/omap2/dss/dss.h index 8ff22c134c62..da7f5f9bc270 100644 --- a/drivers/video/fbdev/omap2/dss/dss.h +++ b/drivers/video/fbdev/omap2/dss/dss.h | |||
@@ -359,7 +359,7 @@ int dpi_init_platform_driver(void) __init; | |||
359 | void dpi_uninit_platform_driver(void) __exit; | 359 | void dpi_uninit_platform_driver(void) __exit; |
360 | 360 | ||
361 | int dpi_init_port(struct platform_device *pdev, struct device_node *port) __init; | 361 | int dpi_init_port(struct platform_device *pdev, struct device_node *port) __init; |
362 | void dpi_uninit_port(void) __exit; | 362 | void dpi_uninit_port(struct platform_device *pdev) __exit; |
363 | 363 | ||
364 | /* DISPC */ | 364 | /* DISPC */ |
365 | int dispc_init_platform_driver(void) __init; | 365 | int dispc_init_platform_driver(void) __init; |