s3c2410_udc.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * linux/drivers/usb/gadget/s3c2410_udc.h
  4. * Samsung on-chip full speed USB device controllers
  5. *
  6. * Copyright (C) 2004-2007 Herbert Pötzl - Arnaud Patard
  7. * Additional cleanups by Ben Dooks <[email protected]>
  8. */
  9. #ifndef _S3C2410_UDC_H
  10. #define _S3C2410_UDC_H
  11. struct s3c2410_ep {
  12. struct list_head queue;
  13. unsigned long last_io; /* jiffies timestamp */
  14. struct usb_gadget *gadget;
  15. struct s3c2410_udc *dev;
  16. struct usb_ep ep;
  17. u8 num;
  18. unsigned short fifo_size;
  19. u8 bEndpointAddress;
  20. u8 bmAttributes;
  21. unsigned halted : 1;
  22. unsigned already_seen : 1;
  23. unsigned setup_stage : 1;
  24. };
  25. /* Warning : ep0 has a fifo of 16 bytes */
  26. /* Don't try to set 32 or 64 */
  27. /* also testusb 14 fails wit 16 but is */
  28. /* fine with 8 */
  29. #define EP0_FIFO_SIZE 8
  30. #define EP_FIFO_SIZE 64
  31. #define DEFAULT_POWER_STATE 0x00
  32. #define S3C2440_EP_FIFO_SIZE 128
  33. static const char ep0name [] = "ep0";
  34. static const char *const ep_name[] = {
  35. ep0name, /* everyone has ep0 */
  36. /* s3c2410 four bidirectional bulk endpoints */
  37. "ep1-bulk", "ep2-bulk", "ep3-bulk", "ep4-bulk",
  38. };
  39. #define S3C2410_ENDPOINTS ARRAY_SIZE(ep_name)
  40. struct s3c2410_request {
  41. struct list_head queue; /* ep's requests */
  42. struct usb_request req;
  43. };
  44. enum ep0_state {
  45. EP0_IDLE,
  46. EP0_IN_DATA_PHASE,
  47. EP0_OUT_DATA_PHASE,
  48. EP0_END_XFER,
  49. EP0_STALL,
  50. };
  51. static const char *ep0states[]= {
  52. "EP0_IDLE",
  53. "EP0_IN_DATA_PHASE",
  54. "EP0_OUT_DATA_PHASE",
  55. "EP0_END_XFER",
  56. "EP0_STALL",
  57. };
  58. struct s3c2410_udc {
  59. spinlock_t lock;
  60. struct s3c2410_ep ep[S3C2410_ENDPOINTS];
  61. int address;
  62. struct usb_gadget gadget;
  63. struct usb_gadget_driver *driver;
  64. struct s3c2410_request fifo_req;
  65. u8 fifo_buf[EP_FIFO_SIZE];
  66. u16 devstatus;
  67. u32 port_status;
  68. int ep0state;
  69. struct gpio_desc *vbus_gpiod;
  70. struct gpio_desc *pullup_gpiod;
  71. unsigned got_irq : 1;
  72. unsigned req_std : 1;
  73. unsigned req_config : 1;
  74. unsigned req_pending : 1;
  75. u8 vbus;
  76. int irq;
  77. };
  78. #define to_s3c2410(g) (container_of((g), struct s3c2410_udc, gadget))
  79. #endif