public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/9] Ata ceva patches
@ 2017-08-21 11:17 Michal Simek
  2017-08-21 11:17 ` [PATCH v2 1/9] devicetree: bindings: Add sata port phy config parameters in ahci-ceva Michal Simek
                   ` (9 more replies)
  0 siblings, 10 replies; 15+ messages in thread
From: Michal Simek @ 2017-08-21 11:17 UTC (permalink / raw)
  To: linux-kernel, monstr
  Cc: Alexander Graf, Rob Herring, Tejun Heo, devicetree, linux-ide,
	Rob Herring, Mark Rutland

Hi,

this patchset contains the latest changes which are available in Xilinx tree.

Thanks,
Michal

Changes in v2:
- DT fix naming in parameters description use pN instead of phy
  reported by Rob

Anurag Kumar Vulisha (9):
  devicetree: bindings: Add sata port phy config parameters in ahci-ceva
  ata: ceva: Move sata port phy oob settings to device-tree
  ata: ceva: Add gen 3 mode support in driver
  ata: ceva: Disable Device Sleep capability
  ata: ceva: Make RxWaterMark value as module parameter
  ata: ceva: Add CCI support for SATA if CCI is enabled
  ata: ceva: Correct the AXI bus configuration for SATA ports
  ata: ceva: Correct the suspend and resume logic for SATA
  ata: ceva: Add SMMU support for SATA IP

 .../devicetree/bindings/ata/ahci-ceva.txt          |  39 ++++
 drivers/ata/ahci_ceva.c                            | 197 +++++++++++++++++----
 2 files changed, 198 insertions(+), 38 deletions(-)

-- 
1.9.1

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

* [PATCH v2 1/9] devicetree: bindings: Add sata port phy config parameters in ahci-ceva
  2017-08-21 11:17 [PATCH v2 0/9] Ata ceva patches Michal Simek
@ 2017-08-21 11:17 ` Michal Simek
  2017-08-23  0:41   ` Rob Herring
  2017-08-21 11:17 ` [PATCH v2 2/9] ata: ceva: Move sata port phy oob settings to device-tree Michal Simek
                   ` (8 subsequent siblings)
  9 siblings, 1 reply; 15+ messages in thread
From: Michal Simek @ 2017-08-21 11:17 UTC (permalink / raw)
  To: linux-kernel, monstr
  Cc: Alexander Graf, Rob Herring, Anurag Kumar Vulisha, Tejun Heo,
	devicetree, linux-ide, Rob Herring, Mark Rutland

From: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>

This patch adds device tree bindings for sata port phy parameters
in the ahci-ceva.txt file.

Signed-off-by: Anurag Kumar Vulisha <anuragku@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

Changes in v2:
- DT fix naming in parameters description use pN instead of phy
  reported by Rob

 .../devicetree/bindings/ata/ahci-ceva.txt          | 39 ++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/Documentation/devicetree/bindings/ata/ahci-ceva.txt b/Documentation/devicetree/bindings/ata/ahci-ceva.txt
index 7ca8b976c13a..7561cc4de371 100644
--- a/Documentation/devicetree/bindings/ata/ahci-ceva.txt
+++ b/Documentation/devicetree/bindings/ata/ahci-ceva.txt
@@ -5,6 +5,36 @@ Required properties:
   - compatible: Compatibility string. Must be 'ceva,ahci-1v84'.
   - clocks: Input clock specifier. Refer to common clock bindings.
   - interrupts: Interrupt specifier. Refer to interrupt binding.
+  - ceva,p0-cominit-params: OOB timing value for COMINIT parameter for port 0.
+  - ceva,p1-cominit-params: OOB timing value for COMINIT parameter for port 1.
+			The fields for the above parameter must be as shown below:
+			ceva,pN-cominit-params = /bits/ 8 <CIBGMN CIBGMX CIBGN CINMP>;
+			CINMP : COMINIT Negate Minimum Period.
+			CIBGN : COMINIT Burst Gap Nominal.
+			CIBGMX: COMINIT Burst Gap Maximum.
+			CIBGMN: COMINIT Burst Gap Minimum.
+  - ceva,p0-comwake-params: OOB timing value for COMWAKE parameter for port 0.
+  - ceva,p1-comwake-params: OOB timing value for COMWAKE parameter for port 1.
+			The fields for the above parameter must be as shown below:
+			ceva,pN-comwake-params = /bits/ 8 <CWBGMN CWBGMX CWBGN CWNMP>;
+			CWBGMN: COMWAKE Burst Gap Minimum.
+			CWBGMX: COMWAKE Burst Gap Maximum.
+			CWBGN: COMWAKE Burst Gap Nominal.
+			CWNMP: COMWAKE Negate Minimum Period.
+  - ceva,p0-burst-params: Burst timing value for COM parameter for port 0.
+  - ceva,p1-burst-params: Burst timing value for COM parameter for port 1.
+			The fields for the above parameter must be as shown below:
+			ceva,pN-burst-params = /bits/ 8 <BMX BNM SFD PTST>;
+			BMX: COM Burst Maximum.
+			BNM: COM Burst Nominal.
+			SFD: Signal Failure Detection value.
+			PTST: Partial to Slumber timer value.
+  - ceva,p0-retry-params: Retry interval timing value for port 0.
+  - ceva,p1-retry-params: Retry interval timing value for port 1.
+			The fields for the above parameter must be as shown below:
+			ceva,pN-retry-params = /bits/ 16 <RIT RCT>;
+			RIT:  Retry Interval Timer.
+			RCT:  Rate Change Timer.
 
 Optional properties:
   - ceva,broken-gen2: limit to gen1 speed instead of gen2.
@@ -16,5 +46,14 @@ Examples:
 		interrupt-parent = <&gic>;
 		interrupts = <0 133 4>;
 		clocks = <&clkc SATA_CLK_ID>;
