subr.c 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099
  1. /*****************************************************************************
  2. * *
  3. * File: subr.c *
  4. * $Revision: 1.27 $ *
  5. * $Date: 2005/06/22 01:08:36 $ *
  6. * Description: *
  7. * Various subroutines (intr,pio,etc.) used by Chelsio 10G Ethernet driver. *
  8. * part of the Chelsio 10Gb Ethernet Driver. *
  9. * *
  10. * This program is free software; you can redistribute it and/or modify *
  11. * it under the terms of the GNU General Public License, version 2, as *
  12. * published by the Free Software Foundation. *
  13. * *
  14. * You should have received a copy of the GNU General Public License along *
  15. * with this program; if not, write to the Free Software Foundation, Inc., *
  16. * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
  17. * *
  18. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED *
  19. * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF *
  20. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. *
  21. * *
  22. * http://www.chelsio.com *
  23. * *
  24. * Copyright (c) 2003 - 2005 Chelsio Communications, Inc. *
  25. * All rights reserved. *
  26. * *
  27. * Maintainers: maintainers@chelsio.com *
  28. * *
  29. * Authors: Dimitrios Michailidis <dm@chelsio.com> *
  30. * Tina Yang <tainay@chelsio.com> *
  31. * Felix Marti <felix@chelsio.com> *
  32. * Scott Bardone <sbardone@chelsio.com> *
  33. * Kurt Ottaway <kottaway@chelsio.com> *
  34. * Frank DiMambro <frank@chelsio.com> *
  35. * *
  36. * History: *
  37. * *
  38. ****************************************************************************/
  39. #include "common.h"
  40. #include "elmer0.h"
  41. #include "regs.h"
  42. #include "gmac.h"
  43. #include "cphy.h"
  44. #include "sge.h"
  45. #include "tp.h"
  46. #include "espi.h"
  47. /**
  48. * t1_wait_op_done - wait until an operation is completed
  49. * @adapter: the adapter performing the operation
  50. * @reg: the register to check for completion
  51. * @mask: a single-bit field within @reg that indicates completion
  52. * @polarity: the value of the field when the operation is completed
  53. * @attempts: number of check iterations
  54. * @delay: delay in usecs between iterations
  55. *
  56. * Wait until an operation is completed by checking a bit in a register
  57. * up to @attempts times. Returns %0 if the operation completes and %1
  58. * otherwise.
  59. */
  60. static int t1_wait_op_done(adapter_t *adapter, int reg, u32 mask, int polarity,
  61. int attempts, int delay)
  62. {
  63. while (1) {
  64. u32 val = readl(adapter->regs + reg) & mask;
  65. if (!!val == polarity)
  66. return 0;
  67. if (--attempts == 0)
  68. return 1;
  69. if (delay)
  70. udelay(delay);
  71. }
  72. }
  73. #define TPI_ATTEMPTS 50
  74. /*
  75. * Write a register over the TPI interface (unlocked and locked versions).
  76. */
  77. int __t1_tpi_write(adapter_t *adapter, u32 addr, u32 value)
  78. {
  79. int tpi_busy;
  80. writel(addr, adapter->regs + A_TPI_ADDR);
  81. writel(value, adapter->regs + A_TPI_WR_DATA);
  82. writel(F_TPIWR, adapter->regs + A_TPI_CSR);
  83. tpi_busy = t1_wait_op_done(adapter, A_TPI_CSR, F_TPIRDY, 1,
  84. TPI_ATTEMPTS, 3);
  85. if (tpi_busy)
  86. CH_ALERT("%s: TPI write to 0x%x failed\n",
  87. adapter->name, addr);
  88. return tpi_busy;
  89. }
  90. int t1_tpi_write(adapter_t *adapter, u32 addr, u32 value)
  91. {
  92. int ret;
  93. spin_lock(&adapter->tpi_lock);
  94. ret = __t1_tpi_write(adapter, addr, value);
  95. spin_unlock(&adapter->tpi_lock);
  96. return ret;
  97. }
  98. /*
  99. * Read a register over the TPI interface (unlocked and locked versions).
  100. */
  101. int __t1_tpi_read(adapter_t *adapter, u32 addr, u32 *valp)
  102. {
  103. int tpi_busy;
  104. writel(addr, adapter->regs + A_TPI_ADDR);
  105. writel(0, adapter->regs + A_TPI_CSR);
  106. tpi_busy = t1_wait_op_done(adapter, A_TPI_CSR, F_TPIRDY, 1,
  107. TPI_ATTEMPTS, 3);
  108. if (tpi_busy)
  109. CH_ALERT("%s: TPI read from 0x%x failed\n",
  110. adapter->name, addr);
  111. else
  112. *valp = readl(adapter->regs + A_TPI_RD_DATA);
  113. return tpi_busy;
  114. }
  115. int t1_tpi_read(adapter_t *adapter, u32 addr, u32 *valp)
  116. {
  117. int ret;
  118. spin_lock(&adapter->tpi_lock);
  119. ret = __t1_tpi_read(adapter, addr, valp);
  120. spin_unlock(&adapter->tpi_lock);
  121. return ret;
  122. }
  123. /*
  124. * Set a TPI parameter.
  125. */
  126. static void t1_tpi_par(adapter_t *adapter, u32 value)
  127. {
  128. writel(V_TPIPAR(value), adapter->regs + A_TPI_PAR);
  129. }
  130. /*
  131. * Called when a port's link settings change to propagate the new values to the
  132. * associated PHY and MAC. After performing the common tasks it invokes an
  133. * OS-specific handler.
  134. */
  135. void t1_link_changed(adapter_t *adapter, int port_id)
  136. {
  137. int link_ok, speed, duplex, fc;
  138. struct cphy *phy = adapter->port[port_id].phy;
  139. struct link_config *lc = &adapter->port[port_id].link_config;
  140. phy->ops->get_link_status(phy, &link_ok, &speed, &duplex, &fc);
  141. lc->speed = speed < 0 ? SPEED_INVALID : speed;
  142. lc->duplex = duplex < 0 ? DUPLEX_INVALID : duplex;
  143. if (!(lc->requested_fc & PAUSE_AUTONEG))
  144. fc = lc->requested_fc & (PAUSE_RX | PAUSE_TX);
  145. if (link_ok && speed >= 0 && lc->autoneg == AUTONEG_ENABLE) {
  146. /* Set MAC speed, duplex, and flow control to match PHY. */
  147. struct cmac *mac = adapter->port[port_id].mac;
  148. mac->ops->set_speed_duplex_fc(mac, speed, duplex, fc);
  149. lc->fc = (unsigned char)fc;
  150. }
  151. t1_link_negotiated(adapter, port_id, link_ok, speed, duplex, fc);
  152. }
  153. static int t1_pci_intr_handler(adapter_t *adapter)
  154. {
  155. u32 pcix_cause;
  156. pci_read_config_dword(adapter->pdev, A_PCICFG_INTR_CAUSE, &pcix_cause);
  157. if (pcix_cause) {
  158. pci_write_config_dword(adapter->pdev, A_PCICFG_INTR_CAUSE,
  159. pcix_cause);
  160. t1_fatal_err(adapter); /* PCI errors are fatal */
  161. }
  162. return 0;
  163. }
  164. #ifdef CONFIG_CHELSIO_T1_COUGAR
  165. #include "cspi.h"
  166. #endif
  167. #ifdef CONFIG_CHELSIO_T1_1G
  168. #include "fpga_defs.h"
  169. /*
  170. * PHY interrupt handler for FPGA boards.
  171. */
  172. static int fpga_phy_intr_handler(adapter_t *adapter)
  173. {
  174. int p;
  175. u32 cause = readl(adapter->regs + FPGA_GMAC_ADDR_INTERRUPT_CAUSE);
  176. for_each_port(adapter, p)
  177. if (cause & (1 << p)) {
  178. struct cphy *phy = adapter->port[p].phy;
  179. int phy_cause = phy->ops->interrupt_handler(phy);
  180. if (phy_cause & cphy_cause_link_change)
  181. t1_link_changed(adapter, p);
  182. }
  183. writel(cause, adapter->regs + FPGA_GMAC_ADDR_INTERRUPT_CAUSE);
  184. return 0;
  185. }
  186. /*
  187. * Slow path interrupt handler for FPGAs.
  188. */
  189. static int fpga_slow_intr(adapter_t *adapter)
  190. {
  191. u32 cause = readl(adapter->regs + A_PL_CAUSE);
  192. cause &= ~F_PL_INTR_SGE_DATA;
  193. if (cause & F_PL_INTR_SGE_ERR)
  194. t1_sge_intr_error_handler(adapter->sge);
  195. if (cause & FPGA_PCIX_INTERRUPT_GMAC)
  196. fpga_phy_intr_handler(adapter);
  197. if (cause & FPGA_PCIX_INTERRUPT_TP) {
  198. /*
  199. * FPGA doesn't support MC4 interrupts and it requires
  200. * this odd layer of indirection for MC5.
  201. */
  202. u32 tp_cause = readl(adapter->regs + FPGA_TP_ADDR_INTERRUPT_CAUSE);
  203. /* Clear TP interrupt */
  204. writel(tp_cause, adapter->regs + FPGA_TP_ADDR_INTERRUPT_CAUSE);
  205. }
  206. if (cause & FPGA_PCIX_INTERRUPT_PCIX)
  207. t1_pci_intr_handler(adapter);
  208. /* Clear the interrupts just processed. */
  209. if (cause)
  210. writel(cause, adapter->regs + A_PL_CAUSE);
  211. return cause != 0;
  212. }
  213. #endif
  214. /*
  215. * Wait until Elmer's MI1 interface is ready for new operations.
  216. */
  217. static int mi1_wait_until_ready(adapter_t *adapter, int mi1_reg)
  218. {
  219. int attempts = 100, busy;
  220. do {
  221. u32 val;
  222. __t1_tpi_read(adapter, mi1_reg, &val);
  223. busy = val & F_MI1_OP_BUSY;
  224. if (busy)
  225. udelay(10);
  226. } while (busy && --attempts);
  227. if (busy)
  228. CH_ALERT("%s: MDIO operation timed out\n", adapter->name);
  229. return busy;
  230. }
  231. /*
  232. * MI1 MDIO initialization.
  233. */
  234. static void mi1_mdio_init(adapter_t *adapter, const struct board_info *bi)
  235. {
  236. u32 clkdiv = bi->clock_elmer0 / (2 * bi->mdio_mdc) - 1;
  237. u32 val = F_MI1_PREAMBLE_ENABLE | V_MI1_MDI_INVERT(bi->mdio_mdiinv) |
  238. V_MI1_MDI_ENABLE(bi->mdio_mdien) | V_MI1_CLK_DIV(clkdiv);
  239. if (!(bi->caps & SUPPORTED_10000baseT_Full))
  240. val |= V_MI1_SOF(1);
  241. t1_tpi_write(adapter, A_ELMER0_PORT0_MI1_CFG, val);
  242. }
  243. #if defined(CONFIG_CHELSIO_T1_1G) || defined(CONFIG_CHELSIO_T1_COUGAR)
  244. /*
  245. * Elmer MI1 MDIO read/write operations.
  246. */
  247. static int mi1_mdio_read(adapter_t *adapter, int phy_addr, int mmd_addr,
  248. int reg_addr, unsigned int *valp)
  249. {
  250. u32 addr = V_MI1_REG_ADDR(reg_addr) | V_MI1_PHY_ADDR(phy_addr);
  251. if (mmd_addr)
  252. return -EINVAL;
  253. spin_lock(&adapter->tpi_lock);
  254. __t1_tpi_write(adapter, A_ELMER0_PORT0_MI1_ADDR, addr);
  255. __t1_tpi_write(adapter,
  256. A_ELMER0_PORT0_MI1_OP, MI1_OP_DIRECT_READ);
  257. mi1_wait_until_ready(adapter, A_ELMER0_PORT0_MI1_OP);
  258. __t1_tpi_read(adapter, A_ELMER0_PORT0_MI1_DATA, valp);
  259. spin_unlock(&adapter->tpi_lock);
  260. return 0;
  261. }
  262. static int mi1_mdio_write(adapter_t *adapter, int phy_addr, int mmd_addr,
  263. int reg_addr, unsigned int val)
  264. {
  265. u32 addr = V_MI1_REG_ADDR(reg_addr) | V_MI1_PHY_ADDR(phy_addr);
  266. if (mmd_addr)
  267. return -EINVAL;
  268. spin_lock(&adapter->tpi_lock);
  269. __t1_tpi_write(adapter, A_ELMER0_PORT0_MI1_ADDR, addr);
  270. __t1_tpi_write(adapter, A_ELMER0_PORT0_MI1_DATA, val);
  271. __t1_tpi_write(adapter,
  272. A_ELMER0_PORT0_MI1_OP, MI1_OP_DIRECT_WRITE);
  273. mi1_wait_until_ready(adapter, A_ELMER0_PORT0_MI1_OP);
  274. spin_unlock(&adapter->tpi_lock);
  275. return 0;
  276. }
  277. #if defined(CONFIG_CHELSIO_T1_1G) || defined(CONFIG_CHELSIO_T1_COUGAR)
  278. static struct mdio_ops mi1_mdio_ops = {
  279. mi1_mdio_init,
  280. mi1_mdio_read,
  281. mi1_mdio_write
  282. };
  283. #endif
  284. #endif
  285. static int mi1_mdio_ext_read(adapter_t *adapter, int phy_addr, int mmd_addr,
  286. int reg_addr, unsigned int *valp)
  287. {
  288. u32 addr = V_MI1_REG_ADDR(mmd_addr) | V_MI1_PHY_ADDR(phy_addr);
  289. spin_lock(&adapter->tpi_lock);
  290. /* Write the address we want. */
  291. __t1_tpi_write(adapter, A_ELMER0_PORT0_MI1_ADDR, addr);
  292. __t1_tpi_write(adapter, A_ELMER0_PORT0_MI1_DATA, reg_addr);
  293. __t1_tpi_write(adapter, A_ELMER0_PORT0_MI1_OP,
  294. MI1_OP_INDIRECT_ADDRESS);
  295. mi1_wait_until_ready(adapter, A_ELMER0_PORT0_MI1_OP);
  296. /* Write the operation we want. */
  297. __t1_tpi_write(adapter,
  298. A_ELMER0_PORT0_MI1_OP, MI1_OP_INDIRECT_READ);
  299. mi1_wait_until_ready(adapter, A_ELMER0_PORT0_MI1_OP);
  300. /* Read the data. */
  301. __t1_tpi_read(adapter, A_ELMER0_PORT0_MI1_DATA, valp);
  302. spin_unlock(&adapter->tpi_lock);
  303. return 0;
  304. }
  305. static int mi1_mdio_ext_write(adapter_t *adapter, int phy_addr, int mmd_addr,
  306. int reg_addr, unsigned int val)
  307. {
  308. u32 addr = V_MI1_REG_ADDR(mmd_addr) | V_MI1_PHY_ADDR(phy_addr);
  309. spin_lock(&adapter->tpi_lock);
  310. /* Write the address we want. */
  311. __t1_tpi_write(adapter, A_ELMER0_PORT0_MI1_ADDR, addr);
  312. __t1_tpi_write(adapter, A_ELMER0_PORT0_MI1_DATA, reg_addr);
  313. __t1_tpi_write(adapter, A_ELMER0_PORT0_MI1_OP,
  314. MI1_OP_INDIRECT_ADDRESS);
  315. mi1_wait_until_ready(adapter, A_ELMER0_PORT0_MI1_OP);
  316. /* Write the data. */
  317. __t1_tpi_write(adapter, A_ELMER0_PORT0_MI1_DATA, val);
  318. __t1_tpi_write(adapter, A_ELMER0_PORT0_MI1_OP, MI1_OP_INDIRECT_WRITE);
  319. mi1_wait_until_ready(adapter, A_ELMER0_PORT0_MI1_OP);
  320. spin_unlock(&adapter->tpi_lock);
  321. return 0;
  322. }
  323. static struct mdio_ops mi1_mdio_ext_ops = {
  324. mi1_mdio_init,
  325. mi1_mdio_ext_read,
  326. mi1_mdio_ext_write
  327. };
  328. enum {
  329. CH_BRD_T110_1CU,
  330. CH_BRD_N110_1F,
  331. CH_BRD_N210_1F,
  332. CH_BRD_T210_1F,
  333. CH_BRD_T210_1CU,
  334. CH_BRD_N204_4CU,
  335. };
  336. static struct board_info t1_board[] = {
  337. { CHBT_BOARD_CHT110, 1/*ports#*/,
  338. SUPPORTED_10000baseT_Full /*caps*/, CHBT_TERM_T1,
  339. CHBT_MAC_PM3393, CHBT_PHY_MY3126,
  340. 125000000/*clk-core*/, 150000000/*clk-mc3*/, 125000000/*clk-mc4*/,
  341. 1/*espi-ports*/, 0/*clk-cspi*/, 44/*clk-elmer0*/, 1/*mdien*/,
  342. 1/*mdiinv*/, 1/*mdc*/, 1/*phybaseaddr*/, &t1_pm3393_ops,
  343. &t1_my3126_ops, &mi1_mdio_ext_ops,
  344. "Chelsio T110 1x10GBase-CX4 TOE" },
  345. { CHBT_BOARD_N110, 1/*ports#*/,
  346. SUPPORTED_10000baseT_Full | SUPPORTED_FIBRE /*caps*/, CHBT_TERM_T1,
  347. CHBT_MAC_PM3393, CHBT_PHY_88X2010,
  348. 125000000/*clk-core*/, 0/*clk-mc3*/, 0/*clk-mc4*/,
  349. 1/*espi-ports*/, 0/*clk-cspi*/, 44/*clk-elmer0*/, 0/*mdien*/,
  350. 0/*mdiinv*/, 1/*mdc*/, 0/*phybaseaddr*/, &t1_pm3393_ops,
  351. &t1_mv88x201x_ops, &mi1_mdio_ext_ops,
  352. "Chelsio N110 1x10GBaseX NIC" },
  353. { CHBT_BOARD_N210, 1/*ports#*/,
  354. SUPPORTED_10000baseT_Full | SUPPORTED_FIBRE /*caps*/, CHBT_TERM_T2,
  355. CHBT_MAC_PM3393, CHBT_PHY_88X2010,
  356. 125000000/*clk-core*/, 0/*clk-mc3*/, 0/*clk-mc4*/,
  357. 1/*espi-ports*/, 0/*clk-cspi*/, 44/*clk-elmer0*/, 0/*mdien*/,
  358. 0/*mdiinv*/, 1/*mdc*/, 0/*phybaseaddr*/, &t1_pm3393_ops,
  359. &t1_mv88x201x_ops, &mi1_mdio_ext_ops,
  360. "Chelsio N210 1x10GBaseX NIC" },
  361. { CHBT_BOARD_CHT210, 1/*ports#*/,
  362. SUPPORTED_10000baseT_Full /*caps*/, CHBT_TERM_T2,
  363. CHBT_MAC_PM3393, CHBT_PHY_88X2010,
  364. 125000000/*clk-core*/, 133000000/*clk-mc3*/, 125000000/*clk-mc4*/,
  365. 1/*espi-ports*/, 0/*clk-cspi*/, 44/*clk-elmer0*/, 0/*mdien*/,
  366. 0/*mdiinv*/, 1/*mdc*/, 0/*phybaseaddr*/, &t1_pm3393_ops,
  367. &t1_mv88x201x_ops, &mi1_mdio_ext_ops,
  368. "Chelsio T210 1x10GBaseX TOE" },
  369. { CHBT_BOARD_CHT210, 1/*ports#*/,
  370. SUPPORTED_10000baseT_Full /*caps*/, CHBT_TERM_T2,
  371. CHBT_MAC_PM3393, CHBT_PHY_MY3126,
  372. 125000000/*clk-core*/, 133000000/*clk-mc3*/, 125000000/*clk-mc4*/,
  373. 1/*espi-ports*/, 0/*clk-cspi*/, 44/*clk-elmer0*/, 1/*mdien*/,
  374. 1/*mdiinv*/, 1/*mdc*/, 1/*phybaseaddr*/, &t1_pm3393_ops,
  375. &t1_my3126_ops, &mi1_mdio_ext_ops,
  376. "Chelsio T210 1x10GBase-CX4 TOE" },
  377. #ifdef CONFIG_CHELSIO_T1_1G
  378. { CHBT_BOARD_CHN204, 4/*ports#*/,
  379. SUPPORTED_10baseT_Half | SUPPORTED_10baseT_Full | SUPPORTED_100baseT_Half |
  380. SUPPORTED_100baseT_Full | SUPPORTED_1000baseT_Full | SUPPORTED_Autoneg |
  381. SUPPORTED_PAUSE | SUPPORTED_TP /*caps*/, CHBT_TERM_T2, CHBT_MAC_VSC7321, CHBT_PHY_88E1111,
  382. 100000000/*clk-core*/, 0/*clk-mc3*/, 0/*clk-mc4*/,
  383. 4/*espi-ports*/, 0/*clk-cspi*/, 44/*clk-elmer0*/, 0/*mdien*/,
  384. 0/*mdiinv*/, 1/*mdc*/, 4/*phybaseaddr*/, &t1_vsc7326_ops,
  385. &t1_mv88e1xxx_ops, &mi1_mdio_ops,
  386. "Chelsio N204 4x100/1000BaseT NIC" },
  387. #endif
  388. };
  389. struct pci_device_id t1_pci_tbl[] = {
  390. CH_DEVICE(8, 0, CH_BRD_T110_1CU),
  391. CH_DEVICE(8, 1, CH_BRD_T110_1CU),
  392. CH_DEVICE(7, 0, CH_BRD_N110_1F),
  393. CH_DEVICE(10, 1, CH_BRD_N210_1F),
  394. CH_DEVICE(11, 1, CH_BRD_T210_1F),
  395. CH_DEVICE(14, 1, CH_BRD_T210_1CU),
  396. CH_DEVICE(16, 1, CH_BRD_N204_4CU),
  397. { 0 }
  398. };
  399. MODULE_DEVICE_TABLE(pci, t1_pci_tbl);
  400. /*
  401. * Return the board_info structure with a given index. Out-of-range indices
  402. * return NULL.
  403. */
  404. const struct board_info *t1_get_board_info(unsigned int board_id)
  405. {
  406. return board_id < ARRAY_SIZE(t1_board) ? &t1_board[board_id] : NULL;
  407. }
  408. struct chelsio_vpd_t {
  409. u32 format_version;
  410. u8 serial_number[16];
  411. u8 mac_base_address[6];
  412. u8 pad[2]; /* make multiple-of-4 size requirement explicit */
  413. };
  414. #define EEPROMSIZE (8 * 1024)
  415. #define EEPROM_MAX_POLL 4
  416. /*
  417. * Read SEEPROM. A zero is written to the flag register when the addres is
  418. * written to the Control register. The hardware device will set the flag to a
  419. * one when 4B have been transferred to the Data register.
  420. */
  421. int t1_seeprom_read(adapter_t *adapter, u32 addr, u32 *data)
  422. {
  423. int i = EEPROM_MAX_POLL;
  424. u16 val;
  425. if (addr >= EEPROMSIZE || (addr & 3))
  426. return -EINVAL;
  427. pci_write_config_word(adapter->pdev, A_PCICFG_VPD_ADDR, (u16)addr);
  428. do {
  429. udelay(50);
  430. pci_read_config_word(adapter->pdev, A_PCICFG_VPD_ADDR, &val);
  431. } while (!(val & F_VPD_OP_FLAG) && --i);
  432. if (!(val & F_VPD_OP_FLAG)) {
  433. CH_ERR("%s: reading EEPROM address 0x%x failed\n",
  434. adapter->name, addr);
  435. return -EIO;
  436. }
  437. pci_read_config_dword(adapter->pdev, A_PCICFG_VPD_DATA, data);
  438. *data = le32_to_cpu(*data);
  439. return 0;
  440. }
  441. static int t1_eeprom_vpd_get(adapter_t *adapter, struct chelsio_vpd_t *vpd)
  442. {
  443. int addr, ret = 0;
  444. for (addr = 0; !ret && addr < sizeof(*vpd); addr += sizeof(u32))
  445. ret = t1_seeprom_read(adapter, addr,
  446. (u32 *)((u8 *)vpd + addr));
  447. return ret;
  448. }
  449. /*
  450. * Read a port's MAC address from the VPD ROM.
  451. */
  452. static int vpd_macaddress_get(adapter_t *adapter, int index, u8 mac_addr[])
  453. {
  454. struct chelsio_vpd_t vpd;
  455. if (t1_eeprom_vpd_get(adapter, &vpd))
  456. return 1;
  457. memcpy(mac_addr, vpd.mac_base_address, 5);
  458. mac_addr[5] = vpd.mac_base_address[5] + index;
  459. return 0;
  460. }
  461. /*
  462. * Set up the MAC/PHY according to the requested link settings.
  463. *
  464. * If the PHY can auto-negotiate first decide what to advertise, then
  465. * enable/disable auto-negotiation as desired and reset.
  466. *
  467. * If the PHY does not auto-negotiate we just reset it.
  468. *
  469. * If auto-negotiation is off set the MAC to the proper speed/duplex/FC,
  470. * otherwise do it later based on the outcome of auto-negotiation.
  471. */
  472. int t1_link_start(struct cphy *phy, struct cmac *mac, struct link_config *lc)
  473. {
  474. unsigned int fc = lc->requested_fc & (PAUSE_RX | PAUSE_TX);
  475. if (lc->supported & SUPPORTED_Autoneg) {
  476. lc->advertising &= ~(ADVERTISED_ASYM_PAUSE | ADVERTISED_PAUSE);
  477. if (fc) {
  478. if (fc == ((PAUSE_RX | PAUSE_TX) &
  479. (mac->adapter->params.nports < 2)))
  480. lc->advertising |= ADVERTISED_PAUSE;
  481. else {
  482. lc->advertising |= ADVERTISED_ASYM_PAUSE;
  483. if (fc == PAUSE_RX)
  484. lc->advertising |= ADVERTISED_PAUSE;
  485. }
  486. }
  487. phy->ops->advertise(phy, lc->advertising);
  488. if (lc->autoneg == AUTONEG_DISABLE) {
  489. lc->speed = lc->requested_speed;
  490. lc->duplex = lc->requested_duplex;
  491. lc->fc = (unsigned char)fc;
  492. mac->ops->set_speed_duplex_fc(mac, lc->speed,
  493. lc->duplex, fc);
  494. /* Also disables autoneg */
  495. phy->state = PHY_AUTONEG_RDY;
  496. phy->ops->set_speed_duplex(phy, lc->speed, lc->duplex);
  497. phy->ops->reset(phy, 0);
  498. } else {
  499. phy->state = PHY_AUTONEG_EN;
  500. phy->ops->autoneg_enable(phy); /* also resets PHY */
  501. }
  502. } else {
  503. phy->state = PHY_AUTONEG_RDY;
  504. mac->ops->set_speed_duplex_fc(mac, -1, -1, fc);
  505. lc->fc = (unsigned char)fc;
  506. phy->ops->reset(phy, 0);
  507. }
  508. return 0;
  509. }
  510. /*
  511. * External interrupt handler for boards using elmer0.
  512. */
  513. int t1_elmer0_ext_intr_handler(adapter_t *adapter)
  514. {
  515. struct cphy *phy;
  516. int phy_cause;
  517. u32 cause;
  518. t1_tpi_read(adapter, A_ELMER0_INT_CAUSE, &cause);
  519. switch (board_info(adapter)->board) {
  520. #ifdef CONFIG_CHELSIO_T1_1G
  521. case CHBT_BOARD_CHT204:
  522. case CHBT_BOARD_CHT204E:
  523. case CHBT_BOARD_CHN204:
  524. case CHBT_BOARD_CHT204V: {
  525. int i, port_bit;
  526. for_each_port(adapter, i) {
  527. port_bit = i + 1;
  528. if (!(cause & (1 << port_bit)))
  529. continue;
  530. phy = adapter->port[i].phy;
  531. phy_cause = phy->ops->interrupt_handler(phy);
  532. if (phy_cause & cphy_cause_link_change)
  533. t1_link_changed(adapter, i);
  534. }
  535. break;
  536. }
  537. case CHBT_BOARD_CHT101:
  538. if (cause & ELMER0_GP_BIT1) { /* Marvell 88E1111 interrupt */
  539. phy = adapter->port[0].phy;
  540. phy_cause = phy->ops->interrupt_handler(phy);
  541. if (phy_cause & cphy_cause_link_change)
  542. t1_link_changed(adapter, 0);
  543. }
  544. break;
  545. case CHBT_BOARD_7500: {
  546. int p;
  547. /*
  548. * Elmer0's interrupt cause isn't useful here because there is
  549. * only one bit that can be set for all 4 ports. This means
  550. * we are forced to check every PHY's interrupt status
  551. * register to see who initiated the interrupt.
  552. */
  553. for_each_port(adapter, p) {
  554. phy = adapter->port[p].phy;
  555. phy_cause = phy->ops->interrupt_handler(phy);
  556. if (phy_cause & cphy_cause_link_change)
  557. t1_link_changed(adapter, p);
  558. }
  559. break;
  560. }
  561. #endif
  562. case CHBT_BOARD_CHT210:
  563. case CHBT_BOARD_N210:
  564. case CHBT_BOARD_N110:
  565. if (cause & ELMER0_GP_BIT6) { /* Marvell 88x2010 interrupt */
  566. phy = adapter->port[0].phy;
  567. phy_cause = phy->ops->interrupt_handler(phy);
  568. if (phy_cause & cphy_cause_link_change)
  569. t1_link_changed(adapter, 0);
  570. }
  571. break;
  572. case CHBT_BOARD_8000:
  573. case CHBT_BOARD_CHT110:
  574. CH_DBG(adapter, INTR, "External interrupt cause 0x%x\n",
  575. cause);
  576. if (cause & ELMER0_GP_BIT1) { /* PMC3393 INTB */
  577. struct cmac *mac = adapter->port[0].mac;
  578. mac->ops->interrupt_handler(mac);
  579. }
  580. if (cause & ELMER0_GP_BIT5) { /* XPAK MOD_DETECT */
  581. u32 mod_detect;
  582. t1_tpi_read(adapter,
  583. A_ELMER0_GPI_STAT, &mod_detect);
  584. CH_MSG(adapter, INFO, LINK, "XPAK %s\n",
  585. mod_detect ? "removed" : "inserted");
  586. }
  587. break;
  588. #ifdef CONFIG_CHELSIO_T1_COUGAR
  589. case CHBT_BOARD_COUGAR:
  590. if (adapter->params.nports == 1) {
  591. if (cause & ELMER0_GP_BIT1) { /* Vitesse MAC */
  592. struct cmac *mac = adapter->port[0].mac;
  593. mac->ops->interrupt_handler(mac);
  594. }
  595. if (cause & ELMER0_GP_BIT5) { /* XPAK MOD_DETECT */
  596. }
  597. } else {
  598. int i, port_bit;
  599. for_each_port(adapter, i) {
  600. port_bit = i ? i + 1 : 0;
  601. if (!(cause & (1 << port_bit)))
  602. continue;
  603. phy = adapter->port[i].phy;
  604. phy_cause = phy->ops->interrupt_handler(phy);
  605. if (phy_cause & cphy_cause_link_change)
  606. t1_link_changed(adapter, i);
  607. }
  608. }
  609. break;
  610. #endif
  611. }
  612. t1_tpi_write(adapter, A_ELMER0_INT_CAUSE, cause);
  613. return 0;
  614. }
  615. /* Enables all interrupts. */
  616. void t1_interrupts_enable(adapter_t *adapter)
  617. {
  618. unsigned int i;
  619. adapter->slow_intr_mask = F_PL_INTR_SGE_ERR | F_PL_INTR_TP;
  620. t1_sge_intr_enable(adapter->sge);
  621. t1_tp_intr_enable(adapter->tp);
  622. if (adapter->espi) {
  623. adapter->slow_intr_mask |= F_PL_INTR_ESPI;
  624. t1_espi_intr_enable(adapter->espi);
  625. }
  626. /* Enable MAC/PHY interrupts for each port. */
  627. for_each_port(adapter, i) {
  628. adapter->port[i].mac->ops->interrupt_enable(adapter->port[i].mac);
  629. adapter->port[i].phy->ops->interrupt_enable(adapter->port[i].phy);
  630. }
  631. /* Enable PCIX & external chip interrupts on ASIC boards. */
  632. if (t1_is_asic(adapter)) {
  633. u32 pl_intr = readl(adapter->regs + A_PL_ENABLE);
  634. /* PCI-X interrupts */
  635. pci_write_config_dword(adapter->pdev, A_PCICFG_INTR_ENABLE,
  636. 0xffffffff);
  637. adapter->slow_intr_mask |= F_PL_INTR_EXT | F_PL_INTR_PCIX;
  638. pl_intr |= F_PL_INTR_EXT | F_PL_INTR_PCIX;
  639. writel(pl_intr, adapter->regs + A_PL_ENABLE);
  640. }
  641. }
  642. /* Disables all interrupts. */
  643. void t1_interrupts_disable(adapter_t* adapter)
  644. {
  645. unsigned int i;
  646. t1_sge_intr_disable(adapter->sge);
  647. t1_tp_intr_disable(adapter->tp);
  648. if (adapter->espi)
  649. t1_espi_intr_disable(adapter->espi);
  650. /* Disable MAC/PHY interrupts for each port. */
  651. for_each_port(adapter, i) {
  652. adapter->port[i].mac->ops->interrupt_disable(adapter->port[i].mac);
  653. adapter->port[i].phy->ops->interrupt_disable(adapter->port[i].phy);
  654. }
  655. /* Disable PCIX & external chip interrupts. */
  656. if (t1_is_asic(adapter))
  657. writel(0, adapter->regs + A_PL_ENABLE);
  658. /* PCI-X interrupts */
  659. pci_write_config_dword(adapter->pdev, A_PCICFG_INTR_ENABLE, 0);
  660. adapter->slow_intr_mask = 0;
  661. }
  662. /* Clears all interrupts */
  663. void t1_interrupts_clear(adapter_t* adapter)
  664. {
  665. unsigned int i;
  666. t1_sge_intr_clear(adapter->sge);
  667. t1_tp_intr_clear(adapter->tp);
  668. if (adapter->espi)
  669. t1_espi_intr_clear(adapter->espi);
  670. /* Clear MAC/PHY interrupts for each port. */
  671. for_each_port(adapter, i) {
  672. adapter->port[i].mac->ops->interrupt_clear(adapter->port[i].mac);
  673. adapter->port[i].phy->ops->interrupt_clear(adapter->port[i].phy);
  674. }
  675. /* Enable interrupts for external devices. */
  676. if (t1_is_asic(adapter)) {
  677. u32 pl_intr = readl(adapter->regs + A_PL_CAUSE);
  678. writel(pl_intr | F_PL_INTR_EXT | F_PL_INTR_PCIX,
  679. adapter->regs + A_PL_CAUSE);
  680. }
  681. /* PCI-X interrupts */
  682. pci_write_config_dword(adapter->pdev, A_PCICFG_INTR_CAUSE, 0xffffffff);
  683. }
  684. /*
  685. * Slow path interrupt handler for ASICs.
  686. */
  687. static int asic_slow_intr(adapter_t *adapter)
  688. {
  689. u32 cause = readl(adapter->regs + A_PL_CAUSE);
  690. cause &= adapter->slow_intr_mask;
  691. if (!cause)
  692. return 0;
  693. if (cause & F_PL_INTR_SGE_ERR)
  694. t1_sge_intr_error_handler(adapter->sge);
  695. if (cause & F_PL_INTR_TP)
  696. t1_tp_intr_handler(adapter->tp);
  697. if (cause & F_PL_INTR_ESPI)
  698. t1_espi_intr_handler(adapter->espi);
  699. if (cause & F_PL_INTR_PCIX)
  700. t1_pci_intr_handler(adapter);
  701. if (cause & F_PL_INTR_EXT)
  702. t1_elmer0_ext_intr_handler(adapter);
  703. /* Clear the interrupts just processed. */
  704. writel(cause, adapter->regs + A_PL_CAUSE);
  705. readl(adapter->regs + A_PL_CAUSE); /* flush writes */
  706. return 1;
  707. }
  708. int t1_slow_intr_handler(adapter_t *adapter)
  709. {
  710. #ifdef CONFIG_CHELSIO_T1_1G
  711. if (!t1_is_asic(adapter))
  712. return fpga_slow_intr(adapter);
  713. #endif
  714. return asic_slow_intr(adapter);
  715. }
  716. /* Power sequencing is a work-around for Intel's XPAKs. */
  717. static void power_sequence_xpak(adapter_t* adapter)
  718. {
  719. u32 mod_detect;
  720. u32 gpo;
  721. /* Check for XPAK */
  722. t1_tpi_read(adapter, A_ELMER0_GPI_STAT, &mod_detect);
  723. if (!(ELMER0_GP_BIT5 & mod_detect)) {
  724. /* XPAK is present */
  725. t1_tpi_read(adapter, A_ELMER0_GPO, &gpo);
  726. gpo |= ELMER0_GP_BIT18;
  727. t1_tpi_write(adapter, A_ELMER0_GPO, gpo);
  728. }
  729. }
  730. int __devinit t1_get_board_rev(adapter_t *adapter, const struct board_info *bi,
  731. struct adapter_params *p)
  732. {
  733. p->chip_version = bi->chip_term;
  734. p->is_asic = (p->chip_version != CHBT_TERM_FPGA);
  735. if (p->chip_version == CHBT_TERM_T1 ||
  736. p->chip_version == CHBT_TERM_T2 ||
  737. p->chip_version == CHBT_TERM_FPGA) {
  738. u32 val = readl(adapter->regs + A_TP_PC_CONFIG);
  739. val = G_TP_PC_REV(val);
  740. if (val == 2)
  741. p->chip_revision = TERM_T1B;
  742. else if (val == 3)
  743. p->chip_revision = TERM_T2;
  744. else
  745. return -1;
  746. } else
  747. return -1;
  748. return 0;
  749. }
  750. /*
  751. * Enable board components other than the Chelsio chip, such as external MAC
  752. * and PHY.
  753. */
  754. static int board_init(adapter_t *adapter, const struct board_info *bi)
  755. {
  756. switch (bi->board) {
  757. case CHBT_BOARD_8000:
  758. case CHBT_BOARD_N110:
  759. case CHBT_BOARD_N210:
  760. case CHBT_BOARD_CHT210:
  761. case CHBT_BOARD_COUGAR:
  762. t1_tpi_par(adapter, 0xf);
  763. t1_tpi_write(adapter, A_ELMER0_GPO, 0x800);
  764. break;
  765. case CHBT_BOARD_CHT110:
  766. t1_tpi_par(adapter, 0xf);
  767. t1_tpi_write(adapter, A_ELMER0_GPO, 0x1800);
  768. /* TBD XXX Might not need. This fixes a problem
  769. * described in the Intel SR XPAK errata.
  770. */
  771. power_sequence_xpak(adapter);
  772. break;
  773. #ifdef CONFIG_CHELSIO_T1_1G
  774. case CHBT_BOARD_CHT204E:
  775. /* add config space write here */
  776. case CHBT_BOARD_CHT204:
  777. case CHBT_BOARD_CHT204V:
  778. case CHBT_BOARD_CHN204:
  779. t1_tpi_par(adapter, 0xf);
  780. t1_tpi_write(adapter, A_ELMER0_GPO, 0x804);
  781. break;
  782. case CHBT_BOARD_CHT101:
  783. case CHBT_BOARD_7500:
  784. t1_tpi_par(adapter, 0xf);
  785. t1_tpi_write(adapter, A_ELMER0_GPO, 0x1804);
  786. break;
  787. #endif
  788. }
  789. return 0;
  790. }
  791. /*
  792. * Initialize and configure the Terminator HW modules. Note that external
  793. * MAC and PHYs are initialized separately.
  794. */
  795. int t1_init_hw_modules(adapter_t *adapter)
  796. {
  797. int err = -EIO;
  798. const struct board_info *bi = board_info(adapter);
  799. if (!bi->clock_mc4) {
  800. u32 val = readl(adapter->regs + A_MC4_CFG);
  801. writel(val | F_READY | F_MC4_SLOW, adapter->regs + A_MC4_CFG);
  802. writel(F_M_BUS_ENABLE | F_TCAM_RESET,
  803. adapter->regs + A_MC5_CONFIG);
  804. }
  805. #ifdef CONFIG_CHELSIO_T1_COUGAR
  806. if (adapter->cspi && t1_cspi_init(adapter->cspi))
  807. goto out_err;
  808. #endif
  809. if (adapter->espi && t1_espi_init(adapter->espi, bi->chip_mac,
  810. bi->espi_nports))
  811. goto out_err;
  812. if (t1_tp_reset(adapter->tp, &adapter->params.tp, bi->clock_core))
  813. goto out_err;
  814. err = t1_sge_configure(adapter->sge, &adapter->params.sge);
  815. if (err)
  816. goto out_err;
  817. err = 0;
  818. out_err:
  819. return err;
  820. }
  821. /*
  822. * Determine a card's PCI mode.
  823. */
  824. static void __devinit get_pci_mode(adapter_t *adapter, struct chelsio_pci_params *p)
  825. {
  826. static const unsigned short speed_map[] = { 33, 66, 100, 133 };
  827. u32 pci_mode;
  828. pci_read_config_dword(adapter->pdev, A_PCICFG_MODE, &pci_mode);
  829. p->speed = speed_map[G_PCI_MODE_CLK(pci_mode)];
  830. p->width = (pci_mode & F_PCI_MODE_64BIT) ? 64 : 32;
  831. p->is_pcix = (pci_mode & F_PCI_MODE_PCIX) != 0;
  832. }
  833. /*
  834. * Release the structures holding the SW per-Terminator-HW-module state.
  835. */
  836. void t1_free_sw_modules(adapter_t *adapter)
  837. {
  838. unsigned int i;
  839. for_each_port(adapter, i) {
  840. struct cmac *mac = adapter->port[i].mac;
  841. struct cphy *phy = adapter->port[i].phy;
  842. if (mac)
  843. mac->ops->destroy(mac);
  844. if (phy)
  845. phy->ops->destroy(phy);
  846. }
  847. if (adapter->sge)
  848. t1_sge_destroy(adapter->sge);
  849. if (adapter->tp)
  850. t1_tp_destroy(adapter->tp);
  851. if (adapter->espi)
  852. t1_espi_destroy(adapter->espi);
  853. #ifdef CONFIG_CHELSIO_T1_COUGAR
  854. if (adapter->cspi)
  855. t1_cspi_destroy(adapter->cspi);
  856. #endif
  857. }
  858. static void __devinit init_link_config(struct link_config *lc,
  859. const struct board_info *bi)
  860. {
  861. lc->supported = bi->caps;
  862. lc->requested_speed = lc->speed = SPEED_INVALID;
  863. lc->requested_duplex = lc->duplex = DUPLEX_INVALID;
  864. lc->requested_fc = lc->fc = PAUSE_RX | PAUSE_TX;
  865. if (lc->supported & SUPPORTED_Autoneg) {
  866. lc->advertising = lc->supported;
  867. lc->autoneg = AUTONEG_ENABLE;
  868. lc->requested_fc |= PAUSE_AUTONEG;
  869. } else {
  870. lc->advertising = 0;
  871. lc->autoneg = AUTONEG_DISABLE;
  872. }
  873. }
  874. #ifdef CONFIG_CHELSIO_T1_COUGAR
  875. if (bi->clock_cspi && !(adapter->cspi = t1_cspi_create(adapter))) {
  876. CH_ERR("%s: CSPI initialization failed\n",
  877. adapter->name);
  878. goto error;
  879. }
  880. #endif
  881. /*
  882. * Allocate and initialize the data structures that hold the SW state of
  883. * the Terminator HW modules.
  884. */
  885. int __devinit t1_init_sw_modules(adapter_t *adapter,
  886. const struct board_info *bi)
  887. {
  888. unsigned int i;
  889. adapter->params.brd_info = bi;
  890. adapter->params.nports = bi->port_number;
  891. adapter->params.stats_update_period = bi->gmac->stats_update_period;
  892. adapter->sge = t1_sge_create(adapter, &adapter->params.sge);
  893. if (!adapter->sge) {
  894. CH_ERR("%s: SGE initialization failed\n",
  895. adapter->name);
  896. goto error;
  897. }
  898. if (bi->espi_nports && !(adapter->espi = t1_espi_create(adapter))) {
  899. CH_ERR("%s: ESPI initialization failed\n",
  900. adapter->name);
  901. goto error;
  902. }
  903. adapter->tp = t1_tp_create(adapter, &adapter->params.tp);
  904. if (!adapter->tp) {
  905. CH_ERR("%s: TP initialization failed\n",
  906. adapter->name);
  907. goto error;
  908. }
  909. board_init(adapter, bi);
  910. bi->mdio_ops->init(adapter, bi);
  911. if (bi->gphy->reset)
  912. bi->gphy->reset(adapter);
  913. if (bi->gmac->reset)
  914. bi->gmac->reset(adapter);
  915. for_each_port(adapter, i) {
  916. u8 hw_addr[6];
  917. struct cmac *mac;
  918. int phy_addr = bi->mdio_phybaseaddr + i;
  919. adapter->port[i].phy = bi->gphy->create(adapter, phy_addr,
  920. bi->mdio_ops);
  921. if (!adapter->port[i].phy) {
  922. CH_ERR("%s: PHY %d initialization failed\n",
  923. adapter->name, i);
  924. goto error;
  925. }
  926. adapter->port[i].mac = mac = bi->gmac->create(adapter, i);
  927. if (!mac) {
  928. CH_ERR("%s: MAC %d initialization failed\n",
  929. adapter->name, i);
  930. goto error;
  931. }
  932. /*
  933. * Get the port's MAC addresses either from the EEPROM if one
  934. * exists or the one hardcoded in the MAC.
  935. */
  936. if (!t1_is_asic(adapter) || bi->chip_mac == CHBT_MAC_DUMMY)
  937. mac->ops->macaddress_get(mac, hw_addr);
  938. else if (vpd_macaddress_get(adapter, i, hw_addr)) {
  939. CH_ERR("%s: could not read MAC address from VPD ROM\n",
  940. adapter->port[i].dev->name);
  941. goto error;
  942. }
  943. memcpy(adapter->port[i].dev->dev_addr, hw_addr, ETH_ALEN);
  944. init_link_config(&adapter->port[i].link_config, bi);
  945. }
  946. get_pci_mode(adapter, &adapter->params.pci);
  947. t1_interrupts_clear(adapter);
  948. return 0;
  949. error:
  950. t1_free_sw_modules(adapter);
  951. return -1;
  952. }