18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci#ifndef _ISP1760_HCD_H_
38c2ecf20Sopenharmony_ci#define _ISP1760_HCD_H_
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci#include <linux/spinlock.h>
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_cistruct isp1760_qh;
88c2ecf20Sopenharmony_cistruct isp1760_qtd;
98c2ecf20Sopenharmony_cistruct resource;
108c2ecf20Sopenharmony_cistruct usb_hcd;
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci/*
138c2ecf20Sopenharmony_ci * 60kb divided in:
148c2ecf20Sopenharmony_ci * - 32 blocks @ 256  bytes
158c2ecf20Sopenharmony_ci * - 20 blocks @ 1024 bytes
168c2ecf20Sopenharmony_ci * -  4 blocks @ 8192 bytes
178c2ecf20Sopenharmony_ci */
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ci#define BLOCK_1_NUM 32
208c2ecf20Sopenharmony_ci#define BLOCK_2_NUM 20
218c2ecf20Sopenharmony_ci#define BLOCK_3_NUM 4
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci#define BLOCK_1_SIZE 256
248c2ecf20Sopenharmony_ci#define BLOCK_2_SIZE 1024
258c2ecf20Sopenharmony_ci#define BLOCK_3_SIZE 8192
268c2ecf20Sopenharmony_ci#define BLOCKS (BLOCK_1_NUM + BLOCK_2_NUM + BLOCK_3_NUM)
278c2ecf20Sopenharmony_ci#define MAX_PAYLOAD_SIZE BLOCK_3_SIZE
288c2ecf20Sopenharmony_ci#define PAYLOAD_AREA_SIZE 0xf000
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_cistruct isp1760_slotinfo {
318c2ecf20Sopenharmony_ci	struct isp1760_qh *qh;
328c2ecf20Sopenharmony_ci	struct isp1760_qtd *qtd;
338c2ecf20Sopenharmony_ci	unsigned long timestamp;
348c2ecf20Sopenharmony_ci};
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ci/* chip memory management */
378c2ecf20Sopenharmony_cistruct isp1760_memory_chunk {
388c2ecf20Sopenharmony_ci	unsigned int start;
398c2ecf20Sopenharmony_ci	unsigned int size;
408c2ecf20Sopenharmony_ci	unsigned int free;
418c2ecf20Sopenharmony_ci};
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_cienum isp1760_queue_head_types {
448c2ecf20Sopenharmony_ci	QH_CONTROL,
458c2ecf20Sopenharmony_ci	QH_BULK,
468c2ecf20Sopenharmony_ci	QH_INTERRUPT,
478c2ecf20Sopenharmony_ci	QH_END
488c2ecf20Sopenharmony_ci};
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_cistruct isp1760_hcd {
518c2ecf20Sopenharmony_ci#ifdef CONFIG_USB_ISP1760_HCD
528c2ecf20Sopenharmony_ci	struct usb_hcd		*hcd;
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_ci	u32 hcs_params;
558c2ecf20Sopenharmony_ci	spinlock_t		lock;
568c2ecf20Sopenharmony_ci	struct isp1760_slotinfo	atl_slots[32];
578c2ecf20Sopenharmony_ci	int			atl_done_map;
588c2ecf20Sopenharmony_ci	struct isp1760_slotinfo	int_slots[32];
598c2ecf20Sopenharmony_ci	int			int_done_map;
608c2ecf20Sopenharmony_ci	struct isp1760_memory_chunk memory_pool[BLOCKS];
618c2ecf20Sopenharmony_ci	struct list_head	qh_list[QH_END];
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_ci	/* periodic schedule support */
648c2ecf20Sopenharmony_ci#define	DEFAULT_I_TDPS		1024
658c2ecf20Sopenharmony_ci	unsigned		periodic_size;
668c2ecf20Sopenharmony_ci	unsigned		i_thresh;
678c2ecf20Sopenharmony_ci	unsigned long		reset_done;
688c2ecf20Sopenharmony_ci	unsigned long		next_statechange;
698c2ecf20Sopenharmony_ci#endif
708c2ecf20Sopenharmony_ci};
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_ci#ifdef CONFIG_USB_ISP1760_HCD
738c2ecf20Sopenharmony_ciint isp1760_hcd_register(struct isp1760_hcd *priv, void __iomem *regs,
748c2ecf20Sopenharmony_ci			 struct resource *mem, int irq, unsigned long irqflags,
758c2ecf20Sopenharmony_ci			 struct device *dev);
768c2ecf20Sopenharmony_civoid isp1760_hcd_unregister(struct isp1760_hcd *priv);
778c2ecf20Sopenharmony_ci
788c2ecf20Sopenharmony_ciint isp1760_init_kmem_once(void);
798c2ecf20Sopenharmony_civoid isp1760_deinit_kmem_cache(void);
808c2ecf20Sopenharmony_ci#else
818c2ecf20Sopenharmony_cistatic inline int isp1760_hcd_register(struct isp1760_hcd *priv,
828c2ecf20Sopenharmony_ci				       void __iomem *regs, struct resource *mem,
838c2ecf20Sopenharmony_ci				       int irq, unsigned long irqflags,
848c2ecf20Sopenharmony_ci				       struct device *dev)
858c2ecf20Sopenharmony_ci{
868c2ecf20Sopenharmony_ci	return 0;
878c2ecf20Sopenharmony_ci}
888c2ecf20Sopenharmony_ci
898c2ecf20Sopenharmony_cistatic inline void isp1760_hcd_unregister(struct isp1760_hcd *priv)
908c2ecf20Sopenharmony_ci{
918c2ecf20Sopenharmony_ci}
928c2ecf20Sopenharmony_ci
938c2ecf20Sopenharmony_cistatic inline int isp1760_init_kmem_once(void)
948c2ecf20Sopenharmony_ci{
958c2ecf20Sopenharmony_ci	return 0;
968c2ecf20Sopenharmony_ci}
978c2ecf20Sopenharmony_ci
988c2ecf20Sopenharmony_cistatic inline void isp1760_deinit_kmem_cache(void)
998c2ecf20Sopenharmony_ci{
1008c2ecf20Sopenharmony_ci}
1018c2ecf20Sopenharmony_ci#endif
1028c2ecf20Sopenharmony_ci
1038c2ecf20Sopenharmony_ci#endif /* _ISP1760_HCD_H_ */
104