xref: /linux/drivers/media/common/siano/sms-cards.c (revision 28a59df4d7cb8f749ba92ad304df4063ccf108fd)
10013ca8cSMauro Carvalho Chehab /*
20013ca8cSMauro Carvalho Chehab  *  Card-specific functions for the Siano SMS1xxx USB dongle
30013ca8cSMauro Carvalho Chehab  *
40013ca8cSMauro Carvalho Chehab  *  Copyright (c) 2008 Michael Krufky <mkrufky@linuxtv.org>
50013ca8cSMauro Carvalho Chehab  *
60013ca8cSMauro Carvalho Chehab  *  This program is free software; you can redistribute it and/or modify
70013ca8cSMauro Carvalho Chehab  *  it under the terms of the GNU General Public License version 2 as
80013ca8cSMauro Carvalho Chehab  *  published by the Free Software Foundation;
90013ca8cSMauro Carvalho Chehab  *
100013ca8cSMauro Carvalho Chehab  *  Software distributed under the License is distributed on an "AS IS"
110013ca8cSMauro Carvalho Chehab  *  basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
120013ca8cSMauro Carvalho Chehab  *
130013ca8cSMauro Carvalho Chehab  *  See the GNU General Public License for more details.
140013ca8cSMauro Carvalho Chehab  *
150013ca8cSMauro Carvalho Chehab  *  You should have received a copy of the GNU General Public License
160013ca8cSMauro Carvalho Chehab  *  along with this program; if not, write to the Free Software
170013ca8cSMauro Carvalho Chehab  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
180013ca8cSMauro Carvalho Chehab  */
190013ca8cSMauro Carvalho Chehab 
200013ca8cSMauro Carvalho Chehab #include "sms-cards.h"
210013ca8cSMauro Carvalho Chehab #include "smsir.h"
220013ca8cSMauro Carvalho Chehab #include <linux/module.h>
230013ca8cSMauro Carvalho Chehab 
240013ca8cSMauro Carvalho Chehab static int sms_dbg;
250013ca8cSMauro Carvalho Chehab module_param_named(cards_dbg, sms_dbg, int, 0644);
260013ca8cSMauro Carvalho Chehab MODULE_PARM_DESC(cards_dbg, "set debug level (info=1, adv=2 (or-able))");
270013ca8cSMauro Carvalho Chehab 
280013ca8cSMauro Carvalho Chehab static struct sms_board sms_boards[] = {
290013ca8cSMauro Carvalho Chehab 	[SMS_BOARD_UNKNOWN] = {
300013ca8cSMauro Carvalho Chehab 		.name	= "Unknown board",
31347d8f1fSMauro Carvalho Chehab 		.type = SMS_UNKNOWN_TYPE,
32347d8f1fSMauro Carvalho Chehab 		.default_mode = DEVICE_MODE_NONE,
330013ca8cSMauro Carvalho Chehab 	},
340013ca8cSMauro Carvalho Chehab 	[SMS1XXX_BOARD_SIANO_STELLAR] = {
350013ca8cSMauro Carvalho Chehab 		.name	= "Siano Stellar Digital Receiver",
360013ca8cSMauro Carvalho Chehab 		.type	= SMS_STELLAR,
37347d8f1fSMauro Carvalho Chehab 		.default_mode = DEVICE_MODE_DVBT_BDA,
380013ca8cSMauro Carvalho Chehab 	},
390013ca8cSMauro Carvalho Chehab 	[SMS1XXX_BOARD_SIANO_NOVA_A] = {
400013ca8cSMauro Carvalho Chehab 		.name	= "Siano Nova A Digital Receiver",
410013ca8cSMauro Carvalho Chehab 		.type	= SMS_NOVA_A0,
42347d8f1fSMauro Carvalho Chehab 		.default_mode = DEVICE_MODE_DVBT_BDA,
430013ca8cSMauro Carvalho Chehab 	},
440013ca8cSMauro Carvalho Chehab 	[SMS1XXX_BOARD_SIANO_NOVA_B] = {
450013ca8cSMauro Carvalho Chehab 		.name	= "Siano Nova B Digital Receiver",
460013ca8cSMauro Carvalho Chehab 		.type	= SMS_NOVA_B0,
47347d8f1fSMauro Carvalho Chehab 		.default_mode = DEVICE_MODE_DVBT_BDA,
480013ca8cSMauro Carvalho Chehab 	},
490013ca8cSMauro Carvalho Chehab 	[SMS1XXX_BOARD_SIANO_VEGA] = {
500013ca8cSMauro Carvalho Chehab 		.name	= "Siano Vega Digital Receiver",
510013ca8cSMauro Carvalho Chehab 		.type	= SMS_VEGA,
52347d8f1fSMauro Carvalho Chehab 		.default_mode = DEVICE_MODE_CMMB,
530013ca8cSMauro Carvalho Chehab 	},
540013ca8cSMauro Carvalho Chehab 	[SMS1XXX_BOARD_HAUPPAUGE_CATAMOUNT] = {
550013ca8cSMauro Carvalho Chehab 		.name	= "Hauppauge Catamount",
560013ca8cSMauro Carvalho Chehab 		.type	= SMS_STELLAR,
5711ad03a5SMauro Carvalho Chehab 		.fw[DEVICE_MODE_DVBT_BDA] = SMS_FW_DVBT_STELLAR,
58347d8f1fSMauro Carvalho Chehab 		.default_mode = DEVICE_MODE_DVBT_BDA,
590013ca8cSMauro Carvalho Chehab 	},
600013ca8cSMauro Carvalho Chehab 	[SMS1XXX_BOARD_HAUPPAUGE_OKEMO_A] = {
610013ca8cSMauro Carvalho Chehab 		.name	= "Hauppauge Okemo-A",
620013ca8cSMauro Carvalho Chehab 		.type	= SMS_NOVA_A0,
6311ad03a5SMauro Carvalho Chehab 		.fw[DEVICE_MODE_DVBT_BDA] = SMS_FW_DVBT_NOVA_A,
64347d8f1fSMauro Carvalho Chehab 		.default_mode = DEVICE_MODE_DVBT_BDA,
650013ca8cSMauro Carvalho Chehab 	},
660013ca8cSMauro Carvalho Chehab 	[SMS1XXX_BOARD_HAUPPAUGE_OKEMO_B] = {
670013ca8cSMauro Carvalho Chehab 		.name	= "Hauppauge Okemo-B",
680013ca8cSMauro Carvalho Chehab 		.type	= SMS_NOVA_B0,
6911ad03a5SMauro Carvalho Chehab 		.fw[DEVICE_MODE_DVBT_BDA] = SMS_FW_DVBT_NOVA_B,
70347d8f1fSMauro Carvalho Chehab 		.default_mode = DEVICE_MODE_DVBT_BDA,
710013ca8cSMauro Carvalho Chehab 	},
720013ca8cSMauro Carvalho Chehab 	[SMS1XXX_BOARD_HAUPPAUGE_WINDHAM] = {
730013ca8cSMauro Carvalho Chehab 		.name	= "Hauppauge WinTV MiniStick",
740013ca8cSMauro Carvalho Chehab 		.type	= SMS_NOVA_B0,
7511ad03a5SMauro Carvalho Chehab 		.fw[DEVICE_MODE_ISDBT_BDA] = SMS_FW_ISDBT_HCW_55XXX,
7611ad03a5SMauro Carvalho Chehab 		.fw[DEVICE_MODE_DVBT_BDA]  = SMS_FW_DVBT_HCW_55XXX,
77347d8f1fSMauro Carvalho Chehab 		.default_mode = DEVICE_MODE_DVBT_BDA,
780013ca8cSMauro Carvalho Chehab 		.rc_codes = RC_MAP_HAUPPAUGE,
790013ca8cSMauro Carvalho Chehab 		.board_cfg.leds_power = 26,
800013ca8cSMauro Carvalho Chehab 		.board_cfg.led0 = 27,
810013ca8cSMauro Carvalho Chehab 		.board_cfg.led1 = 28,
820013ca8cSMauro Carvalho Chehab 		.board_cfg.ir = 9,
830013ca8cSMauro Carvalho Chehab 		.led_power = 26,
840013ca8cSMauro Carvalho Chehab 		.led_lo    = 27,
850013ca8cSMauro Carvalho Chehab 		.led_hi    = 28,
860013ca8cSMauro Carvalho Chehab 	},
870013ca8cSMauro Carvalho Chehab 	[SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD] = {
880013ca8cSMauro Carvalho Chehab 		.name	= "Hauppauge WinTV MiniCard",
890013ca8cSMauro Carvalho Chehab 		.type	= SMS_NOVA_B0,
9011ad03a5SMauro Carvalho Chehab 		.fw[DEVICE_MODE_DVBT_BDA] = SMS_FW_DVBT_HCW_55XXX,
91347d8f1fSMauro Carvalho Chehab 		.default_mode = DEVICE_MODE_DVBT_BDA,
920013ca8cSMauro Carvalho Chehab 		.lna_ctrl  = 29,
930013ca8cSMauro Carvalho Chehab 		.board_cfg.foreign_lna0_ctrl = 29,
940013ca8cSMauro Carvalho Chehab 		.rf_switch = 17,
950013ca8cSMauro Carvalho Chehab 		.board_cfg.rf_switch_uhf = 17,
960013ca8cSMauro Carvalho Chehab 	},
970013ca8cSMauro Carvalho Chehab 	[SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD_R2] = {
980013ca8cSMauro Carvalho Chehab 		.name	= "Hauppauge WinTV MiniCard",
990013ca8cSMauro Carvalho Chehab 		.type	= SMS_NOVA_B0,
10011ad03a5SMauro Carvalho Chehab 		.fw[DEVICE_MODE_DVBT_BDA] = SMS_FW_DVBT_HCW_55XXX,
101347d8f1fSMauro Carvalho Chehab 		.default_mode = DEVICE_MODE_DVBT_BDA,
1020013ca8cSMauro Carvalho Chehab 		.lna_ctrl  = -1,
1030013ca8cSMauro Carvalho Chehab 	},
1040013ca8cSMauro Carvalho Chehab 	[SMS1XXX_BOARD_SIANO_NICE] = {
1050013ca8cSMauro Carvalho Chehab 		.name = "Siano Nice Digital Receiver",
1060013ca8cSMauro Carvalho Chehab 		.type = SMS_NOVA_B0,
107347d8f1fSMauro Carvalho Chehab 		.default_mode = DEVICE_MODE_DVBT_BDA,
1080013ca8cSMauro Carvalho Chehab 	},
1090013ca8cSMauro Carvalho Chehab 	[SMS1XXX_BOARD_SIANO_VENICE] = {
1100013ca8cSMauro Carvalho Chehab 		.name = "Siano Venice Digital Receiver",
1110013ca8cSMauro Carvalho Chehab 		.type = SMS_VEGA,
112347d8f1fSMauro Carvalho Chehab 		.default_mode = DEVICE_MODE_CMMB,
113347d8f1fSMauro Carvalho Chehab 	},
114347d8f1fSMauro Carvalho Chehab 	[SMS1XXX_BOARD_SIANO_STELLAR_ROM] = {
115347d8f1fSMauro Carvalho Chehab 		.name = "Siano Stellar Digital Receiver ROM",
116347d8f1fSMauro Carvalho Chehab 		.type = SMS_STELLAR,
117347d8f1fSMauro Carvalho Chehab 		.default_mode = DEVICE_MODE_DVBT_BDA,
118347d8f1fSMauro Carvalho Chehab 		.intf_num = 1,
119347d8f1fSMauro Carvalho Chehab 	},
120347d8f1fSMauro Carvalho Chehab 	[SMS1XXX_BOARD_ZTE_DVB_DATA_CARD] = {
121347d8f1fSMauro Carvalho Chehab 		.name = "ZTE Data Card Digital Receiver",
122347d8f1fSMauro Carvalho Chehab 		.type = SMS_NOVA_B0,
123347d8f1fSMauro Carvalho Chehab 		.default_mode = DEVICE_MODE_DVBT_BDA,
124347d8f1fSMauro Carvalho Chehab 		.intf_num = 5,
125347d8f1fSMauro Carvalho Chehab 		.mtu = 15792,
126347d8f1fSMauro Carvalho Chehab 	},
127347d8f1fSMauro Carvalho Chehab 	[SMS1XXX_BOARD_ONDA_MDTV_DATA_CARD] = {
128347d8f1fSMauro Carvalho Chehab 		.name = "ONDA Data Card Digital Receiver",
129347d8f1fSMauro Carvalho Chehab 		.type = SMS_NOVA_B0,
130347d8f1fSMauro Carvalho Chehab 		.default_mode = DEVICE_MODE_DVBT_BDA,
131347d8f1fSMauro Carvalho Chehab 		.intf_num = 6,
132347d8f1fSMauro Carvalho Chehab 		.mtu = 15792,
133347d8f1fSMauro Carvalho Chehab 	},
134347d8f1fSMauro Carvalho Chehab 	[SMS1XXX_BOARD_SIANO_MING] = {
135347d8f1fSMauro Carvalho Chehab 		.name = "Siano Ming Digital Receiver",
136347d8f1fSMauro Carvalho Chehab 		.type = SMS_MING,
137347d8f1fSMauro Carvalho Chehab 		.default_mode = DEVICE_MODE_CMMB,
138347d8f1fSMauro Carvalho Chehab 	},
139347d8f1fSMauro Carvalho Chehab 	[SMS1XXX_BOARD_SIANO_PELE] = {
140347d8f1fSMauro Carvalho Chehab 		.name = "Siano Pele Digital Receiver",
141347d8f1fSMauro Carvalho Chehab 		.type = SMS_PELE,
142347d8f1fSMauro Carvalho Chehab 		.default_mode = DEVICE_MODE_ISDBT_BDA,
143347d8f1fSMauro Carvalho Chehab 	},
144347d8f1fSMauro Carvalho Chehab 	[SMS1XXX_BOARD_SIANO_RIO] = {
145347d8f1fSMauro Carvalho Chehab 		.name = "Siano Rio Digital Receiver",
146347d8f1fSMauro Carvalho Chehab 		.type = SMS_RIO,
147347d8f1fSMauro Carvalho Chehab 		.default_mode = DEVICE_MODE_ISDBT_BDA,
148347d8f1fSMauro Carvalho Chehab 	},
149347d8f1fSMauro Carvalho Chehab 	[SMS1XXX_BOARD_SIANO_DENVER_1530] = {
150347d8f1fSMauro Carvalho Chehab 		.name = "Siano Denver (ATSC-M/H) Digital Receiver",
151347d8f1fSMauro Carvalho Chehab 		.type = SMS_DENVER_1530,
152347d8f1fSMauro Carvalho Chehab 		.default_mode = DEVICE_MODE_ATSC,
153347d8f1fSMauro Carvalho Chehab 		.crystal = 2400,
154347d8f1fSMauro Carvalho Chehab 	},
155347d8f1fSMauro Carvalho Chehab 	[SMS1XXX_BOARD_SIANO_DENVER_2160] = {
156347d8f1fSMauro Carvalho Chehab 		.name = "Siano Denver (TDMB) Digital Receiver",
157347d8f1fSMauro Carvalho Chehab 		.type = SMS_DENVER_2160,
158347d8f1fSMauro Carvalho Chehab 		.default_mode = DEVICE_MODE_DAB_TDMB,
1590013ca8cSMauro Carvalho Chehab 	},
1600013ca8cSMauro Carvalho Chehab };
1610013ca8cSMauro Carvalho Chehab 
1620013ca8cSMauro Carvalho Chehab struct sms_board *sms_get_board(unsigned id)
1630013ca8cSMauro Carvalho Chehab {
1640013ca8cSMauro Carvalho Chehab 	BUG_ON(id >= ARRAY_SIZE(sms_boards));
1650013ca8cSMauro Carvalho Chehab 
1660013ca8cSMauro Carvalho Chehab 	return &sms_boards[id];
1670013ca8cSMauro Carvalho Chehab }
1680013ca8cSMauro Carvalho Chehab EXPORT_SYMBOL_GPL(sms_get_board);
1690013ca8cSMauro Carvalho Chehab static inline void sms_gpio_assign_11xx_default_led_config(
170dfef84fcSMauro Carvalho Chehab 		struct smscore_config_gpio *p_gpio_config) {
171dfef84fcSMauro Carvalho Chehab 	p_gpio_config->direction = SMS_GPIO_DIRECTION_OUTPUT;
172dfef84fcSMauro Carvalho Chehab 	p_gpio_config->inputcharacteristics =
173c31b9fb2SMauro Carvalho Chehab 		SMS_GPIO_INPUTCHARACTERISTICS_NORMAL;
174dfef84fcSMauro Carvalho Chehab 	p_gpio_config->outputdriving = SMS_GPIO_OUTPUTDRIVING_4mA;
175dfef84fcSMauro Carvalho Chehab 	p_gpio_config->outputslewrate = SMS_GPIO_OUTPUT_SLEW_RATE_0_45_V_NS;
176dfef84fcSMauro Carvalho Chehab 	p_gpio_config->pullupdown = SMS_GPIO_PULLUPDOWN_NONE;
1770013ca8cSMauro Carvalho Chehab }
1780013ca8cSMauro Carvalho Chehab 
1790013ca8cSMauro Carvalho Chehab int sms_board_event(struct smscore_device_t *coredev,
180347d8f1fSMauro Carvalho Chehab 		    enum SMS_BOARD_EVENTS gevent)
181347d8f1fSMauro Carvalho Chehab {
182*28a59df4SMauro Carvalho Chehab 	struct smscore_config_gpio my_gpio_config;
1830013ca8cSMauro Carvalho Chehab 
184*28a59df4SMauro Carvalho Chehab 	sms_gpio_assign_11xx_default_led_config(&my_gpio_config);
1850013ca8cSMauro Carvalho Chehab 
1860013ca8cSMauro Carvalho Chehab 	switch (gevent) {
1870013ca8cSMauro Carvalho Chehab 	case BOARD_EVENT_POWER_INIT: /* including hotplug */
1880013ca8cSMauro Carvalho Chehab 		break; /* BOARD_EVENT_BIND */
1890013ca8cSMauro Carvalho Chehab 
1900013ca8cSMauro Carvalho Chehab 	case BOARD_EVENT_POWER_SUSPEND:
1910013ca8cSMauro Carvalho Chehab 		break; /* BOARD_EVENT_POWER_SUSPEND */
1920013ca8cSMauro Carvalho Chehab 
1930013ca8cSMauro Carvalho Chehab 	case BOARD_EVENT_POWER_RESUME:
1940013ca8cSMauro Carvalho Chehab 		break; /* BOARD_EVENT_POWER_RESUME */
1950013ca8cSMauro Carvalho Chehab 
1960013ca8cSMauro Carvalho Chehab 	case BOARD_EVENT_BIND:
1970013ca8cSMauro Carvalho Chehab 		break; /* BOARD_EVENT_BIND */
1980013ca8cSMauro Carvalho Chehab 
1990013ca8cSMauro Carvalho Chehab 	case BOARD_EVENT_SCAN_PROG:
2000013ca8cSMauro Carvalho Chehab 		break; /* BOARD_EVENT_SCAN_PROG */
2010013ca8cSMauro Carvalho Chehab 	case BOARD_EVENT_SCAN_COMP:
2020013ca8cSMauro Carvalho Chehab 		break; /* BOARD_EVENT_SCAN_COMP */
2030013ca8cSMauro Carvalho Chehab 	case BOARD_EVENT_EMERGENCY_WARNING_SIGNAL:
2040013ca8cSMauro Carvalho Chehab 		break; /* BOARD_EVENT_EMERGENCY_WARNING_SIGNAL */
2050013ca8cSMauro Carvalho Chehab 	case BOARD_EVENT_FE_LOCK:
2060013ca8cSMauro Carvalho Chehab 		break; /* BOARD_EVENT_FE_LOCK */
2070013ca8cSMauro Carvalho Chehab 	case BOARD_EVENT_FE_UNLOCK:
2080013ca8cSMauro Carvalho Chehab 		break; /* BOARD_EVENT_FE_UNLOCK */
2090013ca8cSMauro Carvalho Chehab 	case BOARD_EVENT_DEMOD_LOCK:
2100013ca8cSMauro Carvalho Chehab 		break; /* BOARD_EVENT_DEMOD_LOCK */
2110013ca8cSMauro Carvalho Chehab 	case BOARD_EVENT_DEMOD_UNLOCK:
2120013ca8cSMauro Carvalho Chehab 		break; /* BOARD_EVENT_DEMOD_UNLOCK */
2130013ca8cSMauro Carvalho Chehab 	case BOARD_EVENT_RECEPTION_MAX_4:
2140013ca8cSMauro Carvalho Chehab 		break; /* BOARD_EVENT_RECEPTION_MAX_4 */
2150013ca8cSMauro Carvalho Chehab 	case BOARD_EVENT_RECEPTION_3:
2160013ca8cSMauro Carvalho Chehab 		break; /* BOARD_EVENT_RECEPTION_3 */
2170013ca8cSMauro Carvalho Chehab 	case BOARD_EVENT_RECEPTION_2:
2180013ca8cSMauro Carvalho Chehab 		break; /* BOARD_EVENT_RECEPTION_2 */
2190013ca8cSMauro Carvalho Chehab 	case BOARD_EVENT_RECEPTION_1:
2200013ca8cSMauro Carvalho Chehab 		break; /* BOARD_EVENT_RECEPTION_1 */
2210013ca8cSMauro Carvalho Chehab 	case BOARD_EVENT_RECEPTION_LOST_0:
2220013ca8cSMauro Carvalho Chehab 		break; /* BOARD_EVENT_RECEPTION_LOST_0 */
2230013ca8cSMauro Carvalho Chehab 	case BOARD_EVENT_MULTIPLEX_OK:
2240013ca8cSMauro Carvalho Chehab 		break; /* BOARD_EVENT_MULTIPLEX_OK */
2250013ca8cSMauro Carvalho Chehab 	case BOARD_EVENT_MULTIPLEX_ERRORS:
2260013ca8cSMauro Carvalho Chehab 		break; /* BOARD_EVENT_MULTIPLEX_ERRORS */
2270013ca8cSMauro Carvalho Chehab 
2280013ca8cSMauro Carvalho Chehab 	default:
2290013ca8cSMauro Carvalho Chehab 		sms_err("Unknown SMS board event");
2300013ca8cSMauro Carvalho Chehab 		break;
2310013ca8cSMauro Carvalho Chehab 	}
2320013ca8cSMauro Carvalho Chehab 	return 0;
2330013ca8cSMauro Carvalho Chehab }
2340013ca8cSMauro Carvalho Chehab EXPORT_SYMBOL_GPL(sms_board_event);
2350013ca8cSMauro Carvalho Chehab 
2360013ca8cSMauro Carvalho Chehab static int sms_set_gpio(struct smscore_device_t *coredev, int pin, int enable)
2370013ca8cSMauro Carvalho Chehab {
2380013ca8cSMauro Carvalho Chehab 	int lvl, ret;
2390013ca8cSMauro Carvalho Chehab 	u32 gpio;
2400013ca8cSMauro Carvalho Chehab 	struct smscore_config_gpio gpioconfig = {
2410013ca8cSMauro Carvalho Chehab 		.direction            = SMS_GPIO_DIRECTION_OUTPUT,
2420013ca8cSMauro Carvalho Chehab 		.pullupdown           = SMS_GPIO_PULLUPDOWN_NONE,
2430013ca8cSMauro Carvalho Chehab 		.inputcharacteristics = SMS_GPIO_INPUTCHARACTERISTICS_NORMAL,
244c31b9fb2SMauro Carvalho Chehab 		.outputslewrate       = SMS_GPIO_OUTPUT_SLEW_RATE_FAST,
245f82757d9SMauro Carvalho Chehab 		.outputdriving        = SMS_GPIO_OUTPUTDRIVING_S_4mA,
2460013ca8cSMauro Carvalho Chehab 	};
2470013ca8cSMauro Carvalho Chehab 
2480013ca8cSMauro Carvalho Chehab 	if (pin == 0)
2490013ca8cSMauro Carvalho Chehab 		return -EINVAL;
2500013ca8cSMauro Carvalho Chehab 
2510013ca8cSMauro Carvalho Chehab 	if (pin < 0) {
2520013ca8cSMauro Carvalho Chehab 		/* inverted gpio */
2530013ca8cSMauro Carvalho Chehab 		gpio = pin * -1;
2540013ca8cSMauro Carvalho Chehab 		lvl = enable ? 0 : 1;
2550013ca8cSMauro Carvalho Chehab 	} else {
2560013ca8cSMauro Carvalho Chehab 		gpio = pin;
2570013ca8cSMauro Carvalho Chehab 		lvl = enable ? 1 : 0;
2580013ca8cSMauro Carvalho Chehab 	}
2590013ca8cSMauro Carvalho Chehab 
2600013ca8cSMauro Carvalho Chehab 	ret = smscore_configure_gpio(coredev, gpio, &gpioconfig);
2610013ca8cSMauro Carvalho Chehab 	if (ret < 0)
2620013ca8cSMauro Carvalho Chehab 		return ret;
2630013ca8cSMauro Carvalho Chehab 
2640013ca8cSMauro Carvalho Chehab 	return smscore_set_gpio(coredev, gpio, lvl);
2650013ca8cSMauro Carvalho Chehab }
2660013ca8cSMauro Carvalho Chehab 
2670013ca8cSMauro Carvalho Chehab int sms_board_setup(struct smscore_device_t *coredev)
2680013ca8cSMauro Carvalho Chehab {
2690013ca8cSMauro Carvalho Chehab 	int board_id = smscore_get_board_id(coredev);
2700013ca8cSMauro Carvalho Chehab 	struct sms_board *board = sms_get_board(board_id);
2710013ca8cSMauro Carvalho Chehab 
2720013ca8cSMauro Carvalho Chehab 	switch (board_id) {
2730013ca8cSMauro Carvalho Chehab 	case SMS1XXX_BOARD_HAUPPAUGE_WINDHAM:
2740013ca8cSMauro Carvalho Chehab 		/* turn off all LEDs */
2750013ca8cSMauro Carvalho Chehab 		sms_set_gpio(coredev, board->led_power, 0);
2760013ca8cSMauro Carvalho Chehab 		sms_set_gpio(coredev, board->led_hi, 0);
2770013ca8cSMauro Carvalho Chehab 		sms_set_gpio(coredev, board->led_lo, 0);
2780013ca8cSMauro Carvalho Chehab 		break;
2790013ca8cSMauro Carvalho Chehab 	case SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD_R2:
2800013ca8cSMauro Carvalho Chehab 	case SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD:
2810013ca8cSMauro Carvalho Chehab 		/* turn off LNA */
2820013ca8cSMauro Carvalho Chehab 		sms_set_gpio(coredev, board->lna_ctrl, 0);
2830013ca8cSMauro Carvalho Chehab 		break;
2840013ca8cSMauro Carvalho Chehab 	}
2850013ca8cSMauro Carvalho Chehab 	return 0;
2860013ca8cSMauro Carvalho Chehab }
2870013ca8cSMauro Carvalho Chehab EXPORT_SYMBOL_GPL(sms_board_setup);
2880013ca8cSMauro Carvalho Chehab 
2890013ca8cSMauro Carvalho Chehab int sms_board_power(struct smscore_device_t *coredev, int onoff)
2900013ca8cSMauro Carvalho Chehab {
2910013ca8cSMauro Carvalho Chehab 	int board_id = smscore_get_board_id(coredev);
2920013ca8cSMauro Carvalho Chehab 	struct sms_board *board = sms_get_board(board_id);
2930013ca8cSMauro Carvalho Chehab 
2940013ca8cSMauro Carvalho Chehab 	switch (board_id) {
2950013ca8cSMauro Carvalho Chehab 	case SMS1XXX_BOARD_HAUPPAUGE_WINDHAM:
2960013ca8cSMauro Carvalho Chehab 		/* power LED */
2970013ca8cSMauro Carvalho Chehab 		sms_set_gpio(coredev,
2980013ca8cSMauro Carvalho Chehab 			     board->led_power, onoff ? 1 : 0);
2990013ca8cSMauro Carvalho Chehab 		break;
3000013ca8cSMauro Carvalho Chehab 	case SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD_R2:
3010013ca8cSMauro Carvalho Chehab 	case SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD:
3020013ca8cSMauro Carvalho Chehab 		/* LNA */
3030013ca8cSMauro Carvalho Chehab 		if (!onoff)
3040013ca8cSMauro Carvalho Chehab 			sms_set_gpio(coredev, board->lna_ctrl, 0);
3050013ca8cSMauro Carvalho Chehab 		break;
3060013ca8cSMauro Carvalho Chehab 	}
3070013ca8cSMauro Carvalho Chehab 	return 0;
3080013ca8cSMauro Carvalho Chehab }
3090013ca8cSMauro Carvalho Chehab EXPORT_SYMBOL_GPL(sms_board_power);
3100013ca8cSMauro Carvalho Chehab 
3110013ca8cSMauro Carvalho Chehab int sms_board_led_feedback(struct smscore_device_t *coredev, int led)
3120013ca8cSMauro Carvalho Chehab {
3130013ca8cSMauro Carvalho Chehab 	int board_id = smscore_get_board_id(coredev);
3140013ca8cSMauro Carvalho Chehab 	struct sms_board *board = sms_get_board(board_id);
3150013ca8cSMauro Carvalho Chehab 
3160013ca8cSMauro Carvalho Chehab 	/* dont touch GPIO if LEDs are already set */
3170013ca8cSMauro Carvalho Chehab 	if (smscore_led_state(coredev, -1) == led)
3180013ca8cSMauro Carvalho Chehab 		return 0;
3190013ca8cSMauro Carvalho Chehab 
3200013ca8cSMauro Carvalho Chehab 	switch (board_id) {
3210013ca8cSMauro Carvalho Chehab 	case SMS1XXX_BOARD_HAUPPAUGE_WINDHAM:
3220013ca8cSMauro Carvalho Chehab 		sms_set_gpio(coredev,
3230013ca8cSMauro Carvalho Chehab 			     board->led_lo, (led & SMS_LED_LO) ? 1 : 0);
3240013ca8cSMauro Carvalho Chehab 		sms_set_gpio(coredev,
3250013ca8cSMauro Carvalho Chehab 			     board->led_hi, (led & SMS_LED_HI) ? 1 : 0);
3260013ca8cSMauro Carvalho Chehab 
3270013ca8cSMauro Carvalho Chehab 		smscore_led_state(coredev, led);
3280013ca8cSMauro Carvalho Chehab 		break;
3290013ca8cSMauro Carvalho Chehab 	}
3300013ca8cSMauro Carvalho Chehab 	return 0;
3310013ca8cSMauro Carvalho Chehab }
3320013ca8cSMauro Carvalho Chehab EXPORT_SYMBOL_GPL(sms_board_led_feedback);
3330013ca8cSMauro Carvalho Chehab 
3340013ca8cSMauro Carvalho Chehab int sms_board_lna_control(struct smscore_device_t *coredev, int onoff)
3350013ca8cSMauro Carvalho Chehab {
3360013ca8cSMauro Carvalho Chehab 	int board_id = smscore_get_board_id(coredev);
3370013ca8cSMauro Carvalho Chehab 	struct sms_board *board = sms_get_board(board_id);
3380013ca8cSMauro Carvalho Chehab 
3390013ca8cSMauro Carvalho Chehab 	sms_debug("%s: LNA %s", __func__, onoff ? "enabled" : "disabled");
3400013ca8cSMauro Carvalho Chehab 
3410013ca8cSMauro Carvalho Chehab 	switch (board_id) {
3420013ca8cSMauro Carvalho Chehab 	case SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD_R2:
3430013ca8cSMauro Carvalho Chehab 	case SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD:
3440013ca8cSMauro Carvalho Chehab 		sms_set_gpio(coredev,
3450013ca8cSMauro Carvalho Chehab 			     board->rf_switch, onoff ? 1 : 0);
3460013ca8cSMauro Carvalho Chehab 		return sms_set_gpio(coredev,
3470013ca8cSMauro Carvalho Chehab 				    board->lna_ctrl, onoff ? 1 : 0);
3480013ca8cSMauro Carvalho Chehab 	}
3490013ca8cSMauro Carvalho Chehab 	return -EINVAL;
3500013ca8cSMauro Carvalho Chehab }
3510013ca8cSMauro Carvalho Chehab EXPORT_SYMBOL_GPL(sms_board_lna_control);
3520013ca8cSMauro Carvalho Chehab 
3530013ca8cSMauro Carvalho Chehab int sms_board_load_modules(int id)
3540013ca8cSMauro Carvalho Chehab {
3550013ca8cSMauro Carvalho Chehab 	request_module("smsdvb");
3560013ca8cSMauro Carvalho Chehab 	return 0;
3570013ca8cSMauro Carvalho Chehab }
3580013ca8cSMauro Carvalho Chehab EXPORT_SYMBOL_GPL(sms_board_load_modules);
359