当前位置:网站首页>Device tree failed to add SPI device node
Device tree failed to add SPI device node
2022-06-22 07:26:00 【Neilo_ chen】
A new... Is added to the device tree spi The equipment nodes are as follows :
&spi1 {
[email protected] {
compatible = “gcore,touchscreen”;
spi-max-frequency = <1000000>;
spi-cpha = <1>;
spi-cpol = <1>;
};
};
It doesn't look like a problem , But in the system /sys/bus/spi/devices/ The device is not found in the directory ?
reason :
By analyzing the code , If I don't read reg attribute , Add device error !
of_register_spi_device(struct spi_master *master, struct device_node *nc)
{
struct spi_device *spi;
int rc;
u32 value;
/* Alloc an spi_device */
spi = spi_alloc_device(master);
if (!spi) {
dev_err(&master->dev, "spi_device alloc error for %s\n",
nc->full_name);
rc = -ENOMEM;
goto err_out;
}
/* Select device driver */
rc = of_modalias_node(nc, spi->modalias,
sizeof(spi->modalias));
if (rc < 0) {
dev_err(&master->dev, "cannot find modalias for %s\n",
nc->full_name);
goto err_out;
}
/* Device address */
rc = of_property_read_u32(nc, "reg", &value);
if (rc) {
dev_err(&master->dev, "%s has no valid 'reg' property (%d)\n",
nc->full_name, rc);
goto err_out;
}
spi->chip_select = value;
/* Mode (clock phase/polarity/etc.) */
if (of_find_property(nc, "spi-cpha", NULL))
spi->mode |= SPI_CPHA;
if (of_find_property(nc, "spi-cpol", NULL))
spi->mode |= SPI_CPOL;
if (of_find_property(nc, "spi-cs-high", NULL))
spi->mode |= SPI_CS_HIGH;
if (of_find_property(nc, "spi-3wire", NULL))
spi->mode |= SPI_3WIRE;
if (of_find_property(nc, "spi-lsb-first", NULL))
spi->mode |= SPI_LSB_FIRST;
...
add to reg attribute ,/bus/spi/devices/ You can see
&spi1 {
#address-cells = <1>;
#size-cells = <0>;
[email protected] {
compatible = “gcore,touchscreen”;
spi-max-frequency = <1000000>;
reg = <1>;
spi-cpha = <1>;
spi-cpol = <1>;
};
};
Note that the #address-cells = <1>; #size-cells = <0>;
To reset reg Length and size of attributes
边栏推荐
- Custom implementation of bind method in JS
- The pit on the school recruitment Road
- What if the finder fails to respond continuously? Finder unresponsive solution tutorial
- Lean production | lean management
- How to import and upload a CSV generated by a third-party platform to a Taobao store
- ROS Qt环境搭建
- Flutter input field maxlines dynamic change
- Backup the method of uploading babies in Taobao stores to multiple stores
- The mountains and rivers are heavy, and there is no doubt that there is no way out. There is another village where the willows are dark and the flowers are bright.
- Get through version - bargain activity
猜你喜欢

Résumé semestriel du programmeur de 33 ans

Parameter curve notes of coursera self driving car Part4 motion planning

Up sampling and down sampling (notes, for personal use)

New year's Day mall material Icon

Kuangshi brain++ Tianyuan platform megstudio

Chromedriver all versions download

Real MySQL interview question (18) -- practical operation analysis

Thousands of sails pass by the side of the sunken boat, and thousands of trees spring before the diseased tree

Taobao assistant can not be used. How to export the baby in the warehouse to backup the data package

Mid year summary of 33 year old programmer
随机推荐
MySQL面试真题(二十)——视频数据分析实战
About pointer (notes, for personal use)
Use of the thrust Library in CUDA
C语言实现的简易考试系统
[standard version 4.3] marketing activities (group bargaining second kill) error reporting under orders
New year's Day mall material Icon
从暴力递归到动态规划
Article editing test of CSDN
校招路上的坑
RFID warehouse management system solution implementation visualization process
robotframework使用 及问题解决
Téléchargement de toutes les versions de chromedriver
What are the ways for Taobao merchants to put their babies on the shelves in batches
Wechat games (3)
CONDA installation method of deepmd kit and the solution of slow speed
okcc呼叫中心的权限管理
Site pre cache code
Vue failed to connect to MySQL database
True MySQL interview question (19) -- Tiktok -- select the list of users who have logged in for two consecutive days every month
How to view cookies in Chrome browser