1 #include <linux/module.h>
3 #include <linux/time.h>
4 #include <linux/errno.h>
7 /* IBM Summit (EXA) Cyclone counter code*/
8 #define CYCLONE_CBAR_ADDR 0xFEB00CD0
9 #define CYCLONE_PMCC_OFFSET 0x51A0
10 #define CYCLONE_MPMC_OFFSET 0x51D0
11 #define CYCLONE_MPCS_OFFSET 0x51A8
12 #define CYCLONE_TIMER_FREQ 100000000
15 void __init cyclone_setup(void)
21 struct time_interpolator cyclone_interpolator = {
22 .source = TIME_SOURCE_MMIO64,
24 .frequency = CYCLONE_TIMER_FREQ,
26 .mask = (1LL << 40) - 1
29 int __init init_cyclone_clock(void)
32 u64 base; /* saved cyclone base address */
33 u64 offset; /* offset from pageaddr to cyclone_timer register */
35 u32* volatile cyclone_timer; /* Cyclone MPMC0 register */
40 printk(KERN_INFO "Summit chipset: Starting Cyclone Counter.\n");
42 /* find base address */
43 offset = (CYCLONE_CBAR_ADDR);
44 reg = (u64*)ioremap_nocache(offset, sizeof(u64));
46 printk(KERN_ERR "Summit chipset: Could not find valid CBAR register.\n");
52 printk(KERN_ERR "Summit chipset: Could not find valid CBAR value.\n");
59 offset = (base + CYCLONE_PMCC_OFFSET);
60 reg = (u64*)ioremap_nocache(offset, sizeof(u64));
62 printk(KERN_ERR "Summit chipset: Could not find valid PMCC register.\n");
66 writel(0x00000001,reg);
70 offset = (base + CYCLONE_MPCS_OFFSET);
71 reg = (u64*)ioremap_nocache(offset, sizeof(u64));
73 printk(KERN_ERR "Summit chipset: Could not find valid MPCS register.\n");
77 writel(0x00000001,reg);
80 /* map in cyclone_timer */
81 offset = (base + CYCLONE_MPMC_OFFSET);
82 cyclone_timer = (u32*)ioremap_nocache(offset, sizeof(u32));
84 printk(KERN_ERR "Summit chipset: Could not find valid MPMC register.\n");
89 /*quick test to make sure its ticking*/
91 u32 old = readl(cyclone_timer);
93 while(stall--) barrier();
94 if(readl(cyclone_timer) == old){
95 printk(KERN_ERR "Summit chipset: Counter not counting! DISABLED\n");
96 iounmap(cyclone_timer);
102 /* initialize last tick */
103 cyclone_interpolator.addr = cyclone_timer;
104 register_time_interpolator(&cyclone_interpolator);
109 __initcall(init_cyclone_clock);