diff -Nru linux/include/asm-mips/ddb5xxx/ddb5477.h.orig linux/include/asm-mips/ddb5xxx/ddb5477.h --- linux/include/asm-mips/ddb5xxx/ddb5477.h.orig Mon Oct 8 09:52:35 2001 +++ linux/include/asm-mips/ddb5xxx/ddb5477.h Fri Nov 30 18:08:45 2001 @@ -172,8 +172,10 @@ * corresponding size. For example, if PCI_IO_SIZE is 16MB, then * PCI_IO_BASE must be aligned along 16MB boundary. */ + +/* the actual ram size is detected at run-time */ #define DDB_SDRAM_BASE 0x00000000 -#define DDB_SDRAM_SIZE 0x08000000 /* 128MB, for sure? */ +#define DDB_MAX_SDRAM_SIZE 0x08000000 /* less than 128MB */ #define DDB_PCI0_MEM_BASE 0x08000000 #define DDB_PCI0_MEM_SIZE 0x08000000 /* 128 MB */ @@ -226,12 +228,17 @@ /* * debug routines */ -#if defined(CONFIG_LL_DEBUG) +#if defined(CONFIG_DEBUG) extern void vrc5477_show_pdar_regs(void); extern void vrc5477_show_pci_regs(void); extern void vrc5477_show_bar_regs(void); extern void vrc5477_show_int_regs(void); extern void vrc5477_show_all_regs(void); #endif + +/* + * RAM size + */ +extern int board_ram_size; #endif /* __ASM_DDB5XXX_DDB5477_H */ diff -Nru linux/include/asm-mips/bootinfo.h.orig linux/include/asm-mips/bootinfo.h --- linux/include/asm-mips/bootinfo.h.orig Wed Nov 28 11:13:21 2001 +++ linux/include/asm-mips/bootinfo.h Mon Dec 3 17:03:57 2001 @@ -32,7 +32,7 @@ #define MACH_GROUP_TOSHIBA 17 /* Toshiba Reference Systems TSBREF */ #define MACH_GROUP_ALCHEMY 18 /* Alchemy Semi Eval Boards*/ #define MACH_GROUP_NEC_VR41XX 19 /* NEC Vr41xx based boards/gadgets */ -#define MACH_GROUP_HP_LASERJET 20 /* Hewlett Packard LaserJet */ +#define MACH_GROUP_HP_LJ 20 /* Hewlett Packard LaserJet */ #define MACH_GROUP_EE 21 /* Emotion Engine (Sony PlayStation 2) */ #define GROUP_NAMES { "unknown", "Jazz", "Digital", "ARC", "SNI", "ACN", \ @@ -119,8 +119,9 @@ #define MACH_NEC_DDB5074 0 /* NEC DDB Vrc-5074 */ #define MACH_NEC_DDB5476 1 /* NEC DDB Vrc-5476 */ #define MACH_NEC_DDB5477 2 /* NEC DDB Vrc-5477 */ +#define MACH_NEC_ROCKHOPPER 3 /* rockhopper base board */ -#define GROUP_NEC_DDB_NAMES { "Vrc-5074", "Vrc-5476", "Vrc-5477"} +#define GROUP_NEC_DDB_NAMES { "Vrc-5074", "Vrc-5476", "Vrc-5477", "Rockhopper" } /* * Valid machtype for group BAGET diff -Nru linux/arch/mips/ddb5xxx/common/prom.c.orig linux/arch/mips/ddb5xxx/common/prom.c --- linux/arch/mips/ddb5xxx/common/prom.c.orig Thu Sep 27 14:48:23 2001 +++ linux/arch/mips/ddb5xxx/common/prom.c Fri Nov 30 18:04:17 2001 @@ -22,6 +22,7 @@ #include #include #include +#include char arcs_cmdline[COMMAND_LINE_SIZE]; @@ -47,15 +48,77 @@ #if defined(CONFIG_DDB5074) mips_machtype = MACH_NEC_DDB5074; + add_memory_region(0, DDB_SDRAM_SIZE, BOOT_MEM_RAM); #elif defined(CONFIG_DDB5476) mips_machtype = MACH_NEC_DDB5476; + add_memory_region(0, DDB_SDRAM_SIZE, BOOT_MEM_RAM); #elif defined(CONFIG_DDB5477) - mips_machtype = MACH_NEC_DDB5477; + ddb5477_runtime_detection(); + add_memory_region(0, board_ram_size, BOOT_MEM_RAM); #endif - - add_memory_region(0, DDB_SDRAM_SIZE, BOOT_MEM_RAM); } void __init prom_free_prom_memory(void) { } + +#if defined(CONFIG_DDB5477) + +#define DEFAULT_LCS1_BASE 0x19000000 +#define TESTVAL1 'K' +#define TESTVAL2 'S' + +int board_ram_size; +void ddb5477_runtime_detection(void) +{ + volatile char *test_offset; + char saved_test_byte; + + /* Determine if this is a DDB5477 board, or a BSB-VR0300 + base board. We can tell by checking for the location of + the NVRAM. It lives at the beginning of LCS1 on the DDB5477, + and the beginning of LCS1 on the BSB-VR0300 is flash memory. + The first 2K of the NVRAM are reserved, so don't we'll poke + around just after that. + */ + + test_offset = (char *)KSEG1ADDR(DEFAULT_LCS1_BASE + 0x800); + saved_test_byte = *test_offset; + + *test_offset = TESTVAL1; + if (*test_offset != TESTVAL1) { + /* We couldn't set our test value, so it must not be NVRAM, + so it's a BSB_VR0300 */ + mips_machtype = MACH_NEC_ROCKHOPPER; + } else { + /* We may have gotten lucky, and the TESTVAL1 was already + stored at the test location, so we must check a second + test value */ + *test_offset = TESTVAL2; + if (*test_offset != TESTVAL2) { + /* OK, we couldn't set this value either, so it must + definately be a BSB_VR0300 */ + mips_machtype = MACH_NEC_ROCKHOPPER; + } else { + /* We could change the value twice, so it must be + NVRAM, so it's a DDB_VRC5477 */ + mips_machtype = MACH_NEC_DDB5477; + } + } + /* Restore the original byte */ + *test_offset = saved_test_byte; + + /* before we know a better way, we will trust PMON for getting + * RAM size + */ + board_ram_size = 1 << (36 - (ddb_in32(DDB_SDRAM0) & 0xf)); + + db_run(printk("DDB run-time detection : %s, %d MB RAM\n", + mips_machtype == MACH_NEC_DDB5477 ? + "DDB5477" : "Rockhopper", + board_ram_size >> 20)); + + /* we can't handle ram size > 128 MB */ + db_assert(board_ram_size <= (128 << 20)); +} +#endif diff -Nru linux/arch/mips/ddb5xxx/ddb5477/lcd44780.c.orig linux/arch/mips/ddb5xxx/ddb5477/lcd44780.c --- linux/arch/mips/ddb5xxx/ddb5477/lcd44780.c.orig Fri Nov 30 18:04:17 2001 +++ linux/arch/mips/ddb5xxx/ddb5477/lcd44780.c Fri Nov 30 18:04:17 2001 @@ -0,0 +1,92 @@ +/* + * lcd44780.c + * Simple "driver" for a memory-mapped 44780-style LCD display. + * + * Copyright 2001 Bradley D. LaRonde + * + * 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. + * + */ + +#define LCD44780_COMMAND ((volatile unsigned char *)0xbe020000) +#define LCD44780_DATA ((volatile unsigned char *)0xbe020001) + +#define LCD44780_4BIT_1LINE 0x20 +#define LCD44780_4BIT_2LINE 0x28 +#define LCD44780_8BIT_1LINE 0x30 +#define LCD44780_8BIT_2LINE 0x38 +#define LCD44780_MODE_DEC 0x04 +#define LCD44780_MODE_DEC_SHIFT 0x05 +#define LCD44780_MODE_INC 0x06 +#define LCD44780_MODE_INC_SHIFT 0x07 +#define LCD44780_SCROLL_LEFT 0x18 +#define LCD44780_SCROLL_RIGHT 0x1e +#define LCD44780_CURSOR_UNDERLINE 0x0e +#define LCD44780_CURSOR_BLOCK 0x0f +#define LCD44780_CURSOR_OFF 0x0c +#define LCD44780_CLEAR 0x01 +#define LCD44780_BLANK 0x08 +#define LCD44780_RESTORE 0x0c // Same as CURSOR_OFF +#define LCD44780_HOME 0x02 +#define LCD44780_LEFT 0x10 +#define LCD44780_RIGHT 0x14 + +void lcd44780_wait(void) +{ + int i, j; + for(i=0; i < 400; i++) + for(j=0; j < 10000; j++); +} + +void lcd44780_command(unsigned char c) +{ + *LCD44780_COMMAND = c; + lcd44780_wait(); +} + +void lcd44780_data(unsigned char c) +{ + *LCD44780_DATA = c; + lcd44780_wait(); +} + +void lcd44780_puts(const char* s) +{ + int i,j; + int pos = 0; + + lcd44780_command(LCD44780_CLEAR); + while(*s) { + lcd44780_data(*s); + s++; + pos++; + if (pos == 8) { + /* We must write 32 of spaces to get cursor to 2nd line */ + for (j=0; j<32; j++) { + lcd44780_data(' '); + } + } + if (pos == 16) { + /* We have filled all 16 character positions, so stop + outputing data */ + break; + } + } +#ifdef LCD44780_PUTS_PAUSE + for(i = 1; i < 2000; i++) + lcd44780_wait(); +#endif +} + +void lcd44780_init(void) +{ + // The display on the RockHopper is physically a single + // 16 char line (two 8 char lines concatenated). bdl + lcd44780_command(LCD44780_8BIT_2LINE); + lcd44780_command(LCD44780_MODE_INC); + lcd44780_command(LCD44780_CURSOR_BLOCK); + lcd44780_command(LCD44780_CLEAR); +} diff -Nru linux/arch/mips/ddb5xxx/ddb5477/lcd44780.h.orig linux/arch/mips/ddb5xxx/ddb5477/lcd44780.h --- linux/arch/mips/ddb5xxx/ddb5477/lcd44780.h.orig Fri Nov 30 18:04:17 2001 +++ linux/arch/mips/ddb5xxx/ddb5477/lcd44780.h Fri Nov 30 18:04:17 2001 @@ -0,0 +1,15 @@ +/* + * lcd44780.h + * Simple "driver" for a memory-mapped 44780-style LCD display. + * + * Copyright 2001 Bradley D. LaRonde + * + * 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. + * + */ + +void lcd44780_puts(const char* s); +void lcd44780_init(void); diff -Nru linux/arch/mips/ddb5xxx/ddb5477/setup.c.orig linux/arch/mips/ddb5xxx/ddb5477/setup.c --- linux/arch/mips/ddb5xxx/ddb5477/setup.c.orig Wed Nov 28 11:13:20 2001 +++ linux/arch/mips/ddb5xxx/ddb5477/setup.c Mon Dec 3 16:57:08 2001 @@ -24,6 +24,7 @@ #include #include /* for HZ */ +#include #include #include #include @@ -34,6 +35,7 @@ #include +#include "lcd44780.h" // #define USE_CPU_COUNTER_TIMER /* whether we use cpu counter */ @@ -85,7 +87,11 @@ #endif /* we have ds1396 RTC chip */ - rtc_ds1386_init(KSEG1ADDR(DDB_LCS1_BASE)); + if (mips_machtype == MACH_NEC_ROCKHOPPER) { + rtc_ds1386_init(KSEG1ADDR(DDB_LCS2_BASE)); + } else { + rtc_ds1386_init(KSEG1ADDR(DDB_LCS1_BASE)); + } } extern int setup_irq(unsigned int irq, struct irqaction *irqaction); @@ -139,6 +145,10 @@ /* Reboot on panic */ panic_timeout = 180; +#ifdef CONFIG_FB + conswitchp = &dummy_con; +#endif + /* initialize board - we don't trust the loader */ ddb5477_board_init(); @@ -147,7 +157,6 @@ initrd_start = (unsigned long)&__rd_start; initrd_end = (unsigned long)&__rd_end; #endif - } static void __init ddb5477_board_init() @@ -156,18 +165,32 @@ /* SDRAM should have been set */ db_assert(ddb_in32(DDB_SDRAM0) == - ddb_calc_pdar(DDB_SDRAM_BASE, DDB_SDRAM_SIZE, 32, 0, 1)); + ddb_calc_pdar(DDB_SDRAM_BASE, board_ram_size, 32, 0, 1)); /* SDRAM1 should be turned off. What is this for anyway ? */ db_assert( (ddb_in32(DDB_SDRAM1) & 0xf) == 0); - /* Set LDCSs */ - /* flash */ + /* Setup local bus. */ + + /* Flash U12 PDAR and timing. */ ddb_set_pdar(DDB_LCS0, DDB_LCS0_BASE, DDB_LCS0_SIZE, 16, 0, 0); - /* misc */ - ddb_set_pdar(DDB_LCS1, DDB_LCS1_BASE, DDB_LCS1_SIZE, 8, 0, 0); - /* mezzanie (?) */ - ddb_set_pdar(DDB_LCS2, DDB_LCS2_BASE, DDB_LCS2_SIZE, 16, 0, 0); + ddb_out32(DDB_LCST0, 0x00090842); + + /* We need to setup LCS1 and LCS2 differently based on the + board_version */ + if (mips_machtype == MACH_NEC_ROCKHOPPER) { + /* Flash U13 PDAR and timing. */ + ddb_set_pdar(DDB_LCS1, DDB_LCS1_BASE, DDB_LCS1_SIZE, 16, 0, 0); + ddb_out32(DDB_LCST1, 0x00090842); + + /* EPLD (NVRAM, switch, LCD, and mezzanie). */ + ddb_set_pdar(DDB_LCS2, DDB_LCS2_BASE, DDB_LCS2_SIZE, 8, 0, 0); + } else { + /* misc */ + ddb_set_pdar(DDB_LCS1, DDB_LCS1_BASE, DDB_LCS1_SIZE, 8, 0, 0); + /* mezzanie (?) */ + ddb_set_pdar(DDB_LCS2, DDB_LCS2_BASE, DDB_LCS2_SIZE, 16, 0, 0); + } /* verify VRC5477 base addr */ db_assert(ddb_in32(DDB_VRC5477) == @@ -239,4 +262,10 @@ /* For dual-function pins, make them all non-GPIO */ ddb_out32(DDB_GIUFUNSEL, 0x0); // ddb_out32(DDB_GIUFUNSEL, 0xfe0fcfff); /* NEC recommanded value */ + + if (mips_machtype == MACH_NEC_ROCKHOPPER) { + printk("lcd44780: initializing\n"); + lcd44780_init(); + lcd44780_puts("Linux/MIPS rolls"); + } } diff -Nru linux/arch/mips/ddb5xxx/ddb5477/Makefile.orig linux/arch/mips/ddb5xxx/ddb5477/Makefile --- linux/arch/mips/ddb5xxx/ddb5477/Makefile.orig Wed Oct 17 12:46:04 2001 +++ linux/arch/mips/ddb5xxx/ddb5477/Makefile Fri Nov 30 18:04:17 2001 @@ -13,7 +13,7 @@ O_TARGET:= ddb5477.o -obj-y += int-handler.o irq.o irq_5477.o setup.o pci.o pci_ops.o +obj-y += int-handler.o irq.o irq_5477.o setup.o pci.o pci_ops.o lcd44780.o obj-$(CONFIG_DEBUG) += debug.o obj-$(CONFIG_REMOTE_DEBUG) += kgdb_io.o