18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci *  cx18 I2C functions
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci *  Derived from ivtv-i2c.c
68c2ecf20Sopenharmony_ci *
78c2ecf20Sopenharmony_ci *  Copyright (C) 2007  Hans Verkuil <hverkuil@xs4all.nl>
88c2ecf20Sopenharmony_ci *  Copyright (C) 2008  Andy Walls <awalls@md.metrocast.net>
98c2ecf20Sopenharmony_ci */
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#include "cx18-driver.h"
128c2ecf20Sopenharmony_ci#include "cx18-io.h"
138c2ecf20Sopenharmony_ci#include "cx18-cards.h"
148c2ecf20Sopenharmony_ci#include "cx18-gpio.h"
158c2ecf20Sopenharmony_ci#include "cx18-i2c.h"
168c2ecf20Sopenharmony_ci#include "cx18-irq.h"
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ci#define CX18_REG_I2C_1_WR   0xf15000
198c2ecf20Sopenharmony_ci#define CX18_REG_I2C_1_RD   0xf15008
208c2ecf20Sopenharmony_ci#define CX18_REG_I2C_2_WR   0xf25100
218c2ecf20Sopenharmony_ci#define CX18_REG_I2C_2_RD   0xf25108
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci#define SETSCL_BIT      0x0001
248c2ecf20Sopenharmony_ci#define SETSDL_BIT      0x0002
258c2ecf20Sopenharmony_ci#define GETSCL_BIT      0x0004
268c2ecf20Sopenharmony_ci#define GETSDL_BIT      0x0008
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci#define CX18_CS5345_I2C_ADDR		0x4c
298c2ecf20Sopenharmony_ci#define CX18_Z8F0811_IR_TX_I2C_ADDR	0x70
308c2ecf20Sopenharmony_ci#define CX18_Z8F0811_IR_RX_I2C_ADDR	0x71
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_ci/* This array should match the CX18_HW_ defines */
338c2ecf20Sopenharmony_cistatic const u8 hw_addrs[] = {
348c2ecf20Sopenharmony_ci	0,				/* CX18_HW_TUNER */
358c2ecf20Sopenharmony_ci	0,				/* CX18_HW_TVEEPROM */
368c2ecf20Sopenharmony_ci	CX18_CS5345_I2C_ADDR,		/* CX18_HW_CS5345 */
378c2ecf20Sopenharmony_ci	0,				/* CX18_HW_DVB */
388c2ecf20Sopenharmony_ci	0,				/* CX18_HW_418_AV */
398c2ecf20Sopenharmony_ci	0,				/* CX18_HW_GPIO_MUX */
408c2ecf20Sopenharmony_ci	0,				/* CX18_HW_GPIO_RESET_CTRL */
418c2ecf20Sopenharmony_ci	CX18_Z8F0811_IR_RX_I2C_ADDR,	/* CX18_HW_Z8F0811_IR_HAUP */
428c2ecf20Sopenharmony_ci};
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_ci/* This array should match the CX18_HW_ defines */
458c2ecf20Sopenharmony_ci/* This might well become a card-specific array */
468c2ecf20Sopenharmony_cistatic const u8 hw_bus[] = {
478c2ecf20Sopenharmony_ci	1,	/* CX18_HW_TUNER */
488c2ecf20Sopenharmony_ci	0,	/* CX18_HW_TVEEPROM */
498c2ecf20Sopenharmony_ci	0,	/* CX18_HW_CS5345 */
508c2ecf20Sopenharmony_ci	0,	/* CX18_HW_DVB */
518c2ecf20Sopenharmony_ci	0,	/* CX18_HW_418_AV */
528c2ecf20Sopenharmony_ci	0,	/* CX18_HW_GPIO_MUX */
538c2ecf20Sopenharmony_ci	0,	/* CX18_HW_GPIO_RESET_CTRL */
548c2ecf20Sopenharmony_ci	0,	/* CX18_HW_Z8F0811_IR_HAUP */
558c2ecf20Sopenharmony_ci};
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ci/* This array should match the CX18_HW_ defines */
588c2ecf20Sopenharmony_cistatic const char * const hw_devicenames[] = {
598c2ecf20Sopenharmony_ci	"tuner",
608c2ecf20Sopenharmony_ci	"tveeprom",
618c2ecf20Sopenharmony_ci	"cs5345",
628c2ecf20Sopenharmony_ci	"cx23418_DTV",
638c2ecf20Sopenharmony_ci	"cx23418_AV",
648c2ecf20Sopenharmony_ci	"gpio_mux",
658c2ecf20Sopenharmony_ci	"gpio_reset_ctrl",
668c2ecf20Sopenharmony_ci	"ir_z8f0811_haup",
678c2ecf20Sopenharmony_ci};
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_cistatic int cx18_i2c_new_ir(struct cx18 *cx, struct i2c_adapter *adap, u32 hw,
708c2ecf20Sopenharmony_ci			   const char *type, u8 addr)
718c2ecf20Sopenharmony_ci{
728c2ecf20Sopenharmony_ci	struct i2c_board_info info;
738c2ecf20Sopenharmony_ci	struct IR_i2c_init_data *init_data = &cx->ir_i2c_init_data;
748c2ecf20Sopenharmony_ci	unsigned short addr_list[2] = { addr, I2C_CLIENT_END };
758c2ecf20Sopenharmony_ci
768c2ecf20Sopenharmony_ci	memset(&info, 0, sizeof(struct i2c_board_info));
778c2ecf20Sopenharmony_ci	strscpy(info.type, type, I2C_NAME_SIZE);
788c2ecf20Sopenharmony_ci
798c2ecf20Sopenharmony_ci	/* Our default information for ir-kbd-i2c.c to use */
808c2ecf20Sopenharmony_ci	switch (hw) {
818c2ecf20Sopenharmony_ci	case CX18_HW_Z8F0811_IR_HAUP:
828c2ecf20Sopenharmony_ci		init_data->ir_codes = RC_MAP_HAUPPAUGE;
838c2ecf20Sopenharmony_ci		init_data->internal_get_key_func = IR_KBD_GET_KEY_HAUP_XVR;
848c2ecf20Sopenharmony_ci		init_data->type = RC_PROTO_BIT_RC5 | RC_PROTO_BIT_RC6_MCE |
858c2ecf20Sopenharmony_ci							RC_PROTO_BIT_RC6_6A_32;
868c2ecf20Sopenharmony_ci		init_data->name = cx->card_name;
878c2ecf20Sopenharmony_ci		info.platform_data = init_data;
888c2ecf20Sopenharmony_ci		break;
898c2ecf20Sopenharmony_ci	}
908c2ecf20Sopenharmony_ci
918c2ecf20Sopenharmony_ci	return IS_ERR(i2c_new_scanned_device(adap, &info, addr_list, NULL)) ?
928c2ecf20Sopenharmony_ci	       -1 : 0;
938c2ecf20Sopenharmony_ci}
948c2ecf20Sopenharmony_ci
958c2ecf20Sopenharmony_ciint cx18_i2c_register(struct cx18 *cx, unsigned idx)
968c2ecf20Sopenharmony_ci{
978c2ecf20Sopenharmony_ci	struct v4l2_subdev *sd;
988c2ecf20Sopenharmony_ci	int bus = hw_bus[idx];
998c2ecf20Sopenharmony_ci	struct i2c_adapter *adap = &cx->i2c_adap[bus];
1008c2ecf20Sopenharmony_ci	const char *type = hw_devicenames[idx];
1018c2ecf20Sopenharmony_ci	u32 hw = 1 << idx;
1028c2ecf20Sopenharmony_ci
1038c2ecf20Sopenharmony_ci	if (hw == CX18_HW_TUNER) {
1048c2ecf20Sopenharmony_ci		/* special tuner group handling */
1058c2ecf20Sopenharmony_ci		sd = v4l2_i2c_new_subdev(&cx->v4l2_dev,
1068c2ecf20Sopenharmony_ci				adap, type, 0, cx->card_i2c->radio);
1078c2ecf20Sopenharmony_ci		if (sd != NULL)
1088c2ecf20Sopenharmony_ci			sd->grp_id = hw;
1098c2ecf20Sopenharmony_ci		sd = v4l2_i2c_new_subdev(&cx->v4l2_dev,
1108c2ecf20Sopenharmony_ci				adap, type, 0, cx->card_i2c->demod);
1118c2ecf20Sopenharmony_ci		if (sd != NULL)
1128c2ecf20Sopenharmony_ci			sd->grp_id = hw;
1138c2ecf20Sopenharmony_ci		sd = v4l2_i2c_new_subdev(&cx->v4l2_dev,
1148c2ecf20Sopenharmony_ci				adap, type, 0, cx->card_i2c->tv);
1158c2ecf20Sopenharmony_ci		if (sd != NULL)
1168c2ecf20Sopenharmony_ci			sd->grp_id = hw;
1178c2ecf20Sopenharmony_ci		return sd != NULL ? 0 : -1;
1188c2ecf20Sopenharmony_ci	}
1198c2ecf20Sopenharmony_ci
1208c2ecf20Sopenharmony_ci	if (hw == CX18_HW_Z8F0811_IR_HAUP)
1218c2ecf20Sopenharmony_ci		return cx18_i2c_new_ir(cx, adap, hw, type, hw_addrs[idx]);
1228c2ecf20Sopenharmony_ci
1238c2ecf20Sopenharmony_ci	/* Is it not an I2C device or one we do not wish to register? */
1248c2ecf20Sopenharmony_ci	if (!hw_addrs[idx])
1258c2ecf20Sopenharmony_ci		return -1;
1268c2ecf20Sopenharmony_ci
1278c2ecf20Sopenharmony_ci	/* It's an I2C device other than an analog tuner or IR chip */
1288c2ecf20Sopenharmony_ci	sd = v4l2_i2c_new_subdev(&cx->v4l2_dev, adap, type, hw_addrs[idx],
1298c2ecf20Sopenharmony_ci				 NULL);
1308c2ecf20Sopenharmony_ci	if (sd != NULL)
1318c2ecf20Sopenharmony_ci		sd->grp_id = hw;
1328c2ecf20Sopenharmony_ci	return sd != NULL ? 0 : -1;
1338c2ecf20Sopenharmony_ci}
1348c2ecf20Sopenharmony_ci
1358c2ecf20Sopenharmony_ci/* Find the first member of the subdev group id in hw */
1368c2ecf20Sopenharmony_cistruct v4l2_subdev *cx18_find_hw(struct cx18 *cx, u32 hw)
1378c2ecf20Sopenharmony_ci{
1388c2ecf20Sopenharmony_ci	struct v4l2_subdev *result = NULL;
1398c2ecf20Sopenharmony_ci	struct v4l2_subdev *sd;
1408c2ecf20Sopenharmony_ci
1418c2ecf20Sopenharmony_ci	spin_lock(&cx->v4l2_dev.lock);
1428c2ecf20Sopenharmony_ci	v4l2_device_for_each_subdev(sd, &cx->v4l2_dev) {
1438c2ecf20Sopenharmony_ci		if (sd->grp_id == hw) {
1448c2ecf20Sopenharmony_ci			result = sd;
1458c2ecf20Sopenharmony_ci			break;
1468c2ecf20Sopenharmony_ci		}
1478c2ecf20Sopenharmony_ci	}
1488c2ecf20Sopenharmony_ci	spin_unlock(&cx->v4l2_dev.lock);
1498c2ecf20Sopenharmony_ci	return result;
1508c2ecf20Sopenharmony_ci}
1518c2ecf20Sopenharmony_ci
1528c2ecf20Sopenharmony_cistatic void cx18_setscl(void *data, int state)
1538c2ecf20Sopenharmony_ci{
1548c2ecf20Sopenharmony_ci	struct cx18 *cx = ((struct cx18_i2c_algo_callback_data *)data)->cx;
1558c2ecf20Sopenharmony_ci	int bus_index = ((struct cx18_i2c_algo_callback_data *)data)->bus_index;
1568c2ecf20Sopenharmony_ci	u32 addr = bus_index ? CX18_REG_I2C_2_WR : CX18_REG_I2C_1_WR;
1578c2ecf20Sopenharmony_ci	u32 r = cx18_read_reg(cx, addr);
1588c2ecf20Sopenharmony_ci
1598c2ecf20Sopenharmony_ci	if (state)
1608c2ecf20Sopenharmony_ci		cx18_write_reg(cx, r | SETSCL_BIT, addr);
1618c2ecf20Sopenharmony_ci	else
1628c2ecf20Sopenharmony_ci		cx18_write_reg(cx, r & ~SETSCL_BIT, addr);
1638c2ecf20Sopenharmony_ci}
1648c2ecf20Sopenharmony_ci
1658c2ecf20Sopenharmony_cistatic void cx18_setsda(void *data, int state)
1668c2ecf20Sopenharmony_ci{
1678c2ecf20Sopenharmony_ci	struct cx18 *cx = ((struct cx18_i2c_algo_callback_data *)data)->cx;
1688c2ecf20Sopenharmony_ci	int bus_index = ((struct cx18_i2c_algo_callback_data *)data)->bus_index;
1698c2ecf20Sopenharmony_ci	u32 addr = bus_index ? CX18_REG_I2C_2_WR : CX18_REG_I2C_1_WR;
1708c2ecf20Sopenharmony_ci	u32 r = cx18_read_reg(cx, addr);
1718c2ecf20Sopenharmony_ci
1728c2ecf20Sopenharmony_ci	if (state)
1738c2ecf20Sopenharmony_ci		cx18_write_reg(cx, r | SETSDL_BIT, addr);
1748c2ecf20Sopenharmony_ci	else
1758c2ecf20Sopenharmony_ci		cx18_write_reg(cx, r & ~SETSDL_BIT, addr);
1768c2ecf20Sopenharmony_ci}
1778c2ecf20Sopenharmony_ci
1788c2ecf20Sopenharmony_cistatic int cx18_getscl(void *data)
1798c2ecf20Sopenharmony_ci{
1808c2ecf20Sopenharmony_ci	struct cx18 *cx = ((struct cx18_i2c_algo_callback_data *)data)->cx;
1818c2ecf20Sopenharmony_ci	int bus_index = ((struct cx18_i2c_algo_callback_data *)data)->bus_index;
1828c2ecf20Sopenharmony_ci	u32 addr = bus_index ? CX18_REG_I2C_2_RD : CX18_REG_I2C_1_RD;
1838c2ecf20Sopenharmony_ci
1848c2ecf20Sopenharmony_ci	return cx18_read_reg(cx, addr) & GETSCL_BIT;
1858c2ecf20Sopenharmony_ci}
1868c2ecf20Sopenharmony_ci
1878c2ecf20Sopenharmony_cistatic int cx18_getsda(void *data)
1888c2ecf20Sopenharmony_ci{
1898c2ecf20Sopenharmony_ci	struct cx18 *cx = ((struct cx18_i2c_algo_callback_data *)data)->cx;
1908c2ecf20Sopenharmony_ci	int bus_index = ((struct cx18_i2c_algo_callback_data *)data)->bus_index;
1918c2ecf20Sopenharmony_ci	u32 addr = bus_index ? CX18_REG_I2C_2_RD : CX18_REG_I2C_1_RD;
1928c2ecf20Sopenharmony_ci
1938c2ecf20Sopenharmony_ci	return cx18_read_reg(cx, addr) & GETSDL_BIT;
1948c2ecf20Sopenharmony_ci}
1958c2ecf20Sopenharmony_ci
1968c2ecf20Sopenharmony_ci/* template for i2c-bit-algo */
1978c2ecf20Sopenharmony_cistatic const struct i2c_adapter cx18_i2c_adap_template = {
1988c2ecf20Sopenharmony_ci	.name = "cx18 i2c driver",
1998c2ecf20Sopenharmony_ci	.algo = NULL,                   /* set by i2c-algo-bit */
2008c2ecf20Sopenharmony_ci	.algo_data = NULL,              /* filled from template */
2018c2ecf20Sopenharmony_ci	.owner = THIS_MODULE,
2028c2ecf20Sopenharmony_ci};
2038c2ecf20Sopenharmony_ci
2048c2ecf20Sopenharmony_ci#define CX18_SCL_PERIOD (10) /* usecs. 10 usec is period for a 100 KHz clock */
2058c2ecf20Sopenharmony_ci#define CX18_ALGO_BIT_TIMEOUT (2) /* seconds */
2068c2ecf20Sopenharmony_ci
2078c2ecf20Sopenharmony_cistatic const struct i2c_algo_bit_data cx18_i2c_algo_template = {
2088c2ecf20Sopenharmony_ci	.setsda		= cx18_setsda,
2098c2ecf20Sopenharmony_ci	.setscl		= cx18_setscl,
2108c2ecf20Sopenharmony_ci	.getsda		= cx18_getsda,
2118c2ecf20Sopenharmony_ci	.getscl		= cx18_getscl,
2128c2ecf20Sopenharmony_ci	.udelay		= CX18_SCL_PERIOD/2,       /* 1/2 clock period in usec*/
2138c2ecf20Sopenharmony_ci	.timeout	= CX18_ALGO_BIT_TIMEOUT*HZ /* jiffies */
2148c2ecf20Sopenharmony_ci};
2158c2ecf20Sopenharmony_ci
2168c2ecf20Sopenharmony_ci/* init + register i2c adapter */
2178c2ecf20Sopenharmony_ciint init_cx18_i2c(struct cx18 *cx)
2188c2ecf20Sopenharmony_ci{
2198c2ecf20Sopenharmony_ci	int i, err;
2208c2ecf20Sopenharmony_ci	CX18_DEBUG_I2C("i2c init\n");
2218c2ecf20Sopenharmony_ci
2228c2ecf20Sopenharmony_ci	for (i = 0; i < 2; i++) {
2238c2ecf20Sopenharmony_ci		/* Setup algorithm for adapter */
2248c2ecf20Sopenharmony_ci		cx->i2c_algo[i] = cx18_i2c_algo_template;
2258c2ecf20Sopenharmony_ci		cx->i2c_algo_cb_data[i].cx = cx;
2268c2ecf20Sopenharmony_ci		cx->i2c_algo_cb_data[i].bus_index = i;
2278c2ecf20Sopenharmony_ci		cx->i2c_algo[i].data = &cx->i2c_algo_cb_data[i];
2288c2ecf20Sopenharmony_ci
2298c2ecf20Sopenharmony_ci		/* Setup adapter */
2308c2ecf20Sopenharmony_ci		cx->i2c_adap[i] = cx18_i2c_adap_template;
2318c2ecf20Sopenharmony_ci		cx->i2c_adap[i].algo_data = &cx->i2c_algo[i];
2328c2ecf20Sopenharmony_ci		sprintf(cx->i2c_adap[i].name + strlen(cx->i2c_adap[i].name),
2338c2ecf20Sopenharmony_ci				" #%d-%d", cx->instance, i);
2348c2ecf20Sopenharmony_ci		i2c_set_adapdata(&cx->i2c_adap[i], &cx->v4l2_dev);
2358c2ecf20Sopenharmony_ci		cx->i2c_adap[i].dev.parent = &cx->pci_dev->dev;
2368c2ecf20Sopenharmony_ci	}
2378c2ecf20Sopenharmony_ci
2388c2ecf20Sopenharmony_ci	if (cx18_read_reg(cx, CX18_REG_I2C_2_WR) != 0x0003c02f) {
2398c2ecf20Sopenharmony_ci		/* Reset/Unreset I2C hardware block */
2408c2ecf20Sopenharmony_ci		/* Clock select 220MHz */
2418c2ecf20Sopenharmony_ci		cx18_write_reg_expect(cx, 0x10000000, 0xc71004,
2428c2ecf20Sopenharmony_ci					  0x00000000, 0x10001000);
2438c2ecf20Sopenharmony_ci		/* Clock Enable */
2448c2ecf20Sopenharmony_ci		cx18_write_reg_expect(cx, 0x10001000, 0xc71024,
2458c2ecf20Sopenharmony_ci					  0x00001000, 0x10001000);
2468c2ecf20Sopenharmony_ci	}
2478c2ecf20Sopenharmony_ci	/* courtesy of Steven Toth <stoth@hauppauge.com> */
2488c2ecf20Sopenharmony_ci	cx18_write_reg_expect(cx, 0x00c00000, 0xc7001c, 0x00000000, 0x00c000c0);
2498c2ecf20Sopenharmony_ci	mdelay(10);
2508c2ecf20Sopenharmony_ci	cx18_write_reg_expect(cx, 0x00c000c0, 0xc7001c, 0x000000c0, 0x00c000c0);
2518c2ecf20Sopenharmony_ci	mdelay(10);
2528c2ecf20Sopenharmony_ci	cx18_write_reg_expect(cx, 0x00c00000, 0xc7001c, 0x00000000, 0x00c000c0);
2538c2ecf20Sopenharmony_ci	mdelay(10);
2548c2ecf20Sopenharmony_ci
2558c2ecf20Sopenharmony_ci	/* Set to edge-triggered intrs. */
2568c2ecf20Sopenharmony_ci	cx18_write_reg(cx, 0x00c00000, 0xc730c8);
2578c2ecf20Sopenharmony_ci	/* Clear any stale intrs */
2588c2ecf20Sopenharmony_ci	cx18_write_reg_expect(cx, HW2_I2C1_INT|HW2_I2C2_INT, HW2_INT_CLR_STATUS,
2598c2ecf20Sopenharmony_ci		       ~(HW2_I2C1_INT|HW2_I2C2_INT), HW2_I2C1_INT|HW2_I2C2_INT);
2608c2ecf20Sopenharmony_ci
2618c2ecf20Sopenharmony_ci	/* Hw I2C1 Clock Freq ~100kHz */
2628c2ecf20Sopenharmony_ci	cx18_write_reg(cx, 0x00021c0f & ~4, CX18_REG_I2C_1_WR);
2638c2ecf20Sopenharmony_ci	cx18_setscl(&cx->i2c_algo_cb_data[0], 1);
2648c2ecf20Sopenharmony_ci	cx18_setsda(&cx->i2c_algo_cb_data[0], 1);
2658c2ecf20Sopenharmony_ci
2668c2ecf20Sopenharmony_ci	/* Hw I2C2 Clock Freq ~100kHz */
2678c2ecf20Sopenharmony_ci	cx18_write_reg(cx, 0x00021c0f & ~4, CX18_REG_I2C_2_WR);
2688c2ecf20Sopenharmony_ci	cx18_setscl(&cx->i2c_algo_cb_data[1], 1);
2698c2ecf20Sopenharmony_ci	cx18_setsda(&cx->i2c_algo_cb_data[1], 1);
2708c2ecf20Sopenharmony_ci
2718c2ecf20Sopenharmony_ci	cx18_call_hw(cx, CX18_HW_GPIO_RESET_CTRL,
2728c2ecf20Sopenharmony_ci		     core, reset, (u32) CX18_GPIO_RESET_I2C);
2738c2ecf20Sopenharmony_ci
2748c2ecf20Sopenharmony_ci	err = i2c_bit_add_bus(&cx->i2c_adap[0]);
2758c2ecf20Sopenharmony_ci	if (err)
2768c2ecf20Sopenharmony_ci		goto err;
2778c2ecf20Sopenharmony_ci	err = i2c_bit_add_bus(&cx->i2c_adap[1]);
2788c2ecf20Sopenharmony_ci	if (err)
2798c2ecf20Sopenharmony_ci		goto err_del_bus_0;
2808c2ecf20Sopenharmony_ci	return 0;
2818c2ecf20Sopenharmony_ci
2828c2ecf20Sopenharmony_ci err_del_bus_0:
2838c2ecf20Sopenharmony_ci	i2c_del_adapter(&cx->i2c_adap[0]);
2848c2ecf20Sopenharmony_ci err:
2858c2ecf20Sopenharmony_ci	return err;
2868c2ecf20Sopenharmony_ci}
2878c2ecf20Sopenharmony_ci
2888c2ecf20Sopenharmony_civoid exit_cx18_i2c(struct cx18 *cx)
2898c2ecf20Sopenharmony_ci{
2908c2ecf20Sopenharmony_ci	int i;
2918c2ecf20Sopenharmony_ci	CX18_DEBUG_I2C("i2c exit\n");
2928c2ecf20Sopenharmony_ci	cx18_write_reg(cx, cx18_read_reg(cx, CX18_REG_I2C_1_WR) | 4,
2938c2ecf20Sopenharmony_ci							CX18_REG_I2C_1_WR);
2948c2ecf20Sopenharmony_ci	cx18_write_reg(cx, cx18_read_reg(cx, CX18_REG_I2C_2_WR) | 4,
2958c2ecf20Sopenharmony_ci							CX18_REG_I2C_2_WR);
2968c2ecf20Sopenharmony_ci
2978c2ecf20Sopenharmony_ci	for (i = 0; i < 2; i++) {
2988c2ecf20Sopenharmony_ci		i2c_del_adapter(&cx->i2c_adap[i]);
2998c2ecf20Sopenharmony_ci	}
3008c2ecf20Sopenharmony_ci}
3018c2ecf20Sopenharmony_ci
3028c2ecf20Sopenharmony_ci/*
3038c2ecf20Sopenharmony_ci   Hauppauge HVR1600 should have:
3048c2ecf20Sopenharmony_ci   32 cx24227
3058c2ecf20Sopenharmony_ci   98 unknown
3068c2ecf20Sopenharmony_ci   a0 eeprom
3078c2ecf20Sopenharmony_ci   c2 tuner
3088c2ecf20Sopenharmony_ci   e? zilog ir
3098c2ecf20Sopenharmony_ci   */
310