Deleted Added
full compact
if_tsec.c (229767) if_tsec.c (232518)
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:

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

23 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27/*
28 * Freescale integrated Three-Speed Ethernet Controller (TSEC) driver.
29 */
30#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:

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

23 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27/*
28 * Freescale integrated Three-Speed Ethernet Controller (TSEC) driver.
29 */
30#include <sys/cdefs.h>
31__FBSDID("$FreeBSD: head/sys/dev/tsec/if_tsec.c 229767 2012-01-07 09:41:57Z kevlo $");
31__FBSDID("$FreeBSD: head/sys/dev/tsec/if_tsec.c 232518 2012-03-04 19:22:52Z raj $");
32
33#ifdef HAVE_KERNEL_OPTION_HEADERS
34#include "opt_device_polling.h"
35#endif
36
37#include <sys/param.h>
38#include <sys/systm.h>
39#include <sys/bus.h>

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

101static void tsec_transmit_intr_locked(struct tsec_softc *sc);
102static void tsec_error_intr_locked(struct tsec_softc *sc, int count);
103static void tsec_offload_setup(struct tsec_softc *sc);
104static void tsec_offload_process_frame(struct tsec_softc *sc,
105 struct mbuf *m);
106static void tsec_setup_multicast(struct tsec_softc *sc);
107static int tsec_set_mtu(struct tsec_softc *sc, unsigned int mtu);
108
32
33#ifdef HAVE_KERNEL_OPTION_HEADERS
34#include "opt_device_polling.h"
35#endif
36
37#include <sys/param.h>
38#include <sys/systm.h>
39#include <sys/bus.h>

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

