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>
4091d7b75aSLaurent Vivier #include <asm/config.h>
411da177e4SLinus Torvalds
420795dbccSAdrian Bunk static unsigned long amiga_model;
438b169fa2SAdrian Bunk
441da177e4SLinus Torvalds unsigned long amiga_eclock;
458b169fa2SAdrian Bunk EXPORT_SYMBOL(amiga_eclock);
468b169fa2SAdrian Bunk
471da177e4SLinus Torvalds unsigned long amiga_colorclock;
488b169fa2SAdrian Bunk EXPORT_SYMBOL(amiga_colorclock);
498b169fa2SAdrian Bunk
501da177e4SLinus Torvalds unsigned long amiga_chipset;
518b169fa2SAdrian Bunk EXPORT_SYMBOL(amiga_chipset);
528b169fa2SAdrian Bunk
531da177e4SLinus Torvalds unsigned char amiga_vblank;
548468afc0SAdrian Bunk EXPORT_SYMBOL(amiga_vblank);
558468afc0SAdrian Bunk
560795dbccSAdrian Bunk static unsigned char amiga_psfreq;
578b169fa2SAdrian Bunk
581da177e4SLinus Torvalds struct amiga_hw_present amiga_hw_present;
598b169fa2SAdrian Bunk EXPORT_SYMBOL(amiga_hw_present);
601da177e4SLinus Torvalds
611da177e4SLinus Torvalds static char s_a500[] __initdata = "A500";
621da177e4SLinus Torvalds static char s_a500p[] __initdata = "A500+";
631da177e4SLinus Torvalds static char s_a600[] __initdata = "A600";
641da177e4SLinus Torvalds static char s_a1000[] __initdata = "A1000";
651da177e4SLinus Torvalds static char s_a1200[] __initdata = "A1200";
661da177e4SLinus Torvalds static char s_a2000[] __initdata = "A2000";
671da177e4SLinus Torvalds static char s_a2500[] __initdata = "A2500";
681da177e4SLinus Torvalds static char s_a3000[] __initdata = "A3000";
691da177e4SLinus Torvalds static char s_a3000t[] __initdata = "A3000T";
701da177e4SLinus Torvalds static char s_a3000p[] __initdata = "A3000+";
711da177e4SLinus Torvalds static char s_a4000[] __initdata = "A4000";
721da177e4SLinus Torvalds static char s_a4000t[] __initdata = "A4000T";
731da177e4SLinus Torvalds static char s_cdtv[] __initdata = "CDTV";
741da177e4SLinus Torvalds static char s_cd32[] __initdata = "CD32";
751da177e4SLinus Torvalds static char s_draco[] __initdata = "Draco";
761da177e4SLinus Torvalds static char *amiga_models[] __initdata = {
771da177e4SLinus Torvalds [AMI_500-AMI_500] = s_a500,
781da177e4SLinus Torvalds [AMI_500PLUS-AMI_500] = s_a500p,
791da177e4SLinus Torvalds [AMI_600-AMI_500] = s_a600,
801da177e4SLinus Torvalds [AMI_1000-AMI_500] = s_a1000,
811da177e4SLinus Torvalds [AMI_1200-AMI_500] = s_a1200,
821da177e4SLinus Torvalds [AMI_2000-AMI_500] = s_a2000,
831da177e4SLinus Torvalds [AMI_2500-AMI_500] = s_a2500,
841da177e4SLinus Torvalds [AMI_3000-AMI_500] = s_a3000,
851da177e4SLinus Torvalds [AMI_3000T-AMI_500] = s_a3000t,
861da177e4SLinus Torvalds [AMI_3000PLUS-AMI_500] = s_a3000p,
871da177e4SLinus Torvalds [AMI_4000-AMI_500] = s_a4000,
881da177e4SLinus Torvalds [AMI_4000T-AMI_500] = s_a4000t,
891da177e4SLinus Torvalds [AMI_CDTV-AMI_500] = s_cdtv,
901da177e4SLinus Torvalds [AMI_CD32-AMI_500] = s_cd32,
911da177e4SLinus Torvalds [AMI_DRACO-AMI_500] = s_draco,
921da177e4SLinus Torvalds };
931da177e4SLinus Torvalds
941da177e4SLinus Torvalds static char amiga_model_name[13] = "Amiga ";
951da177e4SLinus Torvalds
96f9a01539SArnd Bergmann static void amiga_sched_init(void);
971da177e4SLinus Torvalds static void amiga_get_model(char *model);
98813dcf7aSAlexey Dobriyan static void amiga_get_hardware_list(struct seq_file *m);
991da177e4SLinus Torvalds extern void amiga_mksound(unsigned int count, unsigned int ticks);
1001da177e4SLinus Torvalds static void amiga_reset(void);
1011da177e4SLinus Torvalds extern void amiga_init_sound(void);
1021da177e4SLinus Torvalds static void amiga_mem_console_write(struct console *co, const char *b,
1031da177e4SLinus Torvalds unsigned int count);
1041da177e4SLinus Torvalds #ifdef CONFIG_HEARTBEAT
1051da177e4SLinus Torvalds static void amiga_heartbeat(int on);
1061da177e4SLinus Torvalds #endif
1071da177e4SLinus Torvalds
1081da177e4SLinus Torvalds static struct console amiga_console_driver = {
1091da177e4SLinus Torvalds .name = "debug",
1101da177e4SLinus Torvalds .flags = CON_PRINTBUFFER,
1111da177e4SLinus Torvalds .index = -1,
1121da177e4SLinus Torvalds };
1131da177e4SLinus Torvalds
1141da177e4SLinus Torvalds
1151da177e4SLinus Torvalds /*
1161da177e4SLinus Torvalds * Motherboard Resources present in all Amiga models
1171da177e4SLinus Torvalds */
1181da177e4SLinus Torvalds
1191da177e4SLinus Torvalds static struct {
1201da177e4SLinus Torvalds struct resource _ciab, _ciaa, _custom, _kickstart;
1211da177e4SLinus Torvalds } mb_resources = {
1221da177e4SLinus Torvalds ._ciab = {
1231da177e4SLinus Torvalds .name = "CIA B", .start = 0x00bfd000, .end = 0x00bfdfff
1241da177e4SLinus Torvalds },
1251da177e4SLinus Torvalds ._ciaa = {
1261da177e4SLinus Torvalds .name = "CIA A", .start = 0x00bfe000, .end = 0x00bfefff
1271da177e4SLinus Torvalds },
1281da177e4SLinus Torvalds ._custom = {
1291da177e4SLinus Torvalds .name = "Custom I/O", .start = 0x00dff000, .end = 0x00dfffff
1301da177e4SLinus Torvalds },
1311da177e4SLinus Torvalds ._kickstart = {
1321da177e4SLinus Torvalds .name = "Kickstart ROM", .start = 0x00f80000, .end = 0x00ffffff
1331da177e4SLinus Torvalds }
1341da177e4SLinus Torvalds };
1351da177e4SLinus Torvalds
1361da177e4SLinus Torvalds static struct resource ram_resource[NUM_MEMINFO];
1371da177e4SLinus Torvalds
1381da177e4SLinus Torvalds
1391da177e4SLinus Torvalds /*
1401da177e4SLinus Torvalds * Parse an Amiga-specific record in the bootinfo
1411da177e4SLinus Torvalds */
1421da177e4SLinus Torvalds
amiga_parse_bootinfo(const struct bi_record * record)143a4df02a2SGeert Uytterhoeven int __init amiga_parse_bootinfo(const struct bi_record *record)
1441da177e4SLinus Torvalds {
1451da177e4SLinus Torvalds int unknown = 0;
146abe48101SGeert Uytterhoeven const void *data = record->data;
1471da177e4SLinus Torvalds
148abe48101SGeert Uytterhoeven switch (be16_to_cpu(record->tag)) {
1491da177e4SLinus Torvalds case BI_AMIGA_MODEL:
150abe48101SGeert Uytterhoeven amiga_model = be32_to_cpup(data);
1511da177e4SLinus Torvalds break;
1521da177e4SLinus Torvalds
1531da177e4SLinus Torvalds case BI_AMIGA_ECLOCK:
154abe48101SGeert Uytterhoeven amiga_eclock = be32_to_cpup(data);
1551da177e4SLinus Torvalds break;
1561da177e4SLinus Torvalds
1571da177e4SLinus Torvalds case BI_AMIGA_CHIPSET:
158abe48101SGeert Uytterhoeven amiga_chipset = be32_to_cpup(data);
1591da177e4SLinus Torvalds break;
1601da177e4SLinus Torvalds
1611da177e4SLinus Torvalds case BI_AMIGA_CHIP_SIZE:
162abe48101SGeert Uytterhoeven amiga_chip_size = be32_to_cpup(data);
1631da177e4SLinus Torvalds break;
1641da177e4SLinus Torvalds
1651da177e4SLinus Torvalds case BI_AMIGA_VBLANK:
166abe48101SGeert Uytterhoeven amiga_vblank = *(const __u8 *)data;
1671da177e4SLinus Torvalds break;
1681da177e4SLinus Torvalds
1691da177e4SLinus Torvalds case BI_AMIGA_PSFREQ:
170abe48101SGeert Uytterhoeven amiga_psfreq = *(const __u8 *)data;
1711da177e4SLinus Torvalds break;
1721da177e4SLinus Torvalds
1731da177e4SLinus Torvalds case BI_AMIGA_AUTOCON:
1741da177e4SLinus Torvalds #ifdef CONFIG_ZORRO
1751da177e4SLinus Torvalds if (zorro_num_autocon < ZORRO_NUM_AUTO) {
176abe48101SGeert Uytterhoeven const struct ConfigDev *cd = data;
177c293738eSGeert Uytterhoeven struct zorro_dev_init *dev = &zorro_autocon_init[zorro_num_autocon++];
1781da177e4SLinus Torvalds dev->rom = cd->cd_Rom;
179bd9ba8f4SGeert Uytterhoeven dev->slotaddr = be16_to_cpu(cd->cd_SlotAddr);
180bd9ba8f4SGeert Uytterhoeven dev->slotsize = be16_to_cpu(cd->cd_SlotSize);
181bd9ba8f4SGeert Uytterhoeven dev->boardaddr = be32_to_cpu(cd->cd_BoardAddr);
182bd9ba8f4SGeert Uytterhoeven dev->boardsize = be32_to_cpu(cd->cd_BoardSize);
183*8d04ddbaSPaolo Pisati
184*8d04ddbaSPaolo Pisati /* CS-LAB Warp 1260 workaround */
185*8d04ddbaSPaolo Pisati if (be16_to_cpu(dev->rom.er_Manufacturer) == ZORRO_MANUF(ZORRO_PROD_CSLAB_WARP_1260) &&
186*8d04ddbaSPaolo Pisati dev->rom.er_Product == ZORRO_PROD(ZORRO_PROD_CSLAB_WARP_1260)) {
187*8d04ddbaSPaolo Pisati
188*8d04ddbaSPaolo Pisati /* turn off all interrupts */
189*8d04ddbaSPaolo Pisati pr_info("Warp 1260 card detected: applying interrupt storm workaround\n");
190*8d04ddbaSPaolo Pisati *(uint32_t *)(dev->boardaddr + 0x1000) = 0xfff;
191*8d04ddbaSPaolo Pisati }
1921da177e4SLinus Torvalds } else
193f296401bSFabian Frederick pr_warn("amiga_parse_bootinfo: too many AutoConfig devices\n");
1941da177e4SLinus Torvalds #endif /* CONFIG_ZORRO */
1951da177e4SLinus Torvalds break;
1961da177e4SLinus Torvalds
1971da177e4SLinus Torvalds case BI_AMIGA_SERPER:
1981da177e4SLinus Torvalds /* serial port period: ignored here */
1991da177e4SLinus Torvalds break;
2001da177e4SLinus Torvalds
2011da177e4SLinus Torvalds default:
2021da177e4SLinus Torvalds unknown = 1;
2031da177e4SLinus Torvalds }
2046ff5801aSRoman Zippel return unknown;
2051da177e4SLinus Torvalds }
2061da177e4SLinus Torvalds
2071da177e4SLinus Torvalds /*
2081da177e4SLinus Torvalds * Identify builtin hardware
2091da177e4SLinus Torvalds */
2101da177e4SLinus Torvalds
amiga_identify(void)2111da177e4SLinus Torvalds static void __init amiga_identify(void)
2121da177e4SLinus Torvalds {
2131da177e4SLinus Torvalds /* Fill in some default values, if necessary */
2141da177e4SLinus Torvalds if (amiga_eclock == 0)
2151da177e4SLinus Torvalds amiga_eclock = 709379;
2161da177e4SLinus Torvalds
2171da177e4SLinus Torvalds memset(&amiga_hw_present, 0, sizeof(amiga_hw_present));
2181da177e4SLinus Torvalds
219f296401bSFabian Frederick pr_info("Amiga hardware found: ");
2201da177e4SLinus Torvalds if (amiga_model >= AMI_500 && amiga_model <= AMI_DRACO) {
221f296401bSFabian Frederick pr_cont("[%s] ", amiga_models[amiga_model-AMI_500]);
2221da177e4SLinus Torvalds strcat(amiga_model_name, amiga_models[amiga_model-AMI_500]);
2231da177e4SLinus Torvalds }
2241da177e4SLinus Torvalds
2251da177e4SLinus Torvalds switch (amiga_model) {
2261da177e4SLinus Torvalds case AMI_UNKNOWN:
227d473de0fSGeert Uytterhoeven break;
2281da177e4SLinus Torvalds
2291da177e4SLinus Torvalds case AMI_600:
2301da177e4SLinus Torvalds case AMI_1200:
2311da177e4SLinus Torvalds AMIGAHW_SET(A1200_IDE);
2321da177e4SLinus Torvalds AMIGAHW_SET(PCMCIA);
233e09a7440SGustavo A. R. Silva fallthrough;
2341da177e4SLinus Torvalds case AMI_500:
2351da177e4SLinus Torvalds case AMI_500PLUS:
2361da177e4SLinus Torvalds case AMI_1000:
2371da177e4SLinus Torvalds case AMI_2000:
2381da177e4SLinus Torvalds case AMI_2500:
2391da177e4SLinus Torvalds AMIGAHW_SET(A2000_CLK); /* Is this correct for all models? */
240d473de0fSGeert Uytterhoeven break;
2411da177e4SLinus Torvalds
2421da177e4SLinus Torvalds case AMI_3000:
2431da177e4SLinus Torvalds case AMI_3000T:
2441da177e4SLinus Torvalds AMIGAHW_SET(AMBER_FF);
2451da177e4SLinus Torvalds AMIGAHW_SET(MAGIC_REKICK);
246e09a7440SGustavo A. R. Silva fallthrough;
2471da177e4SLinus Torvalds case AMI_3000PLUS:
2481da177e4SLinus Torvalds AMIGAHW_SET(A3000_SCSI);
2491da177e4SLinus Torvalds AMIGAHW_SET(A3000_CLK);
2501da177e4SLinus Torvalds AMIGAHW_SET(ZORRO3);
251d473de0fSGeert Uytterhoeven break;
2521da177e4SLinus Torvalds
2531da177e4SLinus Torvalds case AMI_4000T:
2541da177e4SLinus Torvalds AMIGAHW_SET(A4000_SCSI);
255e09a7440SGustavo A. R. Silva fallthrough;
2561da177e4SLinus Torvalds case AMI_4000:
2571da177e4SLinus Torvalds AMIGAHW_SET(A4000_IDE);
2581da177e4SLinus Torvalds AMIGAHW_SET(A3000_CLK);
2591da177e4SLinus Torvalds AMIGAHW_SET(ZORRO3);
260d473de0fSGeert Uytterhoeven break;
2611da177e4SLinus Torvalds
2621da177e4SLinus Torvalds case AMI_CDTV:
2631da177e4SLinus Torvalds case AMI_CD32:
2641da177e4SLinus Torvalds AMIGAHW_SET(CD_ROM);
2651da177e4SLinus Torvalds AMIGAHW_SET(A2000_CLK); /* Is this correct? */
266d473de0fSGeert Uytterhoeven break;
2671da177e4SLinus Torvalds
268d473de0fSGeert Uytterhoeven case AMI_DRACO:
269d473de0fSGeert Uytterhoeven panic("No support for Draco yet");
270d473de0fSGeert Uytterhoeven
271d473de0fSGeert Uytterhoeven default:
272d473de0fSGeert Uytterhoeven panic("Unknown Amiga Model");
273d473de0fSGeert Uytterhoeven }
274d473de0fSGeert Uytterhoeven
2751da177e4SLinus Torvalds AMIGAHW_SET(AMI_VIDEO);
2761da177e4SLinus Torvalds AMIGAHW_SET(AMI_BLITTER);
2771da177e4SLinus Torvalds AMIGAHW_SET(AMI_AUDIO);
2781da177e4SLinus Torvalds AMIGAHW_SET(AMI_FLOPPY);
2791da177e4SLinus Torvalds AMIGAHW_SET(AMI_KEYBOARD);
2801da177e4SLinus Torvalds AMIGAHW_SET(AMI_MOUSE);
2811da177e4SLinus Torvalds AMIGAHW_SET(AMI_SERIAL);
2821da177e4SLinus Torvalds AMIGAHW_SET(AMI_PARALLEL);
2831da177e4SLinus Torvalds AMIGAHW_SET(CHIP_RAM);
2841da177e4SLinus Torvalds AMIGAHW_SET(PAULA);
2851da177e4SLinus Torvalds
2861da177e4SLinus Torvalds switch (amiga_chipset) {
2871da177e4SLinus Torvalds case CS_OCS:
2881da177e4SLinus Torvalds case CS_ECS:
2891da177e4SLinus Torvalds case CS_AGA:
290b4290a23SAl Viro switch (amiga_custom.deniseid & 0xf) {
2911da177e4SLinus Torvalds case 0x0c:
2921da177e4SLinus Torvalds AMIGAHW_SET(DENISE_HR);
2931da177e4SLinus Torvalds break;
2941da177e4SLinus Torvalds case 0x08:
2951da177e4SLinus Torvalds AMIGAHW_SET(LISA);
2961da177e4SLinus Torvalds break;
2971da177e4SLinus Torvalds default:
2981da177e4SLinus Torvalds AMIGAHW_SET(DENISE);
2991da177e4SLinus Torvalds break;
3001da177e4SLinus Torvalds }
3013b0950afSGeert Uytterhoeven break;
3023b0950afSGeert Uytterhoeven }
303b4290a23SAl Viro switch ((amiga_custom.vposr>>8) & 0x7f) {
3041da177e4SLinus Torvalds case 0x00:
3051da177e4SLinus Torvalds AMIGAHW_SET(AGNUS_PAL);
3061da177e4SLinus Torvalds break;
3071da177e4SLinus Torvalds case 0x10:
3081da177e4SLinus Torvalds AMIGAHW_SET(AGNUS_NTSC);
3091da177e4SLinus Torvalds break;
3101da177e4SLinus Torvalds case 0x20:
3111da177e4SLinus Torvalds case 0x21:
3121da177e4SLinus Torvalds AMIGAHW_SET(AGNUS_HR_PAL);
3131da177e4SLinus Torvalds break;
3141da177e4SLinus Torvalds case 0x30:
3151da177e4SLinus Torvalds case 0x31:
3161da177e4SLinus Torvalds AMIGAHW_SET(AGNUS_HR_NTSC);
3171da177e4SLinus Torvalds break;
3181da177e4SLinus Torvalds case 0x22:
3191da177e4SLinus Torvalds case 0x23:
3201da177e4SLinus Torvalds AMIGAHW_SET(ALICE_PAL);
3211da177e4SLinus Torvalds break;
3221da177e4SLinus Torvalds case 0x32:
3231da177e4SLinus Torvalds case 0x33:
3241da177e4SLinus Torvalds AMIGAHW_SET(ALICE_NTSC);
3251da177e4SLinus Torvalds break;
3261da177e4SLinus Torvalds }
3271da177e4SLinus Torvalds AMIGAHW_SET(ZORRO);
3281da177e4SLinus Torvalds
3291da177e4SLinus Torvalds #define AMIGAHW_ANNOUNCE(name, str) \
3301da177e4SLinus Torvalds if (AMIGAHW_PRESENT(name)) \
331f296401bSFabian Frederick pr_cont(str)
3321da177e4SLinus Torvalds
3331da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(AMI_VIDEO, "VIDEO ");
3341da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(AMI_BLITTER, "BLITTER ");
3351da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(AMBER_FF, "AMBER_FF ");
3361da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(AMI_AUDIO, "AUDIO ");
3371da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(AMI_FLOPPY, "FLOPPY ");
3381da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(A3000_SCSI, "A3000_SCSI ");
3391da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(A4000_SCSI, "A4000_SCSI ");
3401da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(A1200_IDE, "A1200_IDE ");
3411da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(A4000_IDE, "A4000_IDE ");
3421da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(CD_ROM, "CD_ROM ");
3431da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(AMI_KEYBOARD, "KEYBOARD ");
3441da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(AMI_MOUSE, "MOUSE ");
3451da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(AMI_SERIAL, "SERIAL ");
3461da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(AMI_PARALLEL, "PARALLEL ");
3471da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(A2000_CLK, "A2000_CLK ");
3481da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(A3000_CLK, "A3000_CLK ");
3491da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(CHIP_RAM, "CHIP_RAM ");
3501da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(PAULA, "PAULA ");
3511da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(DENISE, "DENISE ");
3521da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(DENISE_HR, "DENISE_HR ");
3531da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(LISA, "LISA ");
3541da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(AGNUS_PAL, "AGNUS_PAL ");
3551da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(AGNUS_NTSC, "AGNUS_NTSC ");
3561da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(AGNUS_HR_PAL, "AGNUS_HR_PAL ");
3571da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(AGNUS_HR_NTSC, "AGNUS_HR_NTSC ");
3581da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(ALICE_PAL, "ALICE_PAL ");
3591da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(ALICE_NTSC, "ALICE_NTSC ");
3601da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(MAGIC_REKICK, "MAGIC_REKICK ");
3611da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(PCMCIA, "PCMCIA ");
3621da177e4SLinus Torvalds if (AMIGAHW_PRESENT(ZORRO))
363f296401bSFabian Frederick pr_cont("ZORRO%s ", AMIGAHW_PRESENT(ZORRO3) ? "3" : "");
364f296401bSFabian Frederick pr_cont("\n");
3651da177e4SLinus Torvalds
3661da177e4SLinus Torvalds #undef AMIGAHW_ANNOUNCE
3671da177e4SLinus Torvalds }
3681da177e4SLinus Torvalds
36950190edbSGeert Uytterhoeven
amiga_random_get_entropy(void)37050190edbSGeert Uytterhoeven static unsigned long amiga_random_get_entropy(void)
37150190edbSGeert Uytterhoeven {
37250190edbSGeert Uytterhoeven /* VPOSR/VHPOSR provide at least 17 bits of data changing at 1.79 MHz */
37350190edbSGeert Uytterhoeven return *(unsigned long *)&amiga_custom.vposr;
37450190edbSGeert Uytterhoeven }
37550190edbSGeert Uytterhoeven
37650190edbSGeert Uytterhoeven
3771da177e4SLinus Torvalds /*
3781da177e4SLinus Torvalds * Setup the Amiga configuration info
3791da177e4SLinus Torvalds */
3801da177e4SLinus Torvalds
config_amiga(void)3811da177e4SLinus Torvalds void __init config_amiga(void)
3821da177e4SLinus Torvalds {
3831da177e4SLinus Torvalds int i;
3841da177e4SLinus Torvalds
3851da177e4SLinus Torvalds amiga_identify();
3861da177e4SLinus Torvalds
3871da177e4SLinus Torvalds /* Yuk, we don't have PCI memory */
3881da177e4SLinus Torvalds iomem_resource.name = "Memory";
3891da177e4SLinus Torvalds for (i = 0; i < 4; i++)
3901da177e4SLinus Torvalds request_resource(&iomem_resource, &((struct resource *)&mb_resources)[i]);
3911da177e4SLinus Torvalds
3921da177e4SLinus Torvalds mach_sched_init = amiga_sched_init;
3931da177e4SLinus Torvalds mach_init_IRQ = amiga_init_IRQ;
3941da177e4SLinus Torvalds mach_get_model = amiga_get_model;
3951da177e4SLinus Torvalds mach_get_hardware_list = amiga_get_hardware_list;
3961da177e4SLinus Torvalds mach_reset = amiga_reset;
397a1a9e88fSGeert Uytterhoeven #if IS_ENABLED(CONFIG_INPUT_M68K_BEEP)
3981da177e4SLinus Torvalds mach_beep = amiga_mksound;
3991da177e4SLinus Torvalds #endif
4001da177e4SLinus Torvalds
4011da177e4SLinus Torvalds #ifdef CONFIG_HEARTBEAT
4021da177e4SLinus Torvalds mach_heartbeat = amiga_heartbeat;
4031da177e4SLinus Torvalds #endif
4041da177e4SLinus Torvalds
40550190edbSGeert Uytterhoeven mach_random_get_entropy = amiga_random_get_entropy;
40650190edbSGeert Uytterhoeven
4070795dbccSAdrian Bunk /* Fill in the clock value (based on the 700 kHz E-Clock) */
4081da177e4SLinus Torvalds amiga_colorclock = 5*amiga_eclock; /* 3.5 MHz */
4091da177e4SLinus Torvalds
4101da177e4SLinus Torvalds /* clear all DMA bits */
411b4290a23SAl Viro amiga_custom.dmacon = DMAF_ALL;
4121da177e4SLinus Torvalds /* ensure that the DMA master bit is set */
413b4290a23SAl Viro amiga_custom.dmacon = DMAF_SETCLR | DMAF_MASTER;
4141da177e4SLinus Torvalds
4151da177e4SLinus Torvalds /* don't use Z2 RAM as system memory on Z3 capable machines */
4161da177e4SLinus Torvalds if (AMIGAHW_PRESENT(ZORRO3)) {
4171da177e4SLinus Torvalds int i, j;
4181da177e4SLinus Torvalds u32 disabled_z2mem = 0;
4196ff5801aSRoman Zippel
4206ff5801aSRoman Zippel for (i = 0; i < m68k_num_memory; i++) {
4211da177e4SLinus Torvalds if (m68k_memory[i].addr < 16*1024*1024) {
4221da177e4SLinus Torvalds if (i == 0) {
4231da177e4SLinus Torvalds /* don't cut off the branch we're sitting on */
424f296401bSFabian Frederick pr_warn("Warning: kernel runs in Zorro II memory\n");
4251da177e4SLinus Torvalds continue;
4261da177e4SLinus Torvalds }
4271da177e4SLinus Torvalds disabled_z2mem += m68k_memory[i].size;
4281da177e4SLinus Torvalds m68k_num_memory--;
4291da177e4SLinus Torvalds for (j = i; j < m68k_num_memory; j++)
4301da177e4SLinus Torvalds m68k_memory[j] = m68k_memory[j+1];
4311da177e4SLinus Torvalds i--;
4321da177e4SLinus Torvalds }
4336ff5801aSRoman Zippel }
4341da177e4SLinus Torvalds if (disabled_z2mem)
435f296401bSFabian Frederick pr_info("%dK of Zorro II memory will not be used as system memory\n",
4361da177e4SLinus Torvalds disabled_z2mem>>10);
4371da177e4SLinus Torvalds }
4381da177e4SLinus Torvalds
4391da177e4SLinus Torvalds /* request all RAM */
4401da177e4SLinus Torvalds for (i = 0; i < m68k_num_memory; i++) {
4411da177e4SLinus Torvalds ram_resource[i].name =
4421da177e4SLinus Torvalds (m68k_memory[i].addr >= 0x01000000) ? "32-bit Fast RAM" :
4431da177e4SLinus Torvalds (m68k_memory[i].addr < 0x00c00000) ? "16-bit Fast RAM" :
4441da177e4SLinus Torvalds "16-bit Slow RAM";
4451da177e4SLinus Torvalds ram_resource[i].start = m68k_memory[i].addr;
4461da177e4SLinus Torvalds ram_resource[i].end = m68k_memory[i].addr+m68k_memory[i].size-1;
4471da177e4SLinus Torvalds request_resource(&iomem_resource, &ram_resource[i]);
4481da177e4SLinus Torvalds }
4491da177e4SLinus Torvalds
4501da177e4SLinus Torvalds /* initialize chipram allocator */
4511da177e4SLinus Torvalds amiga_chip_init();
4521da177e4SLinus Torvalds
4531da177e4SLinus Torvalds /* our beloved beeper */
4541da177e4SLinus Torvalds if (AMIGAHW_PRESENT(AMI_AUDIO))
4551da177e4SLinus Torvalds amiga_init_sound();
4561da177e4SLinus Torvalds
4571da177e4SLinus Torvalds /*
4581da177e4SLinus Torvalds * if it is an A3000, set the magic bit that forces
4591da177e4SLinus Torvalds * a hard rekick
4601da177e4SLinus Torvalds */
4611da177e4SLinus Torvalds if (AMIGAHW_PRESENT(MAGIC_REKICK))
4621da177e4SLinus Torvalds *(unsigned char *)ZTWO_VADDR(0xde0002) |= 0x80;
4631da177e4SLinus Torvalds }
4641da177e4SLinus Torvalds
4655afd3d06SFinn Thain static u64 amiga_read_clk(struct clocksource *cs);
4665afd3d06SFinn Thain
4675afd3d06SFinn Thain static struct clocksource amiga_clk = {
4685afd3d06SFinn Thain .name = "ciab",
4695afd3d06SFinn Thain .rating = 250,
4705afd3d06SFinn Thain .read = amiga_read_clk,
4715afd3d06SFinn Thain .mask = CLOCKSOURCE_MASK(32),
4725afd3d06SFinn Thain .flags = CLOCK_SOURCE_IS_CONTINUOUS,
4735afd3d06SFinn Thain };
4745afd3d06SFinn Thain
4751da177e4SLinus Torvalds static unsigned short jiffy_ticks;
4765afd3d06SFinn Thain static u32 clk_total, clk_offset;
4775afd3d06SFinn Thain
ciab_timer_handler(int irq,void * dev_id)4785afd3d06SFinn Thain static irqreturn_t ciab_timer_handler(int irq, void *dev_id)
4795afd3d06SFinn Thain {
4805afd3d06SFinn Thain clk_total += jiffy_ticks;
4815afd3d06SFinn Thain clk_offset = 0;
48242f1d57fSArnd Bergmann legacy_timer_tick(1);
483d6444094SArnd Bergmann timer_heartbeat();
4845afd3d06SFinn Thain
4855afd3d06SFinn Thain return IRQ_HANDLED;
4865afd3d06SFinn Thain }
4871da177e4SLinus Torvalds
amiga_sched_init(void)488f9a01539SArnd Bergmann static void __init amiga_sched_init(void)
4891da177e4SLinus Torvalds {
4901da177e4SLinus Torvalds static struct resource sched_res = {
4911da177e4SLinus Torvalds .name = "timer", .start = 0x00bfd400, .end = 0x00bfd5ff,
4921da177e4SLinus Torvalds };
4931a0caf41SJulia Lawall jiffy_ticks = DIV_ROUND_CLOSEST(amiga_eclock, HZ);
4941da177e4SLinus Torvalds
4951da177e4SLinus Torvalds if (request_resource(&mb_resources._ciab, &sched_res))
496f296401bSFabian Frederick pr_warn("Cannot allocate ciab.ta{lo,hi}\n");
4971da177e4SLinus Torvalds ciab.cra &= 0xC0; /* turn off timer A, continuous mode, from Eclk */
4981da177e4SLinus Torvalds ciab.talo = jiffy_ticks % 256;
4991da177e4SLinus Torvalds ciab.tahi = jiffy_ticks / 256;
5001da177e4SLinus Torvalds
5011da177e4SLinus Torvalds /* install interrupt service routine for CIAB Timer A
5021da177e4SLinus Torvalds *
5031da177e4SLinus Torvalds * Please don't change this to use ciaa, as it interferes with the
5041da177e4SLinus Torvalds * SCSI code. We'll have to take a look at this later
5051da177e4SLinus Torvalds */
5065afd3d06SFinn Thain if (request_irq(IRQ_AMIGA_CIAB_TA, ciab_timer_handler, IRQF_TIMER,
50742f1d57fSArnd Bergmann "timer", NULL))
50866acd258SGeert Uytterhoeven pr_err("Couldn't register timer interrupt\n");
5091da177e4SLinus Torvalds /* start timer */
5101da177e4SLinus Torvalds ciab.cra |= 0x11;
5115afd3d06SFinn Thain
5125afd3d06SFinn Thain clocksource_register_hz(&amiga_clk, amiga_eclock);
5131da177e4SLinus Torvalds }
5141da177e4SLinus Torvalds
amiga_read_clk(struct clocksource * cs)5155afd3d06SFinn Thain static u64 amiga_read_clk(struct clocksource *cs)
5161da177e4SLinus Torvalds {
5171da177e4SLinus Torvalds unsigned short hi, lo, hi2;
5185afd3d06SFinn Thain unsigned long flags;
5195afd3d06SFinn Thain u32 ticks;
5205afd3d06SFinn Thain
5215afd3d06SFinn Thain local_irq_save(flags);
5221da177e4SLinus Torvalds
5231da177e4SLinus Torvalds /* read CIA B timer A current value */
5241da177e4SLinus Torvalds hi = ciab.tahi;
5251da177e4SLinus Torvalds lo = ciab.talo;
5261da177e4SLinus Torvalds hi2 = ciab.tahi;
5271da177e4SLinus Torvalds
5281da177e4SLinus Torvalds if (hi != hi2) {
5291da177e4SLinus Torvalds lo = ciab.talo;
5301da177e4SLinus Torvalds hi = hi2;
5311da177e4SLinus Torvalds }
5321da177e4SLinus Torvalds
5331da177e4SLinus Torvalds ticks = hi << 8 | lo;
5341da177e4SLinus Torvalds
5351da177e4SLinus Torvalds if (ticks > jiffy_ticks / 2)
5361da177e4SLinus Torvalds /* check for pending interrupt */
5371da177e4SLinus Torvalds if (cia_set_irq(&ciab_base, 0) & CIA_ICR_TA)
5385afd3d06SFinn Thain clk_offset = jiffy_ticks;
5391da177e4SLinus Torvalds
5401da177e4SLinus Torvalds ticks = jiffy_ticks - ticks;
5415afd3d06SFinn Thain ticks += clk_offset + clk_total;
5421da177e4SLinus Torvalds
5435afd3d06SFinn Thain local_irq_restore(flags);
5445afd3d06SFinn Thain
5455afd3d06SFinn Thain return ticks;
5461da177e4SLinus Torvalds }
5471da177e4SLinus Torvalds
548ff2d8b19SJoe Perches static void amiga_reset(void) __noreturn;
5491da177e4SLinus Torvalds
amiga_reset(void)5501da177e4SLinus Torvalds static void amiga_reset(void)
5511da177e4SLinus Torvalds {
5521da177e4SLinus Torvalds unsigned long jmp_addr040 = virt_to_phys(&&jmp_addr_label040);
5531da177e4SLinus Torvalds unsigned long jmp_addr = virt_to_phys(&&jmp_addr_label);
5541da177e4SLinus Torvalds
5551da177e4SLinus Torvalds local_irq_disable();
5561da177e4SLinus Torvalds if (CPU_IS_040_OR_060)
5571da177e4SLinus Torvalds /* Setup transparent translation registers for mapping
5581da177e4SLinus Torvalds * of 16 MB kernel segment before disabling translation
5591da177e4SLinus Torvalds */
5606ff5801aSRoman Zippel asm volatile ("\n"
5616ff5801aSRoman Zippel " move.l %0,%%d0\n"
5626ff5801aSRoman Zippel " and.l #0xff000000,%%d0\n"
5636ff5801aSRoman Zippel " or.w #0xe020,%%d0\n" /* map 16 MB, enable, cacheable */
5646ff5801aSRoman Zippel " .chip 68040\n"
5656ff5801aSRoman Zippel " movec %%d0,%%itt0\n"
5666ff5801aSRoman Zippel " movec %%d0,%%dtt0\n"
5676ff5801aSRoman Zippel " .chip 68k\n"
5686ff5801aSRoman Zippel " jmp %0@\n"
5691da177e4SLinus Torvalds : /* no outputs */
5706ff5801aSRoman Zippel : "a" (jmp_addr040)
5716ff5801aSRoman Zippel : "d0");
5721da177e4SLinus Torvalds else
5731da177e4SLinus Torvalds /* for 680[23]0, just disable translation and jump to the physical
5741da177e4SLinus Torvalds * address of the label
5751da177e4SLinus Torvalds */
5766ff5801aSRoman Zippel asm volatile ("\n"
5776ff5801aSRoman Zippel " pmove %%tc,%@\n"
5786ff5801aSRoman Zippel " bclr #7,%@\n"
5796ff5801aSRoman Zippel " pmove %@,%%tc\n"
5806ff5801aSRoman Zippel " jmp %0@\n"
5811da177e4SLinus Torvalds : /* no outputs */
5821da177e4SLinus Torvalds : "a" (jmp_addr));
5831da177e4SLinus Torvalds jmp_addr_label040:
5841da177e4SLinus Torvalds /* disable translation on '040 now */
5856ff5801aSRoman Zippel asm volatile ("\n"
5866ff5801aSRoman Zippel " moveq #0,%%d0\n"
5876ff5801aSRoman Zippel " .chip 68040\n"
5886ff5801aSRoman Zippel " movec %%d0,%%tc\n" /* disable MMU */
5896ff5801aSRoman Zippel " .chip 68k\n"
5901da177e4SLinus Torvalds : /* no outputs */
5911da177e4SLinus Torvalds : /* no inputs */
5921da177e4SLinus Torvalds : "d0");
5931da177e4SLinus Torvalds
5941da177e4SLinus Torvalds jmp_addr_label:
5951da177e4SLinus Torvalds /* pickup reset address from AmigaOS ROM, reset devices and jump
5961da177e4SLinus Torvalds * to reset address
5971da177e4SLinus Torvalds */
5986ff5801aSRoman Zippel asm volatile ("\n"
5996ff5801aSRoman Zippel " move.w #0x2700,%sr\n"
6006ff5801aSRoman Zippel " lea 0x01000000,%a0\n"
6016ff5801aSRoman Zippel " sub.l %a0@(-0x14),%a0\n"
6026ff5801aSRoman Zippel " move.l %a0@(4),%a0\n"
6036ff5801aSRoman Zippel " subq.l #2,%a0\n"
6046ff5801aSRoman Zippel " jra 1f\n"
6051da177e4SLinus Torvalds /* align on a longword boundary */
6066ff5801aSRoman Zippel " " __ALIGN_STR "\n"
6076ff5801aSRoman Zippel "1:\n"
6086ff5801aSRoman Zippel " reset\n"
6096ff5801aSRoman Zippel " jmp %a0@");
6101da177e4SLinus Torvalds
6116ff5801aSRoman Zippel for (;;)
6126ff5801aSRoman Zippel ;
6131da177e4SLinus Torvalds }
6141da177e4SLinus Torvalds
6151da177e4SLinus Torvalds
6161da177e4SLinus Torvalds /*
6171da177e4SLinus Torvalds * Debugging
6181da177e4SLinus Torvalds */
6191da177e4SLinus Torvalds
6201da177e4SLinus Torvalds #define SAVEKMSG_MAXMEM 128*1024
6211da177e4SLinus Torvalds
6221da177e4SLinus Torvalds #define SAVEKMSG_MAGIC1 0x53415645 /* 'SAVE' */
6231da177e4SLinus Torvalds #define SAVEKMSG_MAGIC2 0x4B4D5347 /* 'KMSG' */
6241da177e4SLinus Torvalds
6251da177e4SLinus Torvalds struct savekmsg {
6261da177e4SLinus Torvalds unsigned long magic1; /* SAVEKMSG_MAGIC1 */
6271da177e4SLinus Torvalds unsigned long magic2; /* SAVEKMSG_MAGIC2 */
6281da177e4SLinus Torvalds unsigned long magicptr; /* address of magic1 */
6291da177e4SLinus Torvalds unsigned long size;
630366b8149SGustavo A. R. Silva char data[];
6311da177e4SLinus Torvalds };
6321da177e4SLinus Torvalds
6331da177e4SLinus Torvalds static struct savekmsg *savekmsg;
6341da177e4SLinus Torvalds
amiga_mem_console_write(struct console * co,const char * s,unsigned int count)6351da177e4SLinus Torvalds static void amiga_mem_console_write(struct console *co, const char *s,
6361da177e4SLinus Torvalds unsigned int count)
6371da177e4SLinus Torvalds {
6381da177e4SLinus Torvalds if (savekmsg->size + count <= SAVEKMSG_MAXMEM-sizeof(struct savekmsg)) {
6391da177e4SLinus Torvalds memcpy(savekmsg->data + savekmsg->size, s, count);
6401da177e4SLinus Torvalds savekmsg->size += count;
6411da177e4SLinus Torvalds }
6421da177e4SLinus Torvalds }
6431da177e4SLinus Torvalds
amiga_savekmsg_setup(char * arg)644d6713b40SRoman Zippel static int __init amiga_savekmsg_setup(char *arg)
6451da177e4SLinus Torvalds {
6468a09cec2SGeert Uytterhoeven bool registered;
6478a09cec2SGeert Uytterhoeven
648d6713b40SRoman Zippel if (!MACH_IS_AMIGA || strcmp(arg, "mem"))
6495df1abdbSGeert Uytterhoeven return 0;
650d6713b40SRoman Zippel
6515df1abdbSGeert Uytterhoeven if (amiga_chip_size < SAVEKMSG_MAXMEM) {
6525df1abdbSGeert Uytterhoeven pr_err("Not enough chipram for debugging\n");
6535df1abdbSGeert Uytterhoeven return -ENOMEM;
654d6713b40SRoman Zippel }
655d6713b40SRoman Zippel
6565df1abdbSGeert Uytterhoeven /* Just steal the block, the chipram allocator isn't functional yet */
6575df1abdbSGeert Uytterhoeven amiga_chip_size -= SAVEKMSG_MAXMEM;
6586112ea08SGeert Uytterhoeven savekmsg = ZTWO_VADDR(CHIP_PHYSADDR + amiga_chip_size);
6591da177e4SLinus Torvalds savekmsg->magic1 = SAVEKMSG_MAGIC1;
6601da177e4SLinus Torvalds savekmsg->magic2 = SAVEKMSG_MAGIC2;
6611da177e4SLinus Torvalds savekmsg->magicptr = ZTWO_PADDR(savekmsg);
6621da177e4SLinus Torvalds savekmsg->size = 0;
663d6713b40SRoman Zippel
6648a09cec2SGeert Uytterhoeven registered = !!amiga_console_driver.write;
665d6713b40SRoman Zippel amiga_console_driver.write = amiga_mem_console_write;
6668a09cec2SGeert Uytterhoeven if (!registered)
667d6713b40SRoman Zippel register_console(&amiga_console_driver);
668d6713b40SRoman Zippel return 0;
6691da177e4SLinus Torvalds }
6701da177e4SLinus Torvalds
671d6713b40SRoman Zippel early_param("debug", amiga_savekmsg_setup);
672d6713b40SRoman Zippel
amiga_serial_putc(char c)6731da177e4SLinus Torvalds static void amiga_serial_putc(char c)
6741da177e4SLinus Torvalds {
675b4290a23SAl Viro amiga_custom.serdat = (unsigned char)c | 0x100;
676b4290a23SAl Viro while (!(amiga_custom.serdatr & 0x2000))
6771da177e4SLinus Torvalds ;
6781da177e4SLinus Torvalds }
6791da177e4SLinus Torvalds
amiga_serial_console_write(struct console * co,const char * s,unsigned int count)6800795dbccSAdrian Bunk static void amiga_serial_console_write(struct console *co, const char *s,
6811da177e4SLinus Torvalds unsigned int count)
6821da177e4SLinus Torvalds {
6831da177e4SLinus Torvalds while (count--) {
6841da177e4SLinus Torvalds if (*s == '\n')
6851da177e4SLinus Torvalds amiga_serial_putc('\r');
6861da177e4SLinus Torvalds amiga_serial_putc(*s++);
6871da177e4SLinus Torvalds }
6881da177e4SLinus Torvalds }
6891da177e4SLinus Torvalds
6900795dbccSAdrian Bunk #if 0
6911da177e4SLinus Torvalds void amiga_serial_puts(const char *s)
6921da177e4SLinus Torvalds {
6931da177e4SLinus Torvalds amiga_serial_console_write(NULL, s, strlen(s));
6941da177e4SLinus Torvalds }
6951da177e4SLinus Torvalds
6961da177e4SLinus Torvalds int amiga_serial_console_wait_key(struct console *co)
6971da177e4SLinus Torvalds {
6981da177e4SLinus Torvalds int ch;
6991da177e4SLinus Torvalds
700b4290a23SAl Viro while (!(amiga_custom.intreqr & IF_RBF))
7011da177e4SLinus Torvalds barrier();
702b4290a23SAl Viro ch = amiga_custom.serdatr & 0xff;
7031da177e4SLinus Torvalds /* clear the interrupt, so that another character can be read */
704b4290a23SAl Viro amiga_custom.intreq = IF_RBF;
7051da177e4SLinus Torvalds return ch;
7061da177e4SLinus Torvalds }
7071da177e4SLinus Torvalds
7081da177e4SLinus Torvalds void amiga_serial_gets(struct console *co, char *s, int len)
7091da177e4SLinus Torvalds {
7101da177e4SLinus Torvalds int ch, cnt = 0;
7111da177e4SLinus Torvalds
7121da177e4SLinus Torvalds while (1) {
7131da177e4SLinus Torvalds ch = amiga_serial_console_wait_key(co);
7141da177e4SLinus Torvalds
7151da177e4SLinus Torvalds /* Check for backspace. */
7161da177e4SLinus Torvalds if (ch == 8 || ch == 127) {
7171da177e4SLinus Torvalds if (cnt == 0) {
7181da177e4SLinus Torvalds amiga_serial_putc('\007');
7191da177e4SLinus Torvalds continue;
7201da177e4SLinus Torvalds }
7211da177e4SLinus Torvalds cnt--;
7221da177e4SLinus Torvalds amiga_serial_puts("\010 \010");
7231da177e4SLinus Torvalds continue;
7241da177e4SLinus Torvalds }
7251da177e4SLinus Torvalds
7261da177e4SLinus Torvalds /* Check for enter. */
7271da177e4SLinus Torvalds if (ch == 10 || ch == 13)
7281da177e4SLinus Torvalds break;
7291da177e4SLinus Torvalds
7301da177e4SLinus Torvalds /* See if line is too long. */
7311da177e4SLinus Torvalds if (cnt >= len + 1) {
7321da177e4SLinus Torvalds amiga_serial_putc(7);
7331da177e4SLinus Torvalds cnt--;
7341da177e4SLinus Torvalds continue;
7351da177e4SLinus Torvalds }
7361da177e4SLinus Torvalds
7371da177e4SLinus Torvalds /* Store and echo character. */
7381da177e4SLinus Torvalds s[cnt++] = ch;
7391da177e4SLinus Torvalds amiga_serial_putc(ch);
7401da177e4SLinus Torvalds }
7411da177e4SLinus Torvalds /* Print enter. */
7421da177e4SLinus Torvalds amiga_serial_puts("\r\n");
7431da177e4SLinus Torvalds s[cnt] = 0;
7441da177e4SLinus Torvalds }
7451da177e4SLinus Torvalds #endif
7461da177e4SLinus Torvalds
amiga_debug_setup(char * arg)747d6713b40SRoman Zippel static int __init amiga_debug_setup(char *arg)
7481da177e4SLinus Torvalds {
7498a09cec2SGeert Uytterhoeven bool registered;
7508a09cec2SGeert Uytterhoeven
7518a09cec2SGeert Uytterhoeven if (!MACH_IS_AMIGA || strcmp(arg, "ser"))
7528a09cec2SGeert Uytterhoeven return 0;
7538a09cec2SGeert Uytterhoeven
7541da177e4SLinus Torvalds /* no initialization required (?) */
7558a09cec2SGeert Uytterhoeven registered = !!amiga_console_driver.write;
7561da177e4SLinus Torvalds amiga_console_driver.write = amiga_serial_console_write;
7578a09cec2SGeert Uytterhoeven if (!registered)
7581da177e4SLinus Torvalds register_console(&amiga_console_driver);
759d6713b40SRoman Zippel return 0;
7601da177e4SLinus Torvalds }
7611da177e4SLinus Torvalds
762d6713b40SRoman Zippel early_param("debug", amiga_debug_setup);
763d6713b40SRoman Zippel
7641da177e4SLinus Torvalds #ifdef CONFIG_HEARTBEAT
amiga_heartbeat(int on)7651da177e4SLinus Torvalds static void amiga_heartbeat(int on)
7661da177e4SLinus Torvalds {
7671da177e4SLinus Torvalds if (on)
7681da177e4SLinus Torvalds ciaa.pra &= ~2;
7691da177e4SLinus Torvalds else
7701da177e4SLinus Torvalds ciaa.pra |= 2;
7711da177e4SLinus Torvalds }
7721da177e4SLinus Torvalds #endif
7731da177e4SLinus Torvalds
7741da177e4SLinus Torvalds /*
7751da177e4SLinus Torvalds * Amiga specific parts of /proc
7761da177e4SLinus Torvalds */
7771da177e4SLinus Torvalds
amiga_get_model(char * model)7781da177e4SLinus Torvalds static void amiga_get_model(char *model)
7791da177e4SLinus Torvalds {
7801da177e4SLinus Torvalds strcpy(model, amiga_model_name);
7811da177e4SLinus Torvalds }
7821da177e4SLinus Torvalds
7831da177e4SLinus Torvalds
amiga_get_hardware_list(struct seq_file * m)784813dcf7aSAlexey Dobriyan static void amiga_get_hardware_list(struct seq_file *m)
7851da177e4SLinus Torvalds {
7861da177e4SLinus Torvalds if (AMIGAHW_PRESENT(CHIP_RAM))
787813dcf7aSAlexey Dobriyan seq_printf(m, "Chip RAM:\t%ldK\n", amiga_chip_size>>10);
788813dcf7aSAlexey Dobriyan seq_printf(m, "PS Freq:\t%dHz\nEClock Freq:\t%ldHz\n",
7891da177e4SLinus Torvalds amiga_psfreq, amiga_eclock);
7901da177e4SLinus Torvalds if (AMIGAHW_PRESENT(AMI_VIDEO)) {
7911da177e4SLinus Torvalds char *type;
7921da177e4SLinus Torvalds switch (amiga_chipset) {
7931da177e4SLinus Torvalds case CS_OCS:
7941da177e4SLinus Torvalds type = "OCS";
7951da177e4SLinus Torvalds break;
7961da177e4SLinus Torvalds case CS_ECS:
7971da177e4SLinus Torvalds type = "ECS";
7981da177e4SLinus Torvalds break;
7991da177e4SLinus Torvalds case CS_AGA:
8001da177e4SLinus Torvalds type = "AGA";
8011da177e4SLinus Torvalds break;
8021da177e4SLinus Torvalds default:
8031da177e4SLinus Torvalds type = "Old or Unknown";
8041da177e4SLinus Torvalds break;
8051da177e4SLinus Torvalds }
806813dcf7aSAlexey Dobriyan seq_printf(m, "Graphics:\t%s\n", type);
8071da177e4SLinus Torvalds }
8081da177e4SLinus Torvalds
8091da177e4SLinus Torvalds #define AMIGAHW_ANNOUNCE(name, str) \
8101da177e4SLinus Torvalds if (AMIGAHW_PRESENT(name)) \
811813dcf7aSAlexey Dobriyan seq_printf (m, "\t%s\n", str)
8121da177e4SLinus Torvalds
813f2a0c534SMarkus Elfring seq_puts(m, "Detected hardware:\n");
8141da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(AMI_VIDEO, "Amiga Video");
8151da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(AMI_BLITTER, "Blitter");
8161da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(AMBER_FF, "Amber Flicker Fixer");
8171da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(AMI_AUDIO, "Amiga Audio");
8181da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(AMI_FLOPPY, "Floppy Controller");
8191da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(A3000_SCSI, "SCSI Controller WD33C93 (A3000 style)");
8201da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(A4000_SCSI, "SCSI Controller NCR53C710 (A4000T style)");
8211da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(A1200_IDE, "IDE Interface (A1200 style)");
8221da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(A4000_IDE, "IDE Interface (A4000 style)");
8231da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(CD_ROM, "Internal CD ROM drive");
8241da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(AMI_KEYBOARD, "Keyboard");
8251da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(AMI_MOUSE, "Mouse Port");
8261da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(AMI_SERIAL, "Serial Port");
8271da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(AMI_PARALLEL, "Parallel Port");
8281da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(A2000_CLK, "Hardware Clock (A2000 style)");
8291da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(A3000_CLK, "Hardware Clock (A3000 style)");
8301da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(CHIP_RAM, "Chip RAM");
8311da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(PAULA, "Paula 8364");
8321da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(DENISE, "Denise 8362");
8331da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(DENISE_HR, "Denise 8373");
8341da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(LISA, "Lisa 8375");
8351da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(AGNUS_PAL, "Normal/Fat PAL Agnus 8367/8371");
8361da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(AGNUS_NTSC, "Normal/Fat NTSC Agnus 8361/8370");
8371da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(AGNUS_HR_PAL, "Fat Hires PAL Agnus 8372");
8381da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(AGNUS_HR_NTSC, "Fat Hires NTSC Agnus 8372");
8391da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(ALICE_PAL, "PAL Alice 8374");
8401da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(ALICE_NTSC, "NTSC Alice 8374");
8411da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(MAGIC_REKICK, "Magic Hard Rekick");
8421da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(PCMCIA, "PCMCIA Slot");
8431da177e4SLinus Torvalds #ifdef CONFIG_ZORRO
8441da177e4SLinus Torvalds if (AMIGAHW_PRESENT(ZORRO))
845813dcf7aSAlexey Dobriyan seq_printf(m, "\tZorro II%s AutoConfig: %d Expansion "
8461da177e4SLinus Torvalds "Device%s\n",
8471da177e4SLinus Torvalds AMIGAHW_PRESENT(ZORRO3) ? "I" : "",
8481da177e4SLinus Torvalds zorro_num_autocon, zorro_num_autocon == 1 ? "" : "s");
8491da177e4SLinus Torvalds #endif /* CONFIG_ZORRO */
8501da177e4SLinus Torvalds
8511da177e4SLinus Torvalds #undef AMIGAHW_ANNOUNCE
8521da177e4SLinus Torvalds }
85339d2d99dSGeert Uytterhoeven
85439d2d99dSGeert Uytterhoeven /*
85539d2d99dSGeert Uytterhoeven * The Amiga keyboard driver needs key_maps, but we cannot export it in
85639d2d99dSGeert Uytterhoeven * drivers/char/defkeymap.c, as it is autogenerated
85739d2d99dSGeert Uytterhoeven */
85839d2d99dSGeert Uytterhoeven #ifdef CONFIG_HW_CONSOLE
85939d2d99dSGeert Uytterhoeven EXPORT_SYMBOL_GPL(key_maps);
86039d2d99dSGeert Uytterhoeven #endif
861