Commit e415c689 authored by Manu Abraham's avatar Manu Abraham Committed by Mauro Carvalho Chehab
Browse files

V4L/DVB (11579): Initial go at TT S2-1600



[mchehab@redhat.com: fix compilation when the new drivers aren't selected]

Signed-off-by: default avatarManu Abraham <manu@linuxtv.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 2460cdac
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -35,6 +35,21 @@ config DVB_STB6100
	  A Silicon tuner from ST used in conjunction with the STB0899
	  demodulator. Say Y when you want to support this tuner.

config DVB_STV090x
	tristate "STV0900/STV0903(A/B) based"
	depends on DVB_CORE && I2C
	default m if DVB_FE_CUSTOMISE
	help
	  DVB-S/S2/DSS Multistandard Professional/Broadcast demodulators.
	  Say Y when you want to support these frontends.

config DVB_STV6110x
	tristate "STV6110/(A) based tuners"
	depends on DVB_CORE && I2C
	default m if DVB_FE_CUSTOMISE
	help
	  A Silicon tuner that supports DVB-S and DVB-S2 modes

comment "DVB-S (satellite) frontends"
	depends on DVB_CORE

@@ -506,6 +521,13 @@ config DVB_ISL6421
	help
	  An SEC control chip.

config DVB_ISL6423
	tristate "ISL6423 SEC controller"
	depends on DVB_CORE && I2C
	default m if DVB_FE_CUSTOMISE
	help
	  A SEC controller chip from Intersil

config DVB_LGS8GL5
	tristate "Silicon Legend LGS-8GL5 demodulator (OFDM)"
	depends on DVB_CORE && I2C
+3 −1
Original line number Diff line number Diff line
@@ -71,4 +71,6 @@ obj-$(CONFIG_DVB_STB6000) += stb6000.o
obj-$(CONFIG_DVB_S921) += s921.o
obj-$(CONFIG_DVB_STV6110) += stv6110.o
obj-$(CONFIG_DVB_STV0900) += stv0900.o
obj-$(CONFIG_DVB_STV090x) += stv090x.o
obj-$(CONFIG_DVB_STV6110x) += stv6110x.o
obj-$(CONFIG_DVB_ISL6423) += isl6423.o
+293 −0
Original line number Diff line number Diff line
/*
	Intersil ISL6423 SEC and LNB Power supply controller

	Copyright (C) Manu Abraham <abraham.manu@gmail.com>

	This program is free software; you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation; either version 2 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program; if not, write to the Free Software
	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#include <linux/delay.h>
#include <linux/errno.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/string.h>
#include <linux/slab.h>

#include "dvb_frontend.h"
#include "isl6423.h"

static unsigned int verbose;
module_param(verbose, int, 0644);
MODULE_PARM_DESC(verbose, "Set Verbosity level");

#define FE_ERROR				0
#define FE_NOTICE				1
#define FE_INFO					2
#define FE_DEBUG				3
#define FE_DEBUGREG				4

#define dprintk(__y, __z, format, arg...) do {						\
	if (__z) {									\
		if	((verbose > FE_ERROR) && (verbose > __y))			\
			printk(KERN_ERR "%s: " format "\n", __func__ , ##arg);		\
		else if	((verbose > FE_NOTICE) && (verbose > __y))			\
			printk(KERN_NOTICE "%s: " format "\n", __func__ , ##arg);	\
		else if ((verbose > FE_INFO) && (verbose > __y))			\
			printk(KERN_INFO "%s: " format "\n", __func__ , ##arg);		\
		else if ((verbose > FE_DEBUG) && (verbose > __y))			\
			printk(KERN_DEBUG "%s: " format "\n", __func__ , ##arg);	\
	} else {									\
		if (verbose > __y)							\
			printk(format, ##arg);						\
	}										\
} while (0)

struct isl6423_dev {
	const struct isl6423_config	*config;
	struct i2c_adapter		*i2c;

	u8 reg_3;
	u8 reg_4;

	unsigned int verbose;
};

static int isl6423_write(struct isl6423_dev *isl6423, u8 reg)
{
	struct i2c_adapter *i2c = isl6423->i2c;
	u8 addr			= isl6423->config->addr;
	int err = 0;

	struct i2c_msg msg = { .addr = addr, .flags = 0, .buf = &reg, .len = 1 };

	err = i2c_transfer(i2c, &msg, 1);
	if (err < 0)
		goto exit;
	return 0;

exit:
	dprintk(FE_ERROR, 1, "I/O error <%d>", err);
	return err;
}

static int isl6423_set_modulation(struct dvb_frontend *fe)
{
	struct isl6423_dev *isl6423		= (struct isl6423_dev *) fe->sec_priv;
	const struct isl6423_config *config	= isl6423->config;
	int err = 0;
	u8 reg_2 = 0;

	reg_2 = 0x01 << 5;

	if (config->mod_extern)
		reg_2 |= (1 << 3);
	else
		reg_2 |= (1 << 4);

	err = isl6423_write(isl6423, reg_2);
	if (err < 0)
		goto exit;
	return 0;

exit:
	dprintk(FE_ERROR, 1, "I/O error <%d>", err);
	return err;
}

static int isl6423_voltage_boost(struct dvb_frontend *fe, long arg)
{
	struct isl6423_dev *isl6423 = (struct isl6423_dev *) fe->sec_priv;
	u8 reg_3 = isl6423->reg_3;
	u8 reg_4 = isl6423->reg_4;
	int err = 0;

	if (arg) {
		/* EN = 1, VSPEN = 1, VBOT = 1 */
		reg_4 |= (1 << 4);
		reg_4 |= 0x1;
		reg_3 |= (1 << 3);
	} else {
		/* EN = 1, VSPEN = 1, VBOT = 0 */
		reg_4 |= (1 << 4);
		reg_4 &= ~0x1;
		reg_3 |= (1 << 3);
	}
	err = isl6423_write(isl6423, reg_3);
	if (err < 0)
		goto exit;

	err = isl6423_write(isl6423, reg_4);
	if (err < 0)
		goto exit;

	return 0;
