Skip to content

Commit

Permalink
SM501: Check SM501 ID register on initialisation
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Ben Dooks authored and Linus Torvalds committed Jun 24, 2007
1 parent ffd65af commit 1e27dbe
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
14 changes: 10 additions & 4 deletions drivers/mfd/sm501.c
Expand Up @@ -893,20 +893,26 @@ 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);
spin_lock_init(&sm->reg_lock);

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);

Expand Down
3 changes: 3 additions & 0 deletions include/linux/sm501-regs.h
Expand Up @@ -109,6 +109,9 @@
#define SM501_DEVICEID (0x000060)
/* 0x050100A0 */

#define SM501_DEVICEID_SM501 (0x05010000)
#define SM501_DEVICEID_IDMASK (0xffff0000)

#define SM501_PLLCLOCK_COUNT (0x000064)
#define SM501_MISC_TIMING (0x000068)
#define SM501_CURRENT_SDRAM_CLOCK (0x00006C)
Expand Down

0 comments on commit 1e27dbe

Please sign in to comment.