diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-01-07 17:50:14 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-01-07 17:50:14 -0500 |
commit | d074b104cefcb6e8ded55a53e62fed59a246f55d (patch) | |
tree | 8c5b3a3992c5abab8b41b6e1f2837bc46f82b207 /drivers | |
parent | 31b6ca0af758a88e5e769b48cc6dde037ee37b96 (diff) | |
parent | c413521eb4e2d7ffd5ce432a144708d479054bd3 (diff) |
Merge branch 'rmobile-latest' of git://git.kernel.org/pub/scm/linux/kernel/git/lethal/sh-2.6
* 'rmobile-latest' of git://git.kernel.org/pub/scm/linux/kernel/git/lethal/sh-2.6: (67 commits)
ARM: mach-shmobile: update for SMP changes.
ARM: mach-shmobile: update for GIC changes.
ARM: mach-shmobile: Fix up clkdev fallout for SH73A0.
dma: shdma: don't register the global die notifier multiple times
ARM: mach-shmobile: Rely on run-time IRQ handlers
ARM: mach-shmobile: Run-time IRQ handler for GIC
ARM: mach-shmobile: Run-time IRQ handler for INTCA
ARM: mach-shmobile: Enable CONFIG_MULTI_IRQ_HANDLER
ARM: mach-shmobile: Use shared GIC entry macros
ARM: mach-shmobile: mackerel: Add zboot support
ARM: mach-shmobile: mackerel: Add HDMI sound support
ARM: mach-shmobile: mackerel: add HDMI video support
ARM: mach-shmobile: ap4evb: fixup clk_put timing of fsib_clk
ARM: mach-shmobile: sh73a0: fix div4 table
ARM: mach-shmobile: ap4/mackerel: modify wrong comment out of USB
ARM: mach-shmobile: Mackerel VGA camera support
mmc: sh_mmcif: make DMA support by the driver unconditional
ARM: mach-shmobile: Add eMMC support through MMCIF on AG5EVM
ARM: mach-shmobile: Use pullups for AG5EVM KEYSC pins
ARM: mach-shmobile: sh73a0 GPIO pullup improvement
...
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/dma/shdma.c | 16 | ||||
-rw-r--r-- | drivers/mmc/host/sh_mmcif.c | 429 | ||||
-rw-r--r-- | drivers/serial/sh-sci.h | 7 |
3 files changed, 311 insertions, 141 deletions
diff --git a/drivers/dma/shdma.c b/drivers/dma/shdma.c index a0069c171518..28720d3103c4 100644 --- a/drivers/dma/shdma.c +++ b/drivers/dma/shdma.c | |||
@@ -1110,11 +1110,6 @@ static int __init sh_dmae_probe(struct platform_device *pdev) | |||
1110 | list_add_tail_rcu(&shdev->node, &sh_dmae_devices); | 1110 | list_add_tail_rcu(&shdev->node, &sh_dmae_devices); |
1111 | spin_unlock_irqrestore(&sh_dmae_lock, flags); | 1111 | spin_unlock_irqrestore(&sh_dmae_lock, flags); |
1112 | 1112 | ||
1113 | /* Wire up NMI handling before bringing the controller online */ | ||
1114 | err = register_die_notifier(&sh_dmae_nmi_notifier); | ||
1115 | if (err) | ||
1116 | goto notifier_err; | ||
1117 | |||
1118 | /* reset dma controller */ | 1113 | /* reset dma controller */ |
1119 | err = sh_dmae_rst(shdev); | 1114 | err = sh_dmae_rst(shdev); |
1120 | if (err) | 1115 | if (err) |
@@ -1218,8 +1213,6 @@ eirqres: | |||
1218 | eirq_err: | 1213 | eirq_err: |
1219 | #endif | 1214 | #endif |
1220 | rst_err: | 1215 | rst_err: |
1221 | unregister_die_notifier(&sh_dmae_nmi_notifier); | ||
1222 | notifier_err: | ||
1223 | spin_lock_irqsave(&sh_dmae_lock, flags); | 1216 | spin_lock_irqsave(&sh_dmae_lock, flags); |
1224 | list_del_rcu(&shdev->node); | 1217 | list_del_rcu(&shdev->node); |
1225 | spin_unlock_irqrestore(&sh_dmae_lock, flags); | 1218 | spin_unlock_irqrestore(&sh_dmae_lock, flags); |
@@ -1252,8 +1245,6 @@ static int __exit sh_dmae_remove(struct platform_device *pdev) | |||
1252 | if (errirq > 0) | 1245 | if (errirq > 0) |
1253 | free_irq(errirq, shdev); | 1246 | free_irq(errirq, shdev); |
1254 | 1247 | ||
1255 | unregister_die_notifier(&sh_dmae_nmi_notifier); | ||
1256 | |||
1257 | spin_lock_irqsave(&sh_dmae_lock, flags); | 1248 | spin_lock_irqsave(&sh_dmae_lock, flags); |
1258 | list_del_rcu(&shdev->node); | 1249 | list_del_rcu(&shdev->node); |
1259 | spin_unlock_irqrestore(&sh_dmae_lock, flags); | 1250 | spin_unlock_irqrestore(&sh_dmae_lock, flags); |
@@ -1296,6 +1287,11 @@ static struct platform_driver sh_dmae_driver = { | |||
1296 | 1287 | ||
1297 | static int __init sh_dmae_init(void) | 1288 | static int __init sh_dmae_init(void) |
1298 | { | 1289 | { |
1290 | /* Wire up NMI handling */ | ||
1291 | int err = register_die_notifier(&sh_dmae_nmi_notifier); | ||
1292 | if (err) | ||
1293 | return err; | ||
1294 | |||
1299 | return platform_driver_probe(&sh_dmae_driver, sh_dmae_probe); | 1295 | return platform_driver_probe(&sh_dmae_driver, sh_dmae_probe); |
1300 | } | 1296 | } |
1301 | module_init(sh_dmae_init); | 1297 | module_init(sh_dmae_init); |
@@ -1303,6 +1299,8 @@ module_init(sh_dmae_init); | |||
1303 | static void __exit sh_dmae_exit(void) | 1299 | static void __exit sh_dmae_exit(void) |
1304 | { | 1300 | { |
1305 | platform_driver_unregister(&sh_dmae_driver); | 1301 | platform_driver_unregister(&sh_dmae_driver); |
1302 | |||
1303 | unregister_die_notifier(&sh_dmae_nmi_notifier); | ||
1306 | } | 1304 | } |
1307 | module_exit(sh_dmae_exit); | 1305 | module_exit(sh_dmae_exit); |
1308 | 1306 | ||
diff --git a/drivers/mmc/host/sh_mmcif.c b/drivers/mmc/host/sh_mmcif.c index ddd09840520b..12884c270171 100644 --- a/drivers/mmc/host/sh_mmcif.c +++ b/drivers/mmc/host/sh_mmcif.c | |||
@@ -16,16 +16,19 @@ | |||
16 | * | 16 | * |
17 | */ | 17 | */ |
18 | 18 | ||
19 | #include <linux/clk.h> | ||
20 | #include <linux/completion.h> | ||
21 | #include <linux/delay.h> | ||
19 | #include <linux/dma-mapping.h> | 22 | #include <linux/dma-mapping.h> |
20 | #include <linux/mmc/host.h> | 23 | #include <linux/dmaengine.h> |
21 | #include <linux/mmc/card.h> | 24 | #include <linux/mmc/card.h> |
22 | #include <linux/mmc/core.h> | 25 | #include <linux/mmc/core.h> |
26 | #include <linux/mmc/host.h> | ||
23 | #include <linux/mmc/mmc.h> | 27 | #include <linux/mmc/mmc.h> |
24 | #include <linux/mmc/sdio.h> | 28 | #include <linux/mmc/sdio.h> |
25 | #include <linux/delay.h> | ||
26 | #include <linux/platform_device.h> | ||
27 | #include <linux/clk.h> | ||
28 | #include <linux/mmc/sh_mmcif.h> | 29 | #include <linux/mmc/sh_mmcif.h> |
30 | #include <linux/pagemap.h> | ||
31 | #include <linux/platform_device.h> | ||
29 | 32 | ||
30 | #define DRIVER_NAME "sh_mmcif" | 33 | #define DRIVER_NAME "sh_mmcif" |
31 | #define DRIVER_VERSION "2010-04-28" | 34 | #define DRIVER_VERSION "2010-04-28" |
@@ -62,25 +65,6 @@ | |||
62 | /* CE_BLOCK_SET */ | 65 | /* CE_BLOCK_SET */ |
63 | #define BLOCK_SIZE_MASK 0x0000ffff | 66 | #define BLOCK_SIZE_MASK 0x0000ffff |
64 | 67 | ||
65 | /* CE_CLK_CTRL */ | ||
66 | #define CLK_ENABLE (1 << 24) /* 1: output mmc clock */ | ||
67 | #define CLK_CLEAR ((1 << 19) | (1 << 18) | (1 << 17) | (1 << 16)) | ||
68 | #define CLK_SUP_PCLK ((1 << 19) | (1 << 18) | (1 << 17) | (1 << 16)) | ||
69 | #define SRSPTO_256 ((1 << 13) | (0 << 12)) /* resp timeout */ | ||
70 | #define SRBSYTO_29 ((1 << 11) | (1 << 10) | \ | ||
71 | (1 << 9) | (1 << 8)) /* resp busy timeout */ | ||
72 | #define SRWDTO_29 ((1 << 7) | (1 << 6) | \ | ||
73 | (1 << 5) | (1 << 4)) /* read/write timeout */ | ||
74 | #define SCCSTO_29 ((1 << 3) | (1 << 2) | \ | ||
75 | (1 << 1) | (1 << 0)) /* ccs timeout */ | ||
76 | |||
77 | /* CE_BUF_ACC */ | ||
78 | #define BUF_ACC_DMAWEN (1 << 25) | ||
79 | #define BUF_ACC_DMAREN (1 << 24) | ||
80 | #define BUF_ACC_BUSW_32 (0 << 17) | ||
81 | #define BUF_ACC_BUSW_16 (1 << 17) | ||
82 | #define BUF_ACC_ATYP (1 << 16) | ||
83 | |||
84 | /* CE_INT */ | 68 | /* CE_INT */ |
85 | #define INT_CCSDE (1 << 29) | 69 | #define INT_CCSDE (1 << 29) |
86 | #define INT_CMD12DRE (1 << 26) | 70 | #define INT_CMD12DRE (1 << 26) |
@@ -165,10 +149,6 @@ | |||
165 | STS2_AC12BSYTO | STS2_RSPBSYTO | \ | 149 | STS2_AC12BSYTO | STS2_RSPBSYTO | \ |
166 | STS2_AC12RSPTO | STS2_RSPTO) | 150 | STS2_AC12RSPTO | STS2_RSPTO) |
167 | 151 | ||
168 | /* CE_VERSION */ | ||
169 | #define SOFT_RST_ON (1 << 31) | ||
170 | #define SOFT_RST_OFF (0 << 31) | ||
171 | |||
172 | #define CLKDEV_EMMC_DATA 52000000 /* 52MHz */ | 152 | #define CLKDEV_EMMC_DATA 52000000 /* 52MHz */ |
173 | #define CLKDEV_MMC_DATA 20000000 /* 20MHz */ | 153 | #define CLKDEV_MMC_DATA 20000000 /* 20MHz */ |
174 | #define CLKDEV_INIT 400000 /* 400 KHz */ | 154 | #define CLKDEV_INIT 400000 /* 400 KHz */ |
@@ -176,18 +156,21 @@ | |||
176 | struct sh_mmcif_host { | 156 | struct sh_mmcif_host { |
177 | struct mmc_host *mmc; | 157 | struct mmc_host *mmc; |
178 | struct mmc_data *data; | 158 | struct mmc_data *data; |
179 | struct mmc_command *cmd; | ||
180 | struct platform_device *pd; | 159 | struct platform_device *pd; |
181 | struct clk *hclk; | 160 | struct clk *hclk; |
182 | unsigned int clk; | 161 | unsigned int clk; |
183 | int bus_width; | 162 | int bus_width; |
184 | u16 wait_int; | 163 | bool sd_error; |
185 | u16 sd_error; | ||
186 | long timeout; | 164 | long timeout; |
187 | void __iomem *addr; | 165 | void __iomem *addr; |
188 | wait_queue_head_t intr_wait; | 166 | struct completion intr_wait; |
189 | }; | ||
190 | 167 | ||
168 | /* DMA support */ | ||
169 | struct dma_chan *chan_rx; | ||
170 | struct dma_chan *chan_tx; | ||
171 | struct completion dma_complete; | ||
172 | unsigned int dma_sglen; | ||
173 | }; | ||
191 | 174 | ||
192 | static inline void sh_mmcif_bitset(struct sh_mmcif_host *host, | 175 | static inline void sh_mmcif_bitset(struct sh_mmcif_host *host, |
193 | unsigned int reg, u32 val) | 176 | unsigned int reg, u32 val) |
@@ -201,6 +184,188 @@ static inline void sh_mmcif_bitclr(struct sh_mmcif_host *host, | |||
201 | writel(~val & readl(host->addr + reg), host->addr + reg); | 184 | writel(~val & readl(host->addr + reg), host->addr + reg); |
202 | } | 185 | } |
203 | 186 | ||
187 | static void mmcif_dma_complete(void *arg) | ||
188 | { | ||
189 | struct sh_mmcif_host *host = arg; | ||
190 | dev_dbg(&host->pd->dev, "Command completed\n"); | ||
191 | |||
192 | if (WARN(!host->data, "%s: NULL data in DMA completion!\n", | ||
193 | dev_name(&host->pd->dev))) | ||
194 | return; | ||
195 | |||
196 | if (host->data->flags & MMC_DATA_READ) | ||
197 | dma_unmap_sg(&host->pd->dev, host->data->sg, host->dma_sglen, | ||
198 | DMA_FROM_DEVICE); | ||
199 | else | ||
200 | dma_unmap_sg(&host->pd->dev, host->data->sg, host->dma_sglen, | ||
201 | DMA_TO_DEVICE); | ||
202 | |||
203 | complete(&host->dma_complete); | ||
204 | } | ||
205 | |||
206 | static void sh_mmcif_start_dma_rx(struct sh_mmcif_host *host) | ||
207 | { | ||
208 | struct scatterlist *sg = host->data->sg; | ||
209 | struct dma_async_tx_descriptor *desc = NULL; | ||
210 | struct dma_chan *chan = host->chan_rx; | ||
211 | dma_cookie_t cookie = -EINVAL; | ||
212 | int ret; | ||
213 | |||
214 | ret = dma_map_sg(&host->pd->dev, sg, host->data->sg_len, DMA_FROM_DEVICE); | ||
215 | if (ret > 0) { | ||
216 | host->dma_sglen = ret; | ||
217 | desc = chan->device->device_prep_slave_sg(chan, sg, ret, | ||
218 | DMA_FROM_DEVICE, DMA_PREP_INTERRUPT | DMA_CTRL_ACK); | ||
219 | } | ||
220 | |||
221 | if (desc) { | ||
222 | desc->callback = mmcif_dma_complete; | ||
223 | desc->callback_param = host; | ||
224 | cookie = desc->tx_submit(desc); | ||
225 | if (cookie < 0) { | ||
226 | desc = NULL; | ||
227 | ret = cookie; | ||
228 | } else { | ||
229 | sh_mmcif_bitset(host, MMCIF_CE_BUF_ACC, BUF_ACC_DMAREN); | ||
230 | chan->device->device_issue_pending(chan); | ||
231 | } | ||
232 | } | ||
233 | dev_dbg(&host->pd->dev, "%s(): mapped %d -> %d, cookie %d\n", | ||
234 | __func__, host->data->sg_len, ret, cookie); | ||
235 | |||
236 | if (!desc) { | ||
237 | /* DMA failed, fall back to PIO */ | ||
238 | if (ret >= 0) | ||
239 | ret = -EIO; | ||
240 | host->chan_rx = NULL; | ||
241 | host->dma_sglen = 0; | ||
242 | dma_release_channel(chan); | ||
243 | /* Free the Tx channel too */ | ||
244 | chan = host->chan_tx; | ||
245 | if (chan) { | ||
246 | host->chan_tx = NULL; | ||
247 | dma_release_channel(chan); | ||
248 | } | ||
249 | dev_warn(&host->pd->dev, | ||
250 | "DMA failed: %d, falling back to PIO\n", ret); | ||
251 | sh_mmcif_bitclr(host, MMCIF_CE_BUF_ACC, BUF_ACC_DMAREN | BUF_ACC_DMAWEN); | ||
252 | } | ||
253 | |||
254 | dev_dbg(&host->pd->dev, "%s(): desc %p, cookie %d, sg[%d]\n", __func__, | ||
255 | desc, cookie, host->data->sg_len); | ||
256 | } | ||
257 | |||
258 | static void sh_mmcif_start_dma_tx(struct sh_mmcif_host *host) | ||
259 | { | ||
260 | struct scatterlist *sg = host->data->sg; | ||
261 | struct dma_async_tx_descriptor *desc = NULL; | ||
262 | struct dma_chan *chan = host->chan_tx; | ||
263 | dma_cookie_t cookie = -EINVAL; | ||
264 | int ret; | ||
265 | |||
266 | ret = dma_map_sg(&host->pd->dev, sg, host->data->sg_len, DMA_TO_DEVICE); | ||
267 | if (ret > 0) { | ||
268 | host->dma_sglen = ret; | ||
269 | desc = chan->device->device_prep_slave_sg(chan, sg, ret, | ||
270 | DMA_TO_DEVICE, DMA_PREP_INTERRUPT | DMA_CTRL_ACK); | ||
271 | } | ||
272 | |||
273 | if (desc) { | ||
274 | desc->callback = mmcif_dma_complete; | ||
275 | desc->callback_param = host; | ||
276 | cookie = desc->tx_submit(desc); | ||
277 | if (cookie < 0) { | ||
278 | desc = NULL; | ||
279 | ret = cookie; | ||
280 | } else { | ||
281 | sh_mmcif_bitset(host, MMCIF_CE_BUF_ACC, BUF_ACC_DMAWEN); | ||
282 | chan->device->device_issue_pending(chan); | ||
283 | } | ||
284 | } | ||
285 | dev_dbg(&host->pd->dev, "%s(): mapped %d -> %d, cookie %d\n", | ||
286 | __func__, host->data->sg_len, ret, cookie); | ||
287 | |||
288 | if (!desc) { | ||
289 | /* DMA failed, fall back to PIO */ | ||
290 | if (ret >= 0) | ||
291 | ret = -EIO; | ||
292 | host->chan_tx = NULL; | ||
293 | host->dma_sglen = 0; | ||
294 | dma_release_channel(chan); | ||
295 | /* Free the Rx channel too */ | ||
296 | chan = host->chan_rx; | ||
297 | if (chan) { | ||
298 | host->chan_rx = NULL; | ||
299 | dma_release_channel(chan); | ||
300 | } | ||
301 | dev_warn(&host->pd->dev, | ||
302 | "DMA failed: %d, falling back to PIO\n", ret); | ||
303 | sh_mmcif_bitclr(host, MMCIF_CE_BUF_ACC, BUF_ACC_DMAREN | BUF_ACC_DMAWEN); | ||
304 | } | ||
305 | |||
306 | dev_dbg(&host->pd->dev, "%s(): desc %p, cookie %d\n", __func__, | ||
307 | desc, cookie); | ||
308 | } | ||
309 | |||
310 | static bool sh_mmcif_filter(struct dma_chan *chan, void *arg) | ||
311 | { | ||
312 | dev_dbg(chan->device->dev, "%s: slave data %p\n", __func__, arg); | ||
313 | chan->private = arg; | ||
314 | return true; | ||
315 | } | ||
316 | |||
317 | static void sh_mmcif_request_dma(struct sh_mmcif_host *host, | ||
318 | struct sh_mmcif_plat_data *pdata) | ||
319 | { | ||
320 | host->dma_sglen = 0; | ||
321 | |||
322 | /* We can only either use DMA for both Tx and Rx or not use it at all */ | ||
323 | if (pdata->dma) { | ||
324 | dma_cap_mask_t mask; | ||
325 | |||
326 | dma_cap_zero(mask); | ||
327 | dma_cap_set(DMA_SLAVE, mask); | ||
328 | |||
329 | host->chan_tx = dma_request_channel(mask, sh_mmcif_filter, | ||
330 | &pdata->dma->chan_priv_tx); | ||
331 | dev_dbg(&host->pd->dev, "%s: TX: got channel %p\n", __func__, | ||
332 | host->chan_tx); | ||
333 | |||
334 | if (!host->chan_tx) | ||
335 | return; | ||
336 | |||
337 | host->chan_rx = dma_request_channel(mask, sh_mmcif_filter, | ||
338 | &pdata->dma->chan_priv_rx); | ||
339 | dev_dbg(&host->pd->dev, "%s: RX: got channel %p\n", __func__, | ||
340 | host->chan_rx); | ||
341 | |||
342 | if (!host->chan_rx) { | ||
343 | dma_release_channel(host->chan_tx); | ||
344 | host->chan_tx = NULL; | ||
345 | return; | ||
346 | } | ||
347 | |||
348 | init_completion(&host->dma_complete); | ||
349 | } | ||
350 | } | ||
351 | |||
352 | static void sh_mmcif_release_dma(struct sh_mmcif_host *host) | ||
353 | { | ||
354 | sh_mmcif_bitclr(host, MMCIF_CE_BUF_ACC, BUF_ACC_DMAREN | BUF_ACC_DMAWEN); | ||
355 | /* Descriptors are freed automatically */ | ||
356 | if (host->chan_tx) { | ||
357 | struct dma_chan *chan = host->chan_tx; | ||
358 | host->chan_tx = NULL; | ||
359 | dma_release_channel(chan); | ||
360 | } | ||
361 | if (host->chan_rx) { | ||
362 | struct dma_chan *chan = host->chan_rx; | ||
363 | host->chan_rx = NULL; | ||
364 | dma_release_channel(chan); | ||
365 | } | ||
366 | |||
367 | host->dma_sglen = 0; | ||
368 | } | ||
204 | 369 | ||
205 | static void sh_mmcif_clock_control(struct sh_mmcif_host *host, unsigned int clk) | 370 | static void sh_mmcif_clock_control(struct sh_mmcif_host *host, unsigned int clk) |
206 | { | 371 | { |
@@ -239,13 +404,12 @@ static int sh_mmcif_error_manage(struct sh_mmcif_host *host) | |||
239 | u32 state1, state2; | 404 | u32 state1, state2; |
240 | int ret, timeout = 10000000; | 405 | int ret, timeout = 10000000; |
241 | 406 | ||
242 | host->sd_error = 0; | 407 | host->sd_error = false; |
243 | host->wait_int = 0; | ||
244 | 408 | ||
245 | state1 = sh_mmcif_readl(host->addr, MMCIF_CE_HOST_STS1); | 409 | state1 = sh_mmcif_readl(host->addr, MMCIF_CE_HOST_STS1); |
246 | state2 = sh_mmcif_readl(host->addr, MMCIF_CE_HOST_STS2); | 410 | state2 = sh_mmcif_readl(host->addr, MMCIF_CE_HOST_STS2); |
247 | pr_debug("%s: ERR HOST_STS1 = %08x\n", DRIVER_NAME, state1); | 411 | dev_dbg(&host->pd->dev, "ERR HOST_STS1 = %08x\n", state1); |
248 | pr_debug("%s: ERR HOST_STS2 = %08x\n", DRIVER_NAME, state2); | 412 | dev_dbg(&host->pd->dev, "ERR HOST_STS2 = %08x\n", state2); |
249 | 413 | ||
250 | if (state1 & STS1_CMDSEQ) { | 414 | if (state1 & STS1_CMDSEQ) { |
251 | sh_mmcif_bitset(host, MMCIF_CE_CMD_CTRL, CMD_CTRL_BREAK); | 415 | sh_mmcif_bitset(host, MMCIF_CE_CMD_CTRL, CMD_CTRL_BREAK); |
@@ -253,8 +417,8 @@ static int sh_mmcif_error_manage(struct sh_mmcif_host *host) | |||
253 | while (1) { | 417 | while (1) { |
254 | timeout--; | 418 | timeout--; |
255 | if (timeout < 0) { | 419 | if (timeout < 0) { |
256 | pr_err(DRIVER_NAME": Forceed end of " \ | 420 | dev_err(&host->pd->dev, |
257 | "command sequence timeout err\n"); | 421 | "Forceed end of command sequence timeout err\n"); |
258 | return -EIO; | 422 | return -EIO; |
259 | } | 423 | } |
260 | if (!(sh_mmcif_readl(host->addr, MMCIF_CE_HOST_STS1) | 424 | if (!(sh_mmcif_readl(host->addr, MMCIF_CE_HOST_STS1) |
@@ -263,18 +427,18 @@ static int sh_mmcif_error_manage(struct sh_mmcif_host *host) | |||
263 | mdelay(1); | 427 | mdelay(1); |
264 | } | 428 | } |
265 | sh_mmcif_sync_reset(host); | 429 | sh_mmcif_sync_reset(host); |
266 | pr_debug(DRIVER_NAME": Forced end of command sequence\n"); | 430 | dev_dbg(&host->pd->dev, "Forced end of command sequence\n"); |
267 | return -EIO; | 431 | return -EIO; |
268 | } | 432 | } |
269 | 433 | ||
270 | if (state2 & STS2_CRC_ERR) { | 434 | if (state2 & STS2_CRC_ERR) { |
271 | pr_debug(DRIVER_NAME": Happened CRC error\n"); | 435 | dev_dbg(&host->pd->dev, ": Happened CRC error\n"); |
272 | ret = -EIO; | 436 | ret = -EIO; |
273 | } else if (state2 & STS2_TIMEOUT_ERR) { | 437 | } else if (state2 & STS2_TIMEOUT_ERR) { |
274 | pr_debug(DRIVER_NAME": Happened Timeout error\n"); | 438 | dev_dbg(&host->pd->dev, ": Happened Timeout error\n"); |
275 | ret = -ETIMEDOUT; | 439 | ret = -ETIMEDOUT; |
276 | } else { | 440 | } else { |
277 | pr_debug(DRIVER_NAME": Happened End/Index error\n"); | 441 | dev_dbg(&host->pd->dev, ": Happened End/Index error\n"); |
278 | ret = -EIO; | 442 | ret = -EIO; |
279 | } | 443 | } |
280 | return ret; | 444 | return ret; |
@@ -287,17 +451,13 @@ static int sh_mmcif_single_read(struct sh_mmcif_host *host, | |||
287 | long time; | 451 | long time; |
288 | u32 blocksize, i, *p = sg_virt(data->sg); | 452 | u32 blocksize, i, *p = sg_virt(data->sg); |
289 | 453 | ||
290 | host->wait_int = 0; | ||
291 | |||
292 | /* buf read enable */ | 454 | /* buf read enable */ |
293 | sh_mmcif_bitset(host, MMCIF_CE_INT_MASK, MASK_MBUFREN); | 455 | sh_mmcif_bitset(host, MMCIF_CE_INT_MASK, MASK_MBUFREN); |
294 | time = wait_event_interruptible_timeout(host->intr_wait, | 456 | time = wait_for_completion_interruptible_timeout(&host->intr_wait, |
295 | host->wait_int == 1 || | 457 | host->timeout); |
296 | host->sd_error == 1, host->timeout); | 458 | if (time <= 0 || host->sd_error) |
297 | if (host->wait_int != 1 && (time == 0 || host->sd_error != 0)) | ||
298 | return sh_mmcif_error_manage(host); | 459 | return sh_mmcif_error_manage(host); |
299 | 460 | ||
300 | host->wait_int = 0; | ||
301 | blocksize = (BLOCK_SIZE_MASK & | 461 | blocksize = (BLOCK_SIZE_MASK & |
302 | sh_mmcif_readl(host->addr, MMCIF_CE_BLOCK_SET)) + 3; | 462 | sh_mmcif_readl(host->addr, MMCIF_CE_BLOCK_SET)) + 3; |
303 | for (i = 0; i < blocksize / 4; i++) | 463 | for (i = 0; i < blocksize / 4; i++) |
@@ -305,13 +465,11 @@ static int sh_mmcif_single_read(struct sh_mmcif_host *host, | |||
305 | 465 | ||
306 | /* buffer read end */ | 466 | /* buffer read end */ |
307 | sh_mmcif_bitset(host, MMCIF_CE_INT_MASK, MASK_MBUFRE); | 467 | sh_mmcif_bitset(host, MMCIF_CE_INT_MASK, MASK_MBUFRE); |
308 | time = wait_event_interruptible_timeout(host->intr_wait, | 468 | time = wait_for_completion_interruptible_timeout(&host->intr_wait, |
309 | host->wait_int == 1 || | 469 | host->timeout); |
310 | host->sd_error == 1, host->timeout); | 470 | if (time <= 0 || host->sd_error) |
311 | if (host->wait_int != 1 && (time == 0 || host->sd_error != 0)) | ||
312 | return sh_mmcif_error_manage(host); | 471 | return sh_mmcif_error_manage(host); |
313 | 472 | ||
314 | host->wait_int = 0; | ||
315 | return 0; | 473 | return 0; |
316 | } | 474 | } |
317 | 475 | ||
@@ -326,19 +484,15 @@ static int sh_mmcif_multi_read(struct sh_mmcif_host *host, | |||
326 | MMCIF_CE_BLOCK_SET); | 484 | MMCIF_CE_BLOCK_SET); |
327 | for (j = 0; j < data->sg_len; j++) { | 485 | for (j = 0; j < data->sg_len; j++) { |
328 | p = sg_virt(data->sg); | 486 | p = sg_virt(data->sg); |
329 | host->wait_int = 0; | ||
330 | for (sec = 0; sec < data->sg->length / blocksize; sec++) { | 487 | for (sec = 0; sec < data->sg->length / blocksize; sec++) { |
331 | sh_mmcif_bitset(host, MMCIF_CE_INT_MASK, MASK_MBUFREN); | 488 | sh_mmcif_bitset(host, MMCIF_CE_INT_MASK, MASK_MBUFREN); |
332 | /* buf read enable */ | 489 | /* buf read enable */ |
333 | time = wait_event_interruptible_timeout(host->intr_wait, | 490 | time = wait_for_completion_interruptible_timeout(&host->intr_wait, |
334 | host->wait_int == 1 || | 491 | host->timeout); |
335 | host->sd_error == 1, host->timeout); | ||
336 | 492 | ||
337 | if (host->wait_int != 1 && | 493 | if (time <= 0 || host->sd_error) |
338 | (time == 0 || host->sd_error != 0)) | ||
339 | return sh_mmcif_error_manage(host); | 494 | return sh_mmcif_error_manage(host); |
340 | 495 | ||
341 | host->wait_int = 0; | ||
342 | for (i = 0; i < blocksize / 4; i++) | 496 | for (i = 0; i < blocksize / 4; i++) |
343 | *p++ = sh_mmcif_readl(host->addr, | 497 | *p++ = sh_mmcif_readl(host->addr, |
344 | MMCIF_CE_DATA); | 498 | MMCIF_CE_DATA); |
@@ -356,17 +510,14 @@ static int sh_mmcif_single_write(struct sh_mmcif_host *host, | |||
356 | long time; | 510 | long time; |
357 | u32 blocksize, i, *p = sg_virt(data->sg); | 511 | u32 blocksize, i, *p = sg_virt(data->sg); |
358 | 512 | ||
359 | host->wait_int = 0; | ||
360 | sh_mmcif_bitset(host, MMCIF_CE_INT_MASK, MASK_MBUFWEN); | 513 | sh_mmcif_bitset(host, MMCIF_CE_INT_MASK, MASK_MBUFWEN); |
361 | 514 | ||
362 | /* buf write enable */ | 515 | /* buf write enable */ |
363 | time = wait_event_interruptible_timeout(host->intr_wait, | 516 | time = wait_for_completion_interruptible_timeout(&host->intr_wait, |
364 | host->wait_int == 1 || | 517 | host->timeout); |
365 | host->sd_error == 1, host->timeout); | 518 | if (time <= 0 || host->sd_error) |
366 | if (host->wait_int != 1 && (time == 0 || host->sd_error != 0)) | ||
367 | return sh_mmcif_error_manage(host); | 519 | return sh_mmcif_error_manage(host); |
368 | 520 | ||
369 | host->wait_int = 0; | ||
370 | blocksize = (BLOCK_SIZE_MASK & | 521 | blocksize = (BLOCK_SIZE_MASK & |
371 | sh_mmcif_readl(host->addr, MMCIF_CE_BLOCK_SET)) + 3; | 522 | sh_mmcif_readl(host->addr, MMCIF_CE_BLOCK_SET)) + 3; |
372 | for (i = 0; i < blocksize / 4; i++) | 523 | for (i = 0; i < blocksize / 4; i++) |
@@ -375,13 +526,11 @@ static int sh_mmcif_single_write(struct sh_mmcif_host *host, | |||
375 | /* buffer write end */ | 526 | /* buffer write end */ |
376 | sh_mmcif_bitset(host, MMCIF_CE_INT_MASK, MASK_MDTRANE); | 527 | sh_mmcif_bitset(host, MMCIF_CE_INT_MASK, MASK_MDTRANE); |
377 | 528 | ||
378 | time = wait_event_interruptible_timeout(host->intr_wait, | 529 | time = wait_for_completion_interruptible_timeout(&host->intr_wait, |
379 | host->wait_int == 1 || | 530 | host->timeout); |
380 | host->sd_error == 1, host->timeout); | 531 | if (time <= 0 || host->sd_error) |
381 | if (host->wait_int != 1 && (time == 0 || host->sd_error != 0)) | ||
382 | return sh_mmcif_error_manage(host); | 532 | return sh_mmcif_error_manage(host); |
383 | 533 | ||
384 | host->wait_int = 0; | ||
385 | return 0; | 534 | return 0; |
386 | } | 535 | } |
387 | 536 | ||
@@ -397,19 +546,15 @@ static int sh_mmcif_multi_write(struct sh_mmcif_host *host, | |||
397 | 546 | ||
398 | for (j = 0; j < data->sg_len; j++) { | 547 | for (j = 0; j < data->sg_len; j++) { |
399 | p = sg_virt(data->sg); | 548 | p = sg_virt(data->sg); |
400 | host->wait_int = 0; | ||
401 | for (sec = 0; sec < data->sg->length / blocksize; sec++) { | 549 | for (sec = 0; sec < data->sg->length / blocksize; sec++) { |
402 | sh_mmcif_bitset(host, MMCIF_CE_INT_MASK, MASK_MBUFWEN); | 550 | sh_mmcif_bitset(host, MMCIF_CE_INT_MASK, MASK_MBUFWEN); |
403 | /* buf write enable*/ | 551 | /* buf write enable*/ |
404 | time = wait_event_interruptible_timeout(host->intr_wait, | 552 | time = wait_for_completion_interruptible_timeout(&host->intr_wait, |
405 | host->wait_int == 1 || | 553 | host->timeout); |
406 | host->sd_error == 1, host->timeout); | ||
407 | 554 | ||
408 | if (host->wait_int != 1 && | 555 | if (time <= 0 || host->sd_error) |
409 | (time == 0 || host->sd_error != 0)) | ||
410 | return sh_mmcif_error_manage(host); | 556 | return sh_mmcif_error_manage(host); |
411 | 557 | ||
412 | host->wait_int = 0; | ||
413 | for (i = 0; i < blocksize / 4; i++) | 558 | for (i = 0; i < blocksize / 4; i++) |
414 | sh_mmcif_writel(host->addr, | 559 | sh_mmcif_writel(host->addr, |
415 | MMCIF_CE_DATA, *p++); | 560 | MMCIF_CE_DATA, *p++); |
@@ -457,7 +602,7 @@ static u32 sh_mmcif_set_cmd(struct sh_mmcif_host *host, | |||
457 | tmp |= CMD_SET_RTYP_17B; | 602 | tmp |= CMD_SET_RTYP_17B; |
458 | break; | 603 | break; |
459 | default: | 604 | default: |
460 | pr_err(DRIVER_NAME": Not support type response.\n"); | 605 | dev_err(&host->pd->dev, "Unsupported response type.\n"); |
461 | break; | 606 | break; |
462 | } | 607 | } |
463 | switch (opc) { | 608 | switch (opc) { |
@@ -485,7 +630,7 @@ static u32 sh_mmcif_set_cmd(struct sh_mmcif_host *host, | |||
485 | tmp |= CMD_SET_DATW_8; | 630 | tmp |= CMD_SET_DATW_8; |
486 | break; | 631 | break; |
487 | default: | 632 | default: |
488 | pr_err(DRIVER_NAME": Not support bus width.\n"); | 633 | dev_err(&host->pd->dev, "Unsupported bus width.\n"); |
489 | break; | 634 | break; |
490 | } | 635 | } |
491 | } | 636 | } |
@@ -513,10 +658,10 @@ static u32 sh_mmcif_set_cmd(struct sh_mmcif_host *host, | |||
513 | return opc = ((opc << 24) | tmp); | 658 | return opc = ((opc << 24) | tmp); |
514 | } | 659 | } |
515 | 660 | ||
516 | static u32 sh_mmcif_data_trans(struct sh_mmcif_host *host, | 661 | static int sh_mmcif_data_trans(struct sh_mmcif_host *host, |
517 | struct mmc_request *mrq, u32 opc) | 662 | struct mmc_request *mrq, u32 opc) |
518 | { | 663 | { |
519 | u32 ret; | 664 | int ret; |
520 | 665 | ||
521 | switch (opc) { | 666 | switch (opc) { |
522 | case MMC_READ_MULTIPLE_BLOCK: | 667 | case MMC_READ_MULTIPLE_BLOCK: |
@@ -533,7 +678,7 @@ static u32 sh_mmcif_data_trans(struct sh_mmcif_host *host, | |||
533 | ret = sh_mmcif_single_read(host, mrq); | 678 | ret = sh_mmcif_single_read(host, mrq); |
534 | break; | 679 | break; |
535 | default: | 680 | default: |
536 | pr_err(DRIVER_NAME": NOT SUPPORT CMD = d'%08d\n", opc); | 681 | dev_err(&host->pd->dev, "UNSUPPORTED CMD = d'%08d\n", opc); |
537 | ret = -EINVAL; | 682 | ret = -EINVAL; |
538 | break; | 683 | break; |
539 | } | 684 | } |
@@ -547,8 +692,6 @@ static void sh_mmcif_start_cmd(struct sh_mmcif_host *host, | |||
547 | int ret = 0, mask = 0; | 692 | int ret = 0, mask = 0; |
548 | u32 opc = cmd->opcode; | 693 | u32 opc = cmd->opcode; |
549 | 694 | ||
550 | host->cmd = cmd; | ||
551 | |||
552 | switch (opc) { | 695 | switch (opc) { |
553 | /* respons busy check */ | 696 | /* respons busy check */ |
554 | case MMC_SWITCH: | 697 | case MMC_SWITCH: |
@@ -579,13 +722,12 @@ static void sh_mmcif_start_cmd(struct sh_mmcif_host *host, | |||
579 | sh_mmcif_writel(host->addr, MMCIF_CE_INT_MASK, mask); | 722 | sh_mmcif_writel(host->addr, MMCIF_CE_INT_MASK, mask); |
580 | /* set arg */ | 723 | /* set arg */ |
581 | sh_mmcif_writel(host->addr, MMCIF_CE_ARG, cmd->arg); | 724 | sh_mmcif_writel(host->addr, MMCIF_CE_ARG, cmd->arg); |
582 | host->wait_int = 0; | ||
583 | /* set cmd */ | 725 | /* set cmd */ |
584 | sh_mmcif_writel(host->addr, MMCIF_CE_CMD_SET, opc); | 726 | sh_mmcif_writel(host->addr, MMCIF_CE_CMD_SET, opc); |
585 | 727 | ||
586 | time = wait_event_interruptible_timeout(host->intr_wait, | 728 | time = wait_for_completion_interruptible_timeout(&host->intr_wait, |
587 | host->wait_int == 1 || host->sd_error == 1, host->timeout); | 729 | host->timeout); |
588 | if (host->wait_int != 1 && time == 0) { | 730 | if (time <= 0) { |
589 | cmd->error = sh_mmcif_error_manage(host); | 731 | cmd->error = sh_mmcif_error_manage(host); |
590 | return; | 732 | return; |
591 | } | 733 | } |
@@ -597,26 +739,34 @@ static void sh_mmcif_start_cmd(struct sh_mmcif_host *host, | |||
597 | cmd->error = -ETIMEDOUT; | 739 | cmd->error = -ETIMEDOUT; |
598 | break; | 740 | break; |
599 | default: | 741 | default: |
600 | pr_debug("%s: Cmd(d'%d) err\n", | 742 | dev_dbg(&host->pd->dev, "Cmd(d'%d) err\n", |
601 | DRIVER_NAME, cmd->opcode); | 743 | cmd->opcode); |
602 | cmd->error = sh_mmcif_error_manage(host); | 744 | cmd->error = sh_mmcif_error_manage(host); |
603 | break; | 745 | break; |
604 | } | 746 | } |
605 | host->sd_error = 0; | 747 | host->sd_error = false; |
606 | host->wait_int = 0; | ||
607 | return; | 748 | return; |
608 | } | 749 | } |
609 | if (!(cmd->flags & MMC_RSP_PRESENT)) { | 750 | if (!(cmd->flags & MMC_RSP_PRESENT)) { |
610 | cmd->error = ret; | 751 | cmd->error = 0; |
611 | host->wait_int = 0; | ||
612 | return; | 752 | return; |
613 | } | 753 | } |
614 | if (host->wait_int == 1) { | 754 | sh_mmcif_get_response(host, cmd); |
615 | sh_mmcif_get_response(host, cmd); | ||
616 | host->wait_int = 0; | ||
617 | } | ||
618 | if (host->data) { | 755 | if (host->data) { |
619 | ret = sh_mmcif_data_trans(host, mrq, cmd->opcode); | 756 | if (!host->dma_sglen) { |
757 | ret = sh_mmcif_data_trans(host, mrq, cmd->opcode); | ||
758 | } else { | ||
759 | long time = | ||
760 | wait_for_completion_interruptible_timeout(&host->dma_complete, | ||
761 | host->timeout); | ||
762 | if (!time) | ||
763 | ret = -ETIMEDOUT; | ||
764 | else if (time < 0) | ||
765 | ret = time; | ||
766 | sh_mmcif_bitclr(host, MMCIF_CE_BUF_ACC, | ||
767 | BUF_ACC_DMAREN | BUF_ACC_DMAWEN); | ||
768 | host->dma_sglen = 0; | ||
769 | } | ||
620 | if (ret < 0) | 770 | if (ret < 0) |
621 | mrq->data->bytes_xfered = 0; | 771 | mrq->data->bytes_xfered = 0; |
622 | else | 772 | else |
@@ -636,20 +786,18 @@ static void sh_mmcif_stop_cmd(struct sh_mmcif_host *host, | |||
636 | else if (mrq->cmd->opcode == MMC_WRITE_MULTIPLE_BLOCK) | 786 | else if (mrq->cmd->opcode == MMC_WRITE_MULTIPLE_BLOCK) |
637 | sh_mmcif_bitset(host, MMCIF_CE_INT_MASK, MASK_MCMD12RBE); | 787 | sh_mmcif_bitset(host, MMCIF_CE_INT_MASK, MASK_MCMD12RBE); |
638 | else { | 788 | else { |
639 | pr_err(DRIVER_NAME": not support stop cmd\n"); | 789 | dev_err(&host->pd->dev, "unsupported stop cmd\n"); |
640 | cmd->error = sh_mmcif_error_manage(host); | 790 | cmd->error = sh_mmcif_error_manage(host); |
641 | return; | 791 | return; |
642 | } | 792 | } |
643 | 793 | ||
644 | time = wait_event_interruptible_timeout(host->intr_wait, | 794 | time = wait_for_completion_interruptible_timeout(&host->intr_wait, |
645 | host->wait_int == 1 || | 795 | host->timeout); |
646 | host->sd_error == 1, host->timeout); | 796 | if (time <= 0 || host->sd_error) { |
647 | if (host->wait_int != 1 && (time == 0 || host->sd_error != 0)) { | ||
648 | cmd->error = sh_mmcif_error_manage(host); | 797 | cmd->error = sh_mmcif_error_manage(host); |
649 | return; | 798 | return; |
650 | } | 799 | } |
651 | sh_mmcif_get_cmd12response(host, cmd); | 800 | sh_mmcif_get_cmd12response(host, cmd); |
652 | host->wait_int = 0; | ||
653 | cmd->error = 0; | 801 | cmd->error = 0; |
654 | } | 802 | } |
655 | 803 | ||
@@ -676,6 +824,15 @@ static void sh_mmcif_request(struct mmc_host *mmc, struct mmc_request *mrq) | |||
676 | break; | 824 | break; |
677 | } | 825 | } |
678 | host->data = mrq->data; | 826 | host->data = mrq->data; |
827 | if (mrq->data) { | ||
828 | if (mrq->data->flags & MMC_DATA_READ) { | ||
829 | if (host->chan_rx) | ||
830 | sh_mmcif_start_dma_rx(host); | ||
831 | } else { | ||
832 | if (host->chan_tx) | ||
833 | sh_mmcif_start_dma_tx(host); | ||
834 | } | ||
835 | } | ||
679 | sh_mmcif_start_cmd(host, mrq, mrq->cmd); | 836 | sh_mmcif_start_cmd(host, mrq, mrq->cmd); |
680 | host->data = NULL; | 837 | host->data = NULL; |
681 | 838 | ||
@@ -735,7 +892,7 @@ static void sh_mmcif_detect(struct mmc_host *mmc) | |||
735 | static irqreturn_t sh_mmcif_intr(int irq, void *dev_id) | 892 | static irqreturn_t sh_mmcif_intr(int irq, void *dev_id) |
736 | { | 893 | { |
737 | struct sh_mmcif_host *host = dev_id; | 894 | struct sh_mmcif_host *host = dev_id; |
738 | u32 state = 0; | 895 | u32 state; |
739 | int err = 0; | 896 | int err = 0; |
740 | 897 | ||
741 | state = sh_mmcif_readl(host->addr, MMCIF_CE_INT); | 898 | state = sh_mmcif_readl(host->addr, MMCIF_CE_INT); |
@@ -774,17 +931,19 @@ static irqreturn_t sh_mmcif_intr(int irq, void *dev_id) | |||
774 | sh_mmcif_bitclr(host, MMCIF_CE_INT_MASK, state); | 931 | sh_mmcif_bitclr(host, MMCIF_CE_INT_MASK, state); |
775 | err = 1; | 932 | err = 1; |
776 | } else { | 933 | } else { |
777 | pr_debug("%s: Not support int\n", DRIVER_NAME); | 934 | dev_dbg(&host->pd->dev, "Not support int\n"); |
778 | sh_mmcif_writel(host->addr, MMCIF_CE_INT, ~state); | 935 | sh_mmcif_writel(host->addr, MMCIF_CE_INT, ~state); |
779 | sh_mmcif_bitclr(host, MMCIF_CE_INT_MASK, state); | 936 | sh_mmcif_bitclr(host, MMCIF_CE_INT_MASK, state); |
780 | err = 1; | 937 | err = 1; |
781 | } | 938 | } |
782 | if (err) { | 939 | if (err) { |
783 | host->sd_error = 1; | 940 | host->sd_error = true; |
784 | pr_debug("%s: int err state = %08x\n", DRIVER_NAME, state); | 941 | dev_dbg(&host->pd->dev, "int err state = %08x\n", state); |
785 | } | 942 | } |
786 | host->wait_int = 1; | 943 | if (state & ~(INT_CMD12RBE | INT_CMD12CRE)) |
787 | wake_up(&host->intr_wait); | 944 | complete(&host->intr_wait); |
945 | else | ||
946 | dev_dbg(&host->pd->dev, "Unexpected IRQ 0x%x\n", state); | ||
788 | 947 | ||
789 | return IRQ_HANDLED; | 948 | return IRQ_HANDLED; |
790 | } | 949 | } |
@@ -793,8 +952,8 @@ static int __devinit sh_mmcif_probe(struct platform_device *pdev) | |||
793 | { | 952 | { |
794 | int ret = 0, irq[2]; | 953 | int ret = 0, irq[2]; |
795 | struct mmc_host *mmc; | 954 | struct mmc_host *mmc; |
796 | struct sh_mmcif_host *host = NULL; | 955 | struct sh_mmcif_host *host; |
797 | struct sh_mmcif_plat_data *pd = NULL; | 956 | struct sh_mmcif_plat_data *pd; |
798 | struct resource *res; | 957 | struct resource *res; |
799 | void __iomem *reg; | 958 | void __iomem *reg; |
800 | char clk_name[8]; | 959 | char clk_name[8]; |
@@ -802,7 +961,7 @@ static int __devinit sh_mmcif_probe(struct platform_device *pdev) | |||
802 | irq[0] = platform_get_irq(pdev, 0); | 961 | irq[0] = platform_get_irq(pdev, 0); |
803 | irq[1] = platform_get_irq(pdev, 1); | 962 | irq[1] = platform_get_irq(pdev, 1); |
804 | if (irq[0] < 0 || irq[1] < 0) { | 963 | if (irq[0] < 0 || irq[1] < 0) { |
805 | pr_err(DRIVER_NAME": Get irq error\n"); | 964 | dev_err(&pdev->dev, "Get irq error\n"); |
806 | return -ENXIO; | 965 | return -ENXIO; |
807 | } | 966 | } |
808 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 967 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
@@ -815,7 +974,7 @@ static int __devinit sh_mmcif_probe(struct platform_device *pdev) | |||
815 | dev_err(&pdev->dev, "ioremap error.\n"); | 974 | dev_err(&pdev->dev, "ioremap error.\n"); |
816 | return -ENOMEM; | 975 | return -ENOMEM; |
817 | } | 976 | } |
818 | pd = (struct sh_mmcif_plat_data *)(pdev->dev.platform_data); | 977 | pd = pdev->dev.platform_data; |
819 | if (!pd) { | 978 | if (!pd) { |
820 | dev_err(&pdev->dev, "sh_mmcif plat data error.\n"); | 979 | dev_err(&pdev->dev, "sh_mmcif plat data error.\n"); |
821 | ret = -ENXIO; | 980 | ret = -ENXIO; |
@@ -842,7 +1001,7 @@ static int __devinit sh_mmcif_probe(struct platform_device *pdev) | |||
842 | host->clk = clk_get_rate(host->hclk); | 1001 | host->clk = clk_get_rate(host->hclk); |
843 | host->pd = pdev; | 1002 | host->pd = pdev; |
844 | 1003 | ||
845 | init_waitqueue_head(&host->intr_wait); | 1004 | init_completion(&host->intr_wait); |
846 | 1005 | ||
847 | mmc->ops = &sh_mmcif_ops; | 1006 | mmc->ops = &sh_mmcif_ops; |
848 | mmc->f_max = host->clk; | 1007 | mmc->f_max = host->clk; |
@@ -858,33 +1017,37 @@ static int __devinit sh_mmcif_probe(struct platform_device *pdev) | |||
858 | mmc->caps = MMC_CAP_MMC_HIGHSPEED; | 1017 | mmc->caps = MMC_CAP_MMC_HIGHSPEED; |
859 | if (pd->caps) | 1018 | if (pd->caps) |
860 | mmc->caps |= pd->caps; | 1019 | mmc->caps |= pd->caps; |
861 | mmc->max_segs = 128; | 1020 | mmc->max_segs = 32; |
862 | mmc->max_blk_size = 512; | 1021 | mmc->max_blk_size = 512; |
863 | mmc->max_blk_count = 65535; | 1022 | mmc->max_req_size = PAGE_CACHE_SIZE * mmc->max_segs; |
864 | mmc->max_req_size = mmc->max_blk_size * mmc->max_blk_count; | 1023 | mmc->max_blk_count = mmc->max_req_size / mmc->max_blk_size; |
865 | mmc->max_seg_size = mmc->max_req_size; | 1024 | mmc->max_seg_size = mmc->max_req_size; |
866 | 1025 | ||
867 | sh_mmcif_sync_reset(host); | 1026 | sh_mmcif_sync_reset(host); |
868 | platform_set_drvdata(pdev, host); | 1027 | platform_set_drvdata(pdev, host); |
1028 | |||
1029 | /* See if we also get DMA */ | ||
1030 | sh_mmcif_request_dma(host, pd); | ||
1031 | |||
869 | mmc_add_host(mmc); | 1032 | mmc_add_host(mmc); |
870 | 1033 | ||
871 | ret = request_irq(irq[0], sh_mmcif_intr, 0, "sh_mmc:error", host); | 1034 | ret = request_irq(irq[0], sh_mmcif_intr, 0, "sh_mmc:error", host); |
872 | if (ret) { | 1035 | if (ret) { |
873 | pr_err(DRIVER_NAME": request_irq error (sh_mmc:error)\n"); | 1036 | dev_err(&pdev->dev, "request_irq error (sh_mmc:error)\n"); |
874 | goto clean_up2; | 1037 | goto clean_up2; |
875 | } | 1038 | } |
876 | ret = request_irq(irq[1], sh_mmcif_intr, 0, "sh_mmc:int", host); | 1039 | ret = request_irq(irq[1], sh_mmcif_intr, 0, "sh_mmc:int", host); |
877 | if (ret) { | 1040 | if (ret) { |
878 | free_irq(irq[0], host); | 1041 | free_irq(irq[0], host); |
879 | pr_err(DRIVER_NAME": request_irq error (sh_mmc:int)\n"); | 1042 | dev_err(&pdev->dev, "request_irq error (sh_mmc:int)\n"); |
880 | goto clean_up2; | 1043 | goto clean_up2; |
881 | } | 1044 | } |
882 | 1045 | ||
883 | sh_mmcif_writel(host->addr, MMCIF_CE_INT_MASK, MASK_ALL); | 1046 | sh_mmcif_writel(host->addr, MMCIF_CE_INT_MASK, MASK_ALL); |
884 | sh_mmcif_detect(host->mmc); | 1047 | sh_mmcif_detect(host->mmc); |
885 | 1048 | ||
886 | pr_info("%s: driver version %s\n", DRIVER_NAME, DRIVER_VERSION); | 1049 | dev_info(&pdev->dev, "driver version %s\n", DRIVER_VERSION); |
887 | pr_debug("%s: chip ver H'%04x\n", DRIVER_NAME, | 1050 | dev_dbg(&pdev->dev, "chip ver H'%04x\n", |
888 | sh_mmcif_readl(host->addr, MMCIF_CE_VERSION) & 0x0000ffff); | 1051 | sh_mmcif_readl(host->addr, MMCIF_CE_VERSION) & 0x0000ffff); |
889 | return ret; | 1052 | return ret; |
890 | 1053 | ||
@@ -903,20 +1066,22 @@ static int __devexit sh_mmcif_remove(struct platform_device *pdev) | |||
903 | struct sh_mmcif_host *host = platform_get_drvdata(pdev); | 1066 | struct sh_mmcif_host *host = platform_get_drvdata(pdev); |
904 | int irq[2]; | 1067 | int irq[2]; |
905 | 1068 | ||
906 | sh_mmcif_writel(host->addr, MMCIF_CE_INT_MASK, MASK_ALL); | 1069 | mmc_remove_host(host->mmc); |
907 | 1070 | sh_mmcif_release_dma(host); | |
908 | irq[0] = platform_get_irq(pdev, 0); | ||
909 | irq[1] = platform_get_irq(pdev, 1); | ||
910 | 1071 | ||
911 | if (host->addr) | 1072 | if (host->addr) |
912 | iounmap(host->addr); | 1073 | iounmap(host->addr); |
913 | 1074 | ||
914 | platform_set_drvdata(pdev, NULL); | 1075 | sh_mmcif_writel(host->addr, MMCIF_CE_INT_MASK, MASK_ALL); |
915 | mmc_remove_host(host->mmc); | 1076 | |
1077 | irq[0] = platform_get_irq(pdev, 0); | ||
1078 | irq[1] = platform_get_irq(pdev, 1); | ||
916 | 1079 | ||
917 | free_irq(irq[0], host); | 1080 | free_irq(irq[0], host); |
918 | free_irq(irq[1], host); | 1081 | free_irq(irq[1], host); |
919 | 1082 | ||
1083 | platform_set_drvdata(pdev, NULL); | ||
1084 | |||
920 | clk_disable(host->hclk); | 1085 | clk_disable(host->hclk); |
921 | mmc_free_host(host->mmc); | 1086 | mmc_free_host(host->mmc); |
922 | 1087 | ||
@@ -947,5 +1112,5 @@ module_exit(sh_mmcif_exit); | |||
947 | 1112 | ||
948 | MODULE_DESCRIPTION("SuperH on-chip MMC/eMMC interface driver"); | 1113 | MODULE_DESCRIPTION("SuperH on-chip MMC/eMMC interface driver"); |
949 | MODULE_LICENSE("GPL"); | 1114 | MODULE_LICENSE("GPL"); |
950 | MODULE_ALIAS(DRIVER_NAME); | 1115 | MODULE_ALIAS("platform:" DRIVER_NAME); |
951 | MODULE_AUTHOR("Yusuke Goda <yusuke.goda.sx@renesas.com>"); | 1116 | MODULE_AUTHOR("Yusuke Goda <yusuke.goda.sx@renesas.com>"); |
diff --git a/drivers/serial/sh-sci.h b/drivers/serial/sh-sci.h index d2352ac437c5..4bc614e4221c 100644 --- a/drivers/serial/sh-sci.h +++ b/drivers/serial/sh-sci.h | |||
@@ -31,6 +31,7 @@ | |||
31 | # define SCSCR_INIT(port) (port->mapbase == SCIF2) ? 0xF3 : 0xF0 | 31 | # define SCSCR_INIT(port) (port->mapbase == SCIF2) ? 0xF3 : 0xF0 |
32 | #elif defined(CONFIG_CPU_SUBTYPE_SH7720) || \ | 32 | #elif defined(CONFIG_CPU_SUBTYPE_SH7720) || \ |
33 | defined(CONFIG_CPU_SUBTYPE_SH7721) || \ | 33 | defined(CONFIG_CPU_SUBTYPE_SH7721) || \ |
34 | defined(CONFIG_ARCH_SH73A0) || \ | ||
34 | defined(CONFIG_ARCH_SH7367) || \ | 35 | defined(CONFIG_ARCH_SH7367) || \ |
35 | defined(CONFIG_ARCH_SH7377) || \ | 36 | defined(CONFIG_ARCH_SH7377) || \ |
36 | defined(CONFIG_ARCH_SH7372) | 37 | defined(CONFIG_ARCH_SH7372) |
@@ -244,6 +245,7 @@ | |||
244 | #if defined(CONFIG_CPU_SUBTYPE_SH7705) || \ | 245 | #if defined(CONFIG_CPU_SUBTYPE_SH7705) || \ |
245 | defined(CONFIG_CPU_SUBTYPE_SH7720) || \ | 246 | defined(CONFIG_CPU_SUBTYPE_SH7720) || \ |
246 | defined(CONFIG_CPU_SUBTYPE_SH7721) || \ | 247 | defined(CONFIG_CPU_SUBTYPE_SH7721) || \ |
248 | defined(CONFIG_ARCH_SH73A0) || \ | ||
247 | defined(CONFIG_ARCH_SH7367) || \ | 249 | defined(CONFIG_ARCH_SH7367) || \ |
248 | defined(CONFIG_ARCH_SH7377) || \ | 250 | defined(CONFIG_ARCH_SH7377) || \ |
249 | defined(CONFIG_ARCH_SH7372) | 251 | defined(CONFIG_ARCH_SH7372) |
@@ -280,6 +282,7 @@ | |||
280 | #if defined(CONFIG_CPU_SUBTYPE_SH7705) || \ | 282 | #if defined(CONFIG_CPU_SUBTYPE_SH7705) || \ |
281 | defined(CONFIG_CPU_SUBTYPE_SH7720) || \ | 283 | defined(CONFIG_CPU_SUBTYPE_SH7720) || \ |
282 | defined(CONFIG_CPU_SUBTYPE_SH7721) || \ | 284 | defined(CONFIG_CPU_SUBTYPE_SH7721) || \ |
285 | defined(CONFIG_ARCH_SH73A0) || \ | ||
283 | defined(CONFIG_ARCH_SH7367) || \ | 286 | defined(CONFIG_ARCH_SH7367) || \ |
284 | defined(CONFIG_ARCH_SH7377) || \ | 287 | defined(CONFIG_ARCH_SH7377) || \ |
285 | defined(CONFIG_ARCH_SH7372) | 288 | defined(CONFIG_ARCH_SH7372) |
@@ -378,6 +381,7 @@ | |||
378 | } | 381 | } |
379 | 382 | ||
380 | #if defined(CONFIG_CPU_SH3) || \ | 383 | #if defined(CONFIG_CPU_SH3) || \ |
384 | defined(CONFIG_ARCH_SH73A0) || \ | ||
381 | defined(CONFIG_ARCH_SH7367) || \ | 385 | defined(CONFIG_ARCH_SH7367) || \ |
382 | defined(CONFIG_ARCH_SH7377) || \ | 386 | defined(CONFIG_ARCH_SH7377) || \ |
383 | defined(CONFIG_ARCH_SH7372) | 387 | defined(CONFIG_ARCH_SH7372) |
@@ -391,6 +395,7 @@ | |||
391 | #elif defined(CONFIG_CPU_SUBTYPE_SH7705) || \ | 395 | #elif defined(CONFIG_CPU_SUBTYPE_SH7705) || \ |
392 | defined(CONFIG_CPU_SUBTYPE_SH7720) || \ | 396 | defined(CONFIG_CPU_SUBTYPE_SH7720) || \ |
393 | defined(CONFIG_CPU_SUBTYPE_SH7721) || \ | 397 | defined(CONFIG_CPU_SUBTYPE_SH7721) || \ |
398 | defined(CONFIG_ARCH_SH73A0) || \ | ||
394 | defined(CONFIG_ARCH_SH7367) || \ | 399 | defined(CONFIG_ARCH_SH7367) || \ |
395 | defined(CONFIG_ARCH_SH7377) | 400 | defined(CONFIG_ARCH_SH7377) |
396 | #define SCIF_FNS(name, scif_offset, scif_size) \ | 401 | #define SCIF_FNS(name, scif_offset, scif_size) \ |
@@ -433,6 +438,7 @@ | |||
433 | #if defined(CONFIG_CPU_SUBTYPE_SH7705) || \ | 438 | #if defined(CONFIG_CPU_SUBTYPE_SH7705) || \ |
434 | defined(CONFIG_CPU_SUBTYPE_SH7720) || \ | 439 | defined(CONFIG_CPU_SUBTYPE_SH7720) || \ |
435 | defined(CONFIG_CPU_SUBTYPE_SH7721) || \ | 440 | defined(CONFIG_CPU_SUBTYPE_SH7721) || \ |
441 | defined(CONFIG_ARCH_SH73A0) || \ | ||
436 | defined(CONFIG_ARCH_SH7367) || \ | 442 | defined(CONFIG_ARCH_SH7367) || \ |
437 | defined(CONFIG_ARCH_SH7377) | 443 | defined(CONFIG_ARCH_SH7377) |
438 | 444 | ||
@@ -632,6 +638,7 @@ static inline int sci_rxd_in(struct uart_port *port) | |||
632 | #elif defined(CONFIG_CPU_SUBTYPE_SH7705) || \ | 638 | #elif defined(CONFIG_CPU_SUBTYPE_SH7705) || \ |
633 | defined(CONFIG_CPU_SUBTYPE_SH7720) || \ | 639 | defined(CONFIG_CPU_SUBTYPE_SH7720) || \ |
634 | defined(CONFIG_CPU_SUBTYPE_SH7721) || \ | 640 | defined(CONFIG_CPU_SUBTYPE_SH7721) || \ |
641 | defined(CONFIG_ARCH_SH73A0) || \ | ||
635 | defined(CONFIG_ARCH_SH7367) || \ | 642 | defined(CONFIG_ARCH_SH7367) || \ |
636 | defined(CONFIG_ARCH_SH7377) || \ | 643 | defined(CONFIG_ARCH_SH7377) || \ |
637 | defined(CONFIG_ARCH_SH7372) | 644 | defined(CONFIG_ARCH_SH7372) |