Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f4f8dfde authored by Joachim Eastwood's avatar Joachim Eastwood Committed by David S. Miller
Browse files

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: default avatarJoachim Eastwood <manabian@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 402dae0b
Loading
Loading
Loading
Loading
+23 −36
Original line number Original line Diff line number Diff line
@@ -25,66 +25,53 @@
# define LPC18XX_CREG_CREG6_ETHMODE_MII		0x0
# define LPC18XX_CREG_CREG6_ETHMODE_MII		0x0
# define LPC18XX_CREG_CREG6_ETHMODE_RMII	0x4
# define LPC18XX_CREG_CREG6_ETHMODE_RMII	0x4


struct lpc18xx_dwmac_priv_data {
static int lpc18xx_dwmac_probe(struct platform_device *pdev)
	struct regmap *reg;
	int interface;
};

static void *lpc18xx_dwmac_setup(struct platform_device *pdev)
{
{
	struct lpc18xx_dwmac_priv_data *dwmac;
	struct plat_stmmacenet_data *plat_dat;
	struct stmmac_resources stmmac_res;
	struct regmap *reg;
	u8 ethmode;
	int ret;


	dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL);
	ret = stmmac_get_platform_resources(pdev, &stmmac_res);
	if (!dwmac)
	if (ret)
		return ERR_PTR(-ENOMEM);
		return ret;


	dwmac->interface = of_get_phy_mode(pdev->dev.of_node);
	plat_dat = stmmac_probe_config_dt(pdev, &stmmac_res.mac);
	if (dwmac->interface < 0)
	if (IS_ERR(plat_dat))
		return ERR_PTR(dwmac->interface);
		return PTR_ERR(plat_dat);


	dwmac->reg = syscon_regmap_lookup_by_compatible("nxp,lpc1850-creg");
	plat_dat->has_gmac = true;
	if (IS_ERR(dwmac->reg)) {
		dev_err(&pdev->dev, "Syscon lookup failed\n");
		return dwmac->reg;
	}


	return dwmac;
	reg = syscon_regmap_lookup_by_compatible("nxp,lpc1850-creg");
	if (IS_ERR(reg)) {
		dev_err(&pdev->dev, "syscon lookup failed\n");
		return PTR_ERR(reg);
	}
	}


static int lpc18xx_dwmac_init(struct platform_device *pdev, void *priv)
	if (plat_dat->interface == PHY_INTERFACE_MODE_MII) {
{
	struct lpc18xx_dwmac_priv_data *dwmac = priv;
	u8 ethmode;

	if (dwmac->interface == PHY_INTERFACE_MODE_MII) {
		ethmode = LPC18XX_CREG_CREG6_ETHMODE_MII;
		ethmode = LPC18XX_CREG_CREG6_ETHMODE_MII;
	} else if (dwmac->interface == PHY_INTERFACE_MODE_RMII) {
	} else if (plat_dat->interface == PHY_INTERFACE_MODE_RMII) {
		ethmode = LPC18XX_CREG_CREG6_ETHMODE_RMII;
		ethmode = LPC18XX_CREG_CREG6_ETHMODE_RMII;
	} else {
	} else {
		dev_err(&pdev->dev, "Only MII and RMII mode supported\n");
		dev_err(&pdev->dev, "Only MII and RMII mode supported\n");
		return -EINVAL;
		return -EINVAL;
	}
	}


	regmap_update_bits(dwmac->reg, LPC18XX_CREG_CREG6,
	regmap_update_bits(reg, LPC18XX_CREG_CREG6,
			   LPC18XX_CREG_CREG6_ETHMODE_MASK, ethmode);
			   LPC18XX_CREG_CREG6_ETHMODE_MASK, ethmode);


	return 0;
	return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
}
}


static const struct stmmac_of_data lpc18xx_dwmac_data = {
	.has_gmac = 1,
	.setup = lpc18xx_dwmac_setup,
	.init = lpc18xx_dwmac_init,
};

static const struct of_device_id lpc18xx_dwmac_match[] = {
static const struct of_device_id lpc18xx_dwmac_match[] = {
	{ .compatible = "nxp,lpc1850-dwmac", .data = &lpc18xx_dwmac_data },
	{ .compatible = "nxp,lpc1850-dwmac" },
	{ }
	{ }
};
};
MODULE_DEVICE_TABLE(of, lpc18xx_dwmac_match);
MODULE_DEVICE_TABLE(of, lpc18xx_dwmac_match);


static struct platform_driver lpc18xx_dwmac_driver = {
static struct platform_driver lpc18xx_dwmac_driver = {
	.probe  = stmmac_pltfr_probe,
	.probe  = lpc18xx_dwmac_probe,
	.remove = stmmac_pltfr_remove,
	.remove = stmmac_pltfr_remove,
	.driver = {
	.driver = {
		.name           = "lpc18xx-dwmac",
		.name           = "lpc18xx-dwmac",