aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/sh/clk
diff options
context:
space:
mode:
authorPaul Mundt <lethal@linux-sh.org>2012-04-10 23:05:50 -0400
committerPaul Mundt <lethal@linux-sh.org>2012-04-10 23:05:50 -0400
commit4d6ddb08acc48368c5b7ac431f9d00db7227d2ed (patch)
tree5030162ef3c2f9954e43baf02cff7f8794a8ba74 /drivers/sh/clk
parenta9e1e53bcfb29b3b503a5e75ce498d9a64f32c1e (diff)
sh: clkfwk: Support variable size accesses for MSTP clocks.
The bulk of the MSTP users require 32-bit access, but this isn't the case for some of the SH-2A parts, so add in some basic infrastructure to let the CPU define its required access size in preparation. Requested-by: Phil Edworthy <phil.edworthy@renesas.com> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'drivers/sh/clk')
-rw-r--r--drivers/sh/clk/cpg.c38
1 files changed, 27 insertions, 11 deletions
diff --git a/drivers/sh/clk/cpg.c b/drivers/sh/clk/cpg.c
index 91b6d52f74eb..6cbda4841589 100644
--- a/drivers/sh/clk/cpg.c
+++ b/drivers/sh/clk/cpg.c
@@ -2,6 +2,7 @@
2 * Helper routines for SuperH Clock Pulse Generator blocks (CPG). 2 * Helper routines for SuperH Clock Pulse Generator blocks (CPG).
3 * 3 *
4 * Copyright (C) 2010 Magnus Damm 4 * Copyright (C) 2010 Magnus Damm
5 * Copyright (C) 2010 - 2012 Paul Mundt
5 * 6 *
6 * This file is subject to the terms and conditions of the GNU General Public 7 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive 8 * License. See the file "COPYING" in the main directory of this archive
@@ -13,26 +14,41 @@
13#include <linux/io.h> 14#include <linux/io.h>
14#include <linux/sh_clk.h> 15#include <linux/sh_clk.h>
15 16
16static int sh_clk_mstp32_enable(struct clk *clk) 17static int sh_clk_mstp_enable(struct clk *clk)
17{ 18{
18 iowrite32(ioread32(clk->mapped_reg) & ~(1 << clk->enable_bit), 19 if (clk->flags & CLK_ENABLE_REG_8BIT)
19 clk->mapped_reg); 20 iowrite8(ioread8(clk->mapped_reg) & ~(1 << clk->enable_bit),
21 clk->mapped_reg);
22 else if (clk->flags & CLK_ENABLE_REG_16BIT)
23 iowrite16(ioread16(clk->mapped_reg) & ~(1 << clk->enable_bit),
24 clk->mapped_reg);
25 else
26 iowrite32(ioread32(clk->mapped_reg) & ~(1 << clk->enable_bit),
27 clk->mapped_reg);
28
20 return 0; 29 return 0;
21} 30}
22 31
23static void sh_clk_mstp32_disable(struct clk *clk) 32static void sh_clk_mstp_disable(struct clk *clk)
24{ 33{
25 iowrite32(ioread32(clk->mapped_reg) | (1 << clk->enable_bit), 34 if (clk->flags & CLK_ENABLE_REG_8BIT)
26 clk->mapped_reg); 35 iowrite8(ioread8(clk->mapped_reg) | (1 << clk->enable_bit),
36 clk->mapped_reg);
37 else if (clk->flags & CLK_ENABLE_REG_16BIT)
38 iowrite16(ioread16(clk->mapped_reg) | (1 << clk->enable_bit),
39 clk->mapped_reg);
40 else
41 iowrite32(ioread32(clk->mapped_reg) | (1 << clk->enable_bit),
42 clk->mapped_reg);
27} 43}
28 44
29static struct sh_clk_ops sh_clk_mstp32_clk_ops = { 45static struct sh_clk_ops sh_clk_mstp_clk_ops = {
30 .enable = sh_clk_mstp32_enable, 46 .enable = sh_clk_mstp_enable,
31 .disable = sh_clk_mstp32_disable, 47 .disable = sh_clk_mstp_disable,
32 .recalc = followparent_recalc, 48 .recalc = followparent_recalc,
33}; 49};
34 50
35int __init sh_clk_mstp32_register(struct clk *clks, int nr) 51int __init sh_clk_mstp_register(struct clk *clks, int nr)
36{ 52{
37 struct clk *clkp; 53 struct clk *clkp;
38 int ret = 0; 54 int ret = 0;
@@ -40,7 +56,7 @@ int __init sh_clk_mstp32_register(struct clk *clks, int nr)
40 56
41 for (k = 0; !ret && (k < nr); k++) { 57 for (k = 0; !ret && (k < nr); k++) {
42 clkp = clks + k; 58 clkp = clks + k;
43 clkp->ops = &sh_clk_mstp32_clk_ops; 59 clkp->ops = &sh_clk_mstp_clk_ops;
44 ret |= clk_register(clkp); 60 ret |= clk_register(clkp);
45 } 61 }
46 62