mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-11 12:28:41 +08:00
net: airoha: configure hw mac address according to the port id
GDM1 port on EN7581 SoC is connected to the lan dsa switch. GDM{2,3,4} can be used as wan port connected to an external phy module. Configure hw mac address registers according to the port id. Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Link: https://patch.msgid.link/20240821-airoha-eth-wan-mac-addr-v2-1-8706d0cd6cd5@kernel.org Signed-off-by: Paolo Abeni <pabeni@redhat.com>
This commit is contained in:
parent
bcc3773c49
commit
812a2751e8
@ -67,9 +67,11 @@
|
||||
#define FE_RST_GDM3_MBI_ARB_MASK BIT(2)
|
||||
#define FE_RST_CORE_MASK BIT(0)
|
||||
|
||||
#define REG_FE_WAN_MAC_H 0x0030
|
||||
#define REG_FE_LAN_MAC_H 0x0040
|
||||
#define REG_FE_LAN_MAC_LMIN 0x0044
|
||||
#define REG_FE_LAN_MAC_LMAX 0x0048
|
||||
|
||||
#define REG_FE_MAC_LMIN(_n) ((_n) + 0x04)
|
||||
#define REG_FE_MAC_LMAX(_n) ((_n) + 0x08)
|
||||
|
||||
#define REG_FE_CDM1_OQ_MAP0 0x0050
|
||||
#define REG_FE_CDM1_OQ_MAP1 0x0054
|
||||
@ -900,16 +902,28 @@ static void airoha_qdma_irq_disable(struct airoha_qdma *qdma, int index,
|
||||
airoha_qdma_set_irqmask(qdma, index, mask, 0);
|
||||
}
|
||||
|
||||
static void airoha_set_macaddr(struct airoha_eth *eth, const u8 *addr)
|
||||
static bool airhoa_is_lan_gdm_port(struct airoha_gdm_port *port)
|
||||
{
|
||||
u32 val;
|
||||
/* GDM1 port on EN7581 SoC is connected to the lan dsa switch.
|
||||
* GDM{2,3,4} can be used as wan port connected to an external
|
||||
* phy module.
|
||||
*/
|
||||
return port->id == 1;
|
||||
}
|
||||
|
||||
static void airoha_set_macaddr(struct airoha_gdm_port *port, const u8 *addr)
|
||||
{
|
||||
struct airoha_eth *eth = port->qdma->eth;
|
||||
u32 val, reg;
|
||||
|
||||
reg = airhoa_is_lan_gdm_port(port) ? REG_FE_LAN_MAC_H
|
||||
: REG_FE_WAN_MAC_H;
|
||||
val = (addr[0] << 16) | (addr[1] << 8) | addr[2];
|
||||
airoha_fe_wr(eth, REG_FE_LAN_MAC_H, val);
|
||||
airoha_fe_wr(eth, reg, val);
|
||||
|
||||
val = (addr[3] << 16) | (addr[4] << 8) | addr[5];
|
||||
airoha_fe_wr(eth, REG_FE_LAN_MAC_LMIN, val);
|
||||
airoha_fe_wr(eth, REG_FE_LAN_MAC_LMAX, val);
|
||||
airoha_fe_wr(eth, REG_FE_MAC_LMIN(reg), val);
|
||||
airoha_fe_wr(eth, REG_FE_MAC_LMAX(reg), val);
|
||||
}
|
||||
|
||||
static void airoha_set_gdm_port_fwd_cfg(struct airoha_eth *eth, u32 addr,
|
||||
@ -2340,7 +2354,7 @@ static int airoha_dev_set_macaddr(struct net_device *dev, void *p)
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
airoha_set_macaddr(port->qdma->eth, dev->dev_addr);
|
||||
airoha_set_macaddr(port, dev->dev_addr);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -2349,7 +2363,7 @@ static int airoha_dev_init(struct net_device *dev)
|
||||
{
|
||||
struct airoha_gdm_port *port = netdev_priv(dev);
|
||||
|
||||
airoha_set_macaddr(port->qdma->eth, dev->dev_addr);
|
||||
airoha_set_macaddr(port, dev->dev_addr);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user