linux/drivers/greybus/es2.c

// SPDX-License-Identifier: GPL-2.0
/*
 * Greybus "AP" USB driver for "ES2" controller chips
 *
 * Copyright 2014-2015 Google Inc.
 * Copyright 2014-2015 Linaro Ltd.
 */
#include <linux/kthread.h>
#include <linux/sizes.h>
#include <linux/usb.h>
#include <linux/kfifo.h>
#include <linux/debugfs.h>
#include <linux/list.h>
#include <linux/greybus.h>
#include <asm/unaligned.h>

#include "arpc.h"
#include "greybus_trace.h"


/* Default timeout for USB vendor requests. */
#define ES2_USB_CTRL_TIMEOUT

/* Default timeout for ARPC CPort requests */
#define ES2_ARPC_CPORT_TIMEOUT

/* Fixed CPort numbers */
#define ES2_CPORT_CDSI0
#define ES2_CPORT_CDSI1

/* Memory sizes for the buffers sent to/from the ES2 controller */
#define ES2_GBUF_MSG_SIZE_MAX

/* Memory sizes for the ARPC buffers */
#define ARPC_OUT_SIZE_MAX
#define ARPC_IN_SIZE_MAX

static const struct usb_device_id id_table[] =;
MODULE_DEVICE_TABLE(usb, id_table);

#define APB1_LOG_SIZE

/*
 * Number of CPort IN urbs in flight at any point in time.
 * Adjust if we are having stalls in the USB buffer due to not enough urbs in
 * flight.
 */
#define NUM_CPORT_IN_URB

/* Number of CPort OUT urbs in flight at any point in time.
 * Adjust if we get messages saying we are out of urbs in the system log.
 */
#define NUM_CPORT_OUT_URB

/*
 * Number of ARPC in urbs in flight at any point in time.
 */
#define NUM_ARPC_IN_URB

/*
 * @endpoint: bulk in endpoint for CPort data
 * @urb: array of urbs for the CPort in messages
 * @buffer: array of buffers for the @cport_in_urb urbs
 */
struct es2_cport_in {};

/**
 * struct es2_ap_dev - ES2 USB Bridge to AP structure
 * @usb_dev: pointer to the USB device we are.
 * @usb_intf: pointer to the USB interface we are bound to.
 * @hd: pointer to our gb_host_device structure
 *
 * @cport_in: endpoint, urbs and buffer for cport in messages
 * @cport_out_endpoint: endpoint for cport out messages
 * @cport_out_urb: array of urbs for the CPort out messages
 * @cport_out_urb_busy: array of flags to see if the @cport_out_urb is busy or
 *			not.
 * @cport_out_urb_cancelled: array of flags indicating whether the
 *			corresponding @cport_out_urb is being cancelled
 * @cport_out_urb_lock: locks the @cport_out_urb_busy "list"
 * @cdsi1_in_use: true if cport CDSI1 is in use
 * @apb_log_task: task pointer for logging thread
 * @apb_log_dentry: file system entry for the log file interface
 * @apb_log_enable_dentry: file system entry for enabling logging
 * @apb_log_fifo: kernel FIFO to carry logged data
 * @arpc_urb: array of urbs for the ARPC in messages
 * @arpc_buffer: array of buffers for the @arpc_urb urbs
 * @arpc_endpoint_in: bulk in endpoint for APBridgeA RPC
 * @arpc_id_cycle: gives an unique id to ARPC
 * @arpc_lock: locks ARPC list
 * @arpcs: list of in progress ARPCs
 */
struct es2_ap_dev {};

struct arpc {};

static inline struct es2_ap_dev *hd_to_es2(struct gb_host_device *hd)
{}

static void cport_out_callback(struct urb *urb);
static void usb_log_enable(struct es2_ap_dev *es2);
static void usb_log_disable(struct es2_ap_dev *es2);
static int arpc_sync(struct es2_ap_dev *es2, u8 type, void *payload,
		     size_t size, int *result, unsigned int timeout);

static int output_sync(struct es2_ap_dev *es2, void *req, u16 size, u8 cmd)
{}

static void ap_urb_complete(struct urb *urb)
{}

static int output_async(struct es2_ap_dev *es2, void *req, u16 size, u8 cmd)
{}

static int output(struct gb_host_device *hd, void *req, u16 size, u8 cmd,
		  bool async)
{}

static int es2_cport_in_enable(struct es2_ap_dev *es2,
			       struct es2_cport_in *cport_in)
{}

static void es2_cport_in_disable(struct es2_ap_dev *es2,
				 struct es2_cport_in *cport_in)
{}

static int es2_arpc_in_enable(struct es2_ap_dev *es2)
{}

