Lukasz Majewski | 38517a7 | 2011-10-27 10:36:46 +0200 | [diff] [blame] | 1 | /* |
| 2 | * drivers/usb/gadget/s3c_udc.h |
| 3 | * Samsung S3C on-chip full/high speed USB device controllers |
| 4 | * Copyright (C) 2005 for Samsung Electronics |
| 5 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 6 | * SPDX-License-Identifier: GPL-2.0+ |
Lukasz Majewski | 38517a7 | 2011-10-27 10:36:46 +0200 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #ifndef __S3C_USB_GADGET |
| 10 | #define __S3C_USB_GADGET |
| 11 | |
| 12 | #include <asm/errno.h> |
| 13 | #include <linux/usb/ch9.h> |
| 14 | #include <linux/usb/gadget.h> |
| 15 | #include <linux/list.h> |
| 16 | #include <usb/lin_gadget_compat.h> |
| 17 | |
| 18 | #define PHY0_SLEEP (1 << 5) |
| 19 | |
| 20 | /*-------------------------------------------------------------------------*/ |
| 21 | /* DMA bounce buffer size, 16K is enough even for mass storage */ |
| 22 | #define DMA_BUFFER_SIZE (4096*4) |
| 23 | |
| 24 | #define EP0_FIFO_SIZE 64 |
| 25 | #define EP_FIFO_SIZE 512 |
| 26 | #define EP_FIFO_SIZE2 1024 |
| 27 | /* ep0-control, ep1in-bulk, ep2out-bulk, ep3in-int */ |
| 28 | #define S3C_MAX_ENDPOINTS 4 |
| 29 | #define S3C_MAX_HW_ENDPOINTS 16 |
| 30 | |
| 31 | #define WAIT_FOR_SETUP 0 |
| 32 | #define DATA_STATE_XMIT 1 |
| 33 | #define DATA_STATE_NEED_ZLP 2 |
| 34 | #define WAIT_FOR_OUT_STATUS 3 |
| 35 | #define DATA_STATE_RECV 4 |
| 36 | #define WAIT_FOR_COMPLETE 5 |
| 37 | #define WAIT_FOR_OUT_COMPLETE 6 |
| 38 | #define WAIT_FOR_IN_COMPLETE 7 |
| 39 | #define WAIT_FOR_NULL_COMPLETE 8 |
| 40 | |
| 41 | #define TEST_J_SEL 0x1 |
| 42 | #define TEST_K_SEL 0x2 |
| 43 | #define TEST_SE0_NAK_SEL 0x3 |
| 44 | #define TEST_PACKET_SEL 0x4 |
| 45 | #define TEST_FORCE_ENABLE_SEL 0x5 |
| 46 | |
| 47 | /* ************************************************************************* */ |
| 48 | /* IO |
| 49 | */ |
| 50 | |
| 51 | enum ep_type { |
| 52 | ep_control, ep_bulk_in, ep_bulk_out, ep_interrupt |
| 53 | }; |
| 54 | |
| 55 | struct s3c_ep { |
| 56 | struct usb_ep ep; |
| 57 | struct s3c_udc *dev; |
| 58 | |
| 59 | const struct usb_endpoint_descriptor *desc; |
| 60 | struct list_head queue; |
| 61 | unsigned long pio_irqs; |
| 62 | int len; |
| 63 | void *dma_buf; |
| 64 | |
| 65 | u8 stopped; |
| 66 | u8 bEndpointAddress; |
| 67 | u8 bmAttributes; |
| 68 | |
| 69 | enum ep_type ep_type; |
| 70 | int fifo_num; |
| 71 | }; |
| 72 | |
| 73 | struct s3c_request { |
| 74 | struct usb_request req; |
| 75 | struct list_head queue; |
| 76 | }; |
| 77 | |
| 78 | struct s3c_udc { |
| 79 | struct usb_gadget gadget; |
| 80 | struct usb_gadget_driver *driver; |
| 81 | |
| 82 | struct s3c_plat_otg_data *pdata; |
| 83 | |
| 84 | void *dma_buf[S3C_MAX_ENDPOINTS+1]; |
| 85 | dma_addr_t dma_addr[S3C_MAX_ENDPOINTS+1]; |
| 86 | |
| 87 | int ep0state; |
| 88 | struct s3c_ep ep[S3C_MAX_ENDPOINTS]; |
| 89 | |
| 90 | unsigned char usb_address; |
| 91 | |
Ćukasz Majewski | 7cf7bef | 2012-03-12 22:08:06 +0000 | [diff] [blame] | 92 | unsigned req_pending:1, req_std:1; |
Lukasz Majewski | 38517a7 | 2011-10-27 10:36:46 +0200 | [diff] [blame] | 93 | }; |
| 94 | |
| 95 | extern struct s3c_udc *the_controller; |
| 96 | |
| 97 | #define ep_is_in(EP) (((EP)->bEndpointAddress&USB_DIR_IN) == USB_DIR_IN) |
| 98 | #define ep_index(EP) ((EP)->bEndpointAddress&0xF) |
| 99 | #define ep_maxpacket(EP) ((EP)->ep.maxpacket) |
| 100 | |
Lukasz Majewski | 38517a7 | 2011-10-27 10:36:46 +0200 | [diff] [blame] | 101 | extern void otg_phy_init(struct s3c_udc *dev); |
| 102 | extern void otg_phy_off(struct s3c_udc *dev); |
| 103 | |
| 104 | extern void s3c_udc_ep_set_stall(struct s3c_ep *ep); |
| 105 | extern int s3c_udc_probe(struct s3c_plat_otg_data *pdata); |
| 106 | |
| 107 | struct s3c_plat_otg_data { |
| 108 | int (*phy_control)(int on); |
| 109 | unsigned int regs_phy; |
| 110 | unsigned int regs_otg; |
| 111 | unsigned int usb_phy_ctrl; |
| 112 | unsigned int usb_flags; |
| 113 | }; |
| 114 | #endif |