mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-03-27 17:44:30 +00:00
stmmac: add proper probe function to dwmac-meson
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>
This commit is contained in:
parent
f4f8dfdedf
commit
1734befd06
1 changed files with 20 additions and 11 deletions
|
@ -47,36 +47,45 @@ static void meson6_dwmac_fix_mac_speed(void *priv, unsigned int speed)
|
||||||
writel(val, dwmac->reg);
|
writel(val, dwmac->reg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *meson6_dwmac_setup(struct platform_device *pdev)
|
static int meson6_dwmac_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
|
struct plat_stmmacenet_data *plat_dat;
|
||||||
|
struct stmmac_resources stmmac_res;
|
||||||
struct meson_dwmac *dwmac;
|
struct meson_dwmac *dwmac;
|
||||||
struct resource *res;
|
struct resource *res;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = stmmac_get_platform_resources(pdev, &stmmac_res);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
plat_dat = stmmac_probe_config_dt(pdev, &stmmac_res.mac);
|
||||||
|
if (IS_ERR(plat_dat))
|
||||||
|
return PTR_ERR(plat_dat);
|
||||||
|
|
||||||
dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL);
|
dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL);
|
||||||
if (!dwmac)
|
if (!dwmac)
|
||||||
return ERR_PTR(-ENOMEM);
|
return -ENOMEM;
|
||||||
|
|
||||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
|
res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
|
||||||
dwmac->reg = devm_ioremap_resource(&pdev->dev, res);
|
dwmac->reg = devm_ioremap_resource(&pdev->dev, res);
|
||||||
if (IS_ERR(dwmac->reg))
|
if (IS_ERR(dwmac->reg))
|
||||||
return ERR_CAST(dwmac->reg);
|
return PTR_ERR(dwmac->reg);
|
||||||
|
|
||||||
return dwmac;
|
plat_dat->bsp_priv = dwmac;
|
||||||
|
plat_dat->fix_mac_speed = meson6_dwmac_fix_mac_speed;
|
||||||
|
|
||||||
|
return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct stmmac_of_data meson6_dwmac_data = {
|
|
||||||
.setup = meson6_dwmac_setup,
|
|
||||||
.fix_mac_speed = meson6_dwmac_fix_mac_speed,
|
|
||||||
};
|
|
||||||
|
|
||||||
static const struct of_device_id meson6_dwmac_match[] = {
|
static const struct of_device_id meson6_dwmac_match[] = {
|
||||||
{ .compatible = "amlogic,meson6-dwmac", .data = &meson6_dwmac_data},
|
{ .compatible = "amlogic,meson6-dwmac" },
|
||||||
{ }
|
{ }
|
||||||
};
|
};
|
||||||
MODULE_DEVICE_TABLE(of, meson6_dwmac_match);
|
MODULE_DEVICE_TABLE(of, meson6_dwmac_match);
|
||||||
|
|
||||||
static struct platform_driver meson6_dwmac_driver = {
|
static struct platform_driver meson6_dwmac_driver = {
|
||||||
.probe = stmmac_pltfr_probe,
|
.probe = meson6_dwmac_probe,
|
||||||
.remove = stmmac_pltfr_remove,
|
.remove = stmmac_pltfr_remove,
|
||||||
.driver = {
|
.driver = {
|
||||||
.name = "meson6-dwmac",
|
.name = "meson6-dwmac",
|
||||||
|
|
Loading…
Add table
Reference in a new issue