18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci	Mantis VP-1041 driver
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci	Copyright (C) Manu Abraham (abraham.manu@gmail.com)
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci*/
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#include <linux/signal.h>
108c2ecf20Sopenharmony_ci#include <linux/sched.h>
118c2ecf20Sopenharmony_ci#include <linux/interrupt.h>
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci#include <media/dmxdev.h>
148c2ecf20Sopenharmony_ci#include <media/dvbdev.h>
158c2ecf20Sopenharmony_ci#include <media/dvb_demux.h>
168c2ecf20Sopenharmony_ci#include <media/dvb_frontend.h>
178c2ecf20Sopenharmony_ci#include <media/dvb_net.h>
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ci#include "mantis_common.h"
208c2ecf20Sopenharmony_ci#include "mantis_ioc.h"
218c2ecf20Sopenharmony_ci#include "mantis_dvb.h"
228c2ecf20Sopenharmony_ci#include "mantis_vp1041.h"
238c2ecf20Sopenharmony_ci#include "stb0899_reg.h"
248c2ecf20Sopenharmony_ci#include "stb0899_drv.h"
258c2ecf20Sopenharmony_ci#include "stb0899_cfg.h"
268c2ecf20Sopenharmony_ci#include "stb6100_cfg.h"
278c2ecf20Sopenharmony_ci#include "stb6100.h"
288c2ecf20Sopenharmony_ci#include "lnbp21.h"
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci#define MANTIS_MODEL_NAME	"VP-1041"
318c2ecf20Sopenharmony_ci#define MANTIS_DEV_TYPE		"DSS/DVB-S/DVB-S2"
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_cistatic const struct stb0899_s1_reg vp1041_stb0899_s1_init_1[] = {
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ci	/* 0x0000000b, *//* SYSREG */
368c2ecf20Sopenharmony_ci	{ STB0899_DEV_ID		, 0x30 },
378c2ecf20Sopenharmony_ci	{ STB0899_DISCNTRL1		, 0x32 },
388c2ecf20Sopenharmony_ci	{ STB0899_DISCNTRL2		, 0x80 },
398c2ecf20Sopenharmony_ci	{ STB0899_DISRX_ST0		, 0x04 },
408c2ecf20Sopenharmony_ci	{ STB0899_DISRX_ST1		, 0x00 },
418c2ecf20Sopenharmony_ci	{ STB0899_DISPARITY		, 0x00 },
428c2ecf20Sopenharmony_ci	{ STB0899_DISSTATUS		, 0x20 },
438c2ecf20Sopenharmony_ci	{ STB0899_DISF22		, 0x99 },
448c2ecf20Sopenharmony_ci	{ STB0899_DISF22RX		, 0xa8 },
458c2ecf20Sopenharmony_ci	/* SYSREG ? */
468c2ecf20Sopenharmony_ci	{ STB0899_ACRPRESC		, 0x11 },
478c2ecf20Sopenharmony_ci	{ STB0899_ACRDIV1		, 0x0a },
488c2ecf20Sopenharmony_ci	{ STB0899_ACRDIV2		, 0x05 },
498c2ecf20Sopenharmony_ci	{ STB0899_DACR1			, 0x00 },
508c2ecf20Sopenharmony_ci	{ STB0899_DACR2			, 0x00 },
518c2ecf20Sopenharmony_ci	{ STB0899_OUTCFG		, 0x00 },
528c2ecf20Sopenharmony_ci	{ STB0899_MODECFG		, 0x00 },
538c2ecf20Sopenharmony_ci	{ STB0899_IRQSTATUS_3		, 0xfe },
548c2ecf20Sopenharmony_ci	{ STB0899_IRQSTATUS_2		, 0x03 },
558c2ecf20Sopenharmony_ci	{ STB0899_IRQSTATUS_1		, 0x7c },
568c2ecf20Sopenharmony_ci	{ STB0899_IRQSTATUS_0		, 0xf4 },
578c2ecf20Sopenharmony_ci	{ STB0899_IRQMSK_3		, 0xf3 },
588c2ecf20Sopenharmony_ci	{ STB0899_IRQMSK_2		, 0xfc },
598c2ecf20Sopenharmony_ci	{ STB0899_IRQMSK_1		, 0xff },
608c2ecf20Sopenharmony_ci	{ STB0899_IRQMSK_0		, 0xff },
618c2ecf20Sopenharmony_ci	{ STB0899_IRQCFG		, 0x00 },
628c2ecf20Sopenharmony_ci	{ STB0899_I2CCFG		, 0x88 },
638c2ecf20Sopenharmony_ci	{ STB0899_I2CRPT		, 0x58 },
648c2ecf20Sopenharmony_ci	{ STB0899_IOPVALUE5		, 0x00 },
658c2ecf20Sopenharmony_ci	{ STB0899_IOPVALUE4		, 0x33 },
668c2ecf20Sopenharmony_ci	{ STB0899_IOPVALUE3		, 0x6d },
678c2ecf20Sopenharmony_ci	{ STB0899_IOPVALUE2		, 0x90 },
688c2ecf20Sopenharmony_ci	{ STB0899_IOPVALUE1		, 0x60 },
698c2ecf20Sopenharmony_ci	{ STB0899_IOPVALUE0		, 0x00 },
708c2ecf20Sopenharmony_ci	{ STB0899_GPIO00CFG		, 0x82 },
718c2ecf20Sopenharmony_ci	{ STB0899_GPIO01CFG		, 0x82 },
728c2ecf20Sopenharmony_ci	{ STB0899_GPIO02CFG		, 0x82 },
738c2ecf20Sopenharmony_ci	{ STB0899_GPIO03CFG		, 0x82 },
748c2ecf20Sopenharmony_ci	{ STB0899_GPIO04CFG		, 0x82 },
758c2ecf20Sopenharmony_ci	{ STB0899_GPIO05CFG		, 0x82 },
768c2ecf20Sopenharmony_ci	{ STB0899_GPIO06CFG		, 0x82 },
778c2ecf20Sopenharmony_ci	{ STB0899_GPIO07CFG		, 0x82 },
788c2ecf20Sopenharmony_ci	{ STB0899_GPIO08CFG		, 0x82 },
798c2ecf20Sopenharmony_ci	{ STB0899_GPIO09CFG		, 0x82 },
808c2ecf20Sopenharmony_ci	{ STB0899_GPIO10CFG		, 0x82 },
818c2ecf20Sopenharmony_ci	{ STB0899_GPIO11CFG		, 0x82 },
828c2ecf20Sopenharmony_ci	{ STB0899_GPIO12CFG		, 0x82 },
838c2ecf20Sopenharmony_ci	{ STB0899_GPIO13CFG		, 0x82 },
848c2ecf20Sopenharmony_ci	{ STB0899_GPIO14CFG		, 0x82 },
858c2ecf20Sopenharmony_ci	{ STB0899_GPIO15CFG		, 0x82 },
868c2ecf20Sopenharmony_ci	{ STB0899_GPIO16CFG		, 0x82 },
878c2ecf20Sopenharmony_ci	{ STB0899_GPIO17CFG		, 0x82 },
888c2ecf20Sopenharmony_ci	{ STB0899_GPIO18CFG		, 0x82 },
898c2ecf20Sopenharmony_ci	{ STB0899_GPIO19CFG		, 0x82 },
908c2ecf20Sopenharmony_ci	{ STB0899_GPIO20CFG		, 0x82 },
918c2ecf20Sopenharmony_ci	{ STB0899_SDATCFG		, 0xb8 },
928c2ecf20Sopenharmony_ci	{ STB0899_SCLTCFG		, 0xba },
938c2ecf20Sopenharmony_ci	{ STB0899_AGCRFCFG		, 0x1c }, /* 0x11 */
948c2ecf20Sopenharmony_ci	{ STB0899_GPIO22		, 0x82 }, /* AGCBB2CFG */
958c2ecf20Sopenharmony_ci	{ STB0899_GPIO21		, 0x91 }, /* AGCBB1CFG */
968c2ecf20Sopenharmony_ci	{ STB0899_DIRCLKCFG		, 0x82 },
978c2ecf20Sopenharmony_ci	{ STB0899_CLKOUT27CFG		, 0x7e },
988c2ecf20Sopenharmony_ci	{ STB0899_STDBYCFG		, 0x82 },
998c2ecf20Sopenharmony_ci	{ STB0899_CS0CFG		, 0x82 },
1008c2ecf20Sopenharmony_ci	{ STB0899_CS1CFG		, 0x82 },
1018c2ecf20Sopenharmony_ci	{ STB0899_DISEQCOCFG		, 0x20 },
1028c2ecf20Sopenharmony_ci	{ STB0899_GPIO32CFG		, 0x82 },
1038c2ecf20Sopenharmony_ci	{ STB0899_GPIO33CFG		, 0x82 },
1048c2ecf20Sopenharmony_ci	{ STB0899_GPIO34CFG		, 0x82 },
1058c2ecf20Sopenharmony_ci	{ STB0899_GPIO35CFG		, 0x82 },
1068c2ecf20Sopenharmony_ci	{ STB0899_GPIO36CFG		, 0x82 },
1078c2ecf20Sopenharmony_ci	{ STB0899_GPIO37CFG		, 0x82 },
1088c2ecf20Sopenharmony_ci	{ STB0899_GPIO38CFG		, 0x82 },
1098c2ecf20Sopenharmony_ci	{ STB0899_GPIO39CFG		, 0x82 },
1108c2ecf20Sopenharmony_ci	{ STB0899_NCOARSE		, 0x17 }, /* 0x15 = 27 Mhz Clock, F/3 = 198MHz, F/6 = 99MHz */
1118c2ecf20Sopenharmony_ci	{ STB0899_SYNTCTRL		, 0x02 }, /* 0x00 = CLK from CLKI, 0x02 = CLK from XTALI */
1128c2ecf20Sopenharmony_ci	{ STB0899_FILTCTRL		, 0x00 },
1138c2ecf20Sopenharmony_ci	{ STB0899_SYSCTRL		, 0x01 },
1148c2ecf20Sopenharmony_ci	{ STB0899_STOPCLK1		, 0x20 },
1158c2ecf20Sopenharmony_ci	{ STB0899_STOPCLK2		, 0x00 },
1168c2ecf20Sopenharmony_ci	{ STB0899_INTBUFSTATUS		, 0x00 },
1178c2ecf20Sopenharmony_ci	{ STB0899_INTBUFCTRL		, 0x0a },
1188c2ecf20Sopenharmony_ci	{ 0xffff			, 0xff },
1198c2ecf20Sopenharmony_ci};
1208c2ecf20Sopenharmony_ci
1218c2ecf20Sopenharmony_cistatic const struct stb0899_s1_reg vp1041_stb0899_s1_init_3[] = {
1228c2ecf20Sopenharmony_ci	{ STB0899_DEMOD			, 0x00 },
1238c2ecf20Sopenharmony_ci	{ STB0899_RCOMPC		, 0xc9 },
1248c2ecf20Sopenharmony_ci	{ STB0899_AGC1CN		, 0x01 },
1258c2ecf20Sopenharmony_ci	{ STB0899_AGC1REF		, 0x10 },
1268c2ecf20Sopenharmony_ci	{ STB0899_RTC			, 0x23 },
1278c2ecf20Sopenharmony_ci	{ STB0899_TMGCFG		, 0x4e },
1288c2ecf20Sopenharmony_ci	{ STB0899_AGC2REF		, 0x34 },
1298c2ecf20Sopenharmony_ci	{ STB0899_TLSR			, 0x84 },
1308c2ecf20Sopenharmony_ci	{ STB0899_CFD			, 0xf7 },
1318c2ecf20Sopenharmony_ci	{ STB0899_ACLC			, 0x87 },
1328c2ecf20Sopenharmony_ci	{ STB0899_BCLC			, 0x94 },
1338c2ecf20Sopenharmony_ci	{ STB0899_EQON			, 0x41 },
1348c2ecf20Sopenharmony_ci	{ STB0899_LDT			, 0xf1 },
1358c2ecf20Sopenharmony_ci	{ STB0899_LDT2			, 0xe3 },
1368c2ecf20Sopenharmony_ci	{ STB0899_EQUALREF		, 0xb4 },
1378c2ecf20Sopenharmony_ci	{ STB0899_TMGRAMP		, 0x10 },
1388c2ecf20Sopenharmony_ci	{ STB0899_TMGTHD		, 0x30 },
1398c2ecf20Sopenharmony_ci	{ STB0899_IDCCOMP		, 0xfd },
1408c2ecf20Sopenharmony_ci	{ STB0899_QDCCOMP		, 0xff },
1418c2ecf20Sopenharmony_ci	{ STB0899_POWERI		, 0x0c },
1428c2ecf20Sopenharmony_ci	{ STB0899_POWERQ		, 0x0f },
1438c2ecf20Sopenharmony_ci	{ STB0899_RCOMP			, 0x6c },
1448c2ecf20Sopenharmony_ci	{ STB0899_AGCIQIN		, 0x80 },
1458c2ecf20Sopenharmony_ci	{ STB0899_AGC2I1		, 0x06 },
1468c2ecf20Sopenharmony_ci	{ STB0899_AGC2I2		, 0x00 },
1478c2ecf20Sopenharmony_ci	{ STB0899_TLIR			, 0x30 },
1488c2ecf20Sopenharmony_ci	{ STB0899_RTF			, 0x7f },
1498c2ecf20Sopenharmony_ci	{ STB0899_DSTATUS		, 0x00 },
1508c2ecf20Sopenharmony_ci	{ STB0899_LDI			, 0xbc },
1518c2ecf20Sopenharmony_ci	{ STB0899_CFRM			, 0xea },
1528c2ecf20Sopenharmony_ci	{ STB0899_CFRL			, 0x31 },
1538c2ecf20Sopenharmony_ci	{ STB0899_NIRM			, 0x2b },
1548c2ecf20Sopenharmony_ci	{ STB0899_NIRL			, 0x80 },
1558c2ecf20Sopenharmony_ci	{ STB0899_ISYMB			, 0x1d },
1568c2ecf20Sopenharmony_ci	{ STB0899_QSYMB			, 0xa6 },
1578c2ecf20Sopenharmony_ci	{ STB0899_SFRH			, 0x2f },
1588c2ecf20Sopenharmony_ci	{ STB0899_SFRM			, 0x68 },
1598c2ecf20Sopenharmony_ci	{ STB0899_SFRL			, 0x40 },
1608c2ecf20Sopenharmony_ci	{ STB0899_SFRUPH		, 0x2f },
1618c2ecf20Sopenharmony_ci	{ STB0899_SFRUPM		, 0x68 },
1628c2ecf20Sopenharmony_ci	{ STB0899_SFRUPL		, 0x40 },
1638c2ecf20Sopenharmony_ci	{ STB0899_EQUAI1		, 0x02 },
1648c2ecf20Sopenharmony_ci	{ STB0899_EQUAQ1		, 0xff },
1658c2ecf20Sopenharmony_ci	{ STB0899_EQUAI2		, 0x04 },
1668c2ecf20Sopenharmony_ci	{ STB0899_EQUAQ2		, 0x05 },
1678c2ecf20Sopenharmony_ci	{ STB0899_EQUAI3		, 0x02 },
1688c2ecf20Sopenharmony_ci	{ STB0899_EQUAQ3		, 0xfd },
1698c2ecf20Sopenharmony_ci	{ STB0899_EQUAI4		, 0x03 },
1708c2ecf20Sopenharmony_ci	{ STB0899_EQUAQ4		, 0x07 },
1718c2ecf20Sopenharmony_ci	{ STB0899_EQUAI5		, 0x08 },
1728c2ecf20Sopenharmony_ci	{ STB0899_EQUAQ5		, 0xf5 },
1738c2ecf20Sopenharmony_ci	{ STB0899_DSTATUS2		, 0x00 },
1748c2ecf20Sopenharmony_ci	{ STB0899_VSTATUS		, 0x00 },
1758c2ecf20Sopenharmony_ci	{ STB0899_VERROR		, 0x86 },
1768c2ecf20Sopenharmony_ci	{ STB0899_IQSWAP		, 0x2a },
1778c2ecf20Sopenharmony_ci	{ STB0899_ECNT1M		, 0x00 },
1788c2ecf20Sopenharmony_ci	{ STB0899_ECNT1L		, 0x00 },
1798c2ecf20Sopenharmony_ci	{ STB0899_ECNT2M		, 0x00 },
1808c2ecf20Sopenharmony_ci	{ STB0899_ECNT2L		, 0x00 },
1818c2ecf20Sopenharmony_ci	{ STB0899_ECNT3M		, 0x0a },
1828c2ecf20Sopenharmony_ci	{ STB0899_ECNT3L		, 0xad },
1838c2ecf20Sopenharmony_ci	{ STB0899_FECAUTO1		, 0x06 },
1848c2ecf20Sopenharmony_ci	{ STB0899_FECM			, 0x01 },
1858c2ecf20Sopenharmony_ci	{ STB0899_VTH12			, 0xb0 },
1868c2ecf20Sopenharmony_ci	{ STB0899_VTH23			, 0x7a },
1878c2ecf20Sopenharmony_ci	{ STB0899_VTH34			, 0x58 },
1888c2ecf20Sopenharmony_ci	{ STB0899_VTH56			, 0x38 },
1898c2ecf20Sopenharmony_ci	{ STB0899_VTH67			, 0x34 },
1908c2ecf20Sopenharmony_ci	{ STB0899_VTH78			, 0x24 },
1918c2ecf20Sopenharmony_ci	{ STB0899_PRVIT			, 0xff },
1928c2ecf20Sopenharmony_ci	{ STB0899_VITSYNC		, 0x19 },
1938c2ecf20Sopenharmony_ci	{ STB0899_RSULC			, 0xb1 }, /* DVB = 0xb1, DSS = 0xa1 */
1948c2ecf20Sopenharmony_ci	{ STB0899_TSULC			, 0x42 },
1958c2ecf20Sopenharmony_ci	{ STB0899_RSLLC			, 0x41 },
1968c2ecf20Sopenharmony_ci	{ STB0899_TSLPL			, 0x12 },
1978c2ecf20Sopenharmony_ci	{ STB0899_TSCFGH		, 0x0c },
1988c2ecf20Sopenharmony_ci	{ STB0899_TSCFGM		, 0x00 },
1998c2ecf20Sopenharmony_ci	{ STB0899_TSCFGL		, 0x00 },
2008c2ecf20Sopenharmony_ci	{ STB0899_TSOUT			, 0x69 }, /* 0x0d for CAM */
2018c2ecf20Sopenharmony_ci	{ STB0899_RSSYNCDEL		, 0x00 },
2028c2ecf20Sopenharmony_ci	{ STB0899_TSINHDELH		, 0x02 },
2038c2ecf20Sopenharmony_ci	{ STB0899_TSINHDELM		, 0x00 },
2048c2ecf20Sopenharmony_ci	{ STB0899_TSINHDELL		, 0x00 },
2058c2ecf20Sopenharmony_ci	{ STB0899_TSLLSTKM		, 0x1b },
2068c2ecf20Sopenharmony_ci	{ STB0899_TSLLSTKL		, 0xb3 },
2078c2ecf20Sopenharmony_ci	{ STB0899_TSULSTKM		, 0x00 },
2088c2ecf20Sopenharmony_ci	{ STB0899_TSULSTKL		, 0x00 },
2098c2ecf20Sopenharmony_ci	{ STB0899_PCKLENUL		, 0xbc },
2108c2ecf20Sopenharmony_ci	{ STB0899_PCKLENLL		, 0xcc },
2118c2ecf20Sopenharmony_ci	{ STB0899_RSPCKLEN		, 0xbd },
2128c2ecf20Sopenharmony_ci	{ STB0899_TSSTATUS		, 0x90 },
2138c2ecf20Sopenharmony_ci	{ STB0899_ERRCTRL1		, 0xb6 },
2148c2ecf20Sopenharmony_ci	{ STB0899_ERRCTRL2		, 0x95 },
2158c2ecf20Sopenharmony_ci	{ STB0899_ERRCTRL3		, 0x8d },
2168c2ecf20Sopenharmony_ci	{ STB0899_DMONMSK1		, 0x27 },
2178c2ecf20Sopenharmony_ci	{ STB0899_DMONMSK0		, 0x03 },
2188c2ecf20Sopenharmony_ci	{ STB0899_DEMAPVIT		, 0x5c },
2198c2ecf20Sopenharmony_ci	{ STB0899_PLPARM		, 0x19 },
2208c2ecf20Sopenharmony_ci	{ STB0899_PDELCTRL		, 0x48 },
2218c2ecf20Sopenharmony_ci	{ STB0899_PDELCTRL2		, 0x00 },
2228c2ecf20Sopenharmony_ci	{ STB0899_BBHCTRL1		, 0x00 },
2238c2ecf20Sopenharmony_ci	{ STB0899_BBHCTRL2		, 0x00 },
2248c2ecf20Sopenharmony_ci	{ STB0899_HYSTTHRESH		, 0x77 },
2258c2ecf20Sopenharmony_ci	{ STB0899_MATCSTM		, 0x00 },
2268c2ecf20Sopenharmony_ci	{ STB0899_MATCSTL		, 0x00 },
2278c2ecf20Sopenharmony_ci	{ STB0899_UPLCSTM		, 0x00 },
2288c2ecf20Sopenharmony_ci	{ STB0899_UPLCSTL		, 0x00 },
2298c2ecf20Sopenharmony_ci	{ STB0899_DFLCSTM		, 0x00 },
2308c2ecf20Sopenharmony_ci	{ STB0899_DFLCSTL		, 0x00 },
2318c2ecf20Sopenharmony_ci	{ STB0899_SYNCCST		, 0x00 },
2328c2ecf20Sopenharmony_ci	{ STB0899_SYNCDCSTM		, 0x00 },
2338c2ecf20Sopenharmony_ci	{ STB0899_SYNCDCSTL		, 0x00 },
2348c2ecf20Sopenharmony_ci	{ STB0899_ISI_ENTRY		, 0x00 },
2358c2ecf20Sopenharmony_ci	{ STB0899_ISI_BIT_EN		, 0x00 },
2368c2ecf20Sopenharmony_ci	{ STB0899_MATSTRM		, 0xf0 },
2378c2ecf20Sopenharmony_ci	{ STB0899_MATSTRL		, 0x02 },
2388c2ecf20Sopenharmony_ci	{ STB0899_UPLSTRM		, 0x45 },
2398c2ecf20Sopenharmony_ci	{ STB0899_UPLSTRL		, 0x60 },
2408c2ecf20Sopenharmony_ci	{ STB0899_DFLSTRM		, 0xe3 },
2418c2ecf20Sopenharmony_ci	{ STB0899_DFLSTRL		, 0x00 },
2428c2ecf20Sopenharmony_ci	{ STB0899_SYNCSTR		, 0x47 },
2438c2ecf20Sopenharmony_ci	{ STB0899_SYNCDSTRM		, 0x05 },
2448c2ecf20Sopenharmony_ci	{ STB0899_SYNCDSTRL		, 0x18 },
2458c2ecf20Sopenharmony_ci	{ STB0899_CFGPDELSTATUS1	, 0x19 },
2468c2ecf20Sopenharmony_ci	{ STB0899_CFGPDELSTATUS2	, 0x2b },
2478c2ecf20Sopenharmony_ci	{ STB0899_BBFERRORM		, 0x00 },
2488c2ecf20Sopenharmony_ci	{ STB0899_BBFERRORL		, 0x01 },
2498c2ecf20Sopenharmony_ci	{ STB0899_UPKTERRORM		, 0x00 },
2508c2ecf20Sopenharmony_ci	{ STB0899_UPKTERRORL		, 0x00 },
2518c2ecf20Sopenharmony_ci	{ 0xffff			, 0xff },
2528c2ecf20Sopenharmony_ci};
2538c2ecf20Sopenharmony_ci
2548c2ecf20Sopenharmony_cistatic struct stb0899_config vp1041_stb0899_config = {
2558c2ecf20Sopenharmony_ci	.init_dev		= vp1041_stb0899_s1_init_1,
2568c2ecf20Sopenharmony_ci	.init_s2_demod		= stb0899_s2_init_2,
2578c2ecf20Sopenharmony_ci	.init_s1_demod		= vp1041_stb0899_s1_init_3,
2588c2ecf20Sopenharmony_ci	.init_s2_fec		= stb0899_s2_init_4,
2598c2ecf20Sopenharmony_ci	.init_tst		= stb0899_s1_init_5,
2608c2ecf20Sopenharmony_ci
2618c2ecf20Sopenharmony_ci	.demod_address		= 0x68, /*  0xd0 >> 1 */
2628c2ecf20Sopenharmony_ci
2638c2ecf20Sopenharmony_ci	.xtal_freq		= 27000000,
2648c2ecf20Sopenharmony_ci	.inversion		= IQ_SWAP_ON,
2658c2ecf20Sopenharmony_ci
2668c2ecf20Sopenharmony_ci	.lo_clk			= 76500000,
2678c2ecf20Sopenharmony_ci	.hi_clk			= 99000000,
2688c2ecf20Sopenharmony_ci
2698c2ecf20Sopenharmony_ci	.esno_ave		= STB0899_DVBS2_ESNO_AVE,
2708c2ecf20Sopenharmony_ci	.esno_quant		= STB0899_DVBS2_ESNO_QUANT,
2718c2ecf20Sopenharmony_ci	.avframes_coarse	= STB0899_DVBS2_AVFRAMES_COARSE,
2728c2ecf20Sopenharmony_ci	.avframes_fine		= STB0899_DVBS2_AVFRAMES_FINE,
2738c2ecf20Sopenharmony_ci	.miss_threshold		= STB0899_DVBS2_MISS_THRESHOLD,
2748c2ecf20Sopenharmony_ci	.uwp_threshold_acq	= STB0899_DVBS2_UWP_THRESHOLD_ACQ,
2758c2ecf20Sopenharmony_ci	.uwp_threshold_track	= STB0899_DVBS2_UWP_THRESHOLD_TRACK,
2768c2ecf20Sopenharmony_ci	.uwp_threshold_sof	= STB0899_DVBS2_UWP_THRESHOLD_SOF,
2778c2ecf20Sopenharmony_ci	.sof_search_timeout	= STB0899_DVBS2_SOF_SEARCH_TIMEOUT,
2788c2ecf20Sopenharmony_ci
2798c2ecf20Sopenharmony_ci	.btr_nco_bits		= STB0899_DVBS2_BTR_NCO_BITS,
2808c2ecf20Sopenharmony_ci	.btr_gain_shift_offset	= STB0899_DVBS2_BTR_GAIN_SHIFT_OFFSET,
2818c2ecf20Sopenharmony_ci	.crl_nco_bits		= STB0899_DVBS2_CRL_NCO_BITS,
2828c2ecf20Sopenharmony_ci	.ldpc_max_iter		= STB0899_DVBS2_LDPC_MAX_ITER,
2838c2ecf20Sopenharmony_ci
2848c2ecf20Sopenharmony_ci	.tuner_get_frequency	= stb6100_get_frequency,
2858c2ecf20Sopenharmony_ci	.tuner_set_frequency	= stb6100_set_frequency,
2868c2ecf20Sopenharmony_ci	.tuner_set_bandwidth	= stb6100_set_bandwidth,
2878c2ecf20Sopenharmony_ci	.tuner_get_bandwidth	= stb6100_get_bandwidth,
2888c2ecf20Sopenharmony_ci	.tuner_set_rfsiggain	= NULL,
2898c2ecf20Sopenharmony_ci};
2908c2ecf20Sopenharmony_ci
2918c2ecf20Sopenharmony_cistatic struct stb6100_config vp1041_stb6100_config = {
2928c2ecf20Sopenharmony_ci	.tuner_address	= 0x60,
2938c2ecf20Sopenharmony_ci	.refclock	= 27000000,
2948c2ecf20Sopenharmony_ci};
2958c2ecf20Sopenharmony_ci
2968c2ecf20Sopenharmony_cistatic int vp1041_frontend_init(struct mantis_pci *mantis, struct dvb_frontend *fe)
2978c2ecf20Sopenharmony_ci{
2988c2ecf20Sopenharmony_ci	struct i2c_adapter *adapter	= &mantis->adapter;
2998c2ecf20Sopenharmony_ci
3008c2ecf20Sopenharmony_ci	int err = 0;
3018c2ecf20Sopenharmony_ci
3028c2ecf20Sopenharmony_ci	err = mantis_frontend_power(mantis, POWER_ON);
3038c2ecf20Sopenharmony_ci	if (err == 0) {
3048c2ecf20Sopenharmony_ci		mantis_frontend_soft_reset(mantis);
3058c2ecf20Sopenharmony_ci		msleep(250);
3068c2ecf20Sopenharmony_ci		mantis->fe = dvb_attach(stb0899_attach, &vp1041_stb0899_config, adapter);
3078c2ecf20Sopenharmony_ci		if (mantis->fe) {
3088c2ecf20Sopenharmony_ci			dprintk(MANTIS_ERROR, 1,
3098c2ecf20Sopenharmony_ci				"found STB0899 DVB-S/DVB-S2 frontend @0x%02x",
3108c2ecf20Sopenharmony_ci				vp1041_stb0899_config.demod_address);
3118c2ecf20Sopenharmony_ci
3128c2ecf20Sopenharmony_ci			if (dvb_attach(stb6100_attach, mantis->fe, &vp1041_stb6100_config, adapter)) {
3138c2ecf20Sopenharmony_ci				if (!dvb_attach(lnbp21_attach, mantis->fe, adapter, 0, 0))
3148c2ecf20Sopenharmony_ci					dprintk(MANTIS_ERROR, 1, "No LNBP21 found!");
3158c2ecf20Sopenharmony_ci			}
3168c2ecf20Sopenharmony_ci		} else {
3178c2ecf20Sopenharmony_ci			return -EREMOTEIO;
3188c2ecf20Sopenharmony_ci		}
3198c2ecf20Sopenharmony_ci	} else {
3208c2ecf20Sopenharmony_ci		dprintk(MANTIS_ERROR, 1, "Frontend on <%s> POWER ON failed! <%d>",
3218c2ecf20Sopenharmony_ci			adapter->name,
3228c2ecf20Sopenharmony_ci			err);
3238c2ecf20Sopenharmony_ci
3248c2ecf20Sopenharmony_ci		return -EIO;
3258c2ecf20Sopenharmony_ci	}
3268c2ecf20Sopenharmony_ci
3278c2ecf20Sopenharmony_ci
3288c2ecf20Sopenharmony_ci	dprintk(MANTIS_ERROR, 1, "Done!");
3298c2ecf20Sopenharmony_ci
3308c2ecf20Sopenharmony_ci	return 0;
3318c2ecf20Sopenharmony_ci}
3328c2ecf20Sopenharmony_ci
3338c2ecf20Sopenharmony_cistruct mantis_hwconfig vp1041_config = {
3348c2ecf20Sopenharmony_ci	.model_name	= MANTIS_MODEL_NAME,
3358c2ecf20Sopenharmony_ci	.dev_type	= MANTIS_DEV_TYPE,
3368c2ecf20Sopenharmony_ci	.ts_size	= MANTIS_TS_188,
3378c2ecf20Sopenharmony_ci
3388c2ecf20Sopenharmony_ci	.baud_rate	= MANTIS_BAUD_9600,
3398c2ecf20Sopenharmony_ci	.parity		= MANTIS_PARITY_NONE,
3408c2ecf20Sopenharmony_ci	.bytes		= 0,
3418c2ecf20Sopenharmony_ci
3428c2ecf20Sopenharmony_ci	.frontend_init	= vp1041_frontend_init,
3438c2ecf20Sopenharmony_ci	.power		= GPIF_A12,
3448c2ecf20Sopenharmony_ci	.reset		= GPIF_A13,
3458c2ecf20Sopenharmony_ci};
346