aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc/mei/mei_dev.h
diff options
context:
space:
mode:
authorTomas Winkler <tomas.winkler@intel.com>2013-02-06 07:06:41 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-02-06 14:23:47 -0500
commit827eef51f8dd9a4ab62b4ad270c15472f46938f2 (patch)
tree15798db67af269512bdb4ae54f36e0a26d178d4a /drivers/misc/mei/mei_dev.h
parent52c34561415b420301f1580413a9d1891d079494 (diff)
mei: separate compilation of the ME hardware specifics
We add struct mei_hw_ops to virtualize access to hw specific configurations. This allows us to separate the compilation of the ME interface from the ME hardware specifics Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/misc/mei/mei_dev.h')
-rw-r--r--drivers/misc/mei/mei_dev.h132
1 files changed, 122 insertions, 10 deletions
diff --git a/drivers/misc/mei/mei_dev.h b/drivers/misc/mei/mei_dev.h
index bb759fd9ee4a..c974292f16d6 100644
--- a/drivers/misc/mei/mei_dev.h
+++ b/drivers/misc/mei/mei_dev.h
@@ -211,6 +211,58 @@ struct mei_cl {
211 struct mei_cl_cb *read_cb; 211 struct mei_cl_cb *read_cb;
212}; 212};
213 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 */
238struct 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
214/** 266/**
215 * struct mei_device - MEI private device struct 267 * struct mei_device - MEI private device struct
216 * @mem_addr - mem mapped base register address 268 * @mem_addr - mem mapped base register address
@@ -306,6 +358,8 @@ struct mei_device {
306 bool iamthif_canceled; 358 bool iamthif_canceled;
307 359
308 struct work_struct init_work; 360 struct work_struct init_work;
361
362 const struct mei_hw_ops *ops;
309 char hw[0] __aligned(sizeof(void *)); 363 char hw[0] __aligned(sizeof(void *));
310}; 364};
311 365
@@ -376,26 +430,84 @@ void mei_watchdog_register(struct mei_device *dev);
376 */ 430 */
377void mei_watchdog_unregister(struct mei_device *dev); 431void mei_watchdog_unregister(struct mei_device *dev);
378 432
379
380/* 433/*
381 * Register Access Function 434 * Register Access Function
382 */ 435 */
383 436
384void mei_hw_config(struct mei_device *dev); 437static inline void mei_hw_config(struct mei_device *dev)
385void mei_hw_reset(struct mei_device *dev, bool intr_enable); 438{
386u32 mei_mecbrw_read(const struct mei_device *dev); 439 dev->ops->hw_config(dev);
440}
441static inline void mei_hw_reset(struct mei_device *dev, bool enable)
442{
443 dev->ops->hw_reset(dev, enable);
444}
445
446static inline void mei_clear_interrupts(struct mei_device *dev)
447{
448 dev->ops->intr_clear(dev);
449}
450
451static inline void mei_enable_interrupts(struct mei_device *dev)
452{
453 dev->ops->intr_enable(dev);
454}
387 455
456static inline void mei_disable_interrupts(struct mei_device *dev)
457{
458 dev->ops->intr_disable(dev);
459}
388 460
461static inline void mei_host_set_ready(struct mei_device *dev)
462{
463 dev->ops->host_set_ready(dev);
464}
465static inline bool mei_host_is_ready(struct mei_device *dev)
466{
467 return dev->ops->host_is_ready(dev);
468}
469static inline bool mei_hw_is_ready(struct mei_device *dev)
470{
471 return dev->ops->hw_is_ready(dev);
472}
389 473
390void mei_clear_interrupts(struct mei_device *dev); 474static inline bool mei_hbuf_is_ready(struct mei_device *dev)
391void mei_enable_interrupts(struct mei_device *dev); 475{
392void mei_disable_interrupts(struct mei_device *dev); 476 return dev->ops->hbuf_is_ready(dev);
477}
393 478
394void mei_host_set_ready(struct mei_device *dev); 479static inline int mei_hbuf_empty_slots(struct mei_device *dev)
395bool mei_host_is_ready(struct mei_device *dev); 480{
396bool mei_me_is_ready(struct mei_device *dev); 481 return dev->ops->hbuf_free_slots(dev);
482}
397 483
484static inline size_t mei_hbuf_max_len(const struct mei_device *dev)
485{
486 return dev->ops->hbuf_max_len(dev);
487}
398 488
489static inline int mei_write_message(struct mei_device *dev,
490 struct mei_msg_hdr *hdr,
491 unsigned char *buf)
492{
493 return dev->ops->write(dev, hdr, buf);
494}
495
496static inline u32 mei_read_hdr(const struct mei_device *dev)
497{
498 return dev->ops->read_hdr(dev);
499}
500
501static inline void mei_read_slots(struct mei_device *dev,
502 unsigned char *buf, unsigned long len)
503{
504 dev->ops->read(dev, buf, len);
505}
506
507static inline int mei_count_full_read_slots(struct mei_device *dev)
508{
509 return dev->ops->rdbuf_full_slots(dev);
510}
399 511
400int mei_register(struct device *dev); 512int mei_register(struct device *dev);
401void mei_deregister(void); 513void mei_deregister(void);