dbdma.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Definitions for using the Apple Descriptor-Based DMA controller
  4. * in Power Macintosh computers.
  5. *
  6. * Copyright (C) 1996 Paul Mackerras.
  7. */
  8. #ifdef __KERNEL__
  9. #ifndef _ASM_DBDMA_H_
  10. #define _ASM_DBDMA_H_
  11. /*
  12. * DBDMA control/status registers. All little-endian.
  13. */
  14. struct dbdma_regs {
  15. unsigned int control; /* lets you change bits in status */
  16. unsigned int status; /* DMA and device status bits (see below) */
  17. unsigned int cmdptr_hi; /* upper 32 bits of command address */
  18. unsigned int cmdptr; /* (lower 32 bits of) command address (phys) */
  19. unsigned int intr_sel; /* select interrupt condition bit */
  20. unsigned int br_sel; /* select branch condition bit */
  21. unsigned int wait_sel; /* select wait condition bit */
  22. unsigned int xfer_mode;
  23. unsigned int data2ptr_hi;
  24. unsigned int data2ptr;
  25. unsigned int res1;
  26. unsigned int address_hi;
  27. unsigned int br_addr_hi;
  28. unsigned int res2[3];
  29. };
  30. /* Bits in control and status registers */
  31. #define RUN 0x8000
  32. #define PAUSE 0x4000
  33. #define FLUSH 0x2000
  34. #define WAKE 0x1000
  35. #define DEAD 0x0800
  36. #define ACTIVE 0x0400
  37. #define BT 0x0100
  38. #define DEVSTAT 0x00ff
  39. /*
  40. * DBDMA command structure. These fields are all little-endian!
  41. */
  42. struct dbdma_cmd {
  43. __le16 req_count; /* requested byte transfer count */
  44. __le16 command; /* command word (has bit-fields) */
  45. __le32 phy_addr; /* physical data address */
  46. __le32 cmd_dep; /* command-dependent field */
  47. __le16 res_count; /* residual count after completion */
  48. __le16 xfer_status; /* transfer status */
  49. };
  50. /* DBDMA command values in command field */
  51. #define OUTPUT_MORE 0 /* transfer memory data to stream */
  52. #define OUTPUT_LAST 0x1000 /* ditto followed by end marker */
  53. #define INPUT_MORE 0x2000 /* transfer stream data to memory */
  54. #define INPUT_LAST 0x3000 /* ditto, expect end marker */
  55. #define STORE_WORD 0x4000 /* write word (4 bytes) to device reg */
  56. #define LOAD_WORD 0x5000 /* read word (4 bytes) from device reg */
  57. #define DBDMA_NOP 0x6000 /* do nothing */
  58. #define DBDMA_STOP 0x7000 /* suspend processing */
  59. /* Key values in command field */
  60. #define KEY_STREAM0 0 /* usual data stream */
  61. #define KEY_STREAM1 0x100 /* control/status stream */
  62. #define KEY_STREAM2 0x200 /* device-dependent stream */
  63. #define KEY_STREAM3 0x300 /* device-dependent stream */
  64. #define KEY_REGS 0x500 /* device register space */
  65. #define KEY_SYSTEM 0x600 /* system memory-mapped space */
  66. #define KEY_DEVICE 0x700 /* device memory-mapped space */
  67. /* Interrupt control values in command field */
  68. #define INTR_NEVER 0 /* don't interrupt */
  69. #define INTR_IFSET 0x10 /* intr if condition bit is 1 */
  70. #define INTR_IFCLR 0x20 /* intr if condition bit is 0 */
  71. #define INTR_ALWAYS 0x30 /* always interrupt */
  72. /* Branch control values in command field */
  73. #define BR_NEVER 0 /* don't branch */
  74. #define BR_IFSET 0x4 /* branch if condition bit is 1 */
  75. #define BR_IFCLR 0x8 /* branch if condition bit is 0 */
  76. #define BR_ALWAYS 0xc /* always branch */
  77. /* Wait control values in command field */
  78. #define WAIT_NEVER 0 /* don't wait */
  79. #define WAIT_IFSET 1 /* wait if condition bit is 1 */
  80. #define WAIT_IFCLR 2 /* wait if condition bit is 0 */
  81. #define WAIT_ALWAYS 3 /* always wait */
  82. /* Align an address for a DBDMA command structure */
  83. #define DBDMA_ALIGN(x) (((unsigned long)(x) + sizeof(struct dbdma_cmd) - 1) \
  84. & -sizeof(struct dbdma_cmd))
  85. /* Useful macros */
  86. #define DBDMA_DO_STOP(regs) do { \
  87. out_le32(&((regs)->control), (RUN|FLUSH)<<16); \
  88. while(in_le32(&((regs)->status)) & (ACTIVE|FLUSH)) \
  89. ; \
  90. } while(0)
  91. #define DBDMA_DO_RESET(regs) do { \
  92. out_le32(&((regs)->control), (ACTIVE|DEAD|WAKE|FLUSH|PAUSE|RUN)<<16);\
  93. while(in_le32(&((regs)->status)) & (RUN)) \
  94. ; \
  95. } while(0)
  96. #endif /* _ASM_DBDMA_H_ */
  97. #endif /* __KERNEL__ */