mux.c 1023 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. * DaVinci pin multiplexing configurations
  3. *
  4. * Author: Vladimir Barinov, MontaVista Software, Inc. <source@mvista.com>
  5. *
  6. * 2007 (c) MontaVista Software, Inc. This file is licensed under
  7. * the terms of the GNU General Public License version 2. This program
  8. * is licensed "as is" without any warranty of any kind, whether express
  9. * or implied.
  10. */
  11. #include <linux/io.h>
  12. #include <linux/spinlock.h>
  13. #include <asm/hardware.h>
  14. #include <asm/arch/mux.h>
  15. /* System control register offsets */
  16. #define PINMUX0 0x00
  17. #define PINMUX1 0x04
  18. static DEFINE_SPINLOCK(mux_lock);
  19. void davinci_mux_peripheral(unsigned int mux, unsigned int enable)
  20. {
  21. u32 pinmux, muxreg = PINMUX0;
  22. if (mux >= DAVINCI_MUX_LEVEL2) {
  23. muxreg = PINMUX1;
  24. mux -= DAVINCI_MUX_LEVEL2;
  25. }
  26. spin_lock(&mux_lock);
  27. pinmux = davinci_readl(DAVINCI_SYSTEM_MODULE_BASE + muxreg);
  28. if (enable)
  29. pinmux |= (1 << mux);
  30. else
  31. pinmux &= ~(1 << mux);
  32. davinci_writel(pinmux, DAVINCI_SYSTEM_MODULE_BASE + muxreg);
  33. spin_unlock(&mux_lock);
  34. }