xref: /linux/drivers/media/pci/mantis/hopper_vp3028.c (revision fada1935590f66dc6784981e0d557ca09013c847)
125aee3deSMauro Carvalho Chehab /*
225aee3deSMauro Carvalho Chehab 	Hopper VP-3028 driver
325aee3deSMauro Carvalho Chehab 
425aee3deSMauro Carvalho Chehab 	Copyright (C) Manu Abraham (abraham.manu@gmail.com)
525aee3deSMauro Carvalho Chehab 
625aee3deSMauro Carvalho Chehab 	This program is free software; you can redistribute it and/or modify
725aee3deSMauro Carvalho Chehab 	it under the terms of the GNU General Public License as published by
825aee3deSMauro Carvalho Chehab 	the Free Software Foundation; either version 2 of the License, or
925aee3deSMauro Carvalho Chehab 	(at your option) any later version.
1025aee3deSMauro Carvalho Chehab 
1125aee3deSMauro Carvalho Chehab 	This program is distributed in the hope that it will be useful,
1225aee3deSMauro Carvalho Chehab 	but WITHOUT ANY WARRANTY; without even the implied warranty of
1325aee3deSMauro Carvalho Chehab 	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1425aee3deSMauro Carvalho Chehab 	GNU General Public License for more details.
1525aee3deSMauro Carvalho Chehab 
1625aee3deSMauro Carvalho Chehab 	You should have received a copy of the GNU General Public License
1725aee3deSMauro Carvalho Chehab 	along with this program; if not, write to the Free Software
1825aee3deSMauro Carvalho Chehab 	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
1925aee3deSMauro Carvalho Chehab */
2025aee3deSMauro Carvalho Chehab 
2125aee3deSMauro Carvalho Chehab #include <linux/signal.h>
2225aee3deSMauro Carvalho Chehab #include <linux/sched.h>
2325aee3deSMauro Carvalho Chehab #include <linux/interrupt.h>
2425aee3deSMauro Carvalho Chehab 
25*fada1935SMauro Carvalho Chehab #include <media/dmxdev.h>
26*fada1935SMauro Carvalho Chehab #include <media/dvbdev.h>
27*fada1935SMauro Carvalho Chehab #include <media/dvb_demux.h>
28*fada1935SMauro Carvalho Chehab #include <media/dvb_frontend.h>
29*fada1935SMauro Carvalho Chehab #include <media/dvb_net.h>
3025aee3deSMauro Carvalho Chehab 
3125aee3deSMauro Carvalho Chehab #include "zl10353.h"
3225aee3deSMauro Carvalho Chehab #include "mantis_common.h"
3325aee3deSMauro Carvalho Chehab #include "mantis_ioc.h"
3425aee3deSMauro Carvalho Chehab #include "mantis_dvb.h"
3525aee3deSMauro Carvalho Chehab #include "hopper_vp3028.h"
3625aee3deSMauro Carvalho Chehab 
37967a3783SHans Verkuil static struct zl10353_config hopper_vp3028_config = {
3825aee3deSMauro Carvalho Chehab 	.demod_address	= 0x0f,
3925aee3deSMauro Carvalho Chehab };
4025aee3deSMauro Carvalho Chehab 
4125aee3deSMauro Carvalho Chehab #define MANTIS_MODEL_NAME	"VP-3028"
4225aee3deSMauro Carvalho Chehab #define MANTIS_DEV_TYPE		"DVB-T"
4325aee3deSMauro Carvalho Chehab 
4425aee3deSMauro Carvalho Chehab static int vp3028_frontend_init(struct mantis_pci *mantis, struct dvb_frontend *fe)
4525aee3deSMauro Carvalho Chehab {
4625aee3deSMauro Carvalho Chehab 	struct i2c_adapter *adapter	= &mantis->adapter;
4725aee3deSMauro Carvalho Chehab 	struct mantis_hwconfig *config	= mantis->hwconfig;
4825aee3deSMauro Carvalho Chehab 	int err = 0;
4925aee3deSMauro Carvalho Chehab 
5025aee3deSMauro Carvalho Chehab 	mantis_gpio_set_bits(mantis, config->reset, 0);
5125aee3deSMauro Carvalho Chehab 	msleep(100);
5225aee3deSMauro Carvalho Chehab 	err = mantis_frontend_power(mantis, POWER_ON);
5325aee3deSMauro Carvalho Chehab 	msleep(100);
5425aee3deSMauro Carvalho Chehab 	mantis_gpio_set_bits(mantis, config->reset, 1);
5525aee3deSMauro Carvalho Chehab 
5625aee3deSMauro Carvalho Chehab 	err = mantis_frontend_power(mantis, POWER_ON);
5725aee3deSMauro Carvalho Chehab 	if (err == 0) {
5825aee3deSMauro Carvalho Chehab 		msleep(250);
5925aee3deSMauro Carvalho Chehab 		dprintk(MANTIS_ERROR, 1, "Probing for 10353 (DVB-T)");
6025aee3deSMauro Carvalho Chehab 		fe = dvb_attach(zl10353_attach, &hopper_vp3028_config, adapter);
6125aee3deSMauro Carvalho Chehab 
6225aee3deSMauro Carvalho Chehab 		if (!fe)
6325aee3deSMauro Carvalho Chehab 			return -1;
6425aee3deSMauro Carvalho Chehab 	} else {
6525aee3deSMauro Carvalho Chehab 		dprintk(MANTIS_ERROR, 1, "Frontend on <%s> POWER ON failed! <%d>",
6625aee3deSMauro Carvalho Chehab 			adapter->name,
6725aee3deSMauro Carvalho Chehab 			err);
6825aee3deSMauro Carvalho Chehab 
6925aee3deSMauro Carvalho Chehab 		return -EIO;
7025aee3deSMauro Carvalho Chehab 	}
7125aee3deSMauro Carvalho Chehab 	dprintk(MANTIS_ERROR, 1, "Done!");
7225aee3deSMauro Carvalho Chehab 
7325aee3deSMauro Carvalho Chehab 	return 0;
7425aee3deSMauro Carvalho Chehab }
7525aee3deSMauro Carvalho Chehab 
7625aee3deSMauro Carvalho Chehab struct mantis_hwconfig vp3028_config = {
7725aee3deSMauro Carvalho Chehab 	.model_name	= MANTIS_MODEL_NAME,
7825aee3deSMauro Carvalho Chehab 	.dev_type	= MANTIS_DEV_TYPE,
7925aee3deSMauro Carvalho Chehab 	.ts_size	= MANTIS_TS_188,
8025aee3deSMauro Carvalho Chehab 
8125aee3deSMauro Carvalho Chehab 	.baud_rate	= MANTIS_BAUD_9600,
8225aee3deSMauro Carvalho Chehab 	.parity		= MANTIS_PARITY_NONE,
8325aee3deSMauro Carvalho Chehab 	.bytes		= 0,
8425aee3deSMauro Carvalho Chehab 
8525aee3deSMauro Carvalho Chehab 	.frontend_init	= vp3028_frontend_init,
8625aee3deSMauro Carvalho Chehab 	.power		= GPIF_A00,
8725aee3deSMauro Carvalho Chehab 	.reset		= GPIF_A03,
8825aee3deSMauro Carvalho Chehab };
89