exit:
	dprintk(FE_ERROR, 1, "I/O error <%d>", err);
	return err;
}


static int isl6423_set_voltage(struct dvb_frontend *fe,
			       enum fe_sec_voltage voltage)
{
	struct isl6423_dev *isl6423 = (struct isl6423_dev *) fe->sec_priv;
	u8 reg_4 = isl6423->reg_4;
	int err = 0;

	/* SR4H = 0, SR4M = 1, SR4L = 1 */
	reg_4 = 0x03 << 5;

	switch (voltage) {
	case SEC_VOLTAGE_OFF:
		/* EN = 0 */
		reg_4 &= ~(1 << 4);
		break;

	case SEC_VOLTAGE_13:
		/* EN = 1, VSPEN = 1, VTOP = 0, VBOT = 0 */
		reg_4 |= (1 << 4);
		reg_4 &= ~0x3;
		break;

	case SEC_VOLTAGE_18:
		/* EN = 1, VSPEN = 1, VTOP = 1, VBOT = 0 */
		reg_4 |= (1 << 4);
		reg_4 |=  0x2;
		reg_4 &= ~0x1;
		break;

	default:
		break;
	}
	err = isl6423_write(isl6423, reg_4);
	if (err < 0)
		goto exit;

	return 0;
exit:
	dprintk(FE_ERROR, 1, "I/O error <%d>", err);
	return err;
}

