Lines Matching refs:atcphy
843 static inline void core_mask32(struct apple_atcphy *atcphy, u32 reg, u32 mask, u32 set) in core_mask32() argument
845 mask32(atcphy->regs.core + reg, mask, set); in core_mask32()
853 static inline void core_set32(struct apple_atcphy *atcphy, u32 reg, u32 set) in core_set32() argument
855 core_mask32(atcphy, reg, 0, set); in core_set32()
863 static inline void core_clear32(struct apple_atcphy *atcphy, u32 reg, u32 clear) in core_clear32() argument
865 core_mask32(atcphy, reg, clear, 0); in core_clear32()
868 static const struct atcphy_mode_configuration *atcphy_get_mode_config(struct apple_atcphy *atcphy, in atcphy_get_mode_config() argument
871 if (atcphy->swap_lanes) in atcphy_get_mode_config()
877 static void atcphy_apply_tunables(struct apple_atcphy *atcphy, enum atcphy_mode mode) in atcphy_apply_tunables() argument
879 const int lane0 = atcphy->swap_lanes ? 1 : 0; in atcphy_apply_tunables()
880 const int lane1 = atcphy->swap_lanes ? 0 : 1; in atcphy_apply_tunables()
882 apple_tunable_apply(atcphy->regs.core, atcphy->tunables.common[0]); in atcphy_apply_tunables()
883 apple_tunable_apply(atcphy->regs.axi2af, atcphy->tunables.axi2af); in atcphy_apply_tunables()
884 apple_tunable_apply(atcphy->regs.core, atcphy->tunables.common[1]); in atcphy_apply_tunables()
894 apple_tunable_apply(atcphy->regs.core, atcphy->tunables.lane_usb3[lane0]); in atcphy_apply_tunables()
895 apple_tunable_apply(atcphy->regs.core, atcphy->tunables.lane_dp[lane1]); in atcphy_apply_tunables()
899 apple_tunable_apply(atcphy->regs.core, atcphy->tunables.lane_dp[lane0]); in atcphy_apply_tunables()
900 apple_tunable_apply(atcphy->regs.core, atcphy->tunables.lane_dp[lane1]); in atcphy_apply_tunables()
910 apple_tunable_apply(atcphy->regs.core, atcphy->tunables.lane_usb4[lane0]); in atcphy_apply_tunables()
911 apple_tunable_apply(atcphy->regs.core, atcphy->tunables.lane_usb4[lane1]); in atcphy_apply_tunables()
920 static int atcphy_pipehandler_lock(struct apple_atcphy *atcphy) in atcphy_pipehandler_lock() argument
925 if (readl(atcphy->regs.pipehandler + PIPEHANDLER_LOCK_REQ) & PIPEHANDLER_LOCK_EN) { in atcphy_pipehandler_lock()
926 dev_warn(atcphy->dev, "Pipehandler already locked\n"); in atcphy_pipehandler_lock()
930 set32(atcphy->regs.pipehandler + PIPEHANDLER_LOCK_REQ, PIPEHANDLER_LOCK_EN); in atcphy_pipehandler_lock()
932 ret = readl_poll_timeout(atcphy->regs.pipehandler + PIPEHANDLER_LOCK_ACK, reg, in atcphy_pipehandler_lock()
935 clear32(atcphy->regs.pipehandler + PIPEHANDLER_LOCK_REQ, 1); in atcphy_pipehandler_lock()
936 dev_warn(atcphy->dev, "Pipehandler lock not acked.\n"); in atcphy_pipehandler_lock()
942 static int atcphy_pipehandler_unlock(struct apple_atcphy *atcphy) in atcphy_pipehandler_unlock() argument
947 clear32(atcphy->regs.pipehandler + PIPEHANDLER_LOCK_REQ, PIPEHANDLER_LOCK_EN); in atcphy_pipehandler_unlock()
948 ret = readl_poll_timeout(atcphy->regs.pipehandler + PIPEHANDLER_LOCK_ACK, reg, in atcphy_pipehandler_unlock()
951 dev_warn(atcphy->dev, "Pipehandler lock release not acked.\n"); in atcphy_pipehandler_unlock()
956 static int atcphy_pipehandler_check(struct apple_atcphy *atcphy) in atcphy_pipehandler_check() argument
960 lockdep_assert_held(&atcphy->lock); in atcphy_pipehandler_check()
962 if (readl(atcphy->regs.pipehandler + PIPEHANDLER_LOCK_ACK) & PIPEHANDLER_LOCK_EN) { in atcphy_pipehandler_check()
963 dev_warn(atcphy->dev, "Pipehandler already locked\n"); in atcphy_pipehandler_check()
965 ret = atcphy_pipehandler_unlock(atcphy); in atcphy_pipehandler_check()
967 dev_err(atcphy->dev, "Failed to unlock pipehandler\n"); in atcphy_pipehandler_check()
975 static int atcphy_configure_pipehandler_usb3(struct apple_atcphy *atcphy, bool host) in atcphy_configure_pipehandler_usb3() argument
980 ret = atcphy_pipehandler_check(atcphy); in atcphy_configure_pipehandler_usb3()
990 clear32(atcphy->regs.pipehandler + PIPEHANDLER_OVERRIDE_VALUES, in atcphy_configure_pipehandler_usb3()
992 set32(atcphy->regs.pipehandler + PIPEHANDLER_OVERRIDE, in atcphy_configure_pipehandler_usb3()
994 set32(atcphy->regs.pipehandler + PIPEHANDLER_OVERRIDE, in atcphy_configure_pipehandler_usb3()
997 ret = atcphy_pipehandler_lock(atcphy); in atcphy_configure_pipehandler_usb3()
999 dev_err(atcphy->dev, "Failed to lock pipehandler"); in atcphy_configure_pipehandler_usb3()
1004 core_set32(atcphy, ACIOPHY_TOP_BIST_PHY_CFG0, in atcphy_configure_pipehandler_usb3()
1006 core_set32(atcphy, ACIOPHY_TOP_BIST_OV_CFG, ACIOPHY_TOP_BIST_OV_CFG_LN0_RESET_N_OV); in atcphy_configure_pipehandler_usb3()
1007 ret = readl_poll_timeout(atcphy->regs.core + ACIOPHY_TOP_PHY_STAT, reg, in atcphy_configure_pipehandler_usb3()
1010 dev_warn(atcphy->dev, in atcphy_configure_pipehandler_usb3()
1013 core_set32(atcphy, ACIOPHY_TOP_BIST_READ_CTRL, in atcphy_configure_pipehandler_usb3()
1015 core_clear32(atcphy, ACIOPHY_TOP_BIST_READ_CTRL, in atcphy_configure_pipehandler_usb3()
1018 core_mask32(atcphy, ACIOPHY_TOP_BIST_PHY_CFG1, in atcphy_configure_pipehandler_usb3()
1022 core_set32(atcphy, ACIOPHY_TOP_BIST_OV_CFG, in atcphy_configure_pipehandler_usb3()
1024 core_set32(atcphy, ACIOPHY_TOP_BIST_CIOPHY_CFG1, in atcphy_configure_pipehandler_usb3()
1026 core_set32(atcphy, ACIOPHY_TOP_BIST_CIOPHY_CFG1, in atcphy_configure_pipehandler_usb3()
1028 writel(0, atcphy->regs.core + ACIOPHY_TOP_BIST_CIOPHY_CFG1); in atcphy_configure_pipehandler_usb3()
1030 ret = readl_poll_timeout(atcphy->regs.core + ACIOPHY_TOP_PHY_STAT, reg, in atcphy_configure_pipehandler_usb3()
1033 dev_warn(atcphy->dev, in atcphy_configure_pipehandler_usb3()
1036 ret = readl_poll_timeout(atcphy->regs.core + ACIOPHY_TOP_PHY_STAT, reg, in atcphy_configure_pipehandler_usb3()
1039 dev_warn(atcphy->dev, in atcphy_configure_pipehandler_usb3()
1043 mask32(atcphy->regs.pipehandler + PIPEHANDLER_NONSELECTED_OVERRIDE, in atcphy_configure_pipehandler_usb3()
1045 clear32(atcphy->regs.pipehandler + PIPEHANDLER_NONSELECTED_OVERRIDE, in atcphy_configure_pipehandler_usb3()
1049 writel(0, atcphy->regs.core + ACIOPHY_TOP_BIST_OV_CFG); in atcphy_configure_pipehandler_usb3()
1050 core_set32(atcphy, ACIOPHY_TOP_BIST_CIOPHY_CFG1, in atcphy_configure_pipehandler_usb3()
1052 core_set32(atcphy, ACIOPHY_TOP_BIST_CIOPHY_CFG1, in atcphy_configure_pipehandler_usb3()
1057 mask32(atcphy->regs.pipehandler + PIPEHANDLER_MUX_CTRL, PIPEHANDLER_MUX_CTRL_CLK, in atcphy_configure_pipehandler_usb3()
1060 mask32(atcphy->regs.pipehandler + PIPEHANDLER_MUX_CTRL, PIPEHANDLER_MUX_CTRL_DATA, in atcphy_configure_pipehandler_usb3()
1063 mask32(atcphy->regs.pipehandler + PIPEHANDLER_MUX_CTRL, PIPEHANDLER_MUX_CTRL_CLK, in atcphy_configure_pipehandler_usb3()
1068 clear32(atcphy->regs.pipehandler + PIPEHANDLER_OVERRIDE, PIPEHANDLER_OVERRIDE_RXVALID); in atcphy_configure_pipehandler_usb3()
1069 clear32(atcphy->regs.pipehandler + PIPEHANDLER_OVERRIDE, PIPEHANDLER_OVERRIDE_RXDETECT); in atcphy_configure_pipehandler_usb3()
1073 ret = atcphy_pipehandler_unlock(atcphy); in atcphy_configure_pipehandler_usb3()
1075 dev_warn(atcphy->dev, "Failed to unlock pipehandler"); in atcphy_configure_pipehandler_usb3()
1081 static int atcphy_configure_pipehandler_dummy(struct apple_atcphy *atcphy) in atcphy_configure_pipehandler_dummy() argument
1085 ret = atcphy_pipehandler_check(atcphy); in atcphy_configure_pipehandler_dummy()
1090 clear32(atcphy->regs.pipehandler + PIPEHANDLER_OVERRIDE_VALUES, in atcphy_configure_pipehandler_dummy()
1092 set32(atcphy->regs.pipehandler + PIPEHANDLER_OVERRIDE, PIPEHANDLER_OVERRIDE_RXVALID); in atcphy_configure_pipehandler_dummy()
1093 set32(atcphy->regs.pipehandler + PIPEHANDLER_OVERRIDE, PIPEHANDLER_OVERRIDE_RXDETECT); in atcphy_configure_pipehandler_dummy()
1095 ret = atcphy_pipehandler_lock(atcphy); in atcphy_configure_pipehandler_dummy()
1097 dev_warn(atcphy->dev, "Failed to lock pipehandler"); in atcphy_configure_pipehandler_dummy()
1100 mask32(atcphy->regs.pipehandler + PIPEHANDLER_MUX_CTRL, PIPEHANDLER_MUX_CTRL_CLK, in atcphy_configure_pipehandler_dummy()
1103 mask32(atcphy->regs.pipehandler + PIPEHANDLER_MUX_CTRL, PIPEHANDLER_MUX_CTRL_DATA, in atcphy_configure_pipehandler_dummy()
1106 mask32(atcphy->regs.pipehandler + PIPEHANDLER_MUX_CTRL, PIPEHANDLER_MUX_CTRL_CLK, in atcphy_configure_pipehandler_dummy()
1110 ret = atcphy_pipehandler_unlock(atcphy); in atcphy_configure_pipehandler_dummy()
1112 dev_warn(atcphy->dev, "Failed to unlock pipehandler"); in atcphy_configure_pipehandler_dummy()
1114 mask32(atcphy->regs.pipehandler + PIPEHANDLER_NONSELECTED_OVERRIDE, in atcphy_configure_pipehandler_dummy()
1116 set32(atcphy->regs.pipehandler + PIPEHANDLER_NONSELECTED_OVERRIDE, in atcphy_configure_pipehandler_dummy()
1122 static int atcphy_configure_pipehandler(struct apple_atcphy *atcphy, bool host) in atcphy_configure_pipehandler() argument
1126 lockdep_assert_held(&atcphy->lock); in atcphy_configure_pipehandler()
1128 switch (atcphy_modes[atcphy->mode].pipehandler_state) { in atcphy_configure_pipehandler()
1130 ret = atcphy_configure_pipehandler_usb3(atcphy, host); in atcphy_configure_pipehandler()
1131 atcphy->pipehandler_up = true; in atcphy_configure_pipehandler()
1134 dev_warn(atcphy->dev, in atcphy_configure_pipehandler()
1136 ret = atcphy_configure_pipehandler_dummy(atcphy); in atcphy_configure_pipehandler()
1137 atcphy->pipehandler_up = false; in atcphy_configure_pipehandler()
1146 static void atcphy_setup_pipehandler(struct apple_atcphy *atcphy) in atcphy_setup_pipehandler() argument
1148 lockdep_assert_held(&atcphy->lock); in atcphy_setup_pipehandler()
1150 mask32(atcphy->regs.pipehandler + PIPEHANDLER_MUX_CTRL, PIPEHANDLER_MUX_CTRL_CLK, in atcphy_setup_pipehandler()
1153 mask32(atcphy->regs.pipehandler + PIPEHANDLER_MUX_CTRL, PIPEHANDLER_MUX_CTRL_DATA, in atcphy_setup_pipehandler()
1156 mask32(atcphy->regs.pipehandler + PIPEHANDLER_MUX_CTRL, PIPEHANDLER_MUX_CTRL_CLK, in atcphy_setup_pipehandler()
1161 static void atcphy_configure_lanes(struct apple_atcphy *atcphy, enum atcphy_mode mode) in atcphy_configure_lanes() argument
1163 const struct atcphy_mode_configuration *mode_cfg = atcphy_get_mode_config(atcphy, mode); in atcphy_configure_lanes()
1165 core_mask32(atcphy, ACIOPHY_LANE_MODE, ACIOPHY_LANE_MODE_RX0, in atcphy_configure_lanes()
1167 core_mask32(atcphy, ACIOPHY_LANE_MODE, ACIOPHY_LANE_MODE_TX0, in atcphy_configure_lanes()
1169 core_mask32(atcphy, ACIOPHY_LANE_MODE, ACIOPHY_LANE_MODE_RX1, in atcphy_configure_lanes()
1171 core_mask32(atcphy, ACIOPHY_LANE_MODE, ACIOPHY_LANE_MODE_TX1, in atcphy_configure_lanes()
1173 core_mask32(atcphy, ACIOPHY_CROSSBAR, ACIOPHY_CROSSBAR_PROTOCOL, in atcphy_configure_lanes()
1177 core_set32(atcphy, ATCPHY_MISC, ATCPHY_MISC_LANE_SWAP); in atcphy_configure_lanes()
1179 core_clear32(atcphy, ATCPHY_MISC, ATCPHY_MISC_LANE_SWAP); in atcphy_configure_lanes()
1181 core_mask32(atcphy, ACIOPHY_CROSSBAR, ACIOPHY_CROSSBAR_DP_SINGLE_PMA, in atcphy_configure_lanes()
1184 core_set32(atcphy, ACIOPHY_CROSSBAR, ACIOPHY_CROSSBAR_DP_BOTH_PMA); in atcphy_configure_lanes()
1186 core_clear32(atcphy, ACIOPHY_CROSSBAR, ACIOPHY_CROSSBAR_DP_BOTH_PMA); in atcphy_configure_lanes()
1189 core_set32(atcphy, LN0_AUSPMA_RX_TOP + LN_AUSPMA_RX_TOP_PMAFSM, in atcphy_configure_lanes()
1192 core_clear32(atcphy, LN0_AUSPMA_RX_TOP + LN_AUSPMA_RX_TOP_PMAFSM, in atcphy_configure_lanes()
1195 core_clear32(atcphy, LN0_AUSPMA_RX_TOP + LN_AUSPMA_RX_TOP_PMAFSM, in atcphy_configure_lanes()
1201 core_set32(atcphy, LN1_AUSPMA_RX_TOP + LN_AUSPMA_RX_TOP_PMAFSM, in atcphy_configure_lanes()
1204 core_clear32(atcphy, LN1_AUSPMA_RX_TOP + LN_AUSPMA_RX_TOP_PMAFSM, in atcphy_configure_lanes()
1207 core_clear32(atcphy, LN1_AUSPMA_RX_TOP + LN_AUSPMA_RX_TOP_PMAFSM, in atcphy_configure_lanes()
1213 static void atcphy_enable_dp_aux(struct apple_atcphy *atcphy) in atcphy_enable_dp_aux() argument
1215 core_set32(atcphy, ACIOPHY_LANE_DP_CFG_BLK_TX_DP_CTRL0, DPTXPHY_PMA_LANE_RESET_N); in atcphy_enable_dp_aux()
1216 core_set32(atcphy, ACIOPHY_LANE_DP_CFG_BLK_TX_DP_CTRL0, DPTXPHY_PMA_LANE_RESET_N_OV); in atcphy_enable_dp_aux()
1218 core_mask32(atcphy, ACIOPHY_LANE_DP_CFG_BLK_TX_DP_CTRL0, DPRX_PCLK_SELECT, in atcphy_enable_dp_aux()
1220 core_set32(atcphy, ACIOPHY_LANE_DP_CFG_BLK_TX_DP_CTRL0, DPRX_PCLK_ENABLE); in atcphy_enable_dp_aux()
1222 core_mask32(atcphy, ACIOPHY_LANE_DP_CFG_BLK_TX_DP_CTRL0, DPTX_PCLK1_SELECT, in atcphy_enable_dp_aux()
1224 core_set32(atcphy, ACIOPHY_LANE_DP_CFG_BLK_TX_DP_CTRL0, DPTX_PCLK1_ENABLE); in atcphy_enable_dp_aux()
1226 core_mask32(atcphy, ACIOPHY_LANE_DP_CFG_BLK_TX_DP_CTRL0, DPTX_PCLK2_SELECT, in atcphy_enable_dp_aux()
1228 core_set32(atcphy, ACIOPHY_LANE_DP_CFG_BLK_TX_DP_CTRL0, DPTX_PCLK2_ENABLE); in atcphy_enable_dp_aux()
1230 core_set32(atcphy, ACIOPHY_PLL_COMMON_CTRL, in atcphy_enable_dp_aux()
1233 set32(atcphy->regs.lpdptx + LPDPTX_AUX_CONTROL, LPDPTX_AUX_CLAMP_EN); in atcphy_enable_dp_aux()
1234 set32(atcphy->regs.lpdptx + LPDPTX_AUX_CONTROL, LPDPTX_SLEEP_B_SML_IN); in atcphy_enable_dp_aux()
1236 set32(atcphy->regs.lpdptx + LPDPTX_AUX_CONTROL, LPDPTX_SLEEP_B_BIG_IN); in atcphy_enable_dp_aux()
1238 clear32(atcphy->regs.lpdptx + LPDPTX_AUX_CONTROL, LPDPTX_AUX_CLAMP_EN); in atcphy_enable_dp_aux()
1239 clear32(atcphy->regs.lpdptx + LPDPTX_AUX_CONTROL, LPDPTX_AUX_PWN_DOWN); in atcphy_enable_dp_aux()
1240 clear32(atcphy->regs.lpdptx + LPDPTX_AUX_CONTROL, LPDPTX_TXTERM_CODEMSB); in atcphy_enable_dp_aux()
1241 mask32(atcphy->regs.lpdptx + LPDPTX_AUX_CONTROL, LPDPTX_TXTERM_CODE, in atcphy_enable_dp_aux()
1244 set32(atcphy->regs.lpdptx + LPDPTX_AUX_CFG_BLK_AUX_LDO_CTRL, 0x1c00); in atcphy_enable_dp_aux()
1245 mask32(atcphy->regs.lpdptx + LPDPTX_AUX_SHM_CFG_BLK_AUX_CTRL_REG1, LPDPTX_CFG_PMA_PHYS_ADJ, in atcphy_enable_dp_aux()
1247 set32(atcphy->regs.lpdptx + LPDPTX_AUX_SHM_CFG_BLK_AUX_CTRL_REG1, in atcphy_enable_dp_aux()
1250 clear32(atcphy->regs.lpdptx + LPDPTX_AUX_CFG_BLK_AUX_MARGIN, in atcphy_enable_dp_aux()
1253 clear32(atcphy->regs.lpdptx + LPDPTX_AUX_CFG_BLK_AUX_CTRL, LPDPTX_BLK_AUX_CTRL_PWRDN); in atcphy_enable_dp_aux()
1254 set32(atcphy->regs.lpdptx + LPDPTX_AUX_SHM_CFG_BLK_AUX_CTRL_REG0, in atcphy_enable_dp_aux()
1256 mask32(atcphy->regs.lpdptx + LPDPTX_AUX_CFG_BLK_AUX_CTRL, LPDPTX_BLK_AUX_RXOFFSET, in atcphy_enable_dp_aux()
1259 mask32(atcphy->regs.lpdptx + LPDPTX_AUX_CFG_BLK_AUX_MARGIN, LPDPTX_AUX_MARGIN_RCAL_TXSWING, in atcphy_enable_dp_aux()
1262 atcphy->dp_link_rate = -1; in atcphy_enable_dp_aux()
1265 static void atcphy_disable_dp_aux(struct apple_atcphy *atcphy) in atcphy_disable_dp_aux() argument
1267 set32(atcphy->regs.lpdptx + LPDPTX_AUX_CONTROL, LPDPTX_AUX_PWN_DOWN); in atcphy_disable_dp_aux()
1268 set32(atcphy->regs.lpdptx + LPDPTX_AUX_CFG_BLK_AUX_CTRL, LPDPTX_BLK_AUX_CTRL_PWRDN); in atcphy_disable_dp_aux()
1269 set32(atcphy->regs.lpdptx + LPDPTX_AUX_CONTROL, LPDPTX_AUX_CLAMP_EN); in atcphy_disable_dp_aux()
1270 clear32(atcphy->regs.lpdptx + LPDPTX_AUX_CONTROL, LPDPTX_SLEEP_B_SML_IN); in atcphy_disable_dp_aux()
1272 clear32(atcphy->regs.lpdptx + LPDPTX_AUX_CONTROL, LPDPTX_SLEEP_B_BIG_IN); in atcphy_disable_dp_aux()
1275 core_clear32(atcphy, ACIOPHY_LANE_DP_CFG_BLK_TX_DP_CTRL0, DPTXPHY_PMA_LANE_RESET_N); in atcphy_disable_dp_aux()
1276 core_clear32(atcphy, ACIOPHY_LANE_DP_CFG_BLK_TX_DP_CTRL0, DPRX_PCLK_ENABLE); in atcphy_disable_dp_aux()
1277 core_clear32(atcphy, ACIOPHY_LANE_DP_CFG_BLK_TX_DP_CTRL0, DPTX_PCLK1_ENABLE); in atcphy_disable_dp_aux()
1278 core_clear32(atcphy, ACIOPHY_LANE_DP_CFG_BLK_TX_DP_CTRL0, DPTX_PCLK2_ENABLE); in atcphy_disable_dp_aux()
1281 static int atcphy_dp_configure_lane(struct apple_atcphy *atcphy, enum atcphy_lane lane, in atcphy_dp_configure_lane() argument
1287 lockdep_assert_held(&atcphy->lock); in atcphy_dp_configure_lane()
1291 tx_shm = atcphy->regs.core + LN0_AUSPMA_TX_SHM; in atcphy_dp_configure_lane()
1292 rx_shm = atcphy->regs.core + LN0_AUSPMA_RX_SHM; in atcphy_dp_configure_lane()
1293 rx_top = atcphy->regs.core + LN0_AUSPMA_RX_TOP; in atcphy_dp_configure_lane()
1296 tx_shm = atcphy->regs.core + LN1_AUSPMA_TX_SHM; in atcphy_dp_configure_lane()
1297 rx_shm = atcphy->regs.core + LN1_AUSPMA_RX_SHM; in atcphy_dp_configure_lane()
1298 rx_top = atcphy->regs.core + LN1_AUSPMA_RX_TOP; in atcphy_dp_configure_lane()
1350 tx_cal_code = FIELD_GET(AUS_UNK_A20_TX_CAL_CODE, readl(atcphy->regs.core + AUS_UNK_A20)); in atcphy_dp_configure_lane()
1494 static int atcphy_auspll_apb_command(struct apple_atcphy *atcphy, u32 command) in atcphy_auspll_apb_command() argument
1499 reg = readl(atcphy->regs.core + AUSPLL_APB_CMD_OVERRIDE); in atcphy_auspll_apb_command()
1504 writel(reg, atcphy->regs.core + AUSPLL_APB_CMD_OVERRIDE); in atcphy_auspll_apb_command()
1506 ret = readl_poll_timeout(atcphy->regs.core + AUSPLL_APB_CMD_OVERRIDE, reg, in atcphy_auspll_apb_command()
1509 dev_warn(atcphy->dev, "AUSPLL APB command was not acked\n"); in atcphy_auspll_apb_command()
1511 core_clear32(atcphy, AUSPLL_APB_CMD_OVERRIDE, AUSPLL_APB_CMD_OVERRIDE_REQ); in atcphy_auspll_apb_command()
1516 static int atcphy_dp_configure(struct apple_atcphy *atcphy, enum atcphy_dp_link_rate lr) in atcphy_dp_configure() argument
1523 guard(mutex)(&atcphy->lock); in atcphy_dp_configure()
1524 mode_cfg = atcphy_get_mode_config(atcphy, atcphy->mode); in atcphy_dp_configure()
1527 if (atcphy->dp_link_rate == lr) in atcphy_dp_configure()
1530 ret = readl_poll_timeout(atcphy->regs.core + ACIOPHY_CMN_SHM_STS_REG0, reg, in atcphy_dp_configure()
1533 dev_err(atcphy->dev, "ACIOPHY_CMN_SHM_STS_REG0_CMD_READY not set.\n"); in atcphy_dp_configure()
1537 core_clear32(atcphy, AUSPLL_FREQ_CFG, AUSPLL_FREQ_REFCLK); in atcphy_dp_configure()
1539 core_mask32(atcphy, AUSPLL_FREQ_DESC_A, AUSPLL_FD_FREQ_COUNT_TARGET, in atcphy_dp_configure()
1541 core_clear32(atcphy, AUSPLL_FREQ_DESC_A, AUSPLL_FD_FBDIVN_HALF); in atcphy_dp_configure()
1542 core_clear32(atcphy, AUSPLL_FREQ_DESC_A, AUSPLL_FD_REV_DIVN); in atcphy_dp_configure()
1543 core_mask32(atcphy, AUSPLL_FREQ_DESC_A, AUSPLL_FD_KI_MAN, FIELD_PREP(AUSPLL_FD_KI_MAN, 8)); in atcphy_dp_configure()
1544 core_mask32(atcphy, AUSPLL_FREQ_DESC_A, AUSPLL_FD_KI_EXP, FIELD_PREP(AUSPLL_FD_KI_EXP, 3)); in atcphy_dp_configure()
1545 core_mask32(atcphy, AUSPLL_FREQ_DESC_A, AUSPLL_FD_KP_MAN, FIELD_PREP(AUSPLL_FD_KP_MAN, 8)); in atcphy_dp_configure()
1546 core_mask32(atcphy, AUSPLL_FREQ_DESC_A, AUSPLL_FD_KP_EXP, FIELD_PREP(AUSPLL_FD_KP_EXP, 7)); in atcphy_dp_configure()
1547 core_clear32(atcphy, AUSPLL_FREQ_DESC_A, AUSPLL_FD_KPKI_SCALE_HBW); in atcphy_dp_configure()
1549 core_mask32(atcphy, AUSPLL_FREQ_DESC_B, AUSPLL_FD_FBDIVN_FRAC_DEN, in atcphy_dp_configure()
1551 core_mask32(atcphy, AUSPLL_FREQ_DESC_B, AUSPLL_FD_FBDIVN_FRAC_NUM, in atcphy_dp_configure()
1554 core_clear32(atcphy, AUSPLL_FREQ_DESC_C, AUSPLL_FD_SDM_SSC_STEP); in atcphy_dp_configure()
1555 core_clear32(atcphy, AUSPLL_FREQ_DESC_C, AUSPLL_FD_SDM_SSC_EN); in atcphy_dp_configure()
1556 core_mask32(atcphy, AUSPLL_FREQ_DESC_C, AUSPLL_FD_PCLK_DIV_SEL, in atcphy_dp_configure()
1558 core_mask32(atcphy, AUSPLL_FREQ_DESC_C, AUSPLL_FD_LFSDM_DIV, in atcphy_dp_configure()
1560 core_mask32(atcphy, AUSPLL_FREQ_DESC_C, AUSPLL_FD_LFCLK_CTRL, in atcphy_dp_configure()
1562 core_mask32(atcphy, AUSPLL_FREQ_DESC_C, AUSPLL_FD_VCLK_OP_DIVN, in atcphy_dp_configure()
1564 core_set32(atcphy, AUSPLL_FREQ_DESC_C, AUSPLL_FD_VCLK_PRE_DIVN); in atcphy_dp_configure()
1566 core_mask32(atcphy, AUSPLL_CLKOUT_DIV, AUSPLL_CLKOUT_PLLA_REFBUFCLK_DI, in atcphy_dp_configure()
1570 core_set32(atcphy, AUSPLL_CLKOUT_DTC_VREG, AUSPLL_DTC_VREG_BYPASS); in atcphy_dp_configure()
1572 core_clear32(atcphy, AUSPLL_CLKOUT_DTC_VREG, AUSPLL_DTC_VREG_BYPASS); in atcphy_dp_configure()
1574 core_set32(atcphy, AUSPLL_BGR, AUSPLL_BGR_CTRL_AVAIL); in atcphy_dp_configure()
1576 core_set32(atcphy, AUSPLL_CLKOUT_MASTER, AUSPLL_CLKOUT_MASTER_PCLK_DRVR_EN); in atcphy_dp_configure()
1577 core_set32(atcphy, AUSPLL_CLKOUT_MASTER, AUSPLL_CLKOUT_MASTER_PCLK2_DRVR_EN); in atcphy_dp_configure()
1578 core_set32(atcphy, AUSPLL_CLKOUT_MASTER, AUSPLL_CLKOUT_MASTER_REFBUFCLK_DRVR_EN); in atcphy_dp_configure()
1580 ret = atcphy_auspll_apb_command(atcphy, 0); in atcphy_dp_configure()
1584 ret = readl_poll_timeout(atcphy->regs.core + ACIOPHY_DP_PCLK_STAT, reg, in atcphy_dp_configure()
1587 dev_err(atcphy->dev, "ACIOPHY_DP_PCLK did not lock.\n"); in atcphy_dp_configure()
1591 ret = atcphy_auspll_apb_command(atcphy, 0x2800); in atcphy_dp_configure()
1596 ret = atcphy_dp_configure_lane(atcphy, APPLE_ATCPHY_LANE_0, cfg); in atcphy_dp_configure()
1602 ret = atcphy_dp_configure_lane(atcphy, APPLE_ATCPHY_LANE_1, cfg); in atcphy_dp_configure()
1607 core_clear32(atcphy, ACIOPHY_LANE_DP_CFG_BLK_TX_DP_CTRL0, DP_PMA_BYTECLK_RESET); in atcphy_dp_configure()
1608 core_clear32(atcphy, ACIOPHY_LANE_DP_CFG_BLK_TX_DP_CTRL0, DP_MAC_DIV20_CLK_SEL); in atcphy_dp_configure()
1610 atcphy->dp_link_rate = lr; in atcphy_dp_configure()
1614 static void atcphy_usb2_power_off(struct apple_atcphy *atcphy) in atcphy_usb2_power_off() argument
1617 writel(USB2PHY_USBCTL_ISOLATION, atcphy->regs.usb2phy + USB2PHY_USBCTL); in atcphy_usb2_power_off()
1621 set32(atcphy->regs.usb2phy + USB2PHY_CTL, USB2PHY_CTL_SIDDQ); in atcphy_usb2_power_off()
1625 set32(atcphy->regs.usb2phy + USB2PHY_CTL, USB2PHY_CTL_PORT_RESET); in atcphy_usb2_power_off()
1627 set32(atcphy->regs.usb2phy + USB2PHY_CTL, USB2PHY_CTL_RESET); in atcphy_usb2_power_off()
1629 clear32(atcphy->regs.usb2phy + USB2PHY_CTL, USB2PHY_CTL_APB_RESET_N); in atcphy_usb2_power_off()
1631 set32(atcphy->regs.usb2phy + USB2PHY_MISCTUNE, USB2PHY_MISCTUNE_APBCLK_GATE_OFF); in atcphy_usb2_power_off()
1632 set32(atcphy->regs.usb2phy + USB2PHY_MISCTUNE, USB2PHY_MISCTUNE_REFCLK_GATE_OFF); in atcphy_usb2_power_off()
1635 static int atcphy_power_off(struct apple_atcphy *atcphy) in atcphy_power_off() argument
1640 atcphy_disable_dp_aux(atcphy); in atcphy_power_off()
1643 core_clear32(atcphy, ATCPHY_POWER_CTRL, ATCPHY_POWER_PHY_RESET_N); in atcphy_power_off()
1644 core_set32(atcphy, ATCPHY_POWER_CTRL, ATCPHY_POWER_CLAMP_EN); in atcphy_power_off()
1645 core_clear32(atcphy, ATCPHY_MISC, ATCPHY_MISC_RESET_N | ATCPHY_MISC_LANE_SWAP); in atcphy_power_off()
1646 core_clear32(atcphy, ATCPHY_POWER_CTRL, ATCPHY_POWER_APB_RESET_N); in atcphy_power_off()
1648 core_clear32(atcphy, ATCPHY_POWER_CTRL, ATCPHY_POWER_SLEEP_BIG); in atcphy_power_off()
1649 ret = readl_poll_timeout(atcphy->regs.core + ATCPHY_POWER_STAT, reg, in atcphy_power_off()
1652 dev_err(atcphy->dev, "Failed to sleep atcphy \"big\"\n"); in atcphy_power_off()
1656 core_clear32(atcphy, ATCPHY_POWER_CTRL, ATCPHY_POWER_SLEEP_SMALL); in atcphy_power_off()
1657 ret = readl_poll_timeout(atcphy->regs.core + ATCPHY_POWER_STAT, reg, in atcphy_power_off()
1660 dev_err(atcphy->dev, "Failed to sleep atcphy \"small\"\n"); in atcphy_power_off()
1667 static void atcphy_usb2_power_on(struct apple_atcphy *atcphy) in atcphy_usb2_power_on() argument
1669 set32(atcphy->regs.usb2phy + USB2PHY_SIG, in atcphy_usb2_power_on()
1675 clear32(atcphy->regs.usb2phy + USB2PHY_CTL, USB2PHY_CTL_SIDDQ); in atcphy_usb2_power_on()
1679 clear32(atcphy->regs.usb2phy + USB2PHY_CTL, USB2PHY_CTL_RESET); in atcphy_usb2_power_on()
1681 clear32(atcphy->regs.usb2phy + USB2PHY_CTL, USB2PHY_CTL_PORT_RESET); in atcphy_usb2_power_on()
1683 set32(atcphy->regs.usb2phy + USB2PHY_CTL, USB2PHY_CTL_APB_RESET_N); in atcphy_usb2_power_on()
1685 clear32(atcphy->regs.usb2phy + USB2PHY_MISCTUNE, USB2PHY_MISCTUNE_APBCLK_GATE_OFF); in atcphy_usb2_power_on()
1686 clear32(atcphy->regs.usb2phy + USB2PHY_MISCTUNE, USB2PHY_MISCTUNE_REFCLK_GATE_OFF); in atcphy_usb2_power_on()
1689 writel(USB2PHY_USBCTL_RUN, atcphy->regs.usb2phy + USB2PHY_USBCTL); in atcphy_usb2_power_on()
1692 static int atcphy_power_on(struct apple_atcphy *atcphy) in atcphy_power_on() argument
1697 atcphy_usb2_power_on(atcphy); in atcphy_power_on()
1699 core_set32(atcphy, ATCPHY_MISC, ATCPHY_MISC_RESET_N); in atcphy_power_on()
1701 core_set32(atcphy, ATCPHY_POWER_CTRL, ATCPHY_POWER_SLEEP_SMALL); in atcphy_power_on()
1702 ret = readl_poll_timeout(atcphy->regs.core + ATCPHY_POWER_STAT, reg, in atcphy_power_on()
1705 dev_err(atcphy->dev, "failed to wakeup atcphy \"small\"\n"); in atcphy_power_on()
1709 core_set32(atcphy, ATCPHY_POWER_CTRL, ATCPHY_POWER_SLEEP_BIG); in atcphy_power_on()
1710 ret = readl_poll_timeout(atcphy->regs.core + ATCPHY_POWER_STAT, reg, in atcphy_power_on()
1713 dev_err(atcphy->dev, "failed to wakeup atcphy \"big\"\n"); in atcphy_power_on()
1717 core_clear32(atcphy, ATCPHY_POWER_CTRL, ATCPHY_POWER_CLAMP_EN); in atcphy_power_on()
1718 core_set32(atcphy, ATCPHY_POWER_CTRL, ATCPHY_POWER_APB_RESET_N); in atcphy_power_on()
1723 static int atcphy_configure(struct apple_atcphy *atcphy, enum atcphy_mode mode) in atcphy_configure() argument
1727 lockdep_assert_held(&atcphy->lock); in atcphy_configure()
1730 ret = atcphy_power_off(atcphy); in atcphy_configure()
1731 atcphy->mode = mode; in atcphy_configure()
1735 ret = atcphy_power_on(atcphy); in atcphy_configure()
1739 atcphy_apply_tunables(atcphy, mode); in atcphy_configure()
1741 core_set32(atcphy, AUSPLL_FSM_CTRL, 0x1fe000); in atcphy_configure()
1742 core_set32(atcphy, AUSPLL_APB_CMD_OVERRIDE, AUSPLL_APB_CMD_OVERRIDE_UNK28); in atcphy_configure()
1744 set32(atcphy->regs.core + ACIOPHY_CFG0, ACIOPHY_CFG0_COMMON_SMALL_OV); in atcphy_configure()
1746 set32(atcphy->regs.core + ACIOPHY_CFG0, ACIOPHY_CFG0_COMMON_BIG_OV); in atcphy_configure()
1748 set32(atcphy->regs.core + ACIOPHY_CFG0, ACIOPHY_CFG0_COMMON_CLAMP_OV); in atcphy_configure()
1751 mask32(atcphy->regs.core + ACIOPHY_SLEEP_CTRL, ACIOPHY_SLEEP_CTRL_TX_SMALL_OV, in atcphy_configure()
1754 mask32(atcphy->regs.core + ACIOPHY_SLEEP_CTRL, ACIOPHY_SLEEP_CTRL_TX_BIG_OV, in atcphy_configure()
1757 mask32(atcphy->regs.core + ACIOPHY_SLEEP_CTRL, ACIOPHY_SLEEP_CTRL_TX_CLAMP_OV, in atcphy_configure()
1761 mask32(atcphy->regs.core + ACIOPHY_CFG0, ACIOPHY_CFG0_RX_BIG_OV, in atcphy_configure()
1764 mask32(atcphy->regs.core + ACIOPHY_CFG0, ACIOPHY_CFG0_RX_SMALL_OV, in atcphy_configure()
1767 mask32(atcphy->regs.core + ACIOPHY_CFG0, ACIOPHY_CFG0_RX_CLAMP_OV, in atcphy_configure()
1773 atcphy_enable_dp_aux(atcphy); in atcphy_configure()
1776 core_set32(atcphy, CIO3PLL_CLK_CTRL, CIO3PLL_CLK_PCLK_EN); in atcphy_configure()
1777 core_set32(atcphy, CIO3PLL_CLK_CTRL, CIO3PLL_CLK_REFCLK_EN); in atcphy_configure()
1778 atcphy_configure_lanes(atcphy, mode); in atcphy_configure()
1781 core_set32(atcphy, ATCPHY_POWER_CTRL, ATCPHY_POWER_PHY_RESET_N); in atcphy_configure()
1783 atcphy->mode = mode; in atcphy_configure()
1790 struct apple_atcphy *atcphy = phy_get_drvdata(phy); in atcphy_usb2_set_mode() local
1792 guard(mutex)(&atcphy->lock); in atcphy_usb2_set_mode()
1796 set32(atcphy->regs.usb2phy + USB2PHY_SIG, USB2PHY_SIG_HOST); in atcphy_usb2_set_mode()
1799 clear32(atcphy->regs.usb2phy + USB2PHY_SIG, USB2PHY_SIG_HOST); in atcphy_usb2_set_mode()
1815 struct apple_atcphy *atcphy = phy_get_drvdata(phy); in atcphy_usb3_power_off() local
1818 guard(mutex)(&atcphy->lock); in atcphy_usb3_power_off()
1820 ret = atcphy_configure_pipehandler_dummy(atcphy); in atcphy_usb3_power_off()
1822 dev_warn(atcphy->dev, "Failed to switch pipe to dummy: %d", ret); in atcphy_usb3_power_off()
1824 atcphy->pipehandler_up = false; in atcphy_usb3_power_off()
1826 if (atcphy->mode != APPLE_ATCPHY_MODE_OFF) in atcphy_usb3_power_off()
1827 atcphy_configure(atcphy, APPLE_ATCPHY_MODE_OFF); in atcphy_usb3_power_off()
1834 struct apple_atcphy *atcphy = phy_get_drvdata(phy); in atcphy_usb3_set_mode() local
1836 guard(mutex)(&atcphy->lock); in atcphy_usb3_set_mode()
1843 if (atcphy->pipehandler_up) in atcphy_usb3_set_mode()
1848 return atcphy_configure_pipehandler(atcphy, true); in atcphy_usb3_set_mode()
1850 return atcphy_configure_pipehandler(atcphy, false); in atcphy_usb3_set_mode()
1874 struct apple_atcphy *atcphy = phy_get_drvdata(phy); in atcphy_dpphy_validate() local
1881 switch (atcphy->mode) { in atcphy_dpphy_validate()
1898 struct apple_atcphy *atcphy = phy_get_drvdata(phy); in atcphy_dpphy_configure() local
1923 dev_err(atcphy->dev, "Unsupported link rate: %d\n", opts->link_rate); in atcphy_dpphy_configure()
1927 return atcphy_dp_configure(atcphy, link_rate); in atcphy_dpphy_configure()
1942 struct apple_atcphy *atcphy = dev_get_drvdata(dev); in atcphy_xlate() local
1946 return atcphy->phys.usb2; in atcphy_xlate()
1948 return atcphy->phys.usb3; in atcphy_xlate()
1950 return atcphy->phys.dp; in atcphy_xlate()
1955 static int atcphy_probe_phy(struct apple_atcphy *atcphy) in atcphy_probe_phy() argument
1961 { &atcphy->phys.usb2, &apple_atc_usb2_phy_ops }, in atcphy_probe_phy()
1962 { &atcphy->phys.usb3, &apple_atc_usb3_phy_ops }, in atcphy_probe_phy()
1963 { &atcphy->phys.dp, &apple_atc_dp_phy_ops }, in atcphy_probe_phy()
1967 *phys[i].phy = devm_phy_create(atcphy->dev, NULL, phys[i].ops); in atcphy_probe_phy()
1970 phy_set_drvdata(*phys[i].phy, atcphy); in atcphy_probe_phy()
1973 atcphy->phy_provider = devm_of_phy_provider_register(atcphy->dev, atcphy_xlate); in atcphy_probe_phy()
1974 if (IS_ERR(atcphy->phy_provider)) in atcphy_probe_phy()
1975 return PTR_ERR(atcphy->phy_provider); in atcphy_probe_phy()
1979 static void _atcphy_dwc3_reset_assert(struct apple_atcphy *atcphy) in _atcphy_dwc3_reset_assert() argument
1981 lockdep_assert_held(&atcphy->lock); in _atcphy_dwc3_reset_assert()
1983 clear32(atcphy->regs.pipehandler + PIPEHANDLER_AON_GEN, PIPEHANDLER_AON_GEN_DWC3_RESET_N); in _atcphy_dwc3_reset_assert()
1984 set32(atcphy->regs.pipehandler + PIPEHANDLER_AON_GEN, in _atcphy_dwc3_reset_assert()
1990 struct apple_atcphy *atcphy = container_of(rcdev, struct apple_atcphy, rcdev); in atcphy_dwc3_reset_assert() local
1993 guard(mutex)(&atcphy->lock); in atcphy_dwc3_reset_assert()
1995 _atcphy_dwc3_reset_assert(atcphy); in atcphy_dwc3_reset_assert()
1997 if (atcphy->pipehandler_up) { in atcphy_dwc3_reset_assert()
1998 ret = atcphy_configure_pipehandler_dummy(atcphy); in atcphy_dwc3_reset_assert()
2000 dev_warn(atcphy->dev, "Failed to switch PIPE to dummy: %d\n", ret); in atcphy_dwc3_reset_assert()
2002 atcphy->pipehandler_up = false; in atcphy_dwc3_reset_assert()
2005 atcphy_usb2_power_off(atcphy); in atcphy_dwc3_reset_assert()
2012 struct apple_atcphy *atcphy = container_of(rcdev, struct apple_atcphy, rcdev); in atcphy_dwc3_reset_deassert() local
2014 guard(mutex)(&atcphy->lock); in atcphy_dwc3_reset_deassert()
2016 clear32(atcphy->regs.pipehandler + PIPEHANDLER_AON_GEN, in atcphy_dwc3_reset_deassert()
2018 set32(atcphy->regs.pipehandler + PIPEHANDLER_AON_GEN, PIPEHANDLER_AON_GEN_DWC3_RESET_N); in atcphy_dwc3_reset_deassert()
2034 static int atcphy_probe_rcdev(struct apple_atcphy *atcphy) in atcphy_probe_rcdev() argument
2036 atcphy->rcdev.owner = THIS_MODULE; in atcphy_probe_rcdev()
2037 atcphy->rcdev.nr_resets = 1; in atcphy_probe_rcdev()
2038 atcphy->rcdev.ops = &atcphy_dwc3_reset_ops; in atcphy_probe_rcdev()
2039 atcphy->rcdev.of_node = atcphy->dev->of_node; in atcphy_probe_rcdev()
2040 atcphy->rcdev.of_reset_n_cells = 0; in atcphy_probe_rcdev()
2041 atcphy->rcdev.of_xlate = atcphy_reset_xlate; in atcphy_probe_rcdev()
2043 return devm_reset_controller_register(atcphy->dev, &atcphy->rcdev); in atcphy_probe_rcdev()
2048 struct apple_atcphy *atcphy = typec_switch_get_drvdata(sw); in atcphy_sw_set() local
2050 guard(mutex)(&atcphy->lock); in atcphy_sw_set()
2056 atcphy->swap_lanes = false; in atcphy_sw_set()
2059 atcphy->swap_lanes = true; in atcphy_sw_set()
2071 static int atcphy_probe_switch(struct apple_atcphy *atcphy) in atcphy_probe_switch() argument
2075 .drvdata = atcphy, in atcphy_probe_switch()
2076 .fwnode = atcphy->dev->fwnode, in atcphy_probe_switch()
2080 sw = typec_switch_register(atcphy->dev, &sw_desc); in atcphy_probe_switch()
2084 return devm_add_action_or_reset(atcphy->dev, atcphy_typec_switch_unregister, sw); in atcphy_probe_switch()
2089 struct apple_atcphy *atcphy = typec_mux_get_drvdata(mux); in atcphy_mux_set() local
2092 guard(mutex)(&atcphy->lock); in atcphy_mux_set()
2113 dev_warn(atcphy->dev, "Unsupported EUDO USB mode: 0x%x.\n", eudo_usb_mode); in atcphy_mux_set()
2128 dev_err(atcphy->dev, in atcphy_mux_set()
2134 dev_err(atcphy->dev, in atcphy_mux_set()
2139 dev_err(atcphy->dev, "Unknown mode: 0x%lx, your connected device will not work.\n", in atcphy_mux_set()
2144 if (atcphy->mode == target_mode) in atcphy_mux_set()
2152 WARN_ON_ONCE(atcphy->pipehandler_up); in atcphy_mux_set()
2153 return atcphy_configure(atcphy, target_mode); in atcphy_mux_set()
2161 static int atcphy_probe_mux(struct apple_atcphy *atcphy) in atcphy_probe_mux() argument
2165 .drvdata = atcphy, in atcphy_probe_mux()
2166 .fwnode = atcphy->dev->fwnode, in atcphy_probe_mux()
2170 mux = typec_mux_register(atcphy->dev, &mux_desc); in atcphy_probe_mux()
2174 return devm_add_action_or_reset(atcphy->dev, atcphy_typec_mux_unregister, mux); in atcphy_probe_mux()
2177 static int atcphy_load_tunables(struct apple_atcphy *atcphy) in atcphy_load_tunables() argument
2184 { "apple,tunable-axi2af", &atcphy->tunables.axi2af, atcphy->res.axi2af }, in atcphy_load_tunables()
2185 { "apple,tunable-common-a", &atcphy->tunables.common[0], atcphy->res.core }, in atcphy_load_tunables()
2186 { "apple,tunable-common-b", &atcphy->tunables.common[1], atcphy->res.core }, in atcphy_load_tunables()
2187 { "apple,tunable-lane0-usb", &atcphy->tunables.lane_usb3[0], atcphy->res.core }, in atcphy_load_tunables()
2188 { "apple,tunable-lane1-usb", &atcphy->tunables.lane_usb3[1], atcphy->res.core }, in atcphy_load_tunables()
2189 { "apple,tunable-lane0-cio", &atcphy->tunables.lane_usb4[0], atcphy->res.core }, in atcphy_load_tunables()
2190 { "apple,tunable-lane1-cio", &atcphy->tunables.lane_usb4[1], atcphy->res.core }, in atcphy_load_tunables()
2191 { "apple,tunable-lane0-dp", &atcphy->tunables.lane_dp[0], atcphy->res.core }, in atcphy_load_tunables()
2192 { "apple,tunable-lane1-dp", &atcphy->tunables.lane_dp[1], atcphy->res.core }, in atcphy_load_tunables()
2197 atcphy->dev, atcphy->np, tunables[i].dt_name, tunables[i].res); in atcphy_load_tunables()
2199 dev_err(atcphy->dev, "Failed to read tunable %s: %ld\n", in atcphy_load_tunables()
2208 static int atcphy_map_resources(struct platform_device *pdev, struct apple_atcphy *atcphy) in atcphy_map_resources() argument
2215 { "core", &atcphy->regs.core, &atcphy->res.core }, in atcphy_map_resources()
2216 { "lpdptx", &atcphy->regs.lpdptx, NULL }, in atcphy_map_resources()
2217 { "axi2af", &atcphy->regs.axi2af, &atcphy->res.axi2af }, in atcphy_map_resources()
2218 { "usb2phy", &atcphy->regs.usb2phy, NULL }, in atcphy_map_resources()
2219 { "pipehandler", &atcphy->regs.pipehandler, NULL }, in atcphy_map_resources()
2228 return dev_err_probe(atcphy->dev, PTR_ERR(addr), in atcphy_map_resources()
2239 static int atcphy_probe_finalize(struct apple_atcphy *atcphy) in atcphy_probe_finalize() argument
2243 guard(mutex)(&atcphy->lock); in atcphy_probe_finalize()
2246 _atcphy_dwc3_reset_assert(atcphy); in atcphy_probe_finalize()
2249 atcphy_usb2_power_off(atcphy); in atcphy_probe_finalize()
2250 atcphy_power_off(atcphy); in atcphy_probe_finalize()
2251 atcphy_setup_pipehandler(atcphy); in atcphy_probe_finalize()
2253 ret = atcphy_probe_rcdev(atcphy); in atcphy_probe_finalize()
2255 return dev_err_probe(atcphy->dev, ret, "Probing rcdev failed"); in atcphy_probe_finalize()
2256 ret = atcphy_probe_mux(atcphy); in atcphy_probe_finalize()
2258 return dev_err_probe(atcphy->dev, ret, "Probing mux failed"); in atcphy_probe_finalize()
2259 ret = atcphy_probe_switch(atcphy); in atcphy_probe_finalize()
2261 return dev_err_probe(atcphy->dev, ret, "Probing switch failed"); in atcphy_probe_finalize()
2262 ret = atcphy_probe_phy(atcphy); in atcphy_probe_finalize()
2264 return dev_err_probe(atcphy->dev, ret, "Probing phy failed"); in atcphy_probe_finalize()
2271 struct apple_atcphy *atcphy; in atcphy_probe() local
2275 atcphy = devm_kzalloc(&pdev->dev, sizeof(*atcphy), GFP_KERNEL); in atcphy_probe()
2276 if (!atcphy) in atcphy_probe()
2279 atcphy->dev = dev; in atcphy_probe()
2280 atcphy->np = dev->of_node; in atcphy_probe()
2281 mutex_init(&atcphy->lock); in atcphy_probe()
2282 platform_set_drvdata(pdev, atcphy); in atcphy_probe()
2284 ret = atcphy_map_resources(pdev, atcphy); in atcphy_probe()
2287 ret = atcphy_load_tunables(atcphy); in atcphy_probe()
2291 atcphy->mode = APPLE_ATCPHY_MODE_OFF; in atcphy_probe()
2292 atcphy->pipehandler_up = false; in atcphy_probe()
2294 return atcphy_probe_finalize(atcphy); in atcphy_probe()