aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/thermal/rcar_thermal.c
diff options
context:
space:
mode:
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>2013-01-31 04:03:46 -0500
committerZhang Rui <rui.zhang@intel.com>2013-02-06 01:13:58 -0500
commite9137a582fcbe36d9dedb8d7f6902a059154b14e (patch)
tree51a0666340c10e2f3a3fc8cba6fc08a2bd8f22cb /drivers/thermal/rcar_thermal.c
parent3676d1dd3d3069ca70b8075c0e86482cbaa01c2f (diff)
thermal: rcar: add read/write functions for common/priv data
R-Car thermal driver will use struct common in next feature (interrupt support). But the register address is different between struct priv and common. This patch adds read/write functions for struct common, and use macro technique to avoid wrong register access. This is preparation patch for next feature (interrupt support), therefore, there is no user to use this common read/write function at this point. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Diffstat (limited to 'drivers/thermal/rcar_thermal.c')
-rw-r--r--drivers/thermal/rcar_thermal.c48
1 files changed, 41 insertions, 7 deletions
diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c
index 1ba02770153a..cf6aa98956b9 100644
--- a/drivers/thermal/rcar_thermal.c
+++ b/drivers/thermal/rcar_thermal.c
@@ -29,8 +29,8 @@
29 29
30#define IDLE_INTERVAL 5000 30#define IDLE_INTERVAL 5000
31 31
32#define THSCR 0x2c 32#define REG_THSCR 0x2c
33#define THSSR 0x30 33#define REG_THSSR 0x30
34 34
35/* THSCR */ 35/* THSCR */
36#define CPCTL (1 << 12) 36#define CPCTL (1 << 12)
@@ -63,21 +63,55 @@ struct rcar_thermal_priv {
63/* 63/*
64 * basic functions 64 * basic functions
65 */ 65 */
66static u32 rcar_thermal_read(struct rcar_thermal_priv *priv, u32 reg) 66#if 0
67#define rcar_thermal_common_read(c, r) \
68 _rcar_thermal_common_read(c, COMMON_ ##r)
69static u32 _rcar_thermal_common_read(struct rcar_thermal_common *common,
70 u32 reg)
71{
72 return ioread32(common->base + reg);
73}
74
75#define rcar_thermal_common_write(c, r, d) \
76 _rcar_thermal_common_write(c, COMMON_ ##r, d)
77static void _rcar_thermal_common_write(struct rcar_thermal_common *common,
78 u32 reg, u32 data)
79{
80 iowrite32(data, common->base + reg);
81}
82
83#define rcar_thermal_common_bset(c, r, m, d) \
84 _rcar_thermal_common_bset(c, COMMON_ ##r, m, d)
85static void _rcar_thermal_common_bset(struct rcar_thermal_common *common,
86 u32 reg, u32 mask, u32 data)
87{
88 u32 val;
89
90 val = ioread32(common->base + reg);
91 val &= ~mask;
92 val |= (data & mask);
93 iowrite32(val, common->base + reg);
94}
95#endif
96
97#define rcar_thermal_read(p, r) _rcar_thermal_read(p, REG_ ##r)
98static u32 _rcar_thermal_read(struct rcar_thermal_priv *priv, u32 reg)
67{ 99{
68 return ioread32(priv->base + reg); 100 return ioread32(priv->base + reg);
69} 101}
70 102
71#if 0 /* no user at this point */ 103#if 0 /* no user at this point */
72static void rcar_thermal_write(struct rcar_thermal_priv *priv, 104#define rcar_thermal_write(p, r, d) _rcar_thermal_write(p, REG_ ##r, d)
73 u32 reg, u32 data) 105static void _rcar_thermal_write(struct rcar_thermal_priv *priv,
106 u32 reg, u32 data)
74{ 107{
75 iowrite32(data, priv->base + reg); 108 iowrite32(data, priv->base + reg);
76} 109}
77#endif 110#endif
78 111
79static void rcar_thermal_bset(struct rcar_thermal_priv *priv, u32 reg, 112#define rcar_thermal_bset(p, r, m, d) _rcar_thermal_bset(p, REG_ ##r, m, d)
80 u32 mask, u32 data) 113static void _rcar_thermal_bset(struct rcar_thermal_priv *priv, u32 reg,
114 u32 mask, u32 data)
81{ 115{
82 u32 val; 116 u32 val;
83 117