Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * Greybus Host Device
0004  *
0005  * Copyright 2014-2015 Google Inc.
0006  * Copyright 2014-2015 Linaro Ltd.
0007  */
0008 
0009 #ifndef __HD_H
0010 #define __HD_H
0011 
0012 #include <linux/types.h>
0013 #include <linux/device.h>
0014 
0015 struct gb_host_device;
0016 struct gb_message;
0017 
0018 struct gb_hd_driver {
0019     size_t  hd_priv_size;
0020 
0021     int (*cport_allocate)(struct gb_host_device *hd, int cport_id,
0022                 unsigned long flags);
0023     void (*cport_release)(struct gb_host_device *hd, u16 cport_id);
0024     int (*cport_enable)(struct gb_host_device *hd, u16 cport_id,
0025                 unsigned long flags);
0026     int (*cport_disable)(struct gb_host_device *hd, u16 cport_id);
0027     int (*cport_connected)(struct gb_host_device *hd, u16 cport_id);
0028     int (*cport_flush)(struct gb_host_device *hd, u16 cport_id);
0029     int (*cport_shutdown)(struct gb_host_device *hd, u16 cport_id,
0030                 u8 phase, unsigned int timeout);
0031     int (*cport_quiesce)(struct gb_host_device *hd, u16 cport_id,
0032                 size_t peer_space, unsigned int timeout);
0033     int (*cport_clear)(struct gb_host_device *hd, u16 cport_id);
0034 
0035     int (*message_send)(struct gb_host_device *hd, u16 dest_cport_id,
0036             struct gb_message *message, gfp_t gfp_mask);
0037     void (*message_cancel)(struct gb_message *message);
0038     int (*latency_tag_enable)(struct gb_host_device *hd, u16 cport_id);
0039     int (*latency_tag_disable)(struct gb_host_device *hd, u16 cport_id);
0040     int (*output)(struct gb_host_device *hd, void *req, u16 size, u8 cmd,
0041               bool async);
0042 };
0043 
0044 struct gb_host_device {
0045     struct device dev;
0046     int bus_id;
0047     const struct gb_hd_driver *driver;
0048 
0049     struct list_head modules;
0050     struct list_head connections;
0051     struct ida cport_id_map;
0052 
0053     /* Number of CPorts supported by the UniPro IP */
0054     size_t num_cports;
0055 
0056     /* Host device buffer constraints */
0057     size_t buffer_size_max;
0058 
0059     struct gb_svc *svc;
0060     /* Private data for the host driver */
0061     unsigned long hd_priv[] __aligned(sizeof(s64));
0062 };
0063 #define to_gb_host_device(d) container_of(d, struct gb_host_device, dev)
0064 
0065 int gb_hd_cport_reserve(struct gb_host_device *hd, u16 cport_id);
0066 void gb_hd_cport_release_reserved(struct gb_host_device *hd, u16 cport_id);
0067 int gb_hd_cport_allocate(struct gb_host_device *hd, int cport_id,
0068                     unsigned long flags);
0069 void gb_hd_cport_release(struct gb_host_device *hd, u16 cport_id);
0070 
0071 struct gb_host_device *gb_hd_create(struct gb_hd_driver *driver,
0072                     struct device *parent,
0073                     size_t buffer_size_max,
0074                     size_t num_cports);
0075 int gb_hd_add(struct gb_host_device *hd);
0076 void gb_hd_del(struct gb_host_device *hd);
0077 void gb_hd_shutdown(struct gb_host_device *hd);
0078 void gb_hd_put(struct gb_host_device *hd);
0079 int gb_hd_output(struct gb_host_device *hd, void *req, u16 size, u8 cmd,
0080          bool in_irq);
0081 
0082 int gb_hd_init(void);
0083 void gb_hd_exit(void);
0084 
0085 #endif  /* __HD_H */