changed Makefile and profiles, added patches for kernel 2.6.24
[openwrt.git] / target / linux / s3c24xx / patches-2.6.24 / 1240-debug-add-glamo-drive-strength-module-param.patch.patch
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>
6
7 This patch allows users to control two additional settings
8 in Glamo MCI driver from kernel commandline or module
9 parameters.
10
11
12 First is Glamo drive strength on SD IOs including CLK.
13 This ranges from 0 (weakest) to 3 (strongest).
14
15 echo 0 > /sys/module/glamo_mci/parameters/sd_drive
16
17 (Changes to this take effect on next SD Card transaction)
18
19 or, from kernel commandline
20
21 glamo_mci.sd_drive=0
22
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.
27
28
29 Second is whether we allow SD_CLK when the SD interface
30 is idle.
31
32 # stop the clock when we are idle (default)
33 echo 0 > /sys/module/glamo_mci/parameters/sd_idleclk
34
35 # run the SD clock all the time
36 echo 1 > /sys/module/glamo_mci/parameters/sd_idleclk
37
38 (changes take effect on next SD Card transaction)
39
40 From kernel commandline, eg:
41
42 glamo_mci.sd_idleclk=1
43
44 Normally you don't want to run the SD Clock all the time.
45
46
47 Signed-off-by: Andy Green <andy@openmoko.com>
48 ---
49  drivers/mfd/glamo/glamo-mci.c |   59 +++++++++++++++++++++++++++++++---------
50  1 files changed, 45 insertions(+), 14 deletions(-)
51
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);
59  
60 +/*
61 + * SD Signal drive strength
62 + *
63 + * you can override this on kernel commandline using
64 + *
65 + *   glamo_mci.sd_drive=0
66 + *
67 + * for example
68 + */
69 +
70 +static int sd_drive = 2;
71 +module_param(sd_drive, int, 0644);
72 +
73 +/*
74 + * SD allow SD clock to run while idle
75 + *
76 + * you can override this on kernel commandline using
77 + *
78 + *   glamo_mci.sd_idleclk=0
79 + *
80 + * for example
81 + */
82 +
83 +static int sd_idleclk = 0; /* disallow idle clock by default */
84 +module_param(sd_idleclk, int, 0644);
85 +
86  
87  
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,
90                 if (division)
91                         *division = 0xff;
92  
93 -               __glamo_mci_fix_card_div(host, -1); /* clock off */
94 +               if (!sd_idleclk)
95 +                       /* clock off */
96 +                       __glamo_mci_fix_card_div(host, -1);
97         }
98  
99         return real_rate;
100 @@ -294,8 +322,9 @@ static void glamo_mci_irq(unsigned int irq, struct irq_desc *desc)
101                 host->cmd_is_stop = 0;
102         }
103  
104 -       /* clock off */
105 -       __glamo_mci_fix_card_div(host, -1);
106 +       if (!sd_idleclk)
107 +               /* clock off */
108 +               __glamo_mci_fix_card_div(host, -1);
109  
110  done:
111         host->complete_what = COMPLETION_NONE;
112 @@ -428,12 +457,10 @@ static int glamo_mci_send_command(struct glamo_mci_host *host,
113         } else
114                 writew(0xfff, host->base + GLAMO_REG_MMC_TIMEOUT);
115  
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);
126  
127         /* send the command out on the wire */
128 @@ -620,8 +647,9 @@ done:
129         host->mrq = NULL;
130         mmc_request_done(host->mmc, cmd->mrq);
131  bail:
132 -       /* stop the clock to card */
133 -       __glamo_mci_fix_card_div(host, -1);
134 +       if (!sd_idleclk)
135 +               /* stop the clock to card */
136 +               __glamo_mci_fix_card_div(host, -1);
137  }
138  
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);
142         host->clk_div = div;
143  
144 -       /* stop the clock to card, because we are idle until transfer */
145 -       __glamo_mci_fix_card_div(host, -1);
146 +       if (!sd_idleclk)
147 +               /* stop the clock to card, because we are idle until transfer */
148 +               __glamo_mci_fix_card_div(host, -1);
149  
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);
162  }
163  
164  
165 -- 
166 1.5.6.5
167