diff options
Diffstat (limited to 'arch/arm/mach-at91/clock.c')
-rw-r--r-- | arch/arm/mach-at91/clock.c | 64 |
1 files changed, 58 insertions, 6 deletions
diff --git a/arch/arm/mach-at91/clock.c b/arch/arm/mach-at91/clock.c index a33dfe450726..464bdbbf74df 100644 --- a/arch/arm/mach-at91/clock.c +++ b/arch/arm/mach-at91/clock.c | |||
@@ -112,12 +112,34 @@ static void pmc_sys_mode(struct clk *clk, int is_on) | |||
112 | at91_sys_write(AT91_PMC_SCDR, clk->pmc_mask); | 112 | at91_sys_write(AT91_PMC_SCDR, clk->pmc_mask); |
113 | } | 113 | } |
114 | 114 | ||
115 | static void pmc_uckr_mode(struct clk *clk, int is_on) | ||
116 | { | ||
117 | unsigned int uckr = at91_sys_read(AT91_CKGR_UCKR); | ||
118 | |||
119 | if (is_on) { | ||
120 | is_on = AT91_PMC_LOCKU; | ||
121 | at91_sys_write(AT91_CKGR_UCKR, uckr | clk->pmc_mask); | ||
122 | } else | ||
123 | at91_sys_write(AT91_CKGR_UCKR, uckr & ~(clk->pmc_mask)); | ||
124 | |||
125 | do { | ||
126 | cpu_relax(); | ||
127 | } while ((at91_sys_read(AT91_PMC_SR) & AT91_PMC_LOCKU) != is_on); | ||
128 | } | ||
129 | |||
115 | /* USB function clocks (PLLB must be 48 MHz) */ | 130 | /* USB function clocks (PLLB must be 48 MHz) */ |
116 | static struct clk udpck = { | 131 | static struct clk udpck = { |
117 | .name = "udpck", | 132 | .name = "udpck", |
118 | .parent = &pllb, | 133 | .parent = &pllb, |
119 | .mode = pmc_sys_mode, | 134 | .mode = pmc_sys_mode, |
120 | }; | 135 | }; |
136 | static struct clk utmi_clk = { | ||
137 | .name = "utmi_clk", | ||
138 | .parent = &main_clk, | ||
139 | .pmc_mask = AT91_PMC_UPLLEN, /* in CKGR_UCKR */ | ||
140 | .mode = pmc_uckr_mode, | ||
141 | .type = CLK_TYPE_PLL, | ||
142 | }; | ||
121 | static struct clk uhpck = { | 143 | static struct clk uhpck = { |
122 | .name = "uhpck", | 144 | .name = "uhpck", |
123 | .parent = &pllb, | 145 | .parent = &pllb, |
@@ -361,7 +383,7 @@ static void __init init_programmable_clock(struct clk *clk) | |||
361 | 383 | ||
362 | static int at91_clk_show(struct seq_file *s, void *unused) | 384 | static int at91_clk_show(struct seq_file *s, void *unused) |
363 | { | 385 | { |
364 | u32 scsr, pcsr, sr; | 386 | u32 scsr, pcsr, uckr = 0, sr; |
365 | struct clk *clk; | 387 | struct clk *clk; |
366 | 388 | ||
367 | seq_printf(s, "SCSR = %8x\n", scsr = at91_sys_read(AT91_PMC_SCSR)); | 389 | seq_printf(s, "SCSR = %8x\n", scsr = at91_sys_read(AT91_PMC_SCSR)); |
@@ -369,7 +391,10 @@ static int at91_clk_show(struct seq_file *s, void *unused) | |||
369 | seq_printf(s, "MOR = %8x\n", at91_sys_read(AT91_CKGR_MOR)); | 391 | seq_printf(s, "MOR = %8x\n", at91_sys_read(AT91_CKGR_MOR)); |
370 | seq_printf(s, "MCFR = %8x\n", at91_sys_read(AT91_CKGR_MCFR)); | 392 | seq_printf(s, "MCFR = %8x\n", at91_sys_read(AT91_CKGR_MCFR)); |
371 | seq_printf(s, "PLLA = %8x\n", at91_sys_read(AT91_CKGR_PLLAR)); | 393 | seq_printf(s, "PLLA = %8x\n", at91_sys_read(AT91_CKGR_PLLAR)); |
372 | seq_printf(s, "PLLB = %8x\n", at91_sys_read(AT91_CKGR_PLLBR)); | 394 | if (!cpu_is_at91sam9rl()) |
395 | seq_printf(s, "PLLB = %8x\n", at91_sys_read(AT91_CKGR_PLLBR)); | ||
396 | if (cpu_is_at91cap9() || cpu_is_at91sam9rl()) | ||
397 | seq_printf(s, "UCKR = %8x\n", uckr = at91_sys_read(AT91_CKGR_UCKR)); | ||
373 | seq_printf(s, "MCKR = %8x\n", at91_sys_read(AT91_PMC_MCKR)); | 398 | seq_printf(s, "MCKR = %8x\n", at91_sys_read(AT91_PMC_MCKR)); |
374 | seq_printf(s, "SR = %8x\n", sr = at91_sys_read(AT91_PMC_SR)); | 399 | seq_printf(s, "SR = %8x\n", sr = at91_sys_read(AT91_PMC_SR)); |
375 | 400 | ||
@@ -382,6 +407,8 @@ static int at91_clk_show(struct seq_file *s, void *unused) | |||
382 | state = (scsr & clk->pmc_mask) ? "on" : "off"; | 407 | state = (scsr & clk->pmc_mask) ? "on" : "off"; |
383 | else if (clk->mode == pmc_periph_mode) | 408 | else if (clk->mode == pmc_periph_mode) |
384 | state = (pcsr & clk->pmc_mask) ? "on" : "off"; | 409 | state = (pcsr & clk->pmc_mask) ? "on" : "off"; |
410 | else if (clk->mode == pmc_uckr_mode) | ||
411 | state = (uckr & clk->pmc_mask) ? "on" : "off"; | ||
385 | else if (clk->pmc_mask) | 412 | else if (clk->pmc_mask) |
386 | state = (sr & clk->pmc_mask) ? "on" : "off"; | 413 | state = (sr & clk->pmc_mask) ? "on" : "off"; |
387 | else if (clk == &clk32k || clk == &main_clk) | 414 | else if (clk == &clk32k || clk == &main_clk) |
@@ -488,14 +515,19 @@ static unsigned __init at91_pll_calc(unsigned main_freq, unsigned out_freq) | |||
488 | /* | 515 | /* |
489 | * PLL input between 1MHz and 32MHz per spec, but lower | 516 | * PLL input between 1MHz and 32MHz per spec, but lower |
490 | * frequences seem necessary in some cases so allow 100K. | 517 | * frequences seem necessary in some cases so allow 100K. |
518 | * Warning: some newer products need 2MHz min. | ||
491 | */ | 519 | */ |
492 | input = main_freq / i; | 520 | input = main_freq / i; |
521 | if (cpu_is_at91sam9g20() && input < 2000000) | ||
522 | continue; | ||
493 | if (input < 100000) | 523 | if (input < 100000) |
494 | continue; | 524 | continue; |
495 | if (input > 32000000) | 525 | if (input > 32000000) |
496 | continue; | 526 | continue; |
497 | 527 | ||
498 | mul1 = out_freq / input; | 528 | mul1 = out_freq / input; |
529 | if (cpu_is_at91sam9g20() && mul > 63) | ||
530 | continue; | ||
499 | if (mul1 > 2048) | 531 | if (mul1 > 2048) |
500 | continue; | 532 | continue; |
501 | if (mul1 < 2) | 533 | if (mul1 < 2) |
@@ -555,7 +587,8 @@ int __init at91_clock_init(unsigned long main_clock) | |||
555 | 587 | ||
556 | /* report if PLLA is more than mildly overclocked */ | 588 | /* report if PLLA is more than mildly overclocked */ |
557 | plla.rate_hz = at91_pll_rate(&plla, main_clock, at91_sys_read(AT91_CKGR_PLLAR)); | 589 | plla.rate_hz = at91_pll_rate(&plla, main_clock, at91_sys_read(AT91_CKGR_PLLAR)); |
558 | if (plla.rate_hz > 209000000) | 590 | if ((!cpu_is_at91sam9g20() && plla.rate_hz > 209000000) |
591 | || (cpu_is_at91sam9g20() && plla.rate_hz > 800000000)) | ||
559 | pr_info("Clocks: PLLA overclocked, %ld MHz\n", plla.rate_hz / 1000000); | 592 | pr_info("Clocks: PLLA overclocked, %ld MHz\n", plla.rate_hz / 1000000); |
560 | 593 | ||
561 | /* | 594 | /* |
@@ -570,7 +603,7 @@ int __init at91_clock_init(unsigned long main_clock) | |||
570 | uhpck.pmc_mask = AT91RM9200_PMC_UHP; | 603 | uhpck.pmc_mask = AT91RM9200_PMC_UHP; |
571 | udpck.pmc_mask = AT91RM9200_PMC_UDP; | 604 | udpck.pmc_mask = AT91RM9200_PMC_UDP; |
572 | at91_sys_write(AT91_PMC_SCER, AT91RM9200_PMC_MCKUDP); | 605 | at91_sys_write(AT91_PMC_SCER, AT91RM9200_PMC_MCKUDP); |
573 | } else if (cpu_is_at91sam9260() || cpu_is_at91sam9261() || cpu_is_at91sam9263()) { | 606 | } else if (cpu_is_at91sam9260() || cpu_is_at91sam9261() || cpu_is_at91sam9263() || cpu_is_at91sam9g20()) { |
574 | uhpck.pmc_mask = AT91SAM926x_PMC_UHP; | 607 | uhpck.pmc_mask = AT91SAM926x_PMC_UHP; |
575 | udpck.pmc_mask = AT91SAM926x_PMC_UDP; | 608 | udpck.pmc_mask = AT91SAM926x_PMC_UDP; |
576 | } else if (cpu_is_at91cap9()) { | 609 | } else if (cpu_is_at91cap9()) { |
@@ -582,6 +615,17 @@ int __init at91_clock_init(unsigned long main_clock) | |||
582 | uhpck.rate_hz = at91_usb_rate(&pllb, pllb.rate_hz, at91_pllb_usb_init); | 615 | uhpck.rate_hz = at91_usb_rate(&pllb, pllb.rate_hz, at91_pllb_usb_init); |
583 | 616 | ||
584 | /* | 617 | /* |
618 | * USB HS clock init | ||
619 | */ | ||
620 | if (cpu_is_at91cap9() || cpu_is_at91sam9rl()) { | ||
621 | /* | ||
622 | * multiplier is hard-wired to 40 | ||
623 | * (obtain the USB High Speed 480 MHz when input is 12 MHz) | ||
624 | */ | ||
625 | utmi_clk.rate_hz = 40 * utmi_clk.parent->rate_hz; | ||
626 | } | ||
627 | |||
628 | /* | ||
585 | * MCK and CPU derive from one of those primary clocks. | 629 | * MCK and CPU derive from one of those primary clocks. |
586 | * For now, assume this parentage won't change. | 630 | * For now, assume this parentage won't change. |
587 | */ | 631 | */ |
@@ -591,13 +635,21 @@ int __init at91_clock_init(unsigned long main_clock) | |||
591 | freq /= (1 << ((mckr & AT91_PMC_PRES) >> 2)); /* prescale */ | 635 | freq /= (1 << ((mckr & AT91_PMC_PRES) >> 2)); /* prescale */ |
592 | if (cpu_is_at91rm9200()) | 636 | if (cpu_is_at91rm9200()) |
593 | mck.rate_hz = freq / (1 + ((mckr & AT91_PMC_MDIV) >> 8)); /* mdiv */ | 637 | mck.rate_hz = freq / (1 + ((mckr & AT91_PMC_MDIV) >> 8)); /* mdiv */ |
594 | else | 638 | else if (cpu_is_at91sam9g20()) { |
595 | mck.rate_hz = freq / (1 << ((mckr & AT91_PMC_MDIV) >> 8)); /* mdiv */ | 639 | mck.rate_hz = (mckr & AT91_PMC_MDIV) ? |
640 | freq / ((mckr & AT91_PMC_MDIV) >> 7) : freq; /* mdiv ; (x >> 7) = ((x >> 8) * 2) */ | ||
641 | if (mckr & AT91_PMC_PDIV) | ||
642 | freq /= 2; /* processor clock division */ | ||
643 | } else | ||
644 | mck.rate_hz = freq / (1 << ((mckr & AT91_PMC_MDIV) >> 8)); /* mdiv */ | ||
596 | 645 | ||
597 | /* Register the PMC's standard clocks */ | 646 | /* Register the PMC's standard clocks */ |
598 | for (i = 0; i < ARRAY_SIZE(standard_pmc_clocks); i++) | 647 | for (i = 0; i < ARRAY_SIZE(standard_pmc_clocks); i++) |
599 | list_add_tail(&standard_pmc_clocks[i]->node, &clocks); | 648 | list_add_tail(&standard_pmc_clocks[i]->node, &clocks); |
600 | 649 | ||
650 | if (cpu_is_at91cap9() || cpu_is_at91sam9rl()) | ||
651 | list_add_tail(&utmi_clk.node, &clocks); | ||
652 | |||
601 | /* MCK and CPU clock are "always on" */ | 653 | /* MCK and CPU clock are "always on" */ |
602 | clk_enable(&mck); | 654 | clk_enable(&mck); |
603 | 655 | ||