From: Ben Dooks <ben-linux@fluff.org>
To: linux-kernel@vger.kernel.org
Cc: akpm@linux-foundation.org, Ben Dooks <ben-linux@fluff.org>
Subject: [patch 4/6] SM501: Clock updates and checks
Date: Thu, 14 Jun 2007 11:01:13 +0100 [thread overview]
Message-ID: <20070614100136.187324597@fluff.org.uk> (raw)
In-Reply-To: 20070614100109.192172553@fluff.org.uk
[-- Attachment #1: simtec-drivers-mfd-sm501-clockupdate.patch --]
[-- Type: text/plain, Size: 2810 bytes --]
Ensure that the M1XCLK and MCLK are sourced from
the same PLL (and refuse to bind the driver if they
are not).
Update the PCI to safe initialisation values, as 72MHz
is the maximum clock for 33MHz PCI bus mastering.
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-07 12:42:22.000000000 +0100
+++ linux-2.6.21-quilt8/drivers/mfd/sm501.c 2007-06-07 13:01:02.000000000 +0100
@@ -845,6 +845,24 @@ static void sm501_init_regs(struct sm501
dev_info(sm->dev, "setting MCLK to %ld\n", init->mclk);
sm501_set_clock(sm->dev, SM501_CLOCK_MCLK, init->mclk);
}
+
+}
+
+/* Check the PLL sources for the M1CLK and M1XCLK
+ *
+ * If the M1CLK and M1XCLKs are not sourced from the same PLL, then
+ * there is a risk (see errata AB-5) that the SM501 will cease proper
+ * function. If this happens, then it is likely the SM501 will
+ * hang the system.
+*/
+
+static int sm501_check_clocks(struct sm501_devdata *sm)
+{
+ unsigned long pwrmode = readl(sm->regs + SM501_CURRENT_CLOCK);
+ unsigned long msrc = (pwrmode & SM501_POWERMODE_M_SRC);
+ unsigned long m1src = (pwrmode & SM501_POWERMODE_M1_SRC);
+
+ return ((msrc == 0 && m1src != 0) || (msrc == 0 && msrc != 0));
}
static unsigned int sm501_mem_local[] = {
@@ -901,6 +919,12 @@ static int sm501_init_dev(struct sm501_d
}
}
+ ret = sm501_check_clocks(sm);
+ if (ret) {
+ dev_err(sm->dev, "M1X and M clocks sourced from different PLLs\n");
+ return -EINVAL;
+ }
+
/* always create a framebuffer */
sm501_register_display(sm, &mem_avail);
@@ -1034,8 +1058,12 @@ static struct sm501_initdata sm501_pci_i
},
.devices = SM501_USE_ALL,
- .mclk = 100 * MHZ,
- .m1xclk = 160 * MHZ,
+
+ /* Errata AB-3 says that 72MHz is the fastest available
+ * for 33MHZ PCI with proper bus-mastering operation */
+
+ .mclk = 72 * MHZ,
+ .m1xclk = 144 * MHZ,
};
static struct sm501_platdata_fbsub sm501_pdata_fbsub = {
Index: linux-2.6.21-quilt8/include/linux/sm501-regs.h
===================================================================
--- linux-2.6.21-quilt8.orig/include/linux/sm501-regs.h 2007-06-07 12:41:34.000000000 +0100
+++ linux-2.6.21-quilt8/include/linux/sm501-regs.h 2007-06-07 12:42:22.000000000 +0100
@@ -64,6 +64,11 @@
#define SM501_DEBUG_CONTROL (0x000034)
/* power management */
+#define SM501_POWERMODE_P2X_SRC (1<<29)
+#define SM501_POWERMODE_V2X_SRC (1<<20)
+#define SM501_POWERMODE_M_SRC (1<<12)
+#define SM501_POWERMODE_M1_SRC (1<<4)
+
#define SM501_CURRENT_GATE (0x000038)
#define SM501_CURRENT_CLOCK (0x00003C)
#define SM501_POWER_MODE_0_GATE (0x000040)
--
Ben (ben@fluff.org, http://www.fluff.org/)
'a smiley only costs 4 bytes'
next prev parent reply other threads:[~2007-06-14 10:02 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-14 10:01 [patch 0/6] SM501 fixes and updates Ben Dooks
2007-06-14 10:01 ` [patch 1/6] SM501: suspend support Ben Dooks
2007-06-14 10:01 ` [patch 2/6] SM501: initialise SDRAM clock before bus clocks Ben Dooks
2007-06-14 10:01 ` [patch 3/6] SM501: Fix sm501_init_reg() mask/set order Ben Dooks
2007-06-14 10:01 ` Ben Dooks [this message]
2007-06-14 10:01 ` [patch 5/6] SM501: Add Documentation/SM501.txt Ben Dooks
2007-06-14 10:01 ` [patch 6/6] SM501: Check SM501 ID register on initialisation Ben Dooks
2007-06-14 11:22 ` [patch 0/6] SM501 fixes and updates Sam Ravnborg
2007-06-14 12:51 ` Ben Dooks
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=20070614100136.187324597@fluff.org.uk \
--to=ben-linux@fluff.org \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
/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