comet.c 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569
  1. /* Copyright (C) 2003-2005 SBE, Inc.
  2. *
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License as published by
  5. * the Free Software Foundation; either version 2 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. */
  13. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  14. #include <asm/io.h>
  15. #include <linux/hdlc.h>
  16. #include "pmcc4_sysdep.h"
  17. #include "sbecom_inline_linux.h"
  18. #include "libsbew.h"
  19. #include "pmcc4.h"
  20. #include "comet.h"
  21. #include "comet_tables.h"
  22. #ifdef SBE_INCLUDE_SYMBOLS
  23. #define STATIC
  24. #else
  25. #define STATIC static
  26. #endif
  27. extern int cxt1e1_log_level;
  28. #define COMET_NUM_SAMPLES 24 /* Number of entries in the waveform table */
  29. #define COMET_NUM_UNITS 5 /* Number of points per entry in table */
  30. /* forward references */
  31. STATIC void SetPwrLevel (comet_t * comet);
  32. STATIC void WrtRcvEqualizerTbl (ci_t * ci, comet_t * comet, u_int32_t *table);
  33. STATIC void WrtXmtWaveformTbl (ci_t * ci, comet_t * comet, u_int8_t table[COMET_NUM_SAMPLES][COMET_NUM_UNITS]);
  34. void *TWV_table[12] = {
  35. TWVLongHaul0DB, TWVLongHaul7_5DB, TWVLongHaul15DB, TWVLongHaul22_5DB,
  36. TWVShortHaul0, TWVShortHaul1, TWVShortHaul2, TWVShortHaul3, TWVShortHaul4,
  37. TWVShortHaul5,
  38. TWV_E1_75Ohm, /** PORT POINT - 75 Ohm not supported **/
  39. TWV_E1_120Ohm
  40. };
  41. static int
  42. lbo_tbl_lkup (int t1, int lbo)
  43. {
  44. if ((lbo < CFG_LBO_LH0) || (lbo > CFG_LBO_E120)) /* error switches to
  45. * default */
  46. {
  47. if (t1)
  48. lbo = CFG_LBO_LH0; /* default T1 waveform table */
  49. else
  50. lbo = CFG_LBO_E120; /* default E1 waveform table */
  51. }
  52. return (lbo - 1); /* make index ZERO relative */
  53. }
  54. void
  55. init_comet (void *ci, comet_t * comet, u_int32_t port_mode, int clockmaster,
  56. u_int8_t moreParams)
  57. {
  58. u_int8_t isT1mode;
  59. u_int8_t tix = CFG_LBO_LH0; /* T1 default */
  60. isT1mode = IS_FRAME_ANY_T1 (port_mode);
  61. /* T1 or E1 */
  62. if (isT1mode)
  63. {
  64. pci_write_32 ((u_int32_t *) &comet->gbl_cfg, 0xa0); /* Select T1 Mode & PIO
  65. * output enabled */
  66. tix = lbo_tbl_lkup (isT1mode, CFG_LBO_LH0); /* default T1 waveform
  67. * table */
  68. } else
  69. {
  70. pci_write_32 ((u_int32_t *) &comet->gbl_cfg, 0x81); /* Select E1 Mode & PIO
  71. * output enabled */
  72. tix = lbo_tbl_lkup (isT1mode, CFG_LBO_E120); /* default E1 waveform
  73. * table */
  74. }
  75. if (moreParams & CFG_LBO_MASK)
  76. tix = lbo_tbl_lkup (isT1mode, moreParams & CFG_LBO_MASK); /* dial-in requested
  77. * waveform table */
  78. /* Tx line Intfc cfg ** Set for analog & no special patterns */
  79. pci_write_32 ((u_int32_t *) &comet->tx_line_cfg, 0x00); /* Transmit Line
  80. * Interface Config. */
  81. /* master test ** Ignore Test settings for now */
  82. pci_write_32 ((u_int32_t *) &comet->mtest, 0x00); /* making sure it's
  83. * Default value */
  84. /* Turn on Center (CENT) and everything else off */
  85. pci_write_32 ((u_int32_t *) &comet->rjat_cfg, 0x10); /* RJAT cfg */
  86. /* Set Jitter Attenuation to recommend T1 values */
  87. if (isT1mode)
  88. {
  89. pci_write_32 ((u_int32_t *) &comet->rjat_n1clk, 0x2F); /* RJAT Divider N1
  90. * Control */
  91. pci_write_32 ((u_int32_t *) &comet->rjat_n2clk, 0x2F); /* RJAT Divider N2
  92. * Control */
  93. } else
  94. {
  95. pci_write_32 ((u_int32_t *) &comet->rjat_n1clk, 0xFF); /* RJAT Divider N1
  96. * Control */
  97. pci_write_32 ((u_int32_t *) &comet->rjat_n2clk, 0xFF); /* RJAT Divider N2
  98. * Control */
  99. }
  100. /* Turn on Center (CENT) and everything else off */
  101. pci_write_32 ((u_int32_t *) &comet->tjat_cfg, 0x10); /* TJAT Config. */
  102. /* Do not bypass jitter attenuation and bypass elastic store */
  103. pci_write_32 ((u_int32_t *) &comet->rx_opt, 0x00); /* rx opts */
  104. /* TJAT ctrl & TJAT divider ctrl */
  105. /* Set Jitter Attenuation to recommended T1 values */
  106. if (isT1mode)
  107. {
  108. pci_write_32 ((u_int32_t *) &comet->tjat_n1clk, 0x2F); /* TJAT Divider N1
  109. * Control */
  110. pci_write_32 ((u_int32_t *) &comet->tjat_n2clk, 0x2F); /* TJAT Divider N2
  111. * Control */
  112. } else
  113. {
  114. pci_write_32 ((u_int32_t *) &comet->tjat_n1clk, 0xFF); /* TJAT Divider N1
  115. * Control */
  116. pci_write_32 ((u_int32_t *) &comet->tjat_n2clk, 0xFF); /* TJAT Divider N2
  117. * Control */
  118. }
  119. /* 1c: rx ELST cfg 20: tx ELST cfg 28&38: rx&tx data link ctrl */
  120. if (isT1mode)
  121. { /* Select 193-bit frame format */
  122. pci_write_32 ((u_int32_t *) &comet->rx_elst_cfg, 0x00);
  123. pci_write_32 ((u_int32_t *) &comet->tx_elst_cfg, 0x00);
  124. } else
  125. { /* Select 256-bit frame format */
  126. pci_write_32 ((u_int32_t *) &comet->rx_elst_cfg, 0x03);
  127. pci_write_32 ((u_int32_t *) &comet->tx_elst_cfg, 0x03);
  128. pci_write_32 ((u_int32_t *) &comet->rxce1_ctl, 0x00); /* disable T1 data link
  129. * receive */
  130. pci_write_32 ((u_int32_t *) &comet->txci1_ctl, 0x00); /* disable T1 data link
  131. * transmit */
  132. }
  133. /* the following is a default value */
  134. /* Enable 8 out of 10 validation */
  135. pci_write_32 ((u_int32_t *) &comet->t1_rboc_ena, 0x00); /* t1RBOC
  136. * enable(BOC:BitOriented
  137. * Code) */
  138. if (isT1mode)
  139. {
  140. /* IBCD cfg: aka Inband Code Detection ** loopback code length set to */
  141. pci_write_32 ((u_int32_t *) &comet->ibcd_cfg, 0x04); /* 6 bit down, 5 bit up
  142. * (assert) */
  143. pci_write_32 ((u_int32_t *) &comet->ibcd_act, 0x08); /* line loopback
  144. * activate pattern */
  145. pci_write_32 ((u_int32_t *) &comet->ibcd_deact, 0x24); /* deactivate code
  146. * pattern (i.e.001) */
  147. }
  148. /* 10: CDRC cfg 28&38: rx&tx data link 1 ctrl 48: t1 frmr cfg */
  149. /* 50: SIGX cfg, COSS (change of signaling state) 54: XBAS cfg */
  150. /* 60: t1 ALMI cfg */
  151. /* Configure Line Coding */
  152. switch (port_mode)
  153. {
  154. case CFG_FRAME_SF: /* 1 - T1 B8ZS */
  155. pci_write_32 ((u_int32_t *) &comet->cdrc_cfg, 0);
  156. pci_write_32 ((u_int32_t *) &comet->t1_frmr_cfg, 0);
  157. pci_write_32 ((u_int32_t *) &comet->sigx_cfg, 0);
  158. pci_write_32 ((u_int32_t *) &comet->t1_xbas_cfg, 0x20); /* 5:B8ZS */
  159. pci_write_32 ((u_int32_t *) &comet->t1_almi_cfg, 0);
  160. break;
  161. case CFG_FRAME_ESF: /* 2 - T1 B8ZS */
  162. pci_write_32 ((u_int32_t *) &comet->cdrc_cfg, 0);
  163. pci_write_32 ((u_int32_t *) &comet->rxce1_ctl, 0x20); /* Bit 5: T1 DataLink
  164. * Enable */
  165. pci_write_32 ((u_int32_t *) &comet->txci1_ctl, 0x20); /* 5: T1 DataLink Enable */
  166. pci_write_32 ((u_int32_t *) &comet->t1_frmr_cfg, 0x30); /* 4:ESF 5:ESFFA */
  167. pci_write_32 ((u_int32_t *) &comet->sigx_cfg, 0x04); /* 2:ESF */
  168. pci_write_32 ((u_int32_t *) &comet->t1_xbas_cfg, 0x30); /* 4:ESF 5:B8ZS */
  169. pci_write_32 ((u_int32_t *) &comet->t1_almi_cfg, 0x10); /* 4:ESF */
  170. break;
  171. case CFG_FRAME_E1PLAIN: /* 3 - HDB3 */
  172. pci_write_32 ((u_int32_t *) &comet->cdrc_cfg, 0);
  173. pci_write_32 ((u_int32_t *) &comet->sigx_cfg, 0);
  174. pci_write_32 ((u_int32_t *) &comet->e1_tran_cfg, 0);
  175. pci_write_32 ((u_int32_t *) &comet->e1_frmr_aopts, 0x40);
  176. break;
  177. case CFG_FRAME_E1CAS: /* 4 - HDB3 */
  178. pci_write_32 ((u_int32_t *) &comet->cdrc_cfg, 0);
  179. pci_write_32 ((u_int32_t *) &comet->sigx_cfg, 0);
  180. pci_write_32 ((u_int32_t *) &comet->e1_tran_cfg, 0x60);
  181. pci_write_32 ((u_int32_t *) &comet->e1_frmr_aopts, 0);
  182. break;
  183. case CFG_FRAME_E1CRC: /* 5 - HDB3 */
  184. pci_write_32 ((u_int32_t *) &comet->cdrc_cfg, 0);
  185. pci_write_32 ((u_int32_t *) &comet->sigx_cfg, 0);
  186. pci_write_32 ((u_int32_t *) &comet->e1_tran_cfg, 0x10);
  187. pci_write_32 ((u_int32_t *) &comet->e1_frmr_aopts, 0xc2);
  188. break;
  189. case CFG_FRAME_E1CRC_CAS: /* 6 - HDB3 */
  190. pci_write_32 ((u_int32_t *) &comet->cdrc_cfg, 0);
  191. pci_write_32 ((u_int32_t *) &comet->sigx_cfg, 0);
  192. pci_write_32 ((u_int32_t *) &comet->e1_tran_cfg, 0x70);
  193. pci_write_32 ((u_int32_t *) &comet->e1_frmr_aopts, 0x82);
  194. break;
  195. case CFG_FRAME_SF_AMI: /* 7 - T1 AMI */
  196. pci_write_32 ((u_int32_t *) &comet->cdrc_cfg, 0x80); /* Enable AMI Line
  197. * Decoding */
  198. pci_write_32 ((u_int32_t *) &comet->t1_frmr_cfg, 0);
  199. pci_write_32 ((u_int32_t *) &comet->t1_xbas_cfg, 0);
  200. pci_write_32 ((u_int32_t *) &comet->t1_almi_cfg, 0);
  201. pci_write_32 ((u_int32_t *) &comet->sigx_cfg, 0);
  202. break;
  203. case CFG_FRAME_ESF_AMI: /* 8 - T1 AMI */
  204. pci_write_32 ((u_int32_t *) &comet->cdrc_cfg, 0x80); /* Enable AMI Line
  205. * Decoding */
  206. pci_write_32 ((u_int32_t *) &comet->rxce1_ctl, 0x20); /* 5: T1 DataLink Enable */
  207. pci_write_32 ((u_int32_t *) &comet->txci1_ctl, 0x20); /* 5: T1 DataLink Enable */
  208. pci_write_32 ((u_int32_t *) &comet->t1_frmr_cfg, 0x30); /* Bit 4:ESF 5:ESFFA */
  209. pci_write_32 ((u_int32_t *) &comet->sigx_cfg, 0x04); /* 2:ESF */
  210. pci_write_32 ((u_int32_t *) &comet->t1_xbas_cfg, 0x10); /* 4:ESF */
  211. pci_write_32 ((u_int32_t *) &comet->t1_almi_cfg, 0x10); /* 4:ESF */
  212. break;
  213. case CFG_FRAME_E1PLAIN_AMI: /* 9 - AMI */
  214. pci_write_32 ((u_int32_t *) &comet->cdrc_cfg, 0x80); /* Enable AMI Line
  215. * Decoding */
  216. pci_write_32 ((u_int32_t *) &comet->sigx_cfg, 0);
  217. pci_write_32 ((u_int32_t *) &comet->e1_tran_cfg, 0x80);
  218. pci_write_32 ((u_int32_t *) &comet->e1_frmr_aopts, 0x40);
  219. break;
  220. case CFG_FRAME_E1CAS_AMI: /* 10 - AMI */
  221. pci_write_32 ((u_int32_t *) &comet->cdrc_cfg, 0x80); /* Enable AMI Line
  222. * Decoding */
  223. pci_write_32 ((u_int32_t *) &comet->sigx_cfg, 0);
  224. pci_write_32 ((u_int32_t *) &comet->e1_tran_cfg, 0xe0);
  225. pci_write_32 ((u_int32_t *) &comet->e1_frmr_aopts, 0);
  226. break;
  227. case CFG_FRAME_E1CRC_AMI: /* 11 - AMI */
  228. pci_write_32 ((u_int32_t *) &comet->cdrc_cfg, 0x80); /* Enable AMI Line
  229. * Decoding */
  230. pci_write_32 ((u_int32_t *) &comet->sigx_cfg, 0);
  231. pci_write_32 ((u_int32_t *) &comet->e1_tran_cfg, 0x90);
  232. pci_write_32 ((u_int32_t *) &comet->e1_frmr_aopts, 0xc2);
  233. break;
  234. case CFG_FRAME_E1CRC_CAS_AMI: /* 12 - AMI */
  235. pci_write_32 ((u_int32_t *) &comet->cdrc_cfg, 0x80); /* Enable AMI Line
  236. * Decoding */
  237. pci_write_32 ((u_int32_t *) &comet->sigx_cfg, 0);
  238. pci_write_32 ((u_int32_t *) &comet->e1_tran_cfg, 0xf0);
  239. pci_write_32 ((u_int32_t *) &comet->e1_frmr_aopts, 0x82);
  240. break;
  241. } /* end switch */
  242. /***
  243. * Set Full Frame mode (NXDSO[1] = 0, NXDSO[0] = 0)
  244. * CMODE=1: Clock slave mode with BRCLK as an input,
  245. * DE=0: Use falling edge of BRCLK for data,
  246. * FE=0: Use falling edge of BRCLK for frame,
  247. * CMS=0: Use backplane freq,
  248. * RATE[1:0]=0,0: T1
  249. ***/
  250. /* 0x30: "BRIF cfg"; 0x20 is 'CMODE', 0x03 is (bit) rate */
  251. /* note "rate bits can only be set once after reset" */
  252. if (clockmaster)
  253. { /* CMODE == clockMode, 0=clock master (so
  254. * all 3 others should be slave) */
  255. if (isT1mode) /* rate = 1.544 Mb/s */
  256. pci_write_32 ((u_int32_t *) &comet->brif_cfg, 0x00); /* Comet 0 Master
  257. * Mode(CMODE=0) */
  258. else /* rate = 2.048 Mb/s */
  259. pci_write_32 ((u_int32_t *) &comet->brif_cfg, 0x01); /* Comet 0 Master
  260. * Mode(CMODE=0) */
  261. /* 31: BRIF frame pulse cfg 06: tx timing options */
  262. pci_write_32 ((u_int32_t *) &comet->brif_fpcfg, 0x00); /* Master Mode
  263. * i.e.FPMODE=0 (@0x20) */
  264. if ((moreParams & CFG_CLK_PORT_MASK) == CFG_CLK_PORT_INTERNAL)
  265. {
  266. if (cxt1e1_log_level >= LOG_SBEBUG12)
  267. pr_info(">> %s: clockmaster internal clock\n", __func__);
  268. pci_write_32 ((u_int32_t *) &comet->tx_time, 0x0d); /* internal oscillator */
  269. } else /* external clock source */
  270. {
  271. if (cxt1e1_log_level >= LOG_SBEBUG12)
  272. pr_info(">> %s: clockmaster external clock\n", __func__);
  273. pci_write_32 ((u_int32_t *) &comet->tx_time, 0x09); /* loop timing
  274. * (external) */
  275. }
  276. } else /* slave */
  277. {
  278. if (isT1mode)
  279. pci_write_32 ((u_int32_t *) &comet->brif_cfg, 0x20); /* Slave Mode(CMODE=1,
  280. * see above) */
  281. else
  282. pci_write_32 ((u_int32_t *) &comet->brif_cfg, 0x21); /* Slave Mode (CMODE=1) */
  283. pci_write_32 ((u_int32_t *) &comet->brif_fpcfg, 0x20); /* Slave Mode i.e.
  284. * FPMODE=1 (@0x20) */
  285. if (cxt1e1_log_level >= LOG_SBEBUG12)
  286. pr_info(">> %s: clockslave internal clock\n", __func__);
  287. pci_write_32 ((u_int32_t *) &comet->tx_time, 0x0d); /* oscillator timing */
  288. }
  289. /* 32: BRIF parity F-bit cfg */
  290. /* Totem-pole operation */
  291. pci_write_32 ((u_int32_t *) &comet->brif_pfcfg, 0x01); /* Receive Backplane
  292. * Parity/F-bit */
  293. /* dc: RLPS equalizer V ref */
  294. /* Configuration */
  295. if (isT1mode)
  296. pci_write_32 ((u_int32_t *) &comet->rlps_eqvr, 0x2c); /* RLPS Equalizer
  297. * Voltage */
  298. else
  299. pci_write_32 ((u_int32_t *) &comet->rlps_eqvr, 0x34); /* RLPS Equalizer
  300. * Voltage */
  301. /* Reserved bit set and SQUELCH enabled */
  302. /* f8: RLPS cfg & status f9: RLPS ALOS detect/clear threshold */
  303. pci_write_32 ((u_int32_t *) &comet->rlps_cfgsts, 0x11); /* RLPS Configuration
  304. * Status */
  305. if (isT1mode)
  306. pci_write_32 ((u_int32_t *) &comet->rlps_alos_thresh, 0x55); /* ? */
  307. else
  308. pci_write_32 ((u_int32_t *) &comet->rlps_alos_thresh, 0x22); /* ? */
  309. /* Set Full Frame mode (NXDSO[1] = 0, NXDSO[0] = 0) */
  310. /* CMODE=0: Clock slave mode with BTCLK as an input, DE=1: Use rising */
  311. /* edge of BTCLK for data, FE=1: Use rising edge of BTCLK for frame, */
  312. /* CMS=0: Use backplane freq, RATE[1:0]=0,0: T1 */
  313. /*** Transmit side is always an Input, Slave Clock*/
  314. /* 40: BTIF cfg 41: BTIF frame pulse cfg */
  315. if (isT1mode)
  316. pci_write_32 ((u_int32_t *) &comet->btif_cfg, 0x38); /* BTIF Configuration
  317. * Reg. */
  318. else
  319. pci_write_32 ((u_int32_t *) &comet->btif_cfg, 0x39); /* BTIF Configuration
  320. * Reg. */
  321. pci_write_32 ((u_int32_t *) &comet->btif_fpcfg, 0x01); /* BTIF Frame Pulse
  322. * Config. */
  323. /* 0a: master diag 06: tx timing options */
  324. /* if set Comet to loop back */
  325. /* Comets set to normal */
  326. pci_write_32 ((u_int32_t *) &comet->mdiag, 0x00);
  327. /* BTCLK driven by TCLKI internally (crystal driven) and Xmt Elasted */
  328. /* Store is enabled. */
  329. WrtXmtWaveformTbl (ci, comet, TWV_table[tix]);
  330. if (isT1mode)
  331. WrtRcvEqualizerTbl ((ci_t *) ci, comet, &T1_Equalizer[0]);
  332. else
  333. WrtRcvEqualizerTbl ((ci_t *) ci, comet, &E1_Equalizer[0]);
  334. SetPwrLevel (comet);
  335. }
  336. /*
  337. ** Name: WrtXmtWaveform
  338. ** Description: Formulate the Data for the Pulse Waveform Storage
  339. ** Write register, (F2), from the sample and unit inputs.
  340. ** Write the data to the Pulse Waveform Storage Data register.
  341. ** Returns: Nothing
  342. */
  343. STATIC void
  344. WrtXmtWaveform (ci_t * ci, comet_t * comet, u_int32_t sample, u_int32_t unit, u_int8_t data)
  345. {
  346. u_int8_t WaveformAddr;
  347. WaveformAddr = (sample << 3) + (unit & 7);
  348. pci_write_32 ((u_int32_t *) &comet->xlpg_pwave_addr, WaveformAddr);
  349. pci_flush_write (ci); /* for write order preservation when
  350. * Optimizing driver */
  351. pci_write_32 ((u_int32_t *) &comet->xlpg_pwave_data, 0x7F & data);
  352. }
  353. /*
  354. ** Name: WrtXmtWaveformTbl
  355. ** Description: Fill in the Transmit Waveform Values
  356. ** for driving the transmitter DAC.
  357. ** Returns: Nothing
  358. */
  359. STATIC void
  360. WrtXmtWaveformTbl (ci_t * ci, comet_t * comet,
  361. u_int8_t table[COMET_NUM_SAMPLES][COMET_NUM_UNITS])
  362. {
  363. u_int32_t sample, unit;
  364. for (sample = 0; sample < COMET_NUM_SAMPLES; sample++)
  365. {
  366. for (unit = 0; unit < COMET_NUM_UNITS; unit++)
  367. WrtXmtWaveform (ci, comet, sample, unit, table[sample][unit]);
  368. }
  369. /* Enable transmitter and set output amplitude */
  370. pci_write_32 ((u_int32_t *) &comet->xlpg_cfg, table[COMET_NUM_SAMPLES][0]);
  371. }
  372. /*
  373. ** Name: WrtXmtWaveform
  374. ** Description: Fill in the Receive Equalizer RAM from the desired
  375. ** table.
  376. ** Returns: Nothing
  377. **
  378. ** Remarks: Per PM4351 Device Errata, Receive Equalizer RAM Initialization
  379. ** is coded with early setup of indirect address.
  380. */
  381. STATIC void
  382. WrtRcvEqualizerTbl (ci_t * ci, comet_t * comet, u_int32_t *table)
  383. {
  384. u_int32_t ramaddr;
  385. volatile u_int32_t value;
  386. for (ramaddr = 0; ramaddr < 256; ramaddr++)
  387. {
  388. /*** the following lines are per Errata 7, 2.5 ***/
  389. {
  390. pci_write_32 ((u_int32_t *) &comet->rlps_eq_rwsel, 0x80); /* Set up for a read
  391. * operation */
  392. pci_flush_write (ci); /* for write order preservation when
  393. * Optimizing driver */
  394. pci_write_32 ((u_int32_t *) &comet->rlps_eq_iaddr, (u_int8_t) ramaddr); /* write the addr,
  395. * initiate a read */
  396. pci_flush_write (ci); /* for write order preservation when
  397. * Optimizing driver */
  398. /*
  399. * wait 3 line rate clock cycles to ensure address bits are
  400. * captured by T1/E1 clock
  401. */
  402. OS_uwait (4, "wret"); /* 683ns * 3 = 1366 ns, approx 2us (but
  403. * use 4us) */
  404. }
  405. value = *table++;
  406. pci_write_32 ((u_int32_t *) &comet->rlps_idata3, (u_int8_t) (value >> 24));
  407. pci_write_32 ((u_int32_t *) &comet->rlps_idata2, (u_int8_t) (value >> 16));
  408. pci_write_32 ((u_int32_t *) &comet->rlps_idata1, (u_int8_t) (value >> 8));
  409. pci_write_32 ((u_int32_t *) &comet->rlps_idata0, (u_int8_t) value);
  410. pci_flush_write (ci); /* for write order preservation when
  411. * Optimizing driver */
  412. /* Storing RAM address, causes RAM to be updated */
  413. pci_write_32 ((u_int32_t *) &comet->rlps_eq_rwsel, 0); /* Set up for a write
  414. * operation */
  415. pci_flush_write (ci); /* for write order preservation when
  416. * Optimizing driver */
  417. pci_write_32 ((u_int32_t *) &comet->rlps_eq_iaddr, (u_int8_t) ramaddr); /* write the addr,
  418. * initiate a read */
  419. pci_flush_write (ci); /* for write order preservation when
  420. * Optimizing driver */
  421. /*
  422. * wait 3 line rate clock cycles to ensure address bits are captured
  423. * by T1/E1 clock
  424. */
  425. OS_uwait (4, "wret"); /* 683ns * 3 = 1366 ns, approx 2us (but
  426. * use 4us) */
  427. }
  428. pci_write_32 ((u_int32_t *) &comet->rlps_eq_cfg, 0xCB); /* Enable Equalizer &
  429. * set it to use 256
  430. * periods */
  431. }
  432. /*
  433. ** Name: SetPwrLevel
  434. ** Description: Implement power level setting algorithm described below
  435. ** Returns: Nothing
  436. */
  437. STATIC void
  438. SetPwrLevel (comet_t * comet)
  439. {
  440. volatile u_int32_t temp;
  441. /*
  442. ** Algorithm to Balance the Power Distribution of Ttip Tring
  443. **
  444. ** Zero register F6
  445. ** Write 0x01 to register F4
  446. ** Write another 0x01 to register F4
  447. ** Read register F4
  448. ** Remove the 0x01 bit by Anding register F4 with 0xFE
  449. ** Write the resultant value to register F4
  450. ** Repeat these steps for register F5
  451. ** Write 0x01 to register F6
  452. */
  453. pci_write_32 ((u_int32_t *) &comet->xlpg_fdata_sel, 0x00); /* XLPG Fuse Data Select */
  454. pci_write_32 ((u_int32_t *) &comet->xlpg_atest_pctl, 0x01); /* XLPG Analog Test
  455. * Positive control */
  456. pci_write_32 ((u_int32_t *) &comet->xlpg_atest_pctl, 0x01);
  457. temp = pci_read_32 ((u_int32_t *) &comet->xlpg_atest_pctl) & 0xfe;
  458. pci_write_32 ((u_int32_t *) &comet->xlpg_atest_pctl, temp);
  459. pci_write_32 ((u_int32_t *) &comet->xlpg_atest_nctl, 0x01); /* XLPG Analog Test
  460. * Negative control */
  461. pci_write_32 ((u_int32_t *) &comet->xlpg_atest_nctl, 0x01);
  462. temp = pci_read_32 ((u_int32_t *) &comet->xlpg_atest_nctl) & 0xfe;
  463. pci_write_32 ((u_int32_t *) &comet->xlpg_atest_nctl, temp);
  464. pci_write_32 ((u_int32_t *) &comet->xlpg_fdata_sel, 0x01); /* XLPG */
  465. }
  466. /*
  467. ** Name: SetCometOps
  468. ** Description: Set up the selected Comet's clock edge drive for both
  469. ** the transmit out the analog side and receive to the
  470. ** backplane side.
  471. ** Returns: Nothing
  472. */
  473. #if 0
  474. STATIC void
  475. SetCometOps (comet_t * comet)
  476. {
  477. volatile u_int8_t rd_value;
  478. if (comet == mConfig.C4Func1Base + (COMET0_OFFSET >> 2))
  479. {
  480. rd_value = (u_int8_t) pci_read_32 ((u_int32_t *) &comet->brif_cfg); /* read the BRIF
  481. * Configuration */
  482. rd_value &= ~0x20;
  483. pci_write_32 ((u_int32_t *) &comet->brif_cfg, (u_int32_t) rd_value);
  484. rd_value = (u_int8_t) pci_read_32 ((u_int32_t *) &comet->brif_fpcfg); /* read the BRIF Frame
  485. * Pulse Configuration */
  486. rd_value &= ~0x20;
  487. pci_write_32 ((u_int32_t *) &comet->brif_fpcfg, (u_int8_t) rd_value);
  488. } else
  489. {
  490. rd_value = (u_int8_t) pci_read_32 ((u_int32_t *) &comet->brif_cfg); /* read the BRIF
  491. * Configuration */
  492. rd_value |= 0x20;
  493. pci_write_32 ((u_int32_t *) &comet->brif_cfg, (u_int32_t) rd_value);
  494. rd_value = (u_int8_t) pci_read_32 ((u_int32_t *) &comet->brif_fpcfg); /* read the BRIF Frame
  495. * Pulse Configuration */
  496. rd_value |= 0x20;
  497. pci_write_32 ((u_int32_t *) &comet->brif_fpcfg, (u_int8_t) rd_value);
  498. }
  499. }
  500. #endif
  501. /*** End-of-File ***/