aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/dsa
diff options
context:
space:
mode:
authorVivien Didelot <vivien.didelot@savoirfairelinux.com>2016-05-09 13:22:58 -0400
committerDavid S. Miller <davem@davemloft.net>2016-05-09 14:26:13 -0400
commitf81ec90fe9cbf512f3c632130a37c6d353fa94ea (patch)
tree917a670ad6b4d142987abcb2ac932a7a59e3f412 /drivers/net/dsa
parentb9729e53ade9be2637b46ac98fd85c7eac1b77c8 (diff)
net: dsa: mv88e6xxx: factorize the switch driver
Now that all drivers support the same set of functions and the same setup code, drop every model-specific DSA switch driver and replace them with a common mv88e6xxx driver. This merges the info tables into one, removes the function exports, the model-specific files, and update the defconfigs. Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/dsa')
-rw-r--r--drivers/net/dsa/Kconfig40
-rw-r--r--drivers/net/dsa/Makefile15
-rw-r--r--drivers/net/dsa/mv88e6123.c93
-rw-r--r--drivers/net/dsa/mv88e6131.c101
-rw-r--r--drivers/net/dsa/mv88e6171.c101
-rw-r--r--drivers/net/dsa/mv88e6352.c121
-rw-r--r--drivers/net/dsa/mv88e6xxx.c354
-rw-r--r--drivers/net/dsa/mv88e6xxx.h91
8 files changed, 297 insertions, 619 deletions
diff --git a/drivers/net/dsa/Kconfig b/drivers/net/dsa/Kconfig
index 7e01dce09904..200663c43ce9 100644
--- a/drivers/net/dsa/Kconfig
+++ b/drivers/net/dsa/Kconfig
@@ -1,10 +1,6 @@
1menu "Distributed Switch Architecture drivers" 1menu "Distributed Switch Architecture drivers"
2 depends on HAVE_NET_DSA 2 depends on HAVE_NET_DSA
3 3
4config NET_DSA_MV88E6XXX
5 tristate
6 default n
7
8config NET_DSA_MV88E6060 4config NET_DSA_MV88E6060
9 tristate "Marvell 88E6060 ethernet switch chip support" 5 tristate "Marvell 88E6060 ethernet switch chip support"
10 depends on NET_DSA 6 depends on NET_DSA
@@ -13,41 +9,13 @@ config NET_DSA_MV88E6060
13 This enables support for the Marvell 88E6060 ethernet switch 9 This enables support for the Marvell 88E6060 ethernet switch
14 chip. 10 chip.
15 11
16config NET_DSA_MV88E6131 12config NET_DSA_MV88E6XXX
17 tristate "Marvell 88E6085/6095/6095F/6131 ethernet switch chip support" 13 tristate "Marvell 88E6xxx Ethernet switch chip support"
18 depends on NET_DSA
19 select NET_DSA_MV88E6XXX
20 select NET_DSA_TAG_EDSA
21 ---help---
22 This enables support for the Marvell 88E6085/6095/6095F/6131
23 ethernet switch chips.
24
25config NET_DSA_MV88E6123
26 tristate "Marvell 88E6123/6161/6165 ethernet switch chip support"
27 depends on NET_DSA
28 select NET_DSA_MV88E6XXX
29 select NET_DSA_TAG_EDSA
30 ---help---
31 This enables support for the Marvell 88E6123/6161/6165
32 ethernet switch chips.
33
34config NET_DSA_MV88E6171
35 tristate "Marvell 88E6171/6175/6350/6351 ethernet switch chip support"
36 depends on NET_DSA
37 select NET_DSA_MV88E6XXX
38 select NET_DSA_TAG_EDSA
39 ---help---
40 This enables support for the Marvell 88E6171/6175/6350/6351
41 ethernet switches chips.
42
43config NET_DSA_MV88E6352
44 tristate "Marvell 88E6172/6176/6320/6321/6352 ethernet switch chip support"
45 depends on NET_DSA 14 depends on NET_DSA
46 select NET_DSA_MV88E6XXX
47 select NET_DSA_TAG_EDSA 15 select NET_DSA_TAG_EDSA
48 ---help--- 16 ---help---
49 This enables support for the Marvell 88E6172, 88E6176, 88E6320, 17 This enables support for most of the Marvell 88E6xxx models of
50 88E6321 and 88E6352 ethernet switch chips. 18 Ethernet switch chips, except 88E6060.
51 19
52config NET_DSA_BCM_SF2 20config NET_DSA_BCM_SF2
53 tristate "Broadcom Starfighter 2 Ethernet switch support" 21 tristate "Broadcom Starfighter 2 Ethernet switch support"
diff --git a/drivers/net/dsa/Makefile b/drivers/net/dsa/Makefile
index a6e09939be65..76b751dd9efd 100644
--- a/drivers/net/dsa/Makefile
+++ b/drivers/net/dsa/Makefile
@@ -1,16 +1,3 @@
1obj-$(CONFIG_NET_DSA_MV88E6060) += mv88e6060.o 1obj-$(CONFIG_NET_DSA_MV88E6060) += mv88e6060.o
2obj-$(CONFIG_NET_DSA_MV88E6XXX) += mv88e6xxx_drv.o 2obj-$(CONFIG_NET_DSA_MV88E6XXX) += mv88e6xxx.o
3mv88e6xxx_drv-y += mv88e6xxx.o
4ifdef CONFIG_NET_DSA_MV88E6123
5mv88e6xxx_drv-y += mv88e6123.o
6endif
7ifdef CONFIG_NET_DSA_MV88E6131
8mv88e6xxx_drv-y += mv88e6131.o
9endif
10ifdef CONFIG_NET_DSA_MV88E6352
11mv88e6xxx_drv-y += mv88e6352.o
12endif
13ifdef CONFIG_NET_DSA_MV88E6171
14mv88e6xxx_drv-y += mv88e6171.o
15endif
16obj-$(CONFIG_NET_DSA_BCM_SF2) += bcm_sf2.o 3obj-$(CONFIG_NET_DSA_BCM_SF2) += bcm_sf2.o
diff --git a/drivers/net/dsa/mv88e6123.c b/drivers/net/dsa/mv88e6123.c
deleted file mode 100644
index 2bc407b5632d..000000000000
--- a/drivers/net/dsa/mv88e6123.c
+++ /dev/null
@@ -1,93 +0,0 @@
1/*
2 * net/dsa/mv88e6123_61_65.c - Marvell 88e6123/6161/6165 switch chip support
3 * Copyright (c) 2008-2009 Marvell Semiconductor
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 */
10
11#include <linux/delay.h>
12#include <linux/jiffies.h>
13#include <linux/list.h>
14#include <linux/module.h>
15#include <linux/netdevice.h>
16#include <linux/phy.h>
17#include <net/dsa.h>
18#include "mv88e6xxx.h"
19
20static const struct mv88e6xxx_info mv88e6123_table[] = {
21 {
22 .prod_num = PORT_SWITCH_ID_PROD_NUM_6123,
23 .family = MV88E6XXX_FAMILY_6165,
24 .name = "Marvell 88E6123",
25 .num_databases = 4096,
26 .num_ports = 3,
27 .flags = MV88E6XXX_FLAGS_FAMILY_6165,
28 }, {
29 .prod_num = PORT_SWITCH_ID_PROD_NUM_6161,
30 .family = MV88E6XXX_FAMILY_6165,
31 .name = "Marvell 88E6161",
32 .num_databases = 4096,
33 .num_ports = 6,
34 .flags = MV88E6XXX_FLAGS_FAMILY_6165,
35 }, {
36 .prod_num = PORT_SWITCH_ID_PROD_NUM_6165,
37 .family = MV88E6XXX_FAMILY_6165,
38 .name = "Marvell 88E6165",
39 .num_databases = 4096,
40 .num_ports = 6,
41 .flags = MV88E6XXX_FLAGS_FAMILY_6165,
42 }
43};
44
45static const char *mv88e6123_drv_probe(struct device *dsa_dev,
46 struct device *host_dev, int sw_addr,
47 void **priv)
48{
49 return mv88e6xxx_drv_probe(dsa_dev, host_dev, sw_addr, priv,
50 mv88e6123_table,
51 ARRAY_SIZE(mv88e6123_table));
52}
53
54struct dsa_switch_driver mv88e6123_switch_driver = {
55 .tag_protocol = DSA_TAG_PROTO_EDSA,
56 .probe = mv88e6123_drv_probe,
57 .setup = mv88e6xxx_setup,
58 .set_addr = mv88e6xxx_set_addr,
59 .phy_read = mv88e6xxx_phy_read,
60 .phy_write = mv88e6xxx_phy_write,
61 .set_eee = mv88e6xxx_set_eee,
62 .get_eee = mv88e6xxx_get_eee,
63 .get_strings = mv88e6xxx_get_strings,
64 .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
65 .get_sset_count = mv88e6xxx_get_sset_count,
66 .adjust_link = mv88e6xxx_adjust_link,
67#ifdef CONFIG_NET_DSA_HWMON
68 .get_temp = mv88e6xxx_get_temp,
69 .get_temp_limit = mv88e6xxx_get_temp_limit,
70 .set_temp_limit = mv88e6xxx_set_temp_limit,
71 .get_temp_alarm = mv88e6xxx_get_temp_alarm,
72#endif
73 .get_eeprom = mv88e6xxx_get_eeprom,
74 .set_eeprom = mv88e6xxx_set_eeprom,
75 .get_regs_len = mv88e6xxx_get_regs_len,
76 .get_regs = mv88e6xxx_get_regs,
77 .port_bridge_join = mv88e6xxx_port_bridge_join,
78 .port_bridge_leave = mv88e6xxx_port_bridge_leave,
79 .port_stp_state_set = mv88e6xxx_port_stp_state_set,
80 .port_vlan_filtering = mv88e6xxx_port_vlan_filtering,
81 .port_vlan_prepare = mv88e6xxx_port_vlan_prepare,
82 .port_vlan_add = mv88e6xxx_port_vlan_add,
83 .port_vlan_del = mv88e6xxx_port_vlan_del,
84 .port_vlan_dump = mv88e6xxx_port_vlan_dump,
85 .port_fdb_prepare = mv88e6xxx_port_fdb_prepare,
86 .port_fdb_add = mv88e6xxx_port_fdb_add,
87 .port_fdb_del = mv88e6xxx_port_fdb_del,
88 .port_fdb_dump = mv88e6xxx_port_fdb_dump,
89};
90
91MODULE_ALIAS("platform:mv88e6123");
92MODULE_ALIAS("platform:mv88e6161");
93MODULE_ALIAS("platform:mv88e6165");
diff --git a/drivers/net/dsa/mv88e6131.c b/drivers/net/dsa/mv88e6131.c
deleted file mode 100644
index bbad199b50aa..000000000000
--- a/drivers/net/dsa/mv88e6131.c
+++ /dev/null
@@ -1,101 +0,0 @@
1/*
2 * net/dsa/mv88e6131.c - Marvell 88e6095/6095f/6131 switch chip support
3 * Copyright (c) 2008-2009 Marvell Semiconductor
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 */
10
11#include <linux/delay.h>
12#include <linux/jiffies.h>
13#include <linux/list.h>
14#include <linux/module.h>
15#include <linux/netdevice.h>
16#include <linux/phy.h>
17#include <net/dsa.h>
18#include "mv88e6xxx.h"
19
20static const struct mv88e6xxx_info mv88e6131_table[] = {
21 {
22 .prod_num = PORT_SWITCH_ID_PROD_NUM_6095,
23 .family = MV88E6XXX_FAMILY_6095,
24 .name = "Marvell 88E6095/88E6095F",
25 .num_databases = 256,
26 .num_ports = 11,
27 .flags = MV88E6XXX_FLAGS_FAMILY_6095,
28 }, {
29 .prod_num = PORT_SWITCH_ID_PROD_NUM_6085,
30 .family = MV88E6XXX_FAMILY_6097,
31 .name = "Marvell 88E6085",
32 .num_databases = 4096,
33 .num_ports = 10,
34 .flags = MV88E6XXX_FLAGS_FAMILY_6097,
35 }, {
36 .prod_num = PORT_SWITCH_ID_PROD_NUM_6131,
37 .family = MV88E6XXX_FAMILY_6185,
38 .name = "Marvell 88E6131",
39 .num_databases = 256,
40 .num_ports = 8,
41 .flags = MV88E6XXX_FLAGS_FAMILY_6185,
42 }, {
43 .prod_num = PORT_SWITCH_ID_PROD_NUM_6185,
44 .family = MV88E6XXX_FAMILY_6185,
45 .name = "Marvell 88E6185",
46 .num_databases = 256,
47 .num_ports = 10,
48 .flags = MV88E6XXX_FLAGS_FAMILY_6185,
49 }
50};
51
52static const char *mv88e6131_drv_probe(struct device *dsa_dev,
53 struct device *host_dev, int sw_addr,
54 void **priv)
55{
56 return mv88e6xxx_drv_probe(dsa_dev, host_dev, sw_addr, priv,
57 mv88e6131_table,
58 ARRAY_SIZE(mv88e6131_table));
59}
60
61struct dsa_switch_driver mv88e6131_switch_driver = {
62 .tag_protocol = DSA_TAG_PROTO_EDSA,
63 .probe = mv88e6131_drv_probe,
64 .setup = mv88e6xxx_setup,
65 .set_addr = mv88e6xxx_set_addr,
66 .phy_read = mv88e6xxx_phy_read,
67 .phy_write = mv88e6xxx_phy_write,
68 .set_eee = mv88e6xxx_set_eee,
69 .get_eee = mv88e6xxx_get_eee,
70 .get_strings = mv88e6xxx_get_strings,
71 .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
72 .get_sset_count = mv88e6xxx_get_sset_count,
73 .get_eeprom = mv88e6xxx_get_eeprom,
74 .set_eeprom = mv88e6xxx_set_eeprom,
75 .get_regs_len = mv88e6xxx_get_regs_len,
76 .get_regs = mv88e6xxx_get_regs,
77#ifdef CONFIG_NET_DSA_HWMON
78 .get_temp = mv88e6xxx_get_temp,
79 .get_temp_limit = mv88e6xxx_get_temp_limit,
80 .set_temp_limit = mv88e6xxx_set_temp_limit,
81 .get_temp_alarm = mv88e6xxx_get_temp_alarm,
82#endif
83 .adjust_link = mv88e6xxx_adjust_link,
84 .port_bridge_join = mv88e6xxx_port_bridge_join,
85 .port_bridge_leave = mv88e6xxx_port_bridge_leave,
86 .port_stp_state_set = mv88e6xxx_port_stp_state_set,
87 .port_vlan_filtering = mv88e6xxx_port_vlan_filtering,
88 .port_vlan_prepare = mv88e6xxx_port_vlan_prepare,
89 .port_vlan_add = mv88e6xxx_port_vlan_add,
90 .port_vlan_del = mv88e6xxx_port_vlan_del,
91 .port_vlan_dump = mv88e6xxx_port_vlan_dump,
92 .port_fdb_prepare = mv88e6xxx_port_fdb_prepare,
93 .port_fdb_add = mv88e6xxx_port_fdb_add,
94 .port_fdb_del = mv88e6xxx_port_fdb_del,
95 .port_fdb_dump = mv88e6xxx_port_fdb_dump,
96};
97
98MODULE_ALIAS("platform:mv88e6085");
99MODULE_ALIAS("platform:mv88e6095");
100MODULE_ALIAS("platform:mv88e6095f");
101MODULE_ALIAS("platform:mv88e6131");
diff --git a/drivers/net/dsa/mv88e6171.c b/drivers/net/dsa/mv88e6171.c
deleted file mode 100644
index 4bf517a86acb..000000000000
--- a/drivers/net/dsa/mv88e6171.c
+++ /dev/null
@@ -1,101 +0,0 @@
1/* net/dsa/mv88e6171.c - Marvell 88e6171 switch chip support
2 * Copyright (c) 2008-2009 Marvell Semiconductor
3 * Copyright (c) 2014 Claudio Leite <leitec@staticky.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 */
10
11#include <linux/delay.h>
12#include <linux/jiffies.h>
13#include <linux/list.h>
14#include <linux/module.h>
15#include <linux/netdevice.h>
16#include <linux/phy.h>
17#include <net/dsa.h>
18#include "mv88e6xxx.h"
19
20static const struct mv88e6xxx_info mv88e6171_table[] = {
21 {
22 .prod_num = PORT_SWITCH_ID_PROD_NUM_6171,
23 .family = MV88E6XXX_FAMILY_6351,
24 .name = "Marvell 88E6171",
25 .num_databases = 4096,
26 .num_ports = 7,
27 .flags = MV88E6XXX_FLAGS_FAMILY_6351,
28 }, {
29 .prod_num = PORT_SWITCH_ID_PROD_NUM_6175,
30 .family = MV88E6XXX_FAMILY_6351,
31 .name = "Marvell 88E6175",
32 .num_databases = 4096,
33 .num_ports = 7,
34 .flags = MV88E6XXX_FLAGS_FAMILY_6351,
35 }, {
36 .prod_num = PORT_SWITCH_ID_PROD_NUM_6350,
37 .family = MV88E6XXX_FAMILY_6351,
38 .name = "Marvell 88E6350",
39 .num_databases = 4096,
40 .num_ports = 7,
41 .flags = MV88E6XXX_FLAGS_FAMILY_6351,
42 }, {
43 .prod_num = PORT_SWITCH_ID_PROD_NUM_6351,
44 .family = MV88E6XXX_FAMILY_6351,
45 .name = "Marvell 88E6351",
46 .num_databases = 4096,
47 .num_ports = 7,
48 .flags = MV88E6XXX_FLAGS_FAMILY_6351,
49 }
50};
51
52static const char *mv88e6171_drv_probe(struct device *dsa_dev,
53 struct device *host_dev, int sw_addr,
54 void **priv)
55{
56 return mv88e6xxx_drv_probe(dsa_dev, host_dev, sw_addr, priv,
57 mv88e6171_table,
58 ARRAY_SIZE(mv88e6171_table));
59}
60
61struct dsa_switch_driver mv88e6171_switch_driver = {
62 .tag_protocol = DSA_TAG_PROTO_EDSA,
63 .probe = mv88e6171_drv_probe,
64 .setup = mv88e6xxx_setup,
65 .set_addr = mv88e6xxx_set_addr,
66 .phy_read = mv88e6xxx_phy_read,
67 .phy_write = mv88e6xxx_phy_write,
68 .set_eee = mv88e6xxx_set_eee,
69 .get_eee = mv88e6xxx_get_eee,
70 .get_strings = mv88e6xxx_get_strings,
71 .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
72 .get_sset_count = mv88e6xxx_get_sset_count,
73 .adjust_link = mv88e6xxx_adjust_link,
74#ifdef CONFIG_NET_DSA_HWMON
75 .get_temp = mv88e6xxx_get_temp,
76 .get_temp_limit = mv88e6xxx_get_temp_limit,
77 .set_temp_limit = mv88e6xxx_set_temp_limit,
78 .get_temp_alarm = mv88e6xxx_get_temp_alarm,
79#endif
80 .get_eeprom = mv88e6xxx_get_eeprom,
81 .set_eeprom = mv88e6xxx_set_eeprom,
82 .get_regs_len = mv88e6xxx_get_regs_len,
83 .get_regs = mv88e6xxx_get_regs,
84 .port_bridge_join = mv88e6xxx_port_bridge_join,
85 .port_bridge_leave = mv88e6xxx_port_bridge_leave,
86 .port_stp_state_set = mv88e6xxx_port_stp_state_set,
87 .port_vlan_filtering = mv88e6xxx_port_vlan_filtering,
88 .port_vlan_prepare = mv88e6xxx_port_vlan_prepare,
89 .port_vlan_add = mv88e6xxx_port_vlan_add,
90 .port_vlan_del = mv88e6xxx_port_vlan_del,
91 .port_vlan_dump = mv88e6xxx_port_vlan_dump,
92 .port_fdb_prepare = mv88e6xxx_port_fdb_prepare,
93 .port_fdb_add = mv88e6xxx_port_fdb_add,
94 .port_fdb_del = mv88e6xxx_port_fdb_del,
95 .port_fdb_dump = mv88e6xxx_port_fdb_dump,
96};
97
98MODULE_ALIAS("platform:mv88e6171");
99MODULE_ALIAS("platform:mv88e6175");
100MODULE_ALIAS("platform:mv88e6350");
101MODULE_ALIAS("platform:mv88e6351");
diff --git a/drivers/net/dsa/mv88e6352.c b/drivers/net/dsa/mv88e6352.c
deleted file mode 100644
index d65a90dca0b4..000000000000
--- a/drivers/net/dsa/mv88e6352.c
+++ /dev/null
@@ -1,121 +0,0 @@
1/*
2 * net/dsa/mv88e6352.c - Marvell 88e6352 switch chip support
3 *
4 * Copyright (c) 2014 Guenter Roeck
5 *
6 * Derived from mv88e6123_61_65.c
7 * Copyright (c) 2008-2009 Marvell Semiconductor
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 */
14
15#include <linux/delay.h>
16#include <linux/jiffies.h>
17#include <linux/list.h>
18#include <linux/module.h>
19#include <linux/netdevice.h>
20#include <linux/platform_device.h>
21#include <linux/phy.h>
22#include <net/dsa.h>
23#include "mv88e6xxx.h"
24
25static const struct mv88e6xxx_info mv88e6352_table[] = {
26 {
27 .prod_num = PORT_SWITCH_ID_PROD_NUM_6320,
28 .family = MV88E6XXX_FAMILY_6320,
29 .name = "Marvell 88E6320",
30 .num_databases = 4096,
31 .num_ports = 7,
32 .flags = MV88E6XXX_FLAGS_FAMILY_6320,
33 }, {
34 .prod_num = PORT_SWITCH_ID_PROD_NUM_6321,
35 .family = MV88E6XXX_FAMILY_6320,
36 .name = "Marvell 88E6321",
37 .num_databases = 4096,
38 .num_ports = 7,
39 .flags = MV88E6XXX_FLAGS_FAMILY_6320,
40 }, {
41 .prod_num = PORT_SWITCH_ID_PROD_NUM_6172,
42 .family = MV88E6XXX_FAMILY_6352,
43 .name = "Marvell 88E6172",
44 .num_databases = 4096,
45 .num_ports = 7,
46 .flags = MV88E6XXX_FLAGS_FAMILY_6352,
47 }, {
48 .prod_num = PORT_SWITCH_ID_PROD_NUM_6176,
49 .family = MV88E6XXX_FAMILY_6352,
50 .name = "Marvell 88E6176",
51 .num_databases = 4096,
52 .num_ports = 7,
53 .flags = MV88E6XXX_FLAGS_FAMILY_6352,
54 }, {
55 .prod_num = PORT_SWITCH_ID_PROD_NUM_6240,
56 .family = MV88E6XXX_FAMILY_6352,
57 .name = "Marvell 88E6240",
58 .num_databases = 4096,
59 .num_ports = 7,
60 .flags = MV88E6XXX_FLAGS_FAMILY_6352,
61 }, {
62 .prod_num = PORT_SWITCH_ID_PROD_NUM_6352,
63 .family = MV88E6XXX_FAMILY_6352,
64 .name = "Marvell 88E6352",
65 .num_databases = 4096,
66 .num_ports = 7,
67 .flags = MV88E6XXX_FLAGS_FAMILY_6352,
68 }
69};
70
71static const char *mv88e6352_drv_probe(struct device *dsa_dev,
72 struct device *host_dev, int sw_addr,
73 void **priv)
74{
75 return mv88e6xxx_drv_probe(dsa_dev, host_dev, sw_addr, priv,
76 mv88e6352_table,
77 ARRAY_SIZE(mv88e6352_table));
78}
79
80struct dsa_switch_driver mv88e6352_switch_driver = {
81 .tag_protocol = DSA_TAG_PROTO_EDSA,
82 .probe = mv88e6352_drv_probe,
83 .setup = mv88e6xxx_setup,
84 .set_addr = mv88e6xxx_set_addr,
85 .phy_read = mv88e6xxx_phy_read,
86 .phy_write = mv88e6xxx_phy_write,
87 .get_strings = mv88e6xxx_get_strings,
88 .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
89 .get_sset_count = mv88e6xxx_get_sset_count,
90 .adjust_link = mv88e6xxx_adjust_link,
91 .set_eee = mv88e6xxx_set_eee,
92 .get_eee = mv88e6xxx_get_eee,
93#ifdef CONFIG_NET_DSA_HWMON
94 .get_temp = mv88e6xxx_get_temp,
95 .get_temp_limit = mv88e6xxx_get_temp_limit,
96 .set_temp_limit = mv88e6xxx_set_temp_limit,
97 .get_temp_alarm = mv88e6xxx_get_temp_alarm,
98#endif
99 .get_eeprom = mv88e6xxx_get_eeprom,
100 .set_eeprom = mv88e6xxx_set_eeprom,
101 .get_regs_len = mv88e6xxx_get_regs_len,
102 .get_regs = mv88e6xxx_get_regs,
103 .port_bridge_join = mv88e6xxx_port_bridge_join,
104 .port_bridge_leave = mv88e6xxx_port_bridge_leave,
105 .port_stp_state_set = mv88e6xxx_port_stp_state_set,
106 .port_vlan_filtering = mv88e6xxx_port_vlan_filtering,
107 .port_vlan_prepare = mv88e6xxx_port_vlan_prepare,
108 .port_vlan_add = mv88e6xxx_port_vlan_add,
109 .port_vlan_del = mv88e6xxx_port_vlan_del,
110 .port_vlan_dump = mv88e6xxx_port_vlan_dump,
111 .port_fdb_prepare = mv88e6xxx_port_fdb_prepare,
112 .port_fdb_add = mv88e6xxx_port_fdb_add,
113 .port_fdb_del = mv88e6xxx_port_fdb_del,
114 .port_fdb_dump = mv88e6xxx_port_fdb_dump,
115};
116
117MODULE_ALIAS("platform:mv88e6172");
118MODULE_ALIAS("platform:mv88e6176");
119MODULE_ALIAS("platform:mv88e6320");
120MODULE_ALIAS("platform:mv88e6321");
121MODULE_ALIAS("platform:mv88e6352");
diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c
index 7ea30502d221..1e5ca8e0f48e 100644
--- a/drivers/net/dsa/mv88e6xxx.c
+++ b/drivers/net/dsa/mv88e6xxx.c
@@ -467,8 +467,8 @@ static bool mv88e6xxx_has_stu(struct mv88e6xxx_priv_state *ps)
467 * phy. However, in the case of a fixed link phy, we force the port 467 * phy. However, in the case of a fixed link phy, we force the port
468 * settings from the fixed link settings. 468 * settings from the fixed link settings.
469 */ 469 */
470void mv88e6xxx_adjust_link(struct dsa_switch *ds, int port, 470static void mv88e6xxx_adjust_link(struct dsa_switch *ds, int port,
471 struct phy_device *phydev) 471 struct phy_device *phydev)
472{ 472{
473 struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); 473 struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
474 u32 reg; 474 u32 reg;
@@ -714,7 +714,8 @@ static uint64_t _mv88e6xxx_get_ethtool_stat(struct mv88e6xxx_priv_state *ps,
714 return value; 714 return value;
715} 715}
716 716
717void mv88e6xxx_get_strings(struct dsa_switch *ds, int port, uint8_t *data) 717static void mv88e6xxx_get_strings(struct dsa_switch *ds, int port,
718 uint8_t *data)
718{ 719{
719 struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); 720 struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
720 struct mv88e6xxx_hw_stat *stat; 721 struct mv88e6xxx_hw_stat *stat;
@@ -730,7 +731,7 @@ void mv88e6xxx_get_strings(struct dsa_switch *ds, int port, uint8_t *data)
730 } 731 }
731} 732}
732 733
733int mv88e6xxx_get_sset_count(struct dsa_switch *ds) 734static int mv88e6xxx_get_sset_count(struct dsa_switch *ds)
734{ 735{
735 struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); 736 struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
736 struct mv88e6xxx_hw_stat *stat; 737 struct mv88e6xxx_hw_stat *stat;
@@ -744,9 +745,8 @@ int mv88e6xxx_get_sset_count(struct dsa_switch *ds)
744 return j; 745 return j;
745} 746}
746 747
747void 748static void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int port,
748mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, 749 uint64_t *data)
749 int port, uint64_t *data)
750{ 750{
751 struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); 751 struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
752 struct mv88e6xxx_hw_stat *stat; 752 struct mv88e6xxx_hw_stat *stat;
@@ -771,13 +771,13 @@ mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds,
771 mutex_unlock(&ps->smi_mutex); 771 mutex_unlock(&ps->smi_mutex);
772} 772}
773 773
774int mv88e6xxx_get_regs_len(struct dsa_switch *ds, int port) 774static int mv88e6xxx_get_regs_len(struct dsa_switch *ds, int port)
775{ 775{
776 return 32 * sizeof(u16); 776 return 32 * sizeof(u16);
777} 777}
778 778
779void mv88e6xxx_get_regs(struct dsa_switch *ds, int port, 779static void mv88e6xxx_get_regs(struct dsa_switch *ds, int port,
780 struct ethtool_regs *regs, void *_p) 780 struct ethtool_regs *regs, void *_p)
781{ 781{
782 struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); 782 struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
783 u16 *p = _p; 783 u16 *p = _p;
@@ -876,8 +876,8 @@ error:
876 return ret; 876 return ret;
877} 877}
878 878
879int mv88e6xxx_get_eeprom(struct dsa_switch *ds, struct ethtool_eeprom *eeprom, 879static int mv88e6xxx_get_eeprom(struct dsa_switch *ds,
880 u8 *data) 880 struct ethtool_eeprom *eeprom, u8 *data)
881{ 881{
882 struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); 882 struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
883 int offset; 883 int offset;
@@ -982,8 +982,8 @@ error:
982 return ret; 982 return ret;
983} 983}
984 984
985int mv88e6xxx_set_eeprom(struct dsa_switch *ds, struct ethtool_eeprom *eeprom, 985static int mv88e6xxx_set_eeprom(struct dsa_switch *ds,
986 u8 *data) 986 struct ethtool_eeprom *eeprom, u8 *data)
987{ 987{
988 struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); 988 struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
989 int offset; 989 int offset;
@@ -1104,7 +1104,8 @@ static int _mv88e6xxx_phy_write_indirect(struct mv88e6xxx_priv_state *ps,
1104 return _mv88e6xxx_phy_wait(ps); 1104 return _mv88e6xxx_phy_wait(ps);
1105} 1105}
1106 1106
1107int mv88e6xxx_get_eee(struct dsa_switch *ds, int port, struct ethtool_eee *e) 1107static int mv88e6xxx_get_eee(struct dsa_switch *ds, int port,
1108 struct ethtool_eee *e)
1108{ 1109{
1109 struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); 1110 struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
1110 int reg; 1111 int reg;
@@ -1133,8 +1134,8 @@ out:
1133 return reg; 1134 return reg;
1134} 1135}
1135 1136
1136int mv88e6xxx_set_eee(struct dsa_switch *ds, int port, 1137static int mv88e6xxx_set_eee(struct dsa_switch *ds, int port,
1137 struct phy_device *phydev, struct ethtool_eee *e) 1138 struct phy_device *phydev, struct ethtool_eee *e)
1138{ 1139{
1139 struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); 1140 struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
1140 int reg; 1141 int reg;
@@ -1364,7 +1365,8 @@ static int _mv88e6xxx_port_based_vlan_map(struct mv88e6xxx_priv_state *ps,
1364 return _mv88e6xxx_reg_write(ps, REG_PORT(port), PORT_BASE_VLAN, reg); 1365 return _mv88e6xxx_reg_write(ps, REG_PORT(port), PORT_BASE_VLAN, reg);
1365} 1366}
1366 1367
1367void mv88e6xxx_port_stp_state_set(struct dsa_switch *ds, int port, u8 state) 1368static void mv88e6xxx_port_stp_state_set(struct dsa_switch *ds, int port,
1369 u8 state)
1368{ 1370{
1369 struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); 1371 struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
1370 int stp_state; 1372 int stp_state;
@@ -1587,9 +1589,9 @@ static int _mv88e6xxx_vtu_getnext(struct mv88e6xxx_priv_state *ps,
1587 return 0; 1589 return 0;
1588} 1590}
1589 1591
1590int mv88e6xxx_port_vlan_dump(struct dsa_switch *ds, int port, 1592static int mv88e6xxx_port_vlan_dump(struct dsa_switch *ds, int port,
1591 struct switchdev_obj_port_vlan *vlan, 1593 struct switchdev_obj_port_vlan *vlan,
1592 int (*cb)(struct switchdev_obj *obj)) 1594 int (*cb)(struct switchdev_obj *obj))
1593{ 1595{
1594 struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); 1596 struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
1595 struct mv88e6xxx_vtu_stu_entry next; 1597 struct mv88e6xxx_vtu_stu_entry next;
@@ -2014,8 +2016,8 @@ static const char * const mv88e6xxx_port_8021q_mode_names[] = {
2014 [PORT_CONTROL_2_8021Q_SECURE] = "Secure", 2016 [PORT_CONTROL_2_8021Q_SECURE] = "Secure",
2015}; 2017};
2016 2018
2017int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port, 2019static int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port,
2018 bool vlan_filtering) 2020 bool vlan_filtering)
2019{ 2021{
2020 struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); 2022 struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
2021 u16 old, new = vlan_filtering ? PORT_CONTROL_2_8021Q_SECURE : 2023 u16 old, new = vlan_filtering ? PORT_CONTROL_2_8021Q_SECURE :
@@ -2054,9 +2056,9 @@ unlock:
2054 return ret; 2056 return ret;
2055} 2057}
2056 2058
2057int mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port, 2059static int mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port,
2058 const struct switchdev_obj_port_vlan *vlan, 2060 const struct switchdev_obj_port_vlan *vlan,
2059 struct switchdev_trans *trans) 2061 struct switchdev_trans *trans)
2060{ 2062{
2061 struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); 2063 struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
2062 int err; 2064 int err;
@@ -2095,9 +2097,9 @@ static int _mv88e6xxx_port_vlan_add(struct mv88e6xxx_priv_state *ps, int port,
2095 return _mv88e6xxx_vtu_loadpurge(ps, &vlan); 2097 return _mv88e6xxx_vtu_loadpurge(ps, &vlan);
2096} 2098}
2097 2099
2098void mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port, 2100static void mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port,
2099 const struct switchdev_obj_port_vlan *vlan, 2101 const struct switchdev_obj_port_vlan *vlan,
2100 struct switchdev_trans *trans) 2102 struct switchdev_trans *trans)
2101{ 2103{
2102 struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); 2104 struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
2103 bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED; 2105 bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
@@ -2157,8 +2159,8 @@ static int _mv88e6xxx_port_vlan_del(struct mv88e6xxx_priv_state *ps,
2157 return _mv88e6xxx_atu_remove(ps, vlan.fid, port, false); 2159 return _mv88e6xxx_atu_remove(ps, vlan.fid, port, false);
2158} 2160}
2159 2161
2160int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port, 2162static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port,
2161 const struct switchdev_obj_port_vlan *vlan) 2163 const struct switchdev_obj_port_vlan *vlan)
2162{ 2164{
2163 struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); 2165 struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
2164 u16 pvid, vid; 2166 u16 pvid, vid;
@@ -2271,9 +2273,9 @@ static int _mv88e6xxx_port_fdb_load(struct mv88e6xxx_priv_state *ps, int port,
2271 return _mv88e6xxx_atu_load(ps, &entry); 2273 return _mv88e6xxx_atu_load(ps, &entry);
2272} 2274}
2273 2275
2274int mv88e6xxx_port_fdb_prepare(struct dsa_switch *ds, int port, 2276static int mv88e6xxx_port_fdb_prepare(struct dsa_switch *ds, int port,
2275 const struct switchdev_obj_port_fdb *fdb, 2277 const struct switchdev_obj_port_fdb *fdb,
2276 struct switchdev_trans *trans) 2278 struct switchdev_trans *trans)
2277{ 2279{
2278 struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); 2280 struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
2279 2281
@@ -2286,9 +2288,9 @@ int mv88e6xxx_port_fdb_prepare(struct dsa_switch *ds, int port,
2286 return 0; 2288 return 0;
2287} 2289}
2288 2290
2289void mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port, 2291static void mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
2290 const struct switchdev_obj_port_fdb *fdb, 2292 const struct switchdev_obj_port_fdb *fdb,
2291 struct switchdev_trans *trans) 2293 struct switchdev_trans *trans)
2292{ 2294{
2293 int state = is_multicast_ether_addr(fdb->addr) ? 2295 int state = is_multicast_ether_addr(fdb->addr) ?
2294 GLOBAL_ATU_DATA_STATE_MC_STATIC : 2296 GLOBAL_ATU_DATA_STATE_MC_STATIC :
@@ -2304,8 +2306,8 @@ void mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
2304 mutex_unlock(&ps->smi_mutex); 2306 mutex_unlock(&ps->smi_mutex);
2305} 2307}
2306 2308
2307int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port, 2309static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
2308 const struct switchdev_obj_port_fdb *fdb) 2310 const struct switchdev_obj_port_fdb *fdb)
2309{ 2311{
2310 struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); 2312 struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
2311 int ret; 2313 int ret;
@@ -2407,9 +2409,9 @@ static int _mv88e6xxx_port_fdb_dump_one(struct mv88e6xxx_priv_state *ps,
2407 return err; 2409 return err;
2408} 2410}
2409 2411
2410int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port, 2412static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
2411 struct switchdev_obj_port_fdb *fdb, 2413 struct switchdev_obj_port_fdb *fdb,
2412 int (*cb)(struct switchdev_obj *obj)) 2414 int (*cb)(struct switchdev_obj *obj))
2413{ 2415{
2414 struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); 2416 struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
2415 struct mv88e6xxx_vtu_stu_entry vlan = { 2417 struct mv88e6xxx_vtu_stu_entry vlan = {
@@ -2457,8 +2459,8 @@ unlock:
2457 return err; 2459 return err;
2458} 2460}
2459 2461
2460int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port, 2462static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
2461 struct net_device *bridge) 2463 struct net_device *bridge)
2462{ 2464{
2463 struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); 2465 struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
2464 int i, err = 0; 2466 int i, err = 0;
@@ -2484,7 +2486,7 @@ int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
2484 return err; 2486 return err;
2485} 2487}
2486 2488
2487void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port) 2489static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port)
2488{ 2490{
2489 struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); 2491 struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
2490 struct net_device *bridge = ps->ports[port].bridge_dev; 2492 struct net_device *bridge = ps->ports[port].bridge_dev;
@@ -3108,7 +3110,7 @@ static int mv88e6xxx_setup_global(struct mv88e6xxx_priv_state *ps)
3108 return err; 3110 return err;
3109} 3111}
3110 3112
3111int mv88e6xxx_setup(struct dsa_switch *ds) 3113static int mv88e6xxx_setup(struct dsa_switch *ds)
3112{ 3114{
3113 struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); 3115 struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
3114 int err; 3116 int err;
@@ -3181,8 +3183,7 @@ static int mv88e6xxx_port_to_phy_addr(struct mv88e6xxx_priv_state *ps,
3181 return -EINVAL; 3183 return -EINVAL;
3182} 3184}
3183 3185
3184int 3186static int mv88e6xxx_phy_read(struct dsa_switch *ds, int port, int regnum)
3185mv88e6xxx_phy_read(struct dsa_switch *ds, int port, int regnum)
3186{ 3187{
3187 struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); 3188 struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
3188 int addr = mv88e6xxx_port_to_phy_addr(ps, port); 3189 int addr = mv88e6xxx_port_to_phy_addr(ps, port);
@@ -3204,8 +3205,8 @@ mv88e6xxx_phy_read(struct dsa_switch *ds, int port, int regnum)
3204 return ret; 3205 return ret;
3205} 3206}
3206 3207
3207int 3208static int mv88e6xxx_phy_write(struct dsa_switch *ds, int port, int regnum,
3208mv88e6xxx_phy_write(struct dsa_switch *ds, int port, int regnum, u16 val) 3209 u16 val)
3209{ 3210{
3210 struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); 3211 struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
3211 int addr = mv88e6xxx_port_to_phy_addr(ps, port); 3212 int addr = mv88e6xxx_port_to_phy_addr(ps, port);
@@ -3291,7 +3292,7 @@ static int mv88e63xx_get_temp(struct dsa_switch *ds, int *temp)
3291 return 0; 3292 return 0;
3292} 3293}
3293 3294
3294int mv88e6xxx_get_temp(struct dsa_switch *ds, int *temp) 3295static int mv88e6xxx_get_temp(struct dsa_switch *ds, int *temp)
3295{ 3296{
3296 struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); 3297 struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
3297 3298
@@ -3304,7 +3305,7 @@ int mv88e6xxx_get_temp(struct dsa_switch *ds, int *temp)
3304 return mv88e61xx_get_temp(ds, temp); 3305 return mv88e61xx_get_temp(ds, temp);
3305} 3306}
3306 3307
3307int mv88e6xxx_get_temp_limit(struct dsa_switch *ds, int *temp) 3308static int mv88e6xxx_get_temp_limit(struct dsa_switch *ds, int *temp)
3308{ 3309{
3309 struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); 3310 struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
3310 int phy = mv88e6xxx_6320_family(ps) ? 3 : 0; 3311 int phy = mv88e6xxx_6320_family(ps) ? 3 : 0;
@@ -3324,7 +3325,7 @@ int mv88e6xxx_get_temp_limit(struct dsa_switch *ds, int *temp)
3324 return 0; 3325 return 0;
3325} 3326}
3326 3327
3327int mv88e6xxx_set_temp_limit(struct dsa_switch *ds, int temp) 3328static int mv88e6xxx_set_temp_limit(struct dsa_switch *ds, int temp)
3328{ 3329{
3329 struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); 3330 struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
3330 int phy = mv88e6xxx_6320_family(ps) ? 3 : 0; 3331 int phy = mv88e6xxx_6320_family(ps) ? 3 : 0;
@@ -3341,7 +3342,7 @@ int mv88e6xxx_set_temp_limit(struct dsa_switch *ds, int temp)
3341 (ret & 0xe0ff) | (temp << 8)); 3342 (ret & 0xe0ff) | (temp << 8));
3342} 3343}
3343 3344
3344int mv88e6xxx_get_temp_alarm(struct dsa_switch *ds, bool *alarm) 3345static int mv88e6xxx_get_temp_alarm(struct dsa_switch *ds, bool *alarm)
3345{ 3346{
3346 struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); 3347 struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
3347 int phy = mv88e6xxx_6320_family(ps) ? 3 : 0; 3348 int phy = mv88e6xxx_6320_family(ps) ? 3 : 0;
@@ -3362,6 +3363,161 @@ int mv88e6xxx_get_temp_alarm(struct dsa_switch *ds, bool *alarm)
3362} 3363}
3363#endif /* CONFIG_NET_DSA_HWMON */ 3364#endif /* CONFIG_NET_DSA_HWMON */
3364 3365
3366static const struct mv88e6xxx_info mv88e6xxx_table[] = {
3367 [MV88E6085] = {
3368 .prod_num = PORT_SWITCH_ID_PROD_NUM_6085,
3369 .family = MV88E6XXX_FAMILY_6097,
3370 .name = "Marvell 88E6085",
3371 .num_databases = 4096,
3372 .num_ports = 10,
3373 .flags = MV88E6XXX_FLAGS_FAMILY_6097,
3374 },
3375
3376 [MV88E6095] = {
3377 .prod_num = PORT_SWITCH_ID_PROD_NUM_6095,
3378 .family = MV88E6XXX_FAMILY_6095,
3379 .name = "Marvell 88E6095/88E6095F",
3380 .num_databases = 256,
3381 .num_ports = 11,
3382 .flags = MV88E6XXX_FLAGS_FAMILY_6095,
3383 },
3384
3385 [MV88E6123] = {
3386 .prod_num = PORT_SWITCH_ID_PROD_NUM_6123,
3387 .family = MV88E6XXX_FAMILY_6165,
3388 .name = "Marvell 88E6123",
3389 .num_databases = 4096,
3390 .num_ports = 3,
3391 .flags = MV88E6XXX_FLAGS_FAMILY_6165,
3392 },
3393
3394 [MV88E6131] = {
3395 .prod_num = PORT_SWITCH_ID_PROD_NUM_6131,
3396 .family = MV88E6XXX_FAMILY_6185,
3397 .name = "Marvell 88E6131",
3398 .num_databases = 256,
3399 .num_ports = 8,
3400 .flags = MV88E6XXX_FLAGS_FAMILY_6185,
3401 },
3402
3403 [MV88E6161] = {
3404 .prod_num = PORT_SWITCH_ID_PROD_NUM_6161,
3405 .family = MV88E6XXX_FAMILY_6165,
3406 .name = "Marvell 88E6161",
3407 .num_databases = 4096,
3408 .num_ports = 6,
3409 .flags = MV88E6XXX_FLAGS_FAMILY_6165,
3410 },
3411
3412 [MV88E6165] = {
3413 .prod_num = PORT_SWITCH_ID_PROD_NUM_6165,
3414 .family = MV88E6XXX_FAMILY_6165,
3415 .name = "Marvell 88E6165",
3416 .num_databases = 4096,
3417 .num_ports = 6,
3418 .flags = MV88E6XXX_FLAGS_FAMILY_6165,
3419 },
3420
3421 [MV88E6171] = {
3422 .prod_num = PORT_SWITCH_ID_PROD_NUM_6171,
3423 .family = MV88E6XXX_FAMILY_6351,
3424 .name = "Marvell 88E6171",
3425 .num_databases = 4096,
3426 .num_ports = 7,
3427 .flags = MV88E6XXX_FLAGS_FAMILY_6351,
3428 },
3429
3430 [MV88E6172] = {
3431 .prod_num = PORT_SWITCH_ID_PROD_NUM_6172,
3432 .family = MV88E6XXX_FAMILY_6352,
3433 .name = "Marvell 88E6172",
3434 .num_databases = 4096,
3435 .num_ports = 7,
3436 .flags = MV88E6XXX_FLAGS_FAMILY_6352,
3437 },
3438
3439 [MV88E6175] = {
3440 .prod_num = PORT_SWITCH_ID_PROD_NUM_6175,
3441 .family = MV88E6XXX_FAMILY_6351,
3442 .name = "Marvell 88E6175",
3443 .num_databases = 4096,
3444 .num_ports = 7,
3445 .flags = MV88E6XXX_FLAGS_FAMILY_6351,
3446 },
3447
3448 [MV88E6176] = {
3449 .prod_num = PORT_SWITCH_ID_PROD_NUM_6176,
3450 .family = MV88E6XXX_FAMILY_6352,
3451 .name = "Marvell 88E6176",
3452 .num_databases = 4096,
3453 .num_ports = 7,
3454 .flags = MV88E6XXX_FLAGS_FAMILY_6352,
3455 },
3456
3457 [MV88E6185] = {
3458 .prod_num = PORT_SWITCH_ID_PROD_NUM_6185,
3459 .family = MV88E6XXX_FAMILY_6185,
3460 .name = "Marvell 88E6185",
3461 .num_databases = 256,
3462 .num_ports = 10,
3463 .flags = MV88E6XXX_FLAGS_FAMILY_6185,
3464 },
3465
3466 [MV88E6240] = {
3467 .prod_num = PORT_SWITCH_ID_PROD_NUM_6240,
3468 .family = MV88E6XXX_FAMILY_6352,
3469 .name = "Marvell 88E6240",
3470 .num_databases = 4096,
3471 .num_ports = 7,
3472 .flags = MV88E6XXX_FLAGS_FAMILY_6352,
3473 },
3474
3475 [MV88E6320] = {
3476 .prod_num = PORT_SWITCH_ID_PROD_NUM_6320,
3477 .family = MV88E6XXX_FAMILY_6320,
3478 .name = "Marvell 88E6320",
3479 .num_databases = 4096,
3480 .num_ports = 7,
3481 .flags = MV88E6XXX_FLAGS_FAMILY_6320,
3482 },
3483
3484 [MV88E6321] = {
3485 .prod_num = PORT_SWITCH_ID_PROD_NUM_6321,
3486 .family = MV88E6XXX_FAMILY_6320,
3487 .name = "Marvell 88E6321",
3488 .num_databases = 4096,
3489 .num_ports = 7,
3490 .flags = MV88E6XXX_FLAGS_FAMILY_6320,
3491 },
3492
3493 [MV88E6350] = {
3494 .prod_num = PORT_SWITCH_ID_PROD_NUM_6350,
3495 .family = MV88E6XXX_FAMILY_6351,
3496 .name = "Marvell 88E6350",
3497 .num_databases = 4096,
3498 .num_ports = 7,
3499 .flags = MV88E6XXX_FLAGS_FAMILY_6351,
3500 },
3501
3502 [MV88E6351] = {
3503 .prod_num = PORT_SWITCH_ID_PROD_NUM_6351,
3504 .family = MV88E6XXX_FAMILY_6351,
3505 .name = "Marvell 88E6351",
3506 .num_databases = 4096,
3507 .num_ports = 7,
3508 .flags = MV88E6XXX_FLAGS_FAMILY_6351,
3509 },
3510
3511 [MV88E6352] = {
3512 .prod_num = PORT_SWITCH_ID_PROD_NUM_6352,
3513 .family = MV88E6XXX_FAMILY_6352,
3514 .name = "Marvell 88E6352",
3515 .num_databases = 4096,
3516 .num_ports = 7,
3517 .flags = MV88E6XXX_FLAGS_FAMILY_6352,
3518 },
3519};
3520
3365static const struct mv88e6xxx_info * 3521static const struct mv88e6xxx_info *
3366mv88e6xxx_lookup_info(unsigned int prod_num, const struct mv88e6xxx_info *table, 3522mv88e6xxx_lookup_info(unsigned int prod_num, const struct mv88e6xxx_info *table,
3367 unsigned int num) 3523 unsigned int num)
@@ -3375,10 +3531,9 @@ mv88e6xxx_lookup_info(unsigned int prod_num, const struct mv88e6xxx_info *table,
3375 return NULL; 3531 return NULL;
3376} 3532}
3377 3533
3378const char *mv88e6xxx_drv_probe(struct device *dsa_dev, struct device *host_dev, 3534static const char *mv88e6xxx_probe(struct device *dsa_dev,
3379 int sw_addr, void **priv, 3535 struct device *host_dev, int sw_addr,
3380 const struct mv88e6xxx_info *table, 3536 void **priv)
3381 unsigned int num)
3382{ 3537{
3383 const struct mv88e6xxx_info *info; 3538 const struct mv88e6xxx_info *info;
3384 struct mv88e6xxx_priv_state *ps; 3539 struct mv88e6xxx_priv_state *ps;
@@ -3397,7 +3552,8 @@ const char *mv88e6xxx_drv_probe(struct device *dsa_dev, struct device *host_dev,
3397 prod_num = (id & 0xfff0) >> 4; 3552 prod_num = (id & 0xfff0) >> 4;
3398 rev = id & 0x000f; 3553 rev = id & 0x000f;
3399 3554
3400 info = mv88e6xxx_lookup_info(prod_num, table, num); 3555 info = mv88e6xxx_lookup_info(prod_num, mv88e6xxx_table,
3556 ARRAY_SIZE(mv88e6xxx_table));
3401 if (!info) 3557 if (!info)
3402 return NULL; 3558 return NULL;
3403 3559
@@ -3419,41 +3575,73 @@ const char *mv88e6xxx_drv_probe(struct device *dsa_dev, struct device *host_dev,
3419 return name; 3575 return name;
3420} 3576}
3421 3577
3578struct dsa_switch_driver mv88e6xxx_switch_driver = {
3579 .tag_protocol = DSA_TAG_PROTO_EDSA,
3580 .probe = mv88e6xxx_probe,
3581 .setup = mv88e6xxx_setup,
3582 .set_addr = mv88e6xxx_set_addr,
3583 .phy_read = mv88e6xxx_phy_read,
3584 .phy_write = mv88e6xxx_phy_write,
3585 .adjust_link = mv88e6xxx_adjust_link,
3586 .get_strings = mv88e6xxx_get_strings,
3587 .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
3588 .get_sset_count = mv88e6xxx_get_sset_count,
3589 .set_eee = mv88e6xxx_set_eee,
3590 .get_eee = mv88e6xxx_get_eee,
3591#ifdef CONFIG_NET_DSA_HWMON
3592 .get_temp = mv88e6xxx_get_temp,
3593 .get_temp_limit = mv88e6xxx_get_temp_limit,
3594 .set_temp_limit = mv88e6xxx_set_temp_limit,
3595 .get_temp_alarm = mv88e6xxx_get_temp_alarm,
3596#endif
3597 .get_eeprom = mv88e6xxx_get_eeprom,
3598 .set_eeprom = mv88e6xxx_set_eeprom,
3599 .get_regs_len = mv88e6xxx_get_regs_len,
3600 .get_regs = mv88e6xxx_get_regs,
3601 .port_bridge_join = mv88e6xxx_port_bridge_join,
3602 .port_bridge_leave = mv88e6xxx_port_bridge_leave,
3603 .port_stp_state_set = mv88e6xxx_port_stp_state_set,
3604 .port_vlan_filtering = mv88e6xxx_port_vlan_filtering,
3605 .port_vlan_prepare = mv88e6xxx_port_vlan_prepare,
3606 .port_vlan_add = mv88e6xxx_port_vlan_add,
3607 .port_vlan_del = mv88e6xxx_port_vlan_del,
3608 .port_vlan_dump = mv88e6xxx_port_vlan_dump,
3609 .port_fdb_prepare = mv88e6xxx_port_fdb_prepare,
3610 .port_fdb_add = mv88e6xxx_port_fdb_add,
3611 .port_fdb_del = mv88e6xxx_port_fdb_del,
3612 .port_fdb_dump = mv88e6xxx_port_fdb_dump,
3613};
3614
3422static int __init mv88e6xxx_init(void) 3615static int __init mv88e6xxx_init(void)
3423{ 3616{
3424#if IS_ENABLED(CONFIG_NET_DSA_MV88E6131) 3617 register_switch_driver(&mv88e6xxx_switch_driver);
3425 register_switch_driver(&mv88e6131_switch_driver); 3618
3426#endif
3427#if IS_ENABLED(CONFIG_NET_DSA_MV88E6123)
3428 register_switch_driver(&mv88e6123_switch_driver);
3429#endif
3430#if IS_ENABLED(CONFIG_NET_DSA_MV88E6352)
3431 register_switch_driver(&mv88e6352_switch_driver);
3432#endif
3433#if IS_ENABLED(CONFIG_NET_DSA_MV88E6171)
3434 register_switch_driver(&mv88e6171_switch_driver);
3435#endif
3436 return 0; 3619 return 0;
3437} 3620}
3438module_init(mv88e6xxx_init); 3621module_init(mv88e6xxx_init);
3439 3622
3440static void __exit mv88e6xxx_cleanup(void) 3623static void __exit mv88e6xxx_cleanup(void)
3441{ 3624{
3442#if IS_ENABLED(CONFIG_NET_DSA_MV88E6171) 3625 unregister_switch_driver(&mv88e6xxx_switch_driver);
3443 unregister_switch_driver(&mv88e6171_switch_driver);
3444#endif
3445#if IS_ENABLED(CONFIG_NET_DSA_MV88E6352)
3446 unregister_switch_driver(&mv88e6352_switch_driver);
3447#endif
3448#if IS_ENABLED(CONFIG_NET_DSA_MV88E6123)
3449 unregister_switch_driver(&mv88e6123_switch_driver);
3450#endif
3451#if IS_ENABLED(CONFIG_NET_DSA_MV88E6131)
3452 unregister_switch_driver(&mv88e6131_switch_driver);
3453#endif
3454} 3626}
3455module_exit(mv88e6xxx_cleanup); 3627module_exit(mv88e6xxx_cleanup);
3456 3628
3629MODULE_ALIAS("platform:mv88e6085");
3630MODULE_ALIAS("platform:mv88e6095");
3631MODULE_ALIAS("platform:mv88e6095f");
3632MODULE_ALIAS("platform:mv88e6123");
3633MODULE_ALIAS("platform:mv88e6131");
3634MODULE_ALIAS("platform:mv88e6161");
3635MODULE_ALIAS("platform:mv88e6165");
3636MODULE_ALIAS("platform:mv88e6171");
3637MODULE_ALIAS("platform:mv88e6172");
3638MODULE_ALIAS("platform:mv88e6175");
3639MODULE_ALIAS("platform:mv88e6176");
3640MODULE_ALIAS("platform:mv88e6320");
3641MODULE_ALIAS("platform:mv88e6321");
3642MODULE_ALIAS("platform:mv88e6350");
3643MODULE_ALIAS("platform:mv88e6351");
3644MODULE_ALIAS("platform:mv88e6352");
3457MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>"); 3645MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>");
3458MODULE_DESCRIPTION("Driver for Marvell 88E6XXX ethernet switch chips"); 3646MODULE_DESCRIPTION("Driver for Marvell 88E6XXX ethernet switch chips");
3459MODULE_LICENSE("GPL"); 3647MODULE_LICENSE("GPL");
diff --git a/drivers/net/dsa/mv88e6xxx.h b/drivers/net/dsa/mv88e6xxx.h
index a131827cb26d..ca69a93a42a0 100644
--- a/drivers/net/dsa/mv88e6xxx.h
+++ b/drivers/net/dsa/mv88e6xxx.h
@@ -338,6 +338,27 @@
338 338
339#define MV88E6XXX_N_FID 4096 339#define MV88E6XXX_N_FID 4096
340 340
341/* List of supported models */
342enum mv88e6xxx_model {
343 MV88E6085,
344 MV88E6095,
345 MV88E6123,
346 MV88E6131,
347 MV88E6161,
348 MV88E6165,
349 MV88E6171,
350 MV88E6172,
351 MV88E6175,
352 MV88E6176,
353 MV88E6185,
354 MV88E6240,
355 MV88E6320,
356 MV88E6321,
357 MV88E6350,
358 MV88E6351,
359 MV88E6352,
360};
361
341enum mv88e6xxx_family { 362enum mv88e6xxx_family {
342 MV88E6XXX_FAMILY_NONE, 363 MV88E6XXX_FAMILY_NONE,
343 MV88E6XXX_FAMILY_6065, /* 6031 6035 6061 6065 */ 364 MV88E6XXX_FAMILY_6065, /* 6031 6035 6061 6065 */
@@ -583,74 +604,4 @@ static inline bool mv88e6xxx_has(struct mv88e6xxx_priv_state *ps,
583 return (ps->info->flags & flags) == flags; 604 return (ps->info->flags & flags) == flags;
584} 605}
585 606
586const char *mv88e6xxx_drv_probe(struct device *dsa_dev, struct device *host_dev,
587 int sw_addr, void **priv,
588 const struct mv88e6xxx_info *table,
589 unsigned int num);
590
591int mv88e6xxx_setup(struct dsa_switch *ds);
592int mv88e6xxx_reg_read(struct mv88e6xxx_priv_state *ps, int addr, int reg);
593int mv88e6xxx_reg_write(struct mv88e6xxx_priv_state *ps, int addr,
594 int reg, u16 val);
595int mv88e6xxx_set_addr(struct dsa_switch *ds, u8 *addr);
596int mv88e6xxx_phy_read(struct dsa_switch *ds, int port, int regnum);
597int mv88e6xxx_phy_write(struct dsa_switch *ds, int port, int regnum, u16 val);
598void mv88e6xxx_get_strings(struct dsa_switch *ds, int port, uint8_t *data);
599void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int port,
600 uint64_t *data);
601int mv88e6xxx_get_sset_count(struct dsa_switch *ds);
602int mv88e6xxx_get_sset_count_basic(struct dsa_switch *ds);
603void mv88e6xxx_adjust_link(struct dsa_switch *ds, int port,
604 struct phy_device *phydev);
605int mv88e6xxx_get_regs_len(struct dsa_switch *ds, int port);
606void mv88e6xxx_get_regs(struct dsa_switch *ds, int port,
607 struct ethtool_regs *regs, void *_p);
608int mv88e6xxx_get_temp(struct dsa_switch *ds, int *temp);
609int mv88e6xxx_get_temp_limit(struct dsa_switch *ds, int *temp);
610int mv88e6xxx_set_temp_limit(struct dsa_switch *ds, int temp);
611int mv88e6xxx_get_temp_alarm(struct dsa_switch *ds, bool *alarm);
612int mv88e6xxx_get_eeprom(struct dsa_switch *ds, struct ethtool_eeprom *eeprom,
613 u8 *data);
614int mv88e6xxx_set_eeprom(struct dsa_switch *ds, struct ethtool_eeprom *eeprom,
615 u8 *data);
616int mv88e6xxx_get_eee(struct dsa_switch *ds, int port, struct ethtool_eee *e);
617int mv88e6xxx_set_eee(struct dsa_switch *ds, int port,
618 struct phy_device *phydev, struct ethtool_eee *e);
619int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
620 struct net_device *bridge);
621void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port);
622void mv88e6xxx_port_stp_state_set(struct dsa_switch *ds, int port, u8 state);
623int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port,
624 bool vlan_filtering);
625int mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port,
626 const struct switchdev_obj_port_vlan *vlan,
627 struct switchdev_trans *trans);
628void mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port,
629 const struct switchdev_obj_port_vlan *vlan,
630 struct switchdev_trans *trans);
631int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port,
632 const struct switchdev_obj_port_vlan *vlan);
633int mv88e6xxx_port_vlan_dump(struct dsa_switch *ds, int port,
634 struct switchdev_obj_port_vlan *vlan,
635 int (*cb)(struct switchdev_obj *obj));
636int mv88e6xxx_port_fdb_prepare(struct dsa_switch *ds, int port,
637 const struct switchdev_obj_port_fdb *fdb,
638 struct switchdev_trans *trans);
639void mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
640 const struct switchdev_obj_port_fdb *fdb,
641 struct switchdev_trans *trans);
642int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
643 const struct switchdev_obj_port_fdb *fdb);
644int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
645 struct switchdev_obj_port_fdb *fdb,
646 int (*cb)(struct switchdev_obj *obj));
647int mv88e6xxx_phy_page_read(struct dsa_switch *ds, int port, int page, int reg);
648int mv88e6xxx_phy_page_write(struct dsa_switch *ds, int port, int page,
649 int reg, int val);
650
651extern struct dsa_switch_driver mv88e6131_switch_driver;
652extern struct dsa_switch_driver mv88e6123_switch_driver;
653extern struct dsa_switch_driver mv88e6352_switch_driver;
654extern struct dsa_switch_driver mv88e6171_switch_driver;
655
656#endif 607#endif