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>
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.
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>
18 #include "mv88e6xxx.h"
20 static const struct mv88e6xxx_info mv88e6171_table[] = {
22 .prod_num = PORT_SWITCH_ID_PROD_NUM_6171,
23 .family = MV88E6XXX_FAMILY_6351,
24 .name = "Marvell 88E6171",
25 .num_databases = 4096,
28 .prod_num = PORT_SWITCH_ID_PROD_NUM_6175,
29 .family = MV88E6XXX_FAMILY_6351,
30 .name = "Marvell 88E6175",
31 .num_databases = 4096,
34 .prod_num = PORT_SWITCH_ID_PROD_NUM_6350,
35 .family = MV88E6XXX_FAMILY_6351,
36 .name = "Marvell 88E6350",
37 .num_databases = 4096,
40 .prod_num = PORT_SWITCH_ID_PROD_NUM_6351,
41 .family = MV88E6XXX_FAMILY_6351,
42 .name = "Marvell 88E6351",
43 .num_databases = 4096,
48 static const char *mv88e6171_drv_probe(struct device *dsa_dev,
49 struct device *host_dev, int sw_addr,
52 return mv88e6xxx_drv_probe(dsa_dev, host_dev, sw_addr, priv,
54 ARRAY_SIZE(mv88e6171_table));
57 static int mv88e6171_setup_global(struct dsa_switch *ds)
59 struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
60 u32 upstream_port = dsa_upstream_port(ds);
64 ret = mv88e6xxx_setup_global(ds);
68 /* Discard packets with excessive collisions, mask all
69 * interrupt sources, enable PPU.
71 ret = mv88e6xxx_reg_write(ps, REG_GLOBAL, GLOBAL_CONTROL,
72 GLOBAL_CONTROL_PPU_ENABLE |
73 GLOBAL_CONTROL_DISCARD_EXCESS);
77 /* Configure the upstream port, and configure the upstream
78 * port as the port to which ingress and egress monitor frames
81 reg = upstream_port << GLOBAL_MONITOR_CONTROL_INGRESS_SHIFT |
82 upstream_port << GLOBAL_MONITOR_CONTROL_EGRESS_SHIFT |
83 upstream_port << GLOBAL_MONITOR_CONTROL_ARP_SHIFT |
84 upstream_port << GLOBAL_MONITOR_CONTROL_MIRROR_SHIFT;
85 ret = mv88e6xxx_reg_write(ps, REG_GLOBAL, GLOBAL_MONITOR_CONTROL, reg);
89 /* Disable remote management for now, and set the switch's
92 return mv88e6xxx_reg_write(ps, REG_GLOBAL, GLOBAL_CONTROL_2,
96 static int mv88e6171_setup(struct dsa_switch *ds)
98 struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
103 ret = mv88e6xxx_setup_common(ps);
107 ret = mv88e6xxx_switch_reset(ps, true);
111 ret = mv88e6171_setup_global(ds);
115 return mv88e6xxx_setup_ports(ds);
118 struct dsa_switch_driver mv88e6171_switch_driver = {
119 .tag_protocol = DSA_TAG_PROTO_EDSA,
120 .probe = mv88e6171_drv_probe,
121 .setup = mv88e6171_setup,
122 .set_addr = mv88e6xxx_set_addr_indirect,
123 .phy_read = mv88e6xxx_phy_read_indirect,
124 .phy_write = mv88e6xxx_phy_write_indirect,
125 .get_strings = mv88e6xxx_get_strings,
126 .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
127 .get_sset_count = mv88e6xxx_get_sset_count,
128 .adjust_link = mv88e6xxx_adjust_link,
129 #ifdef CONFIG_NET_DSA_HWMON
130 .get_temp = mv88e6xxx_get_temp,
132 .get_regs_len = mv88e6xxx_get_regs_len,
133 .get_regs = mv88e6xxx_get_regs,
134 .port_bridge_join = mv88e6xxx_port_bridge_join,
135 .port_bridge_leave = mv88e6xxx_port_bridge_leave,
136 .port_stp_state_set = mv88e6xxx_port_stp_state_set,
137 .port_vlan_filtering = mv88e6xxx_port_vlan_filtering,
138 .port_vlan_prepare = mv88e6xxx_port_vlan_prepare,
139 .port_vlan_add = mv88e6xxx_port_vlan_add,
140 .port_vlan_del = mv88e6xxx_port_vlan_del,
141 .port_vlan_dump = mv88e6xxx_port_vlan_dump,
142 .port_fdb_prepare = mv88e6xxx_port_fdb_prepare,
143 .port_fdb_add = mv88e6xxx_port_fdb_add,
144 .port_fdb_del = mv88e6xxx_port_fdb_del,
145 .port_fdb_dump = mv88e6xxx_port_fdb_dump,
148 MODULE_ALIAS("platform:mv88e6171");
149 MODULE_ALIAS("platform:mv88e6175");
150 MODULE_ALIAS("platform:mv88e6350");
151 MODULE_ALIAS("platform:mv88e6351");