2012-01-26 05:43:28 +08:00
|
|
|
/*
|
2013-03-01 05:32:10 +08:00
|
|
|
* Copyright (C) 2012,2013 NVIDIA CORPORATION. All rights reserved.
|
2012-01-26 05:43:28 +08:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms and conditions of the GNU General Public License,
|
|
|
|
* version 2, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
* more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/io.h>
|
|
|
|
#include <linux/of.h>
|
2013-03-01 05:32:10 +08:00
|
|
|
#include <linux/of_address.h>
|
2012-01-26 05:43:28 +08:00
|
|
|
|
|
|
|
#define PMC_CTRL 0x0
|
|
|
|
#define PMC_CTRL_INTR_LOW (1 << 17)
|
|
|
|
|
2013-03-01 05:32:10 +08:00
|
|
|
static void __iomem *tegra_pmc_base;
|
|
|
|
static bool tegra_pmc_invert_interrupt;
|
|
|
|
|
2012-01-26 05:43:28 +08:00
|
|
|
static inline u32 tegra_pmc_readl(u32 reg)
|
|
|
|
{
|
2013-03-01 05:32:10 +08:00
|
|
|
return readl(tegra_pmc_base + reg);
|
2012-01-26 05:43:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void tegra_pmc_writel(u32 val, u32 reg)
|
|
|
|
{
|
2013-03-01 05:32:10 +08:00
|
|
|
writel(val, tegra_pmc_base + reg);
|
2012-01-26 05:43:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct of_device_id matches[] __initconst = {
|
2013-02-27 00:27:42 +08:00
|
|
|
{ .compatible = "nvidia,tegra114-pmc" },
|
|
|
|
{ .compatible = "nvidia,tegra30-pmc" },
|
2012-01-26 05:43:28 +08:00
|
|
|
{ .compatible = "nvidia,tegra20-pmc" },
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2013-03-01 05:32:10 +08:00
|
|
|
static void tegra_pmc_parse_dt(void)
|
2012-01-26 05:43:28 +08:00
|
|
|
{
|
2013-03-01 05:32:10 +08:00
|
|
|
struct device_node *np;
|
|
|
|
|
|
|
|
np = of_find_matching_node(NULL, matches);
|
|
|
|
BUG_ON(!np);
|
2012-01-26 05:43:28 +08:00
|
|
|
|
2013-03-01 05:32:10 +08:00
|
|
|
tegra_pmc_base = of_iomap(np, 0);
|
2012-01-26 05:43:28 +08:00
|
|
|
|
2013-03-01 05:32:10 +08:00
|
|
|
tegra_pmc_invert_interrupt = of_property_read_bool(np,
|
|
|
|
"nvidia,invert-interrupt");
|
|
|
|
}
|
|
|
|
|
|
|
|
void __init tegra_pmc_init(void)
|
|
|
|
{
|
|
|
|
u32 val;
|
2012-01-26 05:43:28 +08:00
|
|
|
|
2013-03-01 05:32:10 +08:00
|
|
|
tegra_pmc_parse_dt();
|
2012-01-26 05:43:28 +08:00
|
|
|
|
|
|
|
val = tegra_pmc_readl(PMC_CTRL);
|
2013-03-01 05:32:10 +08:00
|
|
|
if (tegra_pmc_invert_interrupt)
|
2012-01-26 05:43:28 +08:00
|
|
|
val |= PMC_CTRL_INTR_LOW;
|
|
|
|
else
|
|
|
|
val &= ~PMC_CTRL_INTR_LOW;
|
|
|
|
tegra_pmc_writel(val, PMC_CTRL);
|
|
|
|
}
|