mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-05-24 10:39:52 +00:00

Remove ksz_port_cleanup(), which is unused. Add missing include "ksz_common.h", which fixes the following warning when built with make ... W=1 drivers/net/dsa/microchip/ksz_common.c:23:6: warning: no previous prototype for ‘...’ [-Wmissing-prototypes] Note that the order of the headers cannot be swapped, as that would trigger missing forward declaration errors, which would indicate the way forward is to merge the two headers into one. Signed-off-by: Marek Vasut <marex@denx.de> Cc: Andrew Lunn <andrew@lunn.ch> Cc: David S. Miller <davem@davemloft.net> Cc: Florian Fainelli <f.fainelli@gmail.com> Cc: Tristram Ha <Tristram.Ha@microchip.com> Cc: Vivien Didelot <vivien.didelot@gmail.com> Cc: Woojung Huh <woojung.huh@microchip.com> Signed-off-by: David S. Miller <davem@davemloft.net>
181 lines
5.2 KiB
C
181 lines
5.2 KiB
C
/* SPDX-License-Identifier: GPL-2.0
|
|
* Microchip switch driver common header
|
|
*
|
|
* Copyright (C) 2017-2019 Microchip Technology Inc.
|
|
*/
|
|
|
|
#ifndef __KSZ_COMMON_H
|
|
#define __KSZ_COMMON_H
|
|
|
|
#include <linux/regmap.h>
|
|
|
|
void ksz_update_port_member(struct ksz_device *dev, int port);
|
|
void ksz_init_mib_timer(struct ksz_device *dev);
|
|
|
|
/* Common DSA access functions */
|
|
|
|
int ksz_phy_read16(struct dsa_switch *ds, int addr, int reg);
|
|
int ksz_phy_write16(struct dsa_switch *ds, int addr, int reg, u16 val);
|
|
void ksz_adjust_link(struct dsa_switch *ds, int port,
|
|
struct phy_device *phydev);
|
|
int ksz_sset_count(struct dsa_switch *ds, int port, int sset);
|
|
void ksz_get_ethtool_stats(struct dsa_switch *ds, int port, uint64_t *buf);
|
|
int ksz_port_bridge_join(struct dsa_switch *ds, int port,
|
|
struct net_device *br);
|
|
void ksz_port_bridge_leave(struct dsa_switch *ds, int port,
|
|
struct net_device *br);
|
|
void ksz_port_fast_age(struct dsa_switch *ds, int port);
|
|
int ksz_port_vlan_prepare(struct dsa_switch *ds, int port,
|
|
const struct switchdev_obj_port_vlan *vlan);
|
|
int ksz_port_fdb_dump(struct dsa_switch *ds, int port, dsa_fdb_dump_cb_t *cb,
|
|
void *data);
|
|
int ksz_port_mdb_prepare(struct dsa_switch *ds, int port,
|
|
const struct switchdev_obj_port_mdb *mdb);
|
|
void ksz_port_mdb_add(struct dsa_switch *ds, int port,
|
|
const struct switchdev_obj_port_mdb *mdb);
|
|
int ksz_port_mdb_del(struct dsa_switch *ds, int port,
|
|
const struct switchdev_obj_port_mdb *mdb);
|
|
int ksz_enable_port(struct dsa_switch *ds, int port, struct phy_device *phy);
|
|
void ksz_disable_port(struct dsa_switch *ds, int port);
|
|
|
|
/* Common register access functions */
|
|
|
|
static inline int ksz_read8(struct ksz_device *dev, u32 reg, u8 *val)
|
|
{
|
|
unsigned int value;
|
|
int ret = regmap_read(dev->regmap[0], reg, &value);
|
|
|
|
*val = value;
|
|
return ret;
|
|
}
|
|
|
|
static inline int ksz_read16(struct ksz_device *dev, u32 reg, u16 *val)
|
|
{
|
|
unsigned int value;
|
|
int ret = regmap_read(dev->regmap[1], reg, &value);
|
|
|
|
*val = value;
|
|
return ret;
|
|
}
|
|
|
|
static inline int ksz_read32(struct ksz_device *dev, u32 reg, u32 *val)
|
|
{
|
|
unsigned int value;
|
|
int ret = regmap_read(dev->regmap[2], reg, &value);
|
|
|
|
*val = value;
|
|
return ret;
|
|
}
|
|
|
|
static inline int ksz_read64(struct ksz_device *dev, u32 reg, u64 *val)
|
|
{
|
|
u32 value[2];
|
|
int ret;
|
|
|
|
ret = regmap_bulk_read(dev->regmap[2], reg, value, 2);
|
|
if (!ret) {
|
|
/* Ick! ToDo: Add 64bit R/W to regmap on 32bit systems */
|
|
value[0] = swab32(value[0]);
|
|
value[1] = swab32(value[1]);
|
|
*val = swab64((u64)*value);
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
static inline int ksz_write8(struct ksz_device *dev, u32 reg, u8 value)
|
|
{
|
|
return regmap_write(dev->regmap[0], reg, value);
|
|
}
|
|
|
|
static inline int ksz_write16(struct ksz_device *dev, u32 reg, u16 value)
|
|
{
|
|
return regmap_write(dev->regmap[1], reg, value);
|
|
}
|
|
|
|
static inline int ksz_write32(struct ksz_device *dev, u32 reg, u32 value)
|
|
{
|
|
return regmap_write(dev->regmap[2], reg, value);
|
|
}
|
|
|
|
static inline int ksz_write64(struct ksz_device *dev, u32 reg, u64 value)
|
|
{
|
|
u32 val[2];
|
|
|
|
/* Ick! ToDo: Add 64bit R/W to regmap on 32bit systems */
|
|
value = swab64(value);
|
|
val[0] = swab32(value & 0xffffffffULL);
|
|
val[1] = swab32(value >> 32ULL);
|
|
|
|
return regmap_bulk_write(dev->regmap[2], reg, val, 2);
|
|
}
|
|
|
|
static inline void ksz_pread8(struct ksz_device *dev, int port, int offset,
|
|
u8 *data)
|
|
{
|
|
ksz_read8(dev, dev->dev_ops->get_port_addr(port, offset), data);
|
|
}
|
|
|
|
static inline void ksz_pread16(struct ksz_device *dev, int port, int offset,
|
|
u16 *data)
|
|
{
|
|
ksz_read16(dev, dev->dev_ops->get_port_addr(port, offset), data);
|
|
}
|
|
|
|
static inline void ksz_pread32(struct ksz_device *dev, int port, int offset,
|
|
u32 *data)
|
|
{
|
|
ksz_read32(dev, dev->dev_ops->get_port_addr(port, offset), data);
|
|
}
|
|
|
|
static inline void ksz_pwrite8(struct ksz_device *dev, int port, int offset,
|
|
u8 data)
|
|
{
|
|
ksz_write8(dev, dev->dev_ops->get_port_addr(port, offset), data);
|
|
}
|
|
|
|
static inline void ksz_pwrite16(struct ksz_device *dev, int port, int offset,
|
|
u16 data)
|
|
{
|
|
ksz_write16(dev, dev->dev_ops->get_port_addr(port, offset), data);
|
|
}
|
|
|
|
static inline void ksz_pwrite32(struct ksz_device *dev, int port, int offset,
|
|
u32 data)
|
|
{
|
|
ksz_write32(dev, dev->dev_ops->get_port_addr(port, offset), data);
|
|
}
|
|
|
|
/* Regmap tables generation */
|
|
#define KSZ_SPI_OP_RD 3
|
|
#define KSZ_SPI_OP_WR 2
|
|
|
|
#define KSZ_SPI_OP_FLAG_MASK(opcode, swp, regbits, regpad) \
|
|
swab##swp((opcode) << ((regbits) + (regpad)))
|
|
|
|
#define KSZ_REGMAP_ENTRY(width, swp, regbits, regpad, regalign) \
|
|
{ \
|
|
.val_bits = (width), \
|
|
.reg_stride = (width) / 8, \
|
|
.reg_bits = (regbits) + (regalign), \
|
|
.pad_bits = (regpad), \
|
|
.max_register = BIT(regbits) - 1, \
|
|
.cache_type = REGCACHE_NONE, \
|
|
.read_flag_mask = \
|
|
KSZ_SPI_OP_FLAG_MASK(KSZ_SPI_OP_RD, swp, \
|
|
regbits, regpad), \
|
|
.write_flag_mask = \
|
|
KSZ_SPI_OP_FLAG_MASK(KSZ_SPI_OP_WR, swp, \
|
|
regbits, regpad), \
|
|
.reg_format_endian = REGMAP_ENDIAN_BIG, \
|
|
.val_format_endian = REGMAP_ENDIAN_BIG \
|
|
}
|
|
|
|
#define KSZ_REGMAP_TABLE(ksz, swp, regbits, regpad, regalign) \
|
|
static const struct regmap_config ksz##_regmap_config[] = { \
|
|
KSZ_REGMAP_ENTRY(8, swp, (regbits), (regpad), (regalign)), \
|
|
KSZ_REGMAP_ENTRY(16, swp, (regbits), (regpad), (regalign)), \
|
|
KSZ_REGMAP_ENTRY(32, swp, (regbits), (regpad), (regalign)), \
|
|
}
|
|
|
|
#endif
|