diff mbox series

[net-next,v2,5/7] net: ftgmac100: add pin strap configuration for AST2700

Message ID 20241118060207.141048-6-jacky_chou@aspeedtech.com (mailing list archive)
State New
Delegated to: Netdev Maintainers
Headers show
Series Add Aspeed G7 FTGMAC100 support | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 3 this patch: 3
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 6 of 6 maintainers
netdev/build_clang success Errors and warnings before: 3 this patch: 3
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 4 this patch: 4
netdev/checkpatch warning CHECK: Prefer using the BIT macro
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-11-18--12-00 (tests: 789)

Commit Message

Jacky Chou Nov. 18, 2024, 6:02 a.m. UTC
On AST2700, the RMII/RGMII pin strap is configured by setting
MAC 0x50 bit 20. Set to 0 is RGMII and set to 1 is RMII.
Use compatible property to distinguish different generations for
configuration.

Signed-off-by: Jacky Chou <jacky_chou@aspeedtech.com>
---
 drivers/net/ethernet/faraday/ftgmac100.c | 5 +++++
 drivers/net/ethernet/faraday/ftgmac100.h | 1 +
 2 files changed, 6 insertions(+)

Comments

Arnd Bergmann Nov. 18, 2024, 6:34 a.m. UTC | #1
On Mon, Nov 18, 2024, at 07:02, Jacky Chou wrote:
> @@ -351,6 +352,10 @@ static void ftgmac100_start_hw(struct ftgmac100 *priv)
>  	if (priv->netdev->features & NETIF_F_HW_VLAN_CTAG_RX)
>  		maccr |= FTGMAC100_MACCR_RM_VLAN;
> 
> +	if (of_device_is_compatible(priv->dev->of_node, "aspeed,ast2700-mac") 
> &&
> +	    phydev && phydev->interface == PHY_INTERFACE_MODE_RMII)
> +		maccr |= FTGMAC100_MACCR_RMII_ENABLE;
> +
>  	/* Hit the HW */

Is there a way to probe the presence of 64-bit addressing from
hardware registers? That would be nicer than triggering it from
the compatible string, given that any future SoC is likely
also 64-bit.

      Arnd
Jacky Chou Nov. 18, 2024, 7:51 a.m. UTC | #2
Hi Arnd,

Thank you for your reply.

> > @@ -351,6 +352,10 @@ static void ftgmac100_start_hw(struct ftgmac100
> *priv)
> >  	if (priv->netdev->features & NETIF_F_HW_VLAN_CTAG_RX)
> >  		maccr |= FTGMAC100_MACCR_RM_VLAN;
> >
> > +	if (of_device_is_compatible(priv->dev->of_node,
> > +"aspeed,ast2700-mac")
> > &&
> > +	    phydev && phydev->interface == PHY_INTERFACE_MODE_RMII)
> > +		maccr |= FTGMAC100_MACCR_RMII_ENABLE;
> > +
> >  	/* Hit the HW */
> 
> Is there a way to probe the presence of 64-bit addressing from hardware
> registers? That would be nicer than triggering it from the compatible string,
> given that any future SoC is likely also 64-bit.

There is no register indicated about 64-bit address support in the ftgmac100 
of Aspeed 7th generation. Therefore, we use the compatible to configure pin strap 
and DMA mask.

Thanks,
Jacky
Arnd Bergmann Nov. 18, 2024, 9:04 a.m. UTC | #3
On Mon, Nov 18, 2024, at 08:51, Jacky Chou wrote:
 
>> Is there a way to probe the presence of 64-bit addressing from hardware
>> registers? That would be nicer than triggering it from the compatible string,
>> given that any future SoC is likely also 64-bit.

I just realized I replied to the wrong email, I meant to send
my question as a reply to patch 4/7. The patch for the pin strap
looks fine.

> There is no register indicated about 64-bit address support in the 
> ftgmac100 of Aspeed 7th generation. Therefore, we use the compatible
> to configure pin strap and DMA mask.

