mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-15 16:24:13 +08:00
[media] it913x: change driver model from i2c to platform
That tuner is integrated to demodulator and communicates via demodulators address space. We cannot register both demodulator and tuner having same address to same I2C bus, so better to change it platform driver in order to implement I2C adapter correctly. Signed-off-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
This commit is contained in:
parent
3461831adc
commit
675ee80163
@ -17,10 +17,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "it913x.h"
|
#include "it913x.h"
|
||||||
|
#include <linux/platform_device.h>
|
||||||
#include <linux/regmap.h>
|
#include <linux/regmap.h>
|
||||||
|
|
||||||
struct it913x_dev {
|
struct it913x_dev {
|
||||||
struct i2c_client *client;
|
struct platform_device *pdev;
|
||||||
struct regmap *regmap;
|
struct regmap *regmap;
|
||||||
struct dvb_frontend *fe;
|
struct dvb_frontend *fe;
|
||||||
u8 chip_ver:2;
|
u8 chip_ver:2;
|
||||||
@ -35,13 +36,14 @@ struct it913x_dev {
|
|||||||
static int it913x_init(struct dvb_frontend *fe)
|
static int it913x_init(struct dvb_frontend *fe)
|
||||||
{
|
{
|
||||||
struct it913x_dev *dev = fe->tuner_priv;
|
struct it913x_dev *dev = fe->tuner_priv;
|
||||||
|
struct platform_device *pdev = dev->pdev;
|
||||||
int ret;
|
int ret;
|
||||||
unsigned int utmp;
|
unsigned int utmp;
|
||||||
u8 iqik_m_cal, nv_val, buf[2];
|
u8 iqik_m_cal, nv_val, buf[2];
|
||||||
static const u8 nv[] = {48, 32, 24, 16, 12, 8, 6, 4, 2};
|
static const u8 nv[] = {48, 32, 24, 16, 12, 8, 6, 4, 2};
|
||||||
unsigned long timeout;
|
unsigned long timeout;
|
||||||
|
|
||||||
dev_dbg(&dev->client->dev, "role %u\n", dev->role);
|
dev_dbg(&pdev->dev, "role %u\n", dev->role);
|
||||||
|
|
||||||
ret = regmap_write(dev->regmap, 0x80ec4c, 0x68);
|
ret = regmap_write(dev->regmap, 0x80ec4c, 0x68);
|
||||||
if (ret)
|
if (ret)
|
||||||
@ -69,7 +71,7 @@ static int it913x_init(struct dvb_frontend *fe)
|
|||||||
iqik_m_cal = 6;
|
iqik_m_cal = 6;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
dev_err(&dev->client->dev, "unknown clock identifier %d\n", utmp);
|
dev_err(&pdev->dev, "unknown clock identifier %d\n", utmp);
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,14 +96,14 @@ static int it913x_init(struct dvb_frontend *fe)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
dev_dbg(&dev->client->dev, "r_fbc_m_bdry took %u ms, val %u\n",
|
dev_dbg(&pdev->dev, "r_fbc_m_bdry took %u ms, val %u\n",
|
||||||
jiffies_to_msecs(jiffies) -
|
jiffies_to_msecs(jiffies) -
|
||||||
(jiffies_to_msecs(timeout) - TIMEOUT), utmp);
|
(jiffies_to_msecs(timeout) - TIMEOUT), utmp);
|
||||||
|
|
||||||
dev->fn_min = dev->xtal * utmp;
|
dev->fn_min = dev->xtal * utmp;
|
||||||
dev->fn_min /= (dev->fdiv * nv_val);
|
dev->fn_min /= (dev->fdiv * nv_val);
|
||||||
dev->fn_min *= 1000;
|
dev->fn_min *= 1000;
|
||||||
dev_dbg(&dev->client->dev, "fn_min %u\n", dev->fn_min);
|
dev_dbg(&pdev->dev, "fn_min %u\n", dev->fn_min);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Chip version BX never sets that flag so we just wait 50ms in that
|
* Chip version BX never sets that flag so we just wait 50ms in that
|
||||||
@ -121,7 +123,7 @@ static int it913x_init(struct dvb_frontend *fe)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
dev_dbg(&dev->client->dev, "p_tsm_init_mode took %u ms, val %u\n",
|
dev_dbg(&pdev->dev, "p_tsm_init_mode took %u ms, val %u\n",
|
||||||
jiffies_to_msecs(jiffies) -
|
jiffies_to_msecs(jiffies) -
|
||||||
(jiffies_to_msecs(timeout) - TIMEOUT), utmp);
|
(jiffies_to_msecs(timeout) - TIMEOUT), utmp);
|
||||||
} else {
|
} else {
|
||||||
@ -148,16 +150,17 @@ static int it913x_init(struct dvb_frontend *fe)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
err:
|
err:
|
||||||
dev_dbg(&dev->client->dev, "failed %d\n", ret);
|
dev_dbg(&pdev->dev, "failed %d\n", ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int it913x_sleep(struct dvb_frontend *fe)
|
static int it913x_sleep(struct dvb_frontend *fe)
|
||||||
{
|
{
|
||||||
struct it913x_dev *dev = fe->tuner_priv;
|
struct it913x_dev *dev = fe->tuner_priv;
|
||||||
|
struct platform_device *pdev = dev->pdev;
|
||||||
int ret, len;
|
int ret, len;
|
||||||
|
|
||||||
dev_dbg(&dev->client->dev, "role %u\n", dev->role);
|
dev_dbg(&pdev->dev, "role %u\n", dev->role);
|
||||||
|
|
||||||
dev->active = false;
|
dev->active = false;
|
||||||
|
|
||||||
@ -174,7 +177,7 @@ static int it913x_sleep(struct dvb_frontend *fe)
|
|||||||
else
|
else
|
||||||
len = 15;
|
len = 15;
|
||||||
|
|
||||||
dev_dbg(&dev->client->dev, "role %u, len %d\n", dev->role, len);
|
dev_dbg(&pdev->dev, "role %u, len %d\n", dev->role, len);
|
||||||
|
|
||||||
ret = regmap_bulk_write(dev->regmap, 0x80ec02,
|
ret = regmap_bulk_write(dev->regmap, 0x80ec02,
|
||||||
"\x3f\x1f\x3f\x3e\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
|
"\x3f\x1f\x3f\x3e\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
|
||||||
@ -206,13 +209,14 @@ static int it913x_sleep(struct dvb_frontend *fe)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
err:
|
err:
|
||||||
dev_dbg(&dev->client->dev, "failed %d\n", ret);
|
dev_dbg(&pdev->dev, "failed %d\n", ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int it913x_set_params(struct dvb_frontend *fe)
|
static int it913x_set_params(struct dvb_frontend *fe)
|
||||||
{
|
{
|
||||||
struct it913x_dev *dev = fe->tuner_priv;
|
struct it913x_dev *dev = fe->tuner_priv;
|
||||||
|
struct platform_device *pdev = dev->pdev;
|
||||||
struct dtv_frontend_properties *c = &fe->dtv_property_cache;
|
struct dtv_frontend_properties *c = &fe->dtv_property_cache;
|
||||||
int ret;
|
int ret;
|
||||||
unsigned int utmp;
|
unsigned int utmp;
|
||||||
@ -220,7 +224,7 @@ static int it913x_set_params(struct dvb_frontend *fe)
|
|||||||
u16 iqik_m_cal, n_div;
|
u16 iqik_m_cal, n_div;
|
||||||
u8 u8tmp, n, l_band, lna_band;
|
u8 u8tmp, n, l_band, lna_band;
|
||||||
|
|
||||||
dev_dbg(&dev->client->dev, "role=%u, frequency %u, bandwidth_hz %u\n",
|
dev_dbg(&pdev->dev, "role=%u, frequency %u, bandwidth_hz %u\n",
|
||||||
dev->role, c->frequency, c->bandwidth_hz);
|
dev->role, c->frequency, c->bandwidth_hz);
|
||||||
|
|
||||||
if (!dev->active) {
|
if (!dev->active) {
|
||||||
@ -286,7 +290,7 @@ static int it913x_set_params(struct dvb_frontend *fe)
|
|||||||
pre_lo_freq += (u32) n << 13;
|
pre_lo_freq += (u32) n << 13;
|
||||||
/* Frequency OMEGA_IQIK_M_CAL_MID*/
|
/* Frequency OMEGA_IQIK_M_CAL_MID*/
|
||||||
t_cal_freq = pre_lo_freq + (u32)iqik_m_cal;
|
t_cal_freq = pre_lo_freq + (u32)iqik_m_cal;
|
||||||
dev_dbg(&dev->client->dev, "t_cal_freq %u, pre_lo_freq %u\n",
|
dev_dbg(&pdev->dev, "t_cal_freq %u, pre_lo_freq %u\n",
|
||||||
t_cal_freq, pre_lo_freq);
|
t_cal_freq, pre_lo_freq);
|
||||||
|
|
||||||
if (c->frequency <= 440000000) {
|
if (c->frequency <= 440000000) {
|
||||||
@ -365,7 +369,7 @@ static int it913x_set_params(struct dvb_frontend *fe)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
err:
|
err:
|
||||||
dev_dbg(&dev->client->dev, "failed %d\n", ret);
|
dev_dbg(&pdev->dev, "failed %d\n", ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -381,40 +385,31 @@ static const struct dvb_tuner_ops it913x_tuner_ops = {
|
|||||||
.set_params = it913x_set_params,
|
.set_params = it913x_set_params,
|
||||||
};
|
};
|
||||||
|
|
||||||
static int it913x_probe(struct i2c_client *client,
|
static int it913x_probe(struct platform_device *pdev)
|
||||||
const struct i2c_device_id *id)
|
|
||||||
{
|
{
|
||||||
struct it913x_config *cfg = client->dev.platform_data;
|
struct it913x_platform_data *pdata = pdev->dev.platform_data;
|
||||||
struct dvb_frontend *fe = cfg->fe;
|
struct dvb_frontend *fe = pdata->fe;
|
||||||
struct it913x_dev *dev;
|
struct it913x_dev *dev;
|
||||||
int ret;
|
int ret;
|
||||||
char *chip_ver_str;
|
char *chip_ver_str;
|
||||||
static const struct regmap_config regmap_config = {
|
|
||||||
.reg_bits = 24,
|
|
||||||
.val_bits = 8,
|
|
||||||
};
|
|
||||||
|
|
||||||
dev = kzalloc(sizeof(struct it913x_dev), GFP_KERNEL);
|
dev = kzalloc(sizeof(struct it913x_dev), GFP_KERNEL);
|
||||||
if (dev == NULL) {
|
if (dev == NULL) {
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
dev_err(&client->dev, "kzalloc() failed\n");
|
dev_err(&pdev->dev, "kzalloc() failed\n");
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
dev->client = client;
|
dev->pdev = pdev;
|
||||||
dev->fe = cfg->fe;
|
dev->regmap = pdata->regmap;
|
||||||
dev->chip_ver = cfg->chip_ver;
|
dev->fe = pdata->fe;
|
||||||
dev->role = cfg->role;
|
dev->chip_ver = pdata->chip_ver;
|
||||||
dev->regmap = regmap_init_i2c(client, ®map_config);
|
dev->role = pdata->role;
|
||||||
if (IS_ERR(dev->regmap)) {
|
|
||||||
ret = PTR_ERR(dev->regmap);
|
|
||||||
goto err_kfree;
|
|
||||||
}
|
|
||||||
|
|
||||||
fe->tuner_priv = dev;
|
fe->tuner_priv = dev;
|
||||||
memcpy(&fe->ops.tuner_ops, &it913x_tuner_ops,
|
memcpy(&fe->ops.tuner_ops, &it913x_tuner_ops,
|
||||||
sizeof(struct dvb_tuner_ops));
|
sizeof(struct dvb_tuner_ops));
|
||||||
i2c_set_clientdata(client, dev);
|
platform_set_drvdata(pdev, dev);
|
||||||
|
|
||||||
if (dev->chip_ver == 1)
|
if (dev->chip_ver == 1)
|
||||||
chip_ver_str = "AX";
|
chip_ver_str = "AX";
|
||||||
@ -423,51 +418,39 @@ static int it913x_probe(struct i2c_client *client,
|
|||||||
else
|
else
|
||||||
chip_ver_str = "??";
|
chip_ver_str = "??";
|
||||||
|
|
||||||
dev_info(&dev->client->dev, "ITE IT913X %s successfully attached\n",
|
dev_info(&pdev->dev, "ITE IT913X %s successfully attached\n",
|
||||||
chip_ver_str);
|
chip_ver_str);
|
||||||
dev_dbg(&dev->client->dev, "chip_ver %u, role %u\n",
|
dev_dbg(&pdev->dev, "chip_ver %u, role %u\n", dev->chip_ver, dev->role);
|
||||||
dev->chip_ver, dev->role);
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err_kfree:
|
|
||||||
kfree(dev);
|
|
||||||
err:
|
err:
|
||||||
dev_dbg(&client->dev, "failed %d\n", ret);
|
dev_dbg(&pdev->dev, "failed %d\n", ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int it913x_remove(struct i2c_client *client)
|
static int it913x_remove(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct it913x_dev *dev = i2c_get_clientdata(client);
|
struct it913x_dev *dev = platform_get_drvdata(pdev);
|
||||||
struct dvb_frontend *fe = dev->fe;
|
struct dvb_frontend *fe = dev->fe;
|
||||||
|
|
||||||
dev_dbg(&client->dev, "\n");
|
dev_dbg(&pdev->dev, "\n");
|
||||||
|
|
||||||
memset(&fe->ops.tuner_ops, 0, sizeof(struct dvb_tuner_ops));
|
memset(&fe->ops.tuner_ops, 0, sizeof(struct dvb_tuner_ops));
|
||||||
fe->tuner_priv = NULL;
|
fe->tuner_priv = NULL;
|
||||||
regmap_exit(dev->regmap);
|
|
||||||
kfree(dev);
|
kfree(dev);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct i2c_device_id it913x_id_table[] = {
|
static struct platform_driver it913x_driver = {
|
||||||
{"it913x", 0},
|
|
||||||
{}
|
|
||||||
};
|
|
||||||
MODULE_DEVICE_TABLE(i2c, it913x_id_table);
|
|
||||||
|
|
||||||
static struct i2c_driver it913x_driver = {
|
|
||||||
.driver = {
|
.driver = {
|
||||||
.name = "it913x",
|
.name = "it913x",
|
||||||
.suppress_bind_attrs = true,
|
.suppress_bind_attrs = true,
|
||||||
},
|
},
|
||||||
.probe = it913x_probe,
|
.probe = it913x_probe,
|
||||||
.remove = it913x_remove,
|
.remove = it913x_remove,
|
||||||
.id_table = it913x_id_table,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
module_i2c_driver(it913x_driver);
|
module_platform_driver(it913x_driver);
|
||||||
|
|
||||||
MODULE_DESCRIPTION("ITE IT913X silicon tuner driver");
|
MODULE_DESCRIPTION("ITE IT913X silicon tuner driver");
|
||||||
MODULE_AUTHOR("Antti Palosaari <crope@iki.fi>");
|
MODULE_AUTHOR("Antti Palosaari <crope@iki.fi>");
|
||||||
|
@ -21,30 +21,25 @@
|
|||||||
|
|
||||||
#include "dvb_frontend.h"
|
#include "dvb_frontend.h"
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* I2C address
|
* struct it913x_platform_data - Platform data for the it913x driver
|
||||||
* 0x38, 0x3a, 0x3c, 0x3e
|
* @regmap: af9033 demod driver regmap.
|
||||||
*/
|
* @dvb_frontend: af9033 demod driver DVB frontend.
|
||||||
struct it913x_config {
|
* @chip_ver: Used chip version. 1=IT9133 AX, 2=IT9133 BX.
|
||||||
/*
|
* @role: Chip role, single or dual configuration.
|
||||||
* pointer to DVB frontend
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
struct it913x_platform_data {
|
||||||
|
struct regmap *regmap;
|
||||||
struct dvb_frontend *fe;
|
struct dvb_frontend *fe;
|
||||||
|
|
||||||
/*
|
|
||||||
* chip version
|
|
||||||
* 1 = IT9135 AX
|
|
||||||
* 2 = IT9135 BX
|
|
||||||
*/
|
|
||||||
unsigned int chip_ver:2;
|
unsigned int chip_ver:2;
|
||||||
|
|
||||||
/*
|
|
||||||
* tuner role
|
|
||||||
*/
|
|
||||||
#define IT913X_ROLE_SINGLE 0
|
#define IT913X_ROLE_SINGLE 0
|
||||||
#define IT913X_ROLE_DUAL_MASTER 1
|
#define IT913X_ROLE_DUAL_MASTER 1
|
||||||
#define IT913X_ROLE_DUAL_SLAVE 2
|
#define IT913X_ROLE_DUAL_SLAVE 2
|
||||||
unsigned int role:2;
|
unsigned int role:2;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Backwards compatibility */
|
||||||
|
#define it913x_config it913x_platform_data
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user