aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video
diff options
context:
space:
mode:
authorTomi Valkeinen <tomi.valkeinen@ti.com>2013-12-16 08:13:24 -0500
committerTomi Valkeinen <tomi.valkeinen@ti.com>2014-03-19 05:03:07 -0400
commit2ecef24630f434e58bf3e5adb4d9bb76e50daf78 (patch)
treecb09ca4d405f681e361266f10daadf3bd971b154 /drivers/video
parente6fa68ba82959bd2468271788d89e0fdb2f781e4 (diff)
OMAPDSS: Add DT support to DSS
Add DT support for DSS. Contrary to the non-DT version, the DSS in DT mode contains DPI and SDI outputs, which better reflects the hardware. The non-DT code will be removed after all boards have been converted to DT, so there's no need to change the non-DT code to act the same way. The code for DPI and SDI needs to be refined later to make it possible to add multiple DPI ports. For now, handling just a single DPI port is enough for all the boards. Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com> Reviewed-by: Archit Taneja <archit@ti.com>
Diffstat (limited to 'drivers/video')
-rw-r--r--drivers/video/omap2/dss/dpi.c47
-rw-r--r--drivers/video/omap2/dss/dss.c66
-rw-r--r--drivers/video/omap2/dss/dss.h6
-rw-r--r--drivers/video/omap2/dss/sdi.c45
4 files changed, 164 insertions, 0 deletions
diff --git a/drivers/video/omap2/dss/dpi.c b/drivers/video/omap2/dss/dpi.c
index 23ef21ffc2c4..f02520ff6e32 100644
--- a/drivers/video/omap2/dss/dpi.c
+++ b/drivers/video/omap2/dss/dpi.c
@@ -30,6 +30,7 @@
30#include <linux/platform_device.h> 30#include <linux/platform_device.h>
31#include <linux/regulator/consumer.h> 31#include <linux/regulator/consumer.h>
32#include <linux/string.h> 32#include <linux/string.h>
33#include <linux/of.h>
33 34
34#include <video/omapdss.h> 35#include <video/omapdss.h>
35 36
@@ -49,6 +50,8 @@ static struct {
49 int data_lines; 50 int data_lines;
50 51
51 struct omap_dss_device output; 52 struct omap_dss_device output;
53
54 bool port_initialized;
52} dpi; 55} dpi;
53 56
54static struct platform_device *dpi_get_dsidev(enum omap_channel channel) 57static struct platform_device *dpi_get_dsidev(enum omap_channel channel)
@@ -726,3 +729,47 @@ void __exit dpi_uninit_platform_driver(void)
726{ 729{
727 platform_driver_unregister(&omap_dpi_driver); 730 platform_driver_unregister(&omap_dpi_driver);
728} 731}
732
733int __init dpi_init_port(struct platform_device *pdev, struct device_node *port)
734{
735 struct device_node *ep;
736 u32 datalines;
737 int r;
738
739 ep = omapdss_of_get_next_endpoint(port, NULL);
740 if (!ep)
741 return 0;
742
743 r = of_property_read_u32(ep, "data-lines", &datalines);
744 if (r) {
745 DSSERR("failed to parse datalines\n");
746 goto err_datalines;
747 }
748
749 dpi.data_lines = datalines;
750
751 of_node_put(ep);
752
753 dpi.pdev = pdev;
754
755 mutex_init(&dpi.lock);
756
757 dpi_init_output(pdev);
758
759 dpi.port_initialized = true;
760
761 return 0;
762
763err_datalines:
764 of_node_put(ep);
765
766 return r;
767}
768
769void __exit dpi_uninit_port(void)
770{
771 if (!dpi.port_initialized)
772 return;
773
774 dpi_uninit_output(dpi.pdev);
775}
diff --git a/drivers/video/omap2/dss/dss.c b/drivers/video/omap2/dss/dss.c
index 9a145da35ad3..1b1c02dfdcf9 100644
--- a/drivers/video/omap2/dss/dss.c
+++ b/drivers/video/omap2/dss/dss.c
@@ -23,6 +23,7 @@
23#define DSS_SUBSYS_NAME "DSS" 23#define DSS_SUBSYS_NAME "DSS"
24 24
25#include <linux/kernel.h> 25#include <linux/kernel.h>
26#include <linux/module.h>
26#include <linux/io.h> 27#include <linux/io.h>
27#include <linux/export.h> 28#include <linux/export.h>
28#include <linux/err.h> 29#include <linux/err.h>
@@ -33,6 +34,7 @@
33#include <linux/pm_runtime.h> 34#include <linux/pm_runtime.h>
34#include <linux/gfp.h> 35#include <linux/gfp.h>
35#include <linux/sizes.h> 36#include <linux/sizes.h>
37#include <linux/of.h>
36 38
37#include <video/omapdss.h> 39#include <video/omapdss.h>
38 40
@@ -788,6 +790,56 @@ static int __init dss_init_features(struct platform_device *pdev)
788 return 0; 790 return 0;
789} 791}
790 792
793static int dss_init_ports(struct platform_device *pdev)
794{
795 struct device_node *parent = pdev->dev.of_node;
796 struct device_node *port;
797 int r;
798
799 if (parent == NULL)
800 return 0;
801
802 port = omapdss_of_get_next_port(parent, NULL);
803 if (!port) {
804#ifdef CONFIG_OMAP2_DSS_DPI
805 dpi_init_port(pdev, parent);
806#endif
807 return 0;
808 }
809
810 do {
811 u32 reg;
812
813 r = of_property_read_u32(port, "reg", &reg);
814 if (r)
815 reg = 0;
816
817#ifdef CONFIG_OMAP2_DSS_DPI
818 if (reg == 0)
819 dpi_init_port(pdev, port);
820#endif
821
822#ifdef CONFIG_OMAP2_DSS_SDI
823 if (reg == 1)
824 sdi_init_port(pdev, port);
825#endif
826
827 } while ((port = omapdss_of_get_next_port(parent, port)) != NULL);
828
829 return 0;
830}
831
832static void dss_uninit_ports(void)
833{
834#ifdef CONFIG_OMAP2_DSS_DPI
835 dpi_uninit_port();
836#endif
837
838#ifdef CONFIG_OMAP2_DSS_SDI
839 sdi_uninit_port();
840#endif
841}
842
791/* DSS HW IP initialisation */ 843/* DSS HW IP initialisation */
792static int __init omap_dsshw_probe(struct platform_device *pdev) 844static int __init omap_dsshw_probe(struct platform_device *pdev)
793{ 845{
@@ -846,6 +898,8 @@ static int __init omap_dsshw_probe(struct platform_device *pdev)
846 dss.lcd_clk_source[0] = OMAP_DSS_CLK_SRC_FCK; 898 dss.lcd_clk_source[0] = OMAP_DSS_CLK_SRC_FCK;
847 dss.lcd_clk_source[1] = OMAP_DSS_CLK_SRC_FCK; 899 dss.lcd_clk_source[1] = OMAP_DSS_CLK_SRC_FCK;
848 900
901 dss_init_ports(pdev);
902
849 rev = dss_read_reg(DSS_REVISION); 903 rev = dss_read_reg(DSS_REVISION);
850 printk(KERN_INFO "OMAP DSS rev %d.%d\n", 904 printk(KERN_INFO "OMAP DSS rev %d.%d\n",
851 FLD_GET(rev, 7, 4), FLD_GET(rev, 3, 0)); 905 FLD_GET(rev, 7, 4), FLD_GET(rev, 3, 0));
@@ -865,6 +919,8 @@ err_setup_clocks:
865 919
866static int __exit omap_dsshw_remove(struct platform_device *pdev) 920static int __exit omap_dsshw_remove(struct platform_device *pdev)
867{ 921{
922 dss_uninit_ports();
923
868 pm_runtime_disable(&pdev->dev); 924 pm_runtime_disable(&pdev->dev);
869 925
870 dss_put_clocks(); 926 dss_put_clocks();
@@ -902,12 +958,22 @@ static const struct dev_pm_ops dss_pm_ops = {
902 .runtime_resume = dss_runtime_resume, 958 .runtime_resume = dss_runtime_resume,
903}; 959};
904 960
961static const struct of_device_id dss_of_match[] = {
962 { .compatible = "ti,omap2-dss", },
963 { .compatible = "ti,omap3-dss", },
964 { .compatible = "ti,omap4-dss", },
965 {},
966};
967
968MODULE_DEVICE_TABLE(of, dss_of_match);
969
905static struct platform_driver omap_dsshw_driver = { 970static struct platform_driver omap_dsshw_driver = {
906 .remove = __exit_p(omap_dsshw_remove), 971 .remove = __exit_p(omap_dsshw_remove),
907 .driver = { 972 .driver = {
908 .name = "omapdss_dss", 973 .name = "omapdss_dss",
909 .owner = THIS_MODULE, 974 .owner = THIS_MODULE,
910 .pm = &dss_pm_ops, 975 .pm = &dss_pm_ops,
976 .of_match_table = dss_of_match,
911 }, 977 },
912}; 978};
913 979
diff --git a/drivers/video/omap2/dss/dss.h b/drivers/video/omap2/dss/dss.h
index 057f24c8a332..8ece4f531006 100644
--- a/drivers/video/omap2/dss/dss.h
+++ b/drivers/video/omap2/dss/dss.h
@@ -252,6 +252,9 @@ bool dss_div_calc(unsigned long pck, unsigned long fck_min,
252int sdi_init_platform_driver(void) __init; 252int sdi_init_platform_driver(void) __init;
253void sdi_uninit_platform_driver(void) __exit; 253void sdi_uninit_platform_driver(void) __exit;
254 254
255int sdi_init_port(struct platform_device *pdev, struct device_node *port) __init;
256void sdi_uninit_port(void) __exit;
257
255/* DSI */ 258/* DSI */
256 259
257typedef bool (*dsi_pll_calc_func)(int regn, int regm, unsigned long fint, 260typedef bool (*dsi_pll_calc_func)(int regn, int regm, unsigned long fint,
@@ -363,6 +366,9 @@ static inline bool dsi_pll_calc(struct platform_device *dsidev,
363int dpi_init_platform_driver(void) __init; 366int dpi_init_platform_driver(void) __init;
364void dpi_uninit_platform_driver(void) __exit; 367void dpi_uninit_platform_driver(void) __exit;
365 368
369int dpi_init_port(struct platform_device *pdev, struct device_node *port) __init;
370void dpi_uninit_port(void) __exit;
371
366/* DISPC */ 372/* DISPC */
367int dispc_init_platform_driver(void) __init; 373int dispc_init_platform_driver(void) __init;
368void dispc_uninit_platform_driver(void) __exit; 374void dispc_uninit_platform_driver(void) __exit;
diff --git a/drivers/video/omap2/dss/sdi.c b/drivers/video/omap2/dss/sdi.c
index ba806c9e7f54..d16277ca22a8 100644
--- a/drivers/video/omap2/dss/sdi.c
+++ b/drivers/video/omap2/dss/sdi.c
@@ -26,6 +26,7 @@
26#include <linux/export.h> 26#include <linux/export.h>
27#include <linux/platform_device.h> 27#include <linux/platform_device.h>
28#include <linux/string.h> 28#include <linux/string.h>
29#include <linux/of.h>
29 30
30#include <video/omapdss.h> 31#include <video/omapdss.h>
31#include "dss.h" 32#include "dss.h"
@@ -41,6 +42,8 @@ static struct {
41 int datapairs; 42 int datapairs;
42 43
43 struct omap_dss_device output; 44 struct omap_dss_device output;
45
46 bool port_initialized;
44} sdi; 47} sdi;
45 48
46struct sdi_clk_calc_ctx { 49struct sdi_clk_calc_ctx {
@@ -387,3 +390,45 @@ void __exit sdi_uninit_platform_driver(void)
387{ 390{
388 platform_driver_unregister(&omap_sdi_driver); 391 platform_driver_unregister(&omap_sdi_driver);
389} 392}
393
394int __init sdi_init_port(struct platform_device *pdev, struct device_node *port)
395{
396 struct device_node *ep;
397 u32 datapairs;
398 int r;
399
400 ep = omapdss_of_get_next_endpoint(port, NULL);
401 if (!ep)
402 return 0;
403
404 r = of_property_read_u32(ep, "datapairs", &datapairs);
405 if (r) {
406 DSSERR("failed to parse datapairs\n");
407 goto err_datapairs;
408 }
409
410 sdi.datapairs = datapairs;
411
412 of_node_put(ep);
413
414 sdi.pdev = pdev;
415
416 sdi_init_output(pdev);
417
418 sdi.port_initialized = true;
419
420 return 0;
421
422err_datapairs:
423 of_node_put(ep);
424
425 return r;
426}
427
428void __exit sdi_uninit_port(void)
429{
430 if (!sdi.port_initialized)
431 return;
432
433 sdi_uninit_output(sdi.pdev);
434}