if_wb.c (72084) | if_wb.c (72813) |
---|---|
1/* 2 * Copyright (c) 1997, 1998 3 * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 15 unchanged lines hidden (view full) --- 24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 30 * THE POSSIBILITY OF SUCH DAMAGE. 31 * | 1/* 2 * Copyright (c) 1997, 1998 3 * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 15 unchanged lines hidden (view full) --- 24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 30 * THE POSSIBILITY OF SUCH DAMAGE. 31 * |
32 * $FreeBSD: head/sys/pci/if_wb.c 72084 2001-02-06 10:12:15Z phk $ | 32 * $FreeBSD: head/sys/pci/if_wb.c 72813 2001-02-21 20:54:22Z wpaul $ |
33 */ 34 35/* 36 * Winbond fast ethernet PCI NIC driver 37 * 38 * Supports various cheap network adapters based on the Winbond W89C840F 39 * fast ethernet controller chip. This includes adapters manufactured by 40 * Winbond itself and some made by Linksys. --- 82 unchanged lines hidden (view full) --- 123#define WB_USEIOSPACE 124 125#include <pci/if_wbreg.h> 126 127MODULE_DEPEND(wb, miibus, 1, 1, 1); 128 129#ifndef lint 130static const char rcsid[] = | 33 */ 34 35/* 36 * Winbond fast ethernet PCI NIC driver 37 * 38 * Supports various cheap network adapters based on the Winbond W89C840F 39 * fast ethernet controller chip. This includes adapters manufactured by 40 * Winbond itself and some made by Linksys. --- 82 unchanged lines hidden (view full) --- 123#define WB_USEIOSPACE 124 125#include <pci/if_wbreg.h> 126 127MODULE_DEPEND(wb, miibus, 1, 1, 1); 128 129#ifndef lint 130static const char rcsid[] = |
131 "$FreeBSD: head/sys/pci/if_wb.c 72084 2001-02-06 10:12:15Z phk $"; | 131 "$FreeBSD: head/sys/pci/if_wb.c 72813 2001-02-21 20:54:22Z wpaul $"; |
132#endif 133 134/* 135 * Various supported device vendors/types and their names. 136 */ 137static struct wb_type wb_devs[] = { 138 { WB_VENDORID, WB_DEVICEID_840F, 139 "Winbond W89C840F 10/100BaseTX" }, --- 677 unchanged lines hidden (view full) --- 817 818 mtx_init(&sc->wb_mtx, device_get_nameunit(dev), MTX_DEF | MTX_RECURSE); 819 WB_LOCK(sc); 820 821 /* 822 * Handle power management nonsense. 823 */ 824 | 132#endif 133 134/* 135 * Various supported device vendors/types and their names. 136 */ 137static struct wb_type wb_devs[] = { 138 { WB_VENDORID, WB_DEVICEID_840F, 139 "Winbond W89C840F 10/100BaseTX" }, --- 677 unchanged lines hidden (view full) --- 817 818 mtx_init(&sc->wb_mtx, device_get_nameunit(dev), MTX_DEF | MTX_RECURSE); 819 WB_LOCK(sc); 820 821 /* 822 * Handle power management nonsense. 823 */ 824 |
825 command = pci_read_config(dev, WB_PCI_CAPID, 4) & 0x000000FF; 826 if (command == 0x01) { | 825 if (pci_get_powerstate(dev) != PCI_POWERSTATE_D0) { 826 u_int32_t iobase, membase, irq; |
827 | 827 |
828 command = pci_read_config(dev, WB_PCI_PWRMGMTCTRL, 4); 829 if (command & WB_PSTATE_MASK) { 830 u_int32_t iobase, membase, irq; | 828 /* Save important PCI config data. */ 829 iobase = pci_read_config(dev, WB_PCI_LOIO, 4); 830 membase = pci_read_config(dev, WB_PCI_LOMEM, 4); 831 irq = pci_read_config(dev, WB_PCI_INTLINE, 4); |
831 | 832 |
832 /* Save important PCI config data. */ 833 iobase = pci_read_config(dev, WB_PCI_LOIO, 4); 834 membase = pci_read_config(dev, WB_PCI_LOMEM, 4); 835 irq = pci_read_config(dev, WB_PCI_INTLINE, 4); | 833 /* Reset the power state. */ 834 printf("wb%d: chip is in D%d power mode " 835 "-- setting to D0\n", unit, 836 pci_get_powerstate(dev)); 837 pci_set_powerstate(dev, PCI_POWERSTATE_D0); |
836 | 838 |
837 /* Reset the power state. */ 838 printf("wb%d: chip is in D%d power mode " 839 "-- setting to D0\n", unit, command & WB_PSTATE_MASK); 840 command &= 0xFFFFFFFC; 841 pci_write_config(dev, WB_PCI_PWRMGMTCTRL, command, 4); 842 843 /* Restore PCI config data. */ 844 pci_write_config(dev, WB_PCI_LOIO, iobase, 4); 845 pci_write_config(dev, WB_PCI_LOMEM, membase, 4); 846 pci_write_config(dev, WB_PCI_INTLINE, irq, 4); 847 } | 839 /* Restore PCI config data. */ 840 pci_write_config(dev, WB_PCI_LOIO, iobase, 4); 841 pci_write_config(dev, WB_PCI_LOMEM, membase, 4); 842 pci_write_config(dev, WB_PCI_INTLINE, irq, 4); |
848 } 849 850 /* 851 * Map control/status registers. 852 */ | 843 } 844 845 /* 846 * Map control/status registers. 847 */ |
848 pci_enable_busmaster(dev); 849 pci_enable_io(dev, PCIM_CMD_PORTEN); 850 pci_enable_io(dev, PCIM_CMD_MEMEN); |
|
853 command = pci_read_config(dev, PCIR_COMMAND, 4); | 851 command = pci_read_config(dev, PCIR_COMMAND, 4); |
854 command |= (PCIM_CMD_PORTEN|PCIM_CMD_MEMEN|PCIM_CMD_BUSMASTEREN); 855 pci_write_config(dev, PCIR_COMMAND, command, 4); 856 command = pci_read_config(dev, PCIR_COMMAND, 4); | |
857 858#ifdef WB_USEIOSPACE 859 if (!(command & PCIM_CMD_PORTEN)) { 860 printf("wb%d: failed to enable I/O ports!\n", unit); 861 error = ENXIO; 862 goto fail; 863 } 864#else --- 1029 unchanged lines hidden --- | 852 853#ifdef WB_USEIOSPACE 854 if (!(command & PCIM_CMD_PORTEN)) { 855 printf("wb%d: failed to enable I/O ports!\n", unit); 856 error = ENXIO; 857 goto fail; 858 } 859#else --- 1029 unchanged lines hidden --- |