isp1760-hcd.h 2.1 KB
Newer Older
1
/* SPDX-License-Identifier: GPL-2.0 */
S
Sebastian Siewior 已提交
2 3 4
#ifndef _ISP1760_HCD_H_
#define _ISP1760_HCD_H_

5
#include <linux/spinlock.h>
6 7 8
#include <linux/regmap.h>

#include "isp1760-regs.h"
9

10 11 12 13
struct isp1760_qh;
struct isp1760_qtd;
struct resource;
struct usb_hcd;
S
Sebastian Siewior 已提交
14

15 16 17 18 19 20
/*
 * 60kb divided in:
 * - 32 blocks @ 256  bytes
 * - 20 blocks @ 1024 bytes
 * -  4 blocks @ 8192 bytes
 */
S
Sebastian Siewior 已提交
21

22 23 24
#define BLOCK_1_NUM 32
#define BLOCK_2_NUM 20
#define BLOCK_3_NUM 4
S
Sebastian Siewior 已提交
25

26 27 28 29 30 31
#define BLOCK_1_SIZE 256
#define BLOCK_2_SIZE 1024
#define BLOCK_3_SIZE 8192
#define BLOCKS (BLOCK_1_NUM + BLOCK_2_NUM + BLOCK_3_NUM)
#define MAX_PAYLOAD_SIZE BLOCK_3_SIZE
#define PAYLOAD_AREA_SIZE 0xf000
S
Sebastian Siewior 已提交
32

33 34 35 36 37 38
struct isp1760_slotinfo {
	struct isp1760_qh *qh;
	struct isp1760_qtd *qtd;
	unsigned long timestamp;
};

S
Sebastian Siewior 已提交
39
/* chip memory management */
40
struct isp1760_memory_chunk {
S
Sebastian Siewior 已提交
41 42 43 44 45
	unsigned int start;
	unsigned int size;
	unsigned int free;
};

46 47 48 49 50 51
enum isp1760_queue_head_types {
	QH_CONTROL,
	QH_BULK,
	QH_INTERRUPT,
	QH_END
};
S
Sebastian Siewior 已提交
52

53 54 55
struct isp1760_hcd {
	struct usb_hcd		*hcd;

56 57 58 59 60
	void __iomem		*base;

	struct regmap		*regs;
	struct regmap_field	*fields[HC_FIELD_MAX];

61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
	spinlock_t		lock;
	struct isp1760_slotinfo	atl_slots[32];
	int			atl_done_map;
	struct isp1760_slotinfo	int_slots[32];
	int			int_done_map;
	struct isp1760_memory_chunk memory_pool[BLOCKS];
	struct list_head	qh_list[QH_END];

	/* periodic schedule support */
#define	DEFAULT_I_TDPS		1024
	unsigned		periodic_size;
	unsigned		i_thresh;
	unsigned long		reset_done;
	unsigned long		next_statechange;
};
S
Sebastian Siewior 已提交
76

77
#ifdef CONFIG_USB_ISP1760_HCD
78 79
int isp1760_hcd_register(struct isp1760_hcd *priv, struct resource *mem,
			 int irq, unsigned long irqflags, struct device *dev);
80
void isp1760_hcd_unregister(struct isp1760_hcd *priv);
S
Sebastian Siewior 已提交
81

82 83
int isp1760_init_kmem_once(void);
void isp1760_deinit_kmem_cache(void);
84 85
#else
static inline int isp1760_hcd_register(struct isp1760_hcd *priv,
86
				       struct resource *mem,
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
				       int irq, unsigned long irqflags,
				       struct device *dev)
{
	return 0;
}

static inline void isp1760_hcd_unregister(struct isp1760_hcd *priv)
{
}

static inline int isp1760_init_kmem_once(void)
{
	return 0;
}

static inline void isp1760_deinit_kmem_cache(void)
{
}
#endif
S
Sebastian Siewior 已提交
106

107
#endif /* _ISP1760_HCD_H_ */