#include <linux/kernel.h>
#include <linux/clk.h>
-#include <linux/io.h>
#include <linux/of.h>
#include <linux/of_address.h>
#include <linux/tegra-powergate.h>
};
static DEFINE_SPINLOCK(tegra_powergate_lock);
-static void __iomem *tegra_pmc_base;
static bool tegra_pmc_invert_interrupt;
static struct clk *tegra_pclk;
+void __iomem *tegra_pmc_base;
struct pmc_pm_data {
u32 cpu_good_time; /* CPU power good time in uS */
};
static struct pmc_pm_data pmc_pm_data;
-static inline u32 tegra_pmc_readl(u32 reg)
-{
- return readl(tegra_pmc_base + reg);
-}
-
-static inline void tegra_pmc_writel(u32 val, u32 reg)
-{
- writel(val, tegra_pmc_base + reg);
-}
-
static int tegra_pmc_get_cpu_powerdomain_id(int cpuid)
{
if (cpuid <= 0 || cpuid >= num_possible_cpus())
#ifndef __MACH_TEGRA_PMC_H
#define __MACH_TEGRA_PMC_H
+#include <linux/io.h>
#include <linux/reboot.h>
enum tegra_suspend_mode {
void tegra_pmc_suspend_init(void);
#endif
+extern void __iomem *tegra_pmc_base;
+
+static inline u32 tegra_pmc_readl(u32 reg)
+{
+ return readl(tegra_pmc_base + reg);
+}
+
+static inline void tegra_pmc_writel(u32 val, u32 reg)
+{
+ writel(val, tegra_pmc_base + reg);
+}
+
bool tegra_pmc_cpu_is_powered(int cpuid);
int tegra_pmc_cpu_power_on(int cpuid);
int tegra_pmc_cpu_remove_clamping(int cpuid);
#include <linux/tegra-powergate.h>
#include <linux/tegra-soc.h>
-#include "iomap.h"
+#include "pmc.h"
#define DPD_SAMPLE 0x020
#define DPD_SAMPLE_ENABLE (1 << 0)
static DEFINE_SPINLOCK(tegra_powergate_lock);
-static void __iomem *pmc = IO_ADDRESS(TEGRA_PMC_BASE);
-
-static u32 pmc_read(unsigned long reg)
-{
- return readl(pmc + reg);
-}
-
-static void pmc_write(u32 val, unsigned long reg)
-{
- writel(val, pmc + reg);
-}
-
static int tegra_powergate_set(int id, bool new_state)
{
bool status;
spin_lock_irqsave(&tegra_powergate_lock, flags);
- status = pmc_read(PWRGATE_STATUS) & (1 << id);
+ status = tegra_pmc_readl(PWRGATE_STATUS) & (1 << id);
if (status == new_state) {
spin_unlock_irqrestore(&tegra_powergate_lock, flags);
return 0;
}
- pmc_write(PWRGATE_TOGGLE_START | id, PWRGATE_TOGGLE);
+ tegra_pmc_writel(PWRGATE_TOGGLE_START | id, PWRGATE_TOGGLE);
spin_unlock_irqrestore(&tegra_powergate_lock, flags);
if (id < 0 || id >= tegra_num_powerdomains)
return -EINVAL;
- status = pmc_read(PWRGATE_STATUS) & (1 << id);
+ status = tegra_pmc_readl(PWRGATE_STATUS) & (1 << id);
return !!status;
}
*/
if (tegra_chip_id == TEGRA124) {
if (id == TEGRA_POWERGATE_3D) {
- pmc_write(0, GPU_RG_CNTRL);
+ tegra_pmc_writel(0, GPU_RG_CNTRL);
return 0;
}
}
else
mask = (1 << id);
- pmc_write(mask, REMOVE_CLAMPING);
+ tegra_pmc_writel(mask, REMOVE_CLAMPING);
return 0;
}
rate = clk_get_rate(clk);
clk_put(clk);
- pmc_write(DPD_SAMPLE_ENABLE, DPD_SAMPLE);
+ tegra_pmc_writel(DPD_SAMPLE_ENABLE, DPD_SAMPLE);
/* must be at least 200 ns, in APB (PCLK) clock cycles */
value = DIV_ROUND_UP(1000000000, rate);
value = DIV_ROUND_UP(200, value);
- pmc_write(value, SEL_DPD_TIM);
+ tegra_pmc_writel(value, SEL_DPD_TIM);
return 0;
}
timeout = jiffies + msecs_to_jiffies(timeout);
while (time_after(timeout, jiffies)) {
- value = pmc_read(offset);
+ value = tegra_pmc_readl(offset);
if ((value & mask) == val)
return 0;
static void tegra_io_rail_unprepare(void)
{
- pmc_write(DPD_SAMPLE_DISABLE, DPD_SAMPLE);
+ tegra_pmc_writel(DPD_SAMPLE_DISABLE, DPD_SAMPLE);
}
int tegra_io_rail_power_on(int id)
mask = 1 << bit;
- value = pmc_read(request);
+ value = tegra_pmc_readl(request);
value |= mask;
value &= ~IO_DPD_REQ_CODE_MASK;
value |= IO_DPD_REQ_CODE_OFF;
- pmc_write(value, request);
+ tegra_pmc_writel(value, request);
err = tegra_io_rail_poll(status, mask, 0, 250);
if (err < 0)
mask = 1 << bit;
- value = pmc_read(request);
+ value = tegra_pmc_readl(request);
value |= mask;
value &= ~IO_DPD_REQ_CODE_MASK;
value |= IO_DPD_REQ_CODE_ON;
- pmc_write(value, request);
+ tegra_pmc_writel(value, request);
err = tegra_io_rail_poll(status, mask, mask, 250);
if (err < 0)