| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: if_msk.c,v 1.21 2008/06/20 16:45:13 cube Exp $ */ | | 1 | /* $NetBSD: if_msk.c,v 1.22 2008/11/18 09:30:43 chris Exp $ */ |
2 | /* $OpenBSD: if_msk.c,v 1.42 2007/01/17 02:43:02 krw Exp $ */ | | 2 | /* $OpenBSD: if_msk.c,v 1.42 2007/01/17 02:43:02 krw Exp $ */ |
3 | | | 3 | |
4 | /* | | 4 | /* |
5 | * Copyright (c) 1997, 1998, 1999, 2000 | | 5 | * Copyright (c) 1997, 1998, 1999, 2000 |
6 | * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved. | | 6 | * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved. |
7 | * | | 7 | * |
8 | * Redistribution and use in source and binary forms, with or without | | 8 | * Redistribution and use in source and binary forms, with or without |
9 | * modification, are permitted provided that the following conditions | | 9 | * modification, are permitted provided that the following conditions |
10 | * are met: | | 10 | * are met: |
11 | * 1. Redistributions of source code must retain the above copyright | | 11 | * 1. Redistributions of source code must retain the above copyright |
12 | * notice, this list of conditions and the following disclaimer. | | 12 | * notice, this list of conditions and the following disclaimer. |
13 | * 2. Redistributions in binary form must reproduce the above copyright | | 13 | * 2. Redistributions in binary form must reproduce the above copyright |
14 | * notice, this list of conditions and the following disclaimer in the | | 14 | * notice, this list of conditions and the following disclaimer in the |
| @@ -42,27 +42,27 @@ | | | @@ -42,27 +42,27 @@ |
42 | * purpose with or without fee is hereby granted, provided that the above | | 42 | * purpose with or without fee is hereby granted, provided that the above |
43 | * copyright notice and this permission notice appear in all copies. | | 43 | * copyright notice and this permission notice appear in all copies. |
44 | * | | 44 | * |
45 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | | 45 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
46 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | | 46 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
47 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | | 47 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
48 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | | 48 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
49 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | | 49 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
50 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | | 50 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
51 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | | 51 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
52 | */ | | 52 | */ |
53 | | | 53 | |
54 | #include <sys/cdefs.h> | | 54 | #include <sys/cdefs.h> |
55 | __KERNEL_RCSID(0, "$NetBSD: if_msk.c,v 1.21 2008/06/20 16:45:13 cube Exp $"); | | 55 | __KERNEL_RCSID(0, "$NetBSD: if_msk.c,v 1.22 2008/11/18 09:30:43 chris Exp $"); |
56 | | | 56 | |
57 | #include "bpfilter.h" | | 57 | #include "bpfilter.h" |
58 | #include "rnd.h" | | 58 | #include "rnd.h" |
59 | | | 59 | |
60 | #include <sys/param.h> | | 60 | #include <sys/param.h> |
61 | #include <sys/systm.h> | | 61 | #include <sys/systm.h> |
62 | #include <sys/sockio.h> | | 62 | #include <sys/sockio.h> |
63 | #include <sys/mbuf.h> | | 63 | #include <sys/mbuf.h> |
64 | #include <sys/malloc.h> | | 64 | #include <sys/malloc.h> |
65 | #include <sys/mutex.h> | | 65 | #include <sys/mutex.h> |
66 | #include <sys/kernel.h> | | 66 | #include <sys/kernel.h> |
67 | #include <sys/socket.h> | | 67 | #include <sys/socket.h> |
68 | #include <sys/device.h> | | 68 | #include <sys/device.h> |
| @@ -798,26 +798,46 @@ void msk_reset(struct sk_softc *sc) | | | @@ -798,26 +798,46 @@ void msk_reset(struct sk_softc *sc) |
798 | CSR_WRITE_1(sc, SK_CSR, SK_CSR_MASTER_RESET); | | 798 | CSR_WRITE_1(sc, SK_CSR, SK_CSR_MASTER_RESET); |
799 | | | 799 | |
800 | DELAY(1000); | | 800 | DELAY(1000); |
801 | CSR_WRITE_1(sc, SK_CSR, SK_CSR_SW_UNRESET); | | 801 | CSR_WRITE_1(sc, SK_CSR, SK_CSR_SW_UNRESET); |
802 | DELAY(2); | | 802 | DELAY(2); |
803 | CSR_WRITE_1(sc, SK_CSR, SK_CSR_MASTER_UNRESET); | | 803 | CSR_WRITE_1(sc, SK_CSR, SK_CSR_MASTER_UNRESET); |
804 | sk_win_write_1(sc, SK_TESTCTL1, 2); | | 804 | sk_win_write_1(sc, SK_TESTCTL1, 2); |
805 | | | 805 | |
806 | reg1 = sk_win_read_4(sc, SK_Y2_PCI_REG(SK_PCI_OURREG1)); | | 806 | reg1 = sk_win_read_4(sc, SK_Y2_PCI_REG(SK_PCI_OURREG1)); |
807 | if (sc->sk_type == SK_YUKON_XL && sc->sk_rev > SK_YUKON_XL_REV_A1) | | 807 | if (sc->sk_type == SK_YUKON_XL && sc->sk_rev > SK_YUKON_XL_REV_A1) |
808 | reg1 |= (SK_Y2_REG1_PHY1_COMA | SK_Y2_REG1_PHY2_COMA); | | 808 | reg1 |= (SK_Y2_REG1_PHY1_COMA | SK_Y2_REG1_PHY2_COMA); |
809 | else | | 809 | else |
810 | reg1 &= ~(SK_Y2_REG1_PHY1_COMA | SK_Y2_REG1_PHY2_COMA); | | 810 | reg1 &= ~(SK_Y2_REG1_PHY1_COMA | SK_Y2_REG1_PHY2_COMA); |
| | | 811 | |
| | | 812 | if (sc->sk_type == SK_YUKON_EC_U) { |
| | | 813 | uint32_t our; |
| | | 814 | |
| | | 815 | CSR_WRITE_2(sc, SK_CSR, SK_CSR_WOL_ON); |
| | | 816 | |
| | | 817 | /* enable all clocks. */ |
| | | 818 | sk_win_write_4(sc, SK_Y2_PCI_REG(SK_PCI_OURREG3), 0); |
| | | 819 | our = sk_win_read_4(sc, SK_Y2_PCI_REG(SK_PCI_OURREG4)); |
| | | 820 | our &= (SK_Y2_REG4_FORCE_ASPM_REQUEST| |
| | | 821 | SK_Y2_REG4_ASPM_GPHY_LINK_DOWN| |
| | | 822 | SK_Y2_REG4_ASPM_INT_FIFO_EMPTY| |
| | | 823 | SK_Y2_REG4_ASPM_CLKRUN_REQUEST); |
| | | 824 | /* Set all bits to 0 except bits 15..12 */ |
| | | 825 | sk_win_write_4(sc, SK_Y2_PCI_REG(SK_PCI_OURREG4), our); |
| | | 826 | /* Set to default value */ |
| | | 827 | sk_win_write_4(sc, SK_Y2_PCI_REG(SK_PCI_OURREG5), 0); |
| | | 828 | } |
| | | 829 | |
| | | 830 | /* release PHY from PowerDown/Coma mode. */ |
811 | sk_win_write_4(sc, SK_Y2_PCI_REG(SK_PCI_OURREG1), reg1); | | 831 | sk_win_write_4(sc, SK_Y2_PCI_REG(SK_PCI_OURREG1), reg1); |
812 | | | 832 | |
813 | if (sc->sk_type == SK_YUKON_XL && sc->sk_rev > SK_YUKON_XL_REV_A1) | | 833 | if (sc->sk_type == SK_YUKON_XL && sc->sk_rev > SK_YUKON_XL_REV_A1) |
814 | sk_win_write_1(sc, SK_Y2_CLKGATE, | | 834 | sk_win_write_1(sc, SK_Y2_CLKGATE, |
815 | SK_Y2_CLKGATE_LINK1_GATE_DIS | | | 835 | SK_Y2_CLKGATE_LINK1_GATE_DIS | |
816 | SK_Y2_CLKGATE_LINK2_GATE_DIS | | | 836 | SK_Y2_CLKGATE_LINK2_GATE_DIS | |
817 | SK_Y2_CLKGATE_LINK1_CORE_DIS | | | 837 | SK_Y2_CLKGATE_LINK1_CORE_DIS | |
818 | SK_Y2_CLKGATE_LINK2_CORE_DIS | | | 838 | SK_Y2_CLKGATE_LINK2_CORE_DIS | |
819 | SK_Y2_CLKGATE_LINK1_PCI_DIS | SK_Y2_CLKGATE_LINK2_PCI_DIS); | | 839 | SK_Y2_CLKGATE_LINK1_PCI_DIS | SK_Y2_CLKGATE_LINK2_PCI_DIS); |
820 | else | | 840 | else |
821 | sk_win_write_1(sc, SK_Y2_CLKGATE, 0); | | 841 | sk_win_write_1(sc, SK_Y2_CLKGATE, 0); |
822 | | | 842 | |
823 | CSR_WRITE_2(sc, SK_LINK_CTRL, SK_LINK_RESET_SET); | | 843 | CSR_WRITE_2(sc, SK_LINK_CTRL, SK_LINK_RESET_SET); |
| @@ -1793,28 +1813,32 @@ msk_txeof(struct sk_if_softc *sc_if, int | | | @@ -1793,28 +1813,32 @@ msk_txeof(struct sk_if_softc *sc_if, int |
1793 | | | 1813 | |
1794 | if (sc_if->sk_cdata.sk_tx_cnt < MSK_TX_RING_CNT - 2) | | 1814 | if (sc_if->sk_cdata.sk_tx_cnt < MSK_TX_RING_CNT - 2) |
1795 | ifp->if_flags &= ~IFF_OACTIVE; | | 1815 | ifp->if_flags &= ~IFF_OACTIVE; |
1796 | | | 1816 | |
1797 | if (prog > 0) | | 1817 | if (prog > 0) |
1798 | sc_if->sk_cdata.sk_tx_cons = cons; | | 1818 | sc_if->sk_cdata.sk_tx_cons = cons; |
1799 | } | | 1819 | } |
1800 | | | 1820 | |
1801 | void | | 1821 | void |
1802 | msk_tick(void *xsc_if) | | 1822 | msk_tick(void *xsc_if) |
1803 | { | | 1823 | { |
1804 | struct sk_if_softc *sc_if = xsc_if; | | 1824 | struct sk_if_softc *sc_if = xsc_if; |
1805 | struct mii_data *mii = &sc_if->sk_mii; | | 1825 | struct mii_data *mii = &sc_if->sk_mii; |
| | | 1826 | int s; |
1806 | | | 1827 | |
| | | 1828 | s = splnet(); |
1807 | mii_tick(mii); | | 1829 | mii_tick(mii); |
| | | 1830 | splx(s); |
| | | 1831 | |
1808 | callout_schedule(&sc_if->sk_tick_ch, hz); | | 1832 | callout_schedule(&sc_if->sk_tick_ch, hz); |
1809 | } | | 1833 | } |
1810 | | | 1834 | |
1811 | void | | 1835 | void |
1812 | msk_intr_yukon(struct sk_if_softc *sc_if) | | 1836 | msk_intr_yukon(struct sk_if_softc *sc_if) |
1813 | { | | 1837 | { |
1814 | u_int8_t status; | | 1838 | u_int8_t status; |
1815 | | | 1839 | |
1816 | status = SK_IF_READ_1(sc_if, 0, SK_GMAC_ISR); | | 1840 | status = SK_IF_READ_1(sc_if, 0, SK_GMAC_ISR); |
1817 | /* RX overrun */ | | 1841 | /* RX overrun */ |
1818 | if ((status & SK_GMAC_INT_RX_OVER) != 0) { | | 1842 | if ((status & SK_GMAC_INT_RX_OVER) != 0) { |
1819 | SK_IF_WRITE_1(sc_if, 0, SK_RXMF1_CTRL_TEST, | | 1843 | SK_IF_WRITE_1(sc_if, 0, SK_RXMF1_CTRL_TEST, |
1820 | SK_RFCTL_RX_FIFO_OVER); | | 1844 | SK_RFCTL_RX_FIFO_OVER); |