aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
authorJohn Garry <john.garry@huawei.com>2016-01-25 13:47:13 -0500
committerMartin K. Petersen <martin.petersen@oracle.com>2016-02-23 21:27:02 -0500
commit5473c06081392decb6f79305ba78c2a342162c24 (patch)
treef6a783f694ad8c17d0fdecda7b854f42a3ef8e6a /drivers/scsi
parent7911e66f1f12bdbbb0093baed84cbdb23b34d959 (diff)
hisi_sas: add v2 phy down handler
Signed-off-by: John Garry <john.garry@huawei.com> Reviewed-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/hisi_sas/hisi_sas_v2_hw.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
index a7b83bd8759e..35ce7b6230d2 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
@@ -628,6 +628,29 @@ static void sl_notify_v2_hw(struct hisi_hba *hisi_hba, int phy_no)
628 hisi_sas_phy_write32(hisi_hba, phy_no, SL_CONTROL, sl_control); 628 hisi_sas_phy_write32(hisi_hba, phy_no, SL_CONTROL, sl_control);
629} 629}
630 630
631static int get_wideport_bitmap_v2_hw(struct hisi_hba *hisi_hba, int port_id)
632{
633 int i, bitmap = 0;
634 u32 phy_port_num_ma = hisi_sas_read32(hisi_hba, PHY_PORT_NUM_MA);
635 u32 phy_state = hisi_sas_read32(hisi_hba, PHY_STATE);
636
637 for (i = 0; i < (hisi_hba->n_phy < 9 ? hisi_hba->n_phy : 8); i++)
638 if (phy_state & 1 << i)
639 if (((phy_port_num_ma >> (i * 4)) & 0xf) == port_id)
640 bitmap |= 1 << i;
641
642 if (hisi_hba->n_phy == 9) {
643 u32 port_state = hisi_sas_read32(hisi_hba, PORT_STATE);
644
645 if (phy_state & 1 << 8)
646 if (((port_state & PORT_STATE_PHY8_PORT_NUM_MSK) >>
647 PORT_STATE_PHY8_PORT_NUM_OFF) == port_id)
648 bitmap |= 1 << 9;
649 }
650
651 return bitmap;
652}
653
631static int phy_up_v2_hw(int phy_no, struct hisi_hba *hisi_hba) 654static int phy_up_v2_hw(int phy_no, struct hisi_hba *hisi_hba)
632{ 655{
633 int i, res = 0; 656 int i, res = 0;
@@ -705,6 +728,25 @@ end:
705 return res; 728 return res;
706} 729}
707 730
731static int phy_down_v2_hw(int phy_no, struct hisi_hba *hisi_hba)
732{
733 int res = 0;
734 u32 phy_cfg, phy_state;
735
736 hisi_sas_phy_write32(hisi_hba, phy_no, PHYCTRL_NOT_RDY_MSK, 1);
737
738 phy_cfg = hisi_sas_phy_read32(hisi_hba, phy_no, PHY_CFG);
739
740 phy_state = hisi_sas_read32(hisi_hba, PHY_STATE);
741
742 hisi_sas_phy_down(hisi_hba, phy_no, (phy_state & 1 << phy_no) ? 1 : 0);
743
744 hisi_sas_phy_write32(hisi_hba, phy_no, CHL_INT0, CHL_INT0_NOT_RDY_MSK);
745 hisi_sas_phy_write32(hisi_hba, phy_no, PHYCTRL_NOT_RDY_MSK, 0);
746
747 return res;
748}
749
708static irqreturn_t int_phy_updown_v2_hw(int irq_no, void *p) 750static irqreturn_t int_phy_updown_v2_hw(int irq_no, void *p)
709{ 751{
710 struct hisi_hba *hisi_hba = p; 752 struct hisi_hba *hisi_hba = p;
@@ -726,6 +768,12 @@ static irqreturn_t int_phy_updown_v2_hw(int irq_no, void *p)
726 goto end; 768 goto end;
727 } 769 }
728 770
771 if (irq_value & CHL_INT0_NOT_RDY_MSK)
772 /* phy down */
773 if (phy_down_v2_hw(phy_no, hisi_hba)) {
774 res = IRQ_NONE;
775 goto end;
776 }
729 } 777 }
730 irq_msk >>= 1; 778 irq_msk >>= 1;
731 phy_no++; 779 phy_no++;
@@ -796,6 +844,7 @@ static int hisi_sas_v2_init(struct hisi_hba *hisi_hba)
796static const struct hisi_sas_hw hisi_sas_v2_hw = { 844static const struct hisi_sas_hw hisi_sas_v2_hw = {
797 .hw_init = hisi_sas_v2_init, 845 .hw_init = hisi_sas_v2_init,
798 .sl_notify = sl_notify_v2_hw, 846 .sl_notify = sl_notify_v2_hw,
847 .get_wideport_bitmap = get_wideport_bitmap_v2_hw,
799 .max_command_entries = HISI_SAS_COMMAND_ENTRIES_V2_HW, 848 .max_command_entries = HISI_SAS_COMMAND_ENTRIES_V2_HW,
800 .complete_hdr_size = sizeof(struct hisi_sas_complete_v2_hdr), 849 .complete_hdr_size = sizeof(struct hisi_sas_complete_v2_hdr),
801}; 850};