1 From ef2376d29e996d9d21a9e5798cb88aa73f734c83 Mon Sep 17 00:00:00 2001
2 From: Andy Green <andy@openmoko.com>
3 Date: Thu, 17 Jul 2008 10:02:35 +0100
4 Subject: [PATCH] add-limit-sdcard-clk-cmdline.patch
6 This patch allows you to control the maximum clock rate that will
7 be selected for SD Card access, from the kernel commandline using
9 glamo_mci.sd_max_clk=10000000
13 echo 10000000 > /sys/module/glamo_mci/parameters/sd_max_clk
15 although you have to suspend and resume to make the limit operational
16 on the actual SD_CLK line.
18 Clocks that are possible are divided down from ~50MHz, so 25000000,
19 16666666, 12500000, 10000000, etc. With Freerunner A5 revision that
20 has 100R series resistors in SD Card signals, I didn't get reliable
21 operation above 16MHz. With A6 revision the series resistors went
22 down to 75R, maybe it can work at 25MHz.
24 Reducing the clock rate is something to try if you find that your
25 SD Card is not communicating properly with the default speed.
27 Signed-off-by: Andy Green <andy@openmoko.com>
29 drivers/mfd/glamo/glamo-mci.c | 38 +++++++++++++++++++++++++++++---------
30 1 files changed, 29 insertions(+), 9 deletions(-)
32 diff --git a/drivers/mfd/glamo/glamo-mci.c b/drivers/mfd/glamo/glamo-mci.c
33 index 350b47d..6729244 100644
34 --- a/drivers/mfd/glamo/glamo-mci.c
35 +++ b/drivers/mfd/glamo/glamo-mci.c
36 @@ -40,6 +40,24 @@ static spinlock_t clock_lock;
38 static void glamo_mci_send_request(struct mmc_host *mmc);
43 + * held at /(3 + 1) due to concerns of 100R recommended series resistor
44 + * allows 16MHz @ 4-bit --> 8MBytes/sec raw
46 + * you can override this on kernel commandline using
48 + * glamo_mci.sd_max_clk=10000000
53 +static int sd_max_clk = 50000000 / 3;
54 +module_param(sd_max_clk, int, 0644);
58 unsigned char CRC7(u8 * pu8, int cnt)
61 @@ -676,9 +694,9 @@ static void glamo_mci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
62 (ios->power_mode == MMC_POWER_UP)) {
63 dev_info(&host->pdev->dev,
64 "powered (vdd = %d) clk: %lukHz div=%d (req: %ukHz). "
65 - "Bus width=%d\n",ios->vdd,
66 - host->real_rate / 1000, host->real_rate,
67 - ios->clock / 1000, ios->bus_width);
68 + "Bus width=%d\n",(int)ios->vdd,
69 + host->real_rate / 1000, (int)host->clk_div,
70 + ios->clock / 1000, (int)ios->bus_width);
72 dev_info(&host->pdev->dev, "glamo_mci_set_ios: power down.\n");
74 @@ -800,11 +818,7 @@ static int glamo_mci_probe(struct platform_device *pdev)
75 MMC_CAP_MMC_HIGHSPEED |
77 mmc->f_min = host->clk_rate / 256;
79 - * held at /4 due to concerns of 100R recommended series resistor
80 - * allows 16MHz @ 4-bit --> 8MBytes/sec raw
82 - mmc->f_max = host->clk_rate / 3;
83 + mmc->f_max = sd_max_clk;
85 mmc->max_blk_count = (1 << 16) - 1; /* GLAMO_REG_MMC_RB_BLKCNT */
86 mmc->max_blk_size = (1 << 12) - 1; /* GLAMO_REG_MMC_RB_BLKLEN */
87 @@ -866,12 +880,18 @@ static int glamo_mci_suspend(struct platform_device *dev, pm_message_t state)
89 struct mmc_host *mmc = platform_get_drvdata(dev);
90 struct glamo_mci_host *host = mmc_priv(mmc);
94 if (host->pdata->mci_all_dependencies_resumed)
95 (host->pdata->mci_suspending)(dev);
97 - return mmc_suspend_host(mmc, state);
98 + ret = mmc_suspend_host(mmc, state);
100 + /* so that when we resume, we use any modified max rate */
101 + mmc->f_max = sd_max_clk;
106 int glamo_mci_resume(struct platform_device *dev)