Merge git://git.denx.de/u-boot-fsl-qoriq
[oweals/u-boot.git] / drivers / phy / marvell / comphy_cp110.c
index 21de90c3a1dbbf4d23816110be7669f9ba240100..37187885fa05e3248e97ff296f6c5d1e675a60bd 100644 (file)
@@ -232,6 +232,8 @@ static int comphy_pcie_power_up(u32 lane, u32 pcie_width, bool clk_src,
                mask |= HPIPE_MISC_REFCLK_SEL_MASK;
                data |= 0x1 << HPIPE_MISC_REFCLK_SEL_OFFSET;
        }
+       mask |= HPIPE_MISC_ICP_FORCE_MASK;
+       data |= 0x1 << HPIPE_MISC_ICP_FORCE_OFFSET;
        reg_set(hpipe_addr + HPIPE_MISC_REG, data, mask);
        if (pcie_clk) { /* output */
                /* Set reference frequcency select - 0x2 for 25MHz*/
@@ -267,6 +269,9 @@ static int comphy_pcie_power_up(u32 lane, u32 pcie_width, bool clk_src,
        /* Set Maximal PHY Generation Setting(8Gbps) */
        mask = HPIPE_INTERFACE_GEN_MAX_MASK;
        data = 0x2 << HPIPE_INTERFACE_GEN_MAX_OFFSET;
+       /* Bypass frame detection and sync detection for RX DATA */
+       mask = HPIPE_INTERFACE_DET_BYPASS_MASK;
+       data = 0x1 << HPIPE_INTERFACE_DET_BYPASS_OFFSET;
        /* Set Link Train Mode (Tx training control pins are used) */
        mask |= HPIPE_INTERFACE_LINK_TRAIN_MASK;
        data |= 0x1 << HPIPE_INTERFACE_LINK_TRAIN_OFFSET;
@@ -351,9 +356,9 @@ static int comphy_pcie_power_up(u32 lane, u32 pcie_width, bool clk_src,
        data = 0x3 << HPIPE_G3_DFE_RES_OFFSET;
        reg_set(hpipe_addr + HPIPE_G3_SETTING_4_REG, data, mask);
 
-       /* Force DFE resolution (use GEN table value) */
+       /* Use TX/RX training result for DFE */
        mask = HPIPE_DFE_RES_FORCE_MASK;
-       data = 0x1 << HPIPE_DFE_RES_FORCE_OFFSET;
+       data = 0x0 << HPIPE_DFE_RES_FORCE_OFFSET;
        reg_set(hpipe_addr + HPIPE_DFE_REG0,  data, mask);
 
        /* Configure initial and final coefficient value for receiver */
@@ -379,9 +384,64 @@ static int comphy_pcie_power_up(u32 lane, u32 pcie_width, bool clk_src,
        data = 0x1 << HPIPE_G3_FFE_DEG_RES_LEVEL_OFFSET;
 
        mask |= HPIPE_G3_FFE_LOAD_RES_LEVEL_MASK;
-       data |= 0x1 << HPIPE_G3_FFE_LOAD_RES_LEVEL_OFFSET;
+       data |= 0x3 << HPIPE_G3_FFE_LOAD_RES_LEVEL_OFFSET;
        reg_set(hpipe_addr + HPIPE_G3_SETTING_3_REG, data, mask);
 
+       /* Pattern lock lost timeout disable */
+       mask = HPIPE_PATTERN_LOCK_LOST_TIMEOUT_EN_MASK;
+       data = 0x0 << HPIPE_PATTERN_LOCK_LOST_TIMEOUT_EN_OFFSET;
+       reg_set(hpipe_addr + HPIPE_FRAME_DETECT_CTRL_3_REG, data, mask);
+
+       /* Configure DFE adaptations */
+       mask = HPIPE_CDR_MAX_DFE_ADAPT_1_MASK;
+       data = 0x1 << HPIPE_CDR_MAX_DFE_ADAPT_1_OFFSET;
+       mask |= HPIPE_CDR_MAX_DFE_ADAPT_0_MASK;
+       data |= 0x0 << HPIPE_CDR_MAX_DFE_ADAPT_0_OFFSET;
+       mask |= HPIPE_CDR_RX_MAX_DFE_ADAPT_1_MASK;
+       data |= 0x0 << HPIPE_CDR_RX_MAX_DFE_ADAPT_1_OFFSET;
+       reg_set(hpipe_addr + HPIPE_CDR_CONTROL_REG, data, mask);
+       mask = HPIPE_DFE_TX_MAX_DFE_ADAPT_MASK;
+       data = 0x0 << HPIPE_DFE_TX_MAX_DFE_ADAPT_OFFSET;
+       reg_set(hpipe_addr + HPIPE_DFE_CONTROL_REG, data, mask);
+
+       /* Genration 2 setting 1*/
+       mask = HPIPE_G2_SET_1_G2_RX_SELMUPI_MASK;
+       data = 0x0 << HPIPE_G2_SET_1_G2_RX_SELMUPI_OFFSET;
+       mask |= HPIPE_G2_SET_1_G2_RX_SELMUPP_MASK;
+       data |= 0x1 << HPIPE_G2_SET_1_G2_RX_SELMUPP_OFFSET;
+       mask |= HPIPE_G2_SET_1_G2_RX_SELMUFI_MASK;
+       data |= 0x0 << HPIPE_G2_SET_1_G2_RX_SELMUFI_OFFSET;
+       reg_set(hpipe_addr + HPIPE_G2_SET_1_REG, data, mask);
+
+       /* DFE enable */
+       mask = HPIPE_G2_DFE_RES_MASK;
+       data = 0x3 << HPIPE_G2_DFE_RES_OFFSET;
+       reg_set(hpipe_addr + HPIPE_G2_SETTINGS_4_REG, data, mask);
+
+       /* Configure DFE Resolution */
+       mask = HPIPE_LANE_CFG4_DFE_EN_SEL_MASK;
+       data = 0x1 << HPIPE_LANE_CFG4_DFE_EN_SEL_OFFSET;
+       reg_set(hpipe_addr + HPIPE_LANE_CFG4_REG, data, mask);
+
+       /* VDD calibration control */
+       mask = HPIPE_EXT_SELLV_RXSAMPL_MASK;
+       data = 0x16 << HPIPE_EXT_SELLV_RXSAMPL_OFFSET;
+       reg_set(hpipe_addr + HPIPE_VDD_CAL_CTRL_REG, data, mask);
+
+       /* Set PLL Charge-pump Current Control */
+       mask = HPIPE_G3_SETTING_5_G3_ICP_MASK;
+       data = 0x4 << HPIPE_G3_SETTING_5_G3_ICP_OFFSET;
+       reg_set(hpipe_addr + HPIPE_G3_SETTING_5_REG, data, mask);
+
+       /* Set lane rqualization remote setting */
+       mask = HPIPE_LANE_CFG_FOM_DIRN_OVERRIDE_MASK;
+       data = 0x1 << HPIPE_LANE_CFG_FOM_DIRN_OVERRIDE_OFFSET;
+       mask |= HPIPE_LANE_CFG_FOM_ONLY_MODE_MASK;
+       data |= 0x1 << HPIPE_LANE_CFG_FOM_ONLY_MODE_OFFFSET;
+       mask |= HPIPE_LANE_CFG_FOM_PRESET_VECTOR_MASK;
+       data |= 0x2 << HPIPE_LANE_CFG_FOM_PRESET_VECTOR_OFFSET;
+       reg_set(hpipe_addr + HPIPE_LANE_EQ_REMOTE_SETTING_REG, data, mask);
+
        if (!is_end_point) {
                /* Set phy in root complex mode */
                mask = HPIPE_CFG_PHY_RC_EP_MASK;
@@ -449,7 +509,7 @@ static int comphy_pcie_power_up(u32 lane, u32 pcie_width, bool clk_src,
                                debug("Read from reg = %p - value = 0x%x\n",
                                      hpipe_addr + HPIPE_LANE_STATUS1_REG,
                                      data);
-                               error("HPIPE_LANE_STATUS1_PCLK_EN_MASK is 0\n");
+                               pr_err("HPIPE_LANE_STATUS1_PCLK_EN_MASK is 0\n");
                                ret = 0;
                        }
                }
@@ -573,7 +633,7 @@ static int comphy_usb3_power_up(u32 lane, void __iomem *hpipe_base,
        if (data != 0) {
                debug("Read from reg = %p - value = 0x%x\n",
                      hpipe_addr + HPIPE_LANE_STATUS1_REG, data);
-               error("HPIPE_LANE_STATUS1_PCLK_EN_MASK is 0\n");
+               pr_err("HPIPE_LANE_STATUS1_PCLK_EN_MASK is 0\n");
                ret = 0;
        }
 
@@ -582,7 +642,7 @@ static int comphy_usb3_power_up(u32 lane, void __iomem *hpipe_base,
 }
 
 static int comphy_sata_power_up(u32 lane, void __iomem *hpipe_base,
-                               void __iomem *comphy_base, int comphy_index)
+                               void __iomem *comphy_base, int cp_index)
 {
        u32 mask, data, i, ret = 1;
        void __iomem *hpipe_addr = HPIPE_ADDR(hpipe_base, lane);
@@ -601,19 +661,19 @@ static int comphy_sata_power_up(u32 lane, void __iomem *hpipe_base,
         * In order to parse each CPs SATA node, fdt_node_offset_by_compatible
         * must be called again (according to the CP id)
         */
-       for (i = 0; i < (comphy_index + 1); i++)
+       for (i = 0; i < (cp_index + 1); i++)
                sata_node = fdt_node_offset_by_compatible(
                        gd->fdt_blob, sata_node, "marvell,armada-8k-ahci");
 
        if (sata_node == 0) {
-               error("SATA node not found in FDT\n");
+               pr_err("SATA node not found in FDT\n");
                return 0;
        }
 
        sata_base = (void __iomem *)fdtdec_get_addr_size_auto_noparent(
                gd->fdt_blob, sata_node, "reg", 0, NULL, true);
        if (sata_base == NULL) {
-               error("SATA address not found in FDT\n");
+               pr_err("SATA address not found in FDT\n");
                return 0;
        }
 
@@ -916,7 +976,7 @@ static int comphy_sata_power_up(u32 lane, void __iomem *hpipe_base,
        if (data != 0) {
                debug("Read from reg = %p - value = 0x%x\n",
                      hpipe_addr + HPIPE_LANE_STATUS1_REG, data);
-               error("SD_EXTERNAL_STATUS0_PLL_TX is %d, SD_EXTERNAL_STATUS0_PLL_RX is %d\n",
+               pr_err("SD_EXTERNAL_STATUS0_PLL_TX is %d, SD_EXTERNAL_STATUS0_PLL_RX is %d\n",
                      (data & SD_EXTERNAL_STATUS0_PLL_TX_MASK),
                      (data & SD_EXTERNAL_STATUS0_PLL_RX_MASK));
                ret = 0;
@@ -1039,7 +1099,7 @@ static int comphy_sgmii_power_up(u32 lane, u32 sgmii_speed,
        if (data != 0) {
                debug("Read from reg = %p - value = 0x%x\n",
                      sd_ip_addr + SD_EXTERNAL_STATUS0_REG, data);
-               error("SD_EXTERNAL_STATUS0_PLL_RX is %d, SD_EXTERNAL_STATUS0_PLL_TX is %d\n",
+               pr_err("SD_EXTERNAL_STATUS0_PLL_RX is %d, SD_EXTERNAL_STATUS0_PLL_TX is %d\n",
                      (data & SD_EXTERNAL_STATUS0_PLL_RX_MASK),
                      (data & SD_EXTERNAL_STATUS0_PLL_TX_MASK));
                ret = 0;
@@ -1057,7 +1117,7 @@ static int comphy_sgmii_power_up(u32 lane, u32 sgmii_speed,
        data = polling_with_timeout(addr, data, mask, 100);
        if (data != 0) {
                debug("Read from reg = %p - value = 0x%x\n", sd_ip_addr + SD_EXTERNAL_STATUS0_REG, data);
-               error("SD_EXTERNAL_STATUS0_RX_INIT is 0\n");
+               pr_err("SD_EXTERNAL_STATUS0_RX_INIT is 0\n");
                ret = 0;
        }
 
@@ -1338,7 +1398,7 @@ static int comphy_sfi_power_up(u32 lane, void __iomem *hpipe_base,
        data = polling_with_timeout(addr, data, mask, 15000);
        if (data != 0) {
                debug("Read from reg = %p - value = 0x%x\n", sd_ip_addr + SD_EXTERNAL_STATUS0_REG, data);
-               error("SD_EXTERNAL_STATUS0_PLL_RX is %d, SD_EXTERNAL_STATUS0_PLL_TX is %d\n",
+               pr_err("SD_EXTERNAL_STATUS0_PLL_RX is %d, SD_EXTERNAL_STATUS0_PLL_TX is %d\n",
                      (data & SD_EXTERNAL_STATUS0_PLL_RX_MASK),
                      (data & SD_EXTERNAL_STATUS0_PLL_TX_MASK));
                ret = 0;
@@ -1358,7 +1418,7 @@ static int comphy_sfi_power_up(u32 lane, void __iomem *hpipe_base,
        if (data != 0) {
                debug("Read from reg = %p - value = 0x%x\n",
                      sd_ip_addr + SD_EXTERNAL_STATUS0_REG, data);
-               error("SD_EXTERNAL_STATUS0_RX_INIT is 0\n");
+               pr_err("SD_EXTERNAL_STATUS0_RX_INIT is 0\n");
                ret = 0;
        }
 
@@ -1517,7 +1577,7 @@ static int comphy_rxauii_power_up(u32 lane, void __iomem *hpipe_base,
        if (data != 0) {
                debug("Read from reg = %p - value = 0x%x\n",
                      sd_ip_addr + SD_EXTERNAL_STATUS0_REG, data);
-               error("SD_EXTERNAL_STATUS0_PLL_RX is %d, SD_EXTERNAL_STATUS0_PLL_TX is %d\n",
+               pr_err("SD_EXTERNAL_STATUS0_PLL_RX is %d, SD_EXTERNAL_STATUS0_PLL_TX is %d\n",
                      (data & SD_EXTERNAL_STATUS0_PLL_RX_MASK),
                      (data & SD_EXTERNAL_STATUS0_PLL_TX_MASK));
                ret = 0;
@@ -1536,7 +1596,7 @@ static int comphy_rxauii_power_up(u32 lane, void __iomem *hpipe_base,
        if (data != 0) {
                debug("Read from reg = %p - value = 0x%x\n",
                      sd_ip_addr + SD_EXTERNAL_STATUS0_REG, data);
-               error("SD_EXTERNAL_STATUS0_RX_INIT is 0\n");
+               pr_err("SD_EXTERNAL_STATUS0_RX_INIT is 0\n");
                ret = 0;
        }
 
@@ -1682,7 +1742,7 @@ static int comphy_utmi_power_up(u32 utmi_index, void __iomem *utmi_base_addr,
        mask = data;
        data = polling_with_timeout(addr, data, mask, 100);
        if (data != 0) {
-               error("Impedance calibration is not done\n");
+               pr_err("Impedance calibration is not done\n");
                debug("Read from reg = %p - value = 0x%x\n", addr, data);
                ret = 0;
        }
@@ -1691,7 +1751,7 @@ static int comphy_utmi_power_up(u32 utmi_index, void __iomem *utmi_base_addr,
        mask = data;
        data = polling_with_timeout(addr, data, mask, 100);
        if (data != 0) {
-               error("PLL calibration is not done\n");
+               pr_err("PLL calibration is not done\n");
                debug("Read from reg = %p - value = 0x%x\n", addr, data);
                ret = 0;
        }
@@ -1701,7 +1761,7 @@ static int comphy_utmi_power_up(u32 utmi_index, void __iomem *utmi_base_addr,
        mask = data;
        data = polling_with_timeout(addr, data, mask, 100);
        if (data != 0) {
-               error("PLL is not ready\n");
+               pr_err("PLL is not ready\n");
                debug("Read from reg = %p - value = 0x%x\n", addr, data);
                ret = 0;
        }
@@ -1758,7 +1818,7 @@ static void comphy_utmi_phy_init(u32 utmi_phy_count,
                                          cp110_utmi_data[i].usb_cfg_addr,
                                          cp110_utmi_data[i].utmi_cfg_addr,
                                          cp110_utmi_data[i].utmi_phy_port)) {
-                       error("Failed to initialize UTMI PHY %d\n", i);
+                       pr_err("Failed to initialize UTMI PHY %d\n", i);
                        continue;
                }
                printf("UTMI PHY %d initialized to ", i);
@@ -1804,7 +1864,7 @@ void comphy_dedicated_phys_init(void)
                        (void __iomem *)fdtdec_get_addr_size_auto_noparent(
                                gd->fdt_blob, node, "reg", 0, NULL, true);
                if (cp110_utmi_data[i].utmi_base_addr == NULL) {
-                       error("UTMI PHY base address is invalid\n");
+                       pr_err("UTMI PHY base address is invalid\n");
                        i++;
                        continue;
                }
@@ -1814,7 +1874,7 @@ void comphy_dedicated_phys_init(void)
                        (void __iomem *)fdtdec_get_addr_size_auto_noparent(
                                gd->fdt_blob, node, "reg", 1, NULL, true);
                if (cp110_utmi_data[i].usb_cfg_addr == NULL) {
-                       error("UTMI PHY base address is invalid\n");
+                       pr_err("UTMI PHY base address is invalid\n");
                        i++;
                        continue;
                }
@@ -1824,7 +1884,7 @@ void comphy_dedicated_phys_init(void)
                        (void __iomem *)fdtdec_get_addr_size_auto_noparent(
                                gd->fdt_blob, node, "reg", 2, NULL, true);
                if (cp110_utmi_data[i].utmi_cfg_addr == NULL) {
-                       error("UTMI PHY base address is invalid\n");
+                       pr_err("UTMI PHY base address is invalid\n");
                        i++;
                        continue;
                }
@@ -1836,7 +1896,7 @@ void comphy_dedicated_phys_init(void)
                cp110_utmi_data[i].utmi_phy_port = fdtdec_get_int(
                        gd->fdt_blob, node, "utmi-port", UTMI_PHY_INVALID);
                if (cp110_utmi_data[i].utmi_phy_port == UTMI_PHY_INVALID) {
-                       error("UTMI PHY port type is invalid\n");
+                       pr_err("UTMI PHY port type is invalid\n");
                        i++;
                        continue;
                }
@@ -1947,7 +2007,7 @@ int comphy_cp110_init(struct chip_serdes_phy_config *ptr_chip_cfg,
                case PHY_TYPE_SATA3:
                        ret = comphy_sata_power_up(
                                lane, hpipe_base_addr, comphy_base_addr,
-                               ptr_chip_cfg->comphy_index);
+                               ptr_chip_cfg->cp_index);
                        break;
                case PHY_TYPE_USB3_HOST0:
                case PHY_TYPE_USB3_HOST1:
@@ -1989,7 +2049,7 @@ int comphy_cp110_init(struct chip_serdes_phy_config *ptr_chip_cfg,
                         * PHY_TYPE_UNCONNECTED state.
                         */
                        ptr_comphy_map->type = PHY_TYPE_UNCONNECTED;
-                       error("PLL is not locked - Failed to initialize lane %d\n",
+                       pr_err("PLL is not locked - Failed to initialize lane %d\n",
                              lane);
                }
        }