mv_94xx.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684
  1. /*
  2. * Marvell 88SE94xx hardware specific
  3. *
  4. * Copyright 2007 Red Hat, Inc.
  5. * Copyright 2008 Marvell. <kewei@marvell.com>
  6. * Copyright 2009-2011 Marvell. <yuxiangl@marvell.com>
  7. *
  8. * This file is licensed under GPLv2.
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public License as
  12. * published by the Free Software Foundation; version 2 of the
  13. * License.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18. * General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  23. * USA
  24. */
  25. #include "mv_sas.h"
  26. #include "mv_94xx.h"
  27. #include "mv_chips.h"
  28. static void mvs_94xx_detect_porttype(struct mvs_info *mvi, int i)
  29. {
  30. u32 reg;
  31. struct mvs_phy *phy = &mvi->phy[i];
  32. u32 phy_status;
  33. mvs_write_port_vsr_addr(mvi, i, VSR_PHY_MODE3);
  34. reg = mvs_read_port_vsr_data(mvi, i);
  35. phy_status = ((reg & 0x3f0000) >> 16) & 0xff;
  36. phy->phy_type &= ~(PORT_TYPE_SAS | PORT_TYPE_SATA);
  37. switch (phy_status) {
  38. case 0x10:
  39. phy->phy_type |= PORT_TYPE_SAS;
  40. break;
  41. case 0x1d:
  42. default:
  43. phy->phy_type |= PORT_TYPE_SATA;
  44. break;
  45. }
  46. }
  47. static void __devinit mvs_94xx_enable_xmt(struct mvs_info *mvi, int phy_id)
  48. {
  49. void __iomem *regs = mvi->regs;
  50. u32 tmp;
  51. tmp = mr32(MVS_PCS);
  52. tmp |= 1 << (phy_id + PCS_EN_PORT_XMT_SHIFT2);
  53. mw32(MVS_PCS, tmp);
  54. }
  55. static void mvs_94xx_phy_reset(struct mvs_info *mvi, u32 phy_id, int hard)
  56. {
  57. u32 tmp;
  58. tmp = mvs_read_port_irq_stat(mvi, phy_id);
  59. tmp &= ~PHYEV_RDY_CH;
  60. mvs_write_port_irq_stat(mvi, phy_id, tmp);
  61. if (hard) {
  62. tmp = mvs_read_phy_ctl(mvi, phy_id);
  63. tmp |= PHY_RST_HARD;
  64. mvs_write_phy_ctl(mvi, phy_id, tmp);
  65. do {
  66. tmp = mvs_read_phy_ctl(mvi, phy_id);
  67. } while (tmp & PHY_RST_HARD);
  68. } else {
  69. mvs_write_port_vsr_addr(mvi, phy_id, VSR_PHY_STAT);
  70. tmp = mvs_read_port_vsr_data(mvi, phy_id);
  71. tmp |= PHY_RST;
  72. mvs_write_port_vsr_data(mvi, phy_id, tmp);
  73. }
  74. }
  75. static void mvs_94xx_phy_disable(struct mvs_info *mvi, u32 phy_id)
  76. {
  77. u32 tmp;
  78. mvs_write_port_vsr_addr(mvi, phy_id, VSR_PHY_MODE2);
  79. tmp = mvs_read_port_vsr_data(mvi, phy_id);
  80. mvs_write_port_vsr_data(mvi, phy_id, tmp | 0x00800000);
  81. }
  82. static void mvs_94xx_phy_enable(struct mvs_info *mvi, u32 phy_id)
  83. {
  84. mvs_write_port_vsr_addr(mvi, phy_id, 0x1B4);
  85. mvs_write_port_vsr_data(mvi, phy_id, 0x8300ffc1);
  86. mvs_write_port_vsr_addr(mvi, phy_id, 0x104);
  87. mvs_write_port_vsr_data(mvi, phy_id, 0x00018080);
  88. mvs_write_port_vsr_addr(mvi, phy_id, VSR_PHY_MODE2);
  89. mvs_write_port_vsr_data(mvi, phy_id, 0x00207fff);
  90. }
  91. static int __devinit mvs_94xx_init(struct mvs_info *mvi)
  92. {
  93. void __iomem *regs = mvi->regs;
  94. int i;
  95. u32 tmp, cctl;
  96. mvs_show_pcie_usage(mvi);
  97. if (mvi->flags & MVF_FLAG_SOC) {
  98. tmp = mr32(MVS_PHY_CTL);
  99. tmp &= ~PCTL_PWR_OFF;
  100. tmp |= PCTL_PHY_DSBL;
  101. mw32(MVS_PHY_CTL, tmp);
  102. }
  103. /* Init Chip */
  104. /* make sure RST is set; HBA_RST /should/ have done that for us */
  105. cctl = mr32(MVS_CTL) & 0xFFFF;
  106. if (cctl & CCTL_RST)
  107. cctl &= ~CCTL_RST;
  108. else
  109. mw32_f(MVS_CTL, cctl | CCTL_RST);
  110. if (mvi->flags & MVF_FLAG_SOC) {
  111. tmp = mr32(MVS_PHY_CTL);
  112. tmp &= ~PCTL_PWR_OFF;
  113. tmp |= PCTL_COM_ON;
  114. tmp &= ~PCTL_PHY_DSBL;
  115. tmp |= PCTL_LINK_RST;
  116. mw32(MVS_PHY_CTL, tmp);
  117. msleep(100);
  118. tmp &= ~PCTL_LINK_RST;
  119. mw32(MVS_PHY_CTL, tmp);
  120. msleep(100);
  121. }
  122. /* reset control */
  123. mw32(MVS_PCS, 0); /* MVS_PCS */
  124. mw32(MVS_STP_REG_SET_0, 0);
  125. mw32(MVS_STP_REG_SET_1, 0);
  126. /* init phys */
  127. mvs_phy_hacks(mvi);
  128. /* disable Multiplexing, enable phy implemented */
  129. mw32(MVS_PORTS_IMP, 0xFF);
  130. mw32(MVS_PA_VSR_ADDR, 0x00000104);
  131. mw32(MVS_PA_VSR_PORT, 0x00018080);
  132. mw32(MVS_PA_VSR_ADDR, VSR_PHY_MODE8);
  133. mw32(MVS_PA_VSR_PORT, 0x0084ffff);
  134. /* set LED blink when IO*/
  135. mw32(MVS_PA_VSR_ADDR, 0x00000030);
  136. tmp = mr32(MVS_PA_VSR_PORT);
  137. tmp &= 0xFFFF00FF;
  138. tmp |= 0x00003300;
  139. mw32(MVS_PA_VSR_PORT, tmp);
  140. mw32(MVS_CMD_LIST_LO, mvi->slot_dma);
  141. mw32(MVS_CMD_LIST_HI, (mvi->slot_dma >> 16) >> 16);
  142. mw32(MVS_RX_FIS_LO, mvi->rx_fis_dma);
  143. mw32(MVS_RX_FIS_HI, (mvi->rx_fis_dma >> 16) >> 16);
  144. mw32(MVS_TX_CFG, MVS_CHIP_SLOT_SZ);
  145. mw32(MVS_TX_LO, mvi->tx_dma);
  146. mw32(MVS_TX_HI, (mvi->tx_dma >> 16) >> 16);
  147. mw32(MVS_RX_CFG, MVS_RX_RING_SZ);
  148. mw32(MVS_RX_LO, mvi->rx_dma);
  149. mw32(MVS_RX_HI, (mvi->rx_dma >> 16) >> 16);
  150. for (i = 0; i < mvi->chip->n_phy; i++) {
  151. mvs_94xx_phy_disable(mvi, i);
  152. /* set phy local SAS address */
  153. mvs_set_sas_addr(mvi, i, CONFIG_ID_FRAME3, CONFIG_ID_FRAME4,
  154. (mvi->phy[i].dev_sas_addr));
  155. mvs_94xx_enable_xmt(mvi, i);
  156. mvs_94xx_phy_enable(mvi, i);
  157. mvs_94xx_phy_reset(mvi, i, 1);
  158. msleep(500);
  159. mvs_94xx_detect_porttype(mvi, i);
  160. }
  161. if (mvi->flags & MVF_FLAG_SOC) {
  162. /* set select registers */
  163. writel(0x0E008000, regs + 0x000);
  164. writel(0x59000008, regs + 0x004);
  165. writel(0x20, regs + 0x008);
  166. writel(0x20, regs + 0x00c);
  167. writel(0x20, regs + 0x010);
  168. writel(0x20, regs + 0x014);
  169. writel(0x20, regs + 0x018);
  170. writel(0x20, regs + 0x01c);
  171. }
  172. for (i = 0; i < mvi->chip->n_phy; i++) {
  173. /* clear phy int status */
  174. tmp = mvs_read_port_irq_stat(mvi, i);
  175. tmp &= ~PHYEV_SIG_FIS;
  176. mvs_write_port_irq_stat(mvi, i, tmp);
  177. /* set phy int mask */
  178. tmp = PHYEV_RDY_CH | PHYEV_BROAD_CH |
  179. PHYEV_ID_DONE | PHYEV_DCDR_ERR | PHYEV_CRC_ERR ;
  180. mvs_write_port_irq_mask(mvi, i, tmp);
  181. msleep(100);
  182. mvs_update_phyinfo(mvi, i, 1);
  183. }
  184. /* FIXME: update wide port bitmaps */
  185. /* little endian for open address and command table, etc. */
  186. /*
  187. * it seems that ( from the spec ) turning on big-endian won't
  188. * do us any good on big-endian machines, need further confirmation
  189. */
  190. cctl = mr32(MVS_CTL);
  191. cctl |= CCTL_ENDIAN_CMD;
  192. cctl |= CCTL_ENDIAN_DATA;
  193. cctl &= ~CCTL_ENDIAN_OPEN;
  194. cctl |= CCTL_ENDIAN_RSP;
  195. mw32_f(MVS_CTL, cctl);
  196. /* reset CMD queue */
  197. tmp = mr32(MVS_PCS);
  198. tmp |= PCS_CMD_RST;
  199. mw32(MVS_PCS, tmp);
  200. /* interrupt coalescing may cause missing HW interrput in some case,
  201. * and the max count is 0x1ff, while our max slot is 0x200,
  202. * it will make count 0.
  203. */
  204. tmp = 0;
  205. mw32(MVS_INT_COAL, tmp);
  206. tmp = 0x100;
  207. mw32(MVS_INT_COAL_TMOUT, tmp);
  208. /* ladies and gentlemen, start your engines */
  209. mw32(MVS_TX_CFG, 0);
  210. mw32(MVS_TX_CFG, MVS_CHIP_SLOT_SZ | TX_EN);
  211. mw32(MVS_RX_CFG, MVS_RX_RING_SZ | RX_EN);
  212. /* enable CMD/CMPL_Q/RESP mode */
  213. mw32(MVS_PCS, PCS_SATA_RETRY_2 | PCS_FIS_RX_EN |
  214. PCS_CMD_EN | PCS_CMD_STOP_ERR);
  215. /* enable completion queue interrupt */
  216. tmp = (CINT_PORT_MASK | CINT_DONE | CINT_MEM | CINT_SRS | CINT_CI_STOP |
  217. CINT_DMA_PCIE);
  218. tmp |= CINT_PHY_MASK;
  219. mw32(MVS_INT_MASK, tmp);
  220. /* Enable SRS interrupt */
  221. mw32(MVS_INT_MASK_SRS_0, 0xFFFF);
  222. return 0;
  223. }
  224. static int mvs_94xx_ioremap(struct mvs_info *mvi)
  225. {
  226. if (!mvs_ioremap(mvi, 2, -1)) {
  227. mvi->regs_ex = mvi->regs + 0x10200;
  228. mvi->regs += 0x20000;
  229. if (mvi->id == 1)
  230. mvi->regs += 0x4000;
  231. return 0;
  232. }
  233. return -1;
  234. }
  235. static void mvs_94xx_iounmap(struct mvs_info *mvi)
  236. {
  237. if (mvi->regs) {
  238. mvi->regs -= 0x20000;
  239. if (mvi->id == 1)
  240. mvi->regs -= 0x4000;
  241. mvs_iounmap(mvi->regs);
  242. }
  243. }
  244. static void mvs_94xx_interrupt_enable(struct mvs_info *mvi)
  245. {
  246. void __iomem *regs = mvi->regs_ex;
  247. u32 tmp;
  248. tmp = mr32(MVS_GBL_CTL);
  249. tmp |= (IRQ_SAS_A | IRQ_SAS_B);
  250. mw32(MVS_GBL_INT_STAT, tmp);
  251. writel(tmp, regs + 0x0C);
  252. writel(tmp, regs + 0x10);
  253. writel(tmp, regs + 0x14);
  254. writel(tmp, regs + 0x18);
  255. mw32(MVS_GBL_CTL, tmp);
  256. }
  257. static void mvs_94xx_interrupt_disable(struct mvs_info *mvi)
  258. {
  259. void __iomem *regs = mvi->regs_ex;
  260. u32 tmp;
  261. tmp = mr32(MVS_GBL_CTL);
  262. tmp &= ~(IRQ_SAS_A | IRQ_SAS_B);
  263. mw32(MVS_GBL_INT_STAT, tmp);
  264. writel(tmp, regs + 0x0C);
  265. writel(tmp, regs + 0x10);
  266. writel(tmp, regs + 0x14);
  267. writel(tmp, regs + 0x18);
  268. mw32(MVS_GBL_CTL, tmp);
  269. }
  270. static u32 mvs_94xx_isr_status(struct mvs_info *mvi, int irq)
  271. {
  272. void __iomem *regs = mvi->regs_ex;
  273. u32 stat = 0;
  274. if (!(mvi->flags & MVF_FLAG_SOC)) {
  275. stat = mr32(MVS_GBL_INT_STAT);
  276. if (!(stat & (IRQ_SAS_A | IRQ_SAS_B)))
  277. return 0;
  278. }
  279. return stat;
  280. }
  281. static irqreturn_t mvs_94xx_isr(struct mvs_info *mvi, int irq, u32 stat)
  282. {
  283. void __iomem *regs = mvi->regs;
  284. if (((stat & IRQ_SAS_A) && mvi->id == 0) ||
  285. ((stat & IRQ_SAS_B) && mvi->id == 1)) {
  286. mw32_f(MVS_INT_STAT, CINT_DONE);
  287. #ifndef MVS_USE_TASKLET
  288. spin_lock(&mvi->lock);
  289. #endif
  290. mvs_int_full(mvi);
  291. #ifndef MVS_USE_TASKLET
  292. spin_unlock(&mvi->lock);
  293. #endif
  294. }
  295. return IRQ_HANDLED;
  296. }
  297. static void mvs_94xx_command_active(struct mvs_info *mvi, u32 slot_idx)
  298. {
  299. u32 tmp;
  300. mvs_cw32(mvi, 0x300 + (slot_idx >> 3), 1 << (slot_idx % 32));
  301. do {
  302. tmp = mvs_cr32(mvi, 0x300 + (slot_idx >> 3));
  303. } while (tmp & 1 << (slot_idx % 32));
  304. }
  305. static void mvs_94xx_issue_stop(struct mvs_info *mvi, enum mvs_port_type type,
  306. u32 tfs)
  307. {
  308. void __iomem *regs = mvi->regs;
  309. u32 tmp;
  310. if (type == PORT_TYPE_SATA) {
  311. tmp = mr32(MVS_INT_STAT_SRS_0) | (1U << tfs);
  312. mw32(MVS_INT_STAT_SRS_0, tmp);
  313. }
  314. mw32(MVS_INT_STAT, CINT_CI_STOP);
  315. tmp = mr32(MVS_PCS) | 0xFF00;
  316. mw32(MVS_PCS, tmp);
  317. }
  318. static void mvs_94xx_free_reg_set(struct mvs_info *mvi, u8 *tfs)
  319. {
  320. void __iomem *regs = mvi->regs;
  321. u32 tmp;
  322. u8 reg_set = *tfs;
  323. if (*tfs == MVS_ID_NOT_MAPPED)
  324. return;
  325. mvi->sata_reg_set &= ~bit(reg_set);
  326. if (reg_set < 32) {
  327. w_reg_set_enable(reg_set, (u32)mvi->sata_reg_set);
  328. tmp = mr32(MVS_INT_STAT_SRS_0) & (u32)mvi->sata_reg_set;
  329. if (tmp)
  330. mw32(MVS_INT_STAT_SRS_0, tmp);
  331. } else {
  332. w_reg_set_enable(reg_set, mvi->sata_reg_set);
  333. tmp = mr32(MVS_INT_STAT_SRS_1) & mvi->sata_reg_set;
  334. if (tmp)
  335. mw32(MVS_INT_STAT_SRS_1, tmp);
  336. }
  337. *tfs = MVS_ID_NOT_MAPPED;
  338. return;
  339. }
  340. static u8 mvs_94xx_assign_reg_set(struct mvs_info *mvi, u8 *tfs)
  341. {
  342. int i;
  343. void __iomem *regs = mvi->regs;
  344. if (*tfs != MVS_ID_NOT_MAPPED)
  345. return 0;
  346. i = mv_ffc64(mvi->sata_reg_set);
  347. if (i > 32) {
  348. mvi->sata_reg_set |= bit(i);
  349. w_reg_set_enable(i, (u32)(mvi->sata_reg_set >> 32));
  350. *tfs = i;
  351. return 0;
  352. } else if (i >= 0) {
  353. mvi->sata_reg_set |= bit(i);
  354. w_reg_set_enable(i, (u32)mvi->sata_reg_set);
  355. *tfs = i;
  356. return 0;
  357. }
  358. return MVS_ID_NOT_MAPPED;
  359. }
  360. static void mvs_94xx_make_prd(struct scatterlist *scatter, int nr, void *prd)
  361. {
  362. int i;
  363. struct scatterlist *sg;
  364. struct mvs_prd *buf_prd = prd;
  365. for_each_sg(scatter, sg, nr, i) {
  366. buf_prd->addr = cpu_to_le64(sg_dma_address(sg));
  367. buf_prd->im_len.len = cpu_to_le32(sg_dma_len(sg));
  368. buf_prd++;
  369. }
  370. }
  371. static int mvs_94xx_oob_done(struct mvs_info *mvi, int i)
  372. {
  373. u32 phy_st;
  374. phy_st = mvs_read_phy_ctl(mvi, i);
  375. if (phy_st & PHY_READY_MASK) /* phy ready */
  376. return 1;
  377. return 0;
  378. }
  379. static void mvs_94xx_get_dev_identify_frame(struct mvs_info *mvi, int port_id,
  380. struct sas_identify_frame *id)
  381. {
  382. int i;
  383. u32 id_frame[7];
  384. for (i = 0; i < 7; i++) {
  385. mvs_write_port_cfg_addr(mvi, port_id,
  386. CONFIG_ID_FRAME0 + i * 4);
  387. id_frame[i] = mvs_read_port_cfg_data(mvi, port_id);
  388. }
  389. memcpy(id, id_frame, 28);
  390. }
  391. static void mvs_94xx_get_att_identify_frame(struct mvs_info *mvi, int port_id,
  392. struct sas_identify_frame *id)
  393. {
  394. int i;
  395. u32 id_frame[7];
  396. /* mvs_hexdump(28, (u8 *)id_frame, 0); */
  397. for (i = 0; i < 7; i++) {
  398. mvs_write_port_cfg_addr(mvi, port_id,
  399. CONFIG_ATT_ID_FRAME0 + i * 4);
  400. id_frame[i] = mvs_read_port_cfg_data(mvi, port_id);
  401. mv_dprintk("94xx phy %d atta frame %d %x.\n",
  402. port_id + mvi->id * mvi->chip->n_phy, i, id_frame[i]);
  403. }
  404. /* mvs_hexdump(28, (u8 *)id_frame, 0); */
  405. memcpy(id, id_frame, 28);
  406. }
  407. static u32 mvs_94xx_make_dev_info(struct sas_identify_frame *id)
  408. {
  409. u32 att_dev_info = 0;
  410. att_dev_info |= id->dev_type;
  411. if (id->stp_iport)
  412. att_dev_info |= PORT_DEV_STP_INIT;
  413. if (id->smp_iport)
  414. att_dev_info |= PORT_DEV_SMP_INIT;
  415. if (id->ssp_iport)
  416. att_dev_info |= PORT_DEV_SSP_INIT;
  417. if (id->stp_tport)
  418. att_dev_info |= PORT_DEV_STP_TRGT;
  419. if (id->smp_tport)
  420. att_dev_info |= PORT_DEV_SMP_TRGT;
  421. if (id->ssp_tport)
  422. att_dev_info |= PORT_DEV_SSP_TRGT;
  423. att_dev_info |= (u32)id->phy_id<<24;
  424. return att_dev_info;
  425. }
  426. static u32 mvs_94xx_make_att_info(struct sas_identify_frame *id)
  427. {
  428. return mvs_94xx_make_dev_info(id);
  429. }
  430. static void mvs_94xx_fix_phy_info(struct mvs_info *mvi, int i,
  431. struct sas_identify_frame *id)
  432. {
  433. struct mvs_phy *phy = &mvi->phy[i];
  434. struct asd_sas_phy *sas_phy = &phy->sas_phy;
  435. mv_dprintk("get all reg link rate is 0x%x\n", phy->phy_status);
  436. sas_phy->linkrate =
  437. (phy->phy_status & PHY_NEG_SPP_PHYS_LINK_RATE_MASK) >>
  438. PHY_NEG_SPP_PHYS_LINK_RATE_MASK_OFFSET;
  439. sas_phy->linkrate += 0x8;
  440. mv_dprintk("get link rate is %d\n", sas_phy->linkrate);
  441. phy->minimum_linkrate = SAS_LINK_RATE_1_5_GBPS;
  442. phy->maximum_linkrate = SAS_LINK_RATE_6_0_GBPS;
  443. mvs_94xx_get_dev_identify_frame(mvi, i, id);
  444. phy->dev_info = mvs_94xx_make_dev_info(id);
  445. if (phy->phy_type & PORT_TYPE_SAS) {
  446. mvs_94xx_get_att_identify_frame(mvi, i, id);
  447. phy->att_dev_info = mvs_94xx_make_att_info(id);
  448. phy->att_dev_sas_addr = *(u64 *)id->sas_addr;
  449. } else {
  450. phy->att_dev_info = PORT_DEV_STP_TRGT | 1;
  451. }
  452. }
  453. void mvs_94xx_phy_set_link_rate(struct mvs_info *mvi, u32 phy_id,
  454. struct sas_phy_linkrates *rates)
  455. {
  456. /* TODO */
  457. }
  458. static void mvs_94xx_clear_active_cmds(struct mvs_info *mvi)
  459. {
  460. u32 tmp;
  461. void __iomem *regs = mvi->regs;
  462. tmp = mr32(MVS_STP_REG_SET_0);
  463. mw32(MVS_STP_REG_SET_0, 0);
  464. mw32(MVS_STP_REG_SET_0, tmp);
  465. tmp = mr32(MVS_STP_REG_SET_1);
  466. mw32(MVS_STP_REG_SET_1, 0);
  467. mw32(MVS_STP_REG_SET_1, tmp);
  468. }
  469. u32 mvs_94xx_spi_read_data(struct mvs_info *mvi)
  470. {
  471. void __iomem *regs = mvi->regs_ex - 0x10200;
  472. return mr32(SPI_RD_DATA_REG_94XX);
  473. }
  474. void mvs_94xx_spi_write_data(struct mvs_info *mvi, u32 data)
  475. {
  476. void __iomem *regs = mvi->regs_ex - 0x10200;
  477. mw32(SPI_RD_DATA_REG_94XX, data);
  478. }
  479. int mvs_94xx_spi_buildcmd(struct mvs_info *mvi,
  480. u32 *dwCmd,
  481. u8 cmd,
  482. u8 read,
  483. u8 length,
  484. u32 addr
  485. )
  486. {
  487. void __iomem *regs = mvi->regs_ex - 0x10200;
  488. u32 dwTmp;
  489. dwTmp = ((u32)cmd << 8) | ((u32)length << 4);
  490. if (read)
  491. dwTmp |= SPI_CTRL_READ_94XX;
  492. if (addr != MV_MAX_U32) {
  493. mw32(SPI_ADDR_REG_94XX, (addr & 0x0003FFFFL));
  494. dwTmp |= SPI_ADDR_VLD_94XX;
  495. }
  496. *dwCmd = dwTmp;
  497. return 0;
  498. }
  499. int mvs_94xx_spi_issuecmd(struct mvs_info *mvi, u32 cmd)
  500. {
  501. void __iomem *regs = mvi->regs_ex - 0x10200;
  502. mw32(SPI_CTRL_REG_94XX, cmd | SPI_CTRL_SpiStart_94XX);
  503. return 0;
  504. }
  505. int mvs_94xx_spi_waitdataready(struct mvs_info *mvi, u32 timeout)
  506. {
  507. void __iomem *regs = mvi->regs_ex - 0x10200;
  508. u32 i, dwTmp;
  509. for (i = 0; i < timeout; i++) {
  510. dwTmp = mr32(SPI_CTRL_REG_94XX);
  511. if (!(dwTmp & SPI_CTRL_SpiStart_94XX))
  512. return 0;
  513. msleep(10);
  514. }
  515. return -1;
  516. }
  517. #ifndef DISABLE_HOTPLUG_DMA_FIX
  518. void mvs_94xx_fix_dma(dma_addr_t buf_dma, int buf_len, int from, void *prd)
  519. {
  520. int i;
  521. struct mvs_prd *buf_prd = prd;
  522. buf_prd += from;
  523. for (i = 0; i < MAX_SG_ENTRY - from; i++) {
  524. buf_prd->addr = cpu_to_le64(buf_dma);
  525. buf_prd->im_len.len = cpu_to_le32(buf_len);
  526. ++buf_prd;
  527. }
  528. }
  529. #endif
  530. /*
  531. * FIXME JEJB: temporary nop clear_srs_irq to make 94xx still work
  532. * with 64xx fixes
  533. */
  534. static void mvs_94xx_clear_srs_irq(struct mvs_info *mvi, u8 reg_set,
  535. u8 clear_all)
  536. {
  537. }
  538. const struct mvs_dispatch mvs_94xx_dispatch = {
  539. "mv94xx",
  540. mvs_94xx_init,
  541. NULL,
  542. mvs_94xx_ioremap,
  543. mvs_94xx_iounmap,
  544. mvs_94xx_isr,
  545. mvs_94xx_isr_status,
  546. mvs_94xx_interrupt_enable,
  547. mvs_94xx_interrupt_disable,
  548. mvs_read_phy_ctl,
  549. mvs_write_phy_ctl,
  550. mvs_read_port_cfg_data,
  551. mvs_write_port_cfg_data,
  552. mvs_write_port_cfg_addr,
  553. mvs_read_port_vsr_data,
  554. mvs_write_port_vsr_data,
  555. mvs_write_port_vsr_addr,
  556. mvs_read_port_irq_stat,
  557. mvs_write_port_irq_stat,
  558. mvs_read_port_irq_mask,
  559. mvs_write_port_irq_mask,
  560. mvs_get_sas_addr,
  561. mvs_94xx_command_active,
  562. mvs_94xx_clear_srs_irq,
  563. mvs_94xx_issue_stop,
  564. mvs_start_delivery,
  565. mvs_rx_update,
  566. mvs_int_full,
  567. mvs_94xx_assign_reg_set,
  568. mvs_94xx_free_reg_set,
  569. mvs_get_prd_size,
  570. mvs_get_prd_count,
  571. mvs_94xx_make_prd,
  572. mvs_94xx_detect_porttype,
  573. mvs_94xx_oob_done,
  574. mvs_94xx_fix_phy_info,
  575. NULL,
  576. mvs_94xx_phy_set_link_rate,
  577. mvs_hw_max_link_rate,
  578. mvs_94xx_phy_disable,
  579. mvs_94xx_phy_enable,
  580. mvs_94xx_phy_reset,
  581. NULL,
  582. mvs_94xx_clear_active_cmds,
  583. mvs_94xx_spi_read_data,
  584. mvs_94xx_spi_write_data,
  585. mvs_94xx_spi_buildcmd,
  586. mvs_94xx_spi_issuecmd,
  587. mvs_94xx_spi_waitdataready,
  588. #ifndef DISABLE_HOTPLUG_DMA_FIX
  589. mvs_94xx_fix_dma,
  590. #endif
  591. };