Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 179444
b: refs/heads/master
c: df0cca1
h: refs/heads/master
v: v3
  • Loading branch information
Manu Abraham authored and Mauro Carvalho Chehab committed Jan 17, 2010
1 parent d3fb4f0 commit c7a9bef
Show file tree
Hide file tree
Showing 14 changed files with 216 additions and 219 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: bd1fcac0148fb4a44395227edb0ff8ee31e09de1
refs/heads/master: df0cca174b4d85ea041509a13e5e68b377758bf1
14 changes: 12 additions & 2 deletions trunk/drivers/media/dvb/mantis/mantis_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,19 @@
#define mmaor(dat, addr) mmwrite((dat) | ((mask) & mmread(addr)), addr)


struct mantis_hwconfig {
char *model_name;
char *dev_type;
};


struct mantis_pci {
/* PCI stuff */
u16 vendor_id;
u16 device_id;
u16 subsystem_vendor;
u16 subsystem_device;

u8 latency;

struct pci_dev *pdev;
Expand Down Expand Up @@ -110,7 +119,7 @@ struct mantis_pci {

u8 feeds;

struct mantis_config *config;
struct mantis_hwconfig *hwconfig;

u32 mantis_int_stat;
u32 mantis_int_mask;
Expand All @@ -121,7 +130,8 @@ struct mantis_pci {
u32 sub_device_id;

/* A12 A13 A14 */
int gpio_status;};
int gpio_status;
};

extern unsigned int verbose;
extern unsigned int devs;
Expand Down
95 changes: 47 additions & 48 deletions trunk/drivers/media/dvb/mantis/mantis_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@

#include "mantis_common.h"
#include "mantis_core.h"

#include "mantis_vp1033.h"
#include "mantis_vp1034.h"
#include "mantis_vp2033.h"
#include "mantis_vp3030.h"

static int read_eeprom_byte(struct mantis_pci *mantis, u8 *data, u8 length)
{
Expand All @@ -45,7 +48,7 @@ static int read_eeprom_byte(struct mantis_pci *mantis, u8 *data, u8 length)

return err;
}
msleep_interruptible(2);
// msleep_interruptible(2);

return 0;
}
Expand All @@ -72,41 +75,6 @@ static int write_eeprom_byte(struct mantis_pci *mantis, u8 *data, u8 length)
return 0;
}

static int get_subdevice_id(struct mantis_pci *mantis)
{
int err;
static u8 sub_device_id[2];

mantis->sub_device_id = 0;
sub_device_id[0] = 0xfc;
if ((err = read_eeprom_byte(mantis, &sub_device_id[0], 2)) < 0) {
dprintk(verbose, MANTIS_ERROR, 1, "Mantis EEPROM read error");
return err;
}
mantis->sub_device_id = (sub_device_id[0] << 8) | sub_device_id[1];
dprintk(verbose, MANTIS_ERROR, 1, "Sub Device ID=[0x%04x]",
mantis->sub_device_id);

return 0;
}

static int get_subvendor_id(struct mantis_pci *mantis)
{
int err;
static u8 sub_vendor_id[2];

mantis->sub_vendor_id = 0;
sub_vendor_id[0] = 0xfe;
if ((err = read_eeprom_byte(mantis, &sub_vendor_id[0], 2)) < 0) {
dprintk(verbose, MANTIS_ERROR, 1, "Mantis EEPROM read error");
return err;
}
mantis->sub_vendor_id = (sub_vendor_id[0] << 8) | sub_vendor_id[1];
dprintk(verbose, MANTIS_ERROR, 1, "Sub Vendor ID=[0x%04x]",
mantis->sub_vendor_id);

return 0;
}

