LKML Archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] HiSilicon SAS ACPI support
@ 2016-02-03 18:26 John Garry
  2016-02-03 18:26 ` [PATCH 1/3] hisi_sas: use Unified Device Properties API John Garry
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: John Garry @ 2016-02-03 18:26 UTC (permalink / raw)
  To: JBottomley, martin.petersen
  Cc: linuxarm, john.garry2, linux-scsi, linux-kernel, zhangfei.gao,
	John Garry

This patchset introduces support for ACPI in the
HiSilicon SAS driver. The driver will support
both device tree and ACPI.
Currently only v1 hw will use ACPI.

John Garry (3):
  hisi_sas: use Unified Device Properties API
  hisi_sas: add v1 hw ACPI support
  hisi_sas: update driver version to 1.2

 drivers/scsi/hisi_sas/hisi_sas.h       |  4 +-
 drivers/scsi/hisi_sas/hisi_sas_main.c  | 41 +++++++++++----------
 drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 67 ++++++++++++++++++++++------------
 3 files changed, 67 insertions(+), 45 deletions(-)

-- 
1.9.1

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/3] hisi_sas: use Unified Device Properties API
  2016-02-03 18:26 [PATCH 0/3] HiSilicon SAS ACPI support John Garry
@ 2016-02-03 18:26 ` John Garry
  2016-02-05  3:22   ` Martin K. Petersen
  2016-02-03 18:26 ` [PATCH 2/3] hisi_sas: add v1 hw ACPI support John Garry
  2016-02-03 18:26 ` [PATCH 3/3] hisi_sas: update driver version to 1.2 John Garry
  2 siblings, 1 reply; 5+ messages in thread
From: John Garry @ 2016-02-03 18:26 UTC (permalink / raw)
  To: JBottomley, martin.petersen
  Cc: linuxarm, john.garry2, linux-scsi, linux-kernel, zhangfei.gao,
	John Garry

The hisi_sas driver is required to support both
device tree and ACPI. The scanning of the device
properties now uses the Unified Device Properties
API, which serves both OF and ACPI.

Since syscon is not supported by ACPI, syscon is
only used in the driver when device tree is used.

Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Zhangfei Gao <zhangfei.gao@linaro.org>
---
 drivers/scsi/hisi_sas/hisi_sas.h      |  2 ++
 drivers/scsi/hisi_sas/hisi_sas_main.c | 41 ++++++++++++++++++-----------------
 2 files changed, 23 insertions(+), 20 deletions(-)

diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h
index 9f08c0c..5b8affd 100644
--- a/drivers/scsi/hisi_sas/hisi_sas.h
+++ b/drivers/scsi/hisi_sas/hisi_sas.h
@@ -12,11 +12,13 @@
 #ifndef _HISI_SAS_H_
 #define _HISI_SAS_H_
 
+#include <linux/acpi.h>
 #include <linux/dmapool.h>
 #include <linux/mfd/syscon.h>
 #include <linux/module.h>
 #include <linux/of_address.h>
 #include <linux/platform_device.h>
+#include <linux/property.h>
 #include <linux/regmap.h>
 #include <scsi/sas_ata.h>
 #include <scsi/libsas.h>
diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c
index 406b515..2194917 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_main.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_main.c
@@ -1167,7 +1167,6 @@ static struct Scsi_Host *hisi_sas_shost_alloc(struct platform_device *pdev,
 	struct hisi_hba *hisi_hba;
 	struct device *dev = &pdev->dev;
 	struct device_node *np = pdev->dev.of_node;
-	struct property *sas_addr_prop;
 
 	shost = scsi_host_alloc(&hisi_sas_sht, sizeof(*hisi_hba));
 	if (!shost)
@@ -1181,27 +1180,34 @@ static struct Scsi_Host *hisi_sas_shost_alloc(struct platform_device *pdev,
 
 	init_timer(&hisi_hba->timer);
 
-	sas_addr_prop = of_find_property(np, "sas-addr", NULL);
-	if (!sas_addr_prop || (sas_addr_prop->length != SAS_ADDR_SIZE))
+	if (device_property_read_u8_array(dev, "sas-addr", hisi_hba->sas_addr,
+					  SAS_ADDR_SIZE))
 		goto err_out;
-	memcpy(hisi_hba->sas_addr, sas_addr_prop->value, SAS_ADDR_SIZE);
 
-	if (of_property_read_u32(np, "ctrl-reset-reg",
-				 &hisi_hba->ctrl_reset_reg))
-		goto err_out;
+	if (np) {
+		hisi_hba->ctrl = syscon_regmap_lookup_by_phandle(np,
+					"hisilicon,sas-syscon");
+		if (IS_ERR(hisi_hba->ctrl))
+			goto err_out;
 
-	if (of_property_read_u32(np, "ctrl-reset-sts-reg",
-				 &hisi_hba->ctrl_reset_sts_reg))
-		goto err_out;
+		if (device_property_read_u32(dev, "ctrl-reset-reg",
+					     &hisi_hba->ctrl_reset_reg))
+			goto err_out;
 
-	if (of_property_read_u32(np, "ctrl-clock-ena-reg",
-				 &hisi_hba->ctrl_clock_ena_reg))
-		goto err_out;
+		if (device_property_read_u32(dev, "ctrl-reset-sts-reg",
+					     &hisi_hba->ctrl_reset_sts_reg))
+			goto err_out;
 
-	if (of_property_read_u32(np, "phy-count", &hisi_hba->n_phy))
+		if (device_property_read_u32(dev, "ctrl-clock-ena-reg",
+					     &hisi_hba->ctrl_clock_ena_reg))
+			goto err_out;
+	}
+
+	if (device_property_read_u32(dev, "phy-count", &hisi_hba->n_phy))
 		goto err_out;
 
-	if (of_property_read_u32(np, "queue-count", &hisi_hba->queue_count))
+	if (device_property_read_u32(dev, "queue-count",
+				     &hisi_hba->queue_count))
 		goto err_out;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -1209,11 +1215,6 @@ static struct Scsi_Host *hisi_sas_shost_alloc(struct platform_device *pdev,
 	if (IS_ERR(hisi_hba->regs))
 		goto err_out;
 
-	hisi_hba->ctrl = syscon_regmap_lookup_by_phandle(
-				np, "hisilicon,sas-syscon");
-	if (IS_ERR(hisi_hba->ctrl))
-		goto err_out;
-
 	if (hisi_sas_alloc(hisi_hba, shost)) {
 		hisi_sas_free(hisi_hba);
 		goto err_out;
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/3] hisi_sas: add v1 hw ACPI support
  2016-02-03 18:26 [PATCH 0/3] HiSilicon SAS ACPI support John Garry
  2016-02-03 18:26 ` [PATCH 1/3] hisi_sas: use Unified Device Properties API John Garry
