mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 19:21:31 -04:00
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 <[email protected]> Reviewed-by: Ying-Chun Liu (PaulLiu) <[email protected]> Signed-off-by: Samuel Ortiz <[email protected]>
This commit is contained in:
parent
08b4c118af
commit
b09530ef84
3 changed files with 21 additions and 36 deletions
|
|
@ -41,39 +41,26 @@
|
|||
#include <linux/of_address.h>
|
||||
#include <linux/mfd/anatop.h>
|
||||
|
||||
u32 anatop_get_bits(struct anatop *adata, u32 addr, int bit_shift,
|
||||
int bit_width)
|
||||
u32 anatop_read_reg(struct anatop *adata, u32 addr)
|
||||
{
|
||||
u32 val, mask;
|
||||
|
||||
if (bit_width == 32)
|
||||
mask = ~0;
|
||||
else
|
||||
mask = (1 << bit_width) - 1;
|
||||
|
||||
val = readl(adata->ioreg + addr);
|
||||
val = (val >> bit_shift) & mask;
|
||||
|
||||
return val;
|
||||
return readl(adata->ioreg + addr);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(anatop_get_bits);
|
||||
EXPORT_SYMBOL_GPL(anatop_read_reg);
|
||||
|
||||
void anatop_set_bits(struct anatop *adata, u32 addr, int bit_shift,
|
||||
int bit_width, u32 data)
|
||||
void anatop_write_reg(struct anatop *adata, u32 addr, u32 data, u32 mask)
|
||||
{
|
||||
u32 val, mask;
|
||||
u32 val;
|
||||
|
||||
if (bit_width == 32)
|
||||
mask = ~0;
|
||||
else
|
||||
mask = (1 << bit_width) - 1;
|
||||
data &= mask;
|
||||
|
||||
spin_lock(&adata->reglock);
|
||||
val = readl(adata->ioreg + addr) & ~(mask << bit_shift);
|
||||
writel((data << bit_shift) | val, adata->ioreg + addr);
|
||||
val = readl(adata->ioreg + addr);
|
||||
val &= ~mask;
|
||||
val |= data;
|
||||
writel(val, adata->ioreg + addr);
|
||||
spin_unlock(&adata->reglock);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(anatop_set_bits);
|
||||
EXPORT_SYMBOL_GPL(anatop_write_reg);
|
||||
|
||||
static const struct of_device_id of_anatop_match[] = {
|
||||
{ .compatible = "fsl,imx6q-anatop", },
|
||||
|
|
|
|||
Loading…
Reference in a new issue