aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation
diff options
context:
space:
mode:
authorSamuel Ortiz <sameo@linux.intel.com>2013-03-27 11:29:53 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-03-29 11:35:47 -0400
commite5354107e14755991da82e0d2a4791db92908d9d (patch)
treeadb8491f5d2a37cbd9304aafb1f762fed4d6c4a5 /Documentation
parent40e0b67be099175d069b0cf46f1102f352d46c61 (diff)
mei: bus: Initial MEI Client bus type implementation
mei client bus will present some of the mei clients as devices for other standard subsystems Implement the probe, remove, match, device addtion routines, along with the sysfs and uevent ones. mei_cl_device_id is also added to mod_devicetable.h A mei-cleint-bus.txt document describing the rationale and the API usage is also added while ABI/testing/sysfs-bus-mei describeis the modalias ABI. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com> Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'Documentation')
-rw-r--r--Documentation/ABI/testing/sysfs-bus-mei7
-rw-r--r--Documentation/misc-devices/mei/mei-client-bus.txt135
2 files changed, 142 insertions, 0 deletions
diff --git a/Documentation/ABI/testing/sysfs-bus-mei b/Documentation/ABI/testing/sysfs-bus-mei
new file mode 100644
index 000000000000..2066f0bbd453
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-bus-mei
@@ -0,0 +1,7 @@
1What: /sys/bus/mei/devices/.../modalias
2Date: March 2013
3KernelVersion: 3.10
4Contact: Samuel Ortiz <sameo@linux.intel.com>
5 linux-mei@linux.intel.com
6Description: Stores the same MODALIAS value emitted by uevent
7 Format: mei:<mei device name>
diff --git a/Documentation/misc-devices/mei/mei-client-bus.txt b/Documentation/misc-devices/mei/mei-client-bus.txt
new file mode 100644
index 000000000000..9dc5ebf94eb1
--- /dev/null
+++ b/Documentation/misc-devices/mei/mei-client-bus.txt
@@ -0,0 +1,135 @@
1Intel(R) Management Engine (ME) Client bus API
2===============================================
3
4
5Rationale
6=========
7MEI misc character device is useful for dedicated applications to send and receive
8data to the many FW appliance found in Intel's ME from the user space.
9However for some of the ME functionalities it make sense to leverage existing software
10stack and expose them through existing kernel subsystems.
11
12In order to plug seamlessly into the kernel device driver model we add kernel virtual
13bus abstraction on top of the MEI driver. This allows implementing linux kernel drivers
14for the various MEI features as a stand alone entities found in their respective subsystem.
15Existing device drivers can even potentially be re-used by adding an MEI CL bus layer to
16the existing code.
17
18
19MEI CL bus API
20===========
21A driver implementation for an MEI Client is very similar to existing bus
22based device drivers. The driver registers itself as an MEI CL bus driver through
23the mei_cl_driver structure:
24
25struct mei_cl_driver {
26 struct device_driver driver;
27 const char *name;
28
29 const struct mei_cl_device_id *id_table;
30
31 int (*probe)(struct mei_cl_device *dev, const struct mei_cl_id *id);
32 int (*remove)(struct mei_cl_device *dev);
33};
34
35struct mei_cl_id {
36 char name[MEI_NAME_SIZE];
37 kernel_ulong_t driver_info;
38};
39
40The mei_cl_id structure allows the driver to bind itself against a device name.
41
42To actually register a driver on the ME Client bus one must call the mei_cl_add_driver()
43API. This is typically called at module init time.
44
45Once registered on the ME Client bus, a driver will typically try to do some I/O on
46this bus and this should be done through the mei_cl_send() and mei_cl_recv()
47routines. The latter is synchronous (blocks and sleeps until data shows up).
48In order for drivers to be notified of pending events waiting for them (e.g.
49an Rx event) they can register an event handler through the
50mei_cl_register_event_cb() routine. Currently only the MEI_EVENT_RX event
51will trigger an event handler call and the driver implementation is supposed
52to call mei_recv() from the event handler in order to fetch the pending
53received buffers.
54
55
56Example
57=======
58As a theoretical example let's pretend the ME comes with a "contact" NFC IP.
59The driver init and exit routines for this device would look like:
60
61#define CONTACT_DRIVER_NAME "contact"
62
63static struct mei_cl_device_id contact_mei_cl_tbl[] = {
64 { CONTACT_DRIVER_NAME, },
65
66 /* required last entry */
67 { }
68};
69MODULE_DEVICE_TABLE(mei_cl, contact_mei_cl_tbl);
70
71static struct mei_cl_driver contact_driver = {
72 .id_table = contact_mei_tbl,
73 .name = CONTACT_DRIVER_NAME,
74
75 .probe = contact_probe,
76 .remove = contact_remove,
77};
78
79static int contact_init(void)
80{
81 int r;
82
83 r = mei_cl_driver_register(&contact_driver);
84 if (r) {
85 pr_err(CONTACT_DRIVER_NAME ": driver registration failed\n");
86 return r;
87 }
88
89 return 0;
90}
91
92static void __exit contact_exit(void)
93{
94 mei_cl_driver_unregister(&contact_driver);
95}
96
97module_init(contact_init);
98module_exit(contact_exit);
99
100And the driver's simplified probe routine would look like that:
101
102int contact_probe(struct mei_cl_device *dev, struct mei_cl_device_id *id)
103{
104 struct contact_driver *contact;
105
106 [...]
107 mei_cl_register_event_cb(dev, contact_event_cb, contact);
108
109 return 0;
110 }
111
112In the probe routine the driver basically registers an ME bus event handler
113which is as close as it can get to registering a threaded IRQ handler.
114The handler implementation will typically call some I/O routine depending on
115the pending events:
116
117#define MAX_NFC_PAYLOAD 128
118
119static void contact_event_cb(struct mei_cl_device *dev, u32 events,
120 void *context)
121{
122 struct contact_driver *contact = context;
123
124 if (events & BIT(MEI_EVENT_RX)) {
125 u8 payload[MAX_NFC_PAYLOAD];
126 int payload_size;
127
128 payload_size = mei_recv(dev, payload, MAX_NFC_PAYLOAD);
129 if (payload_size <= 0)
130 return;
131
132 /* Hook to the NFC subsystem */
133 nfc_hci_recv_frame(contact->hdev, payload, payload_size);
134 }
135}