1 // SPDX-License-Identifier: GPL-2.0-only
3 * linux/arch/arm/mach-pxa/viper.c
5 * Support for the Arcom VIPER SBC.
8 * Created: Feb 03, 2003
9 * Copyright: Arcom Control Systems
11 * Maintained by Marc Zyngier <maz@misterjones.org>
12 * <marc.zyngier@altran.com>
15 * Author: Nicolas Pitre
16 * Created: Jun 15, 2001
17 * Copyright: MontaVista Software Inc.
20 #include <linux/types.h>
21 #include <linux/memory.h>
22 #include <linux/cpu.h>
23 #include <linux/cpufreq.h>
24 #include <linux/delay.h>
26 #include <linux/init.h>
27 #include <linux/slab.h>
28 #include <linux/interrupt.h>
29 #include <linux/major.h>
30 #include <linux/module.h>
32 #include <linux/sched.h>
33 #include <linux/gpio.h>
34 #include <linux/jiffies.h>
35 #include <linux/platform_data/i2c-gpio.h>
36 #include <linux/gpio/machine.h>
37 #include <linux/platform_data/i2c-pxa.h>
38 #include <linux/serial_8250.h>
39 #include <linux/smc91x.h>
40 #include <linux/pwm.h>
41 #include <linux/pwm_backlight.h>
42 #include <linux/usb/isp116x.h>
43 #include <linux/mtd/mtd.h>
44 #include <linux/mtd/partitions.h>
45 #include <linux/mtd/physmap.h>
46 #include <linux/syscore_ops.h>
49 #include <mach/audio.h>
50 #include <linux/platform_data/video-pxafb.h>
51 #include <mach/regs-uart.h>
52 #include <linux/platform_data/pcmcia-pxa2xx_viper.h>
55 #include <asm/setup.h>
56 #include <asm/mach-types.h>
58 #include <linux/sizes.h>
59 #include <asm/system_info.h>
61 #include <asm/mach/arch.h>
62 #include <asm/mach/map.h>
63 #include <asm/mach/irq.h>
68 static unsigned int icr
;
70 static void viper_icr_set_bit(unsigned int bit
)
76 static void viper_icr_clear_bit(unsigned int bit
)
82 /* This function is used from the pcmcia module to reset the CF */
83 static void viper_cf_reset(int state
)
86 viper_icr_set_bit(VIPER_ICR_CF_RST
);
88 viper_icr_clear_bit(VIPER_ICR_CF_RST
);
91 static struct arcom_pcmcia_pdata viper_pcmcia_info
= {
92 .cd_gpio
= VIPER_CF_CD_GPIO
,
93 .rdy_gpio
= VIPER_CF_RDY_GPIO
,
94 .pwr_gpio
= VIPER_CF_POWER_GPIO
,
95 .reset
= viper_cf_reset
,
98 static struct platform_device viper_pcmcia_device
= {
99 .name
= "viper-pcmcia",
102 .platform_data
= &viper_pcmcia_info
,
107 * The CPLD version register was not present on VIPER boards prior to
108 * v2i1. On v1 boards where the version register is not present we
109 * will just read back the previous value from the databus.
111 * Therefore we do two reads. The first time we write 0 to the
112 * (read-only) register before reading and the second time we write
113 * 0xff first. If the two reads do not match or they read back as 0xff
114 * or 0x00 then we have version 1 hardware.
116 static u8
viper_hw_version(void)
121 local_irq_save(flags
);
125 VIPER_VERSION
= 0xff;
128 v1
= (v1
!= v2
|| v1
== 0xff) ? 0 : v1
;
130 local_irq_restore(flags
);
134 /* CPU system core operations. */
135 static int viper_cpu_suspend(void)
137 viper_icr_set_bit(VIPER_ICR_R_DIS
);
141 static void viper_cpu_resume(void)
143 viper_icr_clear_bit(VIPER_ICR_R_DIS
);
146 static struct syscore_ops viper_cpu_syscore_ops
= {
147 .suspend
= viper_cpu_suspend
,
148 .resume
= viper_cpu_resume
,
151 static unsigned int current_voltage_divisor
;
154 * If force is not true then step from existing to new divisor. If
155 * force is true then jump straight to the new divisor. Stepping is
156 * used because if the jump in voltage is too large, the VCC can dip
157 * too low and the regulator cuts out.
159 * force can be used to initialize the divisor to a know state by
160 * setting the value for the current clock speed, since we are already
161 * running at that speed we know the voltage should be pretty close so
162 * the jump won't be too large
164 static void viper_set_core_cpu_voltage(unsigned long khz
, int force
)
167 unsigned int divisor
= 0;
171 v
= "1.0"; divisor
= 0xfff;
172 } else if (khz
< 300000) {
173 v
= "1.1"; divisor
= 0xde5;
175 v
= "1.3"; divisor
= 0x325;
178 pr_debug("viper: setting CPU core voltage to %sV at %d.%03dMHz\n",
179 v
, (int)khz
/ 1000, (int)khz
% 1000);
187 else if (current_voltage_divisor
< divisor
- STEP
)
188 step
= current_voltage_divisor
+ STEP
;
189 else if (current_voltage_divisor
> divisor
+ STEP
)
190 step
= current_voltage_divisor
- STEP
;
195 gpio_set_value(VIPER_PSU_CLK_GPIO
, 0);
196 gpio_set_value(VIPER_PSU_nCS_LD_GPIO
, 0);
198 for (i
= 1 << 11 ; i
> 0 ; i
>>= 1) {
201 gpio_set_value(VIPER_PSU_DATA_GPIO
, step
& i
);
204 gpio_set_value(VIPER_PSU_CLK_GPIO
, 1);
207 gpio_set_value(VIPER_PSU_CLK_GPIO
, 0);
211 gpio_set_value(VIPER_PSU_nCS_LD_GPIO
, 1);
214 gpio_set_value(VIPER_PSU_nCS_LD_GPIO
, 0);
216 current_voltage_divisor
= step
;
217 } while (current_voltage_divisor
!= divisor
);
220 /* Interrupt handling */
221 static unsigned long viper_irq_enabled_mask
;
222 static const int viper_isa_irqs
[] = { 3, 4, 5, 6, 7, 10, 11, 12, 9, 14, 15 };
223 static const int viper_isa_irq_map
[] = {
224 0, /* ISA irq #0, invalid */
225 0, /* ISA irq #1, invalid */
226 0, /* ISA irq #2, invalid */
227 1 << 0, /* ISA irq #3 */
228 1 << 1, /* ISA irq #4 */
229 1 << 2, /* ISA irq #5 */
230 1 << 3, /* ISA irq #6 */
231 1 << 4, /* ISA irq #7 */
232 0, /* ISA irq #8, invalid */
233 1 << 8, /* ISA irq #9 */
234 1 << 5, /* ISA irq #10 */
235 1 << 6, /* ISA irq #11 */
236 1 << 7, /* ISA irq #12 */
237 0, /* ISA irq #13, invalid */
238 1 << 9, /* ISA irq #14 */
239 1 << 10, /* ISA irq #15 */
242 static inline int viper_irq_to_bitmask(unsigned int irq
)
244 return viper_isa_irq_map
[irq
- PXA_ISA_IRQ(0)];
247 static inline int viper_bit_to_irq(int bit
)
249 return viper_isa_irqs
[bit
] + PXA_ISA_IRQ(0);
252 static void viper_ack_irq(struct irq_data
*d
)
254 int viper_irq
= viper_irq_to_bitmask(d
->irq
);
256 if (viper_irq
& 0xff)
257 VIPER_LO_IRQ_STATUS
= viper_irq
;
259 VIPER_HI_IRQ_STATUS
= (viper_irq
>> 8);
262 static void viper_mask_irq(struct irq_data
*d
)
264 viper_irq_enabled_mask
&= ~(viper_irq_to_bitmask(d
->irq
));
267 static void viper_unmask_irq(struct irq_data
*d
)
269 viper_irq_enabled_mask
|= viper_irq_to_bitmask(d
->irq
);
272 static inline unsigned long viper_irq_pending(void)
274 return (VIPER_HI_IRQ_STATUS
<< 8 | VIPER_LO_IRQ_STATUS
) &
275 viper_irq_enabled_mask
;
278 static void viper_irq_handler(struct irq_desc
*desc
)
281 unsigned long pending
;
283 pending
= viper_irq_pending();
285 /* we're in a chained irq handler,
286 * so ack the interrupt by hand */
287 desc
->irq_data
.chip
->irq_ack(&desc
->irq_data
);
289 if (likely(pending
)) {
290 irq
= viper_bit_to_irq(__ffs(pending
));
291 generic_handle_irq(irq
);
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
,
316 irq_clear_status_flags(isa_irq
, IRQ_NOREQUEST
| IRQ_NOPROBE
);
319 irq_set_chained_handler(gpio_to_irq(VIPER_CPLD_GPIO
),
321 irq_set_irq_type(gpio_to_irq(VIPER_CPLD_GPIO
), IRQ_TYPE_EDGE_BOTH
);
325 static struct pxafb_mode_info fb_mode_info
[] = {
346 static struct pxafb_mach_info fb_info
= {
347 .modes
= fb_mode_info
,
349 .lcd_conn
= LCD_COLOR_TFT_16BPP
| LCD_PCLK_EDGE_FALL
,
352 static struct pwm_lookup viper_pwm_lookup
[] = {
353 PWM_LOOKUP("pxa25x-pwm.0", 0, "pwm-backlight.0", NULL
, 1000000,
354 PWM_POLARITY_NORMAL
),
357 static int viper_backlight_init(struct device
*dev
)
361 /* GPIO9 and 10 control FB backlight. Initialise to off */
362 ret
= gpio_request(VIPER_BCKLIGHT_EN_GPIO
, "Backlight");
364 goto err_request_bckl
;
366 ret
= gpio_request(VIPER_LCD_EN_GPIO
, "LCD");
368 goto err_request_lcd
;
370 ret
= gpio_direction_output(VIPER_BCKLIGHT_EN_GPIO
, 0);
374 ret
= gpio_direction_output(VIPER_LCD_EN_GPIO
, 0);
381 gpio_free(VIPER_LCD_EN_GPIO
);
383 gpio_free(VIPER_BCKLIGHT_EN_GPIO
);
385 dev_err(dev
, "Failed to setup LCD GPIOs\n");
390 static int viper_backlight_notify(struct device
*dev
, int brightness
)
392 gpio_set_value(VIPER_LCD_EN_GPIO
, !!brightness
);
393 gpio_set_value(VIPER_BCKLIGHT_EN_GPIO
, !!brightness
);
398 static void viper_backlight_exit(struct device
*dev
)
400 gpio_free(VIPER_LCD_EN_GPIO
);
401 gpio_free(VIPER_BCKLIGHT_EN_GPIO
);
404 static struct platform_pwm_backlight_data viper_backlight_data
= {
405 .max_brightness
= 100,
406 .dft_brightness
= 100,
407 .init
= viper_backlight_init
,
408 .notify
= viper_backlight_notify
,
409 .exit
= viper_backlight_exit
,
412 static struct platform_device viper_backlight_device
= {
413 .name
= "pwm-backlight",
415 .parent
= &pxa25x_device_pwm0
.dev
,
416 .platform_data
= &viper_backlight_data
,
421 static struct resource smc91x_resources
[] = {
423 .name
= "smc91x-regs",
424 .start
= VIPER_ETH_PHYS
+ 0x300,
425 .end
= VIPER_ETH_PHYS
+ 0x30f,
426 .flags
= IORESOURCE_MEM
,
429 .start
= PXA_GPIO_TO_IRQ(VIPER_ETH_GPIO
),
430 .end
= PXA_GPIO_TO_IRQ(VIPER_ETH_GPIO
),
431 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_HIGHEDGE
,
434 .name
= "smc91x-data32",
435 .start
= VIPER_ETH_DATA_PHYS
,
436 .end
= VIPER_ETH_DATA_PHYS
+ 3,
437 .flags
= IORESOURCE_MEM
,
441 static struct smc91x_platdata viper_smc91x_info
= {
442 .flags
= SMC91X_USE_16BIT
| SMC91X_NOWAIT
,
443 .leda
= RPC_LED_100_10
,
444 .ledb
= RPC_LED_TX_RX
,
447 static struct platform_device smc91x_device
= {
450 .num_resources
= ARRAY_SIZE(smc91x_resources
),
451 .resource
= smc91x_resources
,
453 .platform_data
= &viper_smc91x_info
,
458 static struct gpiod_lookup_table viper_i2c_gpiod_table
= {
459 .dev_id
= "i2c-gpio.1",
461 GPIO_LOOKUP_IDX("gpio-pxa", VIPER_RTC_I2C_SDA_GPIO
,
462 NULL
, 0, GPIO_ACTIVE_HIGH
| GPIO_OPEN_DRAIN
),
463 GPIO_LOOKUP_IDX("gpio-pxa", VIPER_RTC_I2C_SCL_GPIO
,
464 NULL
, 1, GPIO_ACTIVE_HIGH
| GPIO_OPEN_DRAIN
),
468 static struct i2c_gpio_platform_data i2c_bus_data
= {
473 static struct platform_device i2c_bus_device
= {
475 .id
= 1, /* pxa2xx-i2c is bus 0, so start at 1 */
477 .platform_data
= &i2c_bus_data
,
481 static struct i2c_board_info __initdata viper_i2c_devices
[] = {
483 I2C_BOARD_INFO("ds1338", 0x68),
488 * Serial configuration:
489 * You can either have the standard PXA ports driven by the PXA driver,
490 * or all the ports (PXA + 16850) driven by the 8250 driver.
491 * Choose your poison.
494 static struct resource viper_serial_resources
[] = {
495 #ifndef CONFIG_SERIAL_PXA
499 .flags
= IORESOURCE_MEM
,
504 .flags
= IORESOURCE_MEM
,
509 .flags
= IORESOURCE_MEM
,
512 .start
= VIPER_UARTA_PHYS
,
513 .end
= VIPER_UARTA_PHYS
+ 0xf,
514 .flags
= IORESOURCE_MEM
,
517 .start
= VIPER_UARTB_PHYS
,
518 .end
= VIPER_UARTB_PHYS
+ 0xf,
519 .flags
= IORESOURCE_MEM
,
528 static struct plat_serial8250_port serial_platform_data
[] = {
529 #ifndef CONFIG_SERIAL_PXA
532 .membase
= (void *)&FFUART
,
533 .mapbase
= __PREG(FFUART
),
535 .uartclk
= 921600 * 16,
537 .flags
= UPF_BOOT_AUTOCONF
| UPF_SKIP_TEST
,
541 .membase
= (void *)&BTUART
,
542 .mapbase
= __PREG(BTUART
),
544 .uartclk
= 921600 * 16,
546 .flags
= UPF_BOOT_AUTOCONF
| UPF_SKIP_TEST
,
550 .membase
= (void *)&STUART
,
551 .mapbase
= __PREG(STUART
),
553 .uartclk
= 921600 * 16,
555 .flags
= UPF_BOOT_AUTOCONF
| UPF_SKIP_TEST
,
560 .mapbase
= VIPER_UARTA_PHYS
,
561 .irq
= PXA_GPIO_TO_IRQ(VIPER_UARTA_GPIO
),
562 .irqflags
= IRQF_TRIGGER_RISING
,
566 .flags
= UPF_BOOT_AUTOCONF
| UPF_IOREMAP
|
570 .mapbase
= VIPER_UARTB_PHYS
,
571 .irq
= PXA_GPIO_TO_IRQ(VIPER_UARTB_GPIO
),
572 .irqflags
= IRQF_TRIGGER_RISING
,
576 .flags
= UPF_BOOT_AUTOCONF
| UPF_IOREMAP
|
583 static struct platform_device serial_device
= {
584 .name
= "serial8250",
587 .platform_data
= serial_platform_data
,
589 .num_resources
= ARRAY_SIZE(viper_serial_resources
),
590 .resource
= viper_serial_resources
,
594 static void isp116x_delay(struct device
*dev
, int delay
)
599 static struct resource isp116x_resources
[] = {
601 .start
= VIPER_USB_PHYS
+ 0,
602 .end
= VIPER_USB_PHYS
+ 1,
603 .flags
= IORESOURCE_MEM
,
606 .start
= VIPER_USB_PHYS
+ 2,
607 .end
= VIPER_USB_PHYS
+ 3,
608 .flags
= IORESOURCE_MEM
,
611 .start
= PXA_GPIO_TO_IRQ(VIPER_USB_GPIO
),
612 .end
= PXA_GPIO_TO_IRQ(VIPER_USB_GPIO
),
613 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_HIGHEDGE
,
617 /* (DataBusWidth16|AnalogOCEnable|DREQOutputPolarity|DownstreamPort15KRSel ) */
618 static struct isp116x_platform_data isp116x_platform_data
= {
619 /* Enable internal resistors on downstream ports */
621 /* On-chip overcurrent protection */
623 /* INT output polarity */
625 /* INT edge or level triggered */
626 .int_edge_triggered
= 0,
628 /* WAKEUP pin connected - NOT SUPPORTED */
629 /* .remote_wakeup_connected = 0, */
630 /* Wakeup by devices on usb bus enabled */
631 .remote_wakeup_enable
= 0,
632 .delay
= isp116x_delay
,
635 static struct platform_device isp116x_device
= {
636 .name
= "isp116x-hcd",
638 .num_resources
= ARRAY_SIZE(isp116x_resources
),
639 .resource
= isp116x_resources
,
641 .platform_data
= &isp116x_platform_data
,
647 static struct resource mtd_resources
[] = {
648 [0] = { /* RedBoot config + filesystem flash */
649 .start
= VIPER_FLASH_PHYS
,
650 .end
= VIPER_FLASH_PHYS
+ SZ_32M
- 1,
651 .flags
= IORESOURCE_MEM
,
653 [1] = { /* Boot flash */
654 .start
= VIPER_BOOT_PHYS
,
655 .end
= VIPER_BOOT_PHYS
+ SZ_1M
- 1,
656 .flags
= IORESOURCE_MEM
,
659 * SRAM size is actually 256KB, 8bits, with a sparse mapping
660 * (each byte is on a 16bit boundary).
662 .start
= _VIPER_SRAM_BASE
,
663 .end
= _VIPER_SRAM_BASE
+ SZ_512K
- 1,
664 .flags
= IORESOURCE_MEM
,
668 static struct mtd_partition viper_boot_flash_partition
= {
672 .mask_flags
= MTD_WRITEABLE
, /* force R/O */
675 static struct physmap_flash_data viper_flash_data
[] = {
683 .parts
= &viper_boot_flash_partition
,
688 static struct platform_device viper_mtd_devices
[] = {
690 .name
= "physmap-flash",
693 .platform_data
= &viper_flash_data
[0],
695 .resource
= &mtd_resources
[0],
699 .name
= "physmap-flash",
702 .platform_data
= &viper_flash_data
[1],
704 .resource
= &mtd_resources
[1],
709 static struct platform_device
*viper_devs
[] __initdata
= {
714 &viper_mtd_devices
[0],
715 &viper_mtd_devices
[1],
716 &viper_backlight_device
,
717 &viper_pcmcia_device
,
720 static mfp_cfg_t viper_pin_config
[] __initdata
= {
730 GPIO29_AC97_SDATA_IN_0
,
731 GPIO30_AC97_SDATA_OUT
,
735 GPIO9_GPIO
, /* VIPER_BCKLIGHT_EN_GPIO */
736 GPIO10_GPIO
, /* VIPER_LCD_EN_GPIO */
739 /* Ethernet PHY Ready */
742 /* Serial shutdown */
743 GPIO12_GPIO
| MFP_LPM_DRIVE_HIGH
, /* VIPER_UART_SHDN_GPIO */
745 /* Compact-Flash / PC104 */
756 GPIO8_GPIO
, /* VIPER_CF_RDY_GPIO */
757 GPIO32_GPIO
, /* VIPER_CF_CD_GPIO */
758 GPIO82_GPIO
, /* VIPER_CF_POWER_GPIO */
760 /* Integrated UPS control */
761 GPIO20_GPIO
, /* VIPER_UPS_GPIO */
763 /* Vcc regulator control */
764 GPIO6_GPIO
, /* VIPER_PSU_DATA_GPIO */
765 GPIO11_GPIO
, /* VIPER_PSU_CLK_GPIO */
766 GPIO19_GPIO
, /* VIPER_PSU_nCS_LD_GPIO */
769 GPIO26_GPIO
, /* VIPER_TPM_I2C_SDA_GPIO */
770 GPIO27_GPIO
, /* VIPER_TPM_I2C_SCL_GPIO */
771 GPIO83_GPIO
, /* VIPER_RTC_I2C_SDA_GPIO */
772 GPIO84_GPIO
, /* VIPER_RTC_I2C_SCL_GPIO */
774 /* PC/104 Interrupt */
775 GPIO1_GPIO
| WAKEUP_ON_EDGE_RISE
, /* VIPER_CPLD_GPIO */
778 static unsigned long viper_tpm
;
780 static int __init
viper_tpm_setup(char *str
)
782 return kstrtoul(str
, 10, &viper_tpm
) >= 0;
785 __setup("tpm=", viper_tpm_setup
);
787 struct gpiod_lookup_table viper_tpm_i2c_gpiod_table
= {
788 .dev_id
= "i2c-gpio.2",
790 GPIO_LOOKUP_IDX("gpio-pxa", VIPER_TPM_I2C_SDA_GPIO
,
791 NULL
, 0, GPIO_ACTIVE_HIGH
| GPIO_OPEN_DRAIN
),
792 GPIO_LOOKUP_IDX("gpio-pxa", VIPER_TPM_I2C_SCL_GPIO
,
793 NULL
, 1, GPIO_ACTIVE_HIGH
| GPIO_OPEN_DRAIN
),
797 static void __init
viper_tpm_init(void)
799 struct platform_device
*tpm_device
;
800 struct i2c_gpio_platform_data i2c_tpm_data
= {
806 /* Allocate TPM i2c bus if requested */
810 gpiod_add_lookup_table(&viper_tpm_i2c_gpiod_table
);
811 tpm_device
= platform_device_alloc("i2c-gpio", 2);
813 if (!platform_device_add_data(tpm_device
,
815 sizeof(i2c_tpm_data
))) {
816 if (platform_device_add(tpm_device
)) {
817 errstr
= "register TPM i2c bus";
821 errstr
= "allocate TPM i2c bus data";
825 errstr
= "allocate TPM i2c device";
834 pr_err("viper: Couldn't %s, giving up\n", errstr
);
837 static void __init
viper_init_vcore_gpios(void)
839 if (gpio_request(VIPER_PSU_DATA_GPIO
, "PSU data"))
840 goto err_request_data
;
842 if (gpio_request(VIPER_PSU_CLK_GPIO
, "PSU clock"))
843 goto err_request_clk
;
845 if (gpio_request(VIPER_PSU_nCS_LD_GPIO
, "PSU cs"))
848 if (gpio_direction_output(VIPER_PSU_DATA_GPIO
, 0) ||
849 gpio_direction_output(VIPER_PSU_CLK_GPIO
, 0) ||
850 gpio_direction_output(VIPER_PSU_nCS_LD_GPIO
, 0))
853 /* c/should assume redboot set the correct level ??? */
854 viper_set_core_cpu_voltage(get_clk_frequency_khz(0), 1);
859 gpio_free(VIPER_PSU_nCS_LD_GPIO
);
861 gpio_free(VIPER_PSU_CLK_GPIO
);
863 gpio_free(VIPER_PSU_DATA_GPIO
);
865 pr_err("viper: Failed to setup vcore control GPIOs\n");
868 static void __init
viper_init_serial_gpio(void)
870 if (gpio_request(VIPER_UART_SHDN_GPIO
, "UARTs shutdown"))
873 if (gpio_direction_output(VIPER_UART_SHDN_GPIO
, 0))
879 gpio_free(VIPER_UART_SHDN_GPIO
);
881 pr_err("viper: Failed to setup UART shutdown GPIO\n");
884 #ifdef CONFIG_CPU_FREQ
885 static int viper_cpufreq_notifier(struct notifier_block
*nb
,
886 unsigned long val
, void *data
)
888 struct cpufreq_freqs
*freq
= data
;
890 /* TODO: Adjust timings??? */
893 case CPUFREQ_PRECHANGE
:
894 if (freq
->old
< freq
->new) {
895 /* we are getting faster so raise the voltage
896 * before we change freq */
897 viper_set_core_cpu_voltage(freq
->new, 0);
900 case CPUFREQ_POSTCHANGE
:
901 if (freq
->old
> freq
->new) {
902 /* we are slowing down so drop the power
903 * after we change freq */
904 viper_set_core_cpu_voltage(freq
->new, 0);
915 static struct notifier_block viper_cpufreq_notifier_block
= {
916 .notifier_call
= viper_cpufreq_notifier
919 static void __init
viper_init_cpufreq(void)
921 if (cpufreq_register_notifier(&viper_cpufreq_notifier_block
,
922 CPUFREQ_TRANSITION_NOTIFIER
))
923 pr_err("viper: Failed to setup cpufreq notifier\n");
926 static inline void viper_init_cpufreq(void) {}
929 static void viper_power_off(void)
931 pr_notice("Shutting off UPS\n");
932 gpio_set_value(VIPER_UPS_GPIO
, 1);
933 /* Spin to death... */
937 static void __init
viper_init(void)
941 pm_power_off
= viper_power_off
;
943 pxa2xx_mfp_config(ARRAY_AND_SIZE(viper_pin_config
));
945 pxa_set_ffuart_info(NULL
);
946 pxa_set_btuart_info(NULL
);
947 pxa_set_stuart_info(NULL
);
949 /* Wake-up serial console */
950 viper_init_serial_gpio();
952 pxa_set_fb_info(NULL
, &fb_info
);
954 /* v1 hardware cannot use the datacs line */
955 version
= viper_hw_version();
957 smc91x_device
.num_resources
--;
959 pxa_set_i2c_info(NULL
);
960 gpiod_add_lookup_table(&viper_i2c_gpiod_table
);
961 pwm_add_table(viper_pwm_lookup
, ARRAY_SIZE(viper_pwm_lookup
));
962 platform_add_devices(viper_devs
, ARRAY_SIZE(viper_devs
));
964 viper_init_vcore_gpios();
965 viper_init_cpufreq();
967 register_syscore_ops(&viper_cpu_syscore_ops
);
970 pr_info("viper: hardware v%di%d detected. "
971 "CPLD revision %d.\n",
972 VIPER_BOARD_VERSION(version
),
973 VIPER_BOARD_ISSUE(version
),
974 VIPER_CPLD_REVISION(version
));
975 system_rev
= (VIPER_BOARD_VERSION(version
) << 8) |
976 (VIPER_BOARD_ISSUE(version
) << 4) |
977 VIPER_CPLD_REVISION(version
);
979 pr_info("viper: No version register.\n");
982 i2c_register_board_info(1, ARRAY_AND_SIZE(viper_i2c_devices
));
985 pxa_set_ac97_info(NULL
);
988 static struct map_desc viper_io_desc
[] __initdata
= {
990 .virtual = VIPER_CPLD_BASE
,
991 .pfn
= __phys_to_pfn(VIPER_CPLD_PHYS
),
992 .length
= 0x00300000,
996 .virtual = VIPER_PC104IO_BASE
,
997 .pfn
= __phys_to_pfn(0x30000000),
998 .length
= 0x00800000,
1003 static void __init
viper_map_io(void)
1007 iotable_init(viper_io_desc
, ARRAY_SIZE(viper_io_desc
));
1012 MACHINE_START(VIPER
, "Arcom/Eurotech VIPER SBC")
1013 /* Maintainer: Marc Zyngier <maz@misterjones.org> */
1014 .atag_offset
= 0x100,
1015 .map_io
= viper_map_io
,
1016 .nr_irqs
= PXA_NR_IRQS
,
1017 .init_irq
= viper_init_irq
,
1018 .handle_irq
= pxa25x_handle_irq
,
1019 .init_time
= pxa_timer_init
,
1020 .init_machine
= viper_init
,
1021 .restart
= pxa_restart
,