mesh.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * mesh.h: definitions for the driver for the MESH SCSI bus adaptor
  4. * (Macintosh Enhanced SCSI Hardware) found on Power Macintosh computers.
  5. *
  6. * Copyright (C) 1996 Paul Mackerras.
  7. */
  8. #ifndef _MESH_H
  9. #define _MESH_H
  10. struct mesh_cmd_priv {
  11. int this_residual;
  12. int message;
  13. int status;
  14. };
  15. static inline struct mesh_cmd_priv *mesh_priv(struct scsi_cmnd *cmd)
  16. {
  17. return scsi_cmd_priv(cmd);
  18. }
  19. /*
  20. * Registers in the MESH controller.
  21. */
  22. struct mesh_regs {
  23. unsigned char count_lo;
  24. char pad0[15];
  25. unsigned char count_hi;
  26. char pad1[15];
  27. unsigned char fifo;
  28. char pad2[15];
  29. unsigned char sequence;
  30. char pad3[15];
  31. unsigned char bus_status0;
  32. char pad4[15];
  33. unsigned char bus_status1;
  34. char pad5[15];
  35. unsigned char fifo_count;
  36. char pad6[15];
  37. unsigned char exception;
  38. char pad7[15];
  39. unsigned char error;
  40. char pad8[15];
  41. unsigned char intr_mask;
  42. char pad9[15];
  43. unsigned char interrupt;
  44. char pad10[15];
  45. unsigned char source_id;
  46. char pad11[15];
  47. unsigned char dest_id;
  48. char pad12[15];
  49. unsigned char sync_params;
  50. char pad13[15];
  51. unsigned char mesh_id;
  52. char pad14[15];
  53. unsigned char sel_timeout;
  54. char pad15[15];
  55. };
  56. /* Bits in the sequence register. */
  57. #define SEQ_DMA_MODE 0x80 /* use DMA for data transfer */
  58. #define SEQ_TARGET 0x40 /* put the controller into target mode */
  59. #define SEQ_ATN 0x20 /* assert ATN signal */
  60. #define SEQ_ACTIVE_NEG 0x10 /* use active negation on REQ/ACK */
  61. #define SEQ_CMD 0x0f /* command bits: */
  62. #define SEQ_ARBITRATE 1 /* get the bus */
  63. #define SEQ_SELECT 2 /* select a target */
  64. #define SEQ_COMMAND 3 /* send a command */
  65. #define SEQ_STATUS 4 /* receive status */
  66. #define SEQ_DATAOUT 5 /* send data */
  67. #define SEQ_DATAIN 6 /* receive data */
  68. #define SEQ_MSGOUT 7 /* send a message */
  69. #define SEQ_MSGIN 8 /* receive a message */
  70. #define SEQ_BUSFREE 9 /* look for bus free */
  71. #define SEQ_ENBPARITY 0x0a /* enable parity checking */
  72. #define SEQ_DISPARITY 0x0b /* disable parity checking */
  73. #define SEQ_ENBRESEL 0x0c /* enable reselection */
  74. #define SEQ_DISRESEL 0x0d /* disable reselection */
  75. #define SEQ_RESETMESH 0x0e /* reset the controller */
  76. #define SEQ_FLUSHFIFO 0x0f /* clear out the FIFO */
  77. /* Bits in the bus_status0 and bus_status1 registers:
  78. these correspond directly to the SCSI bus control signals. */
  79. #define BS0_REQ 0x20
  80. #define BS0_ACK 0x10
  81. #define BS0_ATN 0x08
  82. #define BS0_MSG 0x04
  83. #define BS0_CD 0x02
  84. #define BS0_IO 0x01
  85. #define BS1_RST 0x80
  86. #define BS1_BSY 0x40
  87. #define BS1_SEL 0x20
  88. /* Bus phases defined by the bits in bus_status0 */
  89. #define BS0_PHASE (BS0_MSG+BS0_CD+BS0_IO)
  90. #define BP_DATAOUT 0
  91. #define BP_DATAIN BS0_IO
  92. #define BP_COMMAND BS0_CD
  93. #define BP_STATUS (BS0_CD+BS0_IO)
  94. #define BP_MSGOUT (BS0_MSG+BS0_CD)
  95. #define BP_MSGIN (BS0_MSG+BS0_CD+BS0_IO)
  96. /* Bits in the exception register. */
  97. #define EXC_SELWATN 0x20 /* (as target) we were selected with ATN */
  98. #define EXC_SELECTED 0x10 /* (as target) we were selected w/o ATN */
  99. #define EXC_RESELECTED 0x08 /* (as initiator) we were reselected */
  100. #define EXC_ARBLOST 0x04 /* we lost arbitration */
  101. #define EXC_PHASEMM 0x02 /* SCSI phase mismatch */
  102. #define EXC_SELTO 0x01 /* selection timeout */
  103. /* Bits in the error register */
  104. #define ERR_UNEXPDISC 0x40 /* target unexpectedly disconnected */
  105. #define ERR_SCSIRESET 0x20 /* SCSI bus got reset on us */
  106. #define ERR_SEQERR 0x10 /* we did something the chip didn't like */
  107. #define ERR_PARITY 0x01 /* parity error was detected */
  108. /* Bits in the interrupt and intr_mask registers */
  109. #define INT_ERROR 0x04 /* error interrupt */
  110. #define INT_EXCEPTION 0x02 /* exception interrupt */
  111. #define INT_CMDDONE 0x01 /* command done interrupt */
  112. /* Fields in the sync_params register */
  113. #define SYNC_OFF(x) ((x) >> 4) /* offset field */
  114. #define SYNC_PER(x) ((x) & 0xf) /* period field */
  115. #define SYNC_PARAMS(o, p) (((o) << 4) | (p))
  116. #define ASYNC_PARAMS 2 /* sync_params value for async xfers */
  117. /*
  118. * Assuming a clock frequency of 50MHz:
  119. *
  120. * The transfer period with SYNC_PER(sync_params) == x
  121. * is (x + 2) * 40ns, except that x == 0 gives 100ns.
  122. *
  123. * The units of the sel_timeout register are 10ms.
  124. */
  125. #endif /* _MESH_H */