2 * Marvell 88SE64xx hardware specific
4 * Copyright 2007 Red Hat, Inc.
5 * Copyright 2008 Marvell. <kewei@marvell.com>
7 * This file is licensed under GPLv2.
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; version 2 of the
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
29 static void mvs_64xx_detect_porttype(struct mvs_info
*mvi
, int i
)
31 void __iomem
*regs
= mvi
->regs
;
33 struct mvs_phy
*phy
= &mvi
->phy
[i
];
35 /* TODO check & save device type */
36 reg
= mr32(MVS_GBL_PORT_TYPE
);
37 phy
->phy_type
&= ~(PORT_TYPE_SAS
| PORT_TYPE_SATA
);
38 if (reg
& MODE_SAS_SATA
& (1 << i
))
39 phy
->phy_type
|= PORT_TYPE_SAS
;
41 phy
->phy_type
|= PORT_TYPE_SATA
;
44 static void __devinit
mvs_64xx_enable_xmt(struct mvs_info
*mvi
, int phy_id
)
46 void __iomem
*regs
= mvi
->regs
;
50 if (mvi
->chip
->n_phy
<= 4)
51 tmp
|= 1 << (phy_id
+ PCS_EN_PORT_XMT_SHIFT
);
53 tmp
|= 1 << (phy_id
+ PCS_EN_PORT_XMT_SHIFT2
);
57 static void __devinit
mvs_64xx_phy_hacks(struct mvs_info
*mvi
)
59 void __iomem
*regs
= mvi
->regs
;
63 if (!(mvi
->flags
& MVF_FLAG_SOC
)) {
64 /* TEST - for phy decoding error, adjust voltage levels */
65 mw32(MVS_P0_VSR_ADDR
+ 0, 0x8);
66 mw32(MVS_P0_VSR_DATA
+ 0, 0x2F0);
68 mw32(MVS_P0_VSR_ADDR
+ 8, 0x8);
69 mw32(MVS_P0_VSR_DATA
+ 8, 0x2F0);
71 mw32(MVS_P0_VSR_ADDR
+ 16, 0x8);
72 mw32(MVS_P0_VSR_DATA
+ 16, 0x2F0);
74 mw32(MVS_P0_VSR_ADDR
+ 24, 0x8);
75 mw32(MVS_P0_VSR_DATA
+ 24, 0x2F0);
78 /* disable auto port detection */
79 mw32(MVS_GBL_PORT_TYPE
, 0);
80 for (i
= 0; i
< mvi
->chip
->n_phy
; i
++) {
81 mvs_write_port_vsr_addr(mvi
, i
, VSR_PHY_MODE7
);
82 mvs_write_port_vsr_data(mvi
, i
, 0x90000000);
83 mvs_write_port_vsr_addr(mvi
, i
, VSR_PHY_MODE9
);
84 mvs_write_port_vsr_data(mvi
, i
, 0x50f2);
85 mvs_write_port_vsr_addr(mvi
, i
, VSR_PHY_MODE11
);
86 mvs_write_port_vsr_data(mvi
, i
, 0x0e);
91 static void mvs_64xx_stp_reset(struct mvs_info
*mvi
, u32 phy_id
)
93 void __iomem
*regs
= mvi
->regs
;
96 if (!(mvi
->flags
& MVF_FLAG_SOC
)) {
98 pci_read_config_dword(mvi
->pdev
, PCR_PHY_CTL
, ®
);
100 pci_read_config_dword(mvi
->pdev
, PCR_PHY_CTL2
, ®
);
103 reg
= mr32(MVS_PHY_CTL
);
107 tmp
|= (1U << phy_id
) << PCTL_LINK_OFFS
;
109 tmp
|= (1U << (phy_id
- 4)) << PCTL_LINK_OFFS
;
111 if (!(mvi
->flags
& MVF_FLAG_SOC
)) {
113 pci_write_config_dword(mvi
->pdev
, PCR_PHY_CTL
, tmp
);
115 pci_write_config_dword(mvi
->pdev
, PCR_PHY_CTL
, reg
);
117 pci_write_config_dword(mvi
->pdev
, PCR_PHY_CTL2
, tmp
);
119 pci_write_config_dword(mvi
->pdev
, PCR_PHY_CTL2
, reg
);
122 mw32(MVS_PHY_CTL
, tmp
);
124 mw32(MVS_PHY_CTL
, reg
);
128 static void mvs_64xx_phy_reset(struct mvs_info
*mvi
, u32 phy_id
, int hard
)
131 tmp
= mvs_read_port_irq_stat(mvi
, phy_id
);
132 tmp
&= ~PHYEV_RDY_CH
;
133 mvs_write_port_irq_stat(mvi
, phy_id
, tmp
);
134 tmp
= mvs_read_phy_ctl(mvi
, phy_id
);
139 mvs_write_phy_ctl(mvi
, phy_id
, tmp
);
142 tmp
= mvs_read_phy_ctl(mvi
, phy_id
);
143 } while (tmp
& PHY_RST_HARD
);
147 void mvs_64xx_clear_srs_irq(struct mvs_info
*mvi
, u8 reg_set
, u8 clear_all
)
149 void __iomem
*regs
= mvi
->regs
;
152 tmp
= mr32(MVS_INT_STAT_SRS_0
);
154 printk(KERN_DEBUG
"check SRS 0 %08X.\n", tmp
);
155 mw32(MVS_INT_STAT_SRS_0
, tmp
);
158 tmp
= mr32(MVS_INT_STAT_SRS_0
);
159 if (tmp
& (1 << (reg_set
% 32))) {
160 printk(KERN_DEBUG
"register set 0x%x was stopped.\n",
162 mw32(MVS_INT_STAT_SRS_0
, 1 << (reg_set
% 32));
167 static int __devinit
mvs_64xx_chip_reset(struct mvs_info
*mvi
)
169 void __iomem
*regs
= mvi
->regs
;
173 /* make sure interrupts are masked immediately (paranoia) */
174 mw32(MVS_GBL_CTL
, 0);
175 tmp
= mr32(MVS_GBL_CTL
);
177 /* Reset Controller */
178 if (!(tmp
& HBA_RST
)) {
179 if (mvi
->flags
& MVF_PHY_PWR_FIX
) {
180 pci_read_config_dword(mvi
->pdev
, PCR_PHY_CTL
, &tmp
);
181 tmp
&= ~PCTL_PWR_OFF
;
182 tmp
|= PCTL_PHY_DSBL
;
183 pci_write_config_dword(mvi
->pdev
, PCR_PHY_CTL
, tmp
);
185 pci_read_config_dword(mvi
->pdev
, PCR_PHY_CTL2
, &tmp
);
186 tmp
&= ~PCTL_PWR_OFF
;
187 tmp
|= PCTL_PHY_DSBL
;
188 pci_write_config_dword(mvi
->pdev
, PCR_PHY_CTL2
, tmp
);
192 /* make sure interrupts are masked immediately (paranoia) */
193 mw32(MVS_GBL_CTL
, 0);
194 tmp
= mr32(MVS_GBL_CTL
);
196 /* Reset Controller */
197 if (!(tmp
& HBA_RST
)) {
198 /* global reset, incl. COMRESET/H_RESET_N (self-clearing) */
199 mw32_f(MVS_GBL_CTL
, HBA_RST
);
202 /* wait for reset to finish; timeout is just a guess */
207 if (!(mr32(MVS_GBL_CTL
) & HBA_RST
))
210 if (mr32(MVS_GBL_CTL
) & HBA_RST
) {
211 dev_printk(KERN_ERR
, mvi
->dev
, "HBA reset failed\n");
217 static void mvs_64xx_phy_disable(struct mvs_info
*mvi
, u32 phy_id
)
219 void __iomem
*regs
= mvi
->regs
;
221 if (!(mvi
->flags
& MVF_FLAG_SOC
)) {
229 pci_read_config_dword(mvi
->pdev
, offs
, &tmp
);
230 tmp
|= 1U << (PCTL_PHY_DSBL_OFFS
+ phy_id
);
231 pci_write_config_dword(mvi
->pdev
, offs
, tmp
);
233 tmp
= mr32(MVS_PHY_CTL
);
234 tmp
|= 1U << (PCTL_PHY_DSBL_OFFS
+ phy_id
);
235 mw32(MVS_PHY_CTL
, tmp
);
239 static void mvs_64xx_phy_enable(struct mvs_info
*mvi
, u32 phy_id
)
241 void __iomem
*regs
= mvi
->regs
;
243 if (!(mvi
->flags
& MVF_FLAG_SOC
)) {
251 pci_read_config_dword(mvi
->pdev
, offs
, &tmp
);
252 tmp
&= ~(1U << (PCTL_PHY_DSBL_OFFS
+ phy_id
));
253 pci_write_config_dword(mvi
->pdev
, offs
, tmp
);
255 tmp
= mr32(MVS_PHY_CTL
);
256 tmp
&= ~(1U << (PCTL_PHY_DSBL_OFFS
+ phy_id
));
257 mw32(MVS_PHY_CTL
, tmp
);
261 static int __devinit
mvs_64xx_init(struct mvs_info
*mvi
)
263 void __iomem
*regs
= mvi
->regs
;
267 if (mvi
->pdev
&& mvi
->pdev
->revision
== 0)
268 mvi
->flags
|= MVF_PHY_PWR_FIX
;
269 if (!(mvi
->flags
& MVF_FLAG_SOC
)) {
270 mvs_show_pcie_usage(mvi
);
271 tmp
= mvs_64xx_chip_reset(mvi
);
275 tmp
= mr32(MVS_PHY_CTL
);
276 tmp
&= ~PCTL_PWR_OFF
;
277 tmp
|= PCTL_PHY_DSBL
;
278 mw32(MVS_PHY_CTL
, tmp
);
282 /* make sure RST is set; HBA_RST /should/ have done that for us */
283 cctl
= mr32(MVS_CTL
) & 0xFFFF;
287 mw32_f(MVS_CTL
, cctl
| CCTL_RST
);
289 if (!(mvi
->flags
& MVF_FLAG_SOC
)) {
290 /* write to device control _AND_ device status register */
291 pci_read_config_dword(mvi
->pdev
, PCR_DEV_CTRL
, &tmp
);
292 tmp
&= ~PRD_REQ_MASK
;
294 pci_write_config_dword(mvi
->pdev
, PCR_DEV_CTRL
, tmp
);
296 pci_read_config_dword(mvi
->pdev
, PCR_PHY_CTL
, &tmp
);
297 tmp
&= ~PCTL_PWR_OFF
;
298 tmp
&= ~PCTL_PHY_DSBL
;
299 pci_write_config_dword(mvi
->pdev
, PCR_PHY_CTL
, tmp
);
301 pci_read_config_dword(mvi
->pdev
, PCR_PHY_CTL2
, &tmp
);
303 tmp
&= ~PCTL_PHY_DSBL
;
304 pci_write_config_dword(mvi
->pdev
, PCR_PHY_CTL2
, tmp
);
306 tmp
= mr32(MVS_PHY_CTL
);
307 tmp
&= ~PCTL_PWR_OFF
;
309 tmp
&= ~PCTL_PHY_DSBL
;
310 tmp
|= PCTL_LINK_RST
;
311 mw32(MVS_PHY_CTL
, tmp
);
313 tmp
&= ~PCTL_LINK_RST
;
314 mw32(MVS_PHY_CTL
, tmp
);
319 mw32(MVS_PCS
, 0); /* MVS_PCS */
321 mvs_64xx_phy_hacks(mvi
);
323 /* enable auto port detection */
324 mw32(MVS_GBL_PORT_TYPE
, MODE_AUTO_DET_EN
);
326 mw32(MVS_CMD_LIST_LO
, mvi
->slot_dma
);
327 mw32(MVS_CMD_LIST_HI
, (mvi
->slot_dma
>> 16) >> 16);
329 mw32(MVS_RX_FIS_LO
, mvi
->rx_fis_dma
);
330 mw32(MVS_RX_FIS_HI
, (mvi
->rx_fis_dma
>> 16) >> 16);
332 mw32(MVS_TX_CFG
, MVS_CHIP_SLOT_SZ
);
333 mw32(MVS_TX_LO
, mvi
->tx_dma
);
334 mw32(MVS_TX_HI
, (mvi
->tx_dma
>> 16) >> 16);
336 mw32(MVS_RX_CFG
, MVS_RX_RING_SZ
);
337 mw32(MVS_RX_LO
, mvi
->rx_dma
);
338 mw32(MVS_RX_HI
, (mvi
->rx_dma
>> 16) >> 16);
340 for (i
= 0; i
< mvi
->chip
->n_phy
; i
++) {
341 /* set phy local SAS address */
342 /* should set little endian SAS address to 64xx chip */
343 mvs_set_sas_addr(mvi
, i
, PHYR_ADDR_LO
, PHYR_ADDR_HI
,
344 cpu_to_be64(mvi
->phy
[i
].dev_sas_addr
));
346 mvs_64xx_enable_xmt(mvi
, i
);
348 mvs_64xx_phy_reset(mvi
, i
, 1);
350 mvs_64xx_detect_porttype(mvi
, i
);
352 if (mvi
->flags
& MVF_FLAG_SOC
) {
353 /* set select registers */
354 writel(0x0E008000, regs
+ 0x000);
355 writel(0x59000008, regs
+ 0x004);
356 writel(0x20, regs
+ 0x008);
357 writel(0x20, regs
+ 0x00c);
358 writel(0x20, regs
+ 0x010);
359 writel(0x20, regs
+ 0x014);
360 writel(0x20, regs
+ 0x018);
361 writel(0x20, regs
+ 0x01c);
363 for (i
= 0; i
< mvi
->chip
->n_phy
; i
++) {
364 /* clear phy int status */
365 tmp
= mvs_read_port_irq_stat(mvi
, i
);
366 tmp
&= ~PHYEV_SIG_FIS
;
367 mvs_write_port_irq_stat(mvi
, i
, tmp
);
369 /* set phy int mask */
370 tmp
= PHYEV_RDY_CH
| PHYEV_BROAD_CH
| PHYEV_UNASSOC_FIS
|
371 PHYEV_ID_DONE
| PHYEV_DCDR_ERR
| PHYEV_CRC_ERR
|
373 mvs_write_port_irq_mask(mvi
, i
, tmp
);
376 mvs_update_phyinfo(mvi
, i
, 1);
379 /* FIXME: update wide port bitmaps */
381 /* little endian for open address and command table, etc. */
383 * it seems that ( from the spec ) turning on big-endian won't
384 * do us any good on big-endian machines, need further confirmation
386 cctl
= mr32(MVS_CTL
);
387 cctl
|= CCTL_ENDIAN_CMD
;
388 cctl
|= CCTL_ENDIAN_DATA
;
389 cctl
&= ~CCTL_ENDIAN_OPEN
;
390 cctl
|= CCTL_ENDIAN_RSP
;
391 mw32_f(MVS_CTL
, cctl
);
393 /* reset CMD queue */
397 /* interrupt coalescing may cause missing HW interrput in some case,
398 * and the max count is 0x1ff, while our max slot is 0x200,
399 * it will make count 0.
402 mw32(MVS_INT_COAL
, tmp
);
405 mw32(MVS_INT_COAL_TMOUT
, tmp
);
407 /* ladies and gentlemen, start your engines */
409 mw32(MVS_TX_CFG
, MVS_CHIP_SLOT_SZ
| TX_EN
);
410 mw32(MVS_RX_CFG
, MVS_RX_RING_SZ
| RX_EN
);
411 /* enable CMD/CMPL_Q/RESP mode */
412 mw32(MVS_PCS
, PCS_SATA_RETRY
| PCS_FIS_RX_EN
|
413 PCS_CMD_EN
| PCS_CMD_STOP_ERR
);
415 /* enable completion queue interrupt */
416 tmp
= (CINT_PORT_MASK
| CINT_DONE
| CINT_MEM
| CINT_SRS
| CINT_CI_STOP
|
419 mw32(MVS_INT_MASK
, tmp
);
421 /* Enable SRS interrupt */
422 mw32(MVS_INT_MASK_SRS_0
, 0xFFFF);
427 static int mvs_64xx_ioremap(struct mvs_info
*mvi
)
429 if (!mvs_ioremap(mvi
, 4, 2))
434 static void mvs_64xx_iounmap(struct mvs_info
*mvi
)
436 mvs_iounmap(mvi
->regs
);
437 mvs_iounmap(mvi
->regs_ex
);
440 static void mvs_64xx_interrupt_enable(struct mvs_info
*mvi
)
442 void __iomem
*regs
= mvi
->regs
;
445 tmp
= mr32(MVS_GBL_CTL
);
446 mw32(MVS_GBL_CTL
, tmp
| INT_EN
);
449 static void mvs_64xx_interrupt_disable(struct mvs_info
*mvi
)
451 void __iomem
*regs
= mvi
->regs
;
454 tmp
= mr32(MVS_GBL_CTL
);
455 mw32(MVS_GBL_CTL
, tmp
& ~INT_EN
);
458 static u32
mvs_64xx_isr_status(struct mvs_info
*mvi
, int irq
)
460 void __iomem
*regs
= mvi
->regs
;
463 if (!(mvi
->flags
& MVF_FLAG_SOC
)) {
464 stat
= mr32(MVS_GBL_INT_STAT
);
466 if (stat
== 0 || stat
== 0xffffffff)
473 static irqreturn_t
mvs_64xx_isr(struct mvs_info
*mvi
, int irq
, u32 stat
)
475 void __iomem
*regs
= mvi
->regs
;
477 /* clear CMD_CMPLT ASAP */
478 mw32_f(MVS_INT_STAT
, CINT_DONE
);
479 #ifndef MVS_USE_TASKLET
480 spin_lock(&mvi
->lock
);
483 #ifndef MVS_USE_TASKLET
484 spin_unlock(&mvi
->lock
);
489 static void mvs_64xx_command_active(struct mvs_info
*mvi
, u32 slot_idx
)
492 mvs_cw32(mvi
, 0x40 + (slot_idx
>> 3), 1 << (slot_idx
% 32));
493 mvs_cw32(mvi
, 0x00 + (slot_idx
>> 3), 1 << (slot_idx
% 32));
495 tmp
= mvs_cr32(mvi
, 0x00 + (slot_idx
>> 3));
496 } while (tmp
& 1 << (slot_idx
% 32));
498 tmp
= mvs_cr32(mvi
, 0x40 + (slot_idx
>> 3));
499 } while (tmp
& 1 << (slot_idx
% 32));
502 static void mvs_64xx_issue_stop(struct mvs_info
*mvi
, enum mvs_port_type type
,
505 void __iomem
*regs
= mvi
->regs
;
508 if (type
== PORT_TYPE_SATA
) {
509 tmp
= mr32(MVS_INT_STAT_SRS_0
) | (1U << tfs
);
510 mw32(MVS_INT_STAT_SRS_0
, tmp
);
512 mw32(MVS_INT_STAT
, CINT_CI_STOP
);
513 tmp
= mr32(MVS_PCS
) | 0xFF00;
517 static void mvs_64xx_free_reg_set(struct mvs_info
*mvi
, u8
*tfs
)
519 void __iomem
*regs
= mvi
->regs
;
522 if (*tfs
== MVS_ID_NOT_MAPPED
)
525 offs
= 1U << ((*tfs
& 0x0f) + PCS_EN_SATA_REG_SHIFT
);
528 mw32(MVS_PCS
, tmp
& ~offs
);
531 mw32(MVS_CTL
, tmp
& ~offs
);
534 tmp
= mr32(MVS_INT_STAT_SRS_0
) & (1U << *tfs
);
536 mw32(MVS_INT_STAT_SRS_0
, tmp
);
538 *tfs
= MVS_ID_NOT_MAPPED
;
542 static u8
mvs_64xx_assign_reg_set(struct mvs_info
*mvi
, u8
*tfs
)
546 void __iomem
*regs
= mvi
->regs
;
548 if (*tfs
!= MVS_ID_NOT_MAPPED
)
553 for (i
= 0; i
< mvi
->chip
->srs_sz
; i
++) {
556 offs
= 1U << ((i
& 0x0f) + PCS_EN_SATA_REG_SHIFT
);
561 mw32(MVS_PCS
, tmp
| offs
);
563 mw32(MVS_CTL
, tmp
| offs
);
564 tmp
= mr32(MVS_INT_STAT_SRS_0
) & (1U << i
);
566 mw32(MVS_INT_STAT_SRS_0
, tmp
);
570 return MVS_ID_NOT_MAPPED
;
573 void mvs_64xx_make_prd(struct scatterlist
*scatter
, int nr
, void *prd
)
576 struct scatterlist
*sg
;
577 struct mvs_prd
*buf_prd
= prd
;
578 for_each_sg(scatter
, sg
, nr
, i
) {
579 buf_prd
->addr
= cpu_to_le64(sg_dma_address(sg
));
580 buf_prd
->len
= cpu_to_le32(sg_dma_len(sg
));
585 static int mvs_64xx_oob_done(struct mvs_info
*mvi
, int i
)
588 mvs_write_port_cfg_addr(mvi
, i
,
590 phy_st
= mvs_read_port_cfg_data(mvi
, i
);
591 if (phy_st
& PHY_OOB_DTCTD
)
596 static void mvs_64xx_fix_phy_info(struct mvs_info
*mvi
, int i
,
597 struct sas_identify_frame
*id
)
600 struct mvs_phy
*phy
= &mvi
->phy
[i
];
601 struct asd_sas_phy
*sas_phy
= &phy
->sas_phy
;
604 (phy
->phy_status
& PHY_NEG_SPP_PHYS_LINK_RATE_MASK
) >>
605 PHY_NEG_SPP_PHYS_LINK_RATE_MASK_OFFSET
;
607 phy
->minimum_linkrate
=
609 PHY_MIN_SPP_PHYS_LINK_RATE_MASK
) >> 8;
610 phy
->maximum_linkrate
=
612 PHY_MAX_SPP_PHYS_LINK_RATE_MASK
) >> 12;
614 mvs_write_port_cfg_addr(mvi
, i
, PHYR_IDENTIFY
);
615 phy
->dev_info
= mvs_read_port_cfg_data(mvi
, i
);
617 mvs_write_port_cfg_addr(mvi
, i
, PHYR_ATT_DEV_INFO
);
618 phy
->att_dev_info
= mvs_read_port_cfg_data(mvi
, i
);
620 mvs_write_port_cfg_addr(mvi
, i
, PHYR_ATT_ADDR_HI
);
621 phy
->att_dev_sas_addr
=
622 (u64
) mvs_read_port_cfg_data(mvi
, i
) << 32;
623 mvs_write_port_cfg_addr(mvi
, i
, PHYR_ATT_ADDR_LO
);
624 phy
->att_dev_sas_addr
|= mvs_read_port_cfg_data(mvi
, i
);
625 phy
->att_dev_sas_addr
= SAS_ADDR(&phy
->att_dev_sas_addr
);
628 static void mvs_64xx_phy_work_around(struct mvs_info
*mvi
, int i
)
631 struct mvs_phy
*phy
= &mvi
->phy
[i
];
632 /* workaround for HW phy decoding error on 1.5g disk drive */
633 mvs_write_port_vsr_addr(mvi
, i
, VSR_PHY_MODE6
);
634 tmp
= mvs_read_port_vsr_data(mvi
, i
);
635 if (((phy
->phy_status
& PHY_NEG_SPP_PHYS_LINK_RATE_MASK
) >>
636 PHY_NEG_SPP_PHYS_LINK_RATE_MASK_OFFSET
) ==
637 SAS_LINK_RATE_1_5_GBPS
)
638 tmp
&= ~PHY_MODE6_LATECLK
;
640 tmp
|= PHY_MODE6_LATECLK
;
641 mvs_write_port_vsr_data(mvi
, i
, tmp
);
644 void mvs_64xx_phy_set_link_rate(struct mvs_info
*mvi
, u32 phy_id
,
645 struct sas_phy_linkrates
*rates
)
647 u32 lrmin
= 0, lrmax
= 0;
650 tmp
= mvs_read_phy_ctl(mvi
, phy_id
);
651 lrmin
= (rates
->minimum_linkrate
<< 8);
652 lrmax
= (rates
->maximum_linkrate
<< 12);
662 mvs_write_phy_ctl(mvi
, phy_id
, tmp
);
663 mvs_64xx_phy_reset(mvi
, phy_id
, 1);
666 static void mvs_64xx_clear_active_cmds(struct mvs_info
*mvi
)
669 void __iomem
*regs
= mvi
->regs
;
671 mw32(MVS_PCS
, tmp
& 0xFFFF);
674 mw32(MVS_CTL
, tmp
& 0xFFFF);
679 u32
mvs_64xx_spi_read_data(struct mvs_info
*mvi
)
681 void __iomem
*regs
= mvi
->regs_ex
;
682 return ior32(SPI_DATA_REG_64XX
);
685 void mvs_64xx_spi_write_data(struct mvs_info
*mvi
, u32 data
)
687 void __iomem
*regs
= mvi
->regs_ex
;
688 iow32(SPI_DATA_REG_64XX
, data
);
692 int mvs_64xx_spi_buildcmd(struct mvs_info
*mvi
,
702 dwTmp
= ((u32
)cmd
<< 24) | ((u32
)length
<< 19);
706 if (addr
!= MV_MAX_U32
) {
708 dwTmp
|= (addr
& 0x0003FFFF);
716 int mvs_64xx_spi_issuecmd(struct mvs_info
*mvi
, u32 cmd
)
718 void __iomem
*regs
= mvi
->regs_ex
;
721 for (retry
= 0; retry
< 1; retry
++) {
722 iow32(SPI_CTRL_REG_64XX
, SPI_CTRL_VENDOR_ENABLE
);
723 iow32(SPI_CMD_REG_64XX
, cmd
);
724 iow32(SPI_CTRL_REG_64XX
,
725 SPI_CTRL_VENDOR_ENABLE
| SPI_CTRL_SPISTART
);
731 int mvs_64xx_spi_waitdataready(struct mvs_info
*mvi
, u32 timeout
)
733 void __iomem
*regs
= mvi
->regs_ex
;
736 for (i
= 0; i
< timeout
; i
++) {
737 dwTmp
= ior32(SPI_CTRL_REG_64XX
);
738 if (!(dwTmp
& SPI_CTRL_SPISTART
))
746 #ifndef DISABLE_HOTPLUG_DMA_FIX
747 void mvs_64xx_fix_dma(dma_addr_t buf_dma
, int buf_len
, int from
, void *prd
)
750 struct mvs_prd
*buf_prd
= prd
;
752 for (i
= 0; i
< MAX_SG_ENTRY
- from
; i
++) {
753 buf_prd
->addr
= cpu_to_le64(buf_dma
);
754 buf_prd
->len
= cpu_to_le32(buf_len
);
760 const struct mvs_dispatch mvs_64xx_dispatch
= {
768 mvs_64xx_interrupt_enable
,
769 mvs_64xx_interrupt_disable
,
772 mvs_read_port_cfg_data
,
773 mvs_write_port_cfg_data
,
774 mvs_write_port_cfg_addr
,
775 mvs_read_port_vsr_data
,
776 mvs_write_port_vsr_data
,
777 mvs_write_port_vsr_addr
,
778 mvs_read_port_irq_stat
,
779 mvs_write_port_irq_stat
,
780 mvs_read_port_irq_mask
,
781 mvs_write_port_irq_mask
,
783 mvs_64xx_command_active
,
784 mvs_64xx_clear_srs_irq
,
789 mvs_64xx_assign_reg_set
,
790 mvs_64xx_free_reg_set
,
794 mvs_64xx_detect_porttype
,
796 mvs_64xx_fix_phy_info
,
797 mvs_64xx_phy_work_around
,
798 mvs_64xx_phy_set_link_rate
,
799 mvs_hw_max_link_rate
,
800 mvs_64xx_phy_disable
,
804 mvs_64xx_clear_active_cmds
,
805 mvs_64xx_spi_read_data
,
806 mvs_64xx_spi_write_data
,
807 mvs_64xx_spi_buildcmd
,
808 mvs_64xx_spi_issuecmd
,
809 mvs_64xx_spi_waitdataready
,
810 #ifndef DISABLE_HOTPLUG_DMA_FIX