diff options
| -rw-r--r-- | arch/arm/mach-tegra/pmc.c | 51 |
1 files changed, 22 insertions, 29 deletions
diff --git a/arch/arm/mach-tegra/pmc.c b/arch/arm/mach-tegra/pmc.c index 5d79d34e2c0f..a916ecaa96e6 100644 --- a/arch/arm/mach-tegra/pmc.c +++ b/arch/arm/mach-tegra/pmc.c | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * Copyright (C) 2012 NVIDIA CORPORATION. All rights reserved. | 2 | * Copyright (C) 2012,2013 NVIDIA CORPORATION. All rights reserved. |
| 3 | * | 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify it | 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, | 5 | * under the terms and conditions of the GNU General Public License, |
| @@ -18,59 +18,52 @@ | |||
| 18 | #include <linux/kernel.h> | 18 | #include <linux/kernel.h> |
| 19 | #include <linux/io.h> | 19 | #include <linux/io.h> |
| 20 | #include <linux/of.h> | 20 | #include <linux/of.h> |
| 21 | 21 | #include <linux/of_address.h> | |
| 22 | #include "iomap.h" | ||
| 23 | 22 | ||
| 24 | #define PMC_CTRL 0x0 | 23 | #define PMC_CTRL 0x0 |
| 25 | #define PMC_CTRL_INTR_LOW (1 << 17) | 24 | #define PMC_CTRL_INTR_LOW (1 << 17) |
| 26 | 25 | ||
| 26 | static void __iomem *tegra_pmc_base; | ||
| 27 | static bool tegra_pmc_invert_interrupt; | ||
| 28 | |||
| 27 | static inline u32 tegra_pmc_readl(u32 reg) | 29 | static inline u32 tegra_pmc_readl(u32 reg) |
| 28 | { | 30 | { |
| 29 | return readl(IO_ADDRESS(TEGRA_PMC_BASE + reg)); | 31 | return readl(tegra_pmc_base + reg); |
| 30 | } | 32 | } |
| 31 | 33 | ||
| 32 | static inline void tegra_pmc_writel(u32 val, u32 reg) | 34 | static inline void tegra_pmc_writel(u32 val, u32 reg) |
| 33 | { | 35 | { |
| 34 | writel(val, IO_ADDRESS(TEGRA_PMC_BASE + reg)); | 36 | writel(val, tegra_pmc_base + reg); |
| 35 | } | 37 | } |
| 36 | 38 | ||
| 37 | #ifdef CONFIG_OF | ||
| 38 | static const struct of_device_id matches[] __initconst = { | 39 | static const struct of_device_id matches[] __initconst = { |
| 39 | { .compatible = "nvidia,tegra114-pmc" }, | 40 | { .compatible = "nvidia,tegra114-pmc" }, |
| 40 | { .compatible = "nvidia,tegra30-pmc" }, | 41 | { .compatible = "nvidia,tegra30-pmc" }, |
| 41 | { .compatible = "nvidia,tegra20-pmc" }, | 42 | { .compatible = "nvidia,tegra20-pmc" }, |
| 42 | { } | 43 | { } |
| 43 | }; | 44 | }; |
| 44 | #endif | ||
| 45 | 45 | ||
| 46 | void __init tegra_pmc_init(void) | 46 | static void tegra_pmc_parse_dt(void) |
| 47 | { | 47 | { |
| 48 | /* | 48 | struct device_node *np; |
| 49 | * For now, Harmony is the only board that uses the PMC, and it wants | 49 | |
| 50 | * the signal inverted. Seaboard would too if it used the PMC. | 50 | np = of_find_matching_node(NULL, matches); |
| 51 | * Hopefully by the time other boards want to use the PMC, everything | 51 | BUG_ON(!np); |
| 52 | * will be device-tree, or they also want it inverted. | ||
| 53 | */ | ||
| 54 | bool invert_interrupt = true; | ||
| 55 | u32 val; | ||
| 56 | 52 | ||
| 57 | #ifdef CONFIG_OF | 53 | tegra_pmc_base = of_iomap(np, 0); |
| 58 | if (of_have_populated_dt()) { | ||
| 59 | struct device_node *np; | ||
| 60 | 54 | ||
| 61 | invert_interrupt = false; | 55 | tegra_pmc_invert_interrupt = of_property_read_bool(np, |
| 56 | "nvidia,invert-interrupt"); | ||
| 57 | } | ||
| 58 | |||
| 59 | void __init tegra_pmc_init(void) | ||
| 60 | { | ||
| 61 | u32 val; | ||
| 62 | 62 | ||
| 63 | np = of_find_matching_node(NULL, matches); | 63 | tegra_pmc_parse_dt(); |
| 64 | if (np) { | ||
| 65 | if (of_find_property(np, "nvidia,invert-interrupt", | ||
| 66 | NULL)) | ||
| 67 | invert_interrupt = true; | ||
| 68 | } | ||
| 69 | } | ||
| 70 | #endif | ||
| 71 | 64 | ||
| 72 | val = tegra_pmc_readl(PMC_CTRL); | 65 | val = tegra_pmc_readl(PMC_CTRL); |
| 73 | if (invert_interrupt) | 66 | if (tegra_pmc_invert_interrupt) |
| 74 | val |= PMC_CTRL_INTR_LOW; | 67 | val |= PMC_CTRL_INTR_LOW; |
| 75 | else | 68 | else |
| 76 | val &= ~PMC_CTRL_INTR_LOW; | 69 | val &= ~PMC_CTRL_INTR_LOW; |