Later in the series you just unconditionally write the 64-bit
address, so it appears that the ftgmac100 can actually do
64-bti addressing all along, and this doesn't have to be
conditional at all, the call to dma_set_mask_and_coherent()
only tells the kernel that the device can do it, which should
work on all of them. Since the other devices won't have a
larger "dma-ranges" configuration in DT, and no RAM above
32-bit addressing, it should have no effect.

Just make that part in patch 5 unconditional.

     Arnd
Jacky Chou Nov. 18, 2024, 9:36 a.m. UTC | #4
> >> Is there a way to probe the presence of 64-bit addressing from
> >> hardware registers? That would be nicer than triggering it from the
> >> compatible string, given that any future SoC is likely also 64-bit.
> 
> I just realized I replied to the wrong email, I meant to send my question as a
> reply to patch 4/7. The patch for the pin strap looks fine.
> 
> > There is no register indicated about 64-bit address support in the
> > ftgmac100 of Aspeed 7th generation. Therefore, we use the compatible
> > to configure pin strap and DMA mask.
> 
> Later in the series you just unconditionally write the 64-bit address, so it
> appears that the ftgmac100 can actually do 64-bti addressing all along, and
> this doesn't have to be conditional at all, the call to
> dma_set_mask_and_coherent() only tells the kernel that the device can do it,
> which should work on all of them. Since the other devices won't have a larger
> "dma-ranges" configuration in DT, and no RAM above 32-bit addressing, it
> should have no effect.
> 
> Just make that part in patch 5 unconditional.

Agree, I got your point.
We tried to add less codes to compatible the older generations.
I will adjust it to normal probe procedure in next version, not use compatible to call 
dma_set_mask_and_coherent().
Thank you for your kind reminder.

Thanks,
Jacky
diff mbox series

Patch

diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
index 5b277285666a..801fbc89ab09 100644
--- a/drivers/net/ethernet/faraday/ftgmac100.c
+++ b/drivers/net/ethernet/faraday/ftgmac100.c
@@ -323,6 +323,7 @@  static void ftgmac100_init_hw(struct ftgmac100 *priv)
 static void ftgmac100_start_hw(struct ftgmac100 *priv)
 {
 	u32 maccr = ioread32(priv->base + FTGMAC100_OFFSET_MACCR);
+	struct phy_device *phydev = priv->netdev->phydev;
 
 	/* Keep the original GMAC and FAST bits */
 	maccr &= (FTGMAC100_MACCR_FAST_MODE | FTGMAC100_MACCR_GIGA_MODE);
@@ -351,6 +352,10 @@  static void ftgmac100_start_hw(struct ftgmac100 *priv)
 	if (priv->netdev->features & NETIF_F_HW_VLAN_CTAG_RX)
 		maccr |= FTGMAC100_MACCR_RM_VLAN;
 
+	if (of_device_is_compatible(priv->dev->of_node, "aspeed,ast2700-mac") &&
+	    phydev && phydev->interface == PHY_INTERFACE_MODE_RMII)
+		maccr |= FTGMAC100_MACCR_RMII_ENABLE;
+
 	/* Hit the HW */
 	iowrite32(maccr, priv->base + FTGMAC100_OFFSET_MACCR);
 }
diff --git a/drivers/net/ethernet/faraday/ftgmac100.h b/drivers/net/ethernet/faraday/ftgmac100.h
index 4968f6f0bdbc..c87aa7d7f14c 100644
--- a/drivers/net/ethernet/faraday/ftgmac100.h
+++ b/drivers/net/ethernet/faraday/ftgmac100.h
@@ -166,6 +166,7 @@ 
 #define FTGMAC100_MACCR_RX_MULTIPKT	(1 << 16)
 #define FTGMAC100_MACCR_RX_BROADPKT	(1 << 17)
 #define FTGMAC100_MACCR_DISCARD_CRCERR	(1 << 18)
+#define FTGMAC100_MACCR_RMII_ENABLE	(1 << 20) /* defined in ast2700 */
 #define FTGMAC100_MACCR_FAST_MODE	(1 << 19)
 #define FTGMAC100_MACCR_SW_RST		(1 << 31)