Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[media] tda10071: implement I2C client bindings

Implement I2C client bindings.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

authored by

Antti Palosaari and committed by
Mauro Carvalho Chehab
d69abb79 c70316f2

+125
+95
drivers/media/dvb-frontends/tda10071.c
··· 1313 1313 .set_voltage = tda10071_set_voltage, 1314 1314 }; 1315 1315 1316 + static struct dvb_frontend *tda10071_get_dvb_frontend(struct i2c_client *client) 1317 + { 1318 + struct tda10071_priv *dev = i2c_get_clientdata(client); 1319 + 1320 + dev_dbg(&client->dev, "\n"); 1321 + 1322 + return &dev->fe; 1323 + } 1324 + 1325 + static int tda10071_probe(struct i2c_client *client, 1326 + const struct i2c_device_id *id) 1327 + { 1328 + struct tda10071_priv *dev; 1329 + struct tda10071_platform_data *pdata = client->dev.platform_data; 1330 + int ret; 1331 + u8 u8tmp; 1332 + 1333 + dev = kzalloc(sizeof(*dev), GFP_KERNEL); 1334 + if (!dev) { 1335 + ret = -ENOMEM; 1336 + goto err; 1337 + } 1338 + 1339 + dev->client = client; 1340 + dev->i2c = client->adapter; 1341 + dev->cfg.demod_i2c_addr = client->addr; 1342 + dev->cfg.i2c_wr_max = pdata->i2c_wr_max; 1343 + dev->cfg.ts_mode = pdata->ts_mode; 1344 + dev->cfg.spec_inv = pdata->spec_inv; 1345 + dev->cfg.xtal = pdata->clk; 1346 + dev->cfg.pll_multiplier = pdata->pll_multiplier; 1347 + dev->cfg.tuner_i2c_addr = pdata->tuner_i2c_addr; 1348 + 1349 + /* chip ID */ 1350 + ret = tda10071_rd_reg(dev, 0xff, &u8tmp); 1351 + if (ret || u8tmp != 0x0f) 1352 + goto err_kfree; 1353 + 1354 + /* chip type */ 1355 + ret = tda10071_rd_reg(dev, 0xdd, &u8tmp); 1356 + if (ret || u8tmp != 0x00) 1357 + goto err_kfree; 1358 + 1359 + /* chip version */ 1360 + ret = tda10071_rd_reg(dev, 0xfe, &u8tmp); 1361 + if (ret || u8tmp != 0x01) 1362 + goto err_kfree; 1363 + 1364 + /* create dvb_frontend */ 1365 + memcpy(&dev->fe.ops, &tda10071_ops, sizeof(struct dvb_frontend_ops)); 1366 + dev->fe.ops.release = NULL; 1367 + dev->fe.demodulator_priv = dev; 1368 + i2c_set_clientdata(client, dev); 1369 + 1370 + /* setup callbacks */ 1371 + pdata->get_dvb_frontend = tda10071_get_dvb_frontend; 1372 + 1373 + dev_info(&client->dev, "NXP TDA10071 successfully identified\n"); 1374 + return 0; 1375 + err_kfree: 1376 + kfree(dev); 1377 + err: 1378 + dev_dbg(&client->dev, "failed=%d\n", ret); 1379 + return ret; 1380 + } 1381 + 1382 + static int tda10071_remove(struct i2c_client *client) 1383 + { 1384 + struct tda10071_dev *dev = i2c_get_clientdata(client); 1385 + 1386 + dev_dbg(&client->dev, "\n"); 1387 + 1388 + kfree(dev); 1389 + return 0; 1390 + } 1391 + 1392 + static const struct i2c_device_id tda10071_id_table[] = { 1393 + {"tda10071_cx24118", 0}, 1394 + {} 1395 + }; 1396 + MODULE_DEVICE_TABLE(i2c, tda10071_id_table); 1397 + 1398 + static struct i2c_driver tda10071_driver = { 1399 + .driver = { 1400 + .owner = THIS_MODULE, 1401 + .name = "tda10071", 1402 + .suppress_bind_attrs = true, 1403 + }, 1404 + .probe = tda10071_probe, 1405 + .remove = tda10071_remove, 1406 + .id_table = tda10071_id_table, 1407 + }; 1408 + 1409 + module_i2c_driver(tda10071_driver); 1410 + 1316 1411 MODULE_AUTHOR("Antti Palosaari <crope@iki.fi>"); 1317 1412 MODULE_DESCRIPTION("NXP TDA10071 DVB-S/S2 demodulator driver"); 1318 1413 MODULE_LICENSE("GPL");
+29
drivers/media/dvb-frontends/tda10071.h
··· 24 24 #include <linux/kconfig.h> 25 25 #include <linux/dvb/frontend.h> 26 26 27 + /* 28 + * I2C address 29 + * 0x55, 30 + */ 31 + 32 + /** 33 + * struct tda10071_platform_data - Platform data for the tda10071 driver 34 + * @clk: Clock frequency. 35 + * @i2c_wr_max: Max bytes I2C adapter can write at once. 36 + * @ts_mode: TS mode. 37 + * @spec_inv: Input spectrum inversion. 38 + * @pll_multiplier: PLL multiplier. 39 + * @tuner_i2c_addr: CX24118A tuner I2C address (0x14, 0x54, ...). 40 + * @get_dvb_frontend: Get DVB frontend. 41 + */ 42 + 43 + struct tda10071_platform_data { 44 + u32 clk; 45 + u16 i2c_wr_max; 46 + #define TDA10071_TS_SERIAL 0 47 + #define TDA10071_TS_PARALLEL 1 48 + u8 ts_mode; 49 + bool spec_inv; 50 + u8 pll_multiplier; 51 + u8 tuner_i2c_addr; 52 + 53 + struct dvb_frontend* (*get_dvb_frontend)(struct i2c_client *); 54 + }; 55 + 27 56 struct tda10071_config { 28 57 /* Demodulator I2C address. 29 58 * Default: none, must set
+1
drivers/media/dvb-frontends/tda10071_priv.h
··· 28 28 struct tda10071_priv { 29 29 struct i2c_adapter *i2c; 30 30 struct dvb_frontend fe; 31 + struct i2c_client *client; 31 32 struct tda10071_config cfg; 32 33 33 34 u8 meas_count[2];