0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef _ISP1760_UDC_H_
0014 #define _ISP1760_UDC_H_
0015
0016 #include <linux/ioport.h>
0017 #include <linux/list.h>
0018 #include <linux/spinlock.h>
0019 #include <linux/timer.h>
0020 #include <linux/usb/gadget.h>
0021
0022 #include "isp1760-regs.h"
0023
0024 struct isp1760_device;
0025 struct isp1760_udc;
0026
0027 enum isp1760_ctrl_state {
0028 ISP1760_CTRL_SETUP,
0029 ISP1760_CTRL_DATA_IN,
0030 ISP1760_CTRL_DATA_OUT,
0031 ISP1760_CTRL_STATUS,
0032 };
0033
0034 struct isp1760_ep {
0035 struct isp1760_udc *udc;
0036 struct usb_ep ep;
0037
0038 struct list_head queue;
0039
0040 unsigned int addr;
0041 unsigned int maxpacket;
0042 char name[7];
0043
0044 const struct usb_endpoint_descriptor *desc;
0045
0046 bool rx_pending;
0047 bool halted;
0048 bool wedged;
0049 };
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065 struct isp1760_udc {
0066 struct isp1760_device *isp;
0067
0068 int irq;
0069 char *irqname;
0070
0071 struct regmap *regs;
0072 struct regmap_field *fields[DC_FIELD_MAX];
0073
0074 struct usb_gadget_driver *driver;
0075 struct usb_gadget gadget;
0076
0077 spinlock_t lock;
0078 struct timer_list vbus_timer;
0079
0080 struct isp1760_ep ep[15];
0081
0082 enum isp1760_ctrl_state ep0_state;
0083 u8 ep0_dir;
0084 u16 ep0_length;
0085
0086 bool connected;
0087 bool is_isp1763;
0088
0089 unsigned int devstatus;
0090 };
0091
0092 #ifdef CONFIG_USB_ISP1761_UDC
0093 int isp1760_udc_register(struct isp1760_device *isp, int irq,
0094 unsigned long irqflags);
0095 void isp1760_udc_unregister(struct isp1760_device *isp);
0096 #else
0097 static inline int isp1760_udc_register(struct isp1760_device *isp, int irq,
0098 unsigned long irqflags)
0099 {
0100 return 0;
0101 }
0102
0103 static inline void isp1760_udc_unregister(struct isp1760_device *isp)
0104 {
0105 }
0106 #endif
0107
0108 #endif