phy: marvell: a3700: add sata comphy on lane 2 with invert option
authorzachary <zhangzg@marvell.com>
Fri, 28 Aug 2020 14:56:29 +0000 (16:56 +0200)
committerStefan Roese <sr@denx.de>
Fri, 4 Sep 2020 12:02:00 +0000 (14:02 +0200)
- This patch moves sata phy powerup from dedicate phy to compphy
  and adds invert option for sata powerup routine.

Change-Id: I1b4e8753e2b2c14c6efa97bca2ffc7d2553d8a90
Signed-off-by: zachary <zhangzg@marvell.com>
Signed-off-by: Ken Ma <make@marvell.com>
Reviewed-on: http://vgitil04.il.marvell.com:8080/53601
Reviewed-by: Igal Liberman <igall@marvell.com>
Tested-by: Igal Liberman <igall@marvell.com>
[a.heider: adapt to mainline]
Signed-off-by: Andre Heider <a.heider@gmail.com>
Tested-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Stefan Roese <sr@denx.de>
drivers/phy/marvell/comphy_a3700.c

index dc188c4..4606de6 100644 (file)
@@ -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
@@ -925,22 +932,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) {
                node = fdt_node_offset_by_compatible(
@@ -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);