+		ceva,p0-cominit-params = /bits/ 8 <0x0F 0x25 0x18 0x29>;
+		ceva,p0-comwake-params = /bits/ 8 <0x04 0x0B 0x08 0x0F>;
+		ceva,p0-burst-params = /bits/ 8 <0x0A 0x08 0x4A 0x06>;
+		ceva,p0-retry-params = /bits/ 16 <0x0216 0x7F06>;
+
+		ceva,p1-cominit-params = /bits/ 8 <0x0F 0x25 0x18 0x29>;
+		ceva,p1-comwake-params = /bits/ 8 <0x04 0x0B 0x08 0x0F>;
+		ceva,p1-burst-params = /bits/ 8 <0x0A 0x08 0x4A 0x06>;
+		ceva,p1-retry-params = /bits/ 16 <0x0216 0x7F06>;
 		ceva,broken-gen2;
 	};
-- 
1.9.1

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

* [PATCH v2 2/9] ata: ceva: Move sata port phy oob settings to device-tree
  2017-08-21 11:17 [PATCH v2 0/9] Ata ceva patches Michal Simek
  2017-08-21 11:17 ` [PATCH v2 1/9] devicetree: bindings: Add sata port phy config parameters in ahci-ceva Michal Simek
@ 2017-08-21 11:17 ` Michal Simek
  2017-10-20 10:42   ` Michal Simek
  2017-10-21 15:19   ` Tejun Heo
  2017-08-21 11:17 ` [PATCH v2 3/9] ata: ceva: Add gen 3 mode support in driver Michal Simek
                   ` (7 subsequent siblings)
  9 siblings, 2 replies; 15+ messages in thread
From: Michal Simek @ 2017-08-21 11:17 UTC (permalink / raw)
  To: linux-kernel, monstr
  Cc: Alexander Graf, Rob Herring, Anurag Kumar Vulisha, Tejun Heo,
	linux-ide

From: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>

In SATA Speed negotiation happens with  OOB(Out of Band) signals. These OOB
signal timing values are configured through vendor specific registers in the
SATA controller. These OOB timings depends on the generator and detector clock
frequency, which varies from board to board (ex: ep108 and zc1751 has different
clock frequencies).
To avoid maintaing these OOB settings in the driver, it is better to move these
settings to the device-tree node and read from the device-tree.

This patch does the same.

Signed-off-by: Anurag Kumar Vulisha <anuragku@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

Changes in v2: None

 drivers/ata/ahci_ceva.c | 84 +++++++++++++++++++++++++++++++++++--------------
 1 file changed, 61 insertions(+), 23 deletions(-)

diff --git a/drivers/ata/ahci_ceva.c b/drivers/ata/ahci_ceva.c
index 207649d323c5..59de2ca1885c 100644
--- a/drivers/ata/ahci_ceva.c
+++ b/drivers/ata/ahci_ceva.c
@@ -50,21 +50,6 @@
 #define PPCFG_PSS_EN	(1 << 29)
 #define PPCFG_ESDF_EN	(1 << 31)
 
-#define PP2C_CIBGMN	0x0F
-#define PP2C_CIBGMX	(0x25 << 8)
-#define PP2C_CIBGN	(0x18 << 16)
-#define PP2C_CINMP	(0x29 << 24)
-
-#define PP3C_CWBGMN	0x04
-#define PP3C_CWBGMX	(0x0B << 8)
-#define PP3C_CWBGN	(0x08 << 16)
-#define PP3C_CWNMP	(0x0F << 24)
-
-#define PP4C_BMX	0x0a
-#define PP4C_BNM	(0x08 << 8)
-#define PP4C_SFD	(0x4a << 16)
-#define PP4C_PTST	(0x06 << 24)
-
 #define PP5C_RIT	0x60216
 #define PP5C_RCT	(0x7f0 << 20)
 
@@ -87,6 +72,11 @@
 
 struct ceva_ahci_priv {
 	struct platform_device *ahci_pdev;
+	/* Port Phy2Cfg Register */
+	u32 pp2c[NR_PORTS];
+	u32 pp3c[NR_PORTS];
+	u32 pp4c[NR_PORTS];
+	u32 pp5c[NR_PORTS];
 	int flags;
 };
 
@@ -131,20 +121,16 @@ static void ahci_ceva_setup(struct ahci_host_priv *hpriv)
 		writel(tmp, mmio + AHCI_VEND_PPCFG);
 
 		/* Phy Control OOB timing parameters COMINIT */
-		tmp = PP2C_CIBGMN | PP2C_CIBGMX | PP2C_CIBGN | PP2C_CINMP;
-		writel(tmp, mmio + AHCI_VEND_PP2C);
+		writel(cevapriv->pp2c[i], mmio + AHCI_VEND_PP2C);
 
 		/* Phy Control OOB timing parameters COMWAKE */
-		tmp = PP3C_CWBGMN | PP3C_CWBGMX | PP3C_CWBGN | PP3C_CWNMP;
-		writel(tmp, mmio + AHCI_VEND_PP3C);
+		writel(cevapriv->pp3c[i], mmio + AHCI_VEND_PP3C);
 
 		/* Phy Control Burst timing setting */
-		tmp = PP4C_BMX | PP4C_BNM | PP4C_SFD | PP4C_PTST;
-		writel(tmp, mmio + AHCI_VEND_PP4C);
+		writel(cevapriv->pp4c[i], mmio + AHCI_VEND_PP4C);
 
 		/* Rate Change Timer and Retry Interval Timer setting */
-		tmp = PP5C_RIT | PP5C_RCT;
-		writel(tmp, mmio + AHCI_VEND_PP5C);
+		writel(cevapriv->pp5c[i], mmio + AHCI_VEND_PP5C);
 
 		/* Rx Watermark setting  */
 		tmp = PTC_RX_WM_VAL | PTC_RSVD;
