Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Driver for the NXP ISP1761 device controller
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Copyright 2014 Ideas on Board Oy
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * Contacts:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  *	Laurent Pinchart <laurent.pinchart@ideasonboard.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #ifndef _ISP1760_UDC_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #define _ISP1760_UDC_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/ioport.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/list.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/spinlock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <linux/timer.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <linux/usb/gadget.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) struct isp1760_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) struct isp1760_udc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) enum isp1760_ctrl_state {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 	ISP1760_CTRL_SETUP,		/* Waiting for a SETUP transaction */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 	ISP1760_CTRL_DATA_IN,		/* Setup received, data IN stage */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 	ISP1760_CTRL_DATA_OUT,		/* Setup received, data OUT stage */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 	ISP1760_CTRL_STATUS,		/* 0-length request in status stage */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) struct isp1760_ep {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	struct isp1760_udc *udc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	struct usb_ep ep;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	struct list_head queue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	unsigned int addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	unsigned int maxpacket;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	char name[7];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	const struct usb_endpoint_descriptor *desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	bool rx_pending;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	bool halted;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	bool wedged;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48)  * struct isp1760_udc - UDC state information
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49)  * irq: IRQ number
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50)  * irqname: IRQ name (as passed to request_irq)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51)  * regs: Base address of the UDC registers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52)  * driver: Gadget driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53)  * gadget: Gadget device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54)  * lock: Protects driver, vbus_timer, ep, ep0_*, DC_EPINDEX register
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55)  * ep: Array of endpoints
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56)  * ep0_state: Control request state for endpoint 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57)  * ep0_dir: Direction of the current control request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58)  * ep0_length: Length of the current control request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59)  * connected: Tracks gadget driver bus connection state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) struct isp1760_udc {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) #ifdef CONFIG_USB_ISP1761_UDC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	struct isp1760_device *isp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	int irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	char *irqname;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	void __iomem *regs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	struct usb_gadget_driver *driver;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	struct usb_gadget gadget;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	spinlock_t lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	struct timer_list vbus_timer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	struct isp1760_ep ep[15];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	enum isp1760_ctrl_state ep0_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	u8 ep0_dir;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	u16 ep0_length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	bool connected;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	unsigned int devstatus;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) #ifdef CONFIG_USB_ISP1761_UDC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) int isp1760_udc_register(struct isp1760_device *isp, int irq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 			 unsigned long irqflags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) void isp1760_udc_unregister(struct isp1760_device *isp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) static inline int isp1760_udc_register(struct isp1760_device *isp, int irq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 				       unsigned long irqflags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) static inline void isp1760_udc_unregister(struct isp1760_device *isp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) #endif