Commit fc851c66 authored by Antti Palosaari's avatar Antti Palosaari Committed by Mauro Carvalho Chehab

[media] tua9001: add I2C bindings

Add I2C bindings.
Signed-off-by: default avatarAntti Palosaari <crope@iki.fi>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent b3f02270
......@@ -28,7 +28,7 @@ static int tua9001_wr_reg(struct tua9001_priv *priv, u8 reg, u16 val)
u8 buf[3] = { reg, (val >> 8) & 0xff, (val >> 0) & 0xff };
struct i2c_msg msg[1] = {
{
.addr = priv->cfg->i2c_addr,
.addr = priv->i2c_addr,
.flags = 0,
.len = sizeof(buf),
.buf = buf,
......@@ -253,7 +253,7 @@ struct dvb_frontend *tua9001_attach(struct dvb_frontend *fe,
if (priv == NULL)
return NULL;
priv->cfg = cfg;
priv->i2c_addr = cfg->i2c_addr;
priv->i2c = i2c;
if (fe->callback) {
......@@ -289,6 +289,102 @@ err:
}
EXPORT_SYMBOL(tua9001_attach);
static int tua9001_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct tua9001_priv *dev;
struct tua9001_platform_data *pdata = client->dev.platform_data;
struct dvb_frontend *fe = pdata->dvb_frontend;
int ret;
dev = kzalloc(sizeof(*dev), GFP_KERNEL);
if (!dev) {
ret = -ENOMEM;
goto err;
}
dev->client = client;
dev->i2c_addr = client->addr;
dev->i2c = client->adapter;
dev->fe = pdata->dvb_frontend;
if (fe->callback) {
ret = fe->callback(client->adapter,
DVB_FRONTEND_COMPONENT_TUNER,
TUA9001_CMD_CEN, 1);
if (ret)
goto err_kfree;
ret = fe->callback(client->adapter,
DVB_FRONTEND_COMPONENT_TUNER,
TUA9001_CMD_RXEN, 0);
if (ret)
goto err_kfree;
ret = fe->callback(client->adapter,
DVB_FRONTEND_COMPONENT_TUNER,
TUA9001_CMD_RESETN, 1);
if (ret)
goto err_kfree;
}
fe->tuner_priv = dev;
memcpy(&fe->ops.tuner_ops, &tua9001_tuner_ops,
sizeof(struct dvb_tuner_ops));
fe->ops.tuner_ops.release = NULL;
i2c_set_clientdata(client, dev);
dev_info(&client->dev, "Infineon TUA 9001 successfully attached\n");
return 0;
err_kfree:
kfree(dev);
err:
dev_dbg(&client->dev, "failed=%d\n", ret);
return ret;
}
static int tua9001_remove(struct i2c_client *client)
{
struct tua9001_priv *dev = i2c_get_clientdata(client);
struct dvb_frontend *fe = dev->fe;
int ret;
dev_dbg(&client->dev, "\n");
if (fe->callback) {
ret = fe->callback(client->adapter,
DVB_FRONTEND_COMPONENT_TUNER,
TUA9001_CMD_CEN, 0);
if (ret)
goto err_kfree;
}
kfree(dev);
return 0;
err_kfree:
kfree(dev);
dev_dbg(&client->dev, "failed=%d\n", ret);
return ret;
}
static const struct i2c_device_id tua9001_id_table[] = {
{"tua9001", 0},
{}
};
MODULE_DEVICE_TABLE(i2c, tua9001_id_table);
static struct i2c_driver tua9001_driver = {
.driver = {
.owner = THIS_MODULE,
.name = "tua9001",
.suppress_bind_attrs = true,
},
.probe = tua9001_probe,
.remove = tua9001_remove,
.id_table = tua9001_id_table,
};
module_i2c_driver(tua9001_driver);
MODULE_DESCRIPTION("Infineon TUA 9001 silicon tuner driver");
MODULE_AUTHOR("Antti Palosaari <crope@iki.fi>");
MODULE_LICENSE("GPL");
......@@ -24,6 +24,19 @@
#include <linux/kconfig.h>
#include "dvb_frontend.h"
/*
* I2C address
* 0x60,
*/
/**
* struct tua9001_platform_data - Platform data for the tua9001 driver
* @dvb_frontend: DVB frontend.
*/
struct tua9001_platform_data {
struct dvb_frontend *dvb_frontend;
};
struct tua9001_config {
/*
* I2C address
......
......@@ -27,8 +27,10 @@ struct reg_val {
};
struct tua9001_priv {
struct tua9001_config *cfg;
struct i2c_client *client;
struct i2c_adapter *i2c;
u8 i2c_addr;
struct dvb_frontend *fe;
};
#endif
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