18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci Mantis VP-3030 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 "zl10353.h" 208c2ecf20Sopenharmony_ci#include "tda665x.h" 218c2ecf20Sopenharmony_ci#include "mantis_common.h" 228c2ecf20Sopenharmony_ci#include "mantis_ioc.h" 238c2ecf20Sopenharmony_ci#include "mantis_dvb.h" 248c2ecf20Sopenharmony_ci#include "mantis_vp3030.h" 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_cistatic struct zl10353_config mantis_vp3030_config = { 278c2ecf20Sopenharmony_ci .demod_address = 0x0f, 288c2ecf20Sopenharmony_ci}; 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_cistatic struct tda665x_config env57h12d5_config = { 318c2ecf20Sopenharmony_ci .name = "ENV57H12D5 (ET-50DT)", 328c2ecf20Sopenharmony_ci .addr = 0x60, 338c2ecf20Sopenharmony_ci .frequency_min = 47 * MHz, 348c2ecf20Sopenharmony_ci .frequency_max = 862 * MHz, 358c2ecf20Sopenharmony_ci .frequency_offst = 3616667, 368c2ecf20Sopenharmony_ci .ref_multiplier = 6, /* 1/6 MHz */ 378c2ecf20Sopenharmony_ci .ref_divider = 100000, /* 1/6 MHz */ 388c2ecf20Sopenharmony_ci}; 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci#define MANTIS_MODEL_NAME "VP-3030" 418c2ecf20Sopenharmony_ci#define MANTIS_DEV_TYPE "DVB-T" 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_cistatic int vp3030_frontend_init(struct mantis_pci *mantis, struct dvb_frontend *fe) 458c2ecf20Sopenharmony_ci{ 468c2ecf20Sopenharmony_ci struct i2c_adapter *adapter = &mantis->adapter; 478c2ecf20Sopenharmony_ci struct mantis_hwconfig *config = mantis->hwconfig; 488c2ecf20Sopenharmony_ci int err = 0; 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_ci mantis_gpio_set_bits(mantis, config->reset, 0); 518c2ecf20Sopenharmony_ci msleep(100); 528c2ecf20Sopenharmony_ci err = mantis_frontend_power(mantis, POWER_ON); 538c2ecf20Sopenharmony_ci msleep(100); 548c2ecf20Sopenharmony_ci mantis_gpio_set_bits(mantis, config->reset, 1); 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ci if (err == 0) { 578c2ecf20Sopenharmony_ci msleep(250); 588c2ecf20Sopenharmony_ci dprintk(MANTIS_ERROR, 1, "Probing for 10353 (DVB-T)"); 598c2ecf20Sopenharmony_ci fe = dvb_attach(zl10353_attach, &mantis_vp3030_config, adapter); 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_ci if (!fe) 628c2ecf20Sopenharmony_ci return -1; 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ci dvb_attach(tda665x_attach, fe, &env57h12d5_config, adapter); 658c2ecf20Sopenharmony_ci } else { 668c2ecf20Sopenharmony_ci dprintk(MANTIS_ERROR, 1, "Frontend on <%s> POWER ON failed! <%d>", 678c2ecf20Sopenharmony_ci adapter->name, 688c2ecf20Sopenharmony_ci err); 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_ci return -EIO; 718c2ecf20Sopenharmony_ci 728c2ecf20Sopenharmony_ci } 738c2ecf20Sopenharmony_ci mantis->fe = fe; 748c2ecf20Sopenharmony_ci dprintk(MANTIS_ERROR, 1, "Done!"); 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_ci return 0; 778c2ecf20Sopenharmony_ci} 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_cistruct mantis_hwconfig vp3030_config = { 808c2ecf20Sopenharmony_ci .model_name = MANTIS_MODEL_NAME, 818c2ecf20Sopenharmony_ci .dev_type = MANTIS_DEV_TYPE, 828c2ecf20Sopenharmony_ci .ts_size = MANTIS_TS_188, 838c2ecf20Sopenharmony_ci 848c2ecf20Sopenharmony_ci .baud_rate = MANTIS_BAUD_9600, 858c2ecf20Sopenharmony_ci .parity = MANTIS_PARITY_NONE, 868c2ecf20Sopenharmony_ci .bytes = 0, 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_ci .frontend_init = vp3030_frontend_init, 898c2ecf20Sopenharmony_ci .power = GPIF_A12, 908c2ecf20Sopenharmony_ci .reset = GPIF_A13, 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_ci .i2c_mode = MANTIS_BYTE_MODE 938c2ecf20Sopenharmony_ci}; 94