1 From 1d04b142ffeaa15129f046751f1366b0f0614f47 Mon Sep 17 00:00:00 2001
2 From: Andy Green <andy@openmoko.com>
3 Date: Mon, 21 Jul 2008 00:51:30 +0100
4 Subject: [PATCH] debug-add-glamo-drive-strength-module-param.patch
5 Suggested-by: Werner Almesberger <werner@openmoko.org>
7 This patch allows users to control two additional settings
8 in Glamo MCI driver from kernel commandline or module
12 First is Glamo drive strength on SD IOs including CLK.
13 This ranges from 0 (weakest) to 3 (strongest).
15 echo 0 > /sys/module/glamo_mci/parameters/sd_drive
17 (Changes to this take effect on next SD Card transaction)
19 or, from kernel commandline
23 On tests here with 0 strength, communication to SD card
24 (shipped 512MB Sandisk) seemed fine, and a dd of 10MB
25 urandom had the same md5 when written to cache as after
26 a reboot. I set the default to 2.
29 Second is whether we allow SD_CLK when the SD interface
32 # stop the clock when we are idle (default)
33 echo 0 > /sys/module/glamo_mci/parameters/sd_idleclk
35 # run the SD clock all the time
36 echo 1 > /sys/module/glamo_mci/parameters/sd_idleclk
38 (changes take effect on next SD Card transaction)
40 From kernel commandline, eg:
42 glamo_mci.sd_idleclk=1
44 Normally you don't want to run the SD Clock all the time.
47 Signed-off-by: Andy Green <andy@openmoko.com>
49 drivers/mfd/glamo/glamo-mci.c | 59 +++++++++++++++++++++++++++++++---------
50 1 files changed, 45 insertions(+), 14 deletions(-)
52 diff --git a/drivers/mfd/glamo/glamo-mci.c b/drivers/mfd/glamo/glamo-mci.c
53 index 2318e6f..6585821 100644
54 --- a/drivers/mfd/glamo/glamo-mci.c
55 +++ b/drivers/mfd/glamo/glamo-mci.c
56 @@ -56,6 +56,32 @@ static void glamo_mci_send_request(struct mmc_host *mmc);
57 static int sd_max_clk = 50000000 / 3;
58 module_param(sd_max_clk, int, 0644);
61 + * SD Signal drive strength
63 + * you can override this on kernel commandline using
65 + * glamo_mci.sd_drive=0
70 +static int sd_drive = 2;
71 +module_param(sd_drive, int, 0644);
74 + * SD allow SD clock to run while idle
76 + * you can override this on kernel commandline using
78 + * glamo_mci.sd_idleclk=0
83 +static int sd_idleclk = 0; /* disallow idle clock by default */
84 +module_param(sd_idleclk, int, 0644);
88 unsigned char CRC7(u8 * pu8, int cnt)
89 @@ -239,7 +265,9 @@ static int __glamo_mci_set_card_clock(struct glamo_mci_host *host, int freq,
93 - __glamo_mci_fix_card_div(host, -1); /* clock off */
96 + __glamo_mci_fix_card_div(host, -1);
100 @@ -294,8 +322,9 @@ static void glamo_mci_irq(unsigned int irq, struct irq_desc *desc)
101 host->cmd_is_stop = 0;
105 - __glamo_mci_fix_card_div(host, -1);
108 + __glamo_mci_fix_card_div(host, -1);
111 host->complete_what = COMPLETION_NONE;
112 @@ -428,12 +457,10 @@ static int glamo_mci_send_command(struct glamo_mci_host *host,
114 writew(0xfff, host->base + GLAMO_REG_MMC_TIMEOUT);
116 - /* Generate interrupt on txfer; drive strength max */
117 - writew_dly((readw_dly(host->base + GLAMO_REG_MMC_BASIC) & 0xfe) |
118 + /* Generate interrupt on txfer */
119 + writew_dly((readw_dly(host->base + GLAMO_REG_MMC_BASIC) & 0x3e) |
120 0x0800 | GLAMO_BASIC_MMC_NO_CLK_RD_WAIT |
121 - GLAMO_BASIC_MMC_EN_COMPL_INT |
122 - GLAMO_BASIC_MMC_EN_DR_STR0 |
123 - GLAMO_BASIC_MMC_EN_DR_STR1,
124 + GLAMO_BASIC_MMC_EN_COMPL_INT | (sd_drive << 6),
125 host->base + GLAMO_REG_MMC_BASIC);
127 /* send the command out on the wire */
128 @@ -620,8 +647,9 @@ done:
130 mmc_request_done(host->mmc, cmd->mrq);
132 - /* stop the clock to card */
133 - __glamo_mci_fix_card_div(host, -1);
135 + /* stop the clock to card */
136 + __glamo_mci_fix_card_div(host, -1);
139 static void glamo_mci_request(struct mmc_host *mmc, struct mmc_request *mrq)
140 @@ -687,8 +715,9 @@ static void glamo_mci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
141 host->real_rate = __glamo_mci_set_card_clock(host, ios->clock, &div);
144 - /* stop the clock to card, because we are idle until transfer */
145 - __glamo_mci_fix_card_div(host, -1);
147 + /* stop the clock to card, because we are idle until transfer */
148 + __glamo_mci_fix_card_div(host, -1);
150 if ((ios->power_mode == MMC_POWER_ON) ||
151 (ios->power_mode == MMC_POWER_UP)) {
152 @@ -705,8 +734,10 @@ static void glamo_mci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
153 if (host->bus_width == MMC_BUS_WIDTH_4)
154 n = GLAMO_BASIC_MMC_EN_4BIT_DATA;
155 writew_dly((readw_dly(host->base + GLAMO_REG_MMC_BASIC) &
156 - (~GLAMO_BASIC_MMC_EN_4BIT_DATA)) | n,
157 - host->base + GLAMO_REG_MMC_BASIC);
158 + (~(GLAMO_BASIC_MMC_EN_4BIT_DATA |
159 + GLAMO_BASIC_MMC_EN_DR_STR0 |
160 + GLAMO_BASIC_MMC_EN_DR_STR1))) | n |
161 + sd_drive << 6, host->base + GLAMO_REG_MMC_BASIC);