blob: c47b73906ef95aeba9c714b5862b13ee96e2e975 [file] [log] [blame]
Rui Miguel Silva88861a22022-06-29 11:06:15 +01001/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef _ISP1760_HCD_H_
3#define _ISP1760_HCD_H_
4
5#include <regmap.h>
6
7#include "isp1760-regs.h"
8
9struct isp1760_qh;
10struct isp1760_qtd;
11struct resource;
12struct usb_hcd;
13
14struct isp1760_slotinfo {
15 struct isp1760_qh *qh;
16 struct isp1760_qtd *qtd;
17 unsigned long timestamp;
18};
19
20/* chip memory management */
21#define ISP176x_BLOCK_MAX (32 + 20 + 4)
22#define ISP176x_BLOCK_NUM 3
23
24struct isp1760_memory_layout {
25 unsigned int blocks[ISP176x_BLOCK_NUM];
26 unsigned int blocks_size[ISP176x_BLOCK_NUM];
27
28 unsigned int slot_num;
29 unsigned int payload_blocks;
30 unsigned int payload_area_size;
31};
32
33struct isp1760_memory_chunk {
34 unsigned int start;
35 unsigned int size;
36 unsigned int free;
37};
38
39enum isp1760_queue_head_types {
40 QH_CONTROL,
41 QH_BULK,
42 QH_INTERRUPT,
43 QH_END
44};
45
46struct isp1760_hcd {
47 struct usb_hcd *hcd;
48 struct udevice *dev;
49
50 void __iomem *base;
51
52 struct regmap *regs;
53 struct regmap_field *fields[HC_FIELD_MAX];
54
55 bool is_isp1763;
56 const struct isp1760_memory_layout *memory_layout;
57
58 struct isp1760_slotinfo *atl_slots;
59 int atl_done_map;
60 struct isp1760_slotinfo *int_slots;
61 int int_done_map;
62 struct isp1760_memory_chunk memory_pool[ISP176x_BLOCK_MAX];
63 struct list_head qh_list[QH_END];
64
65 /* periodic schedule support */
66#define DEFAULT_I_TDPS 1024
67 unsigned int periodic_size;
68 unsigned int i_thresh;
69 unsigned long reset_done;
70 unsigned long next_statechange;
71};
72
73int isp1760_hcd_register(struct isp1760_hcd *priv, struct resource *mem,
74 int irq, unsigned long irqflags, struct udevice *dev);
75void isp1760_hcd_unregister(struct isp1760_hcd *priv);
76int isp1760_hcd_lowlevel_init(struct isp1760_hcd *priv);
77
78int isp1760_init_kmem_once(void);
79void isp1760_deinit_kmem_cache(void);
80
81#endif /* _ISP1760_HCD_H_ */