Deleted Added
full compact
if_tsec_fdt.c (257324) if_tsec_fdt.c (257993)
1/*-
2 * Copyright (C) 2007-2008 Semihalf, Rafal Jaworowski
3 * Copyright (C) 2006-2007 Semihalf, Piotr Kruszynski
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:

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

25 *
26 * From: FreeBSD: head/sys/dev/tsec/if_tsec_ocp.c 188712 2009-02-17 14:59:47Z raj
27 */
28
29/*
30 * FDT 'simple-bus' attachment for Freescale TSEC controller.
31 */
32#include <sys/cdefs.h>
1/*-
2 * Copyright (C) 2007-2008 Semihalf, Rafal Jaworowski
3 * Copyright (C) 2006-2007 Semihalf, Piotr Kruszynski
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:

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

25 *
26 * From: FreeBSD: head/sys/dev/tsec/if_tsec_ocp.c 188712 2009-02-17 14:59:47Z raj
27 */
28
29/*
30 * FDT 'simple-bus' attachment for Freescale TSEC controller.
31 */
32#include <sys/cdefs.h>
33__FBSDID("$FreeBSD: head/sys/dev/tsec/if_tsec_fdt.c 257324 2013-10-29 11:17:49Z glebius $");
33__FBSDID("$FreeBSD: head/sys/dev/tsec/if_tsec_fdt.c 257993 2013-11-11 15:43:21Z nwhitehorn $");
34
35#include <sys/param.h>
36#include <sys/systm.h>
37#include <sys/endian.h>
38#include <sys/lock.h>
39#include <sys/mbuf.h>
40#include <sys/mutex.h>
41#include <sys/kernel.h>

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

105MODULE_DEPEND(tsec, ether, 1, 1, 1);
106
107static int
108tsec_fdt_probe(device_t dev)
109{
110 struct tsec_softc *sc;
111 uint32_t id;
112
34
35#include <sys/param.h>
36#include <sys/systm.h>
37#include <sys/endian.h>
38#include <sys/lock.h>
39#include <sys/mbuf.h>
40#include <sys/mutex.h>
41#include <sys/kernel.h>

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

105MODULE_DEPEND(tsec, ether, 1, 1, 1);
106
107static int
108tsec_fdt_probe(device_t dev)
109{
110 struct tsec_softc *sc;
111 uint32_t id;
112
113 if (ofw_bus_get_type(dev) == NULL ||
114 strcmp(ofw_bus_get_type(dev), "network") != 0)
115 return (ENXIO);
116
113 if (!ofw_bus_is_compatible(dev, "gianfar"))
114 return (ENXIO);
115
116 sc = device_get_softc(dev);
117
118 sc->sc_rrid = 0;
119 sc->sc_rres = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &sc->sc_rrid,
120 RF_ACTIVE);

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

143
144 return (BUS_PROBE_DEFAULT);
145}
146
147static int
148tsec_fdt_attach(device_t dev)
149{
150 struct tsec_softc *sc;
117 if (!ofw_bus_is_compatible(dev, "gianfar"))
118 return (ENXIO);
119
120 sc = device_get_softc(dev);
121
122 sc->sc_rrid = 0;
123 sc->sc_rres = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &sc->sc_rrid,
124 RF_ACTIVE);

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

147
148 return (BUS_PROBE_DEFAULT);
149}
150
151static int
152tsec_fdt_attach(device_t dev)
153{
154 struct tsec_softc *sc;
155 phandle_t phy;
151 int error = 0;
152
153 sc = device_get_softc(dev);
154 sc->dev = dev;
155 sc->node = ofw_bus_get_node(dev);
156
157 /* Get phy address from fdt */
156 int error = 0;
157
158 sc = device_get_softc(dev);
159 sc->dev = dev;
160 sc->node = ofw_bus_get_node(dev);
161
162 /* Get phy address from fdt */
158 if (fdt_get_phyaddr(sc->node, sc->dev, &sc->phyaddr,
159 (void **)&sc->phy_sc) != 0)
163 if (OF_getencprop(sc->node, "phy-handle", &phy, sizeof(phy)) <= 0) {
164 device_printf(dev, "PHY not found in device tree");
160 return (ENXIO);
165 return (ENXIO);
166 }
161
167
168 phy = OF_xref_phandle(phy);
169 OF_decode_addr(OF_parent(phy), 0, &sc->phy_bst, &sc->phy_bsh);
170 OF_getencprop(phy, "reg", &sc->phyaddr, sizeof(sc->phyaddr));
171
162 /* Init timer */
163 callout_init(&sc->tsec_callout, 1);
164
165 /* Init locks */
166 mtx_init(&sc->transmit_lock, device_get_nameunit(dev), "TSEC TX lock",
167 MTX_DEF);
168 mtx_init(&sc->receive_lock, device_get_nameunit(dev), "TSEC RX lock",
169 MTX_DEF);

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

319
320 /* Retrieve the hardware address from the device tree. */
321 i = OF_getprop(sc->node, "local-mac-address", (void *)hw.addr, 6);
322 if (i == 6 && (hw.reg[0] != 0 || hw.reg[1] != 0)) {
323 bcopy(hw.addr, addr, 6);
324 return;
325 }
326
172 /* Init timer */
173 callout_init(&sc->tsec_callout, 1);
174
175 /* Init locks */
176 mtx_init(&sc->transmit_lock, device_get_nameunit(dev), "TSEC TX lock",
177 MTX_DEF);
178 mtx_init(&sc->receive_lock, device_get_nameunit(dev), "TSEC RX lock",
179 MTX_DEF);

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

329
330 /* Retrieve the hardware address from the device tree. */
331 i = OF_getprop(sc->node, "local-mac-address", (void *)hw.addr, 6);
332 if (i == 6 && (hw.reg[0] != 0 || hw.reg[1] != 0)) {
333 bcopy(hw.addr, addr, 6);
334 return;
335 }
336
337 /* Also try the mac-address property, which is second-best */
338 i = OF_getprop(sc->node, "mac-address", (void *)hw.addr, 6);
339 if (i == 6 && (hw.reg[0] != 0 || hw.reg[1] != 0)) {
340 bcopy(hw.addr, addr, 6);
341 return;
342 }
343
327 /*
328 * Fall back -- use the currently programmed address in the hope that
329 * it was set be firmware...
330 */
331 hw.reg[0] = TSEC_READ(sc, TSEC_REG_MACSTNADDR1);
332 hw.reg[1] = TSEC_READ(sc, TSEC_REG_MACSTNADDR2);
333 for (i = 0; i < 6; i++)
334 addr[5-i] = hw.addr[i];
335}
344 /*
345 * Fall back -- use the currently programmed address in the hope that
346 * it was set be firmware...
347 */
348 hw.reg[0] = TSEC_READ(sc, TSEC_REG_MACSTNADDR1);
349 hw.reg[1] = TSEC_READ(sc, TSEC_REG_MACSTNADDR2);
350 for (i = 0; i < 6; i++)
351 addr[5-i] = hw.addr[i];
352}