blob: a851c254ad6c8a79bc00204063021c1bcba2e118 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * linux/arch/arm/mach-shark/arch.c
3 *
4 * Architecture specific stuff.
5 */
6#include <linux/kernel.h>
7#include <linux/init.h>
8#include <linux/interrupt.h>
Thomas Gleixner5a67b772006-07-01 22:32:37 +01009#include <linux/irq.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010#include <linux/sched.h>
11#include <linux/serial_8250.h>
Russell Kingfced80c2008-09-06 12:10:45 +010012#include <linux/io.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070013
14#include <asm/setup.h>
15#include <asm/mach-types.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070016#include <asm/leds.h>
17#include <asm/param.h>
18
19#include <asm/mach/map.h>
20#include <asm/mach/arch.h>
21#include <asm/mach/time.h>
22
Alexander Schulzeab184c2009-01-08 18:05:58 +010023#define IO_BASE 0xe0000000
24#define IO_SIZE 0x08000000
25#define IO_START 0x40000000
26#define ROMCARD_SIZE 0x08000000
27#define ROMCARD_START 0x10000000
28
Russell Kingb95ff9f2011-11-05 14:41:14 +000029static void shark_restart(char mode, const char *cmd)
Alexander Schulzeab184c2009-01-08 18:05:58 +010030{
31 short temp;
Alexander Schulzeab184c2009-01-08 18:05:58 +010032 /* Reset the Machine via pc[3] of the sequoia chipset */
33 outw(0x09,0x24);
34 temp=inw(0x26);
35 temp = temp | (1<<3) | (1<<10);
36 outw(0x09,0x24);
37 outw(temp,0x26);
38}
39
Linus Torvalds1da177e2005-04-16 15:20:36 -070040static struct plat_serial8250_port serial_platform_data[] = {
41 {
42 .iobase = 0x3f8,
43 .irq = 4,
44 .uartclk = 1843200,
Alexander Schulzb7523412005-07-16 17:17:18 +010045 .regshift = 0,
Linus Torvalds1da177e2005-04-16 15:20:36 -070046 .iotype = UPIO_PORT,
47 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
48 },
49 {
50 .iobase = 0x2f8,
51 .irq = 3,
52 .uartclk = 1843200,
Alexander Schulzb7523412005-07-16 17:17:18 +010053 .regshift = 0,
Linus Torvalds1da177e2005-04-16 15:20:36 -070054 .iotype = UPIO_PORT,
55 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
56 },
57 { },
58};
59
60static struct platform_device serial_device = {
61 .name = "serial8250",
Russell King6df29de2005-09-08 16:04:41 +010062 .id = PLAT8250_DEV_PLATFORM,
Linus Torvalds1da177e2005-04-16 15:20:36 -070063 .dev = {
64 .platform_data = serial_platform_data,
65 },
66};
67
Alexander Schulzeab184c2009-01-08 18:05:58 +010068static struct resource rtc_resources[] = {
69 [0] = {
70 .start = 0x70,
71 .end = 0x73,
72 .flags = IORESOURCE_IO,
73 },
74 [1] = {
75 .start = IRQ_ISA_RTC_ALARM,
76 .end = IRQ_ISA_RTC_ALARM,
77 .flags = IORESOURCE_IRQ,
78 }
79};
80
81static struct platform_device rtc_device = {
82 .name = "rtc_cmos",
83 .id = -1,
84 .resource = rtc_resources,
85 .num_resources = ARRAY_SIZE(rtc_resources),
86};
87
Linus Torvalds1da177e2005-04-16 15:20:36 -070088static int __init shark_init(void)
89{
90 int ret;
91
92 if (machine_is_shark())
Alexander Schulzeab184c2009-01-08 18:05:58 +010093 {
94 ret = platform_device_register(&rtc_device);
95 if (ret) printk(KERN_ERR "Unable to register RTC device: %d\n", ret);
Linus Torvalds1da177e2005-04-16 15:20:36 -070096 ret = platform_device_register(&serial_device);
Alexander Schulzeab184c2009-01-08 18:05:58 +010097 if (ret) printk(KERN_ERR "Unable to register Serial device: %d\n", ret);
98 }
99 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100}
101
102arch_initcall(shark_init);
103
104extern void shark_init_irq(void);
105
106static struct map_desc shark_io_desc[] __initdata = {
Deepak Saxenacd5fc8b2005-10-28 15:19:03 +0100107 {
108 .virtual = IO_BASE,
109 .pfn = __phys_to_pfn(IO_START),
110 .length = IO_SIZE,
111 .type = MT_DEVICE
112 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113};
114
115static void __init shark_map_io(void)
116{
117 iotable_init(shark_io_desc, ARRAY_SIZE(shark_io_desc));
118}
119
120#define IRQ_TIMER 0
121#define HZ_TIME ((1193180 + HZ/2) / HZ)
122
123static irqreturn_t
Linus Torvalds0cd61b62006-10-06 10:53:39 -0700124shark_timer_interrupt(int irq, void *dev_id)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125{
Linus Torvalds0cd61b62006-10-06 10:53:39 -0700126 timer_tick();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127 return IRQ_HANDLED;
128}
129
130static struct irqaction shark_timer_irq = {
131 .name = "Shark Timer Tick",
Bernhard Walleb30faba2007-05-08 00:35:39 -0700132 .flags = IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL,
Russell King09b8b5f2005-06-26 17:06:36 +0100133 .handler = shark_timer_interrupt,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134};
135
136/*
137 * Set up timer interrupt, and return the current time in seconds.
138 */
139static void __init shark_timer_init(void)
140{
141 outb(0x34, 0x43); /* binary, mode 0, LSB/MSB, Ch 0 */
142 outb(HZ_TIME & 0xff, 0x40); /* LSB of count */
143 outb(HZ_TIME >> 8, 0x40);
144
145 setup_irq(IRQ_TIMER, &shark_timer_irq);
146}
147
148static struct sys_timer shark_timer = {
149 .init = shark_timer_init,
150};
151
152MACHINE_START(SHARK, "Shark")
Russell Kinge9dea0c2005-07-03 17:38:58 +0100153 /* Maintainer: Alexander Schulz */
Nicolas Pitre8322cd42011-07-05 22:38:17 -0400154 .atag_offset = 0x3000,
Russell Kinge9dea0c2005-07-03 17:38:58 +0100155 .map_io = shark_map_io,
156 .init_irq = shark_init_irq,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700157 .timer = &shark_timer,
Nicolas Pitrefded1ef2011-07-05 22:28:09 -0400158 .dma_zone_size = SZ_4M,
Russell Kingb95ff9f2011-11-05 14:41:14 +0000159 .restart = shark_restart,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160MACHINE_END