diff options
author | Arun Ramadoss <arun.ramadoss@microchip.com> | 2022-07-24 14:58:17 +0530 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2022-07-27 09:39:17 +0100 |
commit | 8560664fd32aa055b3c128337356e32e8fc25b5a (patch) | |
tree | 72b84dcb58503632a3ae514b040a53133f00216e /drivers/net/dsa/microchip/ksz_common.h | |
parent | net: dsa: microchip: add common ksz port xmii speed selection function (diff) | |
download | linux-dev-8560664fd32aa055b3c128337356e32e8fc25b5a.tar.xz linux-dev-8560664fd32aa055b3c128337356e32e8fc25b5a.zip |
net: dsa: microchip: add common duplex and flow control function
This patch add common function for configuring the Full/Half duplex and
transmit/receive flow control. KSZ8795 uses the Global control register
4 for configuring the duplex and flow control, whereas all other KSZ9477
based switch uses the xMII Control 0 register.
Signed-off-by: Arun Ramadoss <arun.ramadoss@microchip.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/dsa/microchip/ksz_common.h')
-rw-r--r-- | drivers/net/dsa/microchip/ksz_common.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h index d87dc88d9f20..3577fa2c5eab 100644 --- a/drivers/net/dsa/microchip/ksz_common.h +++ b/drivers/net/dsa/microchip/ksz_common.h @@ -197,6 +197,8 @@ enum ksz_masks { DYNAMIC_MAC_TABLE_TIMESTAMP, ALU_STAT_WRITE, ALU_STAT_READ, + P_MII_TX_FLOW_CTRL, + P_MII_RX_FLOW_CTRL, }; enum ksz_shifts { @@ -215,6 +217,8 @@ enum ksz_shifts { enum ksz_xmii_ctrl0 { P_MII_100MBIT, P_MII_10MBIT, + P_MII_FULL_DUPLEX, + P_MII_HALF_DUPLEX, }; enum ksz_xmii_ctrl1 { @@ -310,6 +314,8 @@ void ksz_port_stp_state_set(struct dsa_switch *ds, int port, u8 state); bool ksz_get_gbit(struct ksz_device *dev, int port); void ksz_set_gbit(struct ksz_device *dev, int port, bool gbit); void ksz_port_set_xmii_speed(struct ksz_device *dev, int port, int speed); +void ksz_duplex_flowctrl(struct ksz_device *dev, int port, int duplex, + bool tx_pause, bool rx_pause); extern const struct ksz_chip_data ksz_switch_chips[]; /* Common register access functions */ @@ -416,6 +422,14 @@ static inline void ksz_pwrite32(struct ksz_device *dev, int port, int offset, ksz_write32(dev, dev->dev_ops->get_port_addr(port, offset), data); } +static inline void ksz_prmw8(struct ksz_device *dev, int port, int offset, + u8 mask, u8 val) +{ + regmap_update_bits(dev->regmap[0], + dev->dev_ops->get_port_addr(port, offset), + mask, val); +} + static inline void ksz_regmap_lock(void *__mtx) { struct mutex *mtx = __mtx; @@ -474,6 +488,7 @@ static inline int is_lan937x(struct ksz_device *dev) #define SW_START 0x01 /* xMII configuration */ +#define P_MII_DUPLEX_M BIT(6) #define P_MII_100MBIT_M BIT(4) #define P_GMII_1GBIT_M BIT(6) |