| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: if_cas.c,v 1.41 2020/03/01 05:39:05 thorpej Exp $ */ | | 1 | /* $NetBSD: if_cas.c,v 1.42 2020/03/08 03:16:20 thorpej Exp $ */ |
2 | /* $OpenBSD: if_cas.c,v 1.29 2009/11/29 16:19:38 kettenis Exp $ */ | | 2 | /* $OpenBSD: if_cas.c,v 1.29 2009/11/29 16:19:38 kettenis Exp $ */ |
3 | | | 3 | |
4 | /* | | 4 | /* |
5 | * | | 5 | * |
6 | * Copyright (C) 2007 Mark Kettenis. | | 6 | * Copyright (C) 2007 Mark Kettenis. |
7 | * Copyright (C) 2001 Eduardo Horvath. | | 7 | * Copyright (C) 2001 Eduardo Horvath. |
8 | * All rights reserved. | | 8 | * All rights reserved. |
9 | * | | 9 | * |
10 | * | | 10 | * |
11 | * Redistribution and use in source and binary forms, with or without | | 11 | * Redistribution and use in source and binary forms, with or without |
12 | * modification, are permitted provided that the following conditions | | 12 | * modification, are permitted provided that the following conditions |
13 | * are met: | | 13 | * are met: |
14 | * 1. Redistributions of source code must retain the above copyright | | 14 | * 1. Redistributions of source code must retain the above copyright |
| @@ -34,27 +34,27 @@ | | | @@ -34,27 +34,27 @@ |
34 | /* | | 34 | /* |
35 | * Driver for Sun Cassini ethernet controllers. | | 35 | * Driver for Sun Cassini ethernet controllers. |
36 | * | | 36 | * |
37 | * There are basically two variants of this chip: Cassini and | | 37 | * There are basically two variants of this chip: Cassini and |
38 | * Cassini+. We can distinguish between the two by revision: 0x10 and | | 38 | * Cassini+. We can distinguish between the two by revision: 0x10 and |
39 | * up are Cassini+. The most important difference is that Cassini+ | | 39 | * up are Cassini+. The most important difference is that Cassini+ |
40 | * has a second RX descriptor ring. Cassini+ will not work without | | 40 | * has a second RX descriptor ring. Cassini+ will not work without |
41 | * configuring that second ring. However, since we don't use it we | | 41 | * configuring that second ring. However, since we don't use it we |
42 | * don't actually fill the descriptors, and only hand off the first | | 42 | * don't actually fill the descriptors, and only hand off the first |
43 | * four to the chip. | | 43 | * four to the chip. |
44 | */ | | 44 | */ |
45 | | | 45 | |
46 | #include <sys/cdefs.h> | | 46 | #include <sys/cdefs.h> |
47 | __KERNEL_RCSID(0, "$NetBSD: if_cas.c,v 1.41 2020/03/01 05:39:05 thorpej Exp $"); | | 47 | __KERNEL_RCSID(0, "$NetBSD: if_cas.c,v 1.42 2020/03/08 03:16:20 thorpej Exp $"); |
48 | | | 48 | |
49 | #ifndef _MODULE | | 49 | #ifndef _MODULE |
50 | #include "opt_inet.h" | | 50 | #include "opt_inet.h" |
51 | #endif | | 51 | #endif |
52 | | | 52 | |
53 | #include <sys/param.h> | | 53 | #include <sys/param.h> |
54 | #include <sys/systm.h> | | 54 | #include <sys/systm.h> |
55 | #include <sys/callout.h> | | 55 | #include <sys/callout.h> |
56 | #include <sys/mbuf.h> | | 56 | #include <sys/mbuf.h> |
57 | #include <sys/syslog.h> | | 57 | #include <sys/syslog.h> |
58 | #include <sys/malloc.h> | | 58 | #include <sys/malloc.h> |
59 | #include <sys/kernel.h> | | 59 | #include <sys/kernel.h> |
60 | #include <sys/socket.h> | | 60 | #include <sys/socket.h> |
| @@ -1201,45 +1201,48 @@ cas_init(struct ifnet *ifp) | | | @@ -1201,45 +1201,48 @@ cas_init(struct ifnet *ifp) |
1201 | | | 1201 | |
1202 | /* step 4. TX MAC registers & counters */ | | 1202 | /* step 4. TX MAC registers & counters */ |
1203 | cas_init_regs(sc); | | 1203 | cas_init_regs(sc); |
1204 | max_frame_size = ETHER_MAX_LEN + ETHER_VLAN_ENCAP_LEN; | | 1204 | max_frame_size = ETHER_MAX_LEN + ETHER_VLAN_ENCAP_LEN; |
1205 | v = (max_frame_size) | (0x2000 << 16) /* Burst size */; | | 1205 | v = (max_frame_size) | (0x2000 << 16) /* Burst size */; |
1206 | bus_space_write_4(t, h, CAS_MAC_MAC_MAX_FRAME, v); | | 1206 | bus_space_write_4(t, h, CAS_MAC_MAC_MAX_FRAME, v); |
1207 | | | 1207 | |
1208 | /* step 5. RX MAC registers & counters */ | | 1208 | /* step 5. RX MAC registers & counters */ |
1209 | cas_iff(sc); | | 1209 | cas_iff(sc); |
1210 | | | 1210 | |
1211 | /* step 6 & 7. Program Descriptor Ring Base Addresses */ | | 1211 | /* step 6 & 7. Program Descriptor Ring Base Addresses */ |
1212 | KASSERT((CAS_CDTXADDR(sc, 0) & 0x1fff) == 0); | | 1212 | KASSERT((CAS_CDTXADDR(sc, 0) & 0x1fff) == 0); |
1213 | bus_space_write_4(t, h, CAS_TX_RING_PTR_HI, | | 1213 | bus_space_write_4(t, h, CAS_TX_RING_PTR_HI, |
1214 | (((uint64_t)CAS_CDTXADDR(sc, 0)) >> 32)); | | 1214 | BUS_ADDR_HI32(CAS_CDTXADDR(sc, 0))); |
1215 | bus_space_write_4(t, h, CAS_TX_RING_PTR_LO, CAS_CDTXADDR(sc, 0)); | | 1215 | bus_space_write_4(t, h, CAS_TX_RING_PTR_LO, |
| | | 1216 | BUS_ADDR_LO32(CAS_CDTXADDR(sc, 0))); |
1216 | | | 1217 | |
1217 | KASSERT((CAS_CDRXADDR(sc, 0) & 0x1fff) == 0); | | 1218 | KASSERT((CAS_CDRXADDR(sc, 0) & 0x1fff) == 0); |
1218 | bus_space_write_4(t, h, CAS_RX_DRING_PTR_HI, | | 1219 | bus_space_write_4(t, h, CAS_RX_DRING_PTR_HI, |
1219 | (((uint64_t)CAS_CDRXADDR(sc, 0)) >> 32)); | | 1220 | BUS_ADDR_HI32(CAS_CDRXADDR(sc, 0))); |
1220 | bus_space_write_4(t, h, CAS_RX_DRING_PTR_LO, CAS_CDRXADDR(sc, 0)); | | 1221 | bus_space_write_4(t, h, CAS_RX_DRING_PTR_LO, |
| | | 1222 | BUS_ADDR_LO32(CAS_CDRXADDR(sc, 0))); |
1221 | | | 1223 | |
1222 | KASSERT((CAS_CDRXCADDR(sc, 0) & 0x1fff) == 0); | | 1224 | KASSERT((CAS_CDRXCADDR(sc, 0) & 0x1fff) == 0); |
1223 | bus_space_write_4(t, h, CAS_RX_CRING_PTR_HI, | | 1225 | bus_space_write_4(t, h, CAS_RX_CRING_PTR_HI, |
1224 | (((uint64_t)CAS_CDRXCADDR(sc, 0)) >> 32)); | | 1226 | BUS_ADDR_HI32(CAS_CDRXCADDR(sc, 0))); |
1225 | bus_space_write_4(t, h, CAS_RX_CRING_PTR_LO, CAS_CDRXCADDR(sc, 0)); | | 1227 | bus_space_write_4(t, h, CAS_RX_CRING_PTR_LO, |
| | | 1228 | BUS_ADDR_LO32(CAS_CDRXCADDR(sc, 0))); |
1226 | | | 1229 | |
1227 | if (CAS_PLUS(sc)) { | | 1230 | if (CAS_PLUS(sc)) { |
1228 | KASSERT((CAS_CDRXADDR2(sc, 0) & 0x1fff) == 0); | | 1231 | KASSERT((CAS_CDRXADDR2(sc, 0) & 0x1fff) == 0); |
1229 | bus_space_write_4(t, h, CAS_RX_DRING_PTR_HI2, | | 1232 | bus_space_write_4(t, h, CAS_RX_DRING_PTR_HI2, |
1230 | (((uint64_t)CAS_CDRXADDR2(sc, 0)) >> 32)); | | 1233 | BUS_ADDR_HI32(CAS_CDRXADDR2(sc, 0))); |
1231 | bus_space_write_4(t, h, CAS_RX_DRING_PTR_LO2, | | 1234 | bus_space_write_4(t, h, CAS_RX_DRING_PTR_LO2, |
1232 | CAS_CDRXADDR2(sc, 0)); | | 1235 | BUS_ADDR_LO32(CAS_CDRXADDR2(sc, 0))); |
1233 | } | | 1236 | } |
1234 | | | 1237 | |
1235 | /* step 8. Global Configuration & Interrupt Mask */ | | 1238 | /* step 8. Global Configuration & Interrupt Mask */ |
1236 | cas_estintr(sc, CAS_INTR_REG); | | 1239 | cas_estintr(sc, CAS_INTR_REG); |
1237 | | | 1240 | |
1238 | /* step 9. ETX Configuration: use mostly default values */ | | 1241 | /* step 9. ETX Configuration: use mostly default values */ |
1239 | | | 1242 | |
1240 | /* Enable DMA */ | | 1243 | /* Enable DMA */ |
1241 | v = cas_ringsize(CAS_NTXDESC /*XXX*/) << 10; | | 1244 | v = cas_ringsize(CAS_NTXDESC /*XXX*/) << 10; |
1242 | bus_space_write_4(t, h, CAS_TX_CONFIG, | | 1245 | bus_space_write_4(t, h, CAS_TX_CONFIG, |
1243 | v | CAS_TX_CONFIG_TXDMA_EN | (1 << 24) | (1 << 29)); | | 1246 | v | CAS_TX_CONFIG_TXDMA_EN | (1 << 24) | (1 << 29)); |
1244 | bus_space_write_4(t, h, CAS_TX_KICK, 0); | | 1247 | bus_space_write_4(t, h, CAS_TX_KICK, 0); |
1245 | | | 1248 | |