blob: 25da04549d04070746463dddabc8f40b71c65e26 [file] [log] [blame]
Oren Weilab841162011-05-15 13:43:41 +03001/*
2 *
3 * Intel Management Engine Interface (Intel MEI) Linux driver
Tomas Winkler733ba912012-02-09 19:25:53 +02004 * Copyright (c) 2003-2012, Intel Corporation.
Oren Weilab841162011-05-15 13:43:41 +03005 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 *
15 */
16
17#ifndef _MEI_DEV_H_
18#define _MEI_DEV_H_
19
20#include <linux/types.h>
Oren Weil9ce178e2011-09-07 09:03:09 +030021#include <linux/watchdog.h>
Tomas Winkler744f0f22012-11-11 17:38:02 +020022#include <linux/poll.h>
Tomas Winkler4f3afe12012-05-09 16:38:59 +030023#include <linux/mei.h>
Oren Weilab841162011-05-15 13:43:41 +030024#include "hw.h"
25
26/*
Oren Weilab841162011-05-15 13:43:41 +030027 * watch dog definition
28 */
Tomas Winkler248ffdf2012-08-16 19:39:42 +030029#define MEI_WD_HDR_SIZE 4
30#define MEI_WD_STOP_MSG_SIZE MEI_WD_HDR_SIZE
31#define MEI_WD_START_MSG_SIZE (MEI_WD_HDR_SIZE + 16)
32
33#define MEI_WD_DEFAULT_TIMEOUT 120 /* seconds */
34#define MEI_WD_MIN_TIMEOUT 120 /* seconds */
35#define MEI_WD_MAX_TIMEOUT 65535 /* seconds */
36
Tomas Winklerc216fde2012-08-16 19:39:43 +030037#define MEI_WD_STOP_TIMEOUT 10 /* msecs */
38
Oren Weilab841162011-05-15 13:43:41 +030039#define MEI_WD_STATE_INDEPENDENCE_MSG_SENT (1 << 0)
40
Tomas Winkleredf1eed2012-02-09 19:25:54 +020041#define MEI_RD_MSG_BUF_SIZE (128 * sizeof(u32))
42
Oren Weil9ce178e2011-09-07 09:03:09 +030043
44/*
Oren Weilab841162011-05-15 13:43:41 +030045 * AMTHI Client UUID
46 */
47extern const uuid_le mei_amthi_guid;
48
49/*
50 * Watchdog Client UUID
51 */
52extern const uuid_le mei_wd_guid;
53
54/*
55 * Watchdog independence state message
56 */
57extern const u8 mei_wd_state_independence_msg[3][4];
58
59/*
Tomas Winkler1e2776c2012-08-24 00:35:58 +030060 * Number of Maximum MEI Clients
61 */
62#define MEI_CLIENTS_MAX 256
63
64/*
Oren Weilab841162011-05-15 13:43:41 +030065 * Number of File descriptors/handles
66 * that can be opened to the driver.
67 *
Tomas Winkler1e2776c2012-08-24 00:35:58 +030068 * Limit to 253: 256 Total Clients
69 * minus internal client for MEI Bus Messags
Oren Weilab841162011-05-15 13:43:41 +030070 * minus internal client for AMTHI
71 * minus internal client for Watchdog
72 */
Tomas Winkler1e2776c2012-08-24 00:35:58 +030073#define MEI_MAX_OPEN_HANDLE_COUNT (MEI_CLIENTS_MAX - 3)
Oren Weilab841162011-05-15 13:43:41 +030074
Oren Weilab841162011-05-15 13:43:41 +030075
76/* File state */
77enum file_state {
78 MEI_FILE_INITIALIZING = 0,
79 MEI_FILE_CONNECTING,
80 MEI_FILE_CONNECTED,
81 MEI_FILE_DISCONNECTING,
82 MEI_FILE_DISCONNECTED
83};
84
85/* MEI device states */
Tomas Winklerb210d752012-08-07 00:03:56 +030086enum mei_dev_state {
87 MEI_DEV_INITIALIZING = 0,
88 MEI_DEV_INIT_CLIENTS,
89 MEI_DEV_ENABLED,
90 MEI_DEV_RESETING,
91 MEI_DEV_DISABLED,
92 MEI_DEV_RECOVERING_FROM_RESET,
93 MEI_DEV_POWER_DOWN,
94 MEI_DEV_POWER_UP
Oren Weilab841162011-05-15 13:43:41 +030095};
96
Tomas Winklerb210d752012-08-07 00:03:56 +030097const char *mei_dev_state_str(int state);
98
Justin P. Mattock5f9092f32012-03-12 07:18:09 -070099/* init clients states*/
Oren Weilab841162011-05-15 13:43:41 +0300100enum mei_init_clients_states {
101 MEI_START_MESSAGE = 0,
102 MEI_ENUM_CLIENTS_MESSAGE,
103 MEI_CLIENT_PROPERTIES_MESSAGE
104};
105
106enum iamthif_states {
107 MEI_IAMTHIF_IDLE,
108 MEI_IAMTHIF_WRITING,
109 MEI_IAMTHIF_FLOW_CONTROL,
110 MEI_IAMTHIF_READING,
111 MEI_IAMTHIF_READ_COMPLETE
112};
113
114enum mei_file_transaction_states {
115 MEI_IDLE,
116 MEI_WRITING,
117 MEI_WRITE_COMPLETE,
118 MEI_FLOW_CONTROL,
119 MEI_READING,
120 MEI_READ_COMPLETE
121};
122
Tomas Winklerc216fde2012-08-16 19:39:43 +0300123enum mei_wd_states {
124 MEI_WD_IDLE,
125 MEI_WD_RUNNING,
126 MEI_WD_STOPPING,
127};
128
Tomas Winkler4b8960b2012-11-11 17:38:00 +0200129/**
130 * enum mei_cb_file_ops - file operation associated with the callback
131 * @MEI_FOP_READ - read
132 * @MEI_FOP_WRITE - write
133 * @MEI_FOP_IOCTL - ioctl
134 * @MEI_FOP_OPEN - open
135 * @MEI_FOP_CLOSE - close
136 */
137enum mei_cb_file_ops {
138 MEI_FOP_READ = 0,
139 MEI_FOP_WRITE,
140 MEI_FOP_IOCTL,
141 MEI_FOP_OPEN,
142 MEI_FOP_CLOSE
Oren Weilab841162011-05-15 13:43:41 +0300143};
144
145/*
146 * Intel MEI message data struct
147 */
148struct mei_message_data {
149 u32 size;
Tomas Winkleredf1eed2012-02-09 19:25:54 +0200150 unsigned char *data;
Tomas Winklerf0609392012-09-11 00:43:21 +0300151};
Oren Weilab841162011-05-15 13:43:41 +0300152
153
Tomas Winklerdb3ed432012-11-11 17:37:59 +0200154struct mei_cl;
155
Tomas Winkler4b8960b2012-11-11 17:38:00 +0200156/**
Tomas Winklerdb3ed432012-11-11 17:37:59 +0200157 * struct mei_cl_cb - file operation callback structure
158 *
159 * @cl - file client who is running this operation
Tomas Winkler4b8960b2012-11-11 17:38:00 +0200160 * @fop_type - file operation type
Tomas Winklerdb3ed432012-11-11 17:37:59 +0200161 */
Oren Weilab841162011-05-15 13:43:41 +0300162struct mei_cl_cb {
Tomas Winklerfb601ad2012-10-15 12:06:48 +0200163 struct list_head list;
Tomas Winklerdb3ed432012-11-11 17:37:59 +0200164 struct mei_cl *cl;
Tomas Winkler4b8960b2012-11-11 17:38:00 +0200165 enum mei_cb_file_ops fop_type;
Oren Weilab841162011-05-15 13:43:41 +0300166 struct mei_message_data request_buffer;
167 struct mei_message_data response_buffer;
Tomas Winklerebb108ef2012-10-09 16:50:16 +0200168 unsigned long buf_idx;
Oren Weilab841162011-05-15 13:43:41 +0300169 unsigned long read_time;
170 struct file *file_object;
171};
172
173/* MEI client instance carried as file->pirvate_data*/
174struct mei_cl {
175 struct list_head link;
176 struct mei_device *dev;
177 enum file_state state;
178 wait_queue_head_t tx_wait;
179 wait_queue_head_t rx_wait;
180 wait_queue_head_t wait;
181 int read_pending;
182 int status;
183 /* ID of client connected */
184 u8 host_client_id;
185 u8 me_client_id;
186 u8 mei_flow_ctrl_creds;
187 u8 timer_count;
188 enum mei_file_transaction_states reading_state;
189 enum mei_file_transaction_states writing_state;
190 int sm_state;
191 struct mei_cl_cb *read_cb;
192};
193
Tomas Winkler24aadc82012-06-25 23:46:27 +0300194/**
Tomas Winkler5fb54fb2012-11-18 15:13:15 +0200195 * struct mei_device - MEI private device struct
Tomas Winkler24aadc82012-06-25 23:46:27 +0300196 * @hbuf_depth - depth of host(write) buffer
Tomas Winkler5fb54fb2012-11-18 15:13:15 +0200197 * @wr_ext_msg - buffer for hbm control responses (set in read cycle)
Tomas Winkler24aadc82012-06-25 23:46:27 +0300198 */
Oren Weilab841162011-05-15 13:43:41 +0300199struct mei_device {
200 struct pci_dev *pdev; /* pointer to pci device struct */
201 /*
202 * lists of queues
203 */
Tomas Winklere773efc2012-11-11 17:37:58 +0200204 /* array of pointers to aio lists */
Tomas Winklerfb601ad2012-10-15 12:06:48 +0200205 struct mei_cl_cb read_list; /* driver read queue */
206 struct mei_cl_cb write_list; /* driver write queue */
207 struct mei_cl_cb write_waiting_list; /* write waiting queue */
208 struct mei_cl_cb ctrl_wr_list; /* managed write IOCTL list */
209 struct mei_cl_cb ctrl_rd_list; /* managed read IOCTL list */
Oren Weilab841162011-05-15 13:43:41 +0300210
Oren Weilab841162011-05-15 13:43:41 +0300211 /*
212 * list of files
213 */
214 struct list_head file_list;
Tomas Winklereb9af0a2011-05-25 17:28:22 +0300215 long open_handle_count;
Oren Weilab841162011-05-15 13:43:41 +0300216 /*
217 * memory of device
218 */
219 unsigned int mem_base;
220 unsigned int mem_length;
221 void __iomem *mem_addr;
222 /*
223 * lock for the device
224 */
225 struct mutex device_lock; /* device lock */
Oren Weila61c6532011-09-07 09:03:13 +0300226 struct delayed_work timer_work; /* MEI timer delayed work (timeouts) */
Tomas Winklereb9af0a2011-05-25 17:28:22 +0300227 bool recvd_msg;
Oren Weilab841162011-05-15 13:43:41 +0300228 /*
229 * hw states of host and fw(ME)
230 */
231 u32 host_hw_state;
232 u32 me_hw_state;
Tomas Winkler24aadc82012-06-25 23:46:27 +0300233 u8 hbuf_depth;
Oren Weilab841162011-05-15 13:43:41 +0300234 /*
235 * waiting queue for receive message from FW
236 */
237 wait_queue_head_t wait_recvd_msg;
238 wait_queue_head_t wait_stop_wd;
239
240 /*
241 * mei device states
242 */
Tomas Winklerb210d752012-08-07 00:03:56 +0300243 enum mei_dev_state dev_state;
Oren Weilab841162011-05-15 13:43:41 +0300244 enum mei_init_clients_states init_clients_state;
245 u16 init_clients_timer;
Tomas Winklereb9af0a2011-05-25 17:28:22 +0300246 bool need_reset;
Oren Weilab841162011-05-15 13:43:41 +0300247
Tomas Winkleredf1eed2012-02-09 19:25:54 +0200248 unsigned char rd_msg_buf[MEI_RD_MSG_BUF_SIZE]; /* control messages */
Oren Weilab841162011-05-15 13:43:41 +0300249 u32 rd_msg_hdr;
Tomas Winkler5fb54fb2012-11-18 15:13:15 +0200250 u32 wr_msg_buf[128]; /* used for control messages */
251 struct {
252 struct mei_msg_hdr hdr;
253 unsigned char data[4]; /* All HBM messages are 4 bytes */
254 } wr_ext_msg; /* for control responses */
Oren Weilab841162011-05-15 13:43:41 +0300255
256 struct hbm_version version;
257
Oren Weilab841162011-05-15 13:43:41 +0300258 struct mei_me_client *me_clients; /* Note: memory has to be allocated */
259 DECLARE_BITMAP(me_clients_map, MEI_CLIENTS_MAX);
260 DECLARE_BITMAP(host_clients_map, MEI_CLIENTS_MAX);
Tomas Winklercf9673d2011-06-06 10:44:33 +0300261 u8 me_clients_num;
Oren Weilab841162011-05-15 13:43:41 +0300262 u8 me_client_presentation_num;
263 u8 me_client_index;
Tomas Winklereb9af0a2011-05-25 17:28:22 +0300264 bool mei_host_buffer_is_empty;
Oren Weilab841162011-05-15 13:43:41 +0300265
Tomas Winklereb9af0a2011-05-25 17:28:22 +0300266 struct mei_cl wd_cl;
Tomas Winklerc216fde2012-08-16 19:39:43 +0300267 enum mei_wd_states wd_state;
Tomas Winklereb9af0a2011-05-25 17:28:22 +0300268 bool wd_pending;
Tomas Winklerc216fde2012-08-16 19:39:43 +0300269 u16 wd_timeout;
Tomas Winkler248ffdf2012-08-16 19:39:42 +0300270 unsigned char wd_data[MEI_WD_START_MSG_SIZE];
Oren Weilab841162011-05-15 13:43:41 +0300271
272
Tomas Winklere773efc2012-11-11 17:37:58 +0200273 /* amthif list for cmd waiting */
274 struct mei_cl_cb amthif_cmd_list;
275 /* driver managed amthif list for reading completed amthif cmd data */
276 struct mei_cl_cb amthif_rd_complete_list;
Oren Weilab841162011-05-15 13:43:41 +0300277 struct file *iamthif_file_object;
278 struct mei_cl iamthif_cl;
Tomas Winklereb9af0a2011-05-25 17:28:22 +0300279 struct mei_cl_cb *iamthif_current_cb;
Oren Weilab841162011-05-15 13:43:41 +0300280 int iamthif_mtu;
281 unsigned long iamthif_timer;
282 u32 iamthif_stall_timer;
283 unsigned char *iamthif_msg_buf; /* Note: memory has to be allocated */
284 u32 iamthif_msg_buf_size;
285 u32 iamthif_msg_buf_index;
Oren Weilab841162011-05-15 13:43:41 +0300286 enum iamthif_states iamthif_state;
Tomas Winklereb9af0a2011-05-25 17:28:22 +0300287 bool iamthif_flow_control_pending;
288 bool iamthif_ioctl;
289 bool iamthif_canceled;
Samuel Ortizc1174c02012-11-18 15:13:20 +0200290
291 struct work_struct init_work;
Oren Weilab841162011-05-15 13:43:41 +0300292};
293
Tomas Winkler3870c322012-11-01 21:17:14 +0200294static inline unsigned long mei_secs_to_jiffies(unsigned long sec)
295{
296 return msecs_to_jiffies(sec * MSEC_PER_SEC);
297}
298
Oren Weilab841162011-05-15 13:43:41 +0300299
300/*
301 * mei init function prototypes
302 */
Tomas Winklerc95efb72011-05-25 17:28:21 +0300303struct mei_device *mei_device_init(struct pci_dev *pdev);
Oren Weilab841162011-05-15 13:43:41 +0300304void mei_reset(struct mei_device *dev, int interrupts);
305int mei_hw_init(struct mei_device *dev);
306int mei_task_initialize_clients(void *data);
307int mei_initialize_clients(struct mei_device *dev);
Oren Weilab841162011-05-15 13:43:41 +0300308int mei_disconnect_host_client(struct mei_device *dev, struct mei_cl *cl);
Tomas Winklerc95efb72011-05-25 17:28:21 +0300309void mei_allocate_me_clients_storage(struct mei_device *dev);
Oren Weilab841162011-05-15 13:43:41 +0300310
Oren Weilab841162011-05-15 13:43:41 +0300311
Tomas Winklerff8b2f42012-11-11 17:38:03 +0200312int mei_me_cl_link(struct mei_device *dev, struct mei_cl *cl,
Tomas Winkler07b509b2012-07-23 14:05:39 +0300313 const uuid_le *cguid, u8 host_client_id);
Tomas Winklerff8b2f42012-11-11 17:38:03 +0200314void mei_me_cl_unlink(struct mei_device *dev, struct mei_cl *cl);
Tomas Winkler07b509b2012-07-23 14:05:39 +0300315int mei_me_cl_by_uuid(const struct mei_device *dev, const uuid_le *cuuid);
316int mei_me_cl_by_id(struct mei_device *dev, u8 client_id);
Oren Weilab841162011-05-15 13:43:41 +0300317
318/*
Tomas Winkler601a1ef2012-10-09 16:50:20 +0200319 * MEI IO Functions
Tomas Winkler0288c7c2011-06-06 10:44:34 +0300320 */
Tomas Winkler664df382012-10-11 16:35:08 +0200321struct mei_cl_cb *mei_io_cb_init(struct mei_cl *cl, struct file *fp);
Tomas Winkler601a1ef2012-10-09 16:50:20 +0200322void mei_io_cb_free(struct mei_cl_cb *priv_cb);
Tomas Winkler664df382012-10-11 16:35:08 +0200323int mei_io_cb_alloc_req_buf(struct mei_cl_cb *cb, size_t length);
324int mei_io_cb_alloc_resp_buf(struct mei_cl_cb *cb, size_t length);
325
Tomas Winkler601a1ef2012-10-09 16:50:20 +0200326
Tomas Winklerfb601ad2012-10-15 12:06:48 +0200327/**
328 * mei_io_list_init - Sets up a queue list.
329 *
330 * @list: An instance cl callback structure
331 */
332static inline void mei_io_list_init(struct mei_cl_cb *list)
333{
334 INIT_LIST_HEAD(&list->list);
335}
336void mei_io_list_flush(struct mei_cl_cb *list, struct mei_cl *cl);
Tomas Winkler0288c7c2011-06-06 10:44:34 +0300337
338/*
Tomas Winklerc95efb72011-05-25 17:28:21 +0300339 * MEI ME Client Functions
340 */
341
342struct mei_cl *mei_cl_allocate(struct mei_device *dev);
Tomas Winkler0288c7c2011-06-06 10:44:34 +0300343void mei_cl_init(struct mei_cl *cl, struct mei_device *dev);
344int mei_cl_flush_queues(struct mei_cl *cl);
345/**
346 * mei_cl_cmp_id - tells if file private data have same id
347 *
348 * @fe1: private data of 1. file object
349 * @fe2: private data of 2. file object
350 *
351 * returns true - if ids are the same and not NULL
352 */
353static inline bool mei_cl_cmp_id(const struct mei_cl *cl1,
354 const struct mei_cl *cl2)
355{
356 return cl1 && cl2 &&
357 (cl1->host_client_id == cl2->host_client_id) &&
358 (cl1->me_client_id == cl2->me_client_id);
359}
360
Tomas Winklerc95efb72011-05-25 17:28:21 +0300361
362
363/*
364 * MEI Host Client Functions
365 */
366void mei_host_start_message(struct mei_device *dev);
367void mei_host_enum_clients_message(struct mei_device *dev);
Samuel Ortizc1174c02012-11-18 15:13:20 +0200368int mei_host_client_enumerate(struct mei_device *dev);
369void mei_host_client_init(struct work_struct *work);
Tomas Winklerc95efb72011-05-25 17:28:21 +0300370
371/*
372 * MEI interrupt functions prototype
Oren Weilab841162011-05-15 13:43:41 +0300373 */
374irqreturn_t mei_interrupt_quick_handler(int irq, void *dev_id);
Tomas Winklerc95efb72011-05-25 17:28:21 +0300375irqreturn_t mei_interrupt_thread_handler(int irq, void *dev_id);
Oren Weila61c6532011-09-07 09:03:13 +0300376void mei_timer(struct work_struct *work);
Oren Weilab841162011-05-15 13:43:41 +0300377
378/*
Tomas Winklerc95efb72011-05-25 17:28:21 +0300379 * MEI input output function prototype
Oren Weilab841162011-05-15 13:43:41 +0300380 */
381int mei_ioctl_connect_client(struct file *file,
382 struct mei_connect_client_data *data);
383
384int mei_start_read(struct mei_device *dev, struct mei_cl *cl);
385
Oren Weilab841162011-05-15 13:43:41 +0300386
Tomas Winkler19838fb2012-11-01 21:17:15 +0200387/*
388 * AMTHIF - AMT Host Interface Functions
389 */
390void mei_amthif_reset_params(struct mei_device *dev);
391
392void mei_amthif_host_init(struct mei_device *dev);
393
394int mei_amthif_write(struct mei_device *dev, struct mei_cl_cb *priv_cb);
395
396int mei_amthif_read(struct mei_device *dev, struct file *file,
Tomas Winkler744f0f22012-11-11 17:38:02 +0200397 char __user *ubuf, size_t length, loff_t *offset);
398
399unsigned int mei_amthif_poll(struct mei_device *dev,
400 struct file *file, poll_table *wait);
Oren Weilab841162011-05-15 13:43:41 +0300401
Tomas Winklera562d5c2012-11-11 17:38:01 +0200402int mei_amthif_release(struct mei_device *dev, struct file *file);
403
Tomas Winkler19838fb2012-11-01 21:17:15 +0200404struct mei_cl_cb *mei_amthif_find_read_list_entry(struct mei_device *dev,
Oren Weilab841162011-05-15 13:43:41 +0300405 struct file *file);
406
Tomas Winkler19838fb2012-11-01 21:17:15 +0200407void mei_amthif_run_next_cmd(struct mei_device *dev);
Oren Weilab841162011-05-15 13:43:41 +0300408
Oren Weilab841162011-05-15 13:43:41 +0300409
Tomas Winkler19838fb2012-11-01 21:17:15 +0200410int mei_amthif_read_message(struct mei_cl_cb *complete_list,
411 struct mei_device *dev, struct mei_msg_hdr *mei_hdr);
412
Tomas Winkler24c656e2012-11-18 15:13:17 +0200413int mei_amthif_irq_write_complete(struct mei_device *dev, s32 *slots,
414 struct mei_cl_cb *cb, struct mei_cl_cb *cmpl_list);
Tomas Winkler19838fb2012-11-01 21:17:15 +0200415
416void mei_amthif_complete(struct mei_device *dev, struct mei_cl_cb *cb);
417int mei_amthif_irq_read_message(struct mei_cl_cb *complete_list,
418 struct mei_device *dev, struct mei_msg_hdr *mei_hdr);
419int mei_amthif_irq_read(struct mei_device *dev, s32 *slots);
Oren Weilab841162011-05-15 13:43:41 +0300420
421/*
422 * Register Access Function
423 */
424
425/**
426 * mei_reg_read - Reads 32bit data from the mei device
427 *
428 * @dev: the device structure
429 * @offset: offset from which to read the data
430 *
Oren Weil92eb4012011-09-07 09:03:08 +0300431 * returns register value (u32)
Oren Weilab841162011-05-15 13:43:41 +0300432 */
Tomas Winkler4a0d6a72012-07-04 19:24:49 +0300433static inline u32 mei_reg_read(const struct mei_device *dev,
434 unsigned long offset)
Oren Weilab841162011-05-15 13:43:41 +0300435{
436 return ioread32(dev->mem_addr + offset);
437}
438
439/**
440 * mei_reg_write - Writes 32bit data to the mei device
441 *
442 * @dev: the device structure
443 * @offset: offset from which to write the data
Oren Weil92eb4012011-09-07 09:03:08 +0300444 * @value: register value to write (u32)
Oren Weilab841162011-05-15 13:43:41 +0300445 */
Tomas Winkler4a0d6a72012-07-04 19:24:49 +0300446static inline void mei_reg_write(const struct mei_device *dev,
447 unsigned long offset, u32 value)
Oren Weilab841162011-05-15 13:43:41 +0300448{
449 iowrite32(value, dev->mem_addr + offset);
450}
451
452/**
453 * mei_hcsr_read - Reads 32bit data from the host CSR
454 *
455 * @dev: the device structure
456 *
457 * returns the byte read.
458 */
Tomas Winkler4a0d6a72012-07-04 19:24:49 +0300459static inline u32 mei_hcsr_read(const struct mei_device *dev)
Oren Weilab841162011-05-15 13:43:41 +0300460{
461 return mei_reg_read(dev, H_CSR);
462}
463
464/**
465 * mei_mecsr_read - Reads 32bit data from the ME CSR
466 *
467 * @dev: the device structure
468 *
469 * returns ME_CSR_HA register value (u32)
470 */
Tomas Winkler4a0d6a72012-07-04 19:24:49 +0300471static inline u32 mei_mecsr_read(const struct mei_device *dev)
Oren Weilab841162011-05-15 13:43:41 +0300472{
473 return mei_reg_read(dev, ME_CSR_HA);
474}
475
476/**
477 * get_me_cb_rw - Reads 32bit data from the mei ME_CB_RW register
478 *
479 * @dev: the device structure
480 *
481 * returns ME_CB_RW register value (u32)
482 */
Tomas Winkler4a0d6a72012-07-04 19:24:49 +0300483static inline u32 mei_mecbrw_read(const struct mei_device *dev)
Oren Weilab841162011-05-15 13:43:41 +0300484{
485 return mei_reg_read(dev, ME_CB_RW);
486}
487
488
489/*
490 * mei interface function prototypes
491 */
492void mei_hcsr_set(struct mei_device *dev);
493void mei_csr_clear_his(struct mei_device *dev);
494
495void mei_enable_interrupts(struct mei_device *dev);
496void mei_disable_interrupts(struct mei_device *dev);
497
Tomas Winkler5bd64712012-11-18 15:13:14 +0200498static inline struct mei_msg_hdr *mei_hbm_hdr(u32 *buf, size_t length)
499{
500 struct mei_msg_hdr *hdr = (struct mei_msg_hdr *)buf;
501 hdr->host_addr = 0;
502 hdr->me_addr = 0;
503 hdr->length = length;
504 hdr->msg_complete = 1;
505 hdr->reserved = 0;
506 return hdr;
507}
508
Oren Weilab841162011-05-15 13:43:41 +0300509#endif