static int get_mac_address(struct mantis_pci *mantis)
{
Expand All @@ -118,20 +86,60 @@ static int get_mac_address(struct mantis_pci *mantis)

return err;
}
dprintk(verbose, MANTIS_ERROR, 1,
"MAC Address=[%02x:%02x:%02x:%02x:%02x:%02x]",
dprintk(verbose, MANTIS_ERROR, 0,
" MAC Address=[%02x:%02x:%02x:%02x:%02x:%02x]\n",
mantis->mac_address[0], mantis->mac_address[1],
mantis->mac_address[2], mantis->mac_address[3],
mantis->mac_address[4], mantis->mac_address[5]);

return 0;
}

#define MANTIS_MODEL_UNKNOWN "UNKNOWN"
#define MANTIS_DEV_UNKNOWN "UNKNOWN"

struct mantis_hwconfig unknown_device = {
.model_name = MANTIS_MODEL_UNKNOWN,
.dev_type = MANTIS_DEV_UNKNOWN,
};

static void mantis_load_config(struct mantis_pci *mantis)
{
switch (mantis->subsystem_device) {
case MANTIS_VP_1033_DVB_S: // VP-1033
mantis->hwconfig = &vp1033_mantis_config;
break;
case MANTIS_VP_1034_DVB_S: // VP-1034
mantis->hwconfig = &vp1034_mantis_config;
break;
case MANTIS_VP_2033_DVB_C: // VP-2033
mantis->hwconfig = &vp2033_mantis_config;
break;
case MANTIS_VP_3030_DVB_T: // VP-3030
mantis->hwconfig = &vp3030_mantis_config;
break;
default:
mantis->hwconfig = &unknown_device;
break;
}
}