@@ -187,6 +173,58 @@ static int ceva_ahci_probe(struct platform_device *pdev)
 	if (of_property_read_bool(np, "ceva,broken-gen2"))
 		cevapriv->flags = CEVA_FLAG_BROKEN_GEN2;
 
+	/* Read OOB timing value for COMINIT from device-tree */
+	if (of_property_read_u8_array(np, "ceva,p0-cominit-params",
+					(u8 *)&cevapriv->pp2c[0], 4) < 0) {
+		dev_warn(dev, "ceva,p0-cominit-params property not defined\n");
+		return -EINVAL;
+	}
+
+	if (of_property_read_u8_array(np, "ceva,p1-cominit-params",
+					(u8 *)&cevapriv->pp2c[1], 4) < 0) {
+		dev_warn(dev, "ceva,p1-cominit-params property not defined\n");
+		return -EINVAL;
+	}
+
+	/* Read OOB timing value for COMWAKE from device-tree*/
+	if (of_property_read_u8_array(np, "ceva,p0-comwake-params",
+					(u8 *)&cevapriv->pp3c[0], 4) < 0) {
+		dev_warn(dev, "ceva,p0-comwake-params property not defined\n");
+		return -EINVAL;
+	}
+
+	if (of_property_read_u8_array(np, "ceva,p1-comwake-params",
+					(u8 *)&cevapriv->pp3c[1], 4) < 0) {
+		dev_warn(dev, "ceva,p1-comwake-params property not defined\n");
+		return -EINVAL;
+	}
+
+	/* Read phy BURST timing value from device-tree */
+	if (of_property_read_u8_array(np, "ceva,p0-burst-params",
+					(u8 *)&cevapriv->pp4c[0], 4) < 0) {
+		dev_warn(dev, "ceva,p0-burst-params property not defined\n");
+		return -EINVAL;
+	}
+
+	if (of_property_read_u8_array(np, "ceva,p1-burst-params",
+					(u8 *)&cevapriv->pp4c[1], 4) < 0) {
+		dev_warn(dev, "ceva,p1-burst-params property not defined\n");
+		return -EINVAL;
+	}
+
+	/* Read phy RETRY interval timing value from device-tree */
+	if (of_property_read_u16_array(np, "ceva,p0-retry-params",
+					(u16 *)&cevapriv->pp5c[0], 2) < 0) {
+		dev_warn(dev, "ceva,p0-retry-params property not defined\n");
+		return -EINVAL;
+	}
+
+	if (of_property_read_u16_array(np, "ceva,p1-retry-params",
+					(u16 *)&cevapriv->pp5c[1], 2) < 0) {
+		dev_warn(dev, "ceva,p1-retry-params property not defined\n");
+		return -EINVAL;
+	}
+
 	hpriv->plat_data = cevapriv;
 
 	/* CEVA specific initialization */
-- 
1.9.1

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

* [PATCH v2 3/9] ata: ceva: Add gen 3 mode support in driver
  2017-08-21 11:17 [PATCH v2 0/9] Ata ceva patches Michal Simek
  2017-08-21 11:17 ` [PATCH v2 1/9] devicetree: bindings: Add sata port phy config parameters in ahci-ceva Michal Simek
  2017-08-21 11:17 ` [PATCH v2 2/9] ata: ceva: Move sata port phy oob settings to device-tree Michal Simek
@ 2017-08-21 11:17 ` Michal Simek
  2017-08-21 11:17 ` [PATCH v2 4/9] ata: ceva: Disable Device Sleep capability Michal Simek
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 15+ messages in thread
From: Michal Simek @ 2017-08-21 11:17 UTC (permalink / raw)
  To: linux-kernel, monstr
  Cc: Alexander Graf, Rob Herring, Anurag Kumar Vulisha, Tejun Heo,
	linux-ide

From: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>

This patch sets gen 3 mode as default mode in ahci_ceva driver.

Signed-off-by: Anurag Kumar Vulisha <anuragku@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

Changes in v2: None

 drivers/ata/ahci_ceva.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/ata/ahci_ceva.c b/drivers/ata/ahci_ceva.c
index 59de2ca1885c..aa32c8a0f083 100644
--- a/drivers/ata/ahci_ceva.c
+++ b/drivers/ata/ahci_ceva.c
@@ -60,6 +60,7 @@
 #define PORT1_BASE	0x180
 
 /* Port Control Register Bit Definitions */
+#define PORT_SCTL_SPD_GEN3	(0x3 << 4)
 #define PORT_SCTL_SPD_GEN2	(0x2 << 4)
 #define PORT_SCTL_SPD_GEN1	(0x1 << 4)
 #define PORT_SCTL_IPM		(0x3 << 8)
@@ -136,8 +137,8 @@ static void ahci_ceva_setup(struct ahci_host_priv *hpriv)
 		tmp = PTC_RX_WM_VAL | PTC_RSVD;
 		writel(tmp, mmio + AHCI_VEND_PTC);
 
-		/* Default to Gen 2 Speed and Gen 1 if Gen2 is broken */
-		tmp = PORT_SCTL_SPD_GEN2 | PORT_SCTL_IPM;
+		/* Default to Gen 3 Speed and Gen 1 if Gen2 is broken */
+		tmp = PORT_SCTL_SPD_GEN3 | PORT_SCTL_IPM;
 		if (cevapriv->flags & CEVA_FLAG_BROKEN_GEN2)
 			tmp = PORT_SCTL_SPD_GEN1 | PORT_SCTL_IPM;
 		writel(tmp, mmio + PORT_SCR_CTL + PORT_BASE + PORT_OFFSET * i);
-- 
1.9.1

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

