30 static void mvs_94xx_detect_porttype(
struct mvs_info *mvi,
int i)
37 reg = mvs_read_port_vsr_data(mvi, i);
38 phy_status = ((reg & 0x3f0000) >> 16) & 0xff;
54 u32 tmp, setting_0 = 0, setting_1 = 0;
73 for (i = 0; i < 3; i++) {
96 mvs_write_port_vsr_addr(mvi, phy_id, setting_0);
97 tmp = mvs_read_port_vsr_data(mvi, phy_id);
98 tmp &= ~(0xFBE << 16);
102 mvs_write_port_vsr_data(mvi, phy_id, tmp);
105 mvs_write_port_vsr_addr(mvi, phy_id, setting_1);
106 tmp = mvs_read_port_vsr_data(mvi, phy_id);
109 mvs_write_port_vsr_data(mvi, phy_id, tmp);
131 tmp = mvs_read_port_vsr_data(mvi, phy_id);
139 mvs_write_port_vsr_data(mvi, phy_id, tmp);
146 tmp = mvs_read_port_vsr_data(mvi, phy_id);
151 mvs_write_port_vsr_data(mvi, phy_id, tmp);
159 tmp = mvs_read_port_vsr_data(mvi, phy_id);
163 tmp |= ((0x3F << 6) | (0x0 << 0));
164 mvs_write_port_vsr_data(mvi, phy_id, tmp);
171 tmp = mvs_read_port_vsr_data(mvi, phy_id);
176 mvs_write_port_vsr_data(mvi, phy_id, tmp);
184 phy_cfg_tmp.
v = mvs_read_port_vsr_data(mvi, phy_id);
186 phy_cfg.
u.disable_phy = phy_cfg_tmp.
u.disable_phy;
187 phy_cfg.
u.sas_support = 1;
188 phy_cfg.
u.sata_support = 1;
189 phy_cfg.
u.sata_host_mode = 1;
194 phy_cfg.
u.speed_support = 1;
195 phy_cfg.
u.snw_3_support = 0;
196 phy_cfg.
u.tx_lnk_parity = 1;
197 phy_cfg.
u.tx_spt_phs_lnk_rate = 0x30;
202 phy_cfg.
u.speed_support = 3;
203 phy_cfg.
u.tx_spt_phs_lnk_rate = 0x3c;
204 phy_cfg.
u.tx_lgcl_lnk_rate = 0x08;
209 phy_cfg.
u.speed_support = 7;
210 phy_cfg.
u.snw_3_support = 1;
211 phy_cfg.
u.tx_lnk_parity = 1;
212 phy_cfg.
u.tx_spt_phs_lnk_rate = 0x3f;
213 phy_cfg.
u.tx_lgcl_lnk_rate = 0x09;
216 mvs_write_port_vsr_data(mvi, phy_id, phy_cfg.
v);
224 if (temp == 0xFFFFFFFFL) {
232 switch (mvi->
pdev->revision) {
271 static void mvs_94xx_phy_reset(
struct mvs_info *mvi,
u32 phy_id,
int hard)
277 tmp = mvs_read_port_cfg_data(mvi, phy_id);
278 mvs_write_port_cfg_data(mvi, phy_id, tmp|0x20000000);
279 mvs_write_port_cfg_data(mvi, phy_id, tmp|0x100000);
282 tmp = mvs_read_port_irq_stat(mvi, phy_id);
284 mvs_write_port_irq_stat(mvi, phy_id, tmp);
286 tmp = mvs_read_phy_ctl(mvi, phy_id);
288 mvs_write_phy_ctl(mvi, phy_id, tmp);
290 tmp = mvs_read_phy_ctl(mvi, phy_id);
297 tmp = mvs_read_phy_ctl(mvi, phy_id);
299 mvs_write_phy_ctl(mvi, phy_id, tmp);
303 static void mvs_94xx_phy_disable(
struct mvs_info *mvi,
u32 phy_id)
307 tmp = mvs_read_port_vsr_data(mvi, phy_id);
308 mvs_write_port_vsr_data(mvi, phy_id, tmp | 0x00800000);
311 static void mvs_94xx_phy_enable(
struct mvs_info *mvi,
u32 phy_id)
316 revision = mvi->
pdev->revision;
319 mvs_write_port_vsr_data(mvi, phy_id, 0x8300ffc1);
323 mvs_write_port_vsr_data(mvi, phy_id, 0x08001006);
325 mvs_write_port_vsr_data(mvi, phy_id, 0x0000705f);
329 tmp = mvs_read_port_vsr_data(mvi, phy_id);
331 mvs_write_port_vsr_data(mvi, phy_id, tmp & 0xfd7fffff);
341 revision = mvi->
pdev->revision;
342 mvs_show_pcie_usage(mvi);
432 for (i = 0; i < mvi->
chip->n_phy; i++) {
433 mvs_94xx_phy_disable(mvi, i);
438 mvs_94xx_enable_xmt(mvi, i);
439 mvs_94xx_config_reg_from_hba(mvi, i);
440 mvs_94xx_phy_enable(mvi, i);
444 mvs_94xx_detect_porttype(mvi, i);
449 writel(0x0E008000, regs + 0x000);
450 writel(0x59000008, regs + 0x004);
451 writel(0x20, regs + 0x008);
452 writel(0x20, regs + 0x00c);
453 writel(0x20, regs + 0x010);
454 writel(0x20, regs + 0x014);
455 writel(0x20, regs + 0x018);
456 writel(0x20, regs + 0x01c);
458 for (i = 0; i < mvi->
chip->n_phy; i++) {
460 tmp = mvs_read_port_irq_stat(mvi, i);
462 mvs_write_port_irq_stat(mvi, i, tmp);
467 mvs_write_port_irq_mask(mvi, i, tmp);
540 static int mvs_94xx_ioremap(
struct mvs_info *mvi)
544 mvi->
regs += 0x20000;
552 static void mvs_94xx_iounmap(
struct mvs_info *mvi)
555 mvi->
regs -= 0x20000;
562 static void mvs_94xx_interrupt_enable(
struct mvs_info *mvi)
577 static void mvs_94xx_interrupt_disable(
struct mvs_info *mvi)
593 static u32 mvs_94xx_isr_status(
struct mvs_info *mvi,
int irq)
614 spin_lock(&mvi->
lock);
616 spin_unlock(&mvi->
lock);
621 static void mvs_94xx_command_active(
struct mvs_info *mvi,
u32 slot_idx)
625 if (tmp && 1 << (slot_idx % 32)) {
626 mv_printk(
"command active %08X, slot [%x].\n", tmp, slot_idx);
628 1 << (slot_idx % 32));
632 }
while (tmp & 1 << (slot_idx % 32));
658 if (tmp & (1 << (reg_set % 32))) {
659 mv_dprintk(
"register set 0x%x was stopped.\n", reg_set);
681 static void mvs_94xx_non_spec_ncq_error(
struct mvs_info *mvi)
691 mv_dprintk(
"non specific ncq error err_0:%x,err_1:%x.\n",
693 for (i = 0; i < 32; i++) {
694 if (err_0 &
bit(i)) {
699 if (err_1 &
bit(i)) {
710 static void mvs_94xx_free_reg_set(
struct mvs_info *mvi,
u8 *tfs)
729 static u8 mvs_94xx_assign_reg_set(
struct mvs_info *mvi,
u8 *tfs)
767 static int mvs_94xx_oob_done(
struct mvs_info *mvi,
int i)
770 phy_st = mvs_read_phy_ctl(mvi, i);
776 static void mvs_94xx_get_dev_identify_frame(
struct mvs_info *mvi,
int port_id,
777 struct sas_identify_frame *
id)
782 for (i = 0; i < 7; i++) {
783 mvs_write_port_cfg_addr(mvi, port_id,
785 id_frame[
i] =
cpu_to_le32(mvs_read_port_cfg_data(mvi, port_id));
790 static void mvs_94xx_get_att_identify_frame(
struct mvs_info *mvi,
int port_id,
791 struct sas_identify_frame *
id)
796 for (i = 0; i < 7; i++) {
797 mvs_write_port_cfg_addr(mvi, port_id,
799 id_frame[
i] =
cpu_to_le32(mvs_read_port_cfg_data(mvi, port_id));
801 port_id + mvi->
id * mvi->
chip->n_phy, i, id_frame[i]);
806 static u32 mvs_94xx_make_dev_info(
struct sas_identify_frame *
id)
808 u32 att_dev_info = 0;
810 att_dev_info |=
id->dev_type;
824 att_dev_info |= (
u32)id->phy_id<<24;
828 static u32 mvs_94xx_make_att_info(
struct sas_identify_frame *
id)
830 return mvs_94xx_make_dev_info(
id);
833 static void mvs_94xx_fix_phy_info(
struct mvs_info *mvi,
int i,
834 struct sas_identify_frame *
id)
846 mvs_94xx_get_dev_identify_frame(mvi, i,
id);
847 phy->
dev_info = mvs_94xx_make_dev_info(
id);
850 mvs_94xx_get_att_identify_frame(mvi, i,
id);
859 mvs_write_port_cfg_data(mvi, i, 0x04);
869 tmp = mvs_read_phy_ctl(mvi, phy_id);
876 mvs_write_phy_ctl(mvi, phy_id, tmp);
880 static void mvs_94xx_clear_active_cmds(
struct mvs_info *mvi)
917 dwTmp = ((
u32)cmd << 8) | ((
u32)length << 4);
944 for (i = 0; i < timeout; i++) {
955 int buf_len,
int from,
void *prd)
965 #define PRD_CHAINED_ENTRY 0x01
968 buf_dma = (phy_mask <= 0x08) ?
974 if (i == MAX_SG_ENTRY - 1) {
980 im_len.
len = buf_len;
1003 tmp = 0x10000 |
time;
1016 mvs_94xx_isr_status,
1017 mvs_94xx_interrupt_enable,
1018 mvs_94xx_interrupt_disable,
1021 mvs_read_port_cfg_data,
1022 mvs_write_port_cfg_data,
1023 mvs_write_port_cfg_addr,
1024 mvs_read_port_vsr_data,
1025 mvs_write_port_vsr_data,
1026 mvs_write_port_vsr_addr,
1027 mvs_read_port_irq_stat,
1028 mvs_write_port_irq_stat,
1029 mvs_read_port_irq_mask,
1030 mvs_write_port_irq_mask,
1031 mvs_94xx_command_active,
1033 mvs_94xx_issue_stop,
1037 mvs_94xx_assign_reg_set,
1038 mvs_94xx_free_reg_set,
1042 mvs_94xx_detect_porttype,
1044 mvs_94xx_fix_phy_info,
1047 mvs_hw_max_link_rate,
1048 mvs_94xx_phy_disable,
1049 mvs_94xx_phy_enable,
1052 mvs_94xx_clear_active_cmds,
1059 mvs_94xx_tune_interrupt,
1060 mvs_94xx_non_spec_ncq_error,