--- sys/arch/arm/xscale/pxa2x0_clock.c | 72 ++++++++++++++---------------------- 1 files changed, 28 insertions(+), 44 deletions(-)
diff --git a/sys/arch/arm/xscale/pxa2x0_clock.c b/sys/arch/arm/xscale/pxa2x0_clock.c index 7644c0c..b781edf 100644 --- a/sys/arch/arm/xscale/pxa2x0_clock.c +++ b/sys/arch/arm/xscale/pxa2x0_clock.c @@ -95,7 +95,7 @@ pxaost_attach(parent, self, aux) printf("\n"); - sc->sc_clock_hz = 32768; /* OS Timer 4-11 uses 32768Hz clock */ + sc->sc_clock_hz = 3250000; /* OS Timer 0 uses 3.25MHz clock */ sc->sc_iot = sa->sa_iot; @@ -109,16 +109,13 @@ pxaost_attach(parent, self, aux) bus_space_write_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh, SAOST_IR, 0); bus_space_write_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh, SAOST_SR, 0x3f); - bus_space_write_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh, OST_OMCR4, 0xc1); - bus_space_write_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh, OST_OMCR5, 0x41); - - bus_space_write_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh, OST_OSMR4, + bus_space_write_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh, OST_OSMR0, pxaost_sc->sc_clock_count); - bus_space_write_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh, OST_OSMR5, + bus_space_write_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh, OST_OSMR1, pxaost_sc->sc_statclock_count); /* Zero the counter value */ - bus_space_write_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh, OST_OSCR4, 0); + bus_space_write_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh, OST_OSCR0, 0); } @@ -126,7 +123,7 @@ u_int pxaost_get_timecount(struct timecounter *tc) { return bus_space_read_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh, - OST_OSCR4); + OST_OSCR0); } int @@ -137,7 +134,7 @@ clockintr(arg) u_int32_t oscr, match; u_int32_t match_error; - bus_space_write_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh, SAOST_SR, 0x10); + bus_space_write_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh, SAOST_SR, 0x01); match = pxaost_sc->sc_clock_count; @@ -154,15 +151,15 @@ clockintr(arg) hardclock(frame); oscr = bus_space_read_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh, - OST_OSCR4); + OST_OSCR0); } while ((signed)(oscr - match) > 0); /* prevent missed interrupts */ - if (oscr - match < 5) - match += 5; + if (oscr - match < 50) + match += 50; - bus_space_write_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh, OST_OSMR4, + bus_space_write_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh, OST_OSMR0, match); return(1); @@ -173,9 +170,9 @@ statintr(arg) void *arg; { struct clockframe *frame = arg; - u_int32_t oscr, match; + u_int32_t oscr, match = 0; - bus_space_write_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh, SAOST_SR, 0x20); + bus_space_write_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh, SAOST_SR, 0x02); /* schedule next clock intr */ match = pxaost_sc->sc_statclock_count; @@ -185,14 +182,15 @@ statintr(arg) statclock(frame); oscr = bus_space_read_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh, - OST_OSCR4); + OST_OSCR0); } while ((signed)(oscr - match) > 0); /* prevent missed interrupts */ - if (oscr - match < 5) - match += 5; - bus_space_write_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh, OST_OSMR5, + if (oscr - match < 50) + match += 50; + + bus_space_write_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh, OST_OSMR1, match); return(1); @@ -203,26 +201,11 @@ setstatclockrate(int newstathz) { u_int32_t count; pxaost_sc->sc_statclock_step = pxaost_sc->sc_clock_hz / newstathz; - count = bus_space_read_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh, OST_OSCR4); - count += pxaost_sc->sc_statclock_step; + count = pxaost_sc->sc_statclock_step; + count += bus_space_read_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh, OST_OSCR0); pxaost_sc->sc_statclock_count = count; bus_space_write_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh, - OST_OSMR5, count); -} - -int -doclockintr(void *arg) -{ - u_int32_t status; - int result = 0; - - status = bus_space_read_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh, SAOST_SR); - if (status & 0x10) - result |= clockintr(arg); - if (status & 0x20) - result |= statintr(arg); - - return (result); + OST_OSMR1, count); } void @@ -241,15 +224,16 @@ cpu_initclocks() pxaost_sc->sc_clock_count = pxaost_sc->sc_clock_step; pxaost_sc->sc_statclock_count = pxaost_sc->sc_clock_hz / stathz; - pxa2x0_intr_establish(PXA2X0_INT_OST, IPL_CLOCK, doclockintr, 0, "clock"); + pxa2x0_intr_establish(PXA2X0_INT_OST0, IPL_CLOCK, clockintr, 0, "clock"); + pxa2x0_intr_establish(PXA2X0_INT_OST1, IPL_CLOCK, statintr, 0, "statclock"); - clk = bus_space_read_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh, OST_OSCR4); + clk = bus_space_read_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh, OST_OSCR0); bus_space_write_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh, SAOST_SR, 0x3f); - bus_space_write_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh, SAOST_IR, 0x30); - bus_space_write_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh, OST_OSMR4, + bus_space_write_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh, SAOST_IR, 0x03); + bus_space_write_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh, OST_OSMR0, clk + pxaost_sc->sc_clock_count); - bus_space_write_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh, OST_OSMR5, + bus_space_write_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh, OST_OSMR1, clk + pxaost_sc->sc_statclock_count); pxaost_timecounter.tc_frequency = pxaost_sc->sc_clock_hz; @@ -287,13 +271,13 @@ delay(usecs) } oclock = bus_space_read_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh, - OST_OSCR4); + OST_OSCR0); while (1) { for (j = 100; j > 0; j--) ; clock = bus_space_read_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh, - OST_OSCR4); + OST_OSCR0); delta = clock - oclock; if (delta > delaycnt) break; -- 1.7.0.5