From: Mauro Carvalho Chehab <mchehab@s-opensource.com>
To: Antti Palosaari <crope@iki.fi>
Cc: linux-media@vger.kernel.org
Subject: Re: [PATCHv2 1/6] mt2060: add i2c bindings
Date: Wed, 23 Nov 2016 19:31:06 -0200 [thread overview]
Message-ID: <20161123193106.2ce8ddd2@vento.lan> (raw)
In-Reply-To: <1463883231-14329-1-git-send-email-crope@iki.fi>
Hi Antti,
Em Sun, 22 May 2016 05:13:46 +0300
Antti Palosaari <crope@iki.fi> escreveu:
> Add proper i2c driver model bindings.
Just like version 1 of this series, I'm marking it as RFC.
Please add those patches into a git tree and send me a pull request
when you believe that they're ready for merging.
Thanks!
Mauro
>
> Signed-off-by: Antti Palosaari <crope@iki.fi>
> ---
> drivers/media/tuners/mt2060.c | 83 ++++++++++++++++++++++++++++++++++++++
> drivers/media/tuners/mt2060.h | 20 +++++++++
> drivers/media/tuners/mt2060_priv.h | 2 +
> 3 files changed, 105 insertions(+)
>
> diff --git a/drivers/media/tuners/mt2060.c b/drivers/media/tuners/mt2060.c
> index b87b254..aa8280a 100644
> --- a/drivers/media/tuners/mt2060.c
> +++ b/drivers/media/tuners/mt2060.c
> @@ -397,6 +397,89 @@ struct dvb_frontend * mt2060_attach(struct dvb_frontend *fe, struct i2c_adapter
> }
> EXPORT_SYMBOL(mt2060_attach);
>
> +static int mt2060_probe(struct i2c_client *client,
> + const struct i2c_device_id *id)
> +{
> + struct mt2060_platform_data *pdata = client->dev.platform_data;
> + struct dvb_frontend *fe;
> + struct mt2060_priv *dev;
> + int ret;
> + u8 chip_id;
> +
> + dev_dbg(&client->dev, "\n");
> +
> + if (!pdata) {
> + dev_err(&client->dev, "Cannot proceed without platform data\n");
> + ret = -EINVAL;
> + goto err;
> + }
> +
> + dev = devm_kzalloc(&client->dev, sizeof(*dev), GFP_KERNEL);
> + if (!dev) {
> + ret = -ENOMEM;
> + goto err;
> + }
> +
> + fe = pdata->dvb_frontend;
> + dev->config.i2c_address = client->addr;
> + dev->config.clock_out = pdata->clock_out;
> + dev->cfg = &dev->config;
> + dev->i2c = client->adapter;
> + dev->if1_freq = pdata->if1 ? pdata->if1 : 1220;
> + dev->client = client;
> +
> + ret = mt2060_readreg(dev, REG_PART_REV, &chip_id);
> + if (ret) {
> + ret = -ENODEV;
> + goto err;
> + }
> +
> + dev_dbg(&client->dev, "chip id=%02x\n", chip_id);
> +
> + if (chip_id != PART_REV) {
> + ret = -ENODEV;
> + goto err;
> + }
> +
> + dev_info(&client->dev, "Microtune MT2060 successfully identified\n");
> + memcpy(&fe->ops.tuner_ops, &mt2060_tuner_ops, sizeof(fe->ops.tuner_ops));
> + fe->ops.tuner_ops.release = NULL;
> + fe->tuner_priv = dev;
> + i2c_set_clientdata(client, dev);
> +
> + mt2060_calibrate(dev);
> +
> + return 0;
> +err:
> + dev_dbg(&client->dev, "failed=%d\n", ret);
> + return ret;
> +}
> +
> +static int mt2060_remove(struct i2c_client *client)
> +{
> + dev_dbg(&client->dev, "\n");
> +
> + return 0;
> +}
> +
> +static const struct i2c_device_id mt2060_id_table[] = {
> + {"mt2060", 0},
> + {}
> +};
> +MODULE_DEVICE_TABLE(i2c, mt2060_id_table);
> +
> +static struct i2c_driver mt2060_driver = {
> + .driver = {
> + .name = "mt2060",
> + .suppress_bind_attrs = true,
> + },
> + .probe = mt2060_probe,
> + .remove = mt2060_remove,
> + .id_table = mt2060_id_table,
> +};
> +
> +module_i2c_driver(mt2060_driver);
> +
> MODULE_AUTHOR("Olivier DANET");
> MODULE_DESCRIPTION("Microtune MT2060 silicon tuner driver");
> MODULE_LICENSE("GPL");
> diff --git a/drivers/media/tuners/mt2060.h b/drivers/media/tuners/mt2060.h
> index 6efed35..05c0d55 100644
> --- a/drivers/media/tuners/mt2060.h
> +++ b/drivers/media/tuners/mt2060.h
> @@ -25,6 +25,26 @@
> struct dvb_frontend;
> struct i2c_adapter;
>
> +/*
> + * I2C address
> + * 0x60, ...
> + */
> +
> +/**
> + * struct mt2060_platform_data - Platform data for the mt2060 driver
> + * @clock_out: Clock output setting. 0 = off, 1 = CLK/4, 2 = CLK/2, 3 = CLK/1.
> + * @if1: First IF used [MHz]. 0 defaults to 1220.
> + * @dvb_frontend: DVB frontend.
> + */
> +
> +struct mt2060_platform_data {
> + u8 clock_out;
> + u16 if1;
> + struct dvb_frontend *dvb_frontend;
> +};
> +
> +
> +/* configuration struct for mt2060_attach() */
> struct mt2060_config {
> u8 i2c_address;
> u8 clock_out; /* 0 = off, 1 = CLK/4, 2 = CLK/2, 3 = CLK/1 */
> diff --git a/drivers/media/tuners/mt2060_priv.h b/drivers/media/tuners/mt2060_priv.h
> index 2b60de6..dfc4a06 100644
> --- a/drivers/media/tuners/mt2060_priv.h
> +++ b/drivers/media/tuners/mt2060_priv.h
> @@ -95,6 +95,8 @@
> struct mt2060_priv {
> struct mt2060_config *cfg;
> struct i2c_adapter *i2c;
> + struct i2c_client *client;
> + struct mt2060_config config;
>
> u32 frequency;
> u16 if1_freq;
Thanks,
Mauro
prev parent reply other threads:[~2016-11-23 21:31 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-22 2:13 [PATCHv2 1/6] mt2060: add i2c bindings Antti Palosaari
2016-05-22 2:13 ` [PATCHv2 2/6] mt2060: add param to split long i2c writes Antti Palosaari
2016-05-22 2:13 ` [PATCHv2 3/6] zd1301_demod: ZyDAS ZD1301 DVB-T demodulator driver Antti Palosaari
2016-05-22 2:13 ` [PATCHv2 4/6] MAINTAINERS: add zd1301_demod driver Antti Palosaari
2016-05-22 2:13 ` [PATCHv2 5/6] zd1301: ZyDAS ZD1301 DVB USB interface driver Antti Palosaari
2016-05-22 2:13 ` [PATCHv2 6/6] MAINTAINERS: add zd1301 " Antti Palosaari
2016-11-23 21:31 ` Mauro Carvalho Chehab [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161123193106.2ce8ddd2@vento.lan \
--to=mchehab@s-opensource.com \
--cc=crope@iki.fi \
--cc=linux-media@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.