Skip to content

Commit 8b95274

Browse files
noglitchdavem330
authored andcommitted
net: macb: shrink macb_platform_data structure
This structure was used intensively for machine specific values when DT was not used. Since the removal of AVR32 from the kernel, this structure is only used for passing clocks from PCI macb wrapper, all other fields being 0. All other known platforms use DT. Remove the leftovers but make sure that PCI macb still works as expected by using default values: - phydev->irq is set to PHY_POLL by mdiobus_alloc() - mii_bus->phy_mask is cleared while allocating it - bp->phy_interface is set to PHY_INTERFACE_MODE_MII if mode not found in DT. This simplifies driver probe path and particularly phy handling. Signed-off-by: Nicolas Ferre <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent d5aeb17 commit 8b95274

File tree

2 files changed

+11
-57
lines changed

2 files changed

+11
-57
lines changed

drivers/net/ethernet/cadence/macb_main.c

Lines changed: 11 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -285,34 +285,22 @@ static void macb_set_hwaddr(struct macb *bp)
285285

286286
static void macb_get_hwaddr(struct macb *bp)
287287
{
288-
struct macb_platform_data *pdata;
289288
u32 bottom;
290289
u16 top;
291290
u8 addr[6];
292291
int i;
293292

294-
pdata = dev_get_platdata(&bp->pdev->dev);
295-
296293
/* Check all 4 address register for valid address */
297294
for (i = 0; i < 4; i++) {
298295
bottom = macb_or_gem_readl(bp, SA1B + i * 8);
299296
top = macb_or_gem_readl(bp, SA1T + i * 8);
300297

301-
if (pdata && pdata->rev_eth_addr) {
302-
addr[5] = bottom & 0xff;
303-
addr[4] = (bottom >> 8) & 0xff;
304-
addr[3] = (bottom >> 16) & 0xff;
305-
addr[2] = (bottom >> 24) & 0xff;
306-
addr[1] = top & 0xff;
307-
addr[0] = (top & 0xff00) >> 8;
308-
} else {
309-
addr[0] = bottom & 0xff;
310-
addr[1] = (bottom >> 8) & 0xff;
311-
addr[2] = (bottom >> 16) & 0xff;
312-
addr[3] = (bottom >> 24) & 0xff;
313-
addr[4] = top & 0xff;
314-
addr[5] = (top >> 8) & 0xff;
315-
}
298+
addr[0] = bottom & 0xff;
299+
addr[1] = (bottom >> 8) & 0xff;
300+
addr[2] = (bottom >> 16) & 0xff;
301+
addr[3] = (bottom >> 24) & 0xff;
302+
addr[4] = top & 0xff;
303+
addr[5] = (top >> 8) & 0xff;
316304

317305
if (is_valid_ether_addr(addr)) {
318306
memcpy(bp->dev->dev_addr, addr, sizeof(addr));
@@ -510,12 +498,10 @@ static void macb_handle_link_change(struct net_device *dev)
510498
static int macb_mii_probe(struct net_device *dev)
511499
{
512500
struct macb *bp = netdev_priv(dev);
513-
struct macb_platform_data *pdata;
514501
struct phy_device *phydev;
515502
struct device_node *np;
516-
int phy_irq, ret, i;
503+
int ret, i;
517504

518-
pdata = dev_get_platdata(&bp->pdev->dev);
519505
np = bp->pdev->dev.of_node;
520506
ret = 0;
521507

@@ -557,19 +543,6 @@ static int macb_mii_probe(struct net_device *dev)
557543
return -ENXIO;
558544
}
559545

560-
if (pdata) {
561-
if (gpio_is_valid(pdata->phy_irq_pin)) {
562-
ret = devm_gpio_request(&bp->pdev->dev,
563-
pdata->phy_irq_pin, "phy int");
564-
if (!ret) {
565-
phy_irq = gpio_to_irq(pdata->phy_irq_pin);
566-
phydev->irq = (phy_irq < 0) ? PHY_POLL : phy_irq;
567-
}
568-
} else {
569-
phydev->irq = PHY_POLL;
570-
}
571-
}
572-
573546
/* attach the mac to the phy */
574547
ret = phy_connect_direct(dev, phydev, &macb_handle_link_change,
575548
bp->phy_interface);
@@ -598,7 +571,6 @@ static int macb_mii_probe(struct net_device *dev)
598571

599572
static int macb_mii_init(struct macb *bp)
600573
{
601-
struct macb_platform_data *pdata;
602574
struct device_node *np;
603575
int err = -ENXIO;
604576

@@ -618,7 +590,6 @@ static int macb_mii_init(struct macb *bp)
618590
bp->pdev->name, bp->pdev->id);
619591
bp->mii_bus->priv = bp;
620592
bp->mii_bus->parent = &bp->pdev->dev;
621-
pdata = dev_get_platdata(&bp->pdev->dev);
622593

623594
dev_set_drvdata(&bp->dev->dev, bp->mii_bus);
624595

@@ -632,9 +603,6 @@ static int macb_mii_init(struct macb *bp)
632603

633604
err = mdiobus_register(bp->mii_bus);
634605
} else {
635-
if (pdata)
636-
bp->mii_bus->phy_mask = pdata->phy_mask;
637-
638606
err = of_mdiobus_register(bp->mii_bus, np);
639607
}
640608

@@ -4050,7 +4018,6 @@ static int macb_probe(struct platform_device *pdev)
40504018
struct clk *pclk, *hclk = NULL, *tx_clk = NULL, *rx_clk = NULL;
40514019
struct clk *tsu_clk = NULL;
40524020
unsigned int queue_mask, num_queues;
4053-
struct macb_platform_data *pdata;
40544021
bool native_io;
40554022
struct phy_device *phydev;
40564023
struct net_device *dev;
@@ -4182,15 +4149,11 @@ static int macb_probe(struct platform_device *pdev)
41824149
}
41834150

41844151
err = of_get_phy_mode(np);
4185-
if (err < 0) {
4186-
pdata = dev_get_platdata(&pdev->dev);
4187-
if (pdata && pdata->is_rmii)
4188-
bp->phy_interface = PHY_INTERFACE_MODE_RMII;
4189-
else
4190-
bp->phy_interface = PHY_INTERFACE_MODE_MII;
4191-
} else {
4152+
if (err < 0)
4153+
/* not found in DT, MII by default */
4154+
bp->phy_interface = PHY_INTERFACE_MODE_MII;
4155+
else
41924156
bp->phy_interface = err;
4193-
}
41944157

41954158
/* IP specific init */
41964159
err = init(pdev);

include/linux/platform_data/macb.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,10 @@
1212

1313
/**
1414
* struct macb_platform_data - platform data for MACB Ethernet
15-
* @phy_mask: phy mask passed when register the MDIO bus
16-
* within the driver
17-
* @phy_irq_pin: PHY IRQ
18-
* @is_rmii: using RMII interface?
19-
* @rev_eth_addr: reverse Ethernet address byte order
2015
* @pclk: platform clock
2116
* @hclk: AHB clock
2217
*/
2318
struct macb_platform_data {
24-
u32 phy_mask;
25-
int phy_irq_pin;
26-
u8 is_rmii;
27-
u8 rev_eth_addr;
2819
struct clk *pclk;
2920
struct clk *hclk;
3021
};

0 commit comments

Comments
 (0)