diff --git a/sys/arch/arm/xscale/files.ixp425 b/sys/arch/arm/xscale/files.ixp425 index 5aa350358543..ad43fad3dc4c 100644 --- a/sys/arch/arm/xscale/files.ixp425 +++ b/sys/arch/arm/xscale/files.ixp425 @@ -1,4 +1,4 @@ -# $NetBSD: files.ixp425,v 1.4 2003/10/08 14:55:04 scw Exp $ +# $NetBSD: files.ixp425,v 1.5 2003/11/16 12:41:03 scw Exp $ # # Configuration info for Intel IXP4xx CPU support # @@ -11,7 +11,6 @@ file arch/arm/xscale/xscale_pmc.c perfctrs # IXP425 Slow peripheral devices device ixpsip { [addr=-1], [size=0], [index=-1], [intr=-1] }: bus_space_generic file arch/arm/xscale/ixp425_sip.c ixpsip -file arch/arm/xscale/ixp425_sip_io.c ixpsip # IXP425 Processor CPU support # IXP425 PCI bus diff --git a/sys/arch/arm/xscale/ixp425_sip.c b/sys/arch/arm/xscale/ixp425_sip.c index 7faa27f096ab..ed5fc776ba41 100644 --- a/sys/arch/arm/xscale/ixp425_sip.c +++ b/sys/arch/arm/xscale/ixp425_sip.c @@ -1,4 +1,4 @@ -/* $NetBSD: ixp425_sip.c,v 1.5 2003/11/02 21:24:39 scw Exp $ */ +/* $NetBSD: ixp425_sip.c,v 1.6 2003/11/16 12:41:03 scw Exp $ */ /* * Copyright (c) 2003 @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ixp425_sip.c,v 1.5 2003/11/02 21:24:39 scw Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ixp425_sip.c,v 1.6 2003/11/16 12:41:03 scw Exp $"); /* * Slow peripheral bus of IXP425 Processor @@ -60,7 +60,6 @@ static int ixpsip_print(void *, const char *); CFATTACH_DECL(ixpsip, sizeof(struct ixpsip_softc), ixpsip_match, ixpsip_attach, NULL, NULL); -extern struct bus_space ixpsip_bs_tag; struct ixpsip_softc *ixpsip_softc; int @@ -73,7 +72,7 @@ void ixpsip_attach(struct device *parent, struct device *self, void *aux) { struct ixpsip_softc *sc = (void *) self; - sc->sc_iot = &ixpsip_bs_tag; + sc->sc_iot = &ixp425_bs_tag; ixpsip_softc = sc; @@ -86,11 +85,6 @@ ixpsip_attach(struct device *parent, struct device *self, void *aux) return; } - /* - * Bootstrap the timer (needed for delay(9)) - */ - ixp425_clk_bootstrap(sc->sc_iot); - /* * Attach each devices */ diff --git a/sys/arch/arm/xscale/ixp425_sip_io.c b/sys/arch/arm/xscale/ixp425_sip_io.c deleted file mode 100644 index 62a6108dc531..000000000000 --- a/sys/arch/arm/xscale/ixp425_sip_io.c +++ /dev/null @@ -1,213 +0,0 @@ -/* $NetBSD: ixp425_sip_io.c,v 1.3 2003/11/02 21:20:32 scw Exp $ */ - -/* - * Copyright (c) 2003 - * Ichiro FUKUHARA . - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Ichiro FUKUHARA. - * 4. The name of the company nor the name of the author may be used to - * endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY ICHIRO FUKUHARA ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL ICHIRO FUKUHARA OR THE VOICES IN HIS HEAD BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -__KERNEL_RCSID(0, "$NetBSD: ixp425_sip_io.c,v 1.3 2003/11/02 21:20:32 scw Exp $"); - -/* - * bus_space I/O functions for ixp425 - */ - -#include -#include -#include - -#include - -#include - -/* Proto types for all the bus_space structure functions */ -bs_protos(ixpsip); -bs_protos(generic); -bs_protos(generic_armv4); -bs_protos(bs_notimpl); - -struct bus_space ixpsip_bs_tag = { - /* cookie */ - (void *) 0, - - /* mapping/unmapping */ - ixpsip_bs_map, - ixpsip_bs_unmap, - ixpsip_bs_subregion, - - /* allocation/deallocation */ - ixpsip_bs_alloc, - ixpsip_bs_free, - - /* get kernel virtual address */ - ixpsip_bs_vaddr, - - /* mmap bus space for userland */ - bs_notimpl_bs_mmap, - - /* barrier */ - ixpsip_bs_barrier, - - /* read (single) */ - generic_bs_r_1, - generic_armv4_bs_r_2, - generic_bs_r_4, - bs_notimpl_bs_r_8, - - /* read multiple */ - generic_bs_rm_1, - generic_armv4_bs_rm_2, - generic_bs_rm_4, - bs_notimpl_bs_rm_8, - - /* read region */ - generic_bs_rr_1, - generic_armv4_bs_rr_2, - generic_bs_rr_4, - bs_notimpl_bs_rr_8, - - /* write (single) */ - generic_bs_w_1, - generic_armv4_bs_w_2, - generic_bs_w_4, - bs_notimpl_bs_w_8, - - /* write multiple */ - generic_bs_wm_1, - generic_armv4_bs_wm_2, - generic_bs_wm_4, - bs_notimpl_bs_wm_8, - - /* write region */ - generic_bs_wr_1, - generic_armv4_bs_wr_2, - generic_bs_wr_4, - bs_notimpl_bs_wr_8, - - /* set multiple */ - bs_notimpl_bs_sm_1, - bs_notimpl_bs_sm_2, - bs_notimpl_bs_sm_4, - bs_notimpl_bs_sm_8, - - /* set region */ - bs_notimpl_bs_sr_1, - generic_armv4_bs_sr_2, - generic_bs_sr_4, - bs_notimpl_bs_sr_8, - - /* copy */ - bs_notimpl_bs_c_1, - generic_armv4_bs_c_2, - bs_notimpl_bs_c_4, - bs_notimpl_bs_c_8, -}; - -/* bus space functions */ - -int -ixpsip_bs_map(void *t, bus_addr_t bpa, bus_size_t size, int cacheable, - bus_space_handle_t *bshp) -{ - uint32_t startpa, endpa, pa; - vaddr_t va; - pt_entry_t *pte; - - if (bpa > IXP425_IO_VBASE) { - /* XXX This is a temporary hack to aid transition. */ - *bshp = bpa; - return(0); - } - - startpa = trunc_page(bpa); - endpa = round_page(bpa + size); - - /* XXX use some extent to check for duplicate mappings? */ - - va = uvm_km_valloc(kernel_map, endpa - startpa); - if (! va) - return ENOMEM; - - *bshp = (bus_space_handle_t) (va + (bpa - startpa)); - - for (pa=startpa; pa < endpa; pa += PAGE_SIZE, va += PAGE_SIZE) { - pmap_kenter_pa(va, pa, VM_PROT_READ | VM_PROT_WRITE); - pte = vtopte(va); - *pte &= ~L2_S_CACHE_MASK; - PTE_SYNC(pte); - } - pmap_update(pmap_kernel()); - return(0); -} - -void -ixpsip_bs_unmap(void *t, bus_space_handle_t bsh, bus_size_t size) -{ - /* Nothing to do. */ -} - -int -ixpsip_bs_alloc(void *t, bus_addr_t rstart, bus_addr_t rend, - bus_size_t size, bus_size_t alignment, bus_size_t boundary, int cacheable, - bus_addr_t *bpap, bus_space_handle_t *bshp) -{ - panic("ixpsip_bs_alloc(): Help!"); -} - -void -ixpsip_bs_free(void *t, bus_space_handle_t bsh, bus_size_t size) -{ - panic("ixpsip_bs_free(): Help!"); -} - -int -ixpsip_bs_subregion(void *t, bus_space_handle_t bsh, bus_size_t offset, - bus_size_t size, bus_space_handle_t *nbshp) -{ - - *nbshp = bsh + offset; - return (0); -} - -void * -ixpsip_bs_vaddr(void *t, bus_space_handle_t bsh) -{ - return ((void *)bsh); -} - -void -ixpsip_bs_barrier(void *t, bus_space_handle_t bsh, bus_size_t offset, - bus_size_t len, int flags) -{ - /* Nothing to do. */ -} - -/* End of ixpsip_io.c */ diff --git a/sys/arch/arm/xscale/ixp425_space.c b/sys/arch/arm/xscale/ixp425_space.c index f021c08c3a0e..36a1e32ef7d3 100644 --- a/sys/arch/arm/xscale/ixp425_space.c +++ b/sys/arch/arm/xscale/ixp425_space.c @@ -1,4 +1,4 @@ -/* $NetBSD: ixp425_space.c,v 1.2 2003/10/23 09:25:44 scw Exp $ */ +/* $NetBSD: ixp425_space.c,v 1.3 2003/11/16 12:41:03 scw Exp $ */ /* * Copyright (c) 2003 @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ixp425_space.c,v 1.2 2003/10/23 09:25:44 scw Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ixp425_space.c,v 1.3 2003/11/16 12:41:03 scw Exp $"); /* * bus_space I/O functions for ixp425 @@ -92,7 +92,7 @@ struct bus_space ixp425_bs_tag = { bs_notimpl_bs_rm_8, /* read region */ - bs_notimpl_bs_rr_1, + generic_bs_rr_1, generic_armv4_bs_rr_2, generic_bs_rr_4, bs_notimpl_bs_rr_8, @@ -110,7 +110,7 @@ struct bus_space ixp425_bs_tag = { bs_notimpl_bs_wm_8, /* write region */ - bs_notimpl_bs_wr_1, + generic_bs_wr_1, generic_armv4_bs_wr_2, generic_bs_wr_4, bs_notimpl_bs_wr_8, diff --git a/sys/arch/arm/xscale/ixp425_timer.c b/sys/arch/arm/xscale/ixp425_timer.c index c59229398547..bf3f166c0ead 100644 --- a/sys/arch/arm/xscale/ixp425_timer.c +++ b/sys/arch/arm/xscale/ixp425_timer.c @@ -1,4 +1,4 @@ -/* $NetBSD: ixp425_timer.c,v 1.4 2003/10/08 14:55:04 scw Exp $ */ +/* $NetBSD: ixp425_timer.c,v 1.5 2003/11/16 12:41:03 scw Exp $ */ /* * Copyright (c) 2003 @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ixp425_timer.c,v 1.4 2003/10/08 14:55:04 scw Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ixp425_timer.c,v 1.5 2003/11/16 12:41:03 scw Exp $"); #include "opt_perfctrs.h" @@ -77,7 +77,6 @@ struct ixpclk_softc { #define COUNTS_PER_USEC ((COUNTS_PER_SEC / 1000000) + 1) static struct ixpclk_softc *ixpclk_sc; -static int ixpclk_first_timer; CFATTACH_DECL(ixpclk, sizeof(struct ixpclk_softc), ixpclk_match, ixpclk_attach, NULL, NULL); @@ -86,6 +85,9 @@ CFATTACH_DECL(ixpclk, sizeof(struct ixpclk_softc), (sc)->sc_ioh, \ IXP425_OST_TIM0)) +#define GET_TS_VALUE(sc) (*(volatile u_int32_t *) \ + (IXP425_TIMER_VBASE + IXP425_OST_TS)) + static int ixpclk_match(struct device *parent, struct cfdata *match, void *aux) { @@ -100,32 +102,16 @@ ixpclk_attach(struct device *parent, struct device *self, void *aux) printf("\n"); + ixpclk_sc = sc; + sc->sc_iot = sa->sa_iot; sc->sc_baseaddr = sa->sa_addr; - /* using first timer for system ticks */ - if (!ixpclk_first_timer) { - ixpclk_first_timer = 1; - ixpclk_sc = sc; - } if (bus_space_map(sc->sc_iot, sa->sa_addr, sa->sa_size, 0, &sc->sc_ioh)) panic("%s: Cannot map registers", self->dv_xname); - aprint_normal("%s: IXP425 Interval Timer\n", sc->sc_dev.dv_xname); -} - -void -ixp425_clk_bootstrap(bus_space_tag_t bt) -{ - static struct ixpclk_softc sc; - ixpclk_sc = ≻ - - sc.sc_iot = bt; - sc.sc_baseaddr = IXP425_TIMER_HWBASE; - - if (bus_space_map(sc.sc_iot, sc.sc_baseaddr, 0x30, 0, &sc.sc_ioh)) - panic("ixp425_clk_bootstrap: Cannot map registers"); + aprint_normal("%s: IXP425 Interval Timer\n", sc->sc_dev.dv_xname); } /* @@ -272,31 +258,30 @@ microtime(struct timeval *tvp) void delay(u_int n) { - struct ixpclk_softc* sc = ixpclk_sc; - uint32_t cur, last, delta, usecs; + u_int32_t first, last; + int usecs; + + if (n == 0) + return; /* - * This works by polling the timer and counting the - * number of microseconds that go by. + * Clamp the timeout at a maximum value (about 32 seconds with + * a 66MHz clock). *Nobody* should be delay()ing for anywhere + * near that length of time and if they are, they should be hung + * out to dry. */ - last = GET_TIMER_VALUE(sc); - delta = usecs = 0; + if (n >= (0x80000000U / COUNTS_PER_USEC)) + usecs = (0x80000000U / COUNTS_PER_USEC) - 1; + else + usecs = n * COUNTS_PER_USEC; - while (n > usecs) { - cur = GET_TIMER_VALUE(sc); + /* Note: Timestamp timer counts *up*, unlike the other timers */ + first = GET_TS_VALUE(); - /* Check to see if the timer has wrapped around. */ - if (last < cur) - delta += (last + (counts_per_hz - cur)); - else - delta += (last - cur); - - last = cur; - - if (delta >= COUNTS_PER_USEC) { - usecs += delta / COUNTS_PER_USEC; - delta %= COUNTS_PER_USEC; - } + while (usecs > 0) { + last = GET_TS_VALUE(); + usecs -= (int)(last - first); + first = last; } } diff --git a/sys/arch/arm/xscale/ixp425reg.h b/sys/arch/arm/xscale/ixp425reg.h index 245be0265888..3a0075626a10 100644 --- a/sys/arch/arm/xscale/ixp425reg.h +++ b/sys/arch/arm/xscale/ixp425reg.h @@ -1,4 +1,4 @@ -/* $NetBSD: ixp425reg.h,v 1.13 2003/10/23 09:29:36 scw Exp $ */ +/* $NetBSD: ixp425reg.h,v 1.14 2003/11/16 12:41:03 scw Exp $ */ /* * Copyright (c) 2003 * Ichiro FUKUHARA . @@ -130,7 +130,9 @@ * */ #define IXP425_TIMER_HWBASE (IXP425_IO_HWBASE + IXP425_TIMER_OFFSET) +#define IXP425_TIMER_VBASE (IXP425_IO_VBASE + IXP425_TIMER_OFFSET) +#define IXP425_OST_TS 0x0000 #define IXP425_OST_TIM0 0x0004 #define IXP425_OST_TIM1 0x000C