summaryrefslogtreecommitdiffstats
path: root/drivers/sh
diff options
context:
space:
mode:
authorMagnus Damm <damm@opensource.se>2011-12-14 01:01:14 +0900
committerPaul Mundt <lethal@linux-sh.org>2012-01-09 09:33:57 +0900
commite499ada829cf769ac6f16627cd9f09b855a7fd6d (patch)
tree87064260c6ae7ab6d0548de8109b816dd2609e3e /drivers/sh
parentf78a26f55b2438c439609fc90b473f7f08f5b697 (diff)
downloadlinux-e499ada829cf769ac6f16627cd9f09b855a7fd6d.tar.bz2
sh: pfc: Unlock register support
Add PFC support for a 32-bit unlock register. Needed to drive the r8a7779 PFC that comes with a funky PMMR register. Signed-off-by: Magnus Damm <damm@opensource.se> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'drivers/sh')
-rw-r--r--drivers/sh/pfc.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/drivers/sh/pfc.c b/drivers/sh/pfc.c
index f975f4a33439..522c6c46d1be 100644
--- a/drivers/sh/pfc.c
+++ b/drivers/sh/pfc.c
@@ -210,7 +210,7 @@ static void write_config_reg(struct pinmux_info *gpioc,
unsigned long field, unsigned long value)
{
void __iomem *mapped_reg;
- unsigned long mask, pos;
+ unsigned long mask, pos, data;
config_reg_helper(gpioc, crp, field, &mapped_reg, &mask, &pos);
@@ -221,17 +221,15 @@ static void write_config_reg(struct pinmux_info *gpioc,
mask = ~(mask << pos);
value = value << pos;
- switch (crp->reg_width) {
- case 8:
- iowrite8((ioread8(mapped_reg) & mask) | value, mapped_reg);
- break;
- case 16:
- iowrite16((ioread16(mapped_reg) & mask) | value, mapped_reg);
- break;
- case 32:
- iowrite32((ioread32(mapped_reg) & mask) | value, mapped_reg);
- break;
- }
+ data = gpio_read_raw_reg(mapped_reg, crp->reg_width);
+ data &= mask;
+ data |= value;
+
+ if (gpioc->unlock_reg)
+ gpio_write_raw_reg(pfc_phys_to_virt(gpioc, gpioc->unlock_reg),
+ 32, ~data);
+
+ gpio_write_raw_reg(mapped_reg, crp->reg_width, data);
}
static int setup_data_reg(struct pinmux_info *gpioc, unsigned gpio)