From: John Garry <john.garry@huawei.com>
To: <jejb@linux.vnet.ibm.com>, <martin.petersen@oracle.com>,
<robh+dt@kernel.org>, <mark.rutland@arm.com>
Cc: <linux-scsi@vger.kernel.org>, <devicetree@vger.kernel.org>,
<linuxarm@huawei.com>, <linux-kernel@vger.kernel.org>,
Xiaofei Tan <tanxiaofei@huawei.com>,
John Garry <john.garry@huawei.com>
Subject: [PATCH 2/8] scsi: hisi_sas: support the property of signal attenuation for v2 hw
Date: Tue, 20 Feb 2018 03:13:25 +0800 [thread overview]
Message-ID: <1519067611-206638-3-git-send-email-john.garry@huawei.com> (raw)
In-Reply-To: <1519067611-206638-1-git-send-email-john.garry@huawei.com>
From: Xiaofei Tan <tanxiaofei@huawei.com>
The register SAS_PHY_CTRL is configured according to signal quality.
The signal quality is calculated by signal attenuation of hardware
physical link. It may be different for different PCB layout.
So, in order to give better support to new board, this patch add
support to reading the devicetree property, signal-attenuation.
Of course, we still keep an default value in driver to adapt old
board.
Signed-off-by: Xiaofei Tan <tanxiaofei@huawei.com>
Signed-off-by: John Garry <john.garry@huawei.com>
---
drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 39 +++++++++++++++++++++++++++++++++-
1 file changed, 38 insertions(+), 1 deletion(-)
diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
index 4ccb61e..ab6db50 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
@@ -406,6 +406,17 @@ struct hisi_sas_err_record_v2 {
__le32 dma_rx_err_type;
};
+struct signal_attenuation_s {
+ u32 de_emphasis;
+ u32 preshoot;
+ u32 boost;
+};
+
+struct sig_atten_lu_s {
+ const struct signal_attenuation_s *att;
+ u32 sas_phy_ctrl;
+};
+
static const struct hisi_sas_hw_error one_bit_ecc_errors[] = {
{
.irq_msk = BIT(SAS_ECC_INTR_DQE_ECC_1B_OFF),
@@ -1130,9 +1141,16 @@ static void phys_try_accept_stp_links_v2_hw(struct hisi_hba *hisi_hba)
}
}
+static const struct signal_attenuation_s x6000 = {9200, 0, 10476};
+static const struct sig_atten_lu_s sig_atten_lu[] = {
+ { &x6000, 0x3016a68 },
+};
+
static void init_reg_v2_hw(struct hisi_hba *hisi_hba)
{
struct device *dev = hisi_hba->dev;
+ u32 sas_phy_ctrl = 0x30b9908;
+ u32 signal[3];
int i;
/* Global registers init */
@@ -1176,9 +1194,28 @@ static void init_reg_v2_hw(struct hisi_hba *hisi_hba)
hisi_sas_write32(hisi_hba, AXI_AHB_CLK_CFG, 1);
hisi_sas_write32(hisi_hba, HYPER_STREAM_ID_EN_CFG, 1);
+ /* Get sas_phy_ctrl value to deal with TX FFE issue. */
+ if (!device_property_read_u32_array(dev, "signal-attenuation",
+ signal, ARRAY_SIZE(signal))) {
+ for (i = 0; i < ARRAY_SIZE(sig_atten_lu); i++) {
+ const struct sig_atten_lu_s *lookup = &sig_atten_lu[i];
+ const struct signal_attenuation_s *att = lookup->att;
+
+ if ((signal[0] == att->de_emphasis) &&
+ (signal[1] == att->preshoot) &&
+ (signal[2] == att->boost)) {
+ sas_phy_ctrl = lookup->sas_phy_ctrl;
+ break;
+ }
+ }
+
+ if (i == ARRAY_SIZE(sig_atten_lu))
+ dev_warn(dev, "unknown signal attenuation values, using default PHY ctrl config\n");
+ }
+
for (i = 0; i < hisi_hba->n_phy; i++) {
hisi_sas_phy_write32(hisi_hba, i, PROG_PHY_LINK_RATE, 0x855);
- hisi_sas_phy_write32(hisi_hba, i, SAS_PHY_CTRL, 0x30b9908);
+ hisi_sas_phy_write32(hisi_hba, i, SAS_PHY_CTRL, sas_phy_ctrl);
hisi_sas_phy_write32(hisi_hba, i, SL_TOUT_CFG, 0x7d7d7d7d);
hisi_sas_phy_write32(hisi_hba, i, SL_CONTROL, 0x0);
hisi_sas_phy_write32(hisi_hba, i, TXID_AUTO, 0x2);
--
1.9.1
next prev parent reply other threads:[~2018-02-19 18:23 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-19 19:13 [PATCH 0/8] hisi_sas: support x6000 board and some misc changes John Garry
2018-02-19 19:13 ` [PATCH 1/8] dt-bindings: scsi: hisi_sas: add an property of signal attenuation John Garry
2018-02-23 1:49 ` Martin K. Petersen
2018-03-01 21:40 ` Rob Herring
2018-03-02 9:36 ` John Garry
2018-02-19 19:13 ` John Garry [this message]
2018-02-19 19:13 ` [PATCH 3/8] scsi: hisi_sas: fix the issue of link rate inconsistency John Garry
2018-02-19 19:13 ` [PATCH 4/8] scsi: hisi_sas: fix the issue of setting linkrate register John Garry
2018-02-19 19:13 ` [PATCH 5/8] scsi: hisi_sas: increase timer expire of internal abort task John Garry
2018-02-19 19:13 ` [PATCH 6/8] scsi: hisi_sas: remove unused variable hisi_sas_devices.running_req John Garry
2018-02-19 19:13 ` [PATCH 7/8] scsi: hisi_sas: fix return value of hisi_sas_task_prep() John Garry
2018-02-19 19:13 ` [PATCH 8/8] scsi: hisi_sas: Code cleanup and minor bug fixes John Garry
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1519067611-206638-3-git-send-email-john.garry@huawei.com \
--to=john.garry@huawei.com \
--cc=devicetree@vger.kernel.org \
--cc=jejb@linux.vnet.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=linuxarm@huawei.com \
--cc=mark.rutland@arm.com \
--cc=martin.petersen@oracle.com \
--cc=robh+dt@kernel.org \
--cc=tanxiaofei@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®