[ar71xx] preliminary support for the Ubiquiti RouterStation Pro
[openwrt.git] / target / linux / s3c24xx / patches-2.6.24 / 1246-fix-glamo-mci-possible-timeout-overflow.patch.patch
1 From 87ffb9bd9691230e919a306979217e572fd02690 Mon Sep 17 00:00:00 2001
2 From: Andy Green <andy@openmoko.com>
3 Date: Thu, 24 Jul 2008 00:04:44 +0100
4 Subject: [PATCH] fix-glamo-mci-possible-timeout-overflow.patch
5
6 The MMC stack hands us a timeout calibrated in SD_CLK clocks, but the
7 Glamo can only deal with up to 65520 clocks of timeout. If the stack
8 handed us a request bigger than this, it would just wrap and the
9 timeout we actually used would be way too short.
10
11 With this patch if that happens, we use the longest timeout we can,
12 65520 clocks and give it our best shot.
13
14 Signed-off-by: Andy Green <andy@openmoko.com>
15 ---
16 drivers/mfd/glamo/glamo-mci.c | 19 ++++++++++---------
17 1 files changed, 10 insertions(+), 9 deletions(-)
18
19 diff --git a/drivers/mfd/glamo/glamo-mci.c b/drivers/mfd/glamo/glamo-mci.c
20 index 45b0afc..264a6bc 100644
21 --- a/drivers/mfd/glamo/glamo-mci.c
22 +++ b/drivers/mfd/glamo/glamo-mci.c
23 @@ -338,6 +338,7 @@ static int glamo_mci_send_command(struct glamo_mci_host *host,
24 {
25 u8 u8a[6];
26 u16 fire = 0;
27 + u16 timeout = 0xfff; /* max glamo MMC timeout, in units of 16 clocks */
28
29 /* if we can't do it, reject as busy */
30 if (!readw_dly(host->base + GLAMO_REG_MMC_RB_STAT1) &
31 @@ -447,15 +448,15 @@ static int glamo_mci_send_command(struct glamo_mci_host *host,
32 fire |= GLAMO_FIRE_MMC_CC_BASIC; /* "basic command" */
33 break;
34 }
35 - /* enforce timeout */
36 - if (cmd->data) {
37 - if (cmd->data->timeout_clks)
38 - writew_dly(cmd->data->timeout_clks >> 4, /* / 16 clks */
39 - host->base + GLAMO_REG_MMC_TIMEOUT);
40 - else
41 - writew_dly(0xfff, host->base + GLAMO_REG_MMC_TIMEOUT);
42 - } else
43 - writew(0xfff, host->base + GLAMO_REG_MMC_TIMEOUT);
44 + /* enforce timeout, clipping at default 65520 clocks if larger */
45 + if (cmd->data)
46 + /* so long as there is one... */
47 + if (cmd->data->timeout_clks &&
48 + /* ... and it is not longer than we can handle */
49 + (cmd->data->timeout_clks <= 0xffff))
50 + timeout = cmd->data->timeout_clks >> 4; /* / 16 clks */
51 +
52 + writew(timeout, host->base + GLAMO_REG_MMC_TIMEOUT);
53
54 /* Generate interrupt on txfer */
55 writew_dly((readw_dly(host->base + GLAMO_REG_MMC_BASIC) & 0x3e) |
56 --
57 1.5.6.5
58
This page took 0.048255 seconds and 5 git commands to generate.