1 /* 2 * Intel PXA25x on-chip full speed USB device controller 3 * 4 * Copyright (C) 2003 Robert Schwebel <r.schwebel@pengutronix.de>, Pengutronix 5 * Copyright (C) 2003 David Brownell 6 * Copyright (C) 2012 Lukasz Dalek <luk0104@gmail.com> 7 * 8 * SPDX-License-Identifier: GPL-2.0+ 9 */ 10 11 #ifndef __LINUX_USB_GADGET_PXA25X_H 12 #define __LINUX_USB_GADGET_PXA25X_H 13 14 #include <linux/types.h> 15 #include <asm/arch/regs-usb.h> 16 17 /* 18 * Prefetching support - only ARMv5. 19 */ 20 21 #ifdef ARCH_HAS_PREFETCH 22 static inline void prefetch(const void *ptr) 23 { 24 __asm__ __volatile__( 25 "pld\t%a0" 26 : 27 : "p" (ptr) 28 : "cc"); 29 } 30 31 #define prefetchw(ptr) prefetch(ptr) 32 #endif /* ARCH_HAS_PREFETCH */ 33 34 /*-------------------------------------------------------------------------*/ 35 36 #define UDC_REGS ((struct pxa25x_udc_regs *)PXA25X_UDC_BASE) 37 38 /*-------------------------------------------------------------------------*/ 39 40 struct pxa2xx_udc_mach_info { 41 int (*udc_is_connected)(void); /* do we see host? */ 42 void (*udc_command)(int cmd); 43 #define PXA2XX_UDC_CMD_CONNECT 0 /* let host see us */ 44 #define PXA2XX_UDC_CMD_DISCONNECT 1 /* so host won't see us */ 45 }; 46 47 struct pxa25x_udc; 48 49 struct pxa25x_ep { 50 struct usb_ep ep; 51 struct pxa25x_udc *dev; 52 53 const struct usb_endpoint_descriptor *desc; 54 struct list_head queue; 55 unsigned long pio_irqs; 56 57 unsigned short fifo_size; 58 u8 bEndpointAddress; 59 u8 bmAttributes; 60 61 unsigned stopped:1; 62 63 /* UDCCS = UDC Control/Status for this EP 64 * UBCR = UDC Byte Count Remaining (contents of OUT fifo) 65 * UDDR = UDC Endpoint Data Register (the fifo) 66 * DRCM = DMA Request Channel Map 67 */ 68 u32 *reg_udccs; 69 u32 *reg_ubcr; 70 u32 *reg_uddr; 71 }; 72 73 struct pxa25x_request { 74 struct usb_request req; 75 struct list_head queue; 76 }; 77 78 enum ep0_state { 79 EP0_IDLE, 80 EP0_IN_DATA_PHASE, 81 EP0_OUT_DATA_PHASE, 82 EP0_END_XFER, 83 EP0_STALL, 84 }; 85 86 #define EP0_FIFO_SIZE 16U 87 #define BULK_FIFO_SIZE 64U 88 #define ISO_FIFO_SIZE 256U 89 #define INT_FIFO_SIZE 8U 90 91 struct udc_stats { 92 struct ep0stats { 93 unsigned long ops; 94 unsigned long bytes; 95 } read, write; 96 unsigned long irqs; 97 }; 98 99 #ifdef CONFIG_USB_PXA25X_SMALL 100 /* when memory's tight, SMALL config saves code+data. */ 101 #define PXA_UDC_NUM_ENDPOINTS 3 102 #endif 103 104 #ifndef PXA_UDC_NUM_ENDPOINTS 105 #define PXA_UDC_NUM_ENDPOINTS 16 106 #endif 107 108 struct pxa25x_watchdog { 109 unsigned running:1; 110 ulong period; 111 ulong base; 112 struct pxa25x_udc *udc; 113 114 void (*function)(struct pxa25x_udc *udc); 115 }; 116 117 struct pxa25x_udc { 118 struct usb_gadget gadget; 119 struct usb_gadget_driver *driver; 120 struct pxa25x_udc_regs *regs; 121 122 enum ep0_state ep0state; 123 struct udc_stats stats; 124 unsigned got_irq:1, 125 pullup:1, 126 has_cfr:1, 127 req_pending:1, 128 req_std:1, 129 req_config:1, 130 active:1; 131 132 struct clk *clk; 133 struct pxa2xx_udc_mach_info *mach; 134 u64 dma_mask; 135 struct pxa25x_ep ep[PXA_UDC_NUM_ENDPOINTS]; 136 137 struct pxa25x_watchdog watchdog; 138 }; 139 140 /*-------------------------------------------------------------------------*/ 141 142 static struct pxa25x_udc *the_controller; 143 144 /*-------------------------------------------------------------------------*/ 145 146 #ifndef DEBUG 147 # define NOISY 0 148 #endif 149 150 #endif /* __LINUX_USB_GADGET_PXA25X_H */ 151