2 * net/dsa/mv88e6131.c - Marvell 88e6095/6095f/6131 switch chip support
3 * Copyright (c) 2008-2009 Marvell Semiconductor
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 char *mv88e6131_probe(struct device
*host_dev
, int sw_addr
)
22 struct mii_bus
*bus
= dsa_host_dev_to_mii_bus(host_dev
);
28 ret
= __mv88e6xxx_reg_read(bus
, sw_addr
, REG_PORT(0), PORT_SWITCH_ID
);
30 int ret_masked
= ret
& 0xfff0;
32 if (ret_masked
== PORT_SWITCH_ID_6085
)
33 return "Marvell 88E6085";
34 if (ret_masked
== PORT_SWITCH_ID_6095
)
35 return "Marvell 88E6095/88E6095F";
36 if (ret
== PORT_SWITCH_ID_6131_B2
)
37 return "Marvell 88E6131 (B2)";
38 if (ret_masked
== PORT_SWITCH_ID_6131
)
39 return "Marvell 88E6131";
40 if (ret_masked
== PORT_SWITCH_ID_6185
)
41 return "Marvell 88E6185";
47 static int mv88e6131_setup_global(struct dsa_switch
*ds
)
49 u32 upstream_port
= dsa_upstream_port(ds
);
53 ret
= mv88e6xxx_setup_global(ds
);
57 /* Enable the PHY polling unit, don't discard packets with
58 * excessive collisions, use a weighted fair queueing scheme
59 * to arbitrate between packet queues, set the maximum frame
60 * size to 1632, and mask all interrupt sources.
62 REG_WRITE(REG_GLOBAL
, GLOBAL_CONTROL
,
63 GLOBAL_CONTROL_PPU_ENABLE
| GLOBAL_CONTROL_MAX_FRAME_1632
);
65 /* Set the VLAN ethertype to 0x8100. */
66 REG_WRITE(REG_GLOBAL
, GLOBAL_CORE_TAG_TYPE
, 0x8100);
68 /* Disable ARP mirroring, and configure the upstream port as
69 * the port to which ingress and egress monitor frames are to
72 reg
= upstream_port
<< GLOBAL_MONITOR_CONTROL_INGRESS_SHIFT
|
73 upstream_port
<< GLOBAL_MONITOR_CONTROL_EGRESS_SHIFT
|
74 GLOBAL_MONITOR_CONTROL_ARP_DISABLED
;
75 REG_WRITE(REG_GLOBAL
, GLOBAL_MONITOR_CONTROL
, reg
);
77 /* Disable cascade port functionality unless this device
78 * is used in a cascade configuration, and set the switch's
81 if (ds
->dst
->pd
->nr_chips
> 1)
82 REG_WRITE(REG_GLOBAL
, GLOBAL_CONTROL_2
,
83 GLOBAL_CONTROL_2_MULTIPLE_CASCADE
|
86 REG_WRITE(REG_GLOBAL
, GLOBAL_CONTROL_2
,
87 GLOBAL_CONTROL_2_NO_CASCADE
|
90 /* Force the priority of IGMP/MLD snoop frames and ARP frames
91 * to the highest setting.
93 REG_WRITE(REG_GLOBAL2
, GLOBAL2_PRIO_OVERRIDE
,
94 GLOBAL2_PRIO_OVERRIDE_FORCE_SNOOP
|
95 7 << GLOBAL2_PRIO_OVERRIDE_SNOOP_SHIFT
|
96 GLOBAL2_PRIO_OVERRIDE_FORCE_ARP
|
97 7 << GLOBAL2_PRIO_OVERRIDE_ARP_SHIFT
);
102 static int mv88e6131_setup(struct dsa_switch
*ds
)
104 struct mv88e6xxx_priv_state
*ps
= ds_to_priv(ds
);
107 ret
= mv88e6xxx_setup_common(ds
);
111 mv88e6xxx_ppu_state_init(ds
);
114 case PORT_SWITCH_ID_6085
:
115 case PORT_SWITCH_ID_6185
:
118 case PORT_SWITCH_ID_6095
:
121 case PORT_SWITCH_ID_6131
:
122 case PORT_SWITCH_ID_6131_B2
:
129 ret
= mv88e6xxx_switch_reset(ds
, false);
133 ret
= mv88e6131_setup_global(ds
);
137 return mv88e6xxx_setup_ports(ds
);
140 static int mv88e6131_port_to_phy_addr(struct dsa_switch
*ds
, int port
)
142 struct mv88e6xxx_priv_state
*ps
= ds_to_priv(ds
);
144 if (port
>= 0 && port
< ps
->num_ports
)
151 mv88e6131_phy_read(struct dsa_switch
*ds
, int port
, int regnum
)
153 int addr
= mv88e6131_port_to_phy_addr(ds
, port
);
158 return mv88e6xxx_phy_read_ppu(ds
, addr
, regnum
);
162 mv88e6131_phy_write(struct dsa_switch
*ds
,
163 int port
, int regnum
, u16 val
)
165 int addr
= mv88e6131_port_to_phy_addr(ds
, port
);
170 return mv88e6xxx_phy_write_ppu(ds
, addr
, regnum
, val
);
173 struct dsa_switch_driver mv88e6131_switch_driver
= {
174 .tag_protocol
= DSA_TAG_PROTO_DSA
,
175 .priv_size
= sizeof(struct mv88e6xxx_priv_state
),
176 .probe
= mv88e6131_probe
,
177 .setup
= mv88e6131_setup
,
178 .set_addr
= mv88e6xxx_set_addr_direct
,
179 .phy_read
= mv88e6131_phy_read
,
180 .phy_write
= mv88e6131_phy_write
,
181 .poll_link
= mv88e6xxx_poll_link
,
182 .get_strings
= mv88e6xxx_get_strings
,
183 .get_ethtool_stats
= mv88e6xxx_get_ethtool_stats
,
184 .get_sset_count
= mv88e6xxx_get_sset_count
,
187 MODULE_ALIAS("platform:mv88e6085");
188 MODULE_ALIAS("platform:mv88e6095");
189 MODULE_ALIAS("platform:mv88e6095f");
190 MODULE_ALIAS("platform:mv88e6131");