diff mbox

[2/3,media] af9035: init i2c already in it930x_frontend_attach

Message ID 1489616530-4025-3-git-send-email-andreas@kemnade.info (mailing list archive)
State New, archived
Headers show

Commit Message

Andreas Kemnade March 15, 2017, 10:22 p.m. UTC
i2c bus is already needed when the frontend is probed,
so init it already in it930x_frontend_attach
That prevents errors like
     si2168: probe of 6-0067 failed with error -5

Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
---
 drivers/media/usb/dvb-usb-v2/af9035.c | 43 ++++++++++++++++++++++++++++++++++-
 1 file changed, 42 insertions(+), 1 deletion(-)

Comments

Andreas Kemnade May 4, 2017, 8:18 p.m. UTC | #1
On Wed, 15 Mar 2017 23:22:09 +0100
Andreas Kemnade <andreas@kemnade.info> wrote:

> i2c bus is already needed when the frontend is probed,
> so init it already in it930x_frontend_attach
> That prevents errors like
>      si2168: probe of 6-0067 failed with error -5
> 
> Signed-off-by: Andreas Kemnade <andreas@kemnade.info>

seems to be also needed for the
CINERGY TC2 Stick
Quoting from 
https://www.linuxmintusers.de/index.php?topic=41074.30

Mar 26 12:44:14 minimoose kernel: [  732.884876] usb 1-3: dvb_usb_v2: found a 'TerraTec Cinergy TC2 Stick' in warm state
Mar 26 12:44:14 minimoose kernel: [  732.885012] usb 1-3: dvb_usb_v2: will pass the complete MPEG2 transport stream to the software demuxer
Mar 26 12:44:14 minimoose kernel: [  732.885245] dvbdev: DVB: registering new adapter (TerraTec Cinergy TC2 Stick)
Mar 26 12:44:14 minimoose kernel: [  732.885254] usb 1-3: media controller created
Mar 26 12:44:14 minimoose kernel: [  732.886117] dvbdev: dvb_create_media_entity: media entity 'dvb-demux' registered.
Mar 26 12:44:14 minimoose kernel: [  732.890589] si2168: probe of 8-0067 failed with error -5


Regards,
Andreas Kemnade
diff mbox

Patch

diff --git a/drivers/media/usb/dvb-usb-v2/af9035.c b/drivers/media/usb/dvb-usb-v2/af9035.c
index 4df9486..a95f4b2 100644
--- a/drivers/media/usb/dvb-usb-v2/af9035.c
+++ b/drivers/media/usb/dvb-usb-v2/af9035.c
@@ -1214,8 +1214,49 @@  static int it930x_frontend_attach(struct dvb_usb_adapter *adap)
 	struct si2168_config si2168_config;
 	struct i2c_adapter *adapter;
 
-	dev_dbg(&intf->dev, "adap->id=%d\n", adap->id);
+	dev_dbg(&intf->dev, "%s  adap->id=%d\n", __func__, adap->id);
+
+	/* I2C master bus 2 clock speed 300k */
+	ret = af9035_wr_reg(d, 0x00f6a7, 0x07);
+	if (ret < 0)
+		goto err;
+
+	/* I2C master bus 1,3 clock speed 300k */
+	ret = af9035_wr_reg(d, 0x00f103, 0x07);
+	if (ret < 0)
+		goto err;
+
+	/* set gpio11 low */
+	ret = af9035_wr_reg_mask(d, 0xd8d4, 0x01, 0x01);
+	if (ret < 0)
+		goto err;
+
+	ret = af9035_wr_reg_mask(d, 0xd8d5, 0x01, 0x01);
+	if (ret < 0)
+		goto err;
+
+	ret = af9035_wr_reg_mask(d, 0xd8d3, 0x01, 0x01);
+	if (ret < 0)
+		goto err;
 
+	/* Tuner enable using gpiot2_en, gpiot2_on and gpiot2_o (reset) */
+	ret = af9035_wr_reg_mask(d, 0xd8b8, 0x01, 0x01);
+	if (ret < 0)
+		goto err;
+
+	ret = af9035_wr_reg_mask(d, 0xd8b9, 0x01, 0x01);
+	if (ret < 0)
+		goto err;
+
+	ret = af9035_wr_reg_mask(d, 0xd8b7, 0x00, 0x01);
+	if (ret < 0)
+		goto err;
+
+	msleep(200);
+
+	ret = af9035_wr_reg_mask(d, 0xd8b7, 0x01, 0x01);
+	if (ret < 0)
+		goto err;
 	memset(&si2168_config, 0, sizeof(si2168_config));
 	si2168_config.i2c_adapter = &adapter;
 	si2168_config.fe = &adap->fe[0];