etr.h 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. /*
  2. * include/asm-s390/etr.h
  3. *
  4. * Copyright IBM Corp. 2006
  5. * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
  6. */
  7. #ifndef __S390_ETR_H
  8. #define __S390_ETR_H
  9. /* ETR attachment control register */
  10. struct etr_eacr {
  11. unsigned int e0 : 1; /* port 0 stepping control */
  12. unsigned int e1 : 1; /* port 1 stepping control */
  13. unsigned int _pad0 : 5; /* must be 00100 */
  14. unsigned int dp : 1; /* data port control */
  15. unsigned int p0 : 1; /* port 0 change recognition control */
  16. unsigned int p1 : 1; /* port 1 change recognition control */
  17. unsigned int _pad1 : 3; /* must be 000 */
  18. unsigned int ea : 1; /* ETR alert control */
  19. unsigned int es : 1; /* ETR sync check control */
  20. unsigned int sl : 1; /* switch to local control */
  21. } __attribute__ ((packed));
  22. /* Port state returned by steai */
  23. enum etr_psc {
  24. etr_psc_operational = 0,
  25. etr_psc_semi_operational = 1,
  26. etr_psc_protocol_error = 4,
  27. etr_psc_no_symbols = 8,
  28. etr_psc_no_signal = 12,
  29. etr_psc_pps_mode = 13
  30. };
  31. /* Logical port state returned by stetr */
  32. enum etr_lpsc {
  33. etr_lpsc_operational_step = 0,
  34. etr_lpsc_operational_alt = 1,
  35. etr_lpsc_semi_operational = 2,
  36. etr_lpsc_protocol_error = 4,
  37. etr_lpsc_no_symbol_sync = 8,
  38. etr_lpsc_no_signal = 12,
  39. etr_lpsc_pps_mode = 13
  40. };
  41. /* ETR status words */
  42. struct etr_esw {
  43. struct etr_eacr eacr; /* attachment control register */
  44. unsigned int y : 1; /* stepping mode */
  45. unsigned int _pad0 : 5; /* must be 00000 */
  46. unsigned int p : 1; /* stepping port number */
  47. unsigned int q : 1; /* data port number */
  48. unsigned int psc0 : 4; /* port 0 state code */
  49. unsigned int psc1 : 4; /* port 1 state code */
  50. } __attribute__ ((packed));
  51. /* Second level data register status word */
  52. struct etr_slsw {
  53. unsigned int vv1 : 1; /* copy of validity bit data frame 1 */
  54. unsigned int vv2 : 1; /* copy of validity bit data frame 2 */
  55. unsigned int vv3 : 1; /* copy of validity bit data frame 3 */
  56. unsigned int vv4 : 1; /* copy of validity bit data frame 4 */
  57. unsigned int _pad0 : 19; /* must by all zeroes */
  58. unsigned int n : 1; /* EAF port number */
  59. unsigned int v1 : 1; /* validity bit ETR data frame 1 */
  60. unsigned int v2 : 1; /* validity bit ETR data frame 2 */
  61. unsigned int v3 : 1; /* validity bit ETR data frame 3 */
  62. unsigned int v4 : 1; /* validity bit ETR data frame 4 */
  63. unsigned int _pad1 : 4; /* must be 0000 */
  64. } __attribute__ ((packed));
  65. /* ETR data frames */
  66. struct etr_edf1 {
  67. unsigned int u : 1; /* untuned bit */
  68. unsigned int _pad0 : 1; /* must be 0 */
  69. unsigned int r : 1; /* service request bit */
  70. unsigned int _pad1 : 4; /* must be 0000 */
  71. unsigned int a : 1; /* time adjustment bit */
  72. unsigned int net_id : 8; /* ETR network id */
  73. unsigned int etr_id : 8; /* id of ETR which sends data frames */
  74. unsigned int etr_pn : 8; /* port number of ETR output port */
  75. } __attribute__ ((packed));
  76. struct etr_edf2 {
  77. unsigned int etv : 32; /* Upper 32 bits of TOD. */
  78. } __attribute__ ((packed));
  79. struct etr_edf3 {
  80. unsigned int rc : 8; /* failure reason code */
  81. unsigned int _pad0 : 3; /* must be 000 */
  82. unsigned int c : 1; /* ETR coupled bit */
  83. unsigned int tc : 4; /* ETR type code */
  84. unsigned int blto : 8; /* biased local time offset */
  85. /* (blto - 128) * 15 = minutes */
  86. unsigned int buo : 8; /* biased utc offset */
  87. /* (buo - 128) = leap seconds */
  88. } __attribute__ ((packed));
  89. struct etr_edf4 {
  90. unsigned int ed : 8; /* ETS device dependent data */
  91. unsigned int _pad0 : 1; /* must be 0 */
  92. unsigned int buc : 5; /* biased ut1 correction */
  93. /* (buc - 16) * 0.1 seconds */
  94. unsigned int em : 6; /* ETS error magnitude */
  95. unsigned int dc : 6; /* ETS drift code */
  96. unsigned int sc : 6; /* ETS steering code */
  97. } __attribute__ ((packed));
  98. /*
  99. * ETR attachment information block, two formats
  100. * format 1 has 4 reserved words with a size of 64 bytes
  101. * format 2 has 16 reserved words with a size of 96 bytes
  102. */
  103. struct etr_aib {
  104. struct etr_esw esw;
  105. struct etr_slsw slsw;
  106. unsigned long long tsp;
  107. struct etr_edf1 edf1;
  108. struct etr_edf2 edf2;
  109. struct etr_edf3 edf3;
  110. struct etr_edf4 edf4;
  111. unsigned int reserved[16];
  112. } __attribute__ ((packed,aligned(8)));
  113. /* ETR interruption parameter */
  114. struct etr_irq_parm {
  115. unsigned int _pad0 : 8;
  116. unsigned int pc0 : 1; /* port 0 state change */
  117. unsigned int pc1 : 1; /* port 1 state change */
  118. unsigned int _pad1 : 3;
  119. unsigned int eai : 1; /* ETR alert indication */
  120. unsigned int _pad2 : 18;
  121. } __attribute__ ((packed));
  122. /* Query TOD offset result */
  123. struct etr_ptff_qto {
  124. unsigned long long physical_clock;
  125. unsigned long long tod_offset;
  126. unsigned long long logical_tod_offset;
  127. unsigned long long tod_epoch_difference;
  128. } __attribute__ ((packed));
  129. /* Inline assembly helper functions */
  130. static inline int etr_setr(struct etr_eacr *ctrl)
  131. {
  132. int rc = -ENOSYS;
  133. asm volatile(
  134. " .insn s,0xb2160000,%1\n"
  135. "0: la %0,0\n"
  136. "1:\n"
  137. EX_TABLE(0b,1b)
  138. : "+d" (rc) : "Q" (*ctrl));
  139. return rc;
  140. }
  141. /* Stores a format 1 aib with 64 bytes */
  142. static inline int etr_stetr(struct etr_aib *aib)
  143. {
  144. int rc = -ENOSYS;
  145. asm volatile(
  146. " .insn s,0xb2170000,%1\n"
  147. "0: la %0,0\n"
  148. "1:\n"
  149. EX_TABLE(0b,1b)
  150. : "+d" (rc) : "Q" (*aib));
  151. return rc;
  152. }
  153. /* Stores a format 2 aib with 96 bytes for specified port */
  154. static inline int etr_steai(struct etr_aib *aib, unsigned int func)
  155. {
  156. register unsigned int reg0 asm("0") = func;
  157. int rc = -ENOSYS;
  158. asm volatile(
  159. " .insn s,0xb2b30000,%1\n"
  160. "0: la %0,0\n"
  161. "1:\n"
  162. EX_TABLE(0b,1b)
  163. : "+d" (rc) : "Q" (*aib), "d" (reg0));
  164. return rc;
  165. }
  166. /* Function codes for the steai instruction. */
  167. #define ETR_STEAI_STEPPING_PORT 0x10
  168. #define ETR_STEAI_ALTERNATE_PORT 0x11
  169. #define ETR_STEAI_PORT_0 0x12
  170. #define ETR_STEAI_PORT_1 0x13
  171. static inline int etr_ptff(void *ptff_block, unsigned int func)
  172. {
  173. register unsigned int reg0 asm("0") = func;
  174. register unsigned long reg1 asm("1") = (unsigned long) ptff_block;
  175. int rc = -ENOSYS;
  176. asm volatile(
  177. " .word 0x0104\n"
  178. " ipm %0\n"
  179. " srl %0,28\n"
  180. : "=d" (rc), "=m" (ptff_block)
  181. : "d" (reg0), "d" (reg1), "m" (ptff_block) : "cc");
  182. return rc;
  183. }
  184. /* Function codes for the ptff instruction. */
  185. #define ETR_PTFF_QAF 0x00 /* query available functions */
  186. #define ETR_PTFF_QTO 0x01 /* query tod offset */
  187. #define ETR_PTFF_QSI 0x02 /* query steering information */
  188. #define ETR_PTFF_ATO 0x40 /* adjust tod offset */
  189. #define ETR_PTFF_STO 0x41 /* set tod offset */
  190. #define ETR_PTFF_SFS 0x42 /* set fine steering rate */
  191. #define ETR_PTFF_SGS 0x43 /* set gross steering rate */
  192. /* Functions needed by the machine check handler */
  193. void etr_switch_to_local(void);
  194. void etr_sync_check(void);
  195. /* STP interruption parameter */
  196. struct stp_irq_parm {
  197. unsigned int _pad0 : 14;
  198. unsigned int tsc : 1; /* Timing status change */
  199. unsigned int lac : 1; /* Link availability change */
  200. unsigned int tcpc : 1; /* Time control parameter change */
  201. unsigned int _pad2 : 15;
  202. } __attribute__ ((packed));
  203. #define STP_OP_SYNC 1
  204. #define STP_OP_CTRL 3
  205. struct stp_sstpi {
  206. unsigned int rsvd0;
  207. unsigned int rsvd1 : 8;
  208. unsigned int stratum : 8;
  209. unsigned int vbits : 16;
  210. unsigned int leaps : 16;
  211. unsigned int tmd : 4;
  212. unsigned int ctn : 4;
  213. unsigned int rsvd2 : 3;
  214. unsigned int c : 1;
  215. unsigned int tst : 4;
  216. unsigned int tzo : 16;
  217. unsigned int dsto : 16;
  218. unsigned int ctrl : 16;
  219. unsigned int rsvd3 : 16;
  220. unsigned int tto;
  221. unsigned int rsvd4;
  222. unsigned int ctnid[3];
  223. unsigned int rsvd5;
  224. unsigned int todoff[4];
  225. unsigned int rsvd6[48];
  226. } __attribute__ ((packed));
  227. /* Functions needed by the machine check handler */
  228. void stp_sync_check(void);
  229. void stp_island_check(void);
  230. #endif /* __S390_ETR_H */