1 #include <linux/module.h>
3 #include <linux/time.h>
4 #include <linux/errno.h>
5 #include <linux/timex.h>
6 #include <linux/clocksource.h>
9 /* IBM Summit (EXA) Cyclone counter code*/
10 #define CYCLONE_CBAR_ADDR 0xFEB00CD0
11 #define CYCLONE_PMCC_OFFSET 0x51A0
12 #define CYCLONE_MPMC_OFFSET 0x51D0
13 #define CYCLONE_MPCS_OFFSET 0x51A8
14 #define CYCLONE_TIMER_FREQ 100000000
17 void __init
cyclone_setup(void)
22 static void __iomem
*cyclone_mc
;
24 static u64
read_cyclone(struct clocksource
*cs
)
26 return (u64
)readq((void __iomem
*)cyclone_mc
);
29 static struct clocksource clocksource_cyclone
= {
33 .mask
= (1LL << 40) - 1,
34 .flags
= CLOCK_SOURCE_IS_CONTINUOUS
,
37 int __init
init_cyclone_clock(void)
40 u64 base
; /* saved cyclone base address */
41 u64 offset
; /* offset from pageaddr to cyclone_timer register */
43 u32 __iomem
*cyclone_timer
; /* Cyclone MPMC0 register */
48 printk(KERN_INFO
"Summit chipset: Starting Cyclone Counter.\n");
50 /* find base address */
51 offset
= (CYCLONE_CBAR_ADDR
);
52 reg
= ioremap_nocache(offset
, sizeof(u64
));
54 printk(KERN_ERR
"Summit chipset: Could not find valid CBAR"
62 printk(KERN_ERR
"Summit chipset: Could not find valid CBAR"
69 offset
= (base
+ CYCLONE_PMCC_OFFSET
);
70 reg
= ioremap_nocache(offset
, sizeof(u64
));
72 printk(KERN_ERR
"Summit chipset: Could not find valid PMCC"
77 writel(0x00000001,reg
);
81 offset
= (base
+ CYCLONE_MPCS_OFFSET
);
82 reg
= ioremap_nocache(offset
, sizeof(u64
));
84 printk(KERN_ERR
"Summit chipset: Could not find valid MPCS"
89 writel(0x00000001,reg
);
92 /* map in cyclone_timer */
93 offset
= (base
+ CYCLONE_MPMC_OFFSET
);
94 cyclone_timer
= ioremap_nocache(offset
, sizeof(u32
));
96 printk(KERN_ERR
"Summit chipset: Could not find valid MPMC"
102 /*quick test to make sure its ticking*/
104 u32 old
= readl(cyclone_timer
);
106 while(stall
--) barrier();
107 if(readl(cyclone_timer
) == old
){
108 printk(KERN_ERR
"Summit chipset: Counter not counting!"
110 iounmap(cyclone_timer
);
111 cyclone_timer
= NULL
;
116 /* initialize last tick */
117 cyclone_mc
= cyclone_timer
;
118 clocksource_cyclone
.archdata
.fsys_mmio
= cyclone_timer
;
119 clocksource_register_hz(&clocksource_cyclone
, CYCLONE_TIMER_FREQ
);
124 __initcall(init_cyclone_clock
);