int mantis_core_init(struct mantis_pci *mantis)
{
int err = 0;

mantis_load_config(mantis);
dprintk(verbose, MANTIS_ERROR, 0, "found a %s PCI %s device on (%02x:%02x.%x),\n",
mantis->hwconfig->model_name, mantis->hwconfig->dev_type,
mantis->pdev->bus->number, PCI_SLOT(mantis->pdev->devfn), PCI_FUNC(mantis->pdev->devfn));
dprintk(verbose, MANTIS_ERROR, 0, " Mantis Rev %d [%04x:%04x], ",
mantis->revision,
mantis->subsystem_vendor, mantis->subsystem_device);
dprintk(verbose, MANTIS_ERROR, 0,
"irq: %d, latency: %d\n memory: 0x%lx, mmio: 0x%p\n",
mantis->pdev->irq, mantis->latency,
mantis->mantis_addr, mantis->mantis_mmio);

if ((err = mantis_i2c_init(mantis)) < 0) {
dprintk(verbose, MANTIS_ERROR, 1, "Mantis I2C init failed");
return err;
Expand All @@ -140,14 +148,6 @@ int mantis_core_init(struct mantis_pci *mantis)
dprintk(verbose, MANTIS_ERROR, 1, "get MAC address failed");
return err;
}
if ((err = get_subvendor_id(mantis)) < 0) {
dprintk(verbose, MANTIS_ERROR, 1, "get Sub vendor ID failed");
return err;
}
if ((err = get_subdevice_id(mantis)) < 0) {
dprintk(verbose, MANTIS_ERROR, 1, "get Sub device ID failed");
return err;
}
if ((err = mantis_dma_init(mantis)) < 0) {
dprintk(verbose, MANTIS_ERROR, 1, "Mantis DMA init failed");
return err;
Expand All @@ -162,7 +162,6 @@ int mantis_core_init(struct mantis_pci *mantis)

int mantis_core_exit(struct mantis_pci *mantis)
{

mantis_dma_stop(mantis);
dprintk(verbose, MANTIS_ERROR, 1, "DMA engine stopping");
if (mantis_dma_exit(mantis) < 0)
Expand Down
13 changes: 2 additions & 11 deletions trunk/drivers/media/dvb/mantis/mantis_dvb.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,22 +206,13 @@ int __devinit mantis_dvb_init(struct mantis_pci *mantis)
return result;
}

#define MANTIS_VP_1027_DVB_S 0x0013
#define MANTIS_VP_1033_DVB_S 0x0016
#define MANTIS_VP_1034_DVB_S 0x0014
#define MANTIS_VP_1040_DVB_S2
#define MANTIS_VP_1041_DVB_S2
#define MANTIS_VP_2033_DVB_C 0x0008
#define MANTIS_VP_3024_DVB_T 0x0009
#define MANTIS_VP_3030_DVB_T 0x0024

int __devinit mantis_frontend_init(struct mantis_pci *mantis)
{
dprintk(verbose, MANTIS_DEBUG, 1, "Mantis frontend Init");
mantis_fe_powerup(mantis);
mantis_frontend_reset(mantis);
dprintk(verbose, MANTIS_DEBUG, 1, "Device ID=%02x", mantis->sub_device_id);
switch (mantis->sub_device_id) {
dprintk(verbose, MANTIS_DEBUG, 1, "Device ID=%02x", mantis->subsystem_device);
switch (mantis->subsystem_device) {
case MANTIS_VP_1033_DVB_S: // VP-1033
dprintk(verbose, MANTIS_ERROR, 1, "Probing for STV0299 (DVB-S)");
mantis->fe = stv0299_attach(&lgtdqcs001f_config,
Expand Down
68 changes: 30 additions & 38 deletions trunk/drivers/media/dvb/mantis/mantis_i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,32 +33,27 @@
static int mantis_ack_wait(struct mantis_pci *mantis)
{
int rc = 0;
u32 timeout = 0;

if (wait_event_interruptible_timeout(mantis->i2c_wq,
mantis->mantis_int_stat & MANTIS_INT_I2CRACK,
msecs_to_jiffies(50)) == -ERESTARTSYS)
mantis->mantis_int_stat & MANTIS_INT_I2CDONE,
msecs_to_jiffies(50)) == -ERESTARTSYS) {

dprintk(verbose, MANTIS_DEBUG, 1, "I2C Transfer failed, Master !I2CDONE");
rc = -EREMOTEIO;
/*
// Wait till we are done
while (mantis->mantis_int_stat & MANTIS_INT_I2CRACK){
if (mantis->mantis_int_stat & MANTIS_INT_I2CDONE) {
mantis->mantis_int_stat &= ~MANTIS_INT_I2CRACK;
// dprintk(verbose, MANTIS_DEBUG, 1, "SLAVE RACK 'ed .. Waiting for I2CDONE");
}
while (!(mantis->mantis_int_stat & MANTIS_INT_I2CRACK)) {
dprintk(verbose, MANTIS_DEBUG, 1, "Waiting for Slave RACK");
mantis->mantis_int_stat = mmread(MANTIS_INT_STAT);
msleep(5);
timeout++;
if (timeout > 500) {
dprintk(verbose, MANTIS_ERROR, 1, "Slave RACK Fail !");
rc = -EREMOTEIO;
break;
}
}
if (mantis->mantis_int_stat & MANTIS_INT_I2CDONE) {
// dprintk(verbose, MANTIS_DEBUG, 1, "Mantis Int I2CDONE");
rc = 1;
}
mantis->mantis_int_stat &= ~MANTIS_INT_I2CDONE;
*/
// ..
if (mantis->mantis_int_stat & MANTIS_INT_I2CRACK)
msleep_interruptible(10);
udelay(350);

return rc;
}
Expand All @@ -67,7 +62,7 @@ static int mantis_i2c_read(struct mantis_pci *mantis, const struct i2c_msg *msg)
{
u32 rxd, i;

dprintk(verbose, MANTIS_DEBUG, 1, "Address=[0x%02x]", msg->addr);
dprintk(verbose, MANTIS_INFO, 0, " %s: Address=[0x%02x] <R>[ ", __func__, msg->addr);
for (i = 0; i < msg->len; i++) {
rxd = (msg->addr << 25) | (1 << 24)
| MANTIS_I2C_RATE_3
Expand All @@ -77,18 +72,17 @@ static int mantis_i2c_read(struct mantis_pci *mantis, const struct i2c_msg *msg)
if (i == (msg->len - 1))
rxd &= ~MANTIS_I2C_STOP;

mmwrite(MANTIS_INT_I2CDONE, MANTIS_INT_STAT);
mmwrite(rxd, MANTIS_I2CDATA_CTL);
if (mantis_ack_wait(mantis) < 0) {
if (mantis_ack_wait(mantis) != 0) {
dprintk(verbose, MANTIS_DEBUG, 1, "ACK failed<R>");
return -EIO;
return -EREMOTEIO;
}
rxd = mmread(MANTIS_I2CDATA_CTL);
msg->buf[i] = (u8)((rxd >> 8) & 0xFF);
dprintk(verbose, MANTIS_DEBUG, 1,
"Data<R[%d]>=[0x%02x]", i, msg->buf[i]);

msleep_interruptible(2);
dprintk(verbose, MANTIS_INFO, 0, "%02x ", msg->buf[i]);
}
dprintk(verbose, MANTIS_INFO, 0, "]\n");

return 0;
}
Expand All @@ -98,9 +92,9 @@ static int mantis_i2c_write(struct mantis_pci *mantis, const struct i2c_msg *msg
int i;
u32 txd = 0;

dprintk(verbose, MANTIS_DEBUG, 1, "Address=[0x%02x]", msg->addr);
dprintk(verbose, MANTIS_INFO, 0, " %s: Address=[0x%02x] <W>[ ", __func__, msg->addr);
for (i = 0; i < msg->len; i++) {
dprintk(verbose, MANTIS_DEBUG, 1, "Data<W[%d]>=[0x%02x]", i, msg->buf[i]);
dprintk(verbose, MANTIS_INFO, 0, "%02x ", msg->buf[i]);
txd = (msg->addr << 25) | (msg->buf[i] << 8)
| MANTIS_I2C_RATE_3
| MANTIS_I2C_STOP
Expand All @@ -109,13 +103,14 @@ static int mantis_i2c_write(struct mantis_pci *mantis, const struct i2c_msg *msg
if (i == (msg->len - 1))
txd &= ~MANTIS_I2C_STOP;

mmwrite(MANTIS_INT_I2CDONE, MANTIS_INT_STAT);
mmwrite(txd, MANTIS_I2CDATA_CTL);
if (mantis_ack_wait(mantis) < 0) {
if (mantis_ack_wait(mantis) != 0) {
dprintk(verbose, MANTIS_DEBUG, 1, "ACK failed<W>");
return -1;
return -EREMOTEIO;
}
udelay(500);
}
dprintk(verbose, MANTIS_INFO, 0, "]\n");

return 0;
}
Expand Down Expand Up @@ -159,7 +154,7 @@ static struct i2c_adapter mantis_i2c_adapter = {

int __devinit mantis_i2c_init(struct mantis_pci *mantis)
{
u32 intstat;
u32 intstat, intmask;

memcpy(&mantis->adapter, &mantis_i2c_adapter, sizeof (mantis_i2c_adapter));
i2c_set_adapdata(&mantis->adapter, mantis);
Expand All @@ -169,15 +164,12 @@ int __devinit mantis_i2c_init(struct mantis_pci *mantis)

dprintk(verbose, MANTIS_DEBUG, 1, "Initializing I2C ..");

// Clear all interrupts
intstat = mmread(MANTIS_INT_STAT);
intmask = mmread(MANTIS_INT_MASK);
mmwrite(intstat, MANTIS_INT_STAT);
mmwrite(intmask | MANTIS_INT_I2CDONE, MANTIS_INT_MASK);

mmwrite(mmread(MANTIS_INT_MASK) | MANTIS_INT_I2CDONE,
MANTIS_INT_MASK);

dprintk(verbose, MANTIS_DEBUG, 1, "[0x%08x/%08x]",
mmread(MANTIS_INT_STAT), mmread(MANTIS_INT_MASK));
dprintk(verbose, MANTIS_DEBUG, 1, "[0x%08x/%08x]", intstat, intmask);

return 0;
}
Expand Down
Loading

0 comments on commit c7a9bef

Please sign in to comment.