summaryrefslogtreecommitdiff
path: root/arch/arm/mach-tegra/powergate-priv.h
blob: 946026ef56bab6ba8241f7c9205e10f3a937f118 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
/*
 * Copyright (c) 2012-2013, NVIDIA CORPORATION.  All rights reserved.
 *
 * This software is licensed under the terms of the GNU General Public
 * License version 2, as published by the Free Software Foundation, and
 * may be copied, distributed, and modified under those terms.
 *
 * This program is distributed in the hope that 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.
 *
 */

#ifndef __POWERGATE_PRIV_H__
#define __POWERGATE_PRIV_H__

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/clk.h>
#include <linux/clk/tegra.h>
#include <linux/err.h>
#include <linux/spinlock.h>
#include <linux/io.h>
#include <linux/tegra-powergate.h>

#include "clock.h"
#include "iomap.h"

#define MAX_CLK_EN_NUM			9
#define MAX_HOTRESET_CLIENT_NUM		4

#define PWRGATE_CLAMP_STATUS	0x2c
#define PWRGATE_TOGGLE		0x30
#define PWRGATE_TOGGLE_START	(1 << 8)
#define REMOVE_CLAMPING		0x34
#define PWRGATE_STATUS		0x38

/* MC register read/write */
static void __iomem *mc = IO_ADDRESS(TEGRA_MC_BASE);
static inline u32 mc_read(unsigned long reg)
{
	return readl(mc + reg);
}

static inline void mc_write(u32 val, unsigned long reg)
{
	writel_relaxed(val, mc + reg);
}

/* PMC register read/write */
static void __iomem *pmc = IO_ADDRESS(TEGRA_PMC_BASE);
static inline u32 pmc_read(unsigned long reg)
{
	return readl(pmc + reg);
}

static inline void pmc_write(u32 val, unsigned long reg)
{
	writel_relaxed(val, pmc + reg);
}

enum clk_type {
	CLK_AND_RST,
	RST_ONLY,
	CLK_ONLY,
};

struct partition_clk_info {
	const char *clk_name;
	enum clk_type clk_type;
	struct clk *clk_ptr;
};

struct powergate_partition_info {
	const char *name;
	struct partition_clk_info clk_info[MAX_CLK_EN_NUM];
};

struct powergate_ops {
	const char *soc_name;

	int num_powerdomains;
	int num_cpu_domains;
	u8 *cpu_domains;

	spinlock_t *(*get_powergate_lock)(void);

	const char *(*get_powergate_domain_name)(int id);

	int (*powergate_partition)(int);
	int (*unpowergate_partition)(int id);

	int (*powergate_partition_with_clk_off)(int);
	int (*unpowergate_partition_with_clk_on)(int);

	int (*powergate_mc_enable)(int id);
	int (*powergate_mc_disable)(int id);

	int (*powergate_mc_flush)(int id);
	int (*powergate_mc_flush_done)(int id);

	int (*powergate_init_refcount)(void);

	bool (*powergate_check_clamping)(int id);

	bool (*powergate_skip)(int id);

	bool (*powergate_is_powered)(int id);
};

void get_clk_info(struct powergate_partition_info *pg_info);
int tegra_powergate_remove_clamping(int id);
int partition_clk_enable(struct powergate_partition_info *pg_info);
void partition_clk_disable(struct powergate_partition_info *pg_info);
int is_partition_clk_disabled(struct powergate_partition_info *pg_info);
void powergate_partition_deassert_reset(struct powergate_partition_info *pg_info);
void powergate_partition_assert_reset(struct powergate_partition_info *pg_info);
int tegra_powergate_reset_module(struct powergate_partition_info *pg_info);
int powergate_module(int id);
int unpowergate_module(int id);
int tegra_powergate_set(int id, bool new_state);

/* INIT APIs: New SoC needs to add its support here */
#if defined(CONFIG_ARCH_TEGRA_2x_SOC)
struct powergate_ops *tegra2_powergate_init_chip_support(void);
#else
static inline struct powergate_ops *tegra2_powergate_init_chip_support(void)
{
	return NULL;
}
#endif

#if defined(CONFIG_ARCH_TEGRA_3x_SOC)
struct powergate_ops *tegra3_powergate_init_chip_support(void);
#else
static inline struct powergate_ops *tegra3_powergate_init_chip_support(void)
{
	return NULL;
}
#endif

#if defined(CONFIG_ARCH_TEGRA_11x_SOC)
struct powergate_ops *tegra11x_powergate_init_chip_support(void);
#else
static inline struct powergate_ops *tegra11x_powergate_init_chip_support(void)
{
	return NULL;
}
#endif

#if defined(CONFIG_ARCH_TEGRA_12x_SOC)
struct powergate_ops *tegra12x_powergate_init_chip_support(void);
#else
static inline struct powergate_ops *tegra12x_powergate_init_chip_support(void)
{
	return NULL;
}
#endif

#if defined(CONFIG_ARCH_TEGRA_14x_SOC)
struct powergate_ops *tegra14x_powergate_init_chip_support(void);
#else
static inline struct powergate_ops *tegra14x_powergate_init_chip_support(void)
{
	return NULL;
}
#endif

#endif /* __POWERGATE_PRIV_H__ */