static int isl6423_set_current(struct dvb_frontend *fe)
{
	struct isl6423_dev *isl6423		= (struct isl6423_dev *) fe->sec_priv;
	u8 reg_3 = isl6423->reg_3;
	const struct isl6423_config *config	= isl6423->config;
	int err = 0;

	/* SR3H = 0, SR3M = 1, SR3L = 0 */
	reg_3 = 0x02 << 5;

	switch (config->current_max) {
	case SEC_CURRENT_275m:
		/* 275mA */
		/* ISELH = 0, ISELL = 0 */
		reg_3 &= ~0x3;
		break;

	case SEC_CURRENT_515m:
		/* 515mA */
		/* ISELH = 0, ISELL = 1 */
		reg_3 &= ~0x2;
		reg_3 |=  0x1;
		break;

	case SEC_CURRENT_635m:
		/* 635mA */
		/* ISELH = 1, ISELL = 0 */
		reg_3 &= ~0x1;
		reg_3 |=  0x2;
		break;

	case SEC_CURRENT_800m:
		/* 800mA */
		/* ISELH = 1, ISELL = 1 */
		reg_3 |= 0x3;
		break;
	}

	err = isl6423_write(isl6423, reg_3);
	if (err < 0)
		goto exit;

	switch (config->curlim) {
	case SEC_CURRENT_LIM_ON:
		/* DCL = 1 */
		reg_3 |= 0x10;
		break;

	case SEC_CURRENT_LIM_OFF:
		/* DCL = 0 */
		reg_3 &= ~0x10;
		break;
	}

	err = isl6423_write(isl6423, reg_3);
	if (err < 0)
		goto exit;

	return 0;
exit:
	dprintk(FE_ERROR, 1, "I/O error <%d>", err);
	return err;
}

static void isl6423_release(struct dvb_frontend *fe)
{
	isl6423_set_voltage(fe, SEC_VOLTAGE_OFF);

	kfree(fe->sec_priv);
	fe->sec_priv = NULL;
}

struct dvb_frontend *isl6423_attach(struct dvb_frontend *fe,
				    struct i2c_adapter *i2c,
				    const struct isl6423_config *config)
{
	struct isl6423_dev *isl6423;

	isl6423 = kzalloc(sizeof(struct isl6423_dev), GFP_KERNEL);
	if (!isl6423)
		return NULL;

	isl6423->config	= config;
	isl6423->i2c	= i2c;
	fe->sec_priv	= isl6423;

	if (isl6423_set_current(fe))
		goto exit;

	if (isl6423_set_modulation(fe))
		goto exit;

	fe->ops.release_sec		= isl6423_release;
	fe->ops.set_voltage		= isl6423_set_voltage;
	fe->ops.enable_high_lnb_voltage = isl6423_voltage_boost;
	isl6423->verbose		= verbose;

	return fe;

exit:
	kfree(isl6423);
	fe->sec_priv = NULL;
	return NULL;
}
EXPORT_SYMBOL(isl6423_attach);

MODULE_DESCRIPTION("ISL6423 SEC");
MODULE_AUTHOR("Manu Abraham");
MODULE_LICENSE("GPL");
+63 −0
Original line number Diff line number Diff line
/*
	Intersil ISL6423 SEC and LNB Power supply controller

	Copyright (C) Manu Abraham <abraham.manu@gmail.com>

	This program is free software; you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation; either version 2 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program; if not, write to the Free Software
	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#ifndef __ISL_6423_H
#define __ISL_6423_H

#include <linux/dvb/frontend.h>

enum isl6423_current {
	SEC_CURRENT_275m = 0,
	SEC_CURRENT_515m,
	SEC_CURRENT_635m,
	SEC_CURRENT_800m,
};

enum isl6423_curlim {
	SEC_CURRENT_LIM_ON = 1,
	SEC_CURRENT_LIM_OFF
};

struct isl6423_config {
	enum isl6423_current current_max;
	enum isl6423_curlim curlim;
	u8 addr;
	u8 mod_extern;
};

#if defined(CONFIG_DVB_ISL6423) || (defined(CONFIG_DVB_ISL6423_MODULE) && defined(MODULE))


extern struct dvb_frontend *isl6423_attach(struct dvb_frontend *fe,
					   struct i2c_adapter *i2c,
					   const struct isl6423_config *config);

#else
static inline struct dvb_frontend *isl6423_attach(struct dvb_frontend *fe,
						  struct i2c_adapter *i2c,
						  const struct isl6423_config *config)
{
	printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
	return NULL;
}

#endif /* CONFIG_DVB_ISL6423 */

#endif /* __ISL_6423_H */
+3928 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading