staging: unisys: move timskmod.h functionality
[deliverable/linux.git] / drivers / staging / unisys / include / visorbus.h
CommitLineData
3703987c
EA
1/* visorbus.h
2 *
3 * Copyright (C) 2010 - 2013 UNISYS CORPORATION
4 * All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or (at
9 * your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
14 * NON INFRINGEMENT. See the GNU General Public License for more
15 * details.
16 */
17
18/*
19 * This header file is to be included by other kernel mode components that
20 * implement a particular kind of visor_device. Each of these other kernel
21 * mode components is called a visor device driver. Refer to visortemplate
22 * for a minimal sample visor device driver.
23 *
24 * There should be nothing in this file that is private to the visorbus
25 * bus implementation itself.
26 *
27 */
28
29#ifndef __VISORBUS_H__
30#define __VISORBUS_H__
31
32#include <linux/device.h>
33#include <linux/module.h>
34#include <linux/kernel.h>
35#include <linux/uuid.h>
36
37#include "periodic_work.h"
3703987c 38#include "channel.h"
f6439218 39
3703987c
EA
40struct visor_driver;
41struct visor_device;
42
43typedef void (*visorbus_state_complete_func) (struct visor_device *dev,
44 int status);
45
46/** This struct describes a specific Supervisor channel, by providing its
47 * GUID, name, and sizes.
48 */
49struct visor_channeltype_descriptor {
50 const uuid_le guid;
51 const char *name;
52 unsigned long min_size;
53 unsigned long max_size;
54};
55
56/** Information provided by each visor driver when it registers with the
57 * visorbus driver.
58 */
59struct visor_driver {
60 const char *name;
61 const char *version;
62 const char *vertag;
63 const char *build_date;
64 const char *build_time;
65 struct module *owner;
66
67 /** Types of channels handled by this driver, ending with 0 GUID.
68 * Our specialized BUS.match() method knows about this list, and
69 * uses it to determine whether this driver will in fact handle a
70 * new device that it has detected.
71 */
72 struct visor_channeltype_descriptor *channel_types;
73
74 /** Called when a new device comes online, by our probe() function
75 * specified by driver.probe() (triggered ultimately by some call
76 * to driver_register() / bus_add_driver() / driver_attach()).
77 */
78 int (*probe)(struct visor_device *dev);
79
80 /** Called when a new device is removed, by our remove() function
81 * specified by driver.remove() (triggered ultimately by some call
82 * to device_release_driver()).
83 */
84 void (*remove)(struct visor_device *dev);
85
86 /** Called periodically, whenever there is a possibility that
87 * "something interesting" may have happened to the channel state.
88 */
89 void (*channel_interrupt)(struct visor_device *dev);
90
91 /** Called to initiate a change of the device's state. If the return
92 * valu`e is < 0, there was an error and the state transition will NOT
93 * occur. If the return value is >= 0, then the state transition was
94 * INITIATED successfully, and complete_func() will be called (or was
95 * just called) with the final status when either the state transition
96 * fails or completes successfully.
97 */
98 int (*pause)(struct visor_device *dev,
99 visorbus_state_complete_func complete_func);
100 int (*resume)(struct visor_device *dev,
101 visorbus_state_complete_func complete_func);
102
103 /** These fields are for private use by the bus driver only. */
104 struct device_driver driver;
105 struct driver_attribute version_attr;
106};
107
108#define to_visor_driver(x) container_of(x, struct visor_driver, driver)
109
110/** A device type for things "plugged" into the visorbus bus */
111
112struct visor_device {
113 /** visor driver can use the visorchannel member with the functions
114 * defined in visorchannel.h to access the channel
115 */
116 struct visorchannel *visorchannel;
117 uuid_le channel_type_guid;
118 u64 channel_bytes;
119
120 /** These fields are for private use by the bus driver only.
121 * A notable exception is that the visor driver can use
122 * visor_get_drvdata() and visor_set_drvdata() to retrieve or stash
123 * private visor driver specific data within the device member.
124 */
125 struct device device;
126 struct list_head list_all;
127 struct periodic_work *periodic_work;
128 bool being_removed;
129 bool responded_to_device_create;
130 struct kobject kobjchannel; /* visorbus<x>/dev<y>/channel/ */
131 struct kobject kobjdevmajorminor; /* visorbus<x>/dev<y>/devmajorminor/*/
132 struct {
133 int major, minor;
134 void *attr; /* private use by devmajorminor_attr.c you can
135 * change this constant to whatever you
136 * want; */
137 } devnodes[5];
138 /* the code will detect and behave appropriately) */
139 struct semaphore visordriver_callback_lock;
140 bool pausing;
141 bool resuming;
142 unsigned long chipset_bus_no;
143 unsigned long chipset_dev_no;
144};
145
146#define to_visor_device(x) container_of(x, struct visor_device, device)
147
148#ifndef STANDALONE_CLIENT
149int visorbus_register_visor_driver(struct visor_driver *);
150void visorbus_unregister_visor_driver(struct visor_driver *);
151int visorbus_read_channel(struct visor_device *dev,
152 unsigned long offset, void *dest,
153 unsigned long nbytes);
154int visorbus_write_channel(struct visor_device *dev,
155 unsigned long offset, void *src,
156 unsigned long nbytes);
157int visorbus_clear_channel(struct visor_device *dev,
158 unsigned long offset, u8 ch, unsigned long nbytes);
159int visorbus_registerdevnode(struct visor_device *dev,
160 const char *name, int major, int minor);
161void visorbus_enable_channel_interrupts(struct visor_device *dev);
162void visorbus_disable_channel_interrupts(struct visor_device *dev);
163#endif
164
dd5f9385 165/* Note that for visorchannel_create()
f6439218
DZ
166 * <channel_bytes> and <guid> arguments may be 0 if we are a channel CLIENT.
167 * In this case, the values can simply be read from the channel header.
168 */
d5b3f1dc 169struct visorchannel *visorchannel_create(u64 physaddr,
f6439218 170 ulong channel_bytes, uuid_le guid);
d5b3f1dc 171struct visorchannel *visorchannel_create_with_lock(u64 physaddr,
f6439218
DZ
172 ulong channel_bytes,
173 uuid_le guid);
f6439218
DZ
174void visorchannel_destroy(struct visorchannel *channel);
175int visorchannel_read(struct visorchannel *channel, ulong offset,
176 void *local, ulong nbytes);
177int visorchannel_write(struct visorchannel *channel, ulong offset,
178 void *local, ulong nbytes);
179int visorchannel_clear(struct visorchannel *channel, ulong offset,
180 u8 ch, ulong nbytes);
779d0752 181bool visorchannel_signalremove(struct visorchannel *channel, u32 queue,
f6439218 182 void *msg);
779d0752 183bool visorchannel_signalinsert(struct visorchannel *channel, u32 queue,
f6439218
DZ
184 void *msg);
185int visorchannel_signalqueue_slots_avail(struct visorchannel *channel,
186 u32 queue);
187int visorchannel_signalqueue_max_slots(struct visorchannel *channel, u32 queue);
d5b3f1dc 188u64 visorchannel_get_physaddr(struct visorchannel *channel);
f6439218
DZ
189ulong visorchannel_get_nbytes(struct visorchannel *channel);
190char *visorchannel_id(struct visorchannel *channel, char *s);
191char *visorchannel_zoneid(struct visorchannel *channel, char *s);
192u64 visorchannel_get_clientpartition(struct visorchannel *channel);
193uuid_le visorchannel_get_uuid(struct visorchannel *channel);
f6439218
DZ
194char *visorchannel_uuid_id(uuid_le *guid, char *s);
195void visorchannel_debug(struct visorchannel *channel, int num_queues,
196 struct seq_file *seq, u32 off);
f6439218
DZ
197void __iomem *visorchannel_get_header(struct visorchannel *channel);
198
3703987c 199#endif
This page took 0.034114 seconds and 5 git commands to generate.