stmmac: stand alone platform drivers
Subsystems (5)
cover stmmac: stand alone platform drivers
Hi Arnd,
I ran into some issue using a separate platform driver[1] for lpc1850-dwmac.
My dts files looks like this.
mac: ethernet at 40010000 {
compatible = "nxp,lpc1850-dwmac", "snps,dwmac-3.611", "snps,dwmac";
...
}On boot the generic driver in stmmac_platform.c would grab the device, matching on one of generic compat strings and thus blocking the lpc1850-dwmac driver.
By changing the build order in the Makefile (see patch 1) I managed to get it working, but I am not sure that is a good solution(?).
Another fix would be to remove the generic compat strings from the match table in stmmac_platform but there are some dts-files that only have these compat strings.
See abilis_tb10x.dtsi and exynos5440.dtsi.
I could also remove the generic compat strings from my dts file but I am not sure that is good solution either. If more glue is converted this would then be need in those dts files also.
Any advice on how to handle this situation?
[1] http://marc.info/?l=linux-arm-kernel&m=143076781409270&w=2
Joachim Eastwood (2):
stmac: support standalone platform drivers
stmac: add dwmac glue for NXP 18xx/43xx family
drivers/net/ethernet/stmicro/stmmac/Makefile | 11 ++- .../net/ethernet/stmicro/stmmac/dwmac-lpc18xx.c | 98 ++++++++++++++++++++++ .../net/ethernet/stmicro/stmmac/stmmac_platform.c | 14 ++-- .../net/ethernet/stmicro/stmmac/stmmac_platform.h | 4 + 4 files changed, 120 insertions(+), 7 deletions(-) create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-lpc18xx.c
Signature · 1 line
1.8.0
RFC PATCH 1/2 stmac: support standalone platform drivers
Prepare the stmmac platform code to support standalone drivers by exporting the need functions and having of_match_device use the match table reference already present in the driver struct.
Reorder the build order so that the most specific drivers are built and registered first.
--- drivers/net/ethernet/stmicro/stmmac/Makefile | 10 ++++++++-- drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 14 +++++++++----- drivers/net/ethernet/stmicro/stmmac/stmmac_platform.h | 4 ++++ 3 files changed, 21 insertions(+), 7 deletions(-)
drivers/net/ethernet/stmicro/stmmac/Makefile +8 -2
@@ -4,9 +4,15 @@ stmmac-objs:= stmmac_main.o stmmac_ethtool.o stmmac_mdio.o ring_mode.o \ dwmac100_core.o dwmac100_dma.o enh_desc.o norm_desc.o \ mmc_core.o stmmac_hwtstamp.o stmmac_ptp.o $(stmmac-y) +# ordering matters; keep stmmac_platform.o at the bottom obj-$(CONFIG_STMMAC_PLATFORM) += stmmac-platform.o -stmmac-platform-objs:= stmmac_platform.o dwmac-meson.o dwmac-sunxi.o \ - dwmac-sti.o dwmac-socfpga.o dwmac-rk.o +stmmac-platform-objs:= \ + dwmac-meson.o \ + dwmac-rk.o \ + dwmac-socfpga.o \ + dwmac-sti.o \ + dwmac-sunxi.o \ + stmmac_platform.o obj-$(CONFIG_STMMAC_PCI) += stmmac-pci.o stmmac-pci-objs:= stmmac_pci.o
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +9 -5
@@ -128,11 +128,12 @@ static int stmmac_probe_config_dt(struct platform_device *pdev,struct device_node *np = pdev->dev.of_node;struct stmmac_dma_cfg *dma_cfg;const struct of_device_id *device; +struct device *dev = &pdev->dev;if (!np)return -ENODEV ; - device =of_match_device (stmmac_dt_ids, &pdev->dev); + device =of_match_device (dev->driver->of_match_table, dev);if (!device)return -ENODEV ;
@@ -267,7 +268,7 @@ static int stmmac_probe_config_dt(struct platform_device *pdev,* the necessary platform resources, invoke custom helper (if required) and * invoke the main probe function. */ -static int stmmac_pltfr_probe (struct platform_device *pdev) +int stmmac_pltfr_probe (struct platform_device *pdev) {int ret =0 ;struct resource *res;
@@ -373,6 +374,7 @@ static int stmmac_pltfr_probe(struct platform_device *pdev)return 0 ; } +EXPORT_SYMBOL_GPL (stmmac_pltfr_probe);/** * stmmac_pltfr_remove
@@ -380,7 +382,7 @@ static int stmmac_pltfr_probe(struct platform_device *pdev)* Description: this function calls the main to free the net resources * and calls the platforms hook and release the resources (e.g. mem). */ -static int stmmac_pltfr_remove (struct platform_device *pdev) +int stmmac_pltfr_remove (struct platform_device *pdev) {struct net_device *ndev =platform_get_drvdata (pdev);struct stmmac_priv *priv =netdev_priv (ndev);
@@ -394,6 +396,7 @@ static int stmmac_pltfr_remove(struct platform_device *pdev)return ret; } +EXPORT_SYMBOL_GPL (stmmac_pltfr_remove);#ifdef CONFIG_PM_SLEEP /**
@@ -437,8 +440,9 @@ static int stmmac_pltfr_resume(struct device *dev) }#endif /* CONFIG_PM_SLEEP */ -static SIMPLE_DEV_PM_OPS(stmmac_pltfr_pm_ops, - stmmac_pltfr_suspend, stmmac_pltfr_resume); +SIMPLE_DEV_PM_OPS (stmmac_pltfr_pm_ops, stmmac_pltfr_suspend, + stmmac_pltfr_resume); +EXPORT_SYMBOL_GPL (stmmac_pltfr_pm_ops);static struct platform_driver stmmac_pltfr_driver = { .probe = stmmac_pltfr_probe,
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.h +4 -0
@@ -19,6 +19,10 @@#ifndef __STMMAC_PLATFORM_H__#define __STMMAC_PLATFORM_H__ +int stmmac_pltfr_probe (struct platform_device *pdev); +int stmmac_pltfr_remove (struct platform_device *pdev); +extern const struct dev_pm_ops stmmac_pltfr_pm_ops; +extern const struct stmmac_of_data meson6_dwmac_data;extern const struct stmmac_of_data sun7i_gmac_data;extern const struct stmmac_of_data stih4xx_dwmac_data;
Signature · 1 line
1.8.0
RFC PATCH 2/2 stmac: add dwmac glue for NXP 18xx/43xx family
In reply to Joachim EastwoodAdd support for using the dwmac on NXP LPC18xx and LPC43xx devices.
--- drivers/net/ethernet/stmicro/stmmac/Makefile | 1 + .../net/ethernet/stmicro/stmmac/dwmac-lpc18xx.c | 98 ++++++++++++++++++++++ 2 files changed, 99 insertions(+) create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-lpc18xx.c
drivers/net/ethernet/stmicro/stmmac/Makefile +1 -0
@@ -7,6 +7,7 @@ stmmac-objs:= stmmac_main.o stmmac_ethtool.o stmmac_mdio.o ring_mode.o \ # ordering matters; keep stmmac_platform.o at the bottom obj-$(CONFIG_STMMAC_PLATFORM) += stmmac-platform.o stmmac-platform-objs:= \ + dwmac-lpc18xx.o \ dwmac-meson.o \ dwmac-rk.o \ dwmac-socfpga.o \
drivers/net/ethernet/stmicro/stmmac/dwmac-lpc18xx.c new file +98 -0
98 lines not on this page · raw message
Signature · 1 line
1.8.0
Quoted 10 lines · On Thursday 07 May 2015 20:19:23 Joachim Eastwood wrote:
Hi Arnd,
I ran into some issue using a separate platform driver[1] for lpc1850-dwmac.
My dts files looks like this.
mac: ethernet at 40010000 { compatible = "nxp,lpc1850-dwmac", "snps,dwmac-3.611", "snps,dwmac"; ... }
Quoted 6 lines
On boot the generic driver in
stmmac_platform.cwould grab the device, matching on one of generic compat strings and thus blocking the lpc1850-dwmac driver.By changing the build order in the
Makefile(see patch 1) I managed to get it working, but I am not sure that is a good solution(?).
Changing the link order in the Makefile is an acceptable solution for managing initialization order in general, but I think it won't work here, because if your driver is a loadable module, the base driver would always be attached first.
Quoted 4 lines
Another fix would be to remove the generic compat strings from the match table in
stmmac_platformbut there are some dts-files that only have these compat strings.
Seeabilis_tb10x.dtsiandexynos5440.dtsi.
Yes, that has a high risk of causing regressions.
Quoted 3 lines
I could also remove the generic compat strings from my dts file but I am not sure that is good solution either. If more glue is converted this would then be need in those dts files also.
I think it would work if you move the generic strings into a separate module that is not the one providing the base support. In that case, the kernel should first try to use the driver that matches the first compatible string. Can you try that?
Arnd
Quoted 15 lines · Arnd Bergmann
Quoted 14 lines · On Thursday 07 May 2015 20:19:23 Joachim Eastwood wrote:
Hi Arnd,
I ran into some issue using a separate platform driver[1] for lpc1850-dwmac.
My dts files looks like this.
mac: ethernet at 40010000 { compatible = "nxp,lpc1850-dwmac", "snps,dwmac-3.611", "snps,dwmac"; ... }On boot the generic driver in
stmmac_platform.cwould grab the device, matching on one of generic compat strings and thus blocking the lpc1850-dwmac driver.
Quoted 7 lines
Quoted 2 lines
By changing the build order in the
Makefile(see patch 1) I managed to get it working, but I am not sure that is a good solution(?).Changing the link order in the
Makefileis an acceptable solution for managing initialization order in general, but I think it won't work here, because if your driver is a loadable module, the base driver would always be attached first.
That is true.
The setup/configuration I am testing doesn't use modules though and the only way I can get the lpc1850-dwmac driver to probe the device is to link the generic driver last.
Quoted 7 lines
Quoted 4 lines
Another fix would be to remove the generic compat strings from the match table in
stmmac_platformbut there are some dts-files that only have these compat strings.
Seeabilis_tb10x.dtsiandexynos5440.dtsi.Yes, that has a high risk of causing regressions.
Quoted 8 lines
Quoted 3 lines
I could also remove the generic compat strings from my dts file but I am not sure that is good solution either. If more glue is converted this would then be need in those dts files also.
I think it would work if you move the generic strings into a separate module that is not the one providing the base support. In that case, the kernel should first try to use the driver that matches the first compatible string. Can you try that?
I have now created a generic dt dwmac driver which contain all compat strings that doesn't have any match data. As long as this driver is linked last this works for my built-in drivers configuration. I am not able to test using modules because of my very limited rootfs. This is a Cortex-M system after all.
I also converted all the other DT dwmac drivers and the entire patch set can be found on:
https://github.com/manabian/linux-lpc
After I have done some more cleanups and added proper commit messages I will put them on netdev again.
regards,
Joachim Eastwood
Quoted 7 lines · On Tuesday 12 May 2015 19:20:45 Joachim Eastwood wrote:
I have now created a generic dt dwmac driver which contain all compat strings that doesn't have any match data. As long as this driver is linked last this works for my built-in drivers configuration. I am not able to test using modules because of my very limited rootfs. This is a Cortex-M system after all.
Quoted 8 lines
I also converted all the other DT dwmac drivers and the entire patch set can be found on:
https://github.com/manabian/linux-lpcAfter I have done some more cleanups and added proper commit messages I will put them on netdev again.
Yes, this looks really nice (with the cleanup bits that are obviously missing applied), thanks a lot!
We should probably try to keep existing defconfig files working, which could be done e.g. like
config DWMAC_ROCKCHIP
tristate "Rockchip dwmac support"
+ default ARCH_ROCKCHIP
depends on OF
select MFD_SYSCON
so that any configuration that currently has ARCH_ROCKCHIP and DW_MAC enabled ends up with DWMAC_ROCKCHIP enabled as well.
Arnd
Quoted 23 lines · Arnd Bergmann
Quoted 7 lines · On Tuesday 12 May 2015 19:20:45 Joachim Eastwood wrote:
I have now created a generic dt dwmac driver which contain all compat strings that doesn't have any match data. As long as this driver is linked last this works for my built-in drivers configuration. I am not able to test using modules because of my very limited rootfs. This is a Cortex-M system after all.
Quoted 8 lines
I also converted all the other DT dwmac drivers and the entire patch set can be found on:
https://github.com/manabian/linux-lpcAfter I have done some more cleanups and added proper commit messages I will put them on netdev again.
Yes, this looks really nice (with the cleanup bits that are obviously missing applied), thanks a lot!
We should probably try to keep existing defconfig files working, which could be done e.g. like
Quoted 8 lines
config
DWMAC_ROCKCHIP
tristate "Rockchip dwmac support"
+ defaultARCH_ROCKCHIP
depends on OF
selectMFD_SYSCONso that any configuration that currently has
ARCH_ROCKCHIPandDW_MACenabled ends up withDWMAC_ROCKCHIPenabled as well.
Ah, yes, indeed. I will add a default statement in the Kconfig of the converted drivers.
regards,
Joachim Eastwood