@@ -23,10 +23,12 @@
/*
- * The AB9540 GPIO support is an extended version of the
- * AB8500 GPIO support. The AB9540 supports an additional
- * (7th) register so that more GPIO may be configured and
- * used.
+ * The AB9540 and AB8540 GPIO support are extended versions
+ * of the AB8500 GPIO support.
+ * The AB9540 supports an additional (7th) register so that
+ * more GPIO may be configured and used.
+ * The AB8540 supports 4 new gpios (GPIOx_VBAT) that have
+ * internal pull-up and pull-down capabilities.
*/
/*
@@ -636,46 +638,46 @@ int ab8500_config_pulldown(struct device *dev,
}
EXPORT_SYMBOL(ab8500_config_pulldown);
-/*
- * ab8540_config_pull_updown() only available for following GPIOs:
- * GPIO51(GPIO1_VBAT)
- * GPIO52(GPIO2_VBAT)
- * GPIO53(GPIO3_VBAT)
- * GPIO54(GPIO4_VBAT)
- */
int ab8540_config_pull_updown(struct device *dev,
- int gpio, enum ab8540_gpio_pull_updown reg)
+ int gpio, enum ab8540_gpio_pull_updown val)
{
- u8 offset = gpio - AB8500_PIN_GPIO(51);
- u8 pos = 2 * offset;
+ u8 pos;
int ret;
+ if ((gpio < AB8500_PIN_GPIO(51)) || (gpio > AB8500_PIN_GPIO(54))) {
+ ret = -EINVAL;
+ goto out;
+ }
+
+ pos = (gpio - AB8500_PIN_GPIO(51)) << 1;
+
ret = abx500_mask_and_set_register_interruptible(dev,
AB8500_MISC, AB8540_GPIO_PULL_UPDOWN_REG,
- AB8540_GPIO_PULL_UPDOWN_MASK << pos, reg << pos);
+ AB8540_GPIO_PULL_UPDOWN_MASK << pos, val << pos);
+
+out:
if (ret < 0)
dev_err(dev, "%s failed (%d)\n", __func__, ret);
return ret;
}
EXPORT_SYMBOL(ab8540_config_pull_updown);
-/*
- * ab8540_gpio_config_vinsel() only available for following GPIOs:
- * GPIO51(GPIO1_VBAT)
- * GPIO52(GPIO2_VBAT)
- * GPIO53(GPIO3_VBAT)
- * GPIO54(GPIO4_VBAT)
- */
int ab8540_gpio_config_vinsel(struct device *dev,
- int gpio, enum ab8540_gpio_vinsel reg)
+ int gpio, enum ab8540_gpio_vinsel val)
{
- u8 offset = gpio - AB8500_PIN_GPIO(51);
- u8 pos = 2 * offset;
+ u8 pos;
int ret;
+ if ((gpio < AB8500_PIN_GPIO(51)) || (gpio > AB8500_PIN_GPIO(54))) {
+ ret = -EINVAL;
+ goto out;
+ }
+
ret = abx500_mask_and_set_register_interruptible(dev,
AB8500_MISC, AB8540_GPIO_VINSEL_REG,
- AB8540_GPIO_VINSEL_MASK << pos, reg << pos);
+ AB8540_GPIO_VINSEL_MASK << pos, val << pos);
+
+out:
if (ret < 0)
dev_err(dev, "%s failed (%d)\n", __func__, ret);
return ret;
@@ -39,11 +39,13 @@ enum ab8540_gpio_vinsel {
int ab8500_config_pulldown(struct device *dev,
int gpio, bool enable);
+/* Selects pull up/pull down for GPIOx_VBAT, x=1 to 4 */
int ab8540_config_pull_updown(struct device *dev,
- int gpio, enum ab8540_gpio_pull_updown reg);
+ int gpio, enum ab8540_gpio_pull_updown val);
+/* Selects voltage for GPIOx_VBAT, x=1 to 4 */
int ab8540_gpio_config_vinsel(struct device *dev,
- int gpio, enum ab8540_gpio_vinsel reg);
+ int gpio, enum ab8540_gpio_vinsel val);
int ab8500_gpio_config_select(struct device *dev,
int gpio, bool gpio_select);