Revert "unicode: Don't special case ignorable code points"
[linux.git] / drivers / net / dsa / realtek / realtek.h
bloba1b2e0b529d54831dd5954946cd141d5b2679977
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /* Realtek SMI interface driver defines
4 * Copyright (C) 2017 Linus Walleij <linus.walleij@linaro.org>
5 * Copyright (C) 2009-2010 Gabor Juhos <juhosg@openwrt.org>
6 */
8 #ifndef _REALTEK_H
9 #define _REALTEK_H
11 #include <linux/phy.h>
12 #include <linux/platform_device.h>
13 #include <linux/gpio/consumer.h>
14 #include <net/dsa.h>
15 #include <linux/reset.h>
17 #define REALTEK_HW_STOP_DELAY 25 /* msecs */
18 #define REALTEK_HW_START_DELAY 100 /* msecs */
20 struct phylink_mac_ops;
21 struct realtek_ops;
22 struct dentry;
23 struct inode;
24 struct file;
26 struct rtl8366_mib_counter {
27 unsigned int base;
28 unsigned int offset;
29 unsigned int length;
30 const char *name;
34 * struct rtl8366_vlan_mc - Virtual LAN member configuration
36 struct rtl8366_vlan_mc {
37 u16 vid;
38 u16 untag;
39 u16 member;
40 u8 fid;
41 u8 priority;
44 struct rtl8366_vlan_4k {
45 u16 vid;
46 u16 untag;
47 u16 member;
48 u8 fid;
51 struct realtek_priv {
52 struct device *dev;
53 struct reset_control *reset_ctl;
54 struct gpio_desc *reset;
55 struct gpio_desc *mdc;
56 struct gpio_desc *mdio;
57 struct regmap *map;
58 struct regmap *map_nolock;
59 struct mutex map_lock;
60 struct mii_bus *user_mii_bus;
61 struct mii_bus *bus;
62 int mdio_addr;
64 const struct realtek_variant *variant;
66 spinlock_t lock; /* Locks around command writes */
67 struct dsa_switch ds;
68 struct irq_domain *irqdomain;
69 bool leds_disabled;
71 unsigned int cpu_port;
72 unsigned int num_ports;
73 unsigned int num_vlan_mc;
74 unsigned int num_mib_counters;
75 struct rtl8366_mib_counter *mib_counters;
77 const struct realtek_ops *ops;
78 int (*write_reg_noack)(void *ctx, u32 addr, u32 data);
80 int vlan_enabled;
81 int vlan4k_enabled;
83 char buf[4096];
84 void *chip_data; /* Per-chip extra variant data */
88 * struct realtek_ops - vtable for the per-SMI-chiptype operations
89 * @detect: detects the chiptype
91 struct realtek_ops {
92 int (*detect)(struct realtek_priv *priv);
93 int (*reset_chip)(struct realtek_priv *priv);
94 int (*setup)(struct realtek_priv *priv);
95 int (*get_mib_counter)(struct realtek_priv *priv,
96 int port,
97 struct rtl8366_mib_counter *mib,
98 u64 *mibvalue);
99 int (*get_vlan_mc)(struct realtek_priv *priv, u32 index,
100 struct rtl8366_vlan_mc *vlanmc);
101 int (*set_vlan_mc)(struct realtek_priv *priv, u32 index,
102 const struct rtl8366_vlan_mc *vlanmc);
103 int (*get_vlan_4k)(struct realtek_priv *priv, u32 vid,
104 struct rtl8366_vlan_4k *vlan4k);
105 int (*set_vlan_4k)(struct realtek_priv *priv,
106 const struct rtl8366_vlan_4k *vlan4k);
107 int (*get_mc_index)(struct realtek_priv *priv, int port, int *val);
108 int (*set_mc_index)(struct realtek_priv *priv, int port, int index);
109 bool (*is_vlan_valid)(struct realtek_priv *priv, unsigned int vlan);
110 int (*enable_vlan)(struct realtek_priv *priv, bool enable);
111 int (*enable_vlan4k)(struct realtek_priv *priv, bool enable);
112 int (*enable_port)(struct realtek_priv *priv, int port, bool enable);
113 int (*phy_read)(struct realtek_priv *priv, int phy, int regnum);
114 int (*phy_write)(struct realtek_priv *priv, int phy, int regnum,
115 u16 val);
118 struct realtek_variant {
119 const struct dsa_switch_ops *ds_ops;
120 const struct realtek_ops *ops;
121 const struct phylink_mac_ops *phylink_mac_ops;
122 unsigned int clk_delay;
123 u8 cmd_read;
124 u8 cmd_write;
125 size_t chip_data_sz;
128 /* RTL8366 library helpers */
129 int rtl8366_mc_is_used(struct realtek_priv *priv, int mc_index, int *used);
130 int rtl8366_set_vlan(struct realtek_priv *priv, int vid, u32 member,
131 u32 untag, u32 fid);
132 int rtl8366_set_pvid(struct realtek_priv *priv, unsigned int port,
133 unsigned int vid);
134 int rtl8366_enable_vlan4k(struct realtek_priv *priv, bool enable);
135 int rtl8366_enable_vlan(struct realtek_priv *priv, bool enable);
136 int rtl8366_reset_vlan(struct realtek_priv *priv);
137 int rtl8366_vlan_add(struct dsa_switch *ds, int port,
138 const struct switchdev_obj_port_vlan *vlan,
139 struct netlink_ext_ack *extack);
140 int rtl8366_vlan_del(struct dsa_switch *ds, int port,
141 const struct switchdev_obj_port_vlan *vlan);
142 void rtl8366_get_strings(struct dsa_switch *ds, int port, u32 stringset,
143 uint8_t *data);
144 int rtl8366_get_sset_count(struct dsa_switch *ds, int port, int sset);
145 void rtl8366_get_ethtool_stats(struct dsa_switch *ds, int port, uint64_t *data);
147 extern const struct realtek_variant rtl8366rb_variant;
148 extern const struct realtek_variant rtl8365mb_variant;
150 #endif /* _REALTEK_H */