Deleted Added
full compact
at91_pmc.c (213496) at91_pmc.c (213498)
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

--- 11 unchanged lines hidden (view full) ---

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
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 <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

--- 11 unchanged lines hidden (view full) ---

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
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 <sys/cdefs.h>
28__FBSDID("$FreeBSD: head/sys/arm/at91/at91_pmc.c 213496 2010-10-06 22:25:21Z cognet $");
28__FBSDID("$FreeBSD: head/sys/arm/at91/at91_pmc.c 213498 2010-10-06 22:40:27Z cognet $");
29
30#include <sys/param.h>
31#include <sys/systm.h>
32#include <sys/kernel.h>
33#include <sys/malloc.h>
34#include <sys/module.h>
35#include <sys/time.h>
36#include <sys/bus.h>

--- 289 unchanged lines hidden (view full) ---

326at91_pmc_pll_rate(struct at91_pmc_clock *clk, uint32_t reg)
327{
328 uint32_t mul, div, freq;;
329
330 freq = clk->parent->hz;
331 div = (reg >> clk->pll_div_shift) & clk->pll_div_mask;
332 mul = (reg >> clk->pll_mul_shift) & clk->pll_mul_mask;
333
29
30#include <sys/param.h>
31#include <sys/systm.h>
32#include <sys/kernel.h>
33#include <sys/malloc.h>
34#include <sys/module.h>
35#include <sys/time.h>
36#include <sys/bus.h>

--- 289 unchanged lines hidden (view full) ---

326at91_pmc_pll_rate(struct at91_pmc_clock *clk, uint32_t reg)
327{
328 uint32_t mul, div, freq;;
329
330 freq = clk->parent->hz;
331 div = (reg >> clk->pll_div_shift) & clk->pll_div_mask;
332 mul = (reg >> clk->pll_mul_shift) & clk->pll_mul_mask;
333
334// printf("pll = (%d / %d) * %d = %d\n",
335// freq, div ,mul + 1, (freq/div) * (mul+1));
336
334 if (div != 0 && mul != 0) {
335 freq /= div;
336 freq *= mul + 1;
337 } else {
338 freq = 0;
339 }
340 clk->hz = freq;
337 if (div != 0 && mul != 0) {
338 freq /= div;
339 freq *= mul + 1;
340 } else {
341 freq = 0;
342 }
343 clk->hz = freq;
344
345
341 return (freq);
342}
343
344static uint32_t
345at91_pmc_pll_calc(struct at91_pmc_clock *clk, uint32_t out_freq)
346{
347 uint32_t i, div = 0, mul = 0, diff = 1 << 30;
348

--- 90 unchanged lines hidden (view full) ---

439 mck.parent->refcnt++;
440
441 cpu.hz =
442 mck.hz = mck.parent->hz /
443 (1 << ((mckr & PMC_MCKR_PRES_MASK) >> 2));
444
445 mdiv = (mckr & PMC_MCKR_MDIV_MASK) >> 8;
446 if (at91_is_sam9()) {
346 return (freq);
347}
348
349static uint32_t
350at91_pmc_pll_calc(struct at91_pmc_clock *clk, uint32_t out_freq)
351{
352 uint32_t i, div = 0, mul = 0, diff = 1 << 30;
353

--- 90 unchanged lines hidden (view full) ---

444 mck.parent->refcnt++;
445
446 cpu.hz =
447 mck.hz = mck.parent->hz /
448 (1 << ((mckr & PMC_MCKR_PRES_MASK) >> 2));
449
450 mdiv = (mckr & PMC_MCKR_MDIV_MASK) >> 8;
451 if (at91_is_sam9()) {
447 mck.hz /= (mdiv) ? (mdiv * 2) : 1;
452 if (mdiv > 0)
453 mck.hz /= mdiv * 2;
448 } else
449 mck.hz /= (1 + mdiv);
450
451 /* Only found on SAM9G20 */
452 if (at91_cpu_is(AT91_CPU_SAM9G20))
453 cpu.hz /= (mckr & PMC_MCKR_PDIV) ? 2 : 1;
454
455 at91_master_clock = mck.hz;

--- 126 unchanged lines hidden ---
454 } else
455 mck.hz /= (1 + mdiv);
456
457 /* Only found on SAM9G20 */
458 if (at91_cpu_is(AT91_CPU_SAM9G20))
459 cpu.hz /= (mckr & PMC_MCKR_PDIV) ? 2 : 1;
460
461 at91_master_clock = mck.hz;

--- 126 unchanged lines hidden ---