Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 295730
b: refs/heads/master
c: 0fd1958
h: refs/heads/master
v: v3
  • Loading branch information
Ryan Mallon committed Mar 14, 2012
1 parent 90151e1 commit d3bbc49
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 21 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 2ae18b471d91f7622e54f18ed3a4b5b20e9bf871
refs/heads/master: 0fd1958050e92c859152e775e548284582335d25
10 changes: 10 additions & 0 deletions trunk/arch/arm/mach-ep93xx/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -682,9 +682,19 @@ static struct platform_device ep93xx_fb_device = {
.resource = ep93xx_fb_resource,
};

/* The backlight use a single register in the framebuffer's register space */
#define EP93XX_RASTER_REG_BRIGHTNESS 0x20

static struct resource ep93xx_bl_resources[] = {
DEFINE_RES_MEM(EP93XX_RASTER_PHYS_BASE +
EP93XX_RASTER_REG_BRIGHTNESS, 0x04),
};

static struct platform_device ep93xx_bl_device = {
.name = "ep93xx-bl",
.id = -1,
.num_resources = ARRAY_SIZE(ep93xx_bl_resources),
.resource = ep93xx_bl_resources,
};

/**
Expand Down
25 changes: 14 additions & 11 deletions trunk/drivers/video/backlight/ep93xx_bl.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@
#include <linux/fb.h>
#include <linux/backlight.h>

#include <mach/hardware.h>

#define EP93XX_RASTER_REG(x) (EP93XX_RASTER_BASE + (x))
#define EP93XX_RASTER_BRIGHTNESS EP93XX_RASTER_REG(0x20)

#define EP93XX_MAX_COUNT 255
#define EP93XX_MAX_BRIGHT 255
#define EP93XX_DEF_BRIGHT 128
Expand All @@ -35,7 +30,7 @@ static int ep93xxbl_set(struct backlight_device *bl, int brightness)
{
struct ep93xxbl *ep93xxbl = bl_get_data(bl);

__raw_writel((brightness << 8) | EP93XX_MAX_COUNT, ep93xxbl->mmio);
writel((brightness << 8) | EP93XX_MAX_COUNT, ep93xxbl->mmio);

ep93xxbl->brightness = brightness;

Expand Down Expand Up @@ -70,21 +65,29 @@ static int __init ep93xxbl_probe(struct platform_device *dev)
struct ep93xxbl *ep93xxbl;
struct backlight_device *bl;
struct backlight_properties props;
struct resource *res;

ep93xxbl = devm_kzalloc(&dev->dev, sizeof(*ep93xxbl), GFP_KERNEL);
if (!ep93xxbl)
return -ENOMEM;

res = platform_get_resource(dev, IORESOURCE_MEM, 0);
if (!res)
return -ENXIO;

/*
* This register is located in the range already ioremap'ed by
* the framebuffer driver. A MFD driver seems a bit of overkill
* to handle this so use the static I/O mapping; this address
* is already virtual.
* FIXME - We don't do a request_mem_region here because we are
* sharing the register space with the framebuffer driver (see
* drivers/video/ep93xx-fb.c) and doing so will cause the second
* loaded driver to return -EBUSY.
*
* NOTE: No locking is required; the framebuffer does not touch
* this register.
*/
ep93xxbl->mmio = EP93XX_RASTER_BRIGHTNESS;
ep93xxbl->mmio = devm_ioremap(&dev->dev, res->start,
resource_size(res));
if (!ep93xxbl->mmio)
return -ENXIO;

memset(&props, 0, sizeof(struct backlight_properties));
props.type = BACKLIGHT_RAW;
Expand Down
18 changes: 9 additions & 9 deletions trunk/drivers/video/ep93xx-fb.c
Original file line number Diff line number Diff line change
Expand Up @@ -519,12 +519,15 @@ static int __devinit ep93xxfb_probe(struct platform_device *pdev)
goto failed;
}

res = request_mem_region(res->start, resource_size(res), pdev->name);
if (!res) {
err = -EBUSY;
goto failed;
}

/*
* FIXME - We don't do a request_mem_region here because we are
* sharing the register space with the backlight driver (see
* drivers/video/backlight/ep93xx_bl.c) and doing so will cause
* the second loaded driver to return -EBUSY.
*
* NOTE: No locking is required; the backlight does not touch
* any of the framebuffer registers.
*/
fbi->res = res;
fbi->mmio_base = ioremap(res->start, resource_size(res));
if (!fbi->mmio_base) {
Expand Down Expand Up @@ -586,8 +589,6 @@ static int __devinit ep93xxfb_probe(struct platform_device *pdev)
clk_put(fbi->clk);
if (fbi->mmio_base)
iounmap(fbi->mmio_base);
if (fbi->res)
release_mem_region(fbi->res->start, resource_size(fbi->res));
ep93xxfb_dealloc_videomem(info);
if (&info->cmap)
fb_dealloc_cmap(&info->cmap);
Expand All @@ -608,7 +609,6 @@ static int __devexit ep93xxfb_remove(struct platform_device *pdev)
clk_disable(fbi->clk);
clk_put(fbi->clk);
iounmap(fbi->mmio_base);
release_mem_region(fbi->res->start, resource_size(fbi->res));
ep93xxfb_dealloc_videomem(info);
fb_dealloc_cmap(&info->cmap);

Expand Down

0 comments on commit d3bbc49

Please sign in to comment.