From patchwork Thu Aug 10 16:09:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 109823 Delivered-To: patch@linaro.org Received: by 10.182.109.195 with SMTP id hu3csp2563658obb; Thu, 10 Aug 2017 08:46:04 -0700 (PDT) X-Received: by 10.99.51.200 with SMTP id z191mr11991561pgz.329.1502379964281; Thu, 10 Aug 2017 08:46:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502379964; cv=none; d=google.com; s=arc-20160816; b=AsICOvGcL/QhBBq8jfuShnARaCvIgROgzy+DBx0eTD1QpZsUfHh4cDF2+7XhAzg/fU gDq6lZOrbJbXf/y7yJzj9T8LJtpoXEy5U7Jll8ogkFNZcGLS6uAmKMEt+qmPIakW6ARq LLMwz4qvhO6gbG3MjnYgB6l3yIi5IWYqlEI5Y4Eo94A1mhf9csWgapblR8qA7nsCgz+W QMUvGgtM1HApH3mR+9jlSHyWc5puZtJ8Wo9dhB88jKgWN+FZHbCSK38LgeT8pUGatm6h N2gZ5takbj7fspng2wLQ54AaGUhAG1ynnn21ekN2v0pUJE9ZX0yYIT+vNeZo9Qm5DIoT G5xQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=S37a2k9sWqWiFlRowhEjUIgf7h/N3+tOMlOShXWEeck=; b=GiTbhner0g6kPjZEfiVr4uZ70P+GIMwTIhfDWIrtf3o0rOr+gAO1XI4YBr8zfkBcQd rYHMe+ln4LkoP0c3eeAgr3eiw4OEqrK2XAI5ZH+aKMh2jED3piNN1FG0G1mc/+oMagqM 3f+kNP1t0EV623VX0HoigU2U6JWjWb15XYVNq/zKUgrHkDFPJfhw3k35r5iVjQgK/J1q m6/I+XJlqxft7PU7bjMeB/9NnzU/07WWjhDnJ003RhqafebIDLswt6BNrxICrObnysfN rH1x0bNncNuizhH8gyWwifRBLHuIDbMn2gOhO5WYROd9Li/Ffuu/JK3Aa0UL98LhY1g1 VPkg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x10si4619180plm.860.2017.08.10.08.46.03; Thu, 10 Aug 2017 08:46:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753262AbdHJPqB (ORCPT + 25 others); Thu, 10 Aug 2017 11:46:01 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:3496 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752357AbdHJPmz (ORCPT ); Thu, 10 Aug 2017 11:42:55 -0400 Received: from 172.30.72.58 (EHLO DGGEMS402-HUB.china.huawei.com) ([172.30.72.58]) by dggrg04-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id DEV99177; Thu, 10 Aug 2017 23:42:51 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.301.0; Thu, 10 Aug 2017 23:42:40 +0800 From: John Garry To: , CC: , , , , Xiang Chen , John Garry Subject: [PATCH 16/19] scsi: hisi_sas: add phy_set_linkrate_v3_hw() Date: Fri, 11 Aug 2017 00:09:41 +0800 Message-ID: <1502381384-219889-17-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1502381384-219889-1-git-send-email-john.garry@huawei.com> References: <1502381384-219889-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.212.75] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090202.598C7EFB.0091, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 7635ac857e54d9ceabba143e19d40deb Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xiang Chen Add function to set linkrate for v3 hw. Signed-off-by: Xiang Chen Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 39 ++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) -- 1.9.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c index 111e45c..8e4bfad 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -1680,6 +1680,44 @@ static int hisi_sas_v3_init(struct hisi_hba *hisi_hba) return 0; } +static void phy_set_linkrate_v3_hw(struct hisi_hba *hisi_hba, int phy_no, + struct sas_phy_linkrates *r) +{ + u32 prog_phy_link_rate = + hisi_sas_phy_read32(hisi_hba, phy_no, PROG_PHY_LINK_RATE); + struct hisi_sas_phy *phy = &hisi_hba->phy[phy_no]; + struct asd_sas_phy *sas_phy = &phy->sas_phy; + int i; + enum sas_linkrate min, max; + u32 rate_mask = 0; + + if (r->maximum_linkrate == SAS_LINK_RATE_UNKNOWN) { + max = sas_phy->phy->maximum_linkrate; + min = r->minimum_linkrate; + } else if (r->minimum_linkrate == SAS_LINK_RATE_UNKNOWN) { + max = r->maximum_linkrate; + min = sas_phy->phy->minimum_linkrate; + } else + return; + + sas_phy->phy->maximum_linkrate = max; + sas_phy->phy->minimum_linkrate = min; + + min -= SAS_LINK_RATE_1_5_GBPS; + max -= SAS_LINK_RATE_1_5_GBPS; + + for (i = 0; i <= max; i++) + rate_mask |= 1 << (i * 2); + + prog_phy_link_rate &= ~0xff; + prog_phy_link_rate |= rate_mask; + + hisi_sas_phy_write32(hisi_hba, phy_no, PROG_PHY_LINK_RATE, + prog_phy_link_rate); + + phy_hard_reset_v3_hw(hisi_hba, phy_no); +} + static void interrupt_disable_v3_hw(struct hisi_hba *hisi_hba) { struct pci_dev *pdev = hisi_hba->pci_dev; @@ -1760,6 +1798,7 @@ static int soft_reset_v3_hw(struct hisi_hba *hisi_hba) .phy_disable = disable_phy_v3_hw, .phy_hard_reset = phy_hard_reset_v3_hw, .phy_get_max_linkrate = phy_get_max_linkrate_v3_hw, + .phy_set_linkrate = phy_set_linkrate_v3_hw, .dereg_device = dereg_device_v3_hw, .soft_reset = soft_reset_v3_hw, .get_phys_state = get_phys_state_v3_hw,