Loading...
1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * Microchip KSZ8XXX series register access
4 *
5 * Copyright (C) 2020 Pengutronix, Michael Grzeschik <kernel@pengutronix.de>
6 */
7
8#ifndef __KSZ8XXX_H
9#define __KSZ8XXX_H
10
11#include <linux/types.h>
12#include <net/dsa.h>
13#include "ksz_common.h"
14
15int ksz8_setup(struct dsa_switch *ds);
16u32 ksz8_get_port_addr(int port, int offset);
17void ksz8_cfg_port_member(struct ksz_device *dev, int port, u8 member);
18void ksz8_flush_dyn_mac_table(struct ksz_device *dev, int port);
19void ksz8_port_setup(struct ksz_device *dev, int port, bool cpu_port);
20int ksz8_r_phy(struct ksz_device *dev, u16 phy, u16 reg, u16 *val);
21int ksz8_w_phy(struct ksz_device *dev, u16 phy, u16 reg, u16 val);
22int ksz8_r_dyn_mac_table(struct ksz_device *dev, u16 addr, u8 *mac_addr,
23 u8 *fid, u8 *src_port, u8 *timestamp, u16 *entries);
24void ksz8_r_mib_cnt(struct ksz_device *dev, int port, u16 addr, u64 *cnt);
25void ksz8_r_mib_pkt(struct ksz_device *dev, int port, u16 addr,
26 u64 *dropped, u64 *cnt);
27void ksz8_freeze_mib(struct ksz_device *dev, int port, bool freeze);
28void ksz8_port_init_cnt(struct ksz_device *dev, int port);
29int ksz8_fdb_dump(struct ksz_device *dev, int port,
30 dsa_fdb_dump_cb_t *cb, void *data);
31int ksz8_fdb_add(struct ksz_device *dev, int port, const unsigned char *addr,
32 u16 vid, struct dsa_db db);
33int ksz8_fdb_del(struct ksz_device *dev, int port, const unsigned char *addr,
34 u16 vid, struct dsa_db db);
35int ksz8_mdb_add(struct ksz_device *dev, int port,
36 const struct switchdev_obj_port_mdb *mdb, struct dsa_db db);
37int ksz8_mdb_del(struct ksz_device *dev, int port,
38 const struct switchdev_obj_port_mdb *mdb, struct dsa_db db);
39int ksz8_port_vlan_filtering(struct ksz_device *dev, int port, bool flag,
40 struct netlink_ext_ack *extack);
41int ksz8_port_vlan_add(struct ksz_device *dev, int port,
42 const struct switchdev_obj_port_vlan *vlan,
43 struct netlink_ext_ack *extack);
44int ksz8_port_vlan_del(struct ksz_device *dev, int port,
45 const struct switchdev_obj_port_vlan *vlan);
46int ksz8_port_mirror_add(struct ksz_device *dev, int port,
47 struct dsa_mall_mirror_tc_entry *mirror,
48 bool ingress, struct netlink_ext_ack *extack);
49void ksz8_port_mirror_del(struct ksz_device *dev, int port,
50 struct dsa_mall_mirror_tc_entry *mirror);
51void ksz8_get_caps(struct ksz_device *dev, int port,
52 struct phylink_config *config);
53void ksz8_config_cpu_port(struct dsa_switch *ds);
54int ksz8_enable_stp_addr(struct ksz_device *dev);
55int ksz8_reset_switch(struct ksz_device *dev);
56int ksz8_switch_init(struct ksz_device *dev);
57void ksz8_switch_exit(struct ksz_device *dev);
58int ksz8_change_mtu(struct ksz_device *dev, int port, int mtu);
59void ksz8_phylink_mac_link_up(struct ksz_device *dev, int port,
60 unsigned int mode, phy_interface_t interface,
61 struct phy_device *phydev, int speed, int duplex,
62 bool tx_pause, bool rx_pause);
63
64#endif
1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * Microchip KSZ8XXX series register access
4 *
5 * Copyright (C) 2020 Pengutronix, Michael Grzeschik <kernel@pengutronix.de>
6 */
7
8#ifndef __KSZ8XXX_H
9#define __KSZ8XXX_H
10#include <linux/kernel.h>
11
12enum ksz_regs {
13 REG_IND_CTRL_0,
14 REG_IND_DATA_8,
15 REG_IND_DATA_CHECK,
16 REG_IND_DATA_HI,
17 REG_IND_DATA_LO,
18 REG_IND_MIB_CHECK,
19 P_FORCE_CTRL,
20 P_LINK_STATUS,
21 P_LOCAL_CTRL,
22 P_NEG_RESTART_CTRL,
23 P_REMOTE_STATUS,
24 P_SPEED_STATUS,
25 S_TAIL_TAG_CTRL,
26};
27
28enum ksz_masks {
29 PORT_802_1P_REMAPPING,
30 SW_TAIL_TAG_ENABLE,
31 MIB_COUNTER_OVERFLOW,
32 MIB_COUNTER_VALID,
33 VLAN_TABLE_FID,
34 VLAN_TABLE_MEMBERSHIP,
35 VLAN_TABLE_VALID,
36 STATIC_MAC_TABLE_VALID,
37 STATIC_MAC_TABLE_USE_FID,
38 STATIC_MAC_TABLE_FID,
39 STATIC_MAC_TABLE_OVERRIDE,
40 STATIC_MAC_TABLE_FWD_PORTS,
41 DYNAMIC_MAC_TABLE_ENTRIES_H,
42 DYNAMIC_MAC_TABLE_MAC_EMPTY,
43 DYNAMIC_MAC_TABLE_NOT_READY,
44 DYNAMIC_MAC_TABLE_ENTRIES,
45 DYNAMIC_MAC_TABLE_FID,
46 DYNAMIC_MAC_TABLE_SRC_PORT,
47 DYNAMIC_MAC_TABLE_TIMESTAMP,
48};
49
50enum ksz_shifts {
51 VLAN_TABLE_MEMBERSHIP_S,
52 VLAN_TABLE,
53 STATIC_MAC_FWD_PORTS,
54 STATIC_MAC_FID,
55 DYNAMIC_MAC_ENTRIES_H,
56 DYNAMIC_MAC_ENTRIES,
57 DYNAMIC_MAC_FID,
58 DYNAMIC_MAC_TIMESTAMP,
59 DYNAMIC_MAC_SRC_PORT,
60};
61
62struct ksz8 {
63 const u8 *regs;
64 const u32 *masks;
65 const u8 *shifts;
66 void *priv;
67};
68
69#endif