t113 i2c 总线时钟调节不起作用
-
mangopi dual 的板子,调试触摸屏的时候发现tw2 i2c 调节不生效,无论输入400K还是100K,实际都以1.2M左右运行,查看 /sys目录下和 /proc 目录下i2c 节点的频率都已经是修改过的频率了,请问是否是i2c总线驱动的问题? 使用的是buidlroot
设备树:&twi2 { clock-frequency = <400000>; pinctrl-0 = <&twi2_pins_a>; pinctrl-1 = <&twi2_pins_b>; pinctrl-names = "default", "sleep"; twi_drv_used = <1>; dmas = <&dma 45>, <&dma 45>; dma-names = "tx", "rx"; status = "okay"; ctp@14 { compatible = "allwinner,goodix,gt911"; device_type = "ctp"; reg = <0x14>; status = "disabled"; ctp_name = "gt9xxnew_ts"; ctp_twi_id = <0x2>; ctp_twi_addr = <0x14>; ctp_screen_max_x = <0x320>; ctp_screen_max_y = <0x1e0>; ctp_revert_x_flag = <0x0>; ctp_revert_y_flag = <0x0>; ctp_exchange_x_y_flag = <0x0>; ctp_int_port = <&pio PB 2 GPIO_ACTIVE_HIGH>; ctp_wakeup = <&pio PB 3 GPIO_ACTIVE_HIGH>; /ctp-supply = <®_aldo2>;/ /ctp_power_ldo = <®_aldo2>;/ /ctp_power_ldo_vol = <3300>;/ }; };
-
-
追踪到驱动程序里面的寄存器读写了,发现这句话
writel(reg_val, i2c->base_addr + reg_clk);
无论往寄存器里面写什么值,i2c 输出时钟频率都不变,可能是写入的值需要符合一定的组合,或者寄存器地址根本就不对?还是硬件有Bug? 原厂的技术工程师能否帮忙看一下static void sunxi_i2c_clk_write_reg(struct sunxi_i2c *i2c, unsigned int reg_clk, unsigned int sclk_freq, unsigned char clk_m, unsigned char clk_n, unsigned int mask_clk_m, unsigned int mask_clk_n) { unsigned int reg_val = readl(i2c->base_addr + reg_clk); #if IS_ENABLED(CONFIG_ARCH_SUN50IW10) unsigned int duty; #endif dev_dbg(i2c->dev, "reg_clk = 0x%x, clk_m = %u, clk_n = %u," "mask_clk_m = %x, mask_clk_n = %x\n", reg_clk, clk_m, clk_n, mask_clk_m, mask_clk_n); if (reg_clk == TWI_DRIVER_BUSC) { reg_val &= ~(mask_clk_m | mask_clk_n); reg_val |= ((clk_m | (clk_n << 4)) << 8); #if IS_ENABLED(CONFIG_ARCH_SUN50IW10) duty = TWI_DRV_CLK_DUTY; if (sclk_freq > STANDDARD_FREQ) reg_val |= duty; else reg_val &= ~duty; #endif writel(reg_val, i2c->base_addr + reg_clk); dev_dbg(i2c->dev, "reg: 0x%x value: 0x%x\n", reg_clk, readl(i2c->base_addr + reg_clk)); printk("\n clk reg val:%d - reg:%d, m -n %d-%d",reg_val,i2c->base_addr + reg_clk, clk_m, clk_n); } else { reg_val &= ~(mask_clk_m | mask_clk_n); reg_val |= ((clk_m << 3) | clk_n); #if IS_ENABLED(CONFIG_ARCH_SUN50IW10) duty = TWI_CLK_DUTY; if (sclk_freq > STANDDARD_FREQ) reg_val |= duty; else reg_val &= ~duty; #endif writel(reg_val, i2c->base_addr + reg_clk); dev_dbg(i2c->dev, "reg: 0x%x value: 0x%x\n", reg_clk, readl(i2c->base_addr + reg_clk)); } }
-
@efancier 在longan下确实是这种情况,而在tina下i2c就是正常的,我也不清楚原因
-
@duowei1987 longan sdk是不是有问题,我用PD20 PD21都调不出来I2C。。。。
-
@duowei1987, 多谢确认这个问题,这个坑也太大了,我试试Tina的 I2c 总线驱动看能不能解决这个问题,现在的方案是用GPIO模拟,速度能到100K左右,暂时对付着驱动GT触摸屏
-
我又试了试,可以400K I2C频率啊,longan sdk.
-
@suitjune ,是buildroot编译的吗?
-
@efancier 啥意思?longan sdk不都有自己的SDK的内核?你是指内核是buildroot编译出来的?
-
-
@efancier 将longan的i2c-sunxi.c和i2c-sunxi.h更换为tina linux的文件就可以了,测试过i2c正常
-
@duowei1987 ,谢谢!我对比下看看这两个版本的文件有什么不一样。
Copyright © 2024 深圳全志在线有限公司 粤ICP备2021084185号 粤公网安备44030502007680号