From e8708ef7e86a463b3a5b01d4a9abf16c8748b464 Mon Sep 17 00:00:00 2001 From: Markus Pietrek Date: Tue, 2 Feb 2010 11:29:15 +0900 Subject: [PATCH 1/4] spi: spi_sh_msiof: Fixed data sampling on the correct edge The spi_sh_msiof.c driver presently misconfigures REDG and TEDG. TEDG==0 outputs data at the **rising edge** of the clock and REDG==0 samples data at the **falling edge** of the clock. Therefore for SPI, TEDG must be equal to REDG, otherwise the last byte received is not sampled in SPI mode 3. This brings the driver in line with the SH7723 HW Reference Manual settings documented in Figures 20.20 and 20.21 ("SPI Clock and data timing"). Signed-off-by: Markus Pietrek Acked-by: Magnus Damm Signed-off-by: Paul Mundt --- drivers/spi/spi_sh_msiof.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/drivers/spi/spi_sh_msiof.c b/drivers/spi/spi_sh_msiof.c index 51e5e1dfa6e5..30973ec16a93 100644 --- a/drivers/spi/spi_sh_msiof.c +++ b/drivers/spi/spi_sh_msiof.c @@ -173,15 +173,12 @@ static void sh_msiof_spi_set_pin_regs(struct sh_msiof_spi_priv *p, int edge; /* - * CPOL CPHA TSCKIZ RSCKIZ TEDG REDG(!) - * 0 0 10 10 1 0 - * 0 1 10 10 0 1 - * 1 0 11 11 0 1 - * 1 1 11 11 1 0 - * - * (!) Note: REDG is inverted recommended data sheet setting + * CPOL CPHA TSCKIZ RSCKIZ TEDG REDG + * 0 0 10 10 1 1 + * 0 1 10 10 0 0 + * 1 0 11 11 0 0 + * 1 1 11 11 1 1 */ - sh_msiof_write(p, FCTR, 0); sh_msiof_write(p, TMDR1, 0xe2000005 | (lsb_first << 24)); sh_msiof_write(p, RMDR1, 0x22000005 | (lsb_first << 24)); @@ -193,7 +190,7 @@ static void sh_msiof_spi_set_pin_regs(struct sh_msiof_spi_priv *p, edge = cpol ? cpha : !cpha; tmp |= edge << 27; /* TEDG */ - tmp |= !edge << 26; /* REDG */ + tmp |= edge << 26; /* REDG */ tmp |= (tx_hi_z ? 2 : 0) << 22; /* TXDIZ */ sh_msiof_write(p, CTR, tmp); } From e5ff15bec96ba18698dae5de0bbf7e6a0653ca65 Mon Sep 17 00:00:00 2001 From: Magnus Damm Date: Wed, 27 Jan 2010 07:41:19 +0000 Subject: [PATCH 2/4] usb: r8a66597-hdc disable interrupts fix This patch improves disable_controller() in the r8a66597-hdc driver to disable all interrupts and clear status flags. It also makes sure that disable_controller() is called during probe(). This fixes the relatively rare case of unexpected pending interrupts after kexec reboot. Signed-off-by: Magnus Damm Acked-by: Yoshihiro Shimoda Signed-off-by: Paul Mundt --- drivers/usb/host/r8a66597-hcd.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/usb/host/r8a66597-hcd.c b/drivers/usb/host/r8a66597-hcd.c index b7a661c02bcd..0ceec123ddfd 100644 --- a/drivers/usb/host/r8a66597-hcd.c +++ b/drivers/usb/host/r8a66597-hcd.c @@ -216,8 +216,17 @@ static void disable_controller(struct r8a66597 *r8a66597) { int port; + /* disable interrupts */ r8a66597_write(r8a66597, 0, INTENB0); - r8a66597_write(r8a66597, 0, INTSTS0); + r8a66597_write(r8a66597, 0, INTENB1); + r8a66597_write(r8a66597, 0, BRDYENB); + r8a66597_write(r8a66597, 0, BEMPENB); + r8a66597_write(r8a66597, 0, NRDYENB); + + /* clear status */ + r8a66597_write(r8a66597, 0, BRDYSTS); + r8a66597_write(r8a66597, 0, NRDYSTS); + r8a66597_write(r8a66597, 0, BEMPSTS); for (port = 0; port < r8a66597->max_root_hub; port++) r8a66597_disable_port(r8a66597, port); @@ -2466,6 +2475,12 @@ static int __devinit r8a66597_probe(struct platform_device *pdev) r8a66597->rh_timer.data = (unsigned long)r8a66597; r8a66597->reg = (unsigned long)reg; + /* make sure no interrupts are pending */ + ret = r8a66597_clock_enable(r8a66597); + if (ret < 0) + goto clean_up3; + disable_controller(r8a66597); + for (i = 0; i < R8A66597_MAX_NUM_PIPE; i++) { INIT_LIST_HEAD(&r8a66597->pipe_queue[i]); init_timer(&r8a66597->td_timer[i]); From 00b3e0a2e059f0601feb537b995b0b4de531b543 Mon Sep 17 00:00:00 2001 From: Marek Skuczynski Date: Sat, 30 Jan 2010 22:27:41 +0100 Subject: [PATCH 3/4] sh: Fix access to released memory in dwarf_unwinder_cleanup() Signed-off-by: Marek Skuczynski Acked-by: Matt Fleming Signed-off-by: Paul Mundt --- arch/sh/kernel/dwarf.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/sh/kernel/dwarf.c b/arch/sh/kernel/dwarf.c index 3576b709f052..88d28ec3780a 100644 --- a/arch/sh/kernel/dwarf.c +++ b/arch/sh/kernel/dwarf.c @@ -892,18 +892,18 @@ static struct unwinder dwarf_unwinder = { static void dwarf_unwinder_cleanup(void) { - struct dwarf_cie *cie; - struct dwarf_fde *fde; + struct dwarf_cie *cie, *cie_tmp; + struct dwarf_fde *fde, *fde_tmp; /* * Deallocate all the memory allocated for the DWARF unwinder. * Traverse all the FDE/CIE lists and remove and free all the * memory associated with those data structures. */ - list_for_each_entry(cie, &dwarf_cie_list, link) + list_for_each_entry_safe(cie, cie_tmp, &dwarf_cie_list, link) kfree(cie); - list_for_each_entry(fde, &dwarf_fde_list, link) + list_for_each_entry_safe(fde, fde_tmp, &dwarf_fde_list, link) kfree(fde); kmem_cache_destroy(dwarf_reg_cachep); From bc10e875d4aeaa93a0d418d8b4346b72f5067ea0 Mon Sep 17 00:00:00 2001 From: Marek Skuczynski Date: Sat, 30 Jan 2010 22:29:32 +0100 Subject: [PATCH 4/4] sh: Fix access to released memory in clk_debugfs_register_one() Signed-off-by: Marek Skuczynski Signed-off-by: Paul Mundt --- arch/sh/kernel/cpu/clock.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/sh/kernel/cpu/clock.c b/arch/sh/kernel/cpu/clock.c index f3a46be2ae81..83da5debeedf 100644 --- a/arch/sh/kernel/cpu/clock.c +++ b/arch/sh/kernel/cpu/clock.c @@ -598,7 +598,7 @@ static struct dentry *clk_debugfs_root; static int clk_debugfs_register_one(struct clk *c) { int err; - struct dentry *d, *child; + struct dentry *d, *child, *child_tmp; struct clk *pa = c->parent; char s[255]; char *p = s; @@ -630,7 +630,7 @@ static int clk_debugfs_register_one(struct clk *c) err_out: d = c->dentry; - list_for_each_entry(child, &d->d_subdirs, d_u.d_child) + list_for_each_entry_safe(child, child_tmp, &d->d_subdirs, d_u.d_child) debugfs_remove(child); debugfs_remove(c->dentry); return err;