162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Linux driver for digital TV devices equipped with B2C2 FlexcopII(b)/III 462306a36Sopenharmony_ci * flexcop-usb.h - header file for the USB part 562306a36Sopenharmony_ci * see flexcop.c for copyright information 662306a36Sopenharmony_ci */ 762306a36Sopenharmony_ci#ifndef __FLEXCOP_USB_H_INCLUDED__ 862306a36Sopenharmony_ci#define __FLEXCOP_USB_H_INCLUDED__ 962306a36Sopenharmony_ci 1062306a36Sopenharmony_ci#include <linux/usb.h> 1162306a36Sopenharmony_ci 1262306a36Sopenharmony_ci/* transfer parameters */ 1362306a36Sopenharmony_ci#define B2C2_USB_FRAMES_PER_ISO 4 1462306a36Sopenharmony_ci#define B2C2_USB_NUM_ISO_URB 4 1562306a36Sopenharmony_ci 1662306a36Sopenharmony_ci#define B2C2_USB_CTRL_PIPE_IN usb_rcvctrlpipe(fc_usb->udev, 0) 1762306a36Sopenharmony_ci#define B2C2_USB_CTRL_PIPE_OUT usb_sndctrlpipe(fc_usb->udev, 0) 1862306a36Sopenharmony_ci#define B2C2_USB_DATA_PIPE usb_rcvisocpipe(fc_usb->udev, 1) 1962306a36Sopenharmony_ci 2062306a36Sopenharmony_cistruct flexcop_usb { 2162306a36Sopenharmony_ci struct usb_device *udev; 2262306a36Sopenharmony_ci struct usb_interface *uintf; 2362306a36Sopenharmony_ci 2462306a36Sopenharmony_ci u8 *iso_buffer; 2562306a36Sopenharmony_ci int buffer_size; 2662306a36Sopenharmony_ci dma_addr_t dma_addr; 2762306a36Sopenharmony_ci 2862306a36Sopenharmony_ci struct urb *iso_urb[B2C2_USB_NUM_ISO_URB]; 2962306a36Sopenharmony_ci struct flexcop_device *fc_dev; 3062306a36Sopenharmony_ci 3162306a36Sopenharmony_ci u8 tmp_buffer[1023+190]; 3262306a36Sopenharmony_ci int tmp_buffer_length; 3362306a36Sopenharmony_ci 3462306a36Sopenharmony_ci /* for URB control messages */ 3562306a36Sopenharmony_ci u8 data[80]; 3662306a36Sopenharmony_ci struct mutex data_mutex; 3762306a36Sopenharmony_ci}; 3862306a36Sopenharmony_ci 3962306a36Sopenharmony_ci#if 0 4062306a36Sopenharmony_ci/* request types TODO What is its use?*/ 4162306a36Sopenharmony_citypedef enum { 4262306a36Sopenharmony_ci 4362306a36Sopenharmony_ci} flexcop_usb_request_type_t; 4462306a36Sopenharmony_ci#endif 4562306a36Sopenharmony_ci 4662306a36Sopenharmony_ci/* request */ 4762306a36Sopenharmony_citypedef enum { 4862306a36Sopenharmony_ci B2C2_USB_WRITE_V8_MEM = 0x04, 4962306a36Sopenharmony_ci B2C2_USB_READ_V8_MEM = 0x05, 5062306a36Sopenharmony_ci B2C2_USB_READ_REG = 0x08, 5162306a36Sopenharmony_ci B2C2_USB_WRITE_REG = 0x0A, 5262306a36Sopenharmony_ci B2C2_USB_WRITEREGHI = 0x0B, 5362306a36Sopenharmony_ci B2C2_USB_FLASH_BLOCK = 0x10, 5462306a36Sopenharmony_ci B2C2_USB_I2C_REQUEST = 0x11, 5562306a36Sopenharmony_ci B2C2_USB_UTILITY = 0x12, 5662306a36Sopenharmony_ci} flexcop_usb_request_t; 5762306a36Sopenharmony_ci 5862306a36Sopenharmony_ci/* function definition for I2C_REQUEST */ 5962306a36Sopenharmony_citypedef enum { 6062306a36Sopenharmony_ci USB_FUNC_I2C_WRITE = 0x01, 6162306a36Sopenharmony_ci USB_FUNC_I2C_MULTIWRITE = 0x02, 6262306a36Sopenharmony_ci USB_FUNC_I2C_READ = 0x03, 6362306a36Sopenharmony_ci USB_FUNC_I2C_REPEATWRITE = 0x04, 6462306a36Sopenharmony_ci USB_FUNC_GET_DESCRIPTOR = 0x05, 6562306a36Sopenharmony_ci USB_FUNC_I2C_REPEATREAD = 0x06, 6662306a36Sopenharmony_ci /* DKT 020208 - add this to support special case of DiSEqC */ 6762306a36Sopenharmony_ci USB_FUNC_I2C_CHECKWRITE = 0x07, 6862306a36Sopenharmony_ci USB_FUNC_I2C_CHECKRESULT = 0x08, 6962306a36Sopenharmony_ci} flexcop_usb_i2c_function_t; 7062306a36Sopenharmony_ci 7162306a36Sopenharmony_ci/* function definition for UTILITY request 0x12 7262306a36Sopenharmony_ci * DKT 020304 - new utility function */ 7362306a36Sopenharmony_citypedef enum { 7462306a36Sopenharmony_ci UTILITY_SET_FILTER = 0x01, 7562306a36Sopenharmony_ci UTILITY_DATA_ENABLE = 0x02, 7662306a36Sopenharmony_ci UTILITY_FLEX_MULTIWRITE = 0x03, 7762306a36Sopenharmony_ci UTILITY_SET_BUFFER_SIZE = 0x04, 7862306a36Sopenharmony_ci UTILITY_FLEX_OPERATOR = 0x05, 7962306a36Sopenharmony_ci UTILITY_FLEX_RESET300_START = 0x06, 8062306a36Sopenharmony_ci UTILITY_FLEX_RESET300_STOP = 0x07, 8162306a36Sopenharmony_ci UTILITY_FLEX_RESET300 = 0x08, 8262306a36Sopenharmony_ci UTILITY_SET_ISO_SIZE = 0x09, 8362306a36Sopenharmony_ci UTILITY_DATA_RESET = 0x0A, 8462306a36Sopenharmony_ci UTILITY_GET_DATA_STATUS = 0x10, 8562306a36Sopenharmony_ci UTILITY_GET_V8_REG = 0x11, 8662306a36Sopenharmony_ci /* DKT 020326 - add function for v1.14 */ 8762306a36Sopenharmony_ci UTILITY_SRAM_WRITE = 0x12, 8862306a36Sopenharmony_ci UTILITY_SRAM_READ = 0x13, 8962306a36Sopenharmony_ci UTILITY_SRAM_TESTFILL = 0x14, 9062306a36Sopenharmony_ci UTILITY_SRAM_TESTSET = 0x15, 9162306a36Sopenharmony_ci UTILITY_SRAM_TESTVERIFY = 0x16, 9262306a36Sopenharmony_ci} flexcop_usb_utility_function_t; 9362306a36Sopenharmony_ci 9462306a36Sopenharmony_ci#define B2C2_WAIT_FOR_OPERATION_RW 1000 9562306a36Sopenharmony_ci#define B2C2_WAIT_FOR_OPERATION_RDW 3000 9662306a36Sopenharmony_ci#define B2C2_WAIT_FOR_OPERATION_WDW 1000 9762306a36Sopenharmony_ci 9862306a36Sopenharmony_ci#define B2C2_WAIT_FOR_OPERATION_V8READ 3000 9962306a36Sopenharmony_ci#define B2C2_WAIT_FOR_OPERATION_V8WRITE 3000 10062306a36Sopenharmony_ci#define B2C2_WAIT_FOR_OPERATION_V8FLASH 3000 10162306a36Sopenharmony_ci 10262306a36Sopenharmony_citypedef enum { 10362306a36Sopenharmony_ci V8_MEMORY_PAGE_DVB_CI = 0x20, 10462306a36Sopenharmony_ci V8_MEMORY_PAGE_DVB_DS = 0x40, 10562306a36Sopenharmony_ci V8_MEMORY_PAGE_MULTI2 = 0x60, 10662306a36Sopenharmony_ci V8_MEMORY_PAGE_FLASH = 0x80 10762306a36Sopenharmony_ci} flexcop_usb_mem_page_t; 10862306a36Sopenharmony_ci 10962306a36Sopenharmony_ci#define V8_MEMORY_EXTENDED (1 << 15) 11062306a36Sopenharmony_ci#define USB_MEM_READ_MAX 32 11162306a36Sopenharmony_ci#define USB_MEM_WRITE_MAX 1 11262306a36Sopenharmony_ci#define USB_FLASH_MAX 8 11362306a36Sopenharmony_ci#define V8_MEMORY_PAGE_SIZE 0x8000 /* 32K */ 11462306a36Sopenharmony_ci#define V8_MEMORY_PAGE_MASK 0x7FFF 11562306a36Sopenharmony_ci 11662306a36Sopenharmony_ci#endif 117