u32 lastEvent;
u16 rxrings;
u16 rxringlen;
- u8 smi_bus[MAX_PORTS];
+ int smi_bus[MAX_PORTS];
u8 smi_addr[MAX_PORTS];
u32 sds_id[MAX_PORTS];
bool smi_bus_isc45[MAX_SMI_BUSSES];
for (int i = 0; i < RTL930X_CPU_PORT; i++) {
int pos;
- if (priv->smi_bus[i] > 3)
+ if (priv->smi_bus[i] < 0)
continue;
+
pos = (i % 6) * 5;
sw_w32_mask(0x1f << pos, priv->smi_addr[i] << pos,
RTL930X_SMI_PORT0_5_ADDR + (i / 6) * 4);
mdc_on[0] = mdc_on[1] = mdc_on[2] = mdc_on[3] = false;
/* Mapping of port to phy-addresses on an SMI bus */
poll_sel[0] = poll_sel[1] = poll_sel[2] = poll_sel[3] = 0;
- for (int i = 0; i < 56; i++) {
+ for (int i = 0; i < RTL931X_CPU_PORT; i++) {
u32 pos;
+ if (priv->smi_bus[i] < 0)
+ continue;
+
pos = (i % 6) * 5;
sw_w32_mask(0x1f << pos, priv->smi_addr[i] << pos, RTL931X_SMI_PORT_ADDR + (i / 6) * 4);
pos = (i * 2) % 32;
if (of_property_read_u32(dn, "reg", &pn))
continue;
- if (of_property_read_u32_array(dn, "rtl9300,smi-address", &smi_addr[0], 2)) {
- smi_addr[0] = 0;
- smi_addr[1] = pn;
+ if (pn >= MAX_PORTS) {
+ pr_err("%s: illegal port number %d\n", __func__, pn);
+ return -ENODEV;
}
if (of_property_read_u32(dn, "sds", &priv->sds_id[pn]))
priv->sds_id[pn] = -1;
- else {
+ else
pr_info("set sds port %d to %d\n", pn, priv->sds_id[pn]);
- }
- if (pn < MAX_PORTS) {
+ if (of_property_read_u32_array(dn, "rtl9300,smi-address", &smi_addr[0], 2)) {
+ priv->smi_bus[pn] = 0;
+ priv->smi_addr[pn] = pn;
+ } else {
priv->smi_bus[pn] = smi_addr[0];
priv->smi_addr[pn] = smi_addr[1];
- } else {
- pr_err("%s: illegal port number %d\n", __func__, pn);
}
- if (of_device_is_compatible(dn, "ethernet-phy-ieee802.3-c45"))
- priv->smi_bus_isc45[smi_addr[0]] = true;
-
- if (of_property_read_bool(dn, "phy-is-integrated")) {
- priv->phy_is_internal[pn] = true;
+ if (priv->smi_bus[pn] >= MAX_SMI_BUSSES) {
+ pr_err("%s: illegal SMI bus number %d\n", __func__, priv->smi_bus[pn]);
+ return -ENODEV;
}
+
+ priv->phy_is_internal[pn] = of_property_read_bool(dn, "phy-is-integrated");
+
+ if (priv->phy_is_internal[pn] && priv->sds_id[pn] >= 0)
+ priv->smi_bus[pn]= -1;
+ else if (of_device_is_compatible(dn, "ethernet-phy-ieee802.3-c45"))
+ priv->smi_bus_isc45[priv->smi_bus[pn]] = true;
}
dn = of_find_compatible_node(NULL, NULL, "realtek,rtl83xx-switch");