summaryrefslogtreecommitdiff
path: root/drivers/mfd/sm501.c
diff options
context:
space:
mode:
authorBen Dooks <ben-linux@fluff.org>2007-06-23 17:16:31 -0700
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-06-24 08:59:11 -0700
commit1e27dbe7746f3bcbcf1f9a37f31df4b886e36ce3 (patch)
treecca92108cf97c5c13b0c9e7f85f11da8bd513fb5 /drivers/mfd/sm501.c
parentffd65af0e67a054e1e2393c9b0995c03c47cdc30 (diff)
SM501: Check SM501 ID register on initialisation
When binding the driver, check the ID register for a valid identity, in case the SM501 is not functioning correctly. Signed-off-by: Ben Dooks <ben-linux@fluff.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/mfd/sm501.c')
-rw-r--r--drivers/mfd/sm501.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/drivers/mfd/sm501.c b/drivers/mfd/sm501.c
index e14d70e07418..8135e4c3bf47 100644
--- a/drivers/mfd/sm501.c
+++ b/drivers/mfd/sm501.c
@@ -893,6 +893,7 @@ static int sm501_init_dev(struct sm501_devdata *sm)
{
resource_size_t mem_avail;
unsigned long dramctrl;
+ unsigned long devid;
int ret;
mutex_init(&sm->clock_lock);
@@ -900,13 +901,18 @@ static int sm501_init_dev(struct sm501_devdata *sm)
INIT_LIST_HEAD(&sm->devices);
- dramctrl = readl(sm->regs + SM501_DRAM_CONTROL);
+ devid = readl(sm->regs + SM501_DEVICEID);
+ if ((devid & SM501_DEVICEID_IDMASK) != SM501_DEVICEID_SM501) {
+ dev_err(sm->dev, "incorrect device id %08lx\n", devid);
+ return -EINVAL;
+ }
+
+ dramctrl = readl(sm->regs + SM501_DRAM_CONTROL);
mem_avail = sm501_mem_local[(dramctrl >> 13) & 0x7];
- dev_info(sm->dev, "SM501 At %p: Version %08x, %ld Mb, IRQ %d\n",
- sm->regs, readl(sm->regs + SM501_DEVICEID),
- (unsigned long)mem_avail >> 20, sm->irq);
+ dev_info(sm->dev, "SM501 At %p: Version %08lx, %ld Mb, IRQ %d\n",
+ sm->regs, devid, (unsigned long)mem_avail >> 20, sm->irq);
sm501_dump_gate(sm);