Merge branch 'linux-tegra-2.6.36' into android-tegra-2.6.36
[firefly-linux-kernel-4.4.55.git] / arch / arm / mach-tegra / mc.c
1 /*
2  * arch/arm/mach-tegra/mc.c
3  *
4  * Copyright (C) 2010 Google, Inc.
5  *
6  * Author:
7  *      Erik Gilling <konkers@google.com>
8  *
9  * This software is licensed under the terms of the GNU General Public
10  * License version 2, as published by the Free Software Foundation, and
11  * may be copied, distributed, and modified under those terms.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  */
19
20 #include <linux/io.h>
21 #include <linux/spinlock.h>
22
23 #include <mach/iomap.h>
24 #include <mach/mc.h>
25
26 static DEFINE_SPINLOCK(tegra_mc_lock);
27
28 void tegra_mc_set_priority(unsigned long client, unsigned long prio)
29 {
30         unsigned long mc_base = IO_TO_VIRT(TEGRA_MC_BASE);
31         unsigned long reg = client >> 8;
32         int field = client & 0xff;
33         unsigned long val;
34         unsigned long flags;
35
36         spin_lock_irqsave(&tegra_mc_lock, flags);
37         val = readl(mc_base + reg);
38         val &= ~(TEGRA_MC_PRIO_MASK << field);
39         val |= prio << field;
40         writel(val, mc_base + reg);
41         spin_unlock_irqrestore(&tegra_mc_lock, flags);
42 }