Sebastian Siewior | db11e47 | 2008-04-24 00:37:04 +0200 | [diff] [blame] | 1 | #ifndef _ISP1760_HCD_H_ |
| 2 | #define _ISP1760_HCD_H_ |
| 3 | |
Laurent Pinchart | e19c99e | 2015-01-21 00:55:56 +0200 | [diff] [blame] | 4 | #include <linux/spinlock.h> |
Laurent Pinchart | 10c73f0 | 2015-01-21 00:55:45 +0200 | [diff] [blame] | 5 | |
Laurent Pinchart | e19c99e | 2015-01-21 00:55:56 +0200 | [diff] [blame] | 6 | struct isp1760_qh; |
| 7 | struct isp1760_qtd; |
| 8 | struct resource; |
| 9 | struct usb_hcd; |
Sebastian Siewior | db11e47 | 2008-04-24 00:37:04 +0200 | [diff] [blame] | 10 | |
| 11 | /* |
| 12 | * 60kb divided in: |
| 13 | * - 32 blocks @ 256 bytes |
| 14 | * - 20 blocks @ 1024 bytes |
| 15 | * - 4 blocks @ 8192 bytes |
| 16 | */ |
| 17 | |
| 18 | #define BLOCK_1_NUM 32 |
| 19 | #define BLOCK_2_NUM 20 |
| 20 | #define BLOCK_3_NUM 4 |
| 21 | |
| 22 | #define BLOCK_1_SIZE 256 |
| 23 | #define BLOCK_2_SIZE 1024 |
| 24 | #define BLOCK_3_SIZE 8192 |
| 25 | #define BLOCKS (BLOCK_1_NUM + BLOCK_2_NUM + BLOCK_3_NUM) |
Arvid Brodin | a041d8e | 2011-02-26 22:04:40 +0100 | [diff] [blame] | 26 | #define MAX_PAYLOAD_SIZE BLOCK_3_SIZE |
| 27 | #define PAYLOAD_AREA_SIZE 0xf000 |
Sebastian Siewior | db11e47 | 2008-04-24 00:37:04 +0200 | [diff] [blame] | 28 | |
Laurent Pinchart | e19c99e | 2015-01-21 00:55:56 +0200 | [diff] [blame] | 29 | struct isp1760_slotinfo { |
| 30 | struct isp1760_qh *qh; |
| 31 | struct isp1760_qtd *qtd; |
| 32 | unsigned long timestamp; |
| 33 | }; |
Sebastian Siewior | db11e47 | 2008-04-24 00:37:04 +0200 | [diff] [blame] | 34 | |
Laurent Pinchart | e19c99e | 2015-01-21 00:55:56 +0200 | [diff] [blame] | 35 | /* chip memory management */ |
| 36 | struct isp1760_memory_chunk { |
| 37 | unsigned int start; |
| 38 | unsigned int size; |
| 39 | unsigned int free; |
| 40 | }; |
Sebastian Siewior | db11e47 | 2008-04-24 00:37:04 +0200 | [diff] [blame] | 41 | |
Laurent Pinchart | e19c99e | 2015-01-21 00:55:56 +0200 | [diff] [blame] | 42 | enum isp1760_queue_head_types { |
| 43 | QH_CONTROL, |
| 44 | QH_BULK, |
| 45 | QH_INTERRUPT, |
| 46 | QH_END |
| 47 | }; |
| 48 | |
| 49 | struct isp1760_hcd { |
Laurent Pinchart | 100832a | 2015-01-21 00:56:03 +0200 | [diff] [blame] | 50 | #ifdef CONFIG_USB_ISP1760_HCD |
Laurent Pinchart | e19c99e | 2015-01-21 00:55:56 +0200 | [diff] [blame] | 51 | struct usb_hcd *hcd; |
| 52 | |
| 53 | u32 hcs_params; |
| 54 | spinlock_t lock; |
| 55 | struct isp1760_slotinfo atl_slots[32]; |
| 56 | int atl_done_map; |
| 57 | struct isp1760_slotinfo int_slots[32]; |
| 58 | int int_done_map; |
| 59 | struct isp1760_memory_chunk memory_pool[BLOCKS]; |
| 60 | struct list_head qh_list[QH_END]; |
| 61 | |
| 62 | /* periodic schedule support */ |
| 63 | #define DEFAULT_I_TDPS 1024 |
| 64 | unsigned periodic_size; |
| 65 | unsigned i_thresh; |
| 66 | unsigned long reset_done; |
| 67 | unsigned long next_statechange; |
Laurent Pinchart | 100832a | 2015-01-21 00:56:03 +0200 | [diff] [blame] | 68 | #endif |
Laurent Pinchart | e19c99e | 2015-01-21 00:55:56 +0200 | [diff] [blame] | 69 | }; |
| 70 | |
Laurent Pinchart | 100832a | 2015-01-21 00:56:03 +0200 | [diff] [blame] | 71 | #ifdef CONFIG_USB_ISP1760_HCD |
Laurent Pinchart | 4b1a577 | 2015-01-21 00:55:57 +0200 | [diff] [blame] | 72 | int isp1760_hcd_register(struct isp1760_hcd *priv, void __iomem *regs, |
| 73 | struct resource *mem, int irq, unsigned long irqflags, |
Laurent Pinchart | 5171446 | 2015-01-21 00:55:59 +0200 | [diff] [blame] | 74 | struct device *dev); |
Laurent Pinchart | 4b1a577 | 2015-01-21 00:55:57 +0200 | [diff] [blame] | 75 | void isp1760_hcd_unregister(struct isp1760_hcd *priv); |
Laurent Pinchart | e19c99e | 2015-01-21 00:55:56 +0200 | [diff] [blame] | 76 | |
| 77 | int isp1760_init_kmem_once(void); |
| 78 | void isp1760_deinit_kmem_cache(void); |
Laurent Pinchart | 100832a | 2015-01-21 00:56:03 +0200 | [diff] [blame] | 79 | #else |
| 80 | static inline int isp1760_hcd_register(struct isp1760_hcd *priv, |
| 81 | void __iomem *regs, struct resource *mem, |
| 82 | int irq, unsigned long irqflags, |
| 83 | struct device *dev) |
| 84 | { |
| 85 | return 0; |
| 86 | } |
| 87 | |
| 88 | static inline void isp1760_hcd_unregister(struct isp1760_hcd *priv) |
| 89 | { |
| 90 | } |
| 91 | |
| 92 | static inline int isp1760_init_kmem_once(void) |
| 93 | { |
| 94 | return 0; |
| 95 | } |
| 96 | |
| 97 | static inline void isp1760_deinit_kmem_cache(void) |
| 98 | { |
| 99 | } |
| 100 | #endif |
Sebastian Siewior | db11e47 | 2008-04-24 00:37:04 +0200 | [diff] [blame] | 101 | |
Arvid Brodin | 71a9f9d | 2011-04-26 21:48:30 +0200 | [diff] [blame] | 102 | #endif /* _ISP1760_HCD_H_ */ |