Skip to content

Commit 3bc45af

Browse files
John Garrymartinkpetersen
authored andcommitted
scsi: hisi_sas: Add v2 hw support for different refclk
The hip06 D03 and hip07 D05 boards have different reference clock frequencies for the SAS controller. Register PHY_CTRL needs to be programmed differently according to this frequency, so add support for this. The default register setting in PHY_CTRL is for 50MHz, so only update this register when the refclk frequency is 66MHz. For ACPI we expect the _RST handler to set the correct value for PHY_CTRL (we're forced to take different approach for DT and ACPI as ACPI does not support fixed-clock device). Signed-off-by: John Garry <john.garry@huawei.com> Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 039ae10 commit 3bc45af

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

drivers/scsi/hisi_sas/hisi_sas.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#define _HISI_SAS_H_
1414

1515
#include <linux/acpi.h>
16+
#include <linux/clk.h>
1617
#include <linux/dmapool.h>
1718
#include <linux/mfd/syscon.h>
1819
#include <linux/module.h>
@@ -183,6 +184,7 @@ struct hisi_hba {
183184
u32 ctrl_reset_reg;
184185
u32 ctrl_reset_sts_reg;
185186
u32 ctrl_clock_ena_reg;
187+
u32 refclk_frequency_mhz;
186188
u8 sas_addr[SAS_ADDR_SIZE];
187189

188190
int n_phy;

drivers/scsi/hisi_sas/hisi_sas_main.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1396,6 +1396,7 @@ static struct Scsi_Host *hisi_sas_shost_alloc(struct platform_device *pdev,
13961396
struct hisi_hba *hisi_hba;
13971397
struct device *dev = &pdev->dev;
13981398
struct device_node *np = pdev->dev.of_node;
1399+
struct clk *refclk;
13991400

14001401
shost = scsi_host_alloc(&hisi_sas_sht, sizeof(*hisi_hba));
14011402
if (!shost)
@@ -1432,6 +1433,12 @@ static struct Scsi_Host *hisi_sas_shost_alloc(struct platform_device *pdev,
14321433
goto err_out;
14331434
}
14341435

1436+
refclk = devm_clk_get(&pdev->dev, NULL);
1437+
if (IS_ERR(refclk))
1438+
dev_info(dev, "no ref clk property\n");
1439+
else
1440+
hisi_hba->refclk_frequency_mhz = clk_get_rate(refclk) / 1000000;
1441+
14351442
if (device_property_read_u32(dev, "phy-count", &hisi_hba->n_phy))
14361443
goto err_out;
14371444

drivers/scsi/hisi_sas/hisi_sas_v2_hw.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,9 @@ static void init_reg_v2_hw(struct hisi_hba *hisi_hba)
836836
hisi_sas_phy_write32(hisi_hba, i, SL_RX_BCAST_CHK_MSK, 0x0);
837837
hisi_sas_phy_write32(hisi_hba, i, CHL_INT_COAL_EN, 0x0);
838838
hisi_sas_phy_write32(hisi_hba, i, PHYCTRL_OOB_RESTART_MSK, 0x0);
839-
hisi_sas_phy_write32(hisi_hba, i, PHY_CTRL, 0x199B694);
839+
if (hisi_hba->refclk_frequency_mhz == 66)
840+
hisi_sas_phy_write32(hisi_hba, i, PHY_CTRL, 0x199B694);
841+
/* else, do nothing -> leave it how you found it */
840842
}
841843

842844
for (i = 0; i < hisi_hba->queue_count; i++) {

0 commit comments

Comments
 (0)