* [PATCH v2 4/9] ata: ceva: Disable Device Sleep capability
  2017-08-21 11:17 [PATCH v2 0/9] Ata ceva patches Michal Simek
                   ` (2 preceding siblings ...)
  2017-08-21 11:17 ` [PATCH v2 3/9] ata: ceva: Add gen 3 mode support in driver Michal Simek
@ 2017-08-21 11:17 ` Michal Simek
  2017-08-21 11:17 ` [PATCH v2 5/9] ata: ceva: Make RxWaterMark value as module parameter Michal Simek
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 15+ messages in thread
From: Michal Simek @ 2017-08-21 11:17 UTC (permalink / raw)
  To: linux-kernel, monstr
  Cc: Alexander Graf, Rob Herring, Anurag Kumar Vulisha, Tejun Heo,
	linux-ide

From: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>

Since CEVA controller does not support Device Sleep capability,
we need to clear that feature by clearing the DEVSLP bit in word78
of IDENTIFY DEVICE data. This patch does the same.

Signed-off-by: Anurag Kumar Vulisha <anuragku@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

Changes in v2: None

 drivers/ata/ahci_ceva.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/drivers/ata/ahci_ceva.c b/drivers/ata/ahci_ceva.c
index aa32c8a0f083..b63fab2507fa 100644
--- a/drivers/ata/ahci_ceva.c
+++ b/drivers/ata/ahci_ceva.c
@@ -81,8 +81,26 @@ struct ceva_ahci_priv {
 	int flags;
 };
 
