net: ftgmac100: Add AST2700 support
Subsystems (4)
v5 cover net: ftgmac100: Add AST2700 support
Add the pieces needed for the FTGMAC100 driver to run on Aspeed AST2700 systems.
AST2700 keeps using the FTGMAC100 MAC IP, but the enablement is not limited to a new compatible string. The SoC can boot with the MAC on ARM64, needs the Aspeed-specific RMII mode bit programmed when a port is wired for RMII, and requires the driver to use the upper DMA address fields in the ring base registers and packet descriptors. Those fields expose a 35-bit DMA address range on AST2700, so the driver must request a mask that matches the address bits the hardware can encode.
The series first documents and wires up the aspeed,ast2700-mac compatible. It then treats AST2700 as an Aspeed MAC in the driver, enables the RMII mode programming, writes the AST2700 high descriptor-ring base registers, carries the RX/TX descriptor high address bits, rebuilds full DMA addresses before unmapping buffers, and requests a 35-bit DMA mask. The high ring base registers are only touched for AST2700 so older Aspeed device tree register windows remain unchanged. With that in place, the FTGMAC100 Kconfig entry can be made available on ARM64 while keeping the existing Aspeed MDIO dependency for AST2600 and newer ARCH_ASPEED systems.
RGMII delay is configured at the bootloader stage, the same way it is handled for AST2600, not by this driver. Aspeed's SDK bootloader configures both AST2600 and AST2700 boards with the RGMII delay disabled and advertises "phy-mode = rgmii-id" to match, mirroring the OpenBMC bootloader change that stopped inserting delays on AST2600 so its device trees could use the correct "rgmii-id" setting. On AST2700, every on-chip MAC is likewise configured by the bootloader with RGMII delay disabled and "rgmii-id" phy-mode. Because the delay is already resolved before Linux boots, the ftgmac100 driver does not need to program any RGMII delay for either AST2600 or AST2700.
This series has been validated on AST2700 EVB and AST2600 EVB.
Patch layout:
- patch 1 makes the existing aspeed,ast2400-mac, aspeed,ast2500-mac, and aspeed,ast2600-mac compatibles standalone, dropping the requirement to pair them with the generic "faraday,ftgmac100" fallback compatible.
- patch 2 adds the aspeed,ast2700-mac compatible to the binding, with its RMII RCLK gate, reset support, and the "phy-mode" requirement.
- patch 3 adds the AST2700 match data and OF compatible.
- patch 4 programs the AST2700 RMII enable bit and documents why netdev->phydev can never be NULL at that point for AST2700.
- patch 5 makes "phy-mode" a required device tree property for AST2700 and fails probe if it is missing.
- patch 6 adds AST2700 upper DMA address handling for rings and descriptors.
- patch 7 enables the Faraday/FTGMAC100 Kconfig options on ARM64 and selects MDIO_ASPEED for ARCH_ASPEED.
---
Changes in v5:
- Pick up Reviewed-by from Rob Herring on the AST2700 binding
patch.
- Link to v4: https://lore.kernel.org/r/[email protected]
Changes in v4:
- Split the dt-bindings patch into two: one making the existing aspeed,ast2400-mac, aspeed,ast2500-mac, and aspeed,ast2600-mac
compatibles standalone, and a second adding the new
aspeed,ast2700-mac compatible, per review feedback that these are
two separate concerns.
- Link to v3: https://lore.kernel.org/r/[email protected]
Changes in v3:
- Require "phy-mode" in the devicetree binding when the AST2700
compatible is used, matching the driver's probe-time requirement
added in v2.
- Drop the "faraday,ftgmac100" fallback compatible requirement for
AST2700; "aspeed,ast2700-mac" now stands on its own in the binding,
matching how the driver already matches it independently.
- Drop the same "faraday,ftgmac100" fallback requirement for
aspeed,ast2400-mac, aspeed,ast2500-mac, and aspeed,ast2600-mac as
well, per review feedback. The same EDORR/EDOTR bit mismatch applies
to all of them if a node ever bound through the generic
faraday,ftgmac100 entry alone; there is no evidence this has ever
happened in practice since ftgmac100_of_match[] has had dedicated
entries for these SoCs since commit 03a2aba50b2c, but keeping the
binding correct avoids leaving the same landmine in place. Folded
into this series rather than sent as a follow-up, to avoid
self-conflicting with a later series touching the same "compatible"
block. Note this makes make dtbs_check warn against arch/arm/boot/dts/aspeed/aspeed-g4.dtsi, aspeed-g5.dtsi, and
aspeed-g6.dtsi, which still declare the two-string compatible; that
.dtsi change will be sent separately through the Aspeed/arm-soc tree,
since dt-bindings changes don't go through that tree.
- Document in the RMII-enable patch why netdev->phydev is always
non-NULL by the time ftgmac100_start_hw() checks phydev->interface
for AST2700: ftgmac100_probe_dt() always attaches a phy_device
before register_netdev() can succeed, via a discrete PHY
(phy-handle), a fixed-link node, or NC-SI's internal fixed 100Mbit
PHY, and any failure in that setup aborts probe first.
- Drop Reviewed-by from Krzysztof Kozlowski on the dt-bindings patch
since its content changed.
- Link to v2: https://lore.kernel.org/r/[email protected]
Changes in v2:
- Make "phy-mode" a required device tree property for AST2700 and fail
probe if it is missing, instead of silently defaulting to RGMII.
- Document in the cover letter how RGMII delay is configured at the
bootloader stage for AST2600 and AST2700.
- Simplify the MDIO_ASPEED Kconfig select to ARCH_ASPEED only, dropping
the redundant MACH_ASPEED_G6 condition, and update its help text to
mention AST2700.
- Pick up Reviewed-by from Krzysztof Kozlowski on the dt-bindings patch.
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Jacky Chou (7):
dt-bindings: net: ftgmac100: Make Aspeed compatibles standalone
dt-bindings: net: ftgmac100: Add AST2700 compatible
net: ftgmac100: Add AST2700 compatible support
net: ftgmac100: Enable AST2700 RMII support
net: ftgmac100: Require phy-mode for AST2700
net: ftgmac100: Add AST2700 upper DMA address support
net: ftgmac100: Allow building on ARM64
.../devicetree/bindings/net/faraday,ftgmac100.yaml | 26 ++++-- drivers/net/ethernet/faraday/Kconfig | 7 +- drivers/net/ethernet/faraday/ftgmac100.c | 98 +++++++++++++++++++--- drivers/net/ethernet/faraday/ftgmac100.h | 7 ++ drivers/net/mdio/Kconfig | 16 ++-- 5 files changed, 123 insertions(+), 31 deletions(-)
---
base-commit: 7b6ab4dbc156e2f96419715130b3d5738a306c93
change-id: 20260623-support_ast2700-68fb164da45c
Best regards,
Signature · 1 line
Jacky Chou <[email protected]>
PATCH v5 1/7 dt-bindings: net: ftgmac100: Make Aspeed compatibles standalone
The aspeed,ast2400-mac, aspeed,ast2500-mac, and aspeed,ast2600-mac compatibles are currently only valid when paired with the generic "faraday,ftgmac100" fallback: if a node ever bound through the generic entry alone, ftgmac100_probe() would set rxdes0_edorr_mask/txdes0_edotr_mask to BIT(15) instead of the Aspeed BIT(30), skip Aspeed clock setup, and leave the DMA mask too narrow.
Make each of them a standalone compatible instead, so none of the Aspeed compatibles require the generic fallback alongside them.
---
ftgmac100_of_match[] has had dedicated entries for AST2400, AST2500, and AST2600 since commit 03a2aba50b2c ("net: ftgmac100: List all compatibles"), so there is no known kernel + devicetree combination where a node has actually bound through the generic entry and gotten the wrong EDORR bit. This part is a binding correctness fix, not a fix for an observed failure.
Note that arch/arm/boot/dts/aspeed/aspeed-g4.dtsi, aspeed-g5.dtsi, and aspeed-g6.dtsi still declare their MAC nodes with the two-string "aspeed,astXXXX-mac", "faraday,ftgmac100" compatible, so this will make dtbs_check warn against those files until the redundant fallback compatible is dropped there as well. That .dtsi change will be sent as a separate series through the Aspeed/arm-soc tree, since dt-bindings changes don't go through that tree.
--- .../devicetree/bindings/net/faraday,ftgmac100.yaml | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml +6 -8
@@ -13,12 +13,10 @@ properties: compatible: oneOf: - const: faraday,ftgmac100 - - items: - - enum: - - aspeed,ast2400-mac - - aspeed,ast2500-mac - - aspeed,ast2600-mac - - const: faraday,ftgmac100 + - enum: + - aspeed,ast2400-mac + - aspeed,ast2500-mac + - aspeed,ast2600-mac reg: maxItems: 1
@@ -94,14 +92,14 @@ unevaluatedProperties: false examples: - | ethernet@1e660000 { - compatible = "aspeed,ast2500-mac", "faraday,ftgmac100"; + compatible = "aspeed,ast2500-mac"; reg = <0x1e660000 0x180>; interrupts = <2>; use-ncsi; }; ethernet@1e680000 { - compatible = "aspeed,ast2500-mac", "faraday,ftgmac100"; + compatible = "aspeed,ast2500-mac"; reg = <0x1e680000 0x180>; interrupts = <2>;
Signature · 1 line
2.34.1
Re: [PATCH net-next v5 1/7] dt-bindings: net: ftgmac100: Make Aspeed compatibles standalone
Quoted 6 lines · Jacky Chou
The aspeed,ast2400-mac, aspeed,ast2500-mac, and aspeed,ast2600-mac compatibles are currently only valid when paired with the generic "faraday,ftgmac100" fallback: if a node ever bound through the generic entry alone,
ftgmac100_probe()would set rxdes0_edorr_mask/txdes0_edotr_mask to BIT(15) instead of the Aspeed BIT(30), skip Aspeed clock setup, and leave the DMA mask too narrow.
And device would work or not? If device still works after all these steps above, then why isn't fallback applicable?
Be explicit, because I have no clue whether Aspeed clock setup is necessary for device to operate.
Quoted 30 lines
Make each of them a standalone compatible instead, so none of the Aspeed compatibles require the generic fallback alongside them.
Signed-off-by Jacky Chou <[email protected]>---
ftgmac100_of_match[] has had dedicated entries for AST2400, AST2500, and AST2600 since commit03a2aba50b2c("net: ftgmac100: List all compatibles"), so there is no known kernel + devicetree combination where a node has actually bound through the generic entry and gotten the wrong EDORR bit. This part is a binding correctness fix, not a fix for an observed failure.Note that
arch/arm/boot/dts/aspeed/aspeed-g4.dtsi,aspeed-g5.dtsi, andaspeed-g6.dtsistill declare their MAC nodes with the two-string "aspeed,astXXXX-mac", "faraday,ftgmac100" compatible, so this will makedtbs_checkwarn against those files until the redundant fallback compatible is dropped there as well. That .dtsi change will be sent as a separate series through the Aspeed/arm-soc tree, since dt-bindings changes don't go through that tree.--- .../devicetree/bindings/net/faraday,ftgmac100.yaml | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml +0
-0
Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml properties: · line 15
Quoted 3 lines
Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml +0
-0@@ -13,12 +13,10 @@ properties: compatible: oneOf: - const: faraday,ftgmac100
This const goes to your new enum
Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml properties: · line 16
Quoted 7 lines
Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml +1
-6- - items: - - enum: - - aspeed,ast2400-mac - - aspeed,ast2500-mac - - aspeed,ast2600-mac - - const: faraday,ftgmac100 + - enum:
here.
Best regards,
Krzysztof
回覆: [PATCH net-next v5 1/7] dt-bindings: net: ftgmac100: Make Aspeed compatibles standalone
Hi Krzysztof,
Thank you for your reply.
Quoted 7 lines
Quoted 6 lines
The aspeed,ast2400-mac, aspeed,ast2500-mac, and aspeed,ast2600-mac compatibles are currently only valid when paired with the generic "faraday,ftgmac100" fallback: if a node ever bound through the generic entry alone,
ftgmac100_probe()would set rxdes0_edorr_mask/txdes0_edotr_mask to BIT(15) instead of the Aspeed BIT(30), skip Aspeed clock setup, and leave the DMA mask too narrow.
Quoted 6 lines
And device would work or not? If device still works after all these steps above, then why isn't fallback applicable?
Be explicit, because I have no clue whether Aspeed clock setup is necessary for device to operate.
It is necessary: ftgmac100_setup_clk() enables the MAC's clock, and only runs when priv->is_aspeed is true - skipped if a node ever bound through the generic entry. Without ftgmac100_setup_clk(), the MAC on Aspeed platform would be left without a working clock, so it wouldn't be able to configure register and TX/RX at all.
Quoted 21 lines
Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml properties: · line 15
Quoted 10 lines
a/Documentation/devicetree/bindings/net/faraday,ftgmac100.yamlb/Documentation/devicetree/bindings/net/faraday,ftgmac100.yamlindexd14410018bcf..c870dd0bda7b100644Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml +0
-0@@ -13,12 +13,10 @@ properties: compatible: oneOf: - const: faraday,ftgmac100This const goes to your new enum
Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml properties: · line 16
Quoted 7 lines
Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml +1
-6- - items: - - enum: - - aspeed,ast2400-mac - - aspeed,ast2500-mac - - aspeed,ast2600-mac - - const: faraday,ftgmac100 + - enum:
Quoted 2 lines
here.
Agreed, will collapse to a flat enum in next version:
compatible:
enum:
- faraday,ftgmac100
- aspeed,ast2400-mac
- aspeed,ast2500-mac
- aspeed,ast2600-mac
Thanks,
Jacky
Re: 回覆: [PATCH net-next v5 1/7] dt-bindings: net: ftgmac100: Make Aspeed compatibles standalone
Quoted 14 lines · Jacky Chou
Hi Krzysztof,
Thank you for your reply.
Quoted 10 lines
Quoted 6 lines
The aspeed,ast2400-mac, aspeed,ast2500-mac, and aspeed,ast2600-mac compatibles are currently only valid when paired with the generic "faraday,ftgmac100" fallback: if a node ever bound through the generic entry alone,
ftgmac100_probe()would set rxdes0_edorr_mask/txdes0_edotr_mask to BIT(15) instead of the Aspeed BIT(30), skip Aspeed clock setup, and leave the DMA mask too narrow.And device would work or not? If device still works after all these steps above, then why isn't fallback applicable?
Quoted 7 lines
Quoted 3 lines
Be explicit, because I have no clue whether Aspeed clock setup is necessary for device to operate.
It is necessary:
ftgmac100_setup_clk()enables the MAC's clock, and only runs whenpriv->is_aspeedis true - skipped if a node ever bound through the generic entry. Withoutftgmac100_setup_clk(), the MAC on
This part is obvious.
Quoted 2 lines
Aspeed platform would be left without a working clock, so it wouldn't be able to configure register and TX/RX at all.
So you are saying device will not work? Then make it obvious that clock is necessary for basic register access.
Best regards,
Krzysztof
回覆: 回覆: [PATCH net-next v5 1/7] dt-bindings: net: ftgmac100: Make Aspeed compatibles standalone
Quoted 19 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
The aspeed,ast2400-mac, aspeed,ast2500-mac, and aspeed,ast2600-mac compatibles are currently only valid when paired with the generic "faraday,ftgmac100" fallback: if a node ever bound through the generic entry alone,
ftgmac100_probe()would set rxdes0_edorr_mask/txdes0_edotr_mask to BIT(15) instead of the Aspeed BIT(30), skip Aspeed clock setup, and leave the DMA mask toonarrow.
Quoted 11 lines
Quoted 7 lines
And device would work or not? If device still works after all these steps above, then why isn't fallback applicable?
Be explicit, because I have no clue whether Aspeed clock setup is necessary for device to operate.
It is necessary:
ftgmac100_setup_clk()enables the MAC's clock, and only runs whenpriv->is_aspeedis true - skipped if a node ever bound through the generic entry. Withoutftgmac100_setup_clk(), the MAC on
Quoted 8 lines
This part is obvious.
Quoted 2 lines
Aspeed platform would be left without a working clock, so it wouldn't be able to configure register and TX/RX at all.
So you are saying device will not work? Then make it obvious that clock is necessary for basic register access.
Yes, the MAC on Aspeed platform does not work at all. Without the clock, even basic register access to the MAC is not possible.
Thanks,
Jacky
Andrew Lunn
maintainerRe: 回覆: 回覆: [PATCH net-next v5 1/7] dt-bindings: net: ftgmac100: Make Aspeed compatibles standalone
Quoted 24 lines · Jacky Chou
Quoted 24 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
The aspeed,ast2400-mac, aspeed,ast2500-mac, and aspeed,ast2600-mac compatibles are currently only valid when paired with the generic "faraday,ftgmac100" fallback: if a node ever bound through the generic entry alone,
ftgmac100_probe()would set rxdes0_edorr_mask/txdes0_edotr_mask to BIT(15) instead of the Aspeed BIT(30), skip Aspeed clock setup, and leave the DMA mask toonarrow.
Quoted 11 lines
Quoted 7 lines
And device would work or not? If device still works after all these steps above, then why isn't fallback applicable?
Be explicit, because I have no clue whether Aspeed clock setup is necessary for device to operate.
It is necessary:
ftgmac100_setup_clk()enables the MAC's clock, and only runs whenpriv->is_aspeedis true - skipped if a node ever bound through the generic entry. Withoutftgmac100_setup_clk(), the MAC onThis part is obvious.
Quoted 2 lines
Aspeed platform would be left without a working clock, so it wouldn't be able to configure register and TX/RX at all.
Quoted 6 lines
Quoted 3 lines
So you are saying device will not work? Then make it obvious that clock is necessary for basic register access.
Yes, the MAC on Aspeed platform does not work at all. Without the clock, even basic register access to the MAC is not possible.
Then for this new compatible you can mark it required.
Maybe test what happens if you mark it required for all aspeed compatibles. Do an .dts files fail the test tools?
Andrew
回覆: 回覆: 回覆: [PATCH net-next v5 1/7] dt-bindings: net: ftgmac100: Make Aspeed compatibles standalone
Hi Andrew,
Thank you for your reply.
Quoted 31 lines
Quoted 31 lines
Quoted 30 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
The aspeed,ast2400-mac, aspeed,ast2500-mac, and aspeed,ast2600-mac compatibles are currently only valid when paired with the generic "faraday,ftgmac100" fallback: if a node ever bound through the generic entry alone,
ftgmac100_probe()would set rxdes0_edorr_mask/txdes0_edotr_mask to BIT(15) instead of the Aspeed BIT(30), skip Aspeed clock setup, and leave the DMA mask toonarrow.
Quoted 4 lines
Quoted 4 lines
And device would work or not? If device still works after all these steps above, then why isn't fallback applicable?
Quoted 8 lines
Quoted 3 lines
Be explicit, because I have no clue whether Aspeed clock setup is necessary for device to operate.
It is necessary:
ftgmac100_setup_clk()enables the MAC's clock, and only runs whenpriv->is_aspeedis true - skipped if a node ever bound through the generic entry. Withoutftgmac100_setup_clk(), the MAC onThis part is obvious.
Quoted 2 lines
Aspeed platform would be left without a working clock, so it wouldn't be able to configure register and TX/RX at all.
So you are saying device will not work? Then make it obvious that clock is necessary for basic register access.
Quoted 8 lines
Quoted 2 lines
Yes, the MAC on Aspeed platform does not work at all. Without the clock, even basic register access to the MAC is not possible.
Then for this new compatible you can mark it required.
Maybe test what happens if you mark it required for all aspeed compatibles. Do an .dts files fail the test tools?
Tested dtbs_check against every in-tree AST2400/2500/2600 board .dts:
no failures with "clocks" marked required for all four Aspeed compatibles. Only the pre-existing "compatible ... is too long" warnings show up, from the two-string fallback that gets fixed once the .dtsi change lands separately.
Will do this in v6, split by generation:
- ast2400-mac: clocks/clock-names required, 1 item max (no RCLK)
- ast2500/2600/2700-mac: clocks required, 1-2 items (RCLK optional)
- clock-names required whenever clocks has 2 items, since the driver only picks up RCLK by name - a second clock without a name would silently never get enabled
- clocks/clock-names disallowed for the generic "faraday,ftgmac100"
Thanks,
Jacky
[email protected]
AI reviewRe: [PATCH net-next v5 1/7] dt-bindings: net: ftgmac100: Make Aspeed compatibles standalone
In reply to Jacky ChouThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] dt-bindings: net: ftgmac100: dropping fallback compatible breaks dtbs_check --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] dt-bindings: net: ftgmac100: dropping fallback compatible breaks dtbs_check --
commit 95571d7f339ca9cf43fcba9a2d07a1737a0162eb
Author: Jacky Chou <[email protected]>
dt-bindings: net: ftgmac100: Make Aspeed compatibles standalone
This commit changes the Aspeed MAC compatibles in Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml from requiring the generic faraday,ftgmac100 fallback string to being standalone compatibles.
Quoted 8 lines
Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml +0
-0@@ -13,12 +13,10 @@ properties: compatible: oneOf: - const: faraday,ftgmac100
Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml properties: · line 19
Quoted 10 lines
Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml +4
-6- - items: - - enum: - - aspeed,ast2400-mac - - aspeed,ast2500-mac - - aspeed,ast2600-mac - - const: faraday,ftgmac100 + - enum: + - aspeed,ast2400-mac + - aspeed,ast2500-mac + - aspeed,ast2600-mac
[Severity: Medium]
As reported by Rob Herring on v4 [1], does removing the two-item compatible entry from properties.compatible in Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml break DT schema backward compatibility and cause dtbs_check regressions for existing device trees?
In-tree device trees in arch/arm/boot/dts/aspeed/aspeed-g4.dtsi, arch/arm/boot/dts/aspeed/aspeed-g5.dtsi, and arch/arm/boot/dts/aspeed/aspeed-g6.dtsi still declare their MAC nodes with the two-string compatible form, such as:
compatible = "aspeed,ast2600-mac", "faraday,ftgmac100";
When running make dtbs_check, every board that includes those .dtsi files will fail validation against faraday,ftgmac100.yaml because the two-item list is no longer permitted by the schema.
Should the existing two-item compatible entry be retained (for example marked with deprecated: true) alongside the standalone enum so that existing device trees continue to validate cleanly without introducing dtbs_check warnings?
[1] https://lore.kernel.org/r/[email protected]
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
PATCH v5 2/7 dt-bindings: net: ftgmac100: Add AST2700 compatible
In reply to Jacky ChouAdd AST2700 to the FTGMAC100 compatible list and document that its RMII RCLK gate matches the earlier Aspeed SoCs. Allow the reset line for AST2700 as it follows the same reset requirements as AST2600.
Require "phy-mode" to be present in the device tree when the AST2700 compatible is used, matching the driver's probe-time requirement.
Add aspeed,ast2700-mac as a standalone compatible, consistent with the other Aspeed compatibles.
--- Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml +11 -1
@@ -17,6 +17,7 @@ properties: - aspeed,ast2400-mac - aspeed,ast2500-mac - aspeed,ast2600-mac + - aspeed,ast2700-mac reg: maxItems: 1
@@ -28,7 +29,7 @@ properties: minItems: 1 items: - description: MAC IP clock - - description: RMII RCLK gate for AST2500/2600 + - description: RMII RCLK gate for AST2500/2600/2700 resets: maxItems: 1
@@ -80,12 +81,21 @@ allOf: contains: enum: - aspeed,ast2600-mac + - aspeed,ast2700-mac then: properties: resets: true else: properties: resets: false + - if: + properties: + compatible: + contains: + const: aspeed,ast2700-mac + then: + required: + - phy-mode unevaluatedProperties: false
Signature · 1 line
2.34.1
Re: [PATCH net-next v5 2/7] dt-bindings: net: ftgmac100: Add AST2700 compatible
Quoted 11 lines · Jacky Chou
Add AST2700 to the FTGMAC100 compatible list and document that its RMII RCLK gate matches the earlier Aspeed SoCs. Allow the reset line for AST2700 as it follows the same reset requirements as AST2600.
Require "phy-mode" to be present in the device tree when the AST2700 compatible is used, matching the driver's probe-time requirement.
Add aspeed,ast2700-mac as a standalone compatible, consistent with the other Aspeed compatibles.
Reviewed-by Rob Herring (Arm) <[email protected]>
Your patch changed substantially, so dropping tag was appropriate.
Quoted 18 lines
Signed-off-by Jacky Chou <[email protected]>--- Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml +1
-0@@ -17,6 +17,7 @@ properties: - aspeed,ast2400-mac - aspeed,ast2500-mac - aspeed,ast2600-mac + - aspeed,ast2700-mac reg: maxItems: 1
Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml properties: · line 32
Quoted 5 lines
Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml +1
-1@@ -28,7 +29,7 @@ properties: minItems: 1 items: - description: MAC IP clock - - description: RMII RCLK gate for AST2500/2600 + - description: RMII RCLK gate for AST2500/2600/2700
So not valid for 2600?
Quoted 4 lines
Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml +0
-0resets: maxItems: 1
Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml allOf: · line 90
Quoted 10 lines
Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml +1
-0@@ -80,12 +81,21 @@ allOf: contains: enum: - aspeed,ast2600-mac + - aspeed,ast2700-mac then: properties: resets: true else: properties: resets: false
Blank line here
Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml allOf: · line 98
Quoted 8 lines
Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml +8
-0+ - if: + properties: + compatible: + contains: + const: aspeed,ast2700-mac + then: + required: + - phy-mode
Please constrain clocks.
Best regards,
Krzysztof
回覆: [PATCH net-next v5 2/7] dt-bindings: net: ftgmac100: Add AST2700 compatible
Hi Krzysztof
Thank you for your reply.
Quoted 7 lines
Quoted 7 lines
Add AST2700 to the FTGMAC100 compatible list and document that its RMII RCLK gate matches the earlier Aspeed SoCs. Allow the reset line for AST2700 as it follows the same reset requirements as AST2600.
Require "phy-mode" to be present in the device tree when the AST2700 compatible is used, matching the driver's probe-time requirement.
Quoted 7 lines
Quoted 4 lines
Add aspeed,ast2700-mac as a standalone compatible, consistent with the other Aspeed compatibles.
Reviewed-by Rob Herring (Arm) <[email protected]>Your patch changed substantially, so dropping tag was appropriate.
Got it. I will drop this in next version.
Quoted 30 lines
Quoted 21 lines
Signed-off-by Jacky Chou <[email protected]>--- Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)diff --git
a/Documentation/devicetree/bindings/net/faraday,ftgmac100.yamlb/Documentation/devicetree/bindings/net/faraday,ftgmac100.yamlindexc870dd0bda7b..0a376b849a91100644Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml +1
-0@@ -17,6 +17,7 @@ properties: - aspeed,ast2400-mac - aspeed,ast2500-mac - aspeed,ast2600-mac + - aspeed,ast2700-mac reg: maxItems: 1Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml properties: · line 32
Quoted 5 lines
Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml +1
-1@@ -28,7 +29,7 @@ properties: minItems: 1 items: - description: MAC IP clock - - description: RMII RCLK gate for AST2500/2600 + - description: RMII RCLK gate for AST2500/2600/2700So not valid for 2600?
Quoted 1 line
Quoted 16 lines
Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml allOf: · line 90
Quoted 13 lines
resets:
maxItems: 1Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml +1
-0@@ -80,12 +81,21 @@ allOf: contains: enum: - aspeed,ast2600-mac + - aspeed,ast2700-mac then: properties: resets: true else: properties: resets: falseBlank line here
Agreed.
Quoted 11 lines
Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml allOf: · line 98
Quoted 8 lines
Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml +8
-0+ - if: + properties: + compatible: + contains: + const: aspeed,ast2700-mac + then: + required: + - phy-modePlease constrain clocks.
I will add constrain clock in next version.
- if:
properties:
compatible:
contains:
const: aspeed,ast2400-mac
then:
properties:
clocks:
maxItems: 1
clock-names:
maxItems: 1 - if:
properties:
compatible:
contains:
enum:
- aspeed,ast2500-mac
- aspeed,ast2600-mac
- aspeed,ast2700-mac
then:
properties:
clocks:
minItems: 1
maxItems: 2
clock-names:
minItems: 1
maxItems: 2
- if:
not:
properties:
compatible:
contains:
enum:
- aspeed,ast2400-mac
- aspeed,ast2500-mac
- aspeed,ast2600-mac
- aspeed,ast2700-mac
then:
properties:
clocks: false
clock-names: false
Thanks,
Jacky
[email protected]
AI reviewRe: [PATCH net-next v5 2/7] dt-bindings: net: ftgmac100: Add AST2700 compatible
In reply to Jacky ChouThank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [Medium] dt-bindings: net: ftgmac100: requiring phy-mode on AST2700 breaks use-ncsi - [Low] dt-bindings…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] dt-bindings: net: ftgmac100: requiring phy-mode on AST2700 breaks use-ncsi
- [Low] dt-bindings: net: ftgmac100: split Aspeed binding instead of adding if-thens --
commit 761317ab12f9bb253e49b616ba9665479d666ab1
Author: Jacky Chou <[email protected]>
dt-bindings: net: ftgmac100: Add AST2700 compatible
This commit adds the aspeed,ast2700-mac compatible to the FTGMAC100 Device Tree binding schema, allowing the reset line and requiring the phy-mode property for AST2700.
Quoted 30 lines
Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml +3
-1@@ -17,6 +17,7 @@ properties: - aspeed,ast2400-mac - aspeed,ast2500-mac - aspeed,ast2600-mac + - aspeed,ast2700-mac reg: maxItems: 1@@ -28,7 +29,7 @@ properties: minItems: 1 items: - description: MAC IP clock - - description: RMII RCLK gate for AST2500/2600 + - description: RMII RCLK gate for AST2500/2600/2700 resets: maxItems: 1@@ -80,12 +81,21 @@ allOf: contains: enum: - aspeed,ast2600-mac + - aspeed,ast2700-mac then: properties: resets: true else:
Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml allOf: · line 98
Quoted 10 lines
Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml +8
-0properties: resets: false + - if: + properties: + compatible: + contains: + const: aspeed,ast2700-mac + then: + required: + - phy-mode
[Severity: Medium]
Does unconditionally requiring phy-mode for aspeed,ast2700-mac break schema validation for nodes configured with use-ncsi?
In Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml, use-ncsi is documented as using the NC-SI stack over RMII without an MDIO PHY, and the first example in the binding specifies use-ncsi without phy-mode.
In drivers/net/ethernet/faraday/ftgmac100.c, ftgmac100_probe_dt() checks for use-ncsi before reading phy-mode:
drivers/net/ethernet/faraday/ftgmac100.c:ftgmac100_probe_dt() {
if (of_get_property(np, "use-ncsi", NULL))
return ftgmac100_probe_ncsi(netdev, priv, pdev);
}ftgmac100_probe_ncsi() connects a fixed PHY with PHY_INTERFACE_MODE_RMII directly without consulting phy-mode.
Also, the commit message mentions matching the driver's probe-time requirement, which in commit e655d4e27cbf2 ("net: ftgmac100: Require phy-mode for AST2700") was added to ftgmac100_mii_probe(). However, ftgmac100_mii_probe() is only reachable when priv->mii_bus is allocated by ftgmac100_setup_mdio(), which is only called for FARADAY, AST2400, and AST2500, and not for AST2600 or AST2700. When phy-handle or fixed-link is used, of_phy_get_and_connect() already requires phy-mode across all SoCs.
Should phy-mode not be unconditionally required when use-ncsi is present, or is this AST2700-specific rule unnecessary?
[Severity: Low]
This isn't a bug, but since the Aspeed MAC compatibles (aspeed,ast2400-mac, aspeed,ast2500-mac, aspeed,ast2600-mac, and aspeed,ast2700-mac) are standalone compatibles that no longer fall back to faraday,ftgmac100 and diverge in clocks, resets, use-ncsi, embedded MDIO child nodes, and per-compatible allOf conditionals, would it be cleaner to split the Aspeed MAC binding into a separate schema document rather than adding more per-compatible if-then blocks to faraday,ftgmac100.yaml?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
PATCH v5 3/7 net: ftgmac100: Add AST2700 compatible support
In reply to Jacky ChouAdd match data for the Aspeed AST2700 FTGMAC100 controller and wire its compatible string into the OF match table. This lets AST2700 device tree nodes bind to the ftgmac100 driver.
--- drivers/net/ethernet/faraday/ftgmac100.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/net/ethernet/faraday/ftgmac100.c +10 -2
@@ -37,7 +37,8 @@ enum ftgmac100_mac_id {FTGMAC100_FARADAY =1 ,FTGMAC100_AST2400 ,FTGMAC100_AST2500 , -FTGMAC100_AST2600 +FTGMAC100_AST2600 , +FTGMAC100_AST2700 }; struct ftgmac100_match_data {
@@ -2017,7 +2018,8 @@ static int ftgmac100_probe(struct platform_device *pdev)if (priv->mac_id ==FTGMAC100_AST2400 || priv->mac_id ==FTGMAC100_AST2500 || - priv->mac_id ==FTGMAC100_AST2600 ) { + priv->mac_id ==FTGMAC100_AST2600 || + priv->mac_id ==FTGMAC100_AST2700 ) { priv->rxdes0_edorr_mask =BIT (30 ); priv->txdes0_edotr_mask =BIT (30 ); priv->is_aspeed = true;
@@ -2131,6 +2133,10 @@ static const struct ftgmac100_match_data ftgmac100_match_data_ast2600 = { .mac_id = FTGMAC100_AST2600 }; +static const struct ftgmac100_match_data ftgmac100_match_data_ast2700 = { + .mac_id =FTGMAC100_AST2700 +}; +static const struct ftgmac100_match_data ftgmac100_match_data_faraday = { .mac_id =FTGMAC100_FARADAY };
@@ -2142,6 +2148,8 @@ static const struct of_device_id ftgmac100_of_match[] = { .data = &ftgmac100_match_data_ast2500 }, { .compatible = "aspeed,ast2600-mac", .data = &ftgmac100_match_data_ast2600 }, + { .compatible = "aspeed,ast2700-mac", + .data = &ftgmac100_match_data_ast2700 }, { .compatible = "faraday,ftgmac100", .data = &ftgmac100_match_data_faraday }, { }
Signature · 1 line
2.34.1
[email protected]
AI reviewRe: [PATCH net-next v5 3/7] net: ftgmac100: Add AST2700 compatible support
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] net: ftgmac100: missing reset deassertion for AST2700 in ftgmac100_probe() --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] net: ftgmac100: missing reset deassertion for AST2700 in ftgmac100_probe() --
commit 1b009bb5f71bd76cdeadd675e668f4c589bb3d51
Author: Jacky Chou <[email protected]>
net: ftgmac100: Add AST2700 compatible support
This commit adds match data and the OF compatible entry for the Aspeed AST2700 FTGMAC100 Ethernet controller.
Quoted 4 lines
drivers/net/ethernet/faraday/ftgmac100.c +0
-0
[ ... ]
drivers/net/ethernet/faraday/ftgmac100.c static int ftgmac100_probe(struct platform_device *pdev) · line 2025
Quoted 10 lines
drivers/net/ethernet/faraday/ftgmac100.c +2
-1@@ -2017,7 +2018,8 @@ static int ftgmac100_probe(struct platform_device *pdev)if (priv->mac_id ==FTGMAC100_AST2400 || priv->mac_id ==FTGMAC100_AST2500 || - priv->mac_id ==FTGMAC100_AST2600 ) { + priv->mac_id ==FTGMAC100_AST2600 || + priv->mac_id ==FTGMAC100_AST2700 ) { priv->rxdes0_edorr_mask =BIT (30 ); priv->txdes0_edotr_mask =BIT (30 ); priv->is_aspeed = true;
[Severity: High]
Does AST2700 need its reset control deasserted and clocks enabled during ftgmac100_probe() before accessing registers or bringing up the interface?
On AST2400, AST2500, and AST2600, the MAC clock gates in clk-aspeed.c and clk-ast2600.c include a coupled reset index, so enabling the clock in ftgmac100_setup_clk() automatically deasserts the SCU MAC reset.
On AST2700, however, the MAC clock gates in drivers/clk/aspeed/clk-ast2700.c only control SCU1_CLK_STOP via ast2700_clk_enable() and do not deassert SCU1_RESET_MAC0..2:
drivers/clk/aspeed/clk-ast2700.c:
GATE_CLK(SCU1_CLK_GATE_MAC0CLK, CLK_GATE_ASPEED, "mac0clk-gate", -1, SCU1_CLK_STOP, 8, 0), GATE_CLK(SCU1_CLK_GATE_MAC1CLK, CLK_GATE_ASPEED, "mac1clk-gate", -1, SCU1_CLK_STOP, 9, 0), GATE_CLK(SCU1_CLK_GATE_MAC2CLK, CLK_GATE_ASPEED, "mac2clk-gate", -1, SCU1_CLK_STOP, 10, 0),
In ftgmac100_probe(), priv->rst is acquired via devm_reset_control_get_optional_exclusive(), but reset_control_deassert() is never called during probe:
drivers/net/ethernet/faraday/ftgmac100.c:ftgmac100_probe() {
...
/* MAC address from chip or random one */
err = ftgmac100_initial_mac(priv);
...
priv->rst = devm_reset_control_get_optional_exclusive(priv->dev, NULL);
if (IS_ERR(priv->rst)) {
err = PTR_ERR(priv->rst);
goto err;
}
if (priv->is_aspeed) {
err = ftgmac100_setup_clk(priv);
if (err)
goto err;
}
...
}Furthermore, ftgmac100_reset_and_config_mac() only asserts and deasserts priv->rst when phydev->interface is PHY_INTERFACE_MODE_RMII:
drivers/net/ethernet/faraday/ftgmac100.c:ftgmac100_reset_and_config_mac() {
...
if (priv->is_aspeed && priv->netdev->phydev->interface == PHY_INTERFACE_MODE_RMII) {
int err;
err = reset_control_assert(priv->rst);
...
err = reset_control_deassert(priv->rst);
...
}
...
}If the bootloader leaves the MAC in reset, or when operating in RGMII mode, won't ftgmac100_initial_mac() read FTGMAC100_OFFSET_MAC_MADR and FTGMAC100_OFFSET_MAC_LADR while the clock is still gated and reset is asserted, and won't ftgmac100_open() -> ftgmac100_reset_and_config_mac() -> ftgmac100_reset_mac() fail with -EIO because priv->rst was never deasserted?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
PATCH v5 4/7 net: ftgmac100: Enable AST2700 RMII support
In reply to Jacky ChouSet the RMII enable bit when an AST2700 port uses RMII so the MAC is programmed for the selected interface mode. Describe the requirement as a match-data quirk instead of checking the MAC generation in the data path, allowing later compatible controllers to opt into the behavior.
phydev is always populated by the time this runs: ftgmac100_start_hw() is only reached once the device has been opened, and ftgmac100_probe_dt() always attaches a phy_device before register_netdev() can succeed -- via a discrete PHY ("phy-handle"), a "fixed-link" node, or NC-SI's internal fixed 100Mbit PHY (ftgmac100_probe_ncsi()). Any failure in that setup aborts probe before register_netdev(), so an opened AST2700 netdev always has phydev set. This mirrors the same assumption ftgmac100_reset_and_config_mac() already makes for every Aspeed SoC earlier in the open path.
--- drivers/net/ethernet/faraday/ftgmac100.c | 21 +++++++++++++++++++-- drivers/net/ethernet/faraday/ftgmac100.h | 1 + 2 files changed, 20 insertions(+), 2 deletions(-)
drivers/net/ethernet/faraday/ftgmac100.c +19 -2
@@ -41,8 +41,11 @@ enum ftgmac100_mac_id { FTGMAC100_AST2700 }; +#define FTGMAC100_QUIRK_RMII_ENABLE BIT(0) +struct ftgmac100_match_data {enum ftgmac100_mac_id mac_id; +u32 quirks; };/* Arbitrary values, I am not sure the HW has limits */
@@ -79,6 +82,7 @@ struct ftgmac100 {void __iomem *base;enum ftgmac100_mac_id mac_id; +u32 quirks;/* Rx ring */ unsigned int rx_q_entries;
@@ -355,6 +359,12 @@ static void ftgmac100_init_hw(struct ftgmac100 *priv)static void ftgmac100_start_hw (struct ftgmac100 *priv) {u32 maccr =ioread32 (priv->base +FTGMAC100_OFFSET_MACCR ); +/* +* Only reached once the device is open, so a phy_device is already +* attached: a discrete PHY via "phy-handle", a "fixed-link" node, or +* NC-SI's internal fixed 100M PHY. +*/ +struct phy_device *phydev = priv->netdev->phydev;/* Keep the original GMAC and FAST bits */ maccr &= (FTGMAC100_MACCR_FAST_MODE |FTGMAC100_MACCR_GIGA_MODE );
@@ -383,6 +393,11 @@ static void ftgmac100_start_hw(struct ftgmac100 *priv)if (priv->netdev->features &NETIF_F_HW_VLAN_CTAG_RX ) maccr |=FTGMAC100_MACCR_RM_VLAN ; +if ((priv->quirks &FTGMAC100_QUIRK_RMII_ENABLE ) && + phydev->interface ==PHY_INTERFACE_MODE_RMII ) { + maccr |=FTGMAC100_MACCR_RMII_ENABLE ; + } +/* Hit the HW */ iowrite32 (maccr, priv->base +FTGMAC100_OFFSET_MACCR ); }
@@ -1942,7 +1957,7 @@ static int ftgmac100_probe_dt(struct net_device *netdev,static int ftgmac100_probe (struct platform_device *pdev) { -const struct ftgmac100_match_data *match_data; +const struct ftgmac100_match_data *match_data =NULL ;enum ftgmac100_mac_id mac_id;struct resource *res;int irq;
@@ -1987,6 +2002,7 @@ static int ftgmac100_probe(struct platform_device *pdev) priv->netdev = netdev; priv->dev = &pdev->dev; priv->mac_id = mac_id; + priv->quirks = match_data ? match_data->quirks :0 ;INIT_WORK (&priv->reset_task, ftgmac100_reset_task);/* map io memory */
@@ -2134,7 +2150,8 @@ static const struct ftgmac100_match_data ftgmac100_match_data_ast2600 = { };static const struct ftgmac100_match_data ftgmac100_match_data_ast2700 = { - .mac_id =FTGMAC100_AST2700 + .mac_id =FTGMAC100_AST2700 , + .quirks =FTGMAC100_QUIRK_RMII_ENABLE , };static const struct ftgmac100_match_data ftgmac100_match_data_faraday = {
drivers/net/ethernet/faraday/ftgmac100.h +1 -0
@@ -167,6 +167,7 @@#define FTGMAC100_MACCR_RX_BROADPKT (1 << 17)#define FTGMAC100_MACCR_DISCARD_CRCERR (1 << 18)#define FTGMAC100_MACCR_FAST_MODE (1 << 19) +#define FTGMAC100_MACCR_RMII_ENABLE BIT(20)#define FTGMAC100_MACCR_SW_RST (1 << 31)/*
Signature · 1 line
2.34.1
PATCH v5 5/7 net: ftgmac100: Require phy-mode for AST2700
In reply to Jacky ChouThe driver currently defaults to RGMII when the "phy-mode" property is missing from the device tree. This default is no longer valid for AST2700, which also supports RMII via FTGMAC100_QUIRK_RMII_ENABLE.
Make "phy-mode" a required property for AST2700 and fail probe with an error message if it is not specified, instead of silently defaulting to RGMII.
--- drivers/net/ethernet/faraday/ftgmac100.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/net/ethernet/faraday/ftgmac100.c +6 -1
@@ -1526,8 +1526,13 @@ static int ftgmac100_mii_probe(struct net_device *netdev)/* Default to RGMII. It's a gigabit part after all */ err =of_get_phy_mode (np, &phy_intf); -if (err) +if (err) { +if (priv->mac_id ==FTGMAC100_AST2700 ) { +dev_err (priv->dev,"phy-mode is required for this SoC\n" ); +return -EINVAL ; + } phy_intf =PHY_INTERFACE_MODE_RGMII ; + }/* Aspeed only supports these. I don't know about other IP * block vendors so I'm going to just let them through for
Signature · 1 line
2.34.1
[email protected]
AI reviewRe: [PATCH net-next v5 5/7] net: ftgmac100: Require phy-mode for AST2700
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] net: ftgmac100: unreachable AST2700 phy-mode check in ftgmac100_mii_probe() --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] net: ftgmac100: unreachable AST2700 phy-mode check in ftgmac100_mii_probe() --
commit e655d4e27cbf2e60c068a7ea633651b5660b5493
Author: Jacky Chou <[email protected]>
net: ftgmac100: Require phy-mode for AST2700
This commit adds a check in ftgmac100_mii_probe() to require the phy-mode property when probing an AST2700 MAC instead of defaulting to RGMII.
Quoted 6 lines
drivers/net/ethernet/faraday/ftgmac100.c +0
-0@@ -1526,8 +1526,13 @@ static int ftgmac100_mii_probe(struct net_device *netdev)
drivers/net/ethernet/faraday/ftgmac100.c static int ftgmac100_mii_probe(struct net_device *netdev) · line 1535
Quoted 10 lines
drivers/net/ethernet/faraday/ftgmac100.c +6
-1/* Default to RGMII. It's a gigabit part after all */ err =of_get_phy_mode (np, &phy_intf); -if (err) +if (err) { +if (priv->mac_id ==FTGMAC100_AST2700 ) { +dev_err (priv->dev,"phy-mode is required for this SoC\n" ); +return -EINVAL ; + } phy_intf =PHY_INTERFACE_MODE_RGMII ; + }
[Severity: Medium]
As reported by Sashiko on v4 [1], can this FTGMAC100_AST2700 check in ftgmac100_mii_probe() ever be reached?
In ftgmac100_probe(), ftgmac100_setup_mdio() is the only function that allocates priv->mii_bus, and it is skipped for FTGMAC100_AST2700:
if (priv->mac_id == FTGMAC100_FARADAY ||
priv->mac_id == FTGMAC100_AST2400 ||
priv->mac_id == FTGMAC100_AST2500) {
err = ftgmac100_setup_mdio(netdev);
if (err)
return err;
}When ftgmac100_probe_dt() falls through to ftgmac100_mii_probe(), the guard at the beginning of ftgmac100_mii_probe() sees priv->mii_bus == NULL and returns -ENODEV before reaching of_get_phy_mode():
if (!priv->mii_bus) {
dev_err(priv->dev, "No MDIO bus available\n");
return -ENODEV;
}Meanwhile, AST2700 device tree nodes that specify use-ncsi, fixed-link, phy-handle, or an mdio child node in ftgmac100_probe_dt() do not call ftgmac100_mii_probe() at all. Should the phy-mode requirement for FTGMAC100_AST2700 be checked in ftgmac100_probe_dt() instead?
[1] https://lore.kernel.org/r/[email protected]
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=5
PATCH v5 6/7 net: ftgmac100: Add AST2700 upper DMA address support
In reply to Jacky ChouProgram the high RX and TX descriptor ring base registers and carry the upper DMA address bits in RX and TX descriptors. Rebuild full buffer DMA addresses in a 64-bit type before unmapping them so bits 34:32 are not lost to 32-bit arithmetic.
The descriptor format provides three upper buffer address bits, so request a 35-bit DMA mask instead of advertising an address range that the hardware cannot encode. Gate all extended address handling with a match-data quirk so older register layouts remain untouched and later compatible controllers can opt into the same capability.
--- drivers/net/ethernet/faraday/ftgmac100.c | 62 +++++++++++++++++++++++++++----- drivers/net/ethernet/faraday/ftgmac100.h | 6 ++++ 2 files changed, 59 insertions(+), 9 deletions(-)
drivers/net/ethernet/faraday/ftgmac100.c +53 -9
@@ -8,6 +8,7 @@#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt +#include <linux/bitfield.h> #include <linux/clk.h> #include <linux/reset.h> #include <linux/dma-mapping.h>
@@ -42,6 +43,7 @@ enum ftgmac100_mac_id { };#define FTGMAC100_QUIRK_RMII_ENABLE BIT(0) +#define FTGMAC100_QUIRK_DMA_35BIT BIT(1)struct ftgmac100_match_data {enum ftgmac100_mac_id mac_id;
@@ -303,10 +305,16 @@ static void ftgmac100_init_hw(struct ftgmac100 *priv)iowrite32 (reg, priv->base +FTGMAC100_OFFSET_ISR );/* Setup RX ring buffer base */ -iowrite32 (priv->rxdes_dma, priv->base +FTGMAC100_OFFSET_RXR_BADR ); +iowrite32 (lower_32_bits (priv->rxdes_dma), priv->base +FTGMAC100_OFFSET_RXR_BADR ); +if (priv->quirks &FTGMAC100_QUIRK_DMA_35BIT ) +iowrite32 (upper_32_bits (priv->rxdes_dma), + priv->base +FTGMAC100_OFFSET_RXR_BADDR_HIGH );/* Setup TX ring buffer base */ -iowrite32 (priv->txdes_dma, priv->base +FTGMAC100_OFFSET_NPTXR_BADR ); +iowrite32 (lower_32_bits (priv->txdes_dma), priv->base +FTGMAC100_OFFSET_NPTXR_BADR ); +if (priv->quirks &FTGMAC100_QUIRK_DMA_35BIT ) +iowrite32 (upper_32_bits (priv->txdes_dma), + priv->base +FTGMAC100_OFFSET_TXR_BADDR_HIGH );/* Configure RX buffer size */ iowrite32(FTGMAC100_RBSR_SIZE(RX_BUF_SIZE),
@@ -474,7 +482,10 @@ static int ftgmac100_alloc_rx_buf(struct ftgmac100 *priv, unsigned int entry, priv->rx_skbs[entry] = skb;/* Store DMA address into RX desc */ - rxdes->rxdes3 =cpu_to_le32 (map); +if (priv->quirks &FTGMAC100_QUIRK_DMA_35BIT ) + rxdes->rxdes2 =cpu_to_le32 (FIELD_PREP (FTGMAC100_RXDES2_RXBUF_BADR_HI , +upper_32_bits (map))); + rxdes->rxdes3 =cpu_to_le32 (lower_32_bits (map));/* Ensure the above is ordered vs clearing the OWN bit */ dma_wmb ();
@@ -601,6 +612,9 @@ static bool ftgmac100_rx_packet(struct ftgmac100 *priv, int *processed)/* Tear down DMA mapping, do necessary cache management */ map =le32_to_cpu (rxdes->rxdes3); +if (priv->quirks &FTGMAC100_QUIRK_DMA_35BIT ) + map |= (u64 )FIELD_GET (FTGMAC100_RXDES2_RXBUF_BADR_HI , +le32_to_cpu (rxdes->rxdes2)) <<32 ;#if defined(CONFIG_ARM ) && !defined(CONFIG_ARM_DMA_USE_IOMMU )/* When we don't have an iommu, we can save cycles by not
@@ -677,9 +691,14 @@ static void ftgmac100_free_tx_packet(struct ftgmac100 *priv, struct ftgmac100_txdes *txdes, u32 ctl_stat) { -dma_addr_t map =le32_to_cpu (txdes->txdes3); +dma_addr_t map;size_t len; + map =le32_to_cpu (txdes->txdes3); +if (priv->quirks &FTGMAC100_QUIRK_DMA_35BIT ) + map |= (u64 )FIELD_GET (FTGMAC100_TXDES2_TXBUF_BADR_HI , +le32_to_cpu (txdes->txdes2)) <<32 ; +if (ctl_stat &FTGMAC100_TXDES0_FTS ) { len =skb_headlen (skb);dma_unmap_single (priv->dev, map, len,DMA_TO_DEVICE );
@@ -833,7 +852,10 @@ static netdev_tx_t ftgmac100_hard_start_xmit(struct sk_buff *skb, f_ctl_stat |=FTGMAC100_TXDES0_FTS ;if (nfrags ==0 ) f_ctl_stat |=FTGMAC100_TXDES0_LTS ; - txdes->txdes3 =cpu_to_le32 (map); +if (priv->quirks &FTGMAC100_QUIRK_DMA_35BIT ) + txdes->txdes2 =cpu_to_le32 (FIELD_PREP (FTGMAC100_TXDES2_TXBUF_BADR_HI , +upper_32_bits (map))); + txdes->txdes3 =cpu_to_le32 (lower_32_bits (map)); txdes->txdes1 =cpu_to_le32 (csum_vlan);/* Next descriptor */
@@ -861,7 +883,10 @@ static netdev_tx_t ftgmac100_hard_start_xmit(struct sk_buff *skb, ctl_stat |=FTGMAC100_TXDES0_LTS ; txdes->txdes0 =cpu_to_le32 (ctl_stat); txdes->txdes1 =0 ; - txdes->txdes3 =cpu_to_le32 (map); +if (priv->quirks &FTGMAC100_QUIRK_DMA_35BIT ) + txdes->txdes2 =cpu_to_le32 (FIELD_PREP (FTGMAC100_TXDES2_TXBUF_BADR_HI , +upper_32_bits (map))); + txdes->txdes3 =cpu_to_le32 (lower_32_bits (map));/* Next one */ pointer =ftgmac100_next_tx_pointer (priv, pointer);
@@ -936,7 +961,12 @@ static void ftgmac100_free_buffers(struct ftgmac100 *priv)for (i =0 ; i < priv->rx_q_entries; i++) {struct ftgmac100_rxdes *rxdes = &priv->rxdes[i];struct sk_buff *skb = priv->rx_skbs[i]; -dma_addr_t map =le32_to_cpu (rxdes->rxdes3); +dma_addr_t map; + + map =le32_to_cpu (rxdes->rxdes3); +if (priv->quirks &FTGMAC100_QUIRK_DMA_35BIT ) + map |= (u64 )FIELD_GET (FTGMAC100_RXDES2_RXBUF_BADR_HI , +le32_to_cpu (rxdes->rxdes2)) <<32 ;if (!skb)continue ;
@@ -1055,7 +1085,12 @@ static void ftgmac100_init_rings(struct ftgmac100 *priv)for (i =0 ; i < priv->rx_q_entries; i++) { rxdes = &priv->rxdes[i]; rxdes->rxdes0 =0 ; - rxdes->rxdes3 =cpu_to_le32 (priv->rx_scratch_dma); +if (priv->quirks &FTGMAC100_QUIRK_DMA_35BIT ) { +u32 hi =upper_32_bits (priv->rx_scratch_dma); + + rxdes->rxdes2 =cpu_to_le32 (FIELD_PREP (FTGMAC100_RXDES2_RXBUF_BADR_HI , hi)); + } + rxdes->rxdes3 =cpu_to_le32 (lower_32_bits (priv->rx_scratch_dma)); }/* Mark the end of the ring */ rxdes->rxdes0 |=cpu_to_le32 (priv->rxdes0_edorr_mask);
@@ -2104,6 +2139,14 @@ static int ftgmac100_probe(struct platform_device *pdev) netdev->hw_features &= ~(NETIF_F_HW_CSUM |NETIF_F_RXCSUM ); netdev->features |= netdev->hw_features; +if (priv->quirks &FTGMAC100_QUIRK_DMA_35BIT ) { + err =dma_set_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (35 )); +if (err) { +dev_err (&pdev->dev,"35-bit DMA enable failed\n" ); + goto err; + } + } +/* register network device */ err =register_netdev (netdev);if (err) {
@@ -2156,7 +2199,8 @@ static const struct ftgmac100_match_data ftgmac100_match_data_ast2600 = {static const struct ftgmac100_match_data ftgmac100_match_data_ast2700 = { .mac_id =FTGMAC100_AST2700 , - .quirks =FTGMAC100_QUIRK_RMII_ENABLE , + .quirks =FTGMAC100_QUIRK_RMII_ENABLE | +FTGMAC100_QUIRK_DMA_35BIT , };static const struct ftgmac100_match_data ftgmac100_match_data_faraday = {
drivers/net/ethernet/faraday/ftgmac100.h +6 -0
@@ -57,6 +57,9 @@#define FTGMAC100_OFFSET_RX_RUNT 0xc0#define FTGMAC100_OFFSET_RX_CRCER_FTL 0xc4#define FTGMAC100_OFFSET_RX_COL_LOST 0xc8 +/* reserved 0xcc - 0x178 */ +#define FTGMAC100_OFFSET_TXR_BADDR_HIGH 0x17c +#define FTGMAC100_OFFSET_RXR_BADDR_HIGH 0x18c/* * Interrupt status register & interrupt enable register
@@ -226,6 +229,7 @@ struct ftgmac100_txdes {#define FTGMAC100_TXDES1_TX2FIC (1 << 30)#define FTGMAC100_TXDES1_TXIC (1 << 31) +#define FTGMAC100_TXDES2_TXBUF_BADR_HI GENMASK(18, 16)/* * Receive descriptor, aligned to 16 bytes */
@@ -272,4 +276,6 @@ struct ftgmac100_rxdes {#define FTGMAC100_RXDES1_UDP_CHKSUM_ERR (1 << 26)#define FTGMAC100_RXDES1_IP_CHKSUM_ERR (1 << 27) +#define FTGMAC100_RXDES2_RXBUF_BADR_HI GENMASK(18, 16) +#endif /* __FTGMAC100_H */
Signature · 1 line
2.34.1
PATCH v5 7/7 net: ftgmac100: Allow building on ARM64
In reply to Jacky ChouAllow the Faraday vendor menu and FTGMAC100 driver to be selected on ARM64 so AST2700 platforms can enable the MAC. The driver now programs the upper DMA address fields, so it no longer needs to be marked BROKEN for 64-bit builds.
AST2700 has no dedicated MACH_ASPEED_G7 symbol; unlike the 32-bit generations it is only gated by the common ARCH_ASPEED symbol. On 32-bit Aspeed platforms, arch/arm/mach-aspeed/Kconfig nests MACH_ASPEED_G4/G5/G6 under "if ARCH_ASPEED", so MACH_ASPEED_G6 already implies ARCH_ASPEED and is redundant once ARCH_ASPEED is part of the condition. Drop it and select MDIO_ASPEED directly on ARCH_ASPEED.
This does widen the MDIO_ASPEED select beyond AST2600: it is now also selected for AST2400/AST2500, which keep driving their embedded MDIO controller from FTGMAC100 itself and have no MDIO node for this driver to bind to, so it is built but stays unused there. Update the MDIO_ASPEED help text to describe this.
--- drivers/net/ethernet/faraday/Kconfig | 7 +++---- drivers/net/mdio/Kconfig | 16 ++++++++++------ 2 files changed, 13 insertions(+), 10 deletions(-)
drivers/net/ethernet/faraday/Kconfig +3 -4
@@ -6,7 +6,7 @@ config NET_VENDOR_FARADAY bool "Faraday devices" default y - depends on ARM || COMPILE_TEST + depends on ARM || ARM64 || COMPILE_TEST help If you have a network (Ethernet) card belonging to this class, say Y.
@@ -28,11 +28,10 @@ config FTMAC100 config FTGMAC100 tristate "Faraday FTGMAC100 Gigabit Ethernet support" - depends on ARM || COMPILE_TEST - depends on !64BIT || BROKEN + depends on ARM || ARM64 || COMPILE_TEST select PHYLIB select FIXED_PHY - select MDIO_ASPEED if MACH_ASPEED_G6 + select MDIO_ASPEED if ARCH_ASPEED select CRC32 help This driver supports the FTGMAC100 Gigabit Ethernet controller
drivers/net/mdio/Kconfig +10 -6
@@ -50,12 +50,16 @@ config MDIO_ASPEED depends on OF_MDIO && HAS_IOMEM help This module provides a driver for the independent MDIO bus - controllers found in the ASPEED AST2600 SoC. This is a driver for the - third revision of the ASPEED MDIO register interface - the first two - revisions are the "old" and "new" interfaces found in the AST2400 and - AST2500, embedded in the MAC. For legacy reasons, FTGMAC100 driver - continues to drive the embedded MDIO controller for the AST2400 and - AST2500 SoCs, so say N if AST2600 support is not required. + controllers found in the ASPEED AST2600 and AST2700 SoCs. This is a + driver for the third revision of the ASPEED MDIO register interface - + the first two revisions are the "old" and "new" interfaces found in + the AST2400 and AST2500, embedded in the MAC. For legacy reasons, + FTGMAC100 driver continues to drive the embedded MDIO controller for + the AST2400 and AST2500 SoCs. AST2700 has no dedicated MACH_ASPEED_G7 + symbol and is only gated by ARCH_ASPEED, so FTGMAC100 now + unconditionally selects this driver on every ARCH_ASPEED platform, + including the older AST2400/AST2500 SoCs where it has no MDIO node to + bind to. config MDIO_BITBANG tristate "Bitbanged MDIO buses"
Signature · 1 line
2.34.1