linux/drivers/hid/intel-ish-hid/ishtp/bus.h
<<
>>
Prefs
   1/*
   2 * ISHTP bus definitions
   3 *
   4 * Copyright (c) 2014-2016, Intel Corporation.
   5 *
   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#ifndef _LINUX_ISHTP_CL_BUS_H
  16#define _LINUX_ISHTP_CL_BUS_H
  17
  18#include <linux/device.h>
  19#include <linux/mod_devicetable.h>
  20
  21struct ishtp_cl;
  22struct ishtp_cl_device;
  23struct ishtp_device;
  24struct ishtp_msg_hdr;
  25
  26/**
  27 * struct ishtp_cl_device - ISHTP device handle
  28 * @dev:        device pointer
  29 * @ishtp_dev:  pointer to ishtp device structure to primarily to access
  30 *              hw device operation callbacks and properties
  31 * @fw_client:  fw_client pointer to get fw information like protocol name
  32 *              max message length etc.
  33 * @device_link: Link to next client in the list on a bus
  34 * @event_work: Used to schedule rx event for client
  35 * @driver_data: Storage driver private data
  36 * @reference_count:    Used for get/put device
  37 * @event_cb:   Callback to driver to send events
  38 *
  39 * An ishtp_cl_device pointer is returned from ishtp_add_device()
  40 * and links ISHTP bus clients to their actual host client pointer.
  41 * Drivers for ISHTP devices will get an ishtp_cl_device pointer
  42 * when being probed and shall use it for doing bus I/O.
  43 */
  44struct ishtp_cl_device {
  45        struct device           dev;
  46        struct ishtp_device     *ishtp_dev;
  47        struct ishtp_fw_client  *fw_client;
  48        struct list_head        device_link;
  49        struct work_struct      event_work;
  50        void                    *driver_data;
  51        int                     reference_count;
  52        void (*event_cb)(struct ishtp_cl_device *device);
  53};
  54
  55/**
  56 * struct ishtp_cl_device - ISHTP device handle
  57 * @driver:     driver instance on a bus
  58 * @name:       Name of the device for probe
  59 * @probe:      driver callback for device probe
  60 * @remove:     driver callback on device removal
  61 *
  62 * Client drivers defines to get probed/removed for ISHTP client device.
  63 */
  64struct ishtp_cl_driver {
  65        struct device_driver driver;
  66        const char *name;
  67        int (*probe)(struct ishtp_cl_device *dev);
  68        int (*remove)(struct ishtp_cl_device *dev);
  69        int (*reset)(struct ishtp_cl_device *dev);
  70        const struct dev_pm_ops *pm;
  71};
  72
  73
  74int     ishtp_bus_new_client(struct ishtp_device *dev);
  75void    ishtp_remove_all_clients(struct ishtp_device *dev);
  76int     ishtp_cl_device_bind(struct ishtp_cl *cl);
  77void    ishtp_cl_bus_rx_event(struct ishtp_cl_device *device);
  78
  79/* Write a multi-fragment message */
  80int     ishtp_send_msg(struct ishtp_device *dev,
  81                       struct ishtp_msg_hdr *hdr, void *msg,
  82                       void (*ipc_send_compl)(void *),
  83                       void *ipc_send_compl_prm);
  84
  85/* Write a single-fragment message */
  86int     ishtp_write_message(struct ishtp_device *dev,
  87                            struct ishtp_msg_hdr *hdr,
  88                            unsigned char *buf);
  89
  90/* Use DMA to send/receive messages */
  91int ishtp_use_dma_transfer(void);
  92
  93/* Exported functions */
  94void    ishtp_bus_remove_all_clients(struct ishtp_device *ishtp_dev,
  95                                     bool warm_reset);
  96
  97void    ishtp_recv(struct ishtp_device *dev);
  98void    ishtp_reset_handler(struct ishtp_device *dev);
  99void    ishtp_reset_compl_handler(struct ishtp_device *dev);
 100
 101void    ishtp_put_device(struct ishtp_cl_device *);
 102void    ishtp_get_device(struct ishtp_cl_device *);
 103
 104int     __ishtp_cl_driver_register(struct ishtp_cl_driver *driver,
 105                                   struct module *owner);
 106#define ishtp_cl_driver_register(driver)                \
 107        __ishtp_cl_driver_register(driver, THIS_MODULE)
 108void    ishtp_cl_driver_unregister(struct ishtp_cl_driver *driver);
 109
 110int     ishtp_register_event_cb(struct ishtp_cl_device *device,
 111                                void (*read_cb)(struct ishtp_cl_device *));
 112int     ishtp_fw_cl_by_uuid(struct ishtp_device *dev, const uuid_le *cuuid);
 113
 114#endif /* _LINUX_ISHTP_CL_BUS_H */
 115