Deleted Added
full compact
arswitch.c (235288) arswitch.c (235323)
1/*-
2 * Copyright (c) 2011-2012 Stefan Bethke.
3 * Copyright (c) 2012 Adrian Chadd.
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 10 unchanged lines hidden (view full) ---

19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 *
1/*-
2 * Copyright (c) 2011-2012 Stefan Bethke.
3 * Copyright (c) 2012 Adrian Chadd.
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 10 unchanged lines hidden (view full) ---

19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 *
27 * $FreeBSD: head/sys/dev/etherswitch/arswitch/arswitch.c 235288 2012-05-11 20:53:20Z adrian $
27 * $FreeBSD: head/sys/dev/etherswitch/arswitch/arswitch.c 235323 2012-05-12 05:26:49Z adrian $
28 */
29
30#include <sys/param.h>
31#include <sys/bus.h>
32#include <sys/errno.h>
33#include <sys/kernel.h>
34#include <sys/module.h>
35#include <sys/socket.h>

--- 18 unchanged lines hidden (view full) ---

54
55#include <dev/etherswitch/etherswitch.h>
56
57#include <dev/etherswitch/arswitch/arswitchreg.h>
58#include <dev/etherswitch/arswitch/arswitchvar.h>
59#include <dev/etherswitch/arswitch/arswitch_reg.h>
60#include <dev/etherswitch/arswitch/arswitch_phy.h>
61
28 */
29
30#include <sys/param.h>
31#include <sys/bus.h>
32#include <sys/errno.h>
33#include <sys/kernel.h>
34#include <sys/module.h>
35#include <sys/socket.h>

--- 18 unchanged lines hidden (view full) ---

54
55#include <dev/etherswitch/etherswitch.h>
56
57#include <dev/etherswitch/arswitch/arswitchreg.h>
58#include <dev/etherswitch/arswitch/arswitchvar.h>
59#include <dev/etherswitch/arswitch/arswitch_reg.h>
60#include <dev/etherswitch/arswitch/arswitch_phy.h>
61
62#include <dev/etherswitch/arswitch/arswitch_7240.h>
62#include <dev/etherswitch/arswitch/arswitch_8216.h>
63#include <dev/etherswitch/arswitch/arswitch_8226.h>
64#include <dev/etherswitch/arswitch/arswitch_8316.h>
65
66#include "mdio_if.h"
67#include "miibus_if.h"
68#include "etherswitch_if.h"
69

--- 21 unchanged lines hidden (view full) ---

91{
92 struct arswitch_softc *sc;
93 uint32_t id;
94 char *chipname, desc[256];
95
96 sc = device_get_softc(dev);
97 bzero(sc, sizeof(*sc));
98 sc->page = -1;
63#include <dev/etherswitch/arswitch/arswitch_8216.h>
64#include <dev/etherswitch/arswitch/arswitch_8226.h>
65#include <dev/etherswitch/arswitch/arswitch_8316.h>
66
67#include "mdio_if.h"
68#include "miibus_if.h"
69#include "etherswitch_if.h"
70

--- 21 unchanged lines hidden (view full) ---

92{
93 struct arswitch_softc *sc;
94 uint32_t id;
95 char *chipname, desc[256];
96
97 sc = device_get_softc(dev);
98 bzero(sc, sizeof(*sc));
99 sc->page = -1;
100
101 /* AR7240 probe */
102 if (ar7240_probe(dev) == 0) {
103 chipname = "AR7240";
104 sc->sc_switchtype = AR8X16_SWITCH_AR7240;
105 goto done;
106 }
107
108 /* AR8xxx probe */
99 id = arswitch_readreg(dev, AR8X16_REG_MASK_CTRL);
100 switch ((id & AR8X16_MASK_CTRL_VER_MASK) >>
101 AR8X16_MASK_CTRL_VER_SHIFT) {
102 case 1:
103 chipname = "AR8216";
104 sc->sc_switchtype = AR8X16_SWITCH_AR8216;
105 break;
106 case 2:
107 chipname = "AR8226";
108 sc->sc_switchtype = AR8X16_SWITCH_AR8226;
109 break;
110 case 16:
111 chipname = "AR8316";
112 sc->sc_switchtype = AR8X16_SWITCH_AR8316;
113 break;
114 default:
115 chipname = NULL;
116 }
109 id = arswitch_readreg(dev, AR8X16_REG_MASK_CTRL);
110 switch ((id & AR8X16_MASK_CTRL_VER_MASK) >>
111 AR8X16_MASK_CTRL_VER_SHIFT) {
112 case 1:
113 chipname = "AR8216";
114 sc->sc_switchtype = AR8X16_SWITCH_AR8216;
115 break;
116 case 2:
117 chipname = "AR8226";
118 sc->sc_switchtype = AR8X16_SWITCH_AR8226;
119 break;
120 case 16:
121 chipname = "AR8316";
122 sc->sc_switchtype = AR8X16_SWITCH_AR8316;
123 break;
124 default:
125 chipname = NULL;
126 }
127
128done:
117 DPRINTF(dev, "chipname=%s, rev=%02x\n", chipname,
118 id & AR8X16_MASK_CTRL_REV_MASK);
119 if (chipname != NULL) {
120 snprintf(desc, sizeof(desc),
121 "Atheros %s Ethernet Switch",
122 chipname);
123 device_set_desc_copy(dev, desc);
124 return (BUS_PROBE_DEFAULT);

--- 46 unchanged lines hidden (view full) ---

171 mtx_init(&sc->sc_mtx, "arswitch", NULL, MTX_DEF);
172 sc->page = -1;
173 strlcpy(sc->info.es_name, device_get_desc(dev),
174 sizeof(sc->info.es_name));
175
176 /*
177 * Attach switch related functions
178 */
129 DPRINTF(dev, "chipname=%s, rev=%02x\n", chipname,
130 id & AR8X16_MASK_CTRL_REV_MASK);
131 if (chipname != NULL) {
132 snprintf(desc, sizeof(desc),
133 "Atheros %s Ethernet Switch",
134 chipname);
135 device_set_desc_copy(dev, desc);
136 return (BUS_PROBE_DEFAULT);

--- 46 unchanged lines hidden (view full) ---

183 mtx_init(&sc->sc_mtx, "arswitch", NULL, MTX_DEF);
184 sc->page = -1;
185 strlcpy(sc->info.es_name, device_get_desc(dev),
186 sizeof(sc->info.es_name));
187
188 /*
189 * Attach switch related functions
190 */
179 if (AR8X16_IS_SWITCH(sc, AR8216))
191 if (AR8X16_IS_SWITCH(sc, AR7240))
192 ar7240_attach(sc);
193 else if (AR8X16_IS_SWITCH(sc, AR8216))
180 ar8216_attach(sc);
181 else if (AR8X16_IS_SWITCH(sc, AR8226))
182 ar8226_attach(sc);
183 else if (AR8X16_IS_SWITCH(sc, AR8316))
184 ar8316_attach(sc);
185 else
186 return (ENXIO);
187

--- 370 unchanged lines hidden ---
194 ar8216_attach(sc);
195 else if (AR8X16_IS_SWITCH(sc, AR8226))
196 ar8226_attach(sc);
197 else if (AR8X16_IS_SWITCH(sc, AR8316))
198 ar8316_attach(sc);
199 else
200 return (ENXIO);
201

--- 370 unchanged lines hidden ---