当前位置:网站首页>Transplant DAC chip mcp4725 to nuc980
Transplant DAC chip mcp4725 to nuc980
2022-07-07 01:21:00 【Ti-laser】
This article introduces migration DAC chip MCP4725 Methods .
Because the official linux-4.4.x Although there is one mcp4725.c The driver , But this drive is suitable for none dts Old application scenarios , And my system uses dts The tree needs to replace the driver , The specific method is :
From the website linux/mcp4725.c at master · torvalds/linux · GitHub
download mcp4725.c, The downloaded file can only be compiled and used normally after the following adjustments , As follows :
1 Add header file :#include <linux/of_device.h>
2 find IIO_ENUM_AVAILABLE And delete the second parameter , It takes the form of :
IIO_ENUM_AVAILABLE("powerdown_mode",
&mcp472x_powerdown_mode_enum[MCP4725]),
IIO_ENUM_AVAILABLE("powerdown_mode",
&mcp472x_powerdown_mode_enum[MCP4726]),
3 find device_get_match_data Change to of_device_get_match_data
if (dev_fwnode(&client->dev))
data->id = (uintptr_t)of_device_get_match_data(&client->dev);
else
......
4 Replace include/linux/iio/dac/mcp4725.h For the following :
....
struct mcp4725_platform_data {
bool use_vref;
bool vref_buffered;
};
....
5 Modify file :
drivers/base/property.c +108, allow dev_fwnode Called externally :
struct fwnode_handle *dev_fwnode(struct device *dev)
{
return IS_ENABLED(CONFIG_OF) && dev->of_node ?
&dev->of_node->fwnode : dev->fwnode;
}
EXPORT_SYMBOL_GPL(dev_fwnode);
6 adjustment include/linux/property.h, Declare the output function
struct fwnode_handle *dev_fwnode(struct device *dev);
7 because DAC The chip is attached to I2c1 On the bus , Documents need to be modified nuc980-iot.dtsi, Add blue part :
i2c1: [email protected] {
compatible = "nuvoton,nuc980-i2c1";
.........
#address-cells = <1>;
#size-cells = <0>;
compatible = "microchip,mcp4725";
reg = <0x61>;
};
After the compilation is normal, it will be written into the board and then enter /sys/devices/iio:deviceX You can see the node information , there X Please replace it according to the actual situation of your system .
Can write DA The value is then tested and verified with a multimeter .
echo 2000 > out_voltage0_raw
边栏推荐
猜你喜欢
随机推荐
Realize incremental data synchronization between MySQL and ES
剑指 Offer II 035. 最小时间差-快速排序加数据转换
[case sharing] basic function configuration of network loop detection
Taro 小程序开启wxml代码压缩
2022 Google CTF SEGFAULT LABYRINTH wp
如何管理分布式团队?
Add the applet "lazycodeloading": "requiredcomponents" in taro,
Informatics Orsay Ibn YBT 1172: find the factorial of n within 10000 | 1.6 14: find the factorial of n within 10000
ARM裸板调试之JTAG调试体验
BFS realizes breadth first traversal of adjacency matrix (with examples)
gnet: 一个轻量级且高性能的 Go 网络框架 使用笔记
Cause of handler memory leak
"Exquisite store manager" youth entrepreneurship incubation camp - the first phase of Shunde market has been successfully completed!
golang中的atomic,以及CAS操作
ClickHouse字段分组聚合、按照任意时间段粒度查询SQL
NEON优化:关于交叉存取与反向交叉存取
黑马笔记---创建不可变集合与Stream流
Byte P7 professional level explanation: common tools and test methods for interface testing, Freeman
The difference between spin and sleep
Boot - Prometheus push gateway use