summaryrefslogtreecommitdiff
path: root/sys/dev/pci
diff options
context:
space:
mode:
authorBrad Smith <brad@cvs.openbsd.org>2005-09-17 02:53:11 +0000
committerBrad Smith <brad@cvs.openbsd.org>2005-09-17 02:53:11 +0000
commitf7a9a4b49b19508409a4a5ec6570cca35e25c74f (patch)
treedd97fd0244c6a577d1f6fd7ebb84d29dac2314e9 /sys/dev/pci
parent20a5e6553907b95b815cb948e31ebf270712f5b9 (diff)
add media detection and dual port detection for Yukon-2.
from jason@
Diffstat (limited to 'sys/dev/pci')
-rw-r--r--sys/dev/pci/if_sk.c80
-rw-r--r--sys/dev/pci/if_skreg.h27
2 files changed, 80 insertions, 27 deletions
diff --git a/sys/dev/pci/if_sk.c b/sys/dev/pci/if_sk.c
index 7edbbedbc60..3175dba70d3 100644
--- a/sys/dev/pci/if_sk.c
+++ b/sys/dev/pci/if_sk.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_sk.c,v 1.79 2005/09/16 00:43:31 brad Exp $ */
+/* $OpenBSD: if_sk.c,v 1.80 2005/09/17 02:53:09 brad Exp $ */
/*
* Copyright (c) 1997, 1998, 1999, 2000
@@ -1484,23 +1484,41 @@ skc_attach(struct device *parent, struct device *self, void *aux)
sc->sk_rboff));
/* Read and save physical media type */
- switch(sk_win_read_1(sc, SK_PMDTYPE)) {
- case SK_PMD_1000BASESX:
- sc->sk_pmd = IFM_1000_SX;
- break;
- case SK_PMD_1000BASELX:
- sc->sk_pmd = IFM_1000_LX;
- break;
- case SK_PMD_1000BASECX:
- sc->sk_pmd = IFM_1000_CX;
- break;
- case SK_PMD_1000BASETX:
- sc->sk_pmd = IFM_1000_T;
- break;
- default:
- printf("%s: unknown media type: 0x%x\n",
- sc->sk_dev.dv_xname, sk_win_read_1(sc, SK_PMDTYPE));
- goto fail_2;
+ skrs = sk_win_read_1(sc, SK_PMDTYPE);
+ if (SK_IS_YUKON2(sc)) {
+ switch (skrs) {
+ case 'L':
+ sc->sk_pmd = IFM_1000_LX;
+ break;
+ case 'S':
+ sc->sk_pmd = IFM_1000_SX;
+ break;
+ case SK_PMD_1000BASETX:
+ case SK_PMD_1000BASETX_ALT:
+ default:
+ sc->sk_pmd = IFM_1000_T;
+ break;
+ }
+ } else {
+ switch (skrs) {
+ case SK_PMD_1000BASESX:
+ sc->sk_pmd = IFM_1000_SX;
+ break;
+ case SK_PMD_1000BASELX:
+ sc->sk_pmd = IFM_1000_LX;
+ break;
+ case SK_PMD_1000BASECX:
+ sc->sk_pmd = IFM_1000_CX;
+ break;
+ case SK_PMD_1000BASETX:
+ case SK_PMD_1000BASETX_ALT:
+ sc->sk_pmd = IFM_1000_T;
+ break;
+ default:
+ printf("%s: unknown media type: 0x%x\n",
+ sc->sk_dev.dv_xname, sk_win_read_1(sc, SK_PMDTYPE));
+ goto fail_2;
+ }
}
switch (sc->sk_type) {
@@ -1576,11 +1594,27 @@ skc_attach(struct device *parent, struct device *self, void *aux)
skca.skc_rev = sc->sk_rev;
(void)config_found(&sc->sk_dev, &skca, skcprint);
- if (!(sk_win_read_1(sc, SK_CONFIG) & SK_CONFIG_SINGLEMAC)) {
- skca.skc_port = SK_PORT_B;
- skca.skc_type = sc->sk_type;
- skca.skc_rev = sc->sk_rev;
- (void)config_found(&sc->sk_dev, &skca, skcprint);
+ if (SK_IS_YUKON2(sc)) {
+ u_int8_t hw;
+
+ hw = sk_win_read_1(sc, SK_Y2_HWRES);
+ if ((hw & SK_Y2_HWRES_LINK_MASK) == SK_Y2_HWRES_LINK_DUAL) {
+ if ((sk_win_read_1(sc, SK_Y2_CLKGATE) &
+ SK_Y2_CLKGATE_LINK2_INACTIVE) == 0) {
+ skca.skc_port = SK_PORT_B;
+ skca.skc_type = sc->sk_type;
+ skca.skc_rev = sc->sk_rev;
+ (void)config_found(&sc->sk_dev, &skca,
+ skcprint);
+ }
+ }
+ } else {
+ if (!(sk_win_read_1(sc, SK_CONFIG) & SK_CONFIG_SINGLEMAC)) {
+ skca.skc_port = SK_PORT_B;
+ skca.skc_type = sc->sk_type;
+ skca.skc_rev = sc->sk_rev;
+ (void)config_found(&sc->sk_dev, &skca, skcprint);
+ }
}
/* Turn on the 'driver is loaded' LED. */
diff --git a/sys/dev/pci/if_skreg.h b/sys/dev/pci/if_skreg.h
index 1bb45688e73..45b0d0df21b 100644
--- a/sys/dev/pci/if_skreg.h
+++ b/sys/dev/pci/if_skreg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_skreg.h,v 1.18 2005/09/16 00:43:31 brad Exp $ */
+/* $OpenBSD: if_skreg.h,v 1.19 2005/09/17 02:53:10 brad Exp $ */
/*
* Copyright (c) 1997, 1998, 1999, 2000
@@ -277,8 +277,10 @@
#define SK_CONFIG 0x011A
#define SK_CHIPVER 0x011B
#define SK_EPROM0 0x011C
-#define SK_EPROM1 0x011D
-#define SK_EPROM2 0x011E
+#define SK_EPROM1 0x011D /* yukon/genesis */
+#define SK_Y2_CLKGATE 0x011D /* yukon 2 */
+#define SK_EPROM2 0x011E /* yukon/genesis */
+#define SK_Y2_HWRES 0x011E /* yukon 2 */
#define SK_EPROM3 0x011F
#define SK_EP_ADDR 0x0120
#define SK_EP_DATA 0x0124
@@ -317,6 +319,8 @@
#define SK_YUKON_FE 0xB7
#define SK_YUKON_FAMILY(x) ((x) & 0xB0)
+#define SK_IS_YUKON2(sc) \
+ ((sc)->sk_type >= SK_YUKON_XL && (sc)->sk_type <= SK_YUKON_FE)
/* Known revisions in SK_CONFIG */
#define SK_YUKON_LITE_REV_A0 0x0 /* invented, see test in skc_attach */
@@ -371,9 +375,10 @@
#define SK_CONFIG_SINGLEMAC 0x01
#define SK_CONFIG_DIS_DSL_CLK 0x02
+#define SK_PMD_1000BASETX_ALT 0x31
+#define SK_PMD_1000BASECX 0x43
#define SK_PMD_1000BASELX 0x4C
#define SK_PMD_1000BASESX 0x53
-#define SK_PMD_1000BASECX 0x43
#define SK_PMD_1000BASETX 0x54
/* GPIO bits */
@@ -398,6 +403,20 @@
#define SK_GPIO_DIR8 0x01000000
#define SK_GPIO_DIR9 0x02000000
+#define SK_Y2_CLKGATE_LINK2_INACTIVE 0x80 /* port 2 inactive */
+#define SK_Y2_CLKGATE_LINK2_GATE_DIS 0x40 /* disable clock gate, 2 */
+#define SK_Y2_CLKGATE_LINK2_CORE_DIS 0x20 /* disable core clock, 2 */
+#define SK_Y2_CLKGATE_LINK2_PCI_DIS 0x10 /* disable pci clock, 2 */
+#define SK_Y2_CLKGATE_LINK1_INACTIVE 0x08 /* port 1 inactive */
+#define SK_Y2_CLKGATE_LINK1_GATE_DIS 0x04 /* disable clock gate, 1 */
+#define SK_Y2_CLKGATE_LINK1_CORE_DIS 0x02 /* disable core clock, 1 */
+#define SK_Y2_CLKGATE_LINK1_PCI_DIS 0x01 /* disable pci clock, 1 */
+
+#define SK_Y2_HWRES_LINK_1 0x01
+#define SK_Y2_HWRES_LINK_2 0x02
+#define SK_Y2_HWRES_LINK_MASK (SK_Y2_HWRES_LINK_1 | SK_Y2_HWRES_LINK_2)
+#define SK_Y2_HWRES_LINK_DUAL (SK_Y2_HWRES_LINK_1 | SK_Y2_HWRES_LINK_2)
+
/* Block 3 Ram interface and MAC arbiter registers */
#define SK_RAMADDR 0x0180
#define SK_RAMDATA0 0x0184