aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2011-03-30 22:48:54 -0400
committerFelipe Balbi <balbi@ti.com>2011-04-13 04:51:28 -0400
commit132543074af3cf1e94e3608abf162880edbdcbb3 (patch)
tree498abf639ee20de505593f776756d40fdcbe9d1c /drivers/usb
parent4f9edd2d7e8dd170d10780532cb76eb5890468b4 (diff)
USB: musb: blackfin: work around anomaly 05000450
DMA mode 1 data corruption anomaly on Blackfin systems. This issue is specific to the Blackfin silicon as the bug appears to be related to the connection of the musb ip to the bus/dma fabric. Data corruption when using USB DMA mode 1. (Issue manager 17-01-0105) DMA mode 1 allows large size transfers to generate a single interrupt at the end of the entire transfer. The transfer is split up in packets of length specified in the Maximum Packet Size field for that endpoint. If the transfer size is not an integer multiple of the Maximum Packet Size, a short packet will be present at the end of the transfer. Under certain conditions this packet may be corrupted in the USB FIFO. Workaround: Use DMA mode 1 to transfer (n* Maximum Packet Size) and schedule DMA mode 0 to transfer the short packet. As an example if your transfer size is 33168 bytes and Maximum Packet Size equals 512, schedule [33168 - (33168 mod 512)] in DMA mode 1 and the remainder (33168 mod 512) in DMA mode 0. Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/musb/blackfin.c24
-rw-r--r--drivers/usb/musb/musb_core.h5
-rw-r--r--drivers/usb/musb/musbhsdma.c8
3 files changed, 37 insertions, 0 deletions
diff --git a/drivers/usb/musb/blackfin.c b/drivers/usb/musb/blackfin.c
index 52312e8af213..8e2a1ff8a35a 100644
--- a/drivers/usb/musb/blackfin.c
+++ b/drivers/usb/musb/blackfin.c
@@ -21,6 +21,7 @@
21#include <asm/cacheflush.h> 21#include <asm/cacheflush.h>
22 22
23#include "musb_core.h" 23#include "musb_core.h"
24#include "musbhsdma.h"
24#include "blackfin.h" 25#include "blackfin.h"
25 26
26struct bfin_glue { 27struct bfin_glue {
@@ -332,6 +333,27 @@ static int bfin_musb_set_mode(struct musb *musb, u8 musb_mode)
332 return -EIO; 333 return -EIO;
333} 334}
334 335
336static int bfin_musb_adjust_channel_params(struct dma_channel *channel,
337 u16 packet_sz, u8 *mode,
338 dma_addr_t *dma_addr, u32 *len)
339{
340 struct musb_dma_channel *musb_channel = channel->private_data;
341
342 /*
343 * Anomaly 05000450 might cause data corruption when using DMA
344 * MODE 1 transmits with short packet. So to work around this,
345 * we truncate all MODE 1 transfers down to a multiple of the
346 * max packet size, and then do the last short packet transfer
347 * (if there is any) using MODE 0.
348 */
349 if (ANOMALY_05000450) {
350 if (musb_channel->transmit && *mode == 1)
351 *len = *len - (*len % packet_sz);
352 }
353
354 return 0;
355}
356
335static void bfin_musb_reg_init(struct musb *musb) 357static void bfin_musb_reg_init(struct musb *musb)
336{ 358{
337 if (ANOMALY_05000346) { 359 if (ANOMALY_05000346) {
@@ -430,6 +452,8 @@ static const struct musb_platform_ops bfin_ops = {
430 452
431 .vbus_status = bfin_musb_vbus_status, 453 .vbus_status = bfin_musb_vbus_status,
432 .set_vbus = bfin_musb_set_vbus, 454 .set_vbus = bfin_musb_set_vbus,
455
456 .adjust_channel_params = bfin_musb_adjust_channel_params,
433}; 457};
434 458
435static u64 bfin_dmamask = DMA_BIT_MASK(32); 459static u64 bfin_dmamask = DMA_BIT_MASK(32);
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
index 4bd9e2145ee4..0e053b587960 100644
--- a/drivers/usb/musb/musb_core.h
+++ b/drivers/usb/musb/musb_core.h
@@ -261,6 +261,7 @@ enum musb_g_ep0_state {
261 * @try_ilde: tries to idle the IP 261 * @try_ilde: tries to idle the IP
262 * @vbus_status: returns vbus status if possible 262 * @vbus_status: returns vbus status if possible
263 * @set_vbus: forces vbus status 263 * @set_vbus: forces vbus status
264 * @channel_program: pre check for standard dma channel_program func
264 */ 265 */
265struct musb_platform_ops { 266struct musb_platform_ops {
266 int (*init)(struct musb *musb); 267 int (*init)(struct musb *musb);
@@ -274,6 +275,10 @@ struct musb_platform_ops {
274 275
275 int (*vbus_status)(struct musb *musb); 276 int (*vbus_status)(struct musb *musb);
276 void (*set_vbus)(struct musb *musb, int on); 277 void (*set_vbus)(struct musb *musb, int on);
278
279 int (*adjust_channel_params)(struct dma_channel *channel,
280 u16 packet_sz, u8 *mode,
281 dma_addr_t *dma_addr, u32 *len);
277}; 282};
278 283
279/* 284/*
diff --git a/drivers/usb/musb/musbhsdma.c b/drivers/usb/musb/musbhsdma.c
index 0144a2d481fd..d281792db05c 100644
--- a/drivers/usb/musb/musbhsdma.c
+++ b/drivers/usb/musb/musbhsdma.c
@@ -169,6 +169,14 @@ static int dma_channel_program(struct dma_channel *channel,
169 BUG_ON(channel->status == MUSB_DMA_STATUS_UNKNOWN || 169 BUG_ON(channel->status == MUSB_DMA_STATUS_UNKNOWN ||
170 channel->status == MUSB_DMA_STATUS_BUSY); 170 channel->status == MUSB_DMA_STATUS_BUSY);
171 171
172 /* Let targets check/tweak the arguments */
173 if (musb->ops->adjust_channel_params) {
174 int ret = musb->ops->adjust_channel_params(channel,
175 packet_sz, &mode, &dma_addr, &len);
176 if (ret)
177 return ret;
178 }
179
172 /* 180 /*
173 * The DMA engine in RTL1.8 and above cannot handle 181 * The DMA engine in RTL1.8 and above cannot handle
174 * DMA addresses that are not aligned to a 4 byte boundary. 182 * DMA addresses that are not aligned to a 4 byte boundary.