diff options
author | Magnus Damm <damm@opensource.se> | 2009-12-14 07:52:53 -0500 |
---|---|---|
committer | Paul Mundt <lethal@linux-sh.org> | 2009-12-14 22:07:35 -0500 |
commit | e76fe57447e88916954bdcab1c0d2c708ec3c943 (patch) | |
tree | 990bd22c068284f2f8b962efceed6a2b10f125fc /arch/sh | |
parent | d8d3fbb0248dd0bc9b961f9ccfad8aa8e6b3ccfe (diff) |
sh: Remove old early serial console code V2
Now when the sh-sci driver can do early serial output,
get rid of the old duplicated code. This patch is V2 and
removes support for "earlyprintk=serial" together with
the following kconfig options:
CONFIG_EARLY_SCIF_CONSOLE
CONFIG_EARLY_SCIF_CONSOLE_PORT
CONFIG_EARLY_PRINTK
With this patch applied "earlyprintk=" support is always
built-in the SuperH kernel. For this to work the serial
driver must have early platform support and in the case
of sh-sci the serial console needs to be enabled:
CONFIG_SERIAL_SH_SCI_CONSOLE=y
So after enabling the SuperH SCI console kconfig option
you also need to point out port using the kernel command
line: "earlyprintk=sh-sci.N[,baudrate][,keep]"
Remember that clocks may be disabled by the boot loader
so you may have to do some board specific static clock
setup before earlyprintk will work on your platform.
Signed-off-by: Magnus Damm <damm@opensource.se>
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'arch/sh')
-rw-r--r-- | arch/sh/Kconfig.debug | 44 | ||||
-rw-r--r-- | arch/sh/kernel/Makefile | 3 | ||||
-rw-r--r-- | arch/sh/kernel/early_printk.c | 147 |
3 files changed, 1 insertions, 193 deletions
diff --git a/arch/sh/Kconfig.debug b/arch/sh/Kconfig.debug index 55907af1dc25..12fec72fec5f 100644 --- a/arch/sh/Kconfig.debug +++ b/arch/sh/Kconfig.debug | |||
@@ -19,50 +19,6 @@ config SH_STANDARD_BIOS | |||
19 | mask ROM and no flash (WindowsCE machines fall in this category). | 19 | mask ROM and no flash (WindowsCE machines fall in this category). |
20 | If unsure, say N. | 20 | If unsure, say N. |
21 | 21 | ||
22 | config EARLY_SCIF_CONSOLE | ||
23 | bool "Use early SCIF console" | ||
24 | help | ||
25 | This enables an early console using a fixed SCIF port. This can | ||
26 | be used by platforms that are either not running the SH | ||
27 | standard BIOS, or do not wish to use the BIOS callbacks for the | ||
28 | serial I/O. | ||
29 | |||
30 | config EARLY_SCIF_CONSOLE_PORT | ||
31 | hex | ||
32 | depends on EARLY_SCIF_CONSOLE | ||
33 | default "0xa4400000" if CPU_SUBTYPE_SH7712 || CPU_SUBTYPE_SH7705 | ||
34 | default "0xa4430000" if CPU_SUBTYPE_SH7720 || CPU_SUBTYPE_SH7721 | ||
35 | default "0xf8420000" if CPU_SUBTYPE_SH7619 | ||
36 | default "0xff804000" if CPU_SUBTYPE_MXG | ||
37 | default "0xffc30000" if CPU_SUBTYPE_SHX3 | ||
38 | default "0xffe00000" if CPU_SUBTYPE_SH7780 || CPU_SUBTYPE_SH7763 || \ | ||
39 | CPU_SUBTYPE_SH7722 || CPU_SUBTYPE_SH7366 || \ | ||
40 | CPU_SUBTYPE_SH7343 | ||
41 | default "0xfe4c0000" if CPU_SUBTYPE_SH7757 | ||
42 | default "0xffeb0000" if CPU_SUBTYPE_SH7785 | ||
43 | default "0xffeb0000" if CPU_SUBTYPE_SH7786 | ||
44 | default "0xfffe8000" if CPU_SUBTYPE_SH7203 | ||
45 | default "0xfffe9800" if CPU_SUBTYPE_SH7206 || CPU_SUBTYPE_SH7263 | ||
46 | default "0xffe80000" if CPU_SH4 | ||
47 | default "0xa4000150" if CPU_SH3 | ||
48 | default "0x00000000" | ||
49 | |||
50 | config EARLY_PRINTK | ||
51 | bool "Early printk support" | ||
52 | depends on SH_STANDARD_BIOS || EARLY_SCIF_CONSOLE | ||
53 | help | ||
54 | Say Y here to redirect kernel printk messages to the serial port | ||
55 | used by the SH-IPL bootloader, starting very early in the boot | ||
56 | process and ending when the kernel's serial console is initialised. | ||
57 | This option is only useful porting the kernel to a new machine, | ||
58 | when the kernel may crash or hang before the serial console is | ||
59 | initialised. If unsure, say N. | ||
60 | |||
61 | On devices that are running SH-IPL and want to keep the port | ||
62 | initialization consistent while not using the BIOS callbacks, | ||
63 | select both the EARLY_SCIF_CONSOLE and SH_STANDARD_BIOS, using | ||
64 | the kernel command line option to toggle back and forth. | ||
65 | |||
66 | config STACK_DEBUG | 22 | config STACK_DEBUG |
67 | bool "Check for stack overflows" | 23 | bool "Check for stack overflows" |
68 | depends on DEBUG_KERNEL && SUPERH32 | 24 | depends on DEBUG_KERNEL && SUPERH32 |
diff --git a/arch/sh/kernel/Makefile b/arch/sh/kernel/Makefile index 0471a3eb25ed..0d587da1ef12 100644 --- a/arch/sh/kernel/Makefile +++ b/arch/sh/kernel/Makefile | |||
@@ -22,11 +22,10 @@ obj-y := debugtraps.o dma-nommu.o dumpstack.o \ | |||
22 | obj-y += cpu/ | 22 | obj-y += cpu/ |
23 | obj-$(CONFIG_VSYSCALL) += vsyscall/ | 23 | obj-$(CONFIG_VSYSCALL) += vsyscall/ |
24 | obj-$(CONFIG_SMP) += smp.o | 24 | obj-$(CONFIG_SMP) += smp.o |
25 | obj-$(CONFIG_SH_STANDARD_BIOS) += sh_bios.o | 25 | obj-$(CONFIG_SH_STANDARD_BIOS) += sh_bios.o early_printk.o |
26 | obj-$(CONFIG_KGDB) += kgdb.o | 26 | obj-$(CONFIG_KGDB) += kgdb.o |
27 | obj-$(CONFIG_SH_CPU_FREQ) += cpufreq.o | 27 | obj-$(CONFIG_SH_CPU_FREQ) += cpufreq.o |
28 | obj-$(CONFIG_MODULES) += sh_ksyms_$(BITS).o module.o | 28 | obj-$(CONFIG_MODULES) += sh_ksyms_$(BITS).o module.o |
29 | obj-$(CONFIG_EARLY_PRINTK) += early_printk.o | ||
30 | obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o | 29 | obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o |
31 | obj-$(CONFIG_CRASH_DUMP) += crash_dump.o | 30 | obj-$(CONFIG_CRASH_DUMP) += crash_dump.o |
32 | obj-$(CONFIG_STACKTRACE) += stacktrace.o | 31 | obj-$(CONFIG_STACKTRACE) += stacktrace.o |
diff --git a/arch/sh/kernel/early_printk.c b/arch/sh/kernel/early_printk.c index fe7dc3fe1db1..f8bb50c6e050 100644 --- a/arch/sh/kernel/early_printk.c +++ b/arch/sh/kernel/early_printk.c | |||
@@ -15,7 +15,6 @@ | |||
15 | #include <linux/io.h> | 15 | #include <linux/io.h> |
16 | #include <linux/delay.h> | 16 | #include <linux/delay.h> |
17 | 17 | ||
18 | #ifdef CONFIG_SH_STANDARD_BIOS | ||
19 | #include <asm/sh_bios.h> | 18 | #include <asm/sh_bios.h> |
20 | 19 | ||
21 | /* | 20 | /* |
@@ -57,140 +56,7 @@ static struct console bios_console = { | |||
57 | .flags = CON_PRINTBUFFER, | 56 | .flags = CON_PRINTBUFFER, |
58 | .index = -1, | 57 | .index = -1, |
59 | }; | 58 | }; |
60 | #endif | ||
61 | 59 | ||
62 | #ifdef CONFIG_EARLY_SCIF_CONSOLE | ||
63 | #include <linux/serial_core.h> | ||
64 | #include "../../../drivers/serial/sh-sci.h" | ||
65 | |||
66 | #if defined(CONFIG_CPU_SUBTYPE_SH7720) || \ | ||
67 | defined(CONFIG_CPU_SUBTYPE_SH7721) | ||
68 | #define EPK_SCSMR_VALUE 0x000 | ||
69 | #define EPK_SCBRR_VALUE 0x00C | ||
70 | #define EPK_FIFO_SIZE 64 | ||
71 | #define EPK_FIFO_BITS (0x7f00 >> 8) | ||
72 | #else | ||
73 | #define EPK_FIFO_SIZE 16 | ||
74 | #define EPK_FIFO_BITS (0x1f00 >> 8) | ||
75 | #endif | ||
76 | |||
77 | static struct uart_port scif_port = { | ||
78 | .type = PORT_SCIF, | ||
79 | .mapbase = CONFIG_EARLY_SCIF_CONSOLE_PORT, | ||
80 | .membase = (char __iomem *)CONFIG_EARLY_SCIF_CONSOLE_PORT, | ||
81 | }; | ||
82 | |||
83 | static void scif_sercon_putc(int c) | ||
84 | { | ||
85 | while (((sci_in(&scif_port, SCFDR) & EPK_FIFO_BITS) >= EPK_FIFO_SIZE)) | ||
86 | ; | ||
87 | |||
88 | sci_in(&scif_port, SCxSR); | ||
89 | sci_out(&scif_port, SCxSR, 0xf3 & ~(0x20 | 0x40)); | ||
90 | sci_out(&scif_port, SCxTDR, c); | ||
91 | |||
92 | while ((sci_in(&scif_port, SCxSR) & 0x40) == 0) | ||
93 | ; | ||
94 | |||
95 | if (c == '\n') | ||
96 | scif_sercon_putc('\r'); | ||
97 | } | ||
98 | |||
99 | static void scif_sercon_write(struct console *con, const char *s, | ||
100 | unsigned count) | ||
101 | { | ||
102 | while (count-- > 0) | ||
103 | scif_sercon_putc(*s++); | ||
104 | } | ||
105 | |||
106 | static int __init scif_sercon_setup(struct console *con, char *options) | ||
107 | { | ||
108 | con->cflag = CREAD | HUPCL | CLOCAL | B115200 | CS8; | ||
109 | |||
110 | return 0; | ||
111 | } | ||
112 | |||
113 | static struct console scif_console = { | ||
114 | .name = "sercon", | ||
115 | .write = scif_sercon_write, | ||
116 | .setup = scif_sercon_setup, | ||
117 | .flags = CON_PRINTBUFFER, | ||
118 | .index = -1, | ||
119 | }; | ||
120 | |||
121 | #if !defined(CONFIG_SH_STANDARD_BIOS) | ||
122 | #if defined(CONFIG_CPU_SUBTYPE_SH7720) || \ | ||
123 | defined(CONFIG_CPU_SUBTYPE_SH7721) | ||
124 | static void scif_sercon_init(char *s) | ||
125 | { | ||
126 | sci_out(&scif_port, SCSCR, 0x0000); /* clear TE and RE */ | ||
127 | sci_out(&scif_port, SCFCR, 0x4006); /* reset */ | ||
128 | sci_out(&scif_port, SCSCR, 0x0000); /* select internal clock */ | ||
129 | sci_out(&scif_port, SCSMR, EPK_SCSMR_VALUE); | ||
130 | sci_out(&scif_port, SCBRR, EPK_SCBRR_VALUE); | ||
131 | |||
132 | mdelay(1); /* wait 1-bit time */ | ||
133 | |||
134 | sci_out(&scif_port, SCFCR, 0x0030); /* TTRG=b'11 */ | ||
135 | sci_out(&scif_port, SCSCR, 0x0030); /* TE, RE */ | ||
136 | } | ||
137 | #elif defined(CONFIG_CPU_SH4) || defined(CONFIG_CPU_SH3) | ||
138 | #define DEFAULT_BAUD 115200 | ||
139 | /* | ||
140 | * Simple SCIF init, primarily aimed at SH7750 and other similar SH-4 | ||
141 | * devices that aren't using sh-ipl+g. | ||
142 | */ | ||
143 | static void scif_sercon_init(char *s) | ||
144 | { | ||
145 | struct uart_port *port = &scif_port; | ||
146 | unsigned baud = DEFAULT_BAUD; | ||
147 | unsigned int status; | ||
148 | char *e; | ||
149 | |||
150 | if (*s == ',') | ||
151 | ++s; | ||
152 | |||
153 | if (*s) { | ||
154 | /* ignore ioport/device name */ | ||
155 | s += strcspn(s, ","); | ||
156 | if (*s == ',') | ||
157 | s++; | ||
158 | } | ||
159 | |||
160 | if (*s) { | ||
161 | baud = simple_strtoul(s, &e, 0); | ||
162 | if (baud == 0 || s == e) | ||
163 | baud = DEFAULT_BAUD; | ||
164 | } | ||
165 | |||
166 | do { | ||
167 | status = sci_in(port, SCxSR); | ||
168 | } while (!(status & SCxSR_TEND(port))); | ||
169 | |||
170 | sci_out(port, SCSCR, 0); /* TE=0, RE=0 */ | ||
171 | sci_out(port, SCFCR, SCFCR_RFRST | SCFCR_TFRST); | ||
172 | sci_out(port, SCSMR, 0); | ||
173 | |||
174 | /* Set baud rate */ | ||
175 | sci_out(port, SCBRR, (CONFIG_SH_PCLK_FREQ + 16 * baud) / | ||
176 | (32 * baud) - 1); | ||
177 | udelay((1000000+(baud-1)) / baud); /* Wait one bit interval */ | ||
178 | |||
179 | sci_out(port, SCSPTR, 0); | ||
180 | sci_out(port, SCxSR, 0x60); | ||
181 | sci_out(port, SCLSR, 0); | ||
182 | |||
183 | sci_out(port, SCFCR, 0); | ||
184 | sci_out(port, SCSCR, 0x30); /* TE=1, RE=1 */ | ||
185 | } | ||
186 | #endif /* defined(CONFIG_CPU_SUBTYPE_SH7720) */ | ||
187 | #endif /* !defined(CONFIG_SH_STANDARD_BIOS) */ | ||
188 | #endif /* CONFIG_EARLY_SCIF_CONSOLE */ | ||
189 | |||
190 | /* | ||
191 | * Setup a default console, if more than one is compiled in, rely on the | ||
192 | * earlyprintk= parsing to give priority. | ||
193 | */ | ||
194 | static struct console *early_console; | 60 | static struct console *early_console; |
195 | 61 | ||
196 | static int __init setup_early_printk(char *buf) | 62 | static int __init setup_early_printk(char *buf) |
@@ -203,21 +69,8 @@ static int __init setup_early_printk(char *buf) | |||
203 | if (strstr(buf, "keep")) | 69 | if (strstr(buf, "keep")) |
204 | keep_early = 1; | 70 | keep_early = 1; |
205 | 71 | ||
206 | #ifdef CONFIG_SH_STANDARD_BIOS | ||
207 | if (!strncmp(buf, "bios", 4)) | 72 | if (!strncmp(buf, "bios", 4)) |
208 | early_console = &bios_console; | 73 | early_console = &bios_console; |
209 | #endif | ||
210 | #if defined(CONFIG_EARLY_SCIF_CONSOLE) | ||
211 | if (!strncmp(buf, "serial", 6)) { | ||
212 | early_console = &scif_console; | ||
213 | |||
214 | #if !defined(CONFIG_SH_STANDARD_BIOS) | ||
215 | #if defined(CONFIG_CPU_SH4) || defined(CONFIG_CPU_SH3) | ||
216 | scif_sercon_init(buf + 6); | ||
217 | #endif | ||
218 | #endif | ||
219 | } | ||
220 | #endif | ||
221 | 74 | ||
222 | if (likely(early_console)) { | 75 | if (likely(early_console)) { |
223 | if (keep_early) | 76 | if (keep_early) |