[PATCH] ppc32: fix 44x early serial debug for configurations with more than 512M of RAM

Fix 44x early serial debugging for big RAM configurations (more than 512M).
We cannot use default OpenBIOS virtual mapping, because it interferes with
pinned TLB entry.

While we are at it, move early UART mapping to TLB slot 0, so it can
survive longer during boot process (slot 1 is used by the first ioremap
call, effectively killing UART mapping if it occupies this slot). Also,
change UART TLB entry size to 4K (256M is too much for a bunch of registers
:). Squash some warnings on the way.

Tested on Ebony and Ocotea with 1G of RAM.

Thanks to Scott Coulter <scott.coulter@cyclone.com> for diagnosing this
problem.

Signed-off-by: Eugene Surovegin <ebs@ebshome.net>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by Eugene Surovegin and committed by Linus Torvalds 5ce17b18 e310fd43

+37 -11
+6 -6
arch/ppc/kernel/head_44x.S
··· 179 179 4: 180 180 #ifdef CONFIG_SERIAL_TEXT_DEBUG 181 181 /* 182 - * Add temporary UART mapping for early debug. This 183 - * mapping must be identical to that used by the early 184 - * bootloader code since the same asm/serial.h parameters 185 - * are used for polled operation. 182 + * Add temporary UART mapping for early debug. 183 + * We can map UART registers wherever we want as long as they don't 184 + * interfere with other system mappings (e.g. with pinned entries). 185 + * For an example of how we handle this - see ocotea.h. --ebs 186 186 */ 187 187 /* pageid fields */ 188 188 lis r3,UART0_IO_BASE@h 189 - ori r3,r3,PPC44x_TLB_VALID | PPC44x_TLB_256M 189 + ori r3,r3,PPC44x_TLB_VALID | PPC44x_TLB_4K 190 190 191 191 /* xlat fields */ 192 192 lis r4,UART0_PHYS_IO_BASE@h /* RPN depends on SoC */ ··· 196 196 li r5,0 197 197 ori r5,r5,(PPC44x_TLB_SW | PPC44x_TLB_SR | PPC44x_TLB_I | PPC44x_TLB_G) 198 198 199 - li r0,1 /* TLB slot 1 */ 199 + li r0,0 /* TLB slot 0 */ 200 200 201 201 tlbwe r3,r0,PPC44x_TLB_PAGEID /* Load the pageid fields */ 202 202 tlbwe r4,r0,PPC44x_TLB_XLAT /* Load the translation fields */
+5 -1
arch/ppc/platforms/4xx/ebony.c
··· 7 7 * Copyright 2002-2005 MontaVista Software Inc. 8 8 * 9 9 * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net> 10 - * Copyright (c) 2003, 2004 Zultys Technologies 10 + * Copyright (c) 2003-2005 Zultys Technologies 11 11 * 12 12 * This program is free software; you can redistribute it and/or modify it 13 13 * under the terms of the GNU General Public License as published by the ··· 50 50 #include <asm/bootinfo.h> 51 51 #include <asm/ppc4xx_pic.h> 52 52 #include <asm/ppcboot.h> 53 + #include <asm/tlbflush.h> 53 54 54 55 #include <syslib/gen550.h> 55 56 #include <syslib/ibm440gp_common.h> ··· 249 248 #if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB) 250 249 /* Configure debug serial access */ 251 250 gen550_init(0, &port); 251 + 252 + /* Purge TLB entry added in head_44x.S for early serial access */ 253 + _tlbie(UART0_IO_BASE); 252 254 #endif 253 255 254 256 port.membase = ioremap64(PPC440GP_UART1_ADDR, 8);
+11 -2
arch/ppc/platforms/4xx/ebony.h
··· 56 56 * Serial port defines 57 57 */ 58 58 59 - /* OpenBIOS defined UART mappings, used before early_serial_setup */ 59 + #if defined(__BOOTER__) 60 + /* OpenBIOS defined UART mappings, used by bootloader shim */ 60 61 #define UART0_IO_BASE 0xE0000200 61 62 #define UART1_IO_BASE 0xE0000300 63 + #else 64 + /* head_44x.S created UART mapping, used before early_serial_setup. 65 + * We cannot use default OpenBIOS UART mappings because they 66 + * don't work for configurations with more than 512M RAM. --ebs 67 + */ 68 + #define UART0_IO_BASE 0xF0000200 69 + #define UART1_IO_BASE 0xF0000300 70 + #endif 62 71 63 72 /* external Epson SG-615P */ 64 73 #define BASE_BAUD 691200 ··· 75 66 #define STD_UART_OP(num) \ 76 67 { 0, BASE_BAUD, 0, UART##num##_INT, \ 77 68 (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST), \ 78 - iomem_base: UART##num##_IO_BASE, \ 69 + iomem_base: (void*)UART##num##_IO_BASE, \ 79 70 io_type: SERIAL_IO_MEM}, 80 71 81 72 #define SERIAL_PORT_DFNS \
+4
arch/ppc/platforms/4xx/ocotea.c
··· 48 48 #include <asm/bootinfo.h> 49 49 #include <asm/ppc4xx_pic.h> 50 50 #include <asm/ppcboot.h> 51 + #include <asm/tlbflush.h> 51 52 52 53 #include <syslib/gen550.h> 53 54 #include <syslib/ibm440gx_common.h> ··· 267 266 #if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB) 268 267 /* Configure debug serial access */ 269 268 gen550_init(0, &port); 269 + 270 + /* Purge TLB entry added in head_44x.S for early serial access */ 271 + _tlbie(UART0_IO_BASE); 270 272 #endif 271 273 272 274 port.membase = ioremap64(PPC440GX_UART1_ADDR, 8);
+11 -2
arch/ppc/platforms/4xx/ocotea.h
··· 55 55 */ 56 56 #define RS_TABLE_SIZE 2 57 57 58 - /* OpenBIOS defined UART mappings, used before early_serial_setup */ 58 + #if defined(__BOOTER__) 59 + /* OpenBIOS defined UART mappings, used by bootloader shim */ 59 60 #define UART0_IO_BASE 0xE0000200 60 61 #define UART1_IO_BASE 0xE0000300 62 + #else 63 + /* head_44x.S created UART mapping, used before early_serial_setup. 64 + * We cannot use default OpenBIOS UART mappings because they 65 + * don't work for configurations with more than 512M RAM. --ebs 66 + */ 67 + #define UART0_IO_BASE 0xF0000200 68 + #define UART1_IO_BASE 0xF0000300 69 + #endif 61 70 62 71 #define BASE_BAUD 11059200/16 63 72 #define STD_UART_OP(num) \ 64 73 { 0, BASE_BAUD, 0, UART##num##_INT, \ 65 74 (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST), \ 66 - iomem_base: UART##num##_IO_BASE, \ 75 + iomem_base: (void*)UART##num##_IO_BASE, \ 67 76 io_type: SERIAL_IO_MEM}, 68 77 69 78 #define SERIAL_PORT_DFNS \