/** * struct cdns2_epx_base - base endpoint registers. * @rxbc: OUT endpoint byte count register. * @rxcon: OUT endpoint control register. * @rxcs: OUT endpoint control and status register. * @txbc: IN endpoint byte count register. * @txcon: IN endpoint control register. * @txcs: IN endpoint control and status register.
*/ struct cdns2_epx_base {
__le16 rxbc;
__u8 rxcon;
__u8 rxcs;
__le16 txbc;
__u8 txcon;
__u8 txcs;
} __packed __aligned(4);
/* LPMCTRL - bitmasks. */ /* BESL (Best Effort Service Latency). */ #define LPMCTRLLL_HIRD GENMASK(7, 4) /* Last received Remote Wakeup field from LPM Extended Token packet. */ #define LPMCTRLLH_BREMOTEWAKEUP BIT(8) /* Reflects value of the lpmnyet bit located in the usbcs[1] register. */ #define LPMCTRLLH_LPMNYET BIT(16)
/* LPMCLOCK - bitmasks. */ /* * If bit is 1 the controller automatically turns off clock * (utmisleepm goes to low), else the microprocessor should use * sleep clock gate register to turn off clock.
*/ #define LPMCLOCK_SLEEP_ENTRY BIT(7)
/* USBCS - bitmasks. */ /* Send NYET handshake for the LPM transaction. */ #define USBCS_LPMNYET BIT(2) /* Remote wake-up bit. */ #define USBCS_SIGRSUME BIT(5) /* Software disconnect bit. */ #define USBCS_DISCON BIT(6) /* Indicates that a wakeup pin resumed the controller. */ #define USBCS_WAKESRC BIT(7)
/* SPEEDCTRL - bitmasks. */ /* Device works in Full Speed. */ #define SPEEDCTRL_FS BIT(1) /* Device works in High Speed. */ #define SPEEDCTRL_HS BIT(2) /* Force FS mode. */ #define SPEEDCTRL_HSDISABLE BIT(7)
/* CPUCTRL- bitmasks. */ /* UP clock enable */ #define CPUCTRL_UPCLK BIT(0) /* Controller reset bit. */ #define CPUCTRL_SW_RST BIT(1) /** * If the wuen bit is ‘1’, the upclken is automatically set to ‘1’ after * detecting rising edge of wuintereq interrupt. If the wuen bit is ‘0’, * the wuintereq interrupt is ignored.
*/ #define CPUCTRL_WUEN BIT(7)
/*-------------------------------------------------------------------------*/ #define TRBS_PER_SEGMENT 600 #define ISO_MAX_INTERVAL 8 #define MAX_TRB_LENGTH BIT(16) #define MAX_ISO_SIZE 3076 /* * To improve performance the TRB buffer pointers can't cross * 4KB boundaries.
*/ #define TRB_MAX_ISO_BUFF_SHIFT 12 #define TRB_MAX_ISO_BUFF_SIZE BIT(TRB_MAX_ISO_BUFF_SHIFT) /* How much data is left before the 4KB boundary? */ #define TRB_BUFF_LEN_UP_TO_BOUNDARY(addr) (TRB_MAX_ISO_BUFF_SIZE - \
((addr) & (TRB_MAX_ISO_BUFF_SIZE - 1)))
#if TRBS_PER_SEGMENT < 2 #error"Incorrect TRBS_PER_SEGMENT. Minimal Transfer Ring size is 2." #endif
/** * struct cdns2_trb - represent Transfer Descriptor block. * @buffer: pointer to buffer data. * @length: length of data. * @control: control flags. * * This structure describes transfer block handled by DMA module.
*/ struct cdns2_trb {
__le32 buffer;
__le32 length;
__le32 control;
};
#define TRB_SIZE (sizeof(struct cdns2_trb)) /* * These two extra TRBs are reserved for isochronous transfer * to inject 0 length packet and extra LINK TRB to synchronize the ISO transfer.
*/ #define TRB_ISO_RESERVED 2 #define TR_SEG_SIZE (TRB_SIZE * (TRBS_PER_SEGMENT + TRB_ISO_RESERVED))
/* TRB type IDs. */ /* Used for Bulk, Interrupt, ISOC, and control data stage. */ #define TRB_NORMAL 1 /* TRB for linking ring segments. */ #define TRB_LINK 6
/* Cycle bit - indicates TRB ownership by driver or hw. */ #define TRB_CYCLE BIT(0) /* * When set to '1', the device will toggle its interpretation of the Cycle bit.
*/ #define TRB_TOGGLE BIT(1) /* Interrupt on short packet. */ #define TRB_ISP BIT(2) /* Chain bit associate this TRB with next one TRB. */ #define TRB_CHAIN BIT(4) /* Interrupt on completion. */ #define TRB_IOC BIT(5)
/* Maximum address that can be assigned to device. */ #define USB_DEVICE_MAX_ADDRESS 127
/* One control and 15 IN and 15 OUT endpoints. */ #define CDNS2_ENDPOINTS_NUM 31
#define CDNS2_EP_ZLP_BUF_SIZE 512
/*-------------------------------------------------------------------------*/ /* Used structures. */
struct cdns2_device;
/** * struct cdns2_ring - transfer ring representation. * @trbs: pointer to transfer ring. * @dma: dma address of transfer ring. * @free_trbs: number of free TRBs in transfer ring. * @pcs: producer cycle state. * @ccs: consumer cycle state. * @enqueue: enqueue index in transfer ring. * @dequeue: dequeue index in transfer ring.
*/ struct cdns2_ring { struct cdns2_trb *trbs;
dma_addr_t dma; int free_trbs;
u8 pcs;
u8 ccs; int enqueue; int dequeue;
};
/** * struct cdns2_endpoint - extended device side representation of USB endpoint. * @endpoint: usb endpoint. * @pending_list: list of requests queuing on transfer ring. * @deferred_list: list of requests waiting for queuing on transfer ring. * @pdev: device associated with endpoint. * @name: a human readable name e.g. ep1out. * @ring: transfer ring associated with endpoint. * @ep_state: state of endpoint. * @idx: index of endpoint in pdev->eps table. * @dir: endpoint direction. * @num: endpoint number (1 - 15). * @type: set to bmAttributes & USB_ENDPOINT_XFERTYPE_MASK. * @interval: interval between packets used for ISOC and Interrupt endpoint. * @buffering: on-chip buffers assigned to endpoint. * @trb_burst_size: number of burst used in TRB. * @skip: Sometimes the controller cannot process isochronous endpoint ring * quickly enough and it will miss some isoc tds on the ring and * generate ISO transmition error. * Driver sets skip flag when receive a ISO transmition error and * process the missed TDs on the endpoint ring. * @wa1_set: use WA1. * @wa1_trb: TRB assigned to WA1. * @wa1_trb_index: TRB index for WA1. * @wa1_cycle_bit: correct cycle bit for WA1.
*/ struct cdns2_endpoint { struct usb_ep endpoint; struct list_head pending_list; struct list_head deferred_list;
/** * struct cdns2_request - extended device side representation of usb_request * object. * @request: generic usb_request object describing single I/O request. * @pep: extended representation of usb_ep object. * @trb: the first TRB association with this request. * @start_trb: number of the first TRB in transfer ring. * @end_trb: number of the last TRB in transfer ring. * @list: used for queuing request in lists. * @finished_trb: number of trb has already finished per request. * @num_of_trb: how many trbs are associated with request.
*/ struct cdns2_request { struct usb_request request; struct cdns2_endpoint *pep; struct cdns2_trb *trb; int start_trb; int end_trb; struct list_head list; int finished_trb; int num_of_trb;
};
/* Stages used during enumeration process.*/ #define CDNS2_SETUP_STAGE 0x0 #define CDNS2_DATA_STAGE 0x1 #define CDNS2_STATUS_STAGE 0x2
/** * struct cdns2_device - represent USB device. * @dev: pointer to device structure associated whit this controller. * @gadget: device side representation of the peripheral controller. * @gadget_driver: pointer to the gadget driver. * @lock: for synchronizing. * @irq: interrupt line number. * @regs: base address for registers * @usb_regs: base address for common USB registers. * @ep0_regs: base address for endpoint 0 related registers. * @epx_regs: base address for all none control endpoint registers. * @interrupt_regs: base address for interrupt handling related registers. * @adma_regs: base address for ADMA registers. * @eps_dma_pool: endpoint Transfer Ring pool. * @setup: used while processing usb control requests. * @ep0_preq: private request used while handling EP0. * @ep0_stage: ep0 stage during enumeration process. * @zlp_buf: zlp buffer. * @dev_address: device address assigned by host. * @eps: array of objects describing endpoints. * @selected_ep: actually selected endpoint. It's used only to improve * performance by limiting access to dma_ep_sel register. * @is_selfpowered: device is self powered. * @may_wakeup: allows device to remote wakeup the host. * @status_completion_no_call: indicate that driver is waiting for status * stage completion. It's used in deferred SET_CONFIGURATION request. * @in_lpm: indicate the controller is in low power mode. * @pending_status_wq: workqueue handling status stage for deferred requests. * @pending_status_request: request for which status stage was deferred. * @eps_supported: endpoints supported by controller in form: * bit: 0 - ep0, 1 - epOut1, 2 - epIn1, 3 - epOut2 ... * @burst_opt: array with the best burst size value for different TRB size. * @onchip_tx_buf: size of transmit on-chip buffer in KB. * @onchip_rx_buf: size of receive on-chip buffer in KB.
*/ struct cdns2_device { struct device *dev; struct usb_gadget gadget; struct usb_gadget_driver *gadget_driver;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.