From e6a049807105decf5aa7f0c510f5e5ec96c3548e Mon Sep 17 00:00:00 2001 From: Heiko Schocher Date: Wed, 26 Jan 2011 07:21:22 +0000 Subject: video, sm501: add edid and commandline support - add commandline options: sm501fb.mode: Specify resolution as "x[-][@]" sm501fb.bpp: Specify bit-per-pixel if not specified mode - Add support for encoding display mode information in the device tree using verbatim EDID block. If the "edid" entry in the "smi,sm501" node is present, the driver will build mode database using EDID data and allow setting the display modes from this database. Signed-off-by: Heiko Schocher cc: linux-fbdev@vger.kernel.org cc: devicetree-discuss@ozlabs.org cc: Ben Dooks cc: Vincent Sanders cc: Samuel Ortiz cc: linux-kernel@vger.kernel.org cc: Randy Dunlap cc: Paul Mundt Signed-off-by: Paul Mundt --- Documentation/fb/sm501.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 Documentation/fb/sm501.txt (limited to 'Documentation') diff --git a/Documentation/fb/sm501.txt b/Documentation/fb/sm501.txt new file mode 100644 index 000000000000..8d17aebd2648 --- /dev/null +++ b/Documentation/fb/sm501.txt @@ -0,0 +1,10 @@ +Configuration: + +You can pass the following kernel command line options to sm501 videoframebuffer: + + sm501fb.bpp= SM501 Display driver: + Specifiy bits-per-pixel if not specified by 'mode' + + sm501fb.mode= SM501 Display driver: + Specify resolution as + "x[-][@]" -- cgit v1.2.3-59-g8ed1b From 4295f9bf74a885da390abc49a3b42a011c1bb890 Mon Sep 17 00:00:00 2001 From: Heiko Schocher Date: Wed, 26 Jan 2011 07:21:30 +0000 Subject: video, sm501: add OF binding to support SM501 - add binding to OF, compatible name "smi,sm501" Signed-off-by: Heiko Schocher cc: linux-fbdev@vger.kernel.org cc: devicetree-discuss@ozlabs.org cc: Ben Dooks cc: Vincent Sanders cc: Samuel Ortiz cc: linux-kernel@vger.kernel.org cc: Randy Dunlap cc: Paul Mundt Signed-off-by: Paul Mundt --- Documentation/powerpc/dts-bindings/sm501.txt | 34 ++++++++++++++++++++++ drivers/mfd/sm501.c | 9 +++++- drivers/video/sm501fb.c | 42 ++++++++++++++++++++++++++-- 3 files changed, 81 insertions(+), 4 deletions(-) create mode 100644 Documentation/powerpc/dts-bindings/sm501.txt (limited to 'Documentation') diff --git a/Documentation/powerpc/dts-bindings/sm501.txt b/Documentation/powerpc/dts-bindings/sm501.txt new file mode 100644 index 000000000000..7d319fba9b5b --- /dev/null +++ b/Documentation/powerpc/dts-bindings/sm501.txt @@ -0,0 +1,34 @@ +* SM SM501 + +The SM SM501 is a LCD controller, with proper hardware, it can also +drive DVI monitors. + +Required properties: +- compatible : should be "smi,sm501". +- reg : contain two entries: + - First entry: System Configuration register + - Second entry: IO space (Display Controller register) +- interrupts : SMI interrupt to the cpu should be described here. +- interrupt-parent : the phandle for the interrupt controller that + services interrupts for this device. + +Optional properties: +- mode : select a video mode: + x[-][@] +- edid : verbatim EDID data block describing attached display. + Data from the detailed timing descriptor will be used to + program the display controller. +- little-endian: availiable on big endian systems, to + set different foreign endian. +- big-endian: availiable on little endian systems, to + set different foreign endian. + +Example for MPC5200: + display@1,0 { + compatible = "smi,sm501"; + reg = <1 0x00000000 0x00800000 + 1 0x03e00000 0x00200000>; + interrupts = <1 1 3>; + mode = "640x480-32@60"; + edid = [edid-data]; + }; diff --git a/drivers/mfd/sm501.c b/drivers/mfd/sm501.c index 558d5f3f6d02..df3702c1756d 100644 --- a/drivers/mfd/sm501.c +++ b/drivers/mfd/sm501.c @@ -1377,7 +1377,7 @@ static int __devinit sm501_init_dev(struct sm501_devdata *sm) sm501_register_gpio(sm); } - if (pdata->gpio_i2c != NULL && pdata->gpio_i2c_nr > 0) { + if (pdata && pdata->gpio_i2c != NULL && pdata->gpio_i2c_nr > 0) { if (!sm501_gpio_isregistered(sm)) dev_err(sm->dev, "no gpio available for i2c gpio.\n"); else @@ -1422,6 +1422,7 @@ static int __devinit sm501_plat_probe(struct platform_device *dev) sm->io_res = platform_get_resource(dev, IORESOURCE_MEM, 1); sm->mem_res = platform_get_resource(dev, IORESOURCE_MEM, 0); + if (sm->io_res == NULL || sm->mem_res == NULL) { dev_err(&dev->dev, "failed to get IO resource\n"); ret = -ENOENT; @@ -1735,10 +1736,16 @@ static struct pci_driver sm501_pci_driver = { MODULE_ALIAS("platform:sm501"); +static struct of_device_id __devinitdata of_sm501_match_tbl[] = { + { .compatible = "smi,sm501", }, + { /* end */ } +}; + static struct platform_driver sm501_plat_driver = { .driver = { .name = "sm501", .owner = THIS_MODULE, + .of_match_table = of_sm501_match_tbl, }, .probe = sm501_plat_probe, .remove = sm501_plat_remove, diff --git a/drivers/video/sm501fb.c b/drivers/video/sm501fb.c index f31252ce8892..46d1a64fe80d 100644 --- a/drivers/video/sm501fb.c +++ b/drivers/video/sm501fb.c @@ -1729,6 +1729,15 @@ static int sm501fb_init_fb(struct fb_info *fb, FBINFO_HWACCEL_COPYAREA | FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_XPAN | FBINFO_HWACCEL_YPAN; +#if defined(CONFIG_OF) +#ifdef __BIG_ENDIAN + if (of_get_property(info->dev->parent->of_node, "little-endian", NULL)) + fb->flags |= FBINFO_FOREIGN_ENDIAN; +#else + if (of_get_property(info->dev->parent->of_node, "big-endian", NULL)) + fb->flags |= FBINFO_FOREIGN_ENDIAN; +#endif +#endif /* fixed data */ fb->fix.type = FB_TYPE_PACKED_PIXELS; @@ -1765,14 +1774,17 @@ static int sm501fb_init_fb(struct fb_info *fb, fb->var.xres_virtual = fb->var.xres; fb->var.yres_virtual = fb->var.yres; } else { - if (info->edid_data) + if (info->edid_data) { ret = fb_find_mode(&fb->var, fb, fb_mode, fb->monspecs.modedb, fb->monspecs.modedb_len, &sm501_default_mode, default_bpp); - else + /* edid_data is no longer needed, free it */ + kfree(info->edid_data); + } else { ret = fb_find_mode(&fb->var, fb, NULL, NULL, 0, NULL, 8); + } switch (ret) { case 1: @@ -1933,8 +1945,32 @@ static int __devinit sm501fb_probe(struct platform_device *pdev) } if (info->pdata == NULL) { - dev_info(dev, "using default configuration data\n"); + int found = 0; +#if defined(CONFIG_OF) + struct device_node *np = pdev->dev.parent->of_node; + const u8 *prop; + const char *cp; + int len; + info->pdata = &sm501fb_def_pdata; + if (np) { + /* Get EDID */ + cp = of_get_property(np, "mode", &len); + if (cp) + strcpy(fb_mode, cp); + prop = of_get_property(np, "edid", &len); + if (prop && len == EDID_LENGTH) { + info->edid_data = kmemdup(prop, EDID_LENGTH, + GFP_KERNEL); + if (info->edid_data) + found = 1; + } + } +#endif + if (!found) { + dev_info(dev, "using default configuration data\n"); + info->pdata = &sm501fb_def_pdata; + } } /* probe for the presence of each panel */ -- cgit v1.2.3-59-g8ed1b From 9c7fbe2fbd1d861c50912b10b2bc3a15371a7a5e Mon Sep 17 00:00:00 2001 From: Paul Mundt Date: Wed, 23 Mar 2011 08:16:45 +0900 Subject: video: Move sm501fb devicetree binding documentation to a better place. Now that there is a Documentation/devicetree hierarchy, and the driver in question has no specific platform dependency, move the binding information to a more appropriate place. Signed-off-by: Paul Mundt --- Documentation/devicetree/bindings/fb/sm501fb.txt | 34 ++++++++++++++++++++++++ Documentation/powerpc/dts-bindings/sm501.txt | 34 ------------------------ 2 files changed, 34 insertions(+), 34 deletions(-) create mode 100644 Documentation/devicetree/bindings/fb/sm501fb.txt delete mode 100644 Documentation/powerpc/dts-bindings/sm501.txt (limited to 'Documentation') diff --git a/Documentation/devicetree/bindings/fb/sm501fb.txt b/Documentation/devicetree/bindings/fb/sm501fb.txt new file mode 100644 index 000000000000..7d319fba9b5b --- /dev/null +++ b/Documentation/devicetree/bindings/fb/sm501fb.txt @@ -0,0 +1,34 @@ +* SM SM501 + +The SM SM501 is a LCD controller, with proper hardware, it can also +drive DVI monitors. + +Required properties: +- compatible : should be "smi,sm501". +- reg : contain two entries: + - First entry: System Configuration register + - Second entry: IO space (Display Controller register) +- interrupts : SMI interrupt to the cpu should be described here. +- interrupt-parent : the phandle for the interrupt controller that + services interrupts for this device. + +Optional properties: +- mode : select a video mode: + x[-][@] +- edid : verbatim EDID data block describing attached display. + Data from the detailed timing descriptor will be used to + program the display controller. +- little-endian: availiable on big endian systems, to + set different foreign endian. +- big-endian: availiable on little endian systems, to + set different foreign endian. + +Example for MPC5200: + display@1,0 { + compatible = "smi,sm501"; + reg = <1 0x00000000 0x00800000 + 1 0x03e00000 0x00200000>; + interrupts = <1 1 3>; + mode = "640x480-32@60"; + edid = [edid-data]; + }; diff --git a/Documentation/powerpc/dts-bindings/sm501.txt b/Documentation/powerpc/dts-bindings/sm501.txt deleted file mode 100644 index 7d319fba9b5b..000000000000 --- a/Documentation/powerpc/dts-bindings/sm501.txt +++ /dev/null @@ -1,34 +0,0 @@ -* SM SM501 - -The SM SM501 is a LCD controller, with proper hardware, it can also -drive DVI monitors. - -Required properties: -- compatible : should be "smi,sm501". -- reg : contain two entries: - - First entry: System Configuration register - - Second entry: IO space (Display Controller register) -- interrupts : SMI interrupt to the cpu should be described here. -- interrupt-parent : the phandle for the interrupt controller that - services interrupts for this device. - -Optional properties: -- mode : select a video mode: - x[-][@] -- edid : verbatim EDID data block describing attached display. - Data from the detailed timing descriptor will be used to - program the display controller. -- little-endian: availiable on big endian systems, to - set different foreign endian. -- big-endian: availiable on little endian systems, to - set different foreign endian. - -Example for MPC5200: - display@1,0 { - compatible = "smi,sm501"; - reg = <1 0x00000000 0x00800000 - 1 0x03e00000 0x00200000>; - interrupts = <1 1 3>; - mode = "640x480-32@60"; - edid = [edid-data]; - }; -- cgit v1.2.3-59-g8ed1b