mfd: Versatile Express config infrastructure
[deliverable/linux.git] / include / linux / vexpress.h
CommitLineData
3ecbf05b
PM
1/*
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.
5 *
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.
10 *
11 * Copyright (C) 2012 ARM Limited
12 */
13
14#ifndef _LINUX_VEXPRESS_H
15#define _LINUX_VEXPRESS_H
16
17#include <linux/device.h>
18
19#define VEXPRESS_SITE_MB 0
20#define VEXPRESS_SITE_DB1 1
21#define VEXPRESS_SITE_DB2 2
22#define VEXPRESS_SITE_MASTER 0xf
23
24#define VEXPRESS_CONFIG_STATUS_DONE 0
25#define VEXPRESS_CONFIG_STATUS_WAIT 1
26
27/* Config bridge API */
28
29/**
30 * struct vexpress_config_bridge_info - description of the platform
31 * configuration infrastructure bridge.
32 *
33 * @name: Bridge name
34 *
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.
39 *
40 * @func_put: Tells the bridge that the function will not be used any
41 * more, so all allocated resources can be released.
42 *
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
48 * of error.
49 */
50struct vexpress_config_bridge_info {
51 const char *name;
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);
55};
56
57struct vexpress_config_bridge;
58
59struct vexpress_config_bridge *vexpress_config_bridge_register(
60 struct device_node *node,
61 struct vexpress_config_bridge_info *info);
62void vexpress_config_bridge_unregister(struct vexpress_config_bridge *bridge);
63
64void vexpress_config_complete(struct vexpress_config_bridge *bridge,
65 int status);
66
67/* Config function API */
68
69struct vexpress_config_func;
70
71struct 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)
77void vexpress_config_func_put(struct vexpress_config_func *func);
78
79/* Both may sleep! */
80int vexpress_config_read(struct vexpress_config_func *func, int offset,
81 u32 *data);
82int vexpress_config_write(struct vexpress_config_func *func, int offset,
83 u32 data);
84
85#endif
This page took 0.027772 seconds and 5 git commands to generate.