| .. | .. |
|---|
| 20 | 20 | #include <linux/delay.h> |
|---|
| 21 | 21 | #include <linux/platform_device.h> |
|---|
| 22 | 22 | |
|---|
| 23 | | -#include <asm/clock.h> |
|---|
| 24 | 23 | #include <asm/idle.h> |
|---|
| 25 | 24 | |
|---|
| 26 | | -#include <asm/mach-loongson64/loongson.h> |
|---|
| 25 | +#include <asm/mach-loongson2ef/loongson.h> |
|---|
| 27 | 26 | |
|---|
| 28 | 27 | static uint nowait; |
|---|
| 29 | 28 | |
|---|
| .. | .. |
|---|
| 58 | 57 | loongson2_clockmod_table[index].driver_data) / 8; |
|---|
| 59 | 58 | |
|---|
| 60 | 59 | /* setting the cpu frequency */ |
|---|
| 61 | | - clk_set_rate(policy->clk, freq * 1000); |
|---|
| 60 | + loongson2_cpu_set_rate(freq); |
|---|
| 62 | 61 | |
|---|
| 63 | 62 | return 0; |
|---|
| 64 | 63 | } |
|---|
| 65 | 64 | |
|---|
| 66 | 65 | static int loongson2_cpufreq_cpu_init(struct cpufreq_policy *policy) |
|---|
| 67 | 66 | { |
|---|
| 68 | | - struct clk *cpuclk; |
|---|
| 69 | 67 | int i; |
|---|
| 70 | 68 | unsigned long rate; |
|---|
| 71 | 69 | int ret; |
|---|
| 72 | 70 | |
|---|
| 73 | | - cpuclk = clk_get(NULL, "cpu_clk"); |
|---|
| 74 | | - if (IS_ERR(cpuclk)) { |
|---|
| 75 | | - pr_err("couldn't get CPU clk\n"); |
|---|
| 76 | | - return PTR_ERR(cpuclk); |
|---|
| 77 | | - } |
|---|
| 78 | | - |
|---|
| 79 | 71 | rate = cpu_clock_freq / 1000; |
|---|
| 80 | | - if (!rate) { |
|---|
| 81 | | - clk_put(cpuclk); |
|---|
| 72 | + if (!rate) |
|---|
| 82 | 73 | return -EINVAL; |
|---|
| 83 | | - } |
|---|
| 84 | 74 | |
|---|
| 85 | 75 | /* clock table init */ |
|---|
| 86 | 76 | for (i = 2; |
|---|
| .. | .. |
|---|
| 88 | 78 | i++) |
|---|
| 89 | 79 | loongson2_clockmod_table[i].frequency = (rate * i) / 8; |
|---|
| 90 | 80 | |
|---|
| 91 | | - ret = clk_set_rate(cpuclk, rate * 1000); |
|---|
| 92 | | - if (ret) { |
|---|
| 93 | | - clk_put(cpuclk); |
|---|
| 81 | + ret = loongson2_cpu_set_rate(rate); |
|---|
| 82 | + if (ret) |
|---|
| 94 | 83 | return ret; |
|---|
| 95 | | - } |
|---|
| 96 | 84 | |
|---|
| 97 | | - policy->clk = cpuclk; |
|---|
| 98 | | - return cpufreq_generic_init(policy, &loongson2_clockmod_table[0], 0); |
|---|
| 85 | + cpufreq_generic_init(policy, &loongson2_clockmod_table[0], 0); |
|---|
| 86 | + return 0; |
|---|
| 99 | 87 | } |
|---|
| 100 | 88 | |
|---|
| 101 | 89 | static int loongson2_cpufreq_exit(struct cpufreq_policy *policy) |
|---|
| 102 | 90 | { |
|---|
| 103 | | - clk_put(policy->clk); |
|---|
| 104 | 91 | return 0; |
|---|
| 105 | 92 | } |
|---|
| 106 | 93 | |
|---|
| .. | .. |
|---|
| 143 | 130 | u32 cpu_freq; |
|---|
| 144 | 131 | |
|---|
| 145 | 132 | spin_lock_irqsave(&loongson2_wait_lock, flags); |
|---|
| 146 | | - cpu_freq = LOONGSON_CHIPCFG(0); |
|---|
| 147 | | - LOONGSON_CHIPCFG(0) &= ~0x7; /* Put CPU into wait mode */ |
|---|
| 148 | | - LOONGSON_CHIPCFG(0) = cpu_freq; /* Restore CPU state */ |
|---|
| 133 | + cpu_freq = readl(LOONGSON_CHIPCFG); |
|---|
| 134 | + /* Put CPU into wait mode */ |
|---|
| 135 | + writel(readl(LOONGSON_CHIPCFG) & ~0x7, LOONGSON_CHIPCFG); |
|---|
| 136 | + /* Restore CPU state */ |
|---|
| 137 | + writel(cpu_freq, LOONGSON_CHIPCFG); |
|---|
| 149 | 138 | spin_unlock_irqrestore(&loongson2_wait_lock, flags); |
|---|
| 150 | 139 | local_irq_enable(); |
|---|
| 151 | 140 | } |
|---|