Commit 50408712 authored by John Garry's avatar John Garry Committed by Martin K. Petersen

hisi_sas: add v2 hw ACPI support

Add support in v2 hw driver for ACPI.

A check on whether an ACPI handle is available for the device is used to
decide on whether to use ACPI reset handler or syscon for hw reset.
Signed-off-by: default avatarJohn Garry <john.garry@huawei.com>
Signed-off-by: default avatarWei Xu <xuwei5@hisilicon.com>
Reviewed-by: default avatarZhangfei Gao <zhangfei.gao@linaro.org>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 84b342c0
...@@ -721,30 +721,41 @@ static int reset_hw_v2_hw(struct hisi_hba *hisi_hba) ...@@ -721,30 +721,41 @@ static int reset_hw_v2_hw(struct hisi_hba *hisi_hba)
return -EIO; return -EIO;
} }
/* reset and disable clock*/ if (ACPI_HANDLE(dev)) {
regmap_write(hisi_hba->ctrl, hisi_hba->ctrl_reset_reg, acpi_status s;
reset_val);
regmap_write(hisi_hba->ctrl, hisi_hba->ctrl_clock_ena_reg + 4,
reset_val);
msleep(1);
regmap_read(hisi_hba->ctrl, hisi_hba->ctrl_reset_sts_reg, &val);
if (reset_val != (val & reset_val)) {
dev_err(dev, "SAS reset fail.\n");
return -EIO;
}
/* De-reset and enable clock*/ s = acpi_evaluate_object(ACPI_HANDLE(dev), "_RST", NULL, NULL);
regmap_write(hisi_hba->ctrl, hisi_hba->ctrl_reset_reg + 4, if (ACPI_FAILURE(s)) {
reset_val); dev_err(dev, "Reset failed\n");
regmap_write(hisi_hba->ctrl, hisi_hba->ctrl_clock_ena_reg, return -EIO;
reset_val); }
msleep(1); } else if (hisi_hba->ctrl) {
regmap_read(hisi_hba->ctrl, hisi_hba->ctrl_reset_sts_reg, /* reset and disable clock*/
&val); regmap_write(hisi_hba->ctrl, hisi_hba->ctrl_reset_reg,
if (val & reset_val) { reset_val);
dev_err(dev, "SAS de-reset fail.\n"); regmap_write(hisi_hba->ctrl, hisi_hba->ctrl_clock_ena_reg + 4,
return -EIO; reset_val);
} msleep(1);
regmap_read(hisi_hba->ctrl, hisi_hba->ctrl_reset_sts_reg, &val);
if (reset_val != (val & reset_val)) {
dev_err(dev, "SAS reset fail.\n");
return -EIO;
}
/* De-reset and enable clock*/
regmap_write(hisi_hba->ctrl, hisi_hba->ctrl_reset_reg + 4,
reset_val);
regmap_write(hisi_hba->ctrl, hisi_hba->ctrl_clock_ena_reg,
reset_val);
msleep(1);
regmap_read(hisi_hba->ctrl, hisi_hba->ctrl_reset_sts_reg,
&val);
if (val & reset_val) {
dev_err(dev, "SAS de-reset fail.\n");
return -EIO;
}
} else
dev_warn(dev, "no reset method\n");
return 0; return 0;
} }
...@@ -752,13 +763,12 @@ static int reset_hw_v2_hw(struct hisi_hba *hisi_hba) ...@@ -752,13 +763,12 @@ static int reset_hw_v2_hw(struct hisi_hba *hisi_hba)
static void init_reg_v2_hw(struct hisi_hba *hisi_hba) static void init_reg_v2_hw(struct hisi_hba *hisi_hba)
{ {
struct device *dev = &hisi_hba->pdev->dev; struct device *dev = &hisi_hba->pdev->dev;
struct device_node *np = dev->of_node;
int i; int i;
/* Global registers init */ /* Global registers init */
/* Deal with am-max-transmissions quirk */ /* Deal with am-max-transmissions quirk */
if (of_get_property(np, "hip06-sas-v2-quirk-amt", NULL)) { if (device_property_present(dev, "hip06-sas-v2-quirk-amt")) {
hisi_sas_write32(hisi_hba, AM_CFG_MAX_TRANS, 0x2020); hisi_sas_write32(hisi_hba, AM_CFG_MAX_TRANS, 0x2020);
hisi_sas_write32(hisi_hba, AM_CFG_SINGLE_PORT_MAX_TRANS, hisi_sas_write32(hisi_hba, AM_CFG_SINGLE_PORT_MAX_TRANS,
0x2020); 0x2020);
...@@ -2260,12 +2270,20 @@ static const struct of_device_id sas_v2_of_match[] = { ...@@ -2260,12 +2270,20 @@ static const struct of_device_id sas_v2_of_match[] = {
}; };
MODULE_DEVICE_TABLE(of, sas_v2_of_match); MODULE_DEVICE_TABLE(of, sas_v2_of_match);
static const struct acpi_device_id sas_v2_acpi_match[] = {
{ "HISI0162", 0 },
{ }
};
MODULE_DEVICE_TABLE(acpi, sas_v2_acpi_match);
static struct platform_driver hisi_sas_v2_driver = { static struct platform_driver hisi_sas_v2_driver = {
.probe = hisi_sas_v2_probe, .probe = hisi_sas_v2_probe,
.remove = hisi_sas_v2_remove, .remove = hisi_sas_v2_remove,
.driver = { .driver = {
.name = DRV_NAME, .name = DRV_NAME,
.of_match_table = sas_v2_of_match, .of_match_table = sas_v2_of_match,
.acpi_match_table = ACPI_PTR(sas_v2_acpi_match),
}, },
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment