linux/arch/m68k/amiga/config.c
<<
>>
Prefs
   1/*
   2 *  linux/arch/m68k/amiga/config.c
   3 *
   4 *  Copyright (C) 1993 Hamish Macdonald
   5 *
   6 * This file is subject to the terms and conditions of the GNU General Public
   7 * License.  See the file COPYING in the main directory of this archive
   8 * for more details.
   9 */
  10
  11/*
  12 * Miscellaneous Amiga stuff
  13 */
  14
  15#include <linux/types.h>
  16#include <linux/kernel.h>
  17#include <linux/mm.h>
  18#include <linux/seq_file.h>
  19#include <linux/tty.h>
  20#include <linux/console.h>
  21#include <linux/rtc.h>
  22#include <linux/init.h>
  23#include <linux/vt_kern.h>
  24#include <linux/delay.h>
  25#include <linux/interrupt.h>
  26#include <linux/zorro.h>
  27#include <linux/module.h>
  28#include <linux/keyboard.h>
  29
  30#include <asm/bootinfo.h>
  31#include <asm/setup.h>
  32#include <asm/system.h>
  33#include <asm/pgtable.h>
  34#include <asm/amigahw.h>
  35#include <asm/amigaints.h>
  36#include <asm/irq.h>
  37#include <asm/rtc.h>
  38#include <asm/machdep.h>
  39#include <asm/io.h>
  40
  41static unsigned long amiga_model;
  42
  43unsigned long amiga_eclock;
  44EXPORT_SYMBOL(amiga_eclock);
  45
  46unsigned long amiga_colorclock;
  47EXPORT_SYMBOL(amiga_colorclock);
  48
  49unsigned long amiga_chipset;
  50EXPORT_SYMBOL(amiga_chipset);
  51
  52unsigned char amiga_vblank;
  53EXPORT_SYMBOL(amiga_vblank);
  54
  55static unsigned char amiga_psfreq;
  56
  57struct amiga_hw_present amiga_hw_present;
  58EXPORT_SYMBOL(amiga_hw_present);
  59
  60static char s_a500[] __initdata = "A500";
  61static char s_a500p[] __initdata = "A500+";
  62static char s_a600[] __initdata = "A600";
  63static char s_a1000[] __initdata = "A1000";
  64static char s_a1200[] __initdata = "A1200";
  65static char s_a2000[] __initdata = "A2000";
  66static char s_a2500[] __initdata = "A2500";
  67static char s_a3000[] __initdata = "A3000";
  68static char s_a3000t[] __initdata = "A3000T";
  69static char s_a3000p[] __initdata = "A3000+";
  70static char s_a4000[] __initdata = "A4000";
  71static char s_a4000t[] __initdata = "A4000T";
  72static char s_cdtv[] __initdata = "CDTV";
  73static char s_cd32[] __initdata = "CD32";
  74static char s_draco[] __initdata = "Draco";
  75static char *amiga_models[] __initdata = {
  76        [AMI_500-AMI_500]       = s_a500,
  77        [AMI_500PLUS-AMI_500]   = s_a500p,
  78        [AMI_600-AMI_500]       = s_a600,
  79        [AMI_1000-AMI_500]      = s_a1000,
  80        [AMI_1200-AMI_500]      = s_a1200,
  81        [AMI_2000-AMI_500]      = s_a2000,
  82        [AMI_2500-AMI_500]      = s_a2500,
  83        [AMI_3000-AMI_500]      = s_a3000,
  84        [AMI_3000T-AMI_500]     = s_a3000t,
  85        [AMI_3000PLUS-AMI_500]  = s_a3000p,
  86        [AMI_4000-AMI_500]      = s_a4000,
  87        [AMI_4000T-AMI_500]     = s_a4000t,
  88        [AMI_CDTV-AMI_500]      = s_cdtv,
  89        [AMI_CD32-AMI_500]      = s_cd32,
  90        [AMI_DRACO-AMI_500]     = s_draco,
  91};
  92
  93static char amiga_model_name[13] = "Amiga ";
  94
  95static void amiga_sched_init(irq_handler_t handler);
  96static void amiga_get_model(char *model);
  97static void amiga_get_hardware_list(struct seq_file *m);
  98/* amiga specific timer functions */
  99static unsigned long amiga_gettimeoffset(void);
 100extern void amiga_mksound(unsigned int count, unsigned int ticks);
 101static void amiga_reset(void);
 102extern void amiga_init_sound(void);
 103static void amiga_mem_console_write(struct console *co, const char *b,
 104                                    unsigned int count);
 105#ifdef CONFIG_HEARTBEAT
 106static void amiga_heartbeat(int on);
 107#endif
 108
 109static struct console amiga_console_driver = {
 110        .name   = "debug",
 111        .flags  = CON_PRINTBUFFER,
 112        .index  = -1,
 113};
 114
 115
 116    /*
 117     *  Motherboard Resources present in all Amiga models
 118     */
 119
 120static struct {
 121        struct resource _ciab, _ciaa, _custom, _kickstart;
 122} mb_resources = {
 123        ._ciab = {
 124                .name = "CIA B", .start = 0x00bfd000, .end = 0x00bfdfff
 125        },
 126        ._ciaa = {
 127                .name = "CIA A", .start = 0x00bfe000, .end = 0x00bfefff
 128        },
 129        ._custom = {
 130                .name = "Custom I/O", .start = 0x00dff000, .end = 0x00dfffff
 131        },
 132        ._kickstart = {
 133                .name = "Kickstart ROM", .start = 0x00f80000, .end = 0x00ffffff
 134        }
 135};
 136
 137static struct resource ram_resource[NUM_MEMINFO];
 138
 139
 140    /*
 141     *  Parse an Amiga-specific record in the bootinfo
 142     */
 143
 144int amiga_parse_bootinfo(const struct bi_record *record)
 145{
 146        int unknown = 0;
 147        const unsigned long *data = record->data;
 148
 149        switch (record->tag) {
 150        case BI_AMIGA_MODEL:
 151                amiga_model = *data;
 152                break;
 153
 154        case BI_AMIGA_ECLOCK:
 155                amiga_eclock = *data;
 156                break;
 157
 158        case BI_AMIGA_CHIPSET:
 159                amiga_chipset = *data;
 160                break;
 161
 162        case BI_AMIGA_CHIP_SIZE:
 163                amiga_chip_size = *(const int *)data;
 164                break;
 165
 166        case BI_AMIGA_VBLANK:
 167                amiga_vblank = *(const unsigned char *)data;
 168                break;
 169
 170        case BI_AMIGA_PSFREQ:
 171                amiga_psfreq = *(const unsigned char *)data;
 172                break;
 173
 174        case BI_AMIGA_AUTOCON:
 175#ifdef CONFIG_ZORRO
 176                if (zorro_num_autocon < ZORRO_NUM_AUTO) {
 177                        const struct ConfigDev *cd = (struct ConfigDev *)data;
 178                        struct zorro_dev *dev = &zorro_autocon[zorro_num_autocon++];
 179                        dev->rom = cd->cd_Rom;
 180                        dev->slotaddr = cd->cd_SlotAddr;
 181                        dev->slotsize = cd->cd_SlotSize;
 182                        dev->resource.start = (unsigned long)cd->cd_BoardAddr;
 183                        dev->resource.end = dev->resource.start + cd->cd_BoardSize - 1;
 184                } else
 185                        printk("amiga_parse_bootinfo: too many AutoConfig devices\n");
 186#endif /* CONFIG_ZORRO */
 187                break;
 188
 189        case BI_AMIGA_SERPER:
 190                /* serial port period: ignored here */
 191                break;
 192
 193        default:
 194                unknown = 1;
 195        }
 196        return unknown;
 197}
 198
 199    /*
 200     *  Identify builtin hardware
 201     */
 202
 203static void __init amiga_identify(void)
 204{
 205        /* Fill in some default values, if necessary */
 206        if (amiga_eclock == 0)
 207                amiga_eclock = 709379;
 208
 209        memset(&amiga_hw_present, 0, sizeof(amiga_hw_present));
 210
 211        printk("Amiga hardware found: ");
 212        if (amiga_model >= AMI_500 && amiga_model <= AMI_DRACO) {
 213                printk("[%s] ", amiga_models[amiga_model-AMI_500]);
 214                strcat(amiga_model_name, amiga_models[amiga_model-AMI_500]);
 215        }
 216
 217        switch (amiga_model) {
 218        case AMI_UNKNOWN:
 219                goto Generic;
 220
 221        case AMI_600:
 222        case AMI_1200:
 223                AMIGAHW_SET(A1200_IDE);
 224                AMIGAHW_SET(PCMCIA);
 225        case AMI_500:
 226        case AMI_500PLUS:
 227        case AMI_1000:
 228        case AMI_2000:
 229        case AMI_2500:
 230                AMIGAHW_SET(A2000_CLK); /* Is this correct for all models? */
 231                goto Generic;
 232
 233        case AMI_3000:
 234        case AMI_3000T:
 235                AMIGAHW_SET(AMBER_FF);
 236                AMIGAHW_SET(MAGIC_REKICK);
 237                /* fall through */
 238        case AMI_3000PLUS:
 239                AMIGAHW_SET(A3000_SCSI);
 240                AMIGAHW_SET(A3000_CLK);
 241                AMIGAHW_SET(ZORRO3);
 242                goto Generic;
 243
 244        case AMI_4000T:
 245                AMIGAHW_SET(A4000_SCSI);
 246                /* fall through */
 247        case AMI_4000:
 248                AMIGAHW_SET(A4000_IDE);
 249                AMIGAHW_SET(A3000_CLK);
 250                AMIGAHW_SET(ZORRO3);
 251                goto Generic;
 252
 253        case AMI_CDTV:
 254        case AMI_CD32:
 255                AMIGAHW_SET(CD_ROM);
 256                AMIGAHW_SET(A2000_CLK);             /* Is this correct? */
 257                goto Generic;
 258
 259        Generic:
 260                AMIGAHW_SET(AMI_VIDEO);
 261                AMIGAHW_SET(AMI_BLITTER);
 262                AMIGAHW_SET(AMI_AUDIO);
 263                AMIGAHW_SET(AMI_FLOPPY);
 264                AMIGAHW_SET(AMI_KEYBOARD);
 265                AMIGAHW_SET(AMI_MOUSE);
 266                AMIGAHW_SET(AMI_SERIAL);
 267                AMIGAHW_SET(AMI_PARALLEL);
 268                AMIGAHW_SET(CHIP_RAM);
 269                AMIGAHW_SET(PAULA);
 270
 271                switch (amiga_chipset) {
 272                case CS_OCS:
 273                case CS_ECS:
 274                case CS_AGA:
 275                        switch (amiga_custom.deniseid & 0xf) {
 276                        case 0x0c:
 277                                AMIGAHW_SET(DENISE_HR);
 278                                break;
 279                        case 0x08:
 280                                AMIGAHW_SET(LISA);
 281                                break;
 282                        }
 283                        break;
 284                default:
 285                        AMIGAHW_SET(DENISE);
 286                        break;
 287                }
 288                switch ((amiga_custom.vposr>>8) & 0x7f) {
 289                case 0x00:
 290                        AMIGAHW_SET(AGNUS_PAL);
 291                        break;
 292                case 0x10:
 293                        AMIGAHW_SET(AGNUS_NTSC);
 294                        break;
 295                case 0x20:
 296                case 0x21:
 297                        AMIGAHW_SET(AGNUS_HR_PAL);
 298                        break;
 299                case 0x30:
 300                case 0x31:
 301                        AMIGAHW_SET(AGNUS_HR_NTSC);
 302                        break;
 303                case 0x22:
 304                case 0x23:
 305                        AMIGAHW_SET(ALICE_PAL);
 306                        break;
 307                case 0x32:
 308                case 0x33:
 309                        AMIGAHW_SET(ALICE_NTSC);
 310                        break;
 311                }
 312                AMIGAHW_SET(ZORRO);
 313                break;
 314
 315        case AMI_DRACO:
 316                panic("No support for Draco yet");
 317
 318        default:
 319                panic("Unknown Amiga Model");
 320        }
 321
 322#define AMIGAHW_ANNOUNCE(name, str)             \
 323        if (AMIGAHW_PRESENT(name))              \
 324                printk(str)
 325
 326        AMIGAHW_ANNOUNCE(AMI_VIDEO, "VIDEO ");
 327        AMIGAHW_ANNOUNCE(AMI_BLITTER, "BLITTER ");
 328        AMIGAHW_ANNOUNCE(AMBER_FF, "AMBER_FF ");
 329        AMIGAHW_ANNOUNCE(AMI_AUDIO, "AUDIO ");
 330        AMIGAHW_ANNOUNCE(AMI_FLOPPY, "FLOPPY ");
 331        AMIGAHW_ANNOUNCE(A3000_SCSI, "A3000_SCSI ");
 332        AMIGAHW_ANNOUNCE(A4000_SCSI, "A4000_SCSI ");
 333        AMIGAHW_ANNOUNCE(A1200_IDE, "A1200_IDE ");
 334        AMIGAHW_ANNOUNCE(A4000_IDE, "A4000_IDE ");
 335        AMIGAHW_ANNOUNCE(CD_ROM, "CD_ROM ");
 336        AMIGAHW_ANNOUNCE(AMI_KEYBOARD, "KEYBOARD ");
 337        AMIGAHW_ANNOUNCE(AMI_MOUSE, "MOUSE ");
 338        AMIGAHW_ANNOUNCE(AMI_SERIAL, "SERIAL ");
 339        AMIGAHW_ANNOUNCE(AMI_PARALLEL, "PARALLEL ");
 340        AMIGAHW_ANNOUNCE(A2000_CLK, "A2000_CLK ");
 341        AMIGAHW_ANNOUNCE(A3000_CLK, "A3000_CLK ");
 342        AMIGAHW_ANNOUNCE(CHIP_RAM, "CHIP_RAM ");
 343        AMIGAHW_ANNOUNCE(PAULA, "PAULA ");
 344        AMIGAHW_ANNOUNCE(DENISE, "DENISE ");
 345        AMIGAHW_ANNOUNCE(DENISE_HR, "DENISE_HR ");
 346        AMIGAHW_ANNOUNCE(LISA, "LISA ");
 347        AMIGAHW_ANNOUNCE(AGNUS_PAL, "AGNUS_PAL ");
 348        AMIGAHW_ANNOUNCE(AGNUS_NTSC, "AGNUS_NTSC ");
 349        AMIGAHW_ANNOUNCE(AGNUS_HR_PAL, "AGNUS_HR_PAL ");
 350        AMIGAHW_ANNOUNCE(AGNUS_HR_NTSC, "AGNUS_HR_NTSC ");
 351        AMIGAHW_ANNOUNCE(ALICE_PAL, "ALICE_PAL ");
 352        AMIGAHW_ANNOUNCE(ALICE_NTSC, "ALICE_NTSC ");
 353        AMIGAHW_ANNOUNCE(MAGIC_REKICK, "MAGIC_REKICK ");
 354        AMIGAHW_ANNOUNCE(PCMCIA, "PCMCIA ");
 355        if (AMIGAHW_PRESENT(ZORRO))
 356                printk("ZORRO%s ", AMIGAHW_PRESENT(ZORRO3) ? "3" : "");
 357        printk("\n");
 358
 359#undef AMIGAHW_ANNOUNCE
 360}
 361
 362    /*
 363     *  Setup the Amiga configuration info
 364     */
 365
 366void __init config_amiga(void)
 367{
 368        int i;
 369
 370        amiga_identify();
 371
 372        /* Yuk, we don't have PCI memory */
 373        iomem_resource.name = "Memory";
 374        for (i = 0; i < 4; i++)
 375                request_resource(&iomem_resource, &((struct resource *)&mb_resources)[i]);
 376
 377        mach_sched_init      = amiga_sched_init;
 378        mach_init_IRQ        = amiga_init_IRQ;
 379        mach_get_model       = amiga_get_model;
 380        mach_get_hardware_list = amiga_get_hardware_list;
 381        mach_gettimeoffset   = amiga_gettimeoffset;
 382
 383        /*
 384         * default MAX_DMA=0xffffffff on all machines. If we don't do so, the SCSI
 385         * code will not be able to allocate any mem for transfers, unless we are
 386         * dealing with a Z2 mem only system.                  /Jes
 387         */
 388        mach_max_dma_address = 0xffffffff;
 389
 390        mach_reset           = amiga_reset;
 391#if defined(CONFIG_INPUT_M68K_BEEP) || defined(CONFIG_INPUT_M68K_BEEP_MODULE)
 392        mach_beep            = amiga_mksound;
 393#endif
 394
 395#ifdef CONFIG_HEARTBEAT
 396        mach_heartbeat = amiga_heartbeat;
 397#endif
 398
 399        /* Fill in the clock value (based on the 700 kHz E-Clock) */
 400        amiga_colorclock = 5*amiga_eclock;      /* 3.5 MHz */
 401
 402        /* clear all DMA bits */
 403        amiga_custom.dmacon = DMAF_ALL;
 404        /* ensure that the DMA master bit is set */
 405        amiga_custom.dmacon = DMAF_SETCLR | DMAF_MASTER;
 406
 407        /* don't use Z2 RAM as system memory on Z3 capable machines */
 408        if (AMIGAHW_PRESENT(ZORRO3)) {
 409                int i, j;
 410                u32 disabled_z2mem = 0;
 411
 412                for (i = 0; i < m68k_num_memory; i++) {
 413                        if (m68k_memory[i].addr < 16*1024*1024) {
 414                                if (i == 0) {
 415                                        /* don't cut off the branch we're sitting on */
 416                                        printk("Warning: kernel runs in Zorro II memory\n");
 417                                        continue;
 418                                }
 419                                disabled_z2mem += m68k_memory[i].size;
 420                                m68k_num_memory--;
 421                                for (j = i; j < m68k_num_memory; j++)
 422                                        m68k_memory[j] = m68k_memory[j+1];
 423                                i--;
 424                        }
 425                }
 426                if (disabled_z2mem)
 427                printk("%dK of Zorro II memory will not be used as system memory\n",
 428                disabled_z2mem>>10);
 429        }
 430
 431        /* request all RAM */
 432        for (i = 0; i < m68k_num_memory; i++) {
 433                ram_resource[i].name =
 434                        (m68k_memory[i].addr >= 0x01000000) ? "32-bit Fast RAM" :
 435                        (m68k_memory[i].addr < 0x00c00000) ? "16-bit Fast RAM" :
 436                        "16-bit Slow RAM";
 437                ram_resource[i].start = m68k_memory[i].addr;
 438                ram_resource[i].end = m68k_memory[i].addr+m68k_memory[i].size-1;
 439                request_resource(&iomem_resource, &ram_resource[i]);
 440        }
 441
 442        /* initialize chipram allocator */
 443        amiga_chip_init();
 444
 445        /* our beloved beeper */
 446        if (AMIGAHW_PRESENT(AMI_AUDIO))
 447                amiga_init_sound();
 448
 449        /*
 450         * if it is an A3000, set the magic bit that forces
 451         * a hard rekick
 452         */
 453        if (AMIGAHW_PRESENT(MAGIC_REKICK))
 454                *(unsigned char *)ZTWO_VADDR(0xde0002) |= 0x80;
 455}
 456
 457static unsigned short jiffy_ticks;
 458
 459static void __init amiga_sched_init(irq_handler_t timer_routine)
 460{
 461        static struct resource sched_res = {
 462                .name = "timer", .start = 0x00bfd400, .end = 0x00bfd5ff,
 463        };
 464        jiffy_ticks = DIV_ROUND_CLOSEST(amiga_eclock, HZ);
 465
 466        if (request_resource(&mb_resources._ciab, &sched_res))
 467                printk("Cannot allocate ciab.ta{lo,hi}\n");
 468        ciab.cra &= 0xC0;   /* turn off timer A, continuous mode, from Eclk */
 469        ciab.talo = jiffy_ticks % 256;
 470        ciab.tahi = jiffy_ticks / 256;
 471
 472        /* install interrupt service routine for CIAB Timer A
 473         *
 474         * Please don't change this to use ciaa, as it interferes with the
 475         * SCSI code. We'll have to take a look at this later
 476         */
 477        if (request_irq(IRQ_AMIGA_CIAB_TA, timer_routine, 0, "timer", NULL))
 478                pr_err("Couldn't register timer interrupt\n");
 479        /* start timer */
 480        ciab.cra |= 0x11;
 481}
 482
 483#define TICK_SIZE 10000
 484
 485/* This is always executed with interrupts disabled.  */
 486static unsigned long amiga_gettimeoffset(void)
 487{
 488        unsigned short hi, lo, hi2;
 489        unsigned long ticks, offset = 0;
 490
 491        /* read CIA B timer A current value */
 492        hi  = ciab.tahi;
 493        lo  = ciab.talo;
 494        hi2 = ciab.tahi;
 495
 496        if (hi != hi2) {
 497                lo = ciab.talo;
 498                hi = hi2;
 499        }
 500
 501        ticks = hi << 8 | lo;
 502
 503        if (ticks > jiffy_ticks / 2)
 504                /* check for pending interrupt */
 505                if (cia_set_irq(&ciab_base, 0) & CIA_ICR_TA)
 506                        offset = 10000;
 507
 508        ticks = jiffy_ticks - ticks;
 509        ticks = (10000 * ticks) / jiffy_ticks;
 510
 511        return ticks + offset;
 512}
 513
 514static NORET_TYPE void amiga_reset(void)
 515    ATTRIB_NORET;
 516
 517static void amiga_reset(void)
 518{
 519        unsigned long jmp_addr040 = virt_to_phys(&&jmp_addr_label040);
 520        unsigned long jmp_addr = virt_to_phys(&&jmp_addr_label);
 521
 522        local_irq_disable();
 523        if (CPU_IS_040_OR_060)
 524                /* Setup transparent translation registers for mapping
 525                 * of 16 MB kernel segment before disabling translation
 526                 */
 527                asm volatile ("\n"
 528                        "       move.l  %0,%%d0\n"
 529                        "       and.l   #0xff000000,%%d0\n"
 530                        "       or.w    #0xe020,%%d0\n"   /* map 16 MB, enable, cacheable */
 531                        "       .chip   68040\n"
 532                        "       movec   %%d0,%%itt0\n"
 533                        "       movec   %%d0,%%dtt0\n"
 534                        "       .chip   68k\n"
 535                        "       jmp     %0@\n"
 536                        : /* no outputs */
 537                        : "a" (jmp_addr040)
 538                        : "d0");
 539        else
 540                /* for 680[23]0, just disable translation and jump to the physical
 541                 * address of the label
 542                 */
 543                asm volatile ("\n"
 544                        "       pmove   %%tc,%@\n"
 545                        "       bclr    #7,%@\n"
 546                        "       pmove   %@,%%tc\n"
 547                        "       jmp     %0@\n"
 548                        : /* no outputs */
 549                        : "a" (jmp_addr));
 550jmp_addr_label040:
 551        /* disable translation on '040 now */
 552        asm volatile ("\n"
 553                "       moveq   #0,%%d0\n"
 554                "       .chip   68040\n"
 555                "       movec   %%d0,%%tc\n"    /* disable MMU */
 556                "       .chip   68k\n"
 557                : /* no outputs */
 558                : /* no inputs */
 559                : "d0");
 560
 561        jmp_addr_label:
 562        /* pickup reset address from AmigaOS ROM, reset devices and jump
 563         * to reset address
 564         */
 565        asm volatile ("\n"
 566                "       move.w  #0x2700,%sr\n"
 567                "       lea     0x01000000,%a0\n"
 568                "       sub.l   %a0@(-0x14),%a0\n"
 569                "       move.l  %a0@(4),%a0\n"
 570                "       subq.l  #2,%a0\n"
 571                "       jra     1f\n"
 572                /* align on a longword boundary */
 573                "       " __ALIGN_STR "\n"
 574                "1:\n"
 575                "       reset\n"
 576                "       jmp   %a0@");
 577
 578        for (;;)
 579                ;
 580}
 581
 582
 583    /*
 584     *  Debugging
 585     */
 586
 587#define SAVEKMSG_MAXMEM         128*1024
 588
 589#define SAVEKMSG_MAGIC1         0x53415645      /* 'SAVE' */
 590#define SAVEKMSG_MAGIC2         0x4B4D5347      /* 'KMSG' */
 591
 592struct savekmsg {
 593        unsigned long magic1;           /* SAVEKMSG_MAGIC1 */
 594        unsigned long magic2;           /* SAVEKMSG_MAGIC2 */
 595        unsigned long magicptr;         /* address of magic1 */
 596        unsigned long size;
 597        char data[0];
 598};
 599
 600static struct savekmsg *savekmsg;
 601
 602static void amiga_mem_console_write(struct console *co, const char *s,
 603                                    unsigned int count)
 604{
 605        if (savekmsg->size + count <= SAVEKMSG_MAXMEM-sizeof(struct savekmsg)) {
 606                memcpy(savekmsg->data + savekmsg->size, s, count);
 607                savekmsg->size += count;
 608        }
 609}
 610
 611static int __init amiga_savekmsg_setup(char *arg)
 612{
 613        if (!MACH_IS_AMIGA || strcmp(arg, "mem"))
 614                return 0;
 615
 616        if (amiga_chip_size < SAVEKMSG_MAXMEM) {
 617                pr_err("Not enough chipram for debugging\n");
 618                return -ENOMEM;
 619        }
 620
 621        /* Just steal the block, the chipram allocator isn't functional yet */
 622        amiga_chip_size -= SAVEKMSG_MAXMEM;
 623        savekmsg = (void *)ZTWO_VADDR(CHIP_PHYSADDR + amiga_chip_size);
 624        savekmsg->magic1 = SAVEKMSG_MAGIC1;
 625        savekmsg->magic2 = SAVEKMSG_MAGIC2;
 626        savekmsg->magicptr = ZTWO_PADDR(savekmsg);
 627        savekmsg->size = 0;
 628
 629        amiga_console_driver.write = amiga_mem_console_write;
 630        register_console(&amiga_console_driver);
 631        return 0;
 632}
 633
 634early_param("debug", amiga_savekmsg_setup);
 635
 636static void amiga_serial_putc(char c)
 637{
 638        amiga_custom.serdat = (unsigned char)c | 0x100;
 639        while (!(amiga_custom.serdatr & 0x2000))
 640                ;
 641}
 642
 643static void amiga_serial_console_write(struct console *co, const char *s,
 644                                       unsigned int count)
 645{
 646        while (count--) {
 647                if (*s == '\n')
 648                        amiga_serial_putc('\r');
 649                amiga_serial_putc(*s++);
 650        }
 651}
 652
 653#if 0
 654void amiga_serial_puts(const char *s)
 655{
 656        amiga_serial_console_write(NULL, s, strlen(s));
 657}
 658
 659int amiga_serial_console_wait_key(struct console *co)
 660{
 661        int ch;
 662
 663        while (!(amiga_custom.intreqr & IF_RBF))
 664                barrier();
 665        ch = amiga_custom.serdatr & 0xff;
 666        /* clear the interrupt, so that another character can be read */
 667        amiga_custom.intreq = IF_RBF;
 668        return ch;
 669}
 670
 671void amiga_serial_gets(struct console *co, char *s, int len)
 672{
 673        int ch, cnt = 0;
 674
 675        while (1) {
 676                ch = amiga_serial_console_wait_key(co);
 677
 678                /* Check for backspace. */
 679                if (ch == 8 || ch == 127) {
 680                        if (cnt == 0) {
 681                                amiga_serial_putc('\007');
 682                                continue;
 683                        }
 684                        cnt--;
 685                        amiga_serial_puts("\010 \010");
 686                        continue;
 687                }
 688
 689                /* Check for enter. */
 690                if (ch == 10 || ch == 13)
 691                        break;
 692
 693                /* See if line is too long. */
 694                if (cnt >= len + 1) {
 695                        amiga_serial_putc(7);
 696                        cnt--;
 697                        continue;
 698                }
 699
 700                /* Store and echo character. */
 701                s[cnt++] = ch;
 702                amiga_serial_putc(ch);
 703        }
 704        /* Print enter. */
 705        amiga_serial_puts("\r\n");
 706        s[cnt] = 0;
 707}
 708#endif
 709
 710static int __init amiga_debug_setup(char *arg)
 711{
 712        if (MACH_IS_AMIGA && !strcmp(arg, "ser")) {
 713                /* no initialization required (?) */
 714                amiga_console_driver.write = amiga_serial_console_write;
 715                register_console(&amiga_console_driver);
 716        }
 717        return 0;
 718}
 719
 720early_param("debug", amiga_debug_setup);
 721
 722#ifdef CONFIG_HEARTBEAT
 723static void amiga_heartbeat(int on)
 724{
 725        if (on)
 726                ciaa.pra &= ~2;
 727        else
 728                ciaa.pra |= 2;
 729}
 730#endif
 731
 732    /*
 733     *  Amiga specific parts of /proc
 734     */
 735
 736static void amiga_get_model(char *model)
 737{
 738        strcpy(model, amiga_model_name);
 739}
 740
 741
 742static void amiga_get_hardware_list(struct seq_file *m)
 743{
 744        if (AMIGAHW_PRESENT(CHIP_RAM))
 745                seq_printf(m, "Chip RAM:\t%ldK\n", amiga_chip_size>>10);
 746        seq_printf(m, "PS Freq:\t%dHz\nEClock Freq:\t%ldHz\n",
 747                        amiga_psfreq, amiga_eclock);
 748        if (AMIGAHW_PRESENT(AMI_VIDEO)) {
 749                char *type;
 750                switch (amiga_chipset) {
 751                case CS_OCS:
 752                        type = "OCS";
 753                        break;
 754                case CS_ECS:
 755                        type = "ECS";
 756                        break;
 757                case CS_AGA:
 758                        type = "AGA";
 759                        break;
 760                default:
 761                        type = "Old or Unknown";
 762                        break;
 763                }
 764                seq_printf(m, "Graphics:\t%s\n", type);
 765        }
 766
 767#define AMIGAHW_ANNOUNCE(name, str)                     \
 768        if (AMIGAHW_PRESENT(name))                      \
 769                seq_printf (m, "\t%s\n", str)
 770
 771        seq_printf (m, "Detected hardware:\n");
 772
 773        AMIGAHW_ANNOUNCE(AMI_VIDEO, "Amiga Video");
 774        AMIGAHW_ANNOUNCE(AMI_BLITTER, "Blitter");
 775        AMIGAHW_ANNOUNCE(AMBER_FF, "Amber Flicker Fixer");
 776        AMIGAHW_ANNOUNCE(AMI_AUDIO, "Amiga Audio");
 777        AMIGAHW_ANNOUNCE(AMI_FLOPPY, "Floppy Controller");
 778        AMIGAHW_ANNOUNCE(A3000_SCSI, "SCSI Controller WD33C93 (A3000 style)");
 779        AMIGAHW_ANNOUNCE(A4000_SCSI, "SCSI Controller NCR53C710 (A4000T style)");
 780        AMIGAHW_ANNOUNCE(A1200_IDE, "IDE Interface (A1200 style)");
 781        AMIGAHW_ANNOUNCE(A4000_IDE, "IDE Interface (A4000 style)");
 782        AMIGAHW_ANNOUNCE(CD_ROM, "Internal CD ROM drive");
 783        AMIGAHW_ANNOUNCE(AMI_KEYBOARD, "Keyboard");
 784        AMIGAHW_ANNOUNCE(AMI_MOUSE, "Mouse Port");
 785        AMIGAHW_ANNOUNCE(AMI_SERIAL, "Serial Port");
 786        AMIGAHW_ANNOUNCE(AMI_PARALLEL, "Parallel Port");
 787        AMIGAHW_ANNOUNCE(A2000_CLK, "Hardware Clock (A2000 style)");
 788        AMIGAHW_ANNOUNCE(A3000_CLK, "Hardware Clock (A3000 style)");
 789        AMIGAHW_ANNOUNCE(CHIP_RAM, "Chip RAM");
 790        AMIGAHW_ANNOUNCE(PAULA, "Paula 8364");
 791        AMIGAHW_ANNOUNCE(DENISE, "Denise 8362");
 792        AMIGAHW_ANNOUNCE(DENISE_HR, "Denise 8373");
 793        AMIGAHW_ANNOUNCE(LISA, "Lisa 8375");
 794        AMIGAHW_ANNOUNCE(AGNUS_PAL, "Normal/Fat PAL Agnus 8367/8371");
 795        AMIGAHW_ANNOUNCE(AGNUS_NTSC, "Normal/Fat NTSC Agnus 8361/8370");
 796        AMIGAHW_ANNOUNCE(AGNUS_HR_PAL, "Fat Hires PAL Agnus 8372");
 797        AMIGAHW_ANNOUNCE(AGNUS_HR_NTSC, "Fat Hires NTSC Agnus 8372");
 798        AMIGAHW_ANNOUNCE(ALICE_PAL, "PAL Alice 8374");
 799        AMIGAHW_ANNOUNCE(ALICE_NTSC, "NTSC Alice 8374");
 800        AMIGAHW_ANNOUNCE(MAGIC_REKICK, "Magic Hard Rekick");
 801        AMIGAHW_ANNOUNCE(PCMCIA, "PCMCIA Slot");
 802#ifdef CONFIG_ZORRO
 803        if (AMIGAHW_PRESENT(ZORRO))
 804                seq_printf(m, "\tZorro II%s AutoConfig: %d Expansion "
 805                                "Device%s\n",
 806                                AMIGAHW_PRESENT(ZORRO3) ? "I" : "",
 807                                zorro_num_autocon, zorro_num_autocon == 1 ? "" : "s");
 808#endif /* CONFIG_ZORRO */
 809
 810#undef AMIGAHW_ANNOUNCE
 811}
 812
 813/*
 814 * The Amiga keyboard driver needs key_maps, but we cannot export it in
 815 * drivers/char/defkeymap.c, as it is autogenerated
 816 */
 817#ifdef CONFIG_HW_CONSOLE
 818EXPORT_SYMBOL_GPL(key_maps);
 819#endif
 820