Linux Audio

Check our new training course

Loading...
Note: File does not exist in v6.13.7.
 1/*
 2 * Copyright (C) 2012 NVIDIA CORPORATION. All rights reserved.
 3 *
 4 * This program is free software; you can redistribute it and/or modify it
 5 * under the terms and conditions of the GNU General Public License,
 6 * version 2, as published by the Free Software Foundation.
 7 *
 8 * This program is distributed in the hope it will be useful, but WITHOUT
 9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
15 *
16 */
17
18#include <linux/kernel.h>
19#include <linux/io.h>
20#include <linux/of.h>
21
22#include <mach/iomap.h>
23
24#define PMC_CTRL		0x0
25#define PMC_CTRL_INTR_LOW	(1 << 17)
26
27static inline u32 tegra_pmc_readl(u32 reg)
28{
29	return readl(IO_ADDRESS(TEGRA_PMC_BASE + reg));
30}
31
32static inline void tegra_pmc_writel(u32 val, u32 reg)
33{
34	writel(val, IO_ADDRESS(TEGRA_PMC_BASE + reg));
35}
36
37#ifdef CONFIG_OF
38static const struct of_device_id matches[] __initconst = {
39	{ .compatible = "nvidia,tegra20-pmc" },
40	{ }
41};
42#endif
43
44void __init tegra_pmc_init(void)
45{
46	/*
47	 * For now, Harmony is the only board that uses the PMC, and it wants
48	 * the signal inverted. Seaboard would too if it used the PMC.
49	 * Hopefully by the time other boards want to use the PMC, everything
50	 * will be device-tree, or they also want it inverted.
51	 */
52	bool invert_interrupt = true;
53	u32 val;
54
55#ifdef CONFIG_OF
56	if (of_have_populated_dt()) {
57		struct device_node *np;
58
59		invert_interrupt = false;
60
61		np = of_find_matching_node(NULL, matches);
62		if (np) {
63			if (of_find_property(np, "nvidia,invert-interrupt",
64						NULL))
65				invert_interrupt = true;
66		}
67	}
68#endif
69
70	val = tegra_pmc_readl(PMC_CTRL);
71	if (invert_interrupt)
72		val |= PMC_CTRL_INTR_LOW;
73	else
74		val &= ~PMC_CTRL_INTR_LOW;
75	tegra_pmc_writel(val, PMC_CTRL);
76}