Commit 10ab92d8 authored by Paul Mundt's avatar Paul Mundt

sh: heartbeat: Support access size specification via resource flags.

This permits the resource access size to be handed off through the
resource flags, which saves platforms from having to establish
platform data only to specify the register width.
Signed-off-by: default avatarPaul Mundt <lethal@linux-sh.org>
parent 46c4e5da
/* /*
* Generic heartbeat driver for regular LED banks * Generic heartbeat driver for regular LED banks
* *
* Copyright (C) 2007 Paul Mundt * Copyright (C) 2007 - 2010 Paul Mundt
* *
* Most SH reference boards include a number of individual LEDs that can * Most SH reference boards include a number of individual LEDs that can
* be independently controlled (either via a pre-defined hardware * be independently controlled (either via a pre-defined hardware
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
#include <asm/heartbeat.h> #include <asm/heartbeat.h>
#define DRV_NAME "heartbeat" #define DRV_NAME "heartbeat"
#define DRV_VERSION "0.1.1" #define DRV_VERSION "0.1.2"
static unsigned char default_bit_pos[] = { 0, 1, 2, 3, 4, 5, 6, 7 }; static unsigned char default_bit_pos[] = { 0, 1, 2, 3, 4, 5, 6, 7 };
...@@ -98,7 +98,7 @@ static int heartbeat_drv_probe(struct platform_device *pdev) ...@@ -98,7 +98,7 @@ static int heartbeat_drv_probe(struct platform_device *pdev)
return -ENOMEM; return -ENOMEM;
} }
hd->base = ioremap_nocache(res->start, res->end - res->start + 1); hd->base = ioremap_nocache(res->start, resource_size(res));
if (unlikely(!hd->base)) { if (unlikely(!hd->base)) {
dev_err(&pdev->dev, "ioremap failed\n"); dev_err(&pdev->dev, "ioremap failed\n");
...@@ -117,8 +117,20 @@ static int heartbeat_drv_probe(struct platform_device *pdev) ...@@ -117,8 +117,20 @@ static int heartbeat_drv_probe(struct platform_device *pdev)
for (i = 0; i < hd->nr_bits; i++) for (i = 0; i < hd->nr_bits; i++)
hd->mask |= (1 << hd->bit_pos[i]); hd->mask |= (1 << hd->bit_pos[i]);
if (!hd->regsize) if (!hd->regsize) {
hd->regsize = 8; /* default access size */ switch (res->flags & IORESOURCE_MEM_TYPE_MASK) {
case IORESOURCE_MEM_32BIT:
hd->regsize = 32;
break;
case IORESOURCE_MEM_16BIT:
hd->regsize = 16;
break;
case IORESOURCE_MEM_8BIT:
default:
hd->regsize = 8;
break;
}
}
setup_timer(&hd->timer, heartbeat_timer, (unsigned long)hd); setup_timer(&hd->timer, heartbeat_timer, (unsigned long)hd);
platform_set_drvdata(pdev, hd); platform_set_drvdata(pdev, hd);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment