aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYoshinori Sato <ysato@users.sourceforge.jp>2015-11-21 07:42:58 -0500
committerYoshinori Sato <ysato@users.sourceforge.jp>2016-03-24 12:45:19 -0400
commit8cad489261c564d4ee1db4de4ac365af56807d8a (patch)
tree78dab251d974fcb5c5ab6ff6288170a8919cd2d2
parentd85816167bf50e4ec4a9e477a2eddfe59ed83bdf (diff)
h8300: switch EARLYCON
earlyprintk is architecture specific option. earlycon is generic and small footprint. Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp>
-rw-r--r--arch/h8300/configs/h8300h-sim_defconfig2
-rw-r--r--arch/h8300/kernel/setup.c7
-rw-r--r--arch/h8300/kernel/sim-console.c67
3 files changed, 10 insertions, 66 deletions
diff --git a/arch/h8300/configs/h8300h-sim_defconfig b/arch/h8300/configs/h8300h-sim_defconfig
index 067bfe9c49b3..80624f46b0ed 100644
--- a/arch/h8300/configs/h8300h-sim_defconfig
+++ b/arch/h8300/configs/h8300h-sim_defconfig
@@ -34,7 +34,7 @@ CONFIG_BINFMT_FLAT=y
34# CONFIG_LEGACY_PTYS is not set 34# CONFIG_LEGACY_PTYS is not set
35# CONFIG_DEVKMEM is not set 35# CONFIG_DEVKMEM is not set
36CONFIG_SERIAL_SH_SCI=y 36CONFIG_SERIAL_SH_SCI=y
37CONFIG_SERIAL_SH_SCI_CONSOLE=y 37CONFIG_SERIAL_SH_SCI_EARLYCON=y
38# CONFIG_HW_RANDOM is not set 38# CONFIG_HW_RANDOM is not set
39# CONFIG_HWMON is not set 39# CONFIG_HWMON is not set
40# CONFIG_USB_SUPPORT is not set 40# CONFIG_USB_SUPPORT is not set
diff --git a/arch/h8300/kernel/setup.c b/arch/h8300/kernel/setup.c
index e4985dfa91dc..c8c25a4e9e48 100644
--- a/arch/h8300/kernel/setup.c
+++ b/arch/h8300/kernel/setup.c
@@ -20,8 +20,6 @@
20#include <linux/bootmem.h> 20#include <linux/bootmem.h>
21#include <linux/seq_file.h> 21#include <linux/seq_file.h>
22#include <linux/init.h> 22#include <linux/init.h>
23#include <linux/platform_device.h>
24#include <linux/module.h>
25#include <linux/of.h> 23#include <linux/of.h>
26#include <linux/of_fdt.h> 24#include <linux/of_fdt.h>
27#include <linux/of_platform.h> 25#include <linux/of_platform.h>
@@ -137,11 +135,6 @@ void __init setup_arch(char **cmdline_p)
137 parse_early_param(); 135 parse_early_param();
138 136
139 bootmem_init(); 137 bootmem_init();
140#if defined(CONFIG_H8300H_SIM) || defined(CONFIG_H8S_SIM)
141 sim_console_register();
142#endif
143
144 early_platform_driver_probe("earlyprintk", 1, 0);
145 /* 138 /*
146 * get kmalloc into gear 139 * get kmalloc into gear
147 */ 140 */
diff --git a/arch/h8300/kernel/sim-console.c b/arch/h8300/kernel/sim-console.c
index a15edf0565d9..46138f55a9ea 100644
--- a/arch/h8300/kernel/sim-console.c
+++ b/arch/h8300/kernel/sim-console.c
@@ -1,79 +1,30 @@
1/* 1/*
2 * arch/h8300/kernel/early_printk.c 2 * arch/h8300/kernel/sim-console.c
3 * 3 *
4 * Copyright (C) 2009 Yoshinori Sato <ysato@users.sourceforge.jp> 4 * Copyright (C) 2015 Yoshinori Sato <ysato@users.sourceforge.jp>
5 * 5 *
6 * This file is subject to the terms and conditions of the GNU General Public 6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive 7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details. 8 * for more details.
9 */ 9 */
10#include <linux/console.h> 10#include <linux/console.h>
11#include <linux/tty.h>
12#include <linux/init.h> 11#include <linux/init.h>
13#include <linux/io.h> 12#include <linux/serial_core.h>
14#include <linux/platform_device.h>
15 13
16static void sim_write(struct console *co, const char *ptr, 14static void sim_write(struct console *con, const char *s, unsigned n)
17 unsigned len)
18{ 15{
19 register const int fd __asm__("er0") = 1; /* stdout */ 16 register const int fd __asm__("er0") = 1; /* stdout */
20 register const char *_ptr __asm__("er1") = ptr; 17 register const char *_ptr __asm__("er1") = s;
21 register const unsigned _len __asm__("er2") = len; 18 register const unsigned _len __asm__("er2") = n;
22 19
23 __asm__(".byte 0x5e,0x00,0x00,0xc7\n\t" /* jsr @0xc7 (sys_write) */ 20 __asm__(".byte 0x5e,0x00,0x00,0xc7\n\t" /* jsr @0xc7 (sys_write) */
24 : : "g"(fd), "g"(_ptr), "g"(_len)); 21 : : "g"(fd), "g"(_ptr), "g"(_len));
25} 22}
26 23
27static struct console sim_console = { 24static int __init sim_setup(struct earlycon_device *device, const char *opt)
28 .name = "sim_console",
29 .write = sim_write,
30 .setup = NULL,
31 .flags = CON_PRINTBUFFER,
32 .index = -1,
33};
34
35static char sim_console_buf[32];
36
37static int sim_probe(struct platform_device *pdev)
38{
39 if (sim_console.data)
40 return -EEXIST;
41
42 if (!strstr(sim_console_buf, "keep"))
43 sim_console.flags |= CON_BOOT;
44
45 register_console(&sim_console);
46 return 0;
47}
48
49static int sim_remove(struct platform_device *pdev)
50{ 25{
26 device->con->write = sim_write;
51 return 0; 27 return 0;
52} 28}
53 29
54static struct platform_driver sim_driver = { 30EARLYCON_DECLARE(h8sim, sim_setup);
55 .probe = sim_probe,
56 .remove = sim_remove,
57 .driver = {
58 .name = "h8300-sim",
59 .owner = THIS_MODULE,
60 },
61};
62
63early_platform_init_buffer("earlyprintk", &sim_driver,
64 sim_console_buf, ARRAY_SIZE(sim_console_buf));
65
66static struct platform_device sim_console_device = {
67 .name = "h8300-sim",
68 .id = 0,
69};
70
71static struct platform_device *devices[] __initdata = {
72 &sim_console_device,
73};
74
75void __init sim_console_register(void)
76{
77 early_platform_add_devices(devices,
78 ARRAY_SIZE(devices));
79}