@ 2016-02-03 18:26 ` John Garry
  2016-02-03 18:26 ` [PATCH 3/3] hisi_sas: update driver version to 1.2 John Garry
  2 siblings, 0 replies; 5+ messages in thread
From: John Garry @ 2016-02-03 18:26 UTC (permalink / raw)
  To: JBottomley, martin.petersen
  Cc: linuxarm, john.garry2, linux-scsi, linux-kernel, zhangfei.gao,
	John Garry

Add support in v1 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: John Garry <john.garry@huawei.com>
Signed-off-by: Zhangfei Gao <zhangfei.gao@linaro.org>
---
 drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 67 ++++++++++++++++++++++------------
 1 file changed, 43 insertions(+), 24 deletions(-)

diff --git a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
index 24274f1..55ac703 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
@@ -623,31 +623,42 @@ static int reset_hw_v1_hw(struct hisi_hba *hisi_hba)
 			return -EIO;
 	}
 
-	/* Apply reset and disable clock */
-	/* clk disable reg is offset by +4 bytes from clk enable reg */
-	regmap_write(hisi_hba->ctrl, hisi_hba->ctrl_reset_reg,
-		     RESET_VALUE);
-	regmap_write(hisi_hba->ctrl, hisi_hba->ctrl_clock_ena_reg + 4,
-		     RESET_VALUE);
-	msleep(1);
-	regmap_read(hisi_hba->ctrl, hisi_hba->ctrl_reset_sts_reg, &val);
-	if (RESET_VALUE != (val & RESET_VALUE)) {
-		dev_err(dev, "Reset failed\n");
-		return -EIO;
-	}
+	if (ACPI_HANDLE(dev)) {
+		acpi_status s;
 
-	/* De-reset and enable clock */
-	/* deassert rst reg is offset by +4 bytes from assert reg */
-	regmap_write(hisi_hba->ctrl, hisi_hba->ctrl_reset_reg + 4,
-		     RESET_VALUE);
-	regmap_write(hisi_hba->ctrl, hisi_hba->ctrl_clock_ena_reg,
-		     RESET_VALUE);
-	msleep(1);
-	regmap_read(hisi_hba->ctrl, hisi_hba->ctrl_reset_sts_reg, &val);
-	if (val & RESET_VALUE) {
-		dev_err(dev, "De-reset failed\n");
-		return -EIO;
-	}
+		s = acpi_evaluate_object(ACPI_HANDLE(dev), "_RST", NULL, NULL);
+		if (ACPI_FAILURE(s)) {
+			dev_err(dev, "Reset failed\n");
+			return -EIO;
+		}
+	} else if (hisi_hba->ctrl) {
+		/* Apply reset and disable clock */
+		/* clk disable reg is offset by +4 bytes from clk enable reg */
+		regmap_write(hisi_hba->ctrl, hisi_hba->ctrl_reset_reg,
+			     RESET_VALUE);
+		regmap_write(hisi_hba->ctrl, hisi_hba->ctrl_clock_ena_reg + 4,
+			     RESET_VALUE);
+		msleep(1);
+		regmap_read(hisi_hba->ctrl, hisi_hba->ctrl_reset_sts_reg, &val);
+		if (RESET_VALUE != (val & RESET_VALUE)) {
+			dev_err(dev, "Reset failed\n");
+			return -EIO;
+		}
+
+		/* De-reset and enable clock */
+		/* deassert rst reg is offset by +4 bytes from assert reg */
+		regmap_write(hisi_hba->ctrl, hisi_hba->ctrl_reset_reg + 4,
+			     RESET_VALUE);
+		regmap_write(hisi_hba->ctrl, hisi_hba->ctrl_clock_ena_reg,
+			     RESET_VALUE);
+		msleep(1);
+		regmap_read(hisi_hba->ctrl, hisi_hba->ctrl_reset_sts_reg, &val);
+		if (val & RESET_VALUE) {
+			dev_err(dev, "De-reset failed\n");
+			return -EIO;
+		}
+	} else
+		dev_warn(dev, "no reset method\n");
 
 	return 0;
 }
