sh_eth: get rid of the dedicated regiseter mapping for RZ/A1 (R7S72100)
Subsystems (3)
v2 cover sh_eth: get rid of the dedicated regiseter mapping for RZ/A1 (R7S72100)
Hello!
Here's a set of 5 patches against DaveM's 'net-next.git' repo.
I changed my mind about the RZ/A1 SoC needing its own register map -- now that we don't depend on the register map array in order to determine whether a given register exists any more, we can add a new flag to determine if the GECMR exists (this register is present only on true GEther chips, not RZ/A1). We also need to add the sh_eth_cpu_data::* flag checks where they were missing so far: in the ethtool API for the register dump.
[1/5] sh_eth: check sh_eth_cpu_data::no_tx_cntrs when dumping registers [2/5] sh_eth: check sh_eth_cpu_data::cexcr when dumping registers [3/5] sh_eth: check sh_eth_cpu_data::no_xdfar when dumping registers [4/5] sh_eth: add sh_eth_cpu_data::gecmr flag
[5/5] sh_eth: use Gigabit register map for R7S72100
MBR, Sergei
PATCH v2 1/5 sh_eth: check sh_eth_cpu_data::no_tx_cntrs when dumping registers
When adding the sh_eth_cpu_data::no_tx_cntrs flag I forgot to add the flag check to __sh_eth_get_regs(), causing the non-existing TX counter registers to be considered for dumping on the R7S72100 SoC (the register offset sanity check has the final say here)...
---
Changes in version 2:
- added Chris' tag.
drivers/net/ethernet/renesas/sh_eth.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/net/ethernet/renesas/sh_eth.c +6 -4
@@ -2184,10 +2184,12 @@ static size_t __sh_eth_get_regs(struct nadd_reg (BCULR );add_reg (MAHR );add_reg (MALR ); -add_reg (TROCR ); -add_reg (CDCR ); -add_reg (LCCR ); -add_reg (CNDCR ); +if (!cd->no_tx_cntrs) { +add_reg (TROCR ); +add_reg (CDCR ); +add_reg (LCCR ); +add_reg (CNDCR ); + }add_reg (CEFCR );add_reg (FRECR );add_reg (TSFRCR );
PATCH v2 2/5 sh_eth: check sh_eth_cpu_data::cexcr when dumping registers
In reply to Sergei ShtylyovWhen adding the sh_eth_cpu_data::cexcr flag I forgot to add the flag check to __sh_eth_get_regs(), causing the non-existing RX packet counter registers to be considered for dumping on the R7S72100 SoC (the register offset sanity check has the final say here)...
---
Changes in version 2:
- added Chris' tag.
drivers/net/ethernet/renesas/sh_eth.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/renesas/sh_eth.c +4 -2
@@ -2194,8 +2194,10 @@ static size_t __sh_eth_get_regs(struct nadd_reg (FRECR );add_reg (TSFRCR );add_reg (TLFRCR ); -add_reg (CERCR ); -add_reg (CEECR ); +if (cd->cexcr) { +add_reg (CERCR ); +add_reg (CEECR ); + }add_reg (MAFCR );if (cd->rtrate)add_reg (RTRATE );
PATCH v2 3/5 sh_eth: check sh_eth_cpu_data::no_xdfar when dumping registers
In reply to Sergei ShtylyovWhen adding the sh_eth_cpu_data::no_xdfar flag I forgot to add the flag check to __sh_eth_get_regs(), causing the non-existing RDFAR/TDFAR to be considered for dumping on the R-Car gen1/2 SoCs (the register offset check has the final say here)...
---
Changes in version 2:
- added Chris' tag.
drivers/net/ethernet/renesas/sh_eth.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/renesas/sh_eth.c +4 -2
@@ -2140,11 +2140,13 @@ static size_t __sh_eth_get_regs(struct nadd_reg (EESR );add_reg (EESIPR );add_reg (TDLAR ); -add_reg (TDFAR ); +if (!cd->no_xdfar) +add_reg (TDFAR );add_reg (TDFXR );add_reg (TDFFR );add_reg (RDLAR ); -add_reg (RDFAR ); +if (!cd->no_xdfar) +add_reg (RDFAR );add_reg (RDFXR );add_reg (RDFFR );add_reg (TRSCER );
PATCH v2 4/5 sh_eth: add sh_eth_cpu_data::gecmr flag
In reply to Sergei ShtylyovNot all Ether controllers having the Gigabit register layout have GECMR -- RZ/A1 (AKA R7S72100) actually has the same layout but no Gigabit speed support and hence no GECMR. In the past, the new register map table was added for this SoC, now I think we should have used the existing Gigabit table with the differences (such as GECMR) covered by the mere flags in the 'struct sh_eth_cpu_data'. Add such flag for GECMR -- and then we can get rid of the R7S72100 specific layout in the next patch...
---
Changes in version 2:
- added Chris' tag.
drivers/net/ethernet/renesas/sh_eth.c | 14 +++++++++++++- drivers/net/ethernet/renesas/sh_eth.h | 1 + 2 files changed, 14 insertions(+), 1 deletion(-)
drivers/net/ethernet/renesas/sh_eth.c +13 -1
@@ -569,6 +569,9 @@ static void sh_eth_set_rate_gether(struc {struct sh_eth_private *mdp =netdev_priv (ndev); +if (WARN_ON (!mdp->cd->gecmr)) +return ; +switch (mdp->speed) {case 10 :/* 10BASE */ sh_eth_write (ndev,GECMR_10 ,GECMR );
@@ -663,6 +666,7 @@ static struct sh_eth_cpu_data r8a7740_da .apr = 1, .mpr = 1, .tpauser = 1, + .gecmr = 1, .bculr = 1, .hw_swap = 1, .rpadir = 1,
@@ -788,6 +792,7 @@ static struct sh_eth_cpu_data r8a77980_d .apr = 1, .mpr = 1, .tpauser = 1, + .gecmr = 1, .bculr = 1, .hw_swap = 1, .nbst = 1,
@@ -957,6 +962,9 @@ static void sh_eth_set_rate_giga(struct {struct sh_eth_private *mdp =netdev_priv (ndev); +if (WARN_ON (!mdp->cd->gecmr)) +return ; +switch (mdp->speed) {case 10 :/* 10BASE */ sh_eth_write (ndev,0x00000000 ,GECMR );
@@ -1002,6 +1010,7 @@ static struct sh_eth_cpu_data sh7757_dat .apr = 1, .mpr = 1, .tpauser = 1, + .gecmr = 1, .bculr = 1, .hw_swap = 1, .rpadir = 1,
@@ -1042,6 +1051,7 @@ static struct sh_eth_cpu_data sh7734_dat .apr = 1, .mpr = 1, .tpauser = 1, + .gecmr = 1, .bculr = 1, .hw_swap = 1, .no_trimd = 1,
@@ -1083,6 +1093,7 @@ static struct sh_eth_cpu_data sh7763_dat .apr = 1, .mpr = 1, .tpauser = 1, + .gecmr = 1, .bculr = 1, .hw_swap = 1, .no_trimd = 1,
@@ -2181,7 +2192,8 @@ static size_t __sh_eth_get_regs(struct nif (cd->tpauser)add_reg (TPAUSER );add_reg (TPAUSECR ); -add_reg (GECMR ); +if (cd->gecmr) +add_reg (GECMR );if (cd->bculr)add_reg (BCULR );add_reg (MAHR );
drivers/net/ethernet/renesas/sh_eth.h +1 -0
@@ -490,6 +490,7 @@ struct sh_eth_cpu_data { unsigned apr:1; /* EtherC has APR */ unsigned mpr:1; /* EtherC has MPR */ unsigned tpauser:1; /* EtherC has TPAUSER */ + unsigned gecmr:1; /* EtherC has GECMR */ unsigned bculr:1; /* EtherC has BCULR */ unsigned tsu:1; /* EtherC has TSU */ unsigned hw_swap:1; /* E-DMAC has DE bit in EDMR */
PATCH v2 5/5 sh_eth: use Gigabit register map for R7S72100
In reply to Sergei ShtylyovThe register maps for the Gigabit controllers and the Ether one used on RZ/A1 (AKA R7S72100) are identical except for GECMR which is only present on the true GEther controllers. We no longer use the register map arrays to determine if a given register exists, and have added the GECMR flag to the 'struct sh_eth_cpu_data' in the previous patch, so we're ready to drop the R7S72100 specific register map -- this saves 216 bytes of object code (ARM gcc 4.8.5).
---
Changes in version 2:
- fixed the arch name in the description;
- added Chris' tag.
drivers/net/ethernet/renesas/sh_eth.c | 68 ---------------------------------- drivers/net/ethernet/renesas/sh_eth.h | 1 2 files changed, 1 insertion(+), 68 deletions(-)
drivers/net/ethernet/renesas/sh_eth.c +1 -67
@@ -142,69 +142,6 @@ static const u16 sh_eth_offset_gigabit[S [FWALCR1] = 0x00b4, }; -static const u16 sh_eth_offset_fast_rz[SH_ETH_MAX_REGISTER_OFFSET ] = { -SH_ETH_OFFSET_DEFAULTS , - - [EDSR ] =0x0000 , - [EDMR ] =0x0400 , - [EDTRR ] =0x0408 , - [EDRRR ] =0x0410 , - [EESR ] =0x0428 , - [EESIPR ] =0x0430 , - [TDLAR ] =0x0010 , - [TDFAR ] =0x0014 , - [TDFXR ] =0x0018 , - [TDFFR ] =0x001c , - [RDLAR ] =0x0030 , - [RDFAR ] =0x0034 , - [RDFXR ] =0x0038 , - [RDFFR ] =0x003c , - [TRSCER ] =0x0438 , - [RMFCR ] =0x0440 , - [TFTR ] =0x0448 , - [FDR ] =0x0450 , - [RMCR ] =0x0458 , - [RPADIR ] =0x0460 , - [FCFTR ] =0x0468 , - [CSMR ] =0x04E4 , - - [ECMR ] =0x0500 , - [RFLR ] =0x0508 , - [ECSR ] =0x0510 , - [ECSIPR ] =0x0518 , - [PIR ] =0x0520 , - [APR ] =0x0554 , - [MPR ] =0x0558 , - [PFTCR ] =0x055c , - [PFRCR ] =0x0560 , - [TPAUSER ] =0x0564 , - [MAHR ] =0x05c0 , - [MALR ] =0x05c8 , - [CEFCR ] =0x0740 , - [FRECR ] =0x0748 , - [TSFRCR ] =0x0750 , - [TLFRCR ] =0x0758 , - [RFCR ] =0x0760 , - [MAFCR ] =0x0778 , - - [ARSTR ] =0x0000 , - [TSU_CTRST ] =0x0004 , - [TSU_FWSLC ] =0x0038 , - [TSU_VTAG0 ] =0x0058 , - [TSU_ADSBSY ] =0x0060 , - [TSU_TEN ] =0x0064 , - [TSU_POST1 ] =0x0070 , - [TSU_POST2 ] =0x0074 , - [TSU_POST3 ] =0x0078 , - [TSU_POST4 ] =0x007c , - [TSU_ADRH0 ] =0x0100 , - - [TXNLCR0 ] =0x0080 , - [TXALCR0 ] =0x0084 , - [RXNLCR0 ] =0x0088 , - [RXALCR0 ] =0x008C , -}; -static const u16 sh_eth_offset_fast_rcar[SH_ETH_MAX_REGISTER_OFFSET ] = {SH_ETH_OFFSET_DEFAULTS ,
@@ -593,7 +530,7 @@ static struct sh_eth_cpu_data r7s72100_d .chip_reset = sh_eth_chip_reset, .set_duplex = sh_eth_set_duplex, - .register_type = SH_ETH_REG_FAST_RZ, + .register_type = SH_ETH_REG_GIGABIT, .edtrr_trns = EDTRR_TRNS_GETHER, .ecsr_value = ECSR_ICD,
@@ -3139,9 +3076,6 @@ static const u16 *sh_eth_get_register_ofcase SH_ETH_REG_GIGABIT : reg_offset = sh_eth_offset_gigabit;break ; -case SH_ETH_REG_FAST_RZ : - reg_offset = sh_eth_offset_fast_rz; -break ;case SH_ETH_REG_FAST_RCAR : reg_offset = sh_eth_offset_fast_rcar;break ;
drivers/net/ethernet/renesas/sh_eth.h +0 -1
@@ -145,7 +145,6 @@ enum {enum {SH_ETH_REG_GIGABIT , -SH_ETH_REG_FAST_RZ ,SH_ETH_REG_FAST_RCAR ,SH_ETH_REG_FAST_SH4 ,SH_ETH_REG_FAST_SH3_SH2
David Miller
maintainerFrom: Sergei Shtylyov <[email protected]>
Date: Sat, 15 Feb 2020 23:06:27 +0300
Quoted 9 lines
Here's a set of 5 patches against DaveM's 'net-next.git' repo.
I changed my mind about the RZ/A1 SoC needing its own register map -- now that we don't depend on the register map array in order to determine whether a given register exists any more, we can add a new flag to determine if the GECMR exists (this register is present only on true GEther chips, not RZ/A1). We also need to add the sh_eth_cpu_data::* flag checks where they were missing so far: in the ethtool API for the register dump.
Series applied, thanks Sergei.