Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Stefan Roese | 648391c | 2016-08-30 16:48:20 +0200 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2015-2016 Marvell International Ltd. |
Stefan Roese | 648391c | 2016-08-30 16:48:20 +0200 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <common.h> |
| 7 | #include <fdtdec.h> |
Simon Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 8 | #include <log.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 9 | #include <asm/global_data.h> |
Stefan Roese | 648391c | 2016-08-30 16:48:20 +0200 | [diff] [blame] | 10 | #include <asm/io.h> |
Grzegorz Jaszczyk | 7928a8e | 2020-10-18 17:11:11 +0300 | [diff] [blame] | 11 | #include <asm/ptrace.h> |
Stefan Roese | 648391c | 2016-08-30 16:48:20 +0200 | [diff] [blame] | 12 | #include <asm/arch/cpu.h> |
| 13 | #include <asm/arch/soc.h> |
Simon Glass | dbd7954 | 2020-05-10 11:40:11 -0600 | [diff] [blame] | 14 | #include <linux/delay.h> |
Stefan Roese | 648391c | 2016-08-30 16:48:20 +0200 | [diff] [blame] | 15 | |
Marek BehĂșn | 19ce44c | 2018-08-17 12:58:51 +0200 | [diff] [blame] | 16 | #include "comphy_core.h" |
Stefan Roese | 648391c | 2016-08-30 16:48:20 +0200 | [diff] [blame] | 17 | #include "sata.h" |
| 18 | #include "utmi_phy.h" |
| 19 | |
| 20 | DECLARE_GLOBAL_DATA_PTR; |
| 21 | |
Grzegorz Jaszczyk | 7928a8e | 2020-10-18 17:11:11 +0300 | [diff] [blame] | 22 | /* Firmware related definitions used for SMC calls */ |
| 23 | #define MV_SIP_COMPHY_POWER_ON 0x82000001 |
| 24 | #define MV_SIP_COMPHY_POWER_OFF 0x82000002 |
| 25 | #define MV_SIP_COMPHY_PLL_LOCK 0x82000003 |
Grzegorz Jaszczyk | a8e6b49 | 2018-04-03 16:59:12 +0200 | [diff] [blame] | 26 | #define MV_SIP_COMPHY_XFI_TRAIN 0x82000004 |
Grzegorz Jaszczyk | 7928a8e | 2020-10-18 17:11:11 +0300 | [diff] [blame] | 27 | |
Igal Liberman | 67d1a3f | 2020-10-18 17:11:13 +0300 | [diff] [blame] | 28 | /* Used to distinguish between different possible callers (U-boot/Linux) */ |
| 29 | #define COMPHY_CALLER_UBOOT (0x1 << 21) |
| 30 | |
Grzegorz Jaszczyk | 7928a8e | 2020-10-18 17:11:11 +0300 | [diff] [blame] | 31 | #define COMPHY_FW_MODE_FORMAT(mode) ((mode) << 12) |
| 32 | #define COMPHY_FW_FORMAT(mode, idx, speeds) \ |
| 33 | (((mode) << 12) | ((idx) << 8) | ((speeds) << 2)) |
Grzegorz Jaszczyk | c42b5a3 | 2020-10-18 17:11:12 +0300 | [diff] [blame] | 34 | |
| 35 | #define COMPHY_FW_PCIE_FORMAT(pcie_width, clk_src, mode, speeds) \ |
Igal Liberman | 67d1a3f | 2020-10-18 17:11:13 +0300 | [diff] [blame] | 36 | (COMPHY_CALLER_UBOOT | ((pcie_width) << 18) | \ |
| 37 | ((clk_src) << 17) | COMPHY_FW_FORMAT(mode, 0, speeds)) |
Grzegorz Jaszczyk | c42b5a3 | 2020-10-18 17:11:12 +0300 | [diff] [blame] | 38 | |
Grzegorz Jaszczyk | 7928a8e | 2020-10-18 17:11:11 +0300 | [diff] [blame] | 39 | #define COMPHY_SATA_MODE 0x1 |
| 40 | #define COMPHY_SGMII_MODE 0x2 /* SGMII 1G */ |
| 41 | #define COMPHY_HS_SGMII_MODE 0x3 /* SGMII 2.5G */ |
| 42 | #define COMPHY_USB3H_MODE 0x4 |
| 43 | #define COMPHY_USB3D_MODE 0x5 |
| 44 | #define COMPHY_PCIE_MODE 0x6 |
| 45 | #define COMPHY_RXAUI_MODE 0x7 |
| 46 | #define COMPHY_XFI_MODE 0x8 |
| 47 | #define COMPHY_SFI_MODE 0x9 |
| 48 | #define COMPHY_USB3_MODE 0xa |
| 49 | #define COMPHY_AP_MODE 0xb |
| 50 | |
| 51 | /* Comphy unit index macro */ |
| 52 | #define COMPHY_UNIT_ID0 0 |
| 53 | #define COMPHY_UNIT_ID1 1 |
| 54 | #define COMPHY_UNIT_ID2 2 |
| 55 | #define COMPHY_UNIT_ID3 3 |
| 56 | |
Stefan Roese | 648391c | 2016-08-30 16:48:20 +0200 | [diff] [blame] | 57 | struct utmi_phy_data { |
Grzegorz Jaszczyk | 85bb206 | 2019-02-27 15:35:58 +0100 | [diff] [blame^] | 58 | void __iomem *utmi_pll_addr; |
Stefan Roese | 648391c | 2016-08-30 16:48:20 +0200 | [diff] [blame] | 59 | void __iomem *utmi_base_addr; |
| 60 | void __iomem *usb_cfg_addr; |
| 61 | void __iomem *utmi_cfg_addr; |
| 62 | u32 utmi_phy_port; |
| 63 | }; |
| 64 | |
Stefan Roese | 648391c | 2016-08-30 16:48:20 +0200 | [diff] [blame] | 65 | static u32 polling_with_timeout(void __iomem *addr, u32 val, |
| 66 | u32 mask, unsigned long usec_timout) |
| 67 | { |
| 68 | u32 data; |
| 69 | |
| 70 | do { |
| 71 | udelay(1); |
| 72 | data = readl(addr) & mask; |
| 73 | } while (data != val && --usec_timout > 0); |
| 74 | |
| 75 | if (usec_timout == 0) |
| 76 | return data; |
| 77 | |
| 78 | return 0; |
| 79 | } |
| 80 | |
Grzegorz Jaszczyk | a8e6b49 | 2018-04-03 16:59:12 +0200 | [diff] [blame] | 81 | static int comphy_smc(u32 function_id, void __iomem *comphy_base_addr, |
| 82 | u32 lane, u32 mode) |
Igal Liberman | 6795a66 | 2021-03-23 11:57:57 +0100 | [diff] [blame] | 83 | { |
Grzegorz Jaszczyk | a8e6b49 | 2018-04-03 16:59:12 +0200 | [diff] [blame] | 84 | struct pt_regs pregs = {0}; |
Igal Liberman | 6795a66 | 2021-03-23 11:57:57 +0100 | [diff] [blame] | 85 | |
Grzegorz Jaszczyk | a8e6b49 | 2018-04-03 16:59:12 +0200 | [diff] [blame] | 86 | pregs.regs[0] = function_id; |
| 87 | pregs.regs[1] = (unsigned long)comphy_base_addr; |
| 88 | pregs.regs[2] = lane; |
| 89 | pregs.regs[3] = mode; |
Igal Liberman | 6795a66 | 2021-03-23 11:57:57 +0100 | [diff] [blame] | 90 | |
Grzegorz Jaszczyk | a8e6b49 | 2018-04-03 16:59:12 +0200 | [diff] [blame] | 91 | smc_call(&pregs); |
Igal Liberman | 6795a66 | 2021-03-23 11:57:57 +0100 | [diff] [blame] | 92 | |
Grzegorz Jaszczyk | a8e6b49 | 2018-04-03 16:59:12 +0200 | [diff] [blame] | 93 | /* |
| 94 | * TODO: Firmware return 0 on success, temporary map it to u-boot |
| 95 | * convention, but after all comphy will be reworked the convention in |
| 96 | * u-boot should be change and this conversion removed |
| 97 | */ |
| 98 | return pregs.regs[0] ? 0 : 1; |
Igal Liberman | 6795a66 | 2021-03-23 11:57:57 +0100 | [diff] [blame] | 99 | } |
| 100 | |
| 101 | /* This function performs RX training for all FFE possible values. |
| 102 | * We get the result for each FFE and eventually the best FFE will |
| 103 | * be used and set to the HW. |
| 104 | * |
| 105 | * Return '1' on succsess. |
| 106 | * Return '0' on failure. |
| 107 | */ |
| 108 | int comphy_cp110_sfi_rx_training(struct chip_serdes_phy_config *ptr_chip_cfg, |
| 109 | u32 lane) |
| 110 | { |
Igal Liberman | 6795a66 | 2021-03-23 11:57:57 +0100 | [diff] [blame] | 111 | int ret; |
| 112 | |
| 113 | debug_enter(); |
| 114 | |
| 115 | if (ptr_chip_cfg->comphy_map_data[lane].type != COMPHY_TYPE_SFI) { |
| 116 | pr_err("Comphy %d isn't configured to SFI\n", lane); |
| 117 | return 0; |
| 118 | } |
| 119 | |
Grzegorz Jaszczyk | a8e6b49 | 2018-04-03 16:59:12 +0200 | [diff] [blame] | 120 | /* Mode is not relevant for xfi training */ |
| 121 | ret = comphy_smc(MV_SIP_COMPHY_XFI_TRAIN, |
| 122 | ptr_chip_cfg->comphy_base_addr, lane, 0); |
Igal Liberman | 6795a66 | 2021-03-23 11:57:57 +0100 | [diff] [blame] | 123 | |
| 124 | debug_exit(); |
| 125 | |
| 126 | return ret; |
| 127 | } |
| 128 | |
Stefan Roese | 648391c | 2016-08-30 16:48:20 +0200 | [diff] [blame] | 129 | static int comphy_sata_power_up(u32 lane, void __iomem *hpipe_base, |
Grzegorz Jaszczyk | 7928a8e | 2020-10-18 17:11:11 +0300 | [diff] [blame] | 130 | void __iomem *comphy_base_addr, int cp_index, |
| 131 | u32 type) |
Stefan Roese | 648391c | 2016-08-30 16:48:20 +0200 | [diff] [blame] | 132 | { |
| 133 | u32 mask, data, i, ret = 1; |
Stefan Roese | 648391c | 2016-08-30 16:48:20 +0200 | [diff] [blame] | 134 | void __iomem *sata_base = NULL; |
| 135 | int sata_node = -1; /* Set to -1 in order to read the first sata node */ |
| 136 | |
| 137 | debug_enter(); |
| 138 | |
| 139 | /* |
| 140 | * Assumption - each CP has only one SATA controller |
| 141 | * Calling fdt_node_offset_by_compatible first time (with sata_node = -1 |
| 142 | * will return the first node always. |
| 143 | * In order to parse each CPs SATA node, fdt_node_offset_by_compatible |
| 144 | * must be called again (according to the CP id) |
| 145 | */ |
Igal Liberman | c8855ce | 2017-04-24 18:45:32 +0300 | [diff] [blame] | 146 | for (i = 0; i < (cp_index + 1); i++) |
Stefan Roese | 648391c | 2016-08-30 16:48:20 +0200 | [diff] [blame] | 147 | sata_node = fdt_node_offset_by_compatible( |
| 148 | gd->fdt_blob, sata_node, "marvell,armada-8k-ahci"); |
| 149 | |
| 150 | if (sata_node == 0) { |
Masahiro Yamada | 81e1042 | 2017-09-16 14:10:41 +0900 | [diff] [blame] | 151 | pr_err("SATA node not found in FDT\n"); |
Stefan Roese | 648391c | 2016-08-30 16:48:20 +0200 | [diff] [blame] | 152 | return 0; |
| 153 | } |
| 154 | |
| 155 | sata_base = (void __iomem *)fdtdec_get_addr_size_auto_noparent( |
| 156 | gd->fdt_blob, sata_node, "reg", 0, NULL, true); |
| 157 | if (sata_base == NULL) { |
Masahiro Yamada | 81e1042 | 2017-09-16 14:10:41 +0900 | [diff] [blame] | 158 | pr_err("SATA address not found in FDT\n"); |
Stefan Roese | 648391c | 2016-08-30 16:48:20 +0200 | [diff] [blame] | 159 | return 0; |
| 160 | } |
| 161 | |
| 162 | debug("SATA address found in FDT %p\n", sata_base); |
| 163 | |
| 164 | debug("stage: MAC configuration - power down comphy\n"); |
| 165 | /* |
| 166 | * MAC configuration powe down comphy use indirect address for |
| 167 | * vendor spesific SATA control register |
| 168 | */ |
| 169 | reg_set(sata_base + SATA3_VENDOR_ADDRESS, |
| 170 | SATA_CONTROL_REG << SATA3_VENDOR_ADDR_OFSSET, |
| 171 | SATA3_VENDOR_ADDR_MASK); |
| 172 | /* SATA 0 power down */ |
| 173 | mask = SATA3_CTRL_SATA0_PD_MASK; |
| 174 | data = 0x1 << SATA3_CTRL_SATA0_PD_OFFSET; |
| 175 | /* SATA 1 power down */ |
| 176 | mask |= SATA3_CTRL_SATA1_PD_MASK; |
| 177 | data |= 0x1 << SATA3_CTRL_SATA1_PD_OFFSET; |
| 178 | /* SATA SSU disable */ |
| 179 | mask |= SATA3_CTRL_SATA1_ENABLE_MASK; |
| 180 | data |= 0x0 << SATA3_CTRL_SATA1_ENABLE_OFFSET; |
| 181 | /* SATA port 1 disable */ |
| 182 | mask |= SATA3_CTRL_SATA_SSU_MASK; |
| 183 | data |= 0x0 << SATA3_CTRL_SATA_SSU_OFFSET; |
| 184 | reg_set(sata_base + SATA3_VENDOR_DATA, data, mask); |
| 185 | |
Grzegorz Jaszczyk | 7928a8e | 2020-10-18 17:11:11 +0300 | [diff] [blame] | 186 | ret = comphy_smc(MV_SIP_COMPHY_POWER_ON, comphy_base_addr, lane, type); |
Stefan Roese | 648391c | 2016-08-30 16:48:20 +0200 | [diff] [blame] | 187 | |
Stefan Roese | 648391c | 2016-08-30 16:48:20 +0200 | [diff] [blame] | 188 | /* |
| 189 | * MAC configuration power up comphy - power up PLL/TX/RX |
| 190 | * use indirect address for vendor spesific SATA control register |
| 191 | */ |
| 192 | reg_set(sata_base + SATA3_VENDOR_ADDRESS, |
| 193 | SATA_CONTROL_REG << SATA3_VENDOR_ADDR_OFSSET, |
| 194 | SATA3_VENDOR_ADDR_MASK); |
| 195 | /* SATA 0 power up */ |
| 196 | mask = SATA3_CTRL_SATA0_PD_MASK; |
| 197 | data = 0x0 << SATA3_CTRL_SATA0_PD_OFFSET; |
| 198 | /* SATA 1 power up */ |
| 199 | mask |= SATA3_CTRL_SATA1_PD_MASK; |
| 200 | data |= 0x0 << SATA3_CTRL_SATA1_PD_OFFSET; |
| 201 | /* SATA SSU enable */ |
| 202 | mask |= SATA3_CTRL_SATA1_ENABLE_MASK; |
| 203 | data |= 0x1 << SATA3_CTRL_SATA1_ENABLE_OFFSET; |
| 204 | /* SATA port 1 enable */ |
| 205 | mask |= SATA3_CTRL_SATA_SSU_MASK; |
| 206 | data |= 0x1 << SATA3_CTRL_SATA_SSU_OFFSET; |
| 207 | reg_set(sata_base + SATA3_VENDOR_DATA, data, mask); |
| 208 | |
| 209 | /* MBUS request size and interface select register */ |
| 210 | reg_set(sata_base + SATA3_VENDOR_ADDRESS, |
| 211 | SATA_MBUS_SIZE_SELECT_REG << SATA3_VENDOR_ADDR_OFSSET, |
| 212 | SATA3_VENDOR_ADDR_MASK); |
| 213 | /* Mbus regret enable */ |
| 214 | reg_set(sata_base + SATA3_VENDOR_DATA, |
| 215 | 0x1 << SATA_MBUS_REGRET_EN_OFFSET, SATA_MBUS_REGRET_EN_MASK); |
| 216 | |
Grzegorz Jaszczyk | 7928a8e | 2020-10-18 17:11:11 +0300 | [diff] [blame] | 217 | ret = comphy_smc(MV_SIP_COMPHY_PLL_LOCK, comphy_base_addr, lane, type); |
Stefan Roese | 648391c | 2016-08-30 16:48:20 +0200 | [diff] [blame] | 218 | |
| 219 | debug_exit(); |
| 220 | return ret; |
| 221 | } |
| 222 | |
Stefan Roese | 648391c | 2016-08-30 16:48:20 +0200 | [diff] [blame] | 223 | static void comphy_utmi_power_down(u32 utmi_index, void __iomem *utmi_base_addr, |
| 224 | void __iomem *usb_cfg_addr, |
| 225 | void __iomem *utmi_cfg_addr, |
| 226 | u32 utmi_phy_port) |
| 227 | { |
| 228 | u32 mask, data; |
| 229 | |
| 230 | debug_enter(); |
| 231 | debug("stage: UTMI %d - Power down transceiver (power down Phy), Power down PLL, and SuspendDM\n", |
| 232 | utmi_index); |
| 233 | /* Power down UTMI PHY */ |
| 234 | reg_set(utmi_cfg_addr, 0x0 << UTMI_PHY_CFG_PU_OFFSET, |
| 235 | UTMI_PHY_CFG_PU_MASK); |
| 236 | |
| 237 | /* |
| 238 | * If UTMI connected to USB Device, configure mux prior to PHY init |
| 239 | * (Device can be connected to UTMI0 or to UTMI1) |
| 240 | */ |
Stefan Roese | b781f57 | 2017-04-24 18:45:23 +0300 | [diff] [blame] | 241 | if (utmi_phy_port == UTMI_PHY_TO_USB3_DEVICE0) { |
Stefan Roese | 648391c | 2016-08-30 16:48:20 +0200 | [diff] [blame] | 242 | debug("stage: UTMI %d - Enable Device mode and configure UTMI mux\n", |
| 243 | utmi_index); |
| 244 | /* USB3 Device UTMI enable */ |
| 245 | mask = UTMI_USB_CFG_DEVICE_EN_MASK; |
| 246 | data = 0x1 << UTMI_USB_CFG_DEVICE_EN_OFFSET; |
| 247 | /* USB3 Device UTMI MUX */ |
| 248 | mask |= UTMI_USB_CFG_DEVICE_MUX_MASK; |
| 249 | data |= utmi_index << UTMI_USB_CFG_DEVICE_MUX_OFFSET; |
| 250 | reg_set(usb_cfg_addr, data, mask); |
| 251 | } |
| 252 | |
| 253 | /* Set Test suspendm mode */ |
| 254 | mask = UTMI_CTRL_STATUS0_SUSPENDM_MASK; |
| 255 | data = 0x1 << UTMI_CTRL_STATUS0_SUSPENDM_OFFSET; |
| 256 | /* Enable Test UTMI select */ |
| 257 | mask |= UTMI_CTRL_STATUS0_TEST_SEL_MASK; |
| 258 | data |= 0x1 << UTMI_CTRL_STATUS0_TEST_SEL_OFFSET; |
| 259 | reg_set(utmi_base_addr + UTMI_CTRL_STATUS0_REG, data, mask); |
| 260 | |
| 261 | /* Wait for UTMI power down */ |
| 262 | mdelay(1); |
| 263 | |
| 264 | debug_exit(); |
| 265 | return; |
| 266 | } |
| 267 | |
Grzegorz Jaszczyk | 85bb206 | 2019-02-27 15:35:58 +0100 | [diff] [blame^] | 268 | static void comphy_utmi_phy_config(u32 utmi_index, void __iomem *utmi_pll_addr, |
| 269 | void __iomem *utmi_base_addr, |
Stefan Roese | 648391c | 2016-08-30 16:48:20 +0200 | [diff] [blame] | 270 | void __iomem *usb_cfg_addr, |
| 271 | void __iomem *utmi_cfg_addr, |
| 272 | u32 utmi_phy_port) |
| 273 | { |
| 274 | u32 mask, data; |
| 275 | |
| 276 | debug_exit(); |
| 277 | debug("stage: Configure UTMI PHY %d registers\n", utmi_index); |
| 278 | /* Reference Clock Divider Select */ |
| 279 | mask = UTMI_PLL_CTRL_REFDIV_MASK; |
| 280 | data = 0x5 << UTMI_PLL_CTRL_REFDIV_OFFSET; |
| 281 | /* Feedback Clock Divider Select - 90 for 25Mhz*/ |
| 282 | mask |= UTMI_PLL_CTRL_FBDIV_MASK; |
| 283 | data |= 0x60 << UTMI_PLL_CTRL_FBDIV_OFFSET; |
| 284 | /* Select LPFR - 0x0 for 25Mhz/5=5Mhz*/ |
| 285 | mask |= UTMI_PLL_CTRL_SEL_LPFR_MASK; |
| 286 | data |= 0x0 << UTMI_PLL_CTRL_SEL_LPFR_OFFSET; |
Grzegorz Jaszczyk | 85bb206 | 2019-02-27 15:35:58 +0100 | [diff] [blame^] | 287 | reg_set(utmi_pll_addr + UTMI_PLL_CTRL_REG, data, mask); |
Stefan Roese | 648391c | 2016-08-30 16:48:20 +0200 | [diff] [blame] | 288 | |
| 289 | /* Impedance Calibration Threshold Setting */ |
Grzegorz Jaszczyk | 85bb206 | 2019-02-27 15:35:58 +0100 | [diff] [blame^] | 290 | reg_set(utmi_pll_addr + UTMI_CALIB_CTRL_REG, |
Igal Liberman | 32af216 | 2017-04-30 20:16:55 +0300 | [diff] [blame] | 291 | 0x7 << UTMI_CALIB_CTRL_IMPCAL_VTH_OFFSET, |
Stefan Roese | 648391c | 2016-08-30 16:48:20 +0200 | [diff] [blame] | 292 | UTMI_CALIB_CTRL_IMPCAL_VTH_MASK); |
| 293 | |
| 294 | /* Set LS TX driver strength coarse control */ |
Igal Liberman | 32af216 | 2017-04-30 20:16:55 +0300 | [diff] [blame] | 295 | mask = UTMI_TX_CH_CTRL_AMP_MASK; |
| 296 | data = 0x4 << UTMI_TX_CH_CTRL_AMP_OFFSET; |
Stefan Roese | 648391c | 2016-08-30 16:48:20 +0200 | [diff] [blame] | 297 | reg_set(utmi_base_addr + UTMI_TX_CH_CTRL_REG, data, mask); |
| 298 | |
| 299 | /* Enable SQ */ |
| 300 | mask = UTMI_RX_CH_CTRL0_SQ_DET_MASK; |
| 301 | data = 0x0 << UTMI_RX_CH_CTRL0_SQ_DET_OFFSET; |
| 302 | /* Enable analog squelch detect */ |
| 303 | mask |= UTMI_RX_CH_CTRL0_SQ_ANA_DTC_MASK; |
| 304 | data |= 0x1 << UTMI_RX_CH_CTRL0_SQ_ANA_DTC_OFFSET; |
| 305 | reg_set(utmi_base_addr + UTMI_RX_CH_CTRL0_REG, data, mask); |
| 306 | |
| 307 | /* Set External squelch calibration number */ |
| 308 | mask = UTMI_RX_CH_CTRL1_SQ_AMP_CAL_MASK; |
| 309 | data = 0x1 << UTMI_RX_CH_CTRL1_SQ_AMP_CAL_OFFSET; |
| 310 | /* Enable the External squelch calibration */ |
| 311 | mask |= UTMI_RX_CH_CTRL1_SQ_AMP_CAL_EN_MASK; |
| 312 | data |= 0x1 << UTMI_RX_CH_CTRL1_SQ_AMP_CAL_EN_OFFSET; |
| 313 | reg_set(utmi_base_addr + UTMI_RX_CH_CTRL1_REG, data, mask); |
| 314 | |
| 315 | /* Set Control VDAT Reference Voltage - 0.325V */ |
| 316 | mask = UTMI_CHGDTC_CTRL_VDAT_MASK; |
| 317 | data = 0x1 << UTMI_CHGDTC_CTRL_VDAT_OFFSET; |
| 318 | /* Set Control VSRC Reference Voltage - 0.6V */ |
| 319 | mask |= UTMI_CHGDTC_CTRL_VSRC_MASK; |
| 320 | data |= 0x1 << UTMI_CHGDTC_CTRL_VSRC_OFFSET; |
| 321 | reg_set(utmi_base_addr + UTMI_CHGDTC_CTRL_REG, data, mask); |
| 322 | |
| 323 | debug_exit(); |
| 324 | return; |
| 325 | } |
| 326 | |
Grzegorz Jaszczyk | 85bb206 | 2019-02-27 15:35:58 +0100 | [diff] [blame^] | 327 | static int comphy_utmi_power_up(u32 utmi_index, void __iomem *utmi_pll_addr, |
| 328 | void __iomem *utmi_base_addr, |
Stefan Roese | 648391c | 2016-08-30 16:48:20 +0200 | [diff] [blame] | 329 | void __iomem *usb_cfg_addr, |
| 330 | void __iomem *utmi_cfg_addr, u32 utmi_phy_port) |
| 331 | { |
| 332 | u32 data, mask, ret = 1; |
| 333 | void __iomem *addr; |
| 334 | |
| 335 | debug_enter(); |
| 336 | debug("stage: UTMI %d - Power up transceiver(Power up Phy), and exit SuspendDM\n", |
| 337 | utmi_index); |
| 338 | /* Power UP UTMI PHY */ |
| 339 | reg_set(utmi_cfg_addr, 0x1 << UTMI_PHY_CFG_PU_OFFSET, |
| 340 | UTMI_PHY_CFG_PU_MASK); |
| 341 | /* Disable Test UTMI select */ |
| 342 | reg_set(utmi_base_addr + UTMI_CTRL_STATUS0_REG, |
| 343 | 0x0 << UTMI_CTRL_STATUS0_TEST_SEL_OFFSET, |
| 344 | UTMI_CTRL_STATUS0_TEST_SEL_MASK); |
| 345 | |
| 346 | debug("stage: Polling for PLL and impedance calibration done, and PLL ready done\n"); |
Grzegorz Jaszczyk | 85bb206 | 2019-02-27 15:35:58 +0100 | [diff] [blame^] | 347 | addr = utmi_pll_addr + UTMI_CALIB_CTRL_REG; |
Stefan Roese | 648391c | 2016-08-30 16:48:20 +0200 | [diff] [blame] | 348 | data = UTMI_CALIB_CTRL_IMPCAL_DONE_MASK; |
| 349 | mask = data; |
| 350 | data = polling_with_timeout(addr, data, mask, 100); |
| 351 | if (data != 0) { |
Masahiro Yamada | 81e1042 | 2017-09-16 14:10:41 +0900 | [diff] [blame] | 352 | pr_err("Impedance calibration is not done\n"); |
Stefan Roese | 648391c | 2016-08-30 16:48:20 +0200 | [diff] [blame] | 353 | debug("Read from reg = %p - value = 0x%x\n", addr, data); |
| 354 | ret = 0; |
| 355 | } |
| 356 | |
| 357 | data = UTMI_CALIB_CTRL_PLLCAL_DONE_MASK; |
| 358 | mask = data; |
| 359 | data = polling_with_timeout(addr, data, mask, 100); |
| 360 | if (data != 0) { |
Masahiro Yamada | 81e1042 | 2017-09-16 14:10:41 +0900 | [diff] [blame] | 361 | pr_err("PLL calibration is not done\n"); |
Stefan Roese | 648391c | 2016-08-30 16:48:20 +0200 | [diff] [blame] | 362 | debug("Read from reg = %p - value = 0x%x\n", addr, data); |
| 363 | ret = 0; |
| 364 | } |
| 365 | |
Grzegorz Jaszczyk | 85bb206 | 2019-02-27 15:35:58 +0100 | [diff] [blame^] | 366 | addr = utmi_pll_addr + UTMI_PLL_CTRL_REG; |
Stefan Roese | 648391c | 2016-08-30 16:48:20 +0200 | [diff] [blame] | 367 | data = UTMI_PLL_CTRL_PLL_RDY_MASK; |
| 368 | mask = data; |
| 369 | data = polling_with_timeout(addr, data, mask, 100); |
| 370 | if (data != 0) { |
Masahiro Yamada | 81e1042 | 2017-09-16 14:10:41 +0900 | [diff] [blame] | 371 | pr_err("PLL is not ready\n"); |
Stefan Roese | 648391c | 2016-08-30 16:48:20 +0200 | [diff] [blame] | 372 | debug("Read from reg = %p - value = 0x%x\n", addr, data); |
| 373 | ret = 0; |
| 374 | } |
| 375 | |
| 376 | if (ret) |
| 377 | debug("Passed\n"); |
| 378 | else |
| 379 | debug("\n"); |
| 380 | |
| 381 | debug_exit(); |
| 382 | return ret; |
| 383 | } |
| 384 | |
| 385 | /* |
| 386 | * comphy_utmi_phy_init initialize the UTMI PHY |
| 387 | * the init split in 3 parts: |
| 388 | * 1. Power down transceiver and PLL |
| 389 | * 2. UTMI PHY configure |
Omri Itach | 561930c | 2017-04-06 12:54:16 +0300 | [diff] [blame] | 390 | * 3. Power up transceiver and PLL |
Stefan Roese | 648391c | 2016-08-30 16:48:20 +0200 | [diff] [blame] | 391 | * Note: - Power down/up should be once for both UTMI PHYs |
| 392 | * - comphy_dedicated_phys_init call this function if at least there is |
| 393 | * one UTMI PHY exists in FDT blob. access to cp110_utmi_data[0] is |
| 394 | * legal |
| 395 | */ |
| 396 | static void comphy_utmi_phy_init(u32 utmi_phy_count, |
| 397 | struct utmi_phy_data *cp110_utmi_data) |
| 398 | { |
| 399 | u32 i; |
| 400 | |
| 401 | debug_enter(); |
| 402 | /* UTMI Power down */ |
| 403 | for (i = 0; i < utmi_phy_count; i++) { |
| 404 | comphy_utmi_power_down(i, cp110_utmi_data[i].utmi_base_addr, |
| 405 | cp110_utmi_data[i].usb_cfg_addr, |
| 406 | cp110_utmi_data[i].utmi_cfg_addr, |
| 407 | cp110_utmi_data[i].utmi_phy_port); |
| 408 | } |
| 409 | /* PLL Power down */ |
| 410 | debug("stage: UTMI PHY power down PLL\n"); |
| 411 | for (i = 0; i < utmi_phy_count; i++) { |
| 412 | reg_set(cp110_utmi_data[i].usb_cfg_addr, |
| 413 | 0x0 << UTMI_USB_CFG_PLL_OFFSET, UTMI_USB_CFG_PLL_MASK); |
| 414 | } |
| 415 | /* UTMI configure */ |
| 416 | for (i = 0; i < utmi_phy_count; i++) { |
Grzegorz Jaszczyk | 85bb206 | 2019-02-27 15:35:58 +0100 | [diff] [blame^] | 417 | comphy_utmi_phy_config(i, cp110_utmi_data[i].utmi_pll_addr, |
| 418 | cp110_utmi_data[i].utmi_base_addr, |
Stefan Roese | 648391c | 2016-08-30 16:48:20 +0200 | [diff] [blame] | 419 | cp110_utmi_data[i].usb_cfg_addr, |
| 420 | cp110_utmi_data[i].utmi_cfg_addr, |
| 421 | cp110_utmi_data[i].utmi_phy_port); |
| 422 | } |
| 423 | /* UTMI Power up */ |
| 424 | for (i = 0; i < utmi_phy_count; i++) { |
Grzegorz Jaszczyk | 85bb206 | 2019-02-27 15:35:58 +0100 | [diff] [blame^] | 425 | if (!comphy_utmi_power_up(i, cp110_utmi_data[i].utmi_pll_addr, |
| 426 | cp110_utmi_data[i].utmi_base_addr, |
Stefan Roese | 648391c | 2016-08-30 16:48:20 +0200 | [diff] [blame] | 427 | cp110_utmi_data[i].usb_cfg_addr, |
| 428 | cp110_utmi_data[i].utmi_cfg_addr, |
| 429 | cp110_utmi_data[i].utmi_phy_port)) { |
Masahiro Yamada | 81e1042 | 2017-09-16 14:10:41 +0900 | [diff] [blame] | 430 | pr_err("Failed to initialize UTMI PHY %d\n", i); |
Stefan Roese | 648391c | 2016-08-30 16:48:20 +0200 | [diff] [blame] | 431 | continue; |
| 432 | } |
| 433 | printf("UTMI PHY %d initialized to ", i); |
Stefan Roese | b781f57 | 2017-04-24 18:45:23 +0300 | [diff] [blame] | 434 | if (cp110_utmi_data[i].utmi_phy_port == |
| 435 | UTMI_PHY_TO_USB3_DEVICE0) |
Stefan Roese | 648391c | 2016-08-30 16:48:20 +0200 | [diff] [blame] | 436 | printf("USB Device\n"); |
| 437 | else |
| 438 | printf("USB Host%d\n", |
| 439 | cp110_utmi_data[i].utmi_phy_port); |
| 440 | } |
| 441 | /* PLL Power up */ |
| 442 | debug("stage: UTMI PHY power up PLL\n"); |
| 443 | for (i = 0; i < utmi_phy_count; i++) { |
| 444 | reg_set(cp110_utmi_data[i].usb_cfg_addr, |
| 445 | 0x1 << UTMI_USB_CFG_PLL_OFFSET, UTMI_USB_CFG_PLL_MASK); |
| 446 | } |
| 447 | |
| 448 | debug_exit(); |
| 449 | return; |
| 450 | } |
| 451 | |
| 452 | /* |
| 453 | * comphy_dedicated_phys_init initialize the dedicated PHYs |
| 454 | * - not muxed SerDes lanes e.g. UTMI PHY |
| 455 | */ |
| 456 | void comphy_dedicated_phys_init(void) |
| 457 | { |
| 458 | struct utmi_phy_data cp110_utmi_data[MAX_UTMI_PHY_COUNT]; |
Omri Itach | 561930c | 2017-04-06 12:54:16 +0300 | [diff] [blame] | 459 | int node = -1; |
| 460 | int node_idx; |
Grzegorz Jaszczyk | 85bb206 | 2019-02-27 15:35:58 +0100 | [diff] [blame^] | 461 | int parent = -1; |
Stefan Roese | 648391c | 2016-08-30 16:48:20 +0200 | [diff] [blame] | 462 | |
| 463 | debug_enter(); |
| 464 | debug("Initialize USB UTMI PHYs\n"); |
| 465 | |
Omri Itach | 561930c | 2017-04-06 12:54:16 +0300 | [diff] [blame] | 466 | for (node_idx = 0; node_idx < MAX_UTMI_PHY_COUNT;) { |
| 467 | /* Find the UTMI phy node in device tree */ |
| 468 | node = fdt_node_offset_by_compatible(gd->fdt_blob, node, |
| 469 | "marvell,mvebu-utmi-2.6.0"); |
| 470 | if (node <= 0) |
| 471 | break; |
Stefan Roese | 648391c | 2016-08-30 16:48:20 +0200 | [diff] [blame] | 472 | |
Omri Itach | 561930c | 2017-04-06 12:54:16 +0300 | [diff] [blame] | 473 | /* check if node is enabled */ |
| 474 | if (!fdtdec_get_is_enabled(gd->fdt_blob, node)) |
| 475 | continue; |
| 476 | |
Grzegorz Jaszczyk | 85bb206 | 2019-02-27 15:35:58 +0100 | [diff] [blame^] | 477 | parent = fdt_parent_offset(gd->fdt_blob, node); |
| 478 | if (parent <= 0) |
| 479 | break; |
| 480 | |
| 481 | /* get base address of UTMI PLL */ |
| 482 | cp110_utmi_data[node_idx].utmi_pll_addr = |
| 483 | (void __iomem *)fdtdec_get_addr_size_auto_noparent( |
| 484 | gd->fdt_blob, parent, "reg", 0, NULL, true); |
| 485 | if (!cp110_utmi_data[node_idx].utmi_pll_addr) { |
| 486 | pr_err("UTMI PHY PLL address is invalid\n"); |
| 487 | continue; |
| 488 | } |
| 489 | |
Stefan Roese | 648391c | 2016-08-30 16:48:20 +0200 | [diff] [blame] | 490 | /* get base address of UTMI phy */ |
Omri Itach | 561930c | 2017-04-06 12:54:16 +0300 | [diff] [blame] | 491 | cp110_utmi_data[node_idx].utmi_base_addr = |
Stefan Roese | 648391c | 2016-08-30 16:48:20 +0200 | [diff] [blame] | 492 | (void __iomem *)fdtdec_get_addr_size_auto_noparent( |
| 493 | gd->fdt_blob, node, "reg", 0, NULL, true); |
Omri Itach | 561930c | 2017-04-06 12:54:16 +0300 | [diff] [blame] | 494 | if (!cp110_utmi_data[node_idx].utmi_base_addr) { |
Masahiro Yamada | 81e1042 | 2017-09-16 14:10:41 +0900 | [diff] [blame] | 495 | pr_err("UTMI PHY base address is invalid\n"); |
Stefan Roese | 648391c | 2016-08-30 16:48:20 +0200 | [diff] [blame] | 496 | continue; |
| 497 | } |
| 498 | |
| 499 | /* get usb config address */ |
Omri Itach | 561930c | 2017-04-06 12:54:16 +0300 | [diff] [blame] | 500 | cp110_utmi_data[node_idx].usb_cfg_addr = |
Stefan Roese | 648391c | 2016-08-30 16:48:20 +0200 | [diff] [blame] | 501 | (void __iomem *)fdtdec_get_addr_size_auto_noparent( |
| 502 | gd->fdt_blob, node, "reg", 1, NULL, true); |
Omri Itach | 561930c | 2017-04-06 12:54:16 +0300 | [diff] [blame] | 503 | if (!cp110_utmi_data[node_idx].usb_cfg_addr) { |
Masahiro Yamada | 81e1042 | 2017-09-16 14:10:41 +0900 | [diff] [blame] | 504 | pr_err("UTMI PHY base address is invalid\n"); |
Stefan Roese | 648391c | 2016-08-30 16:48:20 +0200 | [diff] [blame] | 505 | continue; |
| 506 | } |
| 507 | |
| 508 | /* get UTMI config address */ |
Omri Itach | 561930c | 2017-04-06 12:54:16 +0300 | [diff] [blame] | 509 | cp110_utmi_data[node_idx].utmi_cfg_addr = |
Stefan Roese | 648391c | 2016-08-30 16:48:20 +0200 | [diff] [blame] | 510 | (void __iomem *)fdtdec_get_addr_size_auto_noparent( |
| 511 | gd->fdt_blob, node, "reg", 2, NULL, true); |
Omri Itach | 561930c | 2017-04-06 12:54:16 +0300 | [diff] [blame] | 512 | if (!cp110_utmi_data[node_idx].utmi_cfg_addr) { |
Masahiro Yamada | 81e1042 | 2017-09-16 14:10:41 +0900 | [diff] [blame] | 513 | pr_err("UTMI PHY base address is invalid\n"); |
Stefan Roese | 648391c | 2016-08-30 16:48:20 +0200 | [diff] [blame] | 514 | continue; |
| 515 | } |
| 516 | |
| 517 | /* |
| 518 | * get the port number (to check if the utmi connected to |
| 519 | * host/device) |
| 520 | */ |
Omri Itach | 561930c | 2017-04-06 12:54:16 +0300 | [diff] [blame] | 521 | cp110_utmi_data[node_idx].utmi_phy_port = fdtdec_get_int( |
Stefan Roese | 648391c | 2016-08-30 16:48:20 +0200 | [diff] [blame] | 522 | gd->fdt_blob, node, "utmi-port", UTMI_PHY_INVALID); |
Omri Itach | 561930c | 2017-04-06 12:54:16 +0300 | [diff] [blame] | 523 | if (cp110_utmi_data[node_idx].utmi_phy_port == |
| 524 | UTMI_PHY_INVALID) { |
Masahiro Yamada | 81e1042 | 2017-09-16 14:10:41 +0900 | [diff] [blame] | 525 | pr_err("UTMI PHY port type is invalid\n"); |
Stefan Roese | 648391c | 2016-08-30 16:48:20 +0200 | [diff] [blame] | 526 | continue; |
| 527 | } |
| 528 | |
Omri Itach | 561930c | 2017-04-06 12:54:16 +0300 | [diff] [blame] | 529 | /* count valid UTMI unit */ |
| 530 | node_idx++; |
Stefan Roese | 648391c | 2016-08-30 16:48:20 +0200 | [diff] [blame] | 531 | } |
| 532 | |
Omri Itach | 561930c | 2017-04-06 12:54:16 +0300 | [diff] [blame] | 533 | if (node_idx > 0) |
| 534 | comphy_utmi_phy_init(node_idx, cp110_utmi_data); |
Stefan Roese | 648391c | 2016-08-30 16:48:20 +0200 | [diff] [blame] | 535 | |
| 536 | debug_exit(); |
| 537 | } |
| 538 | |
Stefan Roese | 648391c | 2016-08-30 16:48:20 +0200 | [diff] [blame] | 539 | int comphy_cp110_init(struct chip_serdes_phy_config *ptr_chip_cfg, |
| 540 | struct comphy_map *serdes_map) |
| 541 | { |
| 542 | struct comphy_map *ptr_comphy_map; |
| 543 | void __iomem *comphy_base_addr, *hpipe_base_addr; |
Igal Liberman | d009fee | 2018-05-09 18:50:29 +0300 | [diff] [blame] | 544 | u32 comphy_max_count, lane, id, ret = 0; |
Stefan Roese | 648391c | 2016-08-30 16:48:20 +0200 | [diff] [blame] | 545 | u32 pcie_width = 0; |
Grzegorz Jaszczyk | 7928a8e | 2020-10-18 17:11:11 +0300 | [diff] [blame] | 546 | u32 mode; |
Stefan Roese | 648391c | 2016-08-30 16:48:20 +0200 | [diff] [blame] | 547 | |
| 548 | debug_enter(); |
| 549 | |
| 550 | comphy_max_count = ptr_chip_cfg->comphy_lanes_count; |
| 551 | comphy_base_addr = ptr_chip_cfg->comphy_base_addr; |
| 552 | hpipe_base_addr = ptr_chip_cfg->hpipe3_base_addr; |
| 553 | |
Stefan Roese | 648391c | 2016-08-30 16:48:20 +0200 | [diff] [blame] | 554 | /* Check if the first 4 lanes configured as By-4 */ |
| 555 | for (lane = 0, ptr_comphy_map = serdes_map; lane < 4; |
| 556 | lane++, ptr_comphy_map++) { |
Igal Liberman | ffd5d2f | 2017-04-26 15:40:00 +0300 | [diff] [blame] | 557 | if (ptr_comphy_map->type != COMPHY_TYPE_PEX0) |
Stefan Roese | 648391c | 2016-08-30 16:48:20 +0200 | [diff] [blame] | 558 | break; |
| 559 | pcie_width++; |
| 560 | } |
| 561 | |
| 562 | for (lane = 0, ptr_comphy_map = serdes_map; lane < comphy_max_count; |
| 563 | lane++, ptr_comphy_map++) { |
| 564 | debug("Initialize serdes number %d\n", lane); |
| 565 | debug("Serdes type = 0x%x\n", ptr_comphy_map->type); |
| 566 | if (lane == 4) { |
| 567 | /* |
| 568 | * PCIe lanes above the first 4 lanes, can be only |
| 569 | * by1 |
| 570 | */ |
| 571 | pcie_width = 1; |
| 572 | } |
| 573 | switch (ptr_comphy_map->type) { |
Igal Liberman | ffd5d2f | 2017-04-26 15:40:00 +0300 | [diff] [blame] | 574 | case COMPHY_TYPE_UNCONNECTED: |
Igal Liberman | d622f8e | 2018-11-19 09:58:32 +0200 | [diff] [blame] | 575 | mode = COMPHY_TYPE_UNCONNECTED | COMPHY_CALLER_UBOOT; |
Christine Gharzuzi | c63fa15 | 2018-05-23 12:10:36 +0300 | [diff] [blame] | 576 | ret = comphy_smc(MV_SIP_COMPHY_POWER_OFF, |
| 577 | ptr_chip_cfg->comphy_base_addr, |
Igal Liberman | d622f8e | 2018-11-19 09:58:32 +0200 | [diff] [blame] | 578 | lane, mode); |
Igal Liberman | ffd5d2f | 2017-04-26 15:40:00 +0300 | [diff] [blame] | 579 | case COMPHY_TYPE_IGNORE: |
Stefan Roese | 648391c | 2016-08-30 16:48:20 +0200 | [diff] [blame] | 580 | continue; |
| 581 | break; |
Igal Liberman | ffd5d2f | 2017-04-26 15:40:00 +0300 | [diff] [blame] | 582 | case COMPHY_TYPE_PEX0: |
| 583 | case COMPHY_TYPE_PEX1: |
| 584 | case COMPHY_TYPE_PEX2: |
| 585 | case COMPHY_TYPE_PEX3: |
Grzegorz Jaszczyk | c42b5a3 | 2020-10-18 17:11:12 +0300 | [diff] [blame] | 586 | mode = COMPHY_FW_PCIE_FORMAT(pcie_width, |
| 587 | ptr_comphy_map->clk_src, |
| 588 | COMPHY_PCIE_MODE, |
| 589 | ptr_comphy_map->speed); |
| 590 | ret = comphy_smc(MV_SIP_COMPHY_POWER_ON, |
| 591 | ptr_chip_cfg->comphy_base_addr, lane, |
| 592 | mode); |
Stefan Roese | 648391c | 2016-08-30 16:48:20 +0200 | [diff] [blame] | 593 | break; |
Igal Liberman | ffd5d2f | 2017-04-26 15:40:00 +0300 | [diff] [blame] | 594 | case COMPHY_TYPE_SATA0: |
| 595 | case COMPHY_TYPE_SATA1: |
Grzegorz Jaszczyk | 7928a8e | 2020-10-18 17:11:11 +0300 | [diff] [blame] | 596 | mode = COMPHY_FW_MODE_FORMAT(COMPHY_SATA_MODE); |
| 597 | ret = comphy_sata_power_up(lane, hpipe_base_addr, |
| 598 | comphy_base_addr, |
| 599 | ptr_chip_cfg->cp_index, |
| 600 | mode); |
Stefan Roese | 648391c | 2016-08-30 16:48:20 +0200 | [diff] [blame] | 601 | break; |
Igal Liberman | ffd5d2f | 2017-04-26 15:40:00 +0300 | [diff] [blame] | 602 | case COMPHY_TYPE_USB3_HOST0: |
| 603 | case COMPHY_TYPE_USB3_HOST1: |
Grzegorz Jaszczyk | e165970 | 2018-03-29 12:30:20 +0200 | [diff] [blame] | 604 | mode = COMPHY_FW_MODE_FORMAT(COMPHY_USB3H_MODE); |
| 605 | ret = comphy_smc(MV_SIP_COMPHY_POWER_ON, |
| 606 | ptr_chip_cfg->comphy_base_addr, lane, |
| 607 | mode); |
| 608 | break; |
Igal Liberman | ffd5d2f | 2017-04-26 15:40:00 +0300 | [diff] [blame] | 609 | case COMPHY_TYPE_USB3_DEVICE: |
Grzegorz Jaszczyk | e165970 | 2018-03-29 12:30:20 +0200 | [diff] [blame] | 610 | mode = COMPHY_FW_MODE_FORMAT(COMPHY_USB3D_MODE); |
| 611 | ret = comphy_smc(MV_SIP_COMPHY_POWER_ON, |
| 612 | ptr_chip_cfg->comphy_base_addr, lane, |
| 613 | mode); |
Stefan Roese | 648391c | 2016-08-30 16:48:20 +0200 | [diff] [blame] | 614 | break; |
Igal Liberman | ffd5d2f | 2017-04-26 15:40:00 +0300 | [diff] [blame] | 615 | case COMPHY_TYPE_SGMII0: |
| 616 | case COMPHY_TYPE_SGMII1: |
Igal Liberman | ffd5d2f | 2017-04-26 15:40:00 +0300 | [diff] [blame] | 617 | case COMPHY_TYPE_SGMII2: |
Igal Liberman | d009fee | 2018-05-09 18:50:29 +0300 | [diff] [blame] | 618 | /* Calculate SGMII ID */ |
| 619 | id = ptr_comphy_map->type - COMPHY_TYPE_SGMII0; |
| 620 | |
Igal Liberman | ffd5d2f | 2017-04-26 15:40:00 +0300 | [diff] [blame] | 621 | if (ptr_comphy_map->speed == COMPHY_SPEED_INVALID) { |
Stefan Roese | 648391c | 2016-08-30 16:48:20 +0200 | [diff] [blame] | 622 | debug("Warning: SGMII PHY speed in lane %d is invalid, set PHY speed to 1.25G\n", |
| 623 | lane); |
Igal Liberman | ffd5d2f | 2017-04-26 15:40:00 +0300 | [diff] [blame] | 624 | ptr_comphy_map->speed = COMPHY_SPEED_1_25G; |
Stefan Roese | 648391c | 2016-08-30 16:48:20 +0200 | [diff] [blame] | 625 | } |
Grzegorz Jaszczyk | 7928a8e | 2020-10-18 17:11:11 +0300 | [diff] [blame] | 626 | |
Igal Liberman | d009fee | 2018-05-09 18:50:29 +0300 | [diff] [blame] | 627 | mode = COMPHY_FW_FORMAT(COMPHY_SGMII_MODE, id, |
Grzegorz Jaszczyk | 7928a8e | 2020-10-18 17:11:11 +0300 | [diff] [blame] | 628 | ptr_comphy_map->speed); |
| 629 | ret = comphy_smc(MV_SIP_COMPHY_POWER_ON, |
| 630 | ptr_chip_cfg->comphy_base_addr, lane, |
| 631 | mode); |
Stefan Roese | 648391c | 2016-08-30 16:48:20 +0200 | [diff] [blame] | 632 | break; |
Igal Liberman | ffd5d2f | 2017-04-26 15:40:00 +0300 | [diff] [blame] | 633 | case COMPHY_TYPE_SFI: |
Grzegorz Jaszczyk | 7928a8e | 2020-10-18 17:11:11 +0300 | [diff] [blame] | 634 | mode = COMPHY_FW_FORMAT(COMPHY_SFI_MODE, |
| 635 | COMPHY_UNIT_ID0, |
| 636 | ptr_comphy_map->speed); |
| 637 | ret = comphy_smc(MV_SIP_COMPHY_POWER_ON, |
| 638 | ptr_chip_cfg->comphy_base_addr, lane, |
| 639 | mode); |
Stefan Roese | 648391c | 2016-08-30 16:48:20 +0200 | [diff] [blame] | 640 | break; |
Igal Liberman | ffd5d2f | 2017-04-26 15:40:00 +0300 | [diff] [blame] | 641 | case COMPHY_TYPE_RXAUI0: |
| 642 | case COMPHY_TYPE_RXAUI1: |
Grzegorz Jaszczyk | beb4a91 | 2018-03-27 12:52:24 +0200 | [diff] [blame] | 643 | mode = COMPHY_FW_MODE_FORMAT(COMPHY_RXAUI_MODE); |
| 644 | ret = comphy_smc(MV_SIP_COMPHY_POWER_ON, |
| 645 | ptr_chip_cfg->comphy_base_addr, lane, |
| 646 | mode); |
Stefan Roese | 648391c | 2016-08-30 16:48:20 +0200 | [diff] [blame] | 647 | break; |
| 648 | default: |
| 649 | debug("Unknown SerDes type, skip initialize SerDes %d\n", |
| 650 | lane); |
| 651 | break; |
| 652 | } |
| 653 | if (ret == 0) { |
| 654 | /* |
Stefan Roese | 4fbca01 | 2017-04-24 18:45:25 +0300 | [diff] [blame] | 655 | * If interface wans't initialized, set the lane to |
Igal Liberman | ffd5d2f | 2017-04-26 15:40:00 +0300 | [diff] [blame] | 656 | * COMPHY_TYPE_UNCONNECTED state. |
Stefan Roese | 648391c | 2016-08-30 16:48:20 +0200 | [diff] [blame] | 657 | */ |
Igal Liberman | ffd5d2f | 2017-04-26 15:40:00 +0300 | [diff] [blame] | 658 | ptr_comphy_map->type = COMPHY_TYPE_UNCONNECTED; |
Masahiro Yamada | 81e1042 | 2017-09-16 14:10:41 +0900 | [diff] [blame] | 659 | pr_err("PLL is not locked - Failed to initialize lane %d\n", |
Stefan Roese | 648391c | 2016-08-30 16:48:20 +0200 | [diff] [blame] | 660 | lane); |
| 661 | } |
| 662 | } |
| 663 | |
| 664 | debug_exit(); |
| 665 | return 0; |
| 666 | } |