diff options
Diffstat (limited to 'drivers/misc/mei/mei_dev.h')
| -rw-r--r-- | drivers/misc/mei/mei_dev.h | 350 |
1 files changed, 186 insertions, 164 deletions
diff --git a/drivers/misc/mei/mei_dev.h b/drivers/misc/mei/mei_dev.h index 25da04549d04..cb80166161f0 100644 --- a/drivers/misc/mei/mei_dev.h +++ b/drivers/misc/mei/mei_dev.h | |||
| @@ -21,7 +21,9 @@ | |||
| 21 | #include <linux/watchdog.h> | 21 | #include <linux/watchdog.h> |
| 22 | #include <linux/poll.h> | 22 | #include <linux/poll.h> |
| 23 | #include <linux/mei.h> | 23 | #include <linux/mei.h> |
| 24 | |||
| 24 | #include "hw.h" | 25 | #include "hw.h" |
| 26 | #include "hw-me-regs.h" | ||
| 25 | 27 | ||
| 26 | /* | 28 | /* |
| 27 | * watch dog definition | 29 | * watch dog definition |
| @@ -44,7 +46,7 @@ | |||
| 44 | /* | 46 | /* |
| 45 | * AMTHI Client UUID | 47 | * AMTHI Client UUID |
| 46 | */ | 48 | */ |
| 47 | extern const uuid_le mei_amthi_guid; | 49 | extern const uuid_le mei_amthif_guid; |
| 48 | 50 | ||
| 49 | /* | 51 | /* |
| 50 | * Watchdog Client UUID | 52 | * Watchdog Client UUID |
| @@ -65,12 +67,18 @@ extern const u8 mei_wd_state_independence_msg[3][4]; | |||
| 65 | * Number of File descriptors/handles | 67 | * Number of File descriptors/handles |
| 66 | * that can be opened to the driver. | 68 | * that can be opened to the driver. |
| 67 | * | 69 | * |
| 68 | * Limit to 253: 256 Total Clients | 70 | * Limit to 255: 256 Total Clients |
| 69 | * minus internal client for MEI Bus Messags | 71 | * minus internal client for MEI Bus Messags |
| 70 | * minus internal client for AMTHI | ||
| 71 | * minus internal client for Watchdog | ||
| 72 | */ | 72 | */ |
| 73 | #define MEI_MAX_OPEN_HANDLE_COUNT (MEI_CLIENTS_MAX - 3) | 73 | #define MEI_MAX_OPEN_HANDLE_COUNT (MEI_CLIENTS_MAX - 1) |
| 74 | |||
| 75 | /* | ||
| 76 | * Internal Clients Number | ||
| 77 | */ | ||
| 78 | #define MEI_HOST_CLIENT_ID_ANY (-1) | ||
| 79 | #define MEI_HBM_HOST_CLIENT_ID 0 /* not used, just for documentation */ | ||
| 80 | #define MEI_WD_HOST_CLIENT_ID 1 | ||
| 81 | #define MEI_IAMTHIF_HOST_CLIENT_ID 2 | ||
| 74 | 82 | ||
| 75 | 83 | ||
| 76 | /* File state */ | 84 | /* File state */ |
| @@ -150,6 +158,19 @@ struct mei_message_data { | |||
| 150 | unsigned char *data; | 158 | unsigned char *data; |
| 151 | }; | 159 | }; |
| 152 | 160 | ||
| 161 | /** | ||
| 162 | * struct mei_me_client - representation of me (fw) client | ||
| 163 | * | ||
| 164 | * @props - client properties | ||
| 165 | * @client_id - me client id | ||
| 166 | * @mei_flow_ctrl_creds - flow control credits | ||
| 167 | */ | ||
| 168 | struct mei_me_client { | ||
| 169 | struct mei_client_properties props; | ||
| 170 | u8 client_id; | ||
| 171 | u8 mei_flow_ctrl_creds; | ||
| 172 | }; | ||
| 173 | |||
| 153 | 174 | ||
| 154 | struct mei_cl; | 175 | struct mei_cl; |
| 155 | 176 | ||
| @@ -178,7 +199,6 @@ struct mei_cl { | |||
| 178 | wait_queue_head_t tx_wait; | 199 | wait_queue_head_t tx_wait; |
| 179 | wait_queue_head_t rx_wait; | 200 | wait_queue_head_t rx_wait; |
| 180 | wait_queue_head_t wait; | 201 | wait_queue_head_t wait; |
| 181 | int read_pending; | ||
| 182 | int status; | 202 | int status; |
| 183 | /* ID of client connected */ | 203 | /* ID of client connected */ |
| 184 | u8 host_client_id; | 204 | u8 host_client_id; |
| @@ -191,10 +211,67 @@ struct mei_cl { | |||
| 191 | struct mei_cl_cb *read_cb; | 211 | struct mei_cl_cb *read_cb; |
| 192 | }; | 212 | }; |
| 193 | 213 | ||
| 214 | /** struct mei_hw_ops | ||
| 215 | * | ||
| 216 | * @host_set_ready - notify FW that host side is ready | ||
| 217 | * @host_is_ready - query for host readiness | ||
| 218 | |||
| 219 | * @hw_is_ready - query if hw is ready | ||
| 220 | * @hw_reset - reset hw | ||
| 221 | * @hw_config - configure hw | ||
| 222 | |||
| 223 | * @intr_clear - clear pending interrupts | ||
| 224 | * @intr_enable - enable interrupts | ||
| 225 | * @intr_disable - disable interrupts | ||
| 226 | |||
| 227 | * @hbuf_free_slots - query for write buffer empty slots | ||
| 228 | * @hbuf_is_ready - query if write buffer is empty | ||
| 229 | * @hbuf_max_len - query for write buffer max len | ||
| 230 | |||
| 231 | * @write - write a message to FW | ||
| 232 | |||
| 233 | * @rdbuf_full_slots - query how many slots are filled | ||
| 234 | |||
| 235 | * @read_hdr - get first 4 bytes (header) | ||
| 236 | * @read - read a buffer from the FW | ||
| 237 | */ | ||
| 238 | struct mei_hw_ops { | ||
| 239 | |||
| 240 | void (*host_set_ready) (struct mei_device *dev); | ||
| 241 | bool (*host_is_ready) (struct mei_device *dev); | ||
| 242 | |||
| 243 | bool (*hw_is_ready) (struct mei_device *dev); | ||
| 244 | void (*hw_reset) (struct mei_device *dev, bool enable); | ||
| 245 | void (*hw_config) (struct mei_device *dev); | ||
| 246 | |||
| 247 | void (*intr_clear) (struct mei_device *dev); | ||
| 248 | void (*intr_enable) (struct mei_device *dev); | ||
| 249 | void (*intr_disable) (struct mei_device *dev); | ||
| 250 | |||
| 251 | int (*hbuf_free_slots) (struct mei_device *dev); | ||
| 252 | bool (*hbuf_is_ready) (struct mei_device *dev); | ||
| 253 | size_t (*hbuf_max_len) (const struct mei_device *dev); | ||
| 254 | |||
| 255 | int (*write)(struct mei_device *dev, | ||
| 256 | struct mei_msg_hdr *hdr, | ||
| 257 | unsigned char *buf); | ||
| 258 | |||
| 259 | int (*rdbuf_full_slots)(struct mei_device *dev); | ||
| 260 | |||
| 261 | u32 (*read_hdr)(const struct mei_device *dev); | ||
| 262 | int (*read) (struct mei_device *dev, | ||
| 263 | unsigned char *buf, unsigned long len); | ||
| 264 | }; | ||
| 265 | |||
| 194 | /** | 266 | /** |
| 195 | * struct mei_device - MEI private device struct | 267 | * struct mei_device - MEI private device struct |
| 196 | * @hbuf_depth - depth of host(write) buffer | 268 | |
| 197 | * @wr_ext_msg - buffer for hbm control responses (set in read cycle) | 269 | * @mem_addr - mem mapped base register address |
| 270 | |||
| 271 | * @hbuf_depth - depth of hardware host/write buffer is slots | ||
| 272 | * @hbuf_is_ready - query if the host host/write buffer is ready | ||
| 273 | * @wr_msg - the buffer for hbm control messages | ||
| 274 | * @wr_ext_msg - the buffer for hbm control responses (set in read cycle) | ||
| 198 | */ | 275 | */ |
| 199 | struct mei_device { | 276 | struct mei_device { |
| 200 | struct pci_dev *pdev; /* pointer to pci device struct */ | 277 | struct pci_dev *pdev; /* pointer to pci device struct */ |
| @@ -213,24 +290,14 @@ struct mei_device { | |||
| 213 | */ | 290 | */ |
| 214 | struct list_head file_list; | 291 | struct list_head file_list; |
| 215 | long open_handle_count; | 292 | long open_handle_count; |
| 216 | /* | 293 | |
| 217 | * memory of device | ||
| 218 | */ | ||
| 219 | unsigned int mem_base; | ||
| 220 | unsigned int mem_length; | ||
| 221 | void __iomem *mem_addr; | ||
| 222 | /* | 294 | /* |
| 223 | * lock for the device | 295 | * lock for the device |
| 224 | */ | 296 | */ |
| 225 | struct mutex device_lock; /* device lock */ | 297 | struct mutex device_lock; /* device lock */ |
| 226 | struct delayed_work timer_work; /* MEI timer delayed work (timeouts) */ | 298 | struct delayed_work timer_work; /* MEI timer delayed work (timeouts) */ |
| 227 | bool recvd_msg; | 299 | bool recvd_msg; |
| 228 | /* | 300 | |
| 229 | * hw states of host and fw(ME) | ||
| 230 | */ | ||
| 231 | u32 host_hw_state; | ||
| 232 | u32 me_hw_state; | ||
| 233 | u8 hbuf_depth; | ||
| 234 | /* | 301 | /* |
| 235 | * waiting queue for receive message from FW | 302 | * waiting queue for receive message from FW |
| 236 | */ | 303 | */ |
| @@ -243,11 +310,20 @@ struct mei_device { | |||
| 243 | enum mei_dev_state dev_state; | 310 | enum mei_dev_state dev_state; |
| 244 | enum mei_init_clients_states init_clients_state; | 311 | enum mei_init_clients_states init_clients_state; |
| 245 | u16 init_clients_timer; | 312 | u16 init_clients_timer; |
| 246 | bool need_reset; | ||
| 247 | 313 | ||
| 248 | unsigned char rd_msg_buf[MEI_RD_MSG_BUF_SIZE]; /* control messages */ | 314 | unsigned char rd_msg_buf[MEI_RD_MSG_BUF_SIZE]; /* control messages */ |
| 249 | u32 rd_msg_hdr; | 315 | u32 rd_msg_hdr; |
| 250 | u32 wr_msg_buf[128]; /* used for control messages */ | 316 | |
| 317 | /* write buffer */ | ||
| 318 | u8 hbuf_depth; | ||
| 319 | bool hbuf_is_ready; | ||
| 320 | |||
| 321 | /* used for control messages */ | ||
| 322 | struct { | ||
| 323 | struct mei_msg_hdr hdr; | ||
| 324 | unsigned char data[128]; | ||
| 325 | } wr_msg; | ||
| 326 | |||
| 251 | struct { | 327 | struct { |
| 252 | struct mei_msg_hdr hdr; | 328 | struct mei_msg_hdr hdr; |
| 253 | unsigned char data[4]; /* All HBM messages are 4 bytes */ | 329 | unsigned char data[4]; /* All HBM messages are 4 bytes */ |
| @@ -261,7 +337,6 @@ struct mei_device { | |||
| 261 | u8 me_clients_num; | 337 | u8 me_clients_num; |
| 262 | u8 me_client_presentation_num; | 338 | u8 me_client_presentation_num; |
| 263 | u8 me_client_index; | 339 | u8 me_client_index; |
| 264 | bool mei_host_buffer_is_empty; | ||
| 265 | 340 | ||
| 266 | struct mei_cl wd_cl; | 341 | struct mei_cl wd_cl; |
| 267 | enum mei_wd_states wd_state; | 342 | enum mei_wd_states wd_state; |
| @@ -289,6 +364,9 @@ struct mei_device { | |||
| 289 | bool iamthif_canceled; | 364 | bool iamthif_canceled; |
| 290 | 365 | ||
| 291 | struct work_struct init_work; | 366 | struct work_struct init_work; |
| 367 | |||
| 368 | const struct mei_hw_ops *ops; | ||
| 369 | char hw[0] __aligned(sizeof(void *)); | ||
| 292 | }; | 370 | }; |
| 293 | 371 | ||
| 294 | static inline unsigned long mei_secs_to_jiffies(unsigned long sec) | 372 | static inline unsigned long mei_secs_to_jiffies(unsigned long sec) |
| @@ -300,96 +378,28 @@ static inline unsigned long mei_secs_to_jiffies(unsigned long sec) | |||
| 300 | /* | 378 | /* |
| 301 | * mei init function prototypes | 379 | * mei init function prototypes |
| 302 | */ | 380 | */ |
| 303 | struct mei_device *mei_device_init(struct pci_dev *pdev); | 381 | void mei_device_init(struct mei_device *dev); |
| 304 | void mei_reset(struct mei_device *dev, int interrupts); | 382 | void mei_reset(struct mei_device *dev, int interrupts); |
| 305 | int mei_hw_init(struct mei_device *dev); | 383 | int mei_hw_init(struct mei_device *dev); |
| 306 | int mei_task_initialize_clients(void *data); | ||
| 307 | int mei_initialize_clients(struct mei_device *dev); | ||
| 308 | int mei_disconnect_host_client(struct mei_device *dev, struct mei_cl *cl); | ||
| 309 | void mei_allocate_me_clients_storage(struct mei_device *dev); | ||
| 310 | |||
| 311 | |||
| 312 | int mei_me_cl_link(struct mei_device *dev, struct mei_cl *cl, | ||
| 313 | const uuid_le *cguid, u8 host_client_id); | ||
| 314 | void mei_me_cl_unlink(struct mei_device *dev, struct mei_cl *cl); | ||
| 315 | int mei_me_cl_by_uuid(const struct mei_device *dev, const uuid_le *cuuid); | ||
| 316 | int mei_me_cl_by_id(struct mei_device *dev, u8 client_id); | ||
| 317 | |||
| 318 | /* | ||
| 319 | * MEI IO Functions | ||
| 320 | */ | ||
| 321 | struct mei_cl_cb *mei_io_cb_init(struct mei_cl *cl, struct file *fp); | ||
| 322 | void mei_io_cb_free(struct mei_cl_cb *priv_cb); | ||
| 323 | int mei_io_cb_alloc_req_buf(struct mei_cl_cb *cb, size_t length); | ||
| 324 | int mei_io_cb_alloc_resp_buf(struct mei_cl_cb *cb, size_t length); | ||
| 325 | |||
| 326 | |||
| 327 | /** | ||
| 328 | * mei_io_list_init - Sets up a queue list. | ||
| 329 | * | ||
| 330 | * @list: An instance cl callback structure | ||
| 331 | */ | ||
| 332 | static inline void mei_io_list_init(struct mei_cl_cb *list) | ||
| 333 | { | ||
| 334 | INIT_LIST_HEAD(&list->list); | ||
| 335 | } | ||
| 336 | void mei_io_list_flush(struct mei_cl_cb *list, struct mei_cl *cl); | ||
| 337 | |||
| 338 | /* | ||
| 339 | * MEI ME Client Functions | ||
| 340 | */ | ||
| 341 | |||
| 342 | struct mei_cl *mei_cl_allocate(struct mei_device *dev); | ||
| 343 | void mei_cl_init(struct mei_cl *cl, struct mei_device *dev); | ||
| 344 | int 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 | */ | ||
| 353 | static 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 | |||
| 361 | |||
| 362 | |||
| 363 | /* | ||
| 364 | * MEI Host Client Functions | ||
| 365 | */ | ||
| 366 | void mei_host_start_message(struct mei_device *dev); | ||
| 367 | void mei_host_enum_clients_message(struct mei_device *dev); | ||
| 368 | int mei_host_client_enumerate(struct mei_device *dev); | ||
| 369 | void mei_host_client_init(struct work_struct *work); | ||
| 370 | 384 | ||
| 371 | /* | 385 | /* |
| 372 | * MEI interrupt functions prototype | 386 | * MEI interrupt functions prototype |
| 373 | */ | 387 | */ |
| 374 | irqreturn_t mei_interrupt_quick_handler(int irq, void *dev_id); | ||
| 375 | irqreturn_t mei_interrupt_thread_handler(int irq, void *dev_id); | ||
| 376 | void mei_timer(struct work_struct *work); | ||
| 377 | 388 | ||
| 378 | /* | 389 | void mei_timer(struct work_struct *work); |
| 379 | * MEI input output function prototype | 390 | int mei_irq_read_handler(struct mei_device *dev, |
| 380 | */ | 391 | struct mei_cl_cb *cmpl_list, s32 *slots); |
| 381 | int mei_ioctl_connect_client(struct file *file, | ||
| 382 | struct mei_connect_client_data *data); | ||
| 383 | 392 | ||
| 384 | int mei_start_read(struct mei_device *dev, struct mei_cl *cl); | 393 | int mei_irq_write_handler(struct mei_device *dev, struct mei_cl_cb *cmpl_list); |
| 385 | 394 | ||
| 395 | void mei_irq_complete_handler(struct mei_cl *cl, struct mei_cl_cb *cb_pos); | ||
| 386 | 396 | ||
| 387 | /* | 397 | /* |
| 388 | * AMTHIF - AMT Host Interface Functions | 398 | * AMTHIF - AMT Host Interface Functions |
| 389 | */ | 399 | */ |
| 390 | void mei_amthif_reset_params(struct mei_device *dev); | 400 | void mei_amthif_reset_params(struct mei_device *dev); |
| 391 | 401 | ||
| 392 | void mei_amthif_host_init(struct mei_device *dev); | 402 | int mei_amthif_host_init(struct mei_device *dev); |
| 393 | 403 | ||
| 394 | int mei_amthif_write(struct mei_device *dev, struct mei_cl_cb *priv_cb); | 404 | int mei_amthif_write(struct mei_device *dev, struct mei_cl_cb *priv_cb); |
| 395 | 405 | ||
| @@ -407,9 +417,6 @@ struct mei_cl_cb *mei_amthif_find_read_list_entry(struct mei_device *dev, | |||
| 407 | void mei_amthif_run_next_cmd(struct mei_device *dev); | 417 | void mei_amthif_run_next_cmd(struct mei_device *dev); |
| 408 | 418 | ||
| 409 | 419 | ||
| 410 | int mei_amthif_read_message(struct mei_cl_cb *complete_list, | ||
| 411 | struct mei_device *dev, struct mei_msg_hdr *mei_hdr); | ||
| 412 | |||
| 413 | int mei_amthif_irq_write_complete(struct mei_device *dev, s32 *slots, | 420 | int mei_amthif_irq_write_complete(struct mei_device *dev, s32 *slots, |
| 414 | struct mei_cl_cb *cb, struct mei_cl_cb *cmpl_list); | 421 | struct mei_cl_cb *cb, struct mei_cl_cb *cmpl_list); |
| 415 | 422 | ||
| @@ -418,92 +425,107 @@ int mei_amthif_irq_read_message(struct mei_cl_cb *complete_list, | |||
| 418 | struct mei_device *dev, struct mei_msg_hdr *mei_hdr); | 425 | struct mei_device *dev, struct mei_msg_hdr *mei_hdr); |
| 419 | int mei_amthif_irq_read(struct mei_device *dev, s32 *slots); | 426 | int mei_amthif_irq_read(struct mei_device *dev, s32 *slots); |
| 420 | 427 | ||
| 428 | |||
| 429 | int mei_wd_send(struct mei_device *dev); | ||
| 430 | int mei_wd_stop(struct mei_device *dev); | ||
| 431 | int mei_wd_host_init(struct mei_device *dev); | ||
| 421 | /* | 432 | /* |
| 422 | * Register Access Function | 433 | * mei_watchdog_register - Registering watchdog interface |
| 434 | * once we got connection to the WD Client | ||
| 435 | * @dev - mei device | ||
| 436 | */ | ||
| 437 | void mei_watchdog_register(struct mei_device *dev); | ||
| 438 | /* | ||
| 439 | * mei_watchdog_unregister - Unregistering watchdog interface | ||
| 440 | * @dev - mei device | ||
| 423 | */ | 441 | */ |
| 442 | void mei_watchdog_unregister(struct mei_device *dev); | ||
| 424 | 443 | ||
| 425 | /** | 444 | /* |
| 426 | * mei_reg_read - Reads 32bit data from the mei device | 445 | * Register Access Function |
| 427 | * | ||
| 428 | * @dev: the device structure | ||
| 429 | * @offset: offset from which to read the data | ||
| 430 | * | ||
| 431 | * returns register value (u32) | ||
| 432 | */ | 446 | */ |
| 433 | static inline u32 mei_reg_read(const struct mei_device *dev, | 447 | |
| 434 | unsigned long offset) | 448 | static inline void mei_hw_config(struct mei_device *dev) |
| 449 | { | ||
| 450 | dev->ops->hw_config(dev); | ||
| 451 | } | ||
| 452 | static inline void mei_hw_reset(struct mei_device *dev, bool enable) | ||
| 435 | { | 453 | { |
| 436 | return ioread32(dev->mem_addr + offset); | 454 | dev->ops->hw_reset(dev, enable); |
| 437 | } | 455 | } |
| 438 | 456 | ||
| 439 | /** | 457 | static inline void mei_clear_interrupts(struct mei_device *dev) |
| 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 | ||
| 444 | * @value: register value to write (u32) | ||
| 445 | */ | ||
| 446 | static inline void mei_reg_write(const struct mei_device *dev, | ||
| 447 | unsigned long offset, u32 value) | ||
| 448 | { | 458 | { |
| 449 | iowrite32(value, dev->mem_addr + offset); | 459 | dev->ops->intr_clear(dev); |
| 450 | } | 460 | } |
| 451 | 461 | ||
| 452 | /** | 462 | static inline void mei_enable_interrupts(struct mei_device *dev) |
| 453 | * mei_hcsr_read - Reads 32bit data from the host CSR | ||
| 454 | * | ||
| 455 | * @dev: the device structure | ||
| 456 | * | ||
| 457 | * returns the byte read. | ||
| 458 | */ | ||
| 459 | static inline u32 mei_hcsr_read(const struct mei_device *dev) | ||
| 460 | { | 463 | { |
| 461 | return mei_reg_read(dev, H_CSR); | 464 | dev->ops->intr_enable(dev); |
| 462 | } | 465 | } |
| 463 | 466 | ||
| 464 | /** | 467 | static inline void mei_disable_interrupts(struct mei_device *dev) |
| 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 | */ | ||
| 471 | static inline u32 mei_mecsr_read(const struct mei_device *dev) | ||
| 472 | { | 468 | { |
| 473 | return mei_reg_read(dev, ME_CSR_HA); | 469 | dev->ops->intr_disable(dev); |
| 474 | } | 470 | } |
| 475 | 471 | ||
| 476 | /** | 472 | static inline void mei_host_set_ready(struct mei_device *dev) |
| 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 | */ | ||
| 483 | static inline u32 mei_mecbrw_read(const struct mei_device *dev) | ||
| 484 | { | 473 | { |
| 485 | return mei_reg_read(dev, ME_CB_RW); | 474 | dev->ops->host_set_ready(dev); |
| 475 | } | ||
| 476 | static inline bool mei_host_is_ready(struct mei_device *dev) | ||
| 477 | { | ||
| 478 | return dev->ops->host_is_ready(dev); | ||
| 479 | } | ||
| 480 | static inline bool mei_hw_is_ready(struct mei_device *dev) | ||
| 481 | { | ||
| 482 | return dev->ops->hw_is_ready(dev); | ||
| 486 | } | 483 | } |
| 487 | 484 | ||
| 485 | static inline bool mei_hbuf_is_ready(struct mei_device *dev) | ||
| 486 | { | ||
| 487 | return dev->ops->hbuf_is_ready(dev); | ||
| 488 | } | ||
| 488 | 489 | ||
| 489 | /* | 490 | static inline int mei_hbuf_empty_slots(struct mei_device *dev) |
| 490 | * mei interface function prototypes | 491 | { |
| 491 | */ | 492 | return dev->ops->hbuf_free_slots(dev); |
| 492 | void mei_hcsr_set(struct mei_device *dev); | 493 | } |
| 493 | void mei_csr_clear_his(struct mei_device *dev); | 494 | |
| 495 | static inline size_t mei_hbuf_max_len(const struct mei_device *dev) | ||
| 496 | { | ||
| 497 | return dev->ops->hbuf_max_len(dev); | ||
| 498 | } | ||
| 494 | 499 | ||
| 495 | void mei_enable_interrupts(struct mei_device *dev); | 500 | static inline int mei_write_message(struct mei_device *dev, |
| 496 | void mei_disable_interrupts(struct mei_device *dev); | 501 | struct mei_msg_hdr *hdr, |
| 502 | unsigned char *buf) | ||
| 503 | { | ||
| 504 | return dev->ops->write(dev, hdr, buf); | ||
| 505 | } | ||
| 497 | 506 | ||
| 498 | static inline struct mei_msg_hdr *mei_hbm_hdr(u32 *buf, size_t length) | 507 | static inline u32 mei_read_hdr(const struct mei_device *dev) |
| 499 | { | 508 | { |
| 500 | struct mei_msg_hdr *hdr = (struct mei_msg_hdr *)buf; | 509 | return dev->ops->read_hdr(dev); |
| 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 | } | 510 | } |
| 508 | 511 | ||
| 512 | static inline void mei_read_slots(struct mei_device *dev, | ||
| 513 | unsigned char *buf, unsigned long len) | ||
| 514 | { | ||
| 515 | dev->ops->read(dev, buf, len); | ||
| 516 | } | ||
| 517 | |||
| 518 | static inline int mei_count_full_read_slots(struct mei_device *dev) | ||
| 519 | { | ||
| 520 | return dev->ops->rdbuf_full_slots(dev); | ||
| 521 | } | ||
| 522 | |||
| 523 | int mei_register(struct device *dev); | ||
| 524 | void mei_deregister(void); | ||
| 525 | |||
| 526 | #define MEI_HDR_FMT "hdr:host=%02d me=%02d len=%d comp=%1d" | ||
| 527 | #define MEI_HDR_PRM(hdr) \ | ||
| 528 | (hdr)->host_addr, (hdr)->me_addr, \ | ||
| 529 | (hdr)->length, (hdr)->msg_complete | ||
| 530 | |||
| 509 | #endif | 531 | #endif |
