62dffcf915a74d1784214578166f10d07fd3136c
[deliverable/linux.git] / drivers / net / dsa / mv88e6123.c
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
20 static const struct mv88e6xxx_info mv88e6123_table[] = {
21 {
22 .prod_num = PORT_SWITCH_ID_PROD_NUM_6123,
23 .name = "Marvell 88E6123",
24 }, {
25 .prod_num = PORT_SWITCH_ID_PROD_NUM_6161,
26 .name = "Marvell 88E6161",
27 }, {
28 .prod_num = PORT_SWITCH_ID_PROD_NUM_6165,
29 .name = "Marvell 88E6165",
30 }
31 };
32
33 static const char *mv88e6123_drv_probe(struct device *dsa_dev,
34 struct device *host_dev, int sw_addr,
35 void **priv)
36 {
37 return mv88e6xxx_drv_probe(dsa_dev, host_dev, sw_addr, priv,
38 mv88e6123_table,
39 ARRAY_SIZE(mv88e6123_table));
40 }
41
42 static int mv88e6123_setup_global(struct dsa_switch *ds)
43 {
44 u32 upstream_port = dsa_upstream_port(ds);
45 int ret;
46 u32 reg;
47
48 ret = mv88e6xxx_setup_global(ds);
49 if (ret)
50 return ret;
51
52 /* Disable the PHY polling unit (since there won't be any
53 * external PHYs to poll), don't discard packets with
54 * excessive collisions, and mask all interrupt sources.
55 */
56 ret = mv88e6xxx_reg_write(ds, REG_GLOBAL, GLOBAL_CONTROL, 0x0000);
57 if (ret)
58 return ret;
59
60 /* Configure the upstream port, and configure the upstream
61 * port as the port to which ingress and egress monitor frames
62 * are to be sent.
63 */
64 reg = upstream_port << GLOBAL_MONITOR_CONTROL_INGRESS_SHIFT |
65 upstream_port << GLOBAL_MONITOR_CONTROL_EGRESS_SHIFT |
66 upstream_port << GLOBAL_MONITOR_CONTROL_ARP_SHIFT;
67 ret = mv88e6xxx_reg_write(ds, REG_GLOBAL, GLOBAL_MONITOR_CONTROL, reg);
68 if (ret)
69 return ret;
70
71 /* Disable remote management for now, and set the switch's
72 * DSA device number.
73 */
74 return mv88e6xxx_reg_write(ds, REG_GLOBAL, GLOBAL_CONTROL_2,
75 ds->index & 0x1f);
76 }
77
78 static int mv88e6123_setup(struct dsa_switch *ds)
79 {
80 struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
81 int ret;
82
83 ret = mv88e6xxx_setup_common(ds);
84 if (ret < 0)
85 return ret;
86
87 switch (ps->id) {
88 case PORT_SWITCH_ID_6123:
89 ps->num_ports = 3;
90 break;
91 case PORT_SWITCH_ID_6161:
92 case PORT_SWITCH_ID_6165:
93 ps->num_ports = 6;
94 break;
95 default:
96 return -ENODEV;
97 }
98
99 ret = mv88e6xxx_switch_reset(ds, false);
100 if (ret < 0)
101 return ret;
102
103 ret = mv88e6123_setup_global(ds);
104 if (ret < 0)
105 return ret;
106
107 return mv88e6xxx_setup_ports(ds);
108 }
109
110 struct dsa_switch_driver mv88e6123_switch_driver = {
111 .tag_protocol = DSA_TAG_PROTO_EDSA,
112 .probe = mv88e6123_drv_probe,
113 .setup = mv88e6123_setup,
114 .set_addr = mv88e6xxx_set_addr_indirect,
115 .phy_read = mv88e6xxx_phy_read,
116 .phy_write = mv88e6xxx_phy_write,
117 .get_strings = mv88e6xxx_get_strings,
118 .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
119 .get_sset_count = mv88e6xxx_get_sset_count,
120 .adjust_link = mv88e6xxx_adjust_link,
121 #ifdef CONFIG_NET_DSA_HWMON
122 .get_temp = mv88e6xxx_get_temp,
123 #endif
124 .get_regs_len = mv88e6xxx_get_regs_len,
125 .get_regs = mv88e6xxx_get_regs,
126 };
127
128 MODULE_ALIAS("platform:mv88e6123");
129 MODULE_ALIAS("platform:mv88e6161");
130 MODULE_ALIAS("platform:mv88e6165");
This page took 0.038019 seconds and 4 git commands to generate.