2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License version 2 as
4 * published by the Free Software Foundation.
6 * This program is distributed in the hope that it will be useful,
7 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 * GNU General Public License for more details.
11 * Copyright (C) 2012 ARM Limited
14 #ifndef _LINUX_VEXPRESS_H
15 #define _LINUX_VEXPRESS_H
17 #include <linux/device.h>
19 #define VEXPRESS_SITE_MB 0
20 #define VEXPRESS_SITE_DB1 1
21 #define VEXPRESS_SITE_DB2 2
22 #define VEXPRESS_SITE_MASTER 0xf
24 #define VEXPRESS_CONFIG_STATUS_DONE 0
25 #define VEXPRESS_CONFIG_STATUS_WAIT 1
27 /* Config bridge API */
30 * struct vexpress_config_bridge_info - description of the platform
31 * configuration infrastructure bridge.
35 * @func_get: Obtains pointer to a configuration function for a given
36 * device or a Device Tree node, to be used with @func_put
37 * and @func_exec. The node pointer should take precedence
38 * over device pointer when both are passed.
40 * @func_put: Tells the bridge that the function will not be used any
41 * more, so all allocated resources can be released.
43 * @func_exec: Executes a configuration function read or write operation.
44 * The offset selects a 32 bit word of the value accessed.
45 * Must return VEXPRESS_CONFIG_STATUS_DONE when operation
46 * is finished immediately, VEXPRESS_CONFIG_STATUS_WAIT when
47 * will be completed in some time or negative value in case
50 struct vexpress_config_bridge_info {
52 void *(*func_get)(struct device *dev, struct device_node *node);
53 void (*func_put)(void *func);
54 int (*func_exec)(void *func, int offset, bool write, u32 *data);
57 struct vexpress_config_bridge;
59 struct vexpress_config_bridge *vexpress_config_bridge_register(
60 struct device_node *node,
61 struct vexpress_config_bridge_info *info);
62 void vexpress_config_bridge_unregister(struct vexpress_config_bridge *bridge);
64 void vexpress_config_complete(struct vexpress_config_bridge *bridge,
67 /* Config function API */
69 struct vexpress_config_func;
71 struct vexpress_config_func *__vexpress_config_func_get(struct device *dev,
72 struct device_node *node);
73 #define vexpress_config_func_get_by_dev(dev) \
74 __vexpress_config_func_get(dev, NULL)
75 #define vexpress_config_func_get_by_node(node) \
76 __vexpress_config_func_get(NULL, node)
77 void vexpress_config_func_put(struct vexpress_config_func *func);
80 int vexpress_config_read(struct vexpress_config_func *func, int offset,
82 int vexpress_config_write(struct vexpress_config_func *func, int offset,