From dfd3b596fbbfa48b8e7966ef996d587157554b69 Mon Sep 17 00:00:00 2001 From: Nobuhiro Iwamatsu Date: Fri, 4 Nov 2011 22:13:50 +0900 Subject: [PATCH 1/8] sh: Fix cached/uncaced address calculation in 29bit mode In the case of 29bit mode, CAC/UNCAC_ADDR does not return a right address. This revises this problem by using P1SEGADDR and P2SEGADDR in 29bit mode. Reported-by: Yutaro Ebihara Signed-off-by: Nobuhiro Iwamatsu Tested-by: Kuninori Morimoto Tested-by: Simon Horman Cc: stable@kernel.org Signed-off-by: Paul Mundt --- arch/sh/include/asm/page.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/sh/include/asm/page.h b/arch/sh/include/asm/page.h index 0dca9a5c6be6..15d970328f71 100644 --- a/arch/sh/include/asm/page.h +++ b/arch/sh/include/asm/page.h @@ -151,8 +151,13 @@ typedef struct page *pgtable_t; #endif /* !__ASSEMBLY__ */ #ifdef CONFIG_UNCACHED_MAPPING +#if defined(CONFIG_29BIT) +#define UNCAC_ADDR(addr) P2SEGADDR(addr) +#define CAC_ADDR(addr) P1SEGADDR(addr) +#else #define UNCAC_ADDR(addr) ((addr) - PAGE_OFFSET + uncached_start) #define CAC_ADDR(addr) ((addr) - uncached_start + PAGE_OFFSET) +#endif #else #define UNCAC_ADDR(addr) ((addr)) #define CAC_ADDR(addr) ((addr)) From 3af1f8a41feab47b232b0c3d3b2322426672480d Mon Sep 17 00:00:00 2001 From: Phil Edworthy Date: Mon, 3 Oct 2011 15:16:47 +0100 Subject: [PATCH 2/8] serial: sh-sci: Fix up SH-2A SCIF support. This fixes up support for SH-2(A) SCIFs by introducing a new regtype. As expected, it's close to the SH-4A SCIF with fifodata, but still different enough to warrant its own type. Fixes up a number of FIFO overflows and similar for both SH7203/SH7264. Signed-off-by: Phil Edworthy Tested-by: Federico Fuga Signed-off-by: Paul Mundt --- arch/sh/kernel/cpu/sh2a/setup-sh7203.c | 16 ++++++++++++---- drivers/tty/serial/sh-sci.c | 19 +++++++++++++++++++ include/linux/serial_sci.h | 1 + 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/arch/sh/kernel/cpu/sh2a/setup-sh7203.c b/arch/sh/kernel/cpu/sh2a/setup-sh7203.c index a43124e608c3..0bd744f9a3b7 100644 --- a/arch/sh/kernel/cpu/sh2a/setup-sh7203.c +++ b/arch/sh/kernel/cpu/sh2a/setup-sh7203.c @@ -176,10 +176,12 @@ static DECLARE_INTC_DESC(intc_desc, "sh7203", vectors, groups, static struct plat_sci_port scif0_platform_data = { .mapbase = 0xfffe8000, .flags = UPF_BOOT_AUTOCONF, - .scscr = SCSCR_RE | SCSCR_TE | SCSCR_REIE, + .scscr = SCSCR_RIE | SCSCR_TIE | SCSCR_RE | SCSCR_TE | + SCSCR_REIE, .scbrr_algo_id = SCBRR_ALGO_2, .type = PORT_SCIF, .irqs = { 192, 192, 192, 192 }, + .regtype = SCIx_SH2_SCIF_FIFODATA_REGTYPE, }; static struct platform_device scif0_device = { @@ -193,10 +195,12 @@ static struct platform_device scif0_device = { static struct plat_sci_port scif1_platform_data = { .mapbase = 0xfffe8800, .flags = UPF_BOOT_AUTOCONF, - .scscr = SCSCR_RE | SCSCR_TE | SCSCR_REIE, + .scscr = SCSCR_RIE | SCSCR_TIE | SCSCR_RE | SCSCR_TE | + SCSCR_REIE, .scbrr_algo_id = SCBRR_ALGO_2, .type = PORT_SCIF, .irqs = { 196, 196, 196, 196 }, + .regtype = SCIx_SH2_SCIF_FIFODATA_REGTYPE, }; static struct platform_device scif1_device = { @@ -210,10 +214,12 @@ static struct platform_device scif1_device = { static struct plat_sci_port scif2_platform_data = { .mapbase = 0xfffe9000, .flags = UPF_BOOT_AUTOCONF, - .scscr = SCSCR_RE | SCSCR_TE | SCSCR_REIE, + .scscr = SCSCR_RIE | SCSCR_TIE | SCSCR_RE | SCSCR_TE | + SCSCR_REIE, .scbrr_algo_id = SCBRR_ALGO_2, .type = PORT_SCIF, .irqs = { 200, 200, 200, 200 }, + .regtype = SCIx_SH2_SCIF_FIFODATA_REGTYPE, }; static struct platform_device scif2_device = { @@ -227,10 +233,12 @@ static struct platform_device scif2_device = { static struct plat_sci_port scif3_platform_data = { .mapbase = 0xfffe9800, .flags = UPF_BOOT_AUTOCONF, - .scscr = SCSCR_RE | SCSCR_TE | SCSCR_REIE, + .scscr = SCSCR_RIE | SCSCR_TIE | SCSCR_RE | SCSCR_TE | + SCSCR_REIE, .scbrr_algo_id = SCBRR_ALGO_2, .type = PORT_SCIF, .irqs = { 204, 204, 204, 204 }, + .regtype = SCIx_SH2_SCIF_FIFODATA_REGTYPE, }; static struct platform_device scif3_device = { diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c index 9871c57b348e..1b6ec568f32a 100644 --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c @@ -206,6 +206,25 @@ static struct plat_sci_reg sci_regmap[SCIx_NR_REGTYPES][SCIx_NR_REGS] = { [SCLSR] = sci_reg_invalid, }, + /* + * Common SH-2(A) SCIF definitions for ports with FIFO data + * count registers. + */ + [SCIx_SH2_SCIF_FIFODATA_REGTYPE] = { + [SCSMR] = { 0x00, 16 }, + [SCBRR] = { 0x04, 8 }, + [SCSCR] = { 0x08, 16 }, + [SCxTDR] = { 0x0c, 8 }, + [SCxSR] = { 0x10, 16 }, + [SCxRDR] = { 0x14, 8 }, + [SCFCR] = { 0x18, 16 }, + [SCFDR] = { 0x1c, 16 }, + [SCTFDR] = sci_reg_invalid, + [SCRFDR] = sci_reg_invalid, + [SCSPTR] = { 0x20, 16 }, + [SCLSR] = { 0x24, 16 }, + }, + /* * Common SH-3 SCIF definitions. */ diff --git a/include/linux/serial_sci.h b/include/linux/serial_sci.h index 8bffe9ae2ca0..5f3939c67dd8 100644 --- a/include/linux/serial_sci.h +++ b/include/linux/serial_sci.h @@ -67,6 +67,7 @@ enum { SCIx_IRDA_REGTYPE, SCIx_SCIFA_REGTYPE, SCIx_SCIFB_REGTYPE, + SCIx_SH2_SCIF_FIFODATA_REGTYPE, SCIx_SH3_SCIF_REGTYPE, SCIx_SH4_SCIF_REGTYPE, SCIx_SH4_SCIF_NO_SCSPTR_REGTYPE, From dd2c0ca1b153b555c09fd8e08f6842e12cf8e87b Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 19 Sep 2011 18:51:13 -0700 Subject: [PATCH 3/8] sh: clkfwk: add clk_rate_mult_range_round() This provides a clk_rate_mult_range_round() helper for use by some of the CPG PLL ranged multipliers, following the same approach as used by the div ranges. Signed-off-by: Kuninori Morimoto Signed-off-by: Paul Mundt --- drivers/sh/clk/core.c | 20 ++++++++++++++++++++ include/linux/sh_clk.h | 3 +++ 2 files changed, 23 insertions(+) diff --git a/drivers/sh/clk/core.c b/drivers/sh/clk/core.c index dc8d022c07a1..352036b1f9a2 100644 --- a/drivers/sh/clk/core.c +++ b/drivers/sh/clk/core.c @@ -173,6 +173,26 @@ long clk_rate_div_range_round(struct clk *clk, unsigned int div_min, return clk_rate_round_helper(&div_range_round); } +static long clk_rate_mult_range_iter(unsigned int pos, + struct clk_rate_round_data *rounder) +{ + return clk_get_rate(rounder->arg) * pos; +} + +long clk_rate_mult_range_round(struct clk *clk, unsigned int mult_min, + unsigned int mult_max, unsigned long rate) +{ + struct clk_rate_round_data mult_range_round = { + .min = mult_min, + .max = mult_max, + .func = clk_rate_mult_range_iter, + .arg = clk_get_parent(clk), + .rate = rate, + }; + + return clk_rate_round_helper(&mult_range_round); +} + int clk_rate_table_find(struct clk *clk, struct cpufreq_frequency_table *freq_table, unsigned long rate) diff --git a/include/linux/sh_clk.h b/include/linux/sh_clk.h index 3ccf18648d0a..9237c299641c 100644 --- a/include/linux/sh_clk.h +++ b/include/linux/sh_clk.h @@ -94,6 +94,9 @@ int clk_rate_table_find(struct clk *clk, long clk_rate_div_range_round(struct clk *clk, unsigned int div_min, unsigned int div_max, unsigned long rate); +long clk_rate_mult_range_round(struct clk *clk, unsigned int mult_min, + unsigned int mult_max, unsigned long rate); + long clk_round_parent(struct clk *clk, unsigned long target, unsigned long *best_freq, unsigned long *parent_freq, unsigned int div_min, unsigned int div_max); From 149c370f3e06a6b43bf1d922ccd1f969c59c7c77 Mon Sep 17 00:00:00 2001 From: Paul Mundt Date: Mon, 7 Nov 2011 14:40:45 +0900 Subject: [PATCH 4/8] sh: Wire up process_vm syscalls. Signed-off-by: Paul Mundt --- arch/sh/include/asm/unistd_32.h | 4 +++- arch/sh/include/asm/unistd_64.h | 4 +++- arch/sh/kernel/syscalls_32.S | 2 ++ arch/sh/kernel/syscalls_64.S | 2 ++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/arch/sh/include/asm/unistd_32.h b/arch/sh/include/asm/unistd_32.h index 3432008d2888..152b8627a184 100644 --- a/arch/sh/include/asm/unistd_32.h +++ b/arch/sh/include/asm/unistd_32.h @@ -375,8 +375,10 @@ #define __NR_syncfs 362 #define __NR_sendmmsg 363 #define __NR_setns 364 +#define __NR_process_vm_readv 365 +#define __NR_process_vm_writev 366 -#define NR_syscalls 365 +#define NR_syscalls 367 #ifdef __KERNEL__ diff --git a/arch/sh/include/asm/unistd_64.h b/arch/sh/include/asm/unistd_64.h index ec9898665f23..c330c23db5a0 100644 --- a/arch/sh/include/asm/unistd_64.h +++ b/arch/sh/include/asm/unistd_64.h @@ -396,10 +396,12 @@ #define __NR_syncfs 373 #define __NR_sendmmsg 374 #define __NR_setns 375 +#define __NR_process_vm_readv 376 +#define __NR_process_vm_writev 377 #ifdef __KERNEL__ -#define NR_syscalls 376 +#define NR_syscalls 378 #define __ARCH_WANT_IPC_PARSE_VERSION #define __ARCH_WANT_OLD_READDIR diff --git a/arch/sh/kernel/syscalls_32.S b/arch/sh/kernel/syscalls_32.S index 293e39c59c00..ee56a9b1a981 100644 --- a/arch/sh/kernel/syscalls_32.S +++ b/arch/sh/kernel/syscalls_32.S @@ -382,3 +382,5 @@ ENTRY(sys_call_table) .long sys_syncfs .long sys_sendmmsg .long sys_setns + .long sys_process_vm_readv /* 365 */ + .long sys_process_vm_writev diff --git a/arch/sh/kernel/syscalls_64.S b/arch/sh/kernel/syscalls_64.S index ceb34b94afa9..9af7de26fb71 100644 --- a/arch/sh/kernel/syscalls_64.S +++ b/arch/sh/kernel/syscalls_64.S @@ -402,3 +402,5 @@ sys_call_table: .long sys_syncfs .long sys_sendmmsg .long sys_setns /* 375 */ + .long sys_process_vm_readv + .long sys_process_vm_writev From 750a7eee7395492960a7aeb3a3a1aa74158ec326 Mon Sep 17 00:00:00 2001 From: Paul Mundt Date: Fri, 11 Nov 2011 15:41:50 +0900 Subject: [PATCH 5/8] drivers: sh: Generalize runtime PM platform stub. The runtime PM platform support stub in use by ARM-based SH/R-Mobile platforms contains nothing that's specifically ARM-related and instead of wholly generic to anything using the clock framework. The recent runtime PM changes interact rather badly with the lazy disabling of clocks late in the boot process through the clock framework, leading to situations where the runtime suspend/resume paths are entered without a clock being actively driven due to having been lazily gated off. In order to correct this we can trivially tie in the aforementioned stub as a general fallback for all SH platforms that don't presently have their own runtime PM implementations (the corner case being SH-based SH-Mobile platforms, which have their own stub through the hwblk API -- which in turn has bitrotted and will be subsequently adapted to use the same stub as everyone else), regardless of whether the platforms choose to define power domains of their own or not. This fixes up regressions for clock framework users who also build in runtime PM support without any specific power domains of their own, which was previously causing the serial console to be lost when warring with lazy clock disabling. Signed-off-by: Paul Mundt --- arch/arm/mach-shmobile/Makefile | 2 +- drivers/sh/Makefile | 8 ++++++++ {arch/arm/mach-shmobile => drivers/sh}/pm_runtime.c | 0 3 files changed, 9 insertions(+), 1 deletion(-) rename {arch/arm/mach-shmobile => drivers/sh}/pm_runtime.c (100%) diff --git a/arch/arm/mach-shmobile/Makefile b/arch/arm/mach-shmobile/Makefile index 2aec2f732515..737bdc631b0d 100644 --- a/arch/arm/mach-shmobile/Makefile +++ b/arch/arm/mach-shmobile/Makefile @@ -3,7 +3,7 @@ # # Common objects -obj-y := timer.o console.o clock.o pm_runtime.o +obj-y := timer.o console.o clock.o # CPU objects obj-$(CONFIG_ARCH_SH7367) += setup-sh7367.o clock-sh7367.o intc-sh7367.o diff --git a/drivers/sh/Makefile b/drivers/sh/Makefile index 24e6cec0ae8d..67e272ab1623 100644 --- a/drivers/sh/Makefile +++ b/drivers/sh/Makefile @@ -7,3 +7,11 @@ obj-$(CONFIG_HAVE_CLK) += clk/ obj-$(CONFIG_MAPLE) += maple/ obj-$(CONFIG_SUPERHYWAY) += superhyway/ obj-$(CONFIG_GENERIC_GPIO) += pfc.o + +# +# For the moment we only use this framework for ARM-based SH/R-Mobile +# platforms and generic SH. SH-based SH-Mobile platforms are still using +# an older framework that is pending up-porting, at which point this +# special casing can go away. +# +obj-$(CONFIG_SUPERH)$(CONFIG_ARCH_SHMOBILE) += pm_runtime.o diff --git a/arch/arm/mach-shmobile/pm_runtime.c b/drivers/sh/pm_runtime.c similarity index 100% rename from arch/arm/mach-shmobile/pm_runtime.c rename to drivers/sh/pm_runtime.c From d03299ee6020b0cc64fc4180162fb2e8795394e1 Mon Sep 17 00:00:00 2001 From: Paul Mundt Date: Fri, 11 Nov 2011 15:58:50 +0900 Subject: [PATCH 6/8] drivers: sh: Kill off dead pathname for runtime PM stub. Signed-off-by: Paul Mundt --- drivers/sh/pm_runtime.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/sh/pm_runtime.c b/drivers/sh/pm_runtime.c index bd5c6a3b8c55..afe9282629b9 100644 --- a/drivers/sh/pm_runtime.c +++ b/drivers/sh/pm_runtime.c @@ -1,7 +1,5 @@ /* - * arch/arm/mach-shmobile/pm_runtime.c - * - * Runtime PM support code for SuperH Mobile ARM + * Runtime PM support code * * Copyright (C) 2009-2010 Magnus Damm * From 79e7066415a8b12adbeacc41b3dc44423534b8be Mon Sep 17 00:00:00 2001 From: Paul Mundt Date: Fri, 11 Nov 2011 16:11:41 +0900 Subject: [PATCH 7/8] sh: clkfwk: Kill off remaining debugfs cruft. Now that all of the named string association with clocks has been migrated to clkdev lookups there's no meaningful named topology that can be constructed for a debugfs tree view. Get rid of the left over bits, and shrink struct clk a bit in the process. Signed-off-by: Paul Mundt --- drivers/sh/clk/core.c | 87 ------------------------------------------ include/linux/sh_clk.h | 1 - 2 files changed, 88 deletions(-) diff --git a/drivers/sh/clk/core.c b/drivers/sh/clk/core.c index 352036b1f9a2..db257a35e71a 100644 --- a/drivers/sh/clk/core.c +++ b/drivers/sh/clk/core.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include @@ -225,9 +224,6 @@ int clk_reparent(struct clk *child, struct clk *parent) list_add(&child->sibling, &parent->children); child->parent = parent; - /* now do the debugfs renaming to reattach the child - to the proper parent */ - return 0; } @@ -685,89 +681,6 @@ static int __init clk_syscore_init(void) subsys_initcall(clk_syscore_init); #endif -/* - * debugfs support to trace clock tree hierarchy and attributes - */ -static struct dentry *clk_debugfs_root; - -static int clk_debugfs_register_one(struct clk *c) -{ - int err; - struct dentry *d; - struct clk *pa = c->parent; - char s[255]; - char *p = s; - - p += sprintf(p, "%p", c); - d = debugfs_create_dir(s, pa ? pa->dentry : clk_debugfs_root); - if (!d) - return -ENOMEM; - c->dentry = d; - - d = debugfs_create_u8("usecount", S_IRUGO, c->dentry, (u8 *)&c->usecount); - if (!d) { - err = -ENOMEM; - goto err_out; - } - d = debugfs_create_u32("rate", S_IRUGO, c->dentry, (u32 *)&c->rate); - if (!d) { - err = -ENOMEM; - goto err_out; - } - d = debugfs_create_x32("flags", S_IRUGO, c->dentry, (u32 *)&c->flags); - if (!d) { - err = -ENOMEM; - goto err_out; - } - return 0; - -err_out: - debugfs_remove_recursive(c->dentry); - return err; -} - -static int clk_debugfs_register(struct clk *c) -{ - int err; - struct clk *pa = c->parent; - - if (pa && !pa->dentry) { - err = clk_debugfs_register(pa); - if (err) - return err; - } - - if (!c->dentry) { - err = clk_debugfs_register_one(c); - if (err) - return err; - } - return 0; -} - -static int __init clk_debugfs_init(void) -{ - struct clk *c; - struct dentry *d; - int err; - - d = debugfs_create_dir("clock", NULL); - if (!d) - return -ENOMEM; - clk_debugfs_root = d; - - list_for_each_entry(c, &clock_list, node) { - err = clk_debugfs_register(c); - if (err) - goto err_out; - } - return 0; -err_out: - debugfs_remove_recursive(clk_debugfs_root); - return err; -} -late_initcall(clk_debugfs_init); - static int __init clk_late_init(void) { unsigned long flags; diff --git a/include/linux/sh_clk.h b/include/linux/sh_clk.h index 9237c299641c..a20831cf336a 100644 --- a/include/linux/sh_clk.h +++ b/include/linux/sh_clk.h @@ -52,7 +52,6 @@ struct clk { unsigned long arch_flags; void *priv; - struct dentry *dentry; struct clk_mapping *mapping; struct cpufreq_frequency_table *freq_table; unsigned int nr_freqs; From ab4f75cd0a9f5ffdcc3d9fc2b29ca14525215b78 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Thu, 10 Nov 2011 18:43:16 -0800 Subject: [PATCH 8/8] mailmap: Fix up some renesas attributions This adds in entries for both Goda and Morimoto-san who have previously used different conventions. Cc: Yusuke Goda Signed-off-by: Kuninori Morimoto Signed-off-by: Paul Mundt --- .mailmap | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.mailmap b/.mailmap index a4806f0de852..9b0d0267a3c3 100644 --- a/.mailmap +++ b/.mailmap @@ -68,6 +68,7 @@ Juha Yrjola Kay Sievers Kenneth W Chen Koushik +Kuninori Morimoto Leonid I Ananiev Linas Vepstas Mark Brown @@ -111,3 +112,4 @@ Uwe Kleine-König Uwe Kleine-König Valdis Kletnieks Takashi YOSHII +Yusuke Goda