18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci	Mantis PCI bridge driver
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci	Copyright (C) Manu Abraham (abraham.manu@gmail.com)
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci*/
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#ifndef __MANTIS_LINK_H
108c2ecf20Sopenharmony_ci#define __MANTIS_LINK_H
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#include <linux/mutex.h>
138c2ecf20Sopenharmony_ci#include <linux/workqueue.h>
148c2ecf20Sopenharmony_ci#include <media/dvb_ca_en50221.h>
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_cienum mantis_sbuf_status {
178c2ecf20Sopenharmony_ci	MANTIS_SBUF_DATA_AVAIL		= 1,
188c2ecf20Sopenharmony_ci	MANTIS_SBUF_DATA_EMPTY		= 2,
198c2ecf20Sopenharmony_ci	MANTIS_SBUF_DATA_OVFLW		= 3
208c2ecf20Sopenharmony_ci};
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_cistruct mantis_slot {
238c2ecf20Sopenharmony_ci	u32				timeout;
248c2ecf20Sopenharmony_ci	u32				slave_cfg;
258c2ecf20Sopenharmony_ci	u32				bar;
268c2ecf20Sopenharmony_ci};
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci/* Physical layer */
298c2ecf20Sopenharmony_cienum mantis_slot_state {
308c2ecf20Sopenharmony_ci	MODULE_INSERTED			= 3,
318c2ecf20Sopenharmony_ci	MODULE_XTRACTED			= 4
328c2ecf20Sopenharmony_ci};
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_cistruct mantis_ca {
358c2ecf20Sopenharmony_ci	struct mantis_slot		slot[4];
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_ci	struct work_struct		hif_evm_work;
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci	u32				hif_event;
408c2ecf20Sopenharmony_ci	wait_queue_head_t		hif_opdone_wq;
418c2ecf20Sopenharmony_ci	wait_queue_head_t		hif_brrdyw_wq;
428c2ecf20Sopenharmony_ci	wait_queue_head_t		hif_data_wq;
438c2ecf20Sopenharmony_ci	wait_queue_head_t		hif_write_wq; /* HIF Write op */
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ci	enum mantis_sbuf_status		sbuf_status;
468c2ecf20Sopenharmony_ci
478c2ecf20Sopenharmony_ci	enum mantis_slot_state		slot_state;
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ci	void				*ca_priv;
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_ci	struct dvb_ca_en50221		en50221;
528c2ecf20Sopenharmony_ci	struct mutex			ca_lock;
538c2ecf20Sopenharmony_ci};
548c2ecf20Sopenharmony_ci
558c2ecf20Sopenharmony_ci/* CA */
568c2ecf20Sopenharmony_ciextern void mantis_event_cam_plugin(struct mantis_ca *ca);
578c2ecf20Sopenharmony_ciextern void mantis_event_cam_unplug(struct mantis_ca *ca);
588c2ecf20Sopenharmony_ciextern int mantis_pcmcia_init(struct mantis_ca *ca);
598c2ecf20Sopenharmony_ciextern void mantis_pcmcia_exit(struct mantis_ca *ca);
608c2ecf20Sopenharmony_ciextern int mantis_evmgr_init(struct mantis_ca *ca);
618c2ecf20Sopenharmony_ciextern void mantis_evmgr_exit(struct mantis_ca *ca);
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_ci/* HIF */
648c2ecf20Sopenharmony_ciextern int mantis_hif_init(struct mantis_ca *ca);
658c2ecf20Sopenharmony_ciextern void mantis_hif_exit(struct mantis_ca *ca);
668c2ecf20Sopenharmony_ciextern int mantis_hif_read_mem(struct mantis_ca *ca, u32 addr);
678c2ecf20Sopenharmony_ciextern int mantis_hif_write_mem(struct mantis_ca *ca, u32 addr, u8 data);
688c2ecf20Sopenharmony_ciextern int mantis_hif_read_iom(struct mantis_ca *ca, u32 addr);
698c2ecf20Sopenharmony_ciextern int mantis_hif_write_iom(struct mantis_ca *ca, u32 addr, u8 data);
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_ci#endif /* __MANTIS_LINK_H */
72