505-MIPS-ath79-add-ath79_gpio_function_select.patch 1.1 KB

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