Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 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 Gleixner | 5a67b77 | 2006-07-01 22:32:37 +0100 | [diff] [blame] | 9 | #include <linux/irq.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | #include <linux/sched.h> |
| 11 | #include <linux/serial_8250.h> |
Russell King | fced80c | 2008-09-06 12:10:45 +0100 | [diff] [blame] | 12 | #include <linux/io.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | |
| 14 | #include <asm/setup.h> |
| 15 | #include <asm/mach-types.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | #include <asm/leds.h> |
| 17 | #include <asm/param.h> |
Olof Johansson | 86dfe44 | 2012-03-29 23:22:44 -0700 | [diff] [blame] | 18 | #include <asm/system_misc.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | |
| 20 | #include <asm/mach/map.h> |
| 21 | #include <asm/mach/arch.h> |
| 22 | #include <asm/mach/time.h> |
| 23 | |
Alexander Schulz | eab184c | 2009-01-08 18:05:58 +0100 | [diff] [blame] | 24 | #define IO_BASE 0xe0000000 |
| 25 | #define IO_SIZE 0x08000000 |
| 26 | #define IO_START 0x40000000 |
| 27 | #define ROMCARD_SIZE 0x08000000 |
| 28 | #define ROMCARD_START 0x10000000 |
| 29 | |
Russell King | b95ff9f | 2011-11-05 14:41:14 +0000 | [diff] [blame] | 30 | static void shark_restart(char mode, const char *cmd) |
Alexander Schulz | eab184c | 2009-01-08 18:05:58 +0100 | [diff] [blame] | 31 | { |
| 32 | short temp; |
Alexander Schulz | eab184c | 2009-01-08 18:05:58 +0100 | [diff] [blame] | 33 | /* Reset the Machine via pc[3] of the sequoia chipset */ |
| 34 | outw(0x09,0x24); |
| 35 | temp=inw(0x26); |
| 36 | temp = temp | (1<<3) | (1<<10); |
| 37 | outw(0x09,0x24); |
| 38 | outw(temp,0x26); |
| 39 | } |
| 40 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | static struct plat_serial8250_port serial_platform_data[] = { |
| 42 | { |
| 43 | .iobase = 0x3f8, |
| 44 | .irq = 4, |
| 45 | .uartclk = 1843200, |
Alexander Schulz | b752341 | 2005-07-16 17:17:18 +0100 | [diff] [blame] | 46 | .regshift = 0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | .iotype = UPIO_PORT, |
| 48 | .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST, |
| 49 | }, |
| 50 | { |
| 51 | .iobase = 0x2f8, |
| 52 | .irq = 3, |
| 53 | .uartclk = 1843200, |
Alexander Schulz | b752341 | 2005-07-16 17:17:18 +0100 | [diff] [blame] | 54 | .regshift = 0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | .iotype = UPIO_PORT, |
| 56 | .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST, |
| 57 | }, |
| 58 | { }, |
| 59 | }; |
| 60 | |
| 61 | static struct platform_device serial_device = { |
| 62 | .name = "serial8250", |
Russell King | 6df29de | 2005-09-08 16:04:41 +0100 | [diff] [blame] | 63 | .id = PLAT8250_DEV_PLATFORM, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | .dev = { |
| 65 | .platform_data = serial_platform_data, |
| 66 | }, |
| 67 | }; |
| 68 | |
Alexander Schulz | eab184c | 2009-01-08 18:05:58 +0100 | [diff] [blame] | 69 | static struct resource rtc_resources[] = { |
| 70 | [0] = { |
| 71 | .start = 0x70, |
| 72 | .end = 0x73, |
| 73 | .flags = IORESOURCE_IO, |
| 74 | }, |
| 75 | [1] = { |
| 76 | .start = IRQ_ISA_RTC_ALARM, |
| 77 | .end = IRQ_ISA_RTC_ALARM, |
| 78 | .flags = IORESOURCE_IRQ, |
| 79 | } |
| 80 | }; |
| 81 | |
| 82 | static struct platform_device rtc_device = { |
| 83 | .name = "rtc_cmos", |
| 84 | .id = -1, |
| 85 | .resource = rtc_resources, |
| 86 | .num_resources = ARRAY_SIZE(rtc_resources), |
| 87 | }; |
| 88 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 | static int __init shark_init(void) |
| 90 | { |
| 91 | int ret; |
| 92 | |
| 93 | if (machine_is_shark()) |
Alexander Schulz | eab184c | 2009-01-08 18:05:58 +0100 | [diff] [blame] | 94 | { |
| 95 | ret = platform_device_register(&rtc_device); |
| 96 | if (ret) printk(KERN_ERR "Unable to register RTC device: %d\n", ret); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | ret = platform_device_register(&serial_device); |
Alexander Schulz | eab184c | 2009-01-08 18:05:58 +0100 | [diff] [blame] | 98 | if (ret) printk(KERN_ERR "Unable to register Serial device: %d\n", ret); |
| 99 | } |
| 100 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | } |
| 102 | |
| 103 | arch_initcall(shark_init); |
| 104 | |
| 105 | extern void shark_init_irq(void); |
| 106 | |
| 107 | static struct map_desc shark_io_desc[] __initdata = { |
Deepak Saxena | cd5fc8b | 2005-10-28 15:19:03 +0100 | [diff] [blame] | 108 | { |
| 109 | .virtual = IO_BASE, |
| 110 | .pfn = __phys_to_pfn(IO_START), |
| 111 | .length = IO_SIZE, |
| 112 | .type = MT_DEVICE |
| 113 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | }; |
| 115 | |
| 116 | static void __init shark_map_io(void) |
| 117 | { |
| 118 | iotable_init(shark_io_desc, ARRAY_SIZE(shark_io_desc)); |
| 119 | } |
| 120 | |
| 121 | #define IRQ_TIMER 0 |
| 122 | #define HZ_TIME ((1193180 + HZ/2) / HZ) |
| 123 | |
| 124 | static irqreturn_t |
Linus Torvalds | 0cd61b6 | 2006-10-06 10:53:39 -0700 | [diff] [blame] | 125 | shark_timer_interrupt(int irq, void *dev_id) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | { |
Linus Torvalds | 0cd61b6 | 2006-10-06 10:53:39 -0700 | [diff] [blame] | 127 | timer_tick(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 128 | return IRQ_HANDLED; |
| 129 | } |
| 130 | |
| 131 | static struct irqaction shark_timer_irq = { |
| 132 | .name = "Shark Timer Tick", |
Bernhard Walle | b30faba | 2007-05-08 00:35:39 -0700 | [diff] [blame] | 133 | .flags = IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL, |
Russell King | 09b8b5f | 2005-06-26 17:06:36 +0100 | [diff] [blame] | 134 | .handler = shark_timer_interrupt, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | }; |
| 136 | |
| 137 | /* |
| 138 | * Set up timer interrupt, and return the current time in seconds. |
| 139 | */ |
| 140 | static void __init shark_timer_init(void) |
| 141 | { |
| 142 | outb(0x34, 0x43); /* binary, mode 0, LSB/MSB, Ch 0 */ |
| 143 | outb(HZ_TIME & 0xff, 0x40); /* LSB of count */ |
| 144 | outb(HZ_TIME >> 8, 0x40); |
| 145 | |
| 146 | setup_irq(IRQ_TIMER, &shark_timer_irq); |
| 147 | } |
| 148 | |
| 149 | static struct sys_timer shark_timer = { |
| 150 | .init = shark_timer_init, |
| 151 | }; |
| 152 | |
Nicolas Pitre | e5ddf4e | 2011-08-03 12:00:02 -0400 | [diff] [blame] | 153 | static void shark_init_early(void) |
| 154 | { |
| 155 | disable_hlt(); |
| 156 | } |
| 157 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 | MACHINE_START(SHARK, "Shark") |
Russell King | e9dea0c | 2005-07-03 17:38:58 +0100 | [diff] [blame] | 159 | /* Maintainer: Alexander Schulz */ |
Nicolas Pitre | 8322cd4 | 2011-07-05 22:38:17 -0400 | [diff] [blame] | 160 | .atag_offset = 0x3000, |
Russell King | e9dea0c | 2005-07-03 17:38:58 +0100 | [diff] [blame] | 161 | .map_io = shark_map_io, |
Nicolas Pitre | e5ddf4e | 2011-08-03 12:00:02 -0400 | [diff] [blame] | 162 | .init_early = shark_init_early, |
Russell King | e9dea0c | 2005-07-03 17:38:58 +0100 | [diff] [blame] | 163 | .init_irq = shark_init_irq, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 164 | .timer = &shark_timer, |
Nicolas Pitre | fded1ef | 2011-07-05 22:28:09 -0400 | [diff] [blame] | 165 | .dma_zone_size = SZ_4M, |
Russell King | b95ff9f | 2011-11-05 14:41:14 +0000 | [diff] [blame] | 166 | .restart = shark_restart, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 | MACHINE_END |