1cf402c5c576ada4969436b0c2b8c3ec96d16915
[openwrt/svn-archive/archive.git] / target / linux / lantiq / patches / 106-early_printk.patch
1 --- a/arch/mips/lantiq/Kconfig
2 +++ b/arch/mips/lantiq/Kconfig
3 @@ -33,4 +33,19 @@
4 #source "arch/mips/lantiq/falcon/Kconfig"
5 source "arch/mips/lantiq/xway/Kconfig"
6
7 +if EARLY_PRINTK
8 +choice
9 + prompt "Early printk port"
10 + default LANTIQ_PROM_ASC1
11 + help
12 + Choose which serial port is used, until the console driver is loaded
13 +
14 +config LANTIQ_PROM_ASC0
15 + bool "ASC0"
16 +
17 +config LANTIQ_PROM_ASC1
18 + bool "ASC1"
19 +endchoice
20 +endif
21 +
22 endif
23 --- /dev/null
24 +++ b/arch/mips/lantiq/early_printk.c
25 @@ -0,0 +1,68 @@
26 +/*
27 + * This program is free software; you can redistribute it and/or modify it
28 + * under the terms of the GNU General Public License version 2 as published
29 + * by the Free Software Foundation.
30 + *
31 + * Copyright (C) 2010 John Crispin <blogic@openwrt.org>
32 + */
33 +
34 +#include <linux/init.h>
35 +#include <linux/cpu.h>
36 +
37 +#include <lantiq.h>
38 +
39 +#ifdef CONFIG_SOC_LANTIQ_XWAY
40 +#include <xway.h>
41 +#ifdef CONFIG_LANTIQ_PROM_ASC0
42 +#define LQ_ASC_BASE KSEG1ADDR(LQ_ASC0_BASE)
43 +#else
44 +#define LQ_ASC_BASE KSEG1ADDR(LQ_ASC1_BASE)
45 +#endif
46 +
47 +#elif defined(CONFIG_SOC_LANTIQ_FALCON)
48 +#include <falcon/gpon_reg_base.h>
49 +#ifdef CONFIG_LANTIQ_PROM_ASC0
50 +#define LQ_ASC_BASE GPON_ASC0_BASE
51 +#else
52 +#define LQ_ASC_BASE GPON_ASC1_BASE
53 +#endif
54 +
55 +#endif
56 +
57 +#define ASC_BUF 1024
58 +#define LQ_ASC_FSTAT 0x0048
59 +#define LQ_ASC_TBUF 0x0020
60 +#define TXMASK 0x3F00
61 +#define TXOFFSET 8
62 +
63 +static char buf[ASC_BUF];
64 +
65 +void
66 +prom_putchar(char c)
67 +{
68 + unsigned long flags;
69 +
70 + local_irq_save(flags);
71 + while ((lq_r32((u32 *)(LQ_ASC_BASE + LQ_ASC_FSTAT)) & TXMASK) >> TXOFFSET);
72 +
73 + if (c == '\n')
74 + lq_w32('\r', (u32 *)(LQ_ASC_BASE + LQ_ASC_TBUF));
75 + lq_w32(c, (u32 *)(LQ_ASC_BASE + LQ_ASC_TBUF));
76 + local_irq_restore(flags);
77 +}
78 +
79 +void
80 +early_printf(const char *fmt, ...)
81 +{
82 + va_list args;
83 + int l;
84 + char *p, *buf_end;
85 +
86 + va_start(args, fmt);
87 + l = vsnprintf(buf, ASC_BUF, fmt, args);
88 + va_end(args);
89 + buf_end = buf + l;
90 +
91 + for (p = buf; p < buf_end; p++)
92 + prom_putchar(*p);
93 +}