#endif
}
+static void afe_disable_phy_clocks(state_struct *state);
+static void afe_enable_phy_clocks(state_struct *state);
+
void afe_init_t28hpc(state_struct *state,
int num_lanes,
ENUM_AFE_LINK_RATE link_rate)
link_rate);
return;
}
+ if (state->phy_init)
+ afe_disable_phy_clocks(state);
if (phy_reset_workaround) {
int k;
/* for differential clock on the refclk_p and refclk_m off chip pins:
* PHY_PMA_CMN_CTRL1[6:4]=3'b000
- * val = val | 0x0030;
+ * val = val | 0x0000;
*/
val = val | 0x0000; /* select external reference */
Afe_write(state, PHY_PMA_CMN_CTRL1, val);
__func__, link_rate);
return;
}
+ if (state->phy_init)
+ afe_enable_phy_clocks(state);
+ else
+ state->phy_init = 1;
Afe_write(state, TX_DIAG_ACYA_0, 1);
Afe_write(state, TX_DIAG_ACYA_1, 1);
aux_cfg_t28hpc(state);
}
+
+static void afe_disable_phy_clocks(state_struct *state)
+{
+ unsigned short val;
+ int i = 0;
+
+ /* Write PHY_HDP_MODE_CTL[3:0] with 0b1000. (Place the PHY lanes in
+ * the A3 power state.)
+ */
+ Afe_write(state, PHY_HDP_MODE_CTRL, 0x8);
+
+ /* Wait for PHY_HDP_MODE_CTL[7:4] == 0b1000 */
+ do {
+ val = Afe_read(state, PHY_HDP_MODE_CTRL);
+ val = val >> 7;
+ if (i++ % 10000 == 0)
+ pr_info("Wait for A3 ACK\n");
+ } while ((val & 1) != 1);
+
+ /* gate PLL clocks */
+ val = Afe_read(state, PHY_HDP_CLK_CTL);
+ val &= ~(1 << 2);
+ Afe_write(state, PHY_HDP_CLK_CTL, val);
+
+ /* Wait for PHY_HDP_CLK_CTL[bit 3] == 0 */
+ do {
+ val = Afe_read(state, PHY_HDP_CLK_CTL);
+ val = val >> 3;
+ if (i++ % 10000 == 0)
+ pr_info("Wait for PHY_HDP_CLK_CTL[bit 3] == 0\n");
+ } while ((val & 1) != 0);
+
+ /* disable PLL */
+ val = Afe_read(state, PHY_HDP_CLK_CTL);
+ val &= ~(1 << 0);
+ Afe_write(state, PHY_HDP_CLK_CTL, val);
+
+ /* Wait for PHY_HDP_CLK_CTL[bit 1] == 0 */
+ do {
+ val = Afe_read(state, PHY_HDP_CLK_CTL);
+ val = val >> 1;
+ if (i++ % 10000 == 0)
+ pr_info("Wait for PHY_HDP_CLK_CTL[bit 1] == 0\n");
+ } while ((val & 1) != 0);
+}
+
+static void afe_enable_phy_clocks(state_struct *state)
+{
+ unsigned short val;
+ int i = 0;
+
+ /* enable PLL */
+ val = Afe_read(state, PHY_HDP_CLK_CTL);
+ val |= (1 << 0);
+ Afe_write(state, PHY_HDP_CLK_CTL, val);
+
+ /* Wait for PHY_HDP_CLK_CTL[bit 1] == 0 */
+ do {
+ val = Afe_read(state, PHY_HDP_CLK_CTL);
+ val = val >> 1;
+ if (i++ % 10000 == 0)
+ pr_info("Wait until PHY_HDP_CLK_CTL[bit 1] != 0\n");
+ } while ((val & 1) == 0);
+
+ /* ungate PLL clocks */
+ val = Afe_read(state, PHY_HDP_CLK_CTL);
+ val |= (1 << 2);
+ Afe_write(state, PHY_HDP_CLK_CTL, val);
+
+ /* Wait for PHY_HDP_CLK_CTL[bit 3] == 0 */
+ do {
+ val = Afe_read(state, PHY_HDP_CLK_CTL);
+ val = val >> 3;
+ if (i++ % 10000 == 0)
+ pr_info("Wait until PHY_HDP_CLK_CTL[bit 3] != 0\n");
+ } while ((val & 1) == 0);
+}