Merge remote-tracking branch 'origin/develop-3.0' into develop-3.0-jb
[firefly-linux-kernel-4.4.55.git] / drivers / gpio / wm831x-gpio.c
index fdfca9e7cfe6564c833e6715bd0c6f731cbc24ff..0aadbb63c35946bb83905025b3943acaa2ee6277 100755 (executable)
@@ -85,17 +85,17 @@ static int wm831x_gpio_get(struct gpio_chip *chip, unsigned offset)
        return !((ret>>offset)^gpn_pol);
 }
 
-static int wm831x_gpio_direction_out(struct gpio_chip *chip,
-                                    unsigned offset, int value)
+static void wm831x_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
 {
        struct wm831x_gpio *wm831x_gpio = to_wm831x_gpio(chip);
        struct wm831x *wm831x = wm831x_gpio->wm831x;
 
-       return wm831x_set_bits(wm831x, WM831X_GPIO1_CONTROL + offset,
-                              WM831X_GPN_DIR | WM831X_GPN_TRI, 0);
+       wm831x_set_bits(wm831x, WM831X_GPIO_LEVEL, 1 << offset,
+                       value << offset);
 }
 
-static void wm831x_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
+static int wm831x_gpio_direction_out(struct gpio_chip *chip,
+                                    unsigned offset, int value)
 {
        struct wm831x_gpio *wm831x_gpio = to_wm831x_gpio(chip);
        struct wm831x *wm831x = wm831x_gpio->wm831x;
@@ -114,8 +114,7 @@ static void wm831x_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
        /* Can only set GPIO state once it's in output mode */
        wm831x_gpio_set(chip, offset, value);
 
-       wm831x_set_bits(wm831x, WM831X_GPIO_LEVEL, 1 << offset,
-                       value << offset);
+       return 0;
 }
 
 static int wm831x_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
@@ -201,6 +200,7 @@ static void wm831x_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip)
                        break;
                case WM831X_GPIO_PULL_UP:
                        pull = "pullup";
+                       break;
                default:
                        pull = "INVALID PULL";
                        break;
@@ -293,6 +293,17 @@ static int __devinit wm831x_gpio_probe(struct platform_device *pdev)
                goto err;
        }
 
+#ifdef CONFIG_PLAT_RK
+       if (pdata && pdata->pin_type_init) {
+               ret = pdata->pin_type_init(wm831x);
+               if (ret != 0) {
+                       dev_err(wm831x->dev, "pin_type_init() failed: %d\n", ret);
+                       WARN_ON(gpiochip_remove(&wm831x_gpio->gpio_chip));
+                       goto err;
+               }
+       }
+#endif
+
        platform_set_drvdata(pdev, wm831x_gpio);
 
        return ret;