From 0ea59754f1ca9d5ce828e506b83f9a3341d5e2cd Mon Sep 17 00:00:00 2001 From: thorpej Date: Wed, 7 Nov 2001 02:24:18 +0000 Subject: [PATCH] We were already cheating w/ CPLD register access, so cheat all the way and use pointer derefs rather than bus_space to access them. --- sys/arch/evbarm/iq80310/iq80310_7seg.c | 6 +++--- sys/arch/evbarm/iq80310/iq80310_intr.c | 10 ++++----- sys/arch/evbarm/iq80310/iq80310_timer.c | 28 +++++++++++-------------- sys/arch/evbarm/iq80310/iq80310reg.h | 9 +++++++- sys/arch/evbarm/iq80310/obio.c | 8 +++---- 5 files changed, 31 insertions(+), 30 deletions(-) diff --git a/sys/arch/evbarm/iq80310/iq80310_7seg.c b/sys/arch/evbarm/iq80310/iq80310_7seg.c index aec493195bb1..7b14b61eb36a 100644 --- a/sys/arch/evbarm/iq80310/iq80310_7seg.c +++ b/sys/arch/evbarm/iq80310/iq80310_7seg.c @@ -1,4 +1,4 @@ -/* $NetBSD: iq80310_7seg.c,v 1.1 2001/11/07 00:33:23 thorpej Exp $ */ +/* $NetBSD: iq80310_7seg.c,v 1.2 2001/11/07 02:24:18 thorpej Exp $ */ /* * Copyright (c) 2001 Wasabi Systems, Inc. @@ -187,6 +187,6 @@ iq80310_7seg(char a, char b) else lsb = asciimap[b - ASCIIMAP_START] | SEG_DP; - bus_space_write_1(&obio_bs_tag, IQ80310_7SEG_MSB, 0, msb); - bus_space_write_1(&obio_bs_tag, IQ80310_7SEG_LSB, 0, lsb); + CPLD_WRITE(IQ80310_7SEG_MSB, msb); + CPLD_WRITE(IQ80310_7SEG_LSB, lsb); } diff --git a/sys/arch/evbarm/iq80310/iq80310_intr.c b/sys/arch/evbarm/iq80310/iq80310_intr.c index 7bdb3fc86fba..4e6429764e49 100644 --- a/sys/arch/evbarm/iq80310/iq80310_intr.c +++ b/sys/arch/evbarm/iq80310/iq80310_intr.c @@ -1,4 +1,4 @@ -/* $NetBSD: iq80310_intr.c,v 1.2 2001/11/07 02:06:37 thorpej Exp $ */ +/* $NetBSD: iq80310_intr.c,v 1.3 2001/11/07 02:24:18 thorpej Exp $ */ /* * Copyright (c) 2001 Wasabi Systems, Inc. @@ -115,11 +115,9 @@ iq80310_intstat_read(void) { uint32_t intstat; - intstat = bus_space_read_1(&obio_bs_tag, IQ80310_XINT3_STATUS, - 0) & 0x1f; + intstat = CPLD_READ(IQ80310_XINT3_STATUS) & 0x1f; if (1/*rev F or later board*/) - intstat |= (bus_space_read_1(&obio_bs_tag, - IQ80310_XINT0_STATUS, 0) & 0x7) << 5; + intstat |= (CPLD_READ(IQ80310_XINT0_STATUS) & 0x7) << 5; return (intstat); } @@ -141,7 +139,7 @@ irq_setmasks_nointr(void) if (disabled >> 5) disabled |= XINT3_SINTD; - bus_space_write_1(&obio_bs_tag, IQ80310_XINT_MASK, 0, disabled & 0x1f); + CPLD_WRITE(IQ80310_XINT_MASK, disabled & 0x1f); } void diff --git a/sys/arch/evbarm/iq80310/iq80310_timer.c b/sys/arch/evbarm/iq80310/iq80310_timer.c index 93091e5d1227..a54bc06f0786 100644 --- a/sys/arch/evbarm/iq80310/iq80310_timer.c +++ b/sys/arch/evbarm/iq80310/iq80310_timer.c @@ -1,4 +1,4 @@ -/* $NetBSD: iq80310_timer.c,v 1.1 2001/11/07 00:33:24 thorpej Exp $ */ +/* $NetBSD: iq80310_timer.c,v 1.2 2001/11/07 02:24:18 thorpej Exp $ */ /* * Copyright (c) 2001 Wasabi Systems, Inc. @@ -71,16 +71,16 @@ static __inline void timer_enable(uint8_t bit) { - bus_space_write_1(&obio_bs_tag, IQ80310_TIMER_ENABLE, 0, - bus_space_read_1(&obio_bs_tag, IQ80310_TIMER_ENABLE, 0) | bit); + CPLD_WRITE(IQ80310_TIMER_ENABLE, + CPLD_READ(IQ80310_TIMER_ENABLE) | bit); } static __inline void timer_disable(uint8_t bit) { - bus_space_write_1(&obio_bs_tag, IQ80310_TIMER_ENABLE, 0, - bus_space_read_1(&obio_bs_tag, IQ80310_TIMER_ENABLE, 0) & ~bit); + CPLD_WRITE(IQ80310_TIMER_ENABLE, + CPLD_READ(IQ80310_TIMER_ENABLE) & ~bit); } static __inline uint32_t @@ -95,12 +95,11 @@ timer_read(void) * latched. The loop appears to work around the problem. */ do { - la[0] = - bus_space_read_1(&obio_bs_tag, IQ80310_TIMER_LA0, 0) & 0x5f; + la[0] = CPLD_READ(IQ80310_TIMER_LA0) & 0x5f; } while (la[0] == 0); - la[1] = bus_space_read_1(&obio_bs_tag, IQ80310_TIMER_LA1, 0) & 0x5f; - la[2] = bus_space_read_1(&obio_bs_tag, IQ80310_TIMER_LA2, 0) & 0x5f; - la[3] = bus_space_read_1(&obio_bs_tag, IQ80310_TIMER_LA3, 0) & 0x0f; + la[1] = CPLD_READ(IQ80310_TIMER_LA1) & 0x5f; + la[2] = CPLD_READ(IQ80310_TIMER_LA2) & 0x5f; + la[3] = CPLD_READ(IQ80310_TIMER_LA3) & 0x0f; #define SWIZZLE(x) \ x = (((x) & 0x40) >> 1) | ((x) | 0x1f) @@ -118,12 +117,9 @@ static __inline void timer_write(uint32_t x) { - bus_space_write_1(&obio_bs_tag, IQ80310_TIMER_LA0, 0, - x & 0xff); - bus_space_write_1(&obio_bs_tag, IQ80310_TIMER_LA1, 0, - (x >> 8) & 0xff); - bus_space_write_1(&obio_bs_tag, IQ80310_TIMER_LA2, 0, - (x >> 16) & 0x3f); + CPLD_WRITE(IQ80310_TIMER_LA0, x & 0xff); + CPLD_WRITE(IQ80310_TIMER_LA1, (x >> 8) & 0xff); + CPLD_WRITE(IQ80310_TIMER_LA2, (x >> 16) & 0x3f); } /* diff --git a/sys/arch/evbarm/iq80310/iq80310reg.h b/sys/arch/evbarm/iq80310/iq80310reg.h index a9651291c621..4b0f8e19afe9 100644 --- a/sys/arch/evbarm/iq80310/iq80310reg.h +++ b/sys/arch/evbarm/iq80310/iq80310reg.h @@ -1,4 +1,4 @@ -/* $NetBSD: iq80310reg.h,v 1.1 2001/11/07 00:33:24 thorpej Exp $ */ +/* $NetBSD: iq80310reg.h,v 1.2 2001/11/07 02:24:18 thorpej Exp $ */ /* * Copyright (c) 2001 Wasabi Systems, Inc. @@ -72,6 +72,13 @@ * 0000 0000 ------------------------------ */ +/* + * We map the CPLD registers VA==PA, so we go ahead and cheat + * with register access. + */ +#define CPLD_READ(x) *((__volatile uint8_t *)(x)) +#define CPLD_WRITE(x, v) *((__volatile uint8_t *)(x)) = (v) + #define IQ80310_OBIO_BASE 0xfe800000UL #define IQ80310_OBIO_SIZE 0x00100000UL diff --git a/sys/arch/evbarm/iq80310/obio.c b/sys/arch/evbarm/iq80310/obio.c index abb528fa14f4..30b3e7c09edc 100644 --- a/sys/arch/evbarm/iq80310/obio.c +++ b/sys/arch/evbarm/iq80310/obio.c @@ -1,4 +1,4 @@ -/* $NetBSD: obio.c,v 1.1 2001/11/07 00:33:25 thorpej Exp $ */ +/* $NetBSD: obio.c,v 1.2 2001/11/07 02:24:18 thorpej Exp $ */ /* * Copyright (c) 2001 Wasabi Systems, Inc. @@ -114,9 +114,9 @@ obio_attach(struct device *parent, struct device *self, void *aux) * Yes, we're using knowledge of the obio bus space internals, * here. */ - board_rev = bus_space_read_1(&obio_bs_tag, IQ80310_BOARD_REV, 0); - cpld_rev = bus_space_read_1(&obio_bs_tag, IQ80310_CPLD_REV, 0); - backplane = bus_space_read_1(&obio_bs_tag, IQ80310_BACKPLANE_DET, 0); + board_rev = CPLD_READ(IQ80310_BOARD_REV); + cpld_rev = CPLD_READ(IQ80310_CPLD_REV); + backplane = CPLD_READ(IQ80310_BACKPLANE_DET); printf(": board rev. %c, CPLD rev. %c, backplane %spresent\n", BOARD_REV(board_rev), CPLD_REV(cpld_rev),