musbhsdma.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578
  1. /*
  2. * MUSB OTG driver - support for Mentor's DMA controller
  3. *
  4. * Copyright 2005 Mentor Graphics Corporation
  5. * Copyright (C) 2005-2007 by Texas Instruments
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * version 2 as published by the Free Software Foundation.
  10. *
  11. * This program is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  19. * 02110-1301 USA
  20. *
  21. * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
  22. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  23. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
  24. * NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  25. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  26. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  27. * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  28. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  29. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  30. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31. *
  32. */
  33. #include <linux/device.h>
  34. #include <linux/interrupt.h>
  35. #include <linux/platform_device.h>
  36. #include <linux/slab.h>
  37. #include <linux/export.h>
  38. /* #include <asm/system.h> */
  39. #include "musb_core.h"
  40. #include "musbhsdma.h"
  41. #ifdef CONFIG_OF
  42. /* extern void __iomem *USB_BASE; */
  43. #endif
  44. static int dma_controller_start(struct dma_controller *c)
  45. {
  46. /* nothing to do */
  47. return 0;
  48. }
  49. static void dma_channel_release(struct dma_channel *channel);
  50. static int dma_controller_stop(struct dma_controller *c)
  51. {
  52. struct musb_dma_controller *controller = container_of(c,
  53. struct musb_dma_controller,
  54. controller);
  55. struct musb *musb = controller->private_data;
  56. struct dma_channel *channel;
  57. u8 bit;
  58. if (controller->used_channels != 0) {
  59. dev_err(musb->controller, "Stopping DMA controller while channel active\n");
  60. for (bit = 0; bit < MUSB_HSDMA_CHANNELS; bit++) {
  61. if (controller->used_channels & (1 << bit)) {
  62. channel = &controller->channel[bit].channel;
  63. dma_channel_release(channel);
  64. if (!controller->used_channels)
  65. break;
  66. }
  67. }
  68. }
  69. return 0;
  70. }
  71. static struct dma_channel *dma_channel_allocate(struct dma_controller *c,
  72. struct musb_hw_ep *hw_ep, u8 transmit)
  73. {
  74. struct musb_dma_controller *controller = container_of(c,
  75. struct musb_dma_controller,
  76. controller);
  77. struct musb *musb = controller->private_data;
  78. struct musb_dma_channel *musb_channel = NULL;
  79. struct dma_channel *channel = NULL;
  80. u8 bit;
  81. for (bit = 0; bit < MUSB_HSDMA_CHANNELS; bit++) {
  82. if (!(controller->used_channels & (1 << bit))) {
  83. controller->used_channels |= (1 << bit);
  84. musb_channel = &(controller->channel[bit]);
  85. musb_channel->controller = controller;
  86. musb_channel->idx = bit;
  87. if (musb->is_host) {
  88. musb_channel->epnum = hw_ep->epnum;
  89. } else {
  90. if (transmit) {
  91. /* dma irq will use this member to get the hw ep. */
  92. musb_channel->epnum = hw_ep->ep_in.current_epnum;
  93. } else /* after mapping, hw ep num eques to the current num */
  94. musb_channel->epnum = hw_ep->ep_out.current_epnum;
  95. }
  96. musb_channel->transmit = transmit;
  97. channel = &(musb_channel->channel);
  98. channel->private_data = musb_channel;
  99. channel->status = MUSB_DMA_STATUS_FREE;
  100. channel->max_len = 0x100000;
  101. /* Tx => mode 1; Rx => mode 0 */
  102. channel->desired_mode = transmit;
  103. channel->actual_len = 0;
  104. break;
  105. }
  106. }
  107. return channel;
  108. }
  109. static void dma_channel_release(struct dma_channel *channel)
  110. {
  111. struct musb_dma_channel *musb_channel = channel->private_data;
  112. channel->actual_len = 0;
  113. musb_channel->start_addr = 0;
  114. musb_channel->len = 0;
  115. musb_channel->controller->used_channels &= ~(1 << musb_channel->idx);
  116. channel->status = MUSB_DMA_STATUS_UNKNOWN;
  117. }
  118. static void configure_channel(struct dma_channel *channel,
  119. u16 packet_sz, u8 mode, dma_addr_t dma_addr, u32 len)
  120. {
  121. struct musb_dma_channel *musb_channel = channel->private_data;
  122. struct musb_dma_controller *controller = musb_channel->controller;
  123. void __iomem *mbase = controller->base;
  124. u8 bchannel = musb_channel->idx;
  125. u16 csr = 0;
  126. DBG(4, "%p, pkt_sz %d, addr 0x%x, len %d, mode %d\n",
  127. channel, packet_sz, (unsigned int)dma_addr, len, mode);
  128. if (mode) {
  129. csr |= 1 << MUSB_HSDMA_MODE1_SHIFT;
  130. BUG_ON(len < packet_sz);
  131. }
  132. csr |= MUSB_HSDMA_BURSTMODE_INCR16 << MUSB_HSDMA_BURSTMODE_SHIFT;
  133. csr |= (musb_channel->epnum << MUSB_HSDMA_ENDPOINT_SHIFT)
  134. | (1 << MUSB_HSDMA_ENABLE_SHIFT)
  135. | (1 << MUSB_HSDMA_IRQENABLE_SHIFT)
  136. | (musb_channel->transmit ? (1 << MUSB_HSDMA_TRANSMIT_SHIFT)
  137. : 0);
  138. /* address/count */
  139. musb_write_hsdma_addr(mbase, bchannel, dma_addr);
  140. musb_write_hsdma_count(mbase, bchannel, len);
  141. /* control (this should start things) */
  142. musb_writew(mbase, MUSB_HSDMA_CHANNEL_OFFSET(bchannel, MUSB_HSDMA_CONTROL), csr);
  143. DBG(5, "MUSB:DMA channel %d control reg is %x\n", bchannel, musb_readw(mbase,
  144. MUSB_HSDMA_CHANNEL_OFFSET
  145. (bchannel,
  146. MUSB_HSDMA_CONTROL)));
  147. }
  148. static int dma_channel_program(struct dma_channel *channel,
  149. u16 packet_sz, u8 mode, dma_addr_t dma_addr, u32 len)
  150. {
  151. struct musb_dma_channel *musb_channel = channel->private_data;
  152. struct musb_dma_controller *controller = musb_channel->controller;
  153. struct musb *musb = controller->private_data;
  154. DBG(2, "ep%d-%s pkt_sz %d, dma_addr 0x%x length %d, mode %d\n",
  155. musb_channel->epnum,
  156. musb_channel->transmit ? "Tx" : "Rx", packet_sz, (unsigned int)dma_addr, len, mode);
  157. BUG_ON(channel->status == MUSB_DMA_STATUS_UNKNOWN ||
  158. channel->status == MUSB_DMA_STATUS_BUSY);
  159. /* Let targets check/tweak the arguments */
  160. if (musb->ops->adjust_channel_params) {
  161. int ret = musb->ops->adjust_channel_params(channel,
  162. packet_sz, &mode, &dma_addr, &len);
  163. if (ret)
  164. return ret;
  165. }
  166. #if 0
  167. /*
  168. * The DMA engine in RTL1.8 and above cannot handle
  169. * DMA addresses that are not aligned to a 4 byte boundary.
  170. * It ends up masking the last two bits of the address
  171. * programmed in DMA_ADDR.
  172. *
  173. * Fail such DMA transfers, so that the backup PIO mode
  174. * can carry out the transfer
  175. */
  176. if ((musb->hwvers >= MUSB_HWVERS_1800) && (dma_addr % 4))
  177. return false;
  178. #endif
  179. channel->actual_len = 0;
  180. musb_channel->start_addr = dma_addr;
  181. musb_channel->len = len;
  182. musb_channel->max_packet_sz = packet_sz;
  183. channel->status = MUSB_DMA_STATUS_BUSY;
  184. configure_channel(channel, packet_sz, mode, dma_addr, len);
  185. return true;
  186. }
  187. static int dma_channel_abort(struct dma_channel *channel)
  188. {
  189. struct musb_dma_channel *musb_channel = channel->private_data;
  190. void __iomem *mbase = musb_channel->controller->base;
  191. u8 bchannel = musb_channel->idx;
  192. int offset;
  193. u16 csr;
  194. if (channel->status == MUSB_DMA_STATUS_BUSY) {
  195. if (musb_channel->transmit) {
  196. offset = MUSB_EP_OFFSET(musb_channel->epnum, MUSB_TXCSR);
  197. /*
  198. * The programming guide says that we must clear
  199. * the DMAENAB bit before the DMAMODE bit...
  200. */
  201. csr = musb_readw(mbase, offset);
  202. csr &= ~(MUSB_TXCSR_AUTOSET | MUSB_TXCSR_DMAENAB);
  203. musb_writew(mbase, offset, csr);
  204. csr &= ~MUSB_TXCSR_DMAMODE;
  205. musb_writew(mbase, offset, csr);
  206. } else {
  207. offset = MUSB_EP_OFFSET(musb_channel->epnum, MUSB_RXCSR);
  208. csr = musb_readw(mbase, offset);
  209. csr &= ~(MUSB_RXCSR_AUTOCLEAR | MUSB_RXCSR_DMAENAB | MUSB_RXCSR_DMAMODE);
  210. musb_writew(mbase, offset, csr);
  211. }
  212. musb_writew(mbase, MUSB_HSDMA_CHANNEL_OFFSET(bchannel, MUSB_HSDMA_CONTROL), 0);
  213. musb_write_hsdma_addr(mbase, bchannel, 0);
  214. musb_write_hsdma_count(mbase, bchannel, 0);
  215. channel->status = MUSB_DMA_STATUS_FREE;
  216. }
  217. return 0;
  218. }
  219. static int dma_channel_pause(struct dma_channel *channel)
  220. {
  221. /*
  222. * Probably nothing to be done here. This is needed
  223. * only for certain DMA controllers which require
  224. * the DMA channel to be paused to get correct DMA
  225. * transfer residue
  226. */
  227. return 0;
  228. }
  229. static int dma_channel_resume(struct dma_channel *channel)
  230. {
  231. /* Probably nothing to be done here */
  232. return 0;
  233. }
  234. static int dma_channel_tx_status(struct dma_channel *channel)
  235. {
  236. struct musb_dma_channel *musb_channel = channel->private_data;
  237. void __iomem *mbase = musb_channel->controller->base;
  238. u8 bchannel = musb_channel->idx;
  239. u32 addr, count, residue;
  240. /*
  241. * Get the number of bytes left to be transferred over
  242. * DMA
  243. * The MUSB spec mentions "The DMA controller ADDR register
  244. * will have been incremented as packets were unloaded from
  245. * the fifo, the processor can determine the size of the
  246. * transfer by comparing the current value of ADDR against
  247. * the start address of the memory buffer
  248. */
  249. /* residue = musb_read_hsdma_count(mbase, bchannel); */
  250. addr = musb_read_hsdma_addr(mbase, bchannel);
  251. count = addr - musb_channel->start_addr;
  252. residue = channel->prog_len - count;
  253. return residue;
  254. }
  255. static int dma_channel_check_residue(struct dma_channel *channel, u32 residue)
  256. {
  257. int status;
  258. /* In cases where we know the transfer length and were expecting
  259. * a DMA completion we could get into the DMA busy condition
  260. * here if the next packet is short and the EP interrupt occurs
  261. * before we receive dma_completion interrupt for current transfer
  262. * Wait for dma_completion. MUSB will interrupt us again for this
  263. * short packet when we clear the DMA bits
  264. */
  265. if (!residue) {
  266. /* Wait for DMA completion */
  267. status = -EINPROGRESS;
  268. } else if (residue == channel->prog_len) {
  269. /* Nothing transferred over DMA? */
  270. /* WARN_ON(1); */
  271. status = -EINVAL;
  272. } else {
  273. /* residue looks OK */
  274. status = 0;
  275. }
  276. return status;
  277. }
  278. irqreturn_t dma_controller_irq(int irq, void *private_data)
  279. {
  280. struct musb_dma_controller *controller = private_data;
  281. struct musb *musb = controller->private_data;
  282. struct musb_dma_channel *musb_channel;
  283. struct dma_channel *channel;
  284. void __iomem *mbase = controller->base;
  285. irqreturn_t retval = IRQ_NONE;
  286. unsigned long flags;
  287. u8 bchannel;
  288. u8 int_hsdma;
  289. u32 addr, count;
  290. u16 csr;
  291. spin_lock_irqsave(&musb->lock, flags);
  292. /* musb_read_clear_dma_interrupt */
  293. int_hsdma = musb_readb(musb->mregs, MUSB_HSDMA_INTR);
  294. mb();
  295. musb_writeb(musb->mregs, MUSB_HSDMA_INTR, int_hsdma);
  296. /* musb_read_clear_dma_interrupt */
  297. if (unlikely(!musb_epx_transfer_allowed)) {
  298. DBG(0, "!musb_epx_transfer_allowed\n");
  299. spin_unlock_irqrestore(&musb->lock, flags);
  300. return IRQ_HANDLED;
  301. }
  302. if (!int_hsdma) {
  303. DBG(2, "spurious DMA irq\n");
  304. for (bchannel = 0; bchannel < MUSB_HSDMA_CHANNELS; bchannel++) {
  305. musb_channel = (struct musb_dma_channel *)
  306. &(controller->channel[bchannel]);
  307. channel = &musb_channel->channel;
  308. if (channel->status == MUSB_DMA_STATUS_BUSY) {
  309. count = musb_read_hsdma_count(mbase, bchannel);
  310. if (count == 0)
  311. int_hsdma |= (1 << bchannel);
  312. }
  313. }
  314. DBG(2, "int_hsdma = 0x%x\n", int_hsdma);
  315. if (!int_hsdma)
  316. goto done;
  317. }
  318. for (bchannel = 0; bchannel < MUSB_HSDMA_CHANNELS; bchannel++) {
  319. if (int_hsdma & (1 << bchannel)) {
  320. musb_channel = (struct musb_dma_channel *)
  321. &(controller->channel[bchannel]);
  322. channel = &musb_channel->channel;
  323. DBG(1, "MUSB:DMA channel %d interrupt\n", bchannel);
  324. csr = musb_readw(mbase,
  325. MUSB_HSDMA_CHANNEL_OFFSET(bchannel, MUSB_HSDMA_CONTROL));
  326. if (csr & (1 << MUSB_HSDMA_BUSERROR_SHIFT)) {
  327. musb_channel->channel.status = MUSB_DMA_STATUS_BUS_ABORT;
  328. } else {
  329. u8 devctl;
  330. addr = musb_read_hsdma_addr(mbase, bchannel);
  331. channel->actual_len = addr - musb_channel->start_addr;
  332. /* channel->actual_len = musb_readl(mbase,USB_DMA_REALCOUNT(bchannel)); */
  333. DBG(2, "channel %d ch %p, 0x%x -> 0x%x (%zu / %d) %s\n", bchannel,
  334. channel, musb_channel->start_addr,
  335. addr, channel->actual_len,
  336. musb_channel->len,
  337. (channel->actual_len
  338. < musb_channel->len) ? "=> reconfig 0" : "=> complete");
  339. devctl = musb_readb(mbase, MUSB_DEVCTL);
  340. channel->status = MUSB_DMA_STATUS_FREE;
  341. /* completed */
  342. if ((devctl & MUSB_DEVCTL_HM)
  343. && (musb_channel->transmit)
  344. && ((channel->desired_mode == 0)
  345. || (channel->actual_len &
  346. (musb_channel->max_packet_sz - 1)))
  347. ) {
  348. u8 epnum = musb_channel->epnum;
  349. int offset = MUSB_EP_OFFSET(epnum,
  350. MUSB_TXCSR);
  351. u16 txcsr;
  352. /*
  353. * The programming guide says that we
  354. * must clear DMAENAB before DMAMODE.
  355. */
  356. musb_ep_select(mbase, epnum);
  357. txcsr = musb_readw(mbase, offset);
  358. txcsr &= ~(MUSB_TXCSR_DMAENAB | MUSB_TXCSR_AUTOSET);
  359. musb_writew(mbase, offset, txcsr);
  360. /* Send out the packet */
  361. txcsr &= ~MUSB_TXCSR_DMAMODE;
  362. txcsr |= MUSB_TXCSR_TXPKTRDY;
  363. musb_writew(mbase, offset, txcsr);
  364. }
  365. musb_dma_completion(musb, musb_channel->epnum,
  366. musb_channel->transmit);
  367. }
  368. }
  369. }
  370. DBG(4, "MUSB: DMA interrupt completino on ep\n");
  371. retval = IRQ_HANDLED;
  372. done:
  373. spin_unlock_irqrestore(&musb->lock, flags);
  374. return retval;
  375. }
  376. void dma_controller_destroy(struct dma_controller *c)
  377. {
  378. struct musb_dma_controller *controller = container_of(c,
  379. struct musb_dma_controller,
  380. controller);
  381. if (!controller)
  382. return;
  383. if (controller->irq)
  384. free_irq(controller->irq, c);
  385. kfree(controller);
  386. }
  387. struct dma_controller *dma_controller_create(struct musb *musb, void __iomem *base)
  388. {
  389. struct musb_dma_controller *controller;
  390. int irq = musb->dma_irq;
  391. if ((irq <= 0) && (irq != SHARE_IRQ)) {
  392. DBG(0, "No DMA interrupt line!\n");
  393. return NULL;
  394. }
  395. controller = kzalloc(sizeof(*controller), GFP_KERNEL);
  396. if (!controller)
  397. return NULL;
  398. controller->channel_count = MUSB_HSDMA_CHANNELS;
  399. controller->private_data = musb;
  400. controller->base = base;
  401. controller->controller.start = dma_controller_start;
  402. controller->controller.stop = dma_controller_stop;
  403. controller->controller.channel_alloc = dma_channel_allocate;
  404. controller->controller.channel_release = dma_channel_release;
  405. controller->controller.channel_program = dma_channel_program;
  406. controller->controller.channel_abort = dma_channel_abort;
  407. controller->controller.channel_pause = dma_channel_pause;
  408. controller->controller.channel_resume = dma_channel_resume;
  409. controller->controller.tx_status = dma_channel_tx_status;
  410. controller->controller.check_residue = dma_channel_check_residue;
  411. if (irq != SHARE_IRQ) {
  412. if (request_irq(irq, dma_controller_irq, 0,
  413. dev_name(musb->controller), &controller->controller)) {
  414. DBG(0, "request_irq %d failed!\n", irq);
  415. dma_controller_destroy(&controller->controller);
  416. return NULL;
  417. }
  418. }
  419. controller->irq = irq;
  420. return &controller->controller;
  421. }
  422. #define MUSB_HSDMA_REAL_COUNT 0x80
  423. #define USB_HSDMA_CHANNEL_OFFSET(_bchannel, _offset) \
  424. (MUSB_HSDMA_BASE + (_bchannel << 4) + _offset)
  425. #define usb_read_hsdma_addr(mbase, bchannel) \
  426. musb_readl(mbase, \
  427. USB_HSDMA_CHANNEL_OFFSET(bchannel, MUSB_HSDMA_ADDRESS))
  428. #define usb_read_hsdma_ctrl(mbase, bchannel) \
  429. musb_readb(mbase, \
  430. MUSB_HSDMA_CHANNEL_OFFSET(bchannel, MUSB_HSDMA_CONTROL))
  431. #define usb_read_hsdma_count(mbase, bchannel) \
  432. musb_readl(mbase, \
  433. MUSB_HSDMA_CHANNEL_OFFSET(bchannel, MUSB_HSDMA_COUNT))
  434. #define usb_read_hsdma_real_count(mbase, bchannel) \
  435. musb_readl(mbase, \
  436. MUSB_HSDMA_CHANNEL_OFFSET(bchannel, MUSB_HSDMA_REAL_COUNT))
  437. u8 USB_DMA_status(u8 *pbDMAen, u8 *pbDMAdir)
  438. {
  439. u8 bchannel;
  440. u8 bDMAen = 0;
  441. u8 bDMAdir = 0;
  442. #ifdef CONFIG_OF
  443. for (bchannel = 0; bchannel < MUSB_HSDMA_CHANNELS; bchannel++) {
  444. bDMAen |= (usb_read_hsdma_ctrl(mtk_musb->mregs, bchannel) & 0x01) << bchannel;
  445. bDMAdir |=
  446. ((usb_read_hsdma_ctrl(mtk_musb->mregs, bchannel) & 0x02) >> 1) << bchannel;
  447. }
  448. #else
  449. void __iomem *base = USB_BASE;
  450. for (bchannel = 0; bchannel < MUSB_HSDMA_CHANNELS; bchannel++) {
  451. bDMAen |= (usb_read_hsdma_ctrl(base, bchannel) & 0x01) << bchannel;
  452. bDMAdir |= ((usb_read_hsdma_ctrl(base, bchannel) & 0x02) >> 1) << bchannel;
  453. }
  454. #endif
  455. if (pbDMAen)
  456. *pbDMAen = bDMAen;
  457. if (pbDMAdir)
  458. *pbDMAdir = bDMAdir;
  459. if (bDMAen > 0)
  460. return 1;
  461. else
  462. return 0;
  463. }
  464. EXPORT_SYMBOL(USB_DMA_status);
  465. u32 USB_DMA_address(u32 *len, u8 bchannel)
  466. {
  467. #ifdef CONFIG_OF
  468. /* void __iomem *base = USB_BASE; */
  469. if (len) {
  470. *len =
  471. usb_read_hsdma_count(mtk_musb->mregs,
  472. bchannel) + usb_read_hsdma_real_count(mtk_musb->mregs,
  473. bchannel);
  474. }
  475. return (usb_read_hsdma_addr(mtk_musb->mregs, bchannel) -
  476. usb_read_hsdma_real_count(mtk_musb->mregs, bchannel));
  477. #else
  478. void __iomem *base = (void *)USB_BASE;
  479. if (len) {
  480. *len =
  481. usb_read_hsdma_count(base, bchannel) + usb_read_hsdma_real_count(base,
  482. bchannel);
  483. }
  484. return usb_read_hsdma_addr(base, bchannel) - usb_read_hsdma_real_count(base, bchannel);
  485. #endif
  486. }
  487. EXPORT_SYMBOL(USB_DMA_address);