Skip to content

Commit 549437a

Browse files
Zhen Leidlezcano
authored andcommitted
clocksource/drivers/sp804: Enable Hisilicon sp804 timer 64bit mode
A 100MHZ 32-bit timer will be wrapped up less than 43s. Although the kernel maintains a software high 32-bit count in the tick IRQ. But it's not applicable to the user mode APPs. Note: The kernel still uses the lower 32 bits of the timer. Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Link: https://lore.kernel.org/r/20200918132237.3552-9-thunder.leizhen@huawei.com
1 parent bd5a193 commit 549437a

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

drivers/clocksource/timer-sp.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,25 +33,31 @@
3333

3434
struct sp804_timer {
3535
int load;
36+
int load_h;
3637
int value;
38+
int value_h;
3739
int ctrl;
3840
int intclr;
3941
int ris;
4042
int mis;
4143
int bgload;
44+
int bgload_h;
4245
int timer_base[NR_TIMERS];
4346
int width;
4447
};
4548

4649
struct sp804_clkevt {
4750
void __iomem *base;
4851
void __iomem *load;
52+
void __iomem *load_h;
4953
void __iomem *value;
54+
void __iomem *value_h;
5055
void __iomem *ctrl;
5156
void __iomem *intclr;
5257
void __iomem *ris;
5358
void __iomem *mis;
5459
void __iomem *bgload;
60+
void __iomem *bgload_h;
5561
unsigned long reload;
5662
int width;
5763
};

drivers/clocksource/timer-sp804.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,15 @@
2424
#define HISI_TIMER_1_BASE 0x00
2525
#define HISI_TIMER_2_BASE 0x40
2626
#define HISI_TIMER_LOAD 0x00
27+
#define HISI_TIMER_LOAD_H 0x04
2728
#define HISI_TIMER_VALUE 0x08
29+
#define HISI_TIMER_VALUE_H 0x0c
2830
#define HISI_TIMER_CTRL 0x10
2931
#define HISI_TIMER_INTCLR 0x14
3032
#define HISI_TIMER_RIS 0x18
3133
#define HISI_TIMER_MIS 0x1c
3234
#define HISI_TIMER_BGLOAD 0x20
35+
#define HISI_TIMER_BGLOAD_H 0x24
3336

3437

3538
struct sp804_timer __initdata arm_sp804_timer = {
@@ -43,7 +46,9 @@ struct sp804_timer __initdata arm_sp804_timer = {
4346

4447
struct sp804_timer __initdata hisi_sp804_timer = {
4548
.load = HISI_TIMER_LOAD,
49+
.load_h = HISI_TIMER_LOAD_H,
4650
.value = HISI_TIMER_VALUE,
51+
.value_h = HISI_TIMER_VALUE_H,
4752
.ctrl = HISI_TIMER_CTRL,
4853
.intclr = HISI_TIMER_INTCLR,
4954
.timer_base = {HISI_TIMER_1_BASE, HISI_TIMER_2_BASE},
@@ -129,6 +134,10 @@ int __init sp804_clocksource_and_sched_clock_init(void __iomem *base,
129134
writel(0, clkevt->ctrl);
130135
writel(0xffffffff, clkevt->load);
131136
writel(0xffffffff, clkevt->value);
137+
if (clkevt->width == 64) {
138+
writel(0xffffffff, clkevt->load_h);
139+
writel(0xffffffff, clkevt->value_h);
140+
}
132141
writel(TIMER_CTRL_32BIT | TIMER_CTRL_ENABLE | TIMER_CTRL_PERIODIC,
133142
clkevt->ctrl);
134143

@@ -245,7 +254,9 @@ static void __init sp804_clkevt_init(struct sp804_timer *timer, void __iomem *ba
245254
clkevt = &sp804_clkevt[i];
246255
clkevt->base = timer_base;
247256
clkevt->load = timer_base + timer->load;
257+
clkevt->load_h = timer_base + timer->load_h;
248258
clkevt->value = timer_base + timer->value;
259+
clkevt->value_h = timer_base + timer->value_h;
249260
clkevt->ctrl = timer_base + timer->ctrl;
250261
clkevt->intclr = timer_base + timer->intclr;
251262
clkevt->width = timer->width;

0 commit comments

Comments
 (0)