Deleted Added
sdiff udiff text old ( 165138 ) new ( 165611 )
full compact
1/******************************************************************************
2 *
3 * Name : sky2.c
4 * Project: Gigabit Ethernet Driver for FreeBSD 5.x/6.x
5 * Version: $Revision: 1.23 $
6 * Date : $Date: 2005/12/22 09:04:11 $
7 * Purpose: Main driver source file
8 *

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

94
95/*
96 * Device driver for the Marvell Yukon II Ethernet controller.
97 * Due to lack of documentation, this driver is based on the code from
98 * sk(4) and Marvell's myk(4) driver for FreeBSD 5.x.
99 */
100
101#include <sys/cdefs.h>
102__FBSDID("$FreeBSD: head/sys/dev/msk/if_msk.c 165611 2006-12-29 03:33:33Z yongari $");
103
104#include <sys/param.h>
105#include <sys/systm.h>
106#include <sys/bus.h>
107#include <sys/endian.h>
108#include <sys/mbuf.h>
109#include <sys/malloc.h>
110#include <sys/kernel.h>

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

334static devclass_t msk_devclass;
335
336DRIVER_MODULE(mskc, pci, mskc_driver, mskc_devclass, 0, 0);
337DRIVER_MODULE(msk, mskc, msk_driver, msk_devclass, 0, 0);
338DRIVER_MODULE(miibus, msk, miibus_driver, miibus_devclass, 0, 0);
339
340static struct resource_spec msk_res_spec_io[] = {
341 { SYS_RES_IOPORT, PCIR_BAR(1), RF_ACTIVE },
342 { -1, 0, 0 }
343};
344
345static struct resource_spec msk_res_spec_mem[] = {
346 { SYS_RES_MEMORY, PCIR_BAR(0), RF_ACTIVE },
347 { -1, 0, 0 }
348};
349
350static struct resource_spec msk_irq_spec_legacy[] = {
351 { SYS_RES_IRQ, 0, RF_ACTIVE | RF_SHAREABLE },
352 { -1, 0, 0 }
353};
354
355static struct resource_spec msk_irq_spec_msi[] = {
356 { SYS_RES_IRQ, 1, RF_ACTIVE },
357 { SYS_RES_IRQ, 2, RF_ACTIVE },
358 { -1, 0, 0 }
359};
360
361static int
362msk_miibus_readreg(device_t dev, int phy, int reg)
363{
364 struct msk_if_softc *sc_if;
365
366 sc_if = device_get_softc(dev);
367
368 return (msk_phy_readreg(sc_if, phy, reg));

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

1550 mtx_init(&sc->msk_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK,
1551 MTX_DEF);
1552
1553 /*
1554 * Map control/status registers.
1555 */
1556 pci_enable_busmaster(dev);
1557
1558 /* Allocate I/O resource */
1559#ifdef MSK_USEIOSPACE
1560 sc->msk_res_spec = msk_res_spec_io;
1561#else
1562 sc->msk_res_spec = msk_res_spec_mem;
1563#endif
1564 error = bus_alloc_resources(dev, sc->msk_res_spec, sc->msk_res);
1565 if (error) {
1566 if (sc->msk_res_spec == msk_res_spec_mem)

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

1696 HWF_WA_DEV_4115;
1697 }
1698 break;
1699 default:
1700 sc->msk_clock = 156; /* 156 Mhz */
1701 sc->msk_hw_feature = 0;
1702 }
1703
1704 /* Allocate IRQ resources. */
1705 msic = pci_msi_count(dev);
1706 if (bootverbose)
1707 device_printf(dev, "MSI count : %d\n", msic);
1708 /*
1709 * The Yukon II reports it can handle two messages, one for each
1710 * possible port. We go ahead and allocate two messages and only
1711 * setup a handler for both if we have a dual port card.
1712 *
1713 * XXX: I haven't untangled the interrupt handler to handle dual
1714 * port cards with separate MSI messages, so for now I disable MSI
1715 * on dual port cards.
1716 */
1717 if (msic == 2 && msi_disable == 0 && sc->msk_num_port == 1 &&
1718 pci_alloc_msi(dev, &msic) == 0) {
1719 if (msic == 2) {
1720 sc->msk_msi = 1;
1721 sc->msk_irq_spec = msk_irq_spec_msi;
1722 } else {
1723 pci_release_msi(dev);
1724 sc->msk_irq_spec = msk_irq_spec_legacy;
1725 }
1726 }
1727
1728 error = bus_alloc_resources(dev, sc->msk_irq_spec, sc->msk_irq);
1729 if (error) {
1730 device_printf(dev, "couldn't allocate IRQ resources\n");
1731 goto fail;
1732 }
1733
1734 if ((error = msk_status_dma_alloc(sc)) != 0)
1735 goto fail;
1736
1737 /* Set base interrupt mask. */
1738 sc->msk_intrmask = Y2_IS_HW_ERR | Y2_IS_STAT_BMU;
1739 sc->msk_intrhwemask = Y2_IS_TIST_OV | Y2_IS_MST_ERR |
1740 Y2_IS_IRQ_STAT | Y2_IS_PCI_EXP | Y2_IS_PCI_NEXP;
1741

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

1786 }
1787
1788 TASK_INIT(&sc->msk_int_task, 0, msk_int_task, sc);
1789 sc->msk_tq = taskqueue_create_fast("msk_taskq", M_WAITOK,
1790 taskqueue_thread_enqueue, &sc->msk_tq);
1791 taskqueue_start_threads(&sc->msk_tq, 1, PI_NET, "%s taskq",
1792 device_get_nameunit(sc->msk_dev));
1793 /* Hook interrupt last to avoid having to lock softc. */
1794 error = bus_setup_intr(dev, sc->msk_irq[0], INTR_TYPE_NET |
1795 INTR_MPSAFE | INTR_FAST, msk_intr, sc, &sc->msk_intrhand[0]);
1796
1797 if (error != 0) {
1798 device_printf(dev, "couldn't set up interrupt handler\n");
1799 taskqueue_free(sc->msk_tq);
1800 sc->msk_tq = NULL;
1801 goto fail;
1802 }
1803fail:

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

1900
1901 msk_status_dma_free(sc);
1902
1903 if (sc->msk_tq != NULL) {
1904 taskqueue_drain(sc->msk_tq, &sc->msk_int_task);
1905 taskqueue_free(sc->msk_tq);
1906 sc->msk_tq = NULL;
1907 }
1908 if (sc->msk_intrhand[0]) {
1909 bus_teardown_intr(dev, sc->msk_irq[0], sc->msk_intrhand[0]);
1910 sc->msk_intrhand[0] = NULL;
1911 }
1912 if (sc->msk_intrhand[1]) {
1913 bus_teardown_intr(dev, sc->msk_irq[0], sc->msk_intrhand[0]);
1914 sc->msk_intrhand[1] = NULL;
1915 }
1916 bus_release_resources(dev, sc->msk_irq_spec, sc->msk_irq);
1917 if (sc->msk_msi)
1918 pci_release_msi(dev);
1919 bus_release_resources(dev, sc->msk_res_spec, sc->msk_res);
1920 mtx_destroy(&sc->msk_mtx);
1921
1922 return (0);
1923}
1924

--- 2150 unchanged lines hidden ---