#define RTSDS_930X_PLL_1000 0x1
#define RTSDS_930X_PLL_10000 0x5
#define RTSDS_930X_PLL_2500 0x3
-#define RTSDS_930X_PLL_LC 0x3
-#define RTSDS_930X_PLL_RING 0x1
+#define RTPCS_930X_PLL_LC 0x3
+#define RTPCS_930X_PLL_RING 0x1
/* Registers of the internal SerDes of the 9310 */
#define RTL931X_SERDES_MODE_CTRL (0x13cc)
RTPCS_PORT_MEDIA_DAC_500CM,
};
+enum rtpcs_sds_pll_type {
+ RTPCS_SDS_PLL_RING,
+ RTPCS_SDS_PLL_LC,
+ RTPCS_SDS_PLL_END,
+};
+
struct rtpcs_ctrl;
struct rtpcs_serdes {
rtpcs_sds_write_bits(sds, page, 0x15, 4, 4, 0x0);
}
-static void rtpcs_930x_sds_get_pll_data(struct rtpcs_serdes *sds,
- int *pll, int *speed)
+static void rtpcs_930x_sds_get_pll_data(struct rtpcs_serdes *sds, enum rtpcs_sds_pll_type *pll,
+ int *speed)
{
struct rtpcs_serdes *even_sds = rtpcs_sds_get_even(sds);
int sbit, pbit = (sds == even_sds) ? 4 : 6;
+ int pll_val;
/*
* PLL data is shared between adjacent SerDes in the even lane. Each SerDes defines
* what PLL it needs (ring or LC) while the PLL itself stores the current speed.
*/
- *pll = rtpcs_sds_read_bits(even_sds, 0x20, 0x12, pbit + 1, pbit);
- sbit = *pll == RTSDS_930X_PLL_LC ? 8 : 12;
+ pll_val = rtpcs_sds_read_bits(even_sds, 0x20, 0x12, pbit + 1, pbit);
+ *pll = pll_val == RTPCS_930X_PLL_LC ? RTPCS_SDS_PLL_LC : RTPCS_SDS_PLL_RING;
+
+ sbit = *pll == RTPCS_SDS_PLL_LC ? 8 : 12;
*speed = rtpcs_sds_read_bits(even_sds, 0x20, 0x12, sbit + 3, sbit);
}
-static int rtpcs_930x_sds_set_pll_data(struct rtpcs_serdes *sds,
- int pll, int speed)
+static int rtpcs_930x_sds_set_pll_data(struct rtpcs_serdes *sds, enum rtpcs_sds_pll_type pll,
+ int speed)
{
struct rtpcs_serdes *even_sds = rtpcs_sds_get_even(sds);
- int sbit = pll == RTSDS_930X_PLL_LC ? 8 : 12;
+ int sbit = pll == RTPCS_SDS_PLL_LC ? 8 : 12;
int pbit = (sds == even_sds) ? 4 : 6;
+ int pll_val;
if ((speed != RTSDS_930X_PLL_1000) &&
(speed != RTSDS_930X_PLL_2500) &&
(speed != RTSDS_930X_PLL_10000))
return -EINVAL;
- if ((pll != RTSDS_930X_PLL_RING) && (pll != RTSDS_930X_PLL_LC))
+ if (pll >= RTPCS_SDS_PLL_END)
return -EINVAL;
- if ((pll == RTSDS_930X_PLL_RING) && (speed == RTSDS_930X_PLL_10000))
+ if ((pll == RTPCS_SDS_PLL_RING) && (speed == RTSDS_930X_PLL_10000))
return -EINVAL;
/*
* always activate both.
*/
+ pll_val = pll == RTPCS_SDS_PLL_LC ? RTPCS_930X_PLL_LC : RTPCS_930X_PLL_RING;
rtpcs_sds_write_bits(even_sds, 0x20, 0x12, 3, 0, 0xf);
- rtpcs_sds_write_bits(even_sds, 0x20, 0x12, pbit + 1, pbit, pll);
+ rtpcs_sds_write_bits(even_sds, 0x20, 0x12, pbit + 1, pbit, pll_val);
rtpcs_sds_write_bits(even_sds, 0x20, 0x12, sbit + 3, sbit, speed);
return 0;
{
struct rtpcs_serdes *even_sds = rtpcs_sds_get_even(sds);
int reset_sequence[4] = { 3, 2, 3, 1 };
- int pll, speed, i, bit;
+ enum rtpcs_sds_pll_type pll;
+ int speed, i, bit;
/*
* After the PLL speed has changed, the CMU must take over the new values. The models
*/
rtpcs_930x_sds_get_pll_data(sds, &pll, &speed);
- bit = pll == RTSDS_930X_PLL_LC ? 2 : 0;
+ bit = pll == RTPCS_SDS_PLL_LC ? 2 : 0;
for (i = 0; i < ARRAY_SIZE(reset_sequence); i++)
rtpcs_sds_write_bits(even_sds, 0x21, 0x0b, bit + 1, bit,
rtpcs_sds_write_bits(sds, 0x20, 0x00, 5, 4, rx_enable);
}
-static void rtpcs_930x_sds_reconfigure_pll(struct rtpcs_serdes *sds, int pll)
+static void rtpcs_930x_sds_reconfigure_pll(struct rtpcs_serdes *sds, enum rtpcs_sds_pll_type pll)
{
- int mode, tmp, speed;
+ enum rtpcs_sds_pll_type tmp;
+ int mode, speed;
mode = __rtpcs_930x_sds_get_ip_mode(sds);
rtpcs_930x_sds_get_pll_data(sds, &tmp, &speed);
enum rtpcs_sds_mode hw_mode)
{
struct rtpcs_serdes *nb_sds = rtpcs_sds_get_neighbor(sds);
- int neighbor_speed, neighbor_mode, neighbor_pll;
+ enum rtpcs_sds_pll_type pll, neighbor_pll;
+ int speed, neighbor_speed, neighbor_mode;
bool speed_changed = true;
- int pll, speed;
/*
* A SerDes pair on the RTL930x is driven by two PLLs. A low speed ring PLL can generate
return -ENOTSUPP;
if (!neighbor_mode)
- pll = speed == RTSDS_930X_PLL_10000 ? RTSDS_930X_PLL_LC : RTSDS_930X_PLL_RING;
+ pll = speed == RTSDS_930X_PLL_10000 ? RTPCS_SDS_PLL_LC : RTPCS_SDS_PLL_RING;
else if (speed == neighbor_speed) {
speed_changed = false;
pll = neighbor_pll;
- } else if (neighbor_pll == RTSDS_930X_PLL_RING)
- pll = RTSDS_930X_PLL_LC;
+ } else if (neighbor_pll == RTPCS_SDS_PLL_RING)
+ pll = RTPCS_SDS_PLL_LC;
else if (speed == RTSDS_930X_PLL_10000) {
pr_info("%s: SDS %d needs LC PLL, reconfigure SDS %d to use ring PLL\n",
__func__, sds->id, nb_sds->id);
- rtpcs_930x_sds_reconfigure_pll(nb_sds, RTSDS_930X_PLL_RING);
- pll = RTSDS_930X_PLL_LC;
+ rtpcs_930x_sds_reconfigure_pll(nb_sds, RTPCS_SDS_PLL_RING);
+ pll = RTPCS_SDS_PLL_LC;
} else
- pll = RTSDS_930X_PLL_RING;
+ pll = RTPCS_SDS_PLL_RING;
rtpcs_930x_sds_set_pll_data(sds, pll, speed);
rtpcs_930x_sds_reset_cmu(sds);
pr_info("%s: SDS %d using %s PLL for mode %d\n", __func__, sds->id,
- pll == RTSDS_930X_PLL_LC ? "LC" : "ring", hw_mode);
+ pll == RTPCS_SDS_PLL_LC ? "LC" : "ring", hw_mode);
return 0;
}
}
}
-static int rtpcs_931x_sds_cmu_type_set(struct rtpcs_serdes *sds, enum rtpcs_sds_mode hw_mode,
- int chiptype)
+static int rtpcs_931x_sds_config_cmu(struct rtpcs_serdes *sds, enum rtpcs_sds_mode hw_mode,
+ int chiptype)
{
struct rtpcs_serdes *even_sds = rtpcs_sds_get_even(sds);
- u32 frc_lc_mode_bitnum, frc_lc_mode_val_bitnum;
- int cmu_type = 0; /* Clock Management Unit */
+ u32 force_lc_mode_bit, force_lc_mode_val_bit;
+ enum rtpcs_sds_pll_type pll_type; /* SDK calls this cmu_type */
+ bool force_pll_spd;
int cmu_page = 0;
- u32 frc_cmu_spd;
switch (hw_mode) {
case RTPCS_SDS_MODE_OFF:
return; */
case RTPCS_SDS_MODE_QSGMII:
- cmu_type = 1;
- frc_cmu_spd = 0;
+ pll_type = RTPCS_SDS_PLL_RING;
+ force_pll_spd = false;
break;
case RTPCS_SDS_MODE_1000BASEX:
- cmu_type = 1;
- frc_cmu_spd = 0;
+ pll_type = RTPCS_SDS_PLL_RING;
+ force_pll_spd = false;
break;
/* case MII_1000BX100BX_AUTO:
- cmu_type = 1;
- frc_cmu_spd = 0;
+ pll_type = RTPCS_SDS_PLL_RING;
+ force_pll_spd = false;
break; */
case RTPCS_SDS_MODE_SGMII:
- cmu_type = 1;
- frc_cmu_spd = 0;
+ pll_type = RTPCS_SDS_PLL_RING;
+ force_pll_spd = false;
break;
case RTPCS_SDS_MODE_2500BASEX:
- cmu_type = 1;
- frc_cmu_spd = 1;
+ pll_type = RTPCS_SDS_PLL_RING;
+ force_pll_spd = true;
break;
default:
return -EINVAL;
}
- if (cmu_type == 1) {
+ if (pll_type == RTPCS_SDS_PLL_RING) {
cmu_page = rtpcs_931x_sds_cmu_page_get(hw_mode);
if (cmu_page < 0)
return -EINVAL;
}
if (sds == even_sds) {
- frc_lc_mode_bitnum = 4;
- frc_lc_mode_val_bitnum = 5;
+ force_lc_mode_bit = 4;
+ force_lc_mode_val_bit = 5;
} else {
- frc_lc_mode_bitnum = 6;
- frc_lc_mode_val_bitnum = 7;
+ force_lc_mode_bit = 6;
+ force_lc_mode_val_bit = 7;
}
- pr_info("%s: cmu_type %0d cmu_page %x frc_cmu_spd %d even_sds %d sds %d\n",
- __func__, cmu_type, cmu_page, frc_cmu_spd, even_sds->id,
- sds->id);
+ pr_info("%s: pll_type %s cmu_page %x force_pll_spd %d even_sds %d sds %d\n",
+ __func__, pll_type == RTPCS_SDS_PLL_LC ? "LC" : "ring", cmu_page, force_pll_spd,
+ even_sds->id, sds->id);
- if (cmu_type == 1) {
+ if (pll_type == RTPCS_SDS_PLL_RING) {
rtpcs_sds_write_bits(sds, cmu_page, 0x7, 15, 15, 0x0);
if (chiptype)
rtpcs_sds_write_bits(sds, cmu_page, 0xd, 14, 14, 0x0);
rtpcs_sds_write_bits(even_sds, 0x20, 0x12, 3, 2, 0x3);
- rtpcs_sds_write_bits(even_sds, 0x20, 0x12, frc_lc_mode_bitnum,
- frc_lc_mode_bitnum, 0x1);
- rtpcs_sds_write_bits(even_sds, 0x20, 0x12, frc_lc_mode_val_bitnum,
- frc_lc_mode_val_bitnum, 0x0);
+ rtpcs_sds_write_bits(even_sds, 0x20, 0x12, force_lc_mode_bit,
+ force_lc_mode_bit, 0x1);
+ rtpcs_sds_write_bits(even_sds, 0x20, 0x12, force_lc_mode_val_bit,
+ force_lc_mode_val_bit, 0x0);
rtpcs_sds_write_bits(even_sds, 0x20, 0x12, 12, 12, 0x1);
- rtpcs_sds_write_bits(even_sds, 0x20, 0x12, 15, 13, frc_cmu_spd);
+ rtpcs_sds_write_bits(even_sds, 0x20, 0x12, 15, 13, force_pll_spd ? 0x1 : 0x0);
}
return 0;
break;
}
- rtpcs_931x_sds_cmu_type_set(sds, hw_mode, chiptype);
+ rtpcs_931x_sds_config_cmu(sds, hw_mode, chiptype);
if (sds_id >= 2) {
if (chiptype)