]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
stmmac: add proper probe function to dwmac-lpc18xx
authorJoachim Eastwood <manabian@gmail.com>
Thu, 16 Jul 2015 22:26:10 +0000 (00:26 +0200)
committerDavid S. Miller <davem@davemloft.net>
Tue, 21 Jul 2015 03:45:57 +0000 (20:45 -0700)
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>
drivers/net/ethernet/stmicro/stmmac/dwmac-lpc18xx.c

index cb888d3ebbdc3054732bdcfc8b17f8179e8f78fa..78e9d1861896335d86ac31e5701856d9bfe8779b 100644 (file)
 # define LPC18XX_CREG_CREG6_ETHMODE_MII                0x0
 # define LPC18XX_CREG_CREG6_ETHMODE_RMII       0x4
 
-struct lpc18xx_dwmac_priv_data {
+static int lpc18xx_dwmac_probe(struct platform_device *pdev)
+{
+       struct plat_stmmacenet_data *plat_dat;
+       struct stmmac_resources stmmac_res;
        struct regmap *reg;
-       int interface;
-};
+       u8 ethmode;
+       int ret;
 
-static void *lpc18xx_dwmac_setup(struct platform_device *pdev)
-{
-       struct lpc18xx_dwmac_priv_data *dwmac;
+       ret = stmmac_get_platform_resources(pdev, &stmmac_res);
+       if (ret)
+               return ret;
 
-       dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL);
-       if (!dwmac)
-               return ERR_PTR(-ENOMEM);
+       plat_dat = stmmac_probe_config_dt(pdev, &stmmac_res.mac);
+       if (IS_ERR(plat_dat))
+               return PTR_ERR(plat_dat);
 
-       dwmac->interface = of_get_phy_mode(pdev->dev.of_node);
-       if (dwmac->interface < 0)
-               return ERR_PTR(dwmac->interface);
+       plat_dat->has_gmac = true;
 
-       dwmac->reg = syscon_regmap_lookup_by_compatible("nxp,lpc1850-creg");
-       if (IS_ERR(dwmac->reg)) {
-               dev_err(&pdev->dev, "Syscon lookup failed\n");
-               return dwmac->reg;
+       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);
        }
 
-       return dwmac;
-}
-
-static int lpc18xx_dwmac_init(struct platform_device *pdev, void *priv)
-{
-       struct lpc18xx_dwmac_priv_data *dwmac = priv;
-       u8 ethmode;
-
-       if (dwmac->interface == PHY_INTERFACE_MODE_MII) {
+       if (plat_dat->interface == PHY_INTERFACE_MODE_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;
        } else {
                dev_err(&pdev->dev, "Only MII and RMII mode supported\n");
                return -EINVAL;
        }
 
-       regmap_update_bits(dwmac->reg, LPC18XX_CREG_CREG6,
+       regmap_update_bits(reg, LPC18XX_CREG_CREG6,
                           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[] = {
-       { .compatible = "nxp,lpc1850-dwmac", .data = &lpc18xx_dwmac_data },
+       { .compatible = "nxp,lpc1850-dwmac" },
        { }
 };
 MODULE_DEVICE_TABLE(of, lpc18xx_dwmac_match);
 
 static struct platform_driver lpc18xx_dwmac_driver = {
-       .probe  = stmmac_pltfr_probe,
+       .probe  = lpc18xx_dwmac_probe,
        .remove = stmmac_pltfr_remove,
        .driver = {
                .name           = "lpc18xx-dwmac",