Skip to content

Commit 2c4cec1

Browse files
committed
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: Pieter Van Trappen <[email protected]> --- v4: - correct once more Kconfig list of supported switches v3: https://lore.kernel.org/netdev/[email protected]/ - rename all KSZ8830 to KSZ88X3 only (not KSZ8863) - update Kconfig as per Arun's suggestion v2: https://lore.kernel.org/netdev/[email protected]/ - more finegrained description in Kconfig and ksz8.c header - add KSZ8830/ksz8830 to KSZ8863/ksz88x3 renaming v1: https://lore.kernel.org/netdev/[email protected]/ ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 76930d3 + 23de126 commit 2c4cec1

File tree

9 files changed

+57
-46
lines changed

9 files changed

+57
-46
lines changed

drivers/net/dsa/microchip/Kconfig

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
# SPDX-License-Identifier: GPL-2.0-only
22
menuconfig NET_DSA_MICROCHIP_KSZ_COMMON
3-
tristate "Microchip KSZ8795/KSZ9477/LAN937x series switch support"
3+
tristate "Microchip KSZ8XXX/KSZ9XXX/LAN937X series switch support"
44
depends on NET_DSA
55
select NET_DSA_TAG_KSZ
66
select NET_DSA_TAG_NONE
77
select NET_IEEE8021Q_HELPERS
88
select DCB
99
help
10-
This driver adds support for Microchip KSZ9477 series switch and
11-
KSZ8795/KSZ88x3 switch chips.
10+
This driver adds support for Microchip KSZ8, KSZ9 and
11+
LAN937X series switch chips, being KSZ8863/8873,
12+
KSZ8895/8864, KSZ8794/8795/8765,
13+
KSZ9477/9897/9896/9567/8567, KSZ9893/9563/8563 and
14+
LAN9370/9371/9372/9373/9374.
1215

1316
config NET_DSA_MICROCHIP_KSZ9477_I2C
1417
tristate "KSZ series I2C connected switch driver"

drivers/net/dsa/microchip/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
obj-$(CONFIG_NET_DSA_MICROCHIP_KSZ_COMMON) += ksz_switch.o
33
ksz_switch-objs := ksz_common.o ksz_dcb.o
44
ksz_switch-objs += ksz9477.o ksz9477_acl.o ksz9477_tc_flower.o
5-
ksz_switch-objs += ksz8795.o
5+
ksz_switch-objs += ksz8.o
66
ksz_switch-objs += lan937x_main.o
77

88
ifdef CONFIG_NET_DSA_MICROCHIP_KSZ_PTP

drivers/net/dsa/microchip/ksz8795.c renamed to drivers/net/dsa/microchip/ksz8.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
// SPDX-License-Identifier: GPL-2.0
22
/*
3-
* Microchip KSZ8795 switch driver
3+
* Microchip KSZ8XXX series switch driver
4+
*
5+
* It supports the following switches:
6+
* - KSZ8863, KSZ8873 aka KSZ88X3
7+
* - KSZ8895, KSZ8864 aka KSZ8895 family
8+
* - KSZ8794, KSZ8795, KSZ8765 aka KSZ87XX
9+
* Note that it does NOT support:
10+
* - KSZ8563, KSZ8567 - see KSZ9477 driver
411
*
512
* Copyright (C) 2017 Microchip Technology Inc.
613
* Tristram Ha <[email protected]>
@@ -23,7 +30,7 @@
2330
#include <linux/phylink.h>
2431

2532
#include "ksz_common.h"
26-
#include "ksz8795_reg.h"
33+
#include "ksz8_reg.h"
2734
#include "ksz8.h"
2835

2936
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)
187194
case KSZ8794_CHIP_ID:
188195
case KSZ8765_CHIP_ID:
189196
return ksz8795_change_mtu(dev, frame_size);
190-
case KSZ8830_CHIP_ID:
197+
case KSZ88X3_CHIP_ID:
191198
case KSZ8864_CHIP_ID:
192199
case KSZ8895_CHIP_ID:
193200
return ksz8863_change_mtu(dev, frame_size);

drivers/net/dsa/microchip/ksz8863_smi.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,11 +199,11 @@ static void ksz8863_smi_shutdown(struct mdio_device *mdiodev)
199199
static const struct of_device_id ksz8863_dt_ids[] = {
200200
{
201201
.compatible = "microchip,ksz8863",
202-
.data = &ksz_switch_chips[KSZ8830]
202+
.data = &ksz_switch_chips[KSZ88X3]
203203
},
204204
{
205205
.compatible = "microchip,ksz8873",
206-
.data = &ksz_switch_chips[KSZ8830]
206+
.data = &ksz_switch_chips[KSZ88X3]
207207
},
208208
{ },
209209
};

drivers/net/dsa/microchip/ksz8795_reg.h renamed to drivers/net/dsa/microchip/ksz8_reg.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
/* SPDX-License-Identifier: GPL-2.0-or-later */
22
/*
3-
* Microchip KSZ8795 register definitions
3+
* Microchip KSZ8XXX series register definitions
4+
*
5+
* The base for these definitions is KSZ8795 but unless indicated
6+
* differently by their prefix, they apply to all KSZ8 series
7+
* devices. Registers and masks that do change are defined in
8+
* dedicated structures in ksz_common.c.
49
*
510
* Copyright (c) 2017 Microchip Technology Inc.
611
* Tristram Ha <[email protected]>
712
*/
813

