From: <he...@us...> - 2004-10-19 23:07:39
|
Update of /cvsroot/gc-linux/linux/arch/ppc/platforms In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21784/arch/ppc/platforms Modified Files: gamecube.c gamecube.h Log Message: - Removed init/main.c as it is not needed anymore (the console initialization function that was there has been integrated in gamecube.c's setup arch func). - Renamed functions named gamecube_* to gcn_* (which is the official short name of the Nintendo GameCube at least in Europe). - Moved some definitions between gamecube.h and gamecube.c files. - Added some interesting constants and the current memory map to gamecube.h. Index: gamecube.c =================================================================== RCS file: /cvsroot/gc-linux/linux/arch/ppc/platforms/gamecube.c,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- gamecube.c 19 Oct 2004 09:49:50 -0000 1.21 +++ gamecube.c 19 Oct 2004 23:07:13 -0000 1.22 @@ -1,5 +1,14 @@ /* * arch/ppc/platforms/gamecube.c + * + * Nintendo GameCube board-specific support + * Copyright (C) 2004 The GameCube Linux Team + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * */ #include <linux/init.h> @@ -16,8 +25,31 @@ #include <asm/machdep.h> #include <asm/pgtable.h> -#include "console.h" #include "gamecube.h" +#include "gcn-con.h" + +/* + * There are 14 IRQs in total. Each has a corresponding bit in both + * the Interrupt Cause (ICR) and Interrupt Mask (IMR) registers. + * + * Enabling/disabling an interrupt line involves asserting/clearing + * the corresponding bit in IMR. ACK'ing a request simply involves + * asserting the corresponding bit in ICR. + */ +#define FLIPPER_NR_IRQS 14 +#define FLIPPER_ICR ((volatile ulong *)0xcc003000) +#define FLIPPER_IMR ((volatile ulong *)0xcc003004) + +/* + * Anything written here automagically puts us through reset. + */ +#define GCN_PI_RESET 0xcc003024 + +/* + * These registers control where the visible framebuffer is located. + */ +#define GCN_VI_TFBL 0xcc00201c +#define GCN_VI_BFBL 0xcc002024 /* * We happen to be ISA/PCI-free, hence the !CONFIG_PCI. These @@ -27,43 +59,51 @@ unsigned long isa_mem_base = 0; unsigned long pci_dram_offset = 0; -extern long gamecube_time_init(void) __init; -extern unsigned long gamecube_get_rtc_time(void); -extern int gamecube_set_rtc_time(unsigned long nowtime); -unsigned long gamecube_find_end_of_memory(void) +/* from arch/ppc/platforms/gcn-time.c */ +extern long gcn_time_init(void) __init; +extern unsigned long gcn_get_rtc_time(void); +extern int gcn_set_rtc_time(unsigned long nowtime); + + +unsigned long +gcn_find_end_of_memory(void) { - return 24*1024*1024 - (640*576*2); /* 24 MB minus max. framebuffer */ + return GCN_MEM_SIZE; } void __init -gamecube_map_io(void) +gcn_map_io(void) { + /* all RAM and more ??? */ io_block_mapping(0xd0000000, 0, 0x02000000, _PAGE_IO); - io_block_mapping(0xcc000000, 0x0c000000, 0x00100000, _PAGE_IO); /* GC IO */ + + /* access to hardware registers */ + io_block_mapping(0xcc000000, 0x0c000000, 0x00100000, _PAGE_IO); } static void -gamecube_restart(char *cmd) +gcn_restart(char *cmd) { local_irq_disable(); - writeb(0x00, GAMECUBE_RESET); + writeb(0x00, GCN_PI_RESET); } static void -gamecube_power_off(void) +gcn_power_off(void) { local_irq_disable(); for (;;); /* Wait until power button depressed */ } static void -gamecube_halt(void) +gcn_halt(void) { - gamecube_restart(NULL); + gcn_restart(NULL); } -void __init gamecube_calibrate_decr(void) +void __init +gcn_calibrate_decr(void) { int freq, divisor; freq = 162000000; @@ -73,7 +113,7 @@ } static int -gamecube_get_irq(struct pt_regs *regs) +gcn_get_irq(struct pt_regs *regs) { int irq; u_int irq_status, irq_test = 1; @@ -82,7 +122,7 @@ if (irq_status == 0) return -1; /* no more IRQs pending */ - for (irq = 0; irq < 14; irq++, irq_test <<= 1) + for (irq = 0; irq < FLIPPER_NR_IRQS; irq++, irq_test <<= 1) if (irq_status & irq_test) break; @@ -116,7 +156,7 @@ }; static void __init -gamecube_init_IRQ(void) +gcn_init_IRQ(void) { int i; @@ -124,12 +164,12 @@ writel(0x00000000, FLIPPER_IMR); writel(0xffffffff, FLIPPER_ICR); - for (i = 0; i < 14; i++) + for (i = 0; i < FLIPPER_NR_IRQS; i++) irq_desc[i].handler = &flipper_pic; } static int -gamecube_show_cpuinfo(struct seq_file *m) +gcn_show_cpuinfo(struct seq_file *m) { seq_printf(m, "vendor\t\t: IBM\n"); seq_printf(m, "machine\t\t: Nintendo GameCube\n"); @@ -138,8 +178,16 @@ } static void __init -gamecube_setup_arch(void) +gcn_setup_arch(void) { +#ifdef CONFIG_GAMECUBE_CONSOLE +#if (GCN_XFB_START <= 0x00fffe00) + #error Sorry, debug console needs the framebuffer at a higher address. +#endif + writel(0x10000000 | (GCN_XFB_START>>5), GCN_VI_TFBL); + writel(0x10000000 | ((GCN_XFB_START+2*640)>>5), GCN_VI_BFBL); + gcn_con_init(); +#endif } void __init @@ -156,22 +204,23 @@ } #endif - ppc_md.setup_arch = gamecube_setup_arch; - ppc_md.show_cpuinfo = gamecube_show_cpuinfo; + ppc_md.setup_arch = gcn_setup_arch; + ppc_md.show_cpuinfo = gcn_show_cpuinfo; - ppc_md.init_IRQ = gamecube_init_IRQ; - ppc_md.get_irq = gamecube_get_irq; + ppc_md.init_IRQ = gcn_init_IRQ; + ppc_md.get_irq = gcn_get_irq; - ppc_md.restart = gamecube_restart; - ppc_md.power_off = gamecube_power_off; - ppc_md.halt = gamecube_halt; + ppc_md.restart = gcn_restart; + ppc_md.power_off = gcn_power_off; + ppc_md.halt = gcn_halt; - ppc_md.calibrate_decr = gamecube_calibrate_decr; + ppc_md.calibrate_decr = gcn_calibrate_decr; - ppc_md.find_end_of_memory = gamecube_find_end_of_memory; - ppc_md.setup_io_mappings = gamecube_map_io; + ppc_md.find_end_of_memory = gcn_find_end_of_memory; + ppc_md.setup_io_mappings = gcn_map_io; - ppc_md.time_init = gamecube_time_init; - ppc_md.set_rtc_time = gamecube_set_rtc_time; - ppc_md.get_rtc_time = gamecube_get_rtc_time; + ppc_md.time_init = gcn_time_init; + ppc_md.set_rtc_time = gcn_set_rtc_time; + ppc_md.get_rtc_time = gcn_get_rtc_time; } + Index: gamecube.h =================================================================== RCS file: /cvsroot/gc-linux/linux/arch/ppc/platforms/gamecube.h,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- gamecube.h 3 Jun 2004 15:19:44 -0000 1.8 +++ gamecube.h 19 Oct 2004 23:07:28 -0000 1.9 @@ -1,12 +1,14 @@ /* * arch/ppc/platforms/gamecube.h * - * Nintendo GameCube board-specific definitions. + * Nintendo GameCube board-specific definitions + * Copyright (C) 2004 The GameCube Linux Team + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. */ #ifndef __MACH_GAMECUBE_H @@ -15,19 +17,59 @@ #include <asm/ppcboot.h> /* - * There are 14 IRQs in total. Each has a corresponding bit in both - * the Interrupt Cause (ICR) and Interrupt Mask (IMR) registers. + * This is the current memory layout for the GameCube Linux port. + * + * +------------------------------+ + * | framebuffer 640x576x2 bytes | GCN_XFB_END + * . . + * . . + * +------------------------------+ GCN_XFB_START + * | kexec reserved 4x4096 bytes | GCN_KXC_END + * . . + * +------------------------------+ GCN_KXC_START + * | memory remaining bytes | GCN_MEM_END + * . . + * . . + * . . + * +- - - - - - - - - - - - - - - + + * | Dolphin OS 12544 bytes | + * | globals, pre-kernel | + * | | + * | | + * +------------------------------+ GCN_MEM_START * - * Enabling/disabling an interrupt line involves asserting/clearing - * the corresponding bit in IMR. ACK'ing a request simply involves - * asserting the corresponding bit in ICR. */ -#define FLIPPER_ICR ((volatile ulong *)0xcc003000) -#define FLIPPER_IMR ((volatile ulong *)0xcc003004) /* - * Anything written here automagically puts us through reset. + * Some useful sizes */ -#define GAMECUBE_RESET 0xCC003024 +#define GCN_RAM_SIZE (24*1024*1024) /* 24 MB */ +#define GCN_XFB_SIZE (640*576*2) /* pal framebuffer */ +#ifdef CONFIG_KEXEC + #define GCN_KXC_SIZE (4*4096) /* PAGE_ALIGN(GCN_PRESERVE_SIZE) */ +#else + #define GCN_KXC_SIZE (0) +#endif +#define GCN_MEM_SIZE (GCN_MEM_END+1) + +/* + * Start and end of several regions + */ +#define GCN_XFB_END (GCN_RAM_SIZE-1) +#define GCN_XFB_START (GCN_XFB_END-GCN_XFB_SIZE+1) +#define GCN_KXC_END (GCN_XFB_START-1) +#define GCN_KXC_START (GCN_KXC_END-GCN_KXC_SIZE+1) +#define GCN_MEM_END (GCN_KXC_START-1) +#define GCN_MEM_START (0x00000000) + +/* + * Some memory regions will be preserved across kexec reboots, if enabled. + */ +#define GCN_PRESERVE_START (0x00000000) +#define GCN_PRESERVE_END (0x000030ff) +#define GCN_PRESERVE_FROM (GCN_PRESERVE_START) +#define GCN_PRESERVE_TO (GCN_KXC_START) +#define GCN_PRESERVE_SIZE (GCN_PRESERVE_END+1) #endif /* !__MACH_GAMECUBE_H */ + |