From: ben@fluff.org.uk
To: ben@fluff.org, akpm@linux-foundation.org,
linux-kernel@vger.kernel.org, sm5xx-devel@lists.berlios.de
Cc: Ben Dooks <ben-linux@fluff.org>
Subject: [patch #2 6/6] SM501: Check SM501 ID register on initialisation
Date: Mon, 18 Jun 2007 21:56:26 +0100 [thread overview]
Message-ID: <20070618210342.412773833@fluff.org.uk> (raw)
In-Reply-To: 20070618205620.284044146@fluff.org.uk
[-- Attachment #1: simtec-drivers-mfd-sm501-idcheck.patch --]
[-- Type: text/plain, Size: 2081 bytes --]
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>
Index: linux-2.6.21-quilt8/drivers/mfd/sm501.c
===================================================================
--- linux-2.6.21-quilt8.orig/drivers/mfd/sm501.c 2007-06-13 11:33:55.000000000 +0100
+++ linux-2.6.21-quilt8/drivers/mfd/sm501.c 2007-06-13 12:59:31.000000000 +0100
@@ -883,6 +883,7 @@ static int sm501_init_dev(struct sm501_d
{
resource_size_t mem_avail;
unsigned long dramctrl;
+ unsigned long devid;
int ret;
mutex_init(&sm->clock_lock);
@@ -890,13 +891,18 @@ static int sm501_init_dev(struct sm501_d
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);
Index: linux-2.6.21-quilt8/include/linux/sm501-regs.h
===================================================================
--- linux-2.6.21-quilt8.orig/include/linux/sm501-regs.h 2007-06-13 11:33:55.000000000 +0100
+++ linux-2.6.21-quilt8/include/linux/sm501-regs.h 2007-06-13 11:33:56.000000000 +0100
@@ -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)
--
Ben (ben@fluff.org, http://www.fluff.org/)
'a smiley only costs 4 bytes'
prev parent reply other threads:[~2007-06-18 21:04 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-18 20:56 [patch #2 0/6] [#2] SM501 updates ben
2007-06-18 20:56 ` [patch #2 1/6] SM501: suspend support ben
2007-06-19 18:31 ` Andrew Morton
2007-06-18 20:56 ` [patch #2 2/6] SM501: initialise SDRAM clock before bus clocks ben
2007-06-18 20:56 ` [patch #2 3/6] SM501: Fix sm501_init_reg() mask/set order ben
2007-06-18 20:56 ` [patch #2 4/6] SM501: Clock updates and checks ben
2007-06-18 20:56 ` [patch #2 5/6] SM501: Add Documentation/SM501.txt ben
2007-06-18 20:56 ` ben [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070618210342.412773833@fluff.org.uk \
--to=ben@fluff.org.uk \
--cc=akpm@linux-foundation.org \
--cc=ben-linux@fluff.org \
--cc=ben@fluff.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sm5xx-devel@lists.berlios.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).