23 #include <linux/types.h>
30 #include <linux/slab.h>
33 #include <linux/module.h>
35 #include <linux/sched.h>
52 #include <mach/regs-uart.h>
56 #include <asm/setup.h>
59 #include <asm/sizes.h>
69 static unsigned int icr;
71 static void viper_icr_set_bit(
unsigned int bit)
77 static void viper_icr_clear_bit(
unsigned int bit)
84 static void viper_cf_reset(
int state)
96 .reset = viper_cf_reset,
100 .name =
"viper-pcmcia",
103 .platform_data = &viper_pcmcia_info,
117 static u8 viper_hw_version(
void)
129 v1 = (v1 != v2 || v1 == 0xff) ? 0 : v1;
136 static int viper_cpu_suspend(
void)
142 static void viper_cpu_resume(
void)
147 static struct syscore_ops viper_cpu_syscore_ops = {
148 .suspend = viper_cpu_suspend,
149 .resume = viper_cpu_resume,
152 static unsigned int current_voltage_divisor;
165 static void viper_set_core_cpu_voltage(
unsigned long khz,
int force)
172 v =
"1.0"; divisor = 0xfff;
173 }
else if (khz < 300000) {
174 v =
"1.1"; divisor = 0xde5;
176 v =
"1.3"; divisor = 0x325;
179 pr_debug(
"viper: setting CPU core voltage to %sV at %d.%03dMHz\n",
180 v, (
int)khz / 1000, (
int)khz % 1000);
188 else if (current_voltage_divisor < divisor - STEP)
189 step = current_voltage_divisor +
STEP;
190 else if (current_voltage_divisor > divisor + STEP)
191 step = current_voltage_divisor - STEP;
199 for (i = 1 << 11 ; i > 0 ; i >>= 1) {
217 current_voltage_divisor =
step;
218 }
while (current_voltage_divisor != divisor);
222 static unsigned long viper_irq_enabled_mask;
223 static const int viper_isa_irqs[] = { 3, 4, 5, 6, 7, 10, 11, 12, 9, 14, 15 };
224 static const int viper_isa_irq_map[] = {
243 static inline int viper_irq_to_bitmask(
unsigned int irq)
245 return viper_isa_irq_map[irq - PXA_ISA_IRQ(0)];
248 static inline int viper_bit_to_irq(
int bit)
250 return viper_isa_irqs[
bit] + PXA_ISA_IRQ(0);
253 static void viper_ack_irq(
struct irq_data *
d)
255 int viper_irq = viper_irq_to_bitmask(d->
irq);
257 if (viper_irq & 0xff)
263 static void viper_mask_irq(
struct irq_data *d)
265 viper_irq_enabled_mask &= ~(viper_irq_to_bitmask(d->
irq));
268 static void viper_unmask_irq(
struct irq_data *d)
270 viper_irq_enabled_mask |= viper_irq_to_bitmask(d->
irq);
273 static inline unsigned long viper_irq_pending(
void)
276 viper_irq_enabled_mask;
279 static void viper_irq_handler(
unsigned int irq,
struct irq_desc *
desc)
281 unsigned long pending;
283 pending = viper_irq_pending();
290 irq = viper_bit_to_irq(
__ffs(pending));
293 pending = viper_irq_pending();
297 static struct irq_chip viper_irq_chip = {
299 .irq_ack = viper_ack_irq,
300 .irq_mask = viper_mask_irq,
301 .irq_unmask = viper_unmask_irq
304 static void __init viper_init_irq(
void)
312 for (level = 0; level <
ARRAY_SIZE(viper_isa_irqs); level++) {
313 isa_irq = viper_bit_to_irq(level);
314 irq_set_chip_and_handler(isa_irq, &viper_irq_chip,
347 .modes = fb_mode_info,
352 static int viper_backlight_init(
struct device *
dev)
359 goto err_request_bckl;
363 goto err_request_lcd;
380 dev_err(dev,
"Failed to setup LCD GPIOs\n");
393 static void viper_backlight_exit(
struct device *dev)
401 .max_brightness = 100,
402 .dft_brightness = 100,
403 .pwm_period_ns = 1000000,
404 .init = viper_backlight_init,
405 .notify = viper_backlight_notify,
406 .exit = viper_backlight_exit,
410 .name =
"pwm-backlight",
413 .platform_data = &viper_backlight_data,
418 static struct resource smc91x_resources[] = {
420 .name =
"smc91x-regs",
431 .name =
"smc91x-data32",
447 .num_resources =
ARRAY_SIZE(smc91x_resources),
448 .resource = smc91x_resources,
450 .platform_data = &viper_smc91x_info,
466 .platform_data = &i2c_bus_data,
483 static struct resource viper_serial_resources[] = {
484 #ifndef CONFIG_SERIAL_PXA
518 #ifndef CONFIG_SERIAL_PXA
521 .membase = (
void *)&
FFUART,
524 .uartclk = 921600 * 16,
530 .membase = (
void *)&
BTUART,
533 .uartclk = 921600 * 16,
539 .membase = (
void *)&
STUART,
542 .uartclk = 921600 * 16,
573 .name =
"serial8250",
576 .platform_data = serial_platform_data,
578 .num_resources =
ARRAY_SIZE(viper_serial_resources),
579 .resource = viper_serial_resources,
588 static struct resource isp116x_resources[] = {
615 .int_edge_triggered = 0,
620 .remote_wakeup_enable = 0,
625 .name =
"isp116x-hcd",
627 .num_resources =
ARRAY_SIZE(isp116x_resources),
628 .resource = isp116x_resources,
630 .platform_data = &isp116x_platform_data,
636 static struct resource mtd_resources[] = {
672 .parts = &viper_boot_flash_partition,
679 .name =
"physmap-flash",
682 .platform_data = &viper_flash_data[0],
684 .resource = &mtd_resources[0],
688 .
name =
"physmap-flash",
691 .platform_data = &viper_flash_data[1],
693 .resource = &mtd_resources[1],
703 &viper_mtd_devices[0],
704 &viper_mtd_devices[1],
705 &viper_backlight_device,
706 &viper_pcmcia_device,
709 static mfp_cfg_t viper_pin_config[] __initdata = {
767 static unsigned long viper_tpm;
769 static int __init viper_tpm_setup(
char *
str)
774 __setup(
"tpm=", viper_tpm_setup);
776 static void __init viper_tpm_init(
void)
795 sizeof(i2c_tpm_data))) {
797 errstr =
"register TPM i2c bus";
801 errstr =
"allocate TPM i2c bus data";
805 errstr =
"allocate TPM i2c device";
814 pr_err(
"viper: Couldn't %s, giving up\n", errstr);
817 static void __init viper_init_vcore_gpios(
void)
820 goto err_request_data;
823 goto err_request_clk;
845 pr_err(
"viper: Failed to setup vcore control GPIOs\n");
848 static void __init viper_init_serial_gpio(
void)
861 pr_err(
"viper: Failed to setup UART shutdown GPIO\n");
864 #ifdef CONFIG_CPU_FREQ
874 if (freq->
old < freq->
new) {
877 viper_set_core_cpu_voltage(freq->
new, 0);
881 if (freq->
old > freq->
new) {
884 viper_set_core_cpu_voltage(freq->
new, 0);
888 viper_set_core_cpu_voltage(freq->
new, 0);
902 static void __init viper_init_cpufreq(
void)
906 pr_err(
"viper: Failed to setup cpufreq notifier\n");
909 static inline void viper_init_cpufreq(
void) {}
912 static void viper_power_off(
void)
920 static void __init viper_init(
void)
933 viper_init_serial_gpio();
938 version = viper_hw_version();
945 viper_init_vcore_gpios();
946 viper_init_cpufreq();
951 pr_info(
"viper: hardware v%di%d detected. "
952 "CPLD revision %d.\n",
960 pr_info(
"viper: No version register.\n");
969 static struct map_desc viper_io_desc[] __initdata = {
973 .length = 0x00300000,
979 .length = 0x00800000,
984 static void __init viper_map_io(
void)
995 .atag_offset = 0x100,
996 .map_io = viper_map_io,
998 .init_irq = viper_init_irq,
1001 .init_machine = viper_init,