macb usrio/tsu patches
Subsystems (5)
v5 cover macb usrio/tsu patches
From: Conor Dooley <[email protected]>
Hey folks,
At the very least, it'd be good of the soc vendor folks could check their platforms and see if their usrio stuff actually lines up with what the driver currently calls "macb_default_usrio". Ours didn't and it was a nasty surprise.
Ryan and I figured out that the sama7g5 stuff is not actually using the same usrio bits as earlier devices, so there's now more patches in this series to split them apart. I've not tested the split or the new property due to lack of hardware, but Ryan has.
Marking this stuff net-next, because although they're fixes I don't see any particular urgency, and it avoids creating some dependencies between cleanup items and the fixes.
Cheers,
Conor.
v5:
- rebase on net-next
- revert one of the commits that landed in net-next in the meantime
v4:
- deprecate instead of remove existing devicetree property
- pick up Theo's patches
v3:
- reorder patches
- fix smatch issue reported by Simon
- add patches reworking usrio handling of clken/refclk (and remove the issue the llm reported in the process)
- add a new devicetree property for refclk selection, replacing the existing one.
- drop the dts patch
Conor Dooley (11):
Revert "net: macb: Clean up the .usrio settings in macb_config
instances"
net: macb: rename macb_default_usrio to at91_default_usrio as not all
platforms have mii mode control in usrio
net: macb: split USRIO_HAS_CLKEN capability in two
dt-bindings: net: cdns,macb: replace cdns,refclk-ext with
cdns,refclk-source
net: macb: rework usrio refclk selection code
net: macb: np4 doesn't need a usrio pointer
net: macb: add mpfs specific usrio configuration
net: macb: warn on pclk use as a tsu_clk fallback
net: macb: clean up tsu clk rate acquisition
dt-bindings: net: macb: add property indicating timer adjust mode
net: macb: timer adjust mode is not supported
Théo Lebrun (3):
net: macb: runtime detect MACB_CAPS_USRIO_DISABLED
net: macb: set MACB_CAPS_USRIO_DISABLED if no usrio config is provided
net: macb: drop usrio pointer on EyeQ5 config
.../devicetree/bindings/net/cdns,macb.yaml | 71 ++++++- drivers/net/ethernet/cadence/macb.h | 8 + drivers/net/ethernet/cadence/macb_main.c | 187 +++++++++++++----- 3 files changed, 212 insertions(+), 54 deletions(-)
Signature · 1 line
2.53.0
PATCH v5 1/14 Revert "net: macb: Clean up the .usrio settings in macb_config instances"
From: Conor Dooley <[email protected]>
Commit 0ae998c4efd69 ("net: macb: Clean up the .usrio settings in macb_config instances") was a misguided attempt to clean up the driver that actually just propagated problematic code. The default for usrio is actually no usrio, and already there are issues with people using the problematically named "macb_default_usrio" on platforms where the usrio does not have this so-called default behaviour. usrio is platform specific and using the default at91 usrio settings should be opt-in only. Revert the "cleanup" patch.
--- drivers/net/ethernet/cadence/macb_main.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)
drivers/net/ethernet/cadence/macb_main.c +18 -1
@@ -5513,31 +5513,37 @@ static const struct macb_config fu540_c000_config = { .clk_init = fu540_c000_clk_init, .init = fu540_c000_init, .jumbo_max_len = 10240, + .usrio = &macb_default_usrio, };static const struct macb_config at91sam9260_config = { .caps =MACB_CAPS_USRIO_HAS_CLKEN |MACB_CAPS_USRIO_DEFAULT_IS_MII_GMII , + .usrio = &macb_default_usrio, };static const struct macb_config sama5d3macb_config = { .caps =MACB_CAPS_SG_DISABLED |MACB_CAPS_USRIO_HAS_CLKEN |MACB_CAPS_USRIO_DEFAULT_IS_MII_GMII , + .usrio = &macb_default_usrio, };static const struct macb_config pc302gem_config = { .caps =MACB_CAPS_SG_DISABLED |MACB_CAPS_GIGABIT_MODE_AVAILABLE , .dma_burst_length =16 , + .usrio = &macb_default_usrio, };static const struct macb_config sama5d2_config = { .caps =MACB_CAPS_USRIO_DEFAULT_IS_MII_GMII |MACB_CAPS_JUMBO , .dma_burst_length =16 , .jumbo_max_len =10240 , + .usrio = &macb_default_usrio, };static const struct macb_config sama5d29_config = { .caps =MACB_CAPS_USRIO_DEFAULT_IS_MII_GMII |MACB_CAPS_GEM_HAS_PTP , .dma_burst_length =16 , + .usrio = &macb_default_usrio, };static const struct macb_config sama5d3_config = {
@@ -5545,21 +5551,25 @@ static const struct macb_config sama5d3_config = { MACB_CAPS_USRIO_DEFAULT_IS_MII_GMII | MACB_CAPS_JUMBO, .dma_burst_length = 16, .jumbo_max_len = 10240, + .usrio = &macb_default_usrio, };static const struct macb_config sama5d4_config = { .caps =MACB_CAPS_USRIO_DEFAULT_IS_MII_GMII , .dma_burst_length =4 , + .usrio = &macb_default_usrio, };static const struct macb_config emac_config = { .caps =MACB_CAPS_NEEDS_RSTONUBR |MACB_CAPS_MACB_IS_EMAC , .clk_init = at91ether_clk_init, .init = at91ether_init, + .usrio = &macb_default_usrio, };static const struct macb_config np4_config = { .caps =MACB_CAPS_USRIO_DISABLED , + .usrio = &macb_default_usrio, };static const struct macb_config zynqmp_config = {
@@ -5569,12 +5579,14 @@ static const struct macb_config zynqmp_config = { .dma_burst_length = 16, .init = init_reset_optional, .jumbo_max_len = 10240, + .usrio = &macb_default_usrio, };static const struct macb_config zynq_config = { .caps =MACB_CAPS_GIGABIT_MODE_AVAILABLE |MACB_CAPS_NO_GIGABIT_HALF |MACB_CAPS_NEEDS_RSTONUBR , .dma_burst_length =16 , + .usrio = &macb_default_usrio, };static const struct macb_config mpfs_config = {
@@ -5583,6 +5595,7 @@ static const struct macb_config mpfs_config = { MACB_CAPS_GEM_HAS_PTP, .dma_burst_length = 16, .init = init_reset_optional, + .usrio = &macb_default_usrio, .max_tx_length = 4040, /* Cadence Erratum 1686 */ .jumbo_max_len = 4040, };
@@ -5611,6 +5624,7 @@ static const struct macb_config versal_config = { .dma_burst_length = 16, .init = init_reset_optional, .jumbo_max_len = 10240, + .usrio = &macb_default_usrio, };static const struct macb_config eyeq5_config = {
@@ -5620,6 +5634,7 @@ static const struct macb_config eyeq5_config = { .dma_burst_length = 16, .init = eyeq5_init, .jumbo_max_len = 10240, + .usrio = &macb_default_usrio, };static const struct macb_config raspberrypi_rp1_config = {
@@ -5628,6 +5643,7 @@ static const struct macb_config raspberrypi_rp1_config = { MACB_CAPS_GEM_HAS_PTP | MACB_CAPS_EEE, .dma_burst_length = 16, + .usrio = &macb_default_usrio, .jumbo_max_len = 10240, };
@@ -5675,6 +5691,7 @@ static const struct macb_config default_gem_config = { MACB_CAPS_JUMBO | MACB_CAPS_GEM_HAS_PTP, .dma_burst_length = 16, + .usrio = &macb_default_usrio, .jumbo_max_len = 10240, };
@@ -5761,7 +5778,7 @@ static int macb_probe(struct platform_device *pdev) bp->wol =0 ;device_set_wakeup_capable (&pdev->dev,1 ); - bp->usrio = macb_config->usrio ? : &macb_default_usrio; + bp->usrio = macb_config->usrio;/* By default we set to partial store and forward mode for zynqmp. * Disable if not set in devicetree.
Signature · 1 line
2.53.0
PATCH v5 2/14 net: macb: rename macb_default_usrio to at91_default_usrio as not all platforms have mii mode control in usrio
In reply to Conor DooleyFrom: Conor Dooley <[email protected]>
Calling this structure macb_default_usrio is misleading, I believe, as it implies that it should be used if your platform has nothing special to do in usrio. Since usrio is platform dependent, the default here is probably for each usrio to do nothing, with the macb documentation I have access to prescribing no standard behaviour here. We noticed that this was problematic because on mpfs, a bit that macb_default_usrio sets to deal with the MII mode actually changes the source for the tsu_clk to something with how the majority of mpfs devices are actually configured!
Rename it to at91_default_usrio, since that's where the values actually come from for these. I have no idea if any of the other platforms that use the default actually copied at91's usrio configuration or if they have usrio configurations where what the driver does has no impact.
Gate touching these bits behind a capability, like the clken refclock usrio knob, so that platforms without the MII mode stuff can avoid running this code.
--- drivers/net/ethernet/cadence/macb.h | 1 + drivers/net/ethernet/cadence/macb_main.c | 108 +++++++++++++---------- 2 files changed, 63 insertions(+), 46 deletions(-)
drivers/net/ethernet/cadence/macb.h +1 -0
@@ -786,6 +786,7 @@#define MACB_CAPS_RSC BIT(23)#define MACB_CAPS_NO_LSO BIT(24)#define MACB_CAPS_EEE BIT(25) +#define MACB_CAPS_USRIO_HAS_MII BIT(26)/* LSO settings */ #define MACB_LSO_UFO_ENABLE 0x01
drivers/net/ethernet/cadence/macb_main.c +62 -46
234 lines not on this page · raw message
Signature · 1 line
2.53.0
PATCH v5 3/14 net: macb: split USRIO_HAS_CLKEN capability in two
In reply to Conor DooleyFrom: Conor Dooley <[email protected]>
While trying to rework the internal/external refclk selection on sama7g5, Ryan and I noticed that the sama7g5 was "overloading" the meaning of MACB_CAPS_USRIO_HAS_CLKEN, using it differently to how it was originally intended.
Originally, on the macb hardware on sam9620 et al, MACB_CAPS_USRIO_HAS_CLKEN represented the hardware having a bit that needed to be set to turn on the input clock to the transceivers. The sama7g5 doesn't have this bit, so for some reason the decision was made to reuse this capability flag to control selection of internal/external references.
Split the caps in two, so that capabilities do what they say on the tin, and allow reworking the refclk selection handling without impacting the older devices that use MACB_CAPS_USRIO_CLKEN for its original purpose.
--- drivers/net/ethernet/cadence/macb.h | 2 ++ drivers/net/ethernet/cadence/macb_main.c | 11 ++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-)
drivers/net/ethernet/cadence/macb.h +2 -0
@@ -787,6 +787,7 @@#define MACB_CAPS_NO_LSO BIT(24)#define MACB_CAPS_EEE BIT(25)#define MACB_CAPS_USRIO_HAS_MII BIT(26) +#define MACB_CAPS_USRIO_HAS_REFCLK_SOURCE BIT(27)/* LSO settings */ #define MACB_LSO_UFO_ENABLE 0x01
@@ -1226,6 +1227,7 @@ struct macb_usrio_config {u32 rmii;u32 rgmii;u32 refclk; +u32 clken;u32 hdfctlen; };
drivers/net/ethernet/cadence/macb_main.c +8 -3
@@ -4615,7 +4615,7 @@ static void macb_configure_caps(struct macb *bp, }if (refclk_ext) - bp->caps |=MACB_CAPS_USRIO_HAS_CLKEN ; + bp->caps |=MACB_CAPS_USRIO_HAS_REFCLK_SOURCE ;dev_dbg (&bp->pdev->dev,"Cadence caps 0x%08x\n" , bp->caps); }
@@ -4895,6 +4895,9 @@ static int macb_init_dflt(struct platform_device *pdev) }if (bp->caps &MACB_CAPS_USRIO_HAS_CLKEN ) + val |= bp->usrio->clken; + +if (bp->caps &MACB_CAPS_USRIO_HAS_REFCLK_SOURCE ) val |= bp->usrio->refclk;macb_or_gem_writel (bp,USRIO , val);
@@ -5497,7 +5500,7 @@ static const struct macb_usrio_config at91_default_usrio = { .mii = MACB_BIT(MII), .rmii = MACB_BIT(RMII), .rgmii = GEM_BIT(RGMII), - .refclk = MACB_BIT(CLKEN), + .clken = MACB_BIT(CLKEN), };static const struct macb_usrio_config sama7g5_usrio = {
@@ -5615,6 +5618,7 @@ static const struct macb_config mpfs_config = {static const struct macb_config sama7g5_gem_config = { .caps =MACB_CAPS_GIGABIT_MODE_AVAILABLE |MACB_CAPS_CLK_HW_CHG |MACB_CAPS_USRIO_DEFAULT_IS_MII_GMII | +MACB_CAPS_USRIO_HAS_REFCLK_SOURCE |MACB_CAPS_MIIONRGMII |MACB_CAPS_GEM_HAS_PTP |MACB_CAPS_USRIO_HAS_MII , .dma_burst_length =16 ,
@@ -5623,7 +5627,8 @@ static const struct macb_config sama7g5_gem_config = {static const struct macb_config sama7g5_emac_config = { .caps =MACB_CAPS_USRIO_DEFAULT_IS_MII_GMII | -MACB_CAPS_USRIO_HAS_CLKEN |MACB_CAPS_MIIONRGMII | +MACB_CAPS_MIIONRGMII | +MACB_CAPS_USRIO_HAS_REFCLK_SOURCE |MACB_CAPS_GEM_HAS_PTP |MACB_CAPS_USRIO_HAS_MII , .dma_burst_length =16 ,
Signature · 1 line
2.53.0
PATCH v5 4/14 dt-bindings: net: cdns,macb: replace cdns,refclk-ext with cdns,refclk-source
In reply to Conor DooleyFrom: Conor Dooley <[email protected]>
Ryan added cdns,refclk-ext with the intent of decoupling the source of the reference clock on sama7g5 (and related platforms) from the compatible. Unfortunately, the default for sama7g5-emac is an external reference clock, so this property had no effect there, so that compatibility with older devicetrees is preserved.
Replace cdns,refclk-ext with one that supports both default states and therefore is usable for sama7g5-emac.
For now, limit it to only the platforms that have USRIO controlled reference clock selection, but this could be generalised in the future.
The existing property only works on devices that are compatible with sama7g5-gem, so mark it deprecated, and limit its use to that specific scenario.
--- .../devicetree/bindings/net/cdns,macb.yaml | 56 ++++++++++++++++++- 1 file changed, 53 insertions(+), 3 deletions(-)
Documentation/devicetree/bindings/net/cdns,macb.yaml +53 -3
@@ -130,10 +130,23 @@ properties: cdns,refclk-ext: type: boolean + deprecated: true + description: | + This selects if the REFCLK for RMII is provided by an external source. + For RGMII mode this selects if the 125MHz REF clock is provided by an external + source. + + This property has been replaced by cdns,refclk-source, as it only works + for devices that use an internal reference clock by default. + + cdns,refclk-source: + $ref: /schemas/types.yaml#/definitions/string + enum: + - internal + - external description: - This selects if the REFCLK for RMII is provided by an external source. - For RGMII mode this selects if the 125MHz REF clock is provided by an external - source. + Select whether or not the refclk for RGMII or RMII is provided by an + internal or external source. The default is device specific. cdns,rx-watermark: $ref: /schemas/types.yaml#/definitions/uint32
@@ -215,6 +228,43 @@ allOf: properties: mdio: false + - if: + not: + properties: + compatible: + contains: + enum: + - microchip,sama7g5-gem + - microchip,sama7g5-emac + then: + properties: + cdns,refclk-source: false + + - if: + not: + properties: + compatible: + contains: + const: microchip,sama7g5-gem + then: + properties: + cdns,refclk-ext: false + + - if: + properties: + compatible: + contains: + enum: + - microchip,sama7g5-emac + then: + properties: + cdns,refclk-source: + default: external + else: + properties: + cdns,refclk-source: + default: internal + unevaluatedProperties: false examples:
Signature · 1 line
2.53.0
PATCH v5 5/14 net: macb: rework usrio refclk selection code
In reply to Conor DooleyFrom: Conor Dooley <[email protected]>
The USRIO based refclk selection code abuses a capability flag to set the refclk to an external source based on match data/compatible on sama7g5-emac and use an internal source for the gmac.
Ryan previously added a property in an attempt to decouple the refclk source from the compatible, because this is not fixed by compatible and there's variance based on the choices made by board designers.
Originally when Ryan added it, he removed the capability flag entirely from match data, but this changed the default for the sama7g5-emac and the removal had to be reverted for these devices. Because these devices default to an external refclk, and the current property is only capable of communicating external refclks, there's no way to make the sama7g5-emac use an internal refclk.
Additionally, this property has no limiting based on compatible, and if used on a platform with an external refclk that is not controlled by USRIO the capability would be erroneously set. Because of the reuse of the at91_default_usrio struct by non-at91 devices, this could cause the refclk bit to be set in error, on a system where the refclk is externally provided without usrio settings being required.
Change the new capability flag so that it actually represents the hardware being capable of controlling the refclk source via USRIO, and move the selection of default behaviour into the macb_usrio_config struct provided as part of match data.
Modify the devicetree code to support a new property, "cdns,refclk-source" which will support devices with either default, retaining support for "cdns,refclk-external" for compatibility reasons.
--- drivers/net/ethernet/cadence/macb.h | 1 + drivers/net/ethernet/cadence/macb_main.c | 55 ++++++++++++++++++------ 2 files changed, 44 insertions(+), 12 deletions(-)
drivers/net/ethernet/cadence/macb.h +1 -0
@@ -1229,6 +1229,7 @@ struct macb_usrio_config {u32 refclk;u32 clken;u32 hdfctlen; +bool refclk_default_external; };struct macb_config {
drivers/net/ethernet/cadence/macb_main.c +43 -12
97 lines not on this page · raw message
Signature · 1 line
2.53.0
PATCH v5 6/14 net: macb: np4 doesn't need a usrio pointer
In reply to Conor DooleyFrom: Conor Dooley <[email protected]>
USRIO is disabled on this platform, having a pointer to a usrio config structure doesn't actually do anything other than look weird.
--- drivers/net/ethernet/cadence/macb_main.c | 1 - 1 file changed, 1 deletion(-)
drivers/net/ethernet/cadence/macb_main.c +0 -1
@@ -5613,7 +5613,6 @@ static const struct macb_config emac_config = {static const struct macb_config np4_config = { .caps =MACB_CAPS_USRIO_DISABLED , - .usrio = &at91_default_usrio, };static const struct macb_config zynqmp_config = {
Signature · 1 line
2.53.0
PATCH v5 7/14 net: macb: add mpfs specific usrio configuration
In reply to Conor DooleyFrom: Conor Dooley <[email protected]>
On mpfs the driver needs to make sure the tsu clock source is not the fabric, as this requires that the hardware is in Timer Adjust mode, which is not compatible with the linux driver trying to control the hardware. It is unlikely that this will be set, as the peripheral is reset during probe, but if the resets are not provided in devicetree it's probable that this bit is set incorrectly, as U-Boot's macb driver has the same issue with using usrio settings for at91 platforms as the default.
--- drivers/net/ethernet/cadence/macb.h | 2 ++ drivers/net/ethernet/cadence/macb_main.c | 12 ++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-)
drivers/net/ethernet/cadence/macb.h +2 -0
@@ -788,6 +788,7 @@#define MACB_CAPS_EEE BIT(25)#define MACB_CAPS_USRIO_HAS_MII BIT(26)#define MACB_CAPS_USRIO_HAS_REFCLK_SOURCE BIT(27) +#define MACB_CAPS_USRIO_HAS_TSUCLK_SOURCE BIT(28)/* LSO settings */ #define MACB_LSO_UFO_ENABLE 0x01
@@ -1229,6 +1230,7 @@ struct macb_usrio_config {u32 refclk;u32 clken;u32 hdfctlen; +u32 tsu_source;bool refclk_default_external; };
drivers/net/ethernet/cadence/macb_main.c +10 -2
@@ -4921,6 +4921,9 @@ static int macb_init_dflt(struct platform_device *pdev) val |= bp->usrio->refclk; } +if (bp->caps &MACB_CAPS_USRIO_HAS_TSUCLK_SOURCE ) + val |= bp->usrio->tsu_source; +macb_or_gem_writel (bp,USRIO , val); }
@@ -5524,6 +5527,10 @@ static const struct macb_usrio_config at91_default_usrio = { .clken = MACB_BIT(CLKEN), }; +static const struct macb_usrio_config mpfs_usrio = { + .tsu_source =0 , +}; +static const struct macb_usrio_config sama7g5_gem_usrio = { .mii =0 , .rmii =1 ,
@@ -5637,10 +5644,11 @@ static const struct macb_config zynq_config = {static const struct macb_config mpfs_config = { .caps =MACB_CAPS_GIGABIT_MODE_AVAILABLE |MACB_CAPS_JUMBO | -MACB_CAPS_GEM_HAS_PTP , +MACB_CAPS_GEM_HAS_PTP | +MACB_CAPS_USRIO_HAS_TSUCLK_SOURCE , .dma_burst_length =16 , .init = init_reset_optional, - .usrio = &at91_default_usrio, + .usrio = &mpfs_usrio, .max_tx_length =4040 ,/* Cadence Erratum 1686 */ .jumbo_max_len =4040 , };
Signature · 1 line
2.53.0
PATCH v5 8/14 net: macb: warn on pclk use as a tsu_clk fallback
In reply to Conor DooleyFrom: Conor Dooley <[email protected]>
The Candence GEM IP has a configuration parameter which determines the source of the clock used for the timestamp unit (if it is enabled), switching it between using the pclk and a dedicated input.
When ptp support was added to the macb driver, a new tsu_clk was added to represent the dedicated input. While this is understandable, I think it is bug prone and that the tsu_clk should represent whatever clock is used for the timestamper and not just that specific input.
Quoted 1 line
From a driver point of view, the benefit of taking the conceptual
approach is avoiding misconfiguring the driver when the hardware supports ptp (and it is set as a capability in the relevant per-device structure) but no tsu_clk is provided in devicetree. At the moment, the timestamper will be registered and programmed with an increment that reflects the pclk in these cases, but will malfunction if the pclk and tsu_clk frequencies do not match. Obviously, this means the devicetree incorrectly represents the hardware, but this change in approach would make the driver more resilient without meaningfully impacting correctly described users.
Out of the devices that claim MACB_CAPS_GEM_HAS_PTP the fu540, mpfs, sama5d2 and sama7g5-emac (but not sama7g5-gem) are at risk of having this problem with the in-kernel devicetrees. mpfs and sama7g5-emac have been confirmed to be incorrect, and sama5d2 is correct. It may be that the other platforms actually do use the pclk for the timestamper (either by supplying pclk to the tsu_clk input of the IP, or by having the IP block configured to use pclk instead of the tsu_clk input), but at least two are wrong, as they do not use pclk for the tsu_clk, so the driver is registering the ptp clock incorrectly.
Add a warning if no tsu_clk is provided on a platform that uses the timerstamper, to encourage people to specifically provide a tsu_clk and avoid silently registering the timerstamper with the wrong clock. If the pclk is actually used, it can be provided as a tsu_clk for improved clarity in devicetrees.
While this changes the meaning of the devicetree property, it is backwards compatible as there's no functional change for platforms that didn't provide a tsu_clk and the changed meaning of providing a tsu_clk in the devicetree does not impact platforms that already provided one as the decision about the tsu clock source is at IP instantiation time rather than at runtime, so there's no driver behaviour that needs to change based on the input to the IP used for the timestamping unit.
--- drivers/net/ethernet/cadence/macb_main.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/cadence/macb_main.c +1 -0
@@ -3772,6 +3772,7 @@ static unsigned int gem_get_tsu_rate(struct macb *bp)else if (!IS_ERR (bp->pclk)) { tsu_clk = bp->pclk; tsu_rate =clk_get_rate (tsu_clk); +dev_warn (&bp->pdev->dev,"devicetree missing tsu_clk, using pclk as fallback\n" ); }else return -ENOTSUPP ;return tsu_rate;
Signature · 1 line
2.53.0
PATCH v5 9/14 net: macb: clean up tsu clk rate acquisition
In reply to Conor DooleyFrom: Conor Dooley <[email protected]>
tsu_clk is grabbed during probe, so doesn't need to be re-grabbed here. pclk is mandatory, probe will fail if it is err/NULL, so there's no need to check it here or have a !pclk 3rd arm. Simplify gem_get_tsu_rate() to account for these facts.
--- drivers/net/ethernet/cadence/macb_main.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
drivers/net/ethernet/cadence/macb_main.c +5 -7
@@ -3765,16 +3765,14 @@ static unsigned int gem_get_tsu_rate(struct macb *bp)struct clk *tsu_clk;unsigned int tsu_rate; - tsu_clk =devm_clk_get (&bp->pdev->dev,"tsu_clk" ); -if (!IS_ERR (tsu_clk)) - tsu_rate =clk_get_rate (tsu_clk); -/* try pclk instead */ -else if (!IS_ERR (bp->pclk)) { +if (!IS_ERR_OR_NULL (bp->tsu_clk)) { + tsu_rate =clk_get_rate (bp->tsu_clk); + }else { tsu_clk = bp->pclk; tsu_rate =clk_get_rate (tsu_clk);dev_warn (&bp->pdev->dev,"devicetree missing tsu_clk, using pclk as fallback\n" ); - }else -return -ENOTSUPP ; + } +return tsu_rate; }
Signature · 1 line
2.53.0
PATCH v5 10/14 dt-bindings: net: macb: add property indicating timer adjust mode
In reply to Conor DooleyFrom: Conor Dooley <[email protected]>
The GEM IP has two methods for modifying the ptp timer. The first of these, named "increment mode", relies on software controlling the timer by setting tsu_timer_incr and tsu_timer_incr_sub_nsec and performing once-off adjustments via the tsu_timer_adjust register. This is what the macb driver uses. The second mechanism, "timer adjust mode" uses the gem_tsu_inc_ctrl and gem_tsu_ms signals to control the timer. These modes are not intended to be used in parallel, but both can be possible on the same device and which mode is used cannot be determined from the compatible on all devices, because some users of the GEM IP are SoC FPGAs that permit configuring how the IP is wired up.
Add a property to indicate that gem_tsu_inc_ctrl and gem_tsu_ms are wired up for timer adjust mode.
--- .../devicetree/bindings/net/cdns,macb.yaml | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
Documentation/devicetree/bindings/net/cdns,macb.yaml +15 -0
@@ -158,6 +158,12 @@ properties: that need to be filled, before the forwarding process is activated. Width of the SRAM is platform dependent, and can be 4, 8 or 16 bytes. + cdns,timer-adjust: + type: boolean + description: + Set when the hardware is operating in timer-adjust mode, where the timer + is controlled by the gem_tsu_inc_ctrl and gem_tsu_ms inputs. + '#address-cells': const: 1
@@ -207,6 +213,15 @@ allOf: properties: reg: maxItems: 1 + - if: + not: + properties: + compatible: + contains: + const: microchip,mpfs-macb + then: + properties: + cdns,timer-adjust: false - if: properties:
Signature · 1 line
2.53.0
PATCH v5 11/14 net: macb: timer adjust mode is not supported
In reply to Conor DooleyFrom: Conor Dooley <[email protected]>
The ptp portion of this driver controls the tsu's timer using the controls for "increment mode", which is not compatible with the hardware trying to control it via the gem_tsu_inc_ctrl and gem_tsu_ms inputs in "timer adjust mode". Abort probe if the property signalling that the relevant signals have been wired up is present.
--- drivers/net/ethernet/cadence/macb_main.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/net/ethernet/cadence/macb_main.c +7 -0
@@ -5838,6 +5838,13 @@ static int macb_probe(struct platform_device *pdev) bp->usrio = macb_config->usrio; +if (of_property_read_bool (bp->pdev->dev.of_node,"cdns,timer-adjust" ) && +IS_ENABLED (CONFIG_MACB_USE_HWSTAMP )) { +dev_err (&pdev->dev,"Timer adjust mode is not supported\n" ); + err = -EINVAL ; + goto err_out_free_netdev; + } +/* By default we set to partial store and forward mode for zynqmp. * Disable if not set in devicetree. */
Signature · 1 line
2.53.0
PATCH v5 12/14 net: macb: runtime detect MACB_CAPS_USRIO_DISABLED
In reply to Conor DooleyFrom: Théo Lebrun <[email protected]>
DCFG1 (design config 1 register) carries a bit indicating whether User I/O feature has been enabled or not. The MACB/GEM driver has a cap flag indicating that HW has the feature disabled (default is enabled). Add the missing connection between DCFG1 bit and MACB_CAPS_USRIO_DISABLED.
Indirect impact: avoid useless writel() on USERIO register; this is not an important fix because USERIO is anyway read-only when feature is disabled.
If for some reason a compatible sets USRIO_DISABLED but DCFG1 indicates it is enabled, we still keep the disabled capability flag. This ensures we don't break "cdns,np4-macb" that sets the flag from compatible match data.
--- drivers/net/ethernet/cadence/macb.h | 2 ++ drivers/net/ethernet/cadence/macb_main.c | 2 ++ 2 files changed, 4 insertions(+)
drivers/net/ethernet/cadence/macb.h +2 -0
@@ -524,6 +524,8 @@#define GEM_IRQCOR_SIZE 1#define GEM_DBWDEF_OFFSET 25#define GEM_DBWDEF_SIZE 3 +#define GEM_USERIO_OFFSET 9 +#define GEM_USERIO_SIZE 1#define GEM_NO_PCS_OFFSET 0#define GEM_NO_PCS_SIZE 1
drivers/net/ethernet/cadence/macb_main.c +2 -0
@@ -4588,6 +4588,8 @@ static void macb_configure_caps(struct macb *bp, bp->caps |=MACB_CAPS_ISR_CLEAR_ON_WRITE ;if (GEM_BFEXT (NO_PCS , dcfg) ==0 ) bp->caps |=MACB_CAPS_PCS ; +if (!(dcfg &GEM_BIT (USERIO ))) + bp->caps |=MACB_CAPS_USRIO_DISABLED ; dcfg =gem_readl (bp,DCFG12 );if (GEM_BFEXT (HIGH_SPEED , dcfg) ==1 ) bp->caps |=MACB_CAPS_HIGH_SPEED ;
Signature · 1 line
2.53.0
PATCH v5 13/14 net: macb: set MACB_CAPS_USRIO_DISABLED if no usrio config is provided
In reply to Conor DooleyFrom: Théo Lebrun <[email protected]>
bp->usrio is copied directly from dt_conf->usrio in macb_probe().
If dt_conf->usrio is NULL, we do not want to land in USRIO write codepaths which dereference bp->usrio. Inherit automatically MACB_CAPS_USRIO_DISABLED to avoid those.
This means a macb_config that wants to disable usrio can simply drop its .usrio field, rather than add the disabled capability explicitly.
Nit: drop the dt_conf NULL check because the pointer is always valid.
--- drivers/net/ethernet/cadence/macb_main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/cadence/macb_main.c +4 -2
@@ -4577,8 +4577,10 @@ static void macb_configure_caps(struct macb *bp, {u32 dcfg; -if (dt_conf) - bp->caps = dt_conf->caps; + bp->caps = dt_conf->caps; + +if (!dt_conf->usrio) + bp->caps |=MACB_CAPS_USRIO_DISABLED ;if (hw_is_gem (bp->regs, bp->native_io)) { bp->caps |=MACB_CAPS_MACB_IS_GEM ;
Signature · 1 line
2.53.0
PATCH v5 14/14 net: macb: drop usrio pointer on EyeQ5 config
In reply to Conor DooleyFrom: Théo Lebrun <[email protected]>
USRIO is disabled on this platform, drop its inherited usrio config. We will end up with MACB_CAPS_USRIO_DISABLED on this platform:
- We have no config->usrio so macb_configure_caps() deduces that the feature is disabled.
- Anecdotally, we would also land in the runtime detection codepath that reads DCFG1.
--- drivers/net/ethernet/cadence/macb_main.c | 1 - 1 file changed, 1 deletion(-)
drivers/net/ethernet/cadence/macb_main.c +0 -1
@@ -5695,7 +5695,6 @@ static const struct macb_config eyeq5_config = { .dma_burst_length = 16, .init = eyeq5_init, .jumbo_max_len = 10240, - .usrio = &at91_default_usrio, };static const struct macb_config raspberrypi_rp1_config = {
Signature · 1 line
2.53.0
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 10 lines · On Wed, 25 Mar 2026 16:28:04 +0000 you wrote:
From: Conor Dooley <[email protected]>
Hey folks,
At the very least, it'd be good of the soc vendor folks could check their platforms and see if their usrio stuff actually lines up with what the driver currently calls "
macb_default_usrio". Ours didn't and it was a nasty surprise.[...]
Here is the summary with links:
- [net-next,v5,01/14] Revert "net: macb: Clean up the .usrio settings in macb_config instances"
https://git.kernel.org/netdev/net-next/c/8ccf062c6770 - [net-next,v5,02/14] net: macb: rename macb_default_usrio to at91_default_usrio as not all platforms have mii mode control in usrio https://git.kernel.org/netdev/net-next/c/a17871778ee2 - [net-next,v5,03/14] net: macb: split USRIO_HAS_CLKEN capability in two https://git.kernel.org/netdev/net-next/c/039f185a0060 - [net-next,v5,04/14] dt-bindings: net: cdns,macb: replace cdns,refclk-ext with cdns,refclk-source https://git.kernel.org/netdev/net-next/c/dfa36d7e860c - [net-next,v5,05/14] net: macb: rework usrio refclk selection code https://git.kernel.org/netdev/net-next/c/6c5b565d7d41 - [net-next,v5,06/14] net: macb: np4 doesn't need a usrio pointer https://git.kernel.org/netdev/net-next/c/826cbe636e10 - [net-next,v5,07/14] net: macb: add mpfs specific usrio configuration https://git.kernel.org/netdev/net-next/c/c711311d6ba3 - [net-next,v5,08/14] net: macb: warn on pclk use as a tsu_clk fallback https://git.kernel.org/netdev/net-next/c/3fe13d858f83 - [net-next,v5,09/14] net: macb: clean up tsu clk rate acquisition https://git.kernel.org/netdev/net-next/c/b698a1e397ab - [net-next,v5,10/14] dt-bindings: net: macb: add property indicating timer adjust mode https://git.kernel.org/netdev/net-next/c/09a6164a4f1d - [net-next,v5,11/14] net: macb: timer adjust mode is not supported https://git.kernel.org/netdev/net-next/c/41adda8764fd - [net-next,v5,12/14] net: macb: runtime detect MACB_CAPS_USRIO_DISABLED https://git.kernel.org/netdev/net-next/c/47c86c463612 - [net-next,v5,13/14] net: macb: set MACB_CAPS_USRIO_DISABLED if no usrio config is provided https://git.kernel.org/netdev/net-next/c/32fc6a9f6e75 - [net-next,v5,14/14] net: macb: drop usrio pointer on EyeQ5 config https://git.kernel.org/netdev/net-next/c/cd1082a96f9a
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
Quoted 48 lines
Hello:
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 10 lines · On Wed, 25 Mar 2026 16:28:04 +0000 you wrote:
From: Conor Dooley <[email protected]>
Hey folks,
At the very least, it'd be good of the soc vendor folks could check their platforms and see if their usrio stuff actually lines up with what the driver currently calls "
macb_default_usrio". Ours didn't and it was a nasty surprise.[...]
Here is the summary with links:
- [net-next,v5,01/14] Revert "net: macb: Clean up the .usrio settings inmacb_configinstances"https://git.kernel.org/netdev/net-next/c/8ccf062c6770 - [net-next,v5,02/14] net: macb: rename macb_default_usrio to at91_default_usrio as not all platforms have mii mode control in usrio https://git.kernel.org/netdev/net-next/c/a17871778ee2 - [net-next,v5,03/14] net: macb: split USRIO_HAS_CLKEN capability in two https://git.kernel.org/netdev/net-next/c/039f185a0060 - [net-next,v5,04/14] dt-bindings: net: cdns,macb: replace cdns,refclk-ext with cdns,refclk-source https://git.kernel.org/netdev/net-next/c/dfa36d7e860c - [net-next,v5,05/14] net: macb: rework usrio refclk selection code https://git.kernel.org/netdev/net-next/c/6c5b565d7d41 - [net-next,v5,06/14] net: macb: np4 doesn't need a usrio pointer https://git.kernel.org/netdev/net-next/c/826cbe636e10 - [net-next,v5,07/14] net: macb: add mpfs specific usrio configuration https://git.kernel.org/netdev/net-next/c/c711311d6ba3 - [net-next,v5,08/14] net: macb: warn on pclk use as a tsu_clk fallback https://git.kernel.org/netdev/net-next/c/3fe13d858f83 - [net-next,v5,09/14] net: macb: clean up tsu clk rate acquisition https://git.kernel.org/netdev/net-next/c/b698a1e397ab - [net-next,v5,10/14] dt-bindings: net: macb: add property indicating timer adjust mode https://git.kernel.org/netdev/net-next/c/09a6164a4f1d - [net-next,v5,11/14] net: macb: timer adjust mode is not supported https://git.kernel.org/netdev/net-next/c/41adda8764fd - [net-next,v5,12/14] net: macb: runtime detect MACB_CAPS_USRIO_DISABLED https://git.kernel.org/netdev/net-next/c/47c86c463612 - [net-next,v5,13/14] net: macb: set MACB_CAPS_USRIO_DISABLED if no usrio config is provided https://git.kernel.org/netdev/net-next/c/32fc6a9f6e75 - [net-next,v5,14/14] net: macb: drop usrio pointer on EyeQ5 config https://git.kernel.org/netdev/net-next/c/cd1082a96f9a
Quoted 4 lines
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
Hi,
There are compilation errors after merging this patch set. I believe the error occurred where the CONFIG_OF is not set.
root@w-MS-7E16:~/net-next# make C=1 W=1
CALL scripts/checksyscalls.sh
DESCEND objtool
INSTALL libsubcmd_headers
CC [M] drivers/net/ethernet/cadence/macb_main.o
drivers/net/ethernet/cadence/macb_main.c:5755:19: error: ‘at91_default_usrio’ undeclared here (not in a function)
5755 | .usrio = &at91_default_usrio,
| ^~~~~~~~~~~~~~~~~~
make[6]: *** [scripts/Makefile.build:289: drivers/net/ethernet/cadence/macb_main.o] Error 1
make[5]: *** [scripts/Makefile.build:548: drivers/net/ethernet/cadence] Error 2
make[4]: *** [scripts/Makefile.build:548: drivers/net/ethernet] Error 2
make[3]: *** [scripts/Makefile.build:548: drivers/net] Error 2
make[2]: *** [scripts/Makefile.build:548: drivers] Error 2
make[1]: *** [/root/net-next/Makefile:2105: .] Error 2
make: *** [Makefile:248: __sub-make] Error 2Quoted 15 lines · Jiawen Wu
Quoted 15 lines
Hello:
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 9 lines · On Wed, 25 Mar 2026 16:28:04 +0000 you wrote:
From: Conor Dooley <[email protected]>
Hey folks,
At the very least, it'd be good of the soc vendor folks could check their platforms and see if their usrio stuff actually lines up with what the driver currently calls "
macb_default_usrio". Ours didn't and it was a nasty surprise.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
[...]
Here is the summary with links:
- [net-next,v5,02/14] net: macb: rename
macb_default_usriotoat91_default_usrioas not all platforms have mii mode control inThere are compilation errors after merging this patch set. I believe the error occurred where the
CONFIG_OFis not set.
Thanks for the report. I have sent what's hopefully a fix..