diff options
Diffstat (limited to 'drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c')
-rw-r--r-- | drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c | 78 |
1 files changed, 45 insertions, 33 deletions
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c index 8141c5b844ae..401383b252a8 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c | |||
@@ -175,31 +175,6 @@ static int socfpga_dwmac_setup(struct socfpga_dwmac *dwmac) | |||
175 | return 0; | 175 | return 0; |
176 | } | 176 | } |
177 | 177 | ||
178 | static void *socfpga_dwmac_probe(struct platform_device *pdev) | ||
179 | { | ||
180 | struct device *dev = &pdev->dev; | ||
181 | int ret; | ||
182 | struct socfpga_dwmac *dwmac; | ||
183 | |||
184 | dwmac = devm_kzalloc(dev, sizeof(*dwmac), GFP_KERNEL); | ||
185 | if (!dwmac) | ||
186 | return ERR_PTR(-ENOMEM); | ||
187 | |||
188 | ret = socfpga_dwmac_parse_data(dwmac, dev); | ||
189 | if (ret) { | ||
190 | dev_err(dev, "Unable to parse OF data\n"); | ||
191 | return ERR_PTR(ret); | ||
192 | } | ||
193 | |||
194 | ret = socfpga_dwmac_setup(dwmac); | ||
195 | if (ret) { | ||
196 | dev_err(dev, "couldn't setup SoC glue (%d)\n", ret); | ||
197 | return ERR_PTR(ret); | ||
198 | } | ||
199 | |||
200 | return dwmac; | ||
201 | } | ||
202 | |||
203 | static void socfpga_dwmac_exit(struct platform_device *pdev, void *priv) | 178 | static void socfpga_dwmac_exit(struct platform_device *pdev, void *priv) |
204 | { | 179 | { |
205 | struct socfpga_dwmac *dwmac = priv; | 180 | struct socfpga_dwmac *dwmac = priv; |
@@ -257,21 +232,58 @@ static int socfpga_dwmac_init(struct platform_device *pdev, void *priv) | |||
257 | return ret; | 232 | return ret; |
258 | } | 233 | } |
259 | 234 | ||
260 | static const struct stmmac_of_data socfpga_gmac_data = { | 235 | static int socfpga_dwmac_probe(struct platform_device *pdev) |
261 | .setup = socfpga_dwmac_probe, | 236 | { |
262 | .init = socfpga_dwmac_init, | 237 | struct plat_stmmacenet_data *plat_dat; |
263 | .exit = socfpga_dwmac_exit, | 238 | struct stmmac_resources stmmac_res; |
264 | .fix_mac_speed = socfpga_dwmac_fix_mac_speed, | 239 | struct device *dev = &pdev->dev; |
265 | }; | 240 | int ret; |
241 | struct socfpga_dwmac *dwmac; | ||
242 | |||
243 | ret = stmmac_get_platform_resources(pdev, &stmmac_res); | ||
244 | if (ret) | ||
245 | return ret; | ||
246 | |||
247 | plat_dat = stmmac_probe_config_dt(pdev, &stmmac_res.mac); | ||
248 | if (IS_ERR(plat_dat)) | ||
249 | return PTR_ERR(plat_dat); | ||
250 | |||
251 | dwmac = devm_kzalloc(dev, sizeof(*dwmac), GFP_KERNEL); | ||
252 | if (!dwmac) | ||
253 | return -ENOMEM; | ||
254 | |||
255 | ret = socfpga_dwmac_parse_data(dwmac, dev); | ||
256 | if (ret) { | ||
257 | dev_err(dev, "Unable to parse OF data\n"); | ||
258 | return ret; | ||
259 | } | ||
260 | |||
261 | ret = socfpga_dwmac_setup(dwmac); | ||
262 | if (ret) { | ||
263 | dev_err(dev, "couldn't setup SoC glue (%d)\n", ret); | ||
264 | return ret; | ||
265 | } | ||
266 | |||
267 | plat_dat->bsp_priv = dwmac; | ||
268 | plat_dat->init = socfpga_dwmac_init; | ||
269 | plat_dat->exit = socfpga_dwmac_exit; | ||
270 | plat_dat->fix_mac_speed = socfpga_dwmac_fix_mac_speed; | ||
271 | |||
272 | ret = socfpga_dwmac_init(pdev, plat_dat->bsp_priv); | ||
273 | if (ret) | ||
274 | return ret; | ||
275 | |||
276 | return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); | ||
277 | } | ||
266 | 278 | ||
267 | static const struct of_device_id socfpga_dwmac_match[] = { | 279 | static const struct of_device_id socfpga_dwmac_match[] = { |
268 | { .compatible = "altr,socfpga-stmmac", .data = &socfpga_gmac_data }, | 280 | { .compatible = "altr,socfpga-stmmac" }, |
269 | { } | 281 | { } |
270 | }; | 282 | }; |
271 | MODULE_DEVICE_TABLE(of, socfpga_dwmac_match); | 283 | MODULE_DEVICE_TABLE(of, socfpga_dwmac_match); |
272 | 284 | ||
273 | static struct platform_driver socfpga_dwmac_driver = { | 285 | static struct platform_driver socfpga_dwmac_driver = { |
274 | .probe = stmmac_pltfr_probe, | 286 | .probe = socfpga_dwmac_probe, |
275 | .remove = stmmac_pltfr_remove, | 287 | .remove = stmmac_pltfr_remove, |
276 | .driver = { | 288 | .driver = { |
277 | .name = "socfpga-dwmac", | 289 | .name = "socfpga-dwmac", |