diff options
Diffstat (limited to 'drivers/power/axp209.c')
-rw-r--r-- | drivers/power/axp209.c | 64 |
1 files changed, 0 insertions, 64 deletions
diff --git a/drivers/power/axp209.c b/drivers/power/axp209.c index 98c214fa7a..5161bc1472 100644 --- a/drivers/power/axp209.c +++ b/drivers/power/axp209.c @@ -155,67 +155,3 @@ int axp209_power_button(void) return v & AXP209_IRQ5_PEK_DOWN; } - -static u8 axp209_get_gpio_ctrl_reg(unsigned int pin) -{ - switch (pin) { - case 0: return AXP209_GPIO0_CTRL; - case 1: return AXP209_GPIO1_CTRL; - case 2: return AXP209_GPIO2_CTRL; - case 3: return AXP209_GPIO3_CTRL; - } - return 0; -} - -int axp_gpio_direction_input(struct udevice *dev, unsigned pin) -{ - if (pin == SUNXI_GPIO_AXP0_VBUS_DETECT) - return 0; - - u8 reg = axp209_get_gpio_ctrl_reg(pin); - /* GPIO3 is "special" */ - u8 val = (pin == 3) ? AXP209_GPIO3_INPUT : AXP209_GPIO_INPUT; - - return axp209_write(reg, val); -} - -int axp_gpio_direction_output(struct udevice *dev, unsigned pin, int val) -{ - u8 reg = axp209_get_gpio_ctrl_reg(pin); - - if (val) { - val = (pin == 3) ? AXP209_GPIO3_OUTPUT_HIGH : - AXP209_GPIO_OUTPUT_HIGH; - } else { - val = (pin == 3) ? AXP209_GPIO3_OUTPUT_LOW : - AXP209_GPIO_OUTPUT_LOW; - } - - return axp209_write(reg, val); -} - -int axp_gpio_get_value(struct udevice *dev, unsigned pin) -{ - u8 val, mask; - int rc; - - if (pin == SUNXI_GPIO_AXP0_VBUS_DETECT) { - rc = axp209_read(AXP209_POWER_STATUS, &val); - mask = AXP209_POWER_STATUS_VBUS_USABLE; - } else if (pin == 3) { - rc = axp209_read(AXP209_GPIO3_CTRL, &val); - mask = 1; - } else { - rc = axp209_read(AXP209_GPIO_STATE, &val); - mask = 1 << (pin + 4); - } - if (rc) - return rc; - - return (val & mask) ? 1 : 0; -} - -int axp_gpio_set_value(struct udevice *dev, unsigned pin, int val) -{ - return axp_gpio_direction_output(dev, pin, val); -} |