Skip to contentSkip to conversation

scsi: ceva: Clean up the driver code

PATCH New Peng Ma 2 participants 16 messages Apr 16, 2019 – Apr 17, 2019

Subsystems (3)
lore
Share & tools
lore

Peng Ma

author
#0 lore raw

PATCH 1/2 scsi: ceva: Clean up the driver code

Distinguish the ecc val by chassis version and move the ecc addr to dts. Add ls1028a soc support.

---
 drivers/ata/sata_ceva.c |   43 +++++++++++++++++++++++++------------------
 1 files changed, 25 insertions(+), 18 deletions(-)
drivers/ata/sata_ceva.c +25 -18
index 8887be9..d26f712 100644
@@ -88,20 +88,16 @@
 #define LS1021_CEVA_PHY4_CFG	0x064a080b
 #define LS1021_CEVA_PHY5_CFG	0x2aa86470
 
-/* for ls1088a */
-#define LS1088_ECC_DIS_ADDR_CH2	0x100520
-#define LS1088_ECC_DIS_VAL_CH2	0x40000000
-
-/* ecc addr-val pair */
-#define ECC_DIS_ADDR_CH2	0x20140520
+/* ecc val pair */
+#define ECC_DIS_VAL_CH1		0x00020000
 #define ECC_DIS_VAL_CH2		0x80000000
