505-MIPS-ath79-add-ath79_gpio_function_select.patch 993 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. --- a/arch/mips/ath79/common.h
  2. +++ b/arch/mips/ath79/common.h
  3. @@ -28,6 +28,7 @@ void ath79_ddr_wb_flush(unsigned int reg
  4. void ath79_gpio_function_enable(u32 mask);
  5. void ath79_gpio_function_disable(u32 mask);
  6. void ath79_gpio_function_setup(u32 set, u32 clear);
  7. +void ath79_gpio_output_select(unsigned gpio, u8 val);
  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. @@ -57,3 +57,26 @@ void ath79_gpio_function_disable(u32 mas
  13. {
  14. ath79_gpio_function_setup(0, mask);
  15. }
  16. +
  17. +void __init ath79_gpio_output_select(unsigned gpio, u8 val)
  18. +{
  19. + void __iomem *base = ath79_gpio_base;
  20. + unsigned int reg;
  21. + u32 t, s;
  22. +
  23. + BUG_ON(!soc_is_ar934x());
  24. +
  25. + if (gpio >= AR934X_GPIO_COUNT)
  26. + return;
  27. +
  28. + reg = AR934X_GPIO_REG_OUT_FUNC0 + 4 * (gpio / 4);
  29. + s = 8 * (gpio % 4);
  30. +
  31. + t = __raw_readl(base + reg);
  32. + t &= ~(0xff << s);
  33. + t |= val << s;
  34. + __raw_writel(t, base + reg);
  35. +
  36. + /* flush write */
  37. + (void) __raw_readl(base + reg);
  38. +}