blob: 09d602b10d578c6fa4e07e3ae3700b1618da9e80 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * linux/arch/arm/mach-rpc/riscpc.c
3 *
4 * Copyright (C) 1998-2001 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * Architecture specific fixups.
11 */
12#include <linux/kernel.h>
13#include <linux/tty.h>
14#include <linux/delay.h>
15#include <linux/pm.h>
16#include <linux/init.h>
17#include <linux/sched.h>
18#include <linux/device.h>
19#include <linux/serial_8250.h>
Jeff Garzik0a87e3e2008-02-01 18:02:30 -050020#include <linux/ata_platform.h>
Russell Kingfced80c2008-09-06 12:10:45 +010021#include <linux/io.h>
Russell King531660e2009-02-24 19:19:50 +010022#include <linux/i2c.h>
Robin Holt7b6d8642013-07-08 16:01:40 -070023#include <linux/reboot.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070024
25#include <asm/elf.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#include <asm/mach-types.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010027#include <mach/hardware.h>
Russell Kinge11e9092011-11-04 16:42:37 +000028#include <asm/hardware/iomd.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070029#include <asm/page.h>
30#include <asm/domain.h>
31#include <asm/setup.h>
David Howells9f97da72012-03-28 18:30:01 +010032#include <asm/system_misc.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070033
34#include <asm/mach/map.h>
35#include <asm/mach/arch.h>
36#include <asm/mach/time.h>
37
38extern void rpc_init_irq(void);
39
Russell Kingebe2a9f2005-06-22 09:55:04 +010040unsigned int vram_size;
Linus Torvalds1da177e2005-04-16 15:20:36 -070041unsigned int memc_ctrl_reg;
42unsigned int number_mfm_drives;
43
44static int __init parse_tag_acorn(const struct tag *tag)
45{
46 memc_ctrl_reg = tag->u.acorn.memc_control_reg;
47 number_mfm_drives = tag->u.acorn.adfsdrives;
48
49 switch (tag->u.acorn.vram_pages) {
50 case 512:
51 vram_size += PAGE_SIZE * 256;
52 case 256:
53 vram_size += PAGE_SIZE * 256;
54 default:
55 break;
56 }
57#if 0
58 if (vram_size) {
59 desc->video_start = 0x02000000;
60 desc->video_end = 0x02000000 + vram_size;
61 }
62#endif
63 return 0;
64}
65
66__tagtable(ATAG_ACORN, parse_tag_acorn);
67
Linus Torvalds1da177e2005-04-16 15:20:36 -070068static struct map_desc rpc_io_desc[] __initdata = {
Deepak Saxenaf9258f22005-10-28 15:19:02 +010069 { /* VRAM */
70 .virtual = SCREEN_BASE,
71 .pfn = __phys_to_pfn(SCREEN_START),
72 .length = 2*1048576,
73 .type = MT_DEVICE
74 }, { /* IO space */
75 .virtual = (u32)IO_BASE,
76 .pfn = __phys_to_pfn(IO_START),
77 .length = IO_SIZE ,
78 .type = MT_DEVICE
79 }, { /* EASI space */
Russell King5e4cdb82011-07-07 11:40:52 +010080 .virtual = (unsigned long)EASI_BASE,
Deepak Saxenaf9258f22005-10-28 15:19:02 +010081 .pfn = __phys_to_pfn(EASI_START),
82 .length = EASI_SIZE,
83 .type = MT_DEVICE
84 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070085};
86
87static void __init rpc_map_io(void)
88{
89 iotable_init(rpc_io_desc, ARRAY_SIZE(rpc_io_desc));
90
91 /*
92 * Turn off floppy.
93 */
Russell King13a63ab22007-07-20 10:44:02 +010094 writeb(0xc, PCIO_BASE + (0x3f2 << 2));
Linus Torvalds1da177e2005-04-16 15:20:36 -070095
96 /*
97 * RiscPC can't handle half-word loads and stores
98 */
99 elf_hwcap &= ~HWCAP_HALF;
100}
101
102static struct resource acornfb_resources[] = {
Russell King2b7da082012-03-01 20:32:52 +0000103 /* VIDC */
104 DEFINE_RES_MEM(0x03400000, 0x00200000),
105 DEFINE_RES_IRQ(IRQ_VSYNCPULSE),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106};
107
108static struct platform_device acornfb_device = {
109 .name = "acornfb",
110 .id = -1,
111 .dev = {
112 .coherent_dma_mask = 0xffffffff,
113 },
114 .num_resources = ARRAY_SIZE(acornfb_resources),
115 .resource = acornfb_resources,
116};
117
118static struct resource iomd_resources[] = {
Russell King2b7da082012-03-01 20:32:52 +0000119 DEFINE_RES_MEM(0x03200000, 0x10000),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120};
121
122static struct platform_device iomd_device = {
123 .name = "iomd",
124 .id = -1,
125 .num_resources = ARRAY_SIZE(iomd_resources),
126 .resource = iomd_resources,
127};
128
Russell King8c6d9d02012-03-01 15:47:10 +0000129static struct resource iomd_kart_resources[] = {
130 DEFINE_RES_IRQ(IRQ_KEYBOARDRX),
131 DEFINE_RES_IRQ(IRQ_KEYBOARDTX),
132};
133
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134static struct platform_device kbd_device = {
135 .name = "kart",
136 .id = -1,
137 .dev = {
138 .parent = &iomd_device.dev,
139 },
Russell King8c6d9d02012-03-01 15:47:10 +0000140 .num_resources = ARRAY_SIZE(iomd_kart_resources),
141 .resource = iomd_kart_resources,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142};
143
144static struct plat_serial8250_port serial_platform_data[] = {
145 {
146 .mapbase = 0x03010fe0,
Russell King18a66d52012-03-01 16:54:27 +0000147 .irq = IRQ_SERIALPORT,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148 .uartclk = 1843200,
149 .regshift = 2,
150 .iotype = UPIO_MEM,
151 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP | UPF_SKIP_TEST,
152 },
153 { },
154};
155
156static struct platform_device serial_device = {
157 .name = "serial8250",
Russell King6df29de2005-09-08 16:04:41 +0100158 .id = PLAT8250_DEV_PLATFORM,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159 .dev = {
160 .platform_data = serial_platform_data,
161 },
162};
163
Russell Kinga17dba82007-04-21 15:55:06 +0100164static struct pata_platform_info pata_platform_data = {
165 .ioport_shift = 2,
166};
167
168static struct resource pata_resources[] = {
Russell King2b7da082012-03-01 20:32:52 +0000169 DEFINE_RES_MEM(0x030107c0, 0x20),
170 DEFINE_RES_MEM(0x03010fd8, 0x04),
171 DEFINE_RES_IRQ(IRQ_HARDDISK),
Russell Kinga17dba82007-04-21 15:55:06 +0100172};
173
174static struct platform_device pata_device = {
175 .name = "pata_platform",
176 .id = -1,
177 .num_resources = ARRAY_SIZE(pata_resources),
178 .resource = pata_resources,
179 .dev = {
180 .platform_data = &pata_platform_data,
181 .coherent_dma_mask = ~0, /* grumble */
182 },
183};
184
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185static struct platform_device *devs[] __initdata = {
186 &iomd_device,
187 &kbd_device,
188 &serial_device,
189 &acornfb_device,
Russell Kinga17dba82007-04-21 15:55:06 +0100190 &pata_device,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700191};
192
Russell King531660e2009-02-24 19:19:50 +0100193static struct i2c_board_info i2c_rtc = {
194 I2C_BOARD_INFO("pcf8583", 0x50)
195};
196
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197static int __init rpc_init(void)
198{
Russell King531660e2009-02-24 19:19:50 +0100199 i2c_register_board_info(0, &i2c_rtc, 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700200 return platform_add_devices(devs, ARRAY_SIZE(devs));
201}
202
203arch_initcall(rpc_init);
204
Robin Holt7b6d8642013-07-08 16:01:40 -0700205static void rpc_restart(enum reboot_mode mode, const char *cmd)
Russell Kinge11e9092011-11-04 16:42:37 +0000206{
207 iomd_writeb(0, IOMD_ROMCR0);
208
209 /*
210 * Jump into the ROM
211 */
212 soft_restart(0);
213}
214
Stephen Warren6bb27d72012-11-08 12:40:59 -0700215void ioc_timer_init(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700216
217MACHINE_START(RISCPC, "Acorn-RiscPC")
Russell Kinge9dea0c2005-07-03 17:38:58 +0100218 /* Maintainer: Russell King */
Nicolas Pitre237e8872011-07-05 22:38:16 -0400219 .atag_offset = 0x100,
Russell Kinge9dea0c2005-07-03 17:38:58 +0100220 .reserve_lp0 = 1,
221 .reserve_lp1 = 1,
222 .map_io = rpc_map_io,
223 .init_irq = rpc_init_irq,
Stephen Warren6bb27d72012-11-08 12:40:59 -0700224 .init_time = ioc_timer_init,
Russell Kinge11e9092011-11-04 16:42:37 +0000225 .restart = rpc_restart,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700226MACHINE_END