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;
/* 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)
break;
case WM831X_GPIO_PULL_UP:
pull = "pullup";
+ break;
default:
pull = "INVALID PULL";
break;
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;