From 5a26cd69cc8156df8e8bfac8d656ebaabc62be2c Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Fri, 9 Dec 2011 12:26:16 +0100 Subject: microblaze: Use of_find_compatible_node for timer and intc Calling of_find_compatible_node instead of calling private code which does the same. Signed-off-by: Michal Simek --- arch/microblaze/kernel/intc.c | 17 ++++------------- arch/microblaze/kernel/timer.c | 17 ++++------------- 2 files changed, 8 insertions(+), 26 deletions(-) (limited to 'arch/microblaze/kernel') diff --git a/arch/microblaze/kernel/intc.c b/arch/microblaze/kernel/intc.c index eb41441c7fd..da33e45deba 100644 --- a/arch/microblaze/kernel/intc.c +++ b/arch/microblaze/kernel/intc.c @@ -99,7 +99,7 @@ unsigned int get_irq(struct pt_regs *regs) void __init init_IRQ(void) { - u32 i, j, intr_type; + u32 i, intr_type; struct device_node *intc = NULL; #ifdef CONFIG_SELFMOD_INTC unsigned int intc_baseaddr = 0; @@ -113,16 +113,7 @@ void __init init_IRQ(void) 0 }; #endif - const char * const intc_list[] = { - "xlnx,xps-intc-1.00.a", - NULL - }; - - for (j = 0; intc_list[j] != NULL; j++) { - intc = of_find_compatible_node(NULL, NULL, intc_list[j]); - if (intc) - break; - } + intc = of_find_compatible_node(NULL, NULL, "xlnx,xps-intc-1.00.a"); BUG_ON(!intc); intc_baseaddr = be32_to_cpup(of_get_property(intc, @@ -140,8 +131,8 @@ void __init init_IRQ(void) #ifdef CONFIG_SELFMOD_INTC selfmod_function((int *) arr_func, intc_baseaddr); #endif - printk(KERN_INFO "%s #0 at 0x%08x, num_irq=%d, edge=0x%x\n", - intc_list[j], intc_baseaddr, nr_irq, intr_type); + printk(KERN_INFO "XPS intc #0 at 0x%08x, num_irq=%d, edge=0x%x\n", + intc_baseaddr, nr_irq, intr_mask); /* * Disable all external interrupts until they are diff --git a/arch/microblaze/kernel/timer.c b/arch/microblaze/kernel/timer.c index af74b1113aa..3ba1e1c8c2e 100644 --- a/arch/microblaze/kernel/timer.c +++ b/arch/microblaze/kernel/timer.c @@ -243,7 +243,7 @@ static int timer_initialized; void __init time_init(void) { - u32 irq, i = 0; + u32 irq; u32 timer_num = 1; struct device_node *timer = NULL; const void *prop; @@ -258,16 +258,7 @@ void __init time_init(void) 0 }; #endif - const char * const timer_list[] = { - "xlnx,xps-timer-1.00.a", - NULL - }; - - for (i = 0; timer_list[i] != NULL; i++) { - timer = of_find_compatible_node(NULL, NULL, timer_list[i]); - if (timer) - break; - } + timer = of_find_compatible_node(NULL, NULL, "xlnx,xps-timer-1.00.a"); BUG_ON(!timer); timer_baseaddr = be32_to_cpup(of_get_property(timer, "reg", NULL)); @@ -283,8 +274,8 @@ void __init time_init(void) #ifdef CONFIG_SELFMOD_TIMER selfmod_function((int *) arr_func, timer_baseaddr); #endif - printk(KERN_INFO "%s #0 at 0x%08x, irq=%d\n", - timer_list[i], timer_baseaddr, irq); + printk(KERN_INFO "XPS timer #0 at 0x%08x, irq=%d\n", + timer_baseaddr, irq); /* If there is clock-frequency property than use it */ prop = of_get_property(timer, "clock-frequency", NULL); -- cgit v1.2.3 From 2ecb899b4e568afd9e659e80dcd10feb50e4b1dd Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Fri, 9 Dec 2011 12:26:55 +0100 Subject: microblaze: intc: Change variable name intr_type is mask - change name. s/intr_type/intr_mask/g Signed-off-by: Michal Simek --- arch/microblaze/kernel/intc.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'arch/microblaze/kernel') diff --git a/arch/microblaze/kernel/intc.c b/arch/microblaze/kernel/intc.c index da33e45deba..1293098ff70 100644 --- a/arch/microblaze/kernel/intc.c +++ b/arch/microblaze/kernel/intc.c @@ -99,7 +99,7 @@ unsigned int get_irq(struct pt_regs *regs) void __init init_IRQ(void) { - u32 i, intr_type; + u32 i, intr_mask; struct device_node *intc = NULL; #ifdef CONFIG_SELFMOD_INTC unsigned int intc_baseaddr = 0; @@ -122,10 +122,9 @@ void __init init_IRQ(void) nr_irq = be32_to_cpup(of_get_property(intc, "xlnx,num-intr-inputs", NULL)); - intr_type = - be32_to_cpup(of_get_property(intc, - "xlnx,kind-of-intr", NULL)); - if (intr_type > (u32)((1ULL << nr_irq) - 1)) + intr_mask = + be32_to_cpup(of_get_property(intc, "xlnx,kind-of-intr", NULL)); + if (intr_mask > (u32)((1ULL << nr_irq) - 1)) printk(KERN_INFO " ERROR: Mismatch in kind-of-intr param\n"); #ifdef CONFIG_SELFMOD_INTC @@ -147,7 +146,7 @@ void __init init_IRQ(void) out_be32(intc_baseaddr + MER, MER_HIE | MER_ME); for (i = 0; i < nr_irq; ++i) { - if (intr_type & (0x00000001 << i)) { + if (intr_mask & (0x00000001 << i)) { irq_set_chip_and_handler_name(i, &intc_dev, handle_edge_irq, "edge"); irq_clear_status_flags(i, IRQ_LEVEL); -- cgit v1.2.3 From 9d0ced0084d8ae38883cc688ace8a9a4350d6bc9 Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Fri, 9 Dec 2011 10:46:52 +0100 Subject: microblaze: Use irq_of_parse_and_map for timer It is necessary to call generic function for irq finding. The main reason is that this generic function calls irq_create_of_mapping which can add some shift because of NO_IRQ. Signed-off-by: Michal Simek --- arch/microblaze/kernel/timer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'arch/microblaze/kernel') diff --git a/arch/microblaze/kernel/timer.c b/arch/microblaze/kernel/timer.c index 3ba1e1c8c2e..52e3eaf7f30 100644 --- a/arch/microblaze/kernel/timer.c +++ b/arch/microblaze/kernel/timer.c @@ -263,7 +263,7 @@ void __init time_init(void) timer_baseaddr = be32_to_cpup(of_get_property(timer, "reg", NULL)); timer_baseaddr = (unsigned long) ioremap(timer_baseaddr, PAGE_SIZE); - irq = be32_to_cpup(of_get_property(timer, "interrupts", NULL)); + irq = irq_of_parse_and_map(timer, 0); timer_num = be32_to_cpup(of_get_property(timer, "xlnx,one-timer-only", NULL)); if (timer_num) { -- cgit v1.2.3 From 6c7a2676f594ca9a30203b4fd5dc26b53682cffe Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Fri, 9 Dec 2011 10:45:20 +0100 Subject: microblaze: Change NO_IRQ to 0 As has been discussed many times[1], Using NO_IRQ set to anything other than 0 is bug waiting to happen since many drivers follow the pattern "if (!irq)" for testing whether or not an irq has been set. This patch changes the Microblaze NO_IRQ setting from -1 to 0 to bring it in line with most of the rest of the kernel. It also prepares for Microblaze eventually supporting multiple interrupt controllers by breaking the assumption that hwirq# == Linux IRQ#. The Linux IRQ number is just a cookie with no guarantee of a direct relationship with the hardware irq arrangement. At this point, Microblaze interrupt handling only supports only one instance of one kind of interrupt controller (xilinx_intc). This change shouldn't affect any architecture code outside of the interrupt controller driver and the irq_of mapping. Updated to 3.2 and to use irq_data.hwirq by Rob Herring. Tested and fixed by Michal Simek. [1] http://lkml.org/lkml/2005/11/21/221 Signed-off-by: Grant Likely Signed-off-by: Rob Herring Signed-off-by: Michal Simek --- arch/microblaze/include/asm/irq.h | 11 +++++++++-- arch/microblaze/kernel/intc.c | 28 +++++++++++++++------------- arch/microblaze/kernel/irq.c | 11 ++++++----- 3 files changed, 30 insertions(+), 20 deletions(-) (limited to 'arch/microblaze/kernel') diff --git a/arch/microblaze/include/asm/irq.h b/arch/microblaze/include/asm/irq.h index cc54187f3d3..b116a825de7 100644 --- a/arch/microblaze/include/asm/irq.h +++ b/arch/microblaze/include/asm/irq.h @@ -9,7 +9,14 @@ #ifndef _ASM_MICROBLAZE_IRQ_H #define _ASM_MICROBLAZE_IRQ_H -#define NR_IRQS 32 + +/* + * Linux IRQ# is currently offset by one to map to the hardware + * irq number. So hardware IRQ0 maps to Linux irq 1. + */ +#define NO_IRQ_OFFSET 1 +#define IRQ_OFFSET NO_IRQ_OFFSET +#define NR_IRQS (32 + IRQ_OFFSET) #include /* This type is the placeholder for a hardware interrupt number. It has to @@ -20,7 +27,7 @@ typedef unsigned long irq_hw_number_t; extern unsigned int nr_irq; -#define NO_IRQ (-1) +#define NO_IRQ 0 struct pt_regs; extern void do_IRQ(struct pt_regs *regs); diff --git a/arch/microblaze/kernel/intc.c b/arch/microblaze/kernel/intc.c index 1293098ff70..44b177e2ab1 100644 --- a/arch/microblaze/kernel/intc.c +++ b/arch/microblaze/kernel/intc.c @@ -42,8 +42,9 @@ unsigned int nr_irq; static void intc_enable_or_unmask(struct irq_data *d) { - unsigned long mask = 1 << d->irq; - pr_debug("enable_or_unmask: %d\n", d->irq); + unsigned long mask = 1 << d->hwirq; + + pr_debug("enable_or_unmask: %ld\n", d->hwirq); out_be32(INTC_BASE + SIE, mask); /* ack level irqs because they can't be acked during @@ -56,20 +57,21 @@ static void intc_enable_or_unmask(struct irq_data *d) static void intc_disable_or_mask(struct irq_data *d) { - pr_debug("disable: %d\n", d->irq); - out_be32(INTC_BASE + CIE, 1 << d->irq); + pr_debug("disable: %ld\n", d->hwirq); + out_be32(INTC_BASE + CIE, 1 << d->hwirq); } static void intc_ack(struct irq_data *d) { - pr_debug("ack: %d\n", d->irq); - out_be32(INTC_BASE + IAR, 1 << d->irq); + pr_debug("ack: %ld\n", d->hwirq); + out_be32(INTC_BASE + IAR, 1 << d->hwirq); } static void intc_mask_ack(struct irq_data *d) { - unsigned long mask = 1 << d->irq; - pr_debug("disable_and_ack: %d\n", d->irq); + unsigned long mask = 1 << d->hwirq; + + pr_debug("disable_and_ack: %ld\n", d->hwirq); out_be32(INTC_BASE + CIE, mask); out_be32(INTC_BASE + IAR, mask); } @@ -91,7 +93,7 @@ unsigned int get_irq(struct pt_regs *regs) * order to handle multiple interrupt controllers. It currently * is hardcoded to check for interrupts only on the first INTC. */ - irq = in_be32(INTC_BASE + IVR); + irq = in_be32(INTC_BASE + IVR) + NO_IRQ_OFFSET; pr_debug("get_irq: %d\n", irq); return irq; @@ -116,8 +118,7 @@ void __init init_IRQ(void) intc = of_find_compatible_node(NULL, NULL, "xlnx,xps-intc-1.00.a"); BUG_ON(!intc); - intc_baseaddr = be32_to_cpup(of_get_property(intc, - "reg", NULL)); + intc_baseaddr = be32_to_cpup(of_get_property(intc, "reg", NULL)); intc_baseaddr = (unsigned long) ioremap(intc_baseaddr, PAGE_SIZE); nr_irq = be32_to_cpup(of_get_property(intc, "xlnx,num-intr-inputs", NULL)); @@ -145,8 +146,8 @@ void __init init_IRQ(void) /* Turn on the Master Enable. */ out_be32(intc_baseaddr + MER, MER_HIE | MER_ME); - for (i = 0; i < nr_irq; ++i) { - if (intr_mask & (0x00000001 << i)) { + for (i = IRQ_OFFSET; i < (nr_irq + IRQ_OFFSET); ++i) { + if (intr_mask & (0x00000001 << (i - IRQ_OFFSET))) { irq_set_chip_and_handler_name(i, &intc_dev, handle_edge_irq, "edge"); irq_clear_status_flags(i, IRQ_LEVEL); @@ -155,5 +156,6 @@ void __init init_IRQ(void) handle_level_irq, "level"); irq_set_status_flags(i, IRQ_LEVEL); } + irq_get_irq_data(i)->hwirq = i - IRQ_OFFSET; } } diff --git a/arch/microblaze/kernel/irq.c b/arch/microblaze/kernel/irq.c index e5d63a89b9b..bbebcae72c0 100644 --- a/arch/microblaze/kernel/irq.c +++ b/arch/microblaze/kernel/irq.c @@ -33,11 +33,12 @@ void __irq_entry do_IRQ(struct pt_regs *regs) irq_enter(); irq = get_irq(regs); next_irq: - BUG_ON(irq == -1U); - generic_handle_irq(irq); + BUG_ON(!irq); + /* Substract 1 because of get_irq */ + generic_handle_irq(irq + IRQ_OFFSET - NO_IRQ_OFFSET); irq = get_irq(regs); - if (irq != -1U) { + if (irq) { pr_debug("next irq: %d\n", irq); ++concurrent_irq; goto next_irq; @@ -52,13 +53,13 @@ next_irq: intc without any cascades or any connection that's why mapping is 1:1 */ unsigned int irq_create_mapping(struct irq_host *host, irq_hw_number_t hwirq) { - return hwirq; + return hwirq + IRQ_OFFSET; } EXPORT_SYMBOL_GPL(irq_create_mapping); unsigned int irq_create_of_mapping(struct device_node *controller, const u32 *intspec, unsigned int intsize) { - return intspec[0]; + return intspec[0] + IRQ_OFFSET; } EXPORT_SYMBOL_GPL(irq_create_of_mapping); -- cgit v1.2.3 From a8c2e555b05d6203576e396eba01f17cb2516e66 Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Thu, 10 Nov 2011 13:40:08 +0100 Subject: microblaze: Send CR before LF for early console This patch fixes problem with measuring tools. Signed-off-by: Michal Simek --- arch/microblaze/kernel/early_printk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'arch/microblaze/kernel') diff --git a/arch/microblaze/kernel/early_printk.c b/arch/microblaze/kernel/early_printk.c index d26d92d4775..8356e47631c 100644 --- a/arch/microblaze/kernel/early_printk.c +++ b/arch/microblaze/kernel/early_printk.c @@ -50,9 +50,9 @@ static void early_printk_uartlite_write(struct console *unused, const char *s, unsigned n) { while (*s && n-- > 0) { - early_printk_uartlite_putc(*s); if (*s == '\n') early_printk_uartlite_putc('\r'); + early_printk_uartlite_putc(*s); s++; } } @@ -94,9 +94,9 @@ static void early_printk_uart16550_write(struct console *unused, const char *s, unsigned n) { while (*s && n-- > 0) { - early_printk_uart16550_putc(*s); if (*s == '\n') early_printk_uart16550_putc('\r'); + early_printk_uart16550_putc(*s); s++; } } -- cgit v1.2.3 From b6d5b28e446896278a0b02d6cc1bf4447ed07019 Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Thu, 10 Nov 2011 13:38:54 +0100 Subject: microblaze: Remove eprintk macro eprintk macro was used for printing early_printk messages. Early console registration was changed that's why this is not needed. Signed-off-by: Michal Simek --- arch/microblaze/include/asm/setup.h | 6 ------ arch/microblaze/kernel/setup.c | 18 +++++++++--------- arch/microblaze/kernel/timer.c | 2 +- 3 files changed, 10 insertions(+), 16 deletions(-) (limited to 'arch/microblaze/kernel') diff --git a/arch/microblaze/include/asm/setup.h b/arch/microblaze/include/asm/setup.h index 904e5ef6a11..6c72ed7eba9 100644 --- a/arch/microblaze/include/asm/setup.h +++ b/arch/microblaze/include/asm/setup.h @@ -26,12 +26,6 @@ int setup_early_printk(char *opt); void remap_early_printk(void); void disable_early_printk(void); -#if defined(CONFIG_EARLY_PRINTK) -#define eprintk early_printk -#else -#define eprintk printk -#endif - void heartbeat(void); void setup_heartbeat(void); diff --git a/arch/microblaze/kernel/setup.c b/arch/microblaze/kernel/setup.c index 0e654a12d37..604cd9dd133 100644 --- a/arch/microblaze/kernel/setup.c +++ b/arch/microblaze/kernel/setup.c @@ -145,32 +145,32 @@ void __init machine_early_init(const char *cmdline, unsigned int ram, setup_early_printk(NULL); #endif - eprintk("Ramdisk addr 0x%08x, ", ram); + printk("Ramdisk addr 0x%08x, ", ram); if (fdt) - eprintk("FDT at 0x%08x\n", fdt); + printk("FDT at 0x%08x\n", fdt); else - eprintk("Compiled-in FDT at 0x%08x\n", + printk("Compiled-in FDT at 0x%08x\n", (unsigned int)_fdt_start); #ifdef CONFIG_MTD_UCLINUX - eprintk("Found romfs @ 0x%08x (0x%08x)\n", + printk("Found romfs @ 0x%08x (0x%08x)\n", romfs_base, romfs_size); - eprintk("#### klimit %p ####\n", old_klimit); + printk("#### klimit %p ####\n", old_klimit); BUG_ON(romfs_size < 0); /* What else can we do? */ - eprintk("Moved 0x%08x bytes from 0x%08x to 0x%08x\n", + printk("Moved 0x%08x bytes from 0x%08x to 0x%08x\n", romfs_size, romfs_base, (unsigned)&_ebss); - eprintk("New klimit: 0x%08x\n", (unsigned)klimit); + printk("New klimit: 0x%08x\n", (unsigned)klimit); #endif #if CONFIG_XILINX_MICROBLAZE0_USE_MSR_INSTR if (msr) - eprintk("!!!Your kernel has setup MSR instruction but " + printk("!!!Your kernel has setup MSR instruction but " "CPU don't have it %x\n", msr); #else if (!msr) - eprintk("!!!Your kernel not setup MSR instruction but " + printk("!!!Your kernel not setup MSR instruction but " "CPU have it %x\n", msr); #endif diff --git a/arch/microblaze/kernel/timer.c b/arch/microblaze/kernel/timer.c index 52e3eaf7f30..3cb0bf64013 100644 --- a/arch/microblaze/kernel/timer.c +++ b/arch/microblaze/kernel/timer.c @@ -267,7 +267,7 @@ void __init time_init(void) timer_num = be32_to_cpup(of_get_property(timer, "xlnx,one-timer-only", NULL)); if (timer_num) { - eprintk(KERN_EMERG "Please enable two timers in HW\n"); + printk(KERN_EMERG "Please enable two timers in HW\n"); BUG(); } -- cgit v1.2.3 From f5b778bee6daeb9b21ccfbcdc79a2f61a868b300 Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Tue, 29 Nov 2011 12:57:09 +0100 Subject: microblaze: Fix debug message in module Trivial fix. Signed-off-by: Michal Simek --- arch/microblaze/kernel/module.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'arch/microblaze/kernel') diff --git a/arch/microblaze/kernel/module.c b/arch/microblaze/kernel/module.c index 142426f631b..f39257a5abc 100644 --- a/arch/microblaze/kernel/module.c +++ b/arch/microblaze/kernel/module.c @@ -100,7 +100,7 @@ int apply_relocate_add(Elf32_Shdr *sechdrs, const char *strtab, break; case R_MICROBLAZE_64_NONE: - pr_debug("R_MICROBLAZE_NONE\n"); + pr_debug("R_MICROBLAZE_64_NONE\n"); break; case R_MICROBLAZE_NONE: -- cgit v1.2.3 From 5dbeaad3eac6691d57af064c0a60d03751878303 Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Thu, 22 Dec 2011 14:57:13 +0100 Subject: microblaze: Trivial asm fix Just replace one dot with comma. New binutils can detect it. Signed-off-by: Michal Simek --- arch/microblaze/kernel/entry.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'arch/microblaze/kernel') diff --git a/arch/microblaze/kernel/entry.S b/arch/microblaze/kernel/entry.S index ca15bc5c744..66e34a3bfe1 100644 --- a/arch/microblaze/kernel/entry.S +++ b/arch/microblaze/kernel/entry.S @@ -468,7 +468,7 @@ C_ENTRY(sys_fork_wrapper): addi r5, r0, SIGCHLD /* Arg 0: flags */ lwi r6, r1, PT_R1 /* Arg 1: child SP (use parent's) */ addik r7, r1, 0 /* Arg 2: parent context */ - add r8. r0, r0 /* Arg 3: (unused) */ + add r8, r0, r0 /* Arg 3: (unused) */ add r9, r0, r0; /* Arg 4: (unused) */ brid do_fork /* Do real work (tail-call) */ add r10, r0, r0; /* Arg 5: (unused) */ -- cgit v1.2.3 From f3aef2510e2bb28cdbf32e5f3b8f04f03336ac81 Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Thu, 5 Jan 2012 10:27:08 +0100 Subject: microblaze: Wire-up new system calls Wire up three system calls sendmmsg/process_vm_readv/process_vm_writev All tested by testing apps. Look at: net: Add sendmmsg socket system call (sha1: 228e548e602061b08ee8e8966f567c12aa079682) Cross Memory Attach (sha1: fcf634098c00dd9cd247447368495f0b79be12d1) Signed-off-by: Michal Simek --- arch/microblaze/include/asm/unistd.h | 5 ++++- arch/microblaze/kernel/syscall_table.S | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'arch/microblaze/kernel') diff --git a/arch/microblaze/include/asm/unistd.h b/arch/microblaze/include/asm/unistd.h index 7d7092b917a..d20ffbc86be 100644 --- a/arch/microblaze/include/asm/unistd.h +++ b/arch/microblaze/include/asm/unistd.h @@ -391,8 +391,11 @@ #define __NR_clock_adjtime 373 #define __NR_syncfs 374 #define __NR_setns 375 +#define __NR_sendmmsg 376 +#define __NR_process_vm_readv 377 +#define __NR_process_vm_writev 378 -#define __NR_syscalls 376 +#define __NR_syscalls 379 #ifdef __KERNEL__ #ifndef __ASSEMBLY__ diff --git a/arch/microblaze/kernel/syscall_table.S b/arch/microblaze/kernel/syscall_table.S index 8789daa2a34..6a2b294ef6d 100644 --- a/arch/microblaze/kernel/syscall_table.S +++ b/arch/microblaze/kernel/syscall_table.S @@ -380,3 +380,6 @@ ENTRY(sys_call_table) .long sys_clock_adjtime .long sys_syncfs .long sys_setns /* 375 */ + .long sys_sendmmsg + .long sys_process_vm_readv + .long sys_process_vm_writev -- cgit v1.2.3