Vladimir Barinov | 83f5322 | 2007-07-10 13:10:04 +0100 | [diff] [blame] | 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 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 14 | #include <mach/hardware.h> |
Vladimir Barinov | 83f5322 | 2007-07-10 13:10:04 +0100 | [diff] [blame] | 15 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 16 | #include <mach/mux.h> |
Vladimir Barinov | 83f5322 | 2007-07-10 13:10:04 +0100 | [diff] [blame] | 17 | |
| 18 | /* System control register offsets */ |
| 19 | #define PINMUX0 0x00 |
| 20 | #define PINMUX1 0x04 |
| 21 | |
| 22 | static DEFINE_SPINLOCK(mux_lock); |
| 23 | |
| 24 | void davinci_mux_peripheral(unsigned int mux, unsigned int enable) |
| 25 | { |
Kevin Hilman | f5c122d | 2009-04-14 07:04:16 -0500 | [diff] [blame] | 26 | void __iomem *base = IO_ADDRESS(DAVINCI_SYSTEM_MODULE_BASE); |
Vladimir Barinov | 83f5322 | 2007-07-10 13:10:04 +0100 | [diff] [blame] | 27 | u32 pinmux, muxreg = PINMUX0; |
| 28 | |
| 29 | if (mux >= DAVINCI_MUX_LEVEL2) { |
| 30 | muxreg = PINMUX1; |
| 31 | mux -= DAVINCI_MUX_LEVEL2; |
| 32 | } |
| 33 | |
| 34 | spin_lock(&mux_lock); |
Kevin Hilman | f5c122d | 2009-04-14 07:04:16 -0500 | [diff] [blame] | 35 | pinmux = __raw_readl(base + muxreg); |
Vladimir Barinov | 83f5322 | 2007-07-10 13:10:04 +0100 | [diff] [blame] | 36 | if (enable) |
| 37 | pinmux |= (1 << mux); |
| 38 | else |
| 39 | pinmux &= ~(1 << mux); |
Kevin Hilman | f5c122d | 2009-04-14 07:04:16 -0500 | [diff] [blame] | 40 | __raw_writel(pinmux, base + muxreg); |
Vladimir Barinov | 83f5322 | 2007-07-10 13:10:04 +0100 | [diff] [blame] | 41 | spin_unlock(&mux_lock); |
| 42 | } |