isp1760-hcd.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _ISP1760_HCD_H_
  3. #define _ISP1760_HCD_H_
  4. #include <linux/spinlock.h>
  5. struct isp1760_qh;
  6. struct isp1760_qtd;
  7. struct resource;
  8. struct usb_hcd;
  9. /*
  10. * 60kb divided in:
  11. * - 32 blocks @ 256 bytes
  12. * - 20 blocks @ 1024 bytes
  13. * - 4 blocks @ 8192 bytes
  14. */
  15. #define BLOCK_1_NUM 32
  16. #define BLOCK_2_NUM 20
  17. #define BLOCK_3_NUM 4
  18. #define BLOCK_1_SIZE 256
  19. #define BLOCK_2_SIZE 1024
  20. #define BLOCK_3_SIZE 8192
  21. #define BLOCKS (BLOCK_1_NUM + BLOCK_2_NUM + BLOCK_3_NUM)
  22. #define MAX_PAYLOAD_SIZE BLOCK_3_SIZE
  23. #define PAYLOAD_AREA_SIZE 0xf000
  24. struct isp1760_slotinfo {
  25. struct isp1760_qh *qh;
  26. struct isp1760_qtd *qtd;
  27. unsigned long timestamp;
  28. };
  29. /* chip memory management */
  30. struct isp1760_memory_chunk {
  31. unsigned int start;
  32. unsigned int size;
  33. unsigned int free;
  34. };
  35. enum isp1760_queue_head_types {
  36. QH_CONTROL,
  37. QH_BULK,
  38. QH_INTERRUPT,
  39. QH_END
  40. };
  41. struct isp1760_hcd {
  42. #ifdef CONFIG_USB_ISP1760_HCD
  43. struct usb_hcd *hcd;
  44. u32 hcs_params;
  45. spinlock_t lock;
  46. struct isp1760_slotinfo atl_slots[32];
  47. int atl_done_map;
  48. struct isp1760_slotinfo int_slots[32];
  49. int int_done_map;
  50. struct isp1760_memory_chunk memory_pool[BLOCKS];
  51. struct list_head qh_list[QH_END];
  52. /* periodic schedule support */
  53. #define DEFAULT_I_TDPS 1024
  54. unsigned periodic_size;
  55. unsigned i_thresh;
  56. unsigned long reset_done;
  57. unsigned long next_statechange;
  58. #endif
  59. };
  60. #ifdef CONFIG_USB_ISP1760_HCD
  61. int isp1760_hcd_register(struct isp1760_hcd *priv, void __iomem *regs,
  62. struct resource *mem, int irq, unsigned long irqflags,
  63. struct device *dev);
  64. void isp1760_hcd_unregister(struct isp1760_hcd *priv);
  65. int isp1760_init_kmem_once(void);
  66. void isp1760_deinit_kmem_cache(void);
  67. #else
  68. static inline int isp1760_hcd_register(struct isp1760_hcd *priv,
  69. void __iomem *regs, struct resource *mem,
  70. int irq, unsigned long irqflags,
  71. struct device *dev)
  72. {
  73. return 0;
  74. }
  75. static inline void isp1760_hcd_unregister(struct isp1760_hcd *priv)
  76. {
  77. }
  78. static inline int isp1760_init_kmem_once(void)
  79. {
  80. return 0;
  81. }
  82. static inline void isp1760_deinit_kmem_cache(void)
  83. {
  84. }
  85. #endif
  86. #endif /* _ISP1760_HCD_H_ */