aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpio/cs5535-gpio.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpio/cs5535-gpio.c')
-rw-r--r--drivers/gpio/cs5535-gpio.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/drivers/gpio/cs5535-gpio.c b/drivers/gpio/cs5535-gpio.c
index 599f6c9e0fbf..d3e55a0ae92b 100644
--- a/drivers/gpio/cs5535-gpio.c
+++ b/drivers/gpio/cs5535-gpio.c
@@ -56,15 +56,26 @@ static struct cs5535_gpio_chip {
56 * registers, see include/linux/cs5535.h. 56 * registers, see include/linux/cs5535.h.
57 */ 57 */
58 58
59static void errata_outl(u32 val, unsigned long addr) 59static void errata_outl(struct cs5535_gpio_chip *chip, u32 val,
60 unsigned int reg)
60{ 61{
62 unsigned long addr = chip->base + 0x80 + reg;
63
61 /* 64 /*
62 * According to the CS5536 errata (#36), after suspend 65 * According to the CS5536 errata (#36), after suspend
63 * a write to the high bank GPIO register will clear all 66 * a write to the high bank GPIO register will clear all
64 * non-selected bits; the recommended workaround is a 67 * non-selected bits; the recommended workaround is a
65 * read-modify-write operation. 68 * read-modify-write operation.
69 *
70 * Don't apply this errata to the edge status GPIOs, as writing
71 * to their lower bits will clear them.
66 */ 72 */
67 val |= inl(addr); 73 if (reg != GPIO_POSITIVE_EDGE_STS && reg != GPIO_NEGATIVE_EDGE_STS) {
74 if (val & 0xffff)
75 val |= (inl(addr) & 0xffff); /* ignore the high bits */
76 else
77 val |= (inl(addr) ^ (val >> 16));
78 }
68 outl(val, addr); 79 outl(val, addr);
69} 80}
70 81
@@ -76,7 +87,7 @@ static void __cs5535_gpio_set(struct cs5535_gpio_chip *chip, unsigned offset,
76 outl(1 << offset, chip->base + reg); 87 outl(1 << offset, chip->base + reg);
77 else 88 else
78 /* high bank register */ 89 /* high bank register */
79 errata_outl(1 << (offset - 16), chip->base + 0x80 + reg); 90 errata_outl(chip, 1 << (offset - 16), reg);
80} 91}
81 92
82void cs5535_gpio_set(unsigned offset, unsigned int reg) 93void cs5535_gpio_set(unsigned offset, unsigned int reg)
@@ -98,7 +109,7 @@ static void __cs5535_gpio_clear(struct cs5535_gpio_chip *chip, unsigned offset,
98 outl(1 << (offset + 16), chip->base + reg); 109 outl(1 << (offset + 16), chip->base + reg);
99 else 110 else
100 /* high bank register */ 111 /* high bank register */
101 errata_outl(1 << offset, chip->base + 0x80 + reg); 112 errata_outl(chip, 1 << offset, reg);
102} 113}
103 114
104void cs5535_gpio_clear(unsigned offset, unsigned int reg) 115void cs5535_gpio_clear(unsigned offset, unsigned int reg)