+static unsigned int ceva_ahci_read_id(struct ata_device *dev,
+					struct ata_taskfile *tf, u16 *id)
+{
+	u32 err_mask;
+
+	err_mask = ata_do_dev_read_id(dev, tf, id);
+	if (err_mask)
+		return err_mask;
+	/*
+	 * Since CEVA controller does not support device sleep feature, we
+	 * need to clear DEVSLP (bit 8) in word78 of the IDENTIFY DEVICE data.
+	 */
+	id[ATA_ID_FEATURE_SUPP] &= cpu_to_le16(~(1 << 8));
+
+	return 0;
+}
+
 static struct ata_port_operations ahci_ceva_ops = {
 	.inherits = &ahci_platform_ops,
+	.read_id = ceva_ahci_read_id,
 };
 
 static const struct ata_port_info ahci_ceva_port_info = {
-- 
1.9.1

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

* [PATCH v2 5/9] ata: ceva: Make RxWaterMark value as module parameter
  2017-08-21 11:17 [PATCH v2 0/9] Ata ceva patches Michal Simek
                   ` (3 preceding siblings ...)
  2017-08-21 11:17 ` [PATCH v2 4/9] ata: ceva: Disable Device Sleep capability Michal Simek
@ 2017-08-21 11:17 ` Michal Simek
  2017-08-21 11:17 ` [PATCH v2 6/9] ata: ceva: Add CCI support for SATA if CCI is enabled Michal Simek
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 15+ messages in thread
From: Michal Simek @ 2017-08-21 11:17 UTC (permalink / raw)
  To: linux-kernel, monstr
  Cc: Alexander Graf, Rob Herring, Anurag Kumar Vulisha, Tejun Heo,
	linux-ide

From: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>

This patch updates the driver to make Rx Fifo water mark value
as a module parameter.

Signed-off-by: Anurag Kumar Vulisha <anuragku@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

Changes in v2: None

 drivers/ata/ahci_ceva.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/ata/ahci_ceva.c b/drivers/ata/ahci_ceva.c
index b63fab2507fa..eff40ec86065 100644
--- a/drivers/ata/ahci_ceva.c
+++ b/drivers/ata/ahci_ceva.c
@@ -71,6 +71,10 @@
 #define DRV_NAME	"ahci-ceva"
 #define CEVA_FLAG_BROKEN_GEN2	1
 
+static unsigned int rx_watermark = PTC_RX_WM_VAL;
+module_param(rx_watermark, uint, 0644);
+MODULE_PARM_DESC(rx_watermark, "RxWaterMark value (0 - 0x80)");
+
 struct ceva_ahci_priv {
 	struct platform_device *ahci_pdev;
 	/* Port Phy2Cfg Register */
@@ -152,7 +156,7 @@ static void ahci_ceva_setup(struct ahci_host_priv *hpriv)
 		writel(cevapriv->pp5c[i], mmio + AHCI_VEND_PP5C);
 
 		/* Rx Watermark setting  */
-		tmp = PTC_RX_WM_VAL | PTC_RSVD;
+		tmp = rx_watermark | PTC_RSVD;
 		writel(tmp, mmio + AHCI_VEND_PTC);
 
 		/* Default to Gen 3 Speed and Gen 1 if Gen2 is broken */
-- 
1.9.1

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

* [PATCH v2 6/9] ata: ceva: Add CCI support for SATA if CCI is enabled
  2017-08-21 11:17 [PATCH v2 0/9] Ata ceva patches Michal Simek
                   ` (4 preceding siblings ...)
  2017-08-21 11:17 ` [PATCH v2 5/9] ata: ceva: Make RxWaterMark value as module parameter Michal Simek
@ 2017-08-21 11:17 ` Michal Simek
  2017-08-21 11:17 ` [PATCH v2 7/9] ata: ceva: Correct the AXI bus configuration for SATA ports Michal Simek
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 15+ messages in thread
From: Michal Simek @ 2017-08-21 11:17 UTC (permalink / raw)
  To: linux-kernel, monstr
  Cc: Alexander Graf, Rob Herring, Anurag Kumar Vulisha, Tejun Heo,
	linux-ide

From: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>

This patch adds support for CCI in SATA controller if CCI is
enabled in design. This patch will add CCI settings for SATA
if "dma-coherent" dts property is added.

Signed-off-by: Anurag Kumar Vulisha <anuragku@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

Changes in v2: None

 drivers/ata/ahci_ceva.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/drivers/ata/ahci_ceva.c b/drivers/ata/ahci_ceva.c
index eff40ec86065..ec9cfb52c6f6 100644
--- a/drivers/ata/ahci_ceva.c
+++ b/drivers/ata/ahci_ceva.c
@@ -32,6 +32,7 @@
 #define AHCI_VEND_PP3C  0xB0
 #define AHCI_VEND_PP4C  0xB4
 #define AHCI_VEND_PP5C  0xB8
+#define AHCI_VEND_AXICC 0xBC
 #define AHCI_VEND_PAXIC 0xC0
 #define AHCI_VEND_PTC   0xC8
 
@@ -41,6 +42,15 @@
 #define PAXIC_MARIDD	(1 << 16)
 #define PAXIC_OTL	(0x4 << 20)
 
+/* Register bit definitions for cache control */
+#define AXICC_ARCA_VAL  (0xF << 0)
+#define AXICC_ARCF_VAL  (0xF << 4)
+#define AXICC_ARCH_VAL  (0xF << 8)
+#define AXICC_ARCP_VAL  (0xF << 12)
+#define AXICC_AWCFD_VAL (0xF << 16)
+#define AXICC_AWCD_VAL  (0xF << 20)
+#define AXICC_AWCF_VAL  (0xF << 24)
+
 #define PCFG_TPSS_VAL	(0x32 << 16)
 #define PCFG_TPRS_VAL	(0x2 << 12)
 #define PCFG_PAD_VAL	0x2
@@ -82,6 +92,9 @@ struct ceva_ahci_priv {
 	u32 pp3c[NR_PORTS];
 	u32 pp4c[NR_PORTS];
 	u32 pp5c[NR_PORTS];
+	/* Axi Cache Control Register */
+	u32 axicc;
+	bool is_cci_enabled;
 	int flags;
 };
 
@@ -139,6 +152,16 @@ static void ahci_ceva_setup(struct ahci_host_priv *hpriv)
 		tmp = PCFG_TPSS_VAL | PCFG_TPRS_VAL | (PCFG_PAD_VAL + i);
 		writel(tmp, mmio + AHCI_VEND_PCFG);
 
+		/* Set AXI cache control register if CCi is enabled */
+		if (cevapriv->is_cci_enabled) {
+			tmp = readl(mmio + AHCI_VEND_AXICC);
+			tmp |= AXICC_ARCA_VAL | AXICC_ARCF_VAL |
+				AXICC_ARCH_VAL | AXICC_ARCP_VAL |
+				AXICC_AWCFD_VAL | AXICC_AWCD_VAL |
+				AXICC_AWCF_VAL;
+			writel(tmp, mmio + AHCI_VEND_AXICC);
+		}
+
 		/* Port Phy Cfg register enables */
 		tmp = PPCFG_TTA | PPCFG_PSS_EN | PPCFG_ESDF_EN;
 		writel(tmp, mmio + AHCI_VEND_PPCFG);
@@ -177,6 +200,7 @@ static int ceva_ahci_probe(struct platform_device *pdev)
 	struct device *dev = &pdev->dev;
 	struct ahci_host_priv *hpriv;
 	struct ceva_ahci_priv *cevapriv;
+	enum dev_dma_attr attr;
 	int rc;
 
 	cevapriv = devm_kzalloc(dev, sizeof(*cevapriv), GFP_KERNEL);
@@ -248,6 +272,13 @@ static int ceva_ahci_probe(struct platform_device *pdev)
 		return -EINVAL;
 	}
 
+	/*
+	 * Check if CCI is enabled for SATA. The DEV_DMA_COHERENT is returned
+	 * if CCI is enabled, so check for DEV_DMA_COHERENT.
+	 */
+	attr = device_get_dma_attr(dev);
+	cevapriv->is_cci_enabled = (attr == DEV_DMA_COHERENT);
+
 	hpriv->plat_data = cevapriv;
 
 	/* CEVA specific initialization */
-- 
1.9.1

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

* [PATCH v2 7/9] ata: ceva: Correct the AXI bus configuration for SATA ports
  2017-08-21 11:17 [PATCH v2 0/9] Ata ceva patches Michal Simek
                   ` (5 preceding siblings ...)
  2017-08-21 11:17 ` [PATCH v2 6/9] ata: ceva: Add CCI support for SATA if CCI is enabled Michal Simek
@ 2017-08-21 11:17 ` Michal Simek
  2017-08-21 11:17 ` [PATCH v2 8/9] ata: ceva: Correct the suspend and resume logic for SATA Michal Simek
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 15+ messages in thread
From: Michal Simek @ 2017-08-21 11:17 UTC (permalink / raw)
  To: linux-kernel, monstr
  Cc: Alexander Graf, Rob Herring, Anurag Kumar Vulisha, Tejun Heo,
	linux-ide

From: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>

Previously PAXIC register was programmed before configuring PCFG
register. PCFG should be programmed with the address of the port
for which PAXIC should be configured for.
This was not happening before, so only one port PAXIC was written
correctly and the other port was having wrong value.
This patch moves the PXAIC register write after configuring PCFG,
doing so will correct the axi bus settings for sata port0 & port1.

Signed-off-by: Anurag Kumar Vulisha <anuragku@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

Changes in v2: None

 drivers/ata/ahci_ceva.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/ata/ahci_ceva.c b/drivers/ata/ahci_ceva.c
index ec9cfb52c6f6..113c1f617da9 100644
--- a/drivers/ata/ahci_ceva.c
+++ b/drivers/ata/ahci_ceva.c
@@ -134,14 +134,6 @@ static void ahci_ceva_setup(struct ahci_host_priv *hpriv)
 	u32 tmp;
 	int i;
 
-	/*
-	 * AXI Data bus width to 64
-	 * Set Mem Addr Read, Write ID for data transfers
-	 * Transfer limit to 72 DWord
-	 */
-	tmp = PAXIC_ADBW_BW64 | PAXIC_MAWIDD | PAXIC_MARIDD | PAXIC_OTL;
-	writel(tmp, mmio + AHCI_VEND_PAXIC);
-
 	/* Set AHCI Enable */
 	tmp = readl(mmio + HOST_CTL);
 	tmp |= HOST_AHCI_EN;
@@ -152,6 +144,14 @@ static void ahci_ceva_setup(struct ahci_host_priv *hpriv)
 		tmp = PCFG_TPSS_VAL | PCFG_TPRS_VAL | (PCFG_PAD_VAL + i);
 		writel(tmp, mmio + AHCI_VEND_PCFG);
 
+		/*
+		 * AXI Data bus width to 64
+		 * Set Mem Addr Read, Write ID for data transfers
+		 * Transfer limit to 72 DWord
+		 */
+		tmp = PAXIC_ADBW_BW64 | PAXIC_MAWIDD | PAXIC_MARIDD | PAXIC_OTL;
+		writel(tmp, mmio + AHCI_VEND_PAXIC);
+
 		/* Set AXI cache control register if CCi is enabled */
 		if (cevapriv->is_cci_enabled) {
 			tmp = readl(mmio + AHCI_VEND_AXICC);
-- 
1.9.1

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

* [PATCH v2 8/9] ata: ceva: Correct the suspend and resume logic for SATA
  2017-08-21 11:17 [PATCH v2 0/9] Ata ceva patches Michal Simek
                   ` (6 preceding siblings ...)
  2017-08-21 11:17 ` [PATCH v2 7/9] ata: ceva: Correct the AXI bus configuration for SATA ports Michal Simek
@ 2017-08-21 11:17 ` Michal Simek
  2017-08-21 11:17 ` [PATCH v2 9/9] ata: ceva: Add SMMU support for SATA IP Michal Simek
  2017-10-23 14:10 ` [PATCH v2 0/9] Ata ceva patches Tejun Heo
  9 siblings, 0 replies; 15+ messages in thread
From: Michal Simek @ 2017-08-21 11:17 UTC (permalink / raw)
  To: linux-kernel, monstr
  Cc: Alexander Graf, Rob Herring, Anurag Kumar Vulisha, Tejun Heo,
	linux-ide

From: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>

The present suspend code disables the port interrupts
and stops the HBA. On resume it enables the interrupts and HBA.
This works fine until the FPD power domain is not off.
If FPD is off then the ceva vendor specific configurations like
OOB, AXI settings are lost, they need to be re-programmed and
also since SERDES is also in FPD , SATA lane phy init needs to
be called again (which is not happening in the present sequence)
Because of this incorrect sequence SATA fails to work on resume.

This patch corrects the code to make Suspend & Resume work in normal
and FPD off cases.

Signed-off-by: Anurag Kumar Vulisha <anuragku@xilinx.com>
Reviewed-by: Shubhrajyoti Datta <shubhraj@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

Changes in v2: None

 drivers/ata/ahci_ceva.c | 29 +++++++++++++++++++++++++++--
 1 file changed, 27 insertions(+), 2 deletions(-)

diff --git a/drivers/ata/ahci_ceva.c b/drivers/ata/ahci_ceva.c
index 113c1f617da9..c0742cbe4faa 100644
--- a/drivers/ata/ahci_ceva.c
+++ b/drivers/ata/ahci_ceva.c
@@ -298,12 +298,37 @@ static int ceva_ahci_probe(struct platform_device *pdev)
 
 static int __maybe_unused ceva_ahci_suspend(struct device *dev)
 {
-	return ahci_platform_suspend_host(dev);
+	return ahci_platform_suspend(dev);
 }
 
 static int __maybe_unused ceva_ahci_resume(struct device *dev)
 {
-	return ahci_platform_resume_host(dev);
+	struct ata_host *host = dev_get_drvdata(dev);
+	struct ahci_host_priv *hpriv = host->private_data;
+	int rc;
+
+	rc = ahci_platform_enable_resources(hpriv);
+	if (rc)
+		return rc;
+
+	/* Configure CEVA specific config before resuming HBA */
+	ahci_ceva_setup(hpriv);
+
+	rc = ahci_platform_resume_host(dev);
+	if (rc)
+		goto disable_resources;
+
+	/* We resumed so update PM runtime state */
+	pm_runtime_disable(dev);
+	pm_runtime_set_active(dev);
+	pm_runtime_enable(dev);
+
+	return 0;
+
+disable_resources:
+	ahci_platform_disable_resources(hpriv);
+
+	return rc;
 }
 
 static SIMPLE_DEV_PM_OPS(ahci_ceva_pm_ops, ceva_ahci_suspend, ceva_ahci_resume);
-- 
1.9.1

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

* [PATCH v2 9/9] ata: ceva: Add SMMU support for SATA IP
  2017-08-21 11:17 [PATCH v2 0/9] Ata ceva patches Michal Simek
                   ` (7 preceding siblings ...)
  2017-08-21 11:17 ` [PATCH v2 8/9] ata: ceva: Correct the suspend and resume logic for SATA Michal Simek
@ 2017-08-21 11:17 ` Michal Simek
  2017-10-23 14:10 ` [PATCH v2 0/9] Ata ceva patches Tejun Heo
  9 siblings, 0 replies; 15+ messages in thread
From: Michal Simek @ 2017-08-21 11:17 UTC (permalink / raw)
  To: linux-kernel, monstr
  Cc: Alexander Graf, Rob Herring, Anurag Kumar Vulisha, Tejun Heo,
	linux-ide

From: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>

AXI master interface in CEVA AHCI controller requires two unique
Write/Read ID tags per port. This is because, ahci controller uses
different AXI ID[3:0] bits for identifying non-data transfers(like
reading descriptors, updating PRD tables, etc) and data transfers
(like sending/receiving FIS).To make SMMU work with SATA we need to
add correct SMMU stream id for SATA. SMMU stream id for SATA is
determined based on the AXI ID[1:0] as shown below

	SATA SMMU ID =  <TBU number>, 0011, 00, 00, AXI ID[1:0]
	Note: SATA in  ZynqMp uses TBU1 so TBU number = 0x1, so
	      SMMU ID = 001, 0011, 00, 00, AXI ID[1:0]

Since we have four different AXI ID[3:0] (2 for port0 & 2 for port1
as said above) we get four different SMMU stream id's combinations
for SATA. These AXI ID can be configured using PAXIC register.
In this patch we assumed the below AXI ID values

 Read ID/ Write ID for Non-Data Port0 transfers = 0
 Read ID/ Write ID for Data Port0 transfers = 1
 Read ID/ Write ID for Non-Data Port1 transfers = 2
 Read ID/ Write ID for Data Port1 transfers = 3

Based on the above values,SMMU stream ID's for SATA will be 0x4c0 &
0x4c1 for PORT0, 0x4c2 & 0x4c3 for PORT1. These values needed to be
added to iommus dts property. This patch does the same.

Signed-off-by: Anurag Kumar Vulisha <anuragku@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

Changes in v2: None

 drivers/ata/ahci_ceva.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/ata/ahci_ceva.c b/drivers/ata/ahci_ceva.c
index c0742cbe4faa..5ecc9d46cb54 100644
--- a/drivers/ata/ahci_ceva.c
+++ b/drivers/ata/ahci_ceva.c
@@ -38,8 +38,10 @@
 
 /* Vendor Specific Register bit definitions */
 #define PAXIC_ADBW_BW64 0x1
-#define PAXIC_MAWIDD	(1 << 8)
-#define PAXIC_MARIDD	(1 << 16)
+#define PAXIC_MAWID(i)	(((i) * 2) << 4)
+#define PAXIC_MARID(i)	(((i) * 2) << 12)
+#define PAXIC_MARIDD(i)	((((i) * 2) + 1) << 16)
+#define PAXIC_MAWIDD(i)	((((i) * 2) + 1) << 8)
 #define PAXIC_OTL	(0x4 << 20)
 
 /* Register bit definitions for cache control */
@@ -147,9 +149,11 @@ static void ahci_ceva_setup(struct ahci_host_priv *hpriv)
 		/*
 		 * AXI Data bus width to 64
 		 * Set Mem Addr Read, Write ID for data transfers
+		 * Set Mem Addr Read ID, Write ID for non-data transfers
 		 * Transfer limit to 72 DWord
 		 */
-		tmp = PAXIC_ADBW_BW64 | PAXIC_MAWIDD | PAXIC_MARIDD | PAXIC_OTL;
+		tmp = PAXIC_ADBW_BW64 | PAXIC_MAWIDD(i) | PAXIC_MARIDD(i) |
+			PAXIC_MAWID(i) | PAXIC_MARID(i) | PAXIC_OTL;
 		writel(tmp, mmio + AHCI_VEND_PAXIC);
 
 		/* Set AXI cache control register if CCi is enabled */
-- 
1.9.1

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

* Re: [PATCH v2 1/9] devicetree: bindings: Add sata port phy config parameters in ahci-ceva
  2017-08-21 11:17 ` [PATCH v2 1/9] devicetree: bindings: Add sata port phy config parameters in ahci-ceva Michal Simek
@ 2017-08-23  0:41   ` Rob Herring
  0 siblings, 0 replies; 15+ messages in thread
From: Rob Herring @ 2017-08-23  0:41 UTC (permalink / raw)
  To: Michal Simek
  Cc: linux-kernel, monstr, Alexander Graf, Anurag Kumar Vulisha,
	Tejun Heo, devicetree, linux-ide, Mark Rutland

On Mon, Aug 21, 2017 at 01:17:16PM +0200, Michal Simek wrote:
> From: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
> 
> This patch adds device tree bindings for sata port phy parameters
> in the ahci-ceva.txt file.
> 
> Signed-off-by: Anurag Kumar Vulisha <anuragku@xilinx.com>
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> ---
> 
> Changes in v2:
> - DT fix naming in parameters description use pN instead of phy
>   reported by Rob
> 
>  .../devicetree/bindings/ata/ahci-ceva.txt          | 39 ++++++++++++++++++++++
>  1 file changed, 39 insertions(+)

Acked-by: Rob Herring <robh@kernel.org>

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

* Re: [PATCH v2 2/9] ata: ceva: Move sata port phy oob settings to device-tree
  2017-08-21 11:17 ` [PATCH v2 2/9] ata: ceva: Move sata port phy oob settings to device-tree Michal Simek
@ 2017-10-20 10:42   ` Michal Simek
  2017-10-21 15:19   ` Tejun Heo
  1 sibling, 0 replies; 15+ messages in thread
From: Michal Simek @ 2017-10-20 10:42 UTC (permalink / raw)
  To: Michal Simek, linux-kernel, Tejun Heo
  Cc: Alexander Graf, Rob Herring, Anurag Kumar Vulisha, linux-ide


[-- Attachment #1.1: Type: text/plain, Size: 1109 bytes --]

Hi Tejun,

On 21.8.2017 13:17, Michal Simek wrote:
> From: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
> 
> In SATA Speed negotiation happens with  OOB(Out of Band) signals. These OOB
> signal timing values are configured through vendor specific registers in the
> SATA controller. These OOB timings depends on the generator and detector clock
> frequency, which varies from board to board (ex: ep108 and zc1751 has different
> clock frequencies).
> To avoid maintaing these OOB settings in the driver, it is better to move these
> settings to the device-tree node and read from the device-tree.
> 
> This patch does the same.
> 
> Signed-off-by: Anurag Kumar Vulisha <anuragku@xilinx.com>
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>

Can you please look at these patches?

Thanks,
Michal

-- 
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Xilinx Microblaze
Maintainer of Linux kernel - Xilinx Zynq ARM and ZynqMP ARM64 SoCs
U-Boot custodian - Xilinx Microblaze/Zynq/ZynqMP SoCs



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: [PATCH v2 2/9] ata: ceva: Move sata port phy oob settings to device-tree
  2017-08-21 11:17 ` [PATCH v2 2/9] ata: ceva: Move sata port phy oob settings to device-tree Michal Simek
  2017-10-20 10:42   ` Michal Simek
@ 2017-10-21 15:19   ` Tejun Heo
       [not found]     ` <CAHTX3d+cdPBBp-MYHZVQ1RYoHVzfBXqhU+a9dzAbEQ6wgAUC7A@mail.gmail.com>
  1 sibling, 1 reply; 15+ messages in thread
From: Tejun Heo @ 2017-10-21 15:19 UTC (permalink / raw)
  To: Michal Simek
  Cc: linux-kernel, monstr, Alexander Graf, Rob Herring,
	Anurag Kumar Vulisha, linux-ide

On Mon, Aug 21, 2017 at 01:17:17PM +0200, Michal Simek wrote:
> From: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
> 
> In SATA Speed negotiation happens with  OOB(Out of Band) signals. These OOB
> signal timing values are configured through vendor specific registers in the
> SATA controller. These OOB timings depends on the generator and detector clock
> frequency, which varies from board to board (ex: ep108 and zc1751 has different
> clock frequencies).
> To avoid maintaing these OOB settings in the driver, it is better to move these
> settings to the device-tree node and read from the device-tree.
> 
> This patch does the same.
> 
> Signed-off-by: Anurag Kumar Vulisha <anuragku@xilinx.com>
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>

Applied to libata/for-4.15.

Thanks.

-- 
tejun

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

* Re: [PATCH v2 0/9] Ata ceva patches
  2017-08-21 11:17 [PATCH v2 0/9] Ata ceva patches Michal Simek
                   ` (8 preceding siblings ...)
  2017-08-21 11:17 ` [PATCH v2 9/9] ata: ceva: Add SMMU support for SATA IP Michal Simek
@ 2017-10-23 14:10 ` Tejun Heo
  9 siblings, 0 replies; 15+ messages in thread
From: Tejun Heo @ 2017-10-23 14:10 UTC (permalink / raw)
  To: Michal Simek
  Cc: linux-kernel, monstr, Alexander Graf, Rob Herring, devicetree,
	linux-ide, Rob Herring, Mark Rutland

On Mon, Aug 21, 2017 at 01:17:15PM +0200, Michal Simek wrote:
> Hi,
> 
> this patchset contains the latest changes which are available in Xilinx tree.

Applied 1-9 to libata/for-4.15.

Thanks.

-- 
tejun

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

* Re: [PATCH v2 2/9] ata: ceva: Move sata port phy oob settings to device-tree
       [not found]     ` <CAHTX3d+cdPBBp-MYHZVQ1RYoHVzfBXqhU+a9dzAbEQ6wgAUC7A@mail.gmail.com>
@ 2017-10-23 14:10       ` Tejun Heo
  0 siblings, 0 replies; 15+ messages in thread
From: Tejun Heo @ 2017-10-23 14:10 UTC (permalink / raw)
  To: Michal Simek
  Cc: LKML, Alexander Graf, Rob Herring, Anurag Kumar Vulisha,
	linux-ide

On Sun, Oct 22, 2017 at 07:08:49PM +0200, Michal Simek wrote:
> Thanks for applying this patch. Can you please look at all patches in this
> series?
> All of them should go via your tree even DT binding doc.
> (I see only this one applied).

Oops, sorry about that.  Reverted the commit and reapplied the whole
series.

Thanks.

-- 
tejun

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

end of thread, other threads:[~2017-10-23 14:10 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-21 11:17 [PATCH v2 0/9] Ata ceva patches Michal Simek
2017-08-21 11:17 ` [PATCH v2 1/9] devicetree: bindings: Add sata port phy config parameters in ahci-ceva Michal Simek
2017-08-23  0:41   ` Rob Herring
2017-08-21 11:17 ` [PATCH v2 2/9] ata: ceva: Move sata port phy oob settings to device-tree Michal Simek
2017-10-20 10:42   ` Michal Simek
2017-10-21 15:19   ` Tejun Heo
     [not found]     ` <CAHTX3d+cdPBBp-MYHZVQ1RYoHVzfBXqhU+a9dzAbEQ6wgAUC7A@mail.gmail.com>
2017-10-23 14:10       ` Tejun Heo
2017-08-21 11:17 ` [PATCH v2 3/9] ata: ceva: Add gen 3 mode support in driver Michal Simek
2017-08-21 11:17 ` [PATCH v2 4/9] ata: ceva: Disable Device Sleep capability Michal Simek
2017-08-21 11:17 ` [PATCH v2 5/9] ata: ceva: Make RxWaterMark value as module parameter Michal Simek
2017-08-21 11:17 ` [PATCH v2 6/9] ata: ceva: Add CCI support for SATA if CCI is enabled Michal Simek
2017-08-21 11:17 ` [PATCH v2 7/9] ata: ceva: Correct the AXI bus configuration for SATA ports Michal Simek
2017-08-21 11:17 ` [PATCH v2 8/9] ata: ceva: Correct the suspend and resume logic for SATA Michal Simek
2017-08-21 11:17 ` [PATCH v2 9/9] ata: ceva: Add SMMU support for SATA IP Michal Simek
2017-10-23 14:10 ` [PATCH v2 0/9] Ata ceva patches Tejun Heo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox