brcm2708: update 3.10 patches with raspberrypi/rpi-3.10.y of 27 Apr. 2014
[openwrt/svn-archive/archive.git] / target / linux / brcm2708 / patches-3.10 / 0020-Add-sync_after_dma-module-parameter.patch
1 From a30b981976f90774867ec2a60bac86ebe7244d9a Mon Sep 17 00:00:00 2001
2 From: popcornmix <popcornmix@gmail.com>
3 Date: Tue, 17 Jul 2012 00:48:27 +0100
4 Subject: [PATCH 020/196] Add sync_after_dma module parameter
5
6 ---
7 drivers/mmc/host/sdhci-bcm2708.c | 60 +++++++++++++++++++++-------------------
8 1 file changed, 32 insertions(+), 28 deletions(-)
9
10 diff --git a/drivers/mmc/host/sdhci-bcm2708.c b/drivers/mmc/host/sdhci-bcm2708.c
11 index 7bba950..3792b9f 100644
12 --- a/drivers/mmc/host/sdhci-bcm2708.c
13 +++ b/drivers/mmc/host/sdhci-bcm2708.c
14 @@ -51,7 +51,6 @@
15 #undef CONFIG_MMC_SDHCI_BCM2708_DMA
16 #define CONFIG_MMC_SDHCI_BCM2708_DMA y
17
18 -#define USE_SYNC_AFTER_DMA
19 #ifdef CONFIG_MMC_SDHCI_BCM2708_DMA
20 /* #define CHECK_DMA_USE */
21 #endif
22 @@ -131,6 +130,7 @@ static inline unsigned long int since_ns(hptime_t t)
23
24 static bool allow_highspeed = 1;
25 static int emmc_clock_freq = BCM2708_EMMC_CLOCK_FREQ;
26 +static bool sync_after_dma = 1;
27
28 #if 0
29 static void hptime_test(void)
30 @@ -822,34 +822,34 @@ static void sdhci_bcm2708_dma_complete_irq(struct sdhci_host *host,
31 SDHCI_INT_SPACE_AVAIL);
32 }
33 } else {
34 -#ifdef USE_SYNC_AFTER_DMA
35 - /* On the Arasan controller the stop command (which will be
36 - scheduled after this completes) does not seem to work
37 - properly if we allow it to be issued when we are
38 - transferring data to/from the SD card.
39 - We get CRC and DEND errors unless we wait for
40 - the SD controller to finish reading/writing to the card. */
41 - u32 state_mask;
42 - int timeout=5000;
43 -
44 - DBG("PDMA over - sync card\n");
45 - if (data->flags & MMC_DATA_READ)
46 - state_mask = SDHCI_DOING_READ;
47 - else
48 - state_mask = SDHCI_DOING_WRITE;
49 + if (sync_after_dma) {
50 + /* On the Arasan controller the stop command (which will be
51 + scheduled after this completes) does not seem to work
52 + properly if we allow it to be issued when we are
53 + transferring data to/from the SD card.
54 + We get CRC and DEND errors unless we wait for
55 + the SD controller to finish reading/writing to the card. */
56 + u32 state_mask;
57 + int timeout=30*5000;
58 +
59 + DBG("PDMA over - sync card\n");
60 + if (data->flags & MMC_DATA_READ)
61 + state_mask = SDHCI_DOING_READ;
62 + else
63 + state_mask = SDHCI_DOING_WRITE;
64
65 - while (0 != (sdhci_bcm2708_raw_readl(host, SDHCI_PRESENT_STATE)
66 - & state_mask) && --timeout > 0)
67 - {
68 - udelay(30);
69 - continue;
70 + while (0 != (sdhci_bcm2708_raw_readl(host, SDHCI_PRESENT_STATE)
71 + & state_mask) && --timeout > 0)
72 + {
73 + udelay(1);
74 + continue;
75 + }
76 + if (timeout <= 0)
77 + printk(KERN_ERR"%s: final %s to SD card still "
78 + "running\n",
79 + mmc_hostname(host->mmc),
80 + data->flags & MMC_DATA_READ? "read": "write");
81 }
82 - if (timeout <= 0)
83 - printk(KERN_ERR"%s: final %s to SD card still "
84 - "running\n",
85 - mmc_hostname(host->mmc),
86 - data->flags & MMC_DATA_READ? "read": "write");
87 -#endif
88 if (host_priv->complete) {
89 (*host_priv->complete)(host);
90 DBG("PDMA %s complete\n",
91 @@ -1193,7 +1193,9 @@ static int sdhci_bcm2708_probe(struct platform_device *pdev)
92 SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK |
93 SDHCI_QUIRK_BROKEN_TIMEOUT_VAL |
94 SDHCI_QUIRK_MISSING_CAPS |
95 - SDHCI_QUIRK_NO_HISPD_BIT;
96 + SDHCI_QUIRK_NO_HISPD_BIT |
97 + (sync_after_dma ? 0:SDHCI_QUIRK_MULTIBLOCK_READ_ACMD12);
98 +
99
100 #ifdef CONFIG_MMC_SDHCI_BCM2708_DMA
101 host->flags = SDHCI_USE_PLATDMA;
102 @@ -1363,6 +1365,7 @@ module_exit(sdhci_drv_exit);
103
104 module_param(allow_highspeed, bool, 0444);
105 module_param(emmc_clock_freq, int, 0444);
106 +module_param(sync_after_dma, bool, 0444);
107
108 MODULE_DESCRIPTION("Secure Digital Host Controller Interface platform driver");
109 MODULE_AUTHOR("Broadcom <info@broadcom.com>");
110 @@ -1371,5 +1374,6 @@ MODULE_ALIAS("platform:"DRIVER_NAME);
111
112 MODULE_PARM_DESC(allow_highspeed, "Allow high speed transfers modes");
113 MODULE_PARM_DESC(emmc_clock_freq, "Specify the speed of emmc clock");
114 +MODULE_PARM_DESC(sync_after_dma, "Block in driver until dma complete");
115
116
117 --
118 1.9.1
119