diff options
author | Magnus Damm <damm@opensource.se> | 2011-12-13 11:00:37 -0500 |
---|---|---|
committer | Paul Mundt <lethal@linux-sh.org> | 2012-01-08 19:33:50 -0500 |
commit | 92554d97c6dcc448afd56f96bbe933998868be74 (patch) | |
tree | 29c6d6ab1c4150b82b52655807d8a3cc9585a826 /drivers/sh/pfc.c | |
parent | b0e10211cba1629e2e534ca9cb3d87cfc7e389ea (diff) |
sh: pfc: Add gpio_read_bit() for data register access
Introduce gpio_read_bit() for data register read access
and modify sh_gpio_get_value() to make use of the new
function instead of gpio_read_reg(). The purpose of
this change is to update the code to only use the
gpio_read_reg() function for config register access.
Signed-off-by: Magnus Damm <damm@opensource.se>
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'drivers/sh/pfc.c')
-rw-r--r-- | drivers/sh/pfc.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/drivers/sh/pfc.c b/drivers/sh/pfc.c index e7d127a9c1c5..cfca0aaf9820 100644 --- a/drivers/sh/pfc.c +++ b/drivers/sh/pfc.c | |||
@@ -135,6 +135,19 @@ static void gpio_write_raw_reg(void __iomem *mapped_reg, | |||
135 | BUG(); | 135 | BUG(); |
136 | } | 136 | } |
137 | 137 | ||
138 | static int gpio_read_bit(struct pinmux_data_reg *dr, | ||
139 | unsigned long in_pos) | ||
140 | { | ||
141 | unsigned long pos; | ||
142 | |||
143 | pos = dr->reg_width - (in_pos + 1); | ||
144 | |||
145 | pr_debug("read_bit: addr = %lx, pos = %ld, " | ||
146 | "r_width = %ld\n", dr->reg, pos, dr->reg_width); | ||
147 | |||
148 | return (gpio_read_raw_reg(dr->mapped_reg, dr->reg_width) >> pos) & 1; | ||
149 | } | ||
150 | |||
138 | static void gpio_write_bit(struct pinmux_data_reg *dr, | 151 | static void gpio_write_bit(struct pinmux_data_reg *dr, |
139 | unsigned long in_pos, unsigned long value) | 152 | unsigned long in_pos, unsigned long value) |
140 | { | 153 | { |
@@ -644,7 +657,7 @@ static int sh_gpio_get_value(struct pinmux_info *gpioc, unsigned gpio) | |||
644 | if (!gpioc || get_data_reg(gpioc, gpio, &dr, &bit) != 0) | 657 | if (!gpioc || get_data_reg(gpioc, gpio, &dr, &bit) != 0) |
645 | return -EINVAL; | 658 | return -EINVAL; |
646 | 659 | ||
647 | return gpio_read_reg(dr->mapped_reg, dr->reg_width, 1, bit, dr->reg); | 660 | return gpio_read_bit(dr, bit); |
648 | } | 661 | } |
649 | 662 | ||
650 | static int sh_gpio_get(struct gpio_chip *chip, unsigned offset) | 663 | static int sh_gpio_get(struct gpio_chip *chip, unsigned offset) |