xref: /openbmc/linux/arch/arm/mach-rpc/riscpc.c (revision 2f5947df)
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  *  linux/arch/arm/mach-rpc/riscpc.c
4  *
5  *  Copyright (C) 1998-2001 Russell King
6  *
7  *  Architecture specific fixups.
8  */
9 #include <linux/kernel.h>
10 #include <linux/tty.h>
11 #include <linux/delay.h>
12 #include <linux/pm.h>
13 #include <linux/init.h>
14 #include <linux/sched.h>
15 #include <linux/device.h>
16 #include <linux/serial_8250.h>
17 #include <linux/ata_platform.h>
18 #include <linux/io.h>
19 #include <linux/i2c.h>
20 #include <linux/reboot.h>
21 
22 #include <asm/elf.h>
23 #include <asm/mach-types.h>
24 #include <mach/hardware.h>
25 #include <asm/hardware/iomd.h>
26 #include <asm/page.h>
27 #include <asm/domain.h>
28 #include <asm/setup.h>
29 #include <asm/system_misc.h>
30 
31 #include <asm/mach/map.h>
32 #include <asm/mach/arch.h>
33 #include <asm/mach/time.h>
34 
35 extern void rpc_init_irq(void);
36 
37 unsigned int vram_size;
38 unsigned int memc_ctrl_reg;
39 unsigned int number_mfm_drives;
40 
41 static int __init parse_tag_acorn(const struct tag *tag)
42 {
43 	memc_ctrl_reg = tag->u.acorn.memc_control_reg;
44 	number_mfm_drives = tag->u.acorn.adfsdrives;
45 
46 	switch (tag->u.acorn.vram_pages) {
47 	case 512:
48 		vram_size += PAGE_SIZE * 256;
49 	case 256:
50 		vram_size += PAGE_SIZE * 256;
51 	default:
52 		break;
53 	}
54 #if 0
55 	if (vram_size) {
56 		desc->video_start = 0x02000000;
57 		desc->video_end   = 0x02000000 + vram_size;
58 	}
59 #endif
60 	return 0;
61 }
62 
63 __tagtable(ATAG_ACORN, parse_tag_acorn);
64 
65 static struct map_desc rpc_io_desc[] __initdata = {
66  	{	/* VRAM		*/
67 		.virtual	=  SCREEN_BASE,
68 		.pfn		= __phys_to_pfn(SCREEN_START),
69 		.length		= 	2*1048576,
70 		.type		= MT_DEVICE
71 	}, {	/* IO space	*/
72 		.virtual	=  (u32)IO_BASE,
73 		.pfn		= __phys_to_pfn(IO_START),
74 		.length		= 	IO_SIZE	 ,
75 		.type		= MT_DEVICE
76 	}, {	/* EASI space	*/
77 		.virtual	= (unsigned long)EASI_BASE,
78 		.pfn		= __phys_to_pfn(EASI_START),
79 		.length		= EASI_SIZE,
80 		.type		= MT_DEVICE
81 	}
82 };
83 
84 static void __init rpc_map_io(void)
85 {
86 	iotable_init(rpc_io_desc, ARRAY_SIZE(rpc_io_desc));
87 
88 	/*
89 	 * Turn off floppy.
90 	 */
91 	writeb(0xc, PCIO_BASE + (0x3f2 << 2));
92 
93 	/*
94 	 * RiscPC can't handle half-word loads and stores
95 	 */
96 	elf_hwcap &= ~HWCAP_HALF;
97 }
98 
99 static struct resource acornfb_resources[] = {
100 	/* VIDC */
101 	DEFINE_RES_MEM(0x03400000, 0x00200000),
102 	DEFINE_RES_IRQ(IRQ_VSYNCPULSE),
103 };
104 
105 static struct platform_device acornfb_device = {
106 	.name			= "acornfb",
107 	.id			= -1,
108 	.dev			= {
109 		.coherent_dma_mask = 0xffffffff,
110 	},
111 	.num_resources		= ARRAY_SIZE(acornfb_resources),
112 	.resource		= acornfb_resources,
113 };
114 
115 static struct resource iomd_resources[] = {
116 	DEFINE_RES_MEM(0x03200000, 0x10000),
117 };
118 
119 static struct platform_device iomd_device = {
120 	.name			= "iomd",
121 	.id			= -1,
122 	.num_resources		= ARRAY_SIZE(iomd_resources),
123 	.resource		= iomd_resources,
124 };
125 
126 static struct resource iomd_kart_resources[] = {
127 	DEFINE_RES_IRQ(IRQ_KEYBOARDRX),
128 	DEFINE_RES_IRQ(IRQ_KEYBOARDTX),
129 };
130 
131 static struct platform_device kbd_device = {
132 	.name			= "kart",
133 	.id			= -1,
134 	.dev			= {
135 		.parent 	= &iomd_device.dev,
136 	},
137 	.num_resources		= ARRAY_SIZE(iomd_kart_resources),
138 	.resource		= iomd_kart_resources,
139 };
140 
141 static struct plat_serial8250_port serial_platform_data[] = {
142 	{
143 		.mapbase	= 0x03010fe0,
144 		.irq		= IRQ_SERIALPORT,
145 		.uartclk	= 1843200,
146 		.regshift	= 2,
147 		.iotype		= UPIO_MEM,
148 		.flags		= UPF_BOOT_AUTOCONF | UPF_IOREMAP | UPF_SKIP_TEST,
149 	},
150 	{ },
151 };
152 
153 static struct platform_device serial_device = {
154 	.name			= "serial8250",
155 	.id			= PLAT8250_DEV_PLATFORM,
156 	.dev			= {
157 		.platform_data	= serial_platform_data,
158 	},
159 };
160 
161 static struct pata_platform_info pata_platform_data = {
162 	.ioport_shift		= 2,
163 };
164 
165 static struct resource pata_resources[] = {
166 	DEFINE_RES_MEM(0x030107c0, 0x20),
167 	DEFINE_RES_MEM(0x03010fd8, 0x04),
168 	DEFINE_RES_IRQ(IRQ_HARDDISK),
169 };
170 
171 static struct platform_device pata_device = {
172 	.name			= "pata_platform",
173 	.id			= -1,
174 	.num_resources		= ARRAY_SIZE(pata_resources),
175 	.resource		= pata_resources,
176 	.dev			= {
177 		.platform_data	= &pata_platform_data,
178 		.coherent_dma_mask = ~0,	/* grumble */
179 	},
180 };
181 
182 static struct platform_device *devs[] __initdata = {
183 	&iomd_device,
184 	&kbd_device,
185 	&serial_device,
186 	&acornfb_device,
187 	&pata_device,
188 };
189 
190 static struct i2c_board_info i2c_rtc = {
191 	I2C_BOARD_INFO("pcf8583", 0x50)
192 };
193 
194 static int __init rpc_init(void)
195 {
196 	i2c_register_board_info(0, &i2c_rtc, 1);
197 	return platform_add_devices(devs, ARRAY_SIZE(devs));
198 }
199 
200 arch_initcall(rpc_init);
201 
202 static void rpc_restart(enum reboot_mode mode, const char *cmd)
203 {
204 	iomd_writeb(0, IOMD_ROMCR0);
205 
206 	/*
207 	 * Jump into the ROM
208 	 */
209 	soft_restart(0);
210 }
211 
212 void ioc_timer_init(void);
213 
214 MACHINE_START(RISCPC, "Acorn-RiscPC")
215 	/* Maintainer: Russell King */
216 	.atag_offset	= 0x100,
217 	.reserve_lp0	= 1,
218 	.reserve_lp1	= 1,
219 	.map_io		= rpc_map_io,
220 	.init_irq	= rpc_init_irq,
221 	.init_time	= ioc_timer_init,
222 	.restart	= rpc_restart,
223 MACHINE_END
224