11da177e4SLinus Torvalds/*
21da177e4SLinus Torvalds *  linux/arch/m68k/amiga/config.c
31da177e4SLinus Torvalds *
41da177e4SLinus Torvalds *  Copyright (C) 1993 Hamish Macdonald
51da177e4SLinus Torvalds *
61da177e4SLinus Torvalds * This file is subject to the terms and conditions of the GNU General Public
71da177e4SLinus Torvalds * License.  See the file COPYING in the main directory of this archive
81da177e4SLinus Torvalds * for more details.
91da177e4SLinus Torvalds */
101da177e4SLinus Torvalds
111da177e4SLinus Torvalds/*
121da177e4SLinus Torvalds * Miscellaneous Amiga stuff
131da177e4SLinus Torvalds */
141da177e4SLinus Torvalds
151da177e4SLinus Torvalds#include <linux/types.h>
161da177e4SLinus Torvalds#include <linux/kernel.h>
171da177e4SLinus Torvalds#include <linux/mm.h>
18813dcf7aSAlexey Dobriyan#include <linux/seq_file.h>
191da177e4SLinus Torvalds#include <linux/tty.h>
205afd3d06SFinn Thain#include <linux/clocksource.h>
211da177e4SLinus Torvalds#include <linux/console.h>
221da177e4SLinus Torvalds#include <linux/rtc.h>
231da177e4SLinus Torvalds#include <linux/init.h>
241da177e4SLinus Torvalds#include <linux/vt_kern.h>
251da177e4SLinus Torvalds#include <linux/delay.h>
261da177e4SLinus Torvalds#include <linux/interrupt.h>
271da177e4SLinus Torvalds#include <linux/zorro.h>
288b169fa2SAdrian Bunk#include <linux/module.h>
2939d2d99dSGeert Uytterhoeven#include <linux/keyboard.h>
301da177e4SLinus Torvalds
311da177e4SLinus Torvalds#include <asm/bootinfo.h>
324c3c522bSGeert Uytterhoeven#include <asm/bootinfo-amiga.h>
33bd9ba8f4SGeert Uytterhoeven#include <asm/byteorder.h>
341da177e4SLinus Torvalds#include <asm/setup.h>
351da177e4SLinus Torvalds#include <asm/amigahw.h>
361da177e4SLinus Torvalds#include <asm/amigaints.h>
371da177e4SLinus Torvalds#include <asm/irq.h>
381da177e4SLinus Torvalds#include <asm/machdep.h>
391da177e4SLinus Torvalds#include <asm/io.h>
401da177e4SLinus Torvalds
410795dbccSAdrian Bunkstatic unsigned long amiga_model;
428b169fa2SAdrian Bunk
431da177e4SLinus Torvaldsunsigned long amiga_eclock;
448b169fa2SAdrian BunkEXPORT_SYMBOL(amiga_eclock);
458b169fa2SAdrian Bunk
461da177e4SLinus Torvaldsunsigned long amiga_colorclock;
478b169fa2SAdrian BunkEXPORT_SYMBOL(amiga_colorclock);
488b169fa2SAdrian Bunk
491da177e4SLinus Torvaldsunsigned long amiga_chipset;
508b169fa2SAdrian BunkEXPORT_SYMBOL(amiga_chipset);
518b169fa2SAdrian Bunk
521da177e4SLinus Torvaldsunsigned char amiga_vblank;
538468afc0SAdrian BunkEXPORT_SYMBOL(amiga_vblank);
548468afc0SAdrian Bunk
550795dbccSAdrian Bunkstatic unsigned char amiga_psfreq;
568b169fa2SAdrian Bunk
571da177e4SLinus Torvaldsstruct amiga_hw_present amiga_hw_present;
588b169fa2SAdrian BunkEXPORT_SYMBOL(amiga_hw_present);
591da177e4SLinus Torvalds
601da177e4SLinus Torvaldsstatic char s_a500[] __initdata = "A500";
611da177e4SLinus Torvaldsstatic char s_a500p[] __initdata = "A500+";
621da177e4SLinus Torvaldsstatic char s_a600[] __initdata = "A600";
631da177e4SLinus Torvaldsstatic char s_a1000[] __initdata = "A1000";
641da177e4SLinus Torvaldsstatic char s_a1200[] __initdata = "A1200";
651da177e4SLinus Torvaldsstatic char s_a2000[] __initdata = "A2000";
661da177e4SLinus Torvaldsstatic char s_a2500[] __initdata = "A2500";
671da177e4SLinus Torvaldsstatic char s_a3000[] __initdata = "A3000";
681da177e4SLinus Torvaldsstatic char s_a3000t[] __initdata = "A3000T";
691da177e4SLinus Torvaldsstatic char s_a3000p[] __initdata = "A3000+";
701da177e4SLinus Torvaldsstatic char s_a4000[] __initdata = "A4000";
711da177e4SLinus Torvaldsstatic char s_a4000t[] __initdata = "A4000T";
721da177e4SLinus Torvaldsstatic char s_cdtv[] __initdata = "CDTV";
731da177e4SLinus Torvaldsstatic char s_cd32[] __initdata = "CD32";
741da177e4SLinus Torvaldsstatic char s_draco[] __initdata = "Draco";
751da177e4SLinus Torvaldsstatic char *amiga_models[] __initdata = {
766ff5801aSRoman Zippel	[AMI_500-AMI_500]	= s_a500,
776ff5801aSRoman Zippel	[AMI_500PLUS-AMI_500]	= s_a500p,
786ff5801aSRoman Zippel	[AMI_600-AMI_500]	= s_a600,
796ff5801aSRoman Zippel	[AMI_1000-AMI_500]	= s_a1000,
806ff5801aSRoman Zippel	[AMI_1200-AMI_500]	= s_a1200,
816ff5801aSRoman Zippel	[AMI_2000-AMI_500]	= s_a2000,
826ff5801aSRoman Zippel	[AMI_2500-AMI_500]	= s_a2500,
836ff5801aSRoman Zippel	[AMI_3000-AMI_500]	= s_a3000,
846ff5801aSRoman Zippel	[AMI_3000T-AMI_500]	= s_a3000t,
856ff5801aSRoman Zippel	[AMI_3000PLUS-AMI_500]	= s_a3000p,
866ff5801aSRoman Zippel	[AMI_4000-AMI_500]	= s_a4000,
876ff5801aSRoman Zippel	[AMI_4000T-AMI_500]	= s_a4000t,
886ff5801aSRoman Zippel	[AMI_CDTV-AMI_500]	= s_cdtv,
896ff5801aSRoman Zippel	[AMI_CD32-AMI_500]	= s_cd32,
906ff5801aSRoman Zippel	[AMI_DRACO-AMI_500]	= s_draco,
911da177e4SLinus Torvalds};
921da177e4SLinus Torvalds
931da177e4SLinus Torvaldsstatic char amiga_model_name[13] = "Amiga ";
941da177e4SLinus Torvalds
95f9a01539SArnd Bergmannstatic void amiga_sched_init(void);
961da177e4SLinus Torvaldsstatic void amiga_get_model(char *model);
97813dcf7aSAlexey Dobriyanstatic void amiga_get_hardware_list(struct seq_file *m);
986ff5801aSRoman Zippelextern void amiga_mksound(unsigned int count, unsigned int ticks);
996ff5801aSRoman Zippelstatic void amiga_reset(void);
1001da177e4SLinus Torvaldsextern void amiga_init_sound(void);
1011da177e4SLinus Torvaldsstatic void amiga_mem_console_write(struct console *co, const char *b,
1021da177e4SLinus Torvalds				    unsigned int count);
1031da177e4SLinus Torvalds#ifdef CONFIG_HEARTBEAT
1041da177e4SLinus Torvaldsstatic void amiga_heartbeat(int on);
1051da177e4SLinus Torvalds#endif
1061da177e4SLinus Torvalds
1071da177e4SLinus Torvaldsstatic struct console amiga_console_driver = {
1086ff5801aSRoman Zippel	.name	= "debug",
1096ff5801aSRoman Zippel	.flags	= CON_PRINTBUFFER,
1106ff5801aSRoman Zippel	.index	= -1,
1111da177e4SLinus Torvalds};
1121da177e4SLinus Torvalds
1131da177e4SLinus Torvalds
1141da177e4SLinus Torvalds    /*
1151da177e4SLinus Torvalds     *  Motherboard Resources present in all Amiga models
1161da177e4SLinus Torvalds     */
1171da177e4SLinus Torvalds
1181da177e4SLinus Torvaldsstatic struct {
1196ff5801aSRoman Zippel	struct resource _ciab, _ciaa, _custom, _kickstart;
1201da177e4SLinus Torvalds} mb_resources = {
1216ff5801aSRoman Zippel	._ciab = {
1226ff5801aSRoman Zippel		.name = "CIA B", .start = 0x00bfd000, .end = 0x00bfdfff
1236ff5801aSRoman Zippel	},
1246ff5801aSRoman Zippel	._ciaa = {
1256ff5801aSRoman Zippel		.name = "CIA A", .start = 0x00bfe000, .end = 0x00bfefff
1266ff5801aSRoman Zippel	},
1276ff5801aSRoman Zippel	._custom = {
1286ff5801aSRoman Zippel		.name = "Custom I/O", .start = 0x00dff000, .end = 0x00dfffff
1296ff5801aSRoman Zippel	},
1306ff5801aSRoman Zippel	._kickstart = {
1316ff5801aSRoman Zippel		.name = "Kickstart ROM", .start = 0x00f80000, .end = 0x00ffffff
1326ff5801aSRoman Zippel	}
1331da177e4SLinus Torvalds};
1341da177e4SLinus Torvalds
1351da177e4SLinus Torvaldsstatic struct resource ram_resource[NUM_MEMINFO];
1361da177e4SLinus Torvalds
1371da177e4SLinus Torvalds
1381da177e4SLinus Torvalds    /*
1391da177e4SLinus Torvalds     *  Parse an Amiga-specific record in the bootinfo
1401da177e4SLinus Torvalds     */
1411da177e4SLinus Torvalds
142a4df02a2SGeert Uytterhoevenint __init amiga_parse_bootinfo(const struct bi_record *record)
1431da177e4SLinus Torvalds{
1446ff5801aSRoman Zippel	int unknown = 0;
145abe48101SGeert Uytterhoeven	const void *data = record->data;
1461da177e4SLinus Torvalds
147abe48101SGeert Uytterhoeven	switch (be16_to_cpu(record->tag)) {
1481da177e4SLinus Torvalds	case BI_AMIGA_MODEL:
149abe48101SGeert Uytterhoeven		amiga_model = be32_to_cpup(data);
1506ff5801aSRoman Zippel		break;
1511da177e4SLinus Torvalds
1521da177e4SLinus Torvalds	case BI_AMIGA_ECLOCK:
153abe48101SGeert Uytterhoeven		amiga_eclock = be32_to_cpup(data);
1546ff5801aSRoman Zippel		break;
1551da177e4SLinus Torvalds
1561da177e4SLinus Torvalds	case BI_AMIGA_CHIPSET:
157abe48101SGeert Uytterhoeven		amiga_chipset = be32_to_cpup(data);
1586ff5801aSRoman Zippel		break;
1591da177e4SLinus Torvalds
1601da177e4SLinus Torvalds	case BI_AMIGA_CHIP_SIZE:
161abe48101SGeert Uytterhoeven		amiga_chip_size = be32_to_cpup(data);
1626ff5801aSRoman Zippel		break;
1631da177e4SLinus Torvalds
1641da177e4SLinus Torvalds	case BI_AMIGA_VBLANK:
165abe48101SGeert Uytterhoeven		amiga_vblank = *(const __u8 *)data;
1666ff5801aSRoman Zippel		break;
1671da177e4SLinus Torvalds
1681da177e4SLinus Torvalds	case BI_AMIGA_PSFREQ:
169abe48101SGeert Uytterhoeven		amiga_psfreq = *(const __u8 *)data;
1706ff5801aSRoman Zippel		break;
1711da177e4SLinus Torvalds
1721da177e4SLinus Torvalds	case BI_AMIGA_AUTOCON:
1731da177e4SLinus Torvalds#ifdef CONFIG_ZORRO
1746ff5801aSRoman Zippel		if (zorro_num_autocon < ZORRO_NUM_AUTO) {
175abe48101SGeert Uytterhoeven			const struct ConfigDev *cd = data;
176c293738eSGeert Uytterhoeven			struct zorro_dev_init *dev = &zorro_autocon_init[zorro_num_autocon++];
1776ff5801aSRoman Zippel			dev->rom = cd->cd_Rom;
178bd9ba8f4SGeert Uytterhoeven			dev->slotaddr = be16_to_cpu(cd->cd_SlotAddr);
179bd9ba8f4SGeert Uytterhoeven			dev->slotsize = be16_to_cpu(cd->cd_SlotSize);
180bd9ba8f4SGeert Uytterhoeven			dev->boardaddr = be32_to_cpu(cd->cd_BoardAddr);
181bd9ba8f4SGeert Uytterhoeven			dev->boardsize = be32_to_cpu(cd->cd_BoardSize);
1826ff5801aSRoman Zippel		} else
183f296401bSFabian Frederick			pr_warn("amiga_parse_bootinfo: too many AutoConfig devices\n");
1841da177e4SLinus Torvalds#endif /* CONFIG_ZORRO */
1856ff5801aSRoman Zippel		break;
1861da177e4SLinus Torvalds
1871da177e4SLinus Torvalds	case BI_AMIGA_SERPER:
1886ff5801aSRoman Zippel		/* serial port period: ignored here */
1896ff5801aSRoman Zippel		break;
1901da177e4SLinus Torvalds
1911da177e4SLinus Torvalds	default:
1926ff5801aSRoman Zippel		unknown = 1;
1936ff5801aSRoman Zippel	}
1946ff5801aSRoman Zippel	return unknown;
1951da177e4SLinus Torvalds}
1961da177e4SLinus Torvalds
1971da177e4SLinus Torvalds    /*
1981da177e4SLinus Torvalds     *  Identify builtin hardware
1991da177e4SLinus Torvalds     */
2001da177e4SLinus Torvalds
2011da177e4SLinus Torvaldsstatic void __init amiga_identify(void)
2021da177e4SLinus Torvalds{
2036ff5801aSRoman Zippel	/* Fill in some default values, if necessary */
2046ff5801aSRoman Zippel	if (amiga_eclock == 0)
2056ff5801aSRoman Zippel		amiga_eclock = 709379;
2061da177e4SLinus Torvalds
2076ff5801aSRoman Zippel	memset(&amiga_hw_present, 0, sizeof(amiga_hw_present));
2086ff5801aSRoman Zippel
209f296401bSFabian Frederick	pr_info("Amiga hardware found: ");
2106ff5801aSRoman Zippel	if (amiga_model >= AMI_500 && amiga_model <= AMI_DRACO) {
211f296401bSFabian Frederick		pr_cont("[%s] ", amiga_models[amiga_model-AMI_500]);
2126ff5801aSRoman Zippel		strcat(amiga_model_name, amiga_models[amiga_model-AMI_500]);
2136ff5801aSRoman Zippel	}
2146ff5801aSRoman Zippel
2156ff5801aSRoman Zippel	switch (amiga_model) {
2166ff5801aSRoman Zippel	case AMI_UNKNOWN:
217d473de0fSGeert Uytterhoeven		break;
2186ff5801aSRoman Zippel
2196ff5801aSRoman Zippel	case AMI_600:
2206ff5801aSRoman Zippel	case AMI_1200:
2216ff5801aSRoman Zippel		AMIGAHW_SET(A1200_IDE);
2226ff5801aSRoman Zippel		AMIGAHW_SET(PCMCIA);
223e09a7440SGustavo A. R. Silva		fallthrough;
2246ff5801aSRoman Zippel	case AMI_500:
2256ff5801aSRoman Zippel	case AMI_500PLUS:
2266ff5801aSRoman Zippel	case AMI_1000:
2276ff5801aSRoman Zippel	case AMI_2000:
2286ff5801aSRoman Zippel	case AMI_2500:
2296ff5801aSRoman Zippel		AMIGAHW_SET(A2000_CLK);	/* Is this correct for all models? */
230d473de0fSGeert Uytterhoeven		break;
2316ff5801aSRoman Zippel
2326ff5801aSRoman Zippel	case AMI_3000:
2336ff5801aSRoman Zippel	case AMI_3000T:
2346ff5801aSRoman Zippel		AMIGAHW_SET(AMBER_FF);
2356ff5801aSRoman Zippel		AMIGAHW_SET(MAGIC_REKICK);
236e09a7440SGustavo A. R. Silva		fallthrough;
2376ff5801aSRoman Zippel	case AMI_3000PLUS:
2386ff5801aSRoman Zippel		AMIGAHW_SET(A3000_SCSI);
2396ff5801aSRoman Zippel		AMIGAHW_SET(A3000_CLK);
2406ff5801aSRoman Zippel		AMIGAHW_SET(ZORRO3);
241d473de0fSGeert Uytterhoeven		break;
2426ff5801aSRoman Zippel
2436ff5801aSRoman Zippel	case AMI_4000T:
2446ff5801aSRoman Zippel		AMIGAHW_SET(A4000_SCSI);
245e09a7440SGustavo A. R. Silva		fallthrough;
2466ff5801aSRoman Zippel	case AMI_4000:
2476ff5801aSRoman Zippel		AMIGAHW_SET(A4000_IDE);
2486ff5801aSRoman Zippel		AMIGAHW_SET(A3000_CLK);
2496ff5801aSRoman Zippel		AMIGAHW_SET(ZORRO3);
250d473de0fSGeert Uytterhoeven		break;
2516ff5801aSRoman Zippel
2526ff5801aSRoman Zippel	case AMI_CDTV:
2536ff5801aSRoman Zippel	case AMI_CD32:
2546ff5801aSRoman Zippel		AMIGAHW_SET(CD_ROM);
2556ff5801aSRoman Zippel		AMIGAHW_SET(A2000_CLK);             /* Is this correct? */
2566ff5801aSRoman Zippel		break;
2576ff5801aSRoman Zippel
2586ff5801aSRoman Zippel	case AMI_DRACO:
2596ff5801aSRoman Zippel		panic("No support for Draco yet");
2606ff5801aSRoman Zippel
2616ff5801aSRoman Zippel	default:
2626ff5801aSRoman Zippel		panic("Unknown Amiga Model");
2636ff5801aSRoman Zippel	}
2646ff5801aSRoman Zippel
265d473de0fSGeert Uytterhoeven	AMIGAHW_SET(AMI_VIDEO);
266d473de0fSGeert Uytterhoeven	AMIGAHW_SET(AMI_BLITTER);
267d473de0fSGeert Uytterhoeven	AMIGAHW_SET(AMI_AUDIO);
268d473de0fSGeert Uytterhoeven	AMIGAHW_SET(AMI_FLOPPY);
269d473de0fSGeert Uytterhoeven	AMIGAHW_SET(AMI_KEYBOARD);
270d473de0fSGeert Uytterhoeven	AMIGAHW_SET(AMI_MOUSE);
271d473de0fSGeert Uytterhoeven	AMIGAHW_SET(AMI_SERIAL);
272d473de0fSGeert Uytterhoeven	AMIGAHW_SET(AMI_PARALLEL);
273d473de0fSGeert Uytterhoeven	AMIGAHW_SET(CHIP_RAM);
274d473de0fSGeert Uytterhoeven	AMIGAHW_SET(PAULA);
275d473de0fSGeert Uytterhoeven
276d473de0fSGeert Uytterhoeven	switch (amiga_chipset) {
277d473de0fSGeert Uytterhoeven	case CS_OCS:
278d473de0fSGeert Uytterhoeven	case CS_ECS:
279d473de0fSGeert Uytterhoeven	case CS_AGA:
280d473de0fSGeert Uytterhoeven		switch (amiga_custom.deniseid & 0xf) {
281d473de0fSGeert Uytterhoeven		case 0x0c:
282d473de0fSGeert Uytterhoeven			AMIGAHW_SET(DENISE_HR);
283d473de0fSGeert Uytterhoeven			break;
284d473de0fSGeert Uytterhoeven		case 0x08:
285d473de0fSGeert Uytterhoeven			AMIGAHW_SET(LISA);
286d473de0fSGeert Uytterhoeven			break;
287d473de0fSGeert Uytterhoeven		default:
288d473de0fSGeert Uytterhoeven			AMIGAHW_SET(DENISE);
289d473de0fSGeert Uytterhoeven			break;
290d473de0fSGeert Uytterhoeven		}
291d473de0fSGeert Uytterhoeven		break;
292d473de0fSGeert Uytterhoeven	}
293d473de0fSGeert Uytterhoeven	switch ((amiga_custom.vposr>>8) & 0x7f) {
294d473de0fSGeert Uytterhoeven	case 0x00:
295d473de0fSGeert Uytterhoeven		AMIGAHW_SET(AGNUS_PAL);
296d473de0fSGeert Uytterhoeven		break;
297d473de0fSGeert Uytterhoeven	case 0x10:
298d473de0fSGeert Uytterhoeven		AMIGAHW_SET(AGNUS_NTSC);
299d473de0fSGeert Uytterhoeven		break;
300d473de0fSGeert Uytterhoeven	case 0x20:
301d473de0fSGeert Uytterhoeven	case 0x21:
302d473de0fSGeert Uytterhoeven		AMIGAHW_SET(AGNUS_HR_PAL);
303d473de0fSGeert Uytterhoeven		break;
304d473de0fSGeert Uytterhoeven	case 0x30:
305d473de0fSGeert Uytterhoeven	case 0x31:
306d473de0fSGeert Uytterhoeven		AMIGAHW_SET(AGNUS_HR_NTSC);
307d473de0fSGeert Uytterhoeven		break;
308d473de0fSGeert Uytterhoeven	case 0x22:
309d473de0fSGeert Uytterhoeven	case 0x23:
310d473de0fSGeert Uytterhoeven		AMIGAHW_SET(ALICE_PAL);
311d473de0fSGeert Uytterhoeven		break;
312d473de0fSGeert Uytterhoeven	case 0x32:
313d473de0fSGeert Uytterhoeven	case 0x33:
314d473de0fSGeert Uytterhoeven		AMIGAHW_SET(ALICE_NTSC);
315d473de0fSGeert Uytterhoeven		break;
316d473de0fSGeert Uytterhoeven	}
317d473de0fSGeert Uytterhoeven	AMIGAHW_SET(ZORRO);
318d473de0fSGeert Uytterhoeven
3196ff5801aSRoman Zippel#define AMIGAHW_ANNOUNCE(name, str)		\
3206ff5801aSRoman Zippel	if (AMIGAHW_PRESENT(name))		\
321f296401bSFabian Frederick		pr_cont(str)
3226ff5801aSRoman Zippel
3236ff5801aSRoman Zippel	AMIGAHW_ANNOUNCE(AMI_VIDEO, "VIDEO ");
3246ff5801aSRoman Zippel	AMIGAHW_ANNOUNCE(AMI_BLITTER, "BLITTER ");
3256ff5801aSRoman Zippel	AMIGAHW_ANNOUNCE(AMBER_FF, "AMBER_FF ");
3266ff5801aSRoman Zippel	AMIGAHW_ANNOUNCE(AMI_AUDIO, "AUDIO ");
3276ff5801aSRoman Zippel	AMIGAHW_ANNOUNCE(AMI_FLOPPY, "FLOPPY ");
3286ff5801aSRoman Zippel	AMIGAHW_ANNOUNCE(A3000_SCSI, "A3000_SCSI ");
3296ff5801aSRoman Zippel	AMIGAHW_ANNOUNCE(A4000_SCSI, "A4000_SCSI ");
3306ff5801aSRoman Zippel	AMIGAHW_ANNOUNCE(A1200_IDE, "A1200_IDE ");
3316ff5801aSRoman Zippel	AMIGAHW_ANNOUNCE(A4000_IDE, "A4000_IDE ");
3326ff5801aSRoman Zippel	AMIGAHW_ANNOUNCE(CD_ROM, "CD_ROM ");
3336ff5801aSRoman Zippel	AMIGAHW_ANNOUNCE(AMI_KEYBOARD, "KEYBOARD ");
3346ff5801aSRoman Zippel	AMIGAHW_ANNOUNCE(AMI_MOUSE, "MOUSE ");
3356ff5801aSRoman Zippel	AMIGAHW_ANNOUNCE(AMI_SERIAL, "SERIAL ");
3366ff5801aSRoman Zippel	AMIGAHW_ANNOUNCE(AMI_PARALLEL, "PARALLEL ");
3376ff5801aSRoman Zippel	AMIGAHW_ANNOUNCE(A2000_CLK, "A2000_CLK ");
3386ff5801aSRoman Zippel	AMIGAHW_ANNOUNCE(A3000_CLK, "A3000_CLK ");
3396ff5801aSRoman Zippel	AMIGAHW_ANNOUNCE(CHIP_RAM, "CHIP_RAM ");
3406ff5801aSRoman Zippel	AMIGAHW_ANNOUNCE(PAULA, "PAULA ");
3416ff5801aSRoman Zippel	AMIGAHW_ANNOUNCE(DENISE, "DENISE ");
3426ff5801aSRoman Zippel	AMIGAHW_ANNOUNCE(DENISE_HR, "DENISE_HR ");
3436ff5801aSRoman Zippel	AMIGAHW_ANNOUNCE(LISA, "LISA ");
3446ff5801aSRoman Zippel	AMIGAHW_ANNOUNCE(AGNUS_PAL, "AGNUS_PAL ");
3456ff5801aSRoman Zippel	AMIGAHW_ANNOUNCE(AGNUS_NTSC, "AGNUS_NTSC ");
3466ff5801aSRoman Zippel	AMIGAHW_ANNOUNCE(AGNUS_HR_PAL, "AGNUS_HR_PAL ");
3476ff5801aSRoman Zippel	AMIGAHW_ANNOUNCE(AGNUS_HR_NTSC, "AGNUS_HR_NTSC ");
3486ff5801aSRoman Zippel	AMIGAHW_ANNOUNCE(ALICE_PAL, "ALICE_PAL ");
3496ff5801aSRoman Zippel	AMIGAHW_ANNOUNCE(ALICE_NTSC, "ALICE_NTSC ");
3506ff5801aSRoman Zippel	AMIGAHW_ANNOUNCE(MAGIC_REKICK, "MAGIC_REKICK ");
3516ff5801aSRoman Zippel	AMIGAHW_ANNOUNCE(PCMCIA, "PCMCIA ");
3526ff5801aSRoman Zippel	if (AMIGAHW_PRESENT(ZORRO))
353f296401bSFabian Frederick		pr_cont("ZORRO%s ", AMIGAHW_PRESENT(ZORRO3) ? "3" : "");
354f296401bSFabian Frederick	pr_cont("\n");
3551da177e4SLinus Torvalds
3561da177e4SLinus Torvalds#undef AMIGAHW_ANNOUNCE
3571da177e4SLinus Torvalds}
3581da177e4SLinus Torvalds
35950190edbSGeert Uytterhoeven
36050190edbSGeert Uytterhoevenstatic unsigned long amiga_random_get_entropy(void)
36150190edbSGeert Uytterhoeven{
36250190edbSGeert Uytterhoeven	/* VPOSR/VHPOSR provide at least 17 bits of data changing at 1.79 MHz */
36350190edbSGeert Uytterhoeven	return *(unsigned long *)&amiga_custom.vposr;
36450190edbSGeert Uytterhoeven}
36550190edbSGeert Uytterhoeven
36650190edbSGeert Uytterhoeven
3671da177e4SLinus Torvalds    /*
3681da177e4SLinus Torvalds     *  Setup the Amiga configuration info
3691da177e4SLinus Torvalds     */
3701da177e4SLinus Torvalds
3711da177e4SLinus Torvaldsvoid __init config_amiga(void)
3721da177e4SLinus Torvalds{
3736ff5801aSRoman Zippel	int i;
3746ff5801aSRoman Zippel
3756ff5801aSRoman Zippel	amiga_identify();
3766ff5801aSRoman Zippel
3776ff5801aSRoman Zippel	/* Yuk, we don't have PCI memory */
3786ff5801aSRoman Zippel	iomem_resource.name = "Memory";
3796ff5801aSRoman Zippel	for (i = 0; i < 4; i++)
3806ff5801aSRoman Zippel		request_resource(&iomem_resource, &((struct resource *)&mb_resources)[i]);
3816ff5801aSRoman Zippel
3826ff5801aSRoman Zippel	mach_sched_init      = amiga_sched_init;
3836ff5801aSRoman Zippel	mach_init_IRQ        = amiga_init_IRQ;
3846ff5801aSRoman Zippel	mach_get_model       = amiga_get_model;
3856ff5801aSRoman Zippel	mach_get_hardware_list = amiga_get_hardware_list;
3866ff5801aSRoman Zippel	mach_reset           = amiga_reset;
387a1a9e88fSGeert Uytterhoeven#if IS_ENABLED(CONFIG_INPUT_M68K_BEEP)
3886ff5801aSRoman Zippel	mach_beep            = amiga_mksound;
3891da177e4SLinus Torvalds#endif
3901da177e4SLinus Torvalds
3911da177e4SLinus Torvalds#ifdef CONFIG_HEARTBEAT
3926ff5801aSRoman Zippel	mach_heartbeat = amiga_heartbeat;
3931da177e4SLinus Torvalds#endif
3941da177e4SLinus Torvalds
39550190edbSGeert Uytterhoeven	mach_random_get_entropy = amiga_random_get_entropy;
39650190edbSGeert Uytterhoeven
3970795dbccSAdrian Bunk	/* Fill in the clock value (based on the 700 kHz E-Clock) */
3986ff5801aSRoman Zippel	amiga_colorclock = 5*amiga_eclock;	/* 3.5 MHz */
3996ff5801aSRoman Zippel
4006ff5801aSRoman Zippel	/* clear all DMA bits */
4016ff5801aSRoman Zippel	amiga_custom.dmacon = DMAF_ALL;
4026ff5801aSRoman Zippel	/* ensure that the DMA master bit is set */
4036ff5801aSRoman Zippel	amiga_custom.dmacon = DMAF_SETCLR | DMAF_MASTER;
4046ff5801aSRoman Zippel
4056ff5801aSRoman Zippel	/* don't use Z2 RAM as system memory on Z3 capable machines */
4066ff5801aSRoman Zippel	if (AMIGAHW_PRESENT(ZORRO3)) {
4076ff5801aSRoman Zippel		int i, j;
4086ff5801aSRoman Zippel		u32 disabled_z2mem = 0;
4096ff5801aSRoman Zippel
4106ff5801aSRoman Zippel		for (i = 0; i < m68k_num_memory; i++) {
4116ff5801aSRoman Zippel			if (m68k_memory[i].addr < 16*1024*1024) {
4126ff5801aSRoman Zippel				if (i == 0) {
4136ff5801aSRoman Zippel					/* don't cut off the branch we're sitting on */
414f296401bSFabian Frederick					pr_warn("Warning: kernel runs in Zorro II memory\n");
4156ff5801aSRoman Zippel					continue;
4166ff5801aSRoman Zippel				}
4176ff5801aSRoman Zippel				disabled_z2mem += m68k_memory[i].size;
4186ff5801aSRoman Zippel				m68k_num_memory--;
4196ff5801aSRoman Zippel				for (j = i; j < m68k_num_memory; j++)
4206ff5801aSRoman Zippel					m68k_memory[j] = m68k_memory[j+1];
4216ff5801aSRoman Zippel				i--;
4226ff5801aSRoman Zippel			}
4236ff5801aSRoman Zippel		}
4246ff5801aSRoman Zippel		if (disabled_z2mem)
425f296401bSFabian Frederick			pr_info("%dK of Zorro II memory will not be used as system memory\n",
426f296401bSFabian Frederick				disabled_z2mem>>10);
4276ff5801aSRoman Zippel	}
4286ff5801aSRoman Zippel
4296ff5801aSRoman Zippel	/* request all RAM */
4306ff5801aSRoman Zippel	for (i = 0; i < m68k_num_memory; i++) {
4316ff5801aSRoman Zippel		ram_resource[i].name =
4326ff5801aSRoman Zippel			(m68k_memory[i].addr >= 0x01000000) ? "32-bit Fast RAM" :
4336ff5801aSRoman Zippel			(m68k_memory[i].addr < 0x00c00000) ? "16-bit Fast RAM" :
4346ff5801aSRoman Zippel			"16-bit Slow RAM";
4356ff5801aSRoman Zippel		ram_resource[i].start = m68k_memory[i].addr;
4366ff5801aSRoman Zippel		ram_resource[i].end = m68k_memory[i].addr+m68k_memory[i].size-1;
4376ff5801aSRoman Zippel		request_resource(&iomem_resource, &ram_resource[i]);
4386ff5801aSRoman Zippel	}
4396ff5801aSRoman Zippel
4406ff5801aSRoman Zippel	/* initialize chipram allocator */
4416ff5801aSRoman Zippel	amiga_chip_init();
4426ff5801aSRoman Zippel
4436ff5801aSRoman Zippel	/* our beloved beeper */
4446ff5801aSRoman Zippel	if (AMIGAHW_PRESENT(AMI_AUDIO))
4456ff5801aSRoman Zippel		amiga_init_sound();
4466ff5801aSRoman Zippel
4476ff5801aSRoman Zippel	/*
4486ff5801aSRoman Zippel	 * if it is an A3000, set the magic bit that forces
4496ff5801aSRoman Zippel	 * a hard rekick
4506ff5801aSRoman Zippel	 */
4516ff5801aSRoman Zippel	if (AMIGAHW_PRESENT(MAGIC_REKICK))
4526ff5801aSRoman Zippel		*(unsigned char *)ZTWO_VADDR(0xde0002) |= 0x80;
4531da177e4SLinus Torvalds}
4541da177e4SLinus Torvalds
4555afd3d06SFinn Thainstatic u64 amiga_read_clk(struct clocksource *cs);
4565afd3d06SFinn Thain
4575afd3d06SFinn Thainstatic struct clocksource amiga_clk = {
4585afd3d06SFinn Thain	.name   = "ciab",
4595afd3d06SFinn Thain	.rating = 250,
4605afd3d06SFinn Thain	.read   = amiga_read_clk,
4615afd3d06SFinn Thain	.mask   = CLOCKSOURCE_MASK(32),
4625afd3d06SFinn Thain	.flags  = CLOCK_SOURCE_IS_CONTINUOUS,
4635afd3d06SFinn Thain};
4645afd3d06SFinn Thain
4651da177e4SLinus Torvaldsstatic unsigned short jiffy_ticks;
4665afd3d06SFinn Thainstatic u32 clk_total, clk_offset;
4675afd3d06SFinn Thain
4685afd3d06SFinn Thainstatic irqreturn_t ciab_timer_handler(int irq, void *dev_id)
4695afd3d06SFinn Thain{
4705afd3d06SFinn Thain	clk_total += jiffy_ticks;
4715afd3d06SFinn Thain	clk_offset = 0;
47242f1d57fSArnd Bergmann	legacy_timer_tick(1);
473d6444094SArnd Bergmann	timer_heartbeat();
4745afd3d06SFinn Thain
4755afd3d06SFinn Thain	return IRQ_HANDLED;
4765afd3d06SFinn Thain}
4771da177e4SLinus Torvalds
478f9a01539SArnd Bergmannstatic void __init amiga_sched_init(void)
4791da177e4SLinus Torvalds{
4801da177e4SLinus Torvalds	static struct resource sched_res = {
4816ff5801aSRoman Zippel		.name = "timer", .start = 0x00bfd400, .end = 0x00bfd5ff,
4821da177e4SLinus Torvalds	};
4831a0caf41SJulia Lawall	jiffy_ticks = DIV_ROUND_CLOSEST(amiga_eclock, HZ);
4841da177e4SLinus Torvalds
4851da177e4SLinus Torvalds	if (request_resource(&mb_resources._ciab, &sched_res))
486f296401bSFabian Frederick		pr_warn("Cannot allocate ciab.ta{lo,hi}\n");
4871da177e4SLinus Torvalds	ciab.cra &= 0xC0;   /* turn off timer A, continuous mode, from Eclk */
4881da177e4SLinus Torvalds	ciab.talo = jiffy_ticks % 256;
4891da177e4SLinus Torvalds	ciab.tahi = jiffy_ticks / 256;
4901da177e4SLinus Torvalds
4911da177e4SLinus Torvalds	/* install interrupt service routine for CIAB Timer A
4921da177e4SLinus Torvalds	 *
4931da177e4SLinus Torvalds	 * Please don't change this to use ciaa, as it interferes with the
4941da177e4SLinus Torvalds	 * SCSI code. We'll have to take a look at this later
4951da177e4SLinus Torvalds	 */
4965afd3d06SFinn Thain	if (request_irq(IRQ_AMIGA_CIAB_TA, ciab_timer_handler, IRQF_TIMER,
49742f1d57fSArnd Bergmann			"timer", NULL))
49866acd258SGeert Uytterhoeven		pr_err("Couldn't register timer interrupt\n");
4991da177e4SLinus Torvalds	/* start timer */
5001da177e4SLinus Torvalds	ciab.cra |= 0x11;
5011da177e4SLinus Torvalds
5025afd3d06SFinn Thain	clocksource_register_hz(&amiga_clk, amiga_eclock);
5035afd3d06SFinn Thain}
5041da177e4SLinus Torvalds
5055afd3d06SFinn Thainstatic u64 amiga_read_clk(struct clocksource *cs)
5061da177e4SLinus Torvalds{
5071da177e4SLinus Torvalds	unsigned short hi, lo, hi2;
5085afd3d06SFinn Thain	unsigned long flags;
5095afd3d06SFinn Thain	u32 ticks;
5105afd3d06SFinn Thain
5115afd3d06SFinn Thain	local_irq_save(flags);
5121da177e4SLinus Torvalds
5131da177e4SLinus Torvalds	/* read CIA B timer A current value */
5141da177e4SLinus Torvalds	hi  = ciab.tahi;
5151da177e4SLinus Torvalds	lo  = ciab.talo;
5161da177e4SLinus Torvalds	hi2 = ciab.tahi;
5171da177e4SLinus Torvalds
5181da177e4SLinus Torvalds	if (hi != hi2) {
5191da177e4SLinus Torvalds		lo = ciab.talo;
5201da177e4SLinus Torvalds		hi = hi2;
5211da177e4SLinus Torvalds	}
5221da177e4SLinus Torvalds
5231da177e4SLinus Torvalds	ticks = hi << 8 | lo;
5241da177e4SLinus Torvalds
5251da177e4SLinus Torvalds	if (ticks > jiffy_ticks / 2)
5261da177e4SLinus Torvalds		/* check for pending interrupt */
5271da177e4SLinus Torvalds		if (cia_set_irq(&ciab_base, 0) & CIA_ICR_TA)
5285afd3d06SFinn Thain			clk_offset = jiffy_ticks;
5291da177e4SLinus Torvalds
5301da177e4SLinus Torvalds	ticks = jiffy_ticks - ticks;
5315afd3d06SFinn Thain	ticks += clk_offset + clk_total;
5325afd3d06SFinn Thain
5335afd3d06SFinn Thain	local_irq_restore(flags);
5341da177e4SLinus Torvalds
5355afd3d06SFinn Thain	return ticks;
5361da177e4SLinus Torvalds}
5371da177e4SLinus Torvalds
538ff2d8b19SJoe Perchesstatic void amiga_reset(void)  __noreturn;
5391da177e4SLinus Torvalds
5406ff5801aSRoman Zippelstatic void amiga_reset(void)
5411da177e4SLinus Torvalds{
5426ff5801aSRoman Zippel	unsigned long jmp_addr040 = virt_to_phys(&&jmp_addr_label040);
5436ff5801aSRoman Zippel	unsigned long jmp_addr = virt_to_phys(&&jmp_addr_label);
5446ff5801aSRoman Zippel
5456ff5801aSRoman Zippel	local_irq_disable();
5466ff5801aSRoman Zippel	if (CPU_IS_040_OR_060)
5476ff5801aSRoman Zippel		/* Setup transparent translation registers for mapping
5486ff5801aSRoman Zippel		 * of 16 MB kernel segment before disabling translation
5496ff5801aSRoman Zippel		 */
5506ff5801aSRoman Zippel		asm volatile ("\n"
5516ff5801aSRoman Zippel			"	move.l	%0,%%d0\n"
5526ff5801aSRoman Zippel			"	and.l	#0xff000000,%%d0\n"
5536ff5801aSRoman Zippel			"	or.w	#0xe020,%%d0\n"   /* map 16 MB, enable, cacheable */
5546ff5801aSRoman Zippel			"	.chip	68040\n"
5556ff5801aSRoman Zippel			"	movec	%%d0,%%itt0\n"
5566ff5801aSRoman Zippel			"	movec	%%d0,%%dtt0\n"
5576ff5801aSRoman Zippel			"	.chip	68k\n"
5586ff5801aSRoman Zippel			"	jmp	%0@\n"
5596ff5801aSRoman Zippel			: /* no outputs */
5606ff5801aSRoman Zippel			: "a" (jmp_addr040)
5616ff5801aSRoman Zippel			: "d0");
5626ff5801aSRoman Zippel	else
5636ff5801aSRoman Zippel		/* for 680[23]0, just disable translation and jump to the physical
5646ff5801aSRoman Zippel		 * address of the label
5656ff5801aSRoman Zippel		 */
5666ff5801aSRoman Zippel		asm volatile ("\n"
5676ff5801aSRoman Zippel			"	pmove	%%tc,%@\n"
5686ff5801aSRoman Zippel			"	bclr	#7,%@\n"
5696ff5801aSRoman Zippel			"	pmove	%@,%%tc\n"
5706ff5801aSRoman Zippel			"	jmp	%0@\n"
5716ff5801aSRoman Zippel			: /* no outputs */
5726ff5801aSRoman Zippel			: "a" (jmp_addr));
5736ff5801aSRoman Zippeljmp_addr_label040:
5746ff5801aSRoman Zippel	/* disable translation on '040 now */
5756ff5801aSRoman Zippel	asm volatile ("\n"
5766ff5801aSRoman Zippel		"	moveq	#0,%%d0\n"
5776ff5801aSRoman Zippel		"	.chip	68040\n"
5786ff5801aSRoman Zippel		"	movec	%%d0,%%tc\n"	/* disable MMU */
5796ff5801aSRoman Zippel		"	.chip	68k\n"
5806ff5801aSRoman Zippel		: /* no outputs */
5816ff5801aSRoman Zippel		: /* no inputs */
5826ff5801aSRoman Zippel		: "d0");
5836ff5801aSRoman Zippel
5846ff5801aSRoman Zippel	jmp_addr_label:
5856ff5801aSRoman Zippel	/* pickup reset address from AmigaOS ROM, reset devices and jump
5866ff5801aSRoman Zippel	 * to reset address
5876ff5801aSRoman Zippel	 */
5886ff5801aSRoman Zippel	asm volatile ("\n"
5896ff5801aSRoman Zippel		"	move.w	#0x2700,%sr\n"
5906ff5801aSRoman Zippel		"	lea	0x01000000,%a0\n"
5916ff5801aSRoman Zippel		"	sub.l	%a0@(-0x14),%a0\n"
5926ff5801aSRoman Zippel		"	move.l	%a0@(4),%a0\n"
5936ff5801aSRoman Zippel		"	subq.l	#2,%a0\n"
5946ff5801aSRoman Zippel		"	jra	1f\n"
5956ff5801aSRoman Zippel		/* align on a longword boundary */
5966ff5801aSRoman Zippel		"	" __ALIGN_STR "\n"
5976ff5801aSRoman Zippel		"1:\n"
5986ff5801aSRoman Zippel		"	reset\n"
5996ff5801aSRoman Zippel		"	jmp   %a0@");
6006ff5801aSRoman Zippel
6016ff5801aSRoman Zippel	for (;;)
6026ff5801aSRoman Zippel		;
6031da177e4SLinus Torvalds}
6041da177e4SLinus Torvalds
6051da177e4SLinus Torvalds
6061da177e4SLinus Torvalds    /*
6071da177e4SLinus Torvalds     *  Debugging
6081da177e4SLinus Torvalds     */
6091da177e4SLinus Torvalds
6101da177e4SLinus Torvalds#define SAVEKMSG_MAXMEM		128*1024
6111da177e4SLinus Torvalds
6121da177e4SLinus Torvalds#define SAVEKMSG_MAGIC1		0x53415645	/* 'SAVE' */
6131da177e4SLinus Torvalds#define SAVEKMSG_MAGIC2		0x4B4D5347	/* 'KMSG' */
6141da177e4SLinus Torvalds
6151da177e4SLinus Torvaldsstruct savekmsg {
6166ff5801aSRoman Zippel	unsigned long magic1;		/* SAVEKMSG_MAGIC1 */
6176ff5801aSRoman Zippel	unsigned long magic2;		/* SAVEKMSG_MAGIC2 */
6186ff5801aSRoman Zippel	unsigned long magicptr;		/* address of magic1 */
6196ff5801aSRoman Zippel	unsigned long size;
620366b8149SGustavo A. R. Silva	char data[];
6211da177e4SLinus Torvalds};
6221da177e4SLinus Torvalds
6231da177e4SLinus Torvaldsstatic struct savekmsg *savekmsg;
6241da177e4SLinus Torvalds
6251da177e4SLinus Torvaldsstatic void amiga_mem_console_write(struct console *co, const char *s,
6261da177e4SLinus Torvalds				    unsigned int count)
6271da177e4SLinus Torvalds{
6286ff5801aSRoman Zippel	if (savekmsg->size + count <= SAVEKMSG_MAXMEM-sizeof(struct savekmsg)) {
6296ff5801aSRoman Zippel		memcpy(savekmsg->data + savekmsg->size, s, count);
6306ff5801aSRoman Zippel		savekmsg->size += count;
6316ff5801aSRoman Zippel	}
6321da177e4SLinus Torvalds}
6331da177e4SLinus Torvalds
634d6713b40SRoman Zippelstatic int __init amiga_savekmsg_setup(char *arg)
6351da177e4SLinus Torvalds{
6368a09cec2SGeert Uytterhoeven	bool registered;
6378a09cec2SGeert Uytterhoeven
638d6713b40SRoman Zippel	if (!MACH_IS_AMIGA || strcmp(arg, "mem"))
6395df1abdbSGeert Uytterhoeven		return 0;
640d6713b40SRoman Zippel
6415df1abdbSGeert Uytterhoeven	if (amiga_chip_size < SAVEKMSG_MAXMEM) {
6425df1abdbSGeert Uytterhoeven		pr_err("Not enough chipram for debugging\n");
6435df1abdbSGeert Uytterhoeven		return -ENOMEM;
644d6713b40SRoman Zippel	}
645d6713b40SRoman Zippel
6465df1abdbSGeert Uytterhoeven	/* Just steal the block, the chipram allocator isn't functional yet */
6475df1abdbSGeert Uytterhoeven	amiga_chip_size -= SAVEKMSG_MAXMEM;
6486112ea08SGeert Uytterhoeven	savekmsg = ZTWO_VADDR(CHIP_PHYSADDR + amiga_chip_size);
6496ff5801aSRoman Zippel	savekmsg->magic1 = SAVEKMSG_MAGIC1;
6506ff5801aSRoman Zippel	savekmsg->magic2 = SAVEKMSG_MAGIC2;
6516ff5801aSRoman Zippel	savekmsg->magicptr = ZTWO_PADDR(savekmsg);
6526ff5801aSRoman Zippel	savekmsg->size = 0;
653d6713b40SRoman Zippel
6548a09cec2SGeert Uytterhoeven	registered = !!amiga_console_driver.write;
655d6713b40SRoman Zippel	amiga_console_driver.write = amiga_mem_console_write;
6568a09cec2SGeert Uytterhoeven	if (!registered)
6578a09cec2SGeert Uytterhoeven		register_console(&amiga_console_driver);
658d6713b40SRoman Zippel	return 0;
6591da177e4SLinus Torvalds}
6601da177e4SLinus Torvalds
661d6713b40SRoman Zippelearly_param("debug", amiga_savekmsg_setup);
662d6713b40SRoman Zippel
6631da177e4SLinus Torvaldsstatic void amiga_serial_putc(char c)
6641da177e4SLinus Torvalds{
6656ff5801aSRoman Zippel	amiga_custom.serdat = (unsigned char)c | 0x100;
6666ff5801aSRoman Zippel	while (!(amiga_custom.serdatr & 0x2000))
6676ff5801aSRoman Zippel		;
6681da177e4SLinus Torvalds}
6691da177e4SLinus Torvalds
6700795dbccSAdrian Bunkstatic void amiga_serial_console_write(struct console *co, const char *s,
6710795dbccSAdrian Bunk				       unsigned int count)
6721da177e4SLinus Torvalds{
6736ff5801aSRoman Zippel	while (count--) {
6746ff5801aSRoman Zippel		if (*s == '\n')
6756ff5801aSRoman Zippel			amiga_serial_putc('\r');
6766ff5801aSRoman Zippel		amiga_serial_putc(*s++);
6776ff5801aSRoman Zippel	}
6781da177e4SLinus Torvalds}
6791da177e4SLinus Torvalds
6800795dbccSAdrian Bunk#if 0
6811da177e4SLinus Torvaldsvoid amiga_serial_puts(const char *s)
6821da177e4SLinus Torvalds{
6836ff5801aSRoman Zippel	amiga_serial_console_write(NULL, s, strlen(s));
6841da177e4SLinus Torvalds}
6851da177e4SLinus Torvalds
6861da177e4SLinus Torvaldsint amiga_serial_console_wait_key(struct console *co)
6871da177e4SLinus Torvalds{
6886ff5801aSRoman Zippel	int ch;
6896ff5801aSRoman Zippel
6906ff5801aSRoman Zippel	while (!(amiga_custom.intreqr & IF_RBF))
6916ff5801aSRoman Zippel		barrier();
6926ff5801aSRoman Zippel	ch = amiga_custom.serdatr & 0xff;
6936ff5801aSRoman Zippel	/* clear the interrupt, so that another character can be read */
6946ff5801aSRoman Zippel	amiga_custom.intreq = IF_RBF;
6956ff5801aSRoman Zippel	return ch;
6961da177e4SLinus Torvalds}
6971da177e4SLinus Torvalds
6981da177e4SLinus Torvaldsvoid amiga_serial_gets(struct console *co, char *s, int len)
6991da177e4SLinus Torvalds{
7006ff5801aSRoman Zippel	int ch, cnt = 0;
7016ff5801aSRoman Zippel
702