2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2016-08-30 14:48:20 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2015-2016 Marvell International Ltd.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <fdtdec.h>
|
2020-05-10 17:40:05 +00:00
|
|
|
#include <log.h>
|
2020-10-31 03:38:53 +00:00
|
|
|
#include <asm/global_data.h>
|
2016-08-30 14:48:20 +00:00
|
|
|
#include <asm/io.h>
|
2020-10-18 14:11:11 +00:00
|
|
|
#include <asm/ptrace.h>
|
2016-08-30 14:48:20 +00:00
|
|
|
#include <asm/arch/cpu.h>
|
|
|
|
#include <asm/arch/soc.h>
|
2020-05-10 17:40:11 +00:00
|
|
|
#include <linux/delay.h>
|
2023-09-15 00:21:46 +00:00
|
|
|
#include <linux/printk.h>
|
2016-08-30 14:48:20 +00:00
|
|
|
|
2018-08-17 10:58:51 +00:00
|
|
|
#include "comphy_core.h"
|
2016-08-30 14:48:20 +00:00
|
|
|
#include "sata.h"
|
|
|
|
#include "utmi_phy.h"
|
|
|
|
|
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
2020-10-18 14:11:11 +00:00
|
|
|
/* Firmware related definitions used for SMC calls */
|
|
|
|
#define MV_SIP_COMPHY_POWER_ON 0x82000001
|
|
|
|
#define MV_SIP_COMPHY_POWER_OFF 0x82000002
|
|
|
|
#define MV_SIP_COMPHY_PLL_LOCK 0x82000003
|
2018-04-03 14:59:12 +00:00
|
|
|
#define MV_SIP_COMPHY_XFI_TRAIN 0x82000004
|
2020-10-18 14:11:11 +00:00
|
|
|
|
2023-05-17 07:17:16 +00:00
|
|
|
/* Used to distinguish between different possible callers (U-Boot/Linux) */
|
2020-10-18 14:11:13 +00:00
|
|
|
#define COMPHY_CALLER_UBOOT (0x1 << 21)
|
|
|
|
|
2020-10-18 14:11:11 +00:00
|
|
|
#define COMPHY_FW_MODE_FORMAT(mode) ((mode) << 12)
|
|
|
|
#define COMPHY_FW_FORMAT(mode, idx, speeds) \
|
|
|
|
(((mode) << 12) | ((idx) << 8) | ((speeds) << 2))
|
2020-10-18 14:11:12 +00:00
|
|
|
|
|
|
|
#define COMPHY_FW_PCIE_FORMAT(pcie_width, clk_src, mode, speeds) \
|
2020-10-18 14:11:13 +00:00
|
|
|
(COMPHY_CALLER_UBOOT | ((pcie_width) << 18) | \
|
|
|
|
((clk_src) << 17) | COMPHY_FW_FORMAT(mode, 0, speeds))
|
2020-10-18 14:11:12 +00:00
|
|
|
|
2021-09-15 13:45:31 +00:00
|
|
|
/* Invert polarity are bits 1-0 of the mode */
|
|
|
|
#define COMPHY_FW_SATA_FORMAT(mode, invert) \
|
|
|
|
((invert) | COMPHY_FW_MODE_FORMAT(mode))
|
|
|
|
|
2020-10-18 14:11:11 +00:00
|
|
|
#define COMPHY_SATA_MODE 0x1
|
|
|
|
#define COMPHY_SGMII_MODE 0x2 /* SGMII 1G */
|
|
|
|
#define COMPHY_HS_SGMII_MODE 0x3 /* SGMII 2.5G */
|
|
|
|
#define COMPHY_USB3H_MODE 0x4
|
|
|
|
#define COMPHY_USB3D_MODE 0x5
|
|
|
|
#define COMPHY_PCIE_MODE 0x6
|
|
|
|
#define COMPHY_RXAUI_MODE 0x7
|
|
|
|
#define COMPHY_XFI_MODE 0x8
|
|
|
|
#define COMPHY_SFI_MODE 0x9
|
|
|
|
#define COMPHY_USB3_MODE 0xa
|
|
|
|
#define COMPHY_AP_MODE 0xb
|
|
|
|
|
|
|
|
/* Comphy unit index macro */
|
|
|
|
#define COMPHY_UNIT_ID0 0
|
|
|
|
#define COMPHY_UNIT_ID1 1
|
|
|
|
#define COMPHY_UNIT_ID2 2
|
|
|
|
#define COMPHY_UNIT_ID3 3
|
|
|
|
|
2016-08-30 14:48:20 +00:00
|
|
|
struct utmi_phy_data {
|
2019-02-27 14:35:58 +00:00
|
|
|
void __iomem *utmi_pll_addr;
|
2016-08-30 14:48:20 +00:00
|
|
|
void __iomem *utmi_base_addr;
|
|
|
|
void __iomem *usb_cfg_addr;
|
|
|
|
void __iomem *utmi_cfg_addr;
|
|
|
|
u32 utmi_phy_port;
|
|
|
|
};
|
|
|
|
|
|
|
|
static u32 polling_with_timeout(void __iomem *addr, u32 val,
|
|
|
|
u32 mask, unsigned long usec_timout)
|
|
|
|
{
|
|
|
|
u32 data;
|
|
|
|
|
|
|
|
do {
|
|
|
|
udelay(1);
|
|
|
|
data = readl(addr) & mask;
|
|
|
|
} while (data != val && --usec_timout > 0);
|
|
|
|
|
|
|
|
if (usec_timout == 0)
|
|
|
|
return data;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-04-03 14:59:12 +00:00
|
|
|
static int comphy_smc(u32 function_id, void __iomem *comphy_base_addr,
|
|
|
|
u32 lane, u32 mode)
|
2021-03-23 10:57:57 +00:00
|
|
|
{
|
2018-04-03 14:59:12 +00:00
|
|
|
struct pt_regs pregs = {0};
|
2021-03-23 10:57:57 +00:00
|
|
|
|
2018-04-03 14:59:12 +00:00
|
|
|
pregs.regs[0] = function_id;
|
|
|
|
pregs.regs[1] = (unsigned long)comphy_base_addr;
|
|
|
|
pregs.regs[2] = lane;
|
|
|
|
pregs.regs[3] = mode;
|
2021-03-23 10:57:57 +00:00
|
|
|
|
2018-04-03 14:59:12 +00:00
|
|
|
smc_call(&pregs);
|
2021-03-23 10:57:57 +00:00
|
|
|
|
2018-04-03 14:59:12 +00:00
|
|
|
/*
|
|
|
|
* TODO: Firmware return 0 on success, temporary map it to u-boot
|
|
|
|
* convention, but after all comphy will be reworked the convention in
|
|
|
|
* u-boot should be change and this conversion removed
|
|
|
|
*/
|
|
|
|
return pregs.regs[0] ? 0 : 1;
|
2021-03-23 10:57:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* This function performs RX training for all FFE possible values.
|
|
|
|
* We get the result for each FFE and eventually the best FFE will
|
|
|
|
* be used and set to the HW.
|
|
|
|
*
|
|
|
|
* Return '1' on succsess.
|
|
|
|
* Return '0' on failure.
|
|
|
|
*/
|
|
|
|
int comphy_cp110_sfi_rx_training(struct chip_serdes_phy_config *ptr_chip_cfg,
|
|
|
|
u32 lane)
|
|
|
|
{
|
|
|
|
int ret;
|
2018-05-14 08:20:54 +00:00
|
|
|
u32 type = ptr_chip_cfg->comphy_map_data[lane].type;
|
2021-03-23 10:57:57 +00:00
|
|
|
|
|
|
|
debug_enter();
|
|
|
|
|
2018-05-14 08:20:54 +00:00
|
|
|
if (type != COMPHY_TYPE_SFI0 && type != COMPHY_TYPE_SFI1) {
|
2021-03-23 10:57:57 +00:00
|
|
|
pr_err("Comphy %d isn't configured to SFI\n", lane);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-04-03 14:59:12 +00:00
|
|
|
/* Mode is not relevant for xfi training */
|
|
|
|
ret = comphy_smc(MV_SIP_COMPHY_XFI_TRAIN,
|
|
|
|
ptr_chip_cfg->comphy_base_addr, lane, 0);
|
2021-03-23 10:57:57 +00:00
|
|
|
|
|
|
|
debug_exit();
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2016-08-30 14:48:20 +00:00
|
|
|
static int comphy_sata_power_up(u32 lane, void __iomem *hpipe_base,
|
2020-10-18 14:11:11 +00:00
|
|
|
void __iomem *comphy_base_addr, int cp_index,
|
|
|
|
u32 type)
|
2016-08-30 14:48:20 +00:00
|
|
|
{
|
|
|
|
u32 mask, data, i, ret = 1;
|
|
|
|
void __iomem *sata_base = NULL;
|
|
|
|
int sata_node = -1; /* Set to -1 in order to read the first sata node */
|
|
|
|
|
|
|
|
debug_enter();
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Assumption - each CP has only one SATA controller
|
|
|
|
* Calling fdt_node_offset_by_compatible first time (with sata_node = -1
|
|
|
|
* will return the first node always.
|
|
|
|
* In order to parse each CPs SATA node, fdt_node_offset_by_compatible
|
|
|
|
* must be called again (according to the CP id)
|
|
|
|
*/
|
2017-04-24 15:45:32 +00:00
|
|
|
for (i = 0; i < (cp_index + 1); i++)
|
2016-08-30 14:48:20 +00:00
|
|
|
sata_node = fdt_node_offset_by_compatible(
|
|
|
|
gd->fdt_blob, sata_node, "marvell,armada-8k-ahci");
|
|
|
|
|
|
|
|
if (sata_node == 0) {
|
2017-09-16 05:10:41 +00:00
|
|
|
pr_err("SATA node not found in FDT\n");
|
2016-08-30 14:48:20 +00:00
|
|
|
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) {
|
2017-09-16 05:10:41 +00:00
|
|
|
pr_err("SATA address not found in FDT\n");
|
2016-08-30 14:48:20 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
debug("SATA address found in FDT %p\n", sata_base);
|
|
|
|
|
|
|
|
debug("stage: MAC configuration - power down comphy\n");
|
|
|
|
/*
|
|
|
|
* MAC configuration powe down comphy use indirect address for
|
|
|
|
* vendor spesific SATA control register
|
|
|
|
*/
|
|
|
|
reg_set(sata_base + SATA3_VENDOR_ADDRESS,
|
|
|
|
SATA_CONTROL_REG << SATA3_VENDOR_ADDR_OFSSET,
|
|
|
|
SATA3_VENDOR_ADDR_MASK);
|
|
|
|
/* SATA 0 power down */
|
|
|
|
mask = SATA3_CTRL_SATA0_PD_MASK;
|
|
|
|
data = 0x1 << SATA3_CTRL_SATA0_PD_OFFSET;
|
|
|
|
/* SATA 1 power down */
|
|
|
|
mask |= SATA3_CTRL_SATA1_PD_MASK;
|
|
|
|
data |= 0x1 << SATA3_CTRL_SATA1_PD_OFFSET;
|
|
|
|
/* SATA SSU disable */
|
|
|
|
mask |= SATA3_CTRL_SATA1_ENABLE_MASK;
|
|
|
|
data |= 0x0 << SATA3_CTRL_SATA1_ENABLE_OFFSET;
|
|
|
|
/* SATA port 1 disable */
|
|
|
|
mask |= SATA3_CTRL_SATA_SSU_MASK;
|
|
|
|
data |= 0x0 << SATA3_CTRL_SATA_SSU_OFFSET;
|
|
|
|
reg_set(sata_base + SATA3_VENDOR_DATA, data, mask);
|
|
|
|
|
2020-10-18 14:11:11 +00:00
|
|
|
ret = comphy_smc(MV_SIP_COMPHY_POWER_ON, comphy_base_addr, lane, type);
|
2017-04-24 15:45:26 +00:00
|
|
|
|
2016-08-30 14:48:20 +00:00
|
|
|
/*
|
|
|
|
* MAC configuration power up comphy - power up PLL/TX/RX
|
|
|
|
* use indirect address for vendor spesific SATA control register
|
|
|
|
*/
|
|
|
|
reg_set(sata_base + SATA3_VENDOR_ADDRESS,
|
|
|
|
SATA_CONTROL_REG << SATA3_VENDOR_ADDR_OFSSET,
|
|
|
|
SATA3_VENDOR_ADDR_MASK);
|
|
|
|
/* SATA 0 power up */
|
|
|
|
mask = SATA3_CTRL_SATA0_PD_MASK;
|
|
|
|
data = 0x0 << SATA3_CTRL_SATA0_PD_OFFSET;
|
|
|
|
/* SATA 1 power up */
|
|
|
|
mask |= SATA3_CTRL_SATA1_PD_MASK;
|
|
|
|
data |= 0x0 << SATA3_CTRL_SATA1_PD_OFFSET;
|
|
|
|
/* SATA SSU enable */
|
|
|
|
mask |= SATA3_CTRL_SATA1_ENABLE_MASK;
|
|
|
|
data |= 0x1 << SATA3_CTRL_SATA1_ENABLE_OFFSET;
|
|
|
|
/* SATA port 1 enable */
|
|
|
|
mask |= SATA3_CTRL_SATA_SSU_MASK;
|
|
|
|
data |= 0x1 << SATA3_CTRL_SATA_SSU_OFFSET;
|
|
|
|
reg_set(sata_base + SATA3_VENDOR_DATA, data, mask);
|
|
|
|
|
|
|
|
/* MBUS request size and interface select register */
|
|
|
|
reg_set(sata_base + SATA3_VENDOR_ADDRESS,
|
|
|
|
SATA_MBUS_SIZE_SELECT_REG << SATA3_VENDOR_ADDR_OFSSET,
|
|
|
|
SATA3_VENDOR_ADDR_MASK);
|
|
|
|
/* Mbus regret enable */
|
|
|
|
reg_set(sata_base + SATA3_VENDOR_DATA,
|
|
|
|
0x1 << SATA_MBUS_REGRET_EN_OFFSET, SATA_MBUS_REGRET_EN_MASK);
|
|
|
|
|
2020-10-18 14:11:11 +00:00
|
|
|
ret = comphy_smc(MV_SIP_COMPHY_PLL_LOCK, comphy_base_addr, lane, type);
|
2016-08-30 14:48:20 +00:00
|
|
|
|
|
|
|
debug_exit();
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void comphy_utmi_power_down(u32 utmi_index, void __iomem *utmi_base_addr,
|
|
|
|
void __iomem *usb_cfg_addr,
|
|
|
|
void __iomem *utmi_cfg_addr,
|
|
|
|
u32 utmi_phy_port)
|
|
|
|
{
|
|
|
|
u32 mask, data;
|
|
|
|
|
|
|
|
debug_enter();
|
|
|
|
debug("stage: UTMI %d - Power down transceiver (power down Phy), Power down PLL, and SuspendDM\n",
|
|
|
|
utmi_index);
|
|
|
|
/* Power down UTMI PHY */
|
|
|
|
reg_set(utmi_cfg_addr, 0x0 << UTMI_PHY_CFG_PU_OFFSET,
|
|
|
|
UTMI_PHY_CFG_PU_MASK);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If UTMI connected to USB Device, configure mux prior to PHY init
|
|
|
|
* (Device can be connected to UTMI0 or to UTMI1)
|
|
|
|
*/
|
2017-04-24 15:45:23 +00:00
|
|
|
if (utmi_phy_port == UTMI_PHY_TO_USB3_DEVICE0) {
|
2016-08-30 14:48:20 +00:00
|
|
|
debug("stage: UTMI %d - Enable Device mode and configure UTMI mux\n",
|
|
|
|
utmi_index);
|
|
|
|
/* USB3 Device UTMI enable */
|
|
|
|
mask = UTMI_USB_CFG_DEVICE_EN_MASK;
|
|
|
|
data = 0x1 << UTMI_USB_CFG_DEVICE_EN_OFFSET;
|
|
|
|
/* USB3 Device UTMI MUX */
|
|
|
|
mask |= UTMI_USB_CFG_DEVICE_MUX_MASK;
|
|
|
|
data |= utmi_index << UTMI_USB_CFG_DEVICE_MUX_OFFSET;
|
|
|
|
reg_set(usb_cfg_addr, data, mask);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set Test suspendm mode */
|
|
|
|
mask = UTMI_CTRL_STATUS0_SUSPENDM_MASK;
|
|
|
|
data = 0x1 << UTMI_CTRL_STATUS0_SUSPENDM_OFFSET;
|
|
|
|
/* Enable Test UTMI select */
|
|
|
|
mask |= UTMI_CTRL_STATUS0_TEST_SEL_MASK;
|
|
|
|
data |= 0x1 << UTMI_CTRL_STATUS0_TEST_SEL_OFFSET;
|
|
|
|
reg_set(utmi_base_addr + UTMI_CTRL_STATUS0_REG, data, mask);
|
|
|
|
|
|
|
|
/* Wait for UTMI power down */
|
|
|
|
mdelay(1);
|
|
|
|
|
|
|
|
debug_exit();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-02-27 14:35:58 +00:00
|
|
|
static void comphy_utmi_phy_config(u32 utmi_index, void __iomem *utmi_pll_addr,
|
|
|
|
void __iomem *utmi_base_addr,
|
2016-08-30 14:48:20 +00:00
|
|
|
void __iomem *usb_cfg_addr,
|
|
|
|
void __iomem *utmi_cfg_addr,
|
|
|
|
u32 utmi_phy_port)
|
|
|
|
{
|
|
|
|
u32 mask, data;
|
|
|
|
|
|
|
|
debug_exit();
|
|
|
|
debug("stage: Configure UTMI PHY %d registers\n", utmi_index);
|
|
|
|
/* Reference Clock Divider Select */
|
|
|
|
mask = UTMI_PLL_CTRL_REFDIV_MASK;
|
|
|
|
data = 0x5 << UTMI_PLL_CTRL_REFDIV_OFFSET;
|
|
|
|
/* Feedback Clock Divider Select - 90 for 25Mhz*/
|
|
|
|
mask |= UTMI_PLL_CTRL_FBDIV_MASK;
|
|
|
|
data |= 0x60 << UTMI_PLL_CTRL_FBDIV_OFFSET;
|
|
|
|
/* Select LPFR - 0x0 for 25Mhz/5=5Mhz*/
|
|
|
|
mask |= UTMI_PLL_CTRL_SEL_LPFR_MASK;
|
|
|
|
data |= 0x0 << UTMI_PLL_CTRL_SEL_LPFR_OFFSET;
|
2019-02-27 14:35:58 +00:00
|
|
|
reg_set(utmi_pll_addr + UTMI_PLL_CTRL_REG, data, mask);
|
2016-08-30 14:48:20 +00:00
|
|
|
|
|
|
|
/* Impedance Calibration Threshold Setting */
|
2019-03-14 12:00:53 +00:00
|
|
|
mask = UTMI_CALIB_CTRL_IMPCAL_VTH_MASK;
|
|
|
|
data = 0x7 << UTMI_CALIB_CTRL_IMPCAL_VTH_OFFSET;
|
|
|
|
reg_set(utmi_pll_addr + UTMI_CALIB_CTRL_REG, data, mask);
|
|
|
|
|
|
|
|
/* Start Impedance and PLL Calibration */
|
|
|
|
mask = UTMI_CALIB_CTRL_PLLCAL_START_MASK;
|
|
|
|
data = (0x1 << UTMI_CALIB_CTRL_PLLCAL_START_OFFSET);
|
|
|
|
mask |= UTMI_CALIB_CTRL_IMPCAL_START_MASK;
|
|
|
|
data |= (0x1 << UTMI_CALIB_CTRL_IMPCAL_START_OFFSET);
|
|
|
|
reg_set(utmi_pll_addr + UTMI_CALIB_CTRL_REG, data, mask);
|
2016-08-30 14:48:20 +00:00
|
|
|
|
|
|
|
/* Set LS TX driver strength coarse control */
|
2017-04-30 17:16:55 +00:00
|
|
|
mask = UTMI_TX_CH_CTRL_AMP_MASK;
|
|
|
|
data = 0x4 << UTMI_TX_CH_CTRL_AMP_OFFSET;
|
2019-03-14 12:00:53 +00:00
|
|
|
mask |= UTMI_TX_CH_CTRL_IMP_SEL_LS_MASK;
|
|
|
|
data |= 0x3 << UTMI_TX_CH_CTRL_IMP_SEL_LS_OFFSET;
|
|
|
|
mask |= UTMI_TX_CH_CTRL_DRV_EN_LS_MASK;
|
|
|
|
data |= 0x3 << UTMI_TX_CH_CTRL_DRV_EN_LS_OFFSET;
|
2016-08-30 14:48:20 +00:00
|
|
|
reg_set(utmi_base_addr + UTMI_TX_CH_CTRL_REG, data, mask);
|
|
|
|
|
|
|
|
/* Enable SQ */
|
|
|
|
mask = UTMI_RX_CH_CTRL0_SQ_DET_MASK;
|
2019-03-14 12:00:53 +00:00
|
|
|
data = 0x1 << UTMI_RX_CH_CTRL0_SQ_DET_OFFSET;
|
2016-08-30 14:48:20 +00:00
|
|
|
/* Enable analog squelch detect */
|
|
|
|
mask |= UTMI_RX_CH_CTRL0_SQ_ANA_DTC_MASK;
|
2019-03-14 12:00:53 +00:00
|
|
|
data |= 0x0 << UTMI_RX_CH_CTRL0_SQ_ANA_DTC_OFFSET;
|
|
|
|
mask |= UTMI_RX_CH_CTRL0_DISCON_THRESH_MASK;
|
|
|
|
data |= 0x0 << UTMI_RX_CH_CTRL0_DISCON_THRESH_OFFSET;
|
2016-08-30 14:48:20 +00:00
|
|
|
reg_set(utmi_base_addr + UTMI_RX_CH_CTRL0_REG, data, mask);
|
|
|
|
|
|
|
|
/* Set External squelch calibration number */
|
|
|
|
mask = UTMI_RX_CH_CTRL1_SQ_AMP_CAL_MASK;
|
|
|
|
data = 0x1 << UTMI_RX_CH_CTRL1_SQ_AMP_CAL_OFFSET;
|
|
|
|
/* Enable the External squelch calibration */
|
|
|
|
mask |= UTMI_RX_CH_CTRL1_SQ_AMP_CAL_EN_MASK;
|
|
|
|
data |= 0x1 << UTMI_RX_CH_CTRL1_SQ_AMP_CAL_EN_OFFSET;
|
|
|
|
reg_set(utmi_base_addr + UTMI_RX_CH_CTRL1_REG, data, mask);
|
|
|
|
|
|
|
|
/* Set Control VDAT Reference Voltage - 0.325V */
|
|
|
|
mask = UTMI_CHGDTC_CTRL_VDAT_MASK;
|
|
|
|
data = 0x1 << UTMI_CHGDTC_CTRL_VDAT_OFFSET;
|
|
|
|
/* Set Control VSRC Reference Voltage - 0.6V */
|
|
|
|
mask |= UTMI_CHGDTC_CTRL_VSRC_MASK;
|
|
|
|
data |= 0x1 << UTMI_CHGDTC_CTRL_VSRC_OFFSET;
|
|
|
|
reg_set(utmi_base_addr + UTMI_CHGDTC_CTRL_REG, data, mask);
|
|
|
|
|
|
|
|
debug_exit();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-02-27 14:35:58 +00:00
|
|
|
static int comphy_utmi_power_up(u32 utmi_index, void __iomem *utmi_pll_addr,
|
|
|
|
void __iomem *utmi_base_addr,
|
2016-08-30 14:48:20 +00:00
|
|
|
void __iomem *usb_cfg_addr,
|
|
|
|
void __iomem *utmi_cfg_addr, u32 utmi_phy_port)
|
|
|
|
{
|
|
|
|
u32 data, mask, ret = 1;
|
|
|
|
void __iomem *addr;
|
|
|
|
|
|
|
|
debug_enter();
|
|
|
|
debug("stage: UTMI %d - Power up transceiver(Power up Phy), and exit SuspendDM\n",
|
|
|
|
utmi_index);
|
|
|
|
/* Power UP UTMI PHY */
|
|
|
|
reg_set(utmi_cfg_addr, 0x1 << UTMI_PHY_CFG_PU_OFFSET,
|
|
|
|
UTMI_PHY_CFG_PU_MASK);
|
|
|
|
/* Disable Test UTMI select */
|
|
|
|
reg_set(utmi_base_addr + UTMI_CTRL_STATUS0_REG,
|
|
|
|
0x0 << UTMI_CTRL_STATUS0_TEST_SEL_OFFSET,
|
|
|
|
UTMI_CTRL_STATUS0_TEST_SEL_MASK);
|
|
|
|
|
|
|
|
debug("stage: Polling for PLL and impedance calibration done, and PLL ready done\n");
|
2019-02-27 14:35:58 +00:00
|
|
|
addr = utmi_pll_addr + UTMI_CALIB_CTRL_REG;
|
2016-08-30 14:48:20 +00:00
|
|
|
data = UTMI_CALIB_CTRL_IMPCAL_DONE_MASK;
|
|
|
|
mask = data;
|
|
|
|
data = polling_with_timeout(addr, data, mask, 100);
|
|
|
|
if (data != 0) {
|
2017-09-16 05:10:41 +00:00
|
|
|
pr_err("Impedance calibration is not done\n");
|
2016-08-30 14:48:20 +00:00
|
|
|
debug("Read from reg = %p - value = 0x%x\n", addr, data);
|
|
|
|
ret = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
data = UTMI_CALIB_CTRL_PLLCAL_DONE_MASK;
|
|
|
|
mask = data;
|
|
|
|
data = polling_with_timeout(addr, data, mask, 100);
|
|
|
|
if (data != 0) {
|
2017-09-16 05:10:41 +00:00
|
|
|
pr_err("PLL calibration is not done\n");
|
2016-08-30 14:48:20 +00:00
|
|
|
debug("Read from reg = %p - value = 0x%x\n", addr, data);
|
|
|
|
ret = 0;
|
|
|
|
}
|
|
|
|
|
2019-02-27 14:35:58 +00:00
|
|
|
addr = utmi_pll_addr + UTMI_PLL_CTRL_REG;
|
2016-08-30 14:48:20 +00:00
|
|
|
data = UTMI_PLL_CTRL_PLL_RDY_MASK;
|
|
|
|
mask = data;
|
|
|
|
data = polling_with_timeout(addr, data, mask, 100);
|
|
|
|
if (data != 0) {
|
2017-09-16 05:10:41 +00:00
|
|
|
pr_err("PLL is not ready\n");
|
2016-08-30 14:48:20 +00:00
|
|
|
debug("Read from reg = %p - value = 0x%x\n", addr, data);
|
|
|
|
ret = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ret)
|
|
|
|
debug("Passed\n");
|
|
|
|
else
|
|
|
|
debug("\n");
|
|
|
|
|
|
|
|
debug_exit();
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* comphy_utmi_phy_init initialize the UTMI PHY
|
|
|
|
* the init split in 3 parts:
|
|
|
|
* 1. Power down transceiver and PLL
|
|
|
|
* 2. UTMI PHY configure
|
2017-04-06 09:54:16 +00:00
|
|
|
* 3. Power up transceiver and PLL
|
2016-08-30 14:48:20 +00:00
|
|
|
* Note: - Power down/up should be once for both UTMI PHYs
|
|
|
|
* - comphy_dedicated_phys_init call this function if at least there is
|
|
|
|
* one UTMI PHY exists in FDT blob. access to cp110_utmi_data[0] is
|
|
|
|
* legal
|
|
|
|
*/
|
|
|
|
static void comphy_utmi_phy_init(u32 utmi_phy_count,
|
|
|
|
struct utmi_phy_data *cp110_utmi_data)
|
|
|
|
{
|
|
|
|
u32 i;
|
|
|
|
|
|
|
|
debug_enter();
|
|
|
|
/* UTMI Power down */
|
|
|
|
for (i = 0; i < utmi_phy_count; i++) {
|
|
|
|
comphy_utmi_power_down(i, cp110_utmi_data[i].utmi_base_addr,
|
|
|
|
cp110_utmi_data[i].usb_cfg_addr,
|
|
|
|
cp110_utmi_data[i].utmi_cfg_addr,
|
|
|
|
cp110_utmi_data[i].utmi_phy_port);
|
|
|
|
}
|
|
|
|
/* PLL Power down */
|
|
|
|
debug("stage: UTMI PHY power down PLL\n");
|
|
|
|
for (i = 0; i < utmi_phy_count; i++) {
|
|
|
|
reg_set(cp110_utmi_data[i].usb_cfg_addr,
|
|
|
|
0x0 << UTMI_USB_CFG_PLL_OFFSET, UTMI_USB_CFG_PLL_MASK);
|
|
|
|
}
|
|
|
|
/* UTMI configure */
|
|
|
|
for (i = 0; i < utmi_phy_count; i++) {
|
2019-02-27 14:35:58 +00:00
|
|
|
comphy_utmi_phy_config(i, cp110_utmi_data[i].utmi_pll_addr,
|
|
|
|
cp110_utmi_data[i].utmi_base_addr,
|
2016-08-30 14:48:20 +00:00
|
|
|
cp110_utmi_data[i].usb_cfg_addr,
|
|
|
|
cp110_utmi_data[i].utmi_cfg_addr,
|
|
|
|
cp110_utmi_data[i].utmi_phy_port);
|
|
|
|
}
|
|
|
|
/* UTMI Power up */
|
|
|
|
for (i = 0; i < utmi_phy_count; i++) {
|
2019-02-27 14:35:58 +00:00
|
|
|
if (!comphy_utmi_power_up(i, cp110_utmi_data[i].utmi_pll_addr,
|
|
|
|
cp110_utmi_data[i].utmi_base_addr,
|
2016-08-30 14:48:20 +00:00
|
|
|
cp110_utmi_data[i].usb_cfg_addr,
|
|
|
|
cp110_utmi_data[i].utmi_cfg_addr,
|
|
|
|
cp110_utmi_data[i].utmi_phy_port)) {
|
2017-09-16 05:10:41 +00:00
|
|
|
pr_err("Failed to initialize UTMI PHY %d\n", i);
|
2016-08-30 14:48:20 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
printf("UTMI PHY %d initialized to ", i);
|
2017-04-24 15:45:23 +00:00
|
|
|
if (cp110_utmi_data[i].utmi_phy_port ==
|
|
|
|
UTMI_PHY_TO_USB3_DEVICE0)
|
2016-08-30 14:48:20 +00:00
|
|
|
printf("USB Device\n");
|
|
|
|
else
|
|
|
|
printf("USB Host%d\n",
|
|
|
|
cp110_utmi_data[i].utmi_phy_port);
|
|
|
|
}
|
|
|
|
/* PLL Power up */
|
|
|
|
debug("stage: UTMI PHY power up PLL\n");
|
|
|
|
for (i = 0; i < utmi_phy_count; i++) {
|
|
|
|
reg_set(cp110_utmi_data[i].usb_cfg_addr,
|
|
|
|
0x1 << UTMI_USB_CFG_PLL_OFFSET, UTMI_USB_CFG_PLL_MASK);
|
|
|
|
}
|
|
|
|
|
|
|
|
debug_exit();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* comphy_dedicated_phys_init initialize the dedicated PHYs
|
|
|
|
* - not muxed SerDes lanes e.g. UTMI PHY
|
|
|
|
*/
|
|
|
|
void comphy_dedicated_phys_init(void)
|
|
|
|
{
|
|
|
|
struct utmi_phy_data cp110_utmi_data[MAX_UTMI_PHY_COUNT];
|
2017-04-06 09:54:16 +00:00
|
|
|
int node = -1;
|
|
|
|
int node_idx;
|
2019-02-27 14:35:58 +00:00
|
|
|
int parent = -1;
|
2016-08-30 14:48:20 +00:00
|
|
|
|
|
|
|
debug_enter();
|
|
|
|
debug("Initialize USB UTMI PHYs\n");
|
|
|
|
|
2017-04-06 09:54:16 +00:00
|
|
|
for (node_idx = 0; node_idx < MAX_UTMI_PHY_COUNT;) {
|
|
|
|
/* Find the UTMI phy node in device tree */
|
|
|
|
node = fdt_node_offset_by_compatible(gd->fdt_blob, node,
|
|
|
|
"marvell,mvebu-utmi-2.6.0");
|
|
|
|
if (node <= 0)
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* check if node is enabled */
|
|
|
|
if (!fdtdec_get_is_enabled(gd->fdt_blob, node))
|
|
|
|
continue;
|
2016-08-30 14:48:20 +00:00
|
|
|
|
2019-02-27 14:35:58 +00:00
|
|
|
parent = fdt_parent_offset(gd->fdt_blob, node);
|
|
|
|
if (parent <= 0)
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* get base address of UTMI PLL */
|
|
|
|
cp110_utmi_data[node_idx].utmi_pll_addr =
|
|
|
|
(void __iomem *)fdtdec_get_addr_size_auto_noparent(
|
|
|
|
gd->fdt_blob, parent, "reg", 0, NULL, true);
|
|
|
|
if (!cp110_utmi_data[node_idx].utmi_pll_addr) {
|
|
|
|
pr_err("UTMI PHY PLL address is invalid\n");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2016-08-30 14:48:20 +00:00
|
|
|
/* get base address of UTMI phy */
|
2017-04-06 09:54:16 +00:00
|
|
|
cp110_utmi_data[node_idx].utmi_base_addr =
|
2016-08-30 14:48:20 +00:00
|
|
|
(void __iomem *)fdtdec_get_addr_size_auto_noparent(
|
|
|
|
gd->fdt_blob, node, "reg", 0, NULL, true);
|
2017-04-06 09:54:16 +00:00
|
|
|
if (!cp110_utmi_data[node_idx].utmi_base_addr) {
|
2017-09-16 05:10:41 +00:00
|
|
|
pr_err("UTMI PHY base address is invalid\n");
|
2016-08-30 14:48:20 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* get usb config address */
|
2017-04-06 09:54:16 +00:00
|
|
|
cp110_utmi_data[node_idx].usb_cfg_addr =
|
2016-08-30 14:48:20 +00:00
|
|
|
(void __iomem *)fdtdec_get_addr_size_auto_noparent(
|
|
|
|
gd->fdt_blob, node, "reg", 1, NULL, true);
|
2017-04-06 09:54:16 +00:00
|
|
|
if (!cp110_utmi_data[node_idx].usb_cfg_addr) {
|
2017-09-16 05:10:41 +00:00
|
|
|
pr_err("UTMI PHY base address is invalid\n");
|
2016-08-30 14:48:20 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* get UTMI config address */
|
2017-04-06 09:54:16 +00:00
|
|
|
cp110_utmi_data[node_idx].utmi_cfg_addr =
|
2016-08-30 14:48:20 +00:00
|
|
|
(void __iomem *)fdtdec_get_addr_size_auto_noparent(
|
|
|
|
gd->fdt_blob, node, "reg", 2, NULL, true);
|
2017-04-06 09:54:16 +00:00
|
|
|
if (!cp110_utmi_data[node_idx].utmi_cfg_addr) {
|
2017-09-16 05:10:41 +00:00
|
|
|
pr_err("UTMI PHY base address is invalid\n");
|
2016-08-30 14:48:20 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* get the port number (to check if the utmi connected to
|
|
|
|
* host/device)
|
|
|
|
*/
|
2017-04-06 09:54:16 +00:00
|
|
|
cp110_utmi_data[node_idx].utmi_phy_port = fdtdec_get_int(
|
2016-08-30 14:48:20 +00:00
|
|
|
gd->fdt_blob, node, "utmi-port", UTMI_PHY_INVALID);
|
2017-04-06 09:54:16 +00:00
|
|
|
if (cp110_utmi_data[node_idx].utmi_phy_port ==
|
|
|
|
UTMI_PHY_INVALID) {
|
2017-09-16 05:10:41 +00:00
|
|
|
pr_err("UTMI PHY port type is invalid\n");
|
2016-08-30 14:48:20 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2017-04-06 09:54:16 +00:00
|
|
|
/* count valid UTMI unit */
|
|
|
|
node_idx++;
|
2016-08-30 14:48:20 +00:00
|
|
|
}
|
|
|
|
|
2017-04-06 09:54:16 +00:00
|
|
|
if (node_idx > 0)
|
|
|
|
comphy_utmi_phy_init(node_idx, cp110_utmi_data);
|
2016-08-30 14:48:20 +00:00
|
|
|
|
|
|
|
debug_exit();
|
|
|
|
}
|
|
|
|
|
2021-11-26 13:57:13 +00:00
|
|
|
int comphy_cp110_init_serdes_map(int node, struct chip_serdes_phy_config *cfg)
|
|
|
|
{
|
|
|
|
int lane, subnode;
|
|
|
|
|
|
|
|
cfg->comphy_lanes_count = fdtdec_get_int(gd->fdt_blob, node,
|
|
|
|
"max-lanes", 0);
|
|
|
|
if (cfg->comphy_lanes_count <= 0) {
|
|
|
|
printf("comphy max lanes is wrong\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
cfg->comphy_mux_bitcount = fdtdec_get_int(gd->fdt_blob, node,
|
|
|
|
"mux-bitcount", 0);
|
|
|
|
if (cfg->comphy_mux_bitcount <= 0) {
|
|
|
|
printf("comphy mux bit count is wrong\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
cfg->comphy_mux_lane_order = fdtdec_locate_array(gd->fdt_blob, node,
|
|
|
|
"mux-lane-order",
|
|
|
|
cfg->comphy_lanes_count);
|
|
|
|
|
|
|
|
lane = 0;
|
|
|
|
fdt_for_each_subnode(subnode, gd->fdt_blob, node) {
|
|
|
|
/* Skip disabled ports */
|
|
|
|
if (!fdtdec_get_is_enabled(gd->fdt_blob, subnode))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
cfg->comphy_map_data[lane].type =
|
|
|
|
fdtdec_get_int(gd->fdt_blob, subnode, "phy-type",
|
|
|
|
COMPHY_TYPE_INVALID);
|
|
|
|
|
|
|
|
if (cfg->comphy_map_data[lane].type == COMPHY_TYPE_INVALID) {
|
|
|
|
printf("no phy type for lane %d, setting lane as unconnected\n",
|
|
|
|
lane + 1);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
cfg->comphy_map_data[lane].speed =
|
|
|
|
fdtdec_get_int(gd->fdt_blob, subnode, "phy-speed",
|
|
|
|
COMPHY_SPEED_INVALID);
|
|
|
|
|
|
|
|
cfg->comphy_map_data[lane].invert =
|
|
|
|
fdtdec_get_int(gd->fdt_blob, subnode, "phy-invert",
|
|
|
|
COMPHY_POLARITY_NO_INVERT);
|
|
|
|
|
|
|
|
cfg->comphy_map_data[lane].clk_src =
|
|
|
|
fdtdec_get_bool(gd->fdt_blob, subnode, "clk-src");
|
|
|
|
|
|
|
|
cfg->comphy_map_data[lane].end_point =
|
|
|
|
fdtdec_get_bool(gd->fdt_blob, subnode, "end_point");
|
|
|
|
|
|
|
|
lane++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-08-30 14:48:20 +00:00
|
|
|
int comphy_cp110_init(struct chip_serdes_phy_config *ptr_chip_cfg,
|
|
|
|
struct comphy_map *serdes_map)
|
|
|
|
{
|
|
|
|
struct comphy_map *ptr_comphy_map;
|
|
|
|
void __iomem *comphy_base_addr, *hpipe_base_addr;
|
2018-05-09 15:50:29 +00:00
|
|
|
u32 comphy_max_count, lane, id, ret = 0;
|
2016-08-30 14:48:20 +00:00
|
|
|
u32 pcie_width = 0;
|
2020-10-18 14:11:11 +00:00
|
|
|
u32 mode;
|
2016-08-30 14:48:20 +00:00
|
|
|
|
|
|
|
debug_enter();
|
|
|
|
|
|
|
|
comphy_max_count = ptr_chip_cfg->comphy_lanes_count;
|
|
|
|
comphy_base_addr = ptr_chip_cfg->comphy_base_addr;
|
|
|
|
hpipe_base_addr = ptr_chip_cfg->hpipe3_base_addr;
|
|
|
|
|
|
|
|
/* Check if the first 4 lanes configured as By-4 */
|
|
|
|
for (lane = 0, ptr_comphy_map = serdes_map; lane < 4;
|
|
|
|
lane++, ptr_comphy_map++) {
|
2017-04-26 12:40:00 +00:00
|
|
|
if (ptr_comphy_map->type != COMPHY_TYPE_PEX0)
|
2016-08-30 14:48:20 +00:00
|
|
|
break;
|
|
|
|
pcie_width++;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (lane = 0, ptr_comphy_map = serdes_map; lane < comphy_max_count;
|
|
|
|
lane++, ptr_comphy_map++) {
|
|
|
|
debug("Initialize serdes number %d\n", lane);
|
|
|
|
debug("Serdes type = 0x%x\n", ptr_comphy_map->type);
|
|
|
|
if (lane == 4) {
|
|
|
|
/*
|
|
|
|
* PCIe lanes above the first 4 lanes, can be only
|
|
|
|
* by1
|
|
|
|
*/
|
|
|
|
pcie_width = 1;
|
|
|
|
}
|
|
|
|
switch (ptr_comphy_map->type) {
|
2017-04-26 12:40:00 +00:00
|
|
|
case COMPHY_TYPE_UNCONNECTED:
|
2018-11-19 07:58:32 +00:00
|
|
|
mode = COMPHY_TYPE_UNCONNECTED | COMPHY_CALLER_UBOOT;
|
2018-05-23 09:10:36 +00:00
|
|
|
ret = comphy_smc(MV_SIP_COMPHY_POWER_OFF,
|
|
|
|
ptr_chip_cfg->comphy_base_addr,
|
2018-11-19 07:58:32 +00:00
|
|
|
lane, mode);
|
2017-04-26 12:40:00 +00:00
|
|
|
case COMPHY_TYPE_IGNORE:
|
2016-08-30 14:48:20 +00:00
|
|
|
continue;
|
|
|
|
break;
|
2017-04-26 12:40:00 +00:00
|
|
|
case COMPHY_TYPE_PEX0:
|
|
|
|
case COMPHY_TYPE_PEX1:
|
|
|
|
case COMPHY_TYPE_PEX2:
|
|
|
|
case COMPHY_TYPE_PEX3:
|
2020-10-18 14:11:12 +00:00
|
|
|
mode = COMPHY_FW_PCIE_FORMAT(pcie_width,
|
|
|
|
ptr_comphy_map->clk_src,
|
|
|
|
COMPHY_PCIE_MODE,
|
|
|
|
ptr_comphy_map->speed);
|
|
|
|
ret = comphy_smc(MV_SIP_COMPHY_POWER_ON,
|
|
|
|
ptr_chip_cfg->comphy_base_addr, lane,
|
|
|
|
mode);
|
2016-08-30 14:48:20 +00:00
|
|
|
break;
|
2017-04-26 12:40:00 +00:00
|
|
|
case COMPHY_TYPE_SATA0:
|
|
|
|
case COMPHY_TYPE_SATA1:
|
2021-09-15 13:45:31 +00:00
|
|
|
mode = COMPHY_FW_SATA_FORMAT(COMPHY_SATA_MODE,
|
|
|
|
serdes_map[lane].invert);
|
2020-10-18 14:11:11 +00:00
|
|
|
ret = comphy_sata_power_up(lane, hpipe_base_addr,
|
|
|
|
comphy_base_addr,
|
|
|
|
ptr_chip_cfg->cp_index,
|
|
|
|
mode);
|
2016-08-30 14:48:20 +00:00
|
|
|
break;
|
2017-04-26 12:40:00 +00:00
|
|
|
case COMPHY_TYPE_USB3_HOST0:
|
|
|
|
case COMPHY_TYPE_USB3_HOST1:
|
2018-03-29 10:30:20 +00:00
|
|
|
mode = COMPHY_FW_MODE_FORMAT(COMPHY_USB3H_MODE);
|
|
|
|
ret = comphy_smc(MV_SIP_COMPHY_POWER_ON,
|
|
|
|
ptr_chip_cfg->comphy_base_addr, lane,
|
|
|
|
mode);
|
|
|
|
break;
|
2017-04-26 12:40:00 +00:00
|
|
|
case COMPHY_TYPE_USB3_DEVICE:
|
2018-03-29 10:30:20 +00:00
|
|
|
mode = COMPHY_FW_MODE_FORMAT(COMPHY_USB3D_MODE);
|
|
|
|
ret = comphy_smc(MV_SIP_COMPHY_POWER_ON,
|
|
|
|
ptr_chip_cfg->comphy_base_addr, lane,
|
|
|
|
mode);
|
2016-08-30 14:48:20 +00:00
|
|
|
break;
|
2017-04-26 12:40:00 +00:00
|
|
|
case COMPHY_TYPE_SGMII0:
|
|
|
|
case COMPHY_TYPE_SGMII1:
|
|
|
|
case COMPHY_TYPE_SGMII2:
|
2018-05-09 15:50:29 +00:00
|
|
|
/* Calculate SGMII ID */
|
|
|
|
id = ptr_comphy_map->type - COMPHY_TYPE_SGMII0;
|
|
|
|
|
2017-04-26 12:40:00 +00:00
|
|
|
if (ptr_comphy_map->speed == COMPHY_SPEED_INVALID) {
|
2016-08-30 14:48:20 +00:00
|
|
|
debug("Warning: SGMII PHY speed in lane %d is invalid, set PHY speed to 1.25G\n",
|
|
|
|
lane);
|
2017-04-26 12:40:00 +00:00
|
|
|
ptr_comphy_map->speed = COMPHY_SPEED_1_25G;
|
2016-08-30 14:48:20 +00:00
|
|
|
}
|
2020-10-18 14:11:11 +00:00
|
|
|
|
2018-05-09 15:50:29 +00:00
|
|
|
mode = COMPHY_FW_FORMAT(COMPHY_SGMII_MODE, id,
|
2020-10-18 14:11:11 +00:00
|
|
|
ptr_comphy_map->speed);
|
|
|
|
ret = comphy_smc(MV_SIP_COMPHY_POWER_ON,
|
|
|
|
ptr_chip_cfg->comphy_base_addr, lane,
|
|
|
|
mode);
|
2016-08-30 14:48:20 +00:00
|
|
|
break;
|
2018-05-14 08:20:54 +00:00
|
|
|
case COMPHY_TYPE_SFI0:
|
|
|
|
case COMPHY_TYPE_SFI1:
|
|
|
|
/* Calculate SFI id */
|
|
|
|
id = ptr_comphy_map->type - COMPHY_TYPE_SFI0;
|
|
|
|
mode = COMPHY_FW_FORMAT(COMPHY_SFI_MODE, id,
|
2020-10-18 14:11:11 +00:00
|
|
|
ptr_comphy_map->speed);
|
|
|
|
ret = comphy_smc(MV_SIP_COMPHY_POWER_ON,
|
2018-05-14 08:20:54 +00:00
|
|
|
ptr_chip_cfg->comphy_base_addr, lane, mode);
|
2016-08-30 14:48:20 +00:00
|
|
|
break;
|
2017-04-26 12:40:00 +00:00
|
|
|
case COMPHY_TYPE_RXAUI0:
|
|
|
|
case COMPHY_TYPE_RXAUI1:
|
2018-03-27 10:52:24 +00:00
|
|
|
mode = COMPHY_FW_MODE_FORMAT(COMPHY_RXAUI_MODE);
|
|
|
|
ret = comphy_smc(MV_SIP_COMPHY_POWER_ON,
|
|
|
|
ptr_chip_cfg->comphy_base_addr, lane,
|
|
|
|
mode);
|
2016-08-30 14:48:20 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
debug("Unknown SerDes type, skip initialize SerDes %d\n",
|
|
|
|
lane);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (ret == 0) {
|
|
|
|
/*
|
2017-04-24 15:45:25 +00:00
|
|
|
* If interface wans't initialized, set the lane to
|
2017-04-26 12:40:00 +00:00
|
|
|
* COMPHY_TYPE_UNCONNECTED state.
|
2016-08-30 14:48:20 +00:00
|
|
|
*/
|
2017-04-26 12:40:00 +00:00
|
|
|
ptr_comphy_map->type = COMPHY_TYPE_UNCONNECTED;
|
2017-09-16 05:10:41 +00:00
|
|
|
pr_err("PLL is not locked - Failed to initialize lane %d\n",
|
2016-08-30 14:48:20 +00:00
|
|
|
lane);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
debug_exit();
|
|
|
|
return 0;
|
|
|
|
}
|