c67x00-hcd.h 4.2 KB

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