30 #include <linux/module.h>
31 #include <linux/kernel.h>
32 #include <linux/pci.h>
33 #include <linux/errno.h>
38 #define CRVML_DEVICE_MCH 0x5001
39 #define CRVML_REG_MCHBAR 0x44
40 #define CRVML_REG_MCHEN 0x54
41 #define CRVML_MCHEN_BIT (1 << 28)
42 #define CRVML_MCHMAP_SIZE 4096
43 #define CRVML_REG_CLOCK 0xc3c
44 #define CRVML_CLOCK_SHIFT 8
45 #define CRVML_CLOCK_MASK 0x00000f00
49 static void __iomem *mch_regs_base;
50 static u32 saved_clock;
52 static const unsigned crvml_clocks[] = {
67 static const u32 crvml_clock_bits[] = {
79 static const unsigned crvml_num_clocks =
ARRAY_SIZE(crvml_clocks);
81 static int crvml_sys_restore(
struct vml_sys *
sys)
107 cur_diff = clock - crvml_clocks[0];
108 cur_diff = (cur_diff < 0) ? -cur_diff : cur_diff;
109 for (i = 1; i < crvml_num_clocks; ++
i) {
110 diff = clock - crvml_clocks[
i];
111 diff = (diff < 0) ? -diff : diff;
112 if (diff < cur_diff) {
120 static int crvml_nearest_clock(
const struct vml_sys *sys,
int clock)
122 return crvml_clocks[crvml_nearest_index(sys, clock)];
125 static int crvml_set_clock(
struct vml_sys *sys,
int clock)
131 index = crvml_nearest_index(sys, clock);
133 if (crvml_clocks[index] != clock)
144 static struct vml_sys cr_pll_ops = {
145 .name =
"Carillo Ranch",
146 .save = crvml_sys_save,
147 .restore = crvml_sys_restore,
148 .set_clock = crvml_set_clock,
149 .nearest_clock = crvml_nearest_clock,
152 static int __init cr_pll_init(
void)
161 "Could not find Carillo Ranch MCH device.\n");
168 "Carillo Ranch MCH device was not enabled.\n");
177 if (!mch_regs_base) {
179 "Carillo Ranch MCH device was not enabled.\n");
187 "Carillo Ranch failed to initialize vml_sys.\n");
195 static void __exit cr_pll_exit(
void)