Skip to contentSkip to conversation

phy: marvell: a3700: add sata comphy on lane 2 with invert option

PATCH New Andre Heider 3 participants 4 messages Aug 28, 2020 – Sep 4, 2020 Generic PHY framework

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 phy: marvell: a3700: add sata comphy on lane 2 with invert option

From: zachary <[email protected]>

- This patch moves sata phy powerup from dedicate phy to compphy and adds invert option for sata powerup routine.

Change-Id I1b4e8753e2b2c14c6efa97bca2ffc7d2553d8a90

Reviewed-on: http://vgitil04.il.marvell.com:8080/53601

---

This is based on the downstream patch:
https://github.com/MarvellEmbeddedProcessors/u-boot-marvell/commit/0a5b159806baa0746b6449920e450498bc269ba7

Fixes SATA on my espressobin v5.

 drivers/phy/marvell/comphy_a3700.c | 33 +++++++++++++-----------------
 1 file changed, 14 insertions(+), 19 deletions(-)
drivers/phy/marvell/comphy_a3700.c +14 -19
index dc188c44e0..4606de6f48 100644
@@ -273,16 +273,23 @@ static void reg_set_indirect(u32 reg, u16 data, u16 mask)
  *
  * return: 1 if PLL locked (OK), 0 otherwise (FAIL)
  */
