musbhsdma.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * MUSB OTG driver - support for Mentor's DMA controller
  4. *
  5. * Copyright 2005 Mentor Graphics Corporation
  6. * Copyright (C) 2005-2007 by Texas Instruments
  7. */
  8. #define MUSB_HSDMA_BASE 0x200
  9. #define MUSB_HSDMA_INTR (MUSB_HSDMA_BASE + 0)
  10. #define MUSB_HSDMA_CONTROL 0x4
  11. #define MUSB_HSDMA_ADDRESS 0x8
  12. #define MUSB_HSDMA_COUNT 0xc
  13. #define MUSB_HSDMA_CHANNEL_OFFSET(_bchannel, _offset) \
  14. (MUSB_HSDMA_BASE + (_bchannel << 4) + _offset)
  15. #define musb_read_hsdma_addr(mbase, bchannel) \
  16. musb_readl(mbase, \
  17. MUSB_HSDMA_CHANNEL_OFFSET(bchannel, MUSB_HSDMA_ADDRESS))
  18. #define musb_write_hsdma_addr(mbase, bchannel, addr) \
  19. musb_writel(mbase, \
  20. MUSB_HSDMA_CHANNEL_OFFSET(bchannel, MUSB_HSDMA_ADDRESS), \
  21. addr)
  22. #define musb_read_hsdma_count(mbase, bchannel) \
  23. musb_readl(mbase, \
  24. MUSB_HSDMA_CHANNEL_OFFSET(bchannel, MUSB_HSDMA_COUNT))
  25. #define musb_write_hsdma_count(mbase, bchannel, len) \
  26. musb_writel(mbase, \
  27. MUSB_HSDMA_CHANNEL_OFFSET(bchannel, MUSB_HSDMA_COUNT), \
  28. len)
  29. /* control register (16-bit): */
  30. #define MUSB_HSDMA_ENABLE_SHIFT 0
  31. #define MUSB_HSDMA_TRANSMIT_SHIFT 1
  32. #define MUSB_HSDMA_MODE1_SHIFT 2
  33. #define MUSB_HSDMA_IRQENABLE_SHIFT 3
  34. #define MUSB_HSDMA_ENDPOINT_SHIFT 4
  35. #define MUSB_HSDMA_BUSERROR_SHIFT 8
  36. #define MUSB_HSDMA_BURSTMODE_SHIFT 9
  37. #define MUSB_HSDMA_BURSTMODE (3 << MUSB_HSDMA_BURSTMODE_SHIFT)
  38. #define MUSB_HSDMA_BURSTMODE_UNSPEC 0
  39. #define MUSB_HSDMA_BURSTMODE_INCR4 1
  40. #define MUSB_HSDMA_BURSTMODE_INCR8 2
  41. #define MUSB_HSDMA_BURSTMODE_INCR16 3
  42. #define MUSB_HSDMA_CHANNELS 4
  43. struct musb_dma_controller;
  44. struct musb_dma_channel {
  45. struct dma_channel channel;
  46. struct musb_dma_controller *controller;
  47. u32 start_addr;
  48. u32 len;
  49. u16 max_packet_sz;
  50. u8 idx;
  51. u8 epnum;
  52. u8 transmit;
  53. };
  54. struct musb_dma_controller {
  55. struct dma_controller controller;
  56. struct musb_dma_channel channel[MUSB_HSDMA_CHANNELS];
  57. void *private_data;
  58. void __iomem *base;
  59. u8 channel_count;
  60. u8 used_channels;
  61. int irq;
  62. };