162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * SMI PCIe driver for DVBSky cards.
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci * Copyright (C) 2014 Max nibble <nibble.max@gmail.com>
662306a36Sopenharmony_ci */
762306a36Sopenharmony_ci
862306a36Sopenharmony_ci#ifndef _SMI_PCIE_H_
962306a36Sopenharmony_ci#define _SMI_PCIE_H_
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_ci#include <linux/i2c.h>
1262306a36Sopenharmony_ci#include <linux/i2c-algo-bit.h>
1362306a36Sopenharmony_ci#include <linux/init.h>
1462306a36Sopenharmony_ci#include <linux/interrupt.h>
1562306a36Sopenharmony_ci#include <linux/kernel.h>
1662306a36Sopenharmony_ci#include <linux/module.h>
1762306a36Sopenharmony_ci#include <linux/pci.h>
1862306a36Sopenharmony_ci#include <linux/dma-mapping.h>
1962306a36Sopenharmony_ci#include <linux/slab.h>
2062306a36Sopenharmony_ci#include <media/rc-core.h>
2162306a36Sopenharmony_ci
2262306a36Sopenharmony_ci#include <media/demux.h>
2362306a36Sopenharmony_ci#include <media/dmxdev.h>
2462306a36Sopenharmony_ci#include <media/dvb_demux.h>
2562306a36Sopenharmony_ci#include <media/dvb_frontend.h>
2662306a36Sopenharmony_ci#include <media/dvb_net.h>
2762306a36Sopenharmony_ci#include <media/dvbdev.h>
2862306a36Sopenharmony_ci
2962306a36Sopenharmony_ci/* -------- Register Base -------- */
3062306a36Sopenharmony_ci#define    MSI_CONTROL_REG_BASE                 0x0800
3162306a36Sopenharmony_ci#define    SYSTEM_CONTROL_REG_BASE              0x0880
3262306a36Sopenharmony_ci#define    PCIE_EP_DEBUG_REG_BASE               0x08C0
3362306a36Sopenharmony_ci#define    IR_CONTROL_REG_BASE                  0x0900
3462306a36Sopenharmony_ci#define    I2C_A_CONTROL_REG_BASE               0x0940
3562306a36Sopenharmony_ci#define    I2C_B_CONTROL_REG_BASE               0x0980
3662306a36Sopenharmony_ci#define    ATV_PORTA_CONTROL_REG_BASE           0x09C0
3762306a36Sopenharmony_ci#define    DTV_PORTA_CONTROL_REG_BASE           0x0A00
3862306a36Sopenharmony_ci#define    AES_PORTA_CONTROL_REG_BASE           0x0A80
3962306a36Sopenharmony_ci#define    DMA_PORTA_CONTROL_REG_BASE           0x0AC0
4062306a36Sopenharmony_ci#define    ATV_PORTB_CONTROL_REG_BASE           0x0B00
4162306a36Sopenharmony_ci#define    DTV_PORTB_CONTROL_REG_BASE           0x0B40
4262306a36Sopenharmony_ci#define    AES_PORTB_CONTROL_REG_BASE           0x0BC0
4362306a36Sopenharmony_ci#define    DMA_PORTB_CONTROL_REG_BASE           0x0C00
4462306a36Sopenharmony_ci#define    UART_A_REGISTER_BASE                 0x0C40
4562306a36Sopenharmony_ci#define    UART_B_REGISTER_BASE                 0x0C80
4662306a36Sopenharmony_ci#define    GPS_CONTROL_REG_BASE                 0x0CC0
4762306a36Sopenharmony_ci#define    DMA_PORTC_CONTROL_REG_BASE           0x0D00
4862306a36Sopenharmony_ci#define    DMA_PORTD_CONTROL_REG_BASE           0x0D00
4962306a36Sopenharmony_ci#define    AES_RANDOM_DATA_BASE                 0x0D80
5062306a36Sopenharmony_ci#define    AES_KEY_IN_BASE                      0x0D90
5162306a36Sopenharmony_ci#define    RANDOM_DATA_LIB_BASE                 0x0E00
5262306a36Sopenharmony_ci#define    IR_DATA_BUFFER_BASE                  0x0F00
5362306a36Sopenharmony_ci#define    PORTA_TS_BUFFER_BASE                 0x1000
5462306a36Sopenharmony_ci#define    PORTA_I2S_BUFFER_BASE                0x1400
5562306a36Sopenharmony_ci#define    PORTB_TS_BUFFER_BASE                 0x1800
5662306a36Sopenharmony_ci#define    PORTB_I2S_BUFFER_BASE                0x1C00
5762306a36Sopenharmony_ci
5862306a36Sopenharmony_ci/* -------- MSI control and state register -------- */
5962306a36Sopenharmony_ci#define MSI_DELAY_TIMER             (MSI_CONTROL_REG_BASE + 0x00)
6062306a36Sopenharmony_ci#define MSI_INT_STATUS              (MSI_CONTROL_REG_BASE + 0x08)
6162306a36Sopenharmony_ci#define MSI_INT_STATUS_CLR          (MSI_CONTROL_REG_BASE + 0x0C)
6262306a36Sopenharmony_ci#define MSI_INT_STATUS_SET          (MSI_CONTROL_REG_BASE + 0x10)
6362306a36Sopenharmony_ci#define MSI_INT_ENA                 (MSI_CONTROL_REG_BASE + 0x14)
6462306a36Sopenharmony_ci#define MSI_INT_ENA_CLR             (MSI_CONTROL_REG_BASE + 0x18)
6562306a36Sopenharmony_ci#define MSI_INT_ENA_SET             (MSI_CONTROL_REG_BASE + 0x1C)
6662306a36Sopenharmony_ci#define MSI_SOFT_RESET              (MSI_CONTROL_REG_BASE + 0x20)
6762306a36Sopenharmony_ci#define MSI_CFG_SRC0                (MSI_CONTROL_REG_BASE + 0x24)
6862306a36Sopenharmony_ci
6962306a36Sopenharmony_ci/* -------- Hybird Controller System Control register -------- */
7062306a36Sopenharmony_ci#define MUX_MODE_CTRL         (SYSTEM_CONTROL_REG_BASE + 0x00)
7162306a36Sopenharmony_ci	#define rbPaMSMask        0x07
7262306a36Sopenharmony_ci	#define rbPaMSDtvNoGpio   0x00 /*[2:0], DTV Simple mode */
7362306a36Sopenharmony_ci	#define rbPaMSDtv4bitGpio 0x01 /*[2:0], DTV TS2 Serial mode)*/
7462306a36Sopenharmony_ci	#define rbPaMSDtv7bitGpio 0x02 /*[2:0], DTV TS0 Serial mode*/
7562306a36Sopenharmony_ci	#define rbPaMS8bitGpio    0x03 /*[2:0], GPIO mode selected;(8bit GPIO)*/
7662306a36Sopenharmony_ci	#define rbPaMSAtv         0x04 /*[2:0], 3'b1xx: ATV mode select*/
7762306a36Sopenharmony_ci	#define rbPbMSMask        0x38
7862306a36Sopenharmony_ci	#define rbPbMSDtvNoGpio   0x00 /*[5:3], DTV Simple mode */
7962306a36Sopenharmony_ci	#define rbPbMSDtv4bitGpio 0x08 /*[5:3], DTV TS2 Serial mode*/
8062306a36Sopenharmony_ci	#define rbPbMSDtv7bitGpio 0x10 /*[5:3], DTV TS0 Serial mode*/
8162306a36Sopenharmony_ci	#define rbPbMS8bitGpio    0x18 /*[5:3], GPIO mode selected;(8bit GPIO)*/
8262306a36Sopenharmony_ci	#define rbPbMSAtv         0x20 /*[5:3], 3'b1xx: ATV mode select*/
8362306a36Sopenharmony_ci	#define rbPaAESEN         0x40 /*[6], port A AES enable bit*/
8462306a36Sopenharmony_ci	#define rbPbAESEN         0x80 /*[7], port B AES enable bit*/
8562306a36Sopenharmony_ci
8662306a36Sopenharmony_ci#define INTERNAL_RST                (SYSTEM_CONTROL_REG_BASE + 0x04)
8762306a36Sopenharmony_ci#define PERIPHERAL_CTRL             (SYSTEM_CONTROL_REG_BASE + 0x08)
8862306a36Sopenharmony_ci#define GPIO_0to7_CTRL              (SYSTEM_CONTROL_REG_BASE + 0x0C)
8962306a36Sopenharmony_ci#define GPIO_8to15_CTRL             (SYSTEM_CONTROL_REG_BASE + 0x10)
9062306a36Sopenharmony_ci#define GPIO_16to24_CTRL            (SYSTEM_CONTROL_REG_BASE + 0x14)
9162306a36Sopenharmony_ci#define GPIO_INT_SRC_CFG            (SYSTEM_CONTROL_REG_BASE + 0x18)
9262306a36Sopenharmony_ci#define SYS_BUF_STATUS              (SYSTEM_CONTROL_REG_BASE + 0x1C)
9362306a36Sopenharmony_ci#define PCIE_IP_REG_ACS             (SYSTEM_CONTROL_REG_BASE + 0x20)
9462306a36Sopenharmony_ci#define PCIE_IP_REG_ACS_ADDR        (SYSTEM_CONTROL_REG_BASE + 0x24)
9562306a36Sopenharmony_ci#define PCIE_IP_REG_ACS_DATA        (SYSTEM_CONTROL_REG_BASE + 0x28)
9662306a36Sopenharmony_ci
9762306a36Sopenharmony_ci/* -------- IR Control register -------- */
9862306a36Sopenharmony_ci#define   IR_Init_Reg         (IR_CONTROL_REG_BASE + 0x00)
9962306a36Sopenharmony_ci#define   IR_Idle_Cnt_Low     (IR_CONTROL_REG_BASE + 0x04)
10062306a36Sopenharmony_ci#define   IR_Idle_Cnt_High    (IR_CONTROL_REG_BASE + 0x05)
10162306a36Sopenharmony_ci#define   IR_Unit_Cnt_Low     (IR_CONTROL_REG_BASE + 0x06)
10262306a36Sopenharmony_ci#define   IR_Unit_Cnt_High    (IR_CONTROL_REG_BASE + 0x07)
10362306a36Sopenharmony_ci#define   IR_Data_Cnt         (IR_CONTROL_REG_BASE + 0x08)
10462306a36Sopenharmony_ci#define   rbIRen            0x80
10562306a36Sopenharmony_ci#define   rbIRhighidle      0x10
10662306a36Sopenharmony_ci#define   rbIRlowidle       0x00
10762306a36Sopenharmony_ci#define   rbIRVld           0x04
10862306a36Sopenharmony_ci
10962306a36Sopenharmony_ci/* -------- I2C A control and state register -------- */
11062306a36Sopenharmony_ci#define I2C_A_CTL_STATUS                 (I2C_A_CONTROL_REG_BASE + 0x00)
11162306a36Sopenharmony_ci#define I2C_A_ADDR                       (I2C_A_CONTROL_REG_BASE + 0x04)
11262306a36Sopenharmony_ci#define I2C_A_SW_CTL                     (I2C_A_CONTROL_REG_BASE + 0x08)
11362306a36Sopenharmony_ci#define I2C_A_TIME_OUT_CNT               (I2C_A_CONTROL_REG_BASE + 0x0C)
11462306a36Sopenharmony_ci#define I2C_A_FIFO_STATUS                (I2C_A_CONTROL_REG_BASE + 0x10)
11562306a36Sopenharmony_ci#define I2C_A_FS_EN                      (I2C_A_CONTROL_REG_BASE + 0x14)
11662306a36Sopenharmony_ci#define I2C_A_FIFO_DATA                  (I2C_A_CONTROL_REG_BASE + 0x20)
11762306a36Sopenharmony_ci
11862306a36Sopenharmony_ci/* -------- I2C B control and state register -------- */
11962306a36Sopenharmony_ci#define I2C_B_CTL_STATUS                 (I2C_B_CONTROL_REG_BASE + 0x00)
12062306a36Sopenharmony_ci#define I2C_B_ADDR                       (I2C_B_CONTROL_REG_BASE + 0x04)
12162306a36Sopenharmony_ci#define I2C_B_SW_CTL                     (I2C_B_CONTROL_REG_BASE + 0x08)
12262306a36Sopenharmony_ci#define I2C_B_TIME_OUT_CNT               (I2C_B_CONTROL_REG_BASE + 0x0C)
12362306a36Sopenharmony_ci#define I2C_B_FIFO_STATUS                (I2C_B_CONTROL_REG_BASE + 0x10)
12462306a36Sopenharmony_ci#define I2C_B_FS_EN                      (I2C_B_CONTROL_REG_BASE + 0x14)
12562306a36Sopenharmony_ci#define I2C_B_FIFO_DATA                  (I2C_B_CONTROL_REG_BASE + 0x20)
12662306a36Sopenharmony_ci
12762306a36Sopenharmony_ci#define VIDEO_CTRL_STATUS_A	(ATV_PORTA_CONTROL_REG_BASE + 0x04)
12862306a36Sopenharmony_ci
12962306a36Sopenharmony_ci/* -------- Digital TV control register, Port A -------- */
13062306a36Sopenharmony_ci#define MPEG2_CTRL_A		(DTV_PORTA_CONTROL_REG_BASE + 0x00)
13162306a36Sopenharmony_ci#define SERIAL_IN_ADDR_A	(DTV_PORTA_CONTROL_REG_BASE + 0x4C)
13262306a36Sopenharmony_ci#define VLD_CNT_ADDR_A		(DTV_PORTA_CONTROL_REG_BASE + 0x60)
13362306a36Sopenharmony_ci#define ERR_CNT_ADDR_A		(DTV_PORTA_CONTROL_REG_BASE + 0x64)
13462306a36Sopenharmony_ci#define BRD_CNT_ADDR_A		(DTV_PORTA_CONTROL_REG_BASE + 0x68)
13562306a36Sopenharmony_ci
13662306a36Sopenharmony_ci/* -------- DMA Control Register, Port A  -------- */
13762306a36Sopenharmony_ci#define DMA_PORTA_CHAN0_ADDR_LOW        (DMA_PORTA_CONTROL_REG_BASE + 0x00)
13862306a36Sopenharmony_ci#define DMA_PORTA_CHAN0_ADDR_HI         (DMA_PORTA_CONTROL_REG_BASE + 0x04)
13962306a36Sopenharmony_ci#define DMA_PORTA_CHAN0_TRANS_STATE     (DMA_PORTA_CONTROL_REG_BASE + 0x08)
14062306a36Sopenharmony_ci#define DMA_PORTA_CHAN0_CONTROL         (DMA_PORTA_CONTROL_REG_BASE + 0x0C)
14162306a36Sopenharmony_ci#define DMA_PORTA_CHAN1_ADDR_LOW        (DMA_PORTA_CONTROL_REG_BASE + 0x10)
14262306a36Sopenharmony_ci#define DMA_PORTA_CHAN1_ADDR_HI         (DMA_PORTA_CONTROL_REG_BASE + 0x14)
14362306a36Sopenharmony_ci#define DMA_PORTA_CHAN1_TRANS_STATE     (DMA_PORTA_CONTROL_REG_BASE + 0x18)
14462306a36Sopenharmony_ci#define DMA_PORTA_CHAN1_CONTROL         (DMA_PORTA_CONTROL_REG_BASE + 0x1C)
14562306a36Sopenharmony_ci#define DMA_PORTA_MANAGEMENT            (DMA_PORTA_CONTROL_REG_BASE + 0x20)
14662306a36Sopenharmony_ci#define VIDEO_CTRL_STATUS_B             (ATV_PORTB_CONTROL_REG_BASE + 0x04)
14762306a36Sopenharmony_ci
14862306a36Sopenharmony_ci/* -------- Digital TV control register, Port B -------- */
14962306a36Sopenharmony_ci#define MPEG2_CTRL_B		(DTV_PORTB_CONTROL_REG_BASE + 0x00)
15062306a36Sopenharmony_ci#define SERIAL_IN_ADDR_B	(DTV_PORTB_CONTROL_REG_BASE + 0x4C)
15162306a36Sopenharmony_ci#define VLD_CNT_ADDR_B		(DTV_PORTB_CONTROL_REG_BASE + 0x60)
15262306a36Sopenharmony_ci#define ERR_CNT_ADDR_B		(DTV_PORTB_CONTROL_REG_BASE + 0x64)
15362306a36Sopenharmony_ci#define BRD_CNT_ADDR_B		(DTV_PORTB_CONTROL_REG_BASE + 0x68)
15462306a36Sopenharmony_ci
15562306a36Sopenharmony_ci/* -------- AES control register, Port B -------- */
15662306a36Sopenharmony_ci#define AES_CTRL_B		(AES_PORTB_CONTROL_REG_BASE + 0x00)
15762306a36Sopenharmony_ci#define AES_KEY_BASE_B	(AES_PORTB_CONTROL_REG_BASE + 0x04)
15862306a36Sopenharmony_ci
15962306a36Sopenharmony_ci/* -------- DMA Control Register, Port B  -------- */
16062306a36Sopenharmony_ci#define DMA_PORTB_CHAN0_ADDR_LOW        (DMA_PORTB_CONTROL_REG_BASE + 0x00)
16162306a36Sopenharmony_ci#define DMA_PORTB_CHAN0_ADDR_HI         (DMA_PORTB_CONTROL_REG_BASE + 0x04)
16262306a36Sopenharmony_ci#define DMA_PORTB_CHAN0_TRANS_STATE     (DMA_PORTB_CONTROL_REG_BASE + 0x08)
16362306a36Sopenharmony_ci#define DMA_PORTB_CHAN0_CONTROL         (DMA_PORTB_CONTROL_REG_BASE + 0x0C)
16462306a36Sopenharmony_ci#define DMA_PORTB_CHAN1_ADDR_LOW        (DMA_PORTB_CONTROL_REG_BASE + 0x10)
16562306a36Sopenharmony_ci#define DMA_PORTB_CHAN1_ADDR_HI         (DMA_PORTB_CONTROL_REG_BASE + 0x14)
16662306a36Sopenharmony_ci#define DMA_PORTB_CHAN1_TRANS_STATE     (DMA_PORTB_CONTROL_REG_BASE + 0x18)
16762306a36Sopenharmony_ci#define DMA_PORTB_CHAN1_CONTROL         (DMA_PORTB_CONTROL_REG_BASE + 0x1C)
16862306a36Sopenharmony_ci#define DMA_PORTB_MANAGEMENT            (DMA_PORTB_CONTROL_REG_BASE + 0x20)
16962306a36Sopenharmony_ci
17062306a36Sopenharmony_ci#define DMA_TRANS_UNIT_188 (0x00000007)
17162306a36Sopenharmony_ci
17262306a36Sopenharmony_ci/* -------- Macro define of 24 interrupt resource --------*/
17362306a36Sopenharmony_ci#define DMA_A_CHAN0_DONE_INT   (0x00000001)
17462306a36Sopenharmony_ci#define DMA_A_CHAN1_DONE_INT   (0x00000002)
17562306a36Sopenharmony_ci#define DMA_B_CHAN0_DONE_INT   (0x00000004)
17662306a36Sopenharmony_ci#define DMA_B_CHAN1_DONE_INT   (0x00000008)
17762306a36Sopenharmony_ci#define DMA_C_CHAN0_DONE_INT   (0x00000010)
17862306a36Sopenharmony_ci#define DMA_C_CHAN1_DONE_INT   (0x00000020)
17962306a36Sopenharmony_ci#define DMA_D_CHAN0_DONE_INT   (0x00000040)
18062306a36Sopenharmony_ci#define DMA_D_CHAN1_DONE_INT   (0x00000080)
18162306a36Sopenharmony_ci#define DATA_BUF_OVERFLOW_INT  (0x00000100)
18262306a36Sopenharmony_ci#define UART_0_X_INT           (0x00000200)
18362306a36Sopenharmony_ci#define UART_1_X_INT           (0x00000400)
18462306a36Sopenharmony_ci#define IR_X_INT               (0x00000800)
18562306a36Sopenharmony_ci#define GPIO_0_INT             (0x00001000)
18662306a36Sopenharmony_ci#define GPIO_1_INT             (0x00002000)
18762306a36Sopenharmony_ci#define GPIO_2_INT             (0x00004000)
18862306a36Sopenharmony_ci#define GPIO_3_INT             (0x00008000)
18962306a36Sopenharmony_ci#define ALL_INT                (0x0000FFFF)
19062306a36Sopenharmony_ci
19162306a36Sopenharmony_ci/* software I2C bit mask */
19262306a36Sopenharmony_ci#define SW_I2C_MSK_MODE         0x01
19362306a36Sopenharmony_ci#define SW_I2C_MSK_CLK_OUT      0x02
19462306a36Sopenharmony_ci#define SW_I2C_MSK_DAT_OUT      0x04
19562306a36Sopenharmony_ci#define SW_I2C_MSK_CLK_EN       0x08
19662306a36Sopenharmony_ci#define SW_I2C_MSK_DAT_EN       0x10
19762306a36Sopenharmony_ci#define SW_I2C_MSK_DAT_IN       0x40
19862306a36Sopenharmony_ci#define SW_I2C_MSK_CLK_IN       0x80
19962306a36Sopenharmony_ci
20062306a36Sopenharmony_ci#define SMI_VID		0x1ADE
20162306a36Sopenharmony_ci#define SMI_PID		0x3038
20262306a36Sopenharmony_ci#define SMI_TS_DMA_BUF_SIZE	(1024 * 188)
20362306a36Sopenharmony_ci
20462306a36Sopenharmony_cistruct smi_cfg_info {
20562306a36Sopenharmony_ci#define SMI_DVBSKY_S952         0
20662306a36Sopenharmony_ci#define SMI_DVBSKY_S950         1
20762306a36Sopenharmony_ci#define SMI_DVBSKY_T9580        2
20862306a36Sopenharmony_ci#define SMI_DVBSKY_T982         3
20962306a36Sopenharmony_ci#define SMI_TECHNOTREND_S2_4200 4
21062306a36Sopenharmony_ci	int type;
21162306a36Sopenharmony_ci	char *name;
21262306a36Sopenharmony_ci#define SMI_TS_NULL             0
21362306a36Sopenharmony_ci#define SMI_TS_DMA_SINGLE       1
21462306a36Sopenharmony_ci#define SMI_TS_DMA_BOTH         3
21562306a36Sopenharmony_ci/* SMI_TS_NULL: not use;
21662306a36Sopenharmony_ci * SMI_TS_DMA_SINGLE: use DMA 0 only;
21762306a36Sopenharmony_ci * SMI_TS_DMA_BOTH:use DMA 0 and 1.*/
21862306a36Sopenharmony_ci	int ts_0;
21962306a36Sopenharmony_ci	int ts_1;
22062306a36Sopenharmony_ci#define DVBSKY_FE_NULL          0
22162306a36Sopenharmony_ci#define DVBSKY_FE_M88RS6000     1
22262306a36Sopenharmony_ci#define DVBSKY_FE_M88DS3103     2
22362306a36Sopenharmony_ci#define DVBSKY_FE_SIT2          3
22462306a36Sopenharmony_ci	int fe_0;
22562306a36Sopenharmony_ci	int fe_1;
22662306a36Sopenharmony_ci	char *rc_map;
22762306a36Sopenharmony_ci};
22862306a36Sopenharmony_ci
22962306a36Sopenharmony_cistruct smi_rc {
23062306a36Sopenharmony_ci	struct smi_dev *dev;
23162306a36Sopenharmony_ci	struct rc_dev *rc_dev;
23262306a36Sopenharmony_ci	char input_phys[64];
23362306a36Sopenharmony_ci	char device_name[64];
23462306a36Sopenharmony_ci	u8 irData[256];
23562306a36Sopenharmony_ci
23662306a36Sopenharmony_ci	int users;
23762306a36Sopenharmony_ci};
23862306a36Sopenharmony_ci
23962306a36Sopenharmony_cistruct smi_port {
24062306a36Sopenharmony_ci	struct smi_dev *dev;
24162306a36Sopenharmony_ci	int idx;
24262306a36Sopenharmony_ci	int enable;
24362306a36Sopenharmony_ci	int fe_type;
24462306a36Sopenharmony_ci	/* regs */
24562306a36Sopenharmony_ci	u32 DMA_CHAN0_ADDR_LOW;
24662306a36Sopenharmony_ci	u32 DMA_CHAN0_ADDR_HI;
24762306a36Sopenharmony_ci	u32 DMA_CHAN0_TRANS_STATE;
24862306a36Sopenharmony_ci	u32 DMA_CHAN0_CONTROL;
24962306a36Sopenharmony_ci	u32 DMA_CHAN1_ADDR_LOW;
25062306a36Sopenharmony_ci	u32 DMA_CHAN1_ADDR_HI;
25162306a36Sopenharmony_ci	u32 DMA_CHAN1_TRANS_STATE;
25262306a36Sopenharmony_ci	u32 DMA_CHAN1_CONTROL;
25362306a36Sopenharmony_ci	u32 DMA_MANAGEMENT;
25462306a36Sopenharmony_ci	/* dma */
25562306a36Sopenharmony_ci	dma_addr_t dma_addr[2];
25662306a36Sopenharmony_ci	u8 *cpu_addr[2];
25762306a36Sopenharmony_ci	u32 _dmaInterruptCH0;
25862306a36Sopenharmony_ci	u32 _dmaInterruptCH1;
25962306a36Sopenharmony_ci	u32 _int_status;
26062306a36Sopenharmony_ci	struct tasklet_struct tasklet;
26162306a36Sopenharmony_ci	/* dvb */
26262306a36Sopenharmony_ci	struct dmx_frontend hw_frontend;
26362306a36Sopenharmony_ci	struct dmx_frontend mem_frontend;
26462306a36Sopenharmony_ci	struct dmxdev dmxdev;
26562306a36Sopenharmony_ci	struct dvb_adapter dvb_adapter;
26662306a36Sopenharmony_ci	struct dvb_demux demux;
26762306a36Sopenharmony_ci	struct dvb_net dvbnet;
26862306a36Sopenharmony_ci	int users;
26962306a36Sopenharmony_ci	struct dvb_frontend *fe;
27062306a36Sopenharmony_ci	/* frontend i2c module */
27162306a36Sopenharmony_ci	struct i2c_client *i2c_client_demod;
27262306a36Sopenharmony_ci	struct i2c_client *i2c_client_tuner;
27362306a36Sopenharmony_ci};
27462306a36Sopenharmony_ci
27562306a36Sopenharmony_cistruct smi_dev {
27662306a36Sopenharmony_ci	int nr;
27762306a36Sopenharmony_ci	struct smi_cfg_info *info;
27862306a36Sopenharmony_ci
27962306a36Sopenharmony_ci	/* pcie */
28062306a36Sopenharmony_ci	struct pci_dev *pci_dev;
28162306a36Sopenharmony_ci	u32 __iomem *lmmio;
28262306a36Sopenharmony_ci
28362306a36Sopenharmony_ci	/* ts port */
28462306a36Sopenharmony_ci	struct smi_port ts_port[2];
28562306a36Sopenharmony_ci
28662306a36Sopenharmony_ci	/* i2c */
28762306a36Sopenharmony_ci	struct i2c_adapter i2c_bus[2];
28862306a36Sopenharmony_ci	struct i2c_algo_bit_data i2c_bit[2];
28962306a36Sopenharmony_ci
29062306a36Sopenharmony_ci	/* ir */
29162306a36Sopenharmony_ci	struct smi_rc ir;
29262306a36Sopenharmony_ci};
29362306a36Sopenharmony_ci
29462306a36Sopenharmony_ci#define smi_read(reg)             readl(dev->lmmio + ((reg)>>2))
29562306a36Sopenharmony_ci#define smi_write(reg, value)     writel((value), dev->lmmio + ((reg)>>2))
29662306a36Sopenharmony_ci
29762306a36Sopenharmony_ci#define smi_andor(reg, mask, value) \
29862306a36Sopenharmony_ci	writel((readl(dev->lmmio+((reg)>>2)) & ~(mask)) |\
29962306a36Sopenharmony_ci	((value) & (mask)), dev->lmmio+((reg)>>2))
30062306a36Sopenharmony_ci
30162306a36Sopenharmony_ci#define smi_set(reg, bit)          smi_andor((reg), (bit), (bit))
30262306a36Sopenharmony_ci#define smi_clear(reg, bit)        smi_andor((reg), (bit), 0)
30362306a36Sopenharmony_ci
30462306a36Sopenharmony_ciint smi_ir_irq(struct smi_rc *ir, u32 int_status);
30562306a36Sopenharmony_civoid smi_ir_start(struct smi_rc *ir);
30662306a36Sopenharmony_civoid smi_ir_exit(struct smi_dev *dev);
30762306a36Sopenharmony_ciint smi_ir_init(struct smi_dev *dev);
30862306a36Sopenharmony_ci
30962306a36Sopenharmony_ci#endif /* #ifndef _SMI_PCIE_H_ */
310