[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 4: 180 #ifdef CONFIG_SERIAL_TEXT_DEBUG 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. 186 */ 187 /* pageid fields */ 188 lis r3,UART0_IO_BASE@h 189 - ori r3,r3,PPC44x_TLB_VALID | PPC44x_TLB_256M 190 191 /* xlat fields */ 192 lis r4,UART0_PHYS_IO_BASE@h /* RPN depends on SoC */ ··· 196 li r5,0 197 ori r5,r5,(PPC44x_TLB_SW | PPC44x_TLB_SR | PPC44x_TLB_I | PPC44x_TLB_G) 198 199 - li r0,1 /* TLB slot 1 */ 200 201 tlbwe r3,r0,PPC44x_TLB_PAGEID /* Load the pageid fields */ 202 tlbwe r4,r0,PPC44x_TLB_XLAT /* Load the translation fields */
··· 179 4: 180 #ifdef CONFIG_SERIAL_TEXT_DEBUG 181 /* 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 */ 187 /* pageid fields */ 188 lis r3,UART0_IO_BASE@h 189 + ori r3,r3,PPC44x_TLB_VALID | PPC44x_TLB_4K 190 191 /* xlat fields */ 192 lis r4,UART0_PHYS_IO_BASE@h /* RPN depends on SoC */ ··· 196 li r5,0 197 ori r5,r5,(PPC44x_TLB_SW | PPC44x_TLB_SR | PPC44x_TLB_I | PPC44x_TLB_G) 198 199 + li r0,0 /* TLB slot 0 */ 200 201 tlbwe r3,r0,PPC44x_TLB_PAGEID /* Load the pageid fields */ 202 tlbwe r4,r0,PPC44x_TLB_XLAT /* Load the translation fields */
+5 -1
arch/ppc/platforms/4xx/ebony.c
··· 7 * Copyright 2002-2005 MontaVista Software Inc. 8 * 9 * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net> 10 - * Copyright (c) 2003, 2004 Zultys Technologies 11 * 12 * This program is free software; you can redistribute it and/or modify it 13 * under the terms of the GNU General Public License as published by the ··· 50 #include <asm/bootinfo.h> 51 #include <asm/ppc4xx_pic.h> 52 #include <asm/ppcboot.h> 53 54 #include <syslib/gen550.h> 55 #include <syslib/ibm440gp_common.h> ··· 249 #if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB) 250 /* Configure debug serial access */ 251 gen550_init(0, &port); 252 #endif 253 254 port.membase = ioremap64(PPC440GP_UART1_ADDR, 8);
··· 7 * Copyright 2002-2005 MontaVista Software Inc. 8 * 9 * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net> 10 + * Copyright (c) 2003-2005 Zultys Technologies 11 * 12 * This program is free software; you can redistribute it and/or modify it 13 * under the terms of the GNU General Public License as published by the ··· 50 #include <asm/bootinfo.h> 51 #include <asm/ppc4xx_pic.h> 52 #include <asm/ppcboot.h> 53 + #include <asm/tlbflush.h> 54 55 #include <syslib/gen550.h> 56 #include <syslib/ibm440gp_common.h> ··· 248 #if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB) 249 /* Configure debug serial access */ 250 gen550_init(0, &port); 251 + 252 + /* Purge TLB entry added in head_44x.S for early serial access */ 253 + _tlbie(UART0_IO_BASE); 254 #endif 255 256 port.membase = ioremap64(PPC440GP_UART1_ADDR, 8);
+11 -2
arch/ppc/platforms/4xx/ebony.h
··· 56 * Serial port defines 57 */ 58 59 - /* OpenBIOS defined UART mappings, used before early_serial_setup */ 60 #define UART0_IO_BASE 0xE0000200 61 #define UART1_IO_BASE 0xE0000300 62 63 /* external Epson SG-615P */ 64 #define BASE_BAUD 691200 ··· 75 #define STD_UART_OP(num) \ 76 { 0, BASE_BAUD, 0, UART##num##_INT, \ 77 (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST), \ 78 - iomem_base: UART##num##_IO_BASE, \ 79 io_type: SERIAL_IO_MEM}, 80 81 #define SERIAL_PORT_DFNS \
··· 56 * Serial port defines 57 */ 58 59 + #if defined(__BOOTER__) 60 + /* OpenBIOS defined UART mappings, used by bootloader shim */ 61 #define UART0_IO_BASE 0xE0000200 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 71 72 /* external Epson SG-615P */ 73 #define BASE_BAUD 691200 ··· 66 #define STD_UART_OP(num) \ 67 { 0, BASE_BAUD, 0, UART##num##_INT, \ 68 (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST), \ 69 + iomem_base: (void*)UART##num##_IO_BASE, \ 70 io_type: SERIAL_IO_MEM}, 71 72 #define SERIAL_PORT_DFNS \
+4
arch/ppc/platforms/4xx/ocotea.c
··· 48 #include <asm/bootinfo.h> 49 #include <asm/ppc4xx_pic.h> 50 #include <asm/ppcboot.h> 51 52 #include <syslib/gen550.h> 53 #include <syslib/ibm440gx_common.h> ··· 267 #if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB) 268 /* Configure debug serial access */ 269 gen550_init(0, &port); 270 #endif 271 272 port.membase = ioremap64(PPC440GX_UART1_ADDR, 8);
··· 48 #include <asm/bootinfo.h> 49 #include <asm/ppc4xx_pic.h> 50 #include <asm/ppcboot.h> 51 + #include <asm/tlbflush.h> 52 53 #include <syslib/gen550.h> 54 #include <syslib/ibm440gx_common.h> ··· 266 #if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB) 267 /* Configure debug serial access */ 268 gen550_init(0, &port); 269 + 270 + /* Purge TLB entry added in head_44x.S for early serial access */ 271 + _tlbie(UART0_IO_BASE); 272 #endif 273 274 port.membase = ioremap64(PPC440GX_UART1_ADDR, 8);
+11 -2
arch/ppc/platforms/4xx/ocotea.h
··· 55 */ 56 #define RS_TABLE_SIZE 2 57 58 - /* OpenBIOS defined UART mappings, used before early_serial_setup */ 59 #define UART0_IO_BASE 0xE0000200 60 #define UART1_IO_BASE 0xE0000300 61 62 #define BASE_BAUD 11059200/16 63 #define STD_UART_OP(num) \ 64 { 0, BASE_BAUD, 0, UART##num##_INT, \ 65 (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST), \ 66 - iomem_base: UART##num##_IO_BASE, \ 67 io_type: SERIAL_IO_MEM}, 68 69 #define SERIAL_PORT_DFNS \
··· 55 */ 56 #define RS_TABLE_SIZE 2 57 58 + #if defined(__BOOTER__) 59 + /* OpenBIOS defined UART mappings, used by bootloader shim */ 60 #define UART0_IO_BASE 0xE0000200 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 70 71 #define BASE_BAUD 11059200/16 72 #define STD_UART_OP(num) \ 73 { 0, BASE_BAUD, 0, UART##num##_INT, \ 74 (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST), \ 75 + iomem_base: (void*)UART##num##_IO_BASE, \ 76 io_type: SERIAL_IO_MEM}, 77 78 #define SERIAL_PORT_DFNS \