当前位置:网站首页>The kernel determines whether peripherals are attached to the I2C address
The kernel determines whether peripherals are attached to the I2C address
2022-07-06 04:43:00 【Never bald programmer】
List of articles
Record a way to judge i2c Whether peripherals are attached to the address .
Use scenarios , Both drivers use the same reset pin and interrupt pin , Use the same peripheral interface , It is not allowed to use at the same time , Just mounted i2c Different addresses , The idea is to read the value of this register when registering the driver , The return value is used to determine whether there is a cause peripheral .
One 、 Code changes
dits To configure
i2c4{
[email protected]2a {
reg = <0x2a>;
compatible = "eeti,egalax_i2c";
interrupt-parent = <&gpio4>;
interrupts = <13 2>;
int-gpios = <&gpio4 13 0>;
reset-gpios = <&gpio4 12 0>;
};
[email protected]5d {
compatible = "goodix,gt928_ts";
reg = <0x5d>;
irq-gpios = <&gpio4 13 0>;
reset-gpios = <&gpio4 12 0>;
};
};
Then the corresponding peobe Add the following judgment to the function :
The function used is i2c_smbus Read interface of :
/* Correlation function again kernel Of inlcude/linux/i2c.h in *s32 i2c_smbus_read_byte_data(const struct i2c_client *client, u8 command); *const struct i2c_client *client It's designated by your peripheral i2c Bus *u8 command 8 Bit address */
/*vol Is the return value , If it doesn't exist, then it returns a negative number */
/* Before using this function, you need to set client The value of is given first so that it can pass I2C Interface function to read */
vol = i2c_smbus_read_byte_data(p_egalax_i2c_dev->client, p_egalax_i2c_dev->client->addr);
if (vol < 0) {
printk("cluo---> vol 0x%x = %d", client->addr, vol);
return -ENODEV;
}
By inserting different peripherals , You can see different printing information .
[ 3.430773] cluo---> vol 0x2a = -6
[ 3.434279] cluo---> eglax_tp probe error
[ 4.542063] cluo---> vol 0x5d = 0
[ 4.596902] cluo---> goodix probe success
[ 3.448004] cluo---> nret 0x2a = -6
[ 3.451509] cluo---> eglax_tp probe error
[ 4.571818] cluo---> vol 0x5d = -6
[ 4.575928] cluo---> goodix probe error
[ 3.455065] cluo---> nret 0x2a = 2
[ 3.466904] cluo---> egalax probe success
[ 4.592851] cluo---> vol 0x5d = -6
[ 4.596902] cluo---> goodix probe error
Two 、 Realization principle
Because drivers can be loaded successfully alone , The purpose is to avoid driving to the right gpio To operate , Because they all use the same gpio, So we can't let them drive the right gpio To apply for , Because once you apply, it will lead to ningwai gpio You can't be right gpio To operate . So you need to add this judgment function gpio Before applying .
边栏推荐
- 电脑钉钉怎么调整声音
- SharedPreferences source code analysis
- Selection of slow motion function
- A blog to achieve embedded entry
- [face recognition series] | realize automatic makeup
- 2328. 网格图中递增路径的数目(记忆化搜索)
- P3500 [poi2010]tes intelligence test (two points & offline)
- VPP性能测试
- Introduction of several RS485 isolated communication schemes
- Crawler notes: improve data collection efficiency! Use of proxy pool and thread pool
猜你喜欢

麦斯克电子IPO被终止:曾拟募资8亿 河南资产是股东

Basic explanation of turtle module - draw curve

During pycharm debugging, the view is read only and pause the process to use the command line appear on the console input

Yyds dry inventory automatic lighting system based on CC2530 (ZigBee)
![[05-1, 05-02, 05-03] network protocol](/img/25/2e9ccc3f31a1fd46c9ab643d48064b.jpg)
[05-1, 05-02, 05-03] network protocol

JVM garbage collector concept

How to realize automatic playback of H5 video

Distributed transaction solution

SQL injection vulnerability (MSSQL injection)

Jd.com 2: how to prevent oversold in the deduction process of commodity inventory?
随机推荐
P3500 [poi2010]tes intelligence test (two points & offline)
二叉树基本知识和例题
2327. 知道秘密的人数(递推)
Delete subsequence < daily question >
[数学建模] 微分方程--捕鱼业的持续发展
newton interpolation
8. Static file
ETCD数据库源码分析——etcdserver bootstrap初始化存储
Database - MySQL storage engine (deadlock)
优秀PM必须经历这3层蜕变!
I'd like to ask about the current MySQL CDC design. In the full volume phase, if a chunk's binlog backfill phase,
word封面下划线
Patent | subject classification method based on graph convolution neural network fusion of multiple human brain maps
Dry goods collection | Vulkan game engine video tutorial
Supreme Court, judgment standard of divorce cases
CertBot 更新证书失败解决
项目经理,你会画原型嘛?项目经理需要做产品设计了?
Bill Gates posted his 18-year-old resume and expected an annual salary of $12000 48 years ago
C. The third problem
Fedora/rehl installation semanage