632-MIPS-ath79-gpio-enable-set-direction.patch 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. --- a/arch/mips/ath79/common.h
  2. +++ b/arch/mips/ath79/common.h
  3. @@ -28,6 +28,7 @@ void ath79_gpio_function_enable(u32 mask
  4. void ath79_gpio_function_disable(u32 mask);
  5. void ath79_gpio_function_setup(u32 set, u32 clear);
  6. void ath79_gpio_output_select(unsigned gpio, u8 val);
  7. +int ath79_gpio_direction_select(unsigned gpio, bool oe);
  8. void ath79_gpio_init(void);
  9. #endif /* __ATH79_COMMON_H */
  10. --- a/arch/mips/ath79/gpio.c
  11. +++ b/arch/mips/ath79/gpio.c
  12. @@ -130,6 +130,30 @@ static int ar934x_gpio_direction_output(
  13. return 0;
  14. }
  15. +int ath79_gpio_direction_select(unsigned gpio, bool oe)
  16. +{
  17. + void __iomem *base = ath79_gpio_base;
  18. + unsigned long flags;
  19. + bool ieq_1 = (soc_is_ar934x() ||
  20. + soc_is_qca953x());
  21. +
  22. + if (gpio >= ath79_gpio_count)
  23. + return -1;
  24. +
  25. + spin_lock_irqsave(&ath79_gpio_lock, flags);
  26. +
  27. + if ((ieq_1 && oe) || (!ieq_1 && !oe))
  28. + __raw_writel(__raw_readl(base + AR71XX_GPIO_REG_OE) & ~(1 << gpio),
  29. + base + AR71XX_GPIO_REG_OE);
  30. + else
  31. + __raw_writel(__raw_readl(base + AR71XX_GPIO_REG_OE) | (1 << gpio),
  32. + base + AR71XX_GPIO_REG_OE);
  33. +
  34. + spin_unlock_irqrestore(&ath79_gpio_lock, flags);
  35. +
  36. + return 0;
  37. +}
  38. +
  39. static struct gpio_chip ath79_gpio_chip = {
  40. .label = "ath79",
  41. .get = ath79_gpio_get_value,