|
| 1 | +/* SPDX-License-Identifier: GPL-2.0 */ |
| 2 | + |
| 3 | +#ifndef __PHYTIUM_CORE_H__ |
| 4 | +#define __PHYTIUM_CORE_H__ |
| 5 | + |
| 6 | +#include <linux/usb/gadget.h> |
| 7 | +#include <linux/usb/otg.h> |
| 8 | +#include "host_api.h" |
| 9 | +#include "gadget.h" |
| 10 | + |
| 11 | +#define MAX_EPS_CHANNELS 16 |
| 12 | + |
| 13 | +struct phytium_ep { |
| 14 | + struct phytium_cusb *config; |
| 15 | + u16 max_packet; |
| 16 | + u8 ep_num; |
| 17 | + struct GADGET_EP *gadget_ep; |
| 18 | + struct list_head req_list; |
| 19 | + struct usb_ep end_point; |
| 20 | + char name[12]; |
| 21 | + u8 is_tx; |
| 22 | + const struct usb_endpoint_descriptor *desc; |
| 23 | + u8 busy; |
| 24 | +}; |
| 25 | + |
| 26 | +struct phytium_request { |
| 27 | + struct usb_request request; |
| 28 | + struct GADGET_REQ *gadget_request; |
| 29 | + struct list_head list; |
| 30 | + struct phytium_ep *ep; |
| 31 | + struct phytium_cusb *config; |
| 32 | + u8 is_tx; |
| 33 | + u8 epnum; |
| 34 | +}; |
| 35 | + |
| 36 | +struct phytium_cusb { |
| 37 | + struct device *dev; |
| 38 | + void __iomem *regs; |
| 39 | + void __iomem *phy_regs; |
| 40 | + int irq; |
| 41 | + spinlock_t lock; |
| 42 | + enum usb_dr_mode dr_mode; |
| 43 | + |
| 44 | + struct GADGET_OBJ *gadget_obj; |
| 45 | + struct GADGET_CFG gadget_cfg; |
| 46 | + struct GADGET_CALLBACKS gadget_callbacks; |
| 47 | + struct GADGET_SYSREQ gadget_sysreq; |
| 48 | + struct GADGET_DEV *gadget_dev; |
| 49 | + void *gadget_priv; |
| 50 | + |
| 51 | + struct usb_gadget gadget; |
| 52 | + struct usb_gadget_driver *gadget_driver; |
| 53 | + struct phytium_ep endpoints_tx[MAX_EPS_CHANNELS]; |
| 54 | + struct phytium_ep endpoints_rx[MAX_EPS_CHANNELS]; |
| 55 | + u8 ep0_data_stage_is_tx; |
| 56 | + |
| 57 | + struct HOST_OBJ *host_obj; |
| 58 | + struct HOST_CFG host_cfg; |
| 59 | + struct HOST_CALLBACKS host_callbacks; |
| 60 | + struct HOST_SYSREQ host_sysreq; |
| 61 | + void *host_priv; |
| 62 | + struct usb_hcd *hcd; |
| 63 | + |
| 64 | + struct DMA_OBJ *dma_obj; |
| 65 | + struct DMA_CFG dma_cfg; |
| 66 | + struct DMA_CALLBACKS dma_callbacks; |
| 67 | + struct DMA_SYSREQ dma_sysreq; |
| 68 | + bool isVhubHost; |
| 69 | +}; |
| 70 | + |
| 71 | +int phytium_core_reset(struct phytium_cusb *config, bool skip_wait); |
| 72 | + |
| 73 | +int phytium_host_init(struct phytium_cusb *config); |
| 74 | +int phytium_host_uninit(struct phytium_cusb *config); |
| 75 | + |
| 76 | +#ifdef CONFIG_PM |
| 77 | +int phytium_host_resume(void *priv); |
| 78 | +int phytium_host_suspend(void *priv); |
| 79 | +int phytium_gadget_resume(void *priv); |
| 80 | +int phytium_gadget_suspend(void *priv); |
| 81 | +#endif |
| 82 | + |
| 83 | +int phytium_gadget_init(struct phytium_cusb *config); |
| 84 | +int phytium_gadget_uninit(struct phytium_cusb *config); |
| 85 | + |
| 86 | +uint32_t phytium_read32(uint32_t *address); |
| 87 | + |
| 88 | +void phytium_write32(uint32_t *address, uint32_t value); |
| 89 | + |
| 90 | +uint16_t phytium_read16(uint16_t *address); |
| 91 | + |
| 92 | +void phytium_write16(uint16_t *address, uint16_t value); |
| 93 | + |
| 94 | +uint8_t phytium_read8(uint8_t *address); |
| 95 | + |
| 96 | +void phytium_write8(uint8_t *address, uint8_t value); |
| 97 | + |
| 98 | +#endif |
0 commit comments