From 9dee7f7fac3bcb758b6911b4d43db57896f6dc83 Mon Sep 17 00:00:00 2001 From: Martin Pieuchot Date: Wed, 9 Oct 2013 17:43:51 +0000 Subject: Initialize ns_per_tick as soon as we have read the timebase from the device-tree to restore the behaviour present before my last change. This fixes a regression seen on some Powerbooks where one of the two kiic(4) would always timeout when trying to configure the audio chip. --- sys/arch/macppc/include/cpu.h | 3 ++- sys/arch/macppc/macppc/clock.c | 5 ++--- sys/arch/macppc/macppc/cpu.c | 7 +++++-- 3 files changed, 9 insertions(+), 6 deletions(-) (limited to 'sys') diff --git a/sys/arch/macppc/include/cpu.h b/sys/arch/macppc/include/cpu.h index 586d91678f6..3e64b2bcccf 100644 --- a/sys/arch/macppc/include/cpu.h +++ b/sys/arch/macppc/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.13 2013/09/13 07:29:02 mpi Exp $ */ +/* $OpenBSD: cpu.h,v 1.14 2013/10/09 17:43:50 mpi Exp $ */ /* $NetBSD: cpu.h,v 1.1 1996/09/30 16:34:21 ws Exp $ */ /* @@ -63,6 +63,7 @@ extern int ppc_altivec; extern void (*ppc64_slew_voltage)(u_int); extern u_int32_t ticks_per_sec; +extern u_int32_t ns_per_tick; #endif /* _KERNEL */ #endif /* _MACHINE_CPU_H_ */ diff --git a/sys/arch/macppc/macppc/clock.c b/sys/arch/macppc/macppc/clock.c index 37d2a0df05a..3068c010579 100644 --- a/sys/arch/macppc/macppc/clock.c +++ b/sys/arch/macppc/macppc/clock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: clock.c,v 1.34 2013/09/13 07:29:01 mpi Exp $ */ +/* $OpenBSD: clock.c,v 1.35 2013/10/09 17:43:50 mpi Exp $ */ /* $NetBSD: clock.c,v 1.1 1996/09/30 16:34:40 ws Exp $ */ /* @@ -52,7 +52,7 @@ u_int tb_get_timecount(struct timecounter *); * Initially we assume a processor with a bus frequency of 12.5 MHz. */ u_int32_t ticks_per_sec = 3125000; -static u_int32_t ns_per_tick = 320; +u_int32_t ns_per_tick = 320; static int32_t ticks_per_intr; static struct timecounter tb_timecounter = { @@ -304,7 +304,6 @@ cpu_initclocks() intrstate = ppc_intr_disable(); - ns_per_tick = 1000000000 / ticks_per_sec; ticks_per_intr = ticks_per_sec / hz; stathz = 100; diff --git a/sys/arch/macppc/macppc/cpu.c b/sys/arch/macppc/macppc/cpu.c index f24eac50fe2..c68d577a11e 100644 --- a/sys/arch/macppc/macppc/cpu.c +++ b/sys/arch/macppc/macppc/cpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.c,v 1.72 2013/09/13 07:29:02 mpi Exp $ */ +/* $OpenBSD: cpu.c,v 1.73 2013/10/09 17:43:50 mpi Exp $ */ /* * Copyright (c) 1997 Per Fogelstrom @@ -349,8 +349,11 @@ cpuattach(struct device *parent, struct device *dev, void *aux) } } - if (timebase != 0) + if (timebase != 0) { ticks_per_sec = timebase; + ns_per_tick = 1000000000 / ticks_per_sec; + } + if (clock_freq != 0) { /* Openfirmware stores clock in Hz, not MHz */ -- cgit v1.2.3