2 * arch/arm/plat-spear/pl080.c
4 * DMAC pl080 definitions for SPEAr platform
6 * Copyright (C) 2012 ST Microelectronics
7 * Viresh Kumar <viresh.kumar@st.com>
9 * This file is licensed under the terms of the GNU General Public
10 * License version 2. This program is licensed "as is" without any
11 * warranty of any kind, whether express or implied.
14 #include <linux/amba/pl08x.h>
15 #include <linux/amba/bus.h>
16 #include <linux/bug.h>
17 #include <linux/err.h>
19 #include <linux/spinlock_types.h>
20 #include <mach/spear.h>
21 #include <mach/misc_regs.h>
23 static spinlock_t lock = __SPIN_LOCK_UNLOCKED(x);
28 } signals[16] = {{0, 0}, };
30 int pl080_get_signal(struct pl08x_dma_chan *ch)
32 const struct pl08x_channel_data *cd = ch->cd;
33 unsigned int signal = cd->min_signal, val;
36 spin_lock_irqsave(&lock, flags);
38 /* Return if signal is already acquired by somebody else */
39 if (signals[signal].busy &&
40 (signals[signal].val != cd->muxval)) {
41 spin_unlock_irqrestore(&lock, flags);
45 /* If acquiring for the first time, configure it */
46 if (!signals[signal].busy) {
47 val = readl(DMA_CHN_CFG);
50 * Each request line has two bits in DMA_CHN_CFG register. To
51 * goto the bits of current request line, do left shift of
52 * value by 2 * signal number.
54 val &= ~(0x3 << (signal * 2));
55 val |= cd->muxval << (signal * 2);
56 writel(val, DMA_CHN_CFG);
59 signals[signal].busy++;
60 signals[signal].val = cd->muxval;
61 spin_unlock_irqrestore(&lock, flags);
66 void pl080_put_signal(struct pl08x_dma_chan *ch)
68 const struct pl08x_channel_data *cd = ch->cd;
71 spin_lock_irqsave(&lock, flags);
73 /* if signal is not used */
74 if (!signals[cd->min_signal].busy)
77 signals[cd->min_signal].busy--;
79 spin_unlock_irqrestore(&lock, flags);