-#define SATA_ECC_REG_ADDR	0x20220520
-#define SATA_ECC_DISABLE	0x00020000
+#define ECC_DIS_VAL_CH3		0x40000000
 
 enum ceva_soc {
 	CEVA_1V84,
 	CEVA_LS1012A,
 	CEVA_LS1021A,
+	CEVA_LS1028A,
 	CEVA_LS1043A,
 	CEVA_LS1046A,
 	CEVA_LS1088A,
@@ -110,12 +106,14 @@ enum ceva_soc {
 
 struct ceva_sata_priv {
 	ulong base;
+	ulong ecc_base;
 	enum ceva_soc soc;
 	ulong flag;
 };
 
 static int ceva_init_sata(struct ceva_sata_priv *priv)
 {
+	ulong ecc_addr = priv->ecc_base;
 	ulong base = priv->base;
 	ulong tmp;
 
@@ -132,38 +130,38 @@ static int ceva_init_sata(struct ceva_sata_priv *priv)
 		break;
 
 	case CEVA_LS1021A:
-		writel(SATA_ECC_DISABLE, SATA_ECC_REG_ADDR);
+		if (ecc_addr)
+			writel(ECC_DIS_VAL_CH1, ecc_addr);
 		writel(CEVA_PHY1_CFG, base + AHCI_VEND_PPCFG);
 		writel(LS1021_CEVA_PHY2_CFG, base + AHCI_VEND_PP2C);
 		writel(LS1021_CEVA_PHY3_CFG, base + AHCI_VEND_PP3C);
 		writel(LS1021_CEVA_PHY4_CFG, base + AHCI_VEND_PP4C);
 		writel(LS1021_CEVA_PHY5_CFG, base + AHCI_VEND_PP5C);
 		writel(CEVA_TRANS_CFG, base + AHCI_VEND_PTC);
-		if (priv->flag & FLAG_COHERENT)
-			writel(CEVA_AXICC_CFG, base + LS1021_AHCI_VEND_AXICC);
 		break;
 
 	case CEVA_LS1012A:
 	case CEVA_LS1043A:
 	case CEVA_LS1046A:
-		writel(ECC_DIS_VAL_CH2, ECC_DIS_ADDR_CH2);
-		/* fallthrough */
 	case CEVA_LS2080A:
+		if (ecc_addr)
+			writel(ECC_DIS_VAL_CH2, ecc_addr);
 		writel(CEVA_PHY1_CFG, base + AHCI_VEND_PPCFG);
 		writel(CEVA_TRANS_CFG, base + AHCI_VEND_PTC);
-		if (priv->flag & FLAG_COHERENT)
-			writel(CEVA_AXICC_CFG, base + AHCI_VEND_AXICC);
 		break;
 
+	case CEVA_LS1028A:
 	case CEVA_LS1088A:
-		writel(LS1088_ECC_DIS_VAL_CH2, LS1088_ECC_DIS_ADDR_CH2);
+		if (ecc_addr)
+			writel(ECC_DIS_VAL_CH3, ecc_addr);
 		writel(CEVA_PHY1_CFG, base + AHCI_VEND_PPCFG);
 		writel(CEVA_TRANS_CFG, base + AHCI_VEND_PTC);
-		if (priv->flag & FLAG_COHERENT)
-			writel(CEVA_AXICC_CFG, base + AHCI_VEND_AXICC);
 		break;
 	}
 
+	if (priv->flag & FLAG_COHERENT)
+		writel(CEVA_AXICC_CFG, base + AHCI_VEND_AXICC);
+
 	return 0;
 }
 
@@ -187,6 +185,7 @@ static const struct udevice_id sata_ceva_ids[] = {
 	{ .compatible = "ceva,ahci-1v84", .data = CEVA_1V84 },
 	{ .compatible = "fsl,ls1012a-ahci", .data = CEVA_LS1012A },
 	{ .compatible = "fsl,ls1021a-ahci", .data = CEVA_LS1021A },
+	{ .compatible = "fsl,ls1028a-ahci", .data = CEVA_LS1028A },
 	{ .compatible = "fsl,ls1043a-ahci", .data = CEVA_LS1043A },
 	{ .compatible = "fsl,ls1046a-ahci", .data = CEVA_LS1046A },
 	{ .compatible = "fsl,ls1088a-ahci", .data = CEVA_LS1088A },
@@ -205,8 +204,16 @@ static int sata_ceva_ofdata_to_platdata(struct udevice *dev)
 	if (priv->base == FDT_ADDR_T_NONE)
 		return -EINVAL;
 
+	priv->ecc_base = dev_read_addr_index(dev, 1);
+	if (priv->ecc_base == FDT_ADDR_T_NONE)
+		priv->ecc_base = 0;
+
 	priv->soc = dev_get_driver_data(dev);
 
+	debug("ccsr-sata-base %lx\t ecc-base %lx\n",
+	      priv->base,
+	      priv->ecc_base);
+
 	return 0;
 }
 
Signature · 1 line
1.7.1
author
#1 lore raw

PATCH 2/2 ARM: dts: Freescale: Add ecc addr for sata node

Move the ecc addr from driver to dts.

---
 arch/arm/dts/fsl-ls1012a.dtsi |    3 ++-
 arch/arm/dts/fsl-ls1043a.dtsi |    3 ++-
 arch/arm/dts/fsl-ls1046a.dtsi |    3 ++-
 arch/arm/dts/fsl-ls1088a.dtsi |    2 ++
 arch/arm/dts/ls1021a.dtsi     |    3 ++-
 5 files changed, 10 insertions(+), 4 deletions(-)
arch/arm/dts/fsl-ls1012a.dtsi +2 -1
index f22cbf4..30fe268 100644
@@ -136,7 +136,8 @@
 
 		sata: sata at 3200000 {
 			compatible = "fsl,ls1012a-ahci";
-			reg = <0x0 0x3200000 0x0 0x10000>;
+			reg = <0x0 0x3200000 0x0 0x10000	/* ccsr sata base */
+			       0x0 0x20140520 0x0 0x4>;		/* ecc sata addr*/
 			interrupts = <0 69 4>;
 			clocks = <&clockgen 4 0>;
 			status = "disabled";
arch/arm/dts/fsl-ls1043a.dtsi +2 -1
index bb70992..3109765 100644
@@ -290,7 +290,8 @@
 
 		sata: sata at 3200000 {
 			compatible = "fsl,ls1043a-ahci";
-			reg = <0x0 0x3200000 0x0 0x10000>;
+			reg = <0x0 0x3200000 0x0 0x10000	/* ccsr sata base */
+			       0x0 0x20140520 0x0 0x4>;		/* ecc sata addr*/
 			interrupts = <0 69 4>;
 			clocks = <&clockgen 4 0>;
 			status = "disabled";
arch/arm/dts/fsl-ls1046a.dtsi +2 -1
index 5ac10e0..e9c8243 100644
@@ -294,7 +294,8 @@
 
 		sata: sata at 3200000 {
 			compatible = "fsl,ls1046a-ahci";
-			reg = <0x0 0x3200000 0x0 0x10000>;
+			reg = <0x0 0x3200000 0x0 0x10000	/* ccsr sata base */
+			       0x0 0x20140520 0x0 0x4>;		/* ecc sata addr*/
 			interrupts = <0 69 4>;
 			clocks = <&clockgen 4 1>;
 			status = "disabled";
arch/arm/dts/fsl-ls1088a.dtsi +2 -0
index 9455e03..6a1cd0d 100644
@@ -154,6 +154,8 @@
 	sata: sata at 3200000 {
 		compatible = "fsl,ls1088a-ahci";
 		reg = <0x0 0x3200000 0x0 0x10000>;
+		reg = <0x0 0x3200000 0x0 0x10000	/* ccsr sata base */
+		       0x7 0x100520  0x0 0x4>;		/* ecc sata addr*/
 		interrupts = <0 133 4>;
 		status = "disabled";
 	};
arch/arm/dts/ls1021a.dtsi +2 -1
index 7670a39..b3d1b07 100644
@@ -406,7 +406,8 @@
 
 		sata: sata at 3200000 {
 			compatible = "fsl,ls1021a-ahci";
-			reg = <0x3200000 0x10000>;
+			reg = <0x0 0x3200000 0x0 0x10000	/* ccsr sata base */
+			       0x0 0x20220520 0x0 0x4>;		/* ecc sata addr*/
 			interrupts = <0 101 4>;
 			status = "disabled";
 		};
Signature · 1 line
1.7.1
#2 lore raw

PATCH 1/2 scsi: ceva: Clean up the driver code

In reply to Peng Ma
Quoted 110 lines · Peng Ma

Distinguish the ecc val by chassis version and move the ecc addr to dts. Add ls1028a soc support.

---
 drivers/ata/sata_ceva.c |   43 +++++++++++++++++++++++++------------------
 1 files changed, 25 insertions(+), 18 deletions(-)
drivers/ata/sata_ceva.c +17 -18
index 8887be9..d26f712 100644
@@ -88,20 +88,16 @@
 #define LS1021_CEVA_PHY4_CFG	0x064a080b
 #define LS1021_CEVA_PHY5_CFG	0x2aa86470
 
-/* for ls1088a */
-#define LS1088_ECC_DIS_ADDR_CH2	0x100520
-#define LS1088_ECC_DIS_VAL_CH2	0x40000000
-
-/* ecc addr-val pair */
-#define ECC_DIS_ADDR_CH2	0x20140520
+/* ecc val pair */
+#define ECC_DIS_VAL_CH1		0x00020000
 #define ECC_DIS_VAL_CH2		0x80000000
-#define SATA_ECC_REG_ADDR	0x20220520
-#define SATA_ECC_DISABLE	0x00020000
+#define ECC_DIS_VAL_CH3		0x40000000
 
 enum ceva_soc {
 	CEVA_1V84,
 	CEVA_LS1012A,
 	CEVA_LS1021A,
+	CEVA_LS1028A,
 	CEVA_LS1043A,
 	CEVA_LS1046A,
 	CEVA_LS1088A,
@@ -110,12 +106,14 @@ enum ceva_soc {
 
 struct ceva_sata_priv {
 	ulong base;
+	ulong ecc_base;
 	enum ceva_soc soc;
 	ulong flag;
 };
 
 static int ceva_init_sata(struct ceva_sata_priv *priv)
 {
+	ulong ecc_addr = priv->ecc_base;
 	ulong base = priv->base;
 	ulong tmp;
 
@@ -132,38 +130,38 @@ static int ceva_init_sata(struct ceva_sata_priv *priv)
 		break;
 
 	case CEVA_LS1021A:
-		writel(SATA_ECC_DISABLE, SATA_ECC_REG_ADDR);
+		if (ecc_addr)
+			writel(ECC_DIS_VAL_CH1, ecc_addr);
 		writel(CEVA_PHY1_CFG, base + AHCI_VEND_PPCFG);
 		writel(LS1021_CEVA_PHY2_CFG, base + AHCI_VEND_PP2C);
 		writel(LS1021_CEVA_PHY3_CFG, base + AHCI_VEND_PP3C);
 		writel(LS1021_CEVA_PHY4_CFG, base + AHCI_VEND_PP4C);
 		writel(LS1021_CEVA_PHY5_CFG, base + AHCI_VEND_PP5C);
 		writel(CEVA_TRANS_CFG, base + AHCI_VEND_PTC);
-		if (priv->flag & FLAG_COHERENT)
-			writel(CEVA_AXICC_CFG, base + LS1021_AHCI_VEND_AXICC);
 		break;
 
 	case CEVA_LS1012A:
 	case CEVA_LS1043A:
 	case CEVA_LS1046A:
-		writel(ECC_DIS_VAL_CH2, ECC_DIS_ADDR_CH2);
-		/* fallthrough */
 	case CEVA_LS2080A:
+		if (ecc_addr)
+			writel(ECC_DIS_VAL_CH2, ecc_addr);
 		writel(CEVA_PHY1_CFG, base + AHCI_VEND_PPCFG);
 		writel(CEVA_TRANS_CFG, base + AHCI_VEND_PTC);
-		if (priv->flag & FLAG_COHERENT)
-			writel(CEVA_AXICC_CFG, base + AHCI_VEND_AXICC);
 		break;
 
+	case CEVA_LS1028A:
 	case CEVA_LS1088A:
-		writel(LS1088_ECC_DIS_VAL_CH2, LS1088_ECC_DIS_ADDR_CH2);
+		if (ecc_addr)
+			writel(ECC_DIS_VAL_CH3, ecc_addr);
 		writel(CEVA_PHY1_CFG, base + AHCI_VEND_PPCFG);
 		writel(CEVA_TRANS_CFG, base + AHCI_VEND_PTC);
-		if (priv->flag & FLAG_COHERENT)
-			writel(CEVA_AXICC_CFG, base + AHCI_VEND_AXICC);
 		break;
 	}
 
+	if (priv->flag & FLAG_COHERENT)
+		writel(CEVA_AXICC_CFG, base + AHCI_VEND_AXICC);
+
 	return 0;
 }
 
@@ -187,6 +185,7 @@ static const struct udevice_id sata_ceva_ids[] = {
 	{ .compatible = "ceva,ahci-1v84", .data = CEVA_1V84 },
 	{ .compatible = "fsl,ls1012a-ahci", .data = CEVA_LS1012A },
 	{ .compatible = "fsl,ls1021a-ahci", .data = CEVA_LS1021A },
+	{ .compatible = "fsl,ls1028a-ahci", .data = CEVA_LS1028A },
 	{ .compatible = "fsl,ls1043a-ahci", .data = CEVA_LS1043A },
 	{ .compatible = "fsl,ls1046a-ahci", .data = CEVA_LS1046A },
 	{ .compatible = "fsl,ls1088a-ahci", .data = CEVA_LS1088A },

drivers/ata/sata_ceva.c static int sata_ceva_ofdata_to_platdata(struct udevice *dev) · line 207

Quoted 4 lines
drivers/ata/sata_ceva.c +1 -0
@@ -205,8 +204,16 @@ static int sata_ceva_ofdata_to_platdata(struct udevice *dev)
 	if (priv->base == FDT_ADDR_T_NONE)
 		return -EINVAL;
 
+	priv->ecc_base = dev_read_addr_index(dev, 1);

It would be better to do it via reg-name instead of index. But that's up to your binding doc.

Thanks,
Michal

author
#3 lore raw
Quoted 139 lines

-----Original Message-----
From: Michal Simek <[email protected]>
Sent: 2019年4月16日 16:04
To: Peng Ma <[email protected]>; albert.u.boot at aribaud.net; sjg at chromium.org; Fabio Estevam <[email protected]>; York Sun <[email protected]>; Prabhakar Kushwaha <[email protected]>
Cc: Andy Tang <[email protected]>; Yinbo Zhu <[email protected]>; michal.simek at xilinx.com; u-boot at lists.denx.de
Subject: [EXT] Re: [PATCH 1/2] scsi: ceva: Clean up the driver code

WARNING: This email was created outside of NXP. DO NOT CLICK links or attachments unless you recognize the sender and know the content is safe.

Quoted 6 lines · Peng Ma

Distinguish the ecc val by chassis version and move the ecc addr to dts. Add ls1028a soc support.

---
 drivers/ata/sata_ceva.c |   43

+++++++++++++++++++++++++------------------

drivers/ata/sata_ceva.c line 88

Quoted 8 lines
 1 files changed, 25 insertions(+), 18 deletions(-)
drivers/ata/sata_ceva.c index renamed from drivers/ata/sata_ceva.c +0 -0

8887be9..d26f712 100644

drivers/ata/sata_ceva.c +0 -0
@@ -88,20 +88,16 @@
 #define LS1021_CEVA_PHY4_CFG 0x064a080b  #define

LS1021_CEVA_PHY5_CFG

drivers/ata/sata_ceva.c static int ceva_init_sata(struct ceva_sata_priv

Quoted 38 lines

0x2aa86470

drivers/ata/sata_ceva.c +6 -8
-/* for ls1088a */
-#define LS1088_ECC_DIS_ADDR_CH2      0x100520
-#define LS1088_ECC_DIS_VAL_CH2       0x40000000
-
-/* ecc addr-val pair */
-#define ECC_DIS_ADDR_CH2     0x20140520
+/* ecc val pair */
+#define ECC_DIS_VAL_CH1              0x00020000
 #define ECC_DIS_VAL_CH2              0x80000000
-#define SATA_ECC_REG_ADDR    0x20220520
-#define SATA_ECC_DISABLE     0x00020000
+#define ECC_DIS_VAL_CH3              0x40000000
 
 enum ceva_soc {
      CEVA_1V84,
      CEVA_LS1012A,
      CEVA_LS1021A,
+     CEVA_LS1028A,
      CEVA_LS1043A,
      CEVA_LS1046A,
      CEVA_LS1088A,
@@ -110,12 +106,14 @@ enum ceva_soc {
 
 struct ceva_sata_priv {
      ulong base;
+     ulong ecc_base;
      enum ceva_soc soc;
      ulong flag;
 };
 
 static int ceva_init_sata(struct ceva_sata_priv *priv)  {
+     ulong ecc_addr = priv->ecc_base;
      ulong base = priv->base;
      ulong tmp;
 
@@ -132,38 +130,38 @@ static int ceva_init_sata(struct ceva_sata_priv

*priv)

drivers/ata/sata_ceva.c static int ceva_init_sata(struct ceva_sata_priv · line 136

Quoted 8 lines
drivers/ata/sata_ceva.c +2 -1
              break;
 
      case CEVA_LS1021A:
-             writel(SATA_ECC_DISABLE, SATA_ECC_REG_ADDR);
+             if (ecc_addr)
+                     writel(ECC_DIS_VAL_CH1, ecc_addr);
              writel(CEVA_PHY1_CFG, base + AHCI_VEND_PPCFG);
              writel(LS1021_CEVA_PHY2_CFG, base +

AHCI_VEND_PP2C);

drivers/ata/sata_ceva.c static int ceva_init_sata(struct ceva_sata_priv · line 137

Quoted 1 line
drivers/ata/sata_ceva.c +0 -0
              writel(LS1021_CEVA_PHY3_CFG, base +

AHCI_VEND_PP3C);

drivers/ata/sata_ceva.c static int ceva_init_sata(struct ceva_sata_priv · line 138

Quoted 1 line
drivers/ata/sata_ceva.c +0 -0
              writel(LS1021_CEVA_PHY4_CFG, base +

AHCI_VEND_PP4C);

drivers/ata/sata_ceva.c static int ceva_init_sata(struct ceva_sata_priv · line 139

Quoted 1 line
drivers/ata/sata_ceva.c +0 -0
              writel(LS1021_CEVA_PHY5_CFG, base +

AHCI_VEND_PP5C);

drivers/ata/sata_ceva.c static int ceva_init_sata(struct ceva_sata_priv · line 143

Quoted 3 lines
drivers/ata/sata_ceva.c +0 -2
              writel(CEVA_TRANS_CFG, base + AHCI_VEND_PTC);
-             if (priv->flag & FLAG_COHERENT)
-                     writel(CEVA_AXICC_CFG, base +

LS1021_AHCI_VEND_AXICC);

Quoted 4 lines
drivers/ata/sata_ceva.c +0 -0
              break;
 
      case CEVA_LS1012A:
      case CEVA_LS1043A:

drivers/ata/sata_ceva.c static int ceva_init_sata(struct ceva_sata_priv · line 155

Quoted 10 lines
drivers/ata/sata_ceva.c +2 -4
      case CEVA_LS1046A:
-             writel(ECC_DIS_VAL_CH2, ECC_DIS_ADDR_CH2);
-             /* fallthrough */
      case CEVA_LS2080A:
+             if (ecc_addr)
+                     writel(ECC_DIS_VAL_CH2, ecc_addr);
              writel(CEVA_PHY1_CFG, base + AHCI_VEND_PPCFG);
              writel(CEVA_TRANS_CFG, base + AHCI_VEND_PTC);
-             if (priv->flag & FLAG_COHERENT)
-                     writel(CEVA_AXICC_CFG, base +

AHCI_VEND_AXICC);

drivers/ata/sata_ceva.c static int ceva_init_sata(struct ceva_sata_priv · line 159

Quoted 5 lines
drivers/ata/sata_ceva.c +1 -1
              break;
 
+     case CEVA_LS1028A:
      case CEVA_LS1088A:
-             writel(LS1088_ECC_DIS_VAL_CH2,

LS1088_ECC_DIS_ADDR_CH2);

drivers/ata/sata_ceva.c static int ceva_init_sata(struct ceva_sata_priv · line 163

Quoted 6 lines
drivers/ata/sata_ceva.c +2 -2
+             if (ecc_addr)
+                     writel(ECC_DIS_VAL_CH3, ecc_addr);
              writel(CEVA_PHY1_CFG, base + AHCI_VEND_PPCFG);
              writel(CEVA_TRANS_CFG, base + AHCI_VEND_PTC);
-             if (priv->flag & FLAG_COHERENT)
-                     writel(CEVA_AXICC_CFG, base +

AHCI_VEND_AXICC);

Quoted 10 lines
drivers/ata/sata_ceva.c +3 -0
              break;
      }
 
+     if (priv->flag & FLAG_COHERENT)
+             writel(CEVA_AXICC_CFG, base + AHCI_VEND_AXICC);
+
      return 0;
 }
 

drivers/ata/sata_ceva.c static const struct udevice_id sata_ceva_ids[] = {

Quoted 8 lines
drivers/ata/sata_ceva.c +1 -1
@@ -187,6 +185,7 @@ static const struct udevice_id sata_ceva_ids[] = {
      { .compatible = "ceva,ahci-1v84", .data = CEVA_1V84 },
      { .compatible = "fsl,ls1012a-ahci", .data = CEVA_LS1012A },
      { .compatible = "fsl,ls1021a-ahci", .data = CEVA_LS1021A },
+     { .compatible = "fsl,ls1028a-ahci", .data = CEVA_LS1028A },
      { .compatible = "fsl,ls1043a-ahci", .data = CEVA_LS1043A },
      { .compatible = "fsl,ls1046a-ahci", .data = CEVA_LS1046A },
      { .compatible = "fsl,ls1088a-ahci", .data = CEVA_LS1088A }, @@
-205,8 +204,16 @@ static int sata_ceva_ofdata_to_platdata(struct udevice

*dev)

Quoted 8 lines
Quoted 4 lines
      if (priv->base == FDT_ADDR_T_NONE)
              return -EINVAL;

+ priv->ecc_base = dev_read_addr_index(dev, 1);

It would be better to do it via reg-name instead of index. But that's up to your binding doc.

[Peng Ma] OK, could I change arch/arm/dts/zynqmp.dtsi file sata node as fallows?

arch/arm/dts/zynqmp.dtsi +1 -0
index dfb6ebc..9ad2d84 100644
@@ -692,6 +692,7 @@
                        compatible = "ceva,ahci-1v84";
                        status = "disabled";
                        reg = <0x0 0xfd0c0000 0x0 0x2000>;
+                       reg-names = "serdes";
                        interrupt-parent = <&gic>;
                        interrupts = <0 133 4>;
                        #stream-id-cells = <4>; 

Best Regards,
Peng

Quoted 2 lines

Thanks,
Michal

#4 lore raw
Quoted 154 lines · Peng Ma
Quoted 139 lines

-----Original Message-----
From: Michal Simek <[email protected]>
Sent: 2019年4月16日 16:04
To: Peng Ma <[email protected]>; albert.u.boot at aribaud.net; sjg at chromium.org; Fabio Estevam <[email protected]>; York Sun <[email protected]>; Prabhakar Kushwaha <[email protected]>
Cc: Andy Tang <[email protected]>; Yinbo Zhu <[email protected]>; michal.simek at xilinx.com; u-boot at lists.denx.de
Subject: [EXT] Re: [PATCH 1/2] scsi: ceva: Clean up the driver code

WARNING: This email was created outside of NXP. DO NOT CLICK links or attachments unless you recognize the sender and know the content is safe.

Quoted 6 lines · Peng Ma

Distinguish the ecc val by chassis version and move the ecc addr to dts. Add ls1028a soc support.

---
 drivers/ata/sata_ceva.c |   43

+++++++++++++++++++++++++------------------

drivers/ata/sata_ceva.c line 88

Quoted 8 lines
 1 files changed, 25 insertions(+), 18 deletions(-)
drivers/ata/sata_ceva.c index renamed from drivers/ata/sata_ceva.c +0 -0

8887be9..d26f712 100644

drivers/ata/sata_ceva.c +0 -0
@@ -88,20 +88,16 @@
 #define LS1021_CEVA_PHY4_CFG 0x064a080b  #define

LS1021_CEVA_PHY5_CFG

drivers/ata/sata_ceva.c static int ceva_init_sata(struct ceva_sata_priv

Quoted 38 lines

0x2aa86470

drivers/ata/sata_ceva.c +6 -8
-/* for ls1088a */
-#define LS1088_ECC_DIS_ADDR_CH2      0x100520
-#define LS1088_ECC_DIS_VAL_CH2       0x40000000
-
-/* ecc addr-val pair */
-#define ECC_DIS_ADDR_CH2     0x20140520
+/* ecc val pair */
+#define ECC_DIS_VAL_CH1              0x00020000
 #define ECC_DIS_VAL_CH2              0x80000000
-#define SATA_ECC_REG_ADDR    0x20220520
-#define SATA_ECC_DISABLE     0x00020000
+#define ECC_DIS_VAL_CH3              0x40000000
 
 enum ceva_soc {
      CEVA_1V84,
      CEVA_LS1012A,
      CEVA_LS1021A,
+     CEVA_LS1028A,
      CEVA_LS1043A,
      CEVA_LS1046A,
      CEVA_LS1088A,
@@ -110,12 +106,14 @@ enum ceva_soc {
 
 struct ceva_sata_priv {
      ulong base;
+     ulong ecc_base;
      enum ceva_soc soc;
      ulong flag;
 };
 
 static int ceva_init_sata(struct ceva_sata_priv *priv)  {
+     ulong ecc_addr = priv->ecc_base;
      ulong base = priv->base;
      ulong tmp;
 
@@ -132,38 +130,38 @@ static int ceva_init_sata(struct ceva_sata_priv

*priv)

drivers/ata/sata_ceva.c static int ceva_init_sata(struct ceva_sata_priv · line 136

Quoted 8 lines
drivers/ata/sata_ceva.c +2 -1
              break;
 
      case CEVA_LS1021A:
-             writel(SATA_ECC_DISABLE, SATA_ECC_REG_ADDR);
+             if (ecc_addr)
+                     writel(ECC_DIS_VAL_CH1, ecc_addr);
              writel(CEVA_PHY1_CFG, base + AHCI_VEND_PPCFG);
              writel(LS1021_CEVA_PHY2_CFG, base +

AHCI_VEND_PP2C);

drivers/ata/sata_ceva.c static int ceva_init_sata(struct ceva_sata_priv · line 137

Quoted 1 line
drivers/ata/sata_ceva.c +0 -0
              writel(LS1021_CEVA_PHY3_CFG, base +

AHCI_VEND_PP3C);

drivers/ata/sata_ceva.c static int ceva_init_sata(struct ceva_sata_priv · line 138

Quoted 1 line
drivers/ata/sata_ceva.c +0 -0
              writel(LS1021_CEVA_PHY4_CFG, base +

AHCI_VEND_PP4C);

drivers/ata/sata_ceva.c static int ceva_init_sata(struct ceva_sata_priv · line 139

Quoted 1 line
drivers/ata/sata_ceva.c +0 -0
              writel(LS1021_CEVA_PHY5_CFG, base +

AHCI_VEND_PP5C);

drivers/ata/sata_ceva.c static int ceva_init_sata(struct ceva_sata_priv · line 143

Quoted 3 lines
drivers/ata/sata_ceva.c +0 -2
              writel(CEVA_TRANS_CFG, base + AHCI_VEND_PTC);
-             if (priv->flag & FLAG_COHERENT)
-                     writel(CEVA_AXICC_CFG, base +

LS1021_AHCI_VEND_AXICC);

Quoted 4 lines
drivers/ata/sata_ceva.c +0 -0
              break;
 
      case CEVA_LS1012A:
      case CEVA_LS1043A:

drivers/ata/sata_ceva.c static int ceva_init_sata(struct ceva_sata_priv · line 155

Quoted 10 lines
drivers/ata/sata_ceva.c +2 -4
      case CEVA_LS1046A:
-             writel(ECC_DIS_VAL_CH2, ECC_DIS_ADDR_CH2);
-             /* fallthrough */
      case CEVA_LS2080A:
+             if (ecc_addr)
+                     writel(ECC_DIS_VAL_CH2, ecc_addr);
              writel(CEVA_PHY1_CFG, base + AHCI_VEND_PPCFG);
              writel(CEVA_TRANS_CFG, base + AHCI_VEND_PTC);
-             if (priv->flag & FLAG_COHERENT)
-                     writel(CEVA_AXICC_CFG, base +

AHCI_VEND_AXICC);

drivers/ata/sata_ceva.c static int ceva_init_sata(struct ceva_sata_priv · line 159

Quoted 5 lines
drivers/ata/sata_ceva.c +1 -1
              break;
 
+     case CEVA_LS1028A:
      case CEVA_LS1088A:
-             writel(LS1088_ECC_DIS_VAL_CH2,

LS1088_ECC_DIS_ADDR_CH2);

drivers/ata/sata_ceva.c static int ceva_init_sata(struct ceva_sata_priv · line 163

Quoted 6 lines
drivers/ata/sata_ceva.c +2 -2
+             if (ecc_addr)
+                     writel(ECC_DIS_VAL_CH3, ecc_addr);
              writel(CEVA_PHY1_CFG, base + AHCI_VEND_PPCFG);
              writel(CEVA_TRANS_CFG, base + AHCI_VEND_PTC);
-             if (priv->flag & FLAG_COHERENT)
-                     writel(CEVA_AXICC_CFG, base +

AHCI_VEND_AXICC);

Quoted 10 lines
drivers/ata/sata_ceva.c +3 -0
              break;
      }
 
+     if (priv->flag & FLAG_COHERENT)
+             writel(CEVA_AXICC_CFG, base + AHCI_VEND_AXICC);
+
      return 0;
 }
 

drivers/ata/sata_ceva.c static const struct udevice_id sata_ceva_ids[] = {

Quoted 8 lines
drivers/ata/sata_ceva.c +1 -1
@@ -187,6 +185,7 @@ static const struct udevice_id sata_ceva_ids[] = {
      { .compatible = "ceva,ahci-1v84", .data = CEVA_1V84 },
      { .compatible = "fsl,ls1012a-ahci", .data = CEVA_LS1012A },
      { .compatible = "fsl,ls1021a-ahci", .data = CEVA_LS1021A },
+     { .compatible = "fsl,ls1028a-ahci", .data = CEVA_LS1028A },
      { .compatible = "fsl,ls1043a-ahci", .data = CEVA_LS1043A },
      { .compatible = "fsl,ls1046a-ahci", .data = CEVA_LS1046A },
      { .compatible = "fsl,ls1088a-ahci", .data = CEVA_LS1088A }, @@
-205,8 +204,16 @@ static int sata_ceva_ofdata_to_platdata(struct udevice

*dev)

Quoted 8 lines
Quoted 4 lines
      if (priv->base == FDT_ADDR_T_NONE)
              return -EINVAL;

+ priv->ecc_base = dev_read_addr_index(dev, 1);

It would be better to do it via reg-name instead of index. But that's up to your binding doc.

[Peng Ma] OK, could I change arch/arm/dts/zynqmp.dtsi file sata node as fallows?

arch/arm/dts/zynqmp.dtsi +0 -0
index dfb6ebc..9ad2d84 100644

arch/arm/dts/zynqmp.dtsi line 698

Quoted 7 lines
arch/arm/dts/zynqmp.dtsi +1 -0
@@ -692,6 +692,7 @@
                        compatible = "ceva,ahci-1v84";
                        status = "disabled";
                        reg = <0x0 0xfd0c0000 0x0 0x2000>;
+                       reg-names = "serdes";
                        interrupt-parent = <&gic>;
                        interrupts = <0 133 4>;
                        #stream-id-cells = <4>; 

Unfortunately it is not that simple.

First of all you need to reflect this in dt binding doc in the kernel.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/devicetree/bindings/ata/ahci-ceva.txt?h=v5.1-rc5

Did you record your compatible strings anywhere?

Thanks,
Michal

author
#5 lore raw
Quoted 196 lines

-----Original Message-----
From: Michal Simek <[email protected]>
Sent: 2019年4月16日 17:31
To: Peng Ma <[email protected]>; Michal Simek <[email protected]>; albert.u.boot at aribaud.net; sjg at chromium.org; Fabio Estevam <[email protected]>; York Sun <[email protected]>; Prabhakar Kushwaha <[email protected]>
Cc: Andy Tang <[email protected]>; Yinbo Zhu <[email protected]>; u-boot at lists.denx.de
Subject: Re: [EXT] Re: [PATCH 1/2] scsi: ceva: Clean up the driver code

WARNING: This email was created outside of NXP. DO NOT CLICK links or attachments unless you recognize the sender and know the content is safe.

Quoted 8 lines · Peng Ma
Quoted 8 lines

-----Original Message-----
From: Michal Simek <[email protected]>
Sent: 2019年4月16日 16:04
To: Peng Ma <[email protected]>; albert.u.boot at aribaud.net; sjg at chromium.org; Fabio Estevam <[email protected]>; York Sun <[email protected]>; Prabhakar Kushwaha

<[email protected]>

Quoted 136 lines
Quoted 136 lines

Cc: Andy Tang <[email protected]>; Yinbo Zhu <[email protected]>; michal.simek at xilinx.com; u-boot at lists.denx.de
Subject: [EXT] Re: [PATCH 1/2] scsi: ceva: Clean up the driver code

WARNING: This email was created outside of NXP. DO NOT CLICK links or attachments unless you recognize the sender and know the content is safe.

Quoted 6 lines · Peng Ma

Distinguish the ecc val by chassis version and move the ecc addr to dts. Add ls1028a soc support.

---
 drivers/ata/sata_ceva.c |   43

+++++++++++++++++++++++++------------------

drivers/ata/sata_ceva.c line 88

Quoted 8 lines
 1 files changed, 25 insertions(+), 18 deletions(-)
drivers/ata/sata_ceva.c index renamed from drivers/ata/sata_ceva.c +0 -0

8887be9..d26f712 100644

drivers/ata/sata_ceva.c +0 -0
@@ -88,20 +88,16 @@
 #define LS1021_CEVA_PHY4_CFG 0x064a080b  #define

LS1021_CEVA_PHY5_CFG

Quoted 38 lines

0x2aa86470

drivers/ata/sata_ceva.c +6 -8
-/* for ls1088a */
-#define LS1088_ECC_DIS_ADDR_CH2      0x100520
-#define LS1088_ECC_DIS_VAL_CH2       0x40000000
-
-/* ecc addr-val pair */
-#define ECC_DIS_ADDR_CH2     0x20140520
+/* ecc val pair */
+#define ECC_DIS_VAL_CH1              0x00020000
 #define ECC_DIS_VAL_CH2              0x80000000
-#define SATA_ECC_REG_ADDR    0x20220520
-#define SATA_ECC_DISABLE     0x00020000
+#define ECC_DIS_VAL_CH3              0x40000000
 
 enum ceva_soc {
      CEVA_1V84,
      CEVA_LS1012A,
      CEVA_LS1021A,
+     CEVA_LS1028A,
      CEVA_LS1043A,
      CEVA_LS1046A,
      CEVA_LS1088A,
@@ -110,12 +106,14 @@ enum ceva_soc {
 
 struct ceva_sata_priv {
      ulong base;
+     ulong ecc_base;
      enum ceva_soc soc;
      ulong flag;
 };
 
 static int ceva_init_sata(struct ceva_sata_priv *priv)  {
+     ulong ecc_addr = priv->ecc_base;
      ulong base = priv->base;
      ulong tmp;
 
@@ -132,38 +130,38 @@ static int ceva_init_sata(struct
Quoted 1 line

ceva_sata_priv

*priv)

drivers/ata/sata_ceva.c

Quoted 8 lines
              break;

      case CEVA_LS1021A:
drivers/ata/sata_ceva.c +2 -1
-             writel(SATA_ECC_DISABLE, SATA_ECC_REG_ADDR);
+             if (ecc_addr)
+                     writel(ECC_DIS_VAL_CH1, ecc_addr);
              writel(CEVA_PHY1_CFG, base + AHCI_VEND_PPCFG);
              writel(LS1021_CEVA_PHY2_CFG, base +

AHCI_VEND_PP2C);

Quoted 1 line
              writel(LS1021_CEVA_PHY3_CFG, base +

AHCI_VEND_PP3C);

Quoted 1 line
              writel(LS1021_CEVA_PHY4_CFG, base +

AHCI_VEND_PP4C);

Quoted 1 line
              writel(LS1021_CEVA_PHY5_CFG, base +

AHCI_VEND_PP5C);

drivers/ata/sata_ceva.c

Quoted 3 lines
              writel(CEVA_TRANS_CFG, base + AHCI_VEND_PTC);
drivers/ata/sata_ceva.c +0 -2
-             if (priv->flag & FLAG_COHERENT)
-                     writel(CEVA_AXICC_CFG, base +

LS1021_AHCI_VEND_AXICC);

Quoted 5 lines
              break;

      case CEVA_LS1012A:
      case CEVA_LS1043A:
      case CEVA_LS1046A:

drivers/ata/sata_ceva.c

Quoted 9 lines
drivers/ata/sata_ceva.c +2 -4
-             writel(ECC_DIS_VAL_CH2, ECC_DIS_ADDR_CH2);
-             /* fallthrough */
      case CEVA_LS2080A:
+             if (ecc_addr)
+                     writel(ECC_DIS_VAL_CH2, ecc_addr);
              writel(CEVA_PHY1_CFG, base + AHCI_VEND_PPCFG);
              writel(CEVA_TRANS_CFG, base + AHCI_VEND_PTC);
-             if (priv->flag & FLAG_COHERENT)
-                     writel(CEVA_AXICC_CFG, base +

AHCI_VEND_AXICC);

drivers/ata/sata_ceva.c

Quoted 5 lines
              break;
drivers/ata/sata_ceva.c +1 -1
+     case CEVA_LS1028A:
      case CEVA_LS1088A:
-             writel(LS1088_ECC_DIS_VAL_CH2,

LS1088_ECC_DIS_ADDR_CH2);

drivers/ata/sata_ceva.c

Quoted 6 lines
drivers/ata/sata_ceva.c +2 -2
+             if (ecc_addr)
+                     writel(ECC_DIS_VAL_CH3, ecc_addr);
              writel(CEVA_PHY1_CFG, base + AHCI_VEND_PPCFG);
              writel(CEVA_TRANS_CFG, base + AHCI_VEND_PTC);
-             if (priv->flag & FLAG_COHERENT)
-                     writel(CEVA_AXICC_CFG, base +

AHCI_VEND_AXICC);

Quoted 18 lines
              break;
      }
drivers/ata/sata_ceva.c +4 -1
+     if (priv->flag & FLAG_COHERENT)
+             writel(CEVA_AXICC_CFG, base + AHCI_VEND_AXICC);
+
      return 0;
 }
@@ -187,6 +185,7 @@ static const struct udevice_id sata_ceva_ids[] = {
      { .compatible = "ceva,ahci-1v84", .data = CEVA_1V84 },
      { .compatible = "fsl,ls1012a-ahci", .data = CEVA_LS1012A },
      { .compatible = "fsl,ls1021a-ahci", .data = CEVA_LS1021A },
+     { .compatible = "fsl,ls1028a-ahci", .data = CEVA_LS1028A },
      { .compatible = "fsl,ls1043a-ahci", .data = CEVA_LS1043A },
      { .compatible = "fsl,ls1046a-ahci", .data = CEVA_LS1046A },
      { .compatible = "fsl,ls1088a-ahci", .data = CEVA_LS1088A }, @@
-205,8 +204,16 @@ static int sata_ceva_ofdata_to_platdata(struct
Quoted 1 line

udevice

*dev)

Quoted 3 lines
      if (priv->base == FDT_ADDR_T_NONE)
              return -EINVAL;
Quoted 6 lines
Quoted 5 lines
Quoted 1 line

+ priv->ecc_base = dev_read_addr_index(dev, 1);

It would be better to do it via reg-name instead of index. But that's up to your binding doc.

[Peng Ma] OK, could I change arch/arm/dts/zynqmp.dtsi file sata node as

fallows?

arch/arm/dts/zynqmp.dtsi line 698

Quoted 13 lines
arch/arm/dts/zynqmp.dtsi index renamed from arch/arm/dts/zynqmp.dtsi +0 -0

dfb6ebc..9ad2d84 100644

arch/arm/dts/zynqmp.dtsi +1 -0
@@ -692,6 +692,7 @@
                        compatible = "ceva,ahci-1v84";
                        status = "disabled";
                        reg = <0x0 0xfd0c0000 0x0 0x2000>;
+                       reg-names = "serdes";
                        interrupt-parent = <&gic>;
                        interrupts = <0 133 4>;
                        #stream-id-cells = <4>;

Unfortunately it is not that simple.

First of all you need to reflect this in dt binding doc in the kernel.
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit.kern
el.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Ftorvalds%2Flinux.git%2Ftr ee%2FDocumentation%2Fdevicetree%2Fbindings%2Fata%2Fahci-ceva.txt%3F h%3Dv5.1-rc5&amp;data=02%7C01%7Cpeng.ma%40nxp.com%7Cc588ddff1b1 e471f645b08d6c24e54d7%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C 0%7C636910039050031150&amp;sdata=0Gsuo2uI3pot4VAhBr7SQUnCRYT7Xi Ybybu6i1t%2Byzo%3D&amp;reserved=0

Quoted 2 lines

Did you record your compatible strings anywhere?

[Peng Ma] Thanks your quick reply.
You can find our binding document at: (https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/devicetree/bindings/ata/ahci-fsl-qoriq.txt?h=v5.1-rc5)
I think your suggestion is better. But the first register address was got by function dev_read_addr(), to keep consistency, I still prefer to use dev_read_addr_index(). What do you think?

Quoted 3 lines

Thanks,
Michal

#6 lore raw
Quoted 196 lines · Peng Ma
Quoted 196 lines

-----Original Message-----
From: Michal Simek <[email protected]>
Sent: 2019年4月16日 17:31
To: Peng Ma <[email protected]>; Michal Simek <[email protected]>; albert.u.boot at aribaud.net; sjg at chromium.org; Fabio Estevam <[email protected]>; York Sun <[email protected]>; Prabhakar Kushwaha <[email protected]>
Cc: Andy Tang <[email protected]>; Yinbo Zhu <[email protected]>; u-boot at lists.denx.de
Subject: Re: [EXT] Re: [PATCH 1/2] scsi: ceva: Clean up the driver code

WARNING: This email was created outside of NXP. DO NOT CLICK links or attachments unless you recognize the sender and know the content is safe.

Quoted 8 lines · Peng Ma
Quoted 8 lines

-----Original Message-----
From: Michal Simek <[email protected]>
Sent: 2019年4月16日 16:04
To: Peng Ma <[email protected]>; albert.u.boot at aribaud.net; sjg at chromium.org; Fabio Estevam <[email protected]>; York Sun <[email protected]>; Prabhakar Kushwaha

<[email protected]>

Quoted 136 lines
Quoted 136 lines

Cc: Andy Tang <[email protected]>; Yinbo Zhu <[email protected]>; michal.simek at xilinx.com; u-boot at lists.denx.de
Subject: [EXT] Re: [PATCH 1/2] scsi: ceva: Clean up the driver code

WARNING: This email was created outside of NXP. DO NOT CLICK links or attachments unless you recognize the sender and know the content is safe.

Quoted 6 lines · Peng Ma

Distinguish the ecc val by chassis version and move the ecc addr to dts. Add ls1028a soc support.

---
 drivers/ata/sata_ceva.c |   43

+++++++++++++++++++++++++------------------

drivers/ata/sata_ceva.c line 88

Quoted 8 lines
 1 files changed, 25 insertions(+), 18 deletions(-)
drivers/ata/sata_ceva.c index renamed from drivers/ata/sata_ceva.c +0 -0

8887be9..d26f712 100644

drivers/ata/sata_ceva.c +0 -0
@@ -88,20 +88,16 @@
 #define LS1021_CEVA_PHY4_CFG 0x064a080b  #define

LS1021_CEVA_PHY5_CFG

Quoted 38 lines

0x2aa86470

drivers/ata/sata_ceva.c +6 -8
-/* for ls1088a */
-#define LS1088_ECC_DIS_ADDR_CH2      0x100520
-#define LS1088_ECC_DIS_VAL_CH2       0x40000000
-
-/* ecc addr-val pair */
-#define ECC_DIS_ADDR_CH2     0x20140520
+/* ecc val pair */
+#define ECC_DIS_VAL_CH1              0x00020000
 #define ECC_DIS_VAL_CH2              0x80000000
-#define SATA_ECC_REG_ADDR    0x20220520
-#define SATA_ECC_DISABLE     0x00020000
+#define ECC_DIS_VAL_CH3              0x40000000
 
 enum ceva_soc {
      CEVA_1V84,
      CEVA_LS1012A,
      CEVA_LS1021A,
+     CEVA_LS1028A,
      CEVA_LS1043A,
      CEVA_LS1046A,
      CEVA_LS1088A,
@@ -110,12 +106,14 @@ enum ceva_soc {
 
 struct ceva_sata_priv {
      ulong base;
+     ulong ecc_base;
      enum ceva_soc soc;
      ulong flag;
 };
 
 static int ceva_init_sata(struct ceva_sata_priv *priv)  {
+     ulong ecc_addr = priv->ecc_base;
      ulong base = priv->base;
      ulong tmp;
 
@@ -132,38 +130,38 @@ static int ceva_init_sata(struct
Quoted 1 line

ceva_sata_priv

*priv)

drivers/ata/sata_ceva.c

Quoted 8 lines
              break;

      case CEVA_LS1021A:
drivers/ata/sata_ceva.c +2 -1
-             writel(SATA_ECC_DISABLE, SATA_ECC_REG_ADDR);
+             if (ecc_addr)
+                     writel(ECC_DIS_VAL_CH1, ecc_addr);
              writel(CEVA_PHY1_CFG, base + AHCI_VEND_PPCFG);
              writel(LS1021_CEVA_PHY2_CFG, base +

AHCI_VEND_PP2C);

Quoted 1 line
              writel(LS1021_CEVA_PHY3_CFG, base +

AHCI_VEND_PP3C);

Quoted 1 line
              writel(LS1021_CEVA_PHY4_CFG, base +

AHCI_VEND_PP4C);

Quoted 1 line
              writel(LS1021_CEVA_PHY5_CFG, base +

AHCI_VEND_PP5C);

drivers/ata/sata_ceva.c

Quoted 3 lines
              writel(CEVA_TRANS_CFG, base + AHCI_VEND_PTC);
drivers/ata/sata_ceva.c +0 -2
-             if (priv->flag & FLAG_COHERENT)
-                     writel(CEVA_AXICC_CFG, base +

LS1021_AHCI_VEND_AXICC);

Quoted 5 lines
              break;

      case CEVA_LS1012A:
      case CEVA_LS1043A:
      case CEVA_LS1046A:

drivers/ata/sata_ceva.c

Quoted 9 lines
drivers/ata/sata_ceva.c +2 -4
-             writel(ECC_DIS_VAL_CH2, ECC_DIS_ADDR_CH2);
-             /* fallthrough */
      case CEVA_LS2080A:
+             if (ecc_addr)
+                     writel(ECC_DIS_VAL_CH2, ecc_addr);
              writel(CEVA_PHY1_CFG, base + AHCI_VEND_PPCFG);
              writel(CEVA_TRANS_CFG, base + AHCI_VEND_PTC);
-             if (priv->flag & FLAG_COHERENT)
-                     writel(CEVA_AXICC_CFG, base +

AHCI_VEND_AXICC);

drivers/ata/sata_ceva.c

Quoted 5 lines
              break;
drivers/ata/sata_ceva.c +1 -1
+     case CEVA_LS1028A:
      case CEVA_LS1088A:
-             writel(LS1088_ECC_DIS_VAL_CH2,

LS1088_ECC_DIS_ADDR_CH2);

drivers/ata/sata_ceva.c

Quoted 6 lines
drivers/ata/sata_ceva.c +2 -2
+             if (ecc_addr)
+                     writel(ECC_DIS_VAL_CH3, ecc_addr);
              writel(CEVA_PHY1_CFG, base + AHCI_VEND_PPCFG);
              writel(CEVA_TRANS_CFG, base + AHCI_VEND_PTC);
-             if (priv->flag & FLAG_COHERENT)
-                     writel(CEVA_AXICC_CFG, base +

AHCI_VEND_AXICC);

Quoted 18 lines
              break;
      }
drivers/ata/sata_ceva.c +4 -1
+     if (priv->flag & FLAG_COHERENT)
+             writel(CEVA_AXICC_CFG, base + AHCI_VEND_AXICC);
+
      return 0;
 }
@@ -187,6 +185,7 @@ static const struct udevice_id sata_ceva_ids[] = {
      { .compatible = "ceva,ahci-1v84", .data = CEVA_1V84 },
      { .compatible = "fsl,ls1012a-ahci", .data = CEVA_LS1012A },
      { .compatible = "fsl,ls1021a-ahci", .data = CEVA_LS1021A },
+     { .compatible = "fsl,ls1028a-ahci", .data = CEVA_LS1028A },
      { .compatible = "fsl,ls1043a-ahci", .data = CEVA_LS1043A },
      { .compatible = "fsl,ls1046a-ahci", .data = CEVA_LS1046A },
      { .compatible = "fsl,ls1088a-ahci", .data = CEVA_LS1088A }, @@
-205,8 +204,16 @@ static int sata_ceva_ofdata_to_platdata(struct
Quoted 1 line

udevice

*dev)

Quoted 3 lines
      if (priv->base == FDT_ADDR_T_NONE)
              return -EINVAL;
Quoted 6 lines
Quoted 5 lines
Quoted 1 line

+ priv->ecc_base = dev_read_addr_index(dev, 1);

It would be better to do it via reg-name instead of index. But that's up to your binding doc.

[Peng Ma] OK, could I change arch/arm/dts/zynqmp.dtsi file sata node as

fallows?

arch/arm/dts/zynqmp.dtsi line 698

Quoted 13 lines
arch/arm/dts/zynqmp.dtsi index renamed from arch/arm/dts/zynqmp.dtsi +0 -0

dfb6ebc..9ad2d84 100644

arch/arm/dts/zynqmp.dtsi +1 -0
@@ -692,6 +692,7 @@
                        compatible = "ceva,ahci-1v84";
                        status = "disabled";
                        reg = <0x0 0xfd0c0000 0x0 0x2000>;
+                       reg-names = "serdes";
                        interrupt-parent = <&gic>;
                        interrupts = <0 133 4>;
                        #stream-id-cells = <4>;

Unfortunately it is not that simple.

First of all you need to reflect this in dt binding doc in the kernel.
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit.kern
el.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Ftorvalds%2Flinux.git%2Ftr ee%2FDocumentation%2Fdevicetree%2Fbindings%2Fata%2Fahci-ceva.txt%3F h%3Dv5.1-rc5&amp;data=02%7C01%7Cpeng.ma%40nxp.com%7Cc588ddff1b1 e471f645b08d6c24e54d7%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C 0%7C636910039050031150&amp;sdata=0Gsuo2uI3pot4VAhBr7SQUnCRYT7Xi Ybybu6i1t%2Byzo%3D&amp;reserved=0

Quoted 4 lines
Quoted 2 lines

Did you record your compatible strings anywhere?

[Peng Ma] Thanks your quick reply.
You can find our binding document at: (https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/devicetree/bindings/ata/ahci-fsl-qoriq.txt?h=v5.1-rc5)

Interesting. Why did you create separate binding doc if you target the same ceva sata IP core? Any reason not to merge it together? Anyway I see that this was added in 2015.

Quoted 1 line

I think your suggestion is better. But the first register cd address was got by function dev_read_addr(), to keep consistency, I still prefer to use dev_read_addr_index(). What do you think?

We didn't have a need to have second address range that's why reg-names property wasn't used. Do they have all ecc addresses?

M

author
#7 lore raw
Quoted 245 lines

-----Original Message-----
From: Michal Simek <[email protected]>
Sent: 2019年4月16日 18:01
To: Peng Ma <[email protected]>; Michal Simek <[email protected]>; albert.u.boot at aribaud.net; sjg at chromium.org; Fabio Estevam <[email protected]>; York Sun <[email protected]>; Prabhakar Kushwaha <[email protected]>
Cc: Andy Tang <[email protected]>; Yinbo Zhu <[email protected]>; u-boot at lists.denx.de
Subject: Re: [EXT] Re: [PATCH 1/2] scsi: ceva: Clean up the driver code

WARNING: This email was created outside of NXP. DO NOT CLICK links or attachments unless you recognize the sender and know the content is safe.

Quoted 9 lines · Peng Ma
Quoted 9 lines

-----Original Message-----
From: Michal Simek <[email protected]>
Sent: 2019年4月16日 17:31
To: Peng Ma <[email protected]>; Michal Simek <[email protected]>; albert.u.boot at aribaud.net; sjg at chromium.org; Fabio Estevam <[email protected]>; York Sun <[email protected]>; Prabhakar Kushwaha

<[email protected]>

Quoted 19 lines
Quoted 19 lines

Cc: Andy Tang <[email protected]>; Yinbo Zhu <[email protected]>; u-boot at lists.denx.de
Subject: Re: [EXT] Re: [PATCH 1/2] scsi: ceva: Clean up the driver code

WARNING: This email was created outside of NXP. DO NOT CLICK links or attachments unless you recognize the sender and know the content is safe.

Quoted 8 lines · Peng Ma
Quoted 8 lines

-----Original Message-----
From: Michal Simek <[email protected]>
Sent: 2019年4月16日 16:04
To: Peng Ma <[email protected]>; albert.u.boot at aribaud.net; sjg at chromium.org; Fabio Estevam <[email protected]>; York Sun <[email protected]>; Prabhakar Kushwaha

Quoted 7 lines
Quoted 7 lines

<[email protected]>

Quoted 6 lines
Quoted 6 lines

Cc: Andy Tang <[email protected]>; Yinbo Zhu <[email protected]>; michal.simek at xilinx.com; u-boot at lists.denx.de
Subject: [EXT] Re: [PATCH 1/2] scsi: ceva: Clean up the driver code

WARNING: This email was created outside of NXP. DO NOT CLICK links or attachments unless you recognize the sender and know the content is

safe.

Quoted 111 lines
Quoted 111 lines
Quoted 111 lines
Quoted 111 lines · Peng Ma
Quoted 6 lines

Distinguish the ecc val by chassis version and move the ecc addr to dts. Add ls1028a soc support.

---
 drivers/ata/sata_ceva.c |   43

+++++++++++++++++++++++++------------------

drivers/ata/sata_ceva.c line 88

Quoted 9 lines
 1 files changed, 25 insertions(+), 18 deletions(-)
drivers/ata/sata_ceva.c +0 -0

index
8887be9..d26f712 100644

drivers/ata/sata_ceva.c +0 -0
@@ -88,20 +88,16 @@
 #define LS1021_CEVA_PHY4_CFG 0x064a080b  #define

LS1021_CEVA_PHY5_CFG

Quoted 38 lines

0x2aa86470

drivers/ata/sata_ceva.c +6 -8
-/* for ls1088a */
-#define LS1088_ECC_DIS_ADDR_CH2      0x100520
-#define LS1088_ECC_DIS_VAL_CH2       0x40000000
-
-/* ecc addr-val pair */
-#define ECC_DIS_ADDR_CH2     0x20140520
+/* ecc val pair */
+#define ECC_DIS_VAL_CH1              0x00020000
 #define ECC_DIS_VAL_CH2              0x80000000
-#define SATA_ECC_REG_ADDR    0x20220520
-#define SATA_ECC_DISABLE     0x00020000
+#define ECC_DIS_VAL_CH3              0x40000000
 
 enum ceva_soc {
      CEVA_1V84,
      CEVA_LS1012A,
      CEVA_LS1021A,
+     CEVA_LS1028A,
      CEVA_LS1043A,
      CEVA_LS1046A,
      CEVA_LS1088A,
@@ -110,12 +106,14 @@ enum ceva_soc {
 
 struct ceva_sata_priv {
      ulong base;
+     ulong ecc_base;
      enum ceva_soc soc;
      ulong flag;
 };
 
 static int ceva_init_sata(struct ceva_sata_priv *priv)  {
+     ulong ecc_addr = priv->ecc_base;
      ulong base = priv->base;
      ulong tmp;
 
@@ -132,38 +130,38 @@ static int ceva_init_sata(struct
Quoted 1 line

ceva_sata_priv

*priv)

drivers/ata/sata_ceva.c

Quoted 8 lines
              break;

      case CEVA_LS1021A:
drivers/ata/sata_ceva.c +2 -1
-             writel(SATA_ECC_DISABLE, SATA_ECC_REG_ADDR);
+             if (ecc_addr)
+                     writel(ECC_DIS_VAL_CH1, ecc_addr);
              writel(CEVA_PHY1_CFG, base + AHCI_VEND_PPCFG);
              writel(LS1021_CEVA_PHY2_CFG, base +

AHCI_VEND_PP2C);

Quoted 1 line
              writel(LS1021_CEVA_PHY3_CFG, base +

AHCI_VEND_PP3C);

Quoted 1 line
              writel(LS1021_CEVA_PHY4_CFG, base +

AHCI_VEND_PP4C);

Quoted 1 line
              writel(LS1021_CEVA_PHY5_CFG, base +

AHCI_VEND_PP5C);

drivers/ata/sata_ceva.c

Quoted 3 lines
              writel(CEVA_TRANS_CFG, base + AHCI_VEND_PTC);
drivers/ata/sata_ceva.c +0 -2
-             if (priv->flag & FLAG_COHERENT)
-                     writel(CEVA_AXICC_CFG, base +

LS1021_AHCI_VEND_AXICC);

Quoted 5 lines
              break;

      case CEVA_LS1012A:
      case CEVA_LS1043A:
      case CEVA_LS1046A:

drivers/ata/sata_ceva.c

Quoted 9 lines
drivers/ata/sata_ceva.c +2 -4
-             writel(ECC_DIS_VAL_CH2, ECC_DIS_ADDR_CH2);
-             /* fallthrough */
      case CEVA_LS2080A:
+             if (ecc_addr)
+                     writel(ECC_DIS_VAL_CH2, ecc_addr);
              writel(CEVA_PHY1_CFG, base + AHCI_VEND_PPCFG);
              writel(CEVA_TRANS_CFG, base + AHCI_VEND_PTC);
-             if (priv->flag & FLAG_COHERENT)
-                     writel(CEVA_AXICC_CFG, base +

AHCI_VEND_AXICC);

drivers/ata/sata_ceva.c

Quoted 5 lines
              break;
drivers/ata/sata_ceva.c +1 -1
+     case CEVA_LS1028A:
      case CEVA_LS1088A:
-             writel(LS1088_ECC_DIS_VAL_CH2,

LS1088_ECC_DIS_ADDR_CH2);

drivers/ata/sata_ceva.c

Quoted 6 lines
drivers/ata/sata_ceva.c +2 -2
+             if (ecc_addr)
+                     writel(ECC_DIS_VAL_CH3, ecc_addr);
              writel(CEVA_PHY1_CFG, base + AHCI_VEND_PPCFG);
              writel(CEVA_TRANS_CFG, base + AHCI_VEND_PTC);
-             if (priv->flag & FLAG_COHERENT)
-                     writel(CEVA_AXICC_CFG, base +

AHCI_VEND_AXICC);

Quoted 3 lines
              break;
      }
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

drivers/ata/sata_ceva.c static const struct udevice_id sata_ceva_ids[] =

Quoted 7 lines
drivers/ata/sata_ceva.c +3 -0
+     if (priv->flag & FLAG_COHERENT)
+             writel(CEVA_AXICC_CFG, base + AHCI_VEND_AXICC);
+
      return 0;
 }
@@ -187,6 +185,7 @@ static const struct udevice_id sata_ceva_ids[] =

{

Quoted 39 lines
Quoted 39 lines
Quoted 14 lines
Quoted 14 lines
Quoted 10 lines
drivers/ata/sata_ceva.c +1 -0
      { .compatible = "ceva,ahci-1v84", .data = CEVA_1V84 },
      { .compatible = "fsl,ls1012a-ahci", .data = CEVA_LS1012A },
      { .compatible = "fsl,ls1021a-ahci", .data = CEVA_LS1021A },
+     { .compatible = "fsl,ls1028a-ahci", .data = CEVA_LS1028A },
      { .compatible = "fsl,ls1043a-ahci", .data = CEVA_LS1043A },
      { .compatible = "fsl,ls1046a-ahci", .data = CEVA_LS1046A },
      { .compatible = "fsl,ls1088a-ahci", .data = CEVA_LS1088A },

@@
-205,8 +204,16 @@ static int sata_ceva_ofdata_to_platdata(struct udevice

*dev)

Quoted 3 lines
      if (priv->base == FDT_ADDR_T_NONE)
              return -EINVAL;
Quoted 7 lines
Quoted 5 lines
Quoted 1 line

+ priv->ecc_base = dev_read_addr_index(dev, 1);

It would be better to do it via reg-name instead of index. But that's up to your binding doc.

[Peng Ma] OK, could I change arch/arm/dts/zynqmp.dtsi file sata node as

fallows?

Quoted 7 lines
arch/arm/dts/zynqmp.dtsi +0 -0

index
dfb6ebc..9ad2d84 100644

arch/arm/dts/zynqmp.dtsi line 698

Quoted 7 lines
arch/arm/dts/zynqmp.dtsi +1 -0
@@ -692,6 +692,7 @@
                        compatible = "ceva,ahci-1v84";
                        status = "disabled";
                        reg = <0x0 0xfd0c0000 0x0 0x2000>;
+                       reg-names = "serdes";
                        interrupt-parent = <&gic>;
                        interrupts = <0 133 4>;
                        #stream-id-cells = <4>;

Unfortunately it is not that simple.

Quoted 4 lines
Quoted 4 lines

First of all you need to reflect this in dt binding doc in the kernel.
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit
.kern

el.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Ftorvalds%2Flinux.git%2Ftr

Quoted 1 line
Quoted 1 line

ee%2FDocumentation%2Fdevicetree%2Fbindings%2Fata%2Fahci-ceva.txt%3F

Quoted 1 line
Quoted 1 line

h%3Dv5.1-rc5&amp;data=02%7C01%7Cpeng.ma%40nxp.com%7Cc588ddff1b1

Quoted 1 line
Quoted 1 line

e471f645b08d6c24e54d7%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C

Quoted 1 line
Quoted 1 line

0%7C636910039050031150&amp;sdata=0Gsuo2uI3pot4VAhBr7SQUnCRYT7Xi

Quoted 8 lines
Quoted 4 lines

Ybybu6i1t%2Byzo%3D&amp;reserved=0

Did you record your compatible strings anywhere?

[Peng Ma] Thanks your quick reply.
You can find our binding document at:
(https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit
.kernel.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Ftorvalds%2Flinux.git

%

Quoted 1 line

2Ftree%2FDocumentation%2Fdevicetree%2Fbindings%2Fata%2Fahci-fsl-qoriq.

Quoted 1 line

txt%3Fh%3Dv5.1-rc5&amp;data=02%7C01%7Cpeng.ma%40nxp.com%7C977d 7871292f

Quoted 1 line

48332dbb08d6c2526b32%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C 0%7C6369

Quoted 1 line
Quoted 8 lines

10056581930082&amp;sdata=KQryE2RvI8jTOAPKGlGnx2NWYdawFUaTURyzd8 oets4%3

Quoted 1 line

D&amp;reserved=0)

Interesting. Why did you create separate binding doc if you target the same ceva sata IP core? Any reason not to merge it together?
Anyway I see that this was added in 2015.

[Peng Ma] Although they are both ceva sata, our sata driver is different from yours in kernel to Initializa Vendor-specific registers, you could see our driver at kernel driver/ata/ ahci_qoriq.c.

Quoted 7 lines
Quoted 1 line

I think your suggestion is better. But the first register cd address was got by

function dev_read_addr(), to keep consistency, I still prefer to use dev_read_addr_index(). What do you think?

We didn't have a need to have second address range that's why reg-names property wasn't used. Do they have all ecc addresses?

[Peng Ma] Some of our socs need to fixed sata errata. So we should write ecc addr. I didn't add reg-names to keep consistency of Xilinx sata soc.

Quoted 1 line

M

#8 lore raw
Quoted 247 lines · Peng Ma
Quoted 247 lines

-----Original Message-----
From: Michal Simek <[email protected]>
Sent: 2019年4月16日 18:01
To: Peng Ma <[email protected]>; Michal Simek <[email protected]>; albert.u.boot at aribaud.net; sjg at chromium.org; Fabio Estevam <[email protected]>; York Sun <[email protected]>; Prabhakar Kushwaha <[email protected]>
Cc: Andy Tang <[email protected]>; Yinbo Zhu <[email protected]>; u-boot at lists.denx.de
Subject: Re: [EXT] Re: [PATCH 1/2] scsi: ceva: Clean up the driver code

WARNING: This email was created outside of NXP. DO NOT CLICK links or attachments unless you recognize the sender and know the content is safe.

Quoted 9 lines · Peng Ma
Quoted 9 lines

-----Original Message-----
From: Michal Simek <[email protected]>
Sent: 2019年4月16日 17:31
To: Peng Ma <[email protected]>; Michal Simek <[email protected]>; albert.u.boot at aribaud.net; sjg at chromium.org; Fabio Estevam <[email protected]>; York Sun <[email protected]>; Prabhakar Kushwaha

<[email protected]>

Quoted 19 lines
Quoted 19 lines

Cc: Andy Tang <[email protected]>; Yinbo Zhu <[email protected]>; u-boot at lists.denx.de
Subject: Re: [EXT] Re: [PATCH 1/2] scsi: ceva: Clean up the driver code

WARNING: This email was created outside of NXP. DO NOT CLICK links or attachments unless you recognize the sender and know the content is safe.

Quoted 8 lines · Peng Ma
Quoted 8 lines

-----Original Message-----
From: Michal Simek <[email protected]>
Sent: 2019年4月16日 16:04
To: Peng Ma <[email protected]>; albert.u.boot at aribaud.net; sjg at chromium.org; Fabio Estevam <[email protected]>; York Sun <[email protected]>; Prabhakar Kushwaha

Quoted 7 lines
Quoted 7 lines

<[email protected]>

Quoted 6 lines
Quoted 6 lines

Cc: Andy Tang <[email protected]>; Yinbo Zhu <[email protected]>; michal.simek at xilinx.com; u-boot at lists.denx.de
Subject: [EXT] Re: [PATCH 1/2] scsi: ceva: Clean up the driver code

WARNING: This email was created outside of NXP. DO NOT CLICK links or attachments unless you recognize the sender and know the content is

safe.

Quoted 111 lines
Quoted 111 lines
Quoted 111 lines
Quoted 111 lines · Peng Ma
Quoted 6 lines

Distinguish the ecc val by chassis version and move the ecc addr to dts. Add ls1028a soc support.

---
 drivers/ata/sata_ceva.c |   43

+++++++++++++++++++++++++------------------

drivers/ata/sata_ceva.c line 88

Quoted 9 lines
 1 files changed, 25 insertions(+), 18 deletions(-)
drivers/ata/sata_ceva.c +0 -0

index
8887be9..d26f712 100644

drivers/ata/sata_ceva.c +0 -0
@@ -88,20 +88,16 @@
 #define LS1021_CEVA_PHY4_CFG 0x064a080b  #define

LS1021_CEVA_PHY5_CFG

Quoted 38 lines

0x2aa86470

drivers/ata/sata_ceva.c +6 -8
-/* for ls1088a */
-#define LS1088_ECC_DIS_ADDR_CH2      0x100520
-#define LS1088_ECC_DIS_VAL_CH2       0x40000000
-
-/* ecc addr-val pair */
-#define ECC_DIS_ADDR_CH2     0x20140520
+/* ecc val pair */
+#define ECC_DIS_VAL_CH1              0x00020000
 #define ECC_DIS_VAL_CH2              0x80000000
-#define SATA_ECC_REG_ADDR    0x20220520
-#define SATA_ECC_DISABLE     0x00020000
+#define ECC_DIS_VAL_CH3              0x40000000
 
 enum ceva_soc {
      CEVA_1V84,
      CEVA_LS1012A,
      CEVA_LS1021A,
+     CEVA_LS1028A,
      CEVA_LS1043A,
      CEVA_LS1046A,
      CEVA_LS1088A,
@@ -110,12 +106,14 @@ enum ceva_soc {
 
 struct ceva_sata_priv {
      ulong base;
+     ulong ecc_base;
      enum ceva_soc soc;
      ulong flag;
 };
 
 static int ceva_init_sata(struct ceva_sata_priv *priv)  {
+     ulong ecc_addr = priv->ecc_base;
      ulong base = priv->base;
      ulong tmp;
 
@@ -132,38 +130,38 @@ static int ceva_init_sata(struct
Quoted 1 line

ceva_sata_priv

*priv)

drivers/ata/sata_ceva.c

Quoted 8 lines
              break;

      case CEVA_LS1021A:
drivers/ata/sata_ceva.c +2 -1
-             writel(SATA_ECC_DISABLE, SATA_ECC_REG_ADDR);
+             if (ecc_addr)
+                     writel(ECC_DIS_VAL_CH1, ecc_addr);
              writel(CEVA_PHY1_CFG, base + AHCI_VEND_PPCFG);
              writel(LS1021_CEVA_PHY2_CFG, base +

AHCI_VEND_PP2C);

Quoted 1 line
              writel(LS1021_CEVA_PHY3_CFG, base +

AHCI_VEND_PP3C);

Quoted 1 line
              writel(LS1021_CEVA_PHY4_CFG, base +

AHCI_VEND_PP4C);

Quoted 1 line
              writel(LS1021_CEVA_PHY5_CFG, base +

AHCI_VEND_PP5C);

drivers/ata/sata_ceva.c

Quoted 3 lines
              writel(CEVA_TRANS_CFG, base + AHCI_VEND_PTC);
drivers/ata/sata_ceva.c +0 -2
-             if (priv->flag & FLAG_COHERENT)
-                     writel(CEVA_AXICC_CFG, base +

LS1021_AHCI_VEND_AXICC);

Quoted 5 lines
              break;

      case CEVA_LS1012A:
      case CEVA_LS1043A:
      case CEVA_LS1046A:

drivers/ata/sata_ceva.c

Quoted 9 lines
drivers/ata/sata_ceva.c +2 -4
-             writel(ECC_DIS_VAL_CH2, ECC_DIS_ADDR_CH2);
-             /* fallthrough */
      case CEVA_LS2080A:
+             if (ecc_addr)
+                     writel(ECC_DIS_VAL_CH2, ecc_addr);
              writel(CEVA_PHY1_CFG, base + AHCI_VEND_PPCFG);
              writel(CEVA_TRANS_CFG, base + AHCI_VEND_PTC);
-             if (priv->flag & FLAG_COHERENT)
-                     writel(CEVA_AXICC_CFG, base +

AHCI_VEND_AXICC);

drivers/ata/sata_ceva.c

Quoted 5 lines
              break;
drivers/ata/sata_ceva.c +1 -1
+     case CEVA_LS1028A:
      case CEVA_LS1088A:
-             writel(LS1088_ECC_DIS_VAL_CH2,

LS1088_ECC_DIS_ADDR_CH2);

drivers/ata/sata_ceva.c

Quoted 6 lines
drivers/ata/sata_ceva.c +2 -2
+             if (ecc_addr)
+                     writel(ECC_DIS_VAL_CH3, ecc_addr);
              writel(CEVA_PHY1_CFG, base + AHCI_VEND_PPCFG);
              writel(CEVA_TRANS_CFG, base + AHCI_VEND_PTC);
-             if (priv->flag & FLAG_COHERENT)
-                     writel(CEVA_AXICC_CFG, base +

AHCI_VEND_AXICC);

Quoted 3 lines
              break;
      }
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

drivers/ata/sata_ceva.c static const struct udevice_id sata_ceva_ids[] =

Quoted 7 lines
drivers/ata/sata_ceva.c +3 -0
+     if (priv->flag & FLAG_COHERENT)
+             writel(CEVA_AXICC_CFG, base + AHCI_VEND_AXICC);
+
      return 0;
 }
@@ -187,6 +185,7 @@ static const struct udevice_id sata_ceva_ids[] =

{

Quoted 39 lines
Quoted 39 lines
Quoted 14 lines
Quoted 14 lines
Quoted 10 lines
drivers/ata/sata_ceva.c +1 -0
      { .compatible = "ceva,ahci-1v84", .data = CEVA_1V84 },
      { .compatible = "fsl,ls1012a-ahci", .data = CEVA_LS1012A },
      { .compatible = "fsl,ls1021a-ahci", .data = CEVA_LS1021A },
+     { .compatible = "fsl,ls1028a-ahci", .data = CEVA_LS1028A },
      { .compatible = "fsl,ls1043a-ahci", .data = CEVA_LS1043A },
      { .compatible = "fsl,ls1046a-ahci", .data = CEVA_LS1046A },
      { .compatible = "fsl,ls1088a-ahci", .data = CEVA_LS1088A },

@@
-205,8 +204,16 @@ static int sata_ceva_ofdata_to_platdata(struct udevice

*dev)

Quoted 3 lines
      if (priv->base == FDT_ADDR_T_NONE)
              return -EINVAL;
Quoted 7 lines
Quoted 5 lines
Quoted 1 line

+ priv->ecc_base = dev_read_addr_index(dev, 1);

It would be better to do it via reg-name instead of index. But that's up to your binding doc.

[Peng Ma] OK, could I change arch/arm/dts/zynqmp.dtsi file sata node as

fallows?

Quoted 7 lines
arch/arm/dts/zynqmp.dtsi +0 -0

index
dfb6ebc..9ad2d84 100644

arch/arm/dts/zynqmp.dtsi line 698

Quoted 7 lines
arch/arm/dts/zynqmp.dtsi +1 -0
@@ -692,6 +692,7 @@
                        compatible = "ceva,ahci-1v84";
                        status = "disabled";
                        reg = <0x0 0xfd0c0000 0x0 0x2000>;
+                       reg-names = "serdes";
                        interrupt-parent = <&gic>;
                        interrupts = <0 133 4>;
                        #stream-id-cells = <4>;

Unfortunately it is not that simple.

Quoted 4 lines
Quoted 4 lines

First of all you need to reflect this in dt binding doc in the kernel.
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit
.kern

el.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Ftorvalds%2Flinux.git%2Ftr

Quoted 1 line
Quoted 1 line

ee%2FDocumentation%2Fdevicetree%2Fbindings%2Fata%2Fahci-ceva.txt%3F

Quoted 1 line
Quoted 1 line

h%3Dv5.1-rc5&amp;data=02%7C01%7Cpeng.ma%40nxp.com%7Cc588ddff1b1

Quoted 1 line
Quoted 1 line

e471f645b08d6c24e54d7%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C

Quoted 1 line
Quoted 1 line

0%7C636910039050031150&amp;sdata=0Gsuo2uI3pot4VAhBr7SQUnCRYT7Xi

Quoted 8 lines
Quoted 4 lines

Ybybu6i1t%2Byzo%3D&amp;reserved=0

Did you record your compatible strings anywhere?

[Peng Ma] Thanks your quick reply.
You can find our binding document at:
(https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit
.kernel.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Ftorvalds%2Flinux.git

%

Quoted 1 line

2Ftree%2FDocumentation%2Fdevicetree%2Fbindings%2Fata%2Fahci-fsl-qoriq.

Quoted 1 line

txt%3Fh%3Dv5.1-rc5&amp;data=02%7C01%7Cpeng.ma%40nxp.com%7C977d 7871292f

Quoted 1 line

48332dbb08d6c2526b32%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C 0%7C6369

Quoted 1 line

10056581930082&amp;sdata=KQryE2RvI8jTOAPKGlGnx2NWYdawFUaTURyzd8 oets4%3

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

D&amp;reserved=0)

Interesting. Why did you create separate binding doc if you target the same ceva sata IP core? Any reason not to merge it together?
Anyway I see that this was added in 2015.

[Peng Ma] Although they are both ceva sata, our sata driver is different from yours in kernel to Initializa Vendor-specific registers, you could see our driver at kernel driver/ata/ ahci_qoriq.c.

I have briefly looked at it. They should be merged together. It happened to us too that we send driver out but didn't know who was the vendor in past and then we found out.

Quoted 9 lines
Quoted 7 lines
Quoted 1 line

I think your suggestion is better. But the first register cd address was got by

function dev_read_addr(), to keep consistency, I still prefer to use dev_read_addr_index(). What do you think?

We didn't have a need to have second address range that's why reg-names property wasn't used. Do they have all ecc addresses?

[Peng Ma] Some of our socs need to fixed sata errata. So we should write ecc addr. I didn't add reg-names to keep consistency of Xilinx sata soc.

Ok. I think that in this case you should pass different .data to driver.

struct platform_data {
	enum ceva_soc;
	bool ecc_present;
}

It means have current enum followed by bool with "true" for specific IPs which needs to have also ECC range.
Then you can better check that binding is correct.

And use _index there.

Thanks,
Michal

author
#9 lore raw
Quoted 330 lines

-----Original Message-----
From: Michal Simek <[email protected]>
Sent: 2019年4月16日 18:49
To: Peng Ma <[email protected]>; Michal Simek <[email protected]>; albert.u.boot at aribaud.net; sjg at chromium.org; Fabio Estevam <[email protected]>; York Sun <[email protected]>; Prabhakar Kushwaha <[email protected]>
Cc: Andy Tang <[email protected]>; Yinbo Zhu <[email protected]>; u-boot at lists.denx.de
Subject: Re: [EXT] Re: [PATCH 1/2] scsi: ceva: Clean up the driver code

WARNING: This email was created outside of NXP. DO NOT CLICK links or attachments unless you recognize the sender and know the content is safe.

Quoted 9 lines · Peng Ma
Quoted 9 lines

-----Original Message-----
From: Michal Simek <[email protected]>
Sent: 2019年4月16日 18:01
To: Peng Ma <[email protected]>; Michal Simek <[email protected]>; albert.u.boot at aribaud.net; sjg at chromium.org; Fabio Estevam <[email protected]>; York Sun <[email protected]>; Prabhakar Kushwaha

<[email protected]>

Quoted 20 lines
Quoted 20 lines

Cc: Andy Tang <[email protected]>; Yinbo Zhu <[email protected]>; u-boot at lists.denx.de
Subject: Re: [EXT] Re: [PATCH 1/2] scsi: ceva: Clean up the driver code

WARNING: This email was created outside of NXP. DO NOT CLICK links or attachments unless you recognize the sender and know the content is safe.

Quoted 9 lines · Peng Ma
Quoted 9 lines

-----Original Message-----
From: Michal Simek <[email protected]>
Sent: 2019年4月16日 17:31
To: Peng Ma <[email protected]>; Michal Simek <[email protected]>; albert.u.boot at aribaud.net; sjg at chromium.org; Fabio Estevam <[email protected]>; York Sun <[email protected]>; Prabhakar Kushwaha

Quoted 8 lines
Quoted 8 lines

<[email protected]>

Quoted 7 lines
Quoted 7 lines

Cc: Andy Tang <[email protected]>; Yinbo Zhu <[email protected]>; u-boot at lists.denx.de
Subject: Re: [EXT] Re: [PATCH 1/2] scsi: ceva: Clean up the driver code

WARNING: This email was created outside of NXP. DO NOT CLICK links or attachments unless you recognize the sender and know the content is

safe.

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines · Peng Ma
Quoted 7 lines
Quoted 7 lines

-----Original Message-----
From: Michal Simek <[email protected]>
Sent: 2019年4月16日 16:04
To: Peng Ma <[email protected]>; albert.u.boot at aribaud.net; sjg at chromium.org; Fabio Estevam <[email protected]>; York

Sun

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line

<[email protected]>; Prabhakar Kushwaha

<[email protected]>

Quoted 1 line
Quoted 1 line
Cc Andy Tang <[email protected]>; Yinbo Zhu

<[email protected]>;

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

michal.simek at xilinx.com; u-boot at lists.denx.de
Subject: [EXT] Re: [PATCH 1/2] scsi: ceva: Clean up the driver code

WARNING: This email was created outside of NXP. DO NOT CLICK links or attachments unless you recognize the sender and know the content is

Quoted 6 lines
Quoted 6 lines

safe.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines · Peng Ma
Quoted 1 line

Distinguish the ecc val by chassis version and move the ecc addr to

dts.

Quoted 56 lines
Quoted 56 lines
Quoted 56 lines
Quoted 56 lines
Quoted 56 lines
Quoted 56 lines
Quoted 5 lines

Add ls1028a soc support.

---
 drivers/ata/sata_ceva.c |   43

+++++++++++++++++++++++++------------------

drivers/ata/sata_ceva.c line 88

Quoted 9 lines
 1 files changed, 25 insertions(+), 18 deletions(-)
drivers/ata/sata_ceva.c +0 -0

index
8887be9..d26f712 100644

drivers/ata/sata_ceva.c +0 -0
@@ -88,20 +88,16 @@
 #define LS1021_CEVA_PHY4_CFG 0x064a080b  #define

LS1021_CEVA_PHY5_CFG

Quoted 38 lines

0x2aa86470

drivers/ata/sata_ceva.c +6 -8
-/* for ls1088a */
-#define LS1088_ECC_DIS_ADDR_CH2      0x100520
-#define LS1088_ECC_DIS_VAL_CH2       0x40000000
-
-/* ecc addr-val pair */
-#define ECC_DIS_ADDR_CH2     0x20140520
+/* ecc val pair */
+#define ECC_DIS_VAL_CH1              0x00020000
 #define ECC_DIS_VAL_CH2              0x80000000
-#define SATA_ECC_REG_ADDR    0x20220520
-#define SATA_ECC_DISABLE     0x00020000
+#define ECC_DIS_VAL_CH3              0x40000000
 
 enum ceva_soc {
      CEVA_1V84,
      CEVA_LS1012A,
      CEVA_LS1021A,
+     CEVA_LS1028A,
      CEVA_LS1043A,
      CEVA_LS1046A,
      CEVA_LS1088A,
@@ -110,12 +106,14 @@ enum ceva_soc {
 
 struct ceva_sata_priv {
      ulong base;
+     ulong ecc_base;
      enum ceva_soc soc;
      ulong flag;
 };
 
 static int ceva_init_sata(struct ceva_sata_priv *priv)  {
+     ulong ecc_addr = priv->ecc_base;
      ulong base = priv->base;
      ulong tmp;
 
@@ -132,38 +130,38 @@ static int ceva_init_sata(struct
Quoted 1 line

ceva_sata_priv

*priv)

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

drivers/ata/sata_ceva.c

Quoted 7 lines
              break;

      case CEVA_LS1021A:
drivers/ata/sata_ceva.c +2 -1
-             writel(SATA_ECC_DISABLE, SATA_ECC_REG_ADDR);
+             if (ecc_addr)
+                     writel(ECC_DIS_VAL_CH1, ecc_addr);
              writel(CEVA_PHY1_CFG, base +

AHCI_VEND_PPCFG);

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 1 line
              writel(LS1021_CEVA_PHY2_CFG, base +

AHCI_VEND_PP2C);

Quoted 1 line
              writel(LS1021_CEVA_PHY3_CFG, base +

AHCI_VEND_PP3C);

Quoted 1 line
              writel(LS1021_CEVA_PHY4_CFG, base +

AHCI_VEND_PP4C);

Quoted 1 line
              writel(LS1021_CEVA_PHY5_CFG, base +

AHCI_VEND_PP5C);

Quoted 1 line

writel(CEVA_TRANS_CFG, base +

AHCI_VEND_PTC);

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

drivers/ata/sata_ceva.c

Quoted 2 lines
drivers/ata/sata_ceva.c +0 -2
-             if (priv->flag & FLAG_COHERENT)
-                     writel(CEVA_AXICC_CFG, base +

LS1021_AHCI_VEND_AXICC);

Quoted 2 lines
              break;
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

drivers/ata/sata_ceva.c

Quoted 9 lines
      case CEVA_LS1012A:
      case CEVA_LS1043A:
      case CEVA_LS1046A:
drivers/ata/sata_ceva.c +2 -2
-             writel(ECC_DIS_VAL_CH2, ECC_DIS_ADDR_CH2);
-             /* fallthrough */
      case CEVA_LS2080A:
+             if (ecc_addr)
+                     writel(ECC_DIS_VAL_CH2, ecc_addr);
              writel(CEVA_PHY1_CFG, base +

AHCI_VEND_PPCFG);

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

writel(CEVA_TRANS_CFG, base +

AHCI_VEND_PTC);

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

drivers/ata/sata_ceva.c

Quoted 2 lines
drivers/ata/sata_ceva.c +0 -2
-             if (priv->flag & FLAG_COHERENT)
-                     writel(CEVA_AXICC_CFG, base +

AHCI_VEND_AXICC);

Quoted 2 lines
              break;
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

drivers/ata/sata_ceva.c

Quoted 3 lines
drivers/ata/sata_ceva.c +1 -1
+     case CEVA_LS1028A:
      case CEVA_LS1088A:
-             writel(LS1088_ECC_DIS_VAL_CH2,

LS1088_ECC_DIS_ADDR_CH2);

Quoted 3 lines
drivers/ata/sata_ceva.c +2 -0
+             if (ecc_addr)
+                     writel(ECC_DIS_VAL_CH3, ecc_addr);
              writel(CEVA_PHY1_CFG, base +

AHCI_VEND_PPCFG);

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

writel(CEVA_TRANS_CFG, base +

AHCI_VEND_PTC);

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

drivers/ata/sata_ceva.c

Quoted 2 lines
drivers/ata/sata_ceva.c +0 -2
-             if (priv->flag & FLAG_COHERENT)
-                     writel(CEVA_AXICC_CFG, base +

AHCI_VEND_AXICC);

Quoted 5 lines
              break;
      }
drivers/ata/sata_ceva.c +2 -0
+     if (priv->flag & FLAG_COHERENT)
+             writel(CEVA_AXICC_CFG, base +

AHCI_VEND_AXICC);

Quoted 48 lines
Quoted 48 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/ata/sata_ceva.c +1 -0
+
      return 0;
 }
@@ -187,6 +185,7 @@ static const struct udevice_id

sata_ceva_ids[] =

{

Quoted 41 lines
Quoted 41 lines
Quoted 16 lines
Quoted 16 lines
Quoted 10 lines
      { .compatible = "ceva,ahci-1v84", .data = CEVA_1V84 },
      { .compatible = "fsl,ls1012a-ahci", .data = CEVA_LS1012A },
      { .compatible = "fsl,ls1021a-ahci", .data = CEVA_LS1021A
},
+     { .compatible = "fsl,ls1028a-ahci", .data = CEVA_LS1028A
+ },
      { .compatible = "fsl,ls1043a-ahci", .data = CEVA_LS1043A },
      { .compatible = "fsl,ls1046a-ahci", .data = CEVA_LS1046A },
      { .compatible = "fsl,ls1088a-ahci", .data = CEVA_LS1088A
}, @@
Quoted 2 lines

-205,8 +204,16 @@ static int sata_ceva_ofdata_to_platdata(struct udevice

*dev)

Quoted 3 lines
      if (priv->base == FDT_ADDR_T_NONE)
              return -EINVAL;
Quoted 7 lines
Quoted 5 lines
Quoted 1 line

+ priv->ecc_base = dev_read_addr_index(dev, 1);

It would be better to do it via reg-name instead of index. But that's up to your binding doc.

[Peng Ma] OK, could I change arch/arm/dts/zynqmp.dtsi file sata node as

fallows?

Quoted 7 lines
arch/arm/dts/zynqmp.dtsi +0 -0

index
dfb6ebc..9ad2d84 100644

arch/arm/dts/zynqmp.dtsi line 698

Quoted 7 lines
arch/arm/dts/zynqmp.dtsi +1 -0
@@ -692,6 +692,7 @@
                        compatible = "ceva,ahci-1v84";
                        status = "disabled";
                        reg = <0x0 0xfd0c0000 0x0 0x2000>;
+                       reg-names = "serdes";
                        interrupt-parent = <&gic>;
                        interrupts = <0 133 4>;
                        #stream-id-cells = <4>;

Unfortunately it is not that simple.

Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Quoted 5 lines

First of all you need to reflect this in dt binding doc in the kernel.
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fg
it
.kern

el.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Ftorvalds%2Flinux.git%2Ftr

Quoted 2 lines
Quoted 2 lines
Quoted 1 line
Quoted 1 line

ee%2FDocumentation%2Fdevicetree%2Fbindings%2Fata%2Fahci-ceva.txt%3F

Quoted 2 lines
Quoted 2 lines
Quoted 1 line
Quoted 1 line

h%3Dv5.1-rc5&amp;data=02%7C01%7Cpeng.ma%40nxp.com%7Cc588ddff1b1

Quoted 2 lines
Quoted 2 lines
Quoted 1 line
Quoted 1 line

e471f645b08d6c24e54d7%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C

Quoted 2 lines
Quoted 2 lines
Quoted 1 line
Quoted 1 line

0%7C636910039050031150&amp;sdata=0Gsuo2uI3pot4VAhBr7SQUnCRYT7Xi

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 4 lines

Ybybu6i1t%2Byzo%3D&amp;reserved=0

Did you record your compatible strings anywhere?

[Peng Ma] Thanks your quick reply.
You can find our binding document at:
(https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fg
it .kernel.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Ftorvalds%2Flinux.

gi

Quoted 4 lines
Quoted 4 lines
Quoted 1 line

t

%

Quoted 1 line

2Ftree%2FDocumentation%2Fdevicetree%2Fbindings%2Fata%2Fahci-fsl-qoriq.

Quoted 2 lines
Quoted 2 lines
Quoted 1 line

txt%3Fh%3Dv5.1-rc5&amp;data=02%7C01%7Cpeng.ma%40nxp.com%7C977d

Quoted 3 lines
Quoted 3 lines

7871292f

Quoted 1 line

48332dbb08d6c2526b32%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C

Quoted 3 lines
Quoted 3 lines

0%7C6369

Quoted 1 line

10056581930082&amp;sdata=KQryE2RvI8jTOAPKGlGnx2NWYdawFUaTURyzd8

Quoted 9 lines
Quoted 7 lines

oets4%3

Quoted 1 line

D&amp;reserved=0)

Interesting. Why did you create separate binding doc if you target the same ceva sata IP core? Any reason not to merge it together? Anyway I see that this was added in 2015.

[Peng Ma] Although they are both ceva sata, our sata driver is different from yours in kernel to Initializa Vendor-specific registers, you could

see our driver at kernel driver/ata/ ahci_qoriq.c.

I have briefly looked at it. They should be merged together. It happened to us too that we send driver out but didn't know who was the vendor in past and then we found out.

Quoted 9 lines
Quoted 8 lines
Quoted 2 lines

I think your suggestion is better. But the first register cd address was got by

function dev_read_addr(), to keep consistency, I still prefer to use dev_read_addr_index(). What do you think?

We didn't have a need to have second address range that's why reg-names property wasn't used. Do they have all ecc addresses?

[Peng Ma] Some of our socs need to fixed sata errata. So we should write ecc

addr.

Quoted 1 line

I didn't add reg-names to keep consistency of Xilinx sata soc.

Ok. I think that in this case you should pass different .data to driver.

struct platform_data {
       enum ceva_soc;
       bool ecc_present;
}
Quoted 5 lines

It means have current enum followed by bool with "true" for specific IPs which needs to have also ECC range.
Then you can better check that binding is correct.

And use _index there.

[Peng Ma] As far as I am concerned, It is not necessary to do this, I would rather lean on the former way as fallows:

drivers/ata/sata_ceva.c +10 -2
index d26f712..a1d452a 100644
@@ -196,6 +196,10 @@ static const struct udevice_id sata_ceva_ids[] = {
 static int sata_ceva_ofdata_to_platdata(struct udevice *dev)
 {
        struct ceva_sata_priv *priv = dev_get_priv(dev);
+       const void *blob = gd->fdt_blob;
+       int node = dev_of_offset(dev);
+       struct fdt_resource res_regs;
+       int ret;
 
        if (dev_read_bool(dev, "dma-coherent"))
                priv->flag |= FLAG_COHERENT;
@@ -204,9 +208,13 @@ static int sata_ceva_ofdata_to_platdata(struct udevice *dev)
        if (priv->base == FDT_ADDR_T_NONE)
                return -EINVAL;
 
-       priv->ecc_base = dev_read_addr_index(dev, 1);
-       if (priv->ecc_base == FDT_ADDR_T_NONE)
+       ret = fdt_get_named_resource(blob, node, "reg", "reg-names",
+                                    "ecc-addr", &res_regs);
+       if (ret) {
+               debug("Error: can't get ecc addresses(ret = %d)!\n", ret);
                priv->ecc_base = 0;
+       } else
+               priv->ecc_base = res_regs.start;
 
        priv->soc = dev_get_driver_data(dev);

What do you think?

Best Regards,
Peng

Quoted 3 lines

Thanks,
Michal

#10 lore raw
Quoted 342 lines · Peng Ma
Quoted 330 lines

-----Original Message-----
From: Michal Simek <[email protected]>
Sent: 2019年4月16日 18:49
To: Peng Ma <[email protected]>; Michal Simek <[email protected]>; albert.u.boot at aribaud.net; sjg at chromium.org; Fabio Estevam <[email protected]>; York Sun <[email protected]>; Prabhakar Kushwaha <[email protected]>
Cc: Andy Tang <[email protected]>; Yinbo Zhu <[email protected]>; u-boot at lists.denx.de
Subject: Re: [EXT] Re: [PATCH 1/2] scsi: ceva: Clean up the driver code

WARNING: This email was created outside of NXP. DO NOT CLICK links or attachments unless you recognize the sender and know the content is safe.

Quoted 9 lines · Peng Ma
Quoted 9 lines

-----Original Message-----
From: Michal Simek <[email protected]>
Sent: 2019年4月16日 18:01
To: Peng Ma <[email protected]>; Michal Simek <[email protected]>; albert.u.boot at aribaud.net; sjg at chromium.org; Fabio Estevam <[email protected]>; York Sun <[email protected]>; Prabhakar Kushwaha

<[email protected]>

Quoted 20 lines
Quoted 20 lines

Cc: Andy Tang <[email protected]>; Yinbo Zhu <[email protected]>; u-boot at lists.denx.de
Subject: Re: [EXT] Re: [PATCH 1/2] scsi: ceva: Clean up the driver code

WARNING: This email was created outside of NXP. DO NOT CLICK links or attachments unless you recognize the sender and know the content is safe.

Quoted 9 lines · Peng Ma
Quoted 9 lines

-----Original Message-----
From: Michal Simek <[email protected]>
Sent: 2019年4月16日 17:31
To: Peng Ma <[email protected]>; Michal Simek <[email protected]>; albert.u.boot at aribaud.net; sjg at chromium.org; Fabio Estevam <[email protected]>; York Sun <[email protected]>; Prabhakar Kushwaha

Quoted 8 lines
Quoted 8 lines

<[email protected]>

Quoted 7 lines
Quoted 7 lines

Cc: Andy Tang <[email protected]>; Yinbo Zhu <[email protected]>; u-boot at lists.denx.de
Subject: Re: [EXT] Re: [PATCH 1/2] scsi: ceva: Clean up the driver code

WARNING: This email was created outside of NXP. DO NOT CLICK links or attachments unless you recognize the sender and know the content is

safe.

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines · Peng Ma
Quoted 7 lines
Quoted 7 lines

-----Original Message-----
From: Michal Simek <[email protected]>
Sent: 2019年4月16日 16:04
To: Peng Ma <[email protected]>; albert.u.boot at aribaud.net; sjg at chromium.org; Fabio Estevam <[email protected]>; York

Sun

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line

<[email protected]>; Prabhakar Kushwaha

<[email protected]>

Quoted 1 line
Quoted 1 line
Cc Andy Tang <[email protected]>; Yinbo Zhu

<[email protected]>;

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

michal.simek at xilinx.com; u-boot at lists.denx.de
Subject: [EXT] Re: [PATCH 1/2] scsi: ceva: Clean up the driver code

WARNING: This email was created outside of NXP. DO NOT CLICK links or attachments unless you recognize the sender and know the content is

Quoted 6 lines
Quoted 6 lines

safe.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines · Peng Ma
Quoted 1 line

Distinguish the ecc val by chassis version and move the ecc addr to

dts.

Quoted 56 lines
Quoted 56 lines
Quoted 56 lines
Quoted 56 lines
Quoted 56 lines
Quoted 56 lines
Quoted 5 lines

Add ls1028a soc support.

---
 drivers/ata/sata_ceva.c |   43

+++++++++++++++++++++++++------------------

drivers/ata/sata_ceva.c line 88

Quoted 9 lines
 1 files changed, 25 insertions(+), 18 deletions(-)
drivers/ata/sata_ceva.c +0 -0

index
8887be9..d26f712 100644

drivers/ata/sata_ceva.c +0 -0
@@ -88,20 +88,16 @@
 #define LS1021_CEVA_PHY4_CFG 0x064a080b  #define

LS1021_CEVA_PHY5_CFG

Quoted 38 lines

0x2aa86470

drivers/ata/sata_ceva.c +6 -8
-/* for ls1088a */
-#define LS1088_ECC_DIS_ADDR_CH2      0x100520
-#define LS1088_ECC_DIS_VAL_CH2       0x40000000
-
-/* ecc addr-val pair */
-#define ECC_DIS_ADDR_CH2     0x20140520
+/* ecc val pair */
+#define ECC_DIS_VAL_CH1              0x00020000
 #define ECC_DIS_VAL_CH2              0x80000000
-#define SATA_ECC_REG_ADDR    0x20220520
-#define SATA_ECC_DISABLE     0x00020000
+#define ECC_DIS_VAL_CH3              0x40000000
 
 enum ceva_soc {
      CEVA_1V84,
      CEVA_LS1012A,
      CEVA_LS1021A,
+     CEVA_LS1028A,
      CEVA_LS1043A,
      CEVA_LS1046A,
      CEVA_LS1088A,
@@ -110,12 +106,14 @@ enum ceva_soc {
 
 struct ceva_sata_priv {
      ulong base;
+     ulong ecc_base;
      enum ceva_soc soc;
      ulong flag;
 };
 
 static int ceva_init_sata(struct ceva_sata_priv *priv)  {
+     ulong ecc_addr = priv->ecc_base;
      ulong base = priv->base;
      ulong tmp;
 
@@ -132,38 +130,38 @@ static int ceva_init_sata(struct
Quoted 1 line

ceva_sata_priv

*priv)

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

drivers/ata/sata_ceva.c

Quoted 7 lines
              break;

      case CEVA_LS1021A:
drivers/ata/sata_ceva.c +2 -1
-             writel(SATA_ECC_DISABLE, SATA_ECC_REG_ADDR);
+             if (ecc_addr)
+                     writel(ECC_DIS_VAL_CH1, ecc_addr);
              writel(CEVA_PHY1_CFG, base +

AHCI_VEND_PPCFG);

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 1 line
              writel(LS1021_CEVA_PHY2_CFG, base +

AHCI_VEND_PP2C);

Quoted 1 line
              writel(LS1021_CEVA_PHY3_CFG, base +

AHCI_VEND_PP3C);

Quoted 1 line
              writel(LS1021_CEVA_PHY4_CFG, base +

AHCI_VEND_PP4C);

Quoted 1 line
              writel(LS1021_CEVA_PHY5_CFG, base +

AHCI_VEND_PP5C);

Quoted 1 line

writel(CEVA_TRANS_CFG, base +

AHCI_VEND_PTC);

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

drivers/ata/sata_ceva.c

Quoted 2 lines
drivers/ata/sata_ceva.c +0 -2
-             if (priv->flag & FLAG_COHERENT)
-                     writel(CEVA_AXICC_CFG, base +

LS1021_AHCI_VEND_AXICC);

Quoted 2 lines
              break;
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

drivers/ata/sata_ceva.c

Quoted 9 lines
      case CEVA_LS1012A:
      case CEVA_LS1043A:
      case CEVA_LS1046A:
drivers/ata/sata_ceva.c +2 -2
-             writel(ECC_DIS_VAL_CH2, ECC_DIS_ADDR_CH2);
-             /* fallthrough */
      case CEVA_LS2080A:
+             if (ecc_addr)
+                     writel(ECC_DIS_VAL_CH2, ecc_addr);
              writel(CEVA_PHY1_CFG, base +

AHCI_VEND_PPCFG);

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

writel(CEVA_TRANS_CFG, base +

AHCI_VEND_PTC);

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

drivers/ata/sata_ceva.c

Quoted 2 lines
drivers/ata/sata_ceva.c +0 -2
-             if (priv->flag & FLAG_COHERENT)
-                     writel(CEVA_AXICC_CFG, base +

AHCI_VEND_AXICC);

Quoted 2 lines
              break;
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

drivers/ata/sata_ceva.c

Quoted 3 lines
drivers/ata/sata_ceva.c +1 -1
+     case CEVA_LS1028A:
      case CEVA_LS1088A:
-             writel(LS1088_ECC_DIS_VAL_CH2,

LS1088_ECC_DIS_ADDR_CH2);

Quoted 3 lines
drivers/ata/sata_ceva.c +2 -0
+             if (ecc_addr)
+                     writel(ECC_DIS_VAL_CH3, ecc_addr);
              writel(CEVA_PHY1_CFG, base +

AHCI_VEND_PPCFG);

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

writel(CEVA_TRANS_CFG, base +

AHCI_VEND_PTC);

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

drivers/ata/sata_ceva.c

Quoted 2 lines
drivers/ata/sata_ceva.c +0 -2
-             if (priv->flag & FLAG_COHERENT)
-                     writel(CEVA_AXICC_CFG, base +

AHCI_VEND_AXICC);

Quoted 5 lines
              break;
      }
drivers/ata/sata_ceva.c +2 -0
+     if (priv->flag & FLAG_COHERENT)
+             writel(CEVA_AXICC_CFG, base +

AHCI_VEND_AXICC);

Quoted 48 lines
Quoted 48 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/ata/sata_ceva.c +1 -0
+
      return 0;
 }
@@ -187,6 +185,7 @@ static const struct udevice_id

sata_ceva_ids[] =

{

Quoted 41 lines
Quoted 41 lines
Quoted 16 lines
Quoted 16 lines
Quoted 10 lines
      { .compatible = "ceva,ahci-1v84", .data = CEVA_1V84 },
      { .compatible = "fsl,ls1012a-ahci", .data = CEVA_LS1012A },
      { .compatible = "fsl,ls1021a-ahci", .data = CEVA_LS1021A
},
+     { .compatible = "fsl,ls1028a-ahci", .data = CEVA_LS1028A
+ },
      { .compatible = "fsl,ls1043a-ahci", .data = CEVA_LS1043A },
      { .compatible = "fsl,ls1046a-ahci", .data = CEVA_LS1046A },
      { .compatible = "fsl,ls1088a-ahci", .data = CEVA_LS1088A
}, @@
Quoted 2 lines

-205,8 +204,16 @@ static int sata_ceva_ofdata_to_platdata(struct udevice

*dev)

Quoted 3 lines
      if (priv->base == FDT_ADDR_T_NONE)
              return -EINVAL;
Quoted 7 lines
Quoted 5 lines
Quoted 1 line

+ priv->ecc_base = dev_read_addr_index(dev, 1);

It would be better to do it via reg-name instead of index. But that's up to your binding doc.

[Peng Ma] OK, could I change arch/arm/dts/zynqmp.dtsi file sata node as

fallows?

Quoted 7 lines
arch/arm/dts/zynqmp.dtsi +0 -0

index
dfb6ebc..9ad2d84 100644

arch/arm/dts/zynqmp.dtsi line 698

Quoted 7 lines
arch/arm/dts/zynqmp.dtsi +1 -0
@@ -692,6 +692,7 @@
                        compatible = "ceva,ahci-1v84";
                        status = "disabled";
                        reg = <0x0 0xfd0c0000 0x0 0x2000>;
+                       reg-names = "serdes";
                        interrupt-parent = <&gic>;
                        interrupts = <0 133 4>;
                        #stream-id-cells = <4>;

Unfortunately it is not that simple.

Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Quoted 5 lines

First of all you need to reflect this in dt binding doc in the kernel.
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fg
it
.kern

el.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Ftorvalds%2Flinux.git%2Ftr

Quoted 2 lines
Quoted 2 lines
Quoted 1 line
Quoted 1 line

ee%2FDocumentation%2Fdevicetree%2Fbindings%2Fata%2Fahci-ceva.txt%3F

Quoted 2 lines
Quoted 2 lines
Quoted 1 line
Quoted 1 line

h%3Dv5.1-rc5&amp;data=02%7C01%7Cpeng.ma%40nxp.com%7Cc588ddff1b1

Quoted 2 lines
Quoted 2 lines
Quoted 1 line
Quoted 1 line

e471f645b08d6c24e54d7%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C

Quoted 2 lines
Quoted 2 lines
Quoted 1 line
Quoted 1 line

0%7C636910039050031150&amp;sdata=0Gsuo2uI3pot4VAhBr7SQUnCRYT7Xi

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 4 lines

Ybybu6i1t%2Byzo%3D&amp;reserved=0

Did you record your compatible strings anywhere?

[Peng Ma] Thanks your quick reply.
You can find our binding document at:
(https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fg
it .kernel.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Ftorvalds%2Flinux.

gi

Quoted 4 lines
Quoted 4 lines
Quoted 1 line

t

%

Quoted 1 line

2Ftree%2FDocumentation%2Fdevicetree%2Fbindings%2Fata%2Fahci-fsl-qoriq.

Quoted 2 lines
Quoted 2 lines
Quoted 1 line

txt%3Fh%3Dv5.1-rc5&amp;data=02%7C01%7Cpeng.ma%40nxp.com%7C977d

Quoted 3 lines
Quoted 3 lines

7871292f

Quoted 1 line

48332dbb08d6c2526b32%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C

Quoted 3 lines
Quoted 3 lines

0%7C6369

Quoted 1 line

10056581930082&amp;sdata=KQryE2RvI8jTOAPKGlGnx2NWYdawFUaTURyzd8

Quoted 9 lines
Quoted 7 lines

oets4%3

Quoted 1 line

D&amp;reserved=0)

Interesting. Why did you create separate binding doc if you target the same ceva sata IP core? Any reason not to merge it together? Anyway I see that this was added in 2015.

[Peng Ma] Although they are both ceva sata, our sata driver is different from yours in kernel to Initializa Vendor-specific registers, you could

see our driver at kernel driver/ata/ ahci_qoriq.c.

I have briefly looked at it. They should be merged together. It happened to us too that we send driver out but didn't know who was the vendor in past and then we found out.

Quoted 9 lines
Quoted 8 lines
Quoted 2 lines

I think your suggestion is better. But the first register cd address was got by

function dev_read_addr(), to keep consistency, I still prefer to use dev_read_addr_index(). What do you think?

We didn't have a need to have second address range that's why reg-names property wasn't used. Do they have all ecc addresses?

[Peng Ma] Some of our socs need to fixed sata errata. So we should write ecc

addr.

Quoted 1 line

I didn't add reg-names to keep consistency of Xilinx sata soc.

Ok. I think that in this case you should pass different .data to driver.

struct platform_data {
       enum ceva_soc;
       bool ecc_present;
}
Quoted 5 lines

It means have current enum followed by bool with "true" for specific IPs which needs to have also ECC range.
Then you can better check that binding is correct.

And use _index there.

[Peng Ma] As far as I am concerned, It is not necessary to do this, I would rather lean on the former way as fallows:

drivers/ata/sata_ceva.c +0 -0
index d26f712..a1d452a 100644

drivers/ata/sata_ceva.c static const struct udevice_id sata_ceva_ids[] = { · line 199

Quoted 4 lines
drivers/ata/sata_ceva.c +1 -0
@@ -196,6 +196,10 @@ static const struct udevice_id sata_ceva_ids[] = {
 static int sata_ceva_ofdata_to_platdata(struct udevice *dev)
 {
        struct ceva_sata_priv *priv = dev_get_priv(dev);
+       const void *blob = gd->fdt_blob;

gd is suggesting that you use incorrect functions.
We are trying to get rid of gd from device drivers. Please take a look at live tree functions if there is any alternative there.

Quoted 21 lines
drivers/ata/sata_ceva.c +9 -2
+       int node = dev_of_offset(dev);
+       struct fdt_resource res_regs;
+       int ret;
 
        if (dev_read_bool(dev, "dma-coherent"))
                priv->flag |= FLAG_COHERENT;
@@ -204,9 +208,13 @@ static int sata_ceva_ofdata_to_platdata(struct udevice *dev)
        if (priv->base == FDT_ADDR_T_NONE)
                return -EINVAL;
 
-       priv->ecc_base = dev_read_addr_index(dev, 1);
-       if (priv->ecc_base == FDT_ADDR_T_NONE)
+       ret = fdt_get_named_resource(blob, node, "reg", "reg-names",
+                                    "ecc-addr", &res_regs);
+       if (ret) {
+               debug("Error: can't get ecc addresses(ret = %d)!\n", ret);
                priv->ecc_base = 0;
+       } else
+               priv->ecc_base = res_regs.start;
 
        priv->soc = dev_get_driver_data(dev);
Quoted 1 line

What do you think?

One thing I would like to avoid is that we will get any error even in debug for IPs which don't have this ecc space.
And also that we will get this errors for IPs which should have this ecc space.

Thanks,
Michal

author
#11 lore raw
Quoted 414 lines

-----Original Message-----
From: Michal Simek <[email protected]>
Sent: 2019年4月17日 13:58
To: Peng Ma <[email protected]>; Michal Simek <[email protected]>; albert.u.boot at aribaud.net; sjg at chromium.org; Fabio Estevam <[email protected]>; York Sun <[email protected]>; Prabhakar Kushwaha <[email protected]>
Cc: Andy Tang <[email protected]>; Yinbo Zhu <[email protected]>; u-boot at lists.denx.de
Subject: Re: [EXT] Re: [PATCH 1/2] scsi: ceva: Clean up the driver code

WARNING: This email was created outside of NXP. DO NOT CLICK links or attachments unless you recognize the sender and know the content is safe.

Quoted 9 lines · Peng Ma
Quoted 9 lines

-----Original Message-----
From: Michal Simek <[email protected]>
Sent: 2019年4月16日 18:49
To: Peng Ma <[email protected]>; Michal Simek <[email protected]>; albert.u.boot at aribaud.net; sjg at chromium.org; Fabio Estevam <[email protected]>; York Sun <[email protected]>; Prabhakar Kushwaha

<[email protected]>

Quoted 20 lines
Quoted 20 lines

Cc: Andy Tang <[email protected]>; Yinbo Zhu <[email protected]>; u-boot at lists.denx.de
Subject: Re: [EXT] Re: [PATCH 1/2] scsi: ceva: Clean up the driver code

WARNING: This email was created outside of NXP. DO NOT CLICK links or attachments unless you recognize the sender and know the content is safe.

Quoted 9 lines · Peng Ma
Quoted 9 lines

-----Original Message-----
From: Michal Simek <[email protected]>
Sent: 2019年4月16日 18:01
To: Peng Ma <[email protected]>; Michal Simek <[email protected]>; albert.u.boot at aribaud.net; sjg at chromium.org; Fabio Estevam <[email protected]>; York Sun <[email protected]>; Prabhakar Kushwaha

Quoted 8 lines
Quoted 8 lines

<[email protected]>

Quoted 7 lines
Quoted 7 lines

Cc: Andy Tang <[email protected]>; Yinbo Zhu <[email protected]>; u-boot at lists.denx.de
Subject: Re: [EXT] Re: [PATCH 1/2] scsi: ceva: Clean up the driver code

WARNING: This email was created outside of NXP. DO NOT CLICK links or attachments unless you recognize the sender and know the content is

safe.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines · Peng Ma
Quoted 2 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

-----Original Message-----
From: Michal Simek <[email protected]>
Sent: 2019年4月16日 17:31
To: Peng Ma <[email protected]>; Michal Simek <[email protected]>; albert.u.boot at aribaud.net; sjg at chromium.org; Fabio Estevam <[email protected]>; York

Sun

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line

<[email protected]>; Prabhakar Kushwaha

<[email protected]>

Quoted 1 line
Quoted 1 line
Cc Andy Tang <[email protected]>; Yinbo Zhu

<[email protected]>;

Quoted 92 lines
Quoted 92 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

u-boot at lists.denx.de
Subject: Re: [EXT] Re: [PATCH 1/2] scsi: ceva: Clean up the driver code

WARNING: This email was created outside of NXP. DO NOT CLICK links or attachments unless you recognize the sender and know the content is

safe.

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines · Peng Ma
Quoted 7 lines
Quoted 7 lines

-----Original Message-----
From: Michal Simek <[email protected]>
Sent: 2019年4月16日 16:04
To: Peng Ma <[email protected]>; albert.u.boot at aribaud.net; sjg at chromium.org; Fabio Estevam <[email protected]>; York

Sun

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line

<[email protected]>; Prabhakar Kushwaha

<[email protected]>

Quoted 1 line
Quoted 1 line
Cc Andy Tang <[email protected]>; Yinbo Zhu

<[email protected]>;

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

michal.simek at xilinx.com; u-boot at lists.denx.de
Subject: [EXT] Re: [PATCH 1/2] scsi: ceva: Clean up the driver code

WARNING: This email was created outside of NXP. DO NOT CLICK links or attachments unless you recognize the sender and know the content is

Quoted 7 lines
Quoted 7 lines

safe.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines · Peng Ma
Quoted 2 lines

Distinguish the ecc val by chassis version and move the ecc addr to

dts.

Quoted 53 lines
Quoted 53 lines
Quoted 53 lines
Quoted 53 lines
Quoted 53 lines
Quoted 53 lines
Quoted 5 lines

Add ls1028a soc support.

---
 drivers/ata/sata_ceva.c |   43

+++++++++++++++++++++++++------------------

drivers/ata/sata_ceva.c line 88

Quoted 9 lines
 1 files changed, 25 insertions(+), 18 deletions(-)
drivers/ata/sata_ceva.c +0 -0

index
8887be9..d26f712 100644

drivers/ata/sata_ceva.c +0 -0
@@ -88,20 +88,16 @@
 #define LS1021_CEVA_PHY4_CFG 0x064a080b  #define

LS1021_CEVA_PHY5_CFG

Quoted 37 lines

0x2aa86470

drivers/ata/sata_ceva.c +6 -8
-/* for ls1088a */
-#define LS1088_ECC_DIS_ADDR_CH2      0x100520
-#define LS1088_ECC_DIS_VAL_CH2       0x40000000
-
-/* ecc addr-val pair */
-#define ECC_DIS_ADDR_CH2     0x20140520
+/* ecc val pair */
+#define ECC_DIS_VAL_CH1              0x00020000
 #define ECC_DIS_VAL_CH2              0x80000000
-#define SATA_ECC_REG_ADDR    0x20220520
-#define SATA_ECC_DISABLE     0x00020000
+#define ECC_DIS_VAL_CH3              0x40000000
 
 enum ceva_soc {
      CEVA_1V84,
      CEVA_LS1012A,
      CEVA_LS1021A,
+     CEVA_LS1028A,
      CEVA_LS1043A,
      CEVA_LS1046A,
      CEVA_LS1088A,
@@ -110,12 +106,14 @@ enum ceva_soc {
 
 struct ceva_sata_priv {
      ulong base;
+     ulong ecc_base;
      enum ceva_soc soc;
      ulong flag;
 };
 
 static int ceva_init_sata(struct ceva_sata_priv *priv)  {
+     ulong ecc_addr = priv->ecc_base;
      ulong base = priv->base;
      ulong tmp;
 
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
drivers/ata/sata_ceva.c +0 -0
@@ -132,38 +130,38 @@ static int ceva_init_sata(struct

ceva_sata_priv

*priv)

Quoted 4 lines
              break;

      case CEVA_LS1021A:

- writel(SATA_ECC_DISABLE,

SATA_ECC_REG_ADDR);

Quoted 104 lines
Quoted 104 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

drivers/ata/sata_ceva.c

Quoted 3 lines
drivers/ata/sata_ceva.c +2 -0
+             if (ecc_addr)
+                     writel(ECC_DIS_VAL_CH1, ecc_addr);
              writel(CEVA_PHY1_CFG, base +

AHCI_VEND_PPCFG);

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 1 line
              writel(LS1021_CEVA_PHY2_CFG, base +

AHCI_VEND_PP2C);

Quoted 1 line
              writel(LS1021_CEVA_PHY3_CFG, base +

AHCI_VEND_PP3C);

Quoted 1 line
              writel(LS1021_CEVA_PHY4_CFG, base +

AHCI_VEND_PP4C);

Quoted 1 line
              writel(LS1021_CEVA_PHY5_CFG, base +

AHCI_VEND_PP5C);

Quoted 1 line

writel(CEVA_TRANS_CFG, base +

AHCI_VEND_PTC);

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

drivers/ata/sata_ceva.c

Quoted 2 lines
drivers/ata/sata_ceva.c +0 -2
-             if (priv->flag & FLAG_COHERENT)
-                     writel(CEVA_AXICC_CFG, base +

LS1021_AHCI_VEND_AXICC);

Quoted 2 lines
              break;
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

drivers/ata/sata_ceva.c

Quoted 9 lines
      case CEVA_LS1012A:
      case CEVA_LS1043A:
      case CEVA_LS1046A:
drivers/ata/sata_ceva.c +2 -2
-             writel(ECC_DIS_VAL_CH2, ECC_DIS_ADDR_CH2);
-             /* fallthrough */
      case CEVA_LS2080A:
+             if (ecc_addr)
+                     writel(ECC_DIS_VAL_CH2, ecc_addr);
              writel(CEVA_PHY1_CFG, base +

AHCI_VEND_PPCFG);

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

writel(CEVA_TRANS_CFG, base +

AHCI_VEND_PTC);

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

drivers/ata/sata_ceva.c

Quoted 2 lines
drivers/ata/sata_ceva.c +0 -2
-             if (priv->flag & FLAG_COHERENT)
-                     writel(CEVA_AXICC_CFG, base +

AHCI_VEND_AXICC);

Quoted 2 lines
              break;
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

drivers/ata/sata_ceva.c

Quoted 3 lines
drivers/ata/sata_ceva.c +1 -1
+     case CEVA_LS1028A:
      case CEVA_LS1088A:
-             writel(LS1088_ECC_DIS_VAL_CH2,

LS1088_ECC_DIS_ADDR_CH2);

Quoted 3 lines
drivers/ata/sata_ceva.c +2 -0
+             if (ecc_addr)
+                     writel(ECC_DIS_VAL_CH3, ecc_addr);
              writel(CEVA_PHY1_CFG, base +

AHCI_VEND_PPCFG);

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

writel(CEVA_TRANS_CFG, base +

AHCI_VEND_PTC);

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

drivers/ata/sata_ceva.c

Quoted 2 lines
drivers/ata/sata_ceva.c +0 -2
-             if (priv->flag & FLAG_COHERENT)
-                     writel(CEVA_AXICC_CFG, base +

AHCI_VEND_AXICC);

Quoted 5 lines
              break;
      }
drivers/ata/sata_ceva.c +2 -0
+     if (priv->flag & FLAG_COHERENT)
+             writel(CEVA_AXICC_CFG, base +

AHCI_VEND_AXICC);

Quoted 49 lines
Quoted 49 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/ata/sata_ceva.c +1 -0
+
      return 0;
 }
@@ -187,6 +185,7 @@ static const struct udevice_id

sata_ceva_ids[] =

{

Quoted 42 lines
Quoted 42 lines
Quoted 17 lines
Quoted 17 lines
Quoted 10 lines
      { .compatible = "ceva,ahci-1v84", .data = CEVA_1V84 },
      { .compatible = "fsl,ls1012a-ahci", .data = CEVA_LS1012A },
      { .compatible = "fsl,ls1021a-ahci", .data = CEVA_LS1021A
},
+     { .compatible = "fsl,ls1028a-ahci", .data = CEVA_LS1028A
+ },
      { .compatible = "fsl,ls1043a-ahci", .data = CEVA_LS1043A },
      { .compatible = "fsl,ls1046a-ahci", .data = CEVA_LS1046A },
      { .compatible = "fsl,ls1088a-ahci", .data = CEVA_LS1088A
}, @@
Quoted 3 lines

-205,8 +204,16 @@ static int
sata_ceva_ofdata_to_platdata(struct
udevice

*dev)

Quoted 3 lines
      if (priv->base == FDT_ADDR_T_NONE)
              return -EINVAL;
Quoted 7 lines
Quoted 5 lines
Quoted 1 line

+ priv->ecc_base = dev_read_addr_index(dev, 1);

It would be better to do it via reg-name instead of index. But that's up to your binding doc.

[Peng Ma] OK, could I change arch/arm/dts/zynqmp.dtsi file sata node as

fallows?

Quoted 7 lines
arch/arm/dts/zynqmp.dtsi +0 -0

index
dfb6ebc..9ad2d84 100644

arch/arm/dts/zynqmp.dtsi line 698

Quoted 7 lines
arch/arm/dts/zynqmp.dtsi +1 -0
@@ -692,6 +692,7 @@
                        compatible = "ceva,ahci-1v84";
                        status = "disabled";
                        reg = <0x0 0xfd0c0000 0x0 0x2000>;
+                       reg-names = "serdes";
                        interrupt-parent = <&gic>;
                        interrupts = <0 133 4>;
                        #stream-id-cells = <4>;

Unfortunately it is not that simple.

Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 6 lines

First of all you need to reflect this in dt binding doc in the kernel.
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2
Fg
it
.kern

el.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Ftorvalds%2Flinux.git%2Ftr

Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
Quoted 1 line

ee%2FDocumentation%2Fdevicetree%2Fbindings%2Fata%2Fahci-ceva.txt%3F

Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
Quoted 1 line

h%3Dv5.1-rc5&amp;data=02%7C01%7Cpeng.ma%40nxp.com%7Cc588ddff1b1

Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
Quoted 1 line

e471f645b08d6c24e54d7%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C

Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
Quoted 1 line

0%7C636910039050031150&amp;sdata=0Gsuo2uI3pot4VAhBr7SQUnCRYT7Xi

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 4 lines

Ybybu6i1t%2Byzo%3D&amp;reserved=0

Did you record your compatible strings anywhere?

[Peng Ma] Thanks your quick reply.
You can find our binding document at:
(https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2
Fg
it .kernel.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Ftorvalds%2Flin

ux.

Quoted 6 lines
Quoted 6 lines

gi

Quoted 4 lines
Quoted 4 lines
Quoted 1 line

t

%

Quoted 1 line

2Ftree%2FDocumentation%2Fdevicetree%2Fbindings%2Fata%2Fahci-fsl-qoriq.

Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line

txt%3Fh%3Dv5.1-rc5&amp;data=02%7C01%7Cpeng.ma%40nxp.com%7C977d

Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Quoted 3 lines

7871292f

Quoted 1 line

48332dbb08d6c2526b32%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C

Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Quoted 3 lines

0%7C6369

Quoted 1 line

10056581930082&amp;sdata=KQryE2RvI8jTOAPKGlGnx2NWYdawFUaTURyzd8

Quoted 48 lines
Quoted 36 lines
Quoted 10 lines
Quoted 7 lines

oets4%3

Quoted 1 line

D&amp;reserved=0)

Interesting. Why did you create separate binding doc if you target the same ceva sata IP core? Any reason not to merge it together? Anyway I see that this was added in 2015.

[Peng Ma] Although they are both ceva sata, our sata driver is different from yours in kernel to Initializa Vendor-specific registers, you could

see our driver at kernel driver/ata/ ahci_qoriq.c.

I have briefly looked at it. They should be merged together. It happened to us too that we send driver out but didn't know who was the vendor in past and then we found out.

Quoted 10 lines
Quoted 8 lines
Quoted 2 lines

I think your suggestion is better. But the first register cd address was got by

function dev_read_addr(), to keep consistency, I still prefer to use dev_read_addr_index(). What do you think?

We didn't have a need to have second address range that's why reg-names property wasn't used. Do they have all ecc addresses?

[Peng Ma] Some of our socs need to fixed sata errata. So we should write ecc

addr.

Quoted 1 line

I didn't add reg-names to keep consistency of Xilinx sata soc.

Ok. I think that in this case you should pass different .data to driver.

struct platform_data {
       enum ceva_soc;
       bool ecc_present;
}
Quoted 5 lines

It means have current enum followed by bool with "true" for specific IPs which needs to have also ECC range.
Then you can better check that binding is correct.

And use _index there.

[Peng Ma] As far as I am concerned, It is not necessary to do this, I would rather lean on the former way as fallows:

drivers/ata/sata_ceva.c index renamed from drivers/ata/sata_ceva.c +0 -0

d26f712..a1d452a 100644

drivers/ata/sata_ceva.c static const struct udevice_id sata_ceva_ids[] = · line 198

Quoted 3 lines
drivers/ata/sata_ceva.c +1 -0
@@ -196,6 +196,10 @@ static const struct udevice_id sata_ceva_ids[] =
 {  static int sata_ceva_ofdata_to_platdata(struct udevice *dev)  {
        struct ceva_sata_priv *priv = dev_get_priv(dev);
+       const void *blob = gd->fdt_blob;

gd is suggesting that you use incorrect functions.
We are trying to get rid of gd from device drivers. Please take a look at live tree functions if there is any alternative there.

drivers/ata/sata_ceva.c static int sata_ceva_ofdata_to_platdata(struct

Quoted 7 lines
drivers/ata/sata_ceva.c +3 -0
+       int node = dev_of_offset(dev);
+       struct fdt_resource res_regs;
+       int ret;
 
        if (dev_read_bool(dev, "dma-coherent"))
                priv->flag |= FLAG_COHERENT;
@@ -204,9 +208,13 @@ static int sata_ceva_ofdata_to_platdata(struct

udevice *dev)

Quoted 13 lines
drivers/ata/sata_ceva.c +6 -2
        if (priv->base == FDT_ADDR_T_NONE)
                return -EINVAL;
 
-       priv->ecc_base = dev_read_addr_index(dev, 1);
-       if (priv->ecc_base == FDT_ADDR_T_NONE)
+       ret = fdt_get_named_resource(blob, node, "reg", "reg-names",
+                                    "ecc-addr", &res_regs);
+       if (ret) {
+               debug("Error: can't get ecc addresses(ret = %d)!\n", ret);
                priv->ecc_base = 0;
+       } else
+               priv->ecc_base = res_regs.start;
 
Quoted 8 lines
Quoted 2 lines
drivers/ata/sata_ceva.c +0 -0
        priv->soc = dev_get_driver_data(dev);

What do you think?

One thing I would like to avoid is that we will get any error even in debug for IPs which don't have this ecc space.
And also that we will get this errors for IPs which should have this ecc space.

[Peng Ma] OK,changed as fallows:

drivers/ata/sata_ceva.c +7 -2
index d26f712..bd98d85 100644
@@ -8,6 +8,7 @@
 #include <ahci.h>
 #include <scsi.h>
 #include <asm/io.h>
+#include <linux/ioport.h>
 
 /* Vendor Specific Register Offsets */
 #define AHCI_VEND_PCFG  0xA4
@@ -196,6 +197,8 @@ static const struct udevice_id sata_ceva_ids[] = {
 static int sata_ceva_ofdata_to_platdata(struct udevice *dev)
 {
        struct ceva_sata_priv *priv = dev_get_priv(dev);
+       struct resource res_regs;
+       int ret;
 
        if (dev_read_bool(dev, "dma-coherent"))
                priv->flag |= FLAG_COHERENT;
@@ -204,9 +207,11 @@ static int sata_ceva_ofdata_to_platdata(struct udevice *dev)
        if (priv->base == FDT_ADDR_T_NONE)
                return -EINVAL;
 
-       priv->ecc_base = dev_read_addr_index(dev, 1);
-       if (priv->ecc_base == FDT_ADDR_T_NONE)
+       ret = dev_read_resource_byname(dev, "ecc-addr", &res_regs);
+       if (ret)
                priv->ecc_base = 0;
+       else
+               priv->ecc_base = res_regs.start;
 
        priv->soc = dev_get_driver_data(dev);
 

Best Regards,
Peng

Quoted 2 lines

Thanks,
Michal

#12 lore raw
Quoted 448 lines · Peng Ma
Quoted 414 lines

-----Original Message-----
From: Michal Simek <[email protected]>
Sent: 2019年4月17日 13:58
To: Peng Ma <[email protected]>; Michal Simek <[email protected]>; albert.u.boot at aribaud.net; sjg at chromium.org; Fabio Estevam <[email protected]>; York Sun <[email protected]>; Prabhakar Kushwaha <[email protected]>
Cc: Andy Tang <[email protected]>; Yinbo Zhu <[email protected]>; u-boot at lists.denx.de
Subject: Re: [EXT] Re: [PATCH 1/2] scsi: ceva: Clean up the driver code

WARNING: This email was created outside of NXP. DO NOT CLICK links or attachments unless you recognize the sender and know the content is safe.

Quoted 9 lines · Peng Ma
Quoted 9 lines

-----Original Message-----
From: Michal Simek <[email protected]>
Sent: 2019年4月16日 18:49
To: Peng Ma <[email protected]>; Michal Simek <[email protected]>; albert.u.boot at aribaud.net; sjg at chromium.org; Fabio Estevam <[email protected]>; York Sun <[email protected]>; Prabhakar Kushwaha

<[email protected]>

Quoted 20 lines
Quoted 20 lines

Cc: Andy Tang <[email protected]>; Yinbo Zhu <[email protected]>; u-boot at lists.denx.de
Subject: Re: [EXT] Re: [PATCH 1/2] scsi: ceva: Clean up the driver code

WARNING: This email was created outside of NXP. DO NOT CLICK links or attachments unless you recognize the sender and know the content is safe.

Quoted 9 lines · Peng Ma
Quoted 9 lines

-----Original Message-----
From: Michal Simek <[email protected]>
Sent: 2019年4月16日 18:01
To: Peng Ma <[email protected]>; Michal Simek <[email protected]>; albert.u.boot at aribaud.net; sjg at chromium.org; Fabio Estevam <[email protected]>; York Sun <[email protected]>; Prabhakar Kushwaha

Quoted 8 lines
Quoted 8 lines

<[email protected]>

Quoted 7 lines
Quoted 7 lines

Cc: Andy Tang <[email protected]>; Yinbo Zhu <[email protected]>; u-boot at lists.denx.de
Subject: Re: [EXT] Re: [PATCH 1/2] scsi: ceva: Clean up the driver code

WARNING: This email was created outside of NXP. DO NOT CLICK links or attachments unless you recognize the sender and know the content is

safe.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines · Peng Ma
Quoted 2 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

-----Original Message-----
From: Michal Simek <[email protected]>
Sent: 2019年4月16日 17:31
To: Peng Ma <[email protected]>; Michal Simek <[email protected]>; albert.u.boot at aribaud.net; sjg at chromium.org; Fabio Estevam <[email protected]>; York

Sun

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line

<[email protected]>; Prabhakar Kushwaha

<[email protected]>

Quoted 1 line
Quoted 1 line
Cc Andy Tang <[email protected]>; Yinbo Zhu

<[email protected]>;

Quoted 92 lines
Quoted 92 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

u-boot at lists.denx.de
Subject: Re: [EXT] Re: [PATCH 1/2] scsi: ceva: Clean up the driver code

WARNING: This email was created outside of NXP. DO NOT CLICK links or attachments unless you recognize the sender and know the content is

safe.

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines · Peng Ma
Quoted 7 lines
Quoted 7 lines

-----Original Message-----
From: Michal Simek <[email protected]>
Sent: 2019年4月16日 16:04
To: Peng Ma <[email protected]>; albert.u.boot at aribaud.net; sjg at chromium.org; Fabio Estevam <[email protected]>; York

Sun

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line

<[email protected]>; Prabhakar Kushwaha

<[email protected]>

Quoted 1 line
Quoted 1 line
Cc Andy Tang <[email protected]>; Yinbo Zhu

<[email protected]>;

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

michal.simek at xilinx.com; u-boot at lists.denx.de
Subject: [EXT] Re: [PATCH 1/2] scsi: ceva: Clean up the driver code

WARNING: This email was created outside of NXP. DO NOT CLICK links or attachments unless you recognize the sender and know the content is

Quoted 7 lines
Quoted 7 lines

safe.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines · Peng Ma
Quoted 2 lines

Distinguish the ecc val by chassis version and move the ecc addr to

dts.

Quoted 53 lines
Quoted 53 lines
Quoted 53 lines
Quoted 53 lines
Quoted 53 lines
Quoted 53 lines
Quoted 5 lines

Add ls1028a soc support.

---
 drivers/ata/sata_ceva.c |   43

+++++++++++++++++++++++++------------------

drivers/ata/sata_ceva.c line 88

Quoted 9 lines
 1 files changed, 25 insertions(+), 18 deletions(-)
drivers/ata/sata_ceva.c +0 -0

index
8887be9..d26f712 100644

drivers/ata/sata_ceva.c +0 -0
@@ -88,20 +88,16 @@
 #define LS1021_CEVA_PHY4_CFG 0x064a080b  #define

LS1021_CEVA_PHY5_CFG

Quoted 37 lines

0x2aa86470

drivers/ata/sata_ceva.c +6 -8
-/* for ls1088a */
-#define LS1088_ECC_DIS_ADDR_CH2      0x100520
-#define LS1088_ECC_DIS_VAL_CH2       0x40000000
-
-/* ecc addr-val pair */
-#define ECC_DIS_ADDR_CH2     0x20140520
+/* ecc val pair */
+#define ECC_DIS_VAL_CH1              0x00020000
 #define ECC_DIS_VAL_CH2              0x80000000
-#define SATA_ECC_REG_ADDR    0x20220520
-#define SATA_ECC_DISABLE     0x00020000
+#define ECC_DIS_VAL_CH3              0x40000000
 
 enum ceva_soc {
      CEVA_1V84,
      CEVA_LS1012A,
      CEVA_LS1021A,
+     CEVA_LS1028A,
      CEVA_LS1043A,
      CEVA_LS1046A,
      CEVA_LS1088A,
@@ -110,12 +106,14 @@ enum ceva_soc {
 
 struct ceva_sata_priv {
      ulong base;
+     ulong ecc_base;
      enum ceva_soc soc;
      ulong flag;
 };
 
 static int ceva_init_sata(struct ceva_sata_priv *priv)  {
+     ulong ecc_addr = priv->ecc_base;
      ulong base = priv->base;
      ulong tmp;
 
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
drivers/ata/sata_ceva.c +0 -0
@@ -132,38 +130,38 @@ static int ceva_init_sata(struct

ceva_sata_priv

*priv)

Quoted 4 lines
              break;

      case CEVA_LS1021A:

- writel(SATA_ECC_DISABLE,

SATA_ECC_REG_ADDR);

Quoted 104 lines
Quoted 104 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

drivers/ata/sata_ceva.c

Quoted 3 lines
drivers/ata/sata_ceva.c +2 -0
+             if (ecc_addr)
+                     writel(ECC_DIS_VAL_CH1, ecc_addr);
              writel(CEVA_PHY1_CFG, base +

AHCI_VEND_PPCFG);

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 1 line
              writel(LS1021_CEVA_PHY2_CFG, base +

AHCI_VEND_PP2C);

Quoted 1 line
              writel(LS1021_CEVA_PHY3_CFG, base +

AHCI_VEND_PP3C);

Quoted 1 line
              writel(LS1021_CEVA_PHY4_CFG, base +

AHCI_VEND_PP4C);

Quoted 1 line
              writel(LS1021_CEVA_PHY5_CFG, base +

AHCI_VEND_PP5C);

Quoted 1 line

writel(CEVA_TRANS_CFG, base +

AHCI_VEND_PTC);

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

drivers/ata/sata_ceva.c

Quoted 2 lines
drivers/ata/sata_ceva.c +0 -2
-             if (priv->flag & FLAG_COHERENT)
-                     writel(CEVA_AXICC_CFG, base +

LS1021_AHCI_VEND_AXICC);

Quoted 2 lines
              break;
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

drivers/ata/sata_ceva.c

Quoted 9 lines
      case CEVA_LS1012A:
      case CEVA_LS1043A:
      case CEVA_LS1046A:
drivers/ata/sata_ceva.c +2 -2
-             writel(ECC_DIS_VAL_CH2, ECC_DIS_ADDR_CH2);
-             /* fallthrough */
      case CEVA_LS2080A:
+             if (ecc_addr)
+                     writel(ECC_DIS_VAL_CH2, ecc_addr);
              writel(CEVA_PHY1_CFG, base +

AHCI_VEND_PPCFG);

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

writel(CEVA_TRANS_CFG, base +

AHCI_VEND_PTC);

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

drivers/ata/sata_ceva.c

Quoted 2 lines
drivers/ata/sata_ceva.c +0 -2
-             if (priv->flag & FLAG_COHERENT)
-                     writel(CEVA_AXICC_CFG, base +

AHCI_VEND_AXICC);

Quoted 2 lines
              break;
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

drivers/ata/sata_ceva.c

Quoted 3 lines
drivers/ata/sata_ceva.c +1 -1
+     case CEVA_LS1028A:
      case CEVA_LS1088A:
-             writel(LS1088_ECC_DIS_VAL_CH2,

LS1088_ECC_DIS_ADDR_CH2);

Quoted 3 lines
drivers/ata/sata_ceva.c +2 -0
+             if (ecc_addr)
+                     writel(ECC_DIS_VAL_CH3, ecc_addr);
              writel(CEVA_PHY1_CFG, base +

AHCI_VEND_PPCFG);

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

writel(CEVA_TRANS_CFG, base +

AHCI_VEND_PTC);

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

drivers/ata/sata_ceva.c

Quoted 2 lines
drivers/ata/sata_ceva.c +0 -2
-             if (priv->flag & FLAG_COHERENT)
-                     writel(CEVA_AXICC_CFG, base +

AHCI_VEND_AXICC);

Quoted 5 lines
              break;
      }
drivers/ata/sata_ceva.c +2 -0
+     if (priv->flag & FLAG_COHERENT)
+             writel(CEVA_AXICC_CFG, base +

AHCI_VEND_AXICC);

Quoted 49 lines
Quoted 49 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/ata/sata_ceva.c +1 -0
+
      return 0;
 }
@@ -187,6 +185,7 @@ static const struct udevice_id

sata_ceva_ids[] =

{

Quoted 42 lines
Quoted 42 lines
Quoted 17 lines
Quoted 17 lines
Quoted 10 lines
      { .compatible = "ceva,ahci-1v84", .data = CEVA_1V84 },
      { .compatible = "fsl,ls1012a-ahci", .data = CEVA_LS1012A },
      { .compatible = "fsl,ls1021a-ahci", .data = CEVA_LS1021A
},
+     { .compatible = "fsl,ls1028a-ahci", .data = CEVA_LS1028A
+ },
      { .compatible = "fsl,ls1043a-ahci", .data = CEVA_LS1043A },
      { .compatible = "fsl,ls1046a-ahci", .data = CEVA_LS1046A },
      { .compatible = "fsl,ls1088a-ahci", .data = CEVA_LS1088A
}, @@
Quoted 3 lines

-205,8 +204,16 @@ static int
sata_ceva_ofdata_to_platdata(struct
udevice

*dev)

Quoted 3 lines
      if (priv->base == FDT_ADDR_T_NONE)
              return -EINVAL;
Quoted 7 lines
Quoted 5 lines
Quoted 1 line

+ priv->ecc_base = dev_read_addr_index(dev, 1);

It would be better to do it via reg-name instead of index. But that's up to your binding doc.

[Peng Ma] OK, could I change arch/arm/dts/zynqmp.dtsi file sata node as

fallows?

Quoted 7 lines
arch/arm/dts/zynqmp.dtsi +0 -0

index
dfb6ebc..9ad2d84 100644

arch/arm/dts/zynqmp.dtsi line 698

Quoted 7 lines
arch/arm/dts/zynqmp.dtsi +1 -0
@@ -692,6 +692,7 @@
                        compatible = "ceva,ahci-1v84";
                        status = "disabled";
                        reg = <0x0 0xfd0c0000 0x0 0x2000>;
+                       reg-names = "serdes";
                        interrupt-parent = <&gic>;
                        interrupts = <0 133 4>;
                        #stream-id-cells = <4>;

Unfortunately it is not that simple.

Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 6 lines

First of all you need to reflect this in dt binding doc in the kernel.
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2
Fg
it
.kern

el.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Ftorvalds%2Flinux.git%2Ftr

Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
Quoted 1 line

ee%2FDocumentation%2Fdevicetree%2Fbindings%2Fata%2Fahci-ceva.txt%3F

Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
Quoted 1 line

h%3Dv5.1-rc5&amp;data=02%7C01%7Cpeng.ma%40nxp.com%7Cc588ddff1b1

Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
Quoted 1 line

e471f645b08d6c24e54d7%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C

Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
Quoted 1 line

0%7C636910039050031150&amp;sdata=0Gsuo2uI3pot4VAhBr7SQUnCRYT7Xi

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 4 lines

Ybybu6i1t%2Byzo%3D&amp;reserved=0

Did you record your compatible strings anywhere?

[Peng Ma] Thanks your quick reply.
You can find our binding document at:
(https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2
Fg
it .kernel.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Ftorvalds%2Flin

ux.

Quoted 6 lines
Quoted 6 lines

gi

Quoted 4 lines
Quoted 4 lines
Quoted 1 line

t

%

Quoted 1 line

2Ftree%2FDocumentation%2Fdevicetree%2Fbindings%2Fata%2Fahci-fsl-qoriq.

Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line

txt%3Fh%3Dv5.1-rc5&amp;data=02%7C01%7Cpeng.ma%40nxp.com%7C977d

Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Quoted 3 lines

7871292f

Quoted 1 line

48332dbb08d6c2526b32%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C

Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Quoted 3 lines

0%7C6369

Quoted 1 line

10056581930082&amp;sdata=KQryE2RvI8jTOAPKGlGnx2NWYdawFUaTURyzd8

Quoted 48 lines
Quoted 36 lines
Quoted 10 lines
Quoted 7 lines

oets4%3

Quoted 1 line

D&amp;reserved=0)

Interesting. Why did you create separate binding doc if you target the same ceva sata IP core? Any reason not to merge it together? Anyway I see that this was added in 2015.

[Peng Ma] Although they are both ceva sata, our sata driver is different from yours in kernel to Initializa Vendor-specific registers, you could

see our driver at kernel driver/ata/ ahci_qoriq.c.

I have briefly looked at it. They should be merged together. It happened to us too that we send driver out but didn't know who was the vendor in past and then we found out.

Quoted 10 lines
Quoted 8 lines
Quoted 2 lines

I think your suggestion is better. But the first register cd address was got by

function dev_read_addr(), to keep consistency, I still prefer to use dev_read_addr_index(). What do you think?

We didn't have a need to have second address range that's why reg-names property wasn't used. Do they have all ecc addresses?

[Peng Ma] Some of our socs need to fixed sata errata. So we should write ecc

addr.

Quoted 1 line

I didn't add reg-names to keep consistency of Xilinx sata soc.

Ok. I think that in this case you should pass different .data to driver.

struct platform_data {
       enum ceva_soc;
       bool ecc_present;
}
Quoted 5 lines

It means have current enum followed by bool with "true" for specific IPs which needs to have also ECC range.
Then you can better check that binding is correct.

And use _index there.

[Peng Ma] As far as I am concerned, It is not necessary to do this, I would rather lean on the former way as fallows:

drivers/ata/sata_ceva.c index renamed from drivers/ata/sata_ceva.c +0 -0

d26f712..a1d452a 100644

drivers/ata/sata_ceva.c static const struct udevice_id sata_ceva_ids[] = · line 198

Quoted 3 lines
drivers/ata/sata_ceva.c +1 -0
@@ -196,6 +196,10 @@ static const struct udevice_id sata_ceva_ids[] =
 {  static int sata_ceva_ofdata_to_platdata(struct udevice *dev)  {
        struct ceva_sata_priv *priv = dev_get_priv(dev);
+       const void *blob = gd->fdt_blob;

gd is suggesting that you use incorrect functions.
We are trying to get rid of gd from device drivers. Please take a look at live tree functions if there is any alternative there.

drivers/ata/sata_ceva.c static int sata_ceva_ofdata_to_platdata(struct

Quoted 7 lines
drivers/ata/sata_ceva.c +3 -0
+       int node = dev_of_offset(dev);
+       struct fdt_resource res_regs;
+       int ret;
 
        if (dev_read_bool(dev, "dma-coherent"))
                priv->flag |= FLAG_COHERENT;
@@ -204,9 +208,13 @@ static int sata_ceva_ofdata_to_platdata(struct

udevice *dev)

Quoted 13 lines
drivers/ata/sata_ceva.c +6 -2
        if (priv->base == FDT_ADDR_T_NONE)
                return -EINVAL;
 
-       priv->ecc_base = dev_read_addr_index(dev, 1);
-       if (priv->ecc_base == FDT_ADDR_T_NONE)
+       ret = fdt_get_named_resource(blob, node, "reg", "reg-names",
+                                    "ecc-addr", &res_regs);
+       if (ret) {
+               debug("Error: can't get ecc addresses(ret = %d)!\n", ret);
                priv->ecc_base = 0;
+       } else
+               priv->ecc_base = res_regs.start;
 
Quoted 8 lines
Quoted 2 lines
drivers/ata/sata_ceva.c +0 -0
        priv->soc = dev_get_driver_data(dev);

What do you think?

One thing I would like to avoid is that we will get any error even in debug for IPs which don't have this ecc space.
And also that we will get this errors for IPs which should have this ecc space.

[Peng Ma] OK,changed as fallows:

drivers/ata/sata_ceva.c +3 -0
index d26f712..bd98d85 100644
@@ -8,6 +8,7 @@
 #include <ahci.h>
 #include <scsi.h>
 #include <asm/io.h>
+#include <linux/ioport.h>
 
 /* Vendor Specific Register Offsets */
 #define AHCI_VEND_PCFG  0xA4
@@ -196,6 +197,8 @@ static const struct udevice_id sata_ceva_ids[] = {
 static int sata_ceva_ofdata_to_platdata(struct udevice *dev)
 {
        struct ceva_sata_priv *priv = dev_get_priv(dev);
+       struct resource res_regs;
+       int ret;
 
        if (dev_read_bool(dev, "dma-coherent"))
                priv->flag |= FLAG_COHERENT;
@@ -204,9 +207,11 @@ static int sata_ceva_ofdata_to_platdata(struct udevice *dev)
        if (priv->base == FDT_ADDR_T_NONE)
                return -EINVAL;

drivers/ata/sata_ceva.c static int sata_ceva_ofdata_to_platdata(struct udevice *dev) · line 216

Quoted 10 lines
drivers/ata/sata_ceva.c +4 -2
 
-       priv->ecc_base = dev_read_addr_index(dev, 1);
-       if (priv->ecc_base == FDT_ADDR_T_NONE)
+       ret = dev_read_resource_byname(dev, "ecc-addr", &res_regs);
+       if (ret)
                priv->ecc_base = 0;
+       else
+               priv->ecc_base = res_regs.start;
 
        priv->soc = dev_get_driver_data(dev);

This looks good but still missing information that in your case there are some versions where this ecc-addr is required. It means if it is required you should error it out when it is not present in DT.

Thanks,
Michal

author
#13 lore raw
Quoted 504 lines

-----Original Message-----
From: Michal Simek <[email protected]>
Sent: 2019年4月17日 14:58
To: Peng Ma <[email protected]>; Michal Simek <[email protected]>; albert.u.boot at aribaud.net; sjg at chromium.org; Fabio Estevam <[email protected]>; York Sun <[email protected]>; Prabhakar Kushwaha <[email protected]>
Cc: Andy Tang <[email protected]>; Yinbo Zhu <[email protected]>; u-boot at lists.denx.de
Subject: Re: [EXT] Re: [PATCH 1/2] scsi: ceva: Clean up the driver code

WARNING: This email was created outside of NXP. DO NOT CLICK links or attachments unless you recognize the sender and know the content is safe.

Quoted 9 lines · Peng Ma
Quoted 9 lines

-----Original Message-----
From: Michal Simek <[email protected]>
Sent: 2019年4月17日 13:58
To: Peng Ma <[email protected]>; Michal Simek <[email protected]>; albert.u.boot at aribaud.net; sjg at chromium.org; Fabio Estevam <[email protected]>; York Sun <[email protected]>; Prabhakar Kushwaha

<[email protected]>

Quoted 20 lines
Quoted 20 lines

Cc: Andy Tang <[email protected]>; Yinbo Zhu <[email protected]>; u-boot at lists.denx.de
Subject: Re: [EXT] Re: [PATCH 1/2] scsi: ceva: Clean up the driver code

WARNING: This email was created outside of NXP. DO NOT CLICK links or attachments unless you recognize the sender and know the content is safe.

Quoted 9 lines · Peng Ma
Quoted 9 lines

-----Original Message-----
From: Michal Simek <[email protected]>
Sent: 2019年4月16日 18:49
To: Peng Ma <[email protected]>; Michal Simek <[email protected]>; albert.u.boot at aribaud.net; sjg at chromium.org; Fabio Estevam <[email protected]>; York Sun <[email protected]>; Prabhakar Kushwaha

Quoted 8 lines
Quoted 8 lines

<[email protected]>

Quoted 7 lines
Quoted 7 lines

Cc: Andy Tang <[email protected]>; Yinbo Zhu <[email protected]>; u-boot at lists.denx.de
Subject: Re: [EXT] Re: [PATCH 1/2] scsi: ceva: Clean up the driver code

WARNING: This email was created outside of NXP. DO NOT CLICK links or attachments unless you recognize the sender and know the content is

safe.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines · Peng Ma
Quoted 2 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

-----Original Message-----
From: Michal Simek <[email protected]>
Sent: 2019年4月16日 18:01
To: Peng Ma <[email protected]>; Michal Simek <[email protected]>; albert.u.boot at aribaud.net; sjg at chromium.org; Fabio Estevam <[email protected]>; York

Sun

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line

<[email protected]>; Prabhakar Kushwaha

<[email protected]>

Quoted 1 line
Quoted 1 line
Cc Andy Tang <[email protected]>; Yinbo Zhu

<[email protected]>;

Quoted 36 lines
Quoted 36 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

u-boot at lists.denx.de
Subject: Re: [EXT] Re: [PATCH 1/2] scsi: ceva: Clean up the driver code

WARNING: This email was created outside of NXP. DO NOT CLICK links or attachments unless you recognize the sender and know the content is

safe.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines · Peng Ma
Quoted 2 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

-----Original Message-----
From: Michal Simek <[email protected]>
Sent: 2019年4月16日 17:31
To: Peng Ma <[email protected]>; Michal Simek <[email protected]>; albert.u.boot at aribaud.net; sjg at chromium.org; Fabio Estevam <[email protected]>; York

Sun

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line

<[email protected]>; Prabhakar Kushwaha

<[email protected]>

Quoted 1 line
Quoted 1 line
Cc Andy Tang <[email protected]>; Yinbo Zhu

<[email protected]>;

Quoted 11 lines
Quoted 11 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

u-boot at lists.denx.de
Subject: Re: [EXT] Re: [PATCH 1/2] scsi: ceva: Clean up the driver code

WARNING: This email was created outside of NXP. DO NOT CLICK links or attachments unless you recognize the sender and know the content is

safe.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines · Peng Ma
Quoted 7 lines
Quoted 7 lines

-----Original Message-----
From: Michal Simek <[email protected]>
Sent: 2019年4月16日 16:04
To: Peng Ma <[email protected]>; albert.u.boot at aribaud.net; sjg at chromium.org; Fabio Estevam <[email protected]>;

York

Quoted 76 lines
Quoted 76 lines
Quoted 76 lines
Quoted 76 lines

Sun

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line

<[email protected]>; Prabhakar Kushwaha

<[email protected]>

Quoted 1 line
Quoted 1 line
Cc Andy Tang <[email protected]>; Yinbo Zhu

<[email protected]>;

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

michal.simek at xilinx.com; u-boot at lists.denx.de
Subject: [EXT] Re: [PATCH 1/2] scsi: ceva: Clean up the driver code

WARNING: This email was created outside of NXP. DO NOT CLICK links or attachments unless you recognize the sender and know the content is

Quoted 7 lines
Quoted 7 lines

safe.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines · Peng Ma
Quoted 2 lines

Distinguish the ecc val by chassis version and move the ecc addr to

dts.

Quoted 56 lines
Quoted 56 lines
Quoted 56 lines
Quoted 56 lines
Quoted 56 lines
Quoted 56 lines
Quoted 5 lines

Add ls1028a soc support.

---
 drivers/ata/sata_ceva.c |   43

+++++++++++++++++++++++++------------------

drivers/ata/sata_ceva.c line 88

Quoted 9 lines
 1 files changed, 25 insertions(+), 18 deletions(-)
(quoted diff) +0 -0

b/drivers/ata/sata_ceva.c index
8887be9..d26f712 100644

drivers/ata/sata_ceva.c +0 -0
@@ -88,20 +88,16 @@
 #define LS1021_CEVA_PHY4_CFG 0x064a080b  #define

LS1021_CEVA_PHY5_CFG

Quoted 38 lines

0x2aa86470

drivers/ata/sata_ceva.c +6 -8
-/* for ls1088a */
-#define LS1088_ECC_DIS_ADDR_CH2      0x100520
-#define LS1088_ECC_DIS_VAL_CH2       0x40000000
-
-/* ecc addr-val pair */
-#define ECC_DIS_ADDR_CH2     0x20140520
+/* ecc val pair */
+#define ECC_DIS_VAL_CH1              0x00020000
 #define ECC_DIS_VAL_CH2              0x80000000
-#define SATA_ECC_REG_ADDR    0x20220520
-#define SATA_ECC_DISABLE     0x00020000
+#define ECC_DIS_VAL_CH3              0x40000000
 
 enum ceva_soc {
      CEVA_1V84,
      CEVA_LS1012A,
      CEVA_LS1021A,
+     CEVA_LS1028A,
      CEVA_LS1043A,
      CEVA_LS1046A,
      CEVA_LS1088A,
@@ -110,12 +106,14 @@ enum ceva_soc {
 
 struct ceva_sata_priv {
      ulong base;
+     ulong ecc_base;
      enum ceva_soc soc;
      ulong flag;
 };
 
 static int ceva_init_sata(struct ceva_sata_priv *priv)  {
+     ulong ecc_addr = priv->ecc_base;
      ulong base = priv->base;
      ulong tmp;
 
@@ -132,38 +130,38 @@ static int ceva_init_sata(struct
Quoted 1 line

ceva_sata_priv

*priv)

Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
              break;

      case CEVA_LS1021A:

- writel(SATA_ECC_DISABLE,

SATA_ECC_REG_ADDR);

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
drivers/ata/sata_ceva.c +2 -0
+             if (ecc_addr)
+                     writel(ECC_DIS_VAL_CH1,

ecc_addr);

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

writel(CEVA_PHY1_CFG, base +

AHCI_VEND_PPCFG);

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 1 line
              writel(LS1021_CEVA_PHY2_CFG, base +

AHCI_VEND_PP2C);

Quoted 1 line
              writel(LS1021_CEVA_PHY3_CFG, base +

AHCI_VEND_PP3C);

Quoted 1 line
              writel(LS1021_CEVA_PHY4_CFG, base +

AHCI_VEND_PP4C);

Quoted 1 line
              writel(LS1021_CEVA_PHY5_CFG, base +

AHCI_VEND_PP5C);

Quoted 1 line

writel(CEVA_TRANS_CFG, base +

AHCI_VEND_PTC);

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
drivers/ata/sata_ceva.c +0 -2
-             if (priv->flag & FLAG_COHERENT)
-                     writel(CEVA_AXICC_CFG, base +
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

LS1021_AHCI_VEND_AXICC);

Quoted 6 lines
              break;

      case CEVA_LS1012A:
      case CEVA_LS1043A:
      case CEVA_LS1046A:

- writel(ECC_DIS_VAL_CH2,

ECC_DIS_ADDR_CH2);

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

drivers/ata/sata_ceva.c

Quoted 4 lines
drivers/ata/sata_ceva.c +2 -1
-             /* fallthrough */
      case CEVA_LS2080A:
+             if (ecc_addr)
+                     writel(ECC_DIS_VAL_CH2,

ecc_addr);

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

writel(CEVA_PHY1_CFG, base +

AHCI_VEND_PPCFG);

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

writel(CEVA_TRANS_CFG, base +

AHCI_VEND_PTC);

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

drivers/ata/sata_ceva.c

Quoted 2 lines
drivers/ata/sata_ceva.c +0 -2
-             if (priv->flag & FLAG_COHERENT)
-                     writel(CEVA_AXICC_CFG, base +

AHCI_VEND_AXICC);

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

drivers/ata/sata_ceva.c

Quoted 5 lines
              break;
drivers/ata/sata_ceva.c +1 -1
+     case CEVA_LS1028A:
      case CEVA_LS1088A:
-             writel(LS1088_ECC_DIS_VAL_CH2,

LS1088_ECC_DIS_ADDR_CH2);

Quoted 2 lines
drivers/ata/sata_ceva.c +2 -0
+             if (ecc_addr)
+                     writel(ECC_DIS_VAL_CH3,

ecc_addr);

Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

writel(CEVA_PHY1_CFG, base +

AHCI_VEND_PPCFG);

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

writel(CEVA_TRANS_CFG, base +

AHCI_VEND_PTC);

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

drivers/ata/sata_ceva.c

Quoted 2 lines
drivers/ata/sata_ceva.c +0 -2
-             if (priv->flag & FLAG_COHERENT)
-                     writel(CEVA_AXICC_CFG, base +

AHCI_VEND_AXICC);

Quoted 5 lines
              break;
      }
drivers/ata/sata_ceva.c +2 -0
+     if (priv->flag & FLAG_COHERENT)
+             writel(CEVA_AXICC_CFG, base +

AHCI_VEND_AXICC);

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

+

      return 0;

}

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
drivers/ata/sata_ceva.c +0 -0
@@ -187,6 +185,7 @@ static const struct udevice_id

sata_ceva_ids[] =

{

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
      { .compatible = "ceva,ahci-1v84", .data = CEVA_1V84 },
      { .compatible = "fsl,ls1012a-ahci", .data =

CEVA_LS1012A },

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
      { .compatible = "fsl,ls1021a-ahci", .data =
CEVA_LS1021A },
+     { .compatible = "fsl,ls1028a-ahci", .data =
+ CEVA_LS1028A },
      { .compatible = "fsl,ls1043a-ahci", .data =

CEVA_LS1043A },

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
      { .compatible = "fsl,ls1046a-ahci", .data =

CEVA_LS1046A },

Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 9 lines
Quoted 9 lines
Quoted 5 lines
      { .compatible = "fsl,ls1088a-ahci", .data =

CEVA_LS1088A }, @@
-205,8 +204,16 @@ static int
sata_ceva_ofdata_to_platdata(struct
udevice

*dev)

Quoted 3 lines
      if (priv->base == FDT_ADDR_T_NONE)
              return -EINVAL;
Quoted 7 lines
Quoted 5 lines
Quoted 1 line

+ priv->ecc_base = dev_read_addr_index(dev, 1);

It would be better to do it via reg-name instead of index. But that's up to your binding doc.

[Peng Ma] OK, could I change arch/arm/dts/zynqmp.dtsi file sata node as

fallows?

Quoted 1 line
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

arch/arm/dts/zynqmp.dtsi line 694

Quoted 9 lines
(quoted diff) +0 -0

b/arch/arm/dts/zynqmp.dtsi index
dfb6ebc..9ad2d84 100644

arch/arm/dts/zynqmp.dtsi +0 -0
@@ -692,6 +692,7 @@
                        compatible = "ceva,ahci-1v84";
                        status = "disabled";
                        reg = <0x0 0xfd0c0000 0x0

0x2000>;

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

arch/arm/dts/zynqmp.dtsi line 698

Quoted 4 lines
arch/arm/dts/zynqmp.dtsi +1 -0
+                       reg-names = "serdes";
                        interrupt-parent = <&gic>;
                        interrupts = <0 133 4>;
                        #stream-id-cells = <4>;

Unfortunately it is not that simple.

Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 7 lines

First of all you need to reflect this in dt binding doc in the kernel.
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F
%2
Fg
it
.kern

el.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Ftorvalds%2Flinux.git%2Ftr

Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
Quoted 1 line

ee%2FDocumentation%2Fdevicetree%2Fbindings%2Fata%2Fahci-ceva.txt%3F

Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
Quoted 1 line

h%3Dv5.1-rc5&amp;data=02%7C01%7Cpeng.ma%40nxp.com%7Cc588ddff1b1

Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
Quoted 1 line

e471f645b08d6c24e54d7%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C

Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
Quoted 1 line

0%7C636910039050031150&amp;sdata=0Gsuo2uI3pot4VAhBr7SQUnCRYT7Xi

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 4 lines

Ybybu6i1t%2Byzo%3D&amp;reserved=0

Did you record your compatible strings anywhere?

[Peng Ma] Thanks your quick reply.
You can find our binding document at:
(https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F
%2
Fg
it .kernel.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Ftorvalds%2F

lin

Quoted 8 lines
Quoted 8 lines

ux.

Quoted 6 lines
Quoted 6 lines

gi

Quoted 4 lines
Quoted 4 lines
Quoted 1 line

t

%

Quoted 1 line

2Ftree%2FDocumentation%2Fdevicetree%2Fbindings%2Fata%2Fahci-fsl-qoriq.

Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line

txt%3Fh%3Dv5.1-rc5&amp;data=02%7C01%7Cpeng.ma%40nxp.com%7C977d

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Quoted 3 lines

7871292f

Quoted 1 line

48332dbb08d6c2526b32%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Quoted 3 lines

0%7C6369

Quoted 1 line

10056581930082&amp;sdata=KQryE2RvI8jTOAPKGlGnx2NWYdawFUaTURyzd8

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

oets4%3

Quoted 1 line

D&amp;reserved=0)

Interesting. Why did you create separate binding doc if you target the same ceva sata IP core? Any reason not to merge it

together?

Quoted 52 lines
Quoted 52 lines
Quoted 43 lines
Quoted 31 lines
Quoted 5 lines
Quoted 2 lines

Anyway I see that this was added in 2015.

[Peng Ma] Although they are both ceva sata, our sata driver is different from yours in kernel to Initializa Vendor-specific registers, you could

see our driver at kernel driver/ata/ ahci_qoriq.c.

I have briefly looked at it. They should be merged together. It happened to us too that we send driver out but didn't know who was the vendor in past and then we found out.

Quoted 10 lines
Quoted 8 lines
Quoted 2 lines

I think your suggestion is better. But the first register cd address was got by

function dev_read_addr(), to keep consistency, I still prefer to use dev_read_addr_index(). What do you think?

We didn't have a need to have second address range that's why reg-names property wasn't used. Do they have all ecc addresses?

[Peng Ma] Some of our socs need to fixed sata errata. So we should write ecc

addr.

Quoted 1 line

I didn't add reg-names to keep consistency of Xilinx sata soc.

Ok. I think that in this case you should pass different .data to driver.

struct platform_data {
       enum ceva_soc;
       bool ecc_present;
}
Quoted 5 lines

It means have current enum followed by bool with "true" for specific IPs which needs to have also ECC range. Then you can better check that binding is correct.

And use _index there.

[Peng Ma] As far as I am concerned, It is not necessary to do this, I would rather lean on the former way as fallows:

drivers/ata/sata_ceva.c index renamed from drivers/ata/sata_ceva.c +0 -0

d26f712..a1d452a 100644

drivers/ata/sata_ceva.c static const struct udevice_id sata_ceva_ids[] · line 198

Quoted 3 lines
drivers/ata/sata_ceva.c +1 -0
@@ -196,6 +196,10 @@ static const struct udevice_id sata_ceva_ids[]
 = {  static int sata_ceva_ofdata_to_platdata(struct udevice *dev)  {
        struct ceva_sata_priv *priv = dev_get_priv(dev);
+       const void *blob = gd->fdt_blob;

gd is suggesting that you use incorrect functions.
We are trying to get rid of gd from device drivers. Please take a look at live tree functions if there is any alternative there.

Quoted 6 lines
Quoted 6 lines

drivers/ata/sata_ceva.c static const struct udevice_id sata_ceva_ids[] · line 204

Quoted 6 lines
drivers/ata/sata_ceva.c +3 -0
+       int node = dev_of_offset(dev);
+       struct fdt_resource res_regs;
+       int ret;
 
        if (dev_read_bool(dev, "dma-coherent"))
                priv->flag |= FLAG_COHERENT; @@ -204,9 +208,13

@@

Quoted 37 lines
Quoted 16 lines
Quoted 1 line

static int sata_ceva_ofdata_to_platdata(struct

udevice *dev)

Quoted 14 lines
        if (priv->base == FDT_ADDR_T_NONE)
                return -EINVAL;
drivers/ata/sata_ceva.c +7 -2
-       priv->ecc_base = dev_read_addr_index(dev, 1);
-       if (priv->ecc_base == FDT_ADDR_T_NONE)
+       ret = fdt_get_named_resource(blob, node, "reg", "reg-names",
+                                    "ecc-addr", &res_regs);
+       if (ret) {
+               debug("Error: can't get ecc addresses(ret = %d)!\n",
+ ret);
                priv->ecc_base = 0;
+       } else
+               priv->ecc_base = res_regs.start;
Quoted 7 lines
Quoted 1 line
        priv->soc = dev_get_driver_data(dev); What do you think?

One thing I would like to avoid is that we will get any error even in debug for IPs which don't have this ecc space.
And also that we will get this errors for IPs which should have this ecc space.

[Peng Ma] OK,changed as fallows:

drivers/ata/sata_ceva.c index renamed from drivers/ata/sata_ceva.c +0 -0

d26f712..bd98d85 100644

drivers/ata/sata_ceva.c +1 -0
@@ -8,6 +8,7 @@
 #include <ahci.h>
 #include <scsi.h>
 #include <asm/io.h>
+#include <linux/ioport.h>
 
 /* Vendor Specific Register Offsets */  #define AHCI_VEND_PCFG  0xA4

drivers/ata/sata_ceva.c static const struct udevice_id sata_ceva_ids[] = { · line 203

Quoted 7 lines
drivers/ata/sata_ceva.c +2 -0
@@ -196,6 +197,8 @@ static const struct udevice_id sata_ceva_ids[] = {
 static int sata_ceva_ofdata_to_platdata(struct udevice *dev)  {
        struct ceva_sata_priv *priv = dev_get_priv(dev);
+       struct resource res_regs;
+       int ret;
 
        if (dev_read_bool(dev, "dma-coherent"))
                priv->flag |= FLAG_COHERENT; @@ -204,9 +207,11

@@

Quoted 12 lines
drivers/ata/sata_ceva.c +0 -0
 static int sata_ceva_ofdata_to_platdata(struct udevice *dev)
        if (priv->base == FDT_ADDR_T_NONE)
                return -EINVAL;
drivers/ata/sata_ceva.c +4 -2
-       priv->ecc_base = dev_read_addr_index(dev, 1);
-       if (priv->ecc_base == FDT_ADDR_T_NONE)
+       ret = dev_read_resource_byname(dev, "ecc-addr", &res_regs);
+       if (ret)
                priv->ecc_base = 0;
+       else
+               priv->ecc_base = res_regs.start;
Quoted 6 lines
Quoted 1 line
        priv->soc = dev_get_driver_data(dev);

This looks good but still missing information that in your case there are some versions where this ecc-addr is required. It means if it is required you should error it out when it is not present in DT.

[Peng Ma] Ok, It will return error when some socs need ecc address with the regs is not Present in DT.

drivers/ata/sata_ceva.c +16 -8
index d26f712..6e28a38 100644
@@ -8,6 +8,7 @@
 #include <ahci.h>
 #include <scsi.h>
 #include <asm/io.h>
+#include <linux/ioport.h>
 
 /* Vendor Specific Register Offsets */
 #define AHCI_VEND_PCFG  0xA4
@@ -130,8 +131,9 @@ static int ceva_init_sata(struct ceva_sata_priv *priv)
                break;
 
        case CEVA_LS1021A:
-               if (ecc_addr)
-                       writel(ECC_DIS_VAL_CH1, ecc_addr);
+               if (!ecc_addr)
+                       return -EINVAL;
+               writel(ECC_DIS_VAL_CH1, ecc_addr);
                writel(CEVA_PHY1_CFG, base + AHCI_VEND_PPCFG);
                writel(LS1021_CEVA_PHY2_CFG, base + AHCI_VEND_PP2C);
                writel(LS1021_CEVA_PHY3_CFG, base + AHCI_VEND_PP3C);
@@ -143,17 +145,19 @@ static int ceva_init_sata(struct ceva_sata_priv *priv)
        case CEVA_LS1012A:
        case CEVA_LS1043A:
        case CEVA_LS1046A:
+               if (!ecc_addr)
+                       return -EINVAL;
+               writel(ECC_DIS_VAL_CH2, ecc_addr);
        case CEVA_LS2080A:
-               if (ecc_addr)
-                       writel(ECC_DIS_VAL_CH2, ecc_addr);
                writel(CEVA_PHY1_CFG, base + AHCI_VEND_PPCFG);
                writel(CEVA_TRANS_CFG, base + AHCI_VEND_PTC);
                break;
 
        case CEVA_LS1028A:
        case CEVA_LS1088A:
-               if (ecc_addr)
-                       writel(ECC_DIS_VAL_CH3, ecc_addr);
+               if (!ecc_addr)
+                       return -EINVAL;
+               writel(ECC_DIS_VAL_CH3, ecc_addr);
                writel(CEVA_PHY1_CFG, base + AHCI_VEND_PPCFG);
                writel(CEVA_TRANS_CFG, base + AHCI_VEND_PTC);
                break;
@@ -196,6 +200,8 @@ static const struct udevice_id sata_ceva_ids[] = {
 static int sata_ceva_ofdata_to_platdata(struct udevice *dev)
 {
        struct ceva_sata_priv *priv = dev_get_priv(dev);
+       struct resource res_regs;
+       int ret;
 
        if (dev_read_bool(dev, "dma-coherent"))
                priv->flag |= FLAG_COHERENT;
@@ -204,9 +210,11 @@ static int sata_ceva_ofdata_to_platdata(struct udevice *dev)
        if (priv->base == FDT_ADDR_T_NONE)
                return -EINVAL;
 
-       priv->ecc_base = dev_read_addr_index(dev, 1);
-       if (priv->ecc_base == FDT_ADDR_T_NONE)
+       ret = dev_read_resource_byname(dev, "ecc-addr", &res_regs);
+       if (ret)
                priv->ecc_base = 0;
+       else
+               priv->ecc_base = res_regs.start;
 
        priv->soc = dev_get_driver_data(dev);
 

Best Regards,
peng

Quoted 5 lines

Thanks,
Michal

#14 lore raw
Quoted 574 lines · Peng Ma
Quoted 504 lines

-----Original Message-----
From: Michal Simek <[email protected]>
Sent: 2019年4月17日 14:58
To: Peng Ma <[email protected]>; Michal Simek <[email protected]>; albert.u.boot at aribaud.net; sjg at chromium.org; Fabio Estevam <[email protected]>; York Sun <[email protected]>; Prabhakar Kushwaha <[email protected]>
Cc: Andy Tang <[email protected]>; Yinbo Zhu <[email protected]>; u-boot at lists.denx.de
Subject: Re: [EXT] Re: [PATCH 1/2] scsi: ceva: Clean up the driver code

WARNING: This email was created outside of NXP. DO NOT CLICK links or attachments unless you recognize the sender and know the content is safe.

Quoted 9 lines · Peng Ma
Quoted 9 lines

-----Original Message-----
From: Michal Simek <[email protected]>
Sent: 2019年4月17日 13:58
To: Peng Ma <[email protected]>; Michal Simek <[email protected]>; albert.u.boot at aribaud.net; sjg at chromium.org; Fabio Estevam <[email protected]>; York Sun <[email protected]>; Prabhakar Kushwaha

<[email protected]>

Quoted 20 lines
Quoted 20 lines

Cc: Andy Tang <[email protected]>; Yinbo Zhu <[email protected]>; u-boot at lists.denx.de
Subject: Re: [EXT] Re: [PATCH 1/2] scsi: ceva: Clean up the driver code

WARNING: This email was created outside of NXP. DO NOT CLICK links or attachments unless you recognize the sender and know the content is safe.

Quoted 9 lines · Peng Ma
Quoted 9 lines

-----Original Message-----
From: Michal Simek <[email protected]>
Sent: 2019年4月16日 18:49
To: Peng Ma <[email protected]>; Michal Simek <[email protected]>; albert.u.boot at aribaud.net; sjg at chromium.org; Fabio Estevam <[email protected]>; York Sun <[email protected]>; Prabhakar Kushwaha

Quoted 8 lines
Quoted 8 lines

<[email protected]>

Quoted 7 lines
Quoted 7 lines

Cc: Andy Tang <[email protected]>; Yinbo Zhu <[email protected]>; u-boot at lists.denx.de
Subject: Re: [EXT] Re: [PATCH 1/2] scsi: ceva: Clean up the driver code

WARNING: This email was created outside of NXP. DO NOT CLICK links or attachments unless you recognize the sender and know the content is

safe.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines · Peng Ma
Quoted 2 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

-----Original Message-----
From: Michal Simek <[email protected]>
Sent: 2019年4月16日 18:01
To: Peng Ma <[email protected]>; Michal Simek <[email protected]>; albert.u.boot at aribaud.net; sjg at chromium.org; Fabio Estevam <[email protected]>; York

Sun

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line

<[email protected]>; Prabhakar Kushwaha

<[email protected]>

Quoted 1 line
Quoted 1 line
Cc Andy Tang <[email protected]>; Yinbo Zhu

<[email protected]>;

Quoted 36 lines
Quoted 36 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

u-boot at lists.denx.de
Subject: Re: [EXT] Re: [PATCH 1/2] scsi: ceva: Clean up the driver code

WARNING: This email was created outside of NXP. DO NOT CLICK links or attachments unless you recognize the sender and know the content is

safe.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines · Peng Ma
Quoted 2 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

-----Original Message-----
From: Michal Simek <[email protected]>
Sent: 2019年4月16日 17:31
To: Peng Ma <[email protected]>; Michal Simek <[email protected]>; albert.u.boot at aribaud.net; sjg at chromium.org; Fabio Estevam <[email protected]>; York

Sun

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line

<[email protected]>; Prabhakar Kushwaha

<[email protected]>

Quoted 1 line
Quoted 1 line
Cc Andy Tang <[email protected]>; Yinbo Zhu

<[email protected]>;

Quoted 11 lines
Quoted 11 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

u-boot at lists.denx.de
Subject: Re: [EXT] Re: [PATCH 1/2] scsi: ceva: Clean up the driver code

WARNING: This email was created outside of NXP. DO NOT CLICK links or attachments unless you recognize the sender and know the content is

safe.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines · Peng Ma
Quoted 7 lines
Quoted 7 lines

-----Original Message-----
From: Michal Simek <[email protected]>
Sent: 2019年4月16日 16:04
To: Peng Ma <[email protected]>; albert.u.boot at aribaud.net; sjg at chromium.org; Fabio Estevam <[email protected]>;

York

Quoted 76 lines
Quoted 76 lines
Quoted 76 lines
Quoted 76 lines

Sun

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line

<[email protected]>; Prabhakar Kushwaha

<[email protected]>

Quoted 1 line
Quoted 1 line
Cc Andy Tang <[email protected]>; Yinbo Zhu

<[email protected]>;

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

michal.simek at xilinx.com; u-boot at lists.denx.de
Subject: [EXT] Re: [PATCH 1/2] scsi: ceva: Clean up the driver code

WARNING: This email was created outside of NXP. DO NOT CLICK links or attachments unless you recognize the sender and know the content is

Quoted 7 lines
Quoted 7 lines

safe.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines · Peng Ma
Quoted 2 lines

Distinguish the ecc val by chassis version and move the ecc
addr to

dts.

Quoted 56 lines
Quoted 56 lines
Quoted 56 lines
Quoted 56 lines
Quoted 56 lines
Quoted 56 lines
Quoted 5 lines

Add ls1028a soc support.

Signed-off-by: Peng Ma <[email protected]>
---
drivers/ata/sata_ceva.c | 43

+++++++++++++++++++++++++------------------

Quoted 9 lines

1 files changed, 25 insertions(+), 18 deletions(-)

diff --git a/drivers/ata/sata_ceva.c
b/drivers/ata/sata_ceva.c index
8887be9..d26f712 100644
--- a/drivers/ata/sata_ceva.c
+++ b/drivers/ata/sata_ceva.c
@@ -88,20 +88,16 @@
#define LS1021_CEVA_PHY4_CFG 0x064a080b #define

LS1021_CEVA_PHY5_CFG

Quoted 39 lines

0x2aa86470

-/* for ls1088a */
-#define LS1088_ECC_DIS_ADDR_CH2 0x100520
-#define LS1088_ECC_DIS_VAL_CH2 0x40000000
-
-/* ecc addr-val pair */
-#define ECC_DIS_ADDR_CH2 0x20140520
+/* ecc val pair */
+#define ECC_DIS_VAL_CH1 0x00020000
#define ECC_DIS_VAL_CH2 0x80000000
-#define SATA_ECC_REG_ADDR 0x20220520
-#define SATA_ECC_DISABLE 0x00020000
+#define ECC_DIS_VAL_CH3 0x40000000

enum ceva_soc {
CEVA_1V84,
CEVA_LS1012A,
CEVA_LS1021A,
+ CEVA_LS1028A,
CEVA_LS1043A,
CEVA_LS1046A,
CEVA_LS1088A,
@@ -110,12 +106,14 @@ enum ceva_soc {

struct ceva_sata_priv {
ulong base;
+ ulong ecc_base;
enum ceva_soc soc;
ulong flag;
};

static int ceva_init_sata(struct ceva_sata_priv *priv) {
+ ulong ecc_addr = priv->ecc_base;
ulong base = priv->base;
ulong tmp;

@@ -132,38 +130,38 @@ static int ceva_init_sata(struct
ceva_sata_priv

*priv)

Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

break;

case CEVA_LS1021A:
- writel(SATA_ECC_DISABLE,

SATA_ECC_REG_ADDR);

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

+ if (ecc_addr)
+ writel(ECC_DIS_VAL_CH1,

ecc_addr);

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

writel(CEVA_PHY1_CFG, base +

AHCI_VEND_PPCFG);

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 1 line

writel(LS1021_CEVA_PHY2_CFG, base +

AHCI_VEND_PP2C);

Quoted 1 line

writel(LS1021_CEVA_PHY3_CFG, base +

AHCI_VEND_PP3C);

Quoted 1 line

writel(LS1021_CEVA_PHY4_CFG, base +

AHCI_VEND_PP4C);

Quoted 1 line

writel(LS1021_CEVA_PHY5_CFG, base +

AHCI_VEND_PP5C);

Quoted 1 line

writel(CEVA_TRANS_CFG, base +

AHCI_VEND_PTC);

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

- if (priv->flag & FLAG_COHERENT)
- writel(CEVA_AXICC_CFG, base +

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

LS1021_AHCI_VEND_AXICC);

Quoted 6 lines

break;

case CEVA_LS1012A:
case CEVA_LS1043A:
case CEVA_LS1046A:
- writel(ECC_DIS_VAL_CH2,

ECC_DIS_ADDR_CH2);

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

- /* fallthrough */
case CEVA_LS2080A:
+ if (ecc_addr)
+ writel(ECC_DIS_VAL_CH2,

ecc_addr);

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

writel(CEVA_PHY1_CFG, base +

AHCI_VEND_PPCFG);

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

writel(CEVA_TRANS_CFG, base +

AHCI_VEND_PTC);

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines

- if (priv->flag & FLAG_COHERENT)
- writel(CEVA_AXICC_CFG, base +

AHCI_VEND_AXICC);

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines

break;

+ case CEVA_LS1028A:
case CEVA_LS1088A:
- writel(LS1088_ECC_DIS_VAL_CH2,

LS1088_ECC_DIS_ADDR_CH2);

Quoted 2 lines

+ if (ecc_addr)
+ writel(ECC_DIS_VAL_CH3,

ecc_addr);

Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

writel(CEVA_PHY1_CFG, base +

AHCI_VEND_PPCFG);

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

writel(CEVA_TRANS_CFG, base +

AHCI_VEND_PTC);

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines

- if (priv->flag & FLAG_COHERENT)
- writel(CEVA_AXICC_CFG, base +

AHCI_VEND_AXICC);

Quoted 5 lines

break;
}

+ if (priv->flag & FLAG_COHERENT)
+ writel(CEVA_AXICC_CFG, base +

AHCI_VEND_AXICC);

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

+
return 0;
}

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

@@ -187,6 +185,7 @@ static const struct udevice_id
sata_ceva_ids[] =

{

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

{ .compatible = "ceva,ahci-1v84", .data = CEVA_1V84 },
{ .compatible = "fsl,ls1012a-ahci", .data =

CEVA_LS1012A },

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

{ .compatible = "fsl,ls1021a-ahci", .data =
CEVA_LS1021A },
+ { .compatible = "fsl,ls1028a-ahci", .data =
+ CEVA_LS1028A },
{ .compatible = "fsl,ls1043a-ahci", .data =

CEVA_LS1043A },

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

{ .compatible = "fsl,ls1046a-ahci", .data =

CEVA_LS1046A },

Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 9 lines
Quoted 9 lines
Quoted 5 lines

{ .compatible = "fsl,ls1088a-ahci", .data =
CEVA_LS1088A }, @@
-205,8 +204,16 @@ static int
sata_ceva_ofdata_to_platdata(struct
udevice

*dev)

Quoted 3 lines

if (priv->base == FDT_ADDR_T_NONE)
return -EINVAL;

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

+ priv->ecc_base = dev_read_addr_index(dev, 1);

It would be better to do it via reg-name instead of index. But that's up to your binding doc.

[Peng Ma] OK, could I change arch/arm/dts/zynqmp.dtsi file sata node as

fallows?

Quoted 1 line
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

arch/arm/dts/zynqmp.dtsi line 694

Quoted 9 lines
(quoted diff) +0 -0

b/arch/arm/dts/zynqmp.dtsi index
dfb6ebc..9ad2d84 100644

arch/arm/dts/zynqmp.dtsi +0 -0
@@ -692,6 +692,7 @@
                        compatible = "ceva,ahci-1v84";
                        status = "disabled";
                        reg = <0x0 0xfd0c0000 0x0

0x2000>;

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

arch/arm/dts/zynqmp.dtsi line 698

Quoted 4 lines
arch/arm/dts/zynqmp.dtsi +1 -0
+                       reg-names = "serdes";
                        interrupt-parent = <&gic>;
                        interrupts = <0 133 4>;
                        #stream-id-cells = <4>;

Unfortunately it is not that simple.

Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 7 lines

First of all you need to reflect this in dt binding doc in the kernel.
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F
%2
Fg
it
.kern

el.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Ftorvalds%2Flinux.git%2Ftr

Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
Quoted 1 line

ee%2FDocumentation%2Fdevicetree%2Fbindings%2Fata%2Fahci-ceva.txt%3F

Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
Quoted 1 line

h%3Dv5.1-rc5&amp;data=02%7C01%7Cpeng.ma%40nxp.com%7Cc588ddff1b1

Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
Quoted 1 line

e471f645b08d6c24e54d7%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C

Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
Quoted 1 line

0%7C636910039050031150&amp;sdata=0Gsuo2uI3pot4VAhBr7SQUnCRYT7Xi

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 4 lines

Ybybu6i1t%2Byzo%3D&amp;reserved=0

Did you record your compatible strings anywhere?

[Peng Ma] Thanks your quick reply.
You can find our binding document at:
(https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F
%2
Fg
it .kernel.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Ftorvalds%2F

lin

Quoted 8 lines
Quoted 8 lines

ux.

Quoted 6 lines
Quoted 6 lines

gi

Quoted 4 lines
Quoted 4 lines
Quoted 1 line

t

%

Quoted 1 line

2Ftree%2FDocumentation%2Fdevicetree%2Fbindings%2Fata%2Fahci-fsl-qoriq.

Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line

txt%3Fh%3Dv5.1-rc5&amp;data=02%7C01%7Cpeng.ma%40nxp.com%7C977d

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Quoted 3 lines

7871292f

Quoted 1 line

48332dbb08d6c2526b32%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Quoted 3 lines

0%7C6369

Quoted 1 line

10056581930082&amp;sdata=KQryE2RvI8jTOAPKGlGnx2NWYdawFUaTURyzd8

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

oets4%3

Quoted 1 line

D&amp;reserved=0)

Interesting. Why did you create separate binding doc if you target the same ceva sata IP core? Any reason not to merge it

together?

Quoted 52 lines
Quoted 52 lines
Quoted 43 lines
Quoted 31 lines
Quoted 5 lines
Quoted 2 lines

Anyway I see that this was added in 2015.

[Peng Ma] Although they are both ceva sata, our sata driver is different from yours in kernel to Initializa Vendor-specific registers, you could

see our driver at kernel driver/ata/ ahci_qoriq.c.

I have briefly looked at it. They should be merged together. It happened to us too that we send driver out but didn't know who was the vendor in past and then we found out.

Quoted 10 lines
Quoted 8 lines
Quoted 2 lines

I think your suggestion is better. But the first register cd address was got by

function dev_read_addr(), to keep consistency, I still prefer to use dev_read_addr_index(). What do you think?

We didn't have a need to have second address range that's why reg-names property wasn't used. Do they have all ecc addresses?

[Peng Ma] Some of our socs need to fixed sata errata. So we should write ecc

addr.

Quoted 1 line

I didn't add reg-names to keep consistency of Xilinx sata soc.

Ok. I think that in this case you should pass different .data to driver.

struct platform_data {
       enum ceva_soc;
       bool ecc_present;
}
Quoted 5 lines

It means have current enum followed by bool with "true" for specific IPs which needs to have also ECC range. Then you can better check that binding is correct.

And use _index there.

[Peng Ma] As far as I am concerned, It is not necessary to do this, I would rather lean on the former way as fallows:

drivers/ata/sata_ceva.c index renamed from drivers/ata/sata_ceva.c +0 -0

d26f712..a1d452a 100644

drivers/ata/sata_ceva.c static const struct udevice_id sata_ceva_ids[] · line 198

Quoted 3 lines
drivers/ata/sata_ceva.c +1 -0
@@ -196,6 +196,10 @@ static const struct udevice_id sata_ceva_ids[]
 = {  static int sata_ceva_ofdata_to_platdata(struct udevice *dev)  {
        struct ceva_sata_priv *priv = dev_get_priv(dev);
+       const void *blob = gd->fdt_blob;

gd is suggesting that you use incorrect functions.
We are trying to get rid of gd from device drivers. Please take a look at live tree functions if there is any alternative there.

Quoted 6 lines
Quoted 6 lines

drivers/ata/sata_ceva.c static const struct udevice_id sata_ceva_ids[] = {

Quoted 6 lines
drivers/ata/sata_ceva.c +3 -0
+       int node = dev_of_offset(dev);
+       struct fdt_resource res_regs;
+       int ret;
 
        if (dev_read_bool(dev, "dma-coherent"))
                priv->flag |= FLAG_COHERENT; @@ -204,9 +208,13

@@

Quoted 37 lines
Quoted 16 lines
Quoted 1 line

static int sata_ceva_ofdata_to_platdata(struct

udevice *dev)

Quoted 14 lines
        if (priv->base == FDT_ADDR_T_NONE)
                return -EINVAL;
drivers/ata/sata_ceva.c +7 -2
-       priv->ecc_base = dev_read_addr_index(dev, 1);
-       if (priv->ecc_base == FDT_ADDR_T_NONE)
+       ret = fdt_get_named_resource(blob, node, "reg", "reg-names",
+                                    "ecc-addr", &res_regs);
+       if (ret) {
+               debug("Error: can't get ecc addresses(ret = %d)!\n",
+ ret);
                priv->ecc_base = 0;
+       } else
+               priv->ecc_base = res_regs.start;
Quoted 7 lines
Quoted 1 line
        priv->soc = dev_get_driver_data(dev); What do you think?

One thing I would like to avoid is that we will get any error even in debug for IPs which don't have this ecc space.
And also that we will get this errors for IPs which should have this ecc space.

[Peng Ma] OK,changed as fallows:

drivers/ata/sata_ceva.c index renamed from drivers/ata/sata_ceva.c +0 -0

d26f712..bd98d85 100644

drivers/ata/sata_ceva.c +1 -0
@@ -8,6 +8,7 @@
 #include <ahci.h>
 #include <scsi.h>
 #include <asm/io.h>
+#include <linux/ioport.h>
 
 /* Vendor Specific Register Offsets */  #define AHCI_VEND_PCFG  0xA4

drivers/ata/sata_ceva.c static const struct udevice_id sata_ceva_ids[] = { · line 203

Quoted 7 lines
drivers/ata/sata_ceva.c +2 -0
@@ -196,6 +197,8 @@ static const struct udevice_id sata_ceva_ids[] = {
 static int sata_ceva_ofdata_to_platdata(struct udevice *dev)  {
        struct ceva_sata_priv *priv = dev_get_priv(dev);
+       struct resource res_regs;
+       int ret;
 
        if (dev_read_bool(dev, "dma-coherent"))
                priv->flag |= FLAG_COHERENT; @@ -204,9 +207,11

@@

Quoted 12 lines
drivers/ata/sata_ceva.c +0 -0
 static int sata_ceva_ofdata_to_platdata(struct udevice *dev)
        if (priv->base == FDT_ADDR_T_NONE)
                return -EINVAL;
drivers/ata/sata_ceva.c +4 -2
-       priv->ecc_base = dev_read_addr_index(dev, 1);
-       if (priv->ecc_base == FDT_ADDR_T_NONE)
+       ret = dev_read_resource_byname(dev, "ecc-addr", &res_regs);
+       if (ret)
                priv->ecc_base = 0;
+       else
+               priv->ecc_base = res_regs.start;
Quoted 6 lines
Quoted 1 line
        priv->soc = dev_get_driver_data(dev);

This looks good but still missing information that in your case there are some versions where this ecc-addr is required. It means if it is required you should error it out when it is not present in DT.

[Peng Ma] Ok, It will return error when some socs need ecc address with the regs is not Present in DT.

drivers/ata/sata_ceva.c +12 -6
index d26f712..6e28a38 100644
@@ -8,6 +8,7 @@
 #include <ahci.h>
 #include <scsi.h>
 #include <asm/io.h>
+#include <linux/ioport.h>
 
 /* Vendor Specific Register Offsets */
 #define AHCI_VEND_PCFG  0xA4
@@ -130,8 +131,9 @@ static int ceva_init_sata(struct ceva_sata_priv *priv)
                break;
 
        case CEVA_LS1021A:
-               if (ecc_addr)
-                       writel(ECC_DIS_VAL_CH1, ecc_addr);
+               if (!ecc_addr)
+                       return -EINVAL;
+               writel(ECC_DIS_VAL_CH1, ecc_addr);
                writel(CEVA_PHY1_CFG, base + AHCI_VEND_PPCFG);
                writel(LS1021_CEVA_PHY2_CFG, base + AHCI_VEND_PP2C);
                writel(LS1021_CEVA_PHY3_CFG, base + AHCI_VEND_PP3C);
@@ -143,17 +145,19 @@ static int ceva_init_sata(struct ceva_sata_priv *priv)
        case CEVA_LS1012A:
        case CEVA_LS1043A:
        case CEVA_LS1046A:
+               if (!ecc_addr)
+                       return -EINVAL;
+               writel(ECC_DIS_VAL_CH2, ecc_addr);
        case CEVA_LS2080A:
-               if (ecc_addr)
-                       writel(ECC_DIS_VAL_CH2, ecc_addr);
                writel(CEVA_PHY1_CFG, base + AHCI_VEND_PPCFG);
                writel(CEVA_TRANS_CFG, base + AHCI_VEND_PTC);
                break;
 
        case CEVA_LS1028A:
        case CEVA_LS1088A:
-               if (ecc_addr)
-                       writel(ECC_DIS_VAL_CH3, ecc_addr);
+               if (!ecc_addr)
+                       return -EINVAL;
+               writel(ECC_DIS_VAL_CH3, ecc_addr);
                writel(CEVA_PHY1_CFG, base + AHCI_VEND_PPCFG);
                writel(CEVA_TRANS_CFG, base + AHCI_VEND_PTC);
                break;
@@ -196,6 +200,8 @@ static const struct udevice_id sata_ceva_ids[] = {
 static int sata_ceva_ofdata_to_platdata(struct udevice *dev)
 {
        struct ceva_sata_priv *priv = dev_get_priv(dev);
+       struct resource res_regs;
+       int ret;
 
        if (dev_read_bool(dev, "dma-coherent"))
                priv->flag |= FLAG_COHERENT;
@@ -204,9 +210,11 @@ static int sata_ceva_ofdata_to_platdata(struct udevice *dev)
        if (priv->base == FDT_ADDR_T_NONE)
                return -EINVAL;
 

drivers/ata/sata_ceva.c static int sata_ceva_ofdata_to_platdata(struct udevice *dev) · line 220

Quoted 10 lines
drivers/ata/sata_ceva.c +4 -2
-       priv->ecc_base = dev_read_addr_index(dev, 1);
-       if (priv->ecc_base == FDT_ADDR_T_NONE)
+       ret = dev_read_resource_byname(dev, "ecc-addr", &res_regs);
+       if (ret)
                priv->ecc_base = 0;
+       else
+               priv->ecc_base = res_regs.start;
 
        priv->soc = dev_get_driver_data(dev);
 

ok. Looks good.

M

author
#15 lore raw
Quoted 628 lines

-----Original Message-----
From: Michal Simek <[email protected]>
Sent: 2019年4月17日 15:38
To: Peng Ma <[email protected]>; Michal Simek <[email protected]>; albert.u.boot at aribaud.net; sjg at chromium.org; Fabio Estevam <[email protected]>; York Sun <[email protected]>; Prabhakar Kushwaha <[email protected]>
Cc: Andy Tang <[email protected]>; Yinbo Zhu <[email protected]>; u-boot at lists.denx.de
Subject: Re: [EXT] Re: [PATCH 1/2] scsi: ceva: Clean up the driver code

WARNING: This email was created outside of NXP. DO NOT CLICK links or attachments unless you recognize the sender and know the content is safe.

Quoted 9 lines · Peng Ma
Quoted 9 lines

-----Original Message-----
From: Michal Simek <[email protected]>
Sent: 2019年4月17日 14:58
To: Peng Ma <[email protected]>; Michal Simek <[email protected]>; albert.u.boot at aribaud.net; sjg at chromium.org; Fabio Estevam <[email protected]>; York Sun <[email protected]>; Prabhakar Kushwaha

<[email protected]>

Quoted 20 lines
Quoted 20 lines

Cc: Andy Tang <[email protected]>; Yinbo Zhu <[email protected]>; u-boot at lists.denx.de
Subject: Re: [EXT] Re: [PATCH 1/2] scsi: ceva: Clean up the driver code

WARNING: This email was created outside of NXP. DO NOT CLICK links or attachments unless you recognize the sender and know the content is safe.

Quoted 9 lines · Peng Ma
Quoted 9 lines

-----Original Message-----
From: Michal Simek <[email protected]>
Sent: 2019年4月17日 13:58
To: Peng Ma <[email protected]>; Michal Simek <[email protected]>; albert.u.boot at aribaud.net; sjg at chromium.org; Fabio Estevam <[email protected]>; York Sun <[email protected]>; Prabhakar Kushwaha

Quoted 8 lines
Quoted 8 lines

<[email protected]>

Quoted 7 lines
Quoted 7 lines

Cc: Andy Tang <[email protected]>; Yinbo Zhu <[email protected]>; u-boot at lists.denx.de
Subject: Re: [EXT] Re: [PATCH 1/2] scsi: ceva: Clean up the driver code

WARNING: This email was created outside of NXP. DO NOT CLICK links or attachments unless you recognize the sender and know the content is

safe.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines · Peng Ma
Quoted 2 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

-----Original Message-----
From: Michal Simek <[email protected]>
Sent: 2019年4月16日 18:49
To: Peng Ma <[email protected]>; Michal Simek <[email protected]>; albert.u.boot at aribaud.net; sjg at chromium.org; Fabio Estevam <[email protected]>; York

Sun

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line

<[email protected]>; Prabhakar Kushwaha

<[email protected]>

Quoted 1 line
Quoted 1 line
Cc Andy Tang <[email protected]>; Yinbo Zhu

<[email protected]>;

Quoted 39 lines
Quoted 39 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

u-boot at lists.denx.de
Subject: Re: [EXT] Re: [PATCH 1/2] scsi: ceva: Clean up the driver code

WARNING: This email was created outside of NXP. DO NOT CLICK links or attachments unless you recognize the sender and know the content is

safe.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines · Peng Ma
Quoted 2 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

-----Original Message-----
From: Michal Simek <[email protected]>
Sent: 2019年4月16日 18:01
To: Peng Ma <[email protected]>; Michal Simek <[email protected]>; albert.u.boot at aribaud.net; sjg at chromium.org; Fabio Estevam <[email protected]>; York

Sun

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line

<[email protected]>; Prabhakar Kushwaha

<[email protected]>

Quoted 1 line
Quoted 1 line
Cc Andy Tang <[email protected]>; Yinbo Zhu

<[email protected]>;

Quoted 14 lines
Quoted 14 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

u-boot at lists.denx.de
Subject: Re: [EXT] Re: [PATCH 1/2] scsi: ceva: Clean up the driver code

WARNING: This email was created outside of NXP. DO NOT CLICK links or attachments unless you recognize the sender and know the content is

safe.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines · Peng Ma
Quoted 2 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

-----Original Message-----
From: Michal Simek <[email protected]>
Sent: 2019年4月16日 17:31
To: Peng Ma <[email protected]>; Michal Simek <[email protected]>; albert.u.boot at aribaud.net; sjg at chromium.org; Fabio Estevam <[email protected]>;

York

Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines

Sun

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line

<[email protected]>; Prabhakar Kushwaha

<[email protected]>

Quoted 1 line
Quoted 1 line
Cc Andy Tang <[email protected]>; Yinbo Zhu

<[email protected]>;

Quoted 11 lines
Quoted 11 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

u-boot at lists.denx.de
Subject: Re: [EXT] Re: [PATCH 1/2] scsi: ceva: Clean up the driver code

WARNING: This email was created outside of NXP. DO NOT CLICK links or attachments unless you recognize the sender and know the content is

safe.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines · Peng Ma
Quoted 6 lines
Quoted 6 lines

-----Original Message-----
From: Michal Simek <[email protected]>
Sent: 2019年4月16日 16:04
To: Peng Ma <[email protected]>;

albert.u.boot at aribaud.net;

Quoted 142 lines
Quoted 142 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

sjg at chromium.org; Fabio Estevam <[email protected]>;

York

Quoted 76 lines
Quoted 76 lines
Quoted 76 lines
Quoted 76 lines

Sun

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line

<[email protected]>; Prabhakar Kushwaha

<[email protected]>

Quoted 1 line
Quoted 1 line

Cc: Andy Tang <[email protected]>; Yinbo Zhu

<[email protected]>;

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

michal.simek at xilinx.com; u-boot at lists.denx.de
Subject: [EXT] Re: [PATCH 1/2] scsi: ceva: Clean up the
driver code

WARNING: This email was created outside of NXP. DO NOT
CLICK links or attachments unless you recognize the sender
and know the content is

Quoted 7 lines
Quoted 7 lines

safe.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines · Peng Ma

Distinguish the ecc val by chassis version and move the
ecc addr to

dts.

Quoted 56 lines
Quoted 56 lines
Quoted 56 lines
Quoted 56 lines
Quoted 56 lines
Quoted 56 lines

Add ls1028a soc support.

Signed-off-by: Peng Ma <[email protected]>
---
drivers/ata/sata_ceva.c | 43
+++++++++++++++++++++++++------------------
1 files changed, 25 insertions(+), 18 deletions(-)

diff --git a/drivers/ata/sata_ceva.c
b/drivers/ata/sata_ceva.c index
8887be9..d26f712 100644
--- a/drivers/ata/sata_ceva.c
+++ b/drivers/ata/sata_ceva.c
@@ -88,20 +88,16 @@
#define LS1021_CEVA_PHY4_CFG 0x064a080b #define
LS1021_CEVA_PHY5_CFG
0x2aa86470

-/* for ls1088a */
-#define LS1088_ECC_DIS_ADDR_CH2 0x100520
-#define LS1088_ECC_DIS_VAL_CH2 0x40000000
-
-/* ecc addr-val pair */
-#define ECC_DIS_ADDR_CH2 0x20140520
+/* ecc val pair */
+#define ECC_DIS_VAL_CH1 0x00020000
#define ECC_DIS_VAL_CH2 0x80000000
-#define SATA_ECC_REG_ADDR 0x20220520
-#define SATA_ECC_DISABLE 0x00020000
+#define ECC_DIS_VAL_CH3 0x40000000

enum ceva_soc {
CEVA_1V84,
CEVA_LS1012A,
CEVA_LS1021A,
+ CEVA_LS1028A,
CEVA_LS1043A,
CEVA_LS1046A,
CEVA_LS1088A,
@@ -110,12 +106,14 @@ enum ceva_soc {

struct ceva_sata_priv {
ulong base;
+ ulong ecc_base;
enum ceva_soc soc;
ulong flag;
};

static int ceva_init_sata(struct ceva_sata_priv *priv) {
+ ulong ecc_addr = priv->ecc_base;
ulong base = priv->base;
ulong tmp;

@@ -132,38 +130,38 @@ static int ceva_init_sata(struct
ceva_sata_priv
*priv)

Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

break;

case CEVA_LS1021A:
- writel(SATA_ECC_DISABLE,

SATA_ECC_REG_ADDR);

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

+ if (ecc_addr)
+ writel(ECC_DIS_VAL_CH1,

ecc_addr);

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

writel(CEVA_PHY1_CFG, base +

AHCI_VEND_PPCFG);

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

writel(LS1021_CEVA_PHY2_CFG, base +
AHCI_VEND_PP2C);
writel(LS1021_CEVA_PHY3_CFG, base +
AHCI_VEND_PP3C);
writel(LS1021_CEVA_PHY4_CFG, base +
AHCI_VEND_PP4C);
writel(LS1021_CEVA_PHY5_CFG, base +
AHCI_VEND_PP5C);
writel(CEVA_TRANS_CFG, base +

AHCI_VEND_PTC);

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

- if (priv->flag & FLAG_COHERENT)
- writel(CEVA_AXICC_CFG, base +

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

LS1021_AHCI_VEND_AXICC);
break;

case CEVA_LS1012A:
case CEVA_LS1043A:
case CEVA_LS1046A:
- writel(ECC_DIS_VAL_CH2,

ECC_DIS_ADDR_CH2);

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

- /* fallthrough */
case CEVA_LS2080A:
+ if (ecc_addr)
+ writel(ECC_DIS_VAL_CH2,

ecc_addr);

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

writel(CEVA_PHY1_CFG, base +

AHCI_VEND_PPCFG);

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

writel(CEVA_TRANS_CFG, base +

AHCI_VEND_PTC);

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

- if (priv->flag & FLAG_COHERENT)
- writel(CEVA_AXICC_CFG, base +
AHCI_VEND_AXICC);

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

break;

+ case CEVA_LS1028A:
case CEVA_LS1088A:
- writel(LS1088_ECC_DIS_VAL_CH2,
LS1088_ECC_DIS_ADDR_CH2);
+ if (ecc_addr)
+ writel(ECC_DIS_VAL_CH3,

ecc_addr);

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

writel(CEVA_PHY1_CFG, base +

AHCI_VEND_PPCFG);

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

writel(CEVA_TRANS_CFG, base +

AHCI_VEND_PTC);

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

- if (priv->flag & FLAG_COHERENT)
- writel(CEVA_AXICC_CFG, base +
AHCI_VEND_AXICC);
break;
}

+ if (priv->flag & FLAG_COHERENT)
+ writel(CEVA_AXICC_CFG, base +

AHCI_VEND_AXICC);

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

+
return 0;
}

@@ -187,6 +185,7 @@ static const struct udevice_id
sata_ceva_ids[] =

{

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

{ .compatible = "ceva,ahci-1v84", .data =

CEVA_1V84 },

Quoted 45 lines
Quoted 45 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

{ .compatible = "fsl,ls1012a-ahci", .data =

CEVA_LS1012A },

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

{ .compatible = "fsl,ls1021a-ahci", .data =
CEVA_LS1021A },
+ { .compatible = "fsl,ls1028a-ahci", .data =
+ CEVA_LS1028A },
{ .compatible = "fsl,ls1043a-ahci", .data =

CEVA_LS1043A },

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

{ .compatible = "fsl,ls1046a-ahci", .data =

CEVA_LS1046A },

Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 9 lines
Quoted 9 lines

{ .compatible = "fsl,ls1088a-ahci", .data =
CEVA_LS1088A }, @@
-205,8 +204,16 @@ static int
sata_ceva_ofdata_to_platdata(struct
udevice
*dev)
if (priv->base == FDT_ADDR_T_NONE)
return -EINVAL;

Quoted 7 lines
Quoted 5 lines

+ priv->ecc_base = dev_read_addr_index(dev, 1);

It would be better to do it via reg-name instead of index.
But that's up to your binding doc.

[Peng Ma] OK, could I change arch/arm/dts/zynqmp.dtsi file sata node as

fallows?

Quoted 1 line
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

arch/arm/dts/zynqmp.dtsi line 694

Quoted 9 lines
(quoted diff) +0 -0

b/arch/arm/dts/zynqmp.dtsi index
dfb6ebc..9ad2d84 100644

arch/arm/dts/zynqmp.dtsi +0 -0
@@ -692,6 +692,7 @@
                        compatible = "ceva,ahci-1v84";
                        status = "disabled";
                        reg = <0x0 0xfd0c0000 0x0

0x2000>;

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

arch/arm/dts/zynqmp.dtsi line 698

Quoted 4 lines
arch/arm/dts/zynqmp.dtsi +1 -0
+                       reg-names = "serdes";
                        interrupt-parent = <&gic>;
                        interrupts = <0 133 4>;
                        #stream-id-cells = <4>;

Unfortunately it is not that simple.

Quoted 12 lines
Quoted 12 lines
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
Quoted 8 lines

First of all you need to reflect this in dt binding doc in the kernel.
https://eur01.safelinks.protection.outlook.com/?url=https%3A%
2F
%2
Fg
it
.kern

el.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Ftorvalds%2Flinux.git%2Ftr

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
Quoted 1 line

ee%2FDocumentation%2Fdevicetree%2Fbindings%2Fata%2Fahci-ceva.txt%3F

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
Quoted 1 line

h%3Dv5.1-rc5&amp;data=02%7C01%7Cpeng.ma%40nxp.com%7Cc588ddff1b1

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
Quoted 1 line

e471f645b08d6c24e54d7%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
Quoted 1 line

0%7C636910039050031150&amp;sdata=0Gsuo2uI3pot4VAhBr7SQUnCRYT7Xi

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

Ybybu6i1t%2Byzo%3D&amp;reserved=0

Did you record your compatible strings anywhere?

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

[Peng Ma] Thanks your quick reply.
You can find our binding document at:
(https://eur01.safelinks.protection.outlook.com/?url=https%3A%
2F
%2
Fg
it .kernel.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Ftorvalds%

2F

Quoted 10 lines
Quoted 10 lines

lin

Quoted 8 lines
Quoted 8 lines

ux.

Quoted 6 lines
Quoted 6 lines

gi

Quoted 4 lines
Quoted 4 lines
Quoted 1 line

t

%

Quoted 1 line

2Ftree%2FDocumentation%2Fdevicetree%2Fbindings%2Fata%2Fahci-fsl-qoriq.

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line

txt%3Fh%3Dv5.1-rc5&amp;data=02%7C01%7Cpeng.ma%40nxp.com%7C977d

Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Quoted 3 lines

7871292f

Quoted 1 line

48332dbb08d6c2526b32%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C

Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Quoted 3 lines

0%7C6369

Quoted 1 line

10056581930082&amp;sdata=KQryE2RvI8jTOAPKGlGnx2NWYdawFUaTURyzd8

Quoted 42 lines
Quoted 42 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

oets4%3

Quoted 1 line

D&amp;reserved=0)

Interesting. Why did you create separate binding doc if you target the same ceva sata IP core? Any reason not to merge it

together?

Quoted 36 lines
Quoted 36 lines
Quoted 36 lines
Quoted 36 lines
Quoted 5 lines
Quoted 2 lines

Anyway I see that this was added in 2015.

[Peng Ma] Although they are both ceva sata, our sata driver is different from yours in kernel to Initializa Vendor-specific registers, you could

see our driver at kernel driver/ata/ ahci_qoriq.c.

I have briefly looked at it. They should be merged together. It happened to us too that we send driver out but didn't know who was the vendor in past and then we found out.

Quoted 10 lines
Quoted 8 lines
Quoted 2 lines

I think your suggestion is better. But the first register cd address was got by

function dev_read_addr(), to keep consistency, I still prefer to use dev_read_addr_index(). What do you think?

We didn't have a need to have second address range that's why reg-names property wasn't used. Do they have all ecc addresses?

[Peng Ma] Some of our socs need to fixed sata errata. So we should write ecc

addr.

Quoted 1 line

I didn't add reg-names to keep consistency of Xilinx sata soc.

Ok. I think that in this case you should pass different .data to driver.

struct platform_data {
       enum ceva_soc;
       bool ecc_present;
}

It means have current enum followed by bool with "true" for specific IPs which needs to have also ECC range. Then you can better check that binding is correct.

And use _index there.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

[Peng Ma] As far as I am concerned, It is not necessary to do this, I would rather lean on the former way as fallows:

drivers/ata/sata_ceva.c +0 -0
index d26f712..a1d452a 100644
@@ -196,6 +196,10 @@ static const struct udevice_id

sata_ceva_ids[] = { static int sata_ceva_ofdata_to_platdata(struct

udevice *dev) {

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
        struct ceva_sata_priv *priv = dev_get_priv(dev);

+ const void *blob = gd->fdt_blob;

gd is suggesting that you use incorrect functions.
We are trying to get rid of gd from device drivers. Please take a look at live tree functions if there is any alternative there.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

drivers/ata/sata_ceva.c static const struct udevice_id sata_ceva_ids[] = {

Quoted 6 lines
drivers/ata/sata_ceva.c +3 -0
+       int node = dev_of_offset(dev);
+       struct fdt_resource res_regs;
+       int ret;
 
        if (dev_read_bool(dev, "dma-coherent"))
                priv->flag |= FLAG_COHERENT; @@ -204,9

+208,13

Quoted 9 lines
Quoted 9 lines

@@

Quoted 8 lines
Quoted 8 lines
Quoted 1 line

static int sata_ceva_ofdata_to_platdata(struct

udevice *dev)

Quoted 6 lines
        if (priv->base == FDT_ADDR_T_NONE)
                return -EINVAL;
drivers/ata/sata_ceva.c +1 -2
-       priv->ecc_base = dev_read_addr_index(dev, 1);
-       if (priv->ecc_base == FDT_ADDR_T_NONE)
+       ret = fdt_get_named_resource(blob, node, "reg",

"reg-names",

Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 8 lines
Quoted 8 lines
drivers/ata/sata_ceva.c +6 -0
+                                    "ecc-addr", &res_regs);
+       if (ret) {
+               debug("Error: can't get ecc addresses(ret =
+ %d)!\n", ret);
                priv->ecc_base = 0;
+       } else
+               priv->ecc_base = res_regs.start;
Quoted 7 lines
Quoted 1 line
        priv->soc = dev_get_driver_data(dev); What do you think?

One thing I would like to avoid is that we will get any error even in debug for IPs which don't have this ecc space.
And also that we will get this errors for IPs which should have this ecc space.

[Peng Ma] OK,changed as fallows:

drivers/ata/sata_ceva.c index renamed from drivers/ata/sata_ceva.c +0 -0

d26f712..bd98d85 100644

drivers/ata/sata_ceva.c +1 -0
@@ -8,6 +8,7 @@
 #include <ahci.h>
 #include <scsi.h>
 #include <asm/io.h>
+#include <linux/ioport.h>
 
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
drivers/ata/sata_ceva.c +0 -0
 /* Vendor Specific Register Offsets */  #define AHCI_VEND_PCFG

0xA4 @@ -196,6 +197,8 @@ static const struct udevice_id sata_ceva_ids[] = { static int sata_ceva_ofdata_to_platdata(struct udevice

*dev) {

Quoted 40 lines
Quoted 19 lines

drivers/ata/sata_ceva.c static const struct udevice_id sata_ceva_ids[] = {

Quoted 6 lines
        struct ceva_sata_priv *priv = dev_get_priv(dev);
drivers/ata/sata_ceva.c +2 -0
+       struct resource res_regs;
+       int ret;
 
        if (dev_read_bool(dev, "dma-coherent"))
                priv->flag |= FLAG_COHERENT; @@ -204,9 +207,11

@@

Quoted 12 lines

static int sata_ceva_ofdata_to_platdata(struct udevice *dev)

        if (priv->base == FDT_ADDR_T_NONE)
                return -EINVAL;
drivers/ata/sata_ceva.c +4 -2
-       priv->ecc_base = dev_read_addr_index(dev, 1);
-       if (priv->ecc_base == FDT_ADDR_T_NONE)
+       ret = dev_read_resource_byname(dev, "ecc-addr", &res_regs);
+       if (ret)
                priv->ecc_base = 0;
+       else
+               priv->ecc_base = res_regs.start;
Quoted 6 lines
Quoted 1 line
        priv->soc = dev_get_driver_data(dev);

This looks good but still missing information that in your case there are some versions where this ecc-addr is required. It means if it is required you should error it out when it is not present in DT.

[Peng Ma] Ok, It will return error when some socs need ecc address with the regs is not Present in DT.

drivers/ata/sata_ceva.c index renamed from drivers/ata/sata_ceva.c +0 -0

d26f712..6e28a38 100644

drivers/ata/sata_ceva.c +1 -0
@@ -8,6 +8,7 @@
 #include <ahci.h>
 #include <scsi.h>
 #include <asm/io.h>
+#include <linux/ioport.h>
 
 /* Vendor Specific Register Offsets */  #define AHCI_VEND_PCFG  0xA4

drivers/ata/sata_ceva.c static int ceva_init_sata(struct ceva_sata_priv *priv) · line 138

Quoted 10 lines
drivers/ata/sata_ceva.c +3 -2
@@ -130,8 +131,9 @@ static int ceva_init_sata(struct ceva_sata_priv *priv)
                break;
 
        case CEVA_LS1021A:
-               if (ecc_addr)
-                       writel(ECC_DIS_VAL_CH1, ecc_addr);
+               if (!ecc_addr)
+                       return -EINVAL;
+               writel(ECC_DIS_VAL_CH1, ecc_addr);
                writel(CEVA_PHY1_CFG, base + AHCI_VEND_PPCFG);
                writel(LS1021_CEVA_PHY2_CFG, base +

AHCI_VEND_PP2C);

drivers/ata/sata_ceva.c static int ceva_init_sata(struct ceva_sata_priv *priv) · line 139

Quoted 1 line
drivers/ata/sata_ceva.c +0 -0
                writel(LS1021_CEVA_PHY3_CFG, base +

AHCI_VEND_PP3C);

drivers/ata/sata_ceva.c static int ceva_init_sata(struct ceva_sata_priv

Quoted 1 line
drivers/ata/sata_ceva.c +0 -0
@@ -143,17 +145,19 @@ static int ceva_init_sata(struct ceva_sata_priv

*priv)

Quoted 24 lines
drivers/ata/sata_ceva.c +6 -4
        case CEVA_LS1012A:
        case CEVA_LS1043A:
        case CEVA_LS1046A:
+               if (!ecc_addr)
+                       return -EINVAL;
+               writel(ECC_DIS_VAL_CH2, ecc_addr);
        case CEVA_LS2080A:
-               if (ecc_addr)
-                       writel(ECC_DIS_VAL_CH2, ecc_addr);
                writel(CEVA_PHY1_CFG, base + AHCI_VEND_PPCFG);
                writel(CEVA_TRANS_CFG, base + AHCI_VEND_PTC);
                break;
 
        case CEVA_LS1028A:
        case CEVA_LS1088A:
-               if (ecc_addr)
-                       writel(ECC_DIS_VAL_CH3, ecc_addr);
+               if (!ecc_addr)
+                       return -EINVAL;
+               writel(ECC_DIS_VAL_CH3, ecc_addr);
                writel(CEVA_PHY1_CFG, base + AHCI_VEND_PPCFG);
                writel(CEVA_TRANS_CFG, base + AHCI_VEND_PTC);
                break;

drivers/ata/sata_ceva.c static const struct udevice_id sata_ceva_ids[] = { · line 206

Quoted 7 lines
drivers/ata/sata_ceva.c +2 -0
@@ -196,6 +200,8 @@ static const struct udevice_id sata_ceva_ids[] = {
 static int sata_ceva_ofdata_to_platdata(struct udevice *dev)  {
        struct ceva_sata_priv *priv = dev_get_priv(dev);
+       struct resource res_regs;
+       int ret;
 
        if (dev_read_bool(dev, "dma-coherent"))
                priv->flag |= FLAG_COHERENT; @@ -204,9 +210,11

@@

Quoted 12 lines
drivers/ata/sata_ceva.c +0 -0
 static int sata_ceva_ofdata_to_platdata(struct udevice *dev)
        if (priv->base == FDT_ADDR_T_NONE)
                return -EINVAL;
drivers/ata/sata_ceva.c +4 -2
-       priv->ecc_base = dev_read_addr_index(dev, 1);
-       if (priv->ecc_base == FDT_ADDR_T_NONE)
+       ret = dev_read_resource_byname(dev, "ecc-addr", &res_regs);
+       if (ret)
                priv->ecc_base = 0;
+       else
+               priv->ecc_base = res_regs.start;
Quoted 5 lines
Quoted 2 lines
        priv->soc = dev_get_driver_data(dev);

ok. Looks good.

[Peng Ma] Thanks very much for your patient guidance.

Best Regards,
Peng

Quoted 1 line

M