|
@@ -353,7 +353,7 @@ static int ngene_command_mutex(struct ngene *dev, struct ngene_command *com)
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
-static int ngene_command(struct ngene *dev, struct ngene_command *com)
|
|
|
|
|
|
+int ngene_command(struct ngene *dev, struct ngene_command *com)
|
|
{
|
|
{
|
|
int result;
|
|
int result;
|
|
|
|
|
|
@@ -364,55 +364,6 @@ static int ngene_command(struct ngene *dev, struct ngene_command *com)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-static int ngene_command_i2c_read(struct ngene *dev, u8 adr,
|
|
|
|
- u8 *out, u8 outlen, u8 *in, u8 inlen, int flag)
|
|
|
|
-{
|
|
|
|
- struct ngene_command com;
|
|
|
|
-
|
|
|
|
- com.cmd.hdr.Opcode = CMD_I2C_READ;
|
|
|
|
- com.cmd.hdr.Length = outlen + 3;
|
|
|
|
- com.cmd.I2CRead.Device = adr << 1;
|
|
|
|
- memcpy(com.cmd.I2CRead.Data, out, outlen);
|
|
|
|
- com.cmd.I2CRead.Data[outlen] = inlen;
|
|
|
|
- com.cmd.I2CRead.Data[outlen + 1] = 0;
|
|
|
|
- com.in_len = outlen + 3;
|
|
|
|
- com.out_len = inlen + 1;
|
|
|
|
-
|
|
|
|
- if (ngene_command(dev, &com) < 0)
|
|
|
|
- return -EIO;
|
|
|
|
-
|
|
|
|
- if ((com.cmd.raw8[0] >> 1) != adr)
|
|
|
|
- return -EIO;
|
|
|
|
-
|
|
|
|
- if (flag)
|
|
|
|
- memcpy(in, com.cmd.raw8, inlen + 1);
|
|
|
|
- else
|
|
|
|
- memcpy(in, com.cmd.raw8 + 1, inlen);
|
|
|
|
- return 0;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-static int ngene_command_i2c_write(struct ngene *dev, u8 adr,
|
|
|
|
- u8 *out, u8 outlen)
|
|
|
|
-{
|
|
|
|
- struct ngene_command com;
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- com.cmd.hdr.Opcode = CMD_I2C_WRITE;
|
|
|
|
- com.cmd.hdr.Length = outlen + 1;
|
|
|
|
- com.cmd.I2CRead.Device = adr << 1;
|
|
|
|
- memcpy(com.cmd.I2CRead.Data, out, outlen);
|
|
|
|
- com.in_len = outlen + 1;
|
|
|
|
- com.out_len = 1;
|
|
|
|
-
|
|
|
|
- if (ngene_command(dev, &com) < 0)
|
|
|
|
- return -EIO;
|
|
|
|
-
|
|
|
|
- if (com.cmd.raw8[0] == 1)
|
|
|
|
- return -EIO;
|
|
|
|
-
|
|
|
|
- return 0;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
static int ngene_command_load_firmware(struct ngene *dev,
|
|
static int ngene_command_load_firmware(struct ngene *dev,
|
|
u8 *ngene_fw, u32 size)
|
|
u8 *ngene_fw, u32 size)
|
|
{
|
|
{
|
|
@@ -478,7 +429,7 @@ static int ngene_command_config_free_buf(struct ngene *dev, u8 *config)
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
-static int ngene_command_gpio_set(struct ngene *dev, u8 select, u8 level)
|
|
|
|
|
|
+int ngene_command_gpio_set(struct ngene *dev, u8 select, u8 level)
|
|
{
|
|
{
|
|
struct ngene_command com;
|
|
struct ngene_command com;
|
|
|
|
|
|
@@ -776,91 +727,9 @@ static int ngene_command_stream_control(struct ngene *dev, u8 stream,
|
|
|
|
|
|
|
|
|
|
/****************************************************************************/
|
|
/****************************************************************************/
|
|
-/* I2C **********************************************************************/
|
|
|
|
|
|
+/* EEPROM TAGS **************************************************************/
|
|
/****************************************************************************/
|
|
/****************************************************************************/
|
|
|
|
|
|
-static void ngene_i2c_set_bus(struct ngene *dev, int bus)
|
|
|
|
-{
|
|
|
|
- if (!(dev->card_info->i2c_access & 2))
|
|
|
|
- return;
|
|
|
|
- if (dev->i2c_current_bus == bus)
|
|
|
|
- return;
|
|
|
|
-
|
|
|
|
- switch (bus) {
|
|
|
|
- case 0:
|
|
|
|
- ngene_command_gpio_set(dev, 3, 0);
|
|
|
|
- ngene_command_gpio_set(dev, 2, 1);
|
|
|
|
- break;
|
|
|
|
-
|
|
|
|
- case 1:
|
|
|
|
- ngene_command_gpio_set(dev, 2, 0);
|
|
|
|
- ngene_command_gpio_set(dev, 3, 1);
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- dev->i2c_current_bus = bus;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-static int ngene_i2c_master_xfer(struct i2c_adapter *adapter,
|
|
|
|
- struct i2c_msg msg[], int num)
|
|
|
|
-{
|
|
|
|
- struct ngene_channel *chan =
|
|
|
|
- (struct ngene_channel *)i2c_get_adapdata(adapter);
|
|
|
|
- struct ngene *dev = chan->dev;
|
|
|
|
-
|
|
|
|
- down(&dev->i2c_switch_mutex);
|
|
|
|
- ngene_i2c_set_bus(dev, chan->number);
|
|
|
|
-
|
|
|
|
- if (num == 2 && msg[1].flags & I2C_M_RD && !(msg[0].flags & I2C_M_RD))
|
|
|
|
- if (!ngene_command_i2c_read(dev, msg[0].addr,
|
|
|
|
- msg[0].buf, msg[0].len,
|
|
|
|
- msg[1].buf, msg[1].len, 0))
|
|
|
|
- goto done;
|
|
|
|
-
|
|
|
|
- if (num == 1 && !(msg[0].flags & I2C_M_RD))
|
|
|
|
- if (!ngene_command_i2c_write(dev, msg[0].addr,
|
|
|
|
- msg[0].buf, msg[0].len))
|
|
|
|
- goto done;
|
|
|
|
- if (num == 1 && (msg[0].flags & I2C_M_RD))
|
|
|
|
- if (!ngene_command_i2c_read(dev, msg[0].addr, NULL, 0,
|
|
|
|
- msg[0].buf, msg[0].len, 0))
|
|
|
|
- goto done;
|
|
|
|
-
|
|
|
|
- up(&dev->i2c_switch_mutex);
|
|
|
|
- return -EIO;
|
|
|
|
-
|
|
|
|
-done:
|
|
|
|
- up(&dev->i2c_switch_mutex);
|
|
|
|
- return num;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-static u32 ngene_i2c_functionality(struct i2c_adapter *adap)
|
|
|
|
-{
|
|
|
|
- return I2C_FUNC_SMBUS_EMUL;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-static struct i2c_algorithm ngene_i2c_algo = {
|
|
|
|
- .master_xfer = ngene_i2c_master_xfer,
|
|
|
|
- .functionality = ngene_i2c_functionality,
|
|
|
|
-};
|
|
|
|
-
|
|
|
|
-static int ngene_i2c_init(struct ngene *dev, int dev_nr)
|
|
|
|
-{
|
|
|
|
- struct i2c_adapter *adap = &(dev->channel[dev_nr].i2c_adapter);
|
|
|
|
-
|
|
|
|
- i2c_set_adapdata(adap, &(dev->channel[dev_nr]));
|
|
|
|
- adap->class = I2C_CLASS_TV_DIGITAL | I2C_CLASS_TV_ANALOG;
|
|
|
|
-
|
|
|
|
- strcpy(adap->name, "nGene");
|
|
|
|
-
|
|
|
|
- adap->algo = &ngene_i2c_algo;
|
|
|
|
- adap->algo_data = (void *)&(dev->channel[dev_nr]);
|
|
|
|
- adap->dev.parent = &dev->pci_dev->dev;
|
|
|
|
-
|
|
|
|
- return i2c_add_adapter(adap);
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-
|
|
|
|
/****************************************************************************/
|
|
/****************************************************************************/
|
|
/* DVB functions and API interface ******************************************/
|
|
/* DVB functions and API interface ******************************************/
|
|
/****************************************************************************/
|
|
/****************************************************************************/
|