1 .. SPDX-License-Identifier: GPL-2.0 2 3 ============================================== 4 Intel(R) Management Engine (ME) Client bus API 5 ============================================== 6 7 8 Rationale 9 ========= 10 11 The MEI character device is useful for dedicat 12 data to the many FW appliance found in Intel's 13 However, for some of the ME functionalities it 14 stack and expose them through existing kernel 15 16 In order to plug seamlessly into the kernel de 17 bus abstraction on top of the MEI driver. This 18 for the various MEI features as a stand alone 19 Existing device drivers can even potentially b 20 the existing code. 21 22 23 MEI CL bus API 24 ============== 25 26 A driver implementation for an MEI Client is v 27 based device drivers. The driver registers its 28 the ``struct mei_cl_driver`` structure defined 29 30 .. code-block:: C 31 32 struct mei_cl_driver { 33 struct device_driver driver; 34 const char *name; 35 36 const struct mei_cl_device_id 37 38 int (*probe)(struct mei_cl_dev 39 int (*remove)(struct mei_cl_de 40 }; 41 42 43 44 The mei_cl_device_id structure defined in :fil 45 driver to bind itself against a device name. 46 47 .. code-block:: C 48 49 struct mei_cl_device_id { 50 char name[MEI_CL_NAME_SIZE]; 51 uuid_le uuid; 52 __u8 version; 53 kernel_ulong_t driver_info; 54 }; 55 56 To actually register a driver on the ME Client 57 API. This is typically called at module initia 58 59 Once the driver is registered and bound to the 60 try to do some I/O on this bus and this should 61 and :c:func:`mei_cl_recv` functions. More deta 62 63 In order for a driver to be notified about pen 64 should register a callback via :c:func:`mei_cl 65 :c:func:`mei_cldev_register_notify_cb` functio 66 67 .. _api: 68 69 API: 70 ---- 71 .. kernel-doc:: drivers/misc/mei/bus.c 72 :export: drivers/misc/mei/bus.c 73 74 75 76 Example 77 ======= 78 79 As a theoretical example let's pretend the ME 80 The driver init and exit routines for this dev 81 82 .. code-block:: C 83 84 #define CONTACT_DRIVER_NAME "contact" 85 86 static struct mei_cl_device_id contact 87 { CONTACT_DRIVER_NAME, }, 88 89 /* required last entry */ 90 { } 91 }; 92 MODULE_DEVICE_TABLE(mei_cl, contact_me 93 94 static struct mei_cl_driver contact_dr 95 .id_table = contact_mei_tbl, 96 .name = CONTACT_DRIVER_NAME, 97 98 .probe = contact_probe, 99 .remove = contact_remove, 100 }; 101 102 static int contact_init(void) 103 { 104 int r; 105 106 r = mei_cl_driver_register(&co 107 if (r) { 108 pr_err(CONTACT_DRIVER_ 109 return r; 110 } 111 112 return 0; 113 } 114 115 static void __exit contact_exit(void) 116 { 117 mei_cl_driver_unregister(&cont 118 } 119 120 module_init(contact_init); 121 module_exit(contact_exit); 122 123 And the driver's simplified probe routine woul 124 125 .. code-block:: C 126 127 int contact_probe(struct mei_cl_device 128 { 129 [...] 130 mei_cldev_enable(dev); 131 132 mei_cldev_register_rx_cb(dev, 133 134 return 0; 135 } 136 137 In the probe routine the driver first enable t 138 an rx handler which is as close as it can get 139 The handler implementation will typically call 140 process received data. 141 142 .. code-block:: C 143 144 #define MAX_PAYLOAD 128 145 #define HDR_SIZE 4 146 static void conntact_rx_cb(struct mei_ 147 { 148 struct contact *c = mei_cldev_ 149 unsigned char payload[MAX_PAYL 150 ssize_t payload_sz; 151 152 payload_sz = mei_cldev_recv(cl 153 if (reply_size < HDR_SIZE) { 154 return; 155 } 156 157 c->process_rx(payload); 158 159 } 160 161 MEI Client Bus Drivers 162 ====================== 163 164 .. toctree:: 165 :maxdepth: 2 166 167 hdcp 168 nfc
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.