9-
#ifndef __KSZ8795_REG_H
10-
#define __KSZ8795_REG_H
14+
#ifndef __KSZ8_REG_H
15+
#define __KSZ8_REG_H
1116

1217
#define KS_PORT_M 0x1F
1318

@@ -359,8 +364,6 @@
359364
#define REG_IND_DATA_1 0x77
360365
#define REG_IND_DATA_0 0x78
361366

362-
#define REG_IND_DATA_PME_EEE_ACL 0xA0
363-
364367
#define REG_INT_STATUS 0x7C
365368
#define REG_INT_ENABLE 0x7D
366369

@@ -704,8 +707,6 @@
704707
#define KSZ8795_ID_LO 0x1550
705708
#define KSZ8863_ID_LO 0x1430
706709

707-
#define KSZ8795_SW_ID 0x8795
708-
709710
#define PHY_REG_LINK_MD 0x1D
710711

711712
#define PHY_START_CABLE_DIAG BIT(15)

drivers/net/dsa/microchip/ksz_common.c

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -246,16 +246,16 @@ static const struct ksz_drive_strength ksz9477_drive_strengths[] = {
246246
{ SW_DRIVE_STRENGTH_28MA, 28000 },
247247
};
248248

249-
/* ksz8830_drive_strengths - Drive strength mapping for KSZ8830, KSZ8873, ..
249+
/* ksz88x3_drive_strengths - Drive strength mapping for KSZ8863, KSZ8873, ..
250250
* variants.
251251
* This values are documented in KSZ8873 and KSZ8863 datasheets.
252252
*/
253-
static const struct ksz_drive_strength ksz8830_drive_strengths[] = {
253+
static const struct ksz_drive_strength ksz88x3_drive_strengths[] = {
254254
{ 0, 8000 },
255255
{ KSZ8873_DRIVE_STRENGTH_16MA, 16000 },
256256
};
257257

258-
static void ksz8830_phylink_mac_config(struct phylink_config *config,
258+
static void ksz88x3_phylink_mac_config(struct phylink_config *config,
259259
unsigned int mode,
260260
const struct phylink_link_state *state);
261261
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,
265265
unsigned int mode,
266266
phy_interface_t interface);
267267

268-
static const struct phylink_mac_ops ksz8830_phylink_mac_ops = {
269-
.mac_config = ksz8830_phylink_mac_config,
268+
static const struct phylink_mac_ops ksz88x3_phylink_mac_ops = {
269+
.mac_config = ksz88x3_phylink_mac_config,
270270
.mac_link_down = ksz_phylink_mac_link_down,
271271
.mac_link_up = ksz8_phylink_mac_link_up,
272272
};
@@ -1442,8 +1442,8 @@ const struct ksz_chip_data ksz_switch_chips[] = {
14421442
.internal_phy = {true, true, true, true, false},
14431443
},
14441444

1445-
[KSZ8830] = {
1446-
.chip_id = KSZ8830_CHIP_ID,
1445+
[KSZ88X3] = {
1446+
.chip_id = KSZ88X3_CHIP_ID,
14471447
.dev_name = "KSZ8863/KSZ8873",
14481448
.num_vlans = 16,
14491449
.num_alus = 0,
@@ -1453,7 +1453,7 @@ const struct ksz_chip_data ksz_switch_chips[] = {
14531453
.num_tx_queues = 4,
14541454
.num_ipms = 4,
14551455
.ops = &ksz88xx_dev_ops,
1456-
.phylink_mac_ops = &ksz8830_phylink_mac_ops,
1456+
.phylink_mac_ops = &ksz88x3_phylink_mac_ops,
14571457
.mib_names = ksz88xx_mib_names,
14581458
.mib_cnt = ARRAY_SIZE(ksz88xx_mib_names),
14591459
.reg_mib_cnt = MIB_COUNTER_NUM,
@@ -1487,7 +1487,7 @@ const struct ksz_chip_data ksz_switch_chips[] = {
14871487
.num_tx_queues = 4,
14881488
.num_ipms = 4,
14891489
.ops = &ksz88xx_dev_ops,
1490-
.phylink_mac_ops = &ksz8830_phylink_mac_ops,
1490+
.phylink_mac_ops = &ksz88x3_phylink_mac_ops,
14911491
.mib_names = ksz88xx_mib_names,
14921492
.mib_cnt = ARRAY_SIZE(ksz88xx_mib_names),
14931493
.reg_mib_cnt = MIB_COUNTER_NUM,
@@ -1510,7 +1510,7 @@ const struct ksz_chip_data ksz_switch_chips[] = {
15101510
.num_tx_queues = 4,
15111511
.num_ipms = 4,
15121512
.ops = &ksz88xx_dev_ops,
1513-
.phylink_mac_ops = &ksz8830_phylink_mac_ops,
1513+
.phylink_mac_ops = &ksz88x3_phylink_mac_ops,
15141514
.mib_names = ksz88xx_mib_names,
15151515
.mib_cnt = ARRAY_SIZE(ksz88xx_mib_names),
15161516
.reg_mib_cnt = MIB_COUNTER_NUM,
@@ -2724,7 +2724,7 @@ static u32 ksz_get_phy_flags(struct dsa_switch *ds, int port)
27242724
struct ksz_device *dev = ds->priv;
27252725

27262726
switch (dev->chip_id) {
2727-
case KSZ8830_CHIP_ID:
2727+
case KSZ88X3_CHIP_ID:
27282728
/* Silicon Errata Sheet (DS80000830A):
27292729
* Port 1 does not work with LinkMD Cable-Testing.
27302730
* 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,
30503050
if (ksz_is_ksz87xx(dev) || ksz_is_8895_family(dev))
30513051
proto = DSA_TAG_PROTO_KSZ8795;
30523052

3053-
if (dev->chip_id == KSZ8830_CHIP_ID ||
3053+
if (dev->chip_id == KSZ88X3_CHIP_ID ||
30543054
dev->chip_id == KSZ8563_CHIP_ID ||
30553055
dev->chip_id == KSZ9893_CHIP_ID ||
30563056
dev->chip_id == KSZ9563_CHIP_ID)
@@ -3162,7 +3162,7 @@ static int ksz_max_mtu(struct dsa_switch *ds, int port)
31623162
case KSZ8794_CHIP_ID:
31633163
case KSZ8765_CHIP_ID:
31643164
return KSZ8795_HUGE_PACKET_SIZE - VLAN_ETH_HLEN - ETH_FCS_LEN;
3165-
case KSZ8830_CHIP_ID:
3165+
case KSZ88X3_CHIP_ID:
31663166
case KSZ8864_CHIP_ID:
31673167
case KSZ8895_CHIP_ID:
31683168
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)
33343334
return interface;
33353335
}
33363336

3337-
static void ksz8830_phylink_mac_config(struct phylink_config *config,
3337+
static void ksz88x3_phylink_mac_config(struct phylink_config *config,
33383338
unsigned int mode,
33393339
const struct phylink_link_state *state)
33403340
{
@@ -3518,7 +3518,7 @@ static int ksz_switch_detect(struct ksz_device *dev)
35183518
break;
35193519
case KSZ88_FAMILY_ID:
35203520
if (id2 == KSZ88_CHIP_ID_63)
3521-
dev->chip_id = KSZ8830_CHIP_ID;
3521+
dev->chip_id = KSZ88X3_CHIP_ID;
35223522
else
35233523
return -ENODEV;
35243524
break;
@@ -4592,24 +4592,24 @@ static int ksz9477_drive_strength_write(struct ksz_device *dev,
45924592
}
45934593

45944594
/**
4595-
* ksz8830_drive_strength_write() - Set the drive strength configuration for
4596-
* KSZ8830 compatible chip variants.
4595+
* ksz88x3_drive_strength_write() - Set the drive strength configuration for
4596+
* KSZ8863 compatible chip variants.
45974597
* @dev: ksz device
45984598
* @props: Array of drive strength properties to be set
45994599
* @num_props: Number of properties in the array
46004600
*
4601-
* This function applies the specified drive strength settings to KSZ8830 chip
4601+
* This function applies the specified drive strength settings to KSZ88X3 chip
46024602
* variants (KSZ8873, KSZ8863).
46034603
* It ensures the configurations align with what the chip variant supports and
46044604
* warns or errors out on unsupported settings.
46054605
*
46064606
* Return: 0 on success, error code otherwise
46074607
*/
4608-
static int ksz8830_drive_strength_write(struct ksz_device *dev,
4608+
static int ksz88x3_drive_strength_write(struct ksz_device *dev,
46094609
struct ksz_driver_strength_prop *props,
46104610
int num_props)
46114611
{
4612-
size_t array_size = ARRAY_SIZE(ksz8830_drive_strengths);
4612+
size_t array_size = ARRAY_SIZE(ksz88x3_drive_strengths);
46134613
int microamp;
46144614
int i, ret;
46154615

@@ -4622,10 +4622,10 @@ static int ksz8830_drive_strength_write(struct ksz_device *dev,
46224622
}
46234623

46244624
microamp = props[KSZ_DRIVER_STRENGTH_IO].value;
4625-
ret = ksz_drive_strength_to_reg(ksz8830_drive_strengths, array_size,
4625+
ret = ksz_drive_strength_to_reg(ksz88x3_drive_strengths, array_size,
46264626
microamp);
46274627
if (ret < 0) {
4628-
ksz_drive_strength_error(dev, ksz8830_drive_strengths,
4628+
ksz_drive_strength_error(dev, ksz88x3_drive_strengths,
46294629
array_size, microamp);
46304630
return ret;
46314631
}
@@ -4685,8 +4685,8 @@ static int ksz_parse_drive_strength(struct ksz_device *dev)
46854685
return 0;
46864686

46874687
switch (dev->chip_id) {
4688-
case KSZ8830_CHIP_ID:
4689-
return ksz8830_drive_strength_write(dev, of_props,
4688+
case KSZ88X3_CHIP_ID:
4689+
return ksz88x3_drive_strength_write(dev, of_props,
46904690
ARRAY_SIZE(of_props));
46914691
case KSZ8795_CHIP_ID:
46924692
case KSZ8794_CHIP_ID:

drivers/net/dsa/microchip/ksz_common.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ enum ksz_model {
200200
KSZ8795,
201201
KSZ8794,
202202
KSZ8765,
203-
KSZ8830,
203+
KSZ88X3,
204204
KSZ8864,
205205
KSZ8895,
206206
KSZ9477,
@@ -628,7 +628,7 @@ static inline bool ksz_is_ksz87xx(struct ksz_device *dev)
628628

629629
static inline bool ksz_is_ksz88x3(struct ksz_device *dev)
630630
{
631-
return dev->chip_id == KSZ8830_CHIP_ID;
631+
return dev->chip_id == KSZ88X3_CHIP_ID;
632632
}
633633

634634
static inline bool ksz_is_8895_family(struct ksz_device *dev)

drivers/net/dsa/microchip/ksz_spi.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ static int ksz_spi_probe(struct spi_device *spi)
5454
if (!chip)
5555
return -EINVAL;
5656

57-
if (chip->chip_id == KSZ8830_CHIP_ID)
57+
if (chip->chip_id == KSZ88X3_CHIP_ID)
5858
regmap_config = ksz8863_regmap_config;
5959
else if (chip->chip_id == KSZ8795_CHIP_ID ||
6060
chip->chip_id == KSZ8794_CHIP_ID ||
@@ -137,15 +137,15 @@ static const struct of_device_id ksz_dt_ids[] = {
137137
},
138138
{
139139
.compatible = "microchip,ksz8863",
140-
.data = &ksz_switch_chips[KSZ8830]
140+
.data = &ksz_switch_chips[KSZ88X3]
141141
},
142142
{
143143
.compatible = "microchip,ksz8864",
144144
.data = &ksz_switch_chips[KSZ8864]
145145
},
146146
{
147147
.compatible = "microchip,ksz8873",
148-
.data = &ksz_switch_chips[KSZ8830]
148+
.data = &ksz_switch_chips[KSZ88X3]
149149
},
150150
{
151151
.compatible = "microchip,ksz8895",

include/linux/platform_data/microchip-ksz.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ enum ksz_chip_id {
2727
KSZ8795_CHIP_ID = 0x8795,
2828
KSZ8794_CHIP_ID = 0x8794,
2929
KSZ8765_CHIP_ID = 0x8765,
30-
KSZ8830_CHIP_ID = 0x8830,
30+
KSZ88X3_CHIP_ID = 0x8830,
3131
KSZ8864_CHIP_ID = 0x8864,
3232
KSZ8895_CHIP_ID = 0x8895,
3333
KSZ9477_CHIP_ID = 0x00947700,

0 commit comments

Comments
 (0)