[RK3399][Android7.1] 调试笔记 --- I2C探测工具添加

Platform: RK3399
OS: Android 7.1
Kernel: v4.4.83

背景:

rk3288上默认自带i2c_detect工具来探测对应I2C总线上挂载的设备以及地址。
rk3399平台默认没有开启,参考rk3288做如下修改,就可以使用了。


改动:

diff --git a/arch/arm64/configs/rockchip_eco_defconfig 
b/arch/arm64/configs/rockchip_eco_defconfig
index 89b89a5..6dcba49 100644
--- a/arch/arm64/configs/rockchip_eco_defconfig 
+++ b/arch/arm64/configs/rockchip_eco_defconfig 
@@ -400,6 +400,8 @@ CONFIG_SERIAL_8250_DW=y
 CONFIG_I2C_CHARDEV=y
 CONFIG_I2C_GPIO=y
 CONFIG_I2C_RK3X=y
+#Kris,181204, add i2c_detect tool.
+CONFIG_I2C_ROCKCHIP=y
 CONFIG_SPI=y
 CONFIG_SPI_ROCKCHIP=y
 CONFIG_DEBUG_GPIO=y
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index 7b0aa82..14e3bf0 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -806,6 +806,18 @@ config I2C_RK3X
 	  This driver can also be built as a module. If so, the module will
 	  be called i2c-rk3x.
 
+#Kris,181204, add i2c_detect tool.
+config I2C_ROCKCHIP
+	tristate "Rockchip I2C interface"
+	depends on ARCH_ROCKCHIP
+	help
+	  If you say yes to this option, support will be included for the
+	  Rockchip I2C interface.
+
+	  This driver can also be built as a module.  If so, the module
+	  will be called i2c-rockchip.
+
+
 config HAVE_S3C2410_I2C
 	bool
 	help
diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
index 37f2819..67841e9 100644
--- a/drivers/i2c/busses/Makefile
+++ b/drivers/i2c/busses/Makefile
@@ -120,3 +120,6 @@ obj-$(CONFIG_I2C_XGENE_SLIMPRO) += i2c-xgene-slimpro.o
 obj-$(CONFIG_SCx200_ACB)	+= scx200_acb.o
 
 ccflags-$(CONFIG_I2C_DEBUG_BUS) := -DDEBUG
+
+#Kris,181204, add i2c_detect tool.
+obj-$(CONFIG_I2C_ROCKCHIP)	+= i2c-rockchip.o
diff --git a/drivers/i2c/busses/i2c-rockchip.c b/drivers/i2c/busses/i2c-rockchip.c
index 78bb407..df8e6c0 100644
--- a/drivers/i2c/busses/i2c-rockchip.c
+++ b/drivers/i2c/busses/i2c-rockchip.c
@@ -19,7 +19,8 @@
 #include 
 #include 
 #include 
-#include 
+//Kris,181204.
+//#include 
 #include 
 #include 
 #include 
@@ -733,7 +734,8 @@ static int rockchip_i2c_xfer(struct i2c_adapter *adap,
 {
 	int ret;
 	struct rockchip_i2c *i2c = i2c_get_adapdata(adap);
-	unsigned long scl_rate = i2c->scl_rate;
+	//Kris,181204.
+	//unsigned long scl_rate = i2c->scl_rate;
 	int can_sleep = !(in_atomic() || irqs_disabled());
 
 	if (can_sleep) {
@@ -931,7 +933,8 @@ static int rockchip_i2c_probe(struct platform_device *pdev)
 	rockchip_i2c_init_hw(i2c, 100 * 1000);
 	dev_info(&pdev->dev, "%s: Rockchip I2C adapter\n", dev_name(&i2c->adap.dev));
 
-	of_i2c_register_devices(&i2c->adap);
+	//Kris,181204.
+	//of_i2c_register_devices(&i2c->adap);
 	mutex_init(&i2c->suspend_lock);
 
 	return 0;
@@ -1096,7 +1099,12 @@ static ssize_t i2c_detect_write(struct file *file,
 		return -EFAULT;
 
 	sscanf(nr_buf, "%d", &nr);
+//Kris,181204.
+#if 0
 	if (nr >= 5 || nr < 0)
+#else
+	if (nr > 5 || nr < 0)
+#endif
 		return -EFAULT;
 
 	slave_detect(nr);


参考:

[RK3288][Android6.0] 调试笔记 — 测试I2C设备正常传输方法

你可能感兴趣的:(RK3399,子类__I2C)