From owner-freebsd-arm@FreeBSD.ORG Wed Jun 13 08:10:32 2007 Return-Path: X-Original-To: arm@freebsd.org Delivered-To: freebsd-arm@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 28CC016A46D for ; Wed, 13 Jun 2007 08:10:32 +0000 (UTC) (envelope-from bkoenig@alpha-tierchen.de) Received: from mail.liberty-hosting.de (mail.smartterra.de [195.225.132.203]) by mx1.freebsd.org (Postfix) with ESMTP id D8CB213C4AE for ; Wed, 13 Jun 2007 08:10:31 +0000 (UTC) (envelope-from bkoenig@alpha-tierchen.de) Received: from mail.liberty-hosting.de ([195.225.132.203]) by localhost (liberty-mail [195.225.132.203]) (amavisd-new, port 10024) with ESMTP id 88315-03; Wed, 13 Jun 2007 10:10:28 +0200 (CEST) Received: from home.alpha-tierchen.de (port-212-202-170-5.dynamic.qsc.de [212.202.170.5]) by mail.liberty-hosting.de (Postfix) with ESMTP id 4A06F18138D; Wed, 13 Jun 2007 10:10:28 +0200 (CEST) Received: from webmail.alpha-tierchen.de (localhost [127.0.0.1]) by home.alpha-tierchen.de (Postfix) with ESMTP id 1C0CA45046; Wed, 13 Jun 2007 10:10:24 +0200 (CEST) Received: from 2001:6f8:101e:0:20e:cff:fe6d:6adb (SquirrelMail authenticated user bkoenig) by webmail.alpha-tierchen.de with HTTP; Wed, 13 Jun 2007 10:10:24 +0200 (CEST) Message-ID: <57472.2001:6f8:101e:0:20e:cff:fe6d:6adb.1181722224.squirrel@webmail.alpha-tierchen.de> In-Reply-To: <20070612.215430.-365729166.imp@bsdimp.com> References: <55286.2001:6f8:101e:0:20e:cff:fe6d:6adb.1181705783.squirrel@webmail.alpha-tierchen.de> <20070612.215430.-365729166.imp@bsdimp.com> Date: Wed, 13 Jun 2007 10:10:24 +0200 (CEST) From: =?iso-8859-1?Q?Bj=F6rn_K=F6nig?= To: "M. Warner Losh" User-Agent: SquirrelMail/1.4.10a MIME-Version: 1.0 Content-Type: multipart/mixed;boundary="----=_20070613101024_45905" X-Priority: 3 (Normal) Importance: Normal X-Virus-Scanned: by amavisd-new at mail.smartterra.de Cc: arm@freebsd.org Subject: Re: main clock frequency X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Jun 2007 08:10:32 -0000 ------=_20070613101024_45905 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit So this is my patch. It would be interesting for me to know the effective main clock values for 10.0 Hz and 16.0 Hz oscillators. My board uses a 18.432 Hz oscillator. Currently I'm working on changing the PCK and MCK on-the-fly via sysctl MIB which basically works well for me. Björn ------=_20070613101024_45905 Content-Type: text/x-diff; name="at91_pmc.c.diff" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="at91_pmc.c.diff" --- src/sys/arm/at91/at91_pmc.c.orig Wed Jun 13 09:39:36 2007 +++ src/sys/arm/at91/at91_pmc.c Wed Jun 13 09:54:18 2007 @@ -394,16 +394,18 @@ at91_pmc_attach(device_t dev) { int err; + uint32_t mcfr; pmc_softc = device_get_softc(dev); pmc_softc->dev = dev; if ((err = at91_pmc_activate(dev)) != 0) return err; -#if defined(AT91_TSC) | defined (AT91_BWCT) - at91_pmc_init_clock(pmc_softc, 16000000); -#else - at91_pmc_init_clock(pmc_softc, 10000000); -#endif + + mcfr = RD4(pmc_softc, CKGR_MCFR); + if (mcfr & CKGR_MCFR_MAINRDY == 0) + return (ENXIO); + + at91_pmc_init_clock(pmc_softc, (mcfr & CKGR_MCFR_MAINF_MASK) * 32768 / 16); return (0); } ------=_20070613101024_45905--