Merge tag '6.10-rc6-smb3-server-fixes' of git://git.samba.org/ksmbd
[linux.git] / drivers / usb / isp1760 / isp1760-udc.h
blob22044e86bc0ecb841f0f484e6daaba994ba55c47
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3 * Driver for the NXP ISP1761 device controller
5 * Copyright 2021 Linaro, Rui Miguel Silva
6 * Copyright 2014 Ideas on Board Oy
8 * Contacts:
9 * Laurent Pinchart <laurent.pinchart@ideasonboard.com>
10 * Rui Miguel Silva <rui.silva@linaro.org>
13 #ifndef _ISP1760_UDC_H_
14 #define _ISP1760_UDC_H_
16 #include <linux/ioport.h>
17 #include <linux/list.h>
18 #include <linux/spinlock.h>
19 #include <linux/timer.h>
20 #include <linux/usb/gadget.h>
22 #include "isp1760-regs.h"
24 struct isp1760_device;
25 struct isp1760_udc;
27 enum isp1760_ctrl_state {
28 ISP1760_CTRL_SETUP, /* Waiting for a SETUP transaction */
29 ISP1760_CTRL_DATA_IN, /* Setup received, data IN stage */
30 ISP1760_CTRL_DATA_OUT, /* Setup received, data OUT stage */
31 ISP1760_CTRL_STATUS, /* 0-length request in status stage */
34 struct isp1760_ep {
35 struct isp1760_udc *udc;
36 struct usb_ep ep;
38 struct list_head queue;
40 unsigned int addr;
41 unsigned int maxpacket;
42 char name[7];
44 const struct usb_endpoint_descriptor *desc;
46 bool rx_pending;
47 bool halted;
48 bool wedged;
51 /**
52 * struct isp1760_udc - UDC state information
53 * irq: IRQ number
54 * irqname: IRQ name (as passed to request_irq)
55 * regs: regmap for UDC registers
56 * driver: Gadget driver
57 * gadget: Gadget device
58 * lock: Protects driver, vbus_timer, ep, ep0_*, DC_EPINDEX register
59 * ep: Array of endpoints
60 * ep0_state: Control request state for endpoint 0
61 * ep0_dir: Direction of the current control request
62 * ep0_length: Length of the current control request
63 * connected: Tracks gadget driver bus connection state
65 struct isp1760_udc {
66 struct isp1760_device *isp;
68 int irq;
69 char *irqname;
71 struct regmap *regs;
72 struct regmap_field *fields[DC_FIELD_MAX];
74 struct usb_gadget_driver *driver;
75 struct usb_gadget gadget;
77 spinlock_t lock;
78 struct timer_list vbus_timer;
80 struct isp1760_ep ep[15];
82 enum isp1760_ctrl_state ep0_state;
83 u8 ep0_dir;
84 u16 ep0_length;
86 bool connected;
87 bool is_isp1763;
89 unsigned int devstatus;
92 #ifdef CONFIG_USB_ISP1761_UDC
93 int isp1760_udc_register(struct isp1760_device *isp, int irq,
94 unsigned long irqflags);
95 void isp1760_udc_unregister(struct isp1760_device *isp);
96 #else
97 static inline int isp1760_udc_register(struct isp1760_device *isp, int irq,
98 unsigned long irqflags)
100 return 0;
103 static inline void isp1760_udc_unregister(struct isp1760_device *isp)
106 #endif
108 #endif