/* Change the direction of a GPIO pin to output and set the level on this pin.  */
static int a2f_gpio_direction_output(struct gpio_chip *chip, unsigned gpio, int level)
/* Change the direction of a GPIO pin to output and set the level on this pin.  */
static int a2f_gpio_direction_output(struct gpio_chip *chip, unsigned gpio, int level)
{
	struct a2f_gpio_chip *a2f_chip
		= container_of(chip, struct a2f_gpio_chip, chip);
	u32 gpio_cfg;
	unsigned long f;
	spin_lock_irqsave(&a2f_chip->lock, f);
	gpio_cfg = readl(A2F_GPIO_CFG(a2f_chip->gpio_cfg, gpio));
	gpio_cfg |= GPIO_OUT_REG_EN | GPIO_OUT_BUF_EN;
	gpio_cfg &= ~(GPIO_IN_REG_EN);
	writel(0, A2F_GPIO_CFG(a2f_chip->gpio_cfg, gpio));
	a2f_gpio_set_value_locked(a2f_chip, gpio, level);
	writel(gpio_cfg, A2F_GPIO_CFG(a2f_chip->gpio_cfg, gpio));
	spin_unlock_irqrestore(&a2f_chip->lock, f);
	return 0;
}