sh: pfc: Unlock register support
authorMagnus Damm <damm@opensource.se>
Tue, 13 Dec 2011 16:01:14 +0000 (01:01 +0900)
committerPaul Mundt <lethal@linux-sh.org>
Mon, 9 Jan 2012 00:33:57 +0000 (09:33 +0900)
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>
drivers/sh/pfc.c
include/linux/sh_pfc.h

index f975f4a334391887a65fcc7d3e80b5b3cc676194..522c6c46d1be83a5f95527d509cf12142a52e523 100644 (file)
@@ -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)
index 84538c42d64a45c4261ead05c8e1a7089b2a87f8..5c15aed9c4b2430adebf1b5ca0b9325bcbd22acd 100644 (file)
@@ -116,6 +116,8 @@ struct pinmux_info {
        unsigned int num_resources;
        struct pfc_window *window;
 
+       unsigned long unlock_reg;
+
        struct gpio_chip chip;
 };