diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2017-05-12 12:53:16 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2017-05-12 12:53:16 -0400 |
commit | 0ba1c1950c320fcfdfe3dbc7470884e4a390083c (patch) | |
tree | df52579dd94c0d895329193d9896cc02a92235ab | |
parent | 09d79d103371b1b7ea70ea7f9c05ac207ef22f5d (diff) | |
parent | e118c3fec9c0d8d2a96462c4c035305dc952e402 (diff) |
Merge tag 'nios2-v4.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/lftan/nios2
Pull nios2 updates from Ley Foon Tan:
"nios2 fixes/enhancements and adding nios2 R2 support"
* tag 'nios2-v4.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/lftan/nios2:
nios2: remove custom early console implementation
nios2: use generic strncpy_from_user() and strnlen_user()
nios2: Add CDX support
nios2: Add BMX support
nios2: Add NIOS2_ARCH_REVISION to select between R1 and R2
nios2: implement flush_dcache_mmap_lock/unlock
nios2: enable earlycon support
nios2: constify irq_domain_ops
nios2: remove wrapper header for cmpxchg.h
nios2: add .gitignore entries for auto-generated files
-rw-r--r-- | arch/nios2/Kconfig | 2 | ||||
-rw-r--r-- | arch/nios2/Kconfig.debug | 1 | ||||
-rw-r--r-- | arch/nios2/Makefile | 5 | ||||
-rw-r--r-- | arch/nios2/boot/.gitignore | 2 | ||||
-rw-r--r-- | arch/nios2/boot/dts/10m50_devboard.dts | 3 | ||||
-rw-r--r-- | arch/nios2/include/asm/Kbuild | 1 | ||||
-rw-r--r-- | arch/nios2/include/asm/cacheflush.h | 6 | ||||
-rw-r--r-- | arch/nios2/include/asm/cmpxchg.h | 14 | ||||
-rw-r--r-- | arch/nios2/include/asm/cpuinfo.h | 2 | ||||
-rw-r--r-- | arch/nios2/include/asm/prom.h | 22 | ||||
-rw-r--r-- | arch/nios2/include/asm/setup.h | 2 | ||||
-rw-r--r-- | arch/nios2/include/asm/uaccess.h | 7 | ||||
-rw-r--r-- | arch/nios2/kernel/.gitignore | 1 | ||||
-rw-r--r-- | arch/nios2/kernel/Makefile | 1 | ||||
-rw-r--r-- | arch/nios2/kernel/cpuinfo.c | 18 | ||||
-rw-r--r-- | arch/nios2/kernel/early_printk.c | 118 | ||||
-rw-r--r-- | arch/nios2/kernel/irq.c | 2 | ||||
-rw-r--r-- | arch/nios2/kernel/prom.c | 49 | ||||
-rw-r--r-- | arch/nios2/kernel/setup.c | 6 | ||||
-rw-r--r-- | arch/nios2/mm/uaccess.c | 33 | ||||
-rw-r--r-- | arch/nios2/platform/Kconfig.platform | 26 |
21 files changed, 69 insertions, 252 deletions
diff --git a/arch/nios2/Kconfig b/arch/nios2/Kconfig index 51a56c8b04b4..a72d5f0de692 100644 --- a/arch/nios2/Kconfig +++ b/arch/nios2/Kconfig | |||
@@ -6,6 +6,8 @@ config NIOS2 | |||
6 | select GENERIC_CPU_DEVICES | 6 | select GENERIC_CPU_DEVICES |
7 | select GENERIC_IRQ_PROBE | 7 | select GENERIC_IRQ_PROBE |
8 | select GENERIC_IRQ_SHOW | 8 | select GENERIC_IRQ_SHOW |
9 | select GENERIC_STRNCPY_FROM_USER | ||
10 | select GENERIC_STRNLEN_USER | ||
9 | select HAVE_ARCH_TRACEHOOK | 11 | select HAVE_ARCH_TRACEHOOK |
10 | select HAVE_ARCH_KGDB | 12 | select HAVE_ARCH_KGDB |
11 | select IRQ_DOMAIN | 13 | select IRQ_DOMAIN |
diff --git a/arch/nios2/Kconfig.debug b/arch/nios2/Kconfig.debug index 2fd08cbfdddb..55105220370c 100644 --- a/arch/nios2/Kconfig.debug +++ b/arch/nios2/Kconfig.debug | |||
@@ -18,7 +18,6 @@ config EARLY_PRINTK | |||
18 | bool "Activate early kernel debugging" | 18 | bool "Activate early kernel debugging" |
19 | default y | 19 | default y |
20 | select SERIAL_CORE_CONSOLE | 20 | select SERIAL_CORE_CONSOLE |
21 | depends on SERIAL_ALTERA_JTAGUART_CONSOLE || SERIAL_ALTERA_UART_CONSOLE | ||
22 | help | 21 | help |
23 | Enable early printk on console | 22 | Enable early printk on console |
24 | This is useful for kernel debugging when your machine crashes very | 23 | This is useful for kernel debugging when your machine crashes very |
diff --git a/arch/nios2/Makefile b/arch/nios2/Makefile index e74afc12d516..8673a79dca9c 100644 --- a/arch/nios2/Makefile +++ b/arch/nios2/Makefile | |||
@@ -22,10 +22,15 @@ export MMU | |||
22 | 22 | ||
23 | LIBGCC := $(shell $(CC) $(KBUILD_CFLAGS) $(KCFLAGS) -print-libgcc-file-name) | 23 | LIBGCC := $(shell $(CC) $(KBUILD_CFLAGS) $(KCFLAGS) -print-libgcc-file-name) |
24 | 24 | ||
25 | KBUILD_AFLAGS += -march=r$(CONFIG_NIOS2_ARCH_REVISION) | ||
26 | |||
25 | KBUILD_CFLAGS += -pipe -D__linux__ -D__ELF__ | 27 | KBUILD_CFLAGS += -pipe -D__linux__ -D__ELF__ |
28 | KBUILD_CFLAGS += -march=r$(CONFIG_NIOS2_ARCH_REVISION) | ||
26 | KBUILD_CFLAGS += $(if $(CONFIG_NIOS2_HW_MUL_SUPPORT),-mhw-mul,-mno-hw-mul) | 29 | KBUILD_CFLAGS += $(if $(CONFIG_NIOS2_HW_MUL_SUPPORT),-mhw-mul,-mno-hw-mul) |
27 | KBUILD_CFLAGS += $(if $(CONFIG_NIOS2_HW_MULX_SUPPORT),-mhw-mulx,-mno-hw-mulx) | 30 | KBUILD_CFLAGS += $(if $(CONFIG_NIOS2_HW_MULX_SUPPORT),-mhw-mulx,-mno-hw-mulx) |
28 | KBUILD_CFLAGS += $(if $(CONFIG_NIOS2_HW_DIV_SUPPORT),-mhw-div,-mno-hw-div) | 31 | KBUILD_CFLAGS += $(if $(CONFIG_NIOS2_HW_DIV_SUPPORT),-mhw-div,-mno-hw-div) |
32 | KBUILD_CFLAGS += $(if $(CONFIG_NIOS2_BMX_SUPPORT),-mbmx,-mno-bmx) | ||
33 | KBUILD_CFLAGS += $(if $(CONFIG_NIOS2_CDX_SUPPORT),-mcdx,-mno-cdx) | ||
29 | KBUILD_CFLAGS += $(if $(CONFIG_NIOS2_FPU_SUPPORT),-mcustom-fpu-cfg=60-1,) | 34 | KBUILD_CFLAGS += $(if $(CONFIG_NIOS2_FPU_SUPPORT),-mcustom-fpu-cfg=60-1,) |
30 | 35 | ||
31 | KBUILD_CFLAGS += -fno-optimize-sibling-calls | 36 | KBUILD_CFLAGS += -fno-optimize-sibling-calls |
diff --git a/arch/nios2/boot/.gitignore b/arch/nios2/boot/.gitignore new file mode 100644 index 000000000000..109279ca5a4d --- /dev/null +++ b/arch/nios2/boot/.gitignore | |||
@@ -0,0 +1,2 @@ | |||
1 | *.dtb | ||
2 | vmImage | ||
diff --git a/arch/nios2/boot/dts/10m50_devboard.dts b/arch/nios2/boot/dts/10m50_devboard.dts index f362b2224ee7..4bb4dc1b52e9 100644 --- a/arch/nios2/boot/dts/10m50_devboard.dts +++ b/arch/nios2/boot/dts/10m50_devboard.dts | |||
@@ -244,6 +244,7 @@ | |||
244 | }; | 244 | }; |
245 | 245 | ||
246 | chosen { | 246 | chosen { |
247 | bootargs = "debug console=ttyS0,115200"; | 247 | bootargs = "debug earlycon console=ttyS0,115200"; |
248 | stdout-path = &a_16550_uart_0; | ||
248 | }; | 249 | }; |
249 | }; | 250 | }; |
diff --git a/arch/nios2/include/asm/Kbuild b/arch/nios2/include/asm/Kbuild index 87e70f2b463f..727dbb333f60 100644 --- a/arch/nios2/include/asm/Kbuild +++ b/arch/nios2/include/asm/Kbuild | |||
@@ -6,6 +6,7 @@ generic-y += bitsperlong.h | |||
6 | generic-y += bug.h | 6 | generic-y += bug.h |
7 | generic-y += bugs.h | 7 | generic-y += bugs.h |
8 | generic-y += clkdev.h | 8 | generic-y += clkdev.h |
9 | generic-y += cmpxchg.h | ||
9 | generic-y += current.h | 10 | generic-y += current.h |
10 | generic-y += device.h | 11 | generic-y += device.h |
11 | generic-y += div64.h | 12 | generic-y += div64.h |
diff --git a/arch/nios2/include/asm/cacheflush.h b/arch/nios2/include/asm/cacheflush.h index 52abba973dc2..55e383c173f7 100644 --- a/arch/nios2/include/asm/cacheflush.h +++ b/arch/nios2/include/asm/cacheflush.h | |||
@@ -46,7 +46,9 @@ extern void copy_from_user_page(struct vm_area_struct *vma, struct page *page, | |||
46 | extern void flush_dcache_range(unsigned long start, unsigned long end); | 46 | extern void flush_dcache_range(unsigned long start, unsigned long end); |
47 | extern void invalidate_dcache_range(unsigned long start, unsigned long end); | 47 | extern void invalidate_dcache_range(unsigned long start, unsigned long end); |
48 | 48 | ||
49 | #define flush_dcache_mmap_lock(mapping) do { } while (0) | 49 | #define flush_dcache_mmap_lock(mapping) \ |
50 | #define flush_dcache_mmap_unlock(mapping) do { } while (0) | 50 | spin_lock_irq(&(mapping)->tree_lock) |
51 | #define flush_dcache_mmap_unlock(mapping) \ | ||
52 | spin_unlock_irq(&(mapping)->tree_lock) | ||
51 | 53 | ||
52 | #endif /* _ASM_NIOS2_CACHEFLUSH_H */ | 54 | #endif /* _ASM_NIOS2_CACHEFLUSH_H */ |
diff --git a/arch/nios2/include/asm/cmpxchg.h b/arch/nios2/include/asm/cmpxchg.h deleted file mode 100644 index a7978f14d157..000000000000 --- a/arch/nios2/include/asm/cmpxchg.h +++ /dev/null | |||
@@ -1,14 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2004 Microtronix Datacom Ltd. | ||
3 | * | ||
4 | * This file is subject to the terms and conditions of the GNU General Public | ||
5 | * License. See the file "COPYING" in the main directory of this archive | ||
6 | * for more details. | ||
7 | */ | ||
8 | |||
9 | #ifndef _ASM_NIOS2_CMPXCHG_H | ||
10 | #define _ASM_NIOS2_CMPXCHG_H | ||
11 | |||
12 | #include <asm-generic/cmpxchg.h> | ||
13 | |||
14 | #endif /* _ASM_NIOS2_CMPXCHG_H */ | ||
diff --git a/arch/nios2/include/asm/cpuinfo.h b/arch/nios2/include/asm/cpuinfo.h index 348bb228fec9..dbdaf96f28d4 100644 --- a/arch/nios2/include/asm/cpuinfo.h +++ b/arch/nios2/include/asm/cpuinfo.h | |||
@@ -29,6 +29,8 @@ struct cpuinfo { | |||
29 | bool has_div; | 29 | bool has_div; |
30 | bool has_mul; | 30 | bool has_mul; |
31 | bool has_mulx; | 31 | bool has_mulx; |
32 | bool has_bmx; | ||
33 | bool has_cdx; | ||
32 | 34 | ||
33 | /* CPU caches */ | 35 | /* CPU caches */ |
34 | u32 icache_line_size; | 36 | u32 icache_line_size; |
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 | |||
20 | extern 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 | ||
31 | extern void pagetable_init(void); | 31 | extern void pagetable_init(void); |
32 | 32 | ||
33 | extern 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/include/asm/uaccess.h b/arch/nios2/include/asm/uaccess.h index 727bd9504899..dfa3c7cb30b4 100644 --- a/arch/nios2/include/asm/uaccess.h +++ b/arch/nios2/include/asm/uaccess.h | |||
@@ -42,6 +42,8 @@ | |||
42 | 42 | ||
43 | # define __EX_TABLE_SECTION ".section __ex_table,\"a\"\n" | 43 | # define __EX_TABLE_SECTION ".section __ex_table,\"a\"\n" |
44 | 44 | ||
45 | #define user_addr_max() (uaccess_kernel() ? ~0UL : TASK_SIZE) | ||
46 | |||
45 | /* | 47 | /* |
46 | * Zero Userspace | 48 | * Zero Userspace |
47 | */ | 49 | */ |
@@ -81,8 +83,9 @@ raw_copy_to_user(void __user *to, const void *from, unsigned long n); | |||
81 | #define INLINE_COPY_TO_USER | 83 | #define INLINE_COPY_TO_USER |
82 | 84 | ||
83 | extern long strncpy_from_user(char *__to, const char __user *__from, | 85 | extern long strncpy_from_user(char *__to, const char __user *__from, |
84 | long __len); | 86 | long __len); |
85 | extern long strnlen_user(const char __user *s, long n); | 87 | extern __must_check long strlen_user(const char __user *str); |
88 | extern __must_check long strnlen_user(const char __user *s, long n); | ||
86 | 89 | ||
87 | /* Optimized macros */ | 90 | /* Optimized macros */ |
88 | #define __get_user_asm(val, insn, addr, err) \ | 91 | #define __get_user_asm(val, insn, addr, err) \ |
diff --git a/arch/nios2/kernel/.gitignore b/arch/nios2/kernel/.gitignore new file mode 100644 index 000000000000..c5f676c3c224 --- /dev/null +++ b/arch/nios2/kernel/.gitignore | |||
@@ -0,0 +1 @@ | |||
vmlinux.lds | |||
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 | |||
20 | obj-y += time.o | 20 | obj-y += time.o |
21 | obj-y += traps.o | 21 | obj-y += traps.o |
22 | 22 | ||
23 | obj-$(CONFIG_EARLY_PRINTK) += early_printk.o | ||
24 | obj-$(CONFIG_KGDB) += kgdb.o | 23 | obj-$(CONFIG_KGDB) += kgdb.o |
25 | obj-$(CONFIG_MODULES) += module.o | 24 | obj-$(CONFIG_MODULES) += module.o |
26 | obj-$(CONFIG_NIOS2_ALIGNMENT_TRAP) += misaligned.o | 25 | obj-$(CONFIG_NIOS2_ALIGNMENT_TRAP) += misaligned.o |
diff --git a/arch/nios2/kernel/cpuinfo.c b/arch/nios2/kernel/cpuinfo.c index 1cccc36877bc..93207718bb22 100644 --- a/arch/nios2/kernel/cpuinfo.c +++ b/arch/nios2/kernel/cpuinfo.c | |||
@@ -67,6 +67,8 @@ void __init setup_cpuinfo(void) | |||
67 | cpuinfo.has_div = of_property_read_bool(cpu, "altr,has-div"); | 67 | cpuinfo.has_div = of_property_read_bool(cpu, "altr,has-div"); |
68 | cpuinfo.has_mul = of_property_read_bool(cpu, "altr,has-mul"); | 68 | cpuinfo.has_mul = of_property_read_bool(cpu, "altr,has-mul"); |
69 | cpuinfo.has_mulx = of_property_read_bool(cpu, "altr,has-mulx"); | 69 | cpuinfo.has_mulx = of_property_read_bool(cpu, "altr,has-mulx"); |
70 | cpuinfo.has_bmx = of_property_read_bool(cpu, "altr,has-bmx"); | ||
71 | cpuinfo.has_cdx = of_property_read_bool(cpu, "altr,has-cdx"); | ||
70 | cpuinfo.mmu = of_property_read_bool(cpu, "altr,has-mmu"); | 72 | cpuinfo.mmu = of_property_read_bool(cpu, "altr,has-mmu"); |
71 | 73 | ||
72 | if (IS_ENABLED(CONFIG_NIOS2_HW_DIV_SUPPORT) && !cpuinfo.has_div) | 74 | if (IS_ENABLED(CONFIG_NIOS2_HW_DIV_SUPPORT) && !cpuinfo.has_div) |
@@ -78,6 +80,12 @@ void __init setup_cpuinfo(void) | |||
78 | if (IS_ENABLED(CONFIG_NIOS2_HW_MULX_SUPPORT) && !cpuinfo.has_mulx) | 80 | if (IS_ENABLED(CONFIG_NIOS2_HW_MULX_SUPPORT) && !cpuinfo.has_mulx) |
79 | err_cpu("MULX"); | 81 | err_cpu("MULX"); |
80 | 82 | ||
83 | if (IS_ENABLED(CONFIG_NIOS2_BMX_SUPPORT) && !cpuinfo.has_bmx) | ||
84 | err_cpu("BMX"); | ||
85 | |||
86 | if (IS_ENABLED(CONFIG_NIOS2_CDX_SUPPORT) && !cpuinfo.has_cdx) | ||
87 | err_cpu("CDX"); | ||
88 | |||
81 | cpuinfo.tlb_num_ways = fcpu(cpu, "altr,tlb-num-ways"); | 89 | cpuinfo.tlb_num_ways = fcpu(cpu, "altr,tlb-num-ways"); |
82 | if (!cpuinfo.tlb_num_ways) | 90 | if (!cpuinfo.tlb_num_ways) |
83 | panic("altr,tlb-num-ways can't be 0. Please check your hardware " | 91 | panic("altr,tlb-num-ways can't be 0. Please check your hardware " |
@@ -125,12 +133,14 @@ static int show_cpuinfo(struct seq_file *m, void *v) | |||
125 | 133 | ||
126 | seq_printf(m, | 134 | seq_printf(m, |
127 | "CPU:\t\tNios II/%s\n" | 135 | "CPU:\t\tNios II/%s\n" |
136 | "REV:\t\t%i\n" | ||
128 | "MMU:\t\t%s\n" | 137 | "MMU:\t\t%s\n" |
129 | "FPU:\t\tnone\n" | 138 | "FPU:\t\tnone\n" |
130 | "Clocking:\t%u.%02u MHz\n" | 139 | "Clocking:\t%u.%02u MHz\n" |
131 | "BogoMips:\t%lu.%02lu\n" | 140 | "BogoMips:\t%lu.%02lu\n" |
132 | "Calibration:\t%lu loops\n", | 141 | "Calibration:\t%lu loops\n", |
133 | cpuinfo.cpu_impl, | 142 | cpuinfo.cpu_impl, |
143 | CONFIG_NIOS2_ARCH_REVISION, | ||
134 | cpuinfo.mmu ? "present" : "none", | 144 | cpuinfo.mmu ? "present" : "none", |
135 | clockfreq / 1000000, (clockfreq / 100000) % 10, | 145 | clockfreq / 1000000, (clockfreq / 100000) % 10, |
136 | (loops_per_jiffy * HZ) / 500000, | 146 | (loops_per_jiffy * HZ) / 500000, |
@@ -141,10 +151,14 @@ static int show_cpuinfo(struct seq_file *m, void *v) | |||
141 | "HW:\n" | 151 | "HW:\n" |
142 | " MUL:\t\t%s\n" | 152 | " MUL:\t\t%s\n" |
143 | " MULX:\t\t%s\n" | 153 | " MULX:\t\t%s\n" |
144 | " DIV:\t\t%s\n", | 154 | " DIV:\t\t%s\n" |
155 | " BMX:\t\t%s\n" | ||
156 | " CDX:\t\t%s\n", | ||
145 | cpuinfo.has_mul ? "yes" : "no", | 157 | cpuinfo.has_mul ? "yes" : "no", |
146 | cpuinfo.has_mulx ? "yes" : "no", | 158 | cpuinfo.has_mulx ? "yes" : "no", |
147 | cpuinfo.has_div ? "yes" : "no"); | 159 | cpuinfo.has_div ? "yes" : "no", |
160 | cpuinfo.has_bmx ? "yes" : "no", | ||
161 | cpuinfo.has_cdx ? "yes" : "no"); | ||
148 | 162 | ||
149 | seq_printf(m, | 163 | seq_printf(m, |
150 | "Icache:\t\t%ukB, line length: %u\n", | 164 | "Icache:\t\t%ukB, line length: %u\n", |
diff --git a/arch/nios2/kernel/early_printk.c b/arch/nios2/kernel/early_printk.c deleted file mode 100644 index c08e4c1486fc..000000000000 --- a/arch/nios2/kernel/early_printk.c +++ /dev/null | |||
@@ -1,118 +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 | |||
21 | static 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 | |||
37 | static 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 | |||
65 | static 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 | |||
73 | static 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 | # error Neither SERIAL_ALTERA_JTAGUART_CONSOLE nor SERIAL_ALTERA_UART_CONSOLE \ | ||
85 | selected | ||
86 | #endif | ||
87 | |||
88 | static struct console early_console_prom = { | ||
89 | .name = "early", | ||
90 | .write = early_console_write, | ||
91 | .flags = CON_PRINTBUFFER | CON_BOOT, | ||
92 | .index = -1 | ||
93 | }; | ||
94 | |||
95 | void __init setup_early_printk(void) | ||
96 | { | ||
97 | #if defined(CONFIG_SERIAL_ALTERA_JTAGUART_CONSOLE) || \ | ||
98 | defined(CONFIG_SERIAL_ALTERA_UART_CONSOLE) | ||
99 | base_addr = of_early_console(); | ||
100 | #else | ||
101 | base_addr = 0; | ||
102 | #endif | ||
103 | |||
104 | if (!base_addr) | ||
105 | return; | ||
106 | |||
107 | #if defined(CONFIG_SERIAL_ALTERA_JTAGUART_CONSOLE_BYPASS) | ||
108 | /* Clear activity bit so BYPASS doesn't stall if we've used JTAG for | ||
109 | * downloading the kernel. This might cause early data to be lost even | ||
110 | * if the JTAG terminal is running. | ||
111 | */ | ||
112 | JUART_SET_CR(JUART_GET_CR() | ALTERA_JTAGUART_CONTROL_AC_MSK); | ||
113 | #endif | ||
114 | |||
115 | early_console = &early_console_prom; | ||
116 | register_console(early_console); | ||
117 | pr_info("early_console initialized at 0x%08lx\n", base_addr); | ||
118 | } | ||
diff --git a/arch/nios2/kernel/irq.c b/arch/nios2/kernel/irq.c index f5b74ae69b5b..6c833a9d4eab 100644 --- a/arch/nios2/kernel/irq.c +++ b/arch/nios2/kernel/irq.c | |||
@@ -67,7 +67,7 @@ static int irq_map(struct irq_domain *h, unsigned int virq, | |||
67 | return 0; | 67 | return 0; |
68 | } | 68 | } |
69 | 69 | ||
70 | static struct irq_domain_ops irq_ops = { | 70 | static const struct irq_domain_ops irq_ops = { |
71 | .map = irq_map, | 71 | .map = irq_map, |
72 | .xlate = irq_domain_xlate_onecell, | 72 | .xlate = irq_domain_xlate_onecell, |
73 | }; | 73 | }; |
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 | ||
36 | void __init early_init_dt_add_memory_arch(u64 base, u64 size) | 35 | void __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 | ||
76 | static 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 | |||
112 | unsigned 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 6044d9be28b4..926a02b17b31 100644 --- a/arch/nios2/kernel/setup.c +++ b/arch/nios2/kernel/setup.c | |||
@@ -137,6 +137,8 @@ asmlinkage void __init nios2_boot_init(unsigned r4, unsigned r5, unsigned r6, | |||
137 | strncpy(boot_command_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE); | 137 | strncpy(boot_command_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE); |
138 | #endif | 138 | #endif |
139 | #endif | 139 | #endif |
140 | |||
141 | parse_early_param(); | ||
140 | } | 142 | } |
141 | 143 | ||
142 | void __init setup_arch(char **cmdline_p) | 144 | void __init setup_arch(char **cmdline_p) |
@@ -145,10 +147,6 @@ void __init setup_arch(char **cmdline_p) | |||
145 | 147 | ||
146 | console_verbose(); | 148 | console_verbose(); |
147 | 149 | ||
148 | #ifdef CONFIG_EARLY_PRINTK | ||
149 | setup_early_printk(); | ||
150 | #endif | ||
151 | |||
152 | memory_start = PAGE_ALIGN((unsigned long)__pa(_end)); | 150 | memory_start = PAGE_ALIGN((unsigned long)__pa(_end)); |
153 | memory_end = (unsigned long) CONFIG_NIOS2_MEM_BASE + memory_size; | 151 | memory_end = (unsigned long) CONFIG_NIOS2_MEM_BASE + memory_size; |
154 | 152 | ||
diff --git a/arch/nios2/mm/uaccess.c b/arch/nios2/mm/uaccess.c index 804983317766..34f10af8ea40 100644 --- a/arch/nios2/mm/uaccess.c +++ b/arch/nios2/mm/uaccess.c | |||
@@ -128,36 +128,3 @@ asm( | |||
128 | ".word 12b,13b\n" | 128 | ".word 12b,13b\n" |
129 | ".previous\n"); | 129 | ".previous\n"); |
130 | EXPORT_SYMBOL(raw_copy_to_user); | 130 | EXPORT_SYMBOL(raw_copy_to_user); |
131 | |||
132 | long strncpy_from_user(char *__to, const char __user *__from, long __len) | ||
133 | { | ||
134 | int l = strnlen_user(__from, __len); | ||
135 | int is_zt = 1; | ||
136 | |||
137 | if (l > __len) { | ||
138 | is_zt = 0; | ||
139 | l = __len; | ||
140 | } | ||
141 | |||
142 | if (l == 0 || copy_from_user(__to, __from, l)) | ||
143 | return -EFAULT; | ||
144 | |||
145 | if (is_zt) | ||
146 | l--; | ||
147 | return l; | ||
148 | } | ||
149 | |||
150 | long strnlen_user(const char __user *s, long n) | ||
151 | { | ||
152 | long i; | ||
153 | |||
154 | for (i = 0; i < n; i++) { | ||
155 | char c; | ||
156 | |||
157 | if (get_user(c, s + i) == -EFAULT) | ||
158 | return 0; | ||
159 | if (c == 0) | ||
160 | return i + 1; | ||
161 | } | ||
162 | return n + 1; | ||
163 | } | ||
diff --git a/arch/nios2/platform/Kconfig.platform b/arch/nios2/platform/Kconfig.platform index d3e5df9fb36b..74c1aaf588b8 100644 --- a/arch/nios2/platform/Kconfig.platform +++ b/arch/nios2/platform/Kconfig.platform | |||
@@ -52,6 +52,14 @@ config NIOS2_DTB_SOURCE | |||
52 | 52 | ||
53 | comment "Nios II instructions" | 53 | comment "Nios II instructions" |
54 | 54 | ||
55 | config NIOS2_ARCH_REVISION | ||
56 | int "Select Nios II architecture revision" | ||
57 | range 1 2 | ||
58 | default 1 | ||
59 | help | ||
60 | Select between Nios II R1 and Nios II R2 . The architectures | ||
61 | are binary incompatible. Default is R1 . | ||
62 | |||
55 | config NIOS2_HW_MUL_SUPPORT | 63 | config NIOS2_HW_MUL_SUPPORT |
56 | bool "Enable MUL instruction" | 64 | bool "Enable MUL instruction" |
57 | default n | 65 | default n |
@@ -73,6 +81,24 @@ config NIOS2_HW_DIV_SUPPORT | |||
73 | Set to true if you configured the Nios II to include the DIV | 81 | Set to true if you configured the Nios II to include the DIV |
74 | instruction. Enables the -mhw-div compiler flag. | 82 | instruction. Enables the -mhw-div compiler flag. |
75 | 83 | ||
84 | config NIOS2_BMX_SUPPORT | ||
85 | bool "Enable BMX instructions" | ||
86 | depends on NIOS2_ARCH_REVISION = 2 | ||
87 | default n | ||
88 | help | ||
89 | Set to true if you configured the Nios II R2 to include | ||
90 | the BMX Bit Manipulation Extension instructions. Enables | ||
91 | the -mbmx compiler flag. | ||
92 | |||
93 | config NIOS2_CDX_SUPPORT | ||
94 | bool "Enable CDX instructions" | ||
95 | depends on NIOS2_ARCH_REVISION = 2 | ||
96 | default n | ||
97 | help | ||
98 | Set to true if you configured the Nios II R2 to include | ||
99 | the CDX Bit Manipulation Extension instructions. Enables | ||
100 | the -mcdx compiler flag. | ||
101 | |||
76 | config NIOS2_FPU_SUPPORT | 102 | config NIOS2_FPU_SUPPORT |
77 | bool "Custom floating point instr support" | 103 | bool "Custom floating point instr support" |
78 | default n | 104 | default n |