@@ -1834,12 +1845,20 @@ static const struct of_device_id sas_v1_of_match[] = {
 };
 MODULE_DEVICE_TABLE(of, sas_v1_of_match);
 
+static const struct acpi_device_id sas_v1_acpi_match[] = {
+	{ "HISI0161", 0 },
+	{ }
+};
+
+MODULE_DEVICE_TABLE(acpi, sas_v1_acpi_match);
+
 static struct platform_driver hisi_sas_v1_driver = {
 	.probe = hisi_sas_v1_probe,
 	.remove = hisi_sas_v1_remove,
 	.driver = {
 		.name = DRV_NAME,
 		.of_match_table = sas_v1_of_match,
+		.acpi_match_table = ACPI_PTR(sas_v1_acpi_match),
 	},
 };
 
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/3] hisi_sas: update driver version to 1.2
  2016-02-03 18:26 [PATCH 0/3] HiSilicon SAS ACPI support John Garry
  2016-02-03 18:26 ` [PATCH 1/3] hisi_sas: use Unified Device Properties API John Garry
  2016-02-03 18:26 ` [PATCH 2/3] hisi_sas: add v1 hw ACPI support John Garry
@ 2016-02-03 18:26 ` John Garry
  2 siblings, 0 replies; 5+ messages in thread
From: John Garry @ 2016-02-03 18:26 UTC (permalink / raw)
  To: JBottomley, martin.petersen
  Cc: linuxarm, john.garry2, linux-scsi, linux-kernel, zhangfei.gao,
	John Garry

Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Zhangfei Gao <zhangfei.gao@linaro.org>
---
 drivers/scsi/hisi_sas/hisi_sas.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h
index 5b8affd..02da7e4 100644
--- a/drivers/scsi/hisi_sas/hisi_sas.h
+++ b/drivers/scsi/hisi_sas/hisi_sas.h
@@ -23,7 +23,7 @@
 #include <scsi/sas_ata.h>
 #include <scsi/libsas.h>
 
-#define DRV_VERSION "v1.1"
+#define DRV_VERSION "v1.2"
 
 #define HISI_SAS_MAX_PHYS	9
 #define HISI_SAS_MAX_QUEUES	32
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/3] hisi_sas: use Unified Device Properties API
  2016-02-03 18:26 ` [PATCH 1/3] hisi_sas: use Unified Device Properties API John Garry
@ 2016-02-05  3:22   ` Martin K. Petersen
  0 siblings, 0 replies; 5+ messages in thread
From: Martin K. Petersen @ 2016-02-05  3:22 UTC (permalink / raw)
  To: John Garry
  Cc: martin.petersen, linuxarm, john.garry2, linux-scsi, linux-kernel,
	zhangfei.gao

>>>>> "John" == John Garry <john.garry@huawei.com> writes:

John> The hisi_sas driver is required to support both device tree and
John> ACPI. The scanning of the device properties now uses the Unified
John> Device Properties API, which serves both OF and ACPI.

Series applied to 4.6/scsi-queue.

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-02-05  3:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-03 18:26 [PATCH 0/3] HiSilicon SAS ACPI support John Garry
2016-02-03 18:26 ` [PATCH 1/3] hisi_sas: use Unified Device Properties API John Garry
2016-02-05  3:22   ` Martin K. Petersen
2016-02-03 18:26 ` [PATCH 2/3] hisi_sas: add v1 hw ACPI support John Garry
2016-02-03 18:26 ` [PATCH 3/3] hisi_sas: update driver version to 1.2 John Garry

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).