at91_pmc.c (298352) | at91_pmc.c (298848) |
---|---|
1/*- 2 * Copyright (c) 2006 M. Warner Losh. All rights reserved. 3 * Copyright (c) 2010 Greg Ansley. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 13 unchanged lines hidden (view full) --- 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include "opt_platform.h" 28 29#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2006 M. Warner Losh. All rights reserved. 3 * Copyright (c) 2010 Greg Ansley. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 13 unchanged lines hidden (view full) --- 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include "opt_platform.h" 28 29#include <sys/cdefs.h> |
30__FBSDID("$FreeBSD: head/sys/arm/at91/at91_pmc.c 298352 2016-04-20 15:45:55Z pfg $"); | 30__FBSDID("$FreeBSD: head/sys/arm/at91/at91_pmc.c 298848 2016-04-30 14:41:18Z pfg $"); |
31 32#include <sys/param.h> 33#include <sys/systm.h> 34#include <sys/kernel.h> 35#include <sys/malloc.h> 36#include <sys/module.h> 37#include <sys/time.h> 38#include <sys/bus.h> --- 462 unchanged lines hidden (view full) --- 501 * Clocks up to 50MHz can be connected to some models. If 502 * the frequency is >= 21MHz, assume that the slow clock can 503 * measure it correctly, and that any error can be adequately 504 * compensated for by roudning to the nearest 500Hz. Users 505 * with fast, or odd-ball clocks will need to set 506 * AT91C_MAIN_CLOCK in the kernel config file. 507 */ 508 if (ckgr_val >= 21000000) | 31 32#include <sys/param.h> 33#include <sys/systm.h> 34#include <sys/kernel.h> 35#include <sys/malloc.h> 36#include <sys/module.h> 37#include <sys/time.h> 38#include <sys/bus.h> --- 462 unchanged lines hidden (view full) --- 501 * Clocks up to 50MHz can be connected to some models. If 502 * the frequency is >= 21MHz, assume that the slow clock can 503 * measure it correctly, and that any error can be adequately 504 * compensated for by roudning to the nearest 500Hz. Users 505 * with fast, or odd-ball clocks will need to set 506 * AT91C_MAIN_CLOCK in the kernel config file. 507 */ 508 if (ckgr_val >= 21000000) |
509 return ((ckgr_val + 250) / 500 * 500); | 509 return (rounddown(ckgr_val + 250, 500)); |
510 511 /* 512 * Try to find the standard frequency that match best. 513 */ 514 freq = at91_main_clock_tbl[0]; 515 matchdiff = abs(ckgr_val - at91_main_clock_tbl[0]); 516 for (i = 1; i < MAIN_CLOCK_TBL_LEN; i++) { 517 diff = abs(ckgr_val - at91_main_clock_tbl[i]); --- 203 unchanged lines hidden --- | 510 511 /* 512 * Try to find the standard frequency that match best. 513 */ 514 freq = at91_main_clock_tbl[0]; 515 matchdiff = abs(ckgr_val - at91_main_clock_tbl[0]); 516 for (i = 1; i < MAIN_CLOCK_TBL_LEN; i++) { 517 diff = abs(ckgr_val - at91_main_clock_tbl[i]); --- 203 unchanged lines hidden --- |