1c0132f60SStefan Roese /* 2c0132f60SStefan Roese * Copyright (C) 2015-2016 Marvell International Ltd. 3c0132f60SStefan Roese * 4c0132f60SStefan Roese * SPDX-License-Identifier: GPL-2.0+ 5c0132f60SStefan Roese */ 6c0132f60SStefan Roese 7c0132f60SStefan Roese #include <common.h> 8c0132f60SStefan Roese #include <fdtdec.h> 9c0132f60SStefan Roese #include <asm/io.h> 10c0132f60SStefan Roese #include <asm/arch/cpu.h> 11c0132f60SStefan Roese #include <asm/arch/soc.h> 12c0132f60SStefan Roese 13c0132f60SStefan Roese #include "comphy.h" 14c0132f60SStefan Roese #include "comphy_hpipe.h" 15c0132f60SStefan Roese #include "sata.h" 16c0132f60SStefan Roese #include "utmi_phy.h" 17c0132f60SStefan Roese 18c0132f60SStefan Roese DECLARE_GLOBAL_DATA_PTR; 19c0132f60SStefan Roese 20c0132f60SStefan Roese #define SD_ADDR(base, lane) (base + 0x1000 * lane) 21c0132f60SStefan Roese #define HPIPE_ADDR(base, lane) (SD_ADDR(base, lane) + 0x800) 22c0132f60SStefan Roese #define COMPHY_ADDR(base, lane) (base + 0x28 * lane) 23c0132f60SStefan Roese 24c0132f60SStefan Roese struct utmi_phy_data { 25c0132f60SStefan Roese void __iomem *utmi_base_addr; 26c0132f60SStefan Roese void __iomem *usb_cfg_addr; 27c0132f60SStefan Roese void __iomem *utmi_cfg_addr; 28c0132f60SStefan Roese u32 utmi_phy_port; 29c0132f60SStefan Roese }; 30c0132f60SStefan Roese 31c0132f60SStefan Roese /* 32c0132f60SStefan Roese * For CP-110 we have 2 Selector registers "PHY Selectors", 33c0132f60SStefan Roese * and "PIPE Selectors". 34c0132f60SStefan Roese * PIPE selector include USB and PCIe options. 35c0132f60SStefan Roese * PHY selector include the Ethernet and SATA options, every Ethernet 36c0132f60SStefan Roese * option has different options, for example: serdes lane2 had option 37*cb686454SStefan Roese * Eth_port_0 that include (SGMII0, XAUI0, RXAUI0, SFI) 38c0132f60SStefan Roese */ 39c0132f60SStefan Roese struct comphy_mux_data cp110_comphy_phy_mux_data[] = { 40c0132f60SStefan Roese {4, {{PHY_TYPE_UNCONNECTED, 0x0}, {PHY_TYPE_SGMII2, 0x1}, /* Lane 0 */ 41c0132f60SStefan Roese {PHY_TYPE_XAUI2, 0x1}, {PHY_TYPE_SATA1, 0x4} } }, 42c0132f60SStefan Roese {4, {{PHY_TYPE_UNCONNECTED, 0x0}, {PHY_TYPE_SGMII3, 0x1}, /* Lane 1 */ 43c0132f60SStefan Roese {PHY_TYPE_XAUI3, 0x1}, {PHY_TYPE_SATA0, 0x4} } }, 44c0132f60SStefan Roese {6, {{PHY_TYPE_UNCONNECTED, 0x0}, {PHY_TYPE_SGMII0, 0x1}, /* Lane 2 */ 45c0132f60SStefan Roese {PHY_TYPE_XAUI0, 0x1}, {PHY_TYPE_RXAUI0, 0x1}, 46*cb686454SStefan Roese {PHY_TYPE_SFI, 0x1}, {PHY_TYPE_SATA0, 0x4} } }, 47c0132f60SStefan Roese {8, {{PHY_TYPE_UNCONNECTED, 0x0}, {PHY_TYPE_SGMII0, 0x1}, /* Lane 3 */ 48c0132f60SStefan Roese {PHY_TYPE_XAUI0, 0x1}, {PHY_TYPE_RXAUI0, 0x1}, 49*cb686454SStefan Roese {PHY_TYPE_SFI, 0x1}, {PHY_TYPE_XAUI1, 0x1}, 50c0132f60SStefan Roese {PHY_TYPE_RXAUI1, 0x1}, {PHY_TYPE_SATA1, 0x4} } }, 51c0132f60SStefan Roese {7, {{PHY_TYPE_UNCONNECTED, 0x0}, {PHY_TYPE_SGMII0, 0x2}, /* Lane 4 */ 52*cb686454SStefan Roese {PHY_TYPE_XAUI0, 0x1}, {PHY_TYPE_RXAUI0, 0x1}, {PHY_TYPE_SFI, 0x1}, 53c0132f60SStefan Roese {PHY_TYPE_SGMII2, 0x1}, {PHY_TYPE_XAUI2, 0x1} } }, 54c0132f60SStefan Roese {6, {{PHY_TYPE_UNCONNECTED, 0x0}, {PHY_TYPE_XAUI1, 0x1}, /* Lane 5 */ 55c0132f60SStefan Roese {PHY_TYPE_RXAUI1, 0x1}, {PHY_TYPE_SGMII3, 0x1}, 56c0132f60SStefan Roese {PHY_TYPE_XAUI3, 0x1}, {PHY_TYPE_SATA1, 0x4} } }, 57c0132f60SStefan Roese }; 58c0132f60SStefan Roese 59c0132f60SStefan Roese struct comphy_mux_data cp110_comphy_pipe_mux_data[] = { 60c0132f60SStefan Roese {2, {{PHY_TYPE_UNCONNECTED, 0x0}, {PHY_TYPE_PEX0, 0x4} } }, /* Lane 0 */ 61c0132f60SStefan Roese {4, {{PHY_TYPE_UNCONNECTED, 0x0}, /* Lane 1 */ 62c0132f60SStefan Roese {PHY_TYPE_USB3_HOST0, 0x1}, {PHY_TYPE_USB3_DEVICE, 0x2}, 63c0132f60SStefan Roese {PHY_TYPE_PEX0, 0x4} } }, 64c0132f60SStefan Roese {3, {{PHY_TYPE_UNCONNECTED, 0x0}, /* Lane 2 */ 65c0132f60SStefan Roese {PHY_TYPE_USB3_HOST0, 0x1}, {PHY_TYPE_PEX0, 0x4} } }, 66c0132f60SStefan Roese {3, {{PHY_TYPE_UNCONNECTED, 0x0}, /* Lane 3 */ 67c0132f60SStefan Roese {PHY_TYPE_USB3_HOST1, 0x1}, {PHY_TYPE_PEX0, 0x4} } }, 68c0132f60SStefan Roese {4, {{PHY_TYPE_UNCONNECTED, 0x0}, /* Lane 4 */ 69c0132f60SStefan Roese {PHY_TYPE_USB3_HOST1, 0x1}, 70c0132f60SStefan Roese {PHY_TYPE_USB3_DEVICE, 0x2}, {PHY_TYPE_PEX1, 0x4} } }, 71c0132f60SStefan Roese {2, {{PHY_TYPE_UNCONNECTED, 0x0}, {PHY_TYPE_PEX2, 0x4} } }, /* Lane 5 */ 72c0132f60SStefan Roese }; 73c0132f60SStefan Roese 74c0132f60SStefan Roese static u32 polling_with_timeout(void __iomem *addr, u32 val, 75c0132f60SStefan Roese u32 mask, unsigned long usec_timout) 76c0132f60SStefan Roese { 77c0132f60SStefan Roese u32 data; 78c0132f60SStefan Roese 79c0132f60SStefan Roese do { 80c0132f60SStefan Roese udelay(1); 81c0132f60SStefan Roese data = readl(addr) & mask; 82c0132f60SStefan Roese } while (data != val && --usec_timout > 0); 83c0132f60SStefan Roese 84c0132f60SStefan Roese if (usec_timout == 0) 85c0132f60SStefan Roese return data; 86c0132f60SStefan Roese 87c0132f60SStefan Roese return 0; 88c0132f60SStefan Roese } 89c0132f60SStefan Roese 90c0132f60SStefan Roese static int comphy_pcie_power_up(u32 lane, u32 pcie_width, 91c0132f60SStefan Roese bool clk_src, void __iomem *hpipe_base, 92c0132f60SStefan Roese void __iomem *comphy_base) 93c0132f60SStefan Roese { 94c0132f60SStefan Roese u32 mask, data, ret = 1; 95c0132f60SStefan Roese void __iomem *hpipe_addr = HPIPE_ADDR(hpipe_base, lane); 96c0132f60SStefan Roese void __iomem *comphy_addr = COMPHY_ADDR(comphy_base, lane); 97c0132f60SStefan Roese void __iomem *addr; 98c0132f60SStefan Roese u32 pcie_clk = 0; /* set input by default */ 99c0132f60SStefan Roese 100c0132f60SStefan Roese debug_enter(); 101c0132f60SStefan Roese 102c0132f60SStefan Roese /* 103c0132f60SStefan Roese * ToDo: 104c0132f60SStefan Roese * Add SAR (Sample-At-Reset) configuration for the PCIe clock 105c0132f60SStefan Roese * direction. SAR code is currently not ported from Marvell 106c0132f60SStefan Roese * U-Boot to mainline version. 107c0132f60SStefan Roese * 108c0132f60SStefan Roese * SerDes Lane 4/5 got the PCIe ref-clock #1, 109c0132f60SStefan Roese * and SerDes Lane 0 got PCIe ref-clock #0 110c0132f60SStefan Roese */ 111c0132f60SStefan Roese debug("PCIe clock = %x\n", pcie_clk); 112c0132f60SStefan Roese debug("PCIe width = %d\n", pcie_width); 113c0132f60SStefan Roese 114c0132f60SStefan Roese /* enable PCIe by4 and by2 */ 115c0132f60SStefan Roese if (lane == 0) { 116c0132f60SStefan Roese if (pcie_width == 4) { 117c0132f60SStefan Roese reg_set(comphy_base + COMMON_PHY_SD_CTRL1, 118c0132f60SStefan Roese 0x1 << COMMON_PHY_SD_CTRL1_PCIE_X4_EN_OFFSET, 119c0132f60SStefan Roese COMMON_PHY_SD_CTRL1_PCIE_X4_EN_MASK); 120c0132f60SStefan Roese } else if (pcie_width == 2) { 121c0132f60SStefan Roese reg_set(comphy_base + COMMON_PHY_SD_CTRL1, 122c0132f60SStefan Roese 0x1 << COMMON_PHY_SD_CTRL1_PCIE_X2_EN_OFFSET, 123c0132f60SStefan Roese COMMON_PHY_SD_CTRL1_PCIE_X2_EN_MASK); 124c0132f60SStefan Roese } 125c0132f60SStefan Roese } 126c0132f60SStefan Roese 127c0132f60SStefan Roese /* 128c0132f60SStefan Roese * If PCIe clock is output and clock source from SerDes lane 5, 129c0132f60SStefan Roese * we need to configure the clock-source MUX. 130c0132f60SStefan Roese * By default, the clock source is from lane 4 131c0132f60SStefan Roese */ 132c0132f60SStefan Roese if (pcie_clk && clk_src && (lane == 5)) { 133c0132f60SStefan Roese reg_set((void __iomem *)DFX_DEV_GEN_CTRL12, 134c0132f60SStefan Roese 0x3 << DFX_DEV_GEN_PCIE_CLK_SRC_OFFSET, 135c0132f60SStefan Roese DFX_DEV_GEN_PCIE_CLK_SRC_MASK); 136c0132f60SStefan Roese } 137c0132f60SStefan Roese 138c0132f60SStefan Roese debug("stage: RFU configurations - hard reset comphy\n"); 139c0132f60SStefan Roese /* RFU configurations - hard reset comphy */ 140c0132f60SStefan Roese mask = COMMON_PHY_CFG1_PWR_UP_MASK; 141c0132f60SStefan Roese data = 0x1 << COMMON_PHY_CFG1_PWR_UP_OFFSET; 142c0132f60SStefan Roese mask |= COMMON_PHY_CFG1_PIPE_SELECT_MASK; 143c0132f60SStefan Roese data |= 0x1 << COMMON_PHY_CFG1_PIPE_SELECT_OFFSET; 144c0132f60SStefan Roese mask |= COMMON_PHY_CFG1_PWR_ON_RESET_MASK; 145c0132f60SStefan Roese data |= 0x0 << COMMON_PHY_CFG1_PWR_ON_RESET_OFFSET; 146c0132f60SStefan Roese mask |= COMMON_PHY_CFG1_CORE_RSTN_MASK; 147c0132f60SStefan Roese data |= 0x0 << COMMON_PHY_CFG1_CORE_RSTN_OFFSET; 148c0132f60SStefan Roese mask |= COMMON_PHY_PHY_MODE_MASK; 149c0132f60SStefan Roese data |= 0x0 << COMMON_PHY_PHY_MODE_OFFSET; 150c0132f60SStefan Roese reg_set(comphy_addr + COMMON_PHY_CFG1_REG, data, mask); 151c0132f60SStefan Roese 152c0132f60SStefan Roese /* release from hard reset */ 153c0132f60SStefan Roese mask = COMMON_PHY_CFG1_PWR_ON_RESET_MASK; 154c0132f60SStefan Roese data = 0x1 << COMMON_PHY_CFG1_PWR_ON_RESET_OFFSET; 155c0132f60SStefan Roese mask |= COMMON_PHY_CFG1_CORE_RSTN_MASK; 156c0132f60SStefan Roese data |= 0x1 << COMMON_PHY_CFG1_CORE_RSTN_OFFSET; 157c0132f60SStefan Roese reg_set(comphy_addr + COMMON_PHY_CFG1_REG, data, mask); 158c0132f60SStefan Roese 159c0132f60SStefan Roese /* Wait 1ms - until band gap and ref clock ready */ 160c0132f60SStefan Roese mdelay(1); 161c0132f60SStefan Roese /* Start comphy Configuration */ 162c0132f60SStefan Roese debug("stage: Comphy configuration\n"); 163c0132f60SStefan Roese /* Set PIPE soft reset */ 164c0132f60SStefan Roese mask = HPIPE_RST_CLK_CTRL_PIPE_RST_MASK; 165c0132f60SStefan Roese data = 0x1 << HPIPE_RST_CLK_CTRL_PIPE_RST_OFFSET; 166c0132f60SStefan Roese /* Set PHY datapath width mode for V0 */ 167c0132f60SStefan Roese mask |= HPIPE_RST_CLK_CTRL_FIXED_PCLK_MASK; 168c0132f60SStefan Roese data |= 0x1 << HPIPE_RST_CLK_CTRL_FIXED_PCLK_OFFSET; 169c0132f60SStefan Roese /* Set Data bus width USB mode for V0 */ 170c0132f60SStefan Roese mask |= HPIPE_RST_CLK_CTRL_PIPE_WIDTH_MASK; 171c0132f60SStefan Roese data |= 0x0 << HPIPE_RST_CLK_CTRL_PIPE_WIDTH_OFFSET; 172c0132f60SStefan Roese /* Set CORE_CLK output frequency for 250Mhz */ 173c0132f60SStefan Roese mask |= HPIPE_RST_CLK_CTRL_CORE_FREQ_SEL_MASK; 174c0132f60SStefan Roese data |= 0x0 << HPIPE_RST_CLK_CTRL_CORE_FREQ_SEL_OFFSET; 175c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_RST_CLK_CTRL_REG, data, mask); 176c0132f60SStefan Roese /* Set PLL ready delay for 0x2 */ 177c0132f60SStefan Roese data = 0x2 << HPIPE_CLK_SRC_LO_PLL_RDY_DL_OFFSET; 178c0132f60SStefan Roese mask = HPIPE_CLK_SRC_LO_PLL_RDY_DL_MASK; 179c0132f60SStefan Roese if (pcie_width != 1) { 180c0132f60SStefan Roese data |= 0x1 << HPIPE_CLK_SRC_LO_BUNDLE_PERIOD_SEL_OFFSET; 181c0132f60SStefan Roese mask |= HPIPE_CLK_SRC_LO_BUNDLE_PERIOD_SEL_MASK; 182c0132f60SStefan Roese data |= 0x1 << HPIPE_CLK_SRC_LO_BUNDLE_PERIOD_SCALE_OFFSET; 183c0132f60SStefan Roese mask |= HPIPE_CLK_SRC_LO_BUNDLE_PERIOD_SCALE_MASK; 184c0132f60SStefan Roese } 185c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_CLK_SRC_LO_REG, data, mask); 186c0132f60SStefan Roese 187c0132f60SStefan Roese /* Set PIPE mode interface to PCIe3 - 0x1 & set lane order */ 188c0132f60SStefan Roese data = 0x1 << HPIPE_CLK_SRC_HI_MODE_PIPE_OFFSET; 189c0132f60SStefan Roese mask = HPIPE_CLK_SRC_HI_MODE_PIPE_MASK; 190c0132f60SStefan Roese if (pcie_width != 1) { 191c0132f60SStefan Roese mask |= HPIPE_CLK_SRC_HI_LANE_STRT_MASK; 192c0132f60SStefan Roese mask |= HPIPE_CLK_SRC_HI_LANE_MASTER_MASK; 193c0132f60SStefan Roese mask |= HPIPE_CLK_SRC_HI_LANE_BREAK_MASK; 194c0132f60SStefan Roese if (lane == 0) { 195c0132f60SStefan Roese data |= 0x1 << HPIPE_CLK_SRC_HI_LANE_STRT_OFFSET; 196c0132f60SStefan Roese data |= 0x1 << HPIPE_CLK_SRC_HI_LANE_MASTER_OFFSET; 197c0132f60SStefan Roese } else if (lane == (pcie_width - 1)) { 198c0132f60SStefan Roese data |= 0x1 << HPIPE_CLK_SRC_HI_LANE_BREAK_OFFSET; 199c0132f60SStefan Roese } 200c0132f60SStefan Roese } 201c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_CLK_SRC_HI_REG, data, mask); 202c0132f60SStefan Roese /* Config update polarity equalization */ 203c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_LANE_EQ_CFG1_REG, 204c0132f60SStefan Roese 0x1 << HPIPE_CFG_UPDATE_POLARITY_OFFSET, 205c0132f60SStefan Roese HPIPE_CFG_UPDATE_POLARITY_MASK); 206c0132f60SStefan Roese /* Set PIPE version 4 to mode enable */ 207c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_DFE_CTRL_28_REG, 208c0132f60SStefan Roese 0x1 << HPIPE_DFE_CTRL_28_PIPE4_OFFSET, 209c0132f60SStefan Roese HPIPE_DFE_CTRL_28_PIPE4_MASK); 210c0132f60SStefan Roese /* TODO: check if pcie clock is output/input - for bringup use input*/ 211c0132f60SStefan Roese /* Enable PIN clock 100M_125M */ 212c0132f60SStefan Roese mask = 0; 213c0132f60SStefan Roese data = 0; 214c0132f60SStefan Roese /* Only if clock is output, configure the clock-source mux */ 215c0132f60SStefan Roese if (pcie_clk) { 216c0132f60SStefan Roese mask |= HPIPE_MISC_CLK100M_125M_MASK; 217c0132f60SStefan Roese data |= 0x1 << HPIPE_MISC_CLK100M_125M_OFFSET; 218c0132f60SStefan Roese } 219c0132f60SStefan Roese /* 220c0132f60SStefan Roese * Set PIN_TXDCLK_2X Clock Frequency Selection for outputs 500MHz 221c0132f60SStefan Roese * clock 222c0132f60SStefan Roese */ 223c0132f60SStefan Roese mask |= HPIPE_MISC_TXDCLK_2X_MASK; 224c0132f60SStefan Roese data |= 0x0 << HPIPE_MISC_TXDCLK_2X_OFFSET; 225c0132f60SStefan Roese /* Enable 500MHz Clock */ 226c0132f60SStefan Roese mask |= HPIPE_MISC_CLK500_EN_MASK; 227c0132f60SStefan Roese data |= 0x1 << HPIPE_MISC_CLK500_EN_OFFSET; 228c0132f60SStefan Roese if (pcie_clk) { /* output */ 229c0132f60SStefan Roese /* Set reference clock comes from group 1 */ 230c0132f60SStefan Roese mask |= HPIPE_MISC_REFCLK_SEL_MASK; 231c0132f60SStefan Roese data |= 0x0 << HPIPE_MISC_REFCLK_SEL_OFFSET; 232c0132f60SStefan Roese } else { 233c0132f60SStefan Roese /* Set reference clock comes from group 2 */ 234c0132f60SStefan Roese mask |= HPIPE_MISC_REFCLK_SEL_MASK; 235c0132f60SStefan Roese data |= 0x1 << HPIPE_MISC_REFCLK_SEL_OFFSET; 236c0132f60SStefan Roese } 237c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_MISC_REG, data, mask); 238c0132f60SStefan Roese if (pcie_clk) { /* output */ 239c0132f60SStefan Roese /* Set reference frequcency select - 0x2 for 25MHz*/ 240c0132f60SStefan Roese mask = HPIPE_PWR_PLL_REF_FREQ_MASK; 241c0132f60SStefan Roese data = 0x2 << HPIPE_PWR_PLL_REF_FREQ_OFFSET; 242c0132f60SStefan Roese } else { 243c0132f60SStefan Roese /* Set reference frequcency select - 0x0 for 100MHz*/ 244c0132f60SStefan Roese mask = HPIPE_PWR_PLL_REF_FREQ_MASK; 245c0132f60SStefan Roese data = 0x0 << HPIPE_PWR_PLL_REF_FREQ_OFFSET; 246c0132f60SStefan Roese } 247c0132f60SStefan Roese /* Set PHY mode to PCIe */ 248c0132f60SStefan Roese mask |= HPIPE_PWR_PLL_PHY_MODE_MASK; 249c0132f60SStefan Roese data |= 0x3 << HPIPE_PWR_PLL_PHY_MODE_OFFSET; 250c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_PWR_PLL_REG, data, mask); 251c0132f60SStefan Roese 252c0132f60SStefan Roese /* ref clock alignment */ 253c0132f60SStefan Roese if (pcie_width != 1) { 254c0132f60SStefan Roese mask = HPIPE_LANE_ALIGN_OFF_MASK; 255c0132f60SStefan Roese data = 0x0 << HPIPE_LANE_ALIGN_OFF_OFFSET; 256c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_LANE_ALIGN_REG, data, mask); 257c0132f60SStefan Roese } 258c0132f60SStefan Roese 259c0132f60SStefan Roese /* 260c0132f60SStefan Roese * Set the amount of time spent in the LoZ state - set for 0x7 only if 261c0132f60SStefan Roese * the PCIe clock is output 262c0132f60SStefan Roese */ 263c0132f60SStefan Roese if (pcie_clk) { 264c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_GLOBAL_PM_CTRL, 265c0132f60SStefan Roese 0x7 << HPIPE_GLOBAL_PM_RXDLOZ_WAIT_OFFSET, 266c0132f60SStefan Roese HPIPE_GLOBAL_PM_RXDLOZ_WAIT_MASK); 267c0132f60SStefan Roese } 268c0132f60SStefan Roese 269c0132f60SStefan Roese /* Set Maximal PHY Generation Setting(8Gbps) */ 270c0132f60SStefan Roese mask = HPIPE_INTERFACE_GEN_MAX_MASK; 271c0132f60SStefan Roese data = 0x2 << HPIPE_INTERFACE_GEN_MAX_OFFSET; 272c0132f60SStefan Roese /* Set Link Train Mode (Tx training control pins are used) */ 273c0132f60SStefan Roese mask |= HPIPE_INTERFACE_LINK_TRAIN_MASK; 274c0132f60SStefan Roese data |= 0x1 << HPIPE_INTERFACE_LINK_TRAIN_OFFSET; 275c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_INTERFACE_REG, data, mask); 276c0132f60SStefan Roese 277c0132f60SStefan Roese /* Set Idle_sync enable */ 278c0132f60SStefan Roese mask = HPIPE_PCIE_IDLE_SYNC_MASK; 279c0132f60SStefan Roese data = 0x1 << HPIPE_PCIE_IDLE_SYNC_OFFSET; 280c0132f60SStefan Roese /* Select bits for PCIE Gen3(32bit) */ 281c0132f60SStefan Roese mask |= HPIPE_PCIE_SEL_BITS_MASK; 282c0132f60SStefan Roese data |= 0x2 << HPIPE_PCIE_SEL_BITS_OFFSET; 283c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_PCIE_REG0, data, mask); 284c0132f60SStefan Roese 285c0132f60SStefan Roese /* Enable Tx_adapt_g1 */ 286c0132f60SStefan Roese mask = HPIPE_TX_TRAIN_CTRL_G1_MASK; 287c0132f60SStefan Roese data = 0x1 << HPIPE_TX_TRAIN_CTRL_G1_OFFSET; 288c0132f60SStefan Roese /* Enable Tx_adapt_gn1 */ 289c0132f60SStefan Roese mask |= HPIPE_TX_TRAIN_CTRL_GN1_MASK; 290c0132f60SStefan Roese data |= 0x1 << HPIPE_TX_TRAIN_CTRL_GN1_OFFSET; 291c0132f60SStefan Roese /* Disable Tx_adapt_g0 */ 292c0132f60SStefan Roese mask |= HPIPE_TX_TRAIN_CTRL_G0_MASK; 293c0132f60SStefan Roese data |= 0x0 << HPIPE_TX_TRAIN_CTRL_G0_OFFSET; 294c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_TX_TRAIN_CTRL_REG, data, mask); 295c0132f60SStefan Roese 296c0132f60SStefan Roese /* Set reg_tx_train_chk_init */ 297c0132f60SStefan Roese mask = HPIPE_TX_TRAIN_CHK_INIT_MASK; 298c0132f60SStefan Roese data = 0x0 << HPIPE_TX_TRAIN_CHK_INIT_OFFSET; 299c0132f60SStefan Roese /* Enable TX_COE_FM_PIN_PCIE3_EN */ 300c0132f60SStefan Roese mask |= HPIPE_TX_TRAIN_COE_FM_PIN_PCIE3_MASK; 301c0132f60SStefan Roese data |= 0x1 << HPIPE_TX_TRAIN_COE_FM_PIN_PCIE3_OFFSET; 302c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_TX_TRAIN_REG, data, mask); 303c0132f60SStefan Roese 304c0132f60SStefan Roese debug("stage: TRx training parameters\n"); 305c0132f60SStefan Roese /* Set Preset sweep configurations */ 306c0132f60SStefan Roese mask = HPIPE_TX_TX_STATUS_CHECK_MODE_MASK; 307c0132f60SStefan Roese data = 0x1 << HPIPE_TX_STATUS_CHECK_MODE_OFFSET; 308c0132f60SStefan Roese 309c0132f60SStefan Roese mask |= HPIPE_TX_NUM_OF_PRESET_MASK; 310c0132f60SStefan Roese data |= 0x7 << HPIPE_TX_NUM_OF_PRESET_OFFSET; 311c0132f60SStefan Roese 312c0132f60SStefan Roese mask |= HPIPE_TX_SWEEP_PRESET_EN_MASK; 313c0132f60SStefan Roese data |= 0x1 << HPIPE_TX_SWEEP_PRESET_EN_OFFSET; 314c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_TX_TRAIN_CTRL_11_REG, data, mask); 315c0132f60SStefan Roese 316c0132f60SStefan Roese /* Tx train start configuration */ 317c0132f60SStefan Roese mask = HPIPE_TX_TRAIN_START_SQ_EN_MASK; 318c0132f60SStefan Roese data = 0x1 << HPIPE_TX_TRAIN_START_SQ_EN_OFFSET; 319c0132f60SStefan Roese 320c0132f60SStefan Roese mask |= HPIPE_TX_TRAIN_START_FRM_DET_EN_MASK; 321c0132f60SStefan Roese data |= 0x0 << HPIPE_TX_TRAIN_START_FRM_DET_EN_OFFSET; 322c0132f60SStefan Roese 323c0132f60SStefan Roese mask |= HPIPE_TX_TRAIN_START_FRM_LOCK_EN_MASK; 324c0132f60SStefan Roese data |= 0x0 << HPIPE_TX_TRAIN_START_FRM_LOCK_EN_OFFSET; 325c0132f60SStefan Roese 326c0132f60SStefan Roese mask |= HPIPE_TX_TRAIN_WAIT_TIME_EN_MASK; 327c0132f60SStefan Roese data |= 0x1 << HPIPE_TX_TRAIN_WAIT_TIME_EN_OFFSET; 328c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_TX_TRAIN_CTRL_5_REG, data, mask); 329c0132f60SStefan Roese 330c0132f60SStefan Roese /* Enable Tx train P2P */ 331c0132f60SStefan Roese mask = HPIPE_TX_TRAIN_P2P_HOLD_MASK; 332c0132f60SStefan Roese data = 0x1 << HPIPE_TX_TRAIN_P2P_HOLD_OFFSET; 333c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_TX_TRAIN_CTRL_0_REG, data, mask); 334c0132f60SStefan Roese 335c0132f60SStefan Roese /* Configure Tx train timeout */ 336c0132f60SStefan Roese mask = HPIPE_TRX_TRAIN_TIMER_MASK; 337c0132f60SStefan Roese data = 0x17 << HPIPE_TRX_TRAIN_TIMER_OFFSET; 338c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_TX_TRAIN_CTRL_4_REG, data, mask); 339c0132f60SStefan Roese 340c0132f60SStefan Roese /* Disable G0/G1/GN1 adaptation */ 341c0132f60SStefan Roese mask = HPIPE_TX_TRAIN_CTRL_G1_MASK | HPIPE_TX_TRAIN_CTRL_GN1_MASK 342c0132f60SStefan Roese | HPIPE_TX_TRAIN_CTRL_G0_OFFSET; 343c0132f60SStefan Roese data = 0; 344c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_TX_TRAIN_CTRL_REG, data, mask); 345c0132f60SStefan Roese 346c0132f60SStefan Roese /* Disable DTL frequency loop */ 347c0132f60SStefan Roese mask = HPIPE_PWR_CTR_DTL_FLOOP_EN_MASK; 348c0132f60SStefan Roese data = 0x0 << HPIPE_PWR_CTR_DTL_FLOOP_EN_OFFSET; 349c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_PWR_CTR_DTL_REG, data, mask); 350c0132f60SStefan Roese 351c0132f60SStefan Roese /* Configure G3 DFE */ 352c0132f60SStefan Roese mask = HPIPE_G3_DFE_RES_MASK; 353c0132f60SStefan Roese data = 0x3 << HPIPE_G3_DFE_RES_OFFSET; 354c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_G3_SETTING_4_REG, data, mask); 355c0132f60SStefan Roese 356c0132f60SStefan Roese /* Force DFE resolution (use GEN table value) */ 357c0132f60SStefan Roese mask = HPIPE_DFE_RES_FORCE_MASK; 358c0132f60SStefan Roese data = 0x1 << HPIPE_DFE_RES_FORCE_OFFSET; 359c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_DFE_REG0, data, mask); 360c0132f60SStefan Roese 361c0132f60SStefan Roese /* Configure initial and final coefficient value for receiver */ 362c0132f60SStefan Roese mask = HPIPE_G3_RX_SELMUPI_MASK; 363c0132f60SStefan Roese data = 0x1 << HPIPE_G3_RX_SELMUPI_OFFSET; 364c0132f60SStefan Roese 365c0132f60SStefan Roese mask |= HPIPE_G3_RX_SELMUPF_MASK; 366c0132f60SStefan Roese data |= 0x1 << HPIPE_G3_RX_SELMUPF_OFFSET; 367c0132f60SStefan Roese 368c0132f60SStefan Roese mask |= HPIPE_G3_SETTING_BIT_MASK; 369c0132f60SStefan Roese data |= 0x0 << HPIPE_G3_SETTING_BIT_OFFSET; 370c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_G3_SETTINGS_1_REG, data, mask); 371c0132f60SStefan Roese 372c0132f60SStefan Roese /* Trigger sampler enable pulse */ 373c0132f60SStefan Roese mask = HPIPE_SMAPLER_MASK; 374c0132f60SStefan Roese data = 0x1 << HPIPE_SMAPLER_OFFSET; 375c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_SAMPLER_N_PROC_CALIB_CTRL_REG, data, mask); 376c0132f60SStefan Roese udelay(5); 377c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_SAMPLER_N_PROC_CALIB_CTRL_REG, 0, mask); 378c0132f60SStefan Roese 379c0132f60SStefan Roese /* FFE resistor tuning for different bandwidth */ 380c0132f60SStefan Roese mask = HPIPE_G3_FFE_DEG_RES_LEVEL_MASK; 381c0132f60SStefan Roese data = 0x1 << HPIPE_G3_FFE_DEG_RES_LEVEL_OFFSET; 382c0132f60SStefan Roese 383c0132f60SStefan Roese mask |= HPIPE_G3_FFE_LOAD_RES_LEVEL_MASK; 384c0132f60SStefan Roese data |= 0x1 << HPIPE_G3_FFE_LOAD_RES_LEVEL_OFFSET; 385c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_G3_SETTING_3_REG, data, mask); 386c0132f60SStefan Roese 387c0132f60SStefan Roese /* Set phy in root complex mode */ 388c0132f60SStefan Roese mask = HPIPE_CFG_PHY_RC_EP_MASK; 389c0132f60SStefan Roese data = 0x1 << HPIPE_CFG_PHY_RC_EP_OFFSET; 390c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_LANE_EQU_CONFIG_0_REG, data, mask); 391c0132f60SStefan Roese 392c0132f60SStefan Roese debug("stage: Comphy power up\n"); 393c0132f60SStefan Roese 394c0132f60SStefan Roese /* 395c0132f60SStefan Roese * For PCIe by4 or by2 - release from reset only after finish to 396c0132f60SStefan Roese * configure all lanes 397c0132f60SStefan Roese */ 398c0132f60SStefan Roese if ((pcie_width == 1) || (lane == (pcie_width - 1))) { 399c0132f60SStefan Roese u32 i, start_lane, end_lane; 400c0132f60SStefan Roese 401c0132f60SStefan Roese if (pcie_width != 1) { 402c0132f60SStefan Roese /* allows writing to all lanes in one write */ 403c0132f60SStefan Roese reg_set(comphy_base + COMMON_PHY_SD_CTRL1, 404c0132f60SStefan Roese 0x0 << 405c0132f60SStefan Roese COMMON_PHY_SD_CTRL1_COMPHY_0_4_PORT_OFFSET, 406c0132f60SStefan Roese COMMON_PHY_SD_CTRL1_COMPHY_0_4_PORT_MASK); 407c0132f60SStefan Roese start_lane = 0; 408c0132f60SStefan Roese end_lane = pcie_width; 409c0132f60SStefan Roese 410c0132f60SStefan Roese /* 411c0132f60SStefan Roese * Release from PIPE soft reset 412c0132f60SStefan Roese * for PCIe by4 or by2 - release from soft reset 413c0132f60SStefan Roese * all lanes - can't use read modify write 414c0132f60SStefan Roese */ 415c0132f60SStefan Roese reg_set(HPIPE_ADDR(hpipe_base, 0) + 416c0132f60SStefan Roese HPIPE_RST_CLK_CTRL_REG, 0x24, 0xffffffff); 417c0132f60SStefan Roese } else { 418c0132f60SStefan Roese start_lane = lane; 419c0132f60SStefan Roese end_lane = lane + 1; 420c0132f60SStefan Roese 421c0132f60SStefan Roese /* 422c0132f60SStefan Roese * Release from PIPE soft reset 423c0132f60SStefan Roese * for PCIe by4 or by2 - release from soft reset 424c0132f60SStefan Roese * all lanes 425c0132f60SStefan Roese */ 426c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_RST_CLK_CTRL_REG, 427c0132f60SStefan Roese 0x0 << HPIPE_RST_CLK_CTRL_PIPE_RST_OFFSET, 428c0132f60SStefan Roese HPIPE_RST_CLK_CTRL_PIPE_RST_MASK); 429c0132f60SStefan Roese } 430c0132f60SStefan Roese 431c0132f60SStefan Roese 432c0132f60SStefan Roese if (pcie_width != 1) { 433c0132f60SStefan Roese /* disable writing to all lanes with one write */ 434c0132f60SStefan Roese reg_set(comphy_base + COMMON_PHY_SD_CTRL1, 435c0132f60SStefan Roese 0x3210 << 436c0132f60SStefan Roese COMMON_PHY_SD_CTRL1_COMPHY_0_4_PORT_OFFSET, 437c0132f60SStefan Roese COMMON_PHY_SD_CTRL1_COMPHY_0_4_PORT_MASK); 438c0132f60SStefan Roese } 439c0132f60SStefan Roese 440c0132f60SStefan Roese debug("stage: Check PLL\n"); 441c0132f60SStefan Roese /* Read lane status */ 442c0132f60SStefan Roese for (i = start_lane; i < end_lane; i++) { 443c0132f60SStefan Roese addr = HPIPE_ADDR(hpipe_base, i) + 444c0132f60SStefan Roese HPIPE_LANE_STATUS1_REG; 445c0132f60SStefan Roese data = HPIPE_LANE_STATUS1_PCLK_EN_MASK; 446c0132f60SStefan Roese mask = data; 447c0132f60SStefan Roese data = polling_with_timeout(addr, data, mask, 15000); 448c0132f60SStefan Roese if (data != 0) { 449c0132f60SStefan Roese debug("Read from reg = %p - value = 0x%x\n", 450c0132f60SStefan Roese hpipe_addr + HPIPE_LANE_STATUS1_REG, 451c0132f60SStefan Roese data); 452c0132f60SStefan Roese error("HPIPE_LANE_STATUS1_PCLK_EN_MASK is 0\n"); 453c0132f60SStefan Roese ret = 0; 454c0132f60SStefan Roese } 455c0132f60SStefan Roese } 456c0132f60SStefan Roese } 457c0132f60SStefan Roese 458c0132f60SStefan Roese debug_exit(); 459c0132f60SStefan Roese return ret; 460c0132f60SStefan Roese } 461c0132f60SStefan Roese 462c0132f60SStefan Roese static int comphy_usb3_power_up(u32 lane, void __iomem *hpipe_base, 463c0132f60SStefan Roese void __iomem *comphy_base) 464c0132f60SStefan Roese { 465c0132f60SStefan Roese u32 mask, data, ret = 1; 466c0132f60SStefan Roese void __iomem *hpipe_addr = HPIPE_ADDR(hpipe_base, lane); 467c0132f60SStefan Roese void __iomem *comphy_addr = COMPHY_ADDR(comphy_base, lane); 468c0132f60SStefan Roese void __iomem *addr; 469c0132f60SStefan Roese 470c0132f60SStefan Roese debug_enter(); 471c0132f60SStefan Roese debug("stage: RFU configurations - hard reset comphy\n"); 472c0132f60SStefan Roese /* RFU configurations - hard reset comphy */ 473c0132f60SStefan Roese mask = COMMON_PHY_CFG1_PWR_UP_MASK; 474c0132f60SStefan Roese data = 0x1 << COMMON_PHY_CFG1_PWR_UP_OFFSET; 475c0132f60SStefan Roese mask |= COMMON_PHY_CFG1_PIPE_SELECT_MASK; 476c0132f60SStefan Roese data |= 0x1 << COMMON_PHY_CFG1_PIPE_SELECT_OFFSET; 477c0132f60SStefan Roese mask |= COMMON_PHY_CFG1_PWR_ON_RESET_MASK; 478c0132f60SStefan Roese data |= 0x0 << COMMON_PHY_CFG1_PWR_ON_RESET_OFFSET; 479c0132f60SStefan Roese mask |= COMMON_PHY_CFG1_CORE_RSTN_MASK; 480c0132f60SStefan Roese data |= 0x0 << COMMON_PHY_CFG1_CORE_RSTN_OFFSET; 481c0132f60SStefan Roese mask |= COMMON_PHY_PHY_MODE_MASK; 482c0132f60SStefan Roese data |= 0x1 << COMMON_PHY_PHY_MODE_OFFSET; 483c0132f60SStefan Roese reg_set(comphy_addr + COMMON_PHY_CFG1_REG, data, mask); 484c0132f60SStefan Roese 485c0132f60SStefan Roese /* release from hard reset */ 486c0132f60SStefan Roese mask = COMMON_PHY_CFG1_PWR_ON_RESET_MASK; 487c0132f60SStefan Roese data = 0x1 << COMMON_PHY_CFG1_PWR_ON_RESET_OFFSET; 488c0132f60SStefan Roese mask |= COMMON_PHY_CFG1_CORE_RSTN_MASK; 489c0132f60SStefan Roese data |= 0x1 << COMMON_PHY_CFG1_CORE_RSTN_OFFSET; 490c0132f60SStefan Roese reg_set(comphy_addr + COMMON_PHY_CFG1_REG, data, mask); 491c0132f60SStefan Roese 492c0132f60SStefan Roese /* Wait 1ms - until band gap and ref clock ready */ 493c0132f60SStefan Roese mdelay(1); 494c0132f60SStefan Roese 495c0132f60SStefan Roese /* Start comphy Configuration */ 496c0132f60SStefan Roese debug("stage: Comphy configuration\n"); 497c0132f60SStefan Roese /* Set PIPE soft reset */ 498c0132f60SStefan Roese mask = HPIPE_RST_CLK_CTRL_PIPE_RST_MASK; 499c0132f60SStefan Roese data = 0x1 << HPIPE_RST_CLK_CTRL_PIPE_RST_OFFSET; 500c0132f60SStefan Roese /* Set PHY datapath width mode for V0 */ 501c0132f60SStefan Roese mask |= HPIPE_RST_CLK_CTRL_FIXED_PCLK_MASK; 502c0132f60SStefan Roese data |= 0x0 << HPIPE_RST_CLK_CTRL_FIXED_PCLK_OFFSET; 503c0132f60SStefan Roese /* Set Data bus width USB mode for V0 */ 504c0132f60SStefan Roese mask |= HPIPE_RST_CLK_CTRL_PIPE_WIDTH_MASK; 505c0132f60SStefan Roese data |= 0x0 << HPIPE_RST_CLK_CTRL_PIPE_WIDTH_OFFSET; 506c0132f60SStefan Roese /* Set CORE_CLK output frequency for 250Mhz */ 507c0132f60SStefan Roese mask |= HPIPE_RST_CLK_CTRL_CORE_FREQ_SEL_MASK; 508c0132f60SStefan Roese data |= 0x0 << HPIPE_RST_CLK_CTRL_CORE_FREQ_SEL_OFFSET; 509c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_RST_CLK_CTRL_REG, data, mask); 510c0132f60SStefan Roese /* Set PLL ready delay for 0x2 */ 511c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_CLK_SRC_LO_REG, 512c0132f60SStefan Roese 0x2 << HPIPE_CLK_SRC_LO_PLL_RDY_DL_OFFSET, 513c0132f60SStefan Roese HPIPE_CLK_SRC_LO_PLL_RDY_DL_MASK); 514c0132f60SStefan Roese /* Set reference clock to come from group 1 - 25Mhz */ 515c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_MISC_REG, 516c0132f60SStefan Roese 0x0 << HPIPE_MISC_REFCLK_SEL_OFFSET, 517c0132f60SStefan Roese HPIPE_MISC_REFCLK_SEL_MASK); 518c0132f60SStefan Roese /* Set reference frequcency select - 0x2 */ 519c0132f60SStefan Roese mask = HPIPE_PWR_PLL_REF_FREQ_MASK; 520c0132f60SStefan Roese data = 0x2 << HPIPE_PWR_PLL_REF_FREQ_OFFSET; 521c0132f60SStefan Roese /* Set PHY mode to USB - 0x5 */ 522c0132f60SStefan Roese mask |= HPIPE_PWR_PLL_PHY_MODE_MASK; 523c0132f60SStefan Roese data |= 0x5 << HPIPE_PWR_PLL_PHY_MODE_OFFSET; 524c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_PWR_PLL_REG, data, mask); 525c0132f60SStefan Roese /* Set the amount of time spent in the LoZ state - set for 0x7 */ 526c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_GLOBAL_PM_CTRL, 527c0132f60SStefan Roese 0x7 << HPIPE_GLOBAL_PM_RXDLOZ_WAIT_OFFSET, 528c0132f60SStefan Roese HPIPE_GLOBAL_PM_RXDLOZ_WAIT_MASK); 529c0132f60SStefan Roese /* Set max PHY generation setting - 5Gbps */ 530c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_INTERFACE_REG, 531c0132f60SStefan Roese 0x1 << HPIPE_INTERFACE_GEN_MAX_OFFSET, 532c0132f60SStefan Roese HPIPE_INTERFACE_GEN_MAX_MASK); 533c0132f60SStefan Roese /* Set select data width 20Bit (SEL_BITS[2:0]) */ 534c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_LOOPBACK_REG, 535c0132f60SStefan Roese 0x1 << HPIPE_LOOPBACK_SEL_OFFSET, 536c0132f60SStefan Roese HPIPE_LOOPBACK_SEL_MASK); 537c0132f60SStefan Roese /* select de-emphasize 3.5db */ 538c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_LANE_CONFIG0_REG, 539c0132f60SStefan Roese 0x1 << HPIPE_LANE_CONFIG0_TXDEEMPH0_OFFSET, 540c0132f60SStefan Roese HPIPE_LANE_CONFIG0_TXDEEMPH0_MASK); 541c0132f60SStefan Roese /* override tx margining from the MAC */ 542c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_TST_MODE_CTRL_REG, 543c0132f60SStefan Roese 0x1 << HPIPE_TST_MODE_CTRL_MODE_MARGIN_OFFSET, 544c0132f60SStefan Roese HPIPE_TST_MODE_CTRL_MODE_MARGIN_MASK); 545c0132f60SStefan Roese 546c0132f60SStefan Roese /* Start analog paramters from ETP(HW) */ 547c0132f60SStefan Roese debug("stage: Analog paramters from ETP(HW)\n"); 548c0132f60SStefan Roese /* Set Pin DFE_PAT_DIS -> Bit[1]: PIN_DFE_PAT_DIS = 0x0 */ 549c0132f60SStefan Roese mask = HPIPE_LANE_CFG4_DFE_CTRL_MASK; 550c0132f60SStefan Roese data = 0x1 << HPIPE_LANE_CFG4_DFE_CTRL_OFFSET; 551c0132f60SStefan Roese /* Set Override PHY DFE control pins for 0x1 */ 552c0132f60SStefan Roese mask |= HPIPE_LANE_CFG4_DFE_OVER_MASK; 553c0132f60SStefan Roese data |= 0x1 << HPIPE_LANE_CFG4_DFE_OVER_OFFSET; 554c0132f60SStefan Roese /* Set Spread Spectrum Clock Enable fot 0x1 */ 555c0132f60SStefan Roese mask |= HPIPE_LANE_CFG4_SSC_CTRL_MASK; 556c0132f60SStefan Roese data |= 0x1 << HPIPE_LANE_CFG4_SSC_CTRL_OFFSET; 557c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_LANE_CFG4_REG, data, mask); 558c0132f60SStefan Roese /* End of analog parameters */ 559c0132f60SStefan Roese 560c0132f60SStefan Roese debug("stage: Comphy power up\n"); 561c0132f60SStefan Roese /* Release from PIPE soft reset */ 562c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_RST_CLK_CTRL_REG, 563c0132f60SStefan Roese 0x0 << HPIPE_RST_CLK_CTRL_PIPE_RST_OFFSET, 564c0132f60SStefan Roese HPIPE_RST_CLK_CTRL_PIPE_RST_MASK); 565c0132f60SStefan Roese 566c0132f60SStefan Roese /* wait 15ms - for comphy calibration done */ 567c0132f60SStefan Roese debug("stage: Check PLL\n"); 568c0132f60SStefan Roese /* Read lane status */ 569c0132f60SStefan Roese addr = hpipe_addr + HPIPE_LANE_STATUS1_REG; 570c0132f60SStefan Roese data = HPIPE_LANE_STATUS1_PCLK_EN_MASK; 571c0132f60SStefan Roese mask = data; 572c0132f60SStefan Roese data = polling_with_timeout(addr, data, mask, 15000); 573c0132f60SStefan Roese if (data != 0) { 574c0132f60SStefan Roese debug("Read from reg = %p - value = 0x%x\n", 575c0132f60SStefan Roese hpipe_addr + HPIPE_LANE_STATUS1_REG, data); 576c0132f60SStefan Roese error("HPIPE_LANE_STATUS1_PCLK_EN_MASK is 0\n"); 577c0132f60SStefan Roese ret = 0; 578c0132f60SStefan Roese } 579c0132f60SStefan Roese 580c0132f60SStefan Roese debug_exit(); 581c0132f60SStefan Roese return ret; 582c0132f60SStefan Roese } 583c0132f60SStefan Roese 584c0132f60SStefan Roese static int comphy_sata_power_up(u32 lane, void __iomem *hpipe_base, 585c0132f60SStefan Roese void __iomem *comphy_base, int comphy_index) 586c0132f60SStefan Roese { 587c0132f60SStefan Roese u32 mask, data, i, ret = 1; 588c0132f60SStefan Roese void __iomem *hpipe_addr = HPIPE_ADDR(hpipe_base, lane); 589c0132f60SStefan Roese void __iomem *sd_ip_addr = SD_ADDR(hpipe_base, lane); 590c0132f60SStefan Roese void __iomem *comphy_addr = COMPHY_ADDR(comphy_base, lane); 591c0132f60SStefan Roese void __iomem *addr; 592c0132f60SStefan Roese void __iomem *sata_base = NULL; 593c0132f60SStefan Roese int sata_node = -1; /* Set to -1 in order to read the first sata node */ 594c0132f60SStefan Roese 595c0132f60SStefan Roese debug_enter(); 596c0132f60SStefan Roese 597c0132f60SStefan Roese /* 598c0132f60SStefan Roese * Assumption - each CP has only one SATA controller 599c0132f60SStefan Roese * Calling fdt_node_offset_by_compatible first time (with sata_node = -1 600c0132f60SStefan Roese * will return the first node always. 601c0132f60SStefan Roese * In order to parse each CPs SATA node, fdt_node_offset_by_compatible 602c0132f60SStefan Roese * must be called again (according to the CP id) 603c0132f60SStefan Roese */ 604c0132f60SStefan Roese for (i = 0; i < (comphy_index + 1); i++) 605c0132f60SStefan Roese sata_node = fdt_node_offset_by_compatible( 606c0132f60SStefan Roese gd->fdt_blob, sata_node, "marvell,armada-8k-ahci"); 607c0132f60SStefan Roese 608c0132f60SStefan Roese if (sata_node == 0) { 609c0132f60SStefan Roese error("SATA node not found in FDT\n"); 610c0132f60SStefan Roese return 0; 611c0132f60SStefan Roese } 612c0132f60SStefan Roese 613c0132f60SStefan Roese sata_base = (void __iomem *)fdtdec_get_addr_size_auto_noparent( 614c0132f60SStefan Roese gd->fdt_blob, sata_node, "reg", 0, NULL, true); 615c0132f60SStefan Roese if (sata_base == NULL) { 616c0132f60SStefan Roese error("SATA address not found in FDT\n"); 617c0132f60SStefan Roese return 0; 618c0132f60SStefan Roese } 619c0132f60SStefan Roese 620c0132f60SStefan Roese debug("SATA address found in FDT %p\n", sata_base); 621c0132f60SStefan Roese 622c0132f60SStefan Roese debug("stage: MAC configuration - power down comphy\n"); 623c0132f60SStefan Roese /* 624c0132f60SStefan Roese * MAC configuration powe down comphy use indirect address for 625c0132f60SStefan Roese * vendor spesific SATA control register 626c0132f60SStefan Roese */ 627c0132f60SStefan Roese reg_set(sata_base + SATA3_VENDOR_ADDRESS, 628c0132f60SStefan Roese SATA_CONTROL_REG << SATA3_VENDOR_ADDR_OFSSET, 629c0132f60SStefan Roese SATA3_VENDOR_ADDR_MASK); 630c0132f60SStefan Roese /* SATA 0 power down */ 631c0132f60SStefan Roese mask = SATA3_CTRL_SATA0_PD_MASK; 632c0132f60SStefan Roese data = 0x1 << SATA3_CTRL_SATA0_PD_OFFSET; 633c0132f60SStefan Roese /* SATA 1 power down */ 634c0132f60SStefan Roese mask |= SATA3_CTRL_SATA1_PD_MASK; 635c0132f60SStefan Roese data |= 0x1 << SATA3_CTRL_SATA1_PD_OFFSET; 636c0132f60SStefan Roese /* SATA SSU disable */ 637c0132f60SStefan Roese mask |= SATA3_CTRL_SATA1_ENABLE_MASK; 638c0132f60SStefan Roese data |= 0x0 << SATA3_CTRL_SATA1_ENABLE_OFFSET; 639c0132f60SStefan Roese /* SATA port 1 disable */ 640c0132f60SStefan Roese mask |= SATA3_CTRL_SATA_SSU_MASK; 641c0132f60SStefan Roese data |= 0x0 << SATA3_CTRL_SATA_SSU_OFFSET; 642c0132f60SStefan Roese reg_set(sata_base + SATA3_VENDOR_DATA, data, mask); 643c0132f60SStefan Roese 644c0132f60SStefan Roese debug("stage: RFU configurations - hard reset comphy\n"); 645c0132f60SStefan Roese /* RFU configurations - hard reset comphy */ 646c0132f60SStefan Roese mask = COMMON_PHY_CFG1_PWR_UP_MASK; 647c0132f60SStefan Roese data = 0x1 << COMMON_PHY_CFG1_PWR_UP_OFFSET; 648c0132f60SStefan Roese mask |= COMMON_PHY_CFG1_PIPE_SELECT_MASK; 649c0132f60SStefan Roese data |= 0x0 << COMMON_PHY_CFG1_PIPE_SELECT_OFFSET; 650c0132f60SStefan Roese mask |= COMMON_PHY_CFG1_PWR_ON_RESET_MASK; 651c0132f60SStefan Roese data |= 0x0 << COMMON_PHY_CFG1_PWR_ON_RESET_OFFSET; 652c0132f60SStefan Roese mask |= COMMON_PHY_CFG1_CORE_RSTN_MASK; 653c0132f60SStefan Roese data |= 0x0 << COMMON_PHY_CFG1_CORE_RSTN_OFFSET; 654c0132f60SStefan Roese reg_set(comphy_addr + COMMON_PHY_CFG1_REG, data, mask); 655c0132f60SStefan Roese 656c0132f60SStefan Roese /* Set select data width 40Bit - SATA mode only */ 657c0132f60SStefan Roese reg_set(comphy_addr + COMMON_PHY_CFG6_REG, 658c0132f60SStefan Roese 0x1 << COMMON_PHY_CFG6_IF_40_SEL_OFFSET, 659c0132f60SStefan Roese COMMON_PHY_CFG6_IF_40_SEL_MASK); 660c0132f60SStefan Roese 661c0132f60SStefan Roese /* release from hard reset in SD external */ 662c0132f60SStefan Roese mask = SD_EXTERNAL_CONFIG1_RESET_IN_MASK; 663c0132f60SStefan Roese data = 0x1 << SD_EXTERNAL_CONFIG1_RESET_IN_OFFSET; 664c0132f60SStefan Roese mask |= SD_EXTERNAL_CONFIG1_RESET_CORE_MASK; 665c0132f60SStefan Roese data |= 0x1 << SD_EXTERNAL_CONFIG1_RESET_CORE_OFFSET; 666c0132f60SStefan Roese reg_set(sd_ip_addr + SD_EXTERNAL_CONFIG1_REG, data, mask); 667c0132f60SStefan Roese 668c0132f60SStefan Roese /* Wait 1ms - until band gap and ref clock ready */ 669c0132f60SStefan Roese mdelay(1); 670c0132f60SStefan Roese 671c0132f60SStefan Roese debug("stage: Comphy configuration\n"); 672c0132f60SStefan Roese /* Start comphy Configuration */ 673c0132f60SStefan Roese /* Set reference clock to comes from group 1 - choose 25Mhz */ 674c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_MISC_REG, 675c0132f60SStefan Roese 0x0 << HPIPE_MISC_REFCLK_SEL_OFFSET, 676c0132f60SStefan Roese HPIPE_MISC_REFCLK_SEL_MASK); 677c0132f60SStefan Roese /* Reference frequency select set 1 (for SATA = 25Mhz) */ 678c0132f60SStefan Roese mask = HPIPE_PWR_PLL_REF_FREQ_MASK; 679c0132f60SStefan Roese data = 0x1 << HPIPE_PWR_PLL_REF_FREQ_OFFSET; 680c0132f60SStefan Roese /* PHY mode select (set SATA = 0x0 */ 681c0132f60SStefan Roese mask |= HPIPE_PWR_PLL_PHY_MODE_MASK; 682c0132f60SStefan Roese data |= 0x0 << HPIPE_PWR_PLL_PHY_MODE_OFFSET; 683c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_PWR_PLL_REG, data, mask); 684c0132f60SStefan Roese /* Set max PHY generation setting - 6Gbps */ 685c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_INTERFACE_REG, 686c0132f60SStefan Roese 0x2 << HPIPE_INTERFACE_GEN_MAX_OFFSET, 687c0132f60SStefan Roese HPIPE_INTERFACE_GEN_MAX_MASK); 688c0132f60SStefan Roese /* Set select data width 40Bit (SEL_BITS[2:0]) */ 689c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_LOOPBACK_REG, 690c0132f60SStefan Roese 0x2 << HPIPE_LOOPBACK_SEL_OFFSET, HPIPE_LOOPBACK_SEL_MASK); 691c0132f60SStefan Roese 692c0132f60SStefan Roese debug("stage: Analog paramters from ETP(HW)\n"); 693c0132f60SStefan Roese /* 694c0132f60SStefan Roese * TODO: Set analog paramters from ETP(HW) - for now use the 695c0132f60SStefan Roese * default datas 696c0132f60SStefan Roese */ 697c0132f60SStefan Roese 698c0132f60SStefan Roese /* DFE reset sequence */ 699c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_PWR_CTR_REG, 700c0132f60SStefan Roese 0x1 << HPIPE_PWR_CTR_RST_DFE_OFFSET, 701c0132f60SStefan Roese HPIPE_PWR_CTR_RST_DFE_MASK); 702c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_PWR_CTR_REG, 703c0132f60SStefan Roese 0x0 << HPIPE_PWR_CTR_RST_DFE_OFFSET, 704c0132f60SStefan Roese HPIPE_PWR_CTR_RST_DFE_MASK); 705c0132f60SStefan Roese /* SW reset for interupt logic */ 706c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_PWR_CTR_REG, 707c0132f60SStefan Roese 0x1 << HPIPE_PWR_CTR_SFT_RST_OFFSET, 708c0132f60SStefan Roese HPIPE_PWR_CTR_SFT_RST_MASK); 709c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_PWR_CTR_REG, 710c0132f60SStefan Roese 0x0 << HPIPE_PWR_CTR_SFT_RST_OFFSET, 711c0132f60SStefan Roese HPIPE_PWR_CTR_SFT_RST_MASK); 712c0132f60SStefan Roese 713c0132f60SStefan Roese debug("stage: Comphy power up\n"); 714c0132f60SStefan Roese /* 715c0132f60SStefan Roese * MAC configuration power up comphy - power up PLL/TX/RX 716c0132f60SStefan Roese * use indirect address for vendor spesific SATA control register 717c0132f60SStefan Roese */ 718c0132f60SStefan Roese reg_set(sata_base + SATA3_VENDOR_ADDRESS, 719c0132f60SStefan Roese SATA_CONTROL_REG << SATA3_VENDOR_ADDR_OFSSET, 720c0132f60SStefan Roese SATA3_VENDOR_ADDR_MASK); 721c0132f60SStefan Roese /* SATA 0 power up */ 722c0132f60SStefan Roese mask = SATA3_CTRL_SATA0_PD_MASK; 723c0132f60SStefan Roese data = 0x0 << SATA3_CTRL_SATA0_PD_OFFSET; 724c0132f60SStefan Roese /* SATA 1 power up */ 725c0132f60SStefan Roese mask |= SATA3_CTRL_SATA1_PD_MASK; 726c0132f60SStefan Roese data |= 0x0 << SATA3_CTRL_SATA1_PD_OFFSET; 727c0132f60SStefan Roese /* SATA SSU enable */ 728c0132f60SStefan Roese mask |= SATA3_CTRL_SATA1_ENABLE_MASK; 729c0132f60SStefan Roese data |= 0x1 << SATA3_CTRL_SATA1_ENABLE_OFFSET; 730c0132f60SStefan Roese /* SATA port 1 enable */ 731c0132f60SStefan Roese mask |= SATA3_CTRL_SATA_SSU_MASK; 732c0132f60SStefan Roese data |= 0x1 << SATA3_CTRL_SATA_SSU_OFFSET; 733c0132f60SStefan Roese reg_set(sata_base + SATA3_VENDOR_DATA, data, mask); 734c0132f60SStefan Roese 735c0132f60SStefan Roese /* MBUS request size and interface select register */ 736c0132f60SStefan Roese reg_set(sata_base + SATA3_VENDOR_ADDRESS, 737c0132f60SStefan Roese SATA_MBUS_SIZE_SELECT_REG << SATA3_VENDOR_ADDR_OFSSET, 738c0132f60SStefan Roese SATA3_VENDOR_ADDR_MASK); 739c0132f60SStefan Roese /* Mbus regret enable */ 740c0132f60SStefan Roese reg_set(sata_base + SATA3_VENDOR_DATA, 741c0132f60SStefan Roese 0x1 << SATA_MBUS_REGRET_EN_OFFSET, SATA_MBUS_REGRET_EN_MASK); 742c0132f60SStefan Roese 743c0132f60SStefan Roese debug("stage: Check PLL\n"); 744c0132f60SStefan Roese 745c0132f60SStefan Roese addr = sd_ip_addr + SD_EXTERNAL_STATUS0_REG; 746c0132f60SStefan Roese data = SD_EXTERNAL_STATUS0_PLL_TX_MASK & 747c0132f60SStefan Roese SD_EXTERNAL_STATUS0_PLL_RX_MASK; 748c0132f60SStefan Roese mask = data; 749c0132f60SStefan Roese data = polling_with_timeout(addr, data, mask, 15000); 750c0132f60SStefan Roese if (data != 0) { 751c0132f60SStefan Roese debug("Read from reg = %p - value = 0x%x\n", 752c0132f60SStefan Roese hpipe_addr + HPIPE_LANE_STATUS1_REG, data); 753c0132f60SStefan Roese error("SD_EXTERNAL_STATUS0_PLL_TX is %d, SD_EXTERNAL_STATUS0_PLL_RX is %d\n", 754c0132f60SStefan Roese (data & SD_EXTERNAL_STATUS0_PLL_TX_MASK), 755c0132f60SStefan Roese (data & SD_EXTERNAL_STATUS0_PLL_RX_MASK)); 756c0132f60SStefan Roese ret = 0; 757c0132f60SStefan Roese } 758c0132f60SStefan Roese 759c0132f60SStefan Roese debug_exit(); 760c0132f60SStefan Roese return ret; 761c0132f60SStefan Roese } 762c0132f60SStefan Roese 763c0132f60SStefan Roese static int comphy_sgmii_power_up(u32 lane, u32 sgmii_speed, 764c0132f60SStefan Roese void __iomem *hpipe_base, 765c0132f60SStefan Roese void __iomem *comphy_base) 766c0132f60SStefan Roese { 767c0132f60SStefan Roese u32 mask, data, ret = 1; 768c0132f60SStefan Roese void __iomem *hpipe_addr = HPIPE_ADDR(hpipe_base, lane); 769c0132f60SStefan Roese void __iomem *sd_ip_addr = SD_ADDR(hpipe_base, lane); 770c0132f60SStefan Roese void __iomem *comphy_addr = COMPHY_ADDR(comphy_base, lane); 771c0132f60SStefan Roese void __iomem *addr; 772c0132f60SStefan Roese 773c0132f60SStefan Roese debug_enter(); 774c0132f60SStefan Roese debug("stage: RFU configurations - hard reset comphy\n"); 775c0132f60SStefan Roese /* RFU configurations - hard reset comphy */ 776c0132f60SStefan Roese mask = COMMON_PHY_CFG1_PWR_UP_MASK; 777c0132f60SStefan Roese data = 0x1 << COMMON_PHY_CFG1_PWR_UP_OFFSET; 778c0132f60SStefan Roese mask |= COMMON_PHY_CFG1_PIPE_SELECT_MASK; 779c0132f60SStefan Roese data |= 0x0 << COMMON_PHY_CFG1_PIPE_SELECT_OFFSET; 780c0132f60SStefan Roese reg_set(comphy_addr + COMMON_PHY_CFG1_REG, data, mask); 781c0132f60SStefan Roese 782c0132f60SStefan Roese /* Select Baud Rate of Comphy And PD_PLL/Tx/Rx */ 783c0132f60SStefan Roese mask = SD_EXTERNAL_CONFIG0_SD_PU_PLL_MASK; 784c0132f60SStefan Roese data = 0x0 << SD_EXTERNAL_CONFIG0_SD_PU_PLL_OFFSET; 785c0132f60SStefan Roese mask |= SD_EXTERNAL_CONFIG0_SD_PHY_GEN_RX_MASK; 786c0132f60SStefan Roese mask |= SD_EXTERNAL_CONFIG0_SD_PHY_GEN_TX_MASK; 787c0132f60SStefan Roese if (sgmii_speed == PHY_SPEED_1_25G) { 788c0132f60SStefan Roese data |= 0x6 << SD_EXTERNAL_CONFIG0_SD_PHY_GEN_RX_OFFSET; 789c0132f60SStefan Roese data |= 0x6 << SD_EXTERNAL_CONFIG0_SD_PHY_GEN_TX_OFFSET; 790c0132f60SStefan Roese } else { 791c0132f60SStefan Roese /* 3.125G */ 792c0132f60SStefan Roese data |= 0x8 << SD_EXTERNAL_CONFIG0_SD_PHY_GEN_RX_OFFSET; 793c0132f60SStefan Roese data |= 0x8 << SD_EXTERNAL_CONFIG0_SD_PHY_GEN_TX_OFFSET; 794c0132f60SStefan Roese } 795c0132f60SStefan Roese mask |= SD_EXTERNAL_CONFIG0_SD_PU_RX_MASK; 796c0132f60SStefan Roese data |= 0 << SD_EXTERNAL_CONFIG0_SD_PU_RX_OFFSET; 797c0132f60SStefan Roese mask |= SD_EXTERNAL_CONFIG0_SD_PU_TX_MASK; 798c0132f60SStefan Roese data |= 0 << SD_EXTERNAL_CONFIG0_SD_PU_TX_OFFSET; 799c0132f60SStefan Roese mask |= SD_EXTERNAL_CONFIG0_HALF_BUS_MODE_MASK; 800c0132f60SStefan Roese data |= 1 << SD_EXTERNAL_CONFIG0_HALF_BUS_MODE_OFFSET; 801c0132f60SStefan Roese reg_set(sd_ip_addr + SD_EXTERNAL_CONFIG0_REG, data, mask); 802c0132f60SStefan Roese 803c0132f60SStefan Roese /* release from hard reset */ 804c0132f60SStefan Roese mask = SD_EXTERNAL_CONFIG1_RESET_IN_MASK; 805c0132f60SStefan Roese data = 0x0 << SD_EXTERNAL_CONFIG1_RESET_IN_OFFSET; 806c0132f60SStefan Roese mask |= SD_EXTERNAL_CONFIG1_RESET_CORE_MASK; 807c0132f60SStefan Roese data |= 0x0 << SD_EXTERNAL_CONFIG1_RESET_CORE_OFFSET; 808c0132f60SStefan Roese mask |= SD_EXTERNAL_CONFIG1_RF_RESET_IN_MASK; 809c0132f60SStefan Roese data |= 0x0 << SD_EXTERNAL_CONFIG1_RF_RESET_IN_OFFSET; 810c0132f60SStefan Roese reg_set(sd_ip_addr + SD_EXTERNAL_CONFIG1_REG, data, mask); 811c0132f60SStefan Roese 812c0132f60SStefan Roese /* release from hard reset */ 813c0132f60SStefan Roese mask = SD_EXTERNAL_CONFIG1_RESET_IN_MASK; 814c0132f60SStefan Roese data = 0x1 << SD_EXTERNAL_CONFIG1_RESET_IN_OFFSET; 815c0132f60SStefan Roese mask |= SD_EXTERNAL_CONFIG1_RESET_CORE_MASK; 816c0132f60SStefan Roese data |= 0x1 << SD_EXTERNAL_CONFIG1_RESET_CORE_OFFSET; 817c0132f60SStefan Roese reg_set(sd_ip_addr + SD_EXTERNAL_CONFIG1_REG, data, mask); 818c0132f60SStefan Roese 819c0132f60SStefan Roese 820c0132f60SStefan Roese /* Wait 1ms - until band gap and ref clock ready */ 821c0132f60SStefan Roese mdelay(1); 822c0132f60SStefan Roese 823c0132f60SStefan Roese /* Start comphy Configuration */ 824c0132f60SStefan Roese debug("stage: Comphy configuration\n"); 825c0132f60SStefan Roese /* set reference clock */ 826c0132f60SStefan Roese mask = HPIPE_MISC_REFCLK_SEL_MASK; 827c0132f60SStefan Roese data = 0x0 << HPIPE_MISC_REFCLK_SEL_OFFSET; 828c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_MISC_REG, data, mask); 829c0132f60SStefan Roese /* Power and PLL Control */ 830c0132f60SStefan Roese mask = HPIPE_PWR_PLL_REF_FREQ_MASK; 831c0132f60SStefan Roese data = 0x1 << HPIPE_PWR_PLL_REF_FREQ_OFFSET; 832c0132f60SStefan Roese mask |= HPIPE_PWR_PLL_PHY_MODE_MASK; 833c0132f60SStefan Roese data |= 0x4 << HPIPE_PWR_PLL_PHY_MODE_OFFSET; 834c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_PWR_PLL_REG, data, mask); 835c0132f60SStefan Roese /* Loopback register */ 836c0132f60SStefan Roese mask = HPIPE_LOOPBACK_SEL_MASK; 837c0132f60SStefan Roese data = 0x1 << HPIPE_LOOPBACK_SEL_OFFSET; 838c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_LOOPBACK_REG, data, mask); 839c0132f60SStefan Roese /* rx control 1 */ 840c0132f60SStefan Roese mask = HPIPE_RX_CONTROL_1_RXCLK2X_SEL_MASK; 841c0132f60SStefan Roese data = 0x1 << HPIPE_RX_CONTROL_1_RXCLK2X_SEL_OFFSET; 842c0132f60SStefan Roese mask |= HPIPE_RX_CONTROL_1_CLK8T_EN_MASK; 843c0132f60SStefan Roese data |= 0x0 << HPIPE_RX_CONTROL_1_CLK8T_EN_OFFSET; 844c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_RX_CONTROL_1_REG, data, mask); 845c0132f60SStefan Roese /* DTL Control */ 846c0132f60SStefan Roese mask = HPIPE_PWR_CTR_DTL_FLOOP_EN_MASK; 847c0132f60SStefan Roese data = 0x0 << HPIPE_PWR_CTR_DTL_FLOOP_EN_OFFSET; 848c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_PWR_CTR_DTL_REG, data, mask); 849c0132f60SStefan Roese 850c0132f60SStefan Roese /* Set analog paramters from ETP(HW) - for now use the default datas */ 851c0132f60SStefan Roese debug("stage: Analog paramters from ETP(HW)\n"); 852c0132f60SStefan Roese 853c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_G1_SET_0_REG, 854c0132f60SStefan Roese 0x1 << HPIPE_G1_SET_0_G1_TX_EMPH1_OFFSET, 855c0132f60SStefan Roese HPIPE_G1_SET_0_G1_TX_EMPH1_MASK); 856c0132f60SStefan Roese 857c0132f60SStefan Roese debug("stage: RFU configurations- Power Up PLL,Tx,Rx\n"); 858c0132f60SStefan Roese /* SERDES External Configuration */ 859c0132f60SStefan Roese mask = SD_EXTERNAL_CONFIG0_SD_PU_PLL_MASK; 860c0132f60SStefan Roese data = 0x1 << SD_EXTERNAL_CONFIG0_SD_PU_PLL_OFFSET; 861c0132f60SStefan Roese mask |= SD_EXTERNAL_CONFIG0_SD_PU_RX_MASK; 862c0132f60SStefan Roese data |= 0x1 << SD_EXTERNAL_CONFIG0_SD_PU_RX_OFFSET; 863c0132f60SStefan Roese mask |= SD_EXTERNAL_CONFIG0_SD_PU_TX_MASK; 864c0132f60SStefan Roese data |= 0x1 << SD_EXTERNAL_CONFIG0_SD_PU_TX_OFFSET; 865c0132f60SStefan Roese reg_set(sd_ip_addr + SD_EXTERNAL_CONFIG0_REG, data, mask); 866c0132f60SStefan Roese 867c0132f60SStefan Roese /* check PLL rx & tx ready */ 868c0132f60SStefan Roese addr = sd_ip_addr + SD_EXTERNAL_STATUS0_REG; 869c0132f60SStefan Roese data = SD_EXTERNAL_STATUS0_PLL_RX_MASK | 870c0132f60SStefan Roese SD_EXTERNAL_STATUS0_PLL_TX_MASK; 871c0132f60SStefan Roese mask = data; 872c0132f60SStefan Roese data = polling_with_timeout(addr, data, mask, 15000); 873c0132f60SStefan Roese if (data != 0) { 874c0132f60SStefan Roese debug("Read from reg = %p - value = 0x%x\n", 875c0132f60SStefan Roese sd_ip_addr + SD_EXTERNAL_STATUS0_REG, data); 876c0132f60SStefan Roese error("SD_EXTERNAL_STATUS0_PLL_RX is %d, SD_EXTERNAL_STATUS0_PLL_TX is %d\n", 877c0132f60SStefan Roese (data & SD_EXTERNAL_STATUS0_PLL_RX_MASK), 878c0132f60SStefan Roese (data & SD_EXTERNAL_STATUS0_PLL_TX_MASK)); 879c0132f60SStefan Roese ret = 0; 880c0132f60SStefan Roese } 881c0132f60SStefan Roese 882c0132f60SStefan Roese /* RX init */ 883c0132f60SStefan Roese mask = SD_EXTERNAL_CONFIG1_RX_INIT_MASK; 884c0132f60SStefan Roese data = 0x1 << SD_EXTERNAL_CONFIG1_RX_INIT_OFFSET; 885c0132f60SStefan Roese reg_set(sd_ip_addr + SD_EXTERNAL_CONFIG1_REG, data, mask); 886c0132f60SStefan Roese 887c0132f60SStefan Roese /* check that RX init done */ 888c0132f60SStefan Roese addr = sd_ip_addr + SD_EXTERNAL_STATUS0_REG; 889c0132f60SStefan Roese data = SD_EXTERNAL_STATUS0_RX_INIT_MASK; 890c0132f60SStefan Roese mask = data; 891c0132f60SStefan Roese data = polling_with_timeout(addr, data, mask, 100); 892c0132f60SStefan Roese if (data != 0) { 893c0132f60SStefan Roese debug("Read from reg = %p - value = 0x%x\n", sd_ip_addr + SD_EXTERNAL_STATUS0_REG, data); 894c0132f60SStefan Roese error("SD_EXTERNAL_STATUS0_RX_INIT is 0\n"); 895c0132f60SStefan Roese ret = 0; 896c0132f60SStefan Roese } 897c0132f60SStefan Roese 898c0132f60SStefan Roese debug("stage: RF Reset\n"); 899c0132f60SStefan Roese /* RF Reset */ 900c0132f60SStefan Roese mask = SD_EXTERNAL_CONFIG1_RX_INIT_MASK; 901c0132f60SStefan Roese data = 0x0 << SD_EXTERNAL_CONFIG1_RX_INIT_OFFSET; 902c0132f60SStefan Roese mask |= SD_EXTERNAL_CONFIG1_RF_RESET_IN_MASK; 903c0132f60SStefan Roese data |= 0x1 << SD_EXTERNAL_CONFIG1_RF_RESET_IN_OFFSET; 904c0132f60SStefan Roese reg_set(sd_ip_addr + SD_EXTERNAL_CONFIG1_REG, data, mask); 905c0132f60SStefan Roese 906c0132f60SStefan Roese debug_exit(); 907c0132f60SStefan Roese return ret; 908c0132f60SStefan Roese } 909c0132f60SStefan Roese 910*cb686454SStefan Roese static int comphy_sfi_power_up(u32 lane, void __iomem *hpipe_base, 911c0132f60SStefan Roese void __iomem *comphy_base) 912c0132f60SStefan Roese { 913c0132f60SStefan Roese u32 mask, data, ret = 1; 914c0132f60SStefan Roese void __iomem *hpipe_addr = HPIPE_ADDR(hpipe_base, lane); 915c0132f60SStefan Roese void __iomem *sd_ip_addr = SD_ADDR(hpipe_base, lane); 916c0132f60SStefan Roese void __iomem *comphy_addr = COMPHY_ADDR(comphy_base, lane); 917c0132f60SStefan Roese void __iomem *addr; 918c0132f60SStefan Roese 919c0132f60SStefan Roese debug_enter(); 920c0132f60SStefan Roese debug("stage: RFU configurations - hard reset comphy\n"); 921c0132f60SStefan Roese /* RFU configurations - hard reset comphy */ 922c0132f60SStefan Roese mask = COMMON_PHY_CFG1_PWR_UP_MASK; 923c0132f60SStefan Roese data = 0x1 << COMMON_PHY_CFG1_PWR_UP_OFFSET; 924c0132f60SStefan Roese mask |= COMMON_PHY_CFG1_PIPE_SELECT_MASK; 925c0132f60SStefan Roese data |= 0x0 << COMMON_PHY_CFG1_PIPE_SELECT_OFFSET; 926c0132f60SStefan Roese reg_set(comphy_addr + COMMON_PHY_CFG1_REG, data, mask); 927c0132f60SStefan Roese 928c0132f60SStefan Roese /* Select Baud Rate of Comphy And PD_PLL/Tx/Rx */ 929c0132f60SStefan Roese mask = SD_EXTERNAL_CONFIG0_SD_PU_PLL_MASK; 930c0132f60SStefan Roese data = 0x0 << SD_EXTERNAL_CONFIG0_SD_PU_PLL_OFFSET; 931c0132f60SStefan Roese mask |= SD_EXTERNAL_CONFIG0_SD_PHY_GEN_RX_MASK; 932c0132f60SStefan Roese data |= 0xE << SD_EXTERNAL_CONFIG0_SD_PHY_GEN_RX_OFFSET; 933c0132f60SStefan Roese mask |= SD_EXTERNAL_CONFIG0_SD_PHY_GEN_TX_MASK; 934c0132f60SStefan Roese data |= 0xE << SD_EXTERNAL_CONFIG0_SD_PHY_GEN_TX_OFFSET; 935c0132f60SStefan Roese mask |= SD_EXTERNAL_CONFIG0_SD_PU_RX_MASK; 936c0132f60SStefan Roese data |= 0 << SD_EXTERNAL_CONFIG0_SD_PU_RX_OFFSET; 937c0132f60SStefan Roese mask |= SD_EXTERNAL_CONFIG0_SD_PU_TX_MASK; 938c0132f60SStefan Roese data |= 0 << SD_EXTERNAL_CONFIG0_SD_PU_TX_OFFSET; 939c0132f60SStefan Roese mask |= SD_EXTERNAL_CONFIG0_HALF_BUS_MODE_MASK; 940c0132f60SStefan Roese data |= 0 << SD_EXTERNAL_CONFIG0_HALF_BUS_MODE_OFFSET; 941c0132f60SStefan Roese reg_set(sd_ip_addr + SD_EXTERNAL_CONFIG0_REG, data, mask); 942c0132f60SStefan Roese 943c0132f60SStefan Roese /* release from hard reset */ 944c0132f60SStefan Roese mask = SD_EXTERNAL_CONFIG1_RESET_IN_MASK; 945c0132f60SStefan Roese data = 0x0 << SD_EXTERNAL_CONFIG1_RESET_IN_OFFSET; 946c0132f60SStefan Roese mask |= SD_EXTERNAL_CONFIG1_RESET_CORE_MASK; 947c0132f60SStefan Roese data |= 0x0 << SD_EXTERNAL_CONFIG1_RESET_CORE_OFFSET; 948c0132f60SStefan Roese mask |= SD_EXTERNAL_CONFIG1_RF_RESET_IN_MASK; 949c0132f60SStefan Roese data |= 0x0 << SD_EXTERNAL_CONFIG1_RF_RESET_IN_OFFSET; 950c0132f60SStefan Roese reg_set(sd_ip_addr + SD_EXTERNAL_CONFIG1_REG, data, mask); 951c0132f60SStefan Roese 952c0132f60SStefan Roese mask = SD_EXTERNAL_CONFIG1_RESET_IN_MASK; 953c0132f60SStefan Roese data = 0x1 << SD_EXTERNAL_CONFIG1_RESET_IN_OFFSET; 954c0132f60SStefan Roese mask |= SD_EXTERNAL_CONFIG1_RESET_CORE_MASK; 955c0132f60SStefan Roese data |= 0x1 << SD_EXTERNAL_CONFIG1_RESET_CORE_OFFSET; 956c0132f60SStefan Roese reg_set(sd_ip_addr + SD_EXTERNAL_CONFIG1_REG, data, mask); 957c0132f60SStefan Roese 958c0132f60SStefan Roese 959c0132f60SStefan Roese /* Wait 1ms - until band gap and ref clock ready */ 960c0132f60SStefan Roese mdelay(1); 961c0132f60SStefan Roese 962c0132f60SStefan Roese /* Start comphy Configuration */ 963c0132f60SStefan Roese debug("stage: Comphy configuration\n"); 964c0132f60SStefan Roese /* set reference clock */ 965c0132f60SStefan Roese mask = HPIPE_MISC_ICP_FORCE_MASK; 966c0132f60SStefan Roese data = 0x1 << HPIPE_MISC_ICP_FORCE_OFFSET; 967c0132f60SStefan Roese mask |= HPIPE_MISC_REFCLK_SEL_MASK; 968c0132f60SStefan Roese data |= 0x0 << HPIPE_MISC_REFCLK_SEL_OFFSET; 969c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_MISC_REG, data, mask); 970c0132f60SStefan Roese /* Power and PLL Control */ 971c0132f60SStefan Roese mask = HPIPE_PWR_PLL_REF_FREQ_MASK; 972c0132f60SStefan Roese data = 0x1 << HPIPE_PWR_PLL_REF_FREQ_OFFSET; 973c0132f60SStefan Roese mask |= HPIPE_PWR_PLL_PHY_MODE_MASK; 974c0132f60SStefan Roese data |= 0x4 << HPIPE_PWR_PLL_PHY_MODE_OFFSET; 975c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_PWR_PLL_REG, data, mask); 976c0132f60SStefan Roese /* Loopback register */ 977c0132f60SStefan Roese mask = HPIPE_LOOPBACK_SEL_MASK; 978c0132f60SStefan Roese data = 0x1 << HPIPE_LOOPBACK_SEL_OFFSET; 979c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_LOOPBACK_REG, data, mask); 980c0132f60SStefan Roese /* rx control 1 */ 981c0132f60SStefan Roese mask = HPIPE_RX_CONTROL_1_RXCLK2X_SEL_MASK; 982c0132f60SStefan Roese data = 0x1 << HPIPE_RX_CONTROL_1_RXCLK2X_SEL_OFFSET; 983c0132f60SStefan Roese mask |= HPIPE_RX_CONTROL_1_CLK8T_EN_MASK; 984c0132f60SStefan Roese data |= 0x1 << HPIPE_RX_CONTROL_1_CLK8T_EN_OFFSET; 985c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_RX_CONTROL_1_REG, data, mask); 986c0132f60SStefan Roese /* DTL Control */ 987c0132f60SStefan Roese mask = HPIPE_PWR_CTR_DTL_FLOOP_EN_MASK; 988c0132f60SStefan Roese data = 0x1 << HPIPE_PWR_CTR_DTL_FLOOP_EN_OFFSET; 989c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_PWR_CTR_DTL_REG, data, mask); 990c0132f60SStefan Roese 991c0132f60SStefan Roese /* Set analog paramters from ETP(HW) */ 992c0132f60SStefan Roese debug("stage: Analog paramters from ETP(HW)\n"); 993c0132f60SStefan Roese /* SERDES External Configuration 2 */ 994c0132f60SStefan Roese mask = SD_EXTERNAL_CONFIG2_PIN_DFE_EN_MASK; 995c0132f60SStefan Roese data = 0x1 << SD_EXTERNAL_CONFIG2_PIN_DFE_EN_OFFSET; 996c0132f60SStefan Roese reg_set(sd_ip_addr + SD_EXTERNAL_CONFIG2_REG, data, mask); 997c0132f60SStefan Roese /* 0x7-DFE Resolution control */ 998c0132f60SStefan Roese mask = HPIPE_DFE_RES_FORCE_MASK; 999c0132f60SStefan Roese data = 0x1 << HPIPE_DFE_RES_FORCE_OFFSET; 1000c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_DFE_REG0, data, mask); 1001c0132f60SStefan Roese /* 0xd-G1_Setting_0 */ 1002c0132f60SStefan Roese mask = HPIPE_G1_SET_0_G1_TX_AMP_MASK; 1003c0132f60SStefan Roese data = 0x1c << HPIPE_G1_SET_0_G1_TX_AMP_OFFSET; 1004c0132f60SStefan Roese mask |= HPIPE_G1_SET_0_G1_TX_EMPH1_MASK; 1005c0132f60SStefan Roese data |= 0xe << HPIPE_G1_SET_0_G1_TX_EMPH1_OFFSET; 1006c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_G1_SET_0_REG, data, mask); 1007c0132f60SStefan Roese /* Genration 1 setting 2 (G1_Setting_2) */ 1008c0132f60SStefan Roese mask = HPIPE_G1_SET_2_G1_TX_EMPH0_MASK; 1009c0132f60SStefan Roese data = 0x0 << HPIPE_G1_SET_2_G1_TX_EMPH0_OFFSET; 1010c0132f60SStefan Roese mask |= HPIPE_G1_SET_2_G1_TX_EMPH0_EN_MASK; 1011c0132f60SStefan Roese data |= 0x1 << HPIPE_G1_SET_2_G1_TX_EMPH0_EN_OFFSET; 1012c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_G1_SET_2_REG, data, mask); 1013c0132f60SStefan Roese /* Transmitter Slew Rate Control register (tx_reg1) */ 1014c0132f60SStefan Roese mask = HPIPE_TX_REG1_TX_EMPH_RES_MASK; 1015c0132f60SStefan Roese data = 0x3 << HPIPE_TX_REG1_TX_EMPH_RES_OFFSET; 1016c0132f60SStefan Roese mask |= HPIPE_TX_REG1_SLC_EN_MASK; 1017c0132f60SStefan Roese data |= 0x3f << HPIPE_TX_REG1_SLC_EN_OFFSET; 1018c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_TX_REG1_REG, data, mask); 1019c0132f60SStefan Roese /* Impedance Calibration Control register (cal_reg1) */ 1020c0132f60SStefan Roese mask = HPIPE_CAL_REG_1_EXT_TXIMP_MASK; 1021c0132f60SStefan Roese data = 0xe << HPIPE_CAL_REG_1_EXT_TXIMP_OFFSET; 1022c0132f60SStefan Roese mask |= HPIPE_CAL_REG_1_EXT_TXIMP_EN_MASK; 1023c0132f60SStefan Roese data |= 0x1 << HPIPE_CAL_REG_1_EXT_TXIMP_EN_OFFSET; 1024c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_CAL_REG1_REG, data, mask); 1025c0132f60SStefan Roese /* Generation 1 Setting 5 (g1_setting_5) */ 1026c0132f60SStefan Roese mask = HPIPE_G1_SETTING_5_G1_ICP_MASK; 1027c0132f60SStefan Roese data = 0 << HPIPE_CAL_REG_1_EXT_TXIMP_OFFSET; 1028c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_G1_SETTING_5_REG, data, mask); 1029c0132f60SStefan Roese /* 0xE-G1_Setting_1 */ 1030c0132f60SStefan Roese mask = HPIPE_G1_SET_1_G1_RX_SELMUPI_MASK; 1031c0132f60SStefan Roese data = 0x1 << HPIPE_G1_SET_1_G1_RX_SELMUPI_OFFSET; 1032c0132f60SStefan Roese mask |= HPIPE_G1_SET_1_G1_RX_SELMUPP_MASK; 1033c0132f60SStefan Roese data |= 0x1 << HPIPE_G1_SET_1_G1_RX_SELMUPP_OFFSET; 1034c0132f60SStefan Roese mask |= HPIPE_G1_SET_1_G1_RX_DFE_EN_MASK; 1035c0132f60SStefan Roese data |= 0x1 << HPIPE_G1_SET_1_G1_RX_DFE_EN_OFFSET; 1036c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_G1_SET_1_REG, data, mask); 1037c0132f60SStefan Roese /* 0xA-DFE_Reg3 */ 1038c0132f60SStefan Roese mask = HPIPE_DFE_F3_F5_DFE_EN_MASK; 1039c0132f60SStefan Roese data = 0x0 << HPIPE_DFE_F3_F5_DFE_EN_OFFSET; 1040c0132f60SStefan Roese mask |= HPIPE_DFE_F3_F5_DFE_CTRL_MASK; 1041c0132f60SStefan Roese data |= 0x0 << HPIPE_DFE_F3_F5_DFE_CTRL_OFFSET; 1042c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_DFE_F3_F5_REG, data, mask); 1043c0132f60SStefan Roese 1044c0132f60SStefan Roese /* 0x111-G1_Setting_4 */ 1045c0132f60SStefan Roese mask = HPIPE_G1_SETTINGS_4_G1_DFE_RES_MASK; 1046c0132f60SStefan Roese data = 0x1 << HPIPE_G1_SETTINGS_4_G1_DFE_RES_OFFSET; 1047c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_G1_SETTINGS_4_REG, data, mask); 1048c0132f60SStefan Roese /* Genration 1 setting 3 (G1_Setting_3) */ 1049c0132f60SStefan Roese mask = HPIPE_G1_SETTINGS_3_G1_FBCK_SEL_MASK; 1050c0132f60SStefan Roese data = 0x1 << HPIPE_G1_SETTINGS_3_G1_FBCK_SEL_OFFSET; 1051c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_G1_SETTINGS_3_REG, data, mask); 1052c0132f60SStefan Roese 1053c0132f60SStefan Roese debug("stage: RFU configurations- Power Up PLL,Tx,Rx\n"); 1054c0132f60SStefan Roese /* SERDES External Configuration */ 1055c0132f60SStefan Roese mask = SD_EXTERNAL_CONFIG0_SD_PU_PLL_MASK; 1056c0132f60SStefan Roese data = 0x1 << SD_EXTERNAL_CONFIG0_SD_PU_PLL_OFFSET; 1057c0132f60SStefan Roese mask |= SD_EXTERNAL_CONFIG0_SD_PU_RX_MASK; 1058c0132f60SStefan Roese data |= 0x1 << SD_EXTERNAL_CONFIG0_SD_PU_RX_OFFSET; 1059c0132f60SStefan Roese mask |= SD_EXTERNAL_CONFIG0_SD_PU_TX_MASK; 1060c0132f60SStefan Roese data |= 0x1 << SD_EXTERNAL_CONFIG0_SD_PU_TX_OFFSET; 1061c0132f60SStefan Roese reg_set(sd_ip_addr + SD_EXTERNAL_CONFIG0_REG, data, mask); 1062c0132f60SStefan Roese 1063c0132f60SStefan Roese 1064c0132f60SStefan Roese /* check PLL rx & tx ready */ 1065c0132f60SStefan Roese addr = sd_ip_addr + SD_EXTERNAL_STATUS0_REG; 1066c0132f60SStefan Roese data = SD_EXTERNAL_STATUS0_PLL_RX_MASK | 1067c0132f60SStefan Roese SD_EXTERNAL_STATUS0_PLL_TX_MASK; 1068c0132f60SStefan Roese mask = data; 1069c0132f60SStefan Roese data = polling_with_timeout(addr, data, mask, 15000); 1070c0132f60SStefan Roese if (data != 0) { 1071c0132f60SStefan Roese debug("Read from reg = %p - value = 0x%x\n", sd_ip_addr + SD_EXTERNAL_STATUS0_REG, data); 1072c0132f60SStefan Roese error("SD_EXTERNAL_STATUS0_PLL_RX is %d, SD_EXTERNAL_STATUS0_PLL_TX is %d\n", 1073c0132f60SStefan Roese (data & SD_EXTERNAL_STATUS0_PLL_RX_MASK), 1074c0132f60SStefan Roese (data & SD_EXTERNAL_STATUS0_PLL_TX_MASK)); 1075c0132f60SStefan Roese ret = 0; 1076c0132f60SStefan Roese } 1077c0132f60SStefan Roese 1078c0132f60SStefan Roese /* RX init */ 1079c0132f60SStefan Roese mask = SD_EXTERNAL_CONFIG1_RX_INIT_MASK; 1080c0132f60SStefan Roese data = 0x1 << SD_EXTERNAL_CONFIG1_RX_INIT_OFFSET; 1081c0132f60SStefan Roese reg_set(sd_ip_addr + SD_EXTERNAL_CONFIG1_REG, data, mask); 1082c0132f60SStefan Roese 1083c0132f60SStefan Roese 1084c0132f60SStefan Roese /* check that RX init done */ 1085c0132f60SStefan Roese addr = sd_ip_addr + SD_EXTERNAL_STATUS0_REG; 1086c0132f60SStefan Roese data = SD_EXTERNAL_STATUS0_RX_INIT_MASK; 1087c0132f60SStefan Roese mask = data; 1088c0132f60SStefan Roese data = polling_with_timeout(addr, data, mask, 100); 1089c0132f60SStefan Roese if (data != 0) { 1090c0132f60SStefan Roese debug("Read from reg = %p - value = 0x%x\n", 1091c0132f60SStefan Roese sd_ip_addr + SD_EXTERNAL_STATUS0_REG, data); 1092c0132f60SStefan Roese error("SD_EXTERNAL_STATUS0_RX_INIT is 0\n"); 1093c0132f60SStefan Roese ret = 0; 1094c0132f60SStefan Roese } 1095c0132f60SStefan Roese 1096c0132f60SStefan Roese debug("stage: RF Reset\n"); 1097c0132f60SStefan Roese /* RF Reset */ 1098c0132f60SStefan Roese mask = SD_EXTERNAL_CONFIG1_RX_INIT_MASK; 1099c0132f60SStefan Roese data = 0x0 << SD_EXTERNAL_CONFIG1_RX_INIT_OFFSET; 1100c0132f60SStefan Roese mask |= SD_EXTERNAL_CONFIG1_RF_RESET_IN_MASK; 1101c0132f60SStefan Roese data |= 0x1 << SD_EXTERNAL_CONFIG1_RF_RESET_IN_OFFSET; 1102c0132f60SStefan Roese reg_set(sd_ip_addr + SD_EXTERNAL_CONFIG1_REG, data, mask); 1103c0132f60SStefan Roese 1104c0132f60SStefan Roese debug_exit(); 1105c0132f60SStefan Roese return ret; 1106c0132f60SStefan Roese } 1107c0132f60SStefan Roese 1108c0132f60SStefan Roese static int comphy_rxauii_power_up(u32 lane, void __iomem *hpipe_base, 1109c0132f60SStefan Roese void __iomem *comphy_base) 1110c0132f60SStefan Roese { 1111c0132f60SStefan Roese u32 mask, data, ret = 1; 1112c0132f60SStefan Roese void __iomem *hpipe_addr = HPIPE_ADDR(hpipe_base, lane); 1113c0132f60SStefan Roese void __iomem *sd_ip_addr = SD_ADDR(hpipe_base, lane); 1114c0132f60SStefan Roese void __iomem *comphy_addr = COMPHY_ADDR(comphy_base, lane); 1115c0132f60SStefan Roese void __iomem *addr; 1116c0132f60SStefan Roese 1117c0132f60SStefan Roese debug_enter(); 1118c0132f60SStefan Roese debug("stage: RFU configurations - hard reset comphy\n"); 1119c0132f60SStefan Roese /* RFU configurations - hard reset comphy */ 1120c0132f60SStefan Roese mask = COMMON_PHY_CFG1_PWR_UP_MASK; 1121c0132f60SStefan Roese data = 0x1 << COMMON_PHY_CFG1_PWR_UP_OFFSET; 1122c0132f60SStefan Roese mask |= COMMON_PHY_CFG1_PIPE_SELECT_MASK; 1123c0132f60SStefan Roese data |= 0x0 << COMMON_PHY_CFG1_PIPE_SELECT_OFFSET; 1124c0132f60SStefan Roese reg_set(comphy_addr + COMMON_PHY_CFG1_REG, data, mask); 1125c0132f60SStefan Roese 1126c0132f60SStefan Roese if (lane == 2) { 1127c0132f60SStefan Roese reg_set(comphy_base + COMMON_PHY_SD_CTRL1, 1128c0132f60SStefan Roese 0x1 << COMMON_PHY_SD_CTRL1_RXAUI0_OFFSET, 1129c0132f60SStefan Roese COMMON_PHY_SD_CTRL1_RXAUI0_MASK); 1130c0132f60SStefan Roese } 1131c0132f60SStefan Roese if (lane == 4) { 1132c0132f60SStefan Roese reg_set(comphy_base + COMMON_PHY_SD_CTRL1, 1133c0132f60SStefan Roese 0x1 << COMMON_PHY_SD_CTRL1_RXAUI1_OFFSET, 1134c0132f60SStefan Roese COMMON_PHY_SD_CTRL1_RXAUI1_MASK); 1135c0132f60SStefan Roese } 1136c0132f60SStefan Roese 1137c0132f60SStefan Roese /* Select Baud Rate of Comphy And PD_PLL/Tx/Rx */ 1138c0132f60SStefan Roese mask = SD_EXTERNAL_CONFIG0_SD_PU_PLL_MASK; 1139c0132f60SStefan Roese data = 0x0 << SD_EXTERNAL_CONFIG0_SD_PU_PLL_OFFSET; 1140c0132f60SStefan Roese mask |= SD_EXTERNAL_CONFIG0_SD_PHY_GEN_RX_MASK; 1141c0132f60SStefan Roese data |= 0xB << SD_EXTERNAL_CONFIG0_SD_PHY_GEN_RX_OFFSET; 1142c0132f60SStefan Roese mask |= SD_EXTERNAL_CONFIG0_SD_PHY_GEN_TX_MASK; 1143c0132f60SStefan Roese data |= 0xB << SD_EXTERNAL_CONFIG0_SD_PHY_GEN_TX_OFFSET; 1144c0132f60SStefan Roese mask |= SD_EXTERNAL_CONFIG0_SD_PU_RX_MASK; 1145c0132f60SStefan Roese data |= 0x0 << SD_EXTERNAL_CONFIG0_SD_PU_RX_OFFSET; 1146c0132f60SStefan Roese mask |= SD_EXTERNAL_CONFIG0_SD_PU_TX_MASK; 1147c0132f60SStefan Roese data |= 0x0 << SD_EXTERNAL_CONFIG0_SD_PU_TX_OFFSET; 1148c0132f60SStefan Roese mask |= SD_EXTERNAL_CONFIG0_HALF_BUS_MODE_MASK; 1149c0132f60SStefan Roese data |= 0x0 << SD_EXTERNAL_CONFIG0_HALF_BUS_MODE_OFFSET; 1150c0132f60SStefan Roese mask |= SD_EXTERNAL_CONFIG0_MEDIA_MODE_MASK; 1151c0132f60SStefan Roese data |= 0x1 << SD_EXTERNAL_CONFIG0_MEDIA_MODE_OFFSET; 1152c0132f60SStefan Roese reg_set(sd_ip_addr + SD_EXTERNAL_CONFIG0_REG, data, mask); 1153c0132f60SStefan Roese 1154c0132f60SStefan Roese /* release from hard reset */ 1155c0132f60SStefan Roese mask = SD_EXTERNAL_CONFIG1_RESET_IN_MASK; 1156c0132f60SStefan Roese data = 0x0 << SD_EXTERNAL_CONFIG1_RESET_IN_OFFSET; 1157c0132f60SStefan Roese mask |= SD_EXTERNAL_CONFIG1_RESET_CORE_MASK; 1158c0132f60SStefan Roese data |= 0x0 << SD_EXTERNAL_CONFIG1_RESET_CORE_OFFSET; 1159c0132f60SStefan Roese mask |= SD_EXTERNAL_CONFIG1_RF_RESET_IN_MASK; 1160c0132f60SStefan Roese data |= 0x0 << SD_EXTERNAL_CONFIG1_RF_RESET_IN_OFFSET; 1161c0132f60SStefan Roese reg_set(sd_ip_addr + SD_EXTERNAL_CONFIG1_REG, data, mask); 1162c0132f60SStefan Roese 1163c0132f60SStefan Roese mask = SD_EXTERNAL_CONFIG1_RESET_IN_MASK; 1164c0132f60SStefan Roese data = 0x1 << SD_EXTERNAL_CONFIG1_RESET_IN_OFFSET; 1165c0132f60SStefan Roese mask |= SD_EXTERNAL_CONFIG1_RESET_CORE_MASK; 1166c0132f60SStefan Roese data |= 0x1 << SD_EXTERNAL_CONFIG1_RESET_CORE_OFFSET; 1167c0132f60SStefan Roese reg_set(sd_ip_addr + SD_EXTERNAL_CONFIG1_REG, data, mask); 1168c0132f60SStefan Roese 1169c0132f60SStefan Roese /* Wait 1ms - until band gap and ref clock ready */ 1170c0132f60SStefan Roese mdelay(1); 1171c0132f60SStefan Roese 1172c0132f60SStefan Roese /* Start comphy Configuration */ 1173c0132f60SStefan Roese debug("stage: Comphy configuration\n"); 1174c0132f60SStefan Roese /* set reference clock */ 1175c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_MISC_REG, 1176c0132f60SStefan Roese 0x0 << HPIPE_MISC_REFCLK_SEL_OFFSET, 1177c0132f60SStefan Roese HPIPE_MISC_REFCLK_SEL_MASK); 1178c0132f60SStefan Roese /* Power and PLL Control */ 1179c0132f60SStefan Roese mask = HPIPE_PWR_PLL_REF_FREQ_MASK; 1180c0132f60SStefan Roese data = 0x1 << HPIPE_PWR_PLL_REF_FREQ_OFFSET; 1181c0132f60SStefan Roese mask |= HPIPE_PWR_PLL_PHY_MODE_MASK; 1182c0132f60SStefan Roese data |= 0x4 << HPIPE_PWR_PLL_PHY_MODE_OFFSET; 1183c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_PWR_PLL_REG, data, mask); 1184c0132f60SStefan Roese /* Loopback register */ 1185c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_LOOPBACK_REG, 1186c0132f60SStefan Roese 0x1 << HPIPE_LOOPBACK_SEL_OFFSET, HPIPE_LOOPBACK_SEL_MASK); 1187c0132f60SStefan Roese /* rx control 1 */ 1188c0132f60SStefan Roese mask = HPIPE_RX_CONTROL_1_RXCLK2X_SEL_MASK; 1189c0132f60SStefan Roese data = 0x1 << HPIPE_RX_CONTROL_1_RXCLK2X_SEL_OFFSET; 1190c0132f60SStefan Roese mask |= HPIPE_RX_CONTROL_1_CLK8T_EN_MASK; 1191c0132f60SStefan Roese data |= 0x1 << HPIPE_RX_CONTROL_1_CLK8T_EN_OFFSET; 1192c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_RX_CONTROL_1_REG, data, mask); 1193c0132f60SStefan Roese /* DTL Control */ 1194c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_PWR_CTR_DTL_REG, 1195c0132f60SStefan Roese 0x0 << HPIPE_PWR_CTR_DTL_FLOOP_EN_OFFSET, 1196c0132f60SStefan Roese HPIPE_PWR_CTR_DTL_FLOOP_EN_MASK); 1197c0132f60SStefan Roese 1198c0132f60SStefan Roese /* Set analog paramters from ETP(HW) */ 1199c0132f60SStefan Roese debug("stage: Analog paramters from ETP(HW)\n"); 1200c0132f60SStefan Roese /* SERDES External Configuration 2 */ 1201c0132f60SStefan Roese reg_set(sd_ip_addr + SD_EXTERNAL_CONFIG2_REG, 1202c0132f60SStefan Roese 0x1 << SD_EXTERNAL_CONFIG2_PIN_DFE_EN_OFFSET, 1203c0132f60SStefan Roese SD_EXTERNAL_CONFIG2_PIN_DFE_EN_MASK); 1204c0132f60SStefan Roese /* 0x7-DFE Resolution control */ 1205c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_DFE_REG0, 0x1 << HPIPE_DFE_RES_FORCE_OFFSET, 1206c0132f60SStefan Roese HPIPE_DFE_RES_FORCE_MASK); 1207c0132f60SStefan Roese /* 0xd-G1_Setting_0 */ 1208c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_G1_SET_0_REG, 1209c0132f60SStefan Roese 0xd << HPIPE_G1_SET_0_G1_TX_EMPH1_OFFSET, 1210c0132f60SStefan Roese HPIPE_G1_SET_0_G1_TX_EMPH1_MASK); 1211c0132f60SStefan Roese /* 0xE-G1_Setting_1 */ 1212c0132f60SStefan Roese mask = HPIPE_G1_SET_1_G1_RX_SELMUPI_MASK; 1213c0132f60SStefan Roese data = 0x1 << HPIPE_G1_SET_1_G1_RX_SELMUPI_OFFSET; 1214c0132f60SStefan Roese mask |= HPIPE_G1_SET_1_G1_RX_SELMUPP_MASK; 1215c0132f60SStefan Roese data |= 0x1 << HPIPE_G1_SET_1_G1_RX_SELMUPP_OFFSET; 1216c0132f60SStefan Roese mask |= HPIPE_G1_SET_1_G1_RX_DFE_EN_MASK; 1217c0132f60SStefan Roese data |= 0x1 << HPIPE_G1_SET_1_G1_RX_DFE_EN_OFFSET; 1218c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_G1_SET_1_REG, data, mask); 1219c0132f60SStefan Roese /* 0xA-DFE_Reg3 */ 1220c0132f60SStefan Roese mask = HPIPE_DFE_F3_F5_DFE_EN_MASK; 1221c0132f60SStefan Roese data = 0x0 << HPIPE_DFE_F3_F5_DFE_EN_OFFSET; 1222c0132f60SStefan Roese mask |= HPIPE_DFE_F3_F5_DFE_CTRL_MASK; 1223c0132f60SStefan Roese data |= 0x0 << HPIPE_DFE_F3_F5_DFE_CTRL_OFFSET; 1224c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_DFE_F3_F5_REG, data, mask); 1225c0132f60SStefan Roese 1226c0132f60SStefan Roese /* 0x111-G1_Setting_4 */ 1227c0132f60SStefan Roese mask = HPIPE_G1_SETTINGS_4_G1_DFE_RES_MASK; 1228c0132f60SStefan Roese data = 0x1 << HPIPE_G1_SETTINGS_4_G1_DFE_RES_OFFSET; 1229c0132f60SStefan Roese reg_set(hpipe_addr + HPIPE_G1_SETTINGS_4_REG, data, mask); 1230c0132f60SStefan Roese 1231c0132f60SStefan Roese debug("stage: RFU configurations- Power Up PLL,Tx,Rx\n"); 1232c0132f60SStefan Roese /* SERDES External Configuration */ 1233c0132f60SStefan Roese mask = SD_EXTERNAL_CONFIG0_SD_PU_PLL_MASK; 1234c0132f60SStefan Roese data = 0x1 << SD_EXTERNAL_CONFIG0_SD_PU_PLL_OFFSET; 1235c0132f60SStefan Roese mask |= SD_EXTERNAL_CONFIG0_SD_PU_RX_MASK; 1236c0132f60SStefan Roese data |= 0x1 << SD_EXTERNAL_CONFIG0_SD_PU_RX_OFFSET; 1237c0132f60SStefan Roese mask |= SD_EXTERNAL_CONFIG0_SD_PU_TX_MASK; 1238c0132f60SStefan Roese data |= 0x1 << SD_EXTERNAL_CONFIG0_SD_PU_TX_OFFSET; 1239c0132f60SStefan Roese reg_set(sd_ip_addr + SD_EXTERNAL_CONFIG0_REG, data, mask); 1240c0132f60SStefan Roese 1241c0132f60SStefan Roese 1242c0132f60SStefan Roese /* check PLL rx & tx ready */ 1243c0132f60SStefan Roese addr = sd_ip_addr + SD_EXTERNAL_STATUS0_REG; 1244c0132f60SStefan Roese data = SD_EXTERNAL_STATUS0_PLL_RX_MASK | 1245c0132f60SStefan Roese SD_EXTERNAL_STATUS0_PLL_TX_MASK; 1246c0132f60SStefan Roese mask = data; 1247c0132f60SStefan Roese data = polling_with_timeout(addr, data, mask, 15000); 1248c0132f60SStefan Roese if (data != 0) { 1249c0132f60SStefan Roese debug("Read from reg = %p - value = 0x%x\n", 1250c0132f60SStefan Roese sd_ip_addr + SD_EXTERNAL_STATUS0_REG, data); 1251c0132f60SStefan Roese error("SD_EXTERNAL_STATUS0_PLL_RX is %d, SD_EXTERNAL_STATUS0_PLL_TX is %d\n", 1252c0132f60SStefan Roese (data & SD_EXTERNAL_STATUS0_PLL_RX_MASK), 1253c0132f60SStefan Roese (data & SD_EXTERNAL_STATUS0_PLL_TX_MASK)); 1254c0132f60SStefan Roese ret = 0; 1255c0132f60SStefan Roese } 1256c0132f60SStefan Roese 1257c0132f60SStefan Roese /* RX init */ 1258c0132f60SStefan Roese reg_set(sd_ip_addr + SD_EXTERNAL_CONFIG1_REG, 1259c0132f60SStefan Roese 0x1 << SD_EXTERNAL_CONFIG1_RX_INIT_OFFSET, 1260c0132f60SStefan Roese SD_EXTERNAL_CONFIG1_RX_INIT_MASK); 1261c0132f60SStefan Roese 1262c0132f60SStefan Roese /* check that RX init done */ 1263c0132f60SStefan Roese addr = sd_ip_addr + SD_EXTERNAL_STATUS0_REG; 1264c0132f60SStefan Roese data = SD_EXTERNAL_STATUS0_RX_INIT_MASK; 1265c0132f60SStefan Roese mask = data; 1266c0132f60SStefan Roese data = polling_with_timeout(addr, data, mask, 100); 1267c0132f60SStefan Roese if (data != 0) { 1268c0132f60SStefan Roese debug("Read from reg = %p - value = 0x%x\n", 1269c0132f60SStefan Roese sd_ip_addr + SD_EXTERNAL_STATUS0_REG, data); 1270c0132f60SStefan Roese error("SD_EXTERNAL_STATUS0_RX_INIT is 0\n"); 1271c0132f60SStefan Roese ret = 0; 1272c0132f60SStefan Roese } 1273c0132f60SStefan Roese 1274c0132f60SStefan Roese debug("stage: RF Reset\n"); 1275c0132f60SStefan Roese /* RF Reset */ 1276c0132f60SStefan Roese mask = SD_EXTERNAL_CONFIG1_RX_INIT_MASK; 1277c0132f60SStefan Roese data = 0x0 << SD_EXTERNAL_CONFIG1_RX_INIT_OFFSET; 1278c0132f60SStefan Roese mask |= SD_EXTERNAL_CONFIG1_RF_RESET_IN_MASK; 1279c0132f60SStefan Roese data |= 0x1 << SD_EXTERNAL_CONFIG1_RF_RESET_IN_OFFSET; 1280c0132f60SStefan Roese reg_set(sd_ip_addr + SD_EXTERNAL_CONFIG1_REG, data, mask); 1281c0132f60SStefan Roese 1282c0132f60SStefan Roese debug_exit(); 1283c0132f60SStefan Roese return ret; 1284c0132f60SStefan Roese } 1285c0132f60SStefan Roese 1286c0132f60SStefan Roese static void comphy_utmi_power_down(u32 utmi_index, void __iomem *utmi_base_addr, 1287c0132f60SStefan Roese void __iomem *usb_cfg_addr, 1288c0132f60SStefan Roese void __iomem *utmi_cfg_addr, 1289c0132f60SStefan Roese u32 utmi_phy_port) 1290c0132f60SStefan Roese { 1291c0132f60SStefan Roese u32 mask, data; 1292c0132f60SStefan Roese 1293c0132f60SStefan Roese debug_enter(); 1294c0132f60SStefan Roese debug("stage: UTMI %d - Power down transceiver (power down Phy), Power down PLL, and SuspendDM\n", 1295c0132f60SStefan Roese utmi_index); 1296c0132f60SStefan Roese /* Power down UTMI PHY */ 1297c0132f60SStefan Roese reg_set(utmi_cfg_addr, 0x0 << UTMI_PHY_CFG_PU_OFFSET, 1298c0132f60SStefan Roese UTMI_PHY_CFG_PU_MASK); 1299c0132f60SStefan Roese 1300c0132f60SStefan Roese /* 1301c0132f60SStefan Roese * If UTMI connected to USB Device, configure mux prior to PHY init 1302c0132f60SStefan Roese * (Device can be connected to UTMI0 or to UTMI1) 1303c0132f60SStefan Roese */ 1304c0132f60SStefan Roese if (utmi_phy_port == UTMI_PHY_TO_USB_DEVICE0) { 1305c0132f60SStefan Roese debug("stage: UTMI %d - Enable Device mode and configure UTMI mux\n", 1306c0132f60SStefan Roese utmi_index); 1307c0132f60SStefan Roese /* USB3 Device UTMI enable */ 1308c0132f60SStefan Roese mask = UTMI_USB_CFG_DEVICE_EN_MASK; 1309c0132f60SStefan Roese data = 0x1 << UTMI_USB_CFG_DEVICE_EN_OFFSET; 1310c0132f60SStefan Roese /* USB3 Device UTMI MUX */ 1311c0132f60SStefan Roese mask |= UTMI_USB_CFG_DEVICE_MUX_MASK; 1312c0132f60SStefan Roese data |= utmi_index << UTMI_USB_CFG_DEVICE_MUX_OFFSET; 1313c0132f60SStefan Roese reg_set(usb_cfg_addr, data, mask); 1314c0132f60SStefan Roese } 1315c0132f60SStefan Roese 1316c0132f60SStefan Roese /* Set Test suspendm mode */ 1317c0132f60SStefan Roese mask = UTMI_CTRL_STATUS0_SUSPENDM_MASK; 1318c0132f60SStefan Roese data = 0x1 << UTMI_CTRL_STATUS0_SUSPENDM_OFFSET; 1319c0132f60SStefan Roese /* Enable Test UTMI select */ 1320c0132f60SStefan Roese mask |= UTMI_CTRL_STATUS0_TEST_SEL_MASK; 1321c0132f60SStefan Roese data |= 0x1 << UTMI_CTRL_STATUS0_TEST_SEL_OFFSET; 1322c0132f60SStefan Roese reg_set(utmi_base_addr + UTMI_CTRL_STATUS0_REG, data, mask); 1323c0132f60SStefan Roese 1324c0132f60SStefan Roese /* Wait for UTMI power down */ 1325c0132f60SStefan Roese mdelay(1); 1326c0132f60SStefan Roese 1327c0132f60SStefan Roese debug_exit(); 1328c0132f60SStefan Roese return; 1329c0132f60SStefan Roese } 1330c0132f60SStefan Roese 1331c0132f60SStefan Roese static void comphy_utmi_phy_config(u32 utmi_index, void __iomem *utmi_base_addr, 1332c0132f60SStefan Roese void __iomem *usb_cfg_addr, 1333c0132f60SStefan Roese void __iomem *utmi_cfg_addr, 1334c0132f60SStefan Roese u32 utmi_phy_port) 1335c0132f60SStefan Roese { 1336c0132f60SStefan Roese u32 mask, data; 1337c0132f60SStefan Roese 1338c0132f60SStefan Roese debug_exit(); 1339c0132f60SStefan Roese debug("stage: Configure UTMI PHY %d registers\n", utmi_index); 1340c0132f60SStefan Roese /* Reference Clock Divider Select */ 1341c0132f60SStefan Roese mask = UTMI_PLL_CTRL_REFDIV_MASK; 1342c0132f60SStefan Roese data = 0x5 << UTMI_PLL_CTRL_REFDIV_OFFSET; 1343c0132f60SStefan Roese /* Feedback Clock Divider Select - 90 for 25Mhz*/ 1344c0132f60SStefan Roese mask |= UTMI_PLL_CTRL_FBDIV_MASK; 1345c0132f60SStefan Roese data |= 0x60 << UTMI_PLL_CTRL_FBDIV_OFFSET; 1346c0132f60SStefan Roese /* Select LPFR - 0x0 for 25Mhz/5=5Mhz*/ 1347c0132f60SStefan Roese mask |= UTMI_PLL_CTRL_SEL_LPFR_MASK; 1348c0132f60SStefan Roese data |= 0x0 << UTMI_PLL_CTRL_SEL_LPFR_OFFSET; 1349c0132f60SStefan Roese reg_set(utmi_base_addr + UTMI_PLL_CTRL_REG, data, mask); 1350c0132f60SStefan Roese 1351c0132f60SStefan Roese /* Impedance Calibration Threshold Setting */ 1352c0132f60SStefan Roese reg_set(utmi_base_addr + UTMI_CALIB_CTRL_REG, 1353c0132f60SStefan Roese 0x6 << UTMI_CALIB_CTRL_IMPCAL_VTH_OFFSET, 1354c0132f60SStefan Roese UTMI_CALIB_CTRL_IMPCAL_VTH_MASK); 1355c0132f60SStefan Roese 1356c0132f60SStefan Roese /* Set LS TX driver strength coarse control */ 1357c0132f60SStefan Roese mask = UTMI_TX_CH_CTRL_DRV_EN_LS_MASK; 1358c0132f60SStefan Roese data = 0x3 << UTMI_TX_CH_CTRL_DRV_EN_LS_OFFSET; 1359c0132f60SStefan Roese /* Set LS TX driver fine adjustment */ 1360c0132f60SStefan Roese mask |= UTMI_TX_CH_CTRL_IMP_SEL_LS_MASK; 1361c0132f60SStefan Roese data |= 0x3 << UTMI_TX_CH_CTRL_IMP_SEL_LS_OFFSET; 1362c0132f60SStefan Roese reg_set(utmi_base_addr + UTMI_TX_CH_CTRL_REG, data, mask); 1363c0132f60SStefan Roese 1364c0132f60SStefan Roese /* Enable SQ */ 1365c0132f60SStefan Roese mask = UTMI_RX_CH_CTRL0_SQ_DET_MASK; 1366c0132f60SStefan Roese data = 0x0 << UTMI_RX_CH_CTRL0_SQ_DET_OFFSET; 1367c0132f60SStefan Roese /* Enable analog squelch detect */ 1368c0132f60SStefan Roese mask |= UTMI_RX_CH_CTRL0_SQ_ANA_DTC_MASK; 1369c0132f60SStefan Roese data |= 0x1 << UTMI_RX_CH_CTRL0_SQ_ANA_DTC_OFFSET; 1370c0132f60SStefan Roese reg_set(utmi_base_addr + UTMI_RX_CH_CTRL0_REG, data, mask); 1371c0132f60SStefan Roese 1372c0132f60SStefan Roese /* Set External squelch calibration number */ 1373c0132f60SStefan Roese mask = UTMI_RX_CH_CTRL1_SQ_AMP_CAL_MASK; 1374c0132f60SStefan Roese data = 0x1 << UTMI_RX_CH_CTRL1_SQ_AMP_CAL_OFFSET; 1375c0132f60SStefan Roese /* Enable the External squelch calibration */ 1376c0132f60SStefan Roese mask |= UTMI_RX_CH_CTRL1_SQ_AMP_CAL_EN_MASK; 1377c0132f60SStefan Roese data |= 0x1 << UTMI_RX_CH_CTRL1_SQ_AMP_CAL_EN_OFFSET; 1378c0132f60SStefan Roese reg_set(utmi_base_addr + UTMI_RX_CH_CTRL1_REG, data, mask); 1379c0132f60SStefan Roese 1380c0132f60SStefan Roese /* Set Control VDAT Reference Voltage - 0.325V */ 1381c0132f60SStefan Roese mask = UTMI_CHGDTC_CTRL_VDAT_MASK; 1382c0132f60SStefan Roese data = 0x1 << UTMI_CHGDTC_CTRL_VDAT_OFFSET; 1383c0132f60SStefan Roese /* Set Control VSRC Reference Voltage - 0.6V */ 1384c0132f60SStefan Roese mask |= UTMI_CHGDTC_CTRL_VSRC_MASK; 1385c0132f60SStefan Roese data |= 0x1 << UTMI_CHGDTC_CTRL_VSRC_OFFSET; 1386c0132f60SStefan Roese reg_set(utmi_base_addr + UTMI_CHGDTC_CTRL_REG, data, mask); 1387c0132f60SStefan Roese 1388c0132f60SStefan Roese debug_exit(); 1389c0132f60SStefan Roese return; 1390c0132f60SStefan Roese } 1391c0132f60SStefan Roese 1392c0132f60SStefan Roese static int comphy_utmi_power_up(u32 utmi_index, void __iomem *utmi_base_addr, 1393c0132f60SStefan Roese void __iomem *usb_cfg_addr, 1394c0132f60SStefan Roese void __iomem *utmi_cfg_addr, u32 utmi_phy_port) 1395c0132f60SStefan Roese { 1396c0132f60SStefan Roese u32 data, mask, ret = 1; 1397c0132f60SStefan Roese void __iomem *addr; 1398c0132f60SStefan Roese 1399c0132f60SStefan Roese debug_enter(); 1400c0132f60SStefan Roese debug("stage: UTMI %d - Power up transceiver(Power up Phy), and exit SuspendDM\n", 1401c0132f60SStefan Roese utmi_index); 1402c0132f60SStefan Roese /* Power UP UTMI PHY */ 1403c0132f60SStefan Roese reg_set(utmi_cfg_addr, 0x1 << UTMI_PHY_CFG_PU_OFFSET, 1404c0132f60SStefan Roese UTMI_PHY_CFG_PU_MASK); 1405c0132f60SStefan Roese /* Disable Test UTMI select */ 1406c0132f60SStefan Roese reg_set(utmi_base_addr + UTMI_CTRL_STATUS0_REG, 1407c0132f60SStefan Roese 0x0 << UTMI_CTRL_STATUS0_TEST_SEL_OFFSET, 1408c0132f60SStefan Roese UTMI_CTRL_STATUS0_TEST_SEL_MASK); 1409c0132f60SStefan Roese 1410c0132f60SStefan Roese debug("stage: Polling for PLL and impedance calibration done, and PLL ready done\n"); 1411c0132f60SStefan Roese addr = utmi_base_addr + UTMI_CALIB_CTRL_REG; 1412c0132f60SStefan Roese data = UTMI_CALIB_CTRL_IMPCAL_DONE_MASK; 1413c0132f60SStefan Roese mask = data; 1414c0132f60SStefan Roese data = polling_with_timeout(addr, data, mask, 100); 1415c0132f60SStefan Roese if (data != 0) { 1416c0132f60SStefan Roese error("Impedance calibration is not done\n"); 1417c0132f60SStefan Roese debug("Read from reg = %p - value = 0x%x\n", addr, data); 1418c0132f60SStefan Roese ret = 0; 1419c0132f60SStefan Roese } 1420c0132f60SStefan Roese 1421c0132f60SStefan Roese data = UTMI_CALIB_CTRL_PLLCAL_DONE_MASK; 1422c0132f60SStefan Roese mask = data; 1423c0132f60SStefan Roese data = polling_with_timeout(addr, data, mask, 100); 1424c0132f60SStefan Roese if (data != 0) { 1425c0132f60SStefan Roese error("PLL calibration is not done\n"); 1426c0132f60SStefan Roese debug("Read from reg = %p - value = 0x%x\n", addr, data); 1427c0132f60SStefan Roese ret = 0; 1428c0132f60SStefan Roese } 1429c0132f60SStefan Roese 1430c0132f60SStefan Roese addr = utmi_base_addr + UTMI_PLL_CTRL_REG; 1431c0132f60SStefan Roese data = UTMI_PLL_CTRL_PLL_RDY_MASK; 1432c0132f60SStefan Roese mask = data; 1433c0132f60SStefan Roese data = polling_with_timeout(addr, data, mask, 100); 1434c0132f60SStefan Roese if (data != 0) { 1435c0132f60SStefan Roese error("PLL is not ready\n"); 1436c0132f60SStefan Roese debug("Read from reg = %p - value = 0x%x\n", addr, data); 1437c0132f60SStefan Roese ret = 0; 1438c0132f60SStefan Roese } 1439c0132f60SStefan Roese 1440c0132f60SStefan Roese if (ret) 1441c0132f60SStefan Roese debug("Passed\n"); 1442c0132f60SStefan Roese else 1443c0132f60SStefan Roese debug("\n"); 1444c0132f60SStefan Roese 1445c0132f60SStefan Roese debug_exit(); 1446c0132f60SStefan Roese return ret; 1447c0132f60SStefan Roese } 1448c0132f60SStefan Roese 1449c0132f60SStefan Roese /* 1450c0132f60SStefan Roese * comphy_utmi_phy_init initialize the UTMI PHY 1451c0132f60SStefan Roese * the init split in 3 parts: 1452c0132f60SStefan Roese * 1. Power down transceiver and PLL 1453c0132f60SStefan Roese * 2. UTMI PHY configure 1454c0132f60SStefan Roese * 3. Powe up transceiver and PLL 1455c0132f60SStefan Roese * Note: - Power down/up should be once for both UTMI PHYs 1456c0132f60SStefan Roese * - comphy_dedicated_phys_init call this function if at least there is 1457c0132f60SStefan Roese * one UTMI PHY exists in FDT blob. access to cp110_utmi_data[0] is 1458c0132f60SStefan Roese * legal 1459c0132f60SStefan Roese */ 1460c0132f60SStefan Roese static void comphy_utmi_phy_init(u32 utmi_phy_count, 1461c0132f60SStefan Roese struct utmi_phy_data *cp110_utmi_data) 1462c0132f60SStefan Roese { 1463c0132f60SStefan Roese u32 i; 1464c0132f60SStefan Roese 1465c0132f60SStefan Roese debug_enter(); 1466c0132f60SStefan Roese /* UTMI Power down */ 1467c0132f60SStefan Roese for (i = 0; i < utmi_phy_count; i++) { 1468c0132f60SStefan Roese comphy_utmi_power_down(i, cp110_utmi_data[i].utmi_base_addr, 1469c0132f60SStefan Roese cp110_utmi_data[i].usb_cfg_addr, 1470c0132f60SStefan Roese cp110_utmi_data[i].utmi_cfg_addr, 1471c0132f60SStefan Roese cp110_utmi_data[i].utmi_phy_port); 1472c0132f60SStefan Roese } 1473c0132f60SStefan Roese /* PLL Power down */ 1474c0132f60SStefan Roese debug("stage: UTMI PHY power down PLL\n"); 1475c0132f60SStefan Roese for (i = 0; i < utmi_phy_count; i++) { 1476c0132f60SStefan Roese reg_set(cp110_utmi_data[i].usb_cfg_addr, 1477c0132f60SStefan Roese 0x0 << UTMI_USB_CFG_PLL_OFFSET, UTMI_USB_CFG_PLL_MASK); 1478c0132f60SStefan Roese } 1479c0132f60SStefan Roese /* UTMI configure */ 1480c0132f60SStefan Roese for (i = 0; i < utmi_phy_count; i++) { 1481c0132f60SStefan Roese comphy_utmi_phy_config(i, cp110_utmi_data[i].utmi_base_addr, 1482c0132f60SStefan Roese cp110_utmi_data[i].usb_cfg_addr, 1483c0132f60SStefan Roese cp110_utmi_data[i].utmi_cfg_addr, 1484c0132f60SStefan Roese cp110_utmi_data[i].utmi_phy_port); 1485c0132f60SStefan Roese } 1486c0132f60SStefan Roese /* UTMI Power up */ 1487c0132f60SStefan Roese for (i = 0; i < utmi_phy_count; i++) { 1488c0132f60SStefan Roese if (!comphy_utmi_power_up(i, cp110_utmi_data[i].utmi_base_addr, 1489c0132f60SStefan Roese cp110_utmi_data[i].usb_cfg_addr, 1490c0132f60SStefan Roese cp110_utmi_data[i].utmi_cfg_addr, 1491c0132f60SStefan Roese cp110_utmi_data[i].utmi_phy_port)) { 1492c0132f60SStefan Roese error("Failed to initialize UTMI PHY %d\n", i); 1493c0132f60SStefan Roese continue; 1494c0132f60SStefan Roese } 1495c0132f60SStefan Roese printf("UTMI PHY %d initialized to ", i); 1496c0132f60SStefan Roese if (cp110_utmi_data[i].utmi_phy_port == UTMI_PHY_TO_USB_DEVICE0) 1497c0132f60SStefan Roese printf("USB Device\n"); 1498c0132f60SStefan Roese else 1499c0132f60SStefan Roese printf("USB Host%d\n", 1500c0132f60SStefan Roese cp110_utmi_data[i].utmi_phy_port); 1501c0132f60SStefan Roese } 1502c0132f60SStefan Roese /* PLL Power up */ 1503c0132f60SStefan Roese debug("stage: UTMI PHY power up PLL\n"); 1504c0132f60SStefan Roese for (i = 0; i < utmi_phy_count; i++) { 1505c0132f60SStefan Roese reg_set(cp110_utmi_data[i].usb_cfg_addr, 1506c0132f60SStefan Roese 0x1 << UTMI_USB_CFG_PLL_OFFSET, UTMI_USB_CFG_PLL_MASK); 1507c0132f60SStefan Roese } 1508c0132f60SStefan Roese 1509c0132f60SStefan Roese debug_exit(); 1510c0132f60SStefan Roese return; 1511c0132f60SStefan Roese } 1512c0132f60SStefan Roese 1513c0132f60SStefan Roese /* 1514c0132f60SStefan Roese * comphy_dedicated_phys_init initialize the dedicated PHYs 1515c0132f60SStefan Roese * - not muxed SerDes lanes e.g. UTMI PHY 1516c0132f60SStefan Roese */ 1517c0132f60SStefan Roese void comphy_dedicated_phys_init(void) 1518c0132f60SStefan Roese { 1519c0132f60SStefan Roese struct utmi_phy_data cp110_utmi_data[MAX_UTMI_PHY_COUNT]; 1520c0132f60SStefan Roese int node; 1521c0132f60SStefan Roese int i; 1522c0132f60SStefan Roese 1523c0132f60SStefan Roese debug_enter(); 1524c0132f60SStefan Roese debug("Initialize USB UTMI PHYs\n"); 1525c0132f60SStefan Roese 1526c0132f60SStefan Roese /* Find the UTMI phy node in device tree and go over them */ 1527c0132f60SStefan Roese node = fdt_node_offset_by_compatible(gd->fdt_blob, -1, 1528c0132f60SStefan Roese "marvell,mvebu-utmi-2.6.0"); 1529c0132f60SStefan Roese 1530c0132f60SStefan Roese i = 0; 1531c0132f60SStefan Roese while (node > 0) { 1532c0132f60SStefan Roese /* get base address of UTMI phy */ 1533c0132f60SStefan Roese cp110_utmi_data[i].utmi_base_addr = 1534c0132f60SStefan Roese (void __iomem *)fdtdec_get_addr_size_auto_noparent( 1535c0132f60SStefan Roese gd->fdt_blob, node, "reg", 0, NULL, true); 1536c0132f60SStefan Roese if (cp110_utmi_data[i].utmi_base_addr == NULL) { 1537c0132f60SStefan Roese error("UTMI PHY base address is invalid\n"); 1538c0132f60SStefan Roese i++; 1539c0132f60SStefan Roese continue; 1540c0132f60SStefan Roese } 1541c0132f60SStefan Roese 1542c0132f60SStefan Roese /* get usb config address */ 1543c0132f60SStefan Roese cp110_utmi_data[i].usb_cfg_addr = 1544c0132f60SStefan Roese (void __iomem *)fdtdec_get_addr_size_auto_noparent( 1545c0132f60SStefan Roese gd->fdt_blob, node, "reg", 1, NULL, true); 1546c0132f60SStefan Roese if (cp110_utmi_data[i].usb_cfg_addr == NULL) { 1547c0132f60SStefan Roese error("UTMI PHY base address is invalid\n"); 1548c0132f60SStefan Roese i++; 1549c0132f60SStefan Roese continue; 1550c0132f60SStefan Roese } 1551c0132f60SStefan Roese 1552c0132f60SStefan Roese /* get UTMI config address */ 1553c0132f60SStefan Roese cp110_utmi_data[i].utmi_cfg_addr = 1554c0132f60SStefan Roese (void __iomem *)fdtdec_get_addr_size_auto_noparent( 1555c0132f60SStefan Roese gd->fdt_blob, node, "reg", 2, NULL, true); 1556c0132f60SStefan Roese if (cp110_utmi_data[i].utmi_cfg_addr == NULL) { 1557c0132f60SStefan Roese error("UTMI PHY base address is invalid\n"); 1558c0132f60SStefan Roese i++; 1559c0132f60SStefan Roese continue; 1560c0132f60SStefan Roese } 1561c0132f60SStefan Roese 1562c0132f60SStefan Roese /* 1563c0132f60SStefan Roese * get the port number (to check if the utmi connected to 1564c0132f60SStefan Roese * host/device) 1565c0132f60SStefan Roese */ 1566c0132f60SStefan Roese cp110_utmi_data[i].utmi_phy_port = fdtdec_get_int( 1567c0132f60SStefan Roese gd->fdt_blob, node, "utmi-port", UTMI_PHY_INVALID); 1568c0132f60SStefan Roese if (cp110_utmi_data[i].utmi_phy_port == UTMI_PHY_INVALID) { 1569c0132f60SStefan Roese error("UTMI PHY port type is invalid\n"); 1570c0132f60SStefan Roese i++; 1571c0132f60SStefan Roese continue; 1572c0132f60SStefan Roese } 1573c0132f60SStefan Roese 1574c0132f60SStefan Roese node = fdt_node_offset_by_compatible( 1575c0132f60SStefan Roese gd->fdt_blob, node, "marvell,mvebu-utmi-2.6.0"); 1576c0132f60SStefan Roese i++; 1577c0132f60SStefan Roese } 1578c0132f60SStefan Roese 1579c0132f60SStefan Roese if (i > 0) 1580c0132f60SStefan Roese comphy_utmi_phy_init(i, cp110_utmi_data); 1581c0132f60SStefan Roese 1582c0132f60SStefan Roese debug_exit(); 1583c0132f60SStefan Roese } 1584c0132f60SStefan Roese 1585c0132f60SStefan Roese static void comphy_mux_cp110_init(struct chip_serdes_phy_config *ptr_chip_cfg, 1586c0132f60SStefan Roese struct comphy_map *serdes_map) 1587c0132f60SStefan Roese { 1588c0132f60SStefan Roese void __iomem *comphy_base_addr; 1589c0132f60SStefan Roese struct comphy_map comphy_map_pipe_data[MAX_LANE_OPTIONS]; 1590c0132f60SStefan Roese struct comphy_map comphy_map_phy_data[MAX_LANE_OPTIONS]; 1591c0132f60SStefan Roese u32 lane, comphy_max_count; 1592c0132f60SStefan Roese 1593c0132f60SStefan Roese comphy_max_count = ptr_chip_cfg->comphy_lanes_count; 1594c0132f60SStefan Roese comphy_base_addr = ptr_chip_cfg->comphy_base_addr; 1595c0132f60SStefan Roese 1596c0132f60SStefan Roese /* 1597c0132f60SStefan Roese * Copy the SerDes map configuration for PIPE map and PHY map 1598c0132f60SStefan Roese * the comphy_mux_init modify the type of the lane if the type 1599c0132f60SStefan Roese * is not valid because we have 2 selectores run the 1600c0132f60SStefan Roese * comphy_mux_init twice and after that update the original 1601c0132f60SStefan Roese * serdes_map 1602c0132f60SStefan Roese */ 1603c0132f60SStefan Roese for (lane = 0; lane < comphy_max_count; lane++) { 1604c0132f60SStefan Roese comphy_map_pipe_data[lane].type = serdes_map[lane].type; 1605c0132f60SStefan Roese comphy_map_pipe_data[lane].speed = serdes_map[lane].speed; 1606c0132f60SStefan Roese comphy_map_phy_data[lane].type = serdes_map[lane].type; 1607c0132f60SStefan Roese comphy_map_phy_data[lane].speed = serdes_map[lane].speed; 1608c0132f60SStefan Roese } 1609c0132f60SStefan Roese ptr_chip_cfg->mux_data = cp110_comphy_phy_mux_data; 1610c0132f60SStefan Roese comphy_mux_init(ptr_chip_cfg, comphy_map_phy_data, 1611c0132f60SStefan Roese comphy_base_addr + COMMON_SELECTOR_PHY_OFFSET); 1612c0132f60SStefan Roese 1613c0132f60SStefan Roese ptr_chip_cfg->mux_data = cp110_comphy_pipe_mux_data; 1614c0132f60SStefan Roese comphy_mux_init(ptr_chip_cfg, comphy_map_pipe_data, 1615c0132f60SStefan Roese comphy_base_addr + COMMON_SELECTOR_PIPE_OFFSET); 1616c0132f60SStefan Roese /* Fix the type after check the PHY and PIPE configuration */ 1617c0132f60SStefan Roese for (lane = 0; lane < comphy_max_count; lane++) { 1618c0132f60SStefan Roese if ((comphy_map_pipe_data[lane].type == PHY_TYPE_UNCONNECTED) && 1619c0132f60SStefan Roese (comphy_map_phy_data[lane].type == PHY_TYPE_UNCONNECTED)) 1620c0132f60SStefan Roese serdes_map[lane].type = PHY_TYPE_UNCONNECTED; 1621c0132f60SStefan Roese } 1622c0132f60SStefan Roese } 1623c0132f60SStefan Roese 1624c0132f60SStefan Roese int comphy_cp110_init(struct chip_serdes_phy_config *ptr_chip_cfg, 1625c0132f60SStefan Roese struct comphy_map *serdes_map) 1626c0132f60SStefan Roese { 1627c0132f60SStefan Roese struct comphy_map *ptr_comphy_map; 1628c0132f60SStefan Roese void __iomem *comphy_base_addr, *hpipe_base_addr; 1629c0132f60SStefan Roese u32 comphy_max_count, lane, ret = 0; 1630c0132f60SStefan Roese u32 pcie_width = 0; 1631c0132f60SStefan Roese 1632c0132f60SStefan Roese debug_enter(); 1633c0132f60SStefan Roese 1634c0132f60SStefan Roese comphy_max_count = ptr_chip_cfg->comphy_lanes_count; 1635c0132f60SStefan Roese comphy_base_addr = ptr_chip_cfg->comphy_base_addr; 1636c0132f60SStefan Roese hpipe_base_addr = ptr_chip_cfg->hpipe3_base_addr; 1637c0132f60SStefan Roese 1638c0132f60SStefan Roese /* Config Comphy mux configuration */ 1639c0132f60SStefan Roese comphy_mux_cp110_init(ptr_chip_cfg, serdes_map); 1640c0132f60SStefan Roese 1641c0132f60SStefan Roese /* Check if the first 4 lanes configured as By-4 */ 1642c0132f60SStefan Roese for (lane = 0, ptr_comphy_map = serdes_map; lane < 4; 1643c0132f60SStefan Roese lane++, ptr_comphy_map++) { 1644c0132f60SStefan Roese if (ptr_comphy_map->type != PHY_TYPE_PEX0) 1645c0132f60SStefan Roese break; 1646c0132f60SStefan Roese pcie_width++; 1647c0132f60SStefan Roese } 1648c0132f60SStefan Roese 1649c0132f60SStefan Roese for (lane = 0, ptr_comphy_map = serdes_map; lane < comphy_max_count; 1650c0132f60SStefan Roese lane++, ptr_comphy_map++) { 1651c0132f60SStefan Roese debug("Initialize serdes number %d\n", lane); 1652c0132f60SStefan Roese debug("Serdes type = 0x%x\n", ptr_comphy_map->type); 1653c0132f60SStefan Roese if (lane == 4) { 1654c0132f60SStefan Roese /* 1655c0132f60SStefan Roese * PCIe lanes above the first 4 lanes, can be only 1656c0132f60SStefan Roese * by1 1657c0132f60SStefan Roese */ 1658c0132f60SStefan Roese pcie_width = 1; 1659c0132f60SStefan Roese } 1660c0132f60SStefan Roese switch (ptr_comphy_map->type) { 1661c0132f60SStefan Roese case PHY_TYPE_UNCONNECTED: 1662c0132f60SStefan Roese continue; 1663c0132f60SStefan Roese break; 1664c0132f60SStefan Roese case PHY_TYPE_PEX0: 1665c0132f60SStefan Roese case PHY_TYPE_PEX1: 1666c0132f60SStefan Roese case PHY_TYPE_PEX2: 1667c0132f60SStefan Roese case PHY_TYPE_PEX3: 1668c0132f60SStefan Roese ret = comphy_pcie_power_up( 1669c0132f60SStefan Roese lane, pcie_width, ptr_comphy_map->clk_src, 1670c0132f60SStefan Roese hpipe_base_addr, comphy_base_addr); 1671c0132f60SStefan Roese break; 1672c0132f60SStefan Roese case PHY_TYPE_SATA0: 1673c0132f60SStefan Roese case PHY_TYPE_SATA1: 1674c0132f60SStefan Roese case PHY_TYPE_SATA2: 1675c0132f60SStefan Roese case PHY_TYPE_SATA3: 1676c0132f60SStefan Roese ret = comphy_sata_power_up( 1677c0132f60SStefan Roese lane, hpipe_base_addr, comphy_base_addr, 1678c0132f60SStefan Roese ptr_chip_cfg->comphy_index); 1679c0132f60SStefan Roese break; 1680c0132f60SStefan Roese case PHY_TYPE_USB3_HOST0: 1681c0132f60SStefan Roese case PHY_TYPE_USB3_HOST1: 1682c0132f60SStefan Roese case PHY_TYPE_USB3_DEVICE: 1683c0132f60SStefan Roese ret = comphy_usb3_power_up(lane, hpipe_base_addr, 1684c0132f60SStefan Roese comphy_base_addr); 1685c0132f60SStefan Roese break; 1686c0132f60SStefan Roese case PHY_TYPE_SGMII0: 1687c0132f60SStefan Roese case PHY_TYPE_SGMII1: 1688c0132f60SStefan Roese case PHY_TYPE_SGMII2: 1689c0132f60SStefan Roese case PHY_TYPE_SGMII3: 1690c0132f60SStefan Roese if (ptr_comphy_map->speed == PHY_SPEED_INVALID) { 1691c0132f60SStefan Roese debug("Warning: SGMII PHY speed in lane %d is invalid, set PHY speed to 1.25G\n", 1692c0132f60SStefan Roese lane); 1693c0132f60SStefan Roese ptr_comphy_map->speed = PHY_SPEED_1_25G; 1694c0132f60SStefan Roese } 1695c0132f60SStefan Roese ret = comphy_sgmii_power_up( 1696c0132f60SStefan Roese lane, ptr_comphy_map->speed, hpipe_base_addr, 1697c0132f60SStefan Roese comphy_base_addr); 1698c0132f60SStefan Roese break; 1699*cb686454SStefan Roese case PHY_TYPE_SFI: 1700*cb686454SStefan Roese ret = comphy_sfi_power_up(lane, hpipe_base_addr, 1701c0132f60SStefan Roese comphy_base_addr); 1702c0132f60SStefan Roese break; 1703c0132f60SStefan Roese case PHY_TYPE_RXAUI0: 1704c0132f60SStefan Roese case PHY_TYPE_RXAUI1: 1705c0132f60SStefan Roese ret = comphy_rxauii_power_up(lane, hpipe_base_addr, 1706c0132f60SStefan Roese comphy_base_addr); 1707c0132f60SStefan Roese break; 1708c0132f60SStefan Roese default: 1709c0132f60SStefan Roese debug("Unknown SerDes type, skip initialize SerDes %d\n", 1710c0132f60SStefan Roese lane); 1711c0132f60SStefan Roese break; 1712c0132f60SStefan Roese } 1713c0132f60SStefan Roese if (ret == 0) { 1714c0132f60SStefan Roese /* 1715c0132f60SStefan Roese * If interface wans't initialiuzed, set the lane to 1716c0132f60SStefan Roese * PHY_TYPE_UNCONNECTED state. 1717c0132f60SStefan Roese */ 1718c0132f60SStefan Roese ptr_comphy_map->type = PHY_TYPE_UNCONNECTED; 1719c0132f60SStefan Roese error("PLL is not locked - Failed to initialize lane %d\n", 1720c0132f60SStefan Roese lane); 1721c0132f60SStefan Roese } 1722c0132f60SStefan Roese } 1723c0132f60SStefan Roese 1724c0132f60SStefan Roese debug_exit(); 1725c0132f60SStefan Roese return 0; 1726c0132f60SStefan Roese } 1727