Tue Nov 18 09:30:43 2008 UTC ()
Fix Yukon EC Ultra cold power up issue.

For the EC Ultra it is necessary to update some extra registers during
reset.  Without doing so causes the system to hang at boot.  The only
workaround I found was to PXE boot before booting into NetBSD.

This change is based on the code from FreeBSD's if_msk.c.  Specifically the
msk_phy_power function.

Also add an splnet/splx across mii_tick.  This matches most other network
drivers.

Change posted for review on 3rd Oct 2008 to tech-net.  No feedback
received.


(chris)
diff -r1.21 -r1.22 src/sys/dev/pci/if_msk.c
diff -r1.12 -r1.13 src/sys/dev/pci/if_skreg.h

cvs diff -r1.21 -r1.22 src/sys/dev/pci/if_msk.c (expand / switch to unified diff)

--- src/sys/dev/pci/if_msk.c 2008/06/20 16:45:13 1.21
+++ src/sys/dev/pci/if_msk.c 2008/11/18 09:30:43 1.22
@@ -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
1801void 1821void
1802msk_tick(void *xsc_if) 1822msk_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
1811void 1835void
1812msk_intr_yukon(struct sk_if_softc *sc_if) 1836msk_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);

cvs diff -r1.12 -r1.13 src/sys/dev/pci/if_skreg.h (expand / switch to unified diff)

--- src/sys/dev/pci/if_skreg.h 2008/04/28 20:23:55 1.12
+++ src/sys/dev/pci/if_skreg.h 2008/11/18 09:30:43 1.13
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: if_skreg.h,v 1.12 2008/04/28 20:23:55 martin Exp $ */ 1/* $NetBSD: if_skreg.h,v 1.13 2008/11/18 09:30:43 chris Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2003 The NetBSD Foundation, Inc. 4 * Copyright (c) 2003 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -194,26 +194,28 @@ @@ -194,26 +194,28 @@
194/* SK_CSR register */ 194/* SK_CSR register */
195#define SK_CSR_SW_RESET 0x0001 195#define SK_CSR_SW_RESET 0x0001
196#define SK_CSR_SW_UNRESET 0x0002 196#define SK_CSR_SW_UNRESET 0x0002
197#define SK_CSR_MASTER_RESET 0x0004 197#define SK_CSR_MASTER_RESET 0x0004
198#define SK_CSR_MASTER_UNRESET 0x0008 198#define SK_CSR_MASTER_UNRESET 0x0008
199#define SK_CSR_MASTER_STOP 0x0010 199#define SK_CSR_MASTER_STOP 0x0010
200#define SK_CSR_MASTER_DONE 0x0020 200#define SK_CSR_MASTER_DONE 0x0020
201#define SK_CSR_SW_IRQ_CLEAR 0x0040 201#define SK_CSR_SW_IRQ_CLEAR 0x0040
202#define SK_CSR_SW_IRQ_SET 0x0080 202#define SK_CSR_SW_IRQ_SET 0x0080
203#define SK_CSR_SLOTSIZE 0x0100 /* 1 == 64 bits, 0 == 32 */ 203#define SK_CSR_SLOTSIZE 0x0100 /* 1 == 64 bits, 0 == 32 */
204#define SK_CSR_BUSCLOCK 0x0200 /* 1 == 33/66 MHz, = 33 */ 204#define SK_CSR_BUSCLOCK 0x0200 /* 1 == 33/66 MHz, = 33 */
205#define SK_CSR_ASF_OFF 0x1000 205#define SK_CSR_ASF_OFF 0x1000
206#define SK_CSR_ASF_ON 0x2000 206#define SK_CSR_ASF_ON 0x2000
 207#define SK_CSR_WOL_OFF __BIT(14)
 208#define SK_CSR_WOL_ON __BIT(15)
