18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Linux driver for digital TV devices equipped with B2C2 FlexcopII(b)/III
48c2ecf20Sopenharmony_ci * flexcop-usb.h - header file for the USB part
58c2ecf20Sopenharmony_ci * see flexcop.c for copyright information
68c2ecf20Sopenharmony_ci */
78c2ecf20Sopenharmony_ci#ifndef __FLEXCOP_USB_H_INCLUDED__
88c2ecf20Sopenharmony_ci#define __FLEXCOP_USB_H_INCLUDED__
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci#include <linux/usb.h>
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci/* transfer parameters */
138c2ecf20Sopenharmony_ci#define B2C2_USB_FRAMES_PER_ISO 4
148c2ecf20Sopenharmony_ci#define B2C2_USB_NUM_ISO_URB 4
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_ci#define B2C2_USB_CTRL_PIPE_IN usb_rcvctrlpipe(fc_usb->udev, 0)
178c2ecf20Sopenharmony_ci#define B2C2_USB_CTRL_PIPE_OUT usb_sndctrlpipe(fc_usb->udev, 0)
188c2ecf20Sopenharmony_ci#define B2C2_USB_DATA_PIPE usb_rcvisocpipe(fc_usb->udev, 1)
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_cistruct flexcop_usb {
218c2ecf20Sopenharmony_ci	struct usb_device *udev;
228c2ecf20Sopenharmony_ci	struct usb_interface *uintf;
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci	u8 *iso_buffer;
258c2ecf20Sopenharmony_ci	int buffer_size;
268c2ecf20Sopenharmony_ci	dma_addr_t dma_addr;
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci	struct urb *iso_urb[B2C2_USB_NUM_ISO_URB];
298c2ecf20Sopenharmony_ci	struct flexcop_device *fc_dev;
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_ci	u8 tmp_buffer[1023+190];
328c2ecf20Sopenharmony_ci	int tmp_buffer_length;
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ci	/* for URB control messages */
358c2ecf20Sopenharmony_ci	u8 data[80];
368c2ecf20Sopenharmony_ci	struct mutex data_mutex;
378c2ecf20Sopenharmony_ci};
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci#if 0
408c2ecf20Sopenharmony_ci/* request types TODO What is its use?*/
418c2ecf20Sopenharmony_citypedef enum {
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci} flexcop_usb_request_type_t;
448c2ecf20Sopenharmony_ci#endif
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_ci/* request */
478c2ecf20Sopenharmony_citypedef enum {
488c2ecf20Sopenharmony_ci	B2C2_USB_WRITE_V8_MEM = 0x04,
498c2ecf20Sopenharmony_ci	B2C2_USB_READ_V8_MEM  = 0x05,
508c2ecf20Sopenharmony_ci	B2C2_USB_READ_REG     = 0x08,
518c2ecf20Sopenharmony_ci	B2C2_USB_WRITE_REG    = 0x0A,
528c2ecf20Sopenharmony_ci	B2C2_USB_WRITEREGHI   = 0x0B,
538c2ecf20Sopenharmony_ci	B2C2_USB_FLASH_BLOCK  = 0x10,
548c2ecf20Sopenharmony_ci	B2C2_USB_I2C_REQUEST  = 0x11,
558c2ecf20Sopenharmony_ci	B2C2_USB_UTILITY      = 0x12,
568c2ecf20Sopenharmony_ci} flexcop_usb_request_t;
578c2ecf20Sopenharmony_ci
588c2ecf20Sopenharmony_ci/* function definition for I2C_REQUEST */
598c2ecf20Sopenharmony_citypedef enum {
608c2ecf20Sopenharmony_ci	USB_FUNC_I2C_WRITE       = 0x01,
618c2ecf20Sopenharmony_ci	USB_FUNC_I2C_MULTIWRITE  = 0x02,
628c2ecf20Sopenharmony_ci	USB_FUNC_I2C_READ        = 0x03,
638c2ecf20Sopenharmony_ci	USB_FUNC_I2C_REPEATWRITE = 0x04,
648c2ecf20Sopenharmony_ci	USB_FUNC_GET_DESCRIPTOR  = 0x05,
658c2ecf20Sopenharmony_ci	USB_FUNC_I2C_REPEATREAD  = 0x06,
668c2ecf20Sopenharmony_ci	/* DKT 020208 - add this to support special case of DiSEqC */
678c2ecf20Sopenharmony_ci	USB_FUNC_I2C_CHECKWRITE  = 0x07,
688c2ecf20Sopenharmony_ci	USB_FUNC_I2C_CHECKRESULT = 0x08,
698c2ecf20Sopenharmony_ci} flexcop_usb_i2c_function_t;
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_ci/* function definition for UTILITY request 0x12
728c2ecf20Sopenharmony_ci * DKT 020304 - new utility function */
738c2ecf20Sopenharmony_citypedef enum {
748c2ecf20Sopenharmony_ci	UTILITY_SET_FILTER          = 0x01,
758c2ecf20Sopenharmony_ci	UTILITY_DATA_ENABLE         = 0x02,
768c2ecf20Sopenharmony_ci	UTILITY_FLEX_MULTIWRITE     = 0x03,
778c2ecf20Sopenharmony_ci	UTILITY_SET_BUFFER_SIZE     = 0x04,
788c2ecf20Sopenharmony_ci	UTILITY_FLEX_OPERATOR       = 0x05,
798c2ecf20Sopenharmony_ci	UTILITY_FLEX_RESET300_START = 0x06,
808c2ecf20Sopenharmony_ci	UTILITY_FLEX_RESET300_STOP  = 0x07,
818c2ecf20Sopenharmony_ci	UTILITY_FLEX_RESET300       = 0x08,
828c2ecf20Sopenharmony_ci	UTILITY_SET_ISO_SIZE        = 0x09,
838c2ecf20Sopenharmony_ci	UTILITY_DATA_RESET          = 0x0A,
848c2ecf20Sopenharmony_ci	UTILITY_GET_DATA_STATUS     = 0x10,
858c2ecf20Sopenharmony_ci	UTILITY_GET_V8_REG          = 0x11,
868c2ecf20Sopenharmony_ci	/* DKT 020326 - add function for v1.14 */
878c2ecf20Sopenharmony_ci	UTILITY_SRAM_WRITE          = 0x12,
888c2ecf20Sopenharmony_ci	UTILITY_SRAM_READ           = 0x13,
898c2ecf20Sopenharmony_ci	UTILITY_SRAM_TESTFILL       = 0x14,
908c2ecf20Sopenharmony_ci	UTILITY_SRAM_TESTSET        = 0x15,
918c2ecf20Sopenharmony_ci	UTILITY_SRAM_TESTVERIFY     = 0x16,
928c2ecf20Sopenharmony_ci} flexcop_usb_utility_function_t;
938c2ecf20Sopenharmony_ci
948c2ecf20Sopenharmony_ci#define B2C2_WAIT_FOR_OPERATION_RW 1000
958c2ecf20Sopenharmony_ci#define B2C2_WAIT_FOR_OPERATION_RDW 3000
968c2ecf20Sopenharmony_ci#define B2C2_WAIT_FOR_OPERATION_WDW 1000
978c2ecf20Sopenharmony_ci
988c2ecf20Sopenharmony_ci#define B2C2_WAIT_FOR_OPERATION_V8READ 3000
998c2ecf20Sopenharmony_ci#define B2C2_WAIT_FOR_OPERATION_V8WRITE 3000
1008c2ecf20Sopenharmony_ci#define B2C2_WAIT_FOR_OPERATION_V8FLASH 3000
1018c2ecf20Sopenharmony_ci
1028c2ecf20Sopenharmony_citypedef enum {
1038c2ecf20Sopenharmony_ci	V8_MEMORY_PAGE_DVB_CI = 0x20,
1048c2ecf20Sopenharmony_ci	V8_MEMORY_PAGE_DVB_DS = 0x40,
1058c2ecf20Sopenharmony_ci	V8_MEMORY_PAGE_MULTI2 = 0x60,
1068c2ecf20Sopenharmony_ci	V8_MEMORY_PAGE_FLASH  = 0x80
1078c2ecf20Sopenharmony_ci} flexcop_usb_mem_page_t;
1088c2ecf20Sopenharmony_ci
1098c2ecf20Sopenharmony_ci#define V8_MEMORY_EXTENDED (1 << 15)
1108c2ecf20Sopenharmony_ci#define USB_MEM_READ_MAX   32
1118c2ecf20Sopenharmony_ci#define USB_MEM_WRITE_MAX   1
1128c2ecf20Sopenharmony_ci#define USB_FLASH_MAX       8
1138c2ecf20Sopenharmony_ci#define V8_MEMORY_PAGE_SIZE 0x8000 /* 32K */
1148c2ecf20Sopenharmony_ci#define V8_MEMORY_PAGE_MASK 0x7FFF
1158c2ecf20Sopenharmony_ci
1168c2ecf20Sopenharmony_ci#endif
117