Commit 2c4cec16 authored by David S. Miller's avatar David S. Miller

Merge branch 'microchip=ksz8-cleanup'

Pieter Van Trappen says:

====================
net: dsa: microchip: rename and clean ksz8 series files

The first KSZ8 series implementation was done for a KSZ8795 device but
since several other KSZ8 devices have been added. Rename these files
to adhere to the ksz8 naming convention as already used in most
functions and the existing ksz8.h; add an explanatory note.

In addition, clean the files by removing macros that are defined at
more than one place and remove confusion by renaming the KSZ8830
string which in fact is not an existing KSZ series switch.
Signed-off-by: default avatarPieter Van Trappen <pieter.van.trappen@cern.ch>
---
v4:
 - correct once more Kconfig list of supported switches

v3: https://lore.kernel.org/netdev/20240903072946.344507-1-vtpieter@gmail.com/
 - rename all KSZ8830 to KSZ88X3 only (not KSZ8863)
 - update Kconfig as per Arun's suggestion

v2: https://lore.kernel.org/netdev/20240830141250.30425-1-vtpieter@gmail.com/
 - more finegrained description in Kconfig and ksz8.c header
 - add KSZ8830/ksz8830 to KSZ8863/ksz88x3 renaming

v1: https://lore.kernel.org/netdev/20240828102801.227588-1-vtpieter@gmail.com/
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 76930d3d 23de126f
# SPDX-License-Identifier: GPL-2.0-only
menuconfig NET_DSA_MICROCHIP_KSZ_COMMON
tristate "Microchip KSZ8795/KSZ9477/LAN937x series switch support"
tristate "Microchip KSZ8XXX/KSZ9XXX/LAN937X series switch support"
depends on NET_DSA
select NET_DSA_TAG_KSZ
select NET_DSA_TAG_NONE
select NET_IEEE8021Q_HELPERS
select DCB
help
This driver adds support for Microchip KSZ9477 series switch and
KSZ8795/KSZ88x3 switch chips.
This driver adds support for Microchip KSZ8, KSZ9 and
LAN937X series switch chips, being KSZ8863/8873,
KSZ8895/8864, KSZ8794/8795/8765,
KSZ9477/9897/9896/9567/8567, KSZ9893/9563/8563 and
LAN9370/9371/9372/9373/9374.
config NET_DSA_MICROCHIP_KSZ9477_I2C
tristate "KSZ series I2C connected switch driver"
......
......@@ -2,7 +2,7 @@
obj-$(CONFIG_NET_DSA_MICROCHIP_KSZ_COMMON) += ksz_switch.o
ksz_switch-objs := ksz_common.o ksz_dcb.o
ksz_switch-objs += ksz9477.o ksz9477_acl.o ksz9477_tc_flower.o
ksz_switch-objs += ksz8795.o
ksz_switch-objs += ksz8.o
ksz_switch-objs += lan937x_main.o
ifdef CONFIG_NET_DSA_MICROCHIP_KSZ_PTP
......
// SPDX-License-Identifier: GPL-2.0
/*
* Microchip KSZ8795 switch driver
* Microchip KSZ8XXX series switch driver
*
* It supports the following switches:
* - KSZ8863, KSZ8873 aka KSZ88X3
* - KSZ8895, KSZ8864 aka KSZ8895 family
* - KSZ8794, KSZ8795, KSZ8765 aka KSZ87XX
* Note that it does NOT support:
* - KSZ8563, KSZ8567 - see KSZ9477 driver
*
* Copyright (C) 2017 Microchip Technology Inc.
* Tristram Ha <Tristram.Ha@microchip.com>
......@@ -23,7 +30,7 @@
#include <linux/phylink.h>
#include "ksz_common.h"
#include "ksz8795_reg.h"
#include "ksz8_reg.h"
#include "ksz8.h"
static void ksz_cfg(struct ksz_device *dev, u32 addr, u8 bits, bool set)
......@@ -187,7 +194,7 @@ int ksz8_change_mtu(struct ksz_device *dev, int port, int mtu)
case KSZ8794_CHIP_ID:
case KSZ8765_CHIP_ID:
return ksz8795_change_mtu(dev, frame_size);
case KSZ8830_CHIP_ID:
case KSZ88X3_CHIP_ID:
case KSZ8864_CHIP_ID:
case KSZ8895_CHIP_ID:
return ksz8863_change_mtu(dev, frame_size);
......
......@@ -199,11 +199,11 @@ static void ksz8863_smi_shutdown(struct mdio_device *mdiodev)
static const struct of_device_id ksz8863_dt_ids[] = {
{
.compatible = "microchip,ksz8863",
.data = &ksz_switch_chips[KSZ8830]
.data = &ksz_switch_chips[KSZ88X3]
},
{
.compatible = "microchip,ksz8873",
.data = &ksz_switch_chips[KSZ8830]
.data = &ksz_switch_chips[KSZ88X3]
},
{ },
};
......
/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
* Microchip KSZ8795 register definitions
* Microchip KSZ8XXX series register definitions
*
* The base for these definitions is KSZ8795 but unless indicated
* differently by their prefix, they apply to all KSZ8 series
* devices. Registers and masks that do change are defined in
* dedicated structures in ksz_common.c.
*
* Copyright (c) 2017 Microchip Technology Inc.
* Tristram Ha <Tristram.Ha@microchip.com>
*/
#ifndef __KSZ8795_REG_H
#define __KSZ8795_REG_H
#ifndef __KSZ8_REG_H
#define __KSZ8_REG_H
#define KS_PORT_M 0x1F
......@@ -359,8 +364,6 @@
#define REG_IND_DATA_1 0x77
#define REG_IND_DATA_0 0x78
#define REG_IND_DATA_PME_EEE_ACL 0xA0
#define REG_INT_STATUS 0x7C
#define REG_INT_ENABLE 0x7D
......@@ -704,8 +707,6 @@
#define KSZ8795_ID_LO 0x1550
#define KSZ8863_ID_LO 0x1430
#define KSZ8795_SW_ID 0x8795
#define PHY_REG_LINK_MD 0x1D
#define PHY_START_CABLE_DIAG BIT(15)
......
......@@ -246,16 +246,16 @@ static const struct ksz_drive_strength ksz9477_drive_strengths[] = {
{ SW_DRIVE_STRENGTH_28MA, 28000 },
};
/* ksz8830_drive_strengths - Drive strength mapping for KSZ8830, KSZ8873, ..
/* ksz88x3_drive_strengths - Drive strength mapping for KSZ8863, KSZ8873, ..
* variants.
* This values are documented in KSZ8873 and KSZ8863 datasheets.
*/
static const struct ksz_drive_strength ksz8830_drive_strengths[] = {
static const struct ksz_drive_strength ksz88x3_drive_strengths[] = {
{ 0, 8000 },
{ KSZ8873_DRIVE_STRENGTH_16MA, 16000 },
};
static void ksz8830_phylink_mac_config(struct phylink_config *config,
static void ksz88x3_phylink_mac_config(struct phylink_config *config,
unsigned int mode,
const struct phylink_link_state *state);
static void ksz_phylink_mac_config(struct phylink_config *config,
......@@ -265,8 +265,8 @@ static void ksz_phylink_mac_link_down(struct phylink_config *config,
unsigned int mode,
phy_interface_t interface);
static const struct phylink_mac_ops ksz8830_phylink_mac_ops = {
.mac_config = ksz8830_phylink_mac_config,
static const struct phylink_mac_ops ksz88x3_phylink_mac_ops = {
.mac_config = ksz88x3_phylink_mac_config,
.mac_link_down = ksz_phylink_mac_link_down,
.mac_link_up = ksz8_phylink_mac_link_up,
};
......@@ -1442,8 +1442,8 @@ const struct ksz_chip_data ksz_switch_chips[] = {
.internal_phy = {true, true, true, true, false},
},
[KSZ8830] = {
.chip_id = KSZ8830_CHIP_ID,
[KSZ88X3] = {
.chip_id = KSZ88X3_CHIP_ID,
.dev_name = "KSZ8863/KSZ8873",
.num_vlans = 16,
.num_alus = 0,
......@@ -1453,7 +1453,7 @@ const struct ksz_chip_data ksz_switch_chips[] = {
.num_tx_queues = 4,
.num_ipms = 4,
.ops = &ksz88xx_dev_ops,
.phylink_mac_ops = &ksz8830_phylink_mac_ops,
.phylink_mac_ops = &ksz88x3_phylink_mac_ops,
.mib_names = ksz88xx_mib_names,
.mib_cnt = ARRAY_SIZE(ksz88xx_mib_names),
.reg_mib_cnt = MIB_COUNTER_NUM,
......@@ -1487,7 +1487,7 @@ const struct ksz_chip_data ksz_switch_chips[] = {
.num_tx_queues = 4,
.num_ipms = 4,
.ops = &ksz88xx_dev_ops,
.phylink_mac_ops = &ksz8830_phylink_mac_ops,
.phylink_mac_ops = &ksz88x3_phylink_mac_ops,
.mib_names = ksz88xx_mib_names,
.mib_cnt = ARRAY_SIZE(ksz88xx_mib_names),
.reg_mib_cnt = MIB_COUNTER_NUM,
......@@ -1510,7 +1510,7 @@ const struct ksz_chip_data ksz_switch_chips[] = {
.num_tx_queues = 4,
.num_ipms = 4,
.ops = &ksz88xx_dev_ops,
.phylink_mac_ops = &ksz8830_phylink_mac_ops,
.phylink_mac_ops = &ksz88x3_phylink_mac_ops,
.mib_names = ksz88xx_mib_names,
.mib_cnt = ARRAY_SIZE(ksz88xx_mib_names),
.reg_mib_cnt = MIB_COUNTER_NUM,
......@@ -2724,7 +2724,7 @@ static u32 ksz_get_phy_flags(struct dsa_switch *ds, int port)
struct ksz_device *dev = ds->priv;
switch (dev->chip_id) {
case KSZ8830_CHIP_ID:
case KSZ88X3_CHIP_ID:
/* Silicon Errata Sheet (DS80000830A):
* Port 1 does not work with LinkMD Cable-Testing.
* Port 1 does not respond to received PAUSE control frames.
......@@ -3050,7 +3050,7 @@ static enum dsa_tag_protocol ksz_get_tag_protocol(struct dsa_switch *ds,
if (ksz_is_ksz87xx(dev) || ksz_is_8895_family(dev))
proto = DSA_TAG_PROTO_KSZ8795;
if (dev->chip_id == KSZ8830_CHIP_ID ||
if (dev->chip_id == KSZ88X3_CHIP_ID ||
dev->chip_id == KSZ8563_CHIP_ID ||
dev->chip_id == KSZ9893_CHIP_ID ||
dev->chip_id == KSZ9563_CHIP_ID)
......@@ -3162,7 +3162,7 @@ static int ksz_max_mtu(struct dsa_switch *ds, int port)
case KSZ8794_CHIP_ID:
case KSZ8765_CHIP_ID:
return KSZ8795_HUGE_PACKET_SIZE - VLAN_ETH_HLEN - ETH_FCS_LEN;
case KSZ8830_CHIP_ID:
case KSZ88X3_CHIP_ID:
case KSZ8864_CHIP_ID:
case KSZ8895_CHIP_ID:
return KSZ8863_HUGE_PACKET_SIZE - VLAN_ETH_HLEN - ETH_FCS_LEN;
......@@ -3334,7 +3334,7 @@ phy_interface_t ksz_get_xmii(struct ksz_device *dev, int port, bool gbit)
return interface;
}
static void ksz8830_phylink_mac_config(struct phylink_config *config,
static void ksz88x3_phylink_mac_config(struct phylink_config *config,
unsigned int mode,
const struct phylink_link_state *state)
{
......@@ -3518,7 +3518,7 @@ static int ksz_switch_detect(struct ksz_device *dev)
break;
case KSZ88_FAMILY_ID:
if (id2 == KSZ88_CHIP_ID_63)
dev->chip_id = KSZ8830_CHIP_ID;
dev->chip_id = KSZ88X3_CHIP_ID;
else
return -ENODEV;
break;
......@@ -4592,24 +4592,24 @@ static int ksz9477_drive_strength_write(struct ksz_device *dev,
}
/**
* ksz8830_drive_strength_write() - Set the drive strength configuration for
* KSZ8830 compatible chip variants.
* ksz88x3_drive_strength_write() - Set the drive strength configuration for
* KSZ8863 compatible chip variants.
* @dev: ksz device
* @props: Array of drive strength properties to be set
* @num_props: Number of properties in the array
*
* This function applies the specified drive strength settings to KSZ8830 chip
* This function applies the specified drive strength settings to KSZ88X3 chip
* variants (KSZ8873, KSZ8863).
* It ensures the configurations align with what the chip variant supports and
* warns or errors out on unsupported settings.
*
* Return: 0 on success, error code otherwise
*/
static int ksz8830_drive_strength_write(struct ksz_device *dev,
static int ksz88x3_drive_strength_write(struct ksz_device *dev,
struct ksz_driver_strength_prop *props,
int num_props)
{
size_t array_size = ARRAY_SIZE(ksz8830_drive_strengths);
size_t array_size = ARRAY_SIZE(ksz88x3_drive_strengths);
int microamp;
int i, ret;
......@@ -4622,10 +4622,10 @@ static int ksz8830_drive_strength_write(struct ksz_device *dev,
}
microamp = props[KSZ_DRIVER_STRENGTH_IO].value;
ret = ksz_drive_strength_to_reg(ksz8830_drive_strengths, array_size,
ret = ksz_drive_strength_to_reg(ksz88x3_drive_strengths, array_size,
microamp);
if (ret < 0) {
ksz_drive_strength_error(dev, ksz8830_drive_strengths,
ksz_drive_strength_error(dev, ksz88x3_drive_strengths,
array_size, microamp);
return ret;
}
......@@ -4685,8 +4685,8 @@ static int ksz_parse_drive_strength(struct ksz_device *dev)
return 0;
switch (dev->chip_id) {
case KSZ8830_CHIP_ID:
return ksz8830_drive_strength_write(dev, of_props,
case KSZ88X3_CHIP_ID:
return ksz88x3_drive_strength_write(dev, of_props,
ARRAY_SIZE(of_props));
case KSZ8795_CHIP_ID:
case KSZ8794_CHIP_ID:
......
......@@ -200,7 +200,7 @@ enum ksz_model {
KSZ8795,
KSZ8794,
KSZ8765,
KSZ8830,
KSZ88X3,
KSZ8864,
KSZ8895,
KSZ9477,
......@@ -628,7 +628,7 @@ static inline bool ksz_is_ksz87xx(struct ksz_device *dev)
static inline bool ksz_is_ksz88x3(struct ksz_device *dev)
{
return dev->chip_id == KSZ8830_CHIP_ID;
return dev->chip_id == KSZ88X3_CHIP_ID;
}
static inline bool ksz_is_8895_family(struct ksz_device *dev)
......
......@@ -54,7 +54,7 @@ static int ksz_spi_probe(struct spi_device *spi)
if (!chip)
return -EINVAL;
if (chip->chip_id == KSZ8830_CHIP_ID)
if (chip->chip_id == KSZ88X3_CHIP_ID)
regmap_config = ksz8863_regmap_config;
else if (chip->chip_id == KSZ8795_CHIP_ID ||
chip->chip_id == KSZ8794_CHIP_ID ||
......@@ -137,7 +137,7 @@ static const struct of_device_id ksz_dt_ids[] = {
},
{
.compatible = "microchip,ksz8863",
.data = &ksz_switch_chips[KSZ8830]
.data = &ksz_switch_chips[KSZ88X3]
},
{
.compatible = "microchip,ksz8864",
......@@ -145,7 +145,7 @@ static const struct of_device_id ksz_dt_ids[] = {
},
{
.compatible = "microchip,ksz8873",
.data = &ksz_switch_chips[KSZ8830]
.data = &ksz_switch_chips[KSZ88X3]
},
{
.compatible = "microchip,ksz8895",
......
......@@ -27,7 +27,7 @@ enum ksz_chip_id {
KSZ8795_CHIP_ID = 0x8795,
KSZ8794_CHIP_ID = 0x8794,
KSZ8765_CHIP_ID = 0x8765,
KSZ8830_CHIP_ID = 0x8830,
KSZ88X3_CHIP_ID = 0x8830,
KSZ8864_CHIP_ID = 0x8864,
KSZ8895_CHIP_ID = 0x8895,
KSZ9477_CHIP_ID = 0x00947700,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment