linux/drivers/staging/greybus/hd.h
<<
>>
Prefs
   1/*
   2 * Greybus Host Device
   3 *
   4 * Copyright 2014-2015 Google Inc.
   5 * Copyright 2014-2015 Linaro Ltd.
   6 *
   7 * Released under the GPLv2 only.
   8 */
   9
  10#ifndef __HD_H
  11#define __HD_H
  12
  13struct gb_host_device;
  14struct gb_message;
  15
  16struct gb_hd_driver {
  17        size_t  hd_priv_size;
  18
  19        int (*cport_allocate)(struct gb_host_device *hd, int cport_id,
  20                                unsigned long flags);
  21        void (*cport_release)(struct gb_host_device *hd, u16 cport_id);
  22        int (*cport_enable)(struct gb_host_device *hd, u16 cport_id,
  23                                unsigned long flags);
  24        int (*cport_disable)(struct gb_host_device *hd, u16 cport_id);
  25        int (*cport_connected)(struct gb_host_device *hd, u16 cport_id);
  26        int (*cport_flush)(struct gb_host_device *hd, u16 cport_id);
  27        int (*cport_shutdown)(struct gb_host_device *hd, u16 cport_id,
  28                                u8 phase, unsigned int timeout);
  29        int (*cport_quiesce)(struct gb_host_device *hd, u16 cport_id,
  30                                size_t peer_space, unsigned int timeout);
  31        int (*cport_clear)(struct gb_host_device *hd, u16 cport_id);
  32
  33        int (*message_send)(struct gb_host_device *hd, u16 dest_cport_id,
  34                        struct gb_message *message, gfp_t gfp_mask);
  35        void (*message_cancel)(struct gb_message *message);
  36        int (*latency_tag_enable)(struct gb_host_device *hd, u16 cport_id);
  37        int (*latency_tag_disable)(struct gb_host_device *hd, u16 cport_id);
  38        int (*output)(struct gb_host_device *hd, void *req, u16 size, u8 cmd,
  39                      bool async);
  40        int (*timesync_enable)(struct gb_host_device *hd, u8 count,
  41                               u64 frame_time, u32 strobe_delay, u32 refclk);
  42        int (*timesync_disable)(struct gb_host_device *hd);
  43        int (*timesync_authoritative)(struct gb_host_device *hd,
  44                                      u64 *frame_time);
  45        int (*timesync_get_last_event)(struct gb_host_device *hd,
  46                                       u64 *frame_time);
  47};
  48
  49struct gb_host_device {
  50        struct device dev;
  51        int bus_id;
  52        const struct gb_hd_driver *driver;
  53
  54        struct list_head modules;
  55        struct list_head connections;
  56        struct ida cport_id_map;
  57
  58        /* Number of CPorts supported by the UniPro IP */
  59        size_t num_cports;
  60
  61        /* Host device buffer constraints */
  62        size_t buffer_size_max;
  63
  64        struct gb_svc *svc;
  65        /* Private data for the host driver */
  66        unsigned long hd_priv[0] __aligned(sizeof(s64));
  67};
  68#define to_gb_host_device(d) container_of(d, struct gb_host_device, dev)
  69
  70int gb_hd_cport_reserve(struct gb_host_device *hd, u16 cport_id);
  71void gb_hd_cport_release_reserved(struct gb_host_device *hd, u16 cport_id);
  72int gb_hd_cport_allocate(struct gb_host_device *hd, int cport_id,
  73                                        unsigned long flags);
  74void gb_hd_cport_release(struct gb_host_device *hd, u16 cport_id);
  75
  76struct gb_host_device *gb_hd_create(struct gb_hd_driver *driver,
  77                                        struct device *parent,
  78                                        size_t buffer_size_max,
  79                                        size_t num_cports);
  80int gb_hd_add(struct gb_host_device *hd);
  81void gb_hd_del(struct gb_host_device *hd);
  82void gb_hd_shutdown(struct gb_host_device *hd);
  83void gb_hd_put(struct gb_host_device *hd);
  84int gb_hd_output(struct gb_host_device *hd, void *req, u16 size, u8 cmd,
  85                 bool in_irq);
  86
  87int gb_hd_init(void);
  88void gb_hd_exit(void);
  89
  90#endif  /* __HD_H */
  91