|
25 | 25 | # define LPC18XX_CREG_CREG6_ETHMODE_MII 0x0
|
26 | 26 | # define LPC18XX_CREG_CREG6_ETHMODE_RMII 0x4
|
27 | 27 |
|
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; |
29 | 32 | struct regmap *reg;
|
30 |
| - int interface; |
31 |
| -}; |
| 33 | + u8 ethmode; |
| 34 | + int ret; |
32 | 35 |
|
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; |
36 | 39 |
|
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); |
40 | 43 |
|
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; |
44 | 45 |
|
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); |
49 | 50 | }
|
50 | 51 |
|
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) { |
60 | 53 | 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) { |
62 | 55 | ethmode = LPC18XX_CREG_CREG6_ETHMODE_RMII;
|
63 | 56 | } else {
|
64 | 57 | dev_err(&pdev->dev, "Only MII and RMII mode supported\n");
|
65 | 58 | return -EINVAL;
|
66 | 59 | }
|
67 | 60 |
|
68 |
| - regmap_update_bits(dwmac->reg, LPC18XX_CREG_CREG6, |
| 61 | + regmap_update_bits(reg, LPC18XX_CREG_CREG6, |
69 | 62 | LPC18XX_CREG_CREG6_ETHMODE_MASK, ethmode);
|
70 | 63 |
|
71 |
| - return 0; |
| 64 | + return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); |
72 | 65 | }
|
73 | 66 |
|
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 |
| - |
80 | 67 | static const struct of_device_id lpc18xx_dwmac_match[] = {
|
81 |
| - { .compatible = "nxp,lpc1850-dwmac", .data = &lpc18xx_dwmac_data }, |
| 68 | + { .compatible = "nxp,lpc1850-dwmac" }, |
82 | 69 | { }
|
83 | 70 | };
|
84 | 71 | MODULE_DEVICE_TABLE(of, lpc18xx_dwmac_match);
|
85 | 72 |
|
86 | 73 | static struct platform_driver lpc18xx_dwmac_driver = {
|
87 |
| - .probe = stmmac_pltfr_probe, |
| 74 | + .probe = lpc18xx_dwmac_probe, |
88 | 75 | .remove = stmmac_pltfr_remove,
|
89 | 76 | .driver = {
|
90 | 77 | .name = "lpc18xx-dwmac",
|
|
0 commit comments