Blame view
drivers/clocksource/cyclone.c
3.05 KB
5d0cf410e [PATCH] Time: i38... |
1 2 3 4 5 6 7 8 |
#include <linux/clocksource.h> #include <linux/string.h> #include <linux/errno.h> #include <linux/timex.h> #include <linux/init.h> #include <asm/pgtable.h> #include <asm/io.h> |
1164dd009 x86: move mach-de... |
9 |
#include <asm/mach_timer.h> |
5d0cf410e [PATCH] Time: i38... |
10 11 12 13 14 15 |
#define CYCLONE_CBAR_ADDR 0xFEB00CD0 /* base address ptr */ #define CYCLONE_PMCC_OFFSET 0x51A0 /* offset to control register */ #define CYCLONE_MPCS_OFFSET 0x51A8 /* offset to select register */ #define CYCLONE_MPMC_OFFSET 0x51D0 /* offset to count register */ #define CYCLONE_TIMER_FREQ 99780000 /* 100Mhz, but not really */ |
7f9f303aa [PATCH] generic-t... |
16 |
#define CYCLONE_TIMER_MASK CLOCKSOURCE_MASK(32) /* 32 bit mask */ |
5d0cf410e [PATCH] Time: i38... |
17 18 19 |
int use_cyclone = 0; static void __iomem *cyclone_ptr; |
8e19608e8 clocksource: pass... |
20 |
static cycle_t read_cyclone(struct clocksource *cs) |
5d0cf410e [PATCH] Time: i38... |
21 22 23 24 25 26 27 28 |
{ return (cycle_t)readl(cyclone_ptr); } static struct clocksource clocksource_cyclone = { .name = "cyclone", .rating = 250, .read = read_cyclone, |
7f9f303aa [PATCH] generic-t... |
29 |
.mask = CYCLONE_TIMER_MASK, |
5d0cf410e [PATCH] Time: i38... |
30 31 |
.mult = 10, .shift = 0, |
73b08d2aa [PATCH] clocksour... |
32 |
.flags = CLOCK_SOURCE_IS_CONTINUOUS, |
5d0cf410e [PATCH] Time: i38... |
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
}; static int __init init_cyclone_clocksource(void) { unsigned long base; /* saved value from CBAR */ unsigned long offset; u32 __iomem* volatile cyclone_timer; /* Cyclone MPMC0 register */ u32 __iomem* reg; int i; /* make sure we're on a summit box: */ if (!use_cyclone) return -ENODEV; printk(KERN_INFO "Summit chipset: Starting Cyclone Counter. "); /* find base address: */ offset = CYCLONE_CBAR_ADDR; reg = ioremap_nocache(offset, sizeof(reg)); if (!reg) { printk(KERN_ERR "Summit chipset: Could not find valid CBAR register. "); return -ENODEV; } /* even on 64bit systems, this is only 32bits: */ base = readl(reg); if (!base) { printk(KERN_ERR "Summit chipset: Could not find valid CBAR value. "); return -ENODEV; } iounmap(reg); /* setup PMCC: */ offset = base + CYCLONE_PMCC_OFFSET; reg = ioremap_nocache(offset, sizeof(reg)); if (!reg) { printk(KERN_ERR "Summit chipset: Could not find valid PMCC register. "); return -ENODEV; } writel(0x00000001,reg); iounmap(reg); /* setup MPCS: */ offset = base + CYCLONE_MPCS_OFFSET; reg = ioremap_nocache(offset, sizeof(reg)); if (!reg) { printk(KERN_ERR "Summit chipset: Could not find valid MPCS register. "); return -ENODEV; } writel(0x00000001,reg); iounmap(reg); /* map in cyclone_timer: */ offset = base + CYCLONE_MPMC_OFFSET; cyclone_timer = ioremap_nocache(offset, sizeof(u64)); if (!cyclone_timer) { printk(KERN_ERR "Summit chipset: Could not find valid MPMC register. "); return -ENODEV; } /* quick test to make sure its ticking: */ for (i = 0; i < 3; i++){ u32 old = readl(cyclone_timer); int stall = 100; while (stall--) barrier(); if (readl(cyclone_timer) == old) { printk(KERN_ERR "Summit chipset: Counter not counting! DISABLED "); iounmap(cyclone_timer); cyclone_timer = NULL; return -ENODEV; } } cyclone_ptr = cyclone_timer; /* sort out mult/shift values: */ clocksource_cyclone.shift = 22; clocksource_cyclone.mult = clocksource_hz2mult(CYCLONE_TIMER_FREQ, clocksource_cyclone.shift); |
a27525497 [PATCH] time: ren... |
120 |
return clocksource_register(&clocksource_cyclone); |
5d0cf410e [PATCH] Time: i38... |
121 |
} |
6bb74df48 [PATCH] clocksour... |
122 |
arch_initcall(init_cyclone_clocksource); |