2 * linux/arch/arm/mach-versatile/core.c
4 * Copyright (C) 1999 - 2003 ARM Limited
5 * Copyright (C) 2000 Deep Blue Solutions Ltd
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include <linux/init.h>
22 #include <linux/device.h>
23 #include <linux/dma-mapping.h>
24 #include <linux/platform_device.h>
25 #include <linux/sysdev.h>
26 #include <linux/interrupt.h>
27 #include <linux/amba/bus.h>
28 #include <linux/amba/clcd.h>
29 #include <linux/amba/pl061.h>
30 #include <linux/amba/mmci.h>
31 #include <linux/amba/pl022.h>
33 #include <linux/gfp.h>
34 #include <linux/clkdev.h>
36 #include <asm/system.h>
39 #include <asm/hardware/arm_timer.h>
40 #include <asm/hardware/icst.h>
41 #include <asm/hardware/vic.h>
42 #include <asm/mach-types.h>
44 #include <asm/mach/arch.h>
45 #include <asm/mach/flash.h>
46 #include <asm/mach/irq.h>
47 #include <asm/mach/time.h>
48 #include <asm/mach/map.h>
49 #include <mach/hardware.h>
50 #include <mach/platform.h>
51 #include <asm/hardware/timer-sp.h>
53 #include <plat/sched_clock.h>
58 * All IO addresses are mapped onto VA 0xFFFx.xxxx, where x.xxxx
61 * Setup a VA for the Versatile Vectored Interrupt Controller.
63 #define VA_VIC_BASE __io_address(VERSATILE_VIC_BASE)
64 #define VA_SIC_BASE __io_address(VERSATILE_SIC_BASE)
66 static void sic_mask_irq(struct irq_data
*d
)
68 unsigned int irq
= d
->irq
- IRQ_SIC_START
;
70 writel(1 << irq
, VA_SIC_BASE
+ SIC_IRQ_ENABLE_CLEAR
);
73 static void sic_unmask_irq(struct irq_data
*d
)
75 unsigned int irq
= d
->irq
- IRQ_SIC_START
;
77 writel(1 << irq
, VA_SIC_BASE
+ SIC_IRQ_ENABLE_SET
);
80 static struct irq_chip sic_chip
= {
82 .irq_ack
= sic_mask_irq
,
83 .irq_mask
= sic_mask_irq
,
84 .irq_unmask
= sic_unmask_irq
,
88 sic_handle_irq(unsigned int irq
, struct irq_desc
*desc
)
90 unsigned long status
= readl(VA_SIC_BASE
+ SIC_IRQ_STATUS
);
93 do_bad_IRQ(irq
, desc
);
98 irq
= ffs(status
) - 1;
99 status
&= ~(1 << irq
);
101 irq
+= IRQ_SIC_START
;
103 generic_handle_irq(irq
);
108 #define IRQ_MMCI0A IRQ_VICSOURCE22
109 #define IRQ_AACI IRQ_VICSOURCE24
110 #define IRQ_ETH IRQ_VICSOURCE25
111 #define PIC_MASK 0xFFD00000
113 #define IRQ_MMCI0A IRQ_SIC_MMCI0A
114 #define IRQ_AACI IRQ_SIC_AACI
115 #define IRQ_ETH IRQ_SIC_ETH
119 void __init
versatile_init_irq(void)
123 vic_init(VA_VIC_BASE
, IRQ_VIC_START
, ~0, 0);
125 set_irq_chained_handler(IRQ_VICSOURCE31
, sic_handle_irq
);
127 /* Do second interrupt controller */
128 writel(~0, VA_SIC_BASE
+ SIC_IRQ_ENABLE_CLEAR
);
130 for (i
= IRQ_SIC_START
; i
<= IRQ_SIC_END
; i
++) {
131 if ((PIC_MASK
& (1 << (i
- IRQ_SIC_START
))) == 0) {
132 set_irq_chip(i
, &sic_chip
);
133 set_irq_handler(i
, handle_level_irq
);
134 set_irq_flags(i
, IRQF_VALID
| IRQF_PROBE
);
139 * Interrupts on secondary controller from 0 to 8 are routed to
141 * Interrupts from 21 to 31 are routed directly to the VIC on
142 * the corresponding number on primary controller. This is controlled
143 * by setting PIC_ENABLEx.
145 writel(PIC_MASK
, VA_SIC_BASE
+ SIC_INT_PIC_ENABLE
);
148 static struct map_desc versatile_io_desc
[] __initdata
= {
150 .virtual = IO_ADDRESS(VERSATILE_SYS_BASE
),
151 .pfn
= __phys_to_pfn(VERSATILE_SYS_BASE
),
155 .virtual = IO_ADDRESS(VERSATILE_SIC_BASE
),
156 .pfn
= __phys_to_pfn(VERSATILE_SIC_BASE
),
160 .virtual = IO_ADDRESS(VERSATILE_VIC_BASE
),
161 .pfn
= __phys_to_pfn(VERSATILE_VIC_BASE
),
165 .virtual = IO_ADDRESS(VERSATILE_SCTL_BASE
),
166 .pfn
= __phys_to_pfn(VERSATILE_SCTL_BASE
),
170 #ifdef CONFIG_MACH_VERSATILE_AB
172 .virtual = IO_ADDRESS(VERSATILE_GPIO0_BASE
),
173 .pfn
= __phys_to_pfn(VERSATILE_GPIO0_BASE
),
177 .virtual = IO_ADDRESS(VERSATILE_IB2_BASE
),
178 .pfn
= __phys_to_pfn(VERSATILE_IB2_BASE
),
183 #ifdef CONFIG_DEBUG_LL
185 .virtual = IO_ADDRESS(VERSATILE_UART0_BASE
),
186 .pfn
= __phys_to_pfn(VERSATILE_UART0_BASE
),
193 .virtual = IO_ADDRESS(VERSATILE_PCI_CORE_BASE
),
194 .pfn
= __phys_to_pfn(VERSATILE_PCI_CORE_BASE
),
198 .virtual = (unsigned long)VERSATILE_PCI_VIRT_BASE
,
199 .pfn
= __phys_to_pfn(VERSATILE_PCI_BASE
),
200 .length
= VERSATILE_PCI_BASE_SIZE
,
203 .virtual = (unsigned long)VERSATILE_PCI_CFG_VIRT_BASE
,
204 .pfn
= __phys_to_pfn(VERSATILE_PCI_CFG_BASE
),
205 .length
= VERSATILE_PCI_CFG_BASE_SIZE
,
210 .virtual = VERSATILE_PCI_VIRT_MEM_BASE0
,
211 .pfn
= __phys_to_pfn(VERSATILE_PCI_MEM_BASE0
),
215 .virtual = VERSATILE_PCI_VIRT_MEM_BASE1
,
216 .pfn
= __phys_to_pfn(VERSATILE_PCI_MEM_BASE1
),
220 .virtual = VERSATILE_PCI_VIRT_MEM_BASE2
,
221 .pfn
= __phys_to_pfn(VERSATILE_PCI_MEM_BASE2
),
229 void __init
versatile_map_io(void)
231 iotable_init(versatile_io_desc
, ARRAY_SIZE(versatile_io_desc
));
235 #define VERSATILE_FLASHCTRL (__io_address(VERSATILE_SYS_BASE) + VERSATILE_SYS_FLASH_OFFSET)
237 static int versatile_flash_init(void)
241 val
= __raw_readl(VERSATILE_FLASHCTRL
);
242 val
&= ~VERSATILE_FLASHPROG_FLVPPEN
;
243 __raw_writel(val
, VERSATILE_FLASHCTRL
);
248 static void versatile_flash_exit(void)
252 val
= __raw_readl(VERSATILE_FLASHCTRL
);
253 val
&= ~VERSATILE_FLASHPROG_FLVPPEN
;
254 __raw_writel(val
, VERSATILE_FLASHCTRL
);
257 static void versatile_flash_set_vpp(int on
)
261 val
= __raw_readl(VERSATILE_FLASHCTRL
);
263 val
|= VERSATILE_FLASHPROG_FLVPPEN
;
265 val
&= ~VERSATILE_FLASHPROG_FLVPPEN
;
266 __raw_writel(val
, VERSATILE_FLASHCTRL
);
269 static struct flash_platform_data versatile_flash_data
= {
270 .map_name
= "cfi_probe",
272 .init
= versatile_flash_init
,
273 .exit
= versatile_flash_exit
,
274 .set_vpp
= versatile_flash_set_vpp
,
277 static struct resource versatile_flash_resource
= {
278 .start
= VERSATILE_FLASH_BASE
,
279 .end
= VERSATILE_FLASH_BASE
+ VERSATILE_FLASH_SIZE
- 1,
280 .flags
= IORESOURCE_MEM
,
283 static struct platform_device versatile_flash_device
= {
287 .platform_data
= &versatile_flash_data
,
290 .resource
= &versatile_flash_resource
,
293 static struct resource smc91x_resources
[] = {
295 .start
= VERSATILE_ETH_BASE
,
296 .end
= VERSATILE_ETH_BASE
+ SZ_64K
- 1,
297 .flags
= IORESOURCE_MEM
,
302 .flags
= IORESOURCE_IRQ
,
306 static struct platform_device smc91x_device
= {
309 .num_resources
= ARRAY_SIZE(smc91x_resources
),
310 .resource
= smc91x_resources
,
313 static struct resource versatile_i2c_resource
= {
314 .start
= VERSATILE_I2C_BASE
,
315 .end
= VERSATILE_I2C_BASE
+ SZ_4K
- 1,
316 .flags
= IORESOURCE_MEM
,
319 static struct platform_device versatile_i2c_device
= {
320 .name
= "versatile-i2c",
323 .resource
= &versatile_i2c_resource
,
326 static struct i2c_board_info versatile_i2c_board_info
[] = {
328 I2C_BOARD_INFO("ds1338", 0xd0 >> 1),
332 static int __init
versatile_i2c_init(void)
334 return i2c_register_board_info(0, versatile_i2c_board_info
,
335 ARRAY_SIZE(versatile_i2c_board_info
));
337 arch_initcall(versatile_i2c_init
);
339 #define VERSATILE_SYSMCI (__io_address(VERSATILE_SYS_BASE) + VERSATILE_SYS_MCI_OFFSET)
341 unsigned int mmc_status(struct device
*dev
)
343 struct amba_device
*adev
= container_of(dev
, struct amba_device
, dev
);
346 if (adev
->res
.start
== VERSATILE_MMCI0_BASE
)
351 return readl(VERSATILE_SYSMCI
) & mask
;
354 static struct mmci_platform_data mmc0_plat_data
= {
355 .ocr_mask
= MMC_VDD_32_33
|MMC_VDD_33_34
,
356 .status
= mmc_status
,
361 static struct resource char_lcd_resources
[] = {
363 .start
= VERSATILE_CHAR_LCD_BASE
,
364 .end
= (VERSATILE_CHAR_LCD_BASE
+ SZ_4K
- 1),
365 .flags
= IORESOURCE_MEM
,
369 static struct platform_device char_lcd_device
= {
370 .name
= "arm-charlcd",
372 .num_resources
= ARRAY_SIZE(char_lcd_resources
),
373 .resource
= char_lcd_resources
,
379 static const struct icst_params versatile_oscvco_params
= {
381 .vco_max
= ICST307_VCO_MAX
,
382 .vco_min
= ICST307_VCO_MIN
,
387 .s2div
= icst307_s2div
,
388 .idx2s
= icst307_idx2s
,
391 static void versatile_oscvco_set(struct clk
*clk
, struct icst_vco vco
)
393 void __iomem
*sys_lock
= __io_address(VERSATILE_SYS_BASE
) + VERSATILE_SYS_LOCK_OFFSET
;
396 val
= readl(clk
->vcoreg
) & ~0x7ffff;
397 val
|= vco
.v
| (vco
.r
<< 9) | (vco
.s
<< 16);
399 writel(0xa05f, sys_lock
);
400 writel(val
, clk
->vcoreg
);
404 static const struct clk_ops osc4_clk_ops
= {
405 .round
= icst_clk_round
,
407 .setvco
= versatile_oscvco_set
,
410 static struct clk osc4_clk
= {
411 .ops
= &osc4_clk_ops
,
412 .params
= &versatile_oscvco_params
,
416 * These are fixed clocks.
418 static struct clk ref24_clk
= {
422 static struct clk dummy_apb_pclk
;
424 static struct clk_lookup lookups
[] = {
425 { /* AMBA bus clock */
426 .con_id
= "apb_pclk",
427 .clk
= &dummy_apb_pclk
,
464 #define SYS_CLCD_MODE_MASK (3 << 0)
465 #define SYS_CLCD_MODE_888 (0 << 0)
466 #define SYS_CLCD_MODE_5551 (1 << 0)
467 #define SYS_CLCD_MODE_565_RLSB (2 << 0)
468 #define SYS_CLCD_MODE_565_BLSB (3 << 0)
469 #define SYS_CLCD_NLCDIOON (1 << 2)
470 #define SYS_CLCD_VDDPOSSWITCH (1 << 3)
471 #define SYS_CLCD_PWR3V5SWITCH (1 << 4)
472 #define SYS_CLCD_ID_MASK (0x1f << 8)
473 #define SYS_CLCD_ID_SANYO_3_8 (0x00 << 8)
474 #define SYS_CLCD_ID_UNKNOWN_8_4 (0x01 << 8)
475 #define SYS_CLCD_ID_EPSON_2_2 (0x02 << 8)
476 #define SYS_CLCD_ID_SANYO_2_5 (0x07 << 8)
477 #define SYS_CLCD_ID_VGA (0x1f << 8)
479 static struct clcd_panel vga
= {
493 .vmode
= FB_VMODE_NONINTERLACED
,
497 .tim2
= TIM2_BCD
| TIM2_IPC
,
498 .cntl
= CNTL_LCDTFT
| CNTL_LCDVCOMP(1),
502 static struct clcd_panel sanyo_3_8_in
= {
504 .name
= "Sanyo QVGA",
516 .vmode
= FB_VMODE_NONINTERLACED
,
521 .cntl
= CNTL_LCDTFT
| CNTL_LCDVCOMP(1),
525 static struct clcd_panel sanyo_2_5_in
= {
527 .name
= "Sanyo QVGA Portrait",
538 .sync
= FB_SYNC_HOR_HIGH_ACT
| FB_SYNC_VERT_HIGH_ACT
,
539 .vmode
= FB_VMODE_NONINTERLACED
,
543 .tim2
= TIM2_IVS
| TIM2_IHS
| TIM2_IPC
,
544 .cntl
= CNTL_LCDTFT
| CNTL_LCDVCOMP(1),
548 static struct clcd_panel epson_2_2_in
= {
550 .name
= "Epson QCIF",
562 .vmode
= FB_VMODE_NONINTERLACED
,
566 .tim2
= TIM2_BCD
| TIM2_IPC
,
567 .cntl
= CNTL_LCDTFT
| CNTL_LCDVCOMP(1),
572 * Detect which LCD panel is connected, and return the appropriate
573 * clcd_panel structure. Note: we do not have any information on
574 * the required timings for the 8.4in panel, so we presently assume
577 static struct clcd_panel
*versatile_clcd_panel(void)
579 void __iomem
*sys_clcd
= __io_address(VERSATILE_SYS_BASE
) + VERSATILE_SYS_CLCD_OFFSET
;
580 struct clcd_panel
*panel
= &vga
;
583 val
= readl(sys_clcd
) & SYS_CLCD_ID_MASK
;
584 if (val
== SYS_CLCD_ID_SANYO_3_8
)
585 panel
= &sanyo_3_8_in
;
586 else if (val
== SYS_CLCD_ID_SANYO_2_5
)
587 panel
= &sanyo_2_5_in
;
588 else if (val
== SYS_CLCD_ID_EPSON_2_2
)
589 panel
= &epson_2_2_in
;
590 else if (val
== SYS_CLCD_ID_VGA
)
593 printk(KERN_ERR
"CLCD: unknown LCD panel ID 0x%08x, using VGA\n",
602 * Disable all display connectors on the interface module.
604 static void versatile_clcd_disable(struct clcd_fb
*fb
)
606 void __iomem
*sys_clcd
= __io_address(VERSATILE_SYS_BASE
) + VERSATILE_SYS_CLCD_OFFSET
;
609 val
= readl(sys_clcd
);
610 val
&= ~SYS_CLCD_NLCDIOON
| SYS_CLCD_PWR3V5SWITCH
;
611 writel(val
, sys_clcd
);
613 #ifdef CONFIG_MACH_VERSATILE_AB
615 * If the LCD is Sanyo 2x5 in on the IB2 board, turn the back-light off
617 if (machine_is_versatile_ab() && fb
->panel
== &sanyo_2_5_in
) {
618 void __iomem
*versatile_ib2_ctrl
= __io_address(VERSATILE_IB2_CTRL
);
621 ctrl
= readl(versatile_ib2_ctrl
);
623 writel(ctrl
, versatile_ib2_ctrl
);
629 * Enable the relevant connector on the interface module.
631 static void versatile_clcd_enable(struct clcd_fb
*fb
)
633 void __iomem
*sys_clcd
= __io_address(VERSATILE_SYS_BASE
) + VERSATILE_SYS_CLCD_OFFSET
;
636 val
= readl(sys_clcd
);
637 val
&= ~SYS_CLCD_MODE_MASK
;
639 switch (fb
->fb
.var
.green
.length
) {
641 val
|= SYS_CLCD_MODE_5551
;
644 val
|= SYS_CLCD_MODE_565_RLSB
;
647 val
|= SYS_CLCD_MODE_888
;
654 writel(val
, sys_clcd
);
657 * And now enable the PSUs
659 val
|= SYS_CLCD_NLCDIOON
| SYS_CLCD_PWR3V5SWITCH
;
660 writel(val
, sys_clcd
);
662 #ifdef CONFIG_MACH_VERSATILE_AB
664 * If the LCD is Sanyo 2x5 in on the IB2 board, turn the back-light on
666 if (machine_is_versatile_ab() && fb
->panel
== &sanyo_2_5_in
) {
667 void __iomem
*versatile_ib2_ctrl
= __io_address(VERSATILE_IB2_CTRL
);
670 ctrl
= readl(versatile_ib2_ctrl
);
672 writel(ctrl
, versatile_ib2_ctrl
);
677 static unsigned long framesize
= SZ_1M
;
679 static int versatile_clcd_setup(struct clcd_fb
*fb
)
683 fb
->panel
= versatile_clcd_panel();
685 fb
->fb
.screen_base
= dma_alloc_writecombine(&fb
->dev
->dev
, framesize
,
687 if (!fb
->fb
.screen_base
) {
688 printk(KERN_ERR
"CLCD: unable to map framebuffer\n");
692 fb
->fb
.fix
.smem_start
= dma
;
693 fb
->fb
.fix
.smem_len
= framesize
;
698 static int versatile_clcd_mmap(struct clcd_fb
*fb
, struct vm_area_struct
*vma
)
700 return dma_mmap_writecombine(&fb
->dev
->dev
, vma
,
702 fb
->fb
.fix
.smem_start
,
703 fb
->fb
.fix
.smem_len
);
706 static void versatile_clcd_remove(struct clcd_fb
*fb
)
708 dma_free_writecombine(&fb
->dev
->dev
, fb
->fb
.fix
.smem_len
,
709 fb
->fb
.screen_base
, fb
->fb
.fix
.smem_start
);
712 static struct clcd_board clcd_plat_data
= {
714 .check
= clcdfb_check
,
715 .decode
= clcdfb_decode
,
716 .disable
= versatile_clcd_disable
,
717 .enable
= versatile_clcd_enable
,
718 .setup
= versatile_clcd_setup
,
719 .mmap
= versatile_clcd_mmap
,
720 .remove
= versatile_clcd_remove
,
723 static struct pl061_platform_data gpio0_plat_data
= {
725 .irq_base
= IRQ_GPIO0_START
,
728 static struct pl061_platform_data gpio1_plat_data
= {
730 .irq_base
= IRQ_GPIO1_START
,
733 static struct pl022_ssp_controller ssp0_plat_data
= {
739 #define AACI_IRQ { IRQ_AACI, NO_IRQ }
740 #define AACI_DMA { 0x80, 0x81 }
741 #define MMCI0_IRQ { IRQ_MMCI0A,IRQ_SIC_MMCI0B }
742 #define MMCI0_DMA { 0x84, 0 }
743 #define KMI0_IRQ { IRQ_SIC_KMI0, NO_IRQ }
744 #define KMI0_DMA { 0, 0 }
745 #define KMI1_IRQ { IRQ_SIC_KMI1, NO_IRQ }
746 #define KMI1_DMA { 0, 0 }
749 * These devices are connected directly to the multi-layer AHB switch
751 #define SMC_IRQ { NO_IRQ, NO_IRQ }
752 #define SMC_DMA { 0, 0 }
753 #define MPMC_IRQ { NO_IRQ, NO_IRQ }
754 #define MPMC_DMA { 0, 0 }
755 #define CLCD_IRQ { IRQ_CLCDINT, NO_IRQ }
756 #define CLCD_DMA { 0, 0 }
757 #define DMAC_IRQ { IRQ_DMAINT, NO_IRQ }
758 #define DMAC_DMA { 0, 0 }
761 * These devices are connected via the core APB bridge
763 #define SCTL_IRQ { NO_IRQ, NO_IRQ }
764 #define SCTL_DMA { 0, 0 }
765 #define WATCHDOG_IRQ { IRQ_WDOGINT, NO_IRQ }
766 #define WATCHDOG_DMA { 0, 0 }
767 #define GPIO0_IRQ { IRQ_GPIOINT0, NO_IRQ }
768 #define GPIO0_DMA { 0, 0 }
769 #define GPIO1_IRQ { IRQ_GPIOINT1, NO_IRQ }
770 #define GPIO1_DMA { 0, 0 }
771 #define RTC_IRQ { IRQ_RTCINT, NO_IRQ }
772 #define RTC_DMA { 0, 0 }
775 * These devices are connected via the DMA APB bridge
777 #define SCI_IRQ { IRQ_SCIINT, NO_IRQ }
778 #define SCI_DMA { 7, 6 }
779 #define UART0_IRQ { IRQ_UARTINT0, NO_IRQ }
780 #define UART0_DMA { 15, 14 }
781 #define UART1_IRQ { IRQ_UARTINT1, NO_IRQ }
782 #define UART1_DMA { 13, 12 }
783 #define UART2_IRQ { IRQ_UARTINT2, NO_IRQ }
784 #define UART2_DMA { 11, 10 }
785 #define SSP_IRQ { IRQ_SSPINT, NO_IRQ }
786 #define SSP_DMA { 9, 8 }
788 /* FPGA Primecells */
789 AMBA_DEVICE(aaci
, "fpga:04", AACI
, NULL
);
790 AMBA_DEVICE(mmc0
, "fpga:05", MMCI0
, &mmc0_plat_data
);
791 AMBA_DEVICE(kmi0
, "fpga:06", KMI0
, NULL
);
792 AMBA_DEVICE(kmi1
, "fpga:07", KMI1
, NULL
);
794 /* DevChip Primecells */
795 AMBA_DEVICE(smc
, "dev:00", SMC
, NULL
);
796 AMBA_DEVICE(mpmc
, "dev:10", MPMC
, NULL
);
797 AMBA_DEVICE(clcd
, "dev:20", CLCD
, &clcd_plat_data
);
798 AMBA_DEVICE(dmac
, "dev:30", DMAC
, NULL
);
799 AMBA_DEVICE(sctl
, "dev:e0", SCTL
, NULL
);
800 AMBA_DEVICE(wdog
, "dev:e1", WATCHDOG
, NULL
);
801 AMBA_DEVICE(gpio0
, "dev:e4", GPIO0
, &gpio0_plat_data
);
802 AMBA_DEVICE(gpio1
, "dev:e5", GPIO1
, &gpio1_plat_data
);
803 AMBA_DEVICE(rtc
, "dev:e8", RTC
, NULL
);
804 AMBA_DEVICE(sci0
, "dev:f0", SCI
, NULL
);
805 AMBA_DEVICE(uart0
, "dev:f1", UART0
, NULL
);
806 AMBA_DEVICE(uart1
, "dev:f2", UART1
, NULL
);
807 AMBA_DEVICE(uart2
, "dev:f3", UART2
, NULL
);
808 AMBA_DEVICE(ssp0
, "dev:f4", SSP
, &ssp0_plat_data
);
810 static struct amba_device
*amba_devs
[] __initdata
= {
832 #define VA_LEDS_BASE (__io_address(VERSATILE_SYS_BASE) + VERSATILE_SYS_LED_OFFSET)
834 static void versatile_leds_event(led_event_t ledevt
)
839 local_irq_save(flags
);
840 val
= readl(VA_LEDS_BASE
);
844 val
= val
& ~VERSATILE_SYS_LED0
;
848 val
= val
| VERSATILE_SYS_LED0
;
852 val
= val
^ VERSATILE_SYS_LED1
;
863 writel(val
, VA_LEDS_BASE
);
864 local_irq_restore(flags
);
866 #endif /* CONFIG_LEDS */
868 void __init
versatile_init(void)
872 osc4_clk
.vcoreg
= __io_address(VERSATILE_SYS_BASE
) + VERSATILE_SYS_OSCCLCD_OFFSET
;
874 clkdev_add_table(lookups
, ARRAY_SIZE(lookups
));
876 platform_device_register(&versatile_flash_device
);
877 platform_device_register(&versatile_i2c_device
);
878 platform_device_register(&smc91x_device
);
879 platform_device_register(&char_lcd_device
);
881 for (i
= 0; i
< ARRAY_SIZE(amba_devs
); i
++) {
882 struct amba_device
*d
= amba_devs
[i
];
883 amba_device_register(d
, &iomem_resource
);
887 leds_event
= versatile_leds_event
;
892 * The sched_clock counter
894 #define REFCOUNTER (__io_address(VERSATILE_SYS_BASE) + \
895 VERSATILE_SYS_24MHz_OFFSET)
898 * Where is the timer (VA)?
900 #define TIMER0_VA_BASE __io_address(VERSATILE_TIMER0_1_BASE)
901 #define TIMER1_VA_BASE (__io_address(VERSATILE_TIMER0_1_BASE) + 0x20)
902 #define TIMER2_VA_BASE __io_address(VERSATILE_TIMER2_3_BASE)
903 #define TIMER3_VA_BASE (__io_address(VERSATILE_TIMER2_3_BASE) + 0x20)
906 * Set up timer interrupt, and return the current time in seconds.
908 static void __init
versatile_timer_init(void)
912 versatile_sched_clock_init(REFCOUNTER
, 24000000);
915 * set clock frequency:
916 * VERSATILE_REFCLK is 32KHz
917 * VERSATILE_TIMCLK is 1MHz
919 val
= readl(__io_address(VERSATILE_SCTL_BASE
));
920 writel((VERSATILE_TIMCLK
<< VERSATILE_TIMER1_EnSel
) |
921 (VERSATILE_TIMCLK
<< VERSATILE_TIMER2_EnSel
) |
922 (VERSATILE_TIMCLK
<< VERSATILE_TIMER3_EnSel
) |
923 (VERSATILE_TIMCLK
<< VERSATILE_TIMER4_EnSel
) | val
,
924 __io_address(VERSATILE_SCTL_BASE
));
927 * Initialise to a known state (all timers off)
929 writel(0, TIMER0_VA_BASE
+ TIMER_CTRL
);
930 writel(0, TIMER1_VA_BASE
+ TIMER_CTRL
);
931 writel(0, TIMER2_VA_BASE
+ TIMER_CTRL
);
932 writel(0, TIMER3_VA_BASE
+ TIMER_CTRL
);
934 sp804_clocksource_init(TIMER3_VA_BASE
);
935 sp804_clockevents_init(TIMER0_VA_BASE
, IRQ_TIMERINT0_1
);
938 struct sys_timer versatile_timer
= {
939 .init
= versatile_timer_init
,