-static int comphy_sata_power_up(void)
+static int comphy_sata_power_up(u32 invert)
 {
 	int ret;
+	u32 data = 0;
 
 	debug_enter();
 
 	/*
-	 * 0. Swap SATA TX lines
+	 * 0. Check the Polarity invert bits
 	 */
-	reg_set_indirect(vphy_sync_pattern_reg, bs_txd_inv, bs_txd_inv);
+	if (invert & PHY_POLARITY_TXD_INVERT)
+		data |= bs_txd_inv;
+
+	if (invert & PHY_POLARITY_RXD_INVERT)
+		data |= bs_rxd_inv;
+
+	reg_set_indirect(vphy_sync_pattern_reg, data, bs_txd_inv | bs_rxd_inv);
 
 	/*
 	 * 1. Select 40-bit data width width
@@ -924,22 +931,6 @@ void comphy_dedicated_phys_init(void)
 		}
 	}
 
-	node = fdt_node_offset_by_compatible(blob, -1,
-					     "marvell,armada-3700-ahci");
-	if (node > 0) {
-		if (fdtdec_get_is_enabled(blob, node)) {
-			ret = comphy_sata_power_up();
-			if (!ret)
-				printf("Failed to initialize SATA PHY\n");
-			else
-				debug("SATA PHY init succeed\n");
-		} else {
-			debug("SATA node is disabled\n");
-		}
-	}  else {
-		debug("No SATA node in DT\n");
-	}
-
 	node = fdt_node_offset_by_compatible(blob, -1,
 					     "marvell,armada-8k-sdhci");
 	if (node <= 0) {
@@ -1007,6 +998,10 @@ int comphy_a3700_init(struct chip_serdes_phy_config *chip_cfg,
 						    comphy_map->invert);
 			break;
 
+		case PHY_TYPE_SATA0:
+			ret = comphy_sata_power_up(comphy_map->invert);
+			break;
+
 		default:
 			debug("Unknown SerDes type, skip initialize SerDes %d\n",
 			      lane);
Signature · 1 line
2.28.0
#1 lore raw

PATCH 1/1 phy: marvell: a3700: add sata comphy on lane 2 with invert option

Quoted 5 lines · On Friday 28 August 2020 16:56:29 Andre Heider wrote:

From: zachary <[email protected]>

- This patch moves sata phy powerup from dedicate phy to compphy and adds invert option for sata powerup routine.

Quoted 8 lines
Change-Id I1b4e8753e2b2c14c6efa97bca2ffc7d2553d8a90

Reviewed-on: http://vgitil04.il.marvell.com:8080/53601

Quoted 6 lines

---

This is based on the downstream patch:
https://github.com/MarvellEmbeddedProcessors/u-boot-marvell/commit/0a5b159806baa0746b6449920e450498bc269ba7

Fixes SATA on my espressobin v5.

Thanks! It really fixed SATA support on EspressoBin v5 test unit.

Quoted 71 lines
 drivers/phy/marvell/comphy_a3700.c | 33 +++++++++++++-----------------
 1 file changed, 14 insertions(+), 19 deletions(-)
drivers/phy/marvell/comphy_a3700.c +14 -19
index dc188c44e0..4606de6f48 100644
@@ -273,16 +273,23 @@ static void reg_set_indirect(u32 reg, u16 data, u16 mask)
  *
  * return: 1 if PLL locked (OK), 0 otherwise (FAIL)
  */
-static int comphy_sata_power_up(void)
+static int comphy_sata_power_up(u32 invert)
 {
 	int ret;
+	u32 data = 0;
 
 	debug_enter();
 
 	/*
-	 * 0. Swap SATA TX lines
+	 * 0. Check the Polarity invert bits
 	 */
-	reg_set_indirect(vphy_sync_pattern_reg, bs_txd_inv, bs_txd_inv);
+	if (invert & PHY_POLARITY_TXD_INVERT)
+		data |= bs_txd_inv;
+
+	if (invert & PHY_POLARITY_RXD_INVERT)
+		data |= bs_rxd_inv;
+
+	reg_set_indirect(vphy_sync_pattern_reg, data, bs_txd_inv | bs_rxd_inv);
 
 	/*
 	 * 1. Select 40-bit data width width
@@ -924,22 +931,6 @@ void comphy_dedicated_phys_init(void)
 		}
 	}
 
-	node = fdt_node_offset_by_compatible(blob, -1,
-					     "marvell,armada-3700-ahci");
-	if (node > 0) {
-		if (fdtdec_get_is_enabled(blob, node)) {
-			ret = comphy_sata_power_up();
-			if (!ret)
-				printf("Failed to initialize SATA PHY\n");
-			else
-				debug("SATA PHY init succeed\n");
-		} else {
-			debug("SATA node is disabled\n");
-		}
-	}  else {
-		debug("No SATA node in DT\n");
-	}
-
 	node = fdt_node_offset_by_compatible(blob, -1,
 					     "marvell,armada-8k-sdhci");
 	if (node <= 0) {
@@ -1007,6 +998,10 @@ int comphy_a3700_init(struct chip_serdes_phy_config *chip_cfg,
 						    comphy_map->invert);
 			break;
 
+		case PHY_TYPE_SATA0:
+			ret = comphy_sata_power_up(comphy_map->invert);
+			break;
+
 		default:
 			debug("Unknown SerDes type, skip initialize SerDes %d\n",
 			      lane);
Signature · 1 line
2.28.0
#2 lore raw

PATCH 1/1 phy: marvell: a3700: add sata comphy on lane 2 with invert option

In reply to Andre Heider
Quoted 5 lines · Andre Heider

From: zachary <[email protected]>

- This patch moves sata phy powerup from dedicate phy to compphy and adds invert option for sata powerup routine.

Quoted 8 lines
Change-Id I1b4e8753e2b2c14c6efa97bca2ffc7d2553d8a90

Reviewed-on: http://vgitil04.il.marvell.com:8080/53601

Thanks,
Stefan

Quoted 66 lines

---

This is based on the downstream patch:
https://github.com/MarvellEmbeddedProcessors/u-boot-marvell/commit/0a5b159806baa0746b6449920e450498bc269ba7

Fixes SATA on my espressobin v5.

  drivers/phy/marvell/comphy_a3700.c | 33 +++++++++++++-----------------
  1 file changed, 14 insertions(+), 19 deletions(-)
drivers/phy/marvell/comphy_a3700.c +10 -19
index dc188c44e0..4606de6f48 100644
@@ -273,16 +273,23 @@ static void reg_set_indirect(u32 reg, u16 data, u16 mask)
   *
   * return: 1 if PLL locked (OK), 0 otherwise (FAIL)
   */
-static int comphy_sata_power_up(void)
+static int comphy_sata_power_up(u32 invert)
  {
  	int ret;
+	u32 data = 0;
 
  	debug_enter();
 
  	/*
-	 * 0. Swap SATA TX lines
+	 * 0. Check the Polarity invert bits
  	 */
-	reg_set_indirect(vphy_sync_pattern_reg, bs_txd_inv, bs_txd_inv);
+	if (invert & PHY_POLARITY_TXD_INVERT)
+		data |= bs_txd_inv;
+
+	if (invert & PHY_POLARITY_RXD_INVERT)
+		data |= bs_rxd_inv;
+
+	reg_set_indirect(vphy_sync_pattern_reg, data, bs_txd_inv | bs_rxd_inv);
 
  	/*
  	 * 1. Select 40-bit data width width
@@ -924,22 +931,6 @@ void comphy_dedicated_phys_init(void)
  		}
  	}
 
-	node = fdt_node_offset_by_compatible(blob, -1,
-					     "marvell,armada-3700-ahci");
-	if (node > 0) {
-		if (fdtdec_get_is_enabled(blob, node)) {
-			ret = comphy_sata_power_up();
-			if (!ret)
-				printf("Failed to initialize SATA PHY\n");
-			else
-				debug("SATA PHY init succeed\n");
-		} else {
-			debug("SATA node is disabled\n");
-		}
-	}  else {
-		debug("No SATA node in DT\n");
-	}
-
  	node = fdt_node_offset_by_compatible(blob, -1,
  					     "marvell,armada-8k-sdhci");
  	if (node <= 0) {

drivers/phy/marvell/comphy_a3700.c int comphy_a3700_init(struct chip_serdes_phy_config *chip_cfg, · line 1007

Quoted 10 lines
drivers/phy/marvell/comphy_a3700.c +4 -0
@@ -1007,6 +998,10 @@ int comphy_a3700_init(struct chip_serdes_phy_config *chip_cfg,
  						    comphy_map->invert);
  			break;
 
+		case PHY_TYPE_SATA0:
+			ret = comphy_sata_power_up(comphy_map->invert);
+			break;
+
  		default:
  			debug("Unknown SerDes type, skip initialize SerDes %d\n",
  			      lane);

Viele Gr??e,
Stefan

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr at denx.de
#3 lore raw

PATCH 1/1 phy: marvell: a3700: add sata comphy on lane 2 with invert option

Quoted 15 lines · Stefan Roese
Quoted 5 lines · Andre Heider

From: zachary <[email protected]>

- This patch moves sata phy powerup from dedicate phy to compphy ?? and adds invert option for sata powerup routine.

Quoted 8 lines
Change-Id I1b4e8753e2b2c14c6efa97bca2ffc7d2553d8a90

Reviewed-on: http://vgitil04.il.marvell.com:8080/53601

Quoted 1 line

Applied to u-boot-marvell/master

Thanks,
Stefan

Quoted 75 lines

Thanks,
Stefan

Quoted 72 lines

---

This is based on the downstream patch:
https://github.com/MarvellEmbeddedProcessors/u-boot-marvell/commit/0a5b159806baa0746b6449920e450498bc269ba7

Fixes SATA on my espressobin v5.

? drivers/phy/marvell/comphy_a3700.c | 33 +++++++++++++----------------- ? 1 file changed, 14 insertions(+), 19 deletions(-)

drivers/phy/marvell/comphy_a3700.c +0 -0
index dc188c44e0..4606de6f48 100644
@@ -273,16 +273,23 @@ static void reg_set_indirect(u32 reg, u16 data, 
 u16 mask)

?? *
?? * return: 1 if PLL locked (OK), 0 otherwise (FAIL) ?? */

drivers/phy/marvell/comphy_a3700.c +1 -1
-static int comphy_sata_power_up(void)
+static int comphy_sata_power_up(u32 invert)

? {
????? int ret;
+??? u32 data = 0;
????? debug_enter();
????? /*
-???? * 0. Swap SATA TX lines
+???? * 0. Check the Polarity invert bits
?????? */
-??? reg_set_indirect(vphy_sync_pattern_reg, bs_txd_inv, bs_txd_inv); +??? if (invert & PHY_POLARITY_TXD_INVERT)
+??????? data |= bs_txd_inv;

drivers/phy/marvell/comphy_a3700.c +5 -0
+
+??? if (invert & PHY_POLARITY_RXD_INVERT)
+??????? data |= bs_rxd_inv;
+
+??? reg_set_indirect(vphy_sync_pattern_reg, data, bs_txd_inv | 

bs_rxd_inv);
????? /*
?????? * 1. Select 40-bit data width width

drivers/phy/marvell/comphy_a3700.c +4 -16
@@ -924,22 +931,6 @@ void comphy_dedicated_phys_init(void)
 ????????? }
 ????? }
-??? node = fdt_node_offset_by_compatible(blob, -1,
-???????????????????????? "marvell,armada-3700-ahci");
-??? if (node > 0) {
-??????? if (fdtdec_get_is_enabled(blob, node)) {
-??????????? ret = comphy_sata_power_up();
-??????????? if (!ret)
-??????????????? printf("Failed to initialize SATA PHY\n");
-??????????? else
-??????????????? debug("SATA PHY init succeed\n");
-??????? } else {
-??????????? debug("SATA node is disabled\n");
-??????? }
-??? }? else {
-??????? debug("No SATA node in DT\n");
-??? }
-
 ????? node = fdt_node_offset_by_compatible(blob, -1,
 ?????????????????????????? "marvell,armada-8k-sdhci");
 ????? if (node <= 0) {
@@ -1007,6 +998,10 @@ int comphy_a3700_init(struct 
 chip_serdes_phy_config *chip_cfg,
 ????????????????????????????? comphy_map->invert);
 ????????????? break;
+??????? case PHY_TYPE_SATA0:
+??????????? ret = comphy_sata_power_up(comphy_map->invert);
+??????????? break;
+
Quoted 9 lines
Quoted 4 lines

????????? default:
????????????? debug("Unknown SerDes type, skip initialize SerDes %d\n", ??????????????????? lane);

Viele Gr??e,
Stefan

Viele Gr??e,
Stefan

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr at denx.de