|
22 | 22 | #include <linux/gpio.h>
|
23 | 23 | #include <linux/kernel.h>
|
24 | 24 | #include <linux/math.h>
|
| 25 | +#include <linux/minmax.h> |
25 | 26 | #include <linux/module.h>
|
26 | 27 | #include <linux/platform_data/b53.h>
|
27 | 28 | #include <linux/phy.h>
|
@@ -1322,24 +1323,17 @@ static void b53_adjust_63xx_rgmii(struct dsa_switch *ds, int port,
|
1322 | 1323 | phy_interface_t interface)
|
1323 | 1324 | {
|
1324 | 1325 | struct b53_device *dev = ds->priv;
|
1325 |
| - u8 rgmii_ctrl = 0, off; |
| 1326 | + u8 rgmii_ctrl = 0; |
1326 | 1327 |
|
1327 |
| - if (port == dev->imp_port) |
1328 |
| - off = B53_RGMII_CTRL_IMP; |
1329 |
| - else |
1330 |
| - off = B53_RGMII_CTRL_P(port); |
1331 |
| - |
1332 |
| - b53_read8(dev, B53_CTRL_PAGE, off, &rgmii_ctrl); |
| 1328 | + b53_read8(dev, B53_CTRL_PAGE, B53_RGMII_CTRL_P(port), &rgmii_ctrl); |
1333 | 1329 | rgmii_ctrl &= ~(RGMII_CTRL_DLL_RXC | RGMII_CTRL_DLL_TXC);
|
1334 | 1330 |
|
1335 |
| - if (port != dev->imp_port) { |
1336 |
| - if (is63268(dev)) |
1337 |
| - rgmii_ctrl |= RGMII_CTRL_MII_OVERRIDE; |
| 1331 | + if (is63268(dev)) |
| 1332 | + rgmii_ctrl |= RGMII_CTRL_MII_OVERRIDE; |
1338 | 1333 |
|
1339 |
| - rgmii_ctrl |= RGMII_CTRL_ENABLE_GMII; |
1340 |
| - } |
| 1334 | + rgmii_ctrl |= RGMII_CTRL_ENABLE_GMII; |
1341 | 1335 |
|
1342 |
| - b53_write8(dev, B53_CTRL_PAGE, off, rgmii_ctrl); |
| 1336 | + b53_write8(dev, B53_CTRL_PAGE, B53_RGMII_CTRL_P(port), rgmii_ctrl); |
1343 | 1337 |
|
1344 | 1338 | dev_dbg(ds->dev, "Configured port %d for %s\n", port,
|
1345 | 1339 | phy_modes(interface));
|
@@ -1484,7 +1478,7 @@ static void b53_phylink_mac_config(struct phylink_config *config,
|
1484 | 1478 | struct b53_device *dev = ds->priv;
|
1485 | 1479 | int port = dp->index;
|
1486 | 1480 |
|
1487 |
| - if (is63xx(dev) && port >= B53_63XX_RGMII0) |
| 1481 | + if (is63xx(dev) && in_range(port, B53_63XX_RGMII0, 4)) |
1488 | 1482 | b53_adjust_63xx_rgmii(ds, port, interface);
|
1489 | 1483 |
|
1490 | 1484 | if (mode == MLO_AN_FIXED) {
|
|
0 commit comments