Deleted Added
full compact
lsi64854.c (137532) lsi64854.c (145190)
1/*-
2 * Copyright (c) 2004 Scott Long
3 * 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

--- 50 unchanged lines hidden (view full) ---

59 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
60 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
61 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
62 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
63 * POSSIBILITY OF SUCH DAMAGE.
64 */
65
66#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2004 Scott Long
3 * 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

--- 50 unchanged lines hidden (view full) ---

59 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
60 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
61 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
62 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
63 * POSSIBILITY OF SUCH DAMAGE.
64 */
65
66#include <sys/cdefs.h>
67__FBSDID("$FreeBSD: head/sys/sparc64/sbus/lsi64854.c 137532 2004-11-10 14:09:52Z trhodes $");
67__FBSDID("$FreeBSD: head/sys/sparc64/sbus/lsi64854.c 145190 2005-04-17 12:45:20Z marius $");
68
69#include <sys/param.h>
70#include <sys/systm.h>
71#include <sys/bus.h>
72#include <sys/kernel.h>
73#include <sys/resource.h>
74#include <sys/lock.h>
75#include <sys/mutex.h>

--- 35 unchanged lines hidden (view full) ---

111 * sc_regs
112 * sc_burst
113 * sc_channel (one of SCSI, ENET, PP)
114 * sc_client (one of SCSI, ENET, PP `soft_c' pointers)
115 */
116void
117lsi64854_attach(struct lsi64854_softc *sc)
118{
68
69#include <sys/param.h>
70#include <sys/systm.h>
71#include <sys/bus.h>
72#include <sys/kernel.h>
73#include <sys/resource.h>
74#include <sys/lock.h>
75#include <sys/mutex.h>

--- 35 unchanged lines hidden (view full) ---

111 * sc_regs
112 * sc_burst
113 * sc_channel (one of SCSI, ENET, PP)
114 * sc_client (one of SCSI, ENET, PP `soft_c' pointers)
115 */
116void
117lsi64854_attach(struct lsi64854_softc *sc)
118{
119 u_int32_t csr;
119 uint32_t csr;
120
121 sc->dv_name = device_get_nameunit(sc->sc_dev);
122
123 /* Indirect functions */
124 switch (sc->sc_channel) {
125 case L64854_CHANNEL_SCSI:
126 sc->intr = lsi64854_scsi_intr;
127 sc->setup = lsi64854_setup;

--- 72 unchanged lines hidden (view full) ---

200 if (DONTPANIC) \
201 printf(MSG); \
202 else \
203 panic(MSG); \
204 } \
205} while (0)
206
207#define DMA_DRAIN(sc, dontpanic) do { \
120
121 sc->dv_name = device_get_nameunit(sc->sc_dev);
122
123 /* Indirect functions */
124 switch (sc->sc_channel) {
125 case L64854_CHANNEL_SCSI:
126 sc->intr = lsi64854_scsi_intr;
127 sc->setup = lsi64854_setup;

--- 72 unchanged lines hidden (view full) ---

200 if (DONTPANIC) \
201 printf(MSG); \
202 else \
203 panic(MSG); \
204 } \
205} while (0)
206
207#define DMA_DRAIN(sc, dontpanic) do { \
208 u_int32_t csr; \
208 uint32_t csr; \
209 /* \
210 * DMA rev0 & rev1: we are not allowed to touch the DMA "flush" \
211 * and "drain" bits while it is still thinking about a \
212 * request. \
213 * other revs: D_ESC_R_PEND bit reads as 0 \
214 */ \
215 DMAWAIT(sc, L64854_GCSR(sc) & D_ESC_R_PEND, "R_PEND", dontpanic);\
216 if (sc->sc_rev != DMAREV_HME) { \

--- 6 unchanged lines hidden (view full) ---

223 csr |= D_ESC_DRAIN; \
224 else \
225 csr |= L64854_INVALIDATE; \
226 \
227 L64854_SCSR(sc,csr); \
228 } \
229 /* \
230 * Wait for draining to finish \
209 /* \
210 * DMA rev0 & rev1: we are not allowed to touch the DMA "flush" \
211 * and "drain" bits while it is still thinking about a \
212 * request. \
213 * other revs: D_ESC_R_PEND bit reads as 0 \
214 */ \
215 DMAWAIT(sc, L64854_GCSR(sc) & D_ESC_R_PEND, "R_PEND", dontpanic);\
216 if (sc->sc_rev != DMAREV_HME) { \

--- 6 unchanged lines hidden (view full) ---

223 csr |= D_ESC_DRAIN; \
224 else \
225 csr |= L64854_INVALIDATE; \
226 \
227 L64854_SCSR(sc,csr); \
228 } \
229 /* \
230 * Wait for draining to finish \
231 * rev0 & rev1 call this PACKCNT \
231 * rev0 & rev1 call this PACKCNT \
232 */ \
233 DMAWAIT(sc, L64854_GCSR(sc) & L64854_DRAINING, "DRAINING", dontpanic);\
234} while(0)
235
236#define DMA_FLUSH(sc, dontpanic) do { \
232 */ \
233 DMAWAIT(sc, L64854_GCSR(sc) & L64854_DRAINING, "DRAINING", dontpanic);\
234} while(0)
235
236#define DMA_FLUSH(sc, dontpanic) do { \
237 u_int32_t csr; \
237 uint32_t csr; \
238 /* \
239 * DMA rev0 & rev1: we are not allowed to touch the DMA "flush" \
240 * and "drain" bits while it is still thinking about a \
241 * request. \
242 * other revs: D_ESC_R_PEND bit reads as 0 \
243 */ \
244 DMAWAIT(sc, L64854_GCSR(sc) & D_ESC_R_PEND, "R_PEND", dontpanic);\
245 csr = L64854_GCSR(sc); \
246 csr &= ~(L64854_WRITE|L64854_EN_DMA); /* no-ops on ENET */ \
247 csr |= L64854_INVALIDATE; /* XXX FAS ? */ \
248 L64854_SCSR(sc,csr); \
249} while(0)
250
251void
252lsi64854_reset(struct lsi64854_softc *sc)
253{
238 /* \
239 * DMA rev0 & rev1: we are not allowed to touch the DMA "flush" \
240 * and "drain" bits while it is still thinking about a \
241 * request. \
242 * other revs: D_ESC_R_PEND bit reads as 0 \
243 */ \
244 DMAWAIT(sc, L64854_GCSR(sc) & D_ESC_R_PEND, "R_PEND", dontpanic);\
245 csr = L64854_GCSR(sc); \
246 csr &= ~(L64854_WRITE|L64854_EN_DMA); /* no-ops on ENET */ \
247 csr |= L64854_INVALIDATE; /* XXX FAS ? */ \
248 L64854_SCSR(sc,csr); \
249} while(0)
250
251void
252lsi64854_reset(struct lsi64854_softc *sc)
253{
254 u_int32_t csr;
254 uint32_t csr;
255
256 DMA_FLUSH(sc, 1);
257 csr = L64854_GCSR(sc);
258
259 DPRINTF(LDB_ANY, ("lsi64854_reset: csr 0x%x\n", csr));
260
261 /*
262 * XXX is sync needed?

--- 78 unchanged lines hidden (view full) ---

341#define DMAMAX(a) (MAX_DMA_SZ - ((a) & (MAX_DMA_SZ-1)))
342/*
343 * setup a DMA transfer
344 */
345int
346lsi64854_setup(struct lsi64854_softc *sc, caddr_t *addr, size_t *len,
347 int datain, size_t *dmasize)
348{
255
256 DMA_FLUSH(sc, 1);
257 csr = L64854_GCSR(sc);
258
259 DPRINTF(LDB_ANY, ("lsi64854_reset: csr 0x%x\n", csr));
260
261 /*
262 * XXX is sync needed?

--- 78 unchanged lines hidden (view full) ---

341#define DMAMAX(a) (MAX_DMA_SZ - ((a) & (MAX_DMA_SZ-1)))
342/*
343 * setup a DMA transfer
344 */
345int
346lsi64854_setup(struct lsi64854_softc *sc, caddr_t *addr, size_t *len,
347 int datain, size_t *dmasize)
348{
349 u_int32_t csr;
349 uint32_t csr;
350
351 DMA_FLUSH(sc, 0);
352
353#if 0
354 DMACSR(sc) &= ~D_INT_EN;
355#endif
356 sc->sc_dmaaddr = addr;
357 sc->sc_dmalen = len;
358 sc->sc_datain = datain;
359
360 /*
350
351 DMA_FLUSH(sc, 0);
352
353#if 0
354 DMACSR(sc) &= ~D_INT_EN;
355#endif
356 sc->sc_dmaaddr = addr;
357 sc->sc_dmalen = len;
358 sc->sc_datain = datain;
359
360 /*
361 * the rules say we cannot transfer more than the limit
361 * The rules say we cannot transfer more than the limit
362 * of this DMA chip (64k for old and 16Mb for new),
363 * and we cannot cross a 16Mb boundary.
364 */
365 *dmasize = sc->sc_dmasize =
366 min(*dmasize, DMAMAX((size_t) *sc->sc_dmaaddr));
367
368 DPRINTF(LDB_ANY, ("dma_setup: dmasize = %ld\n", (long)sc->sc_dmasize));
369

--- 52 unchanged lines hidden (view full) ---

422 * return 1 if it was a DMA continue.
423 */
424int
425lsi64854_scsi_intr(void *arg)
426{
427 struct lsi64854_softc *sc = arg;
428 struct ncr53c9x_softc *nsc = sc->sc_client;
429 int trans, resid;
362 * of this DMA chip (64k for old and 16Mb for new),
363 * and we cannot cross a 16Mb boundary.
364 */
365 *dmasize = sc->sc_dmasize =
366 min(*dmasize, DMAMAX((size_t) *sc->sc_dmaaddr));
367
368 DPRINTF(LDB_ANY, ("dma_setup: dmasize = %ld\n", (long)sc->sc_dmasize));
369

--- 52 unchanged lines hidden (view full) ---

422 * return 1 if it was a DMA continue.
423 */
424int
425lsi64854_scsi_intr(void *arg)
426{
427 struct lsi64854_softc *sc = arg;
428 struct ncr53c9x_softc *nsc = sc->sc_client;
429 int trans, resid;
430 u_int32_t csr;
430 uint32_t csr;
431
432 csr = L64854_GCSR(sc);
433
434 DPRINTF(LDB_SCSI, ("%s: dmaintr: addr 0x%x, csr %b\n", sc->dv_name,
435 bus_space_read_4(sc->sc_regt, sc->sc_regh, L64854_REG_ADDR),
436 csr, DDMACSR_BITS));
437
438 if (csr & (D_ERR_PEND|D_SLAVE_ERR)) {

--- 106 unchanged lines hidden (view full) ---

545
546/*
547 * Pseudo (chained) interrupt to le driver to handle DMA errors.
548 */
549int
550lsi64854_enet_intr(void *arg)
551{
552 struct lsi64854_softc *sc = arg;
431
432 csr = L64854_GCSR(sc);
433
434 DPRINTF(LDB_SCSI, ("%s: dmaintr: addr 0x%x, csr %b\n", sc->dv_name,
435 bus_space_read_4(sc->sc_regt, sc->sc_regh, L64854_REG_ADDR),
436 csr, DDMACSR_BITS));
437
438 if (csr & (D_ERR_PEND|D_SLAVE_ERR)) {

--- 106 unchanged lines hidden (view full) ---

545
546/*
547 * Pseudo (chained) interrupt to le driver to handle DMA errors.
548 */
549int
550lsi64854_enet_intr(void *arg)
551{
552 struct lsi64854_softc *sc = arg;
553 u_int32_t csr;
553 uint32_t csr;
554 static int dodrain = 0;
555 int rv;
556
557 csr = L64854_GCSR(sc);
558
559 /* If the DMA logic shows an interrupt, claim it */
560 rv = ((csr & E_INT_PEND) != 0) ? 1 : 0;
561

--- 41 unchanged lines hidden (view full) ---

603
604/*
605 * setup a DMA transfer
606 */
607int
608lsi64854_setup_pp(struct lsi64854_softc *sc, caddr_t *addr, size_t *len,
609 int datain, size_t *dmasize)
610{
554 static int dodrain = 0;
555 int rv;
556
557 csr = L64854_GCSR(sc);
558
559 /* If the DMA logic shows an interrupt, claim it */
560 rv = ((csr & E_INT_PEND) != 0) ? 1 : 0;
561

--- 41 unchanged lines hidden (view full) ---

603
604/*
605 * setup a DMA transfer
606 */
607int
608lsi64854_setup_pp(struct lsi64854_softc *sc, caddr_t *addr, size_t *len,
609 int datain, size_t *dmasize)
610{
611 u_int32_t csr;
611 uint32_t csr;
612
613 DMA_FLUSH(sc, 0);
614
615 sc->sc_dmaaddr = addr;
616 sc->sc_dmalen = len;
617 sc->sc_datain = datain;
618
619 DPRINTF(LDB_PP, ("%s: pp start %ld@%p,%d\n", sc->dv_name,

--- 43 unchanged lines hidden (view full) ---

663/*
664 * Parallel port DMA interrupt.
665 */
666int
667lsi64854_pp_intr(void *arg)
668{
669 struct lsi64854_softc *sc = arg;
670 int ret, trans, resid = 0;
612
613 DMA_FLUSH(sc, 0);
614
615 sc->sc_dmaaddr = addr;
616 sc->sc_dmalen = len;
617 sc->sc_datain = datain;
618
619 DPRINTF(LDB_PP, ("%s: pp start %ld@%p,%d\n", sc->dv_name,

--- 43 unchanged lines hidden (view full) ---

663/*
664 * Parallel port DMA interrupt.
665 */
666int
667lsi64854_pp_intr(void *arg)
668{
669 struct lsi64854_softc *sc = arg;
670 int ret, trans, resid = 0;
671 u_int32_t csr;
671 uint32_t csr;
672
673 csr = L64854_GCSR(sc);
674
675 DPRINTF(LDB_PP, ("%s: pp intr: addr 0x%x, csr %b\n", sc->dv_name,
676 bus_space_read_4(sc->sc_regt, sc->sc_regh, L64854_REG_ADDR),
677 csr, PDMACSR_BITS));
678
679 if (csr & (P_ERR_PEND|P_SLAVE_ERR)) {

--- 43 unchanged lines hidden ---
672
673 csr = L64854_GCSR(sc);
674
675 DPRINTF(LDB_PP, ("%s: pp intr: addr 0x%x, csr %b\n", sc->dv_name,
676 bus_space_read_4(sc->sc_regt, sc->sc_regh, L64854_REG_ADDR),
677 csr, PDMACSR_BITS));
678
679 if (csr & (P_ERR_PEND|P_SLAVE_ERR)) {

--- 43 unchanged lines hidden ---