aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2017-05-11 05:40:16 -0400
committerLey Foon Tan <ley.foon.tan@intel.com>2017-05-11 05:44:21 -0400
commite118c3fec9c0d8d2a96462c4c035305dc952e402 (patch)
treef599d72ec3510ded3ac983b3fa1ea256bcb0580a
parent7f1e614113ffe75f5ea7c99f641bf1b56f85be03 (diff)
nios2: remove custom early console implementation
As of commits d8f347ba35cf ("nios2: enable earlycon support"), 0dcc0542a006 ("serial: altera_jtaguart: add earlycon support") and 4d9d7d896d77 ("serial: altera_uart: add earlycon support"), the nios2 architecture and the altera_uart/altera_jtaguart drivers support earlycon. Thus, the custom early console implementation for nios2 is no longer necessary to get early boot messages. Remove it and rely fully on earlycon support. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
-rw-r--r--arch/nios2/include/asm/prom.h22
-rw-r--r--arch/nios2/include/asm/setup.h2
-rw-r--r--arch/nios2/kernel/Makefile1
-rw-r--r--arch/nios2/kernel/early_printk.c121
-rw-r--r--arch/nios2/kernel/prom.c49
-rw-r--r--arch/nios2/kernel/setup.c4
6 files changed, 0 insertions, 199 deletions
diff --git a/arch/nios2/include/asm/prom.h b/arch/nios2/include/asm/prom.h
deleted file mode 100644
index 75fffb42cfa5..000000000000
--- a/arch/nios2/include/asm/prom.h
+++ /dev/null
@@ -1,22 +0,0 @@
1/*
2 * Copyright Altera Corporation (C) <2015>. All rights reserved
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License,
6 * version 2, as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License along with
14 * this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef __ASM_NIOS2_PROM_H__
18#define __ASM_NIOS2_PROM_H__
19
20extern unsigned long __init of_early_console(void);
21
22#endif
diff --git a/arch/nios2/include/asm/setup.h b/arch/nios2/include/asm/setup.h
index dcbf8cf1a344..ac9bff248e6d 100644
--- a/arch/nios2/include/asm/setup.h
+++ b/arch/nios2/include/asm/setup.h
@@ -30,8 +30,6 @@ extern char fast_handler_end[];
30 30
31extern void pagetable_init(void); 31extern void pagetable_init(void);
32 32
33extern void setup_early_printk(void);
34
35#endif/* __KERNEL__ */ 33#endif/* __KERNEL__ */
36#endif /* __ASSEMBLY__ */ 34#endif /* __ASSEMBLY__ */
37 35
diff --git a/arch/nios2/kernel/Makefile b/arch/nios2/kernel/Makefile
index 1aae25703657..06d07432b38d 100644
--- a/arch/nios2/kernel/Makefile
+++ b/arch/nios2/kernel/Makefile
@@ -20,7 +20,6 @@ obj-y += syscall_table.o
20obj-y += time.o 20obj-y += time.o
21obj-y += traps.o 21obj-y += traps.o
22 22
23obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
24obj-$(CONFIG_KGDB) += kgdb.o 23obj-$(CONFIG_KGDB) += kgdb.o
25obj-$(CONFIG_MODULES) += module.o 24obj-$(CONFIG_MODULES) += module.o
26obj-$(CONFIG_NIOS2_ALIGNMENT_TRAP) += misaligned.o 25obj-$(CONFIG_NIOS2_ALIGNMENT_TRAP) += misaligned.o
diff --git a/arch/nios2/kernel/early_printk.c b/arch/nios2/kernel/early_printk.c
deleted file mode 100644
index 4a7bb98f744c..000000000000
--- a/arch/nios2/kernel/early_printk.c
+++ /dev/null
@@ -1,121 +0,0 @@
1/*
2 * Early printk for Nios2.
3 *
4 * Copyright (C) 2015, Altera Corporation
5 * Copyright (C) 2010, Tobias Klauser <tklauser@distanz.ch>
6 * Copyright (C) 2009, Wind River Systems Inc
7 * Implemented by fredrik.markstrom@gmail.com and ivarholmqvist@gmail.com
8 *
9 * This file is subject to the terms and conditions of the GNU General Public
10 * License. See the file "COPYING" in the main directory of this archive
11 * for more details.
12 */
13
14#include <linux/console.h>
15#include <linux/init.h>
16#include <linux/kernel.h>
17#include <linux/io.h>
18
19#include <asm/prom.h>
20
21static unsigned long base_addr;
22
23#if defined(CONFIG_SERIAL_ALTERA_JTAGUART_CONSOLE)
24
25#define ALTERA_JTAGUART_DATA_REG 0
26#define ALTERA_JTAGUART_CONTROL_REG 4
27#define ALTERA_JTAGUART_CONTROL_WSPACE_MSK 0xFFFF0000
28#define ALTERA_JTAGUART_CONTROL_AC_MSK 0x00000400
29
30#define JUART_GET_CR() \
31 __builtin_ldwio((void *)(base_addr + ALTERA_JTAGUART_CONTROL_REG))
32#define JUART_SET_CR(v) \
33 __builtin_stwio((void *)(base_addr + ALTERA_JTAGUART_CONTROL_REG), v)
34#define JUART_SET_TX(v) \
35 __builtin_stwio((void *)(base_addr + ALTERA_JTAGUART_DATA_REG), v)
36
37static void early_console_write(struct console *con, const char *s, unsigned n)
38{
39 unsigned long status;
40
41 while (n-- && *s) {
42 while (((status = JUART_GET_CR())
43 & ALTERA_JTAGUART_CONTROL_WSPACE_MSK) == 0) {
44#if defined(CONFIG_SERIAL_ALTERA_JTAGUART_CONSOLE_BYPASS)
45 if ((status & ALTERA_JTAGUART_CONTROL_AC_MSK) == 0)
46 return; /* no connection activity */
47#endif
48 }
49 JUART_SET_TX(*s);
50 s++;
51 }
52}
53
54#elif defined(CONFIG_SERIAL_ALTERA_UART_CONSOLE)
55
56#define ALTERA_UART_TXDATA_REG 4
57#define ALTERA_UART_STATUS_REG 8
58#define ALTERA_UART_STATUS_TRDY 0x0040
59
60#define UART_GET_SR() \
61 __builtin_ldwio((void *)(base_addr + ALTERA_UART_STATUS_REG))
62#define UART_SET_TX(v) \
63 __builtin_stwio((void *)(base_addr + ALTERA_UART_TXDATA_REG), v)
64
65static void early_console_putc(char c)
66{
67 while (!(UART_GET_SR() & ALTERA_UART_STATUS_TRDY))
68 ;
69
70 UART_SET_TX(c);
71}
72
73static void early_console_write(struct console *con, const char *s, unsigned n)
74{
75 while (n-- && *s) {
76 early_console_putc(*s);
77 if (*s == '\n')
78 early_console_putc('\r');
79 s++;
80 }
81}
82
83#else
84
85static void early_console_write(struct console *con, const char *s, unsigned n)
86{
87}
88
89#endif
90
91static struct console early_console_prom = {
92 .name = "early",
93 .write = early_console_write,
94 .flags = CON_PRINTBUFFER | CON_BOOT,
95 .index = -1
96};
97
98void __init setup_early_printk(void)
99{
100#if defined(CONFIG_SERIAL_ALTERA_JTAGUART_CONSOLE) || \
101 defined(CONFIG_SERIAL_ALTERA_UART_CONSOLE)
102 base_addr = of_early_console();
103#else
104 base_addr = 0;
105#endif
106
107 if (!base_addr)
108 return;
109
110#if defined(CONFIG_SERIAL_ALTERA_JTAGUART_CONSOLE_BYPASS)
111 /* Clear activity bit so BYPASS doesn't stall if we've used JTAG for
112 * downloading the kernel. This might cause early data to be lost even
113 * if the JTAG terminal is running.
114 */
115 JUART_SET_CR(JUART_GET_CR() | ALTERA_JTAGUART_CONTROL_AC_MSK);
116#endif
117
118 early_console = &early_console_prom;
119 register_console(early_console);
120 pr_info("early_console initialized at 0x%08lx\n", base_addr);
121}
diff --git a/arch/nios2/kernel/prom.c b/arch/nios2/kernel/prom.c
index 3901b80d4420..6688576b3a47 100644
--- a/arch/nios2/kernel/prom.c
+++ b/arch/nios2/kernel/prom.c
@@ -30,7 +30,6 @@
30#include <linux/of_fdt.h> 30#include <linux/of_fdt.h>
31#include <linux/io.h> 31#include <linux/io.h>
32 32
33#include <asm/prom.h>
34#include <asm/sections.h> 33#include <asm/sections.h>
35 34
36void __init early_init_dt_add_memory_arch(u64 base, u64 size) 35void __init early_init_dt_add_memory_arch(u64 base, u64 size)
@@ -71,51 +70,3 @@ void __init early_init_devtree(void *params)
71 70
72 early_init_dt_scan(params); 71 early_init_dt_scan(params);
73} 72}
74
75#ifdef CONFIG_EARLY_PRINTK
76static int __init early_init_dt_scan_serial(unsigned long node,
77 const char *uname, int depth, void *data)
78{
79 u64 *addr64 = (u64 *) data;
80 const char *p;
81
82 /* only consider serial nodes */
83 if (strncmp(uname, "serial", 6) != 0)
84 return 0;
85
86 p = of_get_flat_dt_prop(node, "compatible", NULL);
87 if (!p)
88 return 0;
89
90 /*
91 * We found an altera_jtaguart but it wasn't configured for console, so
92 * skip it.
93 */
94#ifndef CONFIG_SERIAL_ALTERA_JTAGUART_CONSOLE
95 if (strncmp(p, "altr,juart", 10) == 0)
96 return 0;
97#endif
98
99 /*
100 * Same for altera_uart.
101 */
102#ifndef CONFIG_SERIAL_ALTERA_UART_CONSOLE
103 if (strncmp(p, "altr,uart", 9) == 0)
104 return 0;
105#endif
106
107 *addr64 = of_flat_dt_translate_address(node);
108
109 return *addr64 == OF_BAD_ADDR ? 0 : 1;
110}
111
112unsigned long __init of_early_console(void)
113{
114 u64 base = 0;
115
116 if (of_scan_flat_dt(early_init_dt_scan_serial, &base))
117 return (u32)ioremap(base, 32);
118 else
119 return 0;
120}
121#endif /* CONFIG_EARLY_PRINTK */
diff --git a/arch/nios2/kernel/setup.c b/arch/nios2/kernel/setup.c
index 8b5146082e3e..926a02b17b31 100644
--- a/arch/nios2/kernel/setup.c
+++ b/arch/nios2/kernel/setup.c
@@ -147,10 +147,6 @@ void __init setup_arch(char **cmdline_p)
147 147
148 console_verbose(); 148 console_verbose();
149 149
150#ifdef CONFIG_EARLY_PRINTK
151 setup_early_printk();
152#endif
153
154 memory_start = PAGE_ALIGN((unsigned long)__pa(_end)); 150 memory_start = PAGE_ALIGN((unsigned long)__pa(_end));
155 memory_end = (unsigned long) CONFIG_NIOS2_MEM_BASE + memory_size; 151 memory_end = (unsigned long) CONFIG_NIOS2_MEM_BASE + memory_size;
156 152