Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Stefan Roese | 8f64e26 | 2016-05-23 11:12:05 +0200 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2015-2016 Marvell International Ltd. |
Stefan Roese | 8f64e26 | 2016-05-23 11:12:05 +0200 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #ifndef _COMPHY_A3700_H_ |
| 7 | #define _COMPHY_A3700_H_ |
| 8 | |
Marek Behún | 19ce44c | 2018-08-17 12:58:51 +0200 | [diff] [blame] | 9 | #include "comphy_core.h" |
Stefan Roese | 8f64e26 | 2016-05-23 11:12:05 +0200 | [diff] [blame] | 10 | |
Marek Behún | 4c02f73 | 2018-04-24 17:21:12 +0200 | [diff] [blame] | 11 | #define MVEBU_REG(offs) \ |
| 12 | ((void __iomem *)(ulong)MVEBU_REGISTER(offs)) |
Stefan Roese | 8f64e26 | 2016-05-23 11:12:05 +0200 | [diff] [blame] | 13 | |
| 14 | #define DEFAULT_REFCLK_MHZ 25 |
| 15 | #define PLL_SET_DELAY_US 600 |
| 16 | #define PLL_LOCK_TIMEOUT 1000 |
| 17 | #define POLL_16B_REG 1 |
| 18 | #define POLL_32B_REG 0 |
| 19 | |
| 20 | /* |
| 21 | * COMPHY SB definitions |
| 22 | */ |
| 23 | #define COMPHY_SEL_ADDR MVEBU_REG(0x0183FC) |
Stefan Roese | 8f64e26 | 2016-05-23 11:12:05 +0200 | [diff] [blame] | 24 | |
Marek Behún | 79c115a | 2018-04-24 17:21:22 +0200 | [diff] [blame] | 25 | #define COMPHY_PHY_CFG1_ADDR(lane) MVEBU_REG(0x018300 + (1 - lane) * 0x28) |
Stefan Roese | 8f64e26 | 2016-05-23 11:12:05 +0200 | [diff] [blame] | 26 | #define rb_pin_pu_iveref BIT(1) |
| 27 | #define rb_pin_reset_core BIT(11) |
| 28 | #define rb_pin_reset_comphy BIT(12) |
| 29 | #define rb_pin_pu_pll BIT(16) |
| 30 | #define rb_pin_pu_rx BIT(17) |
| 31 | #define rb_pin_pu_tx BIT(18) |
| 32 | #define rb_pin_tx_idle BIT(19) |
| 33 | #define rf_gen_rx_sel_shift 22 |
Andre Przywara | 8dfa4ee | 2016-11-16 00:50:10 +0000 | [diff] [blame] | 34 | #define rf_gen_rx_select (0x0F << rf_gen_rx_sel_shift) |
Stefan Roese | 8f64e26 | 2016-05-23 11:12:05 +0200 | [diff] [blame] | 35 | #define rf_gen_tx_sel_shift 26 |
Andre Przywara | 8dfa4ee | 2016-11-16 00:50:10 +0000 | [diff] [blame] | 36 | #define rf_gen_tx_select (0x0F << rf_gen_tx_sel_shift) |
Stefan Roese | 8f64e26 | 2016-05-23 11:12:05 +0200 | [diff] [blame] | 37 | #define rb_phy_rx_init BIT(30) |
| 38 | |
Marek Behún | 79c115a | 2018-04-24 17:21:22 +0200 | [diff] [blame] | 39 | #define COMPHY_PHY_STAT1_ADDR(lane) MVEBU_REG(0x018318 + (1 - lane) * 0x28) |
Stefan Roese | 8f64e26 | 2016-05-23 11:12:05 +0200 | [diff] [blame] | 40 | #define rb_rx_init_done BIT(0) |
| 41 | #define rb_pll_ready_rx BIT(2) |
| 42 | #define rb_pll_ready_tx BIT(3) |
| 43 | |
| 44 | /* |
| 45 | * PCIe/USB/SGMII definitions |
| 46 | */ |
| 47 | #define PCIE_BASE MVEBU_REG(0x070000) |
| 48 | #define PCIETOP_BASE MVEBU_REG(0x080000) |
| 49 | #define PCIE_RAMBASE MVEBU_REG(0x08C000) |
| 50 | #define PCIEPHY_BASE MVEBU_REG(0x01F000) |
| 51 | #define PCIEPHY_SHFT 2 |
| 52 | |
| 53 | #define USB32_BASE MVEBU_REG(0x050000) /* usb3 device */ |
| 54 | #define USB32H_BASE MVEBU_REG(0x058000) /* usb3 host */ |
| 55 | #define USB3PHY_BASE MVEBU_REG(0x05C000) |
| 56 | #define USB2PHY_BASE MVEBU_REG(0x05D000) |
| 57 | #define USB2PHY2_BASE MVEBU_REG(0x05F000) |
| 58 | #define USB32_CTRL_BASE MVEBU_REG(0x05D800) |
| 59 | #define USB3PHY_SHFT 2 |
Marek Behún | ef6f36e | 2018-04-24 17:21:18 +0200 | [diff] [blame] | 60 | #define USB3PHY_LANE2_REG_BASE_OFFSET 0x200 |
Stefan Roese | 8f64e26 | 2016-05-23 11:12:05 +0200 | [diff] [blame] | 61 | |
Marek Behún | ee3e2f6 | 2018-04-24 17:21:13 +0200 | [diff] [blame] | 62 | static inline void __iomem *sgmiiphy_addr(u32 lane, u32 addr) |
| 63 | { |
| 64 | addr = (addr & 0x00007FF) * 2; |
| 65 | if (lane == 1) |
| 66 | return PCIEPHY_BASE + addr; |
| 67 | else |
| 68 | return USB3PHY_BASE + addr; |
| 69 | } |
Stefan Roese | 8f64e26 | 2016-05-23 11:12:05 +0200 | [diff] [blame] | 70 | |
| 71 | /* units */ |
Marek Behún | a89ae13 | 2018-04-24 17:21:14 +0200 | [diff] [blame] | 72 | enum phy_unit { |
| 73 | PCIE = 1, |
| 74 | USB3 = 2, |
| 75 | }; |
Stefan Roese | 8f64e26 | 2016-05-23 11:12:05 +0200 | [diff] [blame] | 76 | |
Marek Behún | a89ae13 | 2018-04-24 17:21:14 +0200 | [diff] [blame] | 77 | static inline void __iomem *phy_addr(enum phy_unit unit, u32 addr) |
| 78 | { |
| 79 | if (unit == PCIE) |
| 80 | return PCIEPHY_BASE + addr * PCIEPHY_SHFT; |
| 81 | else |
| 82 | return USB3PHY_BASE + addr * USB3PHY_SHFT; |
| 83 | } |
Stefan Roese | 8f64e26 | 2016-05-23 11:12:05 +0200 | [diff] [blame] | 84 | |
| 85 | /* bit definition for USB32_CTRL_BASE (USB32 Control Mode) */ |
| 86 | #define usb32_ctrl_id_mode BIT(0) |
| 87 | #define usb32_ctrl_soft_id BIT(1) |
| 88 | #define usb32_ctrl_int_mode BIT(4) |
| 89 | |
Marek Behún | a89ae13 | 2018-04-24 17:21:14 +0200 | [diff] [blame] | 90 | #define PWR_PLL_CTRL 0x01 |
Stefan Roese | 8f64e26 | 2016-05-23 11:12:05 +0200 | [diff] [blame] | 91 | #define rf_phy_mode_shift 5 |
| 92 | #define rf_phy_mode_mask (0x7 << rf_phy_mode_shift) |
| 93 | #define rf_ref_freq_sel_shift 0 |
| 94 | #define rf_ref_freq_sel_mask (0x1F << rf_ref_freq_sel_shift) |
| 95 | #define PHY_MODE_SGMII 0x4 |
| 96 | |
Marek Behún | a89ae13 | 2018-04-24 17:21:14 +0200 | [diff] [blame] | 97 | #define KVCO_CAL_CTRL 0x02 |
Stefan Roese | 8f64e26 | 2016-05-23 11:12:05 +0200 | [diff] [blame] | 98 | #define rb_use_max_pll_rate BIT(12) |
| 99 | #define rb_force_calibration_done BIT(9) |
| 100 | |
Marek Behún | a89ae13 | 2018-04-24 17:21:14 +0200 | [diff] [blame] | 101 | #define DIG_LB_EN 0x23 |
Stefan Roese | 8f64e26 | 2016-05-23 11:12:05 +0200 | [diff] [blame] | 102 | #define rf_data_width_shift 10 |
| 103 | #define rf_data_width_mask (0x3 << rf_data_width_shift) |
| 104 | |
Marek Behún | a89ae13 | 2018-04-24 17:21:14 +0200 | [diff] [blame] | 105 | #define SYNC_PATTERN 0x24 |
Stefan Roese | 8f64e26 | 2016-05-23 11:12:05 +0200 | [diff] [blame] | 106 | #define phy_txd_inv BIT(10) |
| 107 | #define phy_rxd_inv BIT(11) |
| 108 | |
Marek Behún | a89ae13 | 2018-04-24 17:21:14 +0200 | [diff] [blame] | 109 | #define SYNC_MASK_GEN 0x25 |
Stefan Roese | 8f64e26 | 2016-05-23 11:12:05 +0200 | [diff] [blame] | 110 | #define rb_idle_sync_en BIT(12) |
| 111 | |
Marek Behún | a89ae13 | 2018-04-24 17:21:14 +0200 | [diff] [blame] | 112 | #define UNIT_CTRL 0x48 |
| 113 | |
| 114 | #define GEN2_SETTINGS_2 0x3e |
Stefan Roese | 8f64e26 | 2016-05-23 11:12:05 +0200 | [diff] [blame] | 115 | #define g2_tx_ssc_amp BIT(14) |
| 116 | |
Marek Behún | a89ae13 | 2018-04-24 17:21:14 +0200 | [diff] [blame] | 117 | #define GEN2_SETTINGS_3 0x3f |
Stefan Roese | 8f64e26 | 2016-05-23 11:12:05 +0200 | [diff] [blame] | 118 | |
Marek Behún | a89ae13 | 2018-04-24 17:21:14 +0200 | [diff] [blame] | 119 | #define GEN3_SETTINGS_3 0x112 |
| 120 | |
| 121 | #define MISC_REG0 0x4f |
Stefan Roese | 8f64e26 | 2016-05-23 11:12:05 +0200 | [diff] [blame] | 122 | #define rb_clk100m_125m_en BIT(4) |
| 123 | #define rb_clk500m_en BIT(7) |
| 124 | #define rb_ref_clk_sel BIT(10) |
| 125 | |
Marek Behún | a89ae13 | 2018-04-24 17:21:14 +0200 | [diff] [blame] | 126 | #define UNIT_IFACE_REF_CLK_CTRL 0x51 |
Stefan Roese | 8f64e26 | 2016-05-23 11:12:05 +0200 | [diff] [blame] | 127 | #define rb_ref1m_gen_div_force BIT(8) |
| 128 | #define rf_ref1m_gen_div_value_shift 0 |
| 129 | #define rf_ref1m_gen_div_value_mask (0xFF << rf_ref1m_gen_div_value_shift) |
| 130 | |
Marek Behún | a89ae13 | 2018-04-24 17:21:14 +0200 | [diff] [blame] | 131 | #define UNIT_ERR_CNT_CONST_CTRL 0x6a |
Stefan Roese | 8f64e26 | 2016-05-23 11:12:05 +0200 | [diff] [blame] | 132 | #define rb_fast_dfe_enable BIT(13) |
| 133 | |
Marek Behún | a89ae13 | 2018-04-24 17:21:14 +0200 | [diff] [blame] | 134 | #define MISC_REG1 0x73 |
Stefan Roese | 8f64e26 | 2016-05-23 11:12:05 +0200 | [diff] [blame] | 135 | #define bf_sel_bits_pcie_force BIT(15) |
| 136 | |
Marek Behún | a89ae13 | 2018-04-24 17:21:14 +0200 | [diff] [blame] | 137 | #define LANE_CFG0 0x180 |
Stefan Roese | 8f64e26 | 2016-05-23 11:12:05 +0200 | [diff] [blame] | 138 | #define bf_use_max_pll_rate BIT(9) |
Marek Behún | a89ae13 | 2018-04-24 17:21:14 +0200 | [diff] [blame] | 139 | |
| 140 | #define LANE_CFG1 0x181 |
Stefan Roese | 8f64e26 | 2016-05-23 11:12:05 +0200 | [diff] [blame] | 141 | #define bf_use_max_pll_rate BIT(9) |
zachary | 2684a39 | 2018-04-24 17:21:20 +0200 | [diff] [blame] | 142 | #define prd_txdeemph1_mask BIT(15) |
| 143 | #define tx_det_rx_mode BIT(6) |
| 144 | #define gen2_tx_data_dly_deft (2 << 3) |
| 145 | #define gen2_tx_data_dly_mask (BIT(3) | BIT(4)) |
| 146 | #define tx_elec_idle_mode_en BIT(0) |
Marek Behún | a89ae13 | 2018-04-24 17:21:14 +0200 | [diff] [blame] | 147 | |
| 148 | #define LANE_CFG4 0x188 |
Stefan Roese | 8f64e26 | 2016-05-23 11:12:05 +0200 | [diff] [blame] | 149 | #define bf_spread_spectrum_clock_en BIT(7) |
| 150 | |
Marek Behún | a89ae13 | 2018-04-24 17:21:14 +0200 | [diff] [blame] | 151 | #define LANE_STAT1 0x183 |
Stefan Roese | 8f64e26 | 2016-05-23 11:12:05 +0200 | [diff] [blame] | 152 | #define rb_txdclk_pclk_en BIT(0) |
| 153 | |
Marek Behún | a89ae13 | 2018-04-24 17:21:14 +0200 | [diff] [blame] | 154 | #define GLOB_PHY_CTRL0 0x1c1 |
Stefan Roese | 8f64e26 | 2016-05-23 11:12:05 +0200 | [diff] [blame] | 155 | #define bf_soft_rst BIT(0) |
| 156 | #define bf_mode_refdiv 0x30 |
| 157 | #define rb_mode_core_clk_freq_sel BIT(9) |
| 158 | #define rb_mode_pipe_width_32 BIT(3) |
| 159 | |
Marek Behún | a89ae13 | 2018-04-24 17:21:14 +0200 | [diff] [blame] | 160 | #define TEST_MODE_CTRL 0x1c2 |
Stefan Roese | 8f64e26 | 2016-05-23 11:12:05 +0200 | [diff] [blame] | 161 | #define rb_mode_margin_override BIT(2) |
| 162 | |
Marek Behún | a89ae13 | 2018-04-24 17:21:14 +0200 | [diff] [blame] | 163 | #define GLOB_CLK_SRC_LO 0x1c3 |
Stefan Roese | 8f64e26 | 2016-05-23 11:12:05 +0200 | [diff] [blame] | 164 | #define bf_cfg_sel_20b BIT(15) |
| 165 | |
Marek Behún | a89ae13 | 2018-04-24 17:21:14 +0200 | [diff] [blame] | 166 | #define PWR_MGM_TIM1 0x1d0 |
Stefan Roese | 8f64e26 | 2016-05-23 11:12:05 +0200 | [diff] [blame] | 167 | |
Marek Behún | a89ae13 | 2018-04-24 17:21:14 +0200 | [diff] [blame] | 168 | #define PCIE_REF_CLK_ADDR (PCIE_BASE + 0x4814) |
Stefan Roese | 8f64e26 | 2016-05-23 11:12:05 +0200 | [diff] [blame] | 169 | |
| 170 | #define USB3_CTRPUL_VAL_REG (0x20 + USB32_BASE) |
| 171 | #define USB3H_CTRPUL_VAL_REG (0x3454 + USB32H_BASE) |
| 172 | #define rb_usb3_ctr_100ns 0xff000000 |
| 173 | |
| 174 | #define USB2_OTG_PHY_CTRL_ADDR (0x820 + USB2PHY_BASE) |
| 175 | #define rb_usb2phy_suspm BIT(14) |
| 176 | #define rb_usb2phy_pu BIT(0) |
| 177 | |
| 178 | #define USB2_PHY_OTG_CTRL_ADDR (0x34 + USB2PHY_BASE) |
| 179 | #define rb_pu_otg BIT(4) |
| 180 | |
| 181 | #define USB2_PHY_CHRGR_DET_ADDR (0x38 + USB2PHY_BASE) |
| 182 | #define rb_cdp_en BIT(2) |
| 183 | #define rb_dcp_en BIT(3) |
| 184 | #define rb_pd_en BIT(4) |
| 185 | #define rb_pu_chrg_dtc BIT(5) |
| 186 | #define rb_cdp_dm_auto BIT(7) |
| 187 | #define rb_enswitch_dp BIT(12) |
| 188 | #define rb_enswitch_dm BIT(13) |
| 189 | |
| 190 | #define USB2_CAL_CTRL_ADDR (0x8 + USB2PHY_BASE) |
| 191 | #define rb_usb2phy_pllcal_done BIT(31) |
| 192 | #define rb_usb2phy_impcal_done BIT(23) |
| 193 | |
| 194 | #define USB2_PLL_CTRL0_ADDR (0x0 + USB2PHY_BASE) |
| 195 | #define rb_usb2phy_pll_ready BIT(31) |
| 196 | |
| 197 | #define USB2_RX_CHAN_CTRL1_ADDR (0x18 + USB2PHY_BASE) |
| 198 | #define rb_usb2phy_sqcal_done BIT(31) |
| 199 | |
| 200 | #define USB2_PHY2_CTRL_ADDR (0x804 + USB2PHY2_BASE) |
| 201 | #define rb_usb2phy2_suspm BIT(7) |
| 202 | #define rb_usb2phy2_pu BIT(0) |
| 203 | #define USB2_PHY2_CAL_CTRL_ADDR (0x8 + USB2PHY2_BASE) |
| 204 | #define USB2_PHY2_PLL_CTRL0_ADDR (0x0 + USB2PHY2_BASE) |
| 205 | #define USB2_PHY2_RX_CHAN_CTRL1_ADDR (0x18 + USB2PHY2_BASE) |
| 206 | |
| 207 | #define USB2_PHY_BASE(usb32) (usb32 == 0 ? USB2PHY2_BASE : USB2PHY_BASE) |
| 208 | #define USB2_PHY_CTRL_ADDR(usb32) \ |
| 209 | (usb32 == 0 ? USB2_PHY2_CTRL_ADDR : USB2_OTG_PHY_CTRL_ADDR) |
| 210 | #define RB_USB2PHY_SUSPM(usb32) \ |
| 211 | (usb32 == 0 ? rb_usb2phy2_suspm : rb_usb2phy_suspm) |
| 212 | #define RB_USB2PHY_PU(usb32) \ |
| 213 | (usb32 == 0 ? rb_usb2phy2_pu : rb_usb2phy_pu) |
| 214 | #define USB2_PHY_CAL_CTRL_ADDR(usb32) \ |
| 215 | (usb32 == 0 ? USB2_PHY2_CAL_CTRL_ADDR : USB2_CAL_CTRL_ADDR) |
| 216 | #define USB2_PHY_RX_CHAN_CTRL1_ADDR(usb32) \ |
| 217 | (usb32 == 0 ? USB2_PHY2_RX_CHAN_CTRL1_ADDR : USB2_RX_CHAN_CTRL1_ADDR) |
| 218 | #define USB2_PHY_PLL_CTRL0_ADDR(usb32) \ |
| 219 | (usb32 == 0 ? USB2_PHY2_PLL_CTRL0_ADDR : USB2_PLL_CTRL0_ADDR) |
| 220 | |
| 221 | /* |
| 222 | * SATA definitions |
| 223 | */ |
| 224 | #define AHCI_BASE MVEBU_REG(0xE0000) |
| 225 | |
| 226 | #define rh_vsreg_addr (AHCI_BASE + 0x178) |
| 227 | #define rh_vsreg_data (AHCI_BASE + 0x17C) |
| 228 | #define rh_vs0_a (AHCI_BASE + 0xA0) |
| 229 | #define rh_vs0_d (AHCI_BASE + 0xA4) |
| 230 | |
| 231 | #define vphy_sync_pattern_reg 0x224 |
| 232 | #define bs_txd_inv BIT(10) |
| 233 | #define bs_rxd_inv BIT(11) |
| 234 | |
| 235 | #define vphy_loopback_reg0 0x223 |
| 236 | #define bs_phyintf_40bit 0x0C00 |
| 237 | #define bs_pll_ready_tx 0x10 |
| 238 | |
| 239 | #define vphy_power_reg0 0x201 |
| 240 | |
| 241 | #define vphy_calctl_reg 0x202 |
| 242 | #define bs_max_pll_rate BIT(12) |
| 243 | |
| 244 | #define vphy_reserve_reg 0x0e |
| 245 | #define bs_phyctrl_frm_pin BIT(13) |
| 246 | |
| 247 | #define vsata_ctrl_reg 0x00 |
| 248 | #define bs_phy_pu_pll BIT(6) |
| 249 | |
| 250 | /* |
| 251 | * SDIO/eMMC definitions |
| 252 | */ |
| 253 | #define SDIO_BASE MVEBU_REG(0xD8000) |
| 254 | |
| 255 | #define SDIO_HOST_CTRL1_ADDR (SDIO_BASE + 0x28) |
| 256 | #define SDIO_SDHC_FIFO_ADDR (SDIO_BASE + 0x12C) |
| 257 | #define SDIO_CAP_12_ADDR (SDIO_BASE + 0x40) |
| 258 | #define SDIO_ENDIAN_ADDR (SDIO_BASE + 0x1A4) |
| 259 | #define SDIO_PHY_TIMING_ADDR (SDIO_BASE + 0x170) |
| 260 | #define SDIO_PHY_PAD_CTRL0_ADDR (SDIO_BASE + 0x178) |
| 261 | #define SDIO_DLL_RST_ADDR (SDIO_BASE + 0x148) |
| 262 | |
| 263 | #endif /* _COMPHY_A3700_H_ */ |