// 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 500/* Default timeout for ARPC CPort requests */#define ES2_ARPC_CPORT_TIMEOUT 500/* Fixed CPort numbers */#define ES2_CPORT_CDSI0 16#define ES2_CPORT_CDSI1 17/* Memory sizes for the buffers sent to/from the ES2 controller */#define ES2_GBUF_MSG_SIZE_MAX 2048/* Memory sizes for the ARPC buffers */#define ARPC_OUT_SIZE_MAX U16_MAX#define ARPC_IN_SIZE_MAX 128staticconststructusb_device_idid_table[]={{USB_DEVICE(0x18d1,0x1eaf)},{},};MODULE_DEVICE_TABLE(usb,id_table);#define APB1_LOG_SIZE SZ_16K/* * 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 4/* 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 8/* * Number of ARPC in urbs in flight at any point in time. */#define NUM_ARPC_IN_URB 2/* * @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 */structes2_cport_in{__u8endpoint;structurb*urb[NUM_CPORT_IN_URB];u8*buffer[NUM_CPORT_IN_URB];};/** * 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: l