musbhsdma.h 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. #define MUSB_HSDMA_BASE 0x200
  34. #define MUSB_HSDMA_INTR (MUSB_HSDMA_BASE + 0)
  35. #define MUSB_HSDMA_CONTROL 0x4
  36. #define MUSB_HSDMA_ADDRESS 0x8
  37. #define MUSB_HSDMA_COUNT 0xc
  38. #define MUSB_HSDMA_CHANNEL_OFFSET(_bchannel, _offset) \
  39. (MUSB_HSDMA_BASE + (_bchannel << 4) + _offset)
  40. #define musb_read_hsdma_addr(mbase, bchannel) \
  41. musb_readl(mbase, \
  42. MUSB_HSDMA_CHANNEL_OFFSET(bchannel, MUSB_HSDMA_ADDRESS))
  43. #define musb_write_hsdma_addr(mbase, bchannel, addr) \
  44. musb_writel(mbase, \
  45. MUSB_HSDMA_CHANNEL_OFFSET(bchannel, MUSB_HSDMA_ADDRESS), \
  46. addr)
  47. #define musb_read_hsdma_count(mbase, bchannel) \
  48. musb_readl(mbase, \
  49. MUSB_HSDMA_CHANNEL_OFFSET(bchannel, MUSB_HSDMA_COUNT))
  50. #define musb_write_hsdma_count(mbase, bchannel, len) \
  51. musb_writel(mbase, \
  52. MUSB_HSDMA_CHANNEL_OFFSET(bchannel, MUSB_HSDMA_COUNT), \
  53. len)
  54. /* control register (16-bit): */
  55. #define MUSB_HSDMA_ENABLE_SHIFT 0
  56. #define MUSB_HSDMA_TRANSMIT_SHIFT 1
  57. #define MUSB_HSDMA_MODE1_SHIFT 2
  58. #define MUSB_HSDMA_IRQENABLE_SHIFT 3
  59. #define MUSB_HSDMA_ENDPOINT_SHIFT 4
  60. #define MUSB_HSDMA_BUSERROR_SHIFT 8
  61. #define MUSB_HSDMA_BURSTMODE_SHIFT 9
  62. #define MUSB_HSDMA_BURSTMODE (3 << MUSB_HSDMA_BURSTMODE_SHIFT)
  63. #define MUSB_HSDMA_BURSTMODE_UNSPEC 0
  64. #define MUSB_HSDMA_BURSTMODE_INCR4 1
  65. #define MUSB_HSDMA_BURSTMODE_INCR8 2
  66. #define MUSB_HSDMA_BURSTMODE_INCR16 3
  67. #define MUSB_HSDMA_CHANNELS 8
  68. struct musb_dma_controller;
  69. struct musb_dma_channel {
  70. struct dma_channel channel;
  71. struct musb_dma_controller *controller;
  72. u32 start_addr;
  73. u32 len;
  74. u16 max_packet_sz;
  75. u8 idx;
  76. u8 epnum;
  77. u8 transmit;
  78. };
  79. struct musb_dma_controller {
  80. struct dma_controller controller;
  81. struct musb_dma_channel channel[MUSB_HSDMA_CHANNELS];
  82. void *private_data;
  83. void __iomem *base;
  84. u8 channel_count;
  85. u8 used_channels;
  86. u8 irq;
  87. };