diff options
| -rw-r--r-- | arch/arm/mach-omap2/control.h | 4 | ||||
| -rw-r--r-- | arch/arm/mach-omap2/timer.c | 36 |
2 files changed, 38 insertions, 2 deletions
diff --git a/arch/arm/mach-omap2/control.h b/arch/arm/mach-omap2/control.h index a3c013345c45..a80ac2d70bb1 100644 --- a/arch/arm/mach-omap2/control.h +++ b/arch/arm/mach-omap2/control.h | |||
| @@ -286,6 +286,10 @@ | |||
| 286 | #define OMAP5XXX_CONTROL_STATUS 0x134 | 286 | #define OMAP5XXX_CONTROL_STATUS 0x134 |
| 287 | #define OMAP5_DEVICETYPE_MASK (0x7 << 6) | 287 | #define OMAP5_DEVICETYPE_MASK (0x7 << 6) |
| 288 | 288 | ||
| 289 | /* DRA7XX CONTROL CORE BOOTSTRAP */ | ||
| 290 | #define DRA7_CTRL_CORE_BOOTSTRAP 0x6c4 | ||
| 291 | #define DRA7_SPEEDSELECT_MASK (0x3 << 8) | ||
| 292 | |||
| 289 | /* | 293 | /* |
| 290 | * REVISIT: This list of registers is not comprehensive - there are more | 294 | * REVISIT: This list of registers is not comprehensive - there are more |
| 291 | * that should be added. | 295 | * that should be added. |
diff --git a/arch/arm/mach-omap2/timer.c b/arch/arm/mach-omap2/timer.c index fb0cb2b817a9..7d45c84c69ba 100644 --- a/arch/arm/mach-omap2/timer.c +++ b/arch/arm/mach-omap2/timer.c | |||
| @@ -54,6 +54,7 @@ | |||
| 54 | 54 | ||
| 55 | #include "soc.h" | 55 | #include "soc.h" |
| 56 | #include "common.h" | 56 | #include "common.h" |
| 57 | #include "control.h" | ||
| 57 | #include "powerdomain.h" | 58 | #include "powerdomain.h" |
| 58 | #include "omap-secure.h" | 59 | #include "omap-secure.h" |
| 59 | 60 | ||
| @@ -496,7 +497,8 @@ static void __init realtime_counter_init(void) | |||
| 496 | void __iomem *base; | 497 | void __iomem *base; |
| 497 | static struct clk *sys_clk; | 498 | static struct clk *sys_clk; |
| 498 | unsigned long rate; | 499 | unsigned long rate; |
| 499 | unsigned int reg, num, den; | 500 | unsigned int reg; |
| 501 | unsigned long long num, den; | ||
| 500 | 502 | ||
| 501 | base = ioremap(REALTIME_COUNTER_BASE, SZ_32); | 503 | base = ioremap(REALTIME_COUNTER_BASE, SZ_32); |
| 502 | if (!base) { | 504 | if (!base) { |
| @@ -511,6 +513,35 @@ static void __init realtime_counter_init(void) | |||
| 511 | } | 513 | } |
| 512 | 514 | ||
| 513 | rate = clk_get_rate(sys_clk); | 515 | rate = clk_get_rate(sys_clk); |
| 516 | |||
| 517 | if (soc_is_dra7xx()) { | ||
| 518 | /* | ||
| 519 | * Errata i856 says the 32.768KHz crystal does not start at | ||
| 520 | * power on, so the CPU falls back to an emulated 32KHz clock | ||
| 521 | * based on sysclk / 610 instead. This causes the master counter | ||
| 522 | * frequency to not be 6.144MHz but at sysclk / 610 * 375 / 2 | ||
| 523 | * (OR sysclk * 75 / 244) | ||
| 524 | * | ||
| 525 | * This affects at least the DRA7/AM572x 1.0, 1.1 revisions. | ||
| 526 | * Of course any board built without a populated 32.768KHz | ||
| 527 | * crystal would also need this fix even if the CPU is fixed | ||
| 528 | * later. | ||
| 529 | * | ||
| 530 | * Either case can be detected by using the two speedselect bits | ||
| 531 | * If they are not 0, then the 32.768KHz clock driving the | ||
| 532 | * coarse counter that corrects the fine counter every time it | ||
| 533 | * ticks is actually rate/610 rather than 32.768KHz and we | ||
| 534 | * should compensate to avoid the 570ppm (at 20MHz, much worse | ||
| 535 | * at other rates) too fast system time. | ||
| 536 | */ | ||
| 537 | reg = omap_ctrl_readl(DRA7_CTRL_CORE_BOOTSTRAP); | ||
| 538 | if (reg & DRA7_SPEEDSELECT_MASK) { | ||
| 539 | num = 75; | ||
| 540 | den = 244; | ||
| 541 | goto sysclk1_based; | ||
| 542 | } | ||
| 543 | } | ||
| 544 | |||
| 514 | /* Numerator/denumerator values refer TRM Realtime Counter section */ | 545 | /* Numerator/denumerator values refer TRM Realtime Counter section */ |
| 515 | switch (rate) { | 546 | switch (rate) { |
| 516 | case 12000000: | 547 | case 12000000: |
| @@ -545,6 +576,7 @@ static void __init realtime_counter_init(void) | |||
| 545 | break; | 576 | break; |
| 546 | } | 577 | } |
| 547 | 578 | ||
| 579 | sysclk1_based: | ||
| 548 | /* Program numerator and denumerator registers */ | 580 | /* Program numerator and denumerator registers */ |
| 549 | reg = readl_relaxed(base + INCREMENTER_NUMERATOR_OFFSET) & | 581 | reg = readl_relaxed(base + INCREMENTER_NUMERATOR_OFFSET) & |
| 550 | NUMERATOR_DENUMERATOR_MASK; | 582 | NUMERATOR_DENUMERATOR_MASK; |
| @@ -556,7 +588,7 @@ static void __init realtime_counter_init(void) | |||
| 556 | reg |= den; | 588 | reg |= den; |
| 557 | writel_relaxed(reg, base + INCREMENTER_DENUMERATOR_RELOAD_OFFSET); | 589 | writel_relaxed(reg, base + INCREMENTER_DENUMERATOR_RELOAD_OFFSET); |
| 558 | 590 | ||
| 559 | arch_timer_freq = (rate / den) * num; | 591 | arch_timer_freq = DIV_ROUND_UP_ULL(rate * num, den); |
| 560 | set_cntfreq(); | 592 | set_cntfreq(); |
| 561 | 593 | ||
| 562 | iounmap(base); | 594 | iounmap(base); |