101static void tsec_transmit_intr_locked(struct tsec_softc *sc);
102static void tsec_error_intr_locked(struct tsec_softc *sc, int count);
103static void tsec_offload_setup(struct tsec_softc *sc);
104static void tsec_offload_process_frame(struct tsec_softc *sc,
105 struct mbuf *m);
106static void tsec_setup_multicast(struct tsec_softc *sc);
107static int tsec_set_mtu(struct tsec_softc *sc, unsigned int mtu);
108
109struct tsec_softc *tsec0_sc = NULL; /* XXX ugly hack! */
110
111devclass_t tsec_devclass;
112DRIVER_MODULE(miibus, tsec, miibus_driver, miibus_devclass, 0, 0);
113MODULE_DEPEND(tsec, ether, 1, 1, 1);
114MODULE_DEPEND(tsec, miibus, 1, 1, 1);
115
116int
117tsec_attach(struct tsec_softc *sc)
118{

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

401
402 /*
403 * Step 5: Assign a Physical address to the TBI so as to not conflict
404 * with the external PHY physical address
405 */
406 TSEC_WRITE(sc, TSEC_REG_TBIPA, 5);
407
408 /* Step 6: Reset the management interface */
109devclass_t tsec_devclass;
110DRIVER_MODULE(miibus, tsec, miibus_driver, miibus_devclass, 0, 0);
111MODULE_DEPEND(tsec, ether, 1, 1, 1);
112MODULE_DEPEND(tsec, miibus, 1, 1, 1);
113
114int
115tsec_attach(struct tsec_softc *sc)
116{

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

399
400 /*
401 * Step 5: Assign a Physical address to the TBI so as to not conflict
402 * with the external PHY physical address
403 */
404 TSEC_WRITE(sc, TSEC_REG_TBIPA, 5);
405
406 /* Step 6: Reset the management interface */
409 TSEC_WRITE(tsec0_sc, TSEC_REG_MIIMCFG, TSEC_MIIMCFG_RESETMGMT);
407 TSEC_WRITE(sc->phy_sc, TSEC_REG_MIIMCFG, TSEC_MIIMCFG_RESETMGMT);
410
411 /* Step 7: Setup the MII Mgmt clock speed */
408
409 /* Step 7: Setup the MII Mgmt clock speed */
412 TSEC_WRITE(tsec0_sc, TSEC_REG_MIIMCFG, TSEC_MIIMCFG_CLKDIV28);
410 TSEC_WRITE(sc->phy_sc, TSEC_REG_MIIMCFG, TSEC_MIIMCFG_CLKDIV28);
413
414 /* Step 8: Read MII Mgmt indicator register and check for Busy = 0 */
415 timeout = TSEC_READ_RETRY;
411
412 /* Step 8: Read MII Mgmt indicator register and check for Busy = 0 */
413 timeout = TSEC_READ_RETRY;
416 while (--timeout && (TSEC_READ(tsec0_sc, TSEC_REG_MIIMIND) &
414 while (--timeout && (TSEC_READ(sc->phy_sc, TSEC_REG_MIIMIND) &
417 TSEC_MIIMIND_BUSY))
418 DELAY(TSEC_READ_DELAY);
419 if (timeout == 0) {
420 if_printf(ifp, "tsec_init_locked(): Mgmt busy timeout\n");
421 return;
422 }
423
424 /* Step 9: Setup the MII Mgmt */

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

1556}
1557
1558int
1559tsec_miibus_readreg(device_t dev, int phy, int reg)
1560{
1561 struct tsec_softc *sc;
1562 uint32_t timeout;
1563
415 TSEC_MIIMIND_BUSY))
416 DELAY(TSEC_READ_DELAY);
417 if (timeout == 0) {
418 if_printf(ifp, "tsec_init_locked(): Mgmt busy timeout\n");
419 return;
420 }
421
422 /* Step 9: Setup the MII Mgmt */

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

1554}
1555
1556int
1557tsec_miibus_readreg(device_t dev, int phy, int reg)
1558{
1559 struct tsec_softc *sc;
1560 uint32_t timeout;
1561
1564 sc = tsec0_sc;
1562 sc = device_get_softc(dev);
1565
1563
1566 TSEC_WRITE(sc, TSEC_REG_MIIMADD, (phy << 8) | reg);
1567 TSEC_WRITE(sc, TSEC_REG_MIIMCOM, 0);
1568 TSEC_WRITE(sc, TSEC_REG_MIIMCOM, TSEC_MIIMCOM_READCYCLE);
1564 TSEC_WRITE(sc->phy_sc, TSEC_REG_MIIMADD, (phy << 8) | reg);
1565 TSEC_WRITE(sc->phy_sc, TSEC_REG_MIIMCOM, 0);
1566 TSEC_WRITE(sc->phy_sc, TSEC_REG_MIIMCOM, TSEC_MIIMCOM_READCYCLE);
1569
1570 timeout = TSEC_READ_RETRY;
1567
1568 timeout = TSEC_READ_RETRY;
1571 while (--timeout && TSEC_READ(sc, TSEC_REG_MIIMIND) &
1569 while (--timeout && TSEC_READ(sc->phy_sc, TSEC_REG_MIIMIND) &
1572 (TSEC_MIIMIND_NOTVALID | TSEC_MIIMIND_BUSY))
1573 DELAY(TSEC_READ_DELAY);
1574
1575 if (timeout == 0)
1576 device_printf(dev, "Timeout while reading from PHY!\n");
1577
1570 (TSEC_MIIMIND_NOTVALID | TSEC_MIIMIND_BUSY))
1571 DELAY(TSEC_READ_DELAY);
1572
1573 if (timeout == 0)
1574 device_printf(dev, "Timeout while reading from PHY!\n");
1575
1578 return (TSEC_READ(sc, TSEC_REG_MIIMSTAT));
1576 return (TSEC_READ(sc->phy_sc, TSEC_REG_MIIMSTAT));
1579}
1580
1581int
1582tsec_miibus_writereg(device_t dev, int phy, int reg, int value)
1583{
1584 struct tsec_softc *sc;
1585 uint32_t timeout;
1586
1577}
1578
1579int
1580tsec_miibus_writereg(device_t dev, int phy, int reg, int value)
1581{
1582 struct tsec_softc *sc;
1583 uint32_t timeout;
1584
1587 sc = tsec0_sc;
1585 sc = device_get_softc(dev);
1588
1586
1589 TSEC_WRITE(sc, TSEC_REG_MIIMADD, (phy << 8) | reg);
1590 TSEC_WRITE(sc, TSEC_REG_MIIMCON, value);
1587 TSEC_WRITE(sc->phy_sc, TSEC_REG_MIIMADD, (phy << 8) | reg);
1588 TSEC_WRITE(sc->phy_sc, TSEC_REG_MIIMCON, value);
1591
1592 timeout = TSEC_READ_RETRY;
1589
1590 timeout = TSEC_READ_RETRY;
1593 while (--timeout && (TSEC_READ(sc, TSEC_REG_MIIMIND) &
1591 while (--timeout && (TSEC_READ(sc->phy_sc, TSEC_REG_MIIMIND) &
1594 TSEC_MIIMIND_BUSY))
1595 DELAY(TSEC_READ_DELAY);
1596
1597 if (timeout == 0)
1598 device_printf(dev, "Timeout while writing to PHY!\n");
1599
1600 return (0);
1601}

--- 321 unchanged lines hidden ---
1592 TSEC_MIIMIND_BUSY))
1593 DELAY(TSEC_READ_DELAY);
1594
1595 if (timeout == 0)
1596 device_printf(dev, "Timeout while writing to PHY!\n");
1597
1598 return (0);
1599}

--- 321 unchanged lines hidden ---