Skip to content

Commit f4f8dfd

Browse files
manabiandavem330
authored andcommitted
stmmac: add proper probe function to dwmac-lpc18xx
By using a few functions from stmmac_platform we can now create a proper probe function in this driver. By doing so we can drop the OF match data and simplify the overall driver. Signed-off-by: Joachim Eastwood <manabian@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 402dae0 commit f4f8dfd

File tree

1 file changed

+23
-36
lines changed

1 file changed

+23
-36
lines changed

drivers/net/ethernet/stmicro/stmmac/dwmac-lpc18xx.c

Lines changed: 23 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -25,66 +25,53 @@
2525
# define LPC18XX_CREG_CREG6_ETHMODE_MII 0x0
2626
# define LPC18XX_CREG_CREG6_ETHMODE_RMII 0x4
2727

28-
struct lpc18xx_dwmac_priv_data {
28+
static int lpc18xx_dwmac_probe(struct platform_device *pdev)
29+
{
30+
struct plat_stmmacenet_data *plat_dat;
31+
struct stmmac_resources stmmac_res;
2932
struct regmap *reg;
30-
int interface;
31-
};
33+
u8 ethmode;
34+
int ret;
3235

33-
static void *lpc18xx_dwmac_setup(struct platform_device *pdev)
34-
{
35-
struct lpc18xx_dwmac_priv_data *dwmac;
36+
ret = stmmac_get_platform_resources(pdev, &stmmac_res);
37+
if (ret)
38+
return ret;
3639

37-
dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL);
38-
if (!dwmac)
39-
return ERR_PTR(-ENOMEM);
40+
plat_dat = stmmac_probe_config_dt(pdev, &stmmac_res.mac);
41+
if (IS_ERR(plat_dat))
42+
return PTR_ERR(plat_dat);
4043

41-
dwmac->interface = of_get_phy_mode(pdev->dev.of_node);
42-
if (dwmac->interface < 0)
43-
return ERR_PTR(dwmac->interface);
44+
plat_dat->has_gmac = true;
4445

45-
dwmac->reg = syscon_regmap_lookup_by_compatible("nxp,lpc1850-creg");
46-
if (IS_ERR(dwmac->reg)) {
47-
dev_err(&pdev->dev, "Syscon lookup failed\n");
48-
return dwmac->reg;
46+
reg = syscon_regmap_lookup_by_compatible("nxp,lpc1850-creg");
47+
if (IS_ERR(reg)) {
48+
dev_err(&pdev->dev, "syscon lookup failed\n");
49+
return PTR_ERR(reg);
4950
}
5051

51-
return dwmac;
52-
}
53-
54-
static int lpc18xx_dwmac_init(struct platform_device *pdev, void *priv)
55-
{
56-
struct lpc18xx_dwmac_priv_data *dwmac = priv;
57-
u8 ethmode;
58-
59-
if (dwmac->interface == PHY_INTERFACE_MODE_MII) {
52+
if (plat_dat->interface == PHY_INTERFACE_MODE_MII) {
6053
ethmode = LPC18XX_CREG_CREG6_ETHMODE_MII;
61-
} else if (dwmac->interface == PHY_INTERFACE_MODE_RMII) {
54+
} else if (plat_dat->interface == PHY_INTERFACE_MODE_RMII) {
6255
ethmode = LPC18XX_CREG_CREG6_ETHMODE_RMII;
6356
} else {
6457
dev_err(&pdev->dev, "Only MII and RMII mode supported\n");
6558
return -EINVAL;
6659
}
6760

68-
regmap_update_bits(dwmac->reg, LPC18XX_CREG_CREG6,
61+
regmap_update_bits(reg, LPC18XX_CREG_CREG6,
6962
LPC18XX_CREG_CREG6_ETHMODE_MASK, ethmode);
7063

71-
return 0;
64+
return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
7265
}
7366

74-
static const struct stmmac_of_data lpc18xx_dwmac_data = {
75-
.has_gmac = 1,
76-
.setup = lpc18xx_dwmac_setup,
77-
.init = lpc18xx_dwmac_init,
78-
};
79-
8067
static const struct of_device_id lpc18xx_dwmac_match[] = {
81-
{ .compatible = "nxp,lpc1850-dwmac", .data = &lpc18xx_dwmac_data },
68+
{ .compatible = "nxp,lpc1850-dwmac" },
8269
{ }
8370
};
8471
MODULE_DEVICE_TABLE(of, lpc18xx_dwmac_match);
8572

8673
static struct platform_driver lpc18xx_dwmac_driver = {
87-
.probe = stmmac_pltfr_probe,
74+
.probe = lpc18xx_dwmac_probe,
8875
.remove = stmmac_pltfr_remove,
8976
.driver = {
9077
.name = "lpc18xx-dwmac",

0 commit comments

Comments
 (0)