diff options
author | Richard Zhao <richard.zhao@linaro.org> | 2012-05-12 21:18:02 -0400 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2012-05-20 11:27:07 -0400 |
commit | b09530ef844f0bf29ed3677080c02b179be84818 (patch) | |
tree | ed2d3e791823a3e394f0718815895aee37114bfe /drivers/mfd/anatop-mfd.c | |
parent | 08b4c118af35d4d67eca2052aaa8d4a5f7d0aecb (diff) |
mfd: Make anatop register accessor more flexible and rename meaningfully
- rename to anatop_read_reg and anatop_write_reg
- anatop_read_reg directly return reg value
- anatop_write_reg write reg with mask
Signed-off-by: Richard Zhao <richard.zhao@freescale.com>
Reviewed-by: Ying-Chun Liu (PaulLiu) <paul.liu@linaro.org>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/mfd/anatop-mfd.c')
-rw-r--r-- | drivers/mfd/anatop-mfd.c | 35 |
1 files changed, 11 insertions, 24 deletions
diff --git a/drivers/mfd/anatop-mfd.c b/drivers/mfd/anatop-mfd.c index 2af42480635e..6da06341f6c9 100644 --- a/drivers/mfd/anatop-mfd.c +++ b/drivers/mfd/anatop-mfd.c | |||
@@ -41,39 +41,26 @@ | |||
41 | #include <linux/of_address.h> | 41 | #include <linux/of_address.h> |
42 | #include <linux/mfd/anatop.h> | 42 | #include <linux/mfd/anatop.h> |
43 | 43 | ||
44 | u32 anatop_get_bits(struct anatop *adata, u32 addr, int bit_shift, | 44 | u32 anatop_read_reg(struct anatop *adata, u32 addr) |
45 | int bit_width) | ||
46 | { | 45 | { |
47 | u32 val, mask; | 46 | return readl(adata->ioreg + addr); |
48 | |||
49 | if (bit_width == 32) | ||
50 | mask = ~0; | ||
51 | else | ||
52 | mask = (1 << bit_width) - 1; | ||
53 | |||
54 | val = readl(adata->ioreg + addr); | ||
55 | val = (val >> bit_shift) & mask; | ||
56 | |||
57 | return val; | ||
58 | } | 47 | } |
59 | EXPORT_SYMBOL_GPL(anatop_get_bits); | 48 | EXPORT_SYMBOL_GPL(anatop_read_reg); |
60 | 49 | ||
61 | void anatop_set_bits(struct anatop *adata, u32 addr, int bit_shift, | 50 | void anatop_write_reg(struct anatop *adata, u32 addr, u32 data, u32 mask) |
62 | int bit_width, u32 data) | ||
63 | { | 51 | { |
64 | u32 val, mask; | 52 | u32 val; |
65 | 53 | ||
66 | if (bit_width == 32) | 54 | data &= mask; |
67 | mask = ~0; | ||
68 | else | ||
69 | mask = (1 << bit_width) - 1; | ||
70 | 55 | ||
71 | spin_lock(&adata->reglock); | 56 | spin_lock(&adata->reglock); |
72 | val = readl(adata->ioreg + addr) & ~(mask << bit_shift); | 57 | val = readl(adata->ioreg + addr); |
73 | writel((data << bit_shift) | val, adata->ioreg + addr); | 58 | val &= ~mask; |
59 | val |= data; | ||
60 | writel(val, adata->ioreg + addr); | ||
74 | spin_unlock(&adata->reglock); | 61 | spin_unlock(&adata->reglock); |
75 | } | 62 | } |
76 | EXPORT_SYMBOL_GPL(anatop_set_bits); | 63 | EXPORT_SYMBOL_GPL(anatop_write_reg); |
77 | 64 | ||
78 | static const struct of_device_id of_anatop_match[] = { | 65 | static const struct of_device_id of_anatop_match[] = { |
79 | { .compatible = "fsl,imx6q-anatop", }, | 66 | { .compatible = "fsl,imx6q-anatop", }, |