c67x00-hcd.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * c67x00-hcd.h: Cypress C67X00 USB HCD
  4. *
  5. * Copyright (C) 2006-2008 Barco N.V.
  6. * Derived from the Cypress cy7c67200/300 ezusb linux driver and
  7. * based on multiple host controller drivers inside the linux kernel.
  8. */
  9. #ifndef _USB_C67X00_HCD_H
  10. #define _USB_C67X00_HCD_H
  11. #include <linux/kernel.h>
  12. #include <linux/spinlock.h>
  13. #include <linux/list.h>
  14. #include <linux/usb.h>
  15. #include <linux/usb/hcd.h>
  16. #include "c67x00.h"
  17. /*
  18. * The following parameters depend on the CPU speed, bus speed, ...
  19. * These can be tuned for specific use cases, e.g. if isochronous transfers
  20. * are very important, bandwidth can be sacrificed to guarantee that the
  21. * 1ms deadline will be met.
  22. * If bulk transfers are important, the MAX_FRAME_BW can be increased,
  23. * but some (or many) isochronous deadlines might not be met.
  24. *
  25. * The values are specified in bittime.
  26. */
  27. /*
  28. * The current implementation switches between _STD (default) and _ISO (when
  29. * isochronous transfers are scheduled), in order to optimize the throughput
  30. * in normal circumstances, but also provide good isochronous behaviour.
  31. *
  32. * Bandwidth is described in bit time so with a 12MHz USB clock and 1ms
  33. * frames; there are 12000 bit times per frame.
  34. */
  35. #define TOTAL_FRAME_BW 12000
  36. #define DEFAULT_EOT 2250
  37. #define MAX_FRAME_BW_STD (TOTAL_FRAME_BW - DEFAULT_EOT)
  38. #define MAX_FRAME_BW_ISO 2400
  39. /*
  40. * Periodic transfers may only use 90% of the full frame, but as
  41. * we currently don't even use 90% of the full frame, we may
  42. * use the full usable time for periodic transfers.
  43. */
  44. #define MAX_PERIODIC_BW(full_bw) full_bw
  45. /* -------------------------------------------------------------------------- */
  46. struct c67x00_hcd {
  47. spinlock_t lock;
  48. struct c67x00_sie *sie;
  49. unsigned int low_speed_ports; /* bitmask of low speed ports */
  50. unsigned int urb_count;
  51. unsigned int urb_iso_count;
  52. struct list_head list[4]; /* iso, int, ctrl, bulk */
  53. #if PIPE_BULK != 3
  54. #error "Sanity check failed, this code presumes PIPE_... to range from 0 to 3"
  55. #endif
  56. /* USB bandwidth allocated to td_list */
  57. int bandwidth_allocated;
  58. /* USB bandwidth allocated for isoc/int transfer */
  59. int periodic_bw_allocated;
  60. struct list_head td_list;
  61. int max_frame_bw;
  62. u16 td_base_addr;
  63. u16 buf_base_addr;
  64. u16 next_td_addr;
  65. u16 next_buf_addr;
  66. struct tasklet_struct tasklet;
  67. struct completion endpoint_disable;
  68. u16 current_frame;
  69. u16 last_frame;
  70. };
  71. static inline struct c67x00_hcd *hcd_to_c67x00_hcd(struct usb_hcd *hcd)
  72. {
  73. return (struct c67x00_hcd *)(hcd->hcd_priv);
  74. }
  75. static inline struct usb_hcd *c67x00_hcd_to_hcd(struct c67x00_hcd *c67x00)
  76. {
  77. return container_of((void *)c67x00, struct usb_hcd, hcd_priv);
  78. }
  79. /* ---------------------------------------------------------------------
  80. * Functions used by c67x00-drv
  81. */
  82. int c67x00_hcd_probe(struct c67x00_sie *sie);
  83. void c67x00_hcd_remove(struct c67x00_sie *sie);
  84. /* ---------------------------------------------------------------------
  85. * Transfer Descriptor scheduling functions
  86. */
  87. int c67x00_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flags);
  88. int c67x00_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status);
  89. void c67x00_endpoint_disable(struct usb_hcd *hcd,
  90. struct usb_host_endpoint *ep);
  91. void c67x00_hcd_msg_received(struct c67x00_sie *sie, u16 msg);
  92. void c67x00_sched_kick(struct c67x00_hcd *c67x00);
  93. int c67x00_sched_start_scheduler(struct c67x00_hcd *c67x00);
  94. void c67x00_sched_stop_scheduler(struct c67x00_hcd *c67x00);
  95. #define c67x00_hcd_dev(x) (c67x00_hcd_to_hcd(x)->self.controller)
  96. #endif /* _USB_C67X00_HCD_H */