Patch to make ppc_md.progress useful on 4xx
Quoted 15 lines · David Gibson
Currently, ppc_md.progress on 4xx just does a
printk(), which means its messages won't be displayed untilconsole_init()at which point it's usually too late to be useful.The patch below changes
ppc4xx_progress()to write directly to the serial port. I'd like to get comments before pushing the change, because I don't want to break 4xx machines that I don't have (and so can't test).At the moment it should only affect 405GP. NP405H and NP405L support should be trivial (I've only refrained from adding it because I can't test it myself). STBxxxx should be possible but will be much yuckier. It would be nice to have it work on all 4xx though, to get rid of the nasty #ifdef in
ppc4xx_setup.c.
Quoted 10 lines
--
David Gibson | For every complex problem there is a
[email protected] | solution which is simple, neat and
| wrong. -- H.L. Mencken
http://www.ozlabs.org/people/dgibson
What Patch?
I can test on some of the boards
--armin
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
Currently, ppc_md.progress on 4xx just does a printk(), which means its messages won't be displayed until console_init() at which point it's usually too late to be useful.
The patch below changes ppc4xx_progress() to write directly to the serial port. I'd like to get comments before pushing the change, because I don't want to break 4xx machines that I don't have (and so can't test).
At the moment it should only affect 405GP. NP405H and NP405L support should be trivial (I've only refrained from adding it because I can't test it myself). STBxxxx should be possible but will be much yuckier. It would be nice to have it work on all 4xx though, to get rid of the nasty #ifdef in ppc4xx_setup.c.
--
David Gibson | For every complex problem there is a
[email protected] | solution which is simple, neat and
| wrong. -- H.L. Mencken
http://www.ozlabs.org/people/dgibson
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
Quoted 16 lines · Armin
Quoted 9 lines · David Gibson
Currently, ppc_md.progress on 4xx just does a
printk(), which means its messages won't be displayed untilconsole_init()at which point it's usually too late to be useful.The patch below changes
ppc4xx_progress()to write directly to the serial port. I'd like to get comments before pushing the change, because I don't want to break 4xx machines that I don't have (and so can't test).Quoted 5 lines
At the moment it should only affect 405GP. NP405H and NP405L support should be trivial (I've only refrained from adding it because I can't test it myself). STBxxxx should be possible but will be much yuckier. It would be nice to have it work on all 4xx though, to get rid of the nasty #ifdef in
ppc4xx_setup.c.
Quoted 3 lines
What Patch?
I can test on some of the boards
Ah, crud. Forgot to attach it. Ok, this time for sure.
arch/ppc/kernel/head_4xx.S renamed from home/dgibson/kernel/linuxppc_2_4_devel/arch/ppc/kernel/head_4xx.S +20 -0
@@ -1051,6 +1051,26 @@ tlbwe r4,r0,TLB_DATA tlbwe r3,r0,TLB_TAG + +#if defined(CONFIG_SERIAL_TEXT_DEBUG) && defined(SERIAL_DEBUG_IO_BASE) + + /* Load a TLB entry for the UART, so that ppc4xx_progress() can use + * the UARTs nice and early. We use a 4k real==virtual mapping. */ + + lis r3,SERIAL_DEBUG_IO_BASE@h + ori r3,r3,SERIAL_DEBUG_IO_BASE@l + mr r4,r3 + clrrwi r4,r4,12 + ori r4,r4,(TLB_WR|TLB_I|TLB_M|TLB_G) + + clrrwi r3,r3,12 + ori r3,r3,(TLB_VALID | TLB_PAGESZ(PAGESZ_4K)) + + li r0,0 /* TLB slot 0 */ + tlbwe r4,r0,TLB_DATA + tlbwe r3,r0,TLB_TAG +#endif /* CONFIG_SERIAL_DEBUG_TEXT && SERIAL_DEBUG_IO_BASE */ + isync /* Establish the exception vector base
arch/ppc/kernel/ppc4xx_setup.c renamed from home/dgibson/kernel/linuxppc_2_4_devel/arch/ppc/kernel/ppc4xx_setup.c +27 -4
@@ -248,13 +248,36 @@mtspr (SPRN_PIT , tb_ticks_per_jiffy); } -#ifdef CONFIG_DEBUG_TEXT +#ifdef CONFIG_SERIAL_TEXT_DEBUG + +/* We assume that the UART has already been initialized by the +firmware or the boot loader */ static void -ppc4xx_progress (char *s,unsigned short hex) +serial_putc (u8 *com_port,unsigned char c) { -printk ("%s\n\r" , s); +while ((readb (com_port + (UART_LSR )) &UART_LSR_THRE ) ==0 ) + ; +writeb (c, com_port); } + + +static void +ppc4xx_progress (char *s,unsigned short hex) +{ +char c; +#ifdef SERIAL_DEBUG_IO_BASE +u8 *com_port = (u8 *)SERIAL_DEBUG_IO_BASE ; + +while ((c = *s++) !='\0' ) { +serial_putc (com_port, c); + } +serial_putc (com_port,'\r' ); +serial_putc (com_port,'\n' ); +#else +printk ("%s\r\n" );#endif +} +#endif /* CONFIG_SERIAL_TEXT_DEBUG */ /* * IDE stuff.
@@ -381,7 +404,7 @@ ppc_md.find_end_of_memory = ppc4xx_find_end_of_memory; ppc_md.setup_io_mappings = m4xx_map_io; -#ifdef CONFIG_DEBUG_TEXT +#ifdef CONFIG_SERIAL_TEXT_DEBUG ppc_md.progress = ppc4xx_progress;#endif
arch/ppc/platforms/ibm405gp.h renamed from home/dgibson/kernel/linuxppc_2_4_devel/arch/ppc/platforms/ibm405gp.h +5 -3
@@ -88,8 +88,8 @@#define UART1_INT 1#define PCIL0_BASE 0xEF400000 -#define UART0_IO_BASE (u8 *) 0xEF600300 -#define UART1_IO_BASE (u8 *) 0xEF600400 +#define UART0_IO_BASE 0xEF600300 +#define UART1_IO_BASE 0xEF600400#define IIC0_BASE 0xEF600500#define OPB0_BASE 0xEF600600#define GPIO0_BASE 0xEF600700
@@ -102,16 +102,18 @@#define STD_UART_OP (num) \ { 0, BASE_BAUD, 0, UART##num##_INT, \ (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST), \ - iomem_base: UART##num##_IO_BASE, \ + iomem_base: (u8 *)UART##num##_IO_BASE, \ io_type: SERIAL_IO_MEM},#if defined(CONFIG_UART0_TTYS0 ) +#define SERIAL_DEBUG_IO_BASE UART0_IO_BASE#define SERIAL_PORT_DFNS \ STD_UART_OP(0) \ STD_UART_OP(1)#endif #if defined(CONFIG_UART0_TTYS1 ) +#define SERIAL_DEBUG_IO_BASE UART1_IO_BASE#define SERIAL_PORT_DFNS \ STD_UART_OP(1) \ STD_UART_OP(0)
--
David Gibson | For every complex problem there is a
[email protected] | solution which is simple, neat and
| wrong. -- H.L. Mencken
http://www.ozlabs.org/people/dgibson
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
Quoted 145 lines · David Gibson
Quoted 17 lines · Armin
Quoted 9 lines · David Gibson
Currently, ppc_md.progress on 4xx just does a
printk(), which means its messages won't be displayed untilconsole_init()at which point it's usually too late to be useful.The patch below changes
ppc4xx_progress()to write directly to the serial port. I'd like to get comments before pushing the change, because I don't want to break 4xx machines that I don't have (and so can't test).Quoted 6 lines
At the moment it should only affect 405GP. NP405H and NP405L support should be trivial (I've only refrained from adding it because I can't test it myself). STBxxxx should be possible but will be much yuckier. It would be nice to have it work on all 4xx though, to get rid of the nasty #ifdef in
ppc4xx_setup.c.Quoted 4 lines
What Patch?
I can test on some of the boards
Ah, crud. Forgot to attach it. Ok, this time for sure.
diff -urN
/home/dgibson/kernel/linuxppc_2_4_devel/arch/ppc/kernel/head_4xx.Slinux-grinch/arch/ppc/kernel/head_4xx.Sarch/ppc/kernel/head_4xx.S renamed from home/dgibson/kernel/linuxppc_2_4_devel/arch/ppc/kernel/head_4xx.S +20
-0@@ -1051,6 +1051,26 @@ tlbwe r4,r0,TLB_DATA tlbwe r3,r0,TLB_TAG + +#if defined(CONFIG_SERIAL_TEXT_DEBUG) && defined(SERIAL_DEBUG_IO_BASE) + + /* Load a TLB entry for the UART, so that ppc4xx_progress() can use + * the UARTs nice and early. We use a 4k real==virtual mapping. */ + + lis r3,SERIAL_DEBUG_IO_BASE@h + ori r3,r3,SERIAL_DEBUG_IO_BASE@l + mr r4,r3 + clrrwi r4,r4,12 + ori r4,r4,(TLB_WR|TLB_I|TLB_M|TLB_G) + + clrrwi r3,r3,12 + ori r3,r3,(TLB_VALID | TLB_PAGESZ(PAGESZ_4K)) + + li r0,0 /* TLB slot 0 */ + tlbwe r4,r0,TLB_DATA + tlbwe r3,r0,TLB_TAG +#endif /* CONFIG_SERIAL_DEBUG_TEXT && SERIAL_DEBUG_IO_BASE */ + isync /* Establish the exception vector basediff -urN
/home/dgibson/kernel/linuxppc_2_4_devel/arch/ppc/kernel/ppc4xx_setup.clinux-grinch/arch/ppc/kernel/ppc4xx_setup.carch/ppc/kernel/ppc4xx_setup.c renamed from home/dgibson/kernel/linuxppc_2_4_devel/arch/ppc/kernel/ppc4xx_setup.c +27
-4@@ -248,13 +248,36 @@mtspr (SPRN_PIT , tb_ticks_per_jiffy); } -#ifdef CONFIG_DEBUG_TEXT +#ifdef CONFIG_SERIAL_TEXT_DEBUG + +/* We assume that the UART has already been initialized by the +firmware or the boot loader */ static void -ppc4xx_progress (char *s,unsigned short hex) +serial_putc (u8 *com_port,unsigned char c) { -printk ("%s\n\r" , s); +while ((readb (com_port + (UART_LSR )) &UART_LSR_THRE ) ==0 ) + ; +writeb (c, com_port); } + + +static void +ppc4xx_progress (char *s,unsigned short hex) +{ +char c; +#ifdef SERIAL_DEBUG_IO_BASE +u8 *com_port = (u8 *)SERIAL_DEBUG_IO_BASE ; + +while ((c = *s++) !='\0' ) { +serial_putc (com_port, c); + } +serial_putc (com_port,'\r' ); +serial_putc (com_port,'\n' ); +#else +printk ("%s\r\n" );#endif +} +#endif /* CONFIG_SERIAL_TEXT_DEBUG */ /* * IDE stuff. @@ -381,7 +404,7 @@ ppc_md.find_end_of_memory = ppc4xx_find_end_of_memory; ppc_md.setup_io_mappings = m4xx_map_io; -#ifdef CONFIG_DEBUG_TEXT +#ifdef CONFIG_SERIAL_TEXT_DEBUG ppc_md.progress = ppc4xx_progress;#endif diff -urN
/home/dgibson/kernel/linuxppc_2_4_devel/arch/ppc/platforms/ibm405gp.hlinux-grinch/arch/ppc/platforms/ibm405gp.harch/ppc/platforms/ibm405gp.h renamed from home/dgibson/kernel/linuxppc_2_4_devel/arch/ppc/platforms/ibm405gp.h +5
-4@@ -88,8 +88,8 @@#define UART1_INT 1#define PCIL0_BASE 0xEF400000 -#define UART0_IO_BASE (u8 *) 0xEF600300 -#define UART1_IO_BASE (u8 *) 0xEF600400 +#define UART0_IO_BASE 0xEF600300 +#define UART1_IO_BASE 0xEF600400#define IIC0_BASE 0xEF600500#define OPB0_BASE 0xEF600600#define GPIO0_BASE 0xEF600700@@ -102,16 +102,18 @@#define STD_UART_OP (num) \ { 0, BASE_BAUD, 0, UART##num##_INT, \ (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST), \ - iomem_base: UART##num##_IO_BASE, \ + iomem_base: (u8 *)UART##num##_IO_BASE, \ io_type: SERIAL_IO_MEM},#if defined(CONFIG_UART0_TTYS0 ) +#define SERIAL_DEBUG_IO_BASE UART0_IO_BASE#define SERIAL_PORT_DFNS \ STD_UART_OP(0) \ STD_UART_OP(1)#endif #if defined(CONFIG_UART0_TTYS1 ) +#define SERIAL_DEBUG_IO_BASE UART1_IO_BASE#define SERIAL_PORT_DFNS \ STD_UART_OP(1) \ STD_UART_OP(0) --
Quoted 9 lines
David Gibson | For every complex problem there is a
[email protected] | solution which is simple, neat and
| wrong. -- H.L. Mencken
http://www.ozlabs.org/people/dgibson
David,
It works on a walnut, ceder & ash but not on the redwoods.it hangs.
I will look at it later
--armin
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
Quoted 18 lines · David Gibson
Quoted 16 lines · Armin
Quoted 14 lines · David Gibson
Currently, ppc_md.progress on 4xx just does a
printk(), which means its messages won't be displayed untilconsole_init()at which point it's usually too late to be useful.The patch below changes
ppc4xx_progress()to write directly to the serial port. I'd like to get comments before pushing the change, because I don't want to break 4xx machines that I don't have (and so can't test).At the moment it should only affect 405GP. NP405H and NP405L support should be trivial (I've only refrained from adding it because I can't test it myself). STBxxxx should be possible but will be much yuckier. It would be nice to have it work on all 4xx though, to get rid of the nasty #ifdef in
ppc4xx_setup.c.
Quoted 5 lines
Quoted 3 lines
What Patch?
I can test on some of the boards
Ah, crud. Forgot to attach it. Ok, this time for sure.
It looks alright. The thing is all of the systems which use an ns1655x-style uart can use mostly the same code (provided a BAT or TLB is setup for early access). If you could try and forward port the following (old, partially non applying I'm sure) patch that'd be great.
--
Tom Rini (TR1265)
http://gate.crashing.org/~trini/
===== include/asm-ppc/btext.h 1.3 vs edited =====
include/asm-ppc/btext.h +5 -0
@@ -5,6 +5,10 @@* Definitions for using the procedures in btext.c. * * Benjamin Herrenschmidt <[email protected]> +* +* This is also a convenient place to place stuff for the NS1655x version +* of the ppc_md.progress routine. -- Tom <[email protected]> +* */ #ifndef __PPC_BTEXT_H#define __PPC_BTEXT_H
@@ -19,6 +23,7 @@extern boot_infos_t *disp_bi;extern int boot_text_mapped; +extern int mmu_is_setup;void btext_init (boot_infos_t *bi);void btext_welcome (boot_infos_t * bi);
===== arch/ppc/mm/init.c 1.52 vs edited =====
arch/ppc/mm/init.c +6 -3
@@ -345,14 +345,17 @@/* Initialize the context management stuff */ mmu_context_init (); -if (ppc_md.progress) - ppc_md.progress ("MMU:exit" ,0x211 ); -#ifdef CONFIG_BOOTX_TEXT /* Must be done last, or ppc_md.progress will die */ if (have_of)map_boot_text ();#endif +#ifdef CONFIG_DEBUG_TEXT + mmu_is_setup =1 ; +#endif + +if (ppc_md.progress) + ppc_md.progress ("MMU:exit" ,0x211 ); }/* This is only called until mem_init is done. */
===== arch/ppc/kernel/Makefile 1.54 vs edited =====
arch/ppc/kernel/Makefile +1 -0
@@ -109,6 +109,7 @@ iSeries_dma.o iSeries_pic.o \ iSeries_misc.S obj-$(CONFIG_BOOTX_TEXT) += btext.o +obj-$(CONFIG_DEBUG_TEXT) += stext.o ifeq ($(CONFIG_SMP),y) obj-$(CONFIG_ALL_PPC) += pmac_smp.o chrp_smp.o
===== arch/ppc/kernel/prep_setup.c 1.46 vs edited =====
arch/ppc/kernel/prep_setup.c +4 -0
@@ -93,6 +93,7 @@extern unsigned char pckbd_sysrq_xlate[128 ];extern void prep_find_bridges (void ); +extern void serial_progress (char *s,unsigned short hex);extern char saved_command_line[256 ];int _prep_type;
@@ -947,6 +948,9 @@ ppc_md.ppc_kbd_sysrq_xlate = pckbd_sysrq_xlate;SYSRQ_KEY =0x54 ;#endif +#endif +#ifdef CONFIG_DEBUG_TEXT + ppc_md.progress = serial_progress;#endif #ifdef CONFIG_SMP
===== arch/ppc/kernel/zx4500_setup.c 1.8 vs edited =====
arch/ppc/kernel/zx4500_setup.c +6 -39
64 lines not on this page · raw message
===== arch/ppc/kernel/mcpn765_setup.c 1.9 vs edited =====
arch/ppc/kernel/mcpn765_setup.c +7 -42
86 lines not on this page · raw message
===== arch/ppc/kernel/ppc4xx_setup.c 1.3 vs edited =====
arch/ppc/kernel/ppc4xx_setup.c +4 -1
@@ -63,6 +63,7 @@#ifdef CONFIG_PCI extern void ppc4xx_find_bridges (void );#endif +extern void serial_progress (char *s,unsigned short hex);#ifdef CONFIG_VT extern int pckbd_setkeycode (unsigned int scancode,unsigned int keycode);
@@ -515,7 +510,6 @@ ppc_md.find_end_of_memory = ppc4xx_find_end_of_memory; ppc_md.setup_io_mappings = m4xx_map_io; - ppc_md.progress =NULL ;#ifdef CONFIG_VT ppc_md.kbd_setkeycode = pckbd_setkeycode;
@@ -535,6 +529,9 @@#ifdef CONFIG_MAGIC_SYSRQ ppc_md.ppc_kbd_sysrq_xlate =NULL ; +#endif +#ifdef CONFIG_DEBUG_TEXT + ppc_md.progress = serial_progress;#endif
===== arch/ppc/kernel/sandpoint_setup.c 1.11 vs edited =====
arch/ppc/kernel/sandpoint_setup.c +7 -42
74 lines not on this page · raw message
--- /dev/null
+++ arch/ppc/kernel/stext.c
/*
* BK Id: %F% %I% %G% %U% %#%
*
* Procedures for printing to the serial port early on in the boot process.
* This currently only works for NS1655x style uarts. This won't work on
* MPC8xx right now.
*
* Tom Rini <[email protected]>
*/
#include <linux/serial.h>
#include <linux/serialP.h>
#include <linux/serial_reg.h>
#include <linux/init.h>
#include <asm/delay.h>
#include <asm/io.h>
#include <asm/serial.h>
int mmu_is_setup = 0;
static struct serial_state rs_table[RS_TABLE_SIZE] = {
SERIAL_PORT_DFNS /* Defined in <asm/serial.h> */
};
static unsigned long com_port;
static u16 shift;
/* Split this up into init, drawstring -> drawchar && drawhex (->drawchar) */
#if 0
/*
* Setup where the serial port is, and what the register shift is, if any. */
void __initserial_progress_init(void)
{
/* We need to find out which type io we're expecting. If it's
* 'SERIAL_IO_PORT', we get an offset from the isa_io_base.
* If it's 'SERIAL_IO_MEM', we can the exact location. -- Tom */
switch (rs_table[0].io_type) {
case SERIAL_IO_PORT:
com_port = rs_table[0].port;
com_port += isa_io_base;
break;
case SERIAL_IO_MEM:
com_port = (unsigned long)rs_table[0].iomem_base;
break;
default:
/* We can't deal with it. */
return;
}
shift = rs_table[0].iomem_reg_shift;
}#endif
static voidserial_printchar(char c)
{
#if 0
while ((inb(com_port + (UART_LSR << shift))
& UART_LSR_THRE) == 0)
;
#else
udelay(1000); /* 10ms */
#endif
outb(c, com_port);
}static voidserial_printhex(unsigned long v)
{
static char hex_table[] = "0123456789abcdef";
serial_printchar(hex_table[(v >> 28) & 0x0000000FUL]);
serial_printchar(hex_table[(v >> 24) & 0x0000000FUL]);
serial_printchar(hex_table[(v >> 20) & 0x0000000FUL]);
serial_printchar(hex_table[(v >> 16) & 0x0000000FUL]);
serial_printchar(hex_table[(v >> 12) & 0x0000000FUL]);
serial_printchar(hex_table[(v >> 8) & 0x0000000FUL]);
serial_printchar(hex_table[(v >> 4) & 0x0000000FUL]);
serial_printchar(hex_table[(v >> 0) & 0x0000000FUL]);
}/*
* Take a message and a hex number, and then print */
voidserial_progress(char *s, unsigned short hex)
{
char *div = " : 0x";
/* If we aren't done twiddling with the MMU, we shouldn't try and
* touch thw HW. A printk is safe tho. */
if ( !mmu_is_setup ) {
printk("%s : 0x%04x\n", s, hex);
return;
}
/* Not quite right */
/* We need to find out which type io we're expecting. If it's
* 'SERIAL_IO_PORT', we get an offset from the isa_io_base.
* If it's 'SERIAL_IO_MEM', we can the exact location. -- Tom */
switch (rs_table[0].io_type) {
case SERIAL_IO_PORT:
com_port = rs_table[0].port;
// com_port += isa_io_base;
break;
case SERIAL_IO_MEM:
com_port = (unsigned long)rs_table[0].iomem_base;
break;
default:
/* We can't deal with it. */
return;
}
shift = rs_table[0].iomem_reg_shift;
/* Print out the message we got. */
while (*s)
serial_printchar(*s++);
/* Now print " : 0x" */
while (*div)
serial_printchar(*div++);
/* Now the hex */
serial_printhex(hex);
/* Newline */
serial_printchar('\r');
}** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/