diff options
author | Ben Dooks <ben-linux@fluff.org> | 2007-06-23 20:16:31 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-06-24 11:59:11 -0400 |
commit | 1e27dbe7746f3bcbcf1f9a37f31df4b886e36ce3 (patch) | |
tree | cca92108cf97c5c13b0c9e7f85f11da8bd513fb5 | |
parent | ffd65af0e67a054e1e2393c9b0995c03c47cdc30 (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>
-rw-r--r-- | drivers/mfd/sm501.c | 14 | ||||
-rw-r--r-- | include/linux/sm501-regs.h | 3 |
2 files changed, 13 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) | |||
893 | { | 893 | { |
894 | resource_size_t mem_avail; | 894 | resource_size_t mem_avail; |
895 | unsigned long dramctrl; | 895 | unsigned long dramctrl; |
896 | unsigned long devid; | ||
896 | int ret; | 897 | int ret; |
897 | 898 | ||
898 | mutex_init(&sm->clock_lock); | 899 | mutex_init(&sm->clock_lock); |
@@ -900,13 +901,18 @@ static int sm501_init_dev(struct sm501_devdata *sm) | |||
900 | 901 | ||
901 | INIT_LIST_HEAD(&sm->devices); | 902 | INIT_LIST_HEAD(&sm->devices); |
902 | 903 | ||
903 | dramctrl = readl(sm->regs + SM501_DRAM_CONTROL); | 904 | devid = readl(sm->regs + SM501_DEVICEID); |
904 | 905 | ||
906 | if ((devid & SM501_DEVICEID_IDMASK) != SM501_DEVICEID_SM501) { | ||
907 | dev_err(sm->dev, "incorrect device id %08lx\n", devid); | ||
908 | return -EINVAL; | ||
909 | } | ||
910 | |||
911 | dramctrl = readl(sm->regs + SM501_DRAM_CONTROL); | ||
905 | mem_avail = sm501_mem_local[(dramctrl >> 13) & 0x7]; | 912 | mem_avail = sm501_mem_local[(dramctrl >> 13) & 0x7]; |
906 | 913 | ||
907 | dev_info(sm->dev, "SM501 At %p: Version %08x, %ld Mb, IRQ %d\n", | 914 | dev_info(sm->dev, "SM501 At %p: Version %08lx, %ld Mb, IRQ %d\n", |
908 | sm->regs, readl(sm->regs + SM501_DEVICEID), | 915 | sm->regs, devid, (unsigned long)mem_avail >> 20, sm->irq); |
909 | (unsigned long)mem_avail >> 20, sm->irq); | ||
910 | 916 | ||
911 | sm501_dump_gate(sm); | 917 | sm501_dump_gate(sm); |
912 | 918 | ||
diff --git a/include/linux/sm501-regs.h b/include/linux/sm501-regs.h index 8b4ecf02f9dc..014e73b31fc0 100644 --- a/include/linux/sm501-regs.h +++ b/include/linux/sm501-regs.h | |||
@@ -109,6 +109,9 @@ | |||
109 | #define SM501_DEVICEID (0x000060) | 109 | #define SM501_DEVICEID (0x000060) |
110 | /* 0x050100A0 */ | 110 | /* 0x050100A0 */ |
111 | 111 | ||
112 | #define SM501_DEVICEID_SM501 (0x05010000) | ||
113 | #define SM501_DEVICEID_IDMASK (0xffff0000) | ||
114 | |||
112 | #define SM501_PLLCLOCK_COUNT (0x000064) | 115 | #define SM501_PLLCLOCK_COUNT (0x000064) |
113 | #define SM501_MISC_TIMING (0x000068) | 116 | #define SM501_MISC_TIMING (0x000068) |
114 | #define SM501_CURRENT_SDRAM_CLOCK (0x00006C) | 117 | #define SM501_CURRENT_SDRAM_CLOCK (0x00006C) |