18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci/* Microchip switch driver common header
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * Copyright (C) 2017-2019 Microchip Technology Inc.
58c2ecf20Sopenharmony_ci */
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci#ifndef __KSZ_COMMON_H
88c2ecf20Sopenharmony_ci#define __KSZ_COMMON_H
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci#include <linux/etherdevice.h>
118c2ecf20Sopenharmony_ci#include <linux/kernel.h>
128c2ecf20Sopenharmony_ci#include <linux/mutex.h>
138c2ecf20Sopenharmony_ci#include <linux/phy.h>
148c2ecf20Sopenharmony_ci#include <linux/regmap.h>
158c2ecf20Sopenharmony_ci#include <net/dsa.h>
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_cistruct vlan_table {
188c2ecf20Sopenharmony_ci	u32 table[3];
198c2ecf20Sopenharmony_ci};
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_cistruct ksz_port_mib {
228c2ecf20Sopenharmony_ci	struct mutex cnt_mutex;		/* structure access */
238c2ecf20Sopenharmony_ci	u8 cnt_ptr;
248c2ecf20Sopenharmony_ci	u64 *counters;
258c2ecf20Sopenharmony_ci};
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_cistruct ksz_port {
288c2ecf20Sopenharmony_ci	u16 member;
298c2ecf20Sopenharmony_ci	u16 vid_member;
308c2ecf20Sopenharmony_ci	bool remove_tag;		/* Remove Tag flag set, for ksz8795 only */
318c2ecf20Sopenharmony_ci	int stp_state;
328c2ecf20Sopenharmony_ci	struct phy_device phydev;
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ci	u32 on:1;			/* port is not disabled by hardware */
358c2ecf20Sopenharmony_ci	u32 phy:1;			/* port has a PHY */
368c2ecf20Sopenharmony_ci	u32 fiber:1;			/* port is fiber */
378c2ecf20Sopenharmony_ci	u32 sgmii:1;			/* port is SGMII */
388c2ecf20Sopenharmony_ci	u32 force:1;
398c2ecf20Sopenharmony_ci	u32 read:1;			/* read MIB counters in background */
408c2ecf20Sopenharmony_ci	u32 freeze:1;			/* MIB counter freeze is enabled */
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_ci	struct ksz_port_mib mib;
438c2ecf20Sopenharmony_ci	phy_interface_t interface;
448c2ecf20Sopenharmony_ci};
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_cistruct ksz_device {
478c2ecf20Sopenharmony_ci	struct dsa_switch *ds;
488c2ecf20Sopenharmony_ci	struct ksz_platform_data *pdata;
498c2ecf20Sopenharmony_ci	const char *name;
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_ci	struct mutex dev_mutex;		/* device access */
528c2ecf20Sopenharmony_ci	struct mutex regmap_mutex;	/* regmap access */
538c2ecf20Sopenharmony_ci	struct mutex alu_mutex;		/* ALU access */
548c2ecf20Sopenharmony_ci	struct mutex vlan_mutex;	/* vlan access */
558c2ecf20Sopenharmony_ci	const struct ksz_dev_ops *dev_ops;
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ci	struct device *dev;
588c2ecf20Sopenharmony_ci	struct regmap *regmap[3];
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_ci	void *priv;
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_ci	struct gpio_desc *reset_gpio;	/* Optional reset GPIO */
638c2ecf20Sopenharmony_ci
648c2ecf20Sopenharmony_ci	/* chip specific data */
658c2ecf20Sopenharmony_ci	u32 chip_id;
668c2ecf20Sopenharmony_ci	int num_vlans;
678c2ecf20Sopenharmony_ci	int num_alus;
688c2ecf20Sopenharmony_ci	int num_statics;
698c2ecf20Sopenharmony_ci	int cpu_port;			/* port connected to CPU */
708c2ecf20Sopenharmony_ci	int cpu_ports;			/* port bitmap can be cpu port */
718c2ecf20Sopenharmony_ci	int phy_port_cnt;
728c2ecf20Sopenharmony_ci	int port_cnt;
738c2ecf20Sopenharmony_ci	int reg_mib_cnt;
748c2ecf20Sopenharmony_ci	int mib_cnt;
758c2ecf20Sopenharmony_ci	int mib_port_cnt;
768c2ecf20Sopenharmony_ci	int last_port;			/* ports after that not used */
778c2ecf20Sopenharmony_ci	phy_interface_t compat_interface;
788c2ecf20Sopenharmony_ci	u32 regs_size;
798c2ecf20Sopenharmony_ci	bool phy_errata_9477;
808c2ecf20Sopenharmony_ci	bool synclko_125;
818c2ecf20Sopenharmony_ci
828c2ecf20Sopenharmony_ci	struct vlan_table *vlan_cache;
838c2ecf20Sopenharmony_ci
848c2ecf20Sopenharmony_ci	struct ksz_port *ports;
858c2ecf20Sopenharmony_ci	struct delayed_work mib_read;
868c2ecf20Sopenharmony_ci	unsigned long mib_read_interval;
878c2ecf20Sopenharmony_ci	u16 br_member;
888c2ecf20Sopenharmony_ci	u16 member;
898c2ecf20Sopenharmony_ci	u16 mirror_rx;
908c2ecf20Sopenharmony_ci	u16 mirror_tx;
918c2ecf20Sopenharmony_ci	u32 features;			/* chip specific features */
928c2ecf20Sopenharmony_ci	u32 overrides;			/* chip functions set by user */
938c2ecf20Sopenharmony_ci	u16 host_mask;
948c2ecf20Sopenharmony_ci	u16 port_mask;
958c2ecf20Sopenharmony_ci};
968c2ecf20Sopenharmony_ci
978c2ecf20Sopenharmony_cistruct alu_struct {
988c2ecf20Sopenharmony_ci	/* entry 1 */
998c2ecf20Sopenharmony_ci	u8	is_static:1;
1008c2ecf20Sopenharmony_ci	u8	is_src_filter:1;
1018c2ecf20Sopenharmony_ci	u8	is_dst_filter:1;
1028c2ecf20Sopenharmony_ci	u8	prio_age:3;
1038c2ecf20Sopenharmony_ci	u32	_reserv_0_1:23;
1048c2ecf20Sopenharmony_ci	u8	mstp:3;
1058c2ecf20Sopenharmony_ci	/* entry 2 */
1068c2ecf20Sopenharmony_ci	u8	is_override:1;
1078c2ecf20Sopenharmony_ci	u8	is_use_fid:1;
1088c2ecf20Sopenharmony_ci	u32	_reserv_1_1:23;
1098c2ecf20Sopenharmony_ci	u8	port_forward:7;
1108c2ecf20Sopenharmony_ci	/* entry 3 & 4*/
1118c2ecf20Sopenharmony_ci	u32	_reserv_2_1:9;
1128c2ecf20Sopenharmony_ci	u8	fid:7;
1138c2ecf20Sopenharmony_ci	u8	mac[ETH_ALEN];
1148c2ecf20Sopenharmony_ci};
1158c2ecf20Sopenharmony_ci
1168c2ecf20Sopenharmony_cistruct ksz_dev_ops {
1178c2ecf20Sopenharmony_ci	u32 (*get_port_addr)(int port, int offset);
1188c2ecf20Sopenharmony_ci	void (*cfg_port_member)(struct ksz_device *dev, int port, u8 member);
1198c2ecf20Sopenharmony_ci	void (*flush_dyn_mac_table)(struct ksz_device *dev, int port);
1208c2ecf20Sopenharmony_ci	void (*port_cleanup)(struct ksz_device *dev, int port);
1218c2ecf20Sopenharmony_ci	void (*port_setup)(struct ksz_device *dev, int port, bool cpu_port);
1228c2ecf20Sopenharmony_ci	void (*r_phy)(struct ksz_device *dev, u16 phy, u16 reg, u16 *val);
1238c2ecf20Sopenharmony_ci	void (*w_phy)(struct ksz_device *dev, u16 phy, u16 reg, u16 val);
1248c2ecf20Sopenharmony_ci	int (*r_dyn_mac_table)(struct ksz_device *dev, u16 addr, u8 *mac_addr,
1258c2ecf20Sopenharmony_ci			       u8 *fid, u8 *src_port, u8 *timestamp,
1268c2ecf20Sopenharmony_ci			       u16 *entries);
1278c2ecf20Sopenharmony_ci	int (*r_sta_mac_table)(struct ksz_device *dev, u16 addr,
1288c2ecf20Sopenharmony_ci			       struct alu_struct *alu);
1298c2ecf20Sopenharmony_ci	void (*w_sta_mac_table)(struct ksz_device *dev, u16 addr,
1308c2ecf20Sopenharmony_ci				struct alu_struct *alu);
1318c2ecf20Sopenharmony_ci	void (*r_mib_cnt)(struct ksz_device *dev, int port, u16 addr,
1328c2ecf20Sopenharmony_ci			  u64 *cnt);
1338c2ecf20Sopenharmony_ci	void (*r_mib_pkt)(struct ksz_device *dev, int port, u16 addr,
1348c2ecf20Sopenharmony_ci			  u64 *dropped, u64 *cnt);
1358c2ecf20Sopenharmony_ci	void (*freeze_mib)(struct ksz_device *dev, int port, bool freeze);
1368c2ecf20Sopenharmony_ci	void (*port_init_cnt)(struct ksz_device *dev, int port);
1378c2ecf20Sopenharmony_ci	int (*shutdown)(struct ksz_device *dev);
1388c2ecf20Sopenharmony_ci	int (*detect)(struct ksz_device *dev);
1398c2ecf20Sopenharmony_ci	int (*init)(struct ksz_device *dev);
1408c2ecf20Sopenharmony_ci	void (*exit)(struct ksz_device *dev);
1418c2ecf20Sopenharmony_ci};
1428c2ecf20Sopenharmony_ci
1438c2ecf20Sopenharmony_cistruct ksz_device *ksz_switch_alloc(struct device *base, void *priv);
1448c2ecf20Sopenharmony_ciint ksz_switch_register(struct ksz_device *dev,
1458c2ecf20Sopenharmony_ci			const struct ksz_dev_ops *ops);
1468c2ecf20Sopenharmony_civoid ksz_switch_remove(struct ksz_device *dev);
1478c2ecf20Sopenharmony_ci
1488c2ecf20Sopenharmony_ciint ksz8795_switch_register(struct ksz_device *dev);
1498c2ecf20Sopenharmony_ciint ksz9477_switch_register(struct ksz_device *dev);
1508c2ecf20Sopenharmony_ci
1518c2ecf20Sopenharmony_civoid ksz_update_port_member(struct ksz_device *dev, int port);
1528c2ecf20Sopenharmony_civoid ksz_init_mib_timer(struct ksz_device *dev);
1538c2ecf20Sopenharmony_ci
1548c2ecf20Sopenharmony_ci/* Common DSA access functions */
1558c2ecf20Sopenharmony_ci
1568c2ecf20Sopenharmony_ciint ksz_phy_read16(struct dsa_switch *ds, int addr, int reg);
1578c2ecf20Sopenharmony_ciint ksz_phy_write16(struct dsa_switch *ds, int addr, int reg, u16 val);
1588c2ecf20Sopenharmony_civoid ksz_mac_link_down(struct dsa_switch *ds, int port, unsigned int mode,
1598c2ecf20Sopenharmony_ci		       phy_interface_t interface);
1608c2ecf20Sopenharmony_ciint ksz_sset_count(struct dsa_switch *ds, int port, int sset);
1618c2ecf20Sopenharmony_civoid ksz_get_ethtool_stats(struct dsa_switch *ds, int port, uint64_t *buf);
1628c2ecf20Sopenharmony_ciint ksz_port_bridge_join(struct dsa_switch *ds, int port,
1638c2ecf20Sopenharmony_ci			 struct net_device *br);
1648c2ecf20Sopenharmony_civoid ksz_port_bridge_leave(struct dsa_switch *ds, int port,
1658c2ecf20Sopenharmony_ci			   struct net_device *br);
1668c2ecf20Sopenharmony_civoid ksz_port_fast_age(struct dsa_switch *ds, int port);
1678c2ecf20Sopenharmony_ciint ksz_port_vlan_prepare(struct dsa_switch *ds, int port,
1688c2ecf20Sopenharmony_ci			  const struct switchdev_obj_port_vlan *vlan);
1698c2ecf20Sopenharmony_ciint ksz_port_fdb_dump(struct dsa_switch *ds, int port, dsa_fdb_dump_cb_t *cb,
1708c2ecf20Sopenharmony_ci		      void *data);
1718c2ecf20Sopenharmony_ciint ksz_port_mdb_prepare(struct dsa_switch *ds, int port,
1728c2ecf20Sopenharmony_ci			 const struct switchdev_obj_port_mdb *mdb);
1738c2ecf20Sopenharmony_civoid ksz_port_mdb_add(struct dsa_switch *ds, int port,
1748c2ecf20Sopenharmony_ci		      const struct switchdev_obj_port_mdb *mdb);
1758c2ecf20Sopenharmony_ciint ksz_port_mdb_del(struct dsa_switch *ds, int port,
1768c2ecf20Sopenharmony_ci		     const struct switchdev_obj_port_mdb *mdb);
1778c2ecf20Sopenharmony_ciint ksz_enable_port(struct dsa_switch *ds, int port, struct phy_device *phy);
1788c2ecf20Sopenharmony_ci
1798c2ecf20Sopenharmony_ci/* Common register access functions */
1808c2ecf20Sopenharmony_ci
1818c2ecf20Sopenharmony_cistatic inline int ksz_read8(struct ksz_device *dev, u32 reg, u8 *val)
1828c2ecf20Sopenharmony_ci{
1838c2ecf20Sopenharmony_ci	unsigned int value;
1848c2ecf20Sopenharmony_ci	int ret = regmap_read(dev->regmap[0], reg, &value);
1858c2ecf20Sopenharmony_ci
1868c2ecf20Sopenharmony_ci	*val = value;
1878c2ecf20Sopenharmony_ci	return ret;
1888c2ecf20Sopenharmony_ci}
1898c2ecf20Sopenharmony_ci
1908c2ecf20Sopenharmony_cistatic inline int ksz_read16(struct ksz_device *dev, u32 reg, u16 *val)
1918c2ecf20Sopenharmony_ci{
1928c2ecf20Sopenharmony_ci	unsigned int value;
1938c2ecf20Sopenharmony_ci	int ret = regmap_read(dev->regmap[1], reg, &value);
1948c2ecf20Sopenharmony_ci
1958c2ecf20Sopenharmony_ci	*val = value;
1968c2ecf20Sopenharmony_ci	return ret;
1978c2ecf20Sopenharmony_ci}
1988c2ecf20Sopenharmony_ci
1998c2ecf20Sopenharmony_cistatic inline int ksz_read32(struct ksz_device *dev, u32 reg, u32 *val)
2008c2ecf20Sopenharmony_ci{
2018c2ecf20Sopenharmony_ci	unsigned int value;
2028c2ecf20Sopenharmony_ci	int ret = regmap_read(dev->regmap[2], reg, &value);
2038c2ecf20Sopenharmony_ci
2048c2ecf20Sopenharmony_ci	*val = value;
2058c2ecf20Sopenharmony_ci	return ret;
2068c2ecf20Sopenharmony_ci}
2078c2ecf20Sopenharmony_ci
2088c2ecf20Sopenharmony_cistatic inline int ksz_read64(struct ksz_device *dev, u32 reg, u64 *val)
2098c2ecf20Sopenharmony_ci{
2108c2ecf20Sopenharmony_ci	u32 value[2];
2118c2ecf20Sopenharmony_ci	int ret;
2128c2ecf20Sopenharmony_ci
2138c2ecf20Sopenharmony_ci	ret = regmap_bulk_read(dev->regmap[2], reg, value, 2);
2148c2ecf20Sopenharmony_ci	if (!ret)
2158c2ecf20Sopenharmony_ci		*val = (u64)value[0] << 32 | value[1];
2168c2ecf20Sopenharmony_ci
2178c2ecf20Sopenharmony_ci	return ret;
2188c2ecf20Sopenharmony_ci}
2198c2ecf20Sopenharmony_ci
2208c2ecf20Sopenharmony_cistatic inline int ksz_write8(struct ksz_device *dev, u32 reg, u8 value)
2218c2ecf20Sopenharmony_ci{
2228c2ecf20Sopenharmony_ci	return regmap_write(dev->regmap[0], reg, value);
2238c2ecf20Sopenharmony_ci}
2248c2ecf20Sopenharmony_ci
2258c2ecf20Sopenharmony_cistatic inline int ksz_write16(struct ksz_device *dev, u32 reg, u16 value)
2268c2ecf20Sopenharmony_ci{
2278c2ecf20Sopenharmony_ci	return regmap_write(dev->regmap[1], reg, value);
2288c2ecf20Sopenharmony_ci}
2298c2ecf20Sopenharmony_ci
2308c2ecf20Sopenharmony_cistatic inline int ksz_write32(struct ksz_device *dev, u32 reg, u32 value)
2318c2ecf20Sopenharmony_ci{
2328c2ecf20Sopenharmony_ci	return regmap_write(dev->regmap[2], reg, value);
2338c2ecf20Sopenharmony_ci}
2348c2ecf20Sopenharmony_ci
2358c2ecf20Sopenharmony_cistatic inline int ksz_write64(struct ksz_device *dev, u32 reg, u64 value)
2368c2ecf20Sopenharmony_ci{
2378c2ecf20Sopenharmony_ci	u32 val[2];
2388c2ecf20Sopenharmony_ci
2398c2ecf20Sopenharmony_ci	/* Ick! ToDo: Add 64bit R/W to regmap on 32bit systems */
2408c2ecf20Sopenharmony_ci	value = swab64(value);
2418c2ecf20Sopenharmony_ci	val[0] = swab32(value & 0xffffffffULL);
2428c2ecf20Sopenharmony_ci	val[1] = swab32(value >> 32ULL);
2438c2ecf20Sopenharmony_ci
2448c2ecf20Sopenharmony_ci	return regmap_bulk_write(dev->regmap[2], reg, val, 2);
2458c2ecf20Sopenharmony_ci}
2468c2ecf20Sopenharmony_ci
2478c2ecf20Sopenharmony_cistatic inline void ksz_pread8(struct ksz_device *dev, int port, int offset,
2488c2ecf20Sopenharmony_ci			      u8 *data)
2498c2ecf20Sopenharmony_ci{
2508c2ecf20Sopenharmony_ci	ksz_read8(dev, dev->dev_ops->get_port_addr(port, offset), data);
2518c2ecf20Sopenharmony_ci}
2528c2ecf20Sopenharmony_ci
2538c2ecf20Sopenharmony_cistatic inline void ksz_pread16(struct ksz_device *dev, int port, int offset,
2548c2ecf20Sopenharmony_ci			       u16 *data)
2558c2ecf20Sopenharmony_ci{
2568c2ecf20Sopenharmony_ci	ksz_read16(dev, dev->dev_ops->get_port_addr(port, offset), data);
2578c2ecf20Sopenharmony_ci}
2588c2ecf20Sopenharmony_ci
2598c2ecf20Sopenharmony_cistatic inline void ksz_pread32(struct ksz_device *dev, int port, int offset,
2608c2ecf20Sopenharmony_ci			       u32 *data)
2618c2ecf20Sopenharmony_ci{
2628c2ecf20Sopenharmony_ci	ksz_read32(dev, dev->dev_ops->get_port_addr(port, offset), data);
2638c2ecf20Sopenharmony_ci}
2648c2ecf20Sopenharmony_ci
2658c2ecf20Sopenharmony_cistatic inline void ksz_pwrite8(struct ksz_device *dev, int port, int offset,
2668c2ecf20Sopenharmony_ci			       u8 data)
2678c2ecf20Sopenharmony_ci{
2688c2ecf20Sopenharmony_ci	ksz_write8(dev, dev->dev_ops->get_port_addr(port, offset), data);
2698c2ecf20Sopenharmony_ci}
2708c2ecf20Sopenharmony_ci
2718c2ecf20Sopenharmony_cistatic inline void ksz_pwrite16(struct ksz_device *dev, int port, int offset,
2728c2ecf20Sopenharmony_ci				u16 data)
2738c2ecf20Sopenharmony_ci{
2748c2ecf20Sopenharmony_ci	ksz_write16(dev, dev->dev_ops->get_port_addr(port, offset), data);
2758c2ecf20Sopenharmony_ci}
2768c2ecf20Sopenharmony_ci
2778c2ecf20Sopenharmony_cistatic inline void ksz_pwrite32(struct ksz_device *dev, int port, int offset,
2788c2ecf20Sopenharmony_ci				u32 data)
2798c2ecf20Sopenharmony_ci{
2808c2ecf20Sopenharmony_ci	ksz_write32(dev, dev->dev_ops->get_port_addr(port, offset), data);
2818c2ecf20Sopenharmony_ci}
2828c2ecf20Sopenharmony_ci
2838c2ecf20Sopenharmony_cistatic inline void ksz_regmap_lock(void *__mtx)
2848c2ecf20Sopenharmony_ci{
2858c2ecf20Sopenharmony_ci	struct mutex *mtx = __mtx;
2868c2ecf20Sopenharmony_ci	mutex_lock(mtx);
2878c2ecf20Sopenharmony_ci}
2888c2ecf20Sopenharmony_ci
2898c2ecf20Sopenharmony_cistatic inline void ksz_regmap_unlock(void *__mtx)
2908c2ecf20Sopenharmony_ci{
2918c2ecf20Sopenharmony_ci	struct mutex *mtx = __mtx;
2928c2ecf20Sopenharmony_ci	mutex_unlock(mtx);
2938c2ecf20Sopenharmony_ci}
2948c2ecf20Sopenharmony_ci
2958c2ecf20Sopenharmony_ci/* Regmap tables generation */
2968c2ecf20Sopenharmony_ci#define KSZ_SPI_OP_RD		3
2978c2ecf20Sopenharmony_ci#define KSZ_SPI_OP_WR		2
2988c2ecf20Sopenharmony_ci
2998c2ecf20Sopenharmony_ci#define swabnot_used(x)		0
3008c2ecf20Sopenharmony_ci
3018c2ecf20Sopenharmony_ci#define KSZ_SPI_OP_FLAG_MASK(opcode, swp, regbits, regpad)		\
3028c2ecf20Sopenharmony_ci	swab##swp((opcode) << ((regbits) + (regpad)))
3038c2ecf20Sopenharmony_ci
3048c2ecf20Sopenharmony_ci#define KSZ_REGMAP_ENTRY(width, swp, regbits, regpad, regalign)		\
3058c2ecf20Sopenharmony_ci	{								\
3068c2ecf20Sopenharmony_ci		.name = #width,						\
3078c2ecf20Sopenharmony_ci		.val_bits = (width),					\
3088c2ecf20Sopenharmony_ci		.reg_stride = 1,					\
3098c2ecf20Sopenharmony_ci		.reg_bits = (regbits) + (regalign),			\
3108c2ecf20Sopenharmony_ci		.pad_bits = (regpad),					\
3118c2ecf20Sopenharmony_ci		.max_register = BIT(regbits) - 1,			\
3128c2ecf20Sopenharmony_ci		.cache_type = REGCACHE_NONE,				\
3138c2ecf20Sopenharmony_ci		.read_flag_mask =					\
3148c2ecf20Sopenharmony_ci			KSZ_SPI_OP_FLAG_MASK(KSZ_SPI_OP_RD, swp,	\
3158c2ecf20Sopenharmony_ci					     regbits, regpad),		\
3168c2ecf20Sopenharmony_ci		.write_flag_mask =					\
3178c2ecf20Sopenharmony_ci			KSZ_SPI_OP_FLAG_MASK(KSZ_SPI_OP_WR, swp,	\
3188c2ecf20Sopenharmony_ci					     regbits, regpad),		\
3198c2ecf20Sopenharmony_ci		.lock = ksz_regmap_lock,				\
3208c2ecf20Sopenharmony_ci		.unlock = ksz_regmap_unlock,				\
3218c2ecf20Sopenharmony_ci		.reg_format_endian = REGMAP_ENDIAN_BIG,			\
3228c2ecf20Sopenharmony_ci		.val_format_endian = REGMAP_ENDIAN_BIG			\
3238c2ecf20Sopenharmony_ci	}
3248c2ecf20Sopenharmony_ci
3258c2ecf20Sopenharmony_ci#define KSZ_REGMAP_TABLE(ksz, swp, regbits, regpad, regalign)		\
3268c2ecf20Sopenharmony_ci	static const struct regmap_config ksz##_regmap_config[] = {	\
3278c2ecf20Sopenharmony_ci		KSZ_REGMAP_ENTRY(8, swp, (regbits), (regpad), (regalign)), \
3288c2ecf20Sopenharmony_ci		KSZ_REGMAP_ENTRY(16, swp, (regbits), (regpad), (regalign)), \
3298c2ecf20Sopenharmony_ci		KSZ_REGMAP_ENTRY(32, swp, (regbits), (regpad), (regalign)), \
3308c2ecf20Sopenharmony_ci	}
3318c2ecf20Sopenharmony_ci
3328c2ecf20Sopenharmony_ci#endif
333