Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

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

V4L/DVB (13798): [Mantis] Enable power for all cards, use byte mode only on relevant devices

parent 3e978a82
Loading
Loading
Loading
Loading
+20 −7
Original line number Diff line number Diff line
@@ -45,17 +45,30 @@ struct zl10353_config hopper_vp3028_config = {
static int vp3028_frontend_init(struct mantis_pci *mantis, struct dvb_frontend *fe)
{
	struct i2c_adapter *adapter	= &mantis->adapter;
	struct mantis_hwconfig *config	= mantis->hwconfig;
	int err = 0;

	gpio_set_bits(mantis, config->reset, 0);
	msleep(100);
	err = mantis_frontend_power(mantis, POWER_ON);
	mantis_frontend_soft_reset(mantis);
	msleep(100);
	gpio_set_bits(mantis, config->reset, 1);

	err = mantis_frontend_power(mantis, POWER_ON);
	if (err == 0) {
		msleep(250);
		dprintk(MANTIS_ERROR, 1, "Probing for 10353 (DVB-T)");
		fe = zl10353_attach(&hopper_vp3028_config, adapter);

		if (!fe)
			return -1;
	} else {
		dprintk(MANTIS_ERROR, 1, "Frontend on <%s> POWER ON failed! <%d>",
			adapter->name,
			err);

		return -EIO;
	}
	dprintk(MANTIS_ERROR, 1, "Done!");

	return 0;
+10 −3
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@
#define MANTIS_NOTICE		1
#define MANTIS_INFO		2
#define MANTIS_DEBUG		3
#define MANTIS_TMG		9

#define dprintk(y, z, format, arg...) do {								\
	if (z) {											\
@@ -43,6 +44,8 @@
			printk(KERN_INFO "%s (%d): " format "\n" , __func__ , mantis->num , ##arg);	\
		else if ((mantis->verbose > MANTIS_DEBUG) && (mantis->verbose > y))			\
			printk(KERN_DEBUG "%s (%d): " format "\n" , __func__ , mantis->num , ##arg);	\
		else if ((mantis->verbose > MANTIS_TMG) && (mantis->verbose > y))			\
			printk(KERN_DEBUG "%s (%d): " format "\n" , __func__ , mantis->num , ##arg);	\
	} else {											\
		if (mantis->verbose > y)								\
			printk(format , ##arg);								\
@@ -54,9 +57,6 @@

#define mmwrite(dat, addr)	mwrite((dat), (mantis->mmio + (addr)))
#define mmread(addr)		mread(mantis->mmio + (addr))
#define mmand(dat, addr)	mmwrite((dat) & mmread(addr), addr)
#define mmor(dat, addr)		mmwrite((dat) | mmread(addr), addr)
#define mmaor(dat, addr)	mmwrite((dat) | ((mask) & mmread(addr)), addr)

#define MANTIS_TS_188		0
#define MANTIS_TS_204		1
@@ -75,6 +75,11 @@
		.driver_data	= (unsigned long) (__configptr)		\
}

enum mantis_i2c_mode {
	MANTIS_PAGE_MODE = 0,
	MANTIS_BYTE_MODE,
};

struct mantis_pci;

struct mantis_hwconfig {
@@ -91,6 +96,8 @@ struct mantis_hwconfig {

	u8			power;
	u8			reset;

	enum mantis_i2c_mode	i2c_mode;
};

struct mantis_pci {
+37 −10
Original line number Diff line number Diff line
@@ -35,6 +35,8 @@

#define I2C_HW_B_MANTIS		0x1c

#define TRIALS			10000

static int mantis_i2c_read(struct mantis_pci *mantis, const struct i2c_msg *msg)
{
	u32 rxd, i, stat, trials;
@@ -55,13 +57,25 @@ static int mantis_i2c_read(struct mantis_pci *mantis, const struct i2c_msg *msg)
		mmwrite(rxd, MANTIS_I2CDATA_CTL);

		/* wait for xfer completion */
		for (trials = 0; trials < 100; trials++) {
			udelay(500);
		for (trials = 0; trials < TRIALS; trials++) {
			msleep(1);
			stat = mmread(MANTIS_INT_STAT);
			if (stat & MANTIS_INT_I2CDONE)
				break;
		}

		dprintk(MANTIS_TMG, 0, "I2CDONE: trials=%d\n", trials);

		/* wait for xfer completion */
		for (trials = 0; trials < TRIALS; trials++) {
			stat = mmread(MANTIS_INT_STAT);
			if (stat & MANTIS_INT_I2CRACK)
				break;
			msleep(1);
		}

		dprintk(MANTIS_TMG, 0, "I2CRACK: trials=%d\n", trials);

		rxd = mmread(MANTIS_I2CDATA_CTL);
		msg->buf[i] = (u8)((rxd >> 8) & 0xFF);
		dprintk(MANTIS_INFO, 0, "%02x ", msg->buf[i]);
@@ -93,12 +107,24 @@ static int mantis_i2c_write(struct mantis_pci *mantis, const struct i2c_msg *msg
		mmwrite(txd, MANTIS_I2CDATA_CTL);

		/* wait for xfer completion */
		for (trials = 0; trials < 100; trials++) {
			udelay(500);
		for (trials = 0; trials < TRIALS; trials++) {
			msleep(1);
			stat = mmread(MANTIS_INT_STAT);
			if (stat & MANTIS_INT_I2CDONE)
				break;
		}

		dprintk(MANTIS_TMG, 0, "I2CDONE: trials=%d\n", trials);

		/* wait for xfer completion */
		for (trials = 0; trials < TRIALS; trials++) {
			stat = mmread(MANTIS_INT_STAT);
			if (stat & MANTIS_INT_I2CRACK)
				break;
			msleep(1);
		}

		dprintk(MANTIS_TMG, 0, "I2CRACK: trials=%d\n", trials);
	}
	dprintk(MANTIS_INFO, 0, "]\n");

@@ -122,7 +148,8 @@ static int mantis_i2c_xfer(struct i2c_adapter *adapter, struct i2c_msg *msgs, in

	while (i < num) {
		/* Byte MODE */
		if (((i + 1) < num)		&&
		if ((config->i2c_mode & MANTIS_BYTE_MODE) &&
		    ((i + 1) < num)			&&
		    (msgs[i].len < 2)			&&
		    (msgs[i + 1].len < 2)		&&
		    (msgs[i + 1].flags & I2C_M_RD)) {
@@ -136,8 +163,8 @@ static int mantis_i2c_xfer(struct i2c_adapter *adapter, struct i2c_msg *msgs, in

			mmwrite(txd, MANTIS_I2CDATA_CTL);
			/* wait for xfer completion */
			for (trials = 0; trials < 100; trials++) {
				udelay(500);
			for (trials = 0; trials < TRIALS; trials++) {
				msleep(1);
				stat = mmread(MANTIS_INT_STAT);
				if (stat & MANTIS_INT_I2CDONE)
					break;
+27 −9
Original line number Diff line number Diff line
@@ -31,7 +31,10 @@

#include "stv0299.h"
#include "mantis_common.h"
#include "mantis_ioc.h"
#include "mantis_dvb.h"
#include "mantis_vp1033.h"
#include "mantis_reg.h"

u8 lgtdqcs001f_inittab[] = {
	0x01, 0x15,
@@ -163,6 +166,13 @@ static int vp1033_frontend_init(struct mantis_pci *mantis, struct dvb_frontend *
{
	struct i2c_adapter *adapter	= &mantis->adapter;

	int err = 0;

	err = mantis_frontend_power(mantis, POWER_ON);
	if (err == 0) {
		mantis_frontend_soft_reset(mantis);
		msleep(250);

		dprintk(MANTIS_ERROR, 1, "Probing for STV0299 (DVB-S)");
		fe = stv0299_attach(&lgtdqcs001f_config, adapter);

@@ -175,7 +185,13 @@ static int vp1033_frontend_init(struct mantis_pci *mantis, struct dvb_frontend *
		} else {
			return -1;
		}
	} else {
		dprintk(MANTIS_ERROR, 1, "Frontend on <%s> POWER ON failed! <%d>",
			adapter->name,
			err);

		return -EIO;
	}
	mantis->fe = fe;
	dprintk(MANTIS_ERROR, 1, "Done!");

@@ -192,4 +208,6 @@ struct mantis_hwconfig vp1033_config = {
	.bytes			= 0,

	.frontend_init		= vp1033_frontend_init,
	.power			= GPIF_A12,
	.reset			= GPIF_A13,
};
+24 −8
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@
#include "mb86a16.h"
#include "mantis_common.h"
#include "mantis_ioc.h"
#include "mantis_dvb.h"
#include "mantis_vp1034.h"
#include "mantis_reg.h"

@@ -74,6 +75,13 @@ static int vp1034_frontend_init(struct mantis_pci *mantis, struct dvb_frontend *
{
	struct i2c_adapter *adapter	= &mantis->adapter;

	int err = 0;

	err = mantis_frontend_power(mantis, POWER_ON);
	if (err == 0) {
		mantis_frontend_soft_reset(mantis);
		msleep(250);

		dprintk(MANTIS_ERROR, 1, "Probing for MB86A16 (DVB-S/DSS)");
		fe = mb86a16_attach(&vp1034_mb86a16_config, adapter);
		if (fe) {
@@ -84,7 +92,13 @@ static int vp1034_frontend_init(struct mantis_pci *mantis, struct dvb_frontend *
		} else {
			return -1;
		}
	} else {
		dprintk(MANTIS_ERROR, 1, "Frontend on <%s> POWER ON failed! <%d>",
			adapter->name,
			err);

		return -EIO;
	}
	mantis->fe = fe;
	dprintk(MANTIS_ERROR, 1, "Done!");

@@ -101,4 +115,6 @@ struct mantis_hwconfig vp1034_config = {
	.bytes		= 0,

	.frontend_init	= vp1034_frontend_init,
	.power		= GPIF_A12,
	.reset		= GPIF_A13,
};
Loading