207 209
208/* SK_LED register */ 210/* SK_LED register */
209#define SK_LED_GREEN_OFF 0x01 211#define SK_LED_GREEN_OFF 0x01
210#define SK_LED_GREEN_ON 0x02 212#define SK_LED_GREEN_ON 0x02
211 213
212/* SK_ISR register */ 214/* SK_ISR register */
213#define SK_ISR_TX2_AS_CHECK 0x00000001 215#define SK_ISR_TX2_AS_CHECK 0x00000001
214#define SK_ISR_TX2_AS_EOF 0x00000002 216#define SK_ISR_TX2_AS_EOF 0x00000002
215#define SK_ISR_TX2_AS_EOB 0x00000004 217#define SK_ISR_TX2_AS_EOB 0x00000004
216#define SK_ISR_TX2_S_CHECK 0x00000008 218#define SK_ISR_TX2_S_CHECK 0x00000008
217#define SK_ISR_TX2_S_EOF 0x00000010 219#define SK_ISR_TX2_S_EOF 0x00000010
218#define SK_ISR_TX2_S_EOB 0x00000020 220#define SK_ISR_TX2_S_EOB 0x00000020
219#define SK_ISR_TX1_AS_CHECK 0x00000040 221#define SK_ISR_TX1_AS_CHECK 0x00000040
@@ -1494,30 +1496,45 @@ @@ -1494,30 +1496,45 @@
1494 1496
1495/* device specific PCI registers */ 1497/* device specific PCI registers */
1496#define SK_PCI_OURREG1 0x0040 1498#define SK_PCI_OURREG1 0x0040
1497#define SK_PCI_OURREG2 0x0044 1499#define SK_PCI_OURREG2 0x0044
1498#define SK_PCI_CAPID 0x0048 /* 8 bits */ 1500#define SK_PCI_CAPID 0x0048 /* 8 bits */
1499#define SK_PCI_NEXTPTR 0x0049 /* 8 bits */ 1501#define SK_PCI_NEXTPTR 0x0049 /* 8 bits */
1500#define SK_PCI_PWRMGMTCAP 0x004A /* 16 bits */ 1502#define SK_PCI_PWRMGMTCAP 0x004A /* 16 bits */
1501#define SK_PCI_PWRMGMTCTRL 0x004C /* 16 bits */ 1503#define SK_PCI_PWRMGMTCTRL 0x004C /* 16 bits */
1502#define SK_PCI_PME_EVENT 0x004F 1504#define SK_PCI_PME_EVENT 0x004F
1503#define SK_PCI_VPD_CAPID 0x0050 1505#define SK_PCI_VPD_CAPID 0x0050
1504#define SK_PCI_VPD_NEXTPTR 0x0051 1506#define SK_PCI_VPD_NEXTPTR 0x0051
1505#define SK_PCI_VPD_ADDR 0x0052 1507#define SK_PCI_VPD_ADDR 0x0052
1506#define SK_PCI_VPD_DATA 0x0054 1508#define SK_PCI_VPD_DATA 0x0054
 1509#define SK_PCI_OURREG3 0x0080 /* Yukon EC U */
 1510#define SK_PCI_OURREG4 0x0084
 1511#define SK_PCI_OURREG5 0x0088
1507 1512
1508#define SK_Y2_REG1_PHY1_COMA 0x10000000 1513#define SK_Y2_REG1_PHY1_COMA 0x10000000
1509#define SK_Y2_REG1_PHY2_COMA 0x20000000 1514#define SK_Y2_REG1_PHY2_COMA 0x20000000
1510 1515
 1516/* SK_PCI_OURREG4 32bits (Yukon-ECU only) */
 1517#define SK_Y2_REG4_TIMER_VALUE_MSK (0xff << 16)
 1518#define SK_Y2_REG4_FORCE_ASPM_REQUEST __BIT(15)
 1519#define SK_Y2_REG4_ASPM_GPHY_LINK_DOWN __BIT(14)
 1520#define SK_Y2_REG4_ASPM_INT_FIFO_EMPTY __BIT(13)
 1521#define SK_Y2_REG4_ASPM_CLKRUN_REQUEST __BIT(12)
 1522#define SK_Y2_REG4_ASPM_FORCE_CLKREQ_ENA __BIT(4)
 1523#define SK_Y2_REG4_ASPM_CLKREQ_PAD __BIT(3)
 1524#define SK_Y2_REG4_ASPM_A1_MODE_SELECT __BIT(2)
 1525#define SK_Y2_REG4_CLK_GATE_PEX_UNIT_ENA __BIT(1)
 1526#define SK_Y2_REG4_CLK_GATE_ROOT_COR_ENA __BIT(0)
 1527
1511#define SK_PSTATE_MASK 0x0003 1528#define SK_PSTATE_MASK 0x0003
1512#define SK_PSTATE_D0 0x0000 1529#define SK_PSTATE_D0 0x0000
1513#define SK_PSTATE_D1 0x0001 1530#define SK_PSTATE_D1 0x0001
1514#define SK_PSTATE_D2 0x0002 1531#define SK_PSTATE_D2 0x0002
1515#define SK_PSTATE_D3 0x0003 1532#define SK_PSTATE_D3 0x0003
1516#define SK_PME_EN 0x0010 1533#define SK_PME_EN 0x0010
1517#define SK_PME_STATUS 0x8000 1534#define SK_PME_STATUS 0x8000
1518 1535
1519/* 1536/*
1520 * VPD flag bit. Set to 0 to initiate a read, will become 1 when 1537 * VPD flag bit. Set to 0 to initiate a read, will become 1 when
1521 * read is complete. Set to 1 to initiate a write, will become 0 1538 * read is complete. Set to 1 to initiate a write, will become 0
1522 * when write is finished. 1539 * when write is finished.
1523 */ 1540 */