aboutsummaryrefslogtreecommitdiff
path: root/include/linux/vexpress.h
blob: 81fa998e7ad195b3e9ad4d4e2ea9ec66ffdd464a (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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
/*
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 *
 * 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.
 *
 * Copyright (C) 2012 ARM Limited
 */

#ifndef _LINUX_VEXPRESS_H
#define _LINUX_VEXPRESS_H

#include <linux/device.h>
#include <linux/err.h>

#define VEXPRESS_SITE_MB		0
#define VEXPRESS_SITE_DB1		1
#define VEXPRESS_SITE_DB2		2
#define VEXPRESS_SITE_MASTER		0xf

#define VEXPRESS_CONFIG_STATUS_DONE	0
#define VEXPRESS_CONFIG_STATUS_WAIT	1

#define VEXPRESS_GPIO_MMC_CARDIN	0
#define VEXPRESS_GPIO_MMC_WPROT		1
#define VEXPRESS_GPIO_FLASH_WPn		2
#define VEXPRESS_GPIO_LED0		3
#define VEXPRESS_GPIO_LED1		4
#define VEXPRESS_GPIO_LED2		5
#define VEXPRESS_GPIO_LED3		6
#define VEXPRESS_GPIO_LED4		7
#define VEXPRESS_GPIO_LED5		8
#define VEXPRESS_GPIO_LED6		9
#define VEXPRESS_GPIO_LED7		10

#define VEXPRESS_RES_FUNC(_site, _func)	\
{					\
	.start = (_site),		\
	.end = (_func),			\
	.flags = IORESOURCE_BUS,	\
}

/* Config bridge API */

/**
 * struct vexpress_config_bridge_info - description of the platform
 * configuration infrastructure bridge.
 *
 * @name:	Bridge name
 *
 * @func_get:	Obtains pointer to a configuration function for a given
 *		device or a Device Tree node, to be used with @func_put
 *		and @func_exec. The node pointer should take precedence
 *		over device pointer when both are passed.
 *
 * @func_put:	Tells the bridge that the function will not be used any
 *		more, so all allocated resources can be released.
 *
 * @func_exec:	Executes a configuration function read or write operation.
 *		The offset selects a 32 bit word of the value accessed.
 *		Must return VEXPRESS_CONFIG_STATUS_DONE when operation
 *		is finished immediately, VEXPRESS_CONFIG_STATUS_WAIT when
 *		will be completed in some time or negative value in case
 *		of error.
 */
struct vexpress_config_bridge_info {
	const char *name;
	void *(*func_get)(struct device *dev, struct device_node *node);
	void (*func_put)(void *func);
	int (*func_exec)(void *func, int offset, bool write, u32 *data);
};

struct vexpress_config_bridge;

struct vexpress_config_bridge *vexpress_config_bridge_register(
		struct device_node *node,
		struct vexpress_config_bridge_info *info);
void vexpress_config_bridge_unregister(struct vexpress_config_bridge *bridge);

void vexpress_config_complete(struct vexpress_config_bridge *bridge,
		int status);

/* Config function API */

struct vexpress_config_func;

struct vexpress_config_func *__vexpress_config_func_get(struct device *dev,
		struct device_node *node);
#define vexpress_config_func_get_by_dev(dev) \
		__vexpress_config_func_get(dev, NULL)
#define vexpress_config_func_get_by_node(node) \
		__vexpress_config_func_get(NULL, node)
void vexpress_config_func_put(struct vexpress_config_func *func);

/* Both may sleep! */
int vexpress_config_read(struct vexpress_config_func *func, int offset,
		u32 *data);
int vexpress_config_write(struct vexpress_config_func *func, int offset,
		u32 data);

/* Platform control */

u32 vexpress_get_procid(int site);
u32 vexpress_get_hbi(int site);
void *vexpress_get_24mhz_clock_base(void);
void vexpress_flags_set(u32 data);

#define vexpress_get_site_by_node(node) __vexpress_get_site(NULL, node)
#define vexpress_get_site_by_dev(dev) __vexpress_get_site(dev, NULL)
unsigned __vexpress_get_site(struct device *dev, struct device_node *node);

void vexpress_sysreg_early_init(void __iomem *base);
void vexpress_sysreg_of_early_init(void);

void vexpress_power_off(void);
void vexpress_restart(char str, const char *cmd);

/* Clocks */

struct clk *vexpress_osc_setup(struct device *dev);
void vexpress_osc_of_setup(struct device_node *node);

struct clk *vexpress_clk_register_spc(const char *name, int cluster_id);
void vexpress_clk_of_register_spc(void);

void vexpress_clk_init(void __iomem *sp810_base);
void vexpress_clk_of_init(void);

/* SPC */

#define	VEXPRESS_SPC_WAKE_INTR_IRQ(cluster, cpu) \
			(1 << (4 * (cluster) + (cpu)))
#define	VEXPRESS_SPC_WAKE_INTR_FIQ(cluster, cpu) \
			(1 << (7 * (cluster) + (cpu)))
#define	VEXPRESS_SPC_WAKE_INTR_SWDOG			(1 << 10)
#define	VEXPRESS_SPC_WAKE_INTR_GTIMER		(1 << 11)
#define	VEXPRESS_SPC_WAKE_INTR_MASK			0xFFF

#ifdef CONFIG_ARM_SPC

extern u32 vexpress_spc_get_clusterid(int cpu_part_no);
extern u32 vexpress_spc_read_rsthold_reg(int cluster);
extern u32 vexpress_spc_read_rststat_reg(int cluster);
extern u32 vexpress_scc_read_rststat(int cluster);
extern u32 vexpress_spc_get_wake_intr(int raw);
extern int vexpress_spc_standbywfi_status(int cluster, int cpu);
extern int vexpress_spc_standbywfil2_status(int cluster);
extern int vexpress_spc_set_cpu_wakeup_irq(u32 cpu, u32 cluster, u32 set);
extern int vexpress_spc_set_global_wakeup_intr(u32 set);
extern unsigned int *vexpress_spc_get_freq_table(uint32_t cluster, int *count);
extern int vexpress_spc_get_performance(int cluster, u32 *freq);
extern int vexpress_spc_set_performance(int cluster, u32 freq);
extern int vexpress_spc_wfi_cpustat(int cluster);
extern void vexpress_spc_set_wake_intr(u32 mask);
extern void vexpress_spc_write_bxaddr_reg(int cluster, int cpu, u32 val);
extern int vexpress_spc_get_nb_cpus(int cluster);
extern void vexpress_spc_write_rsthold_reg(int cluster, u32 value);
extern void vexpress_spc_powerdown_enable(int cluster, int enable);
extern void vexpress_spc_adb400_pd_enable(int cluster, int enable);
extern void vexpress_spc_wfi_cpureset(int cluster, int cpu, int enable);
extern void vexpress_spc_wfi_cluster_reset(int cluster, int enable);
extern void vexpress_scc_ctl_snoops(int cluster, int enable);
extern bool vexpress_spc_check_loaded(void);
#else
static inline int vexpress_spc_set_cpu_wakeup_irq(u32 cpu, u32 cluster, u32 set)
{
	return  0;
}

static inline int vexpress_spc_set_global_wakeup_intr(u32 set)
{
	return 0;
}

static inline int vexpress_spc_standbywfi_status(int cluster, int cpu)
{
	return 0;
}

static inline int vexpress_spc_standbywfil2_status(int cluster)
{
	return 0;
}

static inline u32 vexpress_spc_get_clusterid(int cpu_part_no)
{
	return 0;
}

static inline u32 vexpress_spc_read_rsthold_reg(int cluster)
{
	return 0;
}

static inline u32 vexpress_spc_read_rststat_reg(int cluster)
{
	return 0;
}

static inline void vexpress_spc_write_bxaddr_reg(int cluster, int cpu, u32 val)
{
}

static inline void vexpress_spc_write_rsthold_reg(int cluster, u32 value)
{
}

static inline u32 vexpress_scc_read_rststat(int cluster)
{
	return 0;
}

static inline unsigned int *vexpress_spc_get_freq_table(uint32_t cluster, int *count)
{
	return ERR_PTR(-ENOSYS);
}

static inline int vexpress_spc_get_performance(int cluster, u32 *freq)
{
	return -ENOSYS;
}
static inline int vexpress_spc_set_performance(int cluster, u32 freq)
{
	return -ENOSYS;
}
static inline void vexpress_spc_set_wake_intr(u32 mask) { }
static inline u32 vexpress_spc_get_wake_intr(int raw) { return 0; }
static inline void vexpress_spc_powerdown_enable(int cluster, int enable) { }
static inline void vexpress_spc_adb400_pd_enable(int cluster, int enable) { }
static inline void vexpress_spc_wfi_cpureset(int cluster, int cpu, int enable)
{ }
static inline int vexpress_spc_wfi_cpustat(int cluster) { return 0; }
static inline void vexpress_spc_wfi_cluster_reset(int cluster, int enable) { }
static inline bool vexpress_spc_check_loaded(void)
{
	return false;
}
static inline void vexpress_scc_ctl_snoops(int cluster, int enable) { }
#endif

#endif