s3c_udc.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. *
  6. * SPDX-License-Identifier: GPL-2.0+
  7. */
  8. #ifndef __S3C_USB_GADGET
  9. #define __S3C_USB_GADGET
  10. #include <asm/errno.h>
  11. #include <linux/sizes.h>
  12. #include <linux/usb/ch9.h>
  13. #include <linux/usb/gadget.h>
  14. #include <linux/list.h>
  15. #include <usb/lin_gadget_compat.h>
  16. #define PHY0_SLEEP (1 << 5)
  17. /*-------------------------------------------------------------------------*/
  18. /* DMA bounce buffer size, 16K is enough even for mass storage */
  19. #define DMA_BUFFER_SIZE (16*SZ_1K)
  20. #define EP0_FIFO_SIZE 64
  21. #define EP_FIFO_SIZE 512
  22. #define EP_FIFO_SIZE2 1024
  23. /* ep0-control, ep1in-bulk, ep2out-bulk, ep3in-int */
  24. #define S3C_MAX_ENDPOINTS 4
  25. #define S3C_MAX_HW_ENDPOINTS 16
  26. #define WAIT_FOR_SETUP 0
  27. #define DATA_STATE_XMIT 1
  28. #define DATA_STATE_NEED_ZLP 2
  29. #define WAIT_FOR_OUT_STATUS 3
  30. #define DATA_STATE_RECV 4
  31. #define WAIT_FOR_COMPLETE 5
  32. #define WAIT_FOR_OUT_COMPLETE 6
  33. #define WAIT_FOR_IN_COMPLETE 7
  34. #define WAIT_FOR_NULL_COMPLETE 8
  35. #define TEST_J_SEL 0x1
  36. #define TEST_K_SEL 0x2
  37. #define TEST_SE0_NAK_SEL 0x3
  38. #define TEST_PACKET_SEL 0x4
  39. #define TEST_FORCE_ENABLE_SEL 0x5
  40. /* ************************************************************************* */
  41. /* IO
  42. */
  43. enum ep_type {
  44. ep_control, ep_bulk_in, ep_bulk_out, ep_interrupt
  45. };
  46. struct s3c_ep {
  47. struct usb_ep ep;
  48. struct dwc2_udc *dev;
  49. const struct usb_endpoint_descriptor *desc;
  50. struct list_head queue;
  51. unsigned long pio_irqs;
  52. int len;
  53. void *dma_buf;
  54. u8 stopped;
  55. u8 bEndpointAddress;
  56. u8 bmAttributes;
  57. enum ep_type ep_type;
  58. int fifo_num;
  59. };
  60. struct s3c_request {
  61. struct usb_request req;
  62. struct list_head queue;
  63. };
  64. struct dwc2_udc {
  65. struct usb_gadget gadget;
  66. struct usb_gadget_driver *driver;
  67. struct s3c_plat_otg_data *pdata;
  68. int ep0state;
  69. struct s3c_ep ep[S3C_MAX_ENDPOINTS];
  70. unsigned char usb_address;
  71. unsigned req_pending:1, req_std:1;
  72. };
  73. extern struct dwc2_udc *the_controller;
  74. #define ep_is_in(EP) (((EP)->bEndpointAddress&USB_DIR_IN) == USB_DIR_IN)
  75. #define ep_index(EP) ((EP)->bEndpointAddress&0xF)
  76. #define ep_maxpacket(EP) ((EP)->ep.maxpacket)
  77. extern void otg_phy_init(struct dwc2_udc *dev);
  78. extern void otg_phy_off(struct dwc2_udc *dev);
  79. extern void s3c_udc_ep_set_stall(struct s3c_ep *ep);
  80. extern int s3c_udc_probe(struct s3c_plat_otg_data *pdata);
  81. struct s3c_plat_otg_data {
  82. int (*phy_control)(int on);
  83. unsigned int regs_phy;
  84. unsigned int regs_otg;
  85. unsigned int usb_phy_ctrl;
  86. unsigned int usb_flags;
  87. unsigned int usb_gusbcfg;
  88. };
  89. #endif