fhci.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613
  1. /*
  2. * Freescale QUICC Engine USB Host Controller Driver
  3. *
  4. * Copyright (c) Freescale Semicondutor, Inc. 2006.
  5. * Shlomi Gridish <gridish@freescale.com>
  6. * Jerry Huang <Chang-Ming.Huang@freescale.com>
  7. * Copyright (c) Logic Product Development, Inc. 2007
  8. * Peter Barada <peterb@logicpd.com>
  9. * Copyright (c) MontaVista Software, Inc. 2008.
  10. * Anton Vorontsov <avorontsov@ru.mvista.com>
  11. *
  12. * This program is free software; you can redistribute it and/or modify it
  13. * under the terms of the GNU General Public License as published by the
  14. * Free Software Foundation; either version 2 of the License, or (at your
  15. * option) any later version.
  16. */
  17. #ifndef __FHCI_H
  18. #define __FHCI_H
  19. #include <linux/kernel.h>
  20. #include <linux/types.h>
  21. #include <linux/bug.h>
  22. #include <linux/spinlock.h>
  23. #include <linux/interrupt.h>
  24. #include <linux/kfifo.h>
  25. #include <linux/io.h>
  26. #include <linux/usb.h>
  27. #include <linux/usb/hcd.h>
  28. #include <asm/qe.h>
  29. #define USB_CLOCK 48000000
  30. #define FHCI_PRAM_SIZE 0x100
  31. #define MAX_EDS 32
  32. #define MAX_TDS 32
  33. /* CRC16 field size */
  34. #define CRC_SIZE 2
  35. /* USB protocol overhead for each frame transmitted from the host */
  36. #define PROTOCOL_OVERHEAD 7
  37. /* Packet structure, info field */
  38. #define PKT_PID_DATA0 0x80000000 /* PID - Data toggle zero */
  39. #define PKT_PID_DATA1 0x40000000 /* PID - Data toggle one */
  40. #define PKT_PID_SETUP 0x20000000 /* PID - Setup bit */
  41. #define PKT_SETUP_STATUS 0x10000000 /* Setup status bit */
  42. #define PKT_SETADDR_STATUS 0x08000000 /* Set address status bit */
  43. #define PKT_SET_HOST_LAST 0x04000000 /* Last data packet */
  44. #define PKT_HOST_DATA 0x02000000 /* Data packet */
  45. #define PKT_FIRST_IN_FRAME 0x01000000 /* First packet in the frame */
  46. #define PKT_TOKEN_FRAME 0x00800000 /* Token packet */
  47. #define PKT_ZLP 0x00400000 /* Zero length packet */
  48. #define PKT_IN_TOKEN_FRAME 0x00200000 /* IN token packet */
  49. #define PKT_OUT_TOKEN_FRAME 0x00100000 /* OUT token packet */
  50. #define PKT_SETUP_TOKEN_FRAME 0x00080000 /* SETUP token packet */
  51. #define PKT_STALL_FRAME 0x00040000 /* STALL packet */
  52. #define PKT_NACK_FRAME 0x00020000 /* NACK packet */
  53. #define PKT_NO_PID 0x00010000 /* No PID */
  54. #define PKT_NO_CRC 0x00008000 /* don't append CRC */
  55. #define PKT_HOST_COMMAND 0x00004000 /* Host command packet */
  56. #define PKT_DUMMY_PACKET 0x00002000 /* Dummy packet, used for mmm */
  57. #define PKT_LOW_SPEED_PACKET 0x00001000 /* Low-Speed packet */
  58. #define TRANS_OK (0)
  59. #define TRANS_INPROGRESS (-1)
  60. #define TRANS_DISCARD (-2)
  61. #define TRANS_FAIL (-3)
  62. #define PS_INT 0
  63. #define PS_DISCONNECTED 1
  64. #define PS_CONNECTED 2
  65. #define PS_READY 3
  66. #define PS_MISSING 4
  67. /* Transfer Descriptor status field */
  68. #define USB_TD_OK 0x00000000 /* TD transmited or received ok */
  69. #define USB_TD_INPROGRESS 0x80000000 /* TD is being transmitted */
  70. #define USB_TD_RX_ER_NONOCT 0x40000000 /* Tx Non Octet Aligned Packet */
  71. #define USB_TD_RX_ER_BITSTUFF 0x20000000 /* Frame Aborted-Received pkt */
  72. #define USB_TD_RX_ER_CRC 0x10000000 /* CRC error */
  73. #define USB_TD_RX_ER_OVERUN 0x08000000 /* Over - run occurred */
  74. #define USB_TD_RX_ER_PID 0x04000000 /* wrong PID received */
  75. #define USB_TD_RX_DATA_UNDERUN 0x02000000 /* shorter than expected */
  76. #define USB_TD_RX_DATA_OVERUN 0x01000000 /* longer than expected */
  77. #define USB_TD_TX_ER_NAK 0x00800000 /* NAK handshake */
  78. #define USB_TD_TX_ER_STALL 0x00400000 /* STALL handshake */
  79. #define USB_TD_TX_ER_TIMEOUT 0x00200000 /* transmit time out */
  80. #define USB_TD_TX_ER_UNDERUN 0x00100000 /* transmit underrun */
  81. #define USB_TD_ERROR (USB_TD_RX_ER_NONOCT | USB_TD_RX_ER_BITSTUFF | \
  82. USB_TD_RX_ER_CRC | USB_TD_RX_ER_OVERUN | USB_TD_RX_ER_PID | \
  83. USB_TD_RX_DATA_UNDERUN | USB_TD_RX_DATA_OVERUN | \
  84. USB_TD_TX_ER_NAK | USB_TD_TX_ER_STALL | \
  85. USB_TD_TX_ER_TIMEOUT | USB_TD_TX_ER_UNDERUN)
  86. /* Transfer Descriptor toggle field */
  87. #define USB_TD_TOGGLE_DATA0 0
  88. #define USB_TD_TOGGLE_DATA1 1
  89. #define USB_TD_TOGGLE_CARRY 2
  90. /* #define MULTI_DATA_BUS */
  91. /* Bus mode register RBMR/TBMR */
  92. #define BUS_MODE_GBL 0x20 /* Global snooping */
  93. #define BUS_MODE_BO 0x18 /* Byte ordering */
  94. #define BUS_MODE_BO_BE 0x10 /* Byte ordering - Big-endian */
  95. #define BUS_MODE_DTB 0x02 /* Data bus */
  96. /* FHCI QE USB Register Description */
  97. /* USB Mode Register bit define */
  98. #define USB_MODE_EN 0x01
  99. #define USB_MODE_HOST 0x02
  100. #define USB_MODE_TEST 0x04
  101. #define USB_MODE_SFTE 0x08
  102. #define USB_MODE_RESUME 0x40
  103. #define USB_MODE_LSS 0x80
  104. /* USB Slave Address Register Mask */
  105. #define USB_SLVADDR_MASK 0x7F
  106. /* USB Endpoint register define */
  107. #define USB_EPNUM_MASK 0xF000
  108. #define USB_EPNUM_SHIFT 12
  109. #define USB_TRANS_MODE_SHIFT 8
  110. #define USB_TRANS_CTR 0x0000
  111. #define USB_TRANS_INT 0x0100
  112. #define USB_TRANS_BULK 0x0200
  113. #define USB_TRANS_ISO 0x0300
  114. #define USB_EP_MF 0x0020
  115. #define USB_EP_RTE 0x0010
  116. #define USB_THS_SHIFT 2
  117. #define USB_THS_MASK 0x000c
  118. #define USB_THS_NORMAL 0x0
  119. #define USB_THS_IGNORE_IN 0x0004
  120. #define USB_THS_NACK 0x0008
  121. #define USB_THS_STALL 0x000c
  122. #define USB_RHS_SHIFT 0
  123. #define USB_RHS_MASK 0x0003
  124. #define USB_RHS_NORMAL 0x0
  125. #define USB_RHS_IGNORE_OUT 0x0001
  126. #define USB_RHS_NACK 0x0002
  127. #define USB_RHS_STALL 0x0003
  128. #define USB_RTHS_MASK 0x000f
  129. /* USB Command Register define */
  130. #define USB_CMD_STR_FIFO 0x80
  131. #define USB_CMD_FLUSH_FIFO 0x40
  132. #define USB_CMD_ISFT 0x20
  133. #define USB_CMD_DSFT 0x10
  134. #define USB_CMD_EP_MASK 0x03
  135. /* USB Event and Mask Register define */
  136. #define USB_E_MSF_MASK 0x0800
  137. #define USB_E_SFT_MASK 0x0400
  138. #define USB_E_RESET_MASK 0x0200
  139. #define USB_E_IDLE_MASK 0x0100
  140. #define USB_E_TXE4_MASK 0x0080
  141. #define USB_E_TXE3_MASK 0x0040
  142. #define USB_E_TXE2_MASK 0x0020
  143. #define USB_E_TXE1_MASK 0x0010
  144. #define USB_E_SOF_MASK 0x0008
  145. #define USB_E_BSY_MASK 0x0004
  146. #define USB_E_TXB_MASK 0x0002
  147. #define USB_E_RXB_MASK 0x0001
  148. /* Freescale USB Host controller registers */
  149. struct fhci_regs {
  150. u8 usb_mod; /* mode register */
  151. u8 usb_addr; /* address register */
  152. u8 usb_comm; /* command register */
  153. u8 reserved1[1];
  154. __be16 usb_ep[4]; /* endpoint register */
  155. u8 reserved2[4];
  156. __be16 usb_event; /* event register */
  157. u8 reserved3[2];
  158. __be16 usb_mask; /* mask register */
  159. u8 reserved4[1];
  160. u8 usb_status; /* status register */
  161. __be16 usb_sof_tmr; /* Start Of Frame timer */
  162. u8 reserved5[2];
  163. __be16 usb_frame_num; /* frame number register */
  164. u8 reserved6[1];
  165. };
  166. /* Freescale USB HOST */
  167. struct fhci_pram {
  168. __be16 ep_ptr[4]; /* Endpoint porter reg */
  169. __be32 rx_state; /* Rx internal state */
  170. __be32 rx_ptr; /* Rx internal data pointer */
  171. __be16 frame_num; /* Frame number */
  172. __be16 rx_cnt; /* Rx byte count */
  173. __be32 rx_temp; /* Rx temp */
  174. __be32 rx_data_temp; /* Rx data temp */
  175. __be16 rx_u_ptr; /* Rx microcode return address temp */
  176. u8 reserved1[2]; /* reserved area */
  177. __be32 sof_tbl; /* SOF lookup table pointer */
  178. u8 sof_u_crc_temp; /* SOF micorcode CRC5 temp reg */
  179. u8 reserved2[0xdb];
  180. };
  181. /* Freescale USB Endpoint*/
  182. struct fhci_ep_pram {
  183. __be16 rx_base; /* Rx BD base address */
  184. __be16 tx_base; /* Tx BD base address */
  185. u8 rx_func_code; /* Rx function code */
  186. u8 tx_func_code; /* Tx function code */
  187. __be16 rx_buff_len; /* Rx buffer length */
  188. __be16 rx_bd_ptr; /* Rx BD pointer */
  189. __be16 tx_bd_ptr; /* Tx BD pointer */
  190. __be32 tx_state; /* Tx internal state */
  191. __be32 tx_ptr; /* Tx internal data pointer */
  192. __be16 tx_crc; /* temp transmit CRC */
  193. __be16 tx_cnt; /* Tx byte count */
  194. __be32 tx_temp; /* Tx temp */
  195. __be16 tx_u_ptr; /* Tx microcode return address temp */
  196. __be16 reserved;
  197. };
  198. struct fhci_controller_list {
  199. struct list_head ctrl_list; /* control endpoints */
  200. struct list_head bulk_list; /* bulk endpoints */
  201. struct list_head iso_list; /* isochronous endpoints */
  202. struct list_head intr_list; /* interruput endpoints */
  203. struct list_head done_list; /* done transfers */
  204. };
  205. struct virtual_root_hub {
  206. int dev_num; /* USB address of the root hub */
  207. u32 feature; /* indicates what feature has been set */
  208. struct usb_hub_status hub;
  209. struct usb_port_status port;
  210. };
  211. enum fhci_gpios {
  212. GPIO_USBOE = 0,
  213. GPIO_USBTP,
  214. GPIO_USBTN,
  215. GPIO_USBRP,
  216. GPIO_USBRN,
  217. /* these are optional */
  218. GPIO_SPEED,
  219. GPIO_POWER,
  220. NUM_GPIOS,
  221. };
  222. enum fhci_pins {
  223. PIN_USBOE = 0,
  224. PIN_USBTP,
  225. PIN_USBTN,
  226. NUM_PINS,
  227. };
  228. struct fhci_hcd {
  229. enum qe_clock fullspeed_clk;
  230. enum qe_clock lowspeed_clk;
  231. struct qe_pin *pins[NUM_PINS];
  232. int gpios[NUM_GPIOS];
  233. bool alow_gpios[NUM_GPIOS];
  234. struct fhci_regs __iomem *regs; /* I/O memory used to communicate */
  235. struct fhci_pram __iomem *pram; /* Parameter RAM */
  236. struct gtm_timer *timer;
  237. spinlock_t lock;
  238. struct fhci_usb *usb_lld; /* Low-level driver */
  239. struct virtual_root_hub *vroot_hub; /* the virtual root hub */
  240. int active_urbs;
  241. struct fhci_controller_list *hc_list;
  242. struct tasklet_struct *process_done_task; /* tasklet for done list */
  243. struct list_head empty_eds;
  244. struct list_head empty_tds;
  245. #ifdef CONFIG_FHCI_DEBUG
  246. int usb_irq_stat[13];
  247. struct dentry *dfs_root;
  248. struct dentry *dfs_regs;
  249. struct dentry *dfs_irq_stat;
  250. #endif
  251. };
  252. #define USB_FRAME_USAGE 90
  253. #define FRAME_TIME_USAGE (USB_FRAME_USAGE*10) /* frame time usage */
  254. #define SW_FIX_TIME_BETWEEN_TRANSACTION 150 /* SW */
  255. #define MAX_BYTES_PER_FRAME (USB_FRAME_USAGE*15)
  256. #define MAX_PERIODIC_FRAME_USAGE 90
  257. /* transaction type */
  258. enum fhci_ta_type {
  259. FHCI_TA_IN = 0, /* input transaction */
  260. FHCI_TA_OUT, /* output transaction */
  261. FHCI_TA_SETUP, /* setup transaction */
  262. };
  263. /* transfer mode */
  264. enum fhci_tf_mode {
  265. FHCI_TF_CTRL = 0,
  266. FHCI_TF_ISO,
  267. FHCI_TF_BULK,
  268. FHCI_TF_INTR,
  269. };
  270. enum fhci_speed {
  271. FHCI_FULL_SPEED,
  272. FHCI_LOW_SPEED,
  273. };
  274. /* endpoint state */
  275. enum fhci_ed_state {
  276. FHCI_ED_NEW = 0, /* pipe is new */
  277. FHCI_ED_OPER, /* pipe is operating */
  278. FHCI_ED_URB_DEL, /* pipe is in hold because urb is being deleted */
  279. FHCI_ED_SKIP, /* skip this pipe */
  280. FHCI_ED_HALTED, /* pipe is halted */
  281. };
  282. enum fhci_port_status {
  283. FHCI_PORT_POWER_OFF = 0,
  284. FHCI_PORT_DISABLED,
  285. FHCI_PORT_DISCONNECTING,
  286. FHCI_PORT_WAITING, /* waiting for connection */
  287. FHCI_PORT_FULL, /* full speed connected */
  288. FHCI_PORT_LOW, /* low speed connected */
  289. };
  290. enum fhci_mem_alloc {
  291. MEM_CACHABLE_SYS = 0x00000001, /* primary DDR,cachable */
  292. MEM_NOCACHE_SYS = 0x00000004, /* primary DDR,non-cachable */
  293. MEM_SECONDARY = 0x00000002, /* either secondary DDR or SDRAM */
  294. MEM_PRAM = 0x00000008, /* multi-user RAM identifier */
  295. };
  296. /* USB default parameters*/
  297. #define DEFAULT_RING_LEN 8
  298. #define DEFAULT_DATA_MEM MEM_CACHABLE_SYS
  299. struct ed {
  300. u8 dev_addr; /* device address */
  301. u8 ep_addr; /* endpoint address */
  302. enum fhci_tf_mode mode; /* USB transfer mode */
  303. enum fhci_speed speed;
  304. unsigned int max_pkt_size;
  305. enum fhci_ed_state state;
  306. struct list_head td_list; /* a list of all queued TD to this pipe */
  307. struct list_head node;
  308. /* read only parameters, should be cleared upon initialization */
  309. u8 toggle_carry; /* toggle carry from the last TD submitted */
  310. u32 last_iso; /* time stamp of last queued ISO transfer */
  311. struct td *td_head; /* a pointer to the current TD handled */
  312. };
  313. struct td {
  314. void *data; /* a pointer to the data buffer */
  315. unsigned int len; /* length of the data to be submitted */
  316. unsigned int actual_len; /* actual bytes transferred on this td */
  317. enum fhci_ta_type type; /* transaction type */
  318. u8 toggle; /* toggle for next trans. within this TD */
  319. u16 iso_index; /* ISO transaction index */
  320. u16 start_frame; /* start frame time stamp */
  321. u16 interval; /* interval between trans. (for ISO/Intr) */
  322. u32 status; /* status of the TD */
  323. struct ed *ed; /* a handle to the corresponding ED */
  324. struct urb *urb; /* a handle to the corresponding URB */
  325. bool ioc; /* Inform On Completion */
  326. struct list_head node;
  327. /* read only parameters should be cleared upon initialization */
  328. struct packet *pkt;
  329. int nak_cnt;
  330. int error_cnt;
  331. struct list_head frame_lh;
  332. };
  333. struct packet {
  334. u8 *data; /* packet data */
  335. u32 len; /* packet length */
  336. u32 status; /* status of the packet - equivalent to the status
  337. * field for the corresponding structure td */
  338. u32 info; /* packet information */
  339. void __iomem *priv_data; /* private data of the driver (TDs or BDs) */
  340. };
  341. /* struct for each URB */
  342. #define URB_INPROGRESS 0
  343. #define URB_DEL 1
  344. /* URB states (state field) */
  345. #define US_BULK 0
  346. #define US_BULK0 1
  347. /* three setup states */
  348. #define US_CTRL_SETUP 2
  349. #define US_CTRL_DATA 1
  350. #define US_CTRL_ACK 0
  351. #define EP_ZERO 0
  352. struct urb_priv {
  353. int num_of_tds;
  354. int tds_cnt;
  355. int state;
  356. struct td **tds;
  357. struct ed *ed;
  358. struct timer_list time_out;
  359. };
  360. struct endpoint {
  361. /* Pointer to ep parameter RAM */
  362. struct fhci_ep_pram __iomem *ep_pram_ptr;
  363. /* Host transactions */
  364. struct usb_td __iomem *td_base; /* first TD in the ring */
  365. struct usb_td __iomem *conf_td; /* next TD for confirm after transac */
  366. struct usb_td __iomem *empty_td;/* next TD for new transaction req. */
  367. struct kfifo empty_frame_Q; /* Empty frames list to use */
  368. struct kfifo conf_frame_Q; /* frames passed to TDs,waiting for tx */
  369. struct kfifo dummy_packets_Q;/* dummy packets for the CRC overun */
  370. bool already_pushed_dummy_bd;
  371. };
  372. /* struct for each 1mSec frame time */
  373. #define FRAME_IS_TRANSMITTED 0x00
  374. #define FRAME_TIMER_END_TRANSMISSION 0x01
  375. #define FRAME_DATA_END_TRANSMISSION 0x02
  376. #define FRAME_END_TRANSMISSION 0x03
  377. #define FRAME_IS_PREPARED 0x04
  378. struct fhci_time_frame {
  379. u16 frame_num; /* frame number */
  380. u16 total_bytes; /* total bytes submitted within this frame */
  381. u8 frame_status; /* flag that indicates to stop fill this frame */
  382. struct list_head tds_list; /* all tds of this frame */
  383. };
  384. /* internal driver structure*/
  385. struct fhci_usb {
  386. u16 saved_msk; /* saving of the USB mask register */
  387. struct endpoint *ep0; /* pointer for endpoint0 structure */
  388. int intr_nesting_cnt; /* interrupt nesting counter */
  389. u16 max_frame_usage; /* max frame time usage,in micro-sec */
  390. u16 max_bytes_per_frame; /* max byte can be tx in one time frame */
  391. u32 sw_transaction_time; /* sw complete trans time,in micro-sec */
  392. struct fhci_time_frame *actual_frame;
  393. struct fhci_controller_list *hc_list; /* main structure for hc */
  394. struct virtual_root_hub *vroot_hub;
  395. enum fhci_port_status port_status; /* v_rh port status */
  396. u32 (*transfer_confirm)(struct fhci_hcd *fhci);
  397. struct fhci_hcd *fhci;
  398. };
  399. /*
  400. * Various helpers and prototypes below.
  401. */
  402. static inline u16 get_frame_num(struct fhci_hcd *fhci)
  403. {
  404. return in_be16(&fhci->pram->frame_num) & 0x07ff;
  405. }
  406. #define fhci_dbg(fhci, fmt, args...) \
  407. dev_dbg(fhci_to_hcd(fhci)->self.controller, fmt, ##args)
  408. #define fhci_vdbg(fhci, fmt, args...) \
  409. dev_vdbg(fhci_to_hcd(fhci)->self.controller, fmt, ##args)
  410. #define fhci_err(fhci, fmt, args...) \
  411. dev_err(fhci_to_hcd(fhci)->self.controller, fmt, ##args)
  412. #define fhci_info(fhci, fmt, args...) \
  413. dev_info(fhci_to_hcd(fhci)->self.controller, fmt, ##args)
  414. #define fhci_warn(fhci, fmt, args...) \
  415. dev_warn(fhci_to_hcd(fhci)->self.controller, fmt, ##args)
  416. static inline struct fhci_hcd *hcd_to_fhci(struct usb_hcd *hcd)
  417. {
  418. return (struct fhci_hcd *)hcd->hcd_priv;
  419. }
  420. static inline struct usb_hcd *fhci_to_hcd(struct fhci_hcd *fhci)
  421. {
  422. return container_of((void *)fhci, struct usb_hcd, hcd_priv);
  423. }
  424. /* fifo of pointers */
  425. static inline int cq_new(struct kfifo *fifo, int size)
  426. {
  427. return kfifo_alloc(fifo, size * sizeof(void *), GFP_KERNEL);
  428. }
  429. static inline void cq_delete(struct kfifo *kfifo)
  430. {
  431. kfifo_free(kfifo);
  432. }
  433. static inline unsigned int cq_howmany(struct kfifo *kfifo)
  434. {
  435. return kfifo_len(kfifo) / sizeof(void *);
  436. }
  437. static inline int cq_put(struct kfifo *kfifo, void *p)
  438. {
  439. return kfifo_in(kfifo, (void *)&p, sizeof(p));
  440. }
  441. static inline void *cq_get(struct kfifo *kfifo)
  442. {
  443. unsigned int sz;
  444. void *p;
  445. sz = kfifo_out(kfifo, (void *)&p, sizeof(p));
  446. if (sz != sizeof(p))
  447. return NULL;
  448. return p;
  449. }
  450. /* fhci-hcd.c */
  451. void fhci_start_sof_timer(struct fhci_hcd *fhci);
  452. void fhci_stop_sof_timer(struct fhci_hcd *fhci);
  453. u16 fhci_get_sof_timer_count(struct fhci_usb *usb);
  454. void fhci_usb_enable_interrupt(struct fhci_usb *usb);
  455. void fhci_usb_disable_interrupt(struct fhci_usb *usb);
  456. int fhci_ioports_check_bus_state(struct fhci_hcd *fhci);
  457. /* fhci-mem.c */
  458. void fhci_recycle_empty_td(struct fhci_hcd *fhci, struct td *td);
  459. void fhci_recycle_empty_ed(struct fhci_hcd *fhci, struct ed *ed);
  460. struct ed *fhci_get_empty_ed(struct fhci_hcd *fhci);
  461. struct td *fhci_td_fill(struct fhci_hcd *fhci, struct urb *urb,
  462. struct urb_priv *urb_priv, struct ed *ed, u16 index,
  463. enum fhci_ta_type type, int toggle, u8 *data, u32 len,
  464. u16 interval, u16 start_frame, bool ioc);
  465. void fhci_add_tds_to_ed(struct ed *ed, struct td **td_list, int number);
  466. /* fhci-hub.c */
  467. void fhci_config_transceiver(struct fhci_hcd *fhci,
  468. enum fhci_port_status status);
  469. void fhci_port_disable(struct fhci_hcd *fhci);
  470. void fhci_port_enable(void *lld);
  471. void fhci_io_port_generate_reset(struct fhci_hcd *fhci);
  472. void fhci_port_reset(void *lld);
  473. int fhci_hub_status_data(struct usb_hcd *hcd, char *buf);
  474. int fhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
  475. u16 wIndex, char *buf, u16 wLength);
  476. /* fhci-tds.c */
  477. void fhci_flush_bds(struct fhci_usb *usb);
  478. void fhci_flush_actual_frame(struct fhci_usb *usb);
  479. u32 fhci_host_transaction(struct fhci_usb *usb, struct packet *pkt,
  480. enum fhci_ta_type trans_type, u8 dest_addr,
  481. u8 dest_ep, enum fhci_tf_mode trans_mode,
  482. enum fhci_speed dest_speed, u8 data_toggle);
  483. void fhci_host_transmit_actual_frame(struct fhci_usb *usb);
  484. void fhci_tx_conf_interrupt(struct fhci_usb *usb);
  485. void fhci_push_dummy_bd(struct endpoint *ep);
  486. u32 fhci_create_ep(struct fhci_usb *usb, enum fhci_mem_alloc data_mem,
  487. u32 ring_len);
  488. void fhci_init_ep_registers(struct fhci_usb *usb,
  489. struct endpoint *ep,
  490. enum fhci_mem_alloc data_mem);
  491. void fhci_ep0_free(struct fhci_usb *usb);
  492. /* fhci-sched.c */
  493. extern struct tasklet_struct fhci_tasklet;
  494. void fhci_transaction_confirm(struct fhci_usb *usb, struct packet *pkt);
  495. void fhci_flush_all_transmissions(struct fhci_usb *usb);
  496. void fhci_schedule_transactions(struct fhci_usb *usb);
  497. void fhci_device_connected_interrupt(struct fhci_hcd *fhci);
  498. void fhci_device_disconnected_interrupt(struct fhci_hcd *fhci);
  499. void fhci_queue_urb(struct fhci_hcd *fhci, struct urb *urb);
  500. u32 fhci_transfer_confirm_callback(struct fhci_hcd *fhci);
  501. irqreturn_t fhci_irq(struct usb_hcd *hcd);
  502. irqreturn_t fhci_frame_limit_timer_irq(int irq, void *_hcd);
  503. /* fhci-q.h */
  504. void fhci_urb_complete_free(struct fhci_hcd *fhci, struct urb *urb);
  505. struct td *fhci_remove_td_from_ed(struct ed *ed);
  506. struct td *fhci_remove_td_from_frame(struct fhci_time_frame *frame);
  507. void fhci_move_td_from_ed_to_done_list(struct fhci_usb *usb, struct ed *ed);
  508. struct td *fhci_peek_td_from_frame(struct fhci_time_frame *frame);
  509. void fhci_add_td_to_frame(struct fhci_time_frame *frame, struct td *td);
  510. struct td *fhci_remove_td_from_done_list(struct fhci_controller_list *p_list);
  511. void fhci_done_td(struct urb *urb, struct td *td);
  512. void fhci_del_ed_list(struct fhci_hcd *fhci, struct ed *ed);
  513. #ifdef CONFIG_FHCI_DEBUG
  514. void fhci_dbg_isr(struct fhci_hcd *fhci, int usb_er);
  515. void fhci_dfs_destroy(struct fhci_hcd *fhci);
  516. void fhci_dfs_create(struct fhci_hcd *fhci);
  517. #else
  518. static inline void fhci_dbg_isr(struct fhci_hcd *fhci, int usb_er) {}
  519. static inline void fhci_dfs_destroy(struct fhci_hcd *fhci) {}
  520. static inline void fhci_dfs_create(struct fhci_hcd *fhci) {}
  521. #endif /* CONFIG_FHCI_DEBUG */
  522. #endif /* __FHCI_H */