aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/sh/clk/cpg.c38
-rw-r--r--include/linux/sh_clk.h34
2 files changed, 58 insertions, 14 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
diff --git a/include/linux/sh_clk.h b/include/linux/sh_clk.h
index 0a9d8f2ac519..c513b73cd7cb 100644
--- a/include/linux/sh_clk.h
+++ b/include/linux/sh_clk.h
@@ -59,7 +59,15 @@ struct clk {
59 unsigned int nr_freqs; 59 unsigned int nr_freqs;
60}; 60};
61 61
62#define CLK_ENABLE_ON_INIT (1 << 0) 62#define CLK_ENABLE_ON_INIT BIT(0)
63
64#define CLK_ENABLE_REG_32BIT BIT(1) /* default access size */
65#define CLK_ENABLE_REG_16BIT BIT(2)
66#define CLK_ENABLE_REG_8BIT BIT(3)
67
68#define CLK_ENABLE_REG_MASK (CLK_ENABLE_REG_32BIT | \
69 CLK_ENABLE_REG_16BIT | \
70 CLK_ENABLE_REG_8BIT)
63 71
64/* drivers/sh/clk.c */ 72/* drivers/sh/clk.c */
65unsigned long followparent_recalc(struct clk *); 73unsigned long followparent_recalc(struct clk *);
@@ -102,7 +110,7 @@ long clk_round_parent(struct clk *clk, unsigned long target,
102 unsigned long *best_freq, unsigned long *parent_freq, 110 unsigned long *best_freq, unsigned long *parent_freq,
103 unsigned int div_min, unsigned int div_max); 111 unsigned int div_min, unsigned int div_max);
104 112
105#define SH_CLK_MSTP32(_parent, _enable_reg, _enable_bit, _flags) \ 113#define SH_CLK_MSTP(_parent, _enable_reg, _enable_bit, _flags) \
106{ \ 114{ \
107 .parent = _parent, \ 115 .parent = _parent, \
108 .enable_reg = (void __iomem *)_enable_reg, \ 116 .enable_reg = (void __iomem *)_enable_reg, \
@@ -110,7 +118,27 @@ long clk_round_parent(struct clk *clk, unsigned long target,
110 .flags = _flags, \ 118 .flags = _flags, \
111} 119}
112 120
113int sh_clk_mstp32_register(struct clk *clks, int nr); 121#define SH_CLK_MSTP32(_p, _r, _b, _f) \
122 SH_CLK_MSTP(_p, _r, _b, _f | CLK_ENABLE_REG_32BIT)
123
124#define SH_CLK_MSTP16(_p, _r, _b, _f) \
125 SH_CLK_MSTP(_p, _r, _b, _f | CLK_ENABLE_REG_16BIT)
126
127#define SH_CLK_MSTP8(_p, _r, _b, _f) \
128 SH_CLK_MSTP(_p, _r, _b, _f | CLK_ENABLE_REG_8BIT)
129
130int sh_clk_mstp_register(struct clk *clks, int nr);
131
132/*
133 * MSTP registration never really cared about access size, despite the
134 * original enable/disable pairs assuming a 32-bit access. Clocks are
135 * responsible for defining their access sizes either directly or via the
136 * clock definition wrappers.
137 */
138static inline int __deprecated sh_clk_mstp32_register(struct clk *clks, int nr)
139{
140 return sh_clk_mstp_register(clks, nr);
141}
114 142
115#define SH_CLK_DIV4(_parent, _reg, _shift, _div_bitmap, _flags) \ 143#define SH_CLK_DIV4(_parent, _reg, _shift, _div_bitmap, _flags) \
116{ \ 144{ \