aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyan Mallon <rmallon@gmail.com>2012-01-22 04:31:32 -0500
committerRyan Mallon <rmallon@gmail.com>2012-03-13 20:41:10 -0400
commit0fd1958050e92c859152e775e548284582335d25 (patch)
treedd457bc43e459ff65aa0dba5034ec52de5d43364
parent2ae18b471d91f7622e54f18ed3a4b5b20e9bf871 (diff)
ep93xx: Use ioremap for backlight driver
The ep93xx backlight driver uses a single register within the framebuffer's register space. Currently the backlight driver uses a static IO mapping for the register since the memory cannot be requested by both drivers. Convert the static mapping to use ioremap so that we can remove the dependency on mach/hardware.h. To do so, we need remove the request_mem_region from both the backlight and framebuffer drivers, since whichever driver is loaded second will fail with -EBUSY otherwise. A proper fix is still required, and a FIXME comment has been added to both drivers. Signed-off-by: Ryan Mallon <rmallon@gmail.com> Suggested-by: Arnd Bergmann <arnd@arndb.de> Cc: Mika Westerberg <mika.westerberg@iki.fi> Cc: Richard Purdie <rpurdie@rpsys.net> Cc: Florian Tobias Schandinat <FlorianSchandinat@gmx.de> Acked-by: Arnd Bergmann <arnd@arndb.de> Acked-by: H Hartley Sweeten <hsweeten@visionengravers.com>
-rw-r--r--arch/arm/mach-ep93xx/core.c10
-rw-r--r--drivers/video/backlight/ep93xx_bl.c25
-rw-r--r--drivers/video/ep93xx-fb.c18
3 files changed, 33 insertions, 20 deletions
diff --git a/arch/arm/mach-ep93xx/core.c b/arch/arm/mach-ep93xx/core.c
index b5c1dae8327..c73e299b08a 100644
--- a/arch/arm/mach-ep93xx/core.c
+++ b/arch/arm/mach-ep93xx/core.c
@@ -682,9 +682,19 @@ static struct platform_device ep93xx_fb_device = {
682 .resource = ep93xx_fb_resource, 682 .resource = ep93xx_fb_resource,
683}; 683};
684 684
685/* The backlight use a single register in the framebuffer's register space */
686#define EP93XX_RASTER_REG_BRIGHTNESS 0x20
687
688static struct resource ep93xx_bl_resources[] = {
689 DEFINE_RES_MEM(EP93XX_RASTER_PHYS_BASE +
690 EP93XX_RASTER_REG_BRIGHTNESS, 0x04),
691};
692
685static struct platform_device ep93xx_bl_device = { 693static struct platform_device ep93xx_bl_device = {
686 .name = "ep93xx-bl", 694 .name = "ep93xx-bl",
687 .id = -1, 695 .id = -1,
696 .num_resources = ARRAY_SIZE(ep93xx_bl_resources),
697 .resource = ep93xx_bl_resources,
688}; 698};
689 699
690/** 700/**
diff --git a/drivers/video/backlight/ep93xx_bl.c b/drivers/video/backlight/ep93xx_bl.c
index b62b8b9063b..08214e1f095 100644
--- a/drivers/video/backlight/ep93xx_bl.c
+++ b/drivers/video/backlight/ep93xx_bl.c
@@ -17,11 +17,6 @@
17#include <linux/fb.h> 17#include <linux/fb.h>
18#include <linux/backlight.h> 18#include <linux/backlight.h>
19 19
20#include <mach/hardware.h>
21
22#define EP93XX_RASTER_REG(x) (EP93XX_RASTER_BASE + (x))
23#define EP93XX_RASTER_BRIGHTNESS EP93XX_RASTER_REG(0x20)
24
25#define EP93XX_MAX_COUNT 255 20#define EP93XX_MAX_COUNT 255
26#define EP93XX_MAX_BRIGHT 255 21#define EP93XX_MAX_BRIGHT 255
27#define EP93XX_DEF_BRIGHT 128 22#define EP93XX_DEF_BRIGHT 128
@@ -35,7 +30,7 @@ static int ep93xxbl_set(struct backlight_device *bl, int brightness)
35{ 30{
36 struct ep93xxbl *ep93xxbl = bl_get_data(bl); 31 struct ep93xxbl *ep93xxbl = bl_get_data(bl);
37 32
38 __raw_writel((brightness << 8) | EP93XX_MAX_COUNT, ep93xxbl->mmio); 33 writel((brightness << 8) | EP93XX_MAX_COUNT, ep93xxbl->mmio);
39 34
40 ep93xxbl->brightness = brightness; 35 ep93xxbl->brightness = brightness;
41 36
@@ -70,21 +65,29 @@ static int __init ep93xxbl_probe(struct platform_device *dev)
70 struct ep93xxbl *ep93xxbl; 65 struct ep93xxbl *ep93xxbl;
71 struct backlight_device *bl; 66 struct backlight_device *bl;
72 struct backlight_properties props; 67 struct backlight_properties props;
68 struct resource *res;
73 69
74 ep93xxbl = devm_kzalloc(&dev->dev, sizeof(*ep93xxbl), GFP_KERNEL); 70 ep93xxbl = devm_kzalloc(&dev->dev, sizeof(*ep93xxbl), GFP_KERNEL);
75 if (!ep93xxbl) 71 if (!ep93xxbl)
76 return -ENOMEM; 72 return -ENOMEM;
77 73
74 res = platform_get_resource(dev, IORESOURCE_MEM, 0);
75 if (!res)
76 return -ENXIO;
77
78 /* 78 /*
79 * This register is located in the range already ioremap'ed by 79 * FIXME - We don't do a request_mem_region here because we are
80 * the framebuffer driver. A MFD driver seems a bit of overkill 80 * sharing the register space with the framebuffer driver (see
81 * to handle this so use the static I/O mapping; this address 81 * drivers/video/ep93xx-fb.c) and doing so will cause the second
82 * is already virtual. 82 * loaded driver to return -EBUSY.
83 * 83 *
84 * NOTE: No locking is required; the framebuffer does not touch 84 * NOTE: No locking is required; the framebuffer does not touch
85 * this register. 85 * this register.
86 */ 86 */
87 ep93xxbl->mmio = EP93XX_RASTER_BRIGHTNESS; 87 ep93xxbl->mmio = devm_ioremap(&dev->dev, res->start,
88 resource_size(res));
89 if (!ep93xxbl->mmio)
90 return -ENXIO;
88 91
89 memset(&props, 0, sizeof(struct backlight_properties)); 92 memset(&props, 0, sizeof(struct backlight_properties));
90 props.type = BACKLIGHT_RAW; 93 props.type = BACKLIGHT_RAW;
diff --git a/drivers/video/ep93xx-fb.c b/drivers/video/ep93xx-fb.c
index 2e830ec52a5..f8babbeee27 100644
--- a/drivers/video/ep93xx-fb.c
+++ b/drivers/video/ep93xx-fb.c
@@ -519,12 +519,15 @@ static int __devinit ep93xxfb_probe(struct platform_device *pdev)
519 goto failed; 519 goto failed;
520 } 520 }
521 521
522 res = request_mem_region(res->start, resource_size(res), pdev->name); 522 /*
523 if (!res) { 523 * FIXME - We don't do a request_mem_region here because we are
524 err = -EBUSY; 524 * sharing the register space with the backlight driver (see
525 goto failed; 525 * drivers/video/backlight/ep93xx_bl.c) and doing so will cause
526 } 526 * the second loaded driver to return -EBUSY.
527 527 *
528 * NOTE: No locking is required; the backlight does not touch
529 * any of the framebuffer registers.
530 */
528 fbi->res = res; 531 fbi->res = res;
529 fbi->mmio_base = ioremap(res->start, resource_size(res)); 532 fbi->mmio_base = ioremap(res->start, resource_size(res));
530 if (!fbi->mmio_base) { 533 if (!fbi->mmio_base) {
@@ -586,8 +589,6 @@ failed:
586 clk_put(fbi->clk); 589 clk_put(fbi->clk);
587 if (fbi->mmio_base) 590 if (fbi->mmio_base)
588 iounmap(fbi->mmio_base); 591 iounmap(fbi->mmio_base);
589 if (fbi->res)
590 release_mem_region(fbi->res->start, resource_size(fbi->res));
591 ep93xxfb_dealloc_videomem(info); 592 ep93xxfb_dealloc_videomem(info);
592 if (&info->cmap) 593 if (&info->cmap)
593 fb_dealloc_cmap(&info->cmap); 594 fb_dealloc_cmap(&info->cmap);
@@ -608,7 +609,6 @@ static int __devexit ep93xxfb_remove(struct platform_device *pdev)
608 clk_disable(fbi->clk); 609 clk_disable(fbi->clk);
609 clk_put(fbi->clk); 610 clk_put(fbi->clk);
610 iounmap(fbi->mmio_base); 611 iounmap(fbi->mmio_base);
611 release_mem_region(fbi->res->start, resource_size(fbi->res));
612 ep93xxfb_dealloc_videomem(info); 612 ep93xxfb_dealloc_videomem(info);
613 fb_dealloc_cmap(&info->cmap); 613 fb_dealloc_cmap(&info->cmap);
614 614