1 #include <linux/module.h>
3 #include <linux/time.h>
4 #include <linux/errno.h>
5 #include <linux/timex.h>
8 /* IBM Summit (EXA) Cyclone counter code*/
9 #define CYCLONE_CBAR_ADDR 0xFEB00CD0
10 #define CYCLONE_PMCC_OFFSET 0x51A0
11 #define CYCLONE_MPMC_OFFSET 0x51D0
12 #define CYCLONE_MPCS_OFFSET 0x51A8
13 #define CYCLONE_TIMER_FREQ 100000000
16 void __init cyclone_setup(void)
22 struct time_interpolator cyclone_interpolator = {
23 .source = TIME_SOURCE_MMIO64,
25 .frequency = CYCLONE_TIMER_FREQ,
27 .mask = (1LL << 40) - 1
30 int __init init_cyclone_clock(void)
33 u64 base; /* saved cyclone base address */
34 u64 offset; /* offset from pageaddr to cyclone_timer register */
36 u32* volatile cyclone_timer; /* Cyclone MPMC0 register */
41 printk(KERN_INFO "Summit chipset: Starting Cyclone Counter.\n");
43 /* find base address */
44 offset = (CYCLONE_CBAR_ADDR);
45 reg = (u64*)ioremap_nocache(offset, sizeof(u64));
47 printk(KERN_ERR "Summit chipset: Could not find valid CBAR register.\n");
53 printk(KERN_ERR "Summit chipset: Could not find valid CBAR value.\n");
60 offset = (base + CYCLONE_PMCC_OFFSET);
61 reg = (u64*)ioremap_nocache(offset, sizeof(u64));
63 printk(KERN_ERR "Summit chipset: Could not find valid PMCC register.\n");
67 writel(0x00000001,reg);
71 offset = (base + CYCLONE_MPCS_OFFSET);
72 reg = (u64*)ioremap_nocache(offset, sizeof(u64));
74 printk(KERN_ERR "Summit chipset: Could not find valid MPCS register.\n");
78 writel(0x00000001,reg);
81 /* map in cyclone_timer */
82 offset = (base + CYCLONE_MPMC_OFFSET);
83 cyclone_timer = (u32*)ioremap_nocache(offset, sizeof(u32));
85 printk(KERN_ERR "Summit chipset: Could not find valid MPMC register.\n");
90 /*quick test to make sure its ticking*/
92 u32 old = readl(cyclone_timer);
94 while(stall--) barrier();
95 if(readl(cyclone_timer) == old){
96 printk(KERN_ERR "Summit chipset: Counter not counting! DISABLED\n");
97 iounmap(cyclone_timer);
103 /* initialize last tick */
104 cyclone_interpolator.addr = cyclone_timer;
105 register_time_interpolator(&cyclone_interpolator);
110 __initcall(init_cyclone_clock);