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

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

Signed-off-by: default avatarManu Abraham <manu@linuxtv.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 3e978a82
...@@ -45,17 +45,30 @@ struct zl10353_config hopper_vp3028_config = { ...@@ -45,17 +45,30 @@ struct zl10353_config hopper_vp3028_config = {
static int vp3028_frontend_init(struct mantis_pci *mantis, struct dvb_frontend *fe) static int vp3028_frontend_init(struct mantis_pci *mantis, struct dvb_frontend *fe)
{ {
struct i2c_adapter *adapter = &mantis->adapter; struct i2c_adapter *adapter = &mantis->adapter;
struct mantis_hwconfig *config = mantis->hwconfig;
int err = 0; int err = 0;
gpio_set_bits(mantis, config->reset, 0);
msleep(100);
err = mantis_frontend_power(mantis, POWER_ON); 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)"); dprintk(MANTIS_ERROR, 1, "Probing for 10353 (DVB-T)");
fe = zl10353_attach(&hopper_vp3028_config, adapter); fe = zl10353_attach(&hopper_vp3028_config, adapter);
if (!fe) if (!fe)
return -1; return -1;
} else {
dprintk(MANTIS_ERROR, 1, "Frontend on <%s> POWER ON failed! <%d>",
adapter->name,
err);
return -EIO;
}
dprintk(MANTIS_ERROR, 1, "Done!"); dprintk(MANTIS_ERROR, 1, "Done!");
return 0; return 0;
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#define MANTIS_NOTICE 1 #define MANTIS_NOTICE 1
#define MANTIS_INFO 2 #define MANTIS_INFO 2
#define MANTIS_DEBUG 3 #define MANTIS_DEBUG 3
#define MANTIS_TMG 9
#define dprintk(y, z, format, arg...) do { \ #define dprintk(y, z, format, arg...) do { \
if (z) { \ if (z) { \
...@@ -43,6 +44,8 @@ ...@@ -43,6 +44,8 @@
printk(KERN_INFO "%s (%d): " format "\n" , __func__ , mantis->num , ##arg); \ printk(KERN_INFO "%s (%d): " format "\n" , __func__ , mantis->num , ##arg); \
else if ((mantis->verbose > MANTIS_DEBUG) && (mantis->verbose > y)) \ else if ((mantis->verbose > MANTIS_DEBUG) && (mantis->verbose > y)) \
printk(KERN_DEBUG "%s (%d): " format "\n" , __func__ , mantis->num , ##arg); \ 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 { \ } else { \
if (mantis->verbose > y) \ if (mantis->verbose > y) \
printk(format , ##arg); \ printk(format , ##arg); \
...@@ -54,9 +57,6 @@ ...@@ -54,9 +57,6 @@
#define mmwrite(dat, addr) mwrite((dat), (mantis->mmio + (addr))) #define mmwrite(dat, addr) mwrite((dat), (mantis->mmio + (addr)))
#define mmread(addr) mread(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_188 0
#define MANTIS_TS_204 1 #define MANTIS_TS_204 1
...@@ -75,6 +75,11 @@ ...@@ -75,6 +75,11 @@
.driver_data = (unsigned long) (__configptr) \ .driver_data = (unsigned long) (__configptr) \
} }
enum mantis_i2c_mode {
MANTIS_PAGE_MODE = 0,
MANTIS_BYTE_MODE,
};
struct mantis_pci; struct mantis_pci;
struct mantis_hwconfig { struct mantis_hwconfig {
...@@ -91,6 +96,8 @@ struct mantis_hwconfig { ...@@ -91,6 +96,8 @@ struct mantis_hwconfig {
u8 power; u8 power;
u8 reset; u8 reset;
enum mantis_i2c_mode i2c_mode;
}; };
struct mantis_pci { struct mantis_pci {
......
...@@ -35,6 +35,8 @@ ...@@ -35,6 +35,8 @@
#define I2C_HW_B_MANTIS 0x1c #define I2C_HW_B_MANTIS 0x1c
#define TRIALS 10000
static int mantis_i2c_read(struct mantis_pci *mantis, const struct i2c_msg *msg) static int mantis_i2c_read(struct mantis_pci *mantis, const struct i2c_msg *msg)
{ {
u32 rxd, i, stat, trials; u32 rxd, i, stat, trials;
...@@ -55,13 +57,25 @@ static int mantis_i2c_read(struct mantis_pci *mantis, const struct i2c_msg *msg) ...@@ -55,13 +57,25 @@ static int mantis_i2c_read(struct mantis_pci *mantis, const struct i2c_msg *msg)
mmwrite(rxd, MANTIS_I2CDATA_CTL); mmwrite(rxd, MANTIS_I2CDATA_CTL);
/* wait for xfer completion */ /* wait for xfer completion */
for (trials = 0; trials < 100; trials++) { for (trials = 0; trials < TRIALS; trials++) {
udelay(500); msleep(1);
stat = mmread(MANTIS_INT_STAT); stat = mmread(MANTIS_INT_STAT);
if (stat & MANTIS_INT_I2CDONE) if (stat & MANTIS_INT_I2CDONE)
break; 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); rxd = mmread(MANTIS_I2CDATA_CTL);
msg->buf[i] = (u8)((rxd >> 8) & 0xFF); msg->buf[i] = (u8)((rxd >> 8) & 0xFF);
dprintk(MANTIS_INFO, 0, "%02x ", msg->buf[i]); 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 ...@@ -93,12 +107,24 @@ static int mantis_i2c_write(struct mantis_pci *mantis, const struct i2c_msg *msg
mmwrite(txd, MANTIS_I2CDATA_CTL); mmwrite(txd, MANTIS_I2CDATA_CTL);
/* wait for xfer completion */ /* wait for xfer completion */
for (trials = 0; trials < 100; trials++) { for (trials = 0; trials < TRIALS; trials++) {
udelay(500); msleep(1);
stat = mmread(MANTIS_INT_STAT); stat = mmread(MANTIS_INT_STAT);
if (stat & MANTIS_INT_I2CDONE) if (stat & MANTIS_INT_I2CDONE)
break; 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"); dprintk(MANTIS_INFO, 0, "]\n");
...@@ -122,7 +148,8 @@ static int mantis_i2c_xfer(struct i2c_adapter *adapter, struct i2c_msg *msgs, in ...@@ -122,7 +148,8 @@ static int mantis_i2c_xfer(struct i2c_adapter *adapter, struct i2c_msg *msgs, in
while (i < num) { while (i < num) {
/* Byte MODE */ /* Byte MODE */
if (((i + 1) < num) && if ((config->i2c_mode & MANTIS_BYTE_MODE) &&
((i + 1) < num) &&
(msgs[i].len < 2) && (msgs[i].len < 2) &&
(msgs[i + 1].len < 2) && (msgs[i + 1].len < 2) &&
(msgs[i + 1].flags & I2C_M_RD)) { (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 ...@@ -136,8 +163,8 @@ static int mantis_i2c_xfer(struct i2c_adapter *adapter, struct i2c_msg *msgs, in
mmwrite(txd, MANTIS_I2CDATA_CTL); mmwrite(txd, MANTIS_I2CDATA_CTL);
/* wait for xfer completion */ /* wait for xfer completion */
for (trials = 0; trials < 100; trials++) { for (trials = 0; trials < TRIALS; trials++) {
udelay(500); msleep(1);
stat = mmread(MANTIS_INT_STAT); stat = mmread(MANTIS_INT_STAT);
if (stat & MANTIS_INT_I2CDONE) if (stat & MANTIS_INT_I2CDONE)
break; break;
......
...@@ -31,7 +31,10 @@ ...@@ -31,7 +31,10 @@
#include "stv0299.h" #include "stv0299.h"
#include "mantis_common.h" #include "mantis_common.h"
#include "mantis_ioc.h"
#include "mantis_dvb.h"
#include "mantis_vp1033.h" #include "mantis_vp1033.h"
#include "mantis_reg.h"
u8 lgtdqcs001f_inittab[] = { u8 lgtdqcs001f_inittab[] = {
0x01, 0x15, 0x01, 0x15,
...@@ -163,6 +166,13 @@ static int vp1033_frontend_init(struct mantis_pci *mantis, struct dvb_frontend * ...@@ -163,6 +166,13 @@ static int vp1033_frontend_init(struct mantis_pci *mantis, struct dvb_frontend *
{ {
struct i2c_adapter *adapter = &mantis->adapter; 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)"); dprintk(MANTIS_ERROR, 1, "Probing for STV0299 (DVB-S)");
fe = stv0299_attach(&lgtdqcs001f_config, adapter); fe = stv0299_attach(&lgtdqcs001f_config, adapter);
...@@ -175,7 +185,13 @@ static int vp1033_frontend_init(struct mantis_pci *mantis, struct dvb_frontend * ...@@ -175,7 +185,13 @@ static int vp1033_frontend_init(struct mantis_pci *mantis, struct dvb_frontend *
} else { } else {
return -1; return -1;
} }
} else {
dprintk(MANTIS_ERROR, 1, "Frontend on <%s> POWER ON failed! <%d>",
adapter->name,
err);
return -EIO;
}
mantis->fe = fe; mantis->fe = fe;
dprintk(MANTIS_ERROR, 1, "Done!"); dprintk(MANTIS_ERROR, 1, "Done!");
...@@ -192,4 +208,6 @@ struct mantis_hwconfig vp1033_config = { ...@@ -192,4 +208,6 @@ struct mantis_hwconfig vp1033_config = {
.bytes = 0, .bytes = 0,
.frontend_init = vp1033_frontend_init, .frontend_init = vp1033_frontend_init,
.power = GPIF_A12,
.reset = GPIF_A13,
}; };
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include "mb86a16.h" #include "mb86a16.h"
#include "mantis_common.h" #include "mantis_common.h"
#include "mantis_ioc.h" #include "mantis_ioc.h"
#include "mantis_dvb.h"
#include "mantis_vp1034.h" #include "mantis_vp1034.h"
#include "mantis_reg.h" #include "mantis_reg.h"
...@@ -74,6 +75,13 @@ static int vp1034_frontend_init(struct mantis_pci *mantis, struct dvb_frontend * ...@@ -74,6 +75,13 @@ static int vp1034_frontend_init(struct mantis_pci *mantis, struct dvb_frontend *
{ {
struct i2c_adapter *adapter = &mantis->adapter; 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)"); dprintk(MANTIS_ERROR, 1, "Probing for MB86A16 (DVB-S/DSS)");
fe = mb86a16_attach(&vp1034_mb86a16_config, adapter); fe = mb86a16_attach(&vp1034_mb86a16_config, adapter);
if (fe) { if (fe) {
...@@ -84,7 +92,13 @@ static int vp1034_frontend_init(struct mantis_pci *mantis, struct dvb_frontend * ...@@ -84,7 +92,13 @@ static int vp1034_frontend_init(struct mantis_pci *mantis, struct dvb_frontend *
} else { } else {
return -1; return -1;
} }
} else {
dprintk(MANTIS_ERROR, 1, "Frontend on <%s> POWER ON failed! <%d>",
adapter->name,
err);
return -EIO;
}
mantis->fe = fe; mantis->fe = fe;
dprintk(MANTIS_ERROR, 1, "Done!"); dprintk(MANTIS_ERROR, 1, "Done!");
...@@ -101,4 +115,6 @@ struct mantis_hwconfig vp1034_config = { ...@@ -101,4 +115,6 @@ struct mantis_hwconfig vp1034_config = {
.bytes = 0, .bytes = 0,
.frontend_init = vp1034_frontend_init, .frontend_init = vp1034_frontend_init,
.power = GPIF_A12,
.reset = GPIF_A13,
}; };
...@@ -31,6 +31,8 @@ ...@@ -31,6 +31,8 @@
#include "tda1002x.h" #include "tda1002x.h"
#include "mantis_common.h" #include "mantis_common.h"
#include "mantis_ioc.h"
#include "mantis_dvb.h"
#include "mantis_vp2033.h" #include "mantis_vp2033.h"
#define MANTIS_MODEL_NAME "VP-2033" #define MANTIS_MODEL_NAME "VP-2033"
...@@ -123,6 +125,13 @@ static int vp2033_frontend_init(struct mantis_pci *mantis, struct dvb_frontend * ...@@ -123,6 +125,13 @@ static int vp2033_frontend_init(struct mantis_pci *mantis, struct dvb_frontend *
{ {
struct i2c_adapter *adapter = &mantis->adapter; 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 CU1216 (DVB-C)"); dprintk(MANTIS_ERROR, 1, "Probing for CU1216 (DVB-C)");
fe = tda10021_attach(&vp2033_tda1002x_cu1216_config, fe = tda10021_attach(&vp2033_tda1002x_cu1216_config,
adapter, adapter,
...@@ -150,6 +159,13 @@ static int vp2033_frontend_init(struct mantis_pci *mantis, struct dvb_frontend * ...@@ -150,6 +159,13 @@ static int vp2033_frontend_init(struct mantis_pci *mantis, struct dvb_frontend *
} else { } else {
return -1; return -1;
} }
} else {
dprintk(MANTIS_ERROR, 1, "Frontend on <%s> POWER ON failed! <%d>",
adapter->name,
err);
return -EIO;
}
mantis->fe = fe; mantis->fe = fe;
dprintk(MANTIS_DEBUG, 1, "Done!"); dprintk(MANTIS_DEBUG, 1, "Done!");
...@@ -167,4 +183,6 @@ struct mantis_hwconfig vp2033_config = { ...@@ -167,4 +183,6 @@ struct mantis_hwconfig vp2033_config = {
.bytes = 0, .bytes = 0,
.frontend_init = vp2033_frontend_init, .frontend_init = vp2033_frontend_init,
.power = GPIF_A12,
.reset = GPIF_A13,
}; };
...@@ -31,6 +31,8 @@ ...@@ -31,6 +31,8 @@
#include "tda1002x.h" #include "tda1002x.h"
#include "mantis_common.h" #include "mantis_common.h"
#include "mantis_ioc.h"
#include "mantis_dvb.h"
#include "mantis_vp2040.h" #include "mantis_vp2040.h"
#define MANTIS_MODEL_NAME "VP-2040" #define MANTIS_MODEL_NAME "VP-2040"
...@@ -123,6 +125,13 @@ static int vp2040_frontend_init(struct mantis_pci *mantis, struct dvb_frontend * ...@@ -123,6 +125,13 @@ static int vp2040_frontend_init(struct mantis_pci *mantis, struct dvb_frontend *
{ {
struct i2c_adapter *adapter = &mantis->adapter; 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 CU1216 (DVB-C)"); dprintk(MANTIS_ERROR, 1, "Probing for CU1216 (DVB-C)");
fe = tda10021_attach(&vp2040_tda1002x_cu1216_config, fe = tda10021_attach(&vp2040_tda1002x_cu1216_config,
adapter, adapter,
...@@ -150,7 +159,13 @@ static int vp2040_frontend_init(struct mantis_pci *mantis, struct dvb_frontend * ...@@ -150,7 +159,13 @@ static int vp2040_frontend_init(struct mantis_pci *mantis, struct dvb_frontend *
} else { } else {
return -1; return -1;
} }
} else {
dprintk(MANTIS_ERROR, 1, "Frontend on <%s> POWER ON failed! <%d>",
adapter->name,
err);
return -EIO;
}
mantis->fe = fe; mantis->fe = fe;
dprintk(MANTIS_DEBUG, 1, "Done!"); dprintk(MANTIS_DEBUG, 1, "Done!");
...@@ -167,4 +182,6 @@ struct mantis_hwconfig vp2040_config = { ...@@ -167,4 +182,6 @@ struct mantis_hwconfig vp2040_config = {
.bytes = 0, .bytes = 0,
.frontend_init = vp2040_frontend_init, .frontend_init = vp2040_frontend_init,
.power = GPIF_A12,
.reset = GPIF_A13,
}; };
...@@ -66,6 +66,8 @@ static int vp3030_frontend_init(struct mantis_pci *mantis, struct dvb_frontend * ...@@ -66,6 +66,8 @@ static int vp3030_frontend_init(struct mantis_pci *mantis, struct dvb_frontend *
msleep(100); msleep(100);
gpio_set_bits(mantis, config->reset, 1); gpio_set_bits(mantis, config->reset, 1);
if (err == 0) {
msleep(250);
dprintk(MANTIS_ERROR, 1, "Probing for 10353 (DVB-T)"); dprintk(MANTIS_ERROR, 1, "Probing for 10353 (DVB-T)");
fe = zl10353_attach(&mantis_vp3030_config, adapter); fe = zl10353_attach(&mantis_vp3030_config, adapter);
...@@ -73,6 +75,14 @@ static int vp3030_frontend_init(struct mantis_pci *mantis, struct dvb_frontend * ...@@ -73,6 +75,14 @@ static int vp3030_frontend_init(struct mantis_pci *mantis, struct dvb_frontend *
return -1; return -1;
tda665x_attach(fe, &env57h12d5_config, adapter); tda665x_attach(fe, &env57h12d5_config, adapter);
} else {
dprintk(MANTIS_ERROR, 1, "Frontend on <%s> POWER ON failed! <%d>",
adapter->name,
err);
return -EIO;
}
mantis->fe = fe; mantis->fe = fe;
dprintk(MANTIS_ERROR, 1, "Done!"); dprintk(MANTIS_ERROR, 1, "Done!");
...@@ -91,4 +101,6 @@ struct mantis_hwconfig vp3030_config = { ...@@ -91,4 +101,6 @@ struct mantis_hwconfig vp3030_config = {
.frontend_init = vp3030_frontend_init, .frontend_init = vp3030_frontend_init,
.power = GPIF_A12, .power = GPIF_A12,
.reset = GPIF_A13, .reset = GPIF_A13,
.i2c_mode = MANTIS_BYTE_MODE
}; };
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment