net: dsa: mv88e6131: drop VLAN Ethertype setup
[cascardo/linux.git] / drivers / net / dsa / mv88e6131.c
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
20 static 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
52 static 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
61 static int mv88e6131_setup_global(struct dsa_switch *ds)
62 {
63         struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
64         u32 upstream_port = dsa_upstream_port(ds);
65         int ret;
66         u32 reg;
67
68         /* Disable ARP mirroring, and configure the upstream port as
69          * the port to which ingress and egress monitor frames are to
70          * be sent.
71          */
72         reg = upstream_port << GLOBAL_MONITOR_CONTROL_INGRESS_SHIFT |
73                 upstream_port << GLOBAL_MONITOR_CONTROL_EGRESS_SHIFT |
74                 GLOBAL_MONITOR_CONTROL_ARP_DISABLED;
75         ret = mv88e6xxx_reg_write(ps, REG_GLOBAL, GLOBAL_MONITOR_CONTROL, reg);
76         if (ret)
77                 return ret;
78
79         /* Disable cascade port functionality unless this device
80          * is used in a cascade configuration, and set the switch's
81          * DSA device number.
82          */
83         if (ds->dst->pd->nr_chips > 1)
84                 ret = mv88e6xxx_reg_write(ps, REG_GLOBAL, GLOBAL_CONTROL_2,
85                                           GLOBAL_CONTROL_2_MULTIPLE_CASCADE |
86                                           (ds->index & 0x1f));
87         else
88                 ret = mv88e6xxx_reg_write(ps, REG_GLOBAL, GLOBAL_CONTROL_2,
89                                           GLOBAL_CONTROL_2_NO_CASCADE |
90                                           (ds->index & 0x1f));
91         if (ret)
92                 return ret;
93
94         /* Force the priority of IGMP/MLD snoop frames and ARP frames
95          * to the highest setting.
96          */
97         return mv88e6xxx_reg_write(ps, REG_GLOBAL2, GLOBAL2_PRIO_OVERRIDE,
98                                    GLOBAL2_PRIO_OVERRIDE_FORCE_SNOOP |
99                                    7 << GLOBAL2_PRIO_OVERRIDE_SNOOP_SHIFT |
100                                    GLOBAL2_PRIO_OVERRIDE_FORCE_ARP |
101                                    7 << GLOBAL2_PRIO_OVERRIDE_ARP_SHIFT);
102 }
103
104 static int mv88e6131_setup(struct dsa_switch *ds)
105 {
106         struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
107         int ret;
108
109         ps->ds = ds;
110
111         ret = mv88e6xxx_setup_common(ps);
112         if (ret < 0)
113                 return ret;
114
115         ret = mv88e6131_setup_global(ds);
116         if (ret < 0)
117                 return ret;
118
119         return mv88e6xxx_setup_ports(ds);
120 }
121
122 struct dsa_switch_driver mv88e6131_switch_driver = {
123         .tag_protocol           = DSA_TAG_PROTO_DSA,
124         .probe                  = mv88e6131_drv_probe,
125         .setup                  = mv88e6131_setup,
126         .set_addr               = mv88e6xxx_set_addr,
127         .phy_read               = mv88e6xxx_phy_read,
128         .phy_write              = mv88e6xxx_phy_write,
129         .set_eee                = mv88e6xxx_set_eee,
130         .get_eee                = mv88e6xxx_get_eee,
131         .get_strings            = mv88e6xxx_get_strings,
132         .get_ethtool_stats      = mv88e6xxx_get_ethtool_stats,
133         .get_sset_count         = mv88e6xxx_get_sset_count,
134         .get_eeprom             = mv88e6xxx_get_eeprom,
135         .set_eeprom             = mv88e6xxx_set_eeprom,
136         .get_regs_len           = mv88e6xxx_get_regs_len,
137         .get_regs               = mv88e6xxx_get_regs,
138 #ifdef CONFIG_NET_DSA_HWMON
139         .get_temp               = mv88e6xxx_get_temp,
140         .get_temp_limit         = mv88e6xxx_get_temp_limit,
141         .set_temp_limit         = mv88e6xxx_set_temp_limit,
142         .get_temp_alarm         = mv88e6xxx_get_temp_alarm,
143 #endif
144         .adjust_link            = mv88e6xxx_adjust_link,
145         .port_bridge_join       = mv88e6xxx_port_bridge_join,
146         .port_bridge_leave      = mv88e6xxx_port_bridge_leave,
147         .port_stp_state_set     = mv88e6xxx_port_stp_state_set,
148         .port_vlan_filtering    = mv88e6xxx_port_vlan_filtering,
149         .port_vlan_prepare      = mv88e6xxx_port_vlan_prepare,
150         .port_vlan_add          = mv88e6xxx_port_vlan_add,
151         .port_vlan_del          = mv88e6xxx_port_vlan_del,
152         .port_vlan_dump         = mv88e6xxx_port_vlan_dump,
153         .port_fdb_prepare       = mv88e6xxx_port_fdb_prepare,
154         .port_fdb_add           = mv88e6xxx_port_fdb_add,
155         .port_fdb_del           = mv88e6xxx_port_fdb_del,
156         .port_fdb_dump          = mv88e6xxx_port_fdb_dump,
157 };
158
159 MODULE_ALIAS("platform:mv88e6085");
160 MODULE_ALIAS("platform:mv88e6095");
161 MODULE_ALIAS("platform:mv88e6095f");
162 MODULE_ALIAS("platform:mv88e6131");