static void es2_arpc_in_disable(struct es2_ap_dev *es2)
{}

static struct urb *next_free_urb(struct es2_ap_dev *es2, gfp_t gfp_mask)
{}

static void free_urb(struct es2_ap_dev *es2, struct urb *urb)
{}

/*
 * We (ab)use the operation-message header pad bytes to transfer the
 * cport id in order to minimise overhead.
 */
static void
gb_message_cport_pack(struct gb_operation_msg_hdr *header, u16 cport_id)
{}

/* Clear the pad bytes used for the CPort id */
static void gb_message_cport_clear(struct gb_operation_msg_hdr *header)
{}

/* Extract the CPort id packed into the header, and clear it */
static u16 gb_message_cport_unpack(struct gb_operation_msg_hdr *header)
{}

/*
 * Returns zero if the message was successfully queued, or a negative errno
 * otherwise.
 */
static int message_send(struct gb_host_device *hd, u16 cport_id,
			struct gb_message *message, gfp_t gfp_mask)
{}

/*
 * Can not be called in atomic context.
 */
static void message_cancel(struct gb_message *message)
{}

static int es2_cport_allocate(struct gb_host_device *hd, int cport_id,
			      unsigned long flags)
{}

static void es2_cport_release(struct gb_host_device *hd, u16 cport_id)
{}

static int cport_enable(struct gb_host_device *hd, u16 cport_id,
			unsigned long flags)
{}

static int es2_cport_connected(struct gb_host_device *hd, u16 cport_id)
{}

static int es2_cport_flush(struct gb_host_device *hd, u16 cport_id)
{}

static int es2_cport_shutdown(struct gb_host_device *hd, u16 cport_id,
			      u8 phase, unsigned int timeout)
{}

static int es2_cport_quiesce(struct gb_host_device *hd, u16 cport_id,
			     size_t peer_space, unsigned int timeout)
{}

static int es2_cport_clear(struct gb_host_device *hd, u16 cport_id)
{}

static int latency_tag_enable(struct gb_host_device *hd, u16 cport_id)
{}

static int latency_tag_disable(struct gb_host_device *hd, u16 cport_id)
{}

static struct gb_hd_driver es2_driver =;

/* Common function to report consistent warnings based on URB status */
static int check_urb_status(struct urb *urb)
{}

static void es2_destroy(struct es2_ap_dev *es2)
{}

static void cport_in_callback(struct urb *urb)
{}

static void cport_out_callback(struct urb *urb)
{}

static struct arpc *arpc_alloc(void *payload, u16 size, u8 type)
{}

static void arpc_free(struct arpc *rpc)
{}

static struct arpc *arpc_find(struct es2_ap_dev *es2, __le16 id)
{}

static void arpc_add(struct es2_ap_dev *es2, struct arpc *rpc)
{}

static void arpc_del(struct es2_ap_dev *es2, struct arpc *rpc)
{}

static int arpc_send(struct es2_ap_dev *es2, struct arpc *rpc, int timeout)
{}

static int arpc_sync(struct es2_ap_dev *es2, u8 type, void *payload,
		     size_t size, int *result, unsigned int timeout)
{}

static void arpc_in_callback(struct urb *urb)
{}

#define APB1_LOG_MSG_SIZE
static void apb_log_get(struct es2_ap_dev *es2, char *buf)
{}

static int apb_log_poll(void *data)
{}

static ssize_t apb_log_read(struct file *f, char __user *buf,
			    size_t count, loff_t *ppos)
{}

static const struct file_operations apb_log_fops =;

static void usb_log_enable(struct es2_ap_dev *es2)
{}

static void usb_log_disable(struct es2_ap_dev *es2)
{}

static ssize_t apb_log_enable_read(struct file *f, char __user *buf,
				   size_t count, loff_t *ppos)
{}

static ssize_t apb_log_enable_write(struct file *f, const char __user *buf,
				    size_t count, loff_t *ppos)
{}

static const struct file_operations apb_log_enable_fops =;

static int apb_get_cport_count(struct usb_device *udev)
{}

/*
 * The ES2 USB Bridge device has 15 endpoints
 * 1 Control - usual USB stuff + AP -> APBridgeA messages
 * 7 Bulk IN - CPort data in
 * 7 Bulk OUT - CPort data out
 */
static int ap_probe(struct usb_interface *interface,
		    const struct usb_device_id *id)
{}

static void ap_disconnect(struct usb_interface *interface)
{}

static struct usb_driver es2_ap_driver =;

module_usb_driver();

MODULE_DESCRIPTION();
MODULE_LICENSE();
MODULE_AUTHOR();