summaryrefslogtreecommitdiff
path: root/drivers/mfd/ricoh583.c
diff options
context:
space:
mode:
authorLaxman Dewangan <ldewangan@nvidia.com>2011-10-12 21:19:51 +0530
committerDan Willemsen <dwillemsen@nvidia.com>2011-11-30 21:49:28 -0800
commitfa36ff379b8283fce834329fd707ca70a8afe306 (patch)
tree914ce8110e95eca6caf5a511f2d727790faa4bd6 /drivers/mfd/ricoh583.c
parenta226e7c73a8aa41f772cedda1ac2f14c000b0065 (diff)
mfd: richo583: Configure pins in gpio mode if used as gpio
Configuring the pins in gpio mode when it is used as gpio. Configuring the correct value of bits when setting the output value. bug 822562 Reviewed-on: http://git-master/r/58276 (cherry picked from commit b854f309151342689b82bd653738eb94c87db4a4) Change-Id: I7474d1771d83650db9be71db1f578fd0a50ad19d Reviewed-on: http://git-master/r/59288 Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com> Tested-by: Laxman Dewangan <ldewangan@nvidia.com> Reviewed-by: Bitan Biswas <bbiswas@nvidia.com> Rebase-Id: Rf0619d6a3d24059dab15c39c5800a5fd7ee6779b
Diffstat (limited to 'drivers/mfd/ricoh583.c')
-rw-r--r--drivers/mfd/ricoh583.c47
1 files changed, 43 insertions, 4 deletions
diff --git a/drivers/mfd/ricoh583.c b/drivers/mfd/ricoh583.c
index edbbf80630a9..27e5063f5750 100644
--- a/drivers/mfd/ricoh583.c
+++ b/drivers/mfd/ricoh583.c
@@ -390,10 +390,10 @@ static void ricoh583_gpio_set(struct gpio_chip *chip, unsigned offset,
{
struct ricoh583 *ricoh583 = container_of(chip, struct ricoh583, gpio);
if (value)
- ricoh583_clr_bits(ricoh583->dev, RICOH583_GPIO_IOOUT,
+ ricoh583_set_bits(ricoh583->dev, RICOH583_GPIO_IOOUT,
1 << offset);
else
- ricoh583_set_bits(ricoh583->dev, RICOH583_GPIO_IOOUT,
+ ricoh583_clr_bits(ricoh583->dev, RICOH583_GPIO_IOOUT,
1 << offset);
}
@@ -425,6 +425,31 @@ static int ricoh583_gpio_to_irq(struct gpio_chip *chip, unsigned off)
return -EIO;
}
+static int ricoh583_gpio_request(struct gpio_chip *chip, unsigned offset)
+{
+ struct ricoh583 *ricoh583 = container_of(chip, struct ricoh583, gpio);
+ int ret;
+
+ ret = ricoh583_clr_bits(ricoh583->dev, RICOH583_GPIO_PGSEL,
+ 1 << offset);
+ if (ret < 0)
+ dev_err(ricoh583->dev, "%s(): The error in writing register "
+ "0x%02x\n", __func__, RICOH583_GPIO_PGSEL);
+ return ret;
+}
+
+static void ricoh583_gpio_free(struct gpio_chip *chip, unsigned offset)
+{
+ struct ricoh583 *ricoh583 = container_of(chip, struct ricoh583, gpio);
+ int ret;
+
+ ret = ricoh583_set_bits(ricoh583->dev, RICOH583_GPIO_PGSEL,
+ 1 << offset);
+ if (ret < 0)
+ dev_err(ricoh583->dev, "%s(): The error in writing register "
+ "0x%02x\n", __func__, RICOH583_GPIO_PGSEL);
+}
+
static void __devinit ricoh583_gpio_init(struct ricoh583 *ricoh583,
struct ricoh583_platform_data *pdata)
{
@@ -435,6 +460,13 @@ static void __devinit ricoh583_gpio_init(struct ricoh583 *ricoh583,
if (pdata->gpio_base <= 0)
return;
+ ret = ricoh583_write(ricoh583->dev, RICOH583_GPIO_PGSEL, 0xEF);
+ if (ret < 0) {
+ dev_err(ricoh583->dev, "%s(): The error in writing register "
+ "0x%02x\n", __func__, RICOH583_GPIO_PGSEL);
+ return;
+ }
+
for (i = 0; i < pdata->num_gpioinit_data; ++i) {
ginit = &pdata->gpio_init_data[i];
if (!ginit->init_apply)
@@ -451,10 +483,10 @@ static void __devinit ricoh583_gpio_init(struct ricoh583 *ricoh583,
if (ginit->output_mode_en) {
if (ginit->output_val)
- ret = ricoh583_clr_bits(ricoh583->dev,
+ ret = ricoh583_set_bits(ricoh583->dev,
RICOH583_GPIO_IOOUT, 1 << i);
else
- ret = ricoh583_set_bits(ricoh583->dev,
+ ret = ricoh583_clr_bits(ricoh583->dev,
RICOH583_GPIO_IOOUT, 1 << i);
if (!ret)
ret = ricoh583_set_bits(ricoh583->dev,
@@ -466,6 +498,11 @@ static void __devinit ricoh583_gpio_init(struct ricoh583 *ricoh583,
if (ret < 0)
dev_err(ricoh583->dev, "Gpio %d init "
"dir configuration failed: %d\n", i, ret);
+
+ ret = ricoh583_clr_bits(ricoh583->dev, RICOH583_GPIO_PGSEL, 1 << i);
+ if (ret < 0)
+ dev_err(ricoh583->dev, "%s(): The error in writing register "
+ "0x%02x\n", __func__, RICOH583_GPIO_PGSEL);
}
ricoh583->gpio.owner = THIS_MODULE;
@@ -475,6 +512,8 @@ static void __devinit ricoh583_gpio_init(struct ricoh583 *ricoh583,
ricoh583->gpio.ngpio = RICOH583_NR_GPIO;
ricoh583->gpio.can_sleep = 1;
+ ricoh583->gpio.request = ricoh583_gpio_request;
+ ricoh583->gpio.free = ricoh583_gpio_free;
ricoh583->gpio.direction_input = ricoh583_gpio_input;
ricoh583->gpio.direction_output = ricoh583_gpio_output;
ricoh583->gpio.set = ricoh583_gpio_set;