]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
hisi_sas: Add control phy handler
authorJohn Garry <john.garry@huawei.com>
Tue, 17 Nov 2015 16:50:57 +0000 (00:50 +0800)
committerMartin K. Petersen <martin.petersen@oracle.com>
Thu, 26 Nov 2015 03:13:07 +0000 (22:13 -0500)
Add method for lldd_control_phy. Currently link rate control and spinup
hold is unsupported.

Signed-off-by: John Garry <john.garry@huawei.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/hisi_sas/hisi_sas.h
drivers/scsi/hisi_sas/hisi_sas_main.c
drivers/scsi/hisi_sas/hisi_sas_v1_hw.c

index 15adeca5ddc97fe213b01df4a9eb87307b43cc75..5b790c9438d65869c9f57fd4b93a72db3081c230 100644 (file)
@@ -137,6 +137,9 @@ struct hisi_sas_hw {
                        struct hisi_sas_slot *slot);
        int (*slot_complete)(struct hisi_hba *hisi_hba,
                             struct hisi_sas_slot *slot, int abort);
+       void (*phy_enable)(struct hisi_hba *hisi_hba, int phy_no);
+       void (*phy_disable)(struct hisi_hba *hisi_hba, int phy_no);
+       void (*phy_hard_reset)(struct hisi_hba *hisi_hba, int phy_no);
        void (*free_device)(struct hisi_hba *hisi_hba,
                            struct hisi_sas_device *dev);
        int (*get_wideport_bitmap)(struct hisi_hba *hisi_hba, int port_id);
index 4ee90eb55a0f6acb7c1db7d8ed05c87c7c1bae65..137762515aa93d314709044f6c1e1595f274770d 100644 (file)
@@ -552,6 +552,34 @@ static int hisi_sas_queue_command(struct sas_task *task, gfp_t gfp_flags)
        return hisi_sas_task_exec(task, gfp_flags, 0, NULL);
 }
 
+static int hisi_sas_control_phy(struct asd_sas_phy *sas_phy, enum phy_func func,
+                               void *funcdata)
+{
+       struct sas_ha_struct *sas_ha = sas_phy->ha;
+       struct hisi_hba *hisi_hba = sas_ha->lldd_ha;
+       int phy_no = sas_phy->id;
+
+       switch (func) {
+       case PHY_FUNC_HARD_RESET:
+               hisi_hba->hw->phy_hard_reset(hisi_hba, phy_no);
+               break;
+
+       case PHY_FUNC_LINK_RESET:
+               hisi_hba->hw->phy_enable(hisi_hba, phy_no);
+               hisi_hba->hw->phy_hard_reset(hisi_hba, phy_no);
+               break;
+
+       case PHY_FUNC_DISABLE:
+               hisi_hba->hw->phy_disable(hisi_hba, phy_no);
+               break;
+
+       case PHY_FUNC_SET_LINK_RATE:
+       case PHY_FUNC_RELEASE_SPINUP_HOLD:
+       default:
+               return -EOPNOTSUPP;
+       }
+       return 0;
+}
 
 static void hisi_sas_task_done(struct sas_task *task)
 {
@@ -932,6 +960,7 @@ static struct sas_domain_function_template hisi_sas_transport_ops = {
        .lldd_dev_found         = hisi_sas_dev_found,
        .lldd_dev_gone          = hisi_sas_dev_gone,
        .lldd_execute_task      = hisi_sas_queue_command,
+       .lldd_control_phy       = hisi_sas_control_phy,
        .lldd_abort_task        = hisi_sas_abort_task,
        .lldd_abort_task_set    = hisi_sas_abort_task_set,
        .lldd_clear_aca         = hisi_sas_clear_aca,
index 64b17a183090f3cc57aba6df301e8ed2f29ee143..a95259cdc2bf74222d069d8c7f65dee377645a05 100644 (file)
@@ -764,6 +764,14 @@ static void enable_phy_v1_hw(struct hisi_hba *hisi_hba, int phy_no)
        hisi_sas_phy_write32(hisi_hba, phy_no, PHY_CFG, cfg);
 }
 
+static void disable_phy_v1_hw(struct hisi_hba *hisi_hba, int phy_no)
+{
+       u32 cfg = hisi_sas_phy_read32(hisi_hba, phy_no, PHY_CFG);
+
+       cfg &= ~PHY_CFG_ENA_MSK;
+       hisi_sas_phy_write32(hisi_hba, phy_no, PHY_CFG, cfg);
+}
+
 static void start_phy_v1_hw(struct hisi_hba *hisi_hba, int phy_no)
 {
        config_id_frame_v1_hw(hisi_hba, phy_no);
@@ -772,6 +780,18 @@ static void start_phy_v1_hw(struct hisi_hba *hisi_hba, int phy_no)
        enable_phy_v1_hw(hisi_hba, phy_no);
 }
 
+static void stop_phy_v1_hw(struct hisi_hba *hisi_hba, int phy_no)
+{
+       disable_phy_v1_hw(hisi_hba, phy_no);
+}
+
+static void phy_hard_reset_v1_hw(struct hisi_hba *hisi_hba, int phy_no)
+{
+       stop_phy_v1_hw(hisi_hba, phy_no);
+       msleep(100);
+       start_phy_v1_hw(hisi_hba, phy_no);
+}
+
 static void start_phys_v1_hw(unsigned long data)
 {
        struct hisi_hba *hisi_hba = (struct hisi_hba *)data;
@@ -1687,6 +1707,9 @@ static const struct hisi_sas_hw hisi_sas_v1_hw = {
        .get_free_slot = get_free_slot_v1_hw,
        .start_delivery = start_delivery_v1_hw,
        .slot_complete = slot_complete_v1_hw,
+       .phy_enable = enable_phy_v1_hw,
+       .phy_disable = disable_phy_v1_hw,
+       .phy_hard_reset = phy_hard_reset_v1_hw,
        .get_wideport_bitmap = get_wideport_bitmap_v1_hw,
        .complete_hdr_size = sizeof(struct hisi_sas_complete_v1_hdr),
 };