123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- /*
- * linux/arch/arm/mach-sa1100/generic.c
- *
- * Author: Nicolas Pitre
- *
- * Code common to all SA11x0 machines.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
- #include <linux/gpio.h>
- #include <linux/module.h>
- #include <linux/kernel.h>
- #include <linux/init.h>
- #include <linux/delay.h>
- #include <linux/dma-mapping.h>
- #include <linux/pm.h>
- #include <linux/cpufreq.h>
- #include <linux/ioport.h>
- #include <linux/platform_device.h>
- #include <video/sa1100fb.h>
- #include <asm/div64.h>
- #include <asm/mach/map.h>
- #include <asm/mach/flash.h>
- #include <asm/irq.h>
- #include <asm/system_misc.h>
- #include <mach/hardware.h>
- #include <mach/irqs.h>
- #include "generic.h"
- unsigned int reset_status;
- EXPORT_SYMBOL(reset_status);
- #define NR_FREQS 16
- /*
- * This table is setup for a 3.6864MHz Crystal.
- */
- static const unsigned short cclk_frequency_100khz[NR_FREQS] = {
- 590, /* 59.0 MHz */
- 737, /* 73.7 MHz */
- 885, /* 88.5 MHz */
- 1032, /* 103.2 MHz */
- 1180, /* 118.0 MHz */
- 1327, /* 132.7 MHz */
- 1475, /* 147.5 MHz */
- 1622, /* 162.2 MHz */
- 1769, /* 176.9 MHz */
- 1917, /* 191.7 MHz */
- 2064, /* 206.4 MHz */
- 2212, /* 221.2 MHz */
- 2359, /* 235.9 MHz */
- 2507, /* 250.7 MHz */
- 2654, /* 265.4 MHz */
- 2802 /* 280.2 MHz */
- };
- /* rounds up(!) */
- unsigned int sa11x0_freq_to_ppcr(unsigned int khz)
- {
- int i;
- khz /= 100;
- for (i = 0; i < NR_FREQS; i++)
- if (cclk_frequency_100khz[i] >= khz)
- break;
- return i;
- }
- unsigned int sa11x0_ppcr_to_freq(unsigned int idx)
- {
- unsigned int freq = 0;
- if (idx < NR_FREQS)
- freq = cclk_frequency_100khz[idx] * 100;
- return freq;
- }
- /* make sure that only the "userspace" governor is run -- anything else wouldn't make sense on
- * this platform, anyway.
- */
- int sa11x0_verify_speed(struct cpufreq_policy *policy)
- {
- unsigned int tmp;
- if (policy->cpu)
- return -EINVAL;
- cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq, policy->cpuinfo.max_freq);
- /* make sure that at least one frequency is within the policy */
- tmp = cclk_frequency_100khz[sa11x0_freq_to_ppcr(policy->min)] * 100;
- if (tmp > policy->max)
- policy->max = tmp;
- cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq, policy->cpuinfo.max_freq);
- return 0;
- }
- unsigned int sa11x0_getspeed(unsigned int cpu)
- {
- if (cpu)
- return 0;
- return cclk_frequency_100khz[PPCR & 0xf] * 100;
|