1.定义board设备
1: struct spi_board_info { 2: /* the device name and module name are coupled, like platform_bus; 3: * "modalias" is normally the driver name. 4: * 5: * platform_data goes to spi_device.dev.platform_data, 6: * controller_data goes to spi_device.controller_data, 7: * irq is copied too 8: */ 9: char modalias[SPI_NAME_SIZE]; 10: const void *platform_data; 11: void *controller_data; 12: int irq; 13:   14: /* slower signaling on noisy or low voltage boards */ 15: u32 max_speed_hz; 16:   17:   18: /* bus_num is board specific and matches the bus_num of some 19: * spi_master that will probably be registered later. 20: * 21: * chip_select reflects how this chip is wired to that master; 22: * it's less than num_chipselect. 23: */ 24: u16 bus_num; 25: u16 chip_select; 26:   27: /* mode becomes spi_device.mode, and is essential for chips 28: * where the default of SPI_CS_HIGH = 0 is wrong. 29: */ 30: u8 mode; 31:   32: /* ... may need additional spi_device chip config data here. 33: * avoid stuff protocol drivers can set; but include stuff 34: * needed to behave without being bound to a driver: 35: * - quirks like clock rate mattering when not selected 36: */

1: /* add by xuyonghong for test */ 2: struct spi_board_info jz_spi0_board_info[] = { 3: { 4: .modalias = "spidev", 5: .mode = SPI_MODE_3, 6: .max_speed_hz = 1000000, 7: .controller_data = (void *)GPIO_PB(2), 8: .bus_num = 0, 9: .chip_select = 0, 10: }, 11: }; 12: int jz_spi0_devs_size = ARRAY_SIZE(jz_spi0_board_info);

 
 
1: int __init 2: spi_register_board_info(struct spi_board_info const *info, unsigned n) 3: { 4: struct boardinfo *bi; 5: int i; 6:   7: bi = kzalloc(n * sizeof(*bi), GFP_KERNEL); 8: if (!bi) 9: return -ENOMEM; 10:   11: for (i = 0; i < n; i++, bi++, info++) { 12: struct spi_master *master; 13:   14: memcpy(&bi->board_info, info, sizeof(*info)); 15: mutex_lock(&board_lock); 16: list_add_tail(&bi->list, &board_list); 17: /* 18: 如果master先注册,则执行spi_match_master_to_boardinfo匹配, 19: 否则在master注册的时候匹配device 20: */ 21: list_for_each_entry(master, &spi_master_list, list) 22: spi_match_master_to_boardinfo(master, &bi->board_info); 23: mutex_unlock(&board_lock); 24: } 25:   26: return 0; 27: }

1: spi_register_board_info(jz_spi0_board_info, jz_spi0_devs_size);

总结:

1. list_add_tail(&bi->list, &board_list); 讲board添加在board_list

2.当master已经注册,则通过spi_match_master_to_boardinfo和spi_new_device创建spi device。

linux SPI驱动——spidev之deive(五)的更多相关文章

  1. linux SPI驱动——spidev之driver(六)

    一: spidev_init注册spidev 1: static int __init spidev_init(void) 2: { 3: int status; 4:   5: /* Claim o ...

  2. Linux spi驱动分析(二)----SPI核心(bus、device_driver和device)

    一.spi总线注册 这里所说的SPI核心,就是指/drivers/spi/目录下spi.c文件中提供给其他文件的函数,首先看下spi核心的初始化函数spi_init(void).程序如下: 点击(此处 ...

  3. linux驱动基础系列--linux spi驱动框架分析

    前言 主要是想对Linux 下spi驱动框架有一个整体的把控,因此会忽略某些细节,同时里面涉及到的一些驱动基础,比如平台驱动.设备模型等也不进行详细说明原理.如果有任何错误地方,请指出,谢谢! spi ...

  4. linux设备驱动归纳总结(五):4.写个简单的LED驱动【转】

    本文转载自:http://blog.chinaunix.net/uid-25014876-id-84693.html linux设备驱动归纳总结(五):4.写个简单的LED驱动 xxxxxxxxxxx ...

  5. linux设备驱动归纳总结(五):3.操作硬件——IO静态映射【转】

    本文转载自:http://blog.chinaunix.net/uid-25014876-id-83299.html linux设备驱动归纳总结(五):3.操作硬件——IO静态映射 xxxxxxxxx ...

  6. linux设备驱动归纳总结(五):1.在内核空间分配内存【转】

    本文转载自:http://blog.chinaunix.net/uid-25014876-id-79134.html linux设备驱动归纳总结(五):1.在内核空间分配内存 xxxxxxxxxxxx ...

  7. linux驱动基础系列--linux spi驱动框架分析(续)

    前言 这篇文章是对linux驱动基础系列--linux spi驱动框架分析的补充,主要是添加了最新的linux内核里设备树相关内容. spi设备树相关信息 如之前的文章里所述,控制器的device和s ...

  8. 【Linux开发】linux设备驱动归纳总结(五):1.在内核空间分配内存

    linux设备驱动归纳总结(五):1.在内核空间分配内存 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ...

  9. 【Linux开发】linux设备驱动归纳总结(五):2.操作硬件——IO内存

    linux设备驱动归纳总结(五):2.操作硬件--IO内存 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ...

随机推荐

  1. 《Linux命令行与shell脚本编程大全 第3版》Linux命令行---33

    以下为阅读<Linux命令行与shell脚本编程大全 第3版>的读书笔记,为了方便记录,特地与书的内容保持同步,特意做成一节一次随笔,特记录如下:

  2. 【剑指offer】构建乘积数组(注意优化空间)

    给定一个数组A[0,1,...,n-1],请构建一个数组B[0,1,...,n-1],其中B中的元素B[i]=A[0]*A[1]*...*A[i-1]*A[i+1]*...*A[n-1].不能使用除法 ...

  3. Python Challenge 第十关

    第十关是一张牛的图片和一行字:len(a[30])=?.图片中的牛是一个链接,点开后进入一个新页面,只有一行字: a = [1, 11, 21, 1211, 111221, 看来要知道第31个数多长, ...

  4. UVA 725 division【暴力枚举】

    [题意]:输入正整数n,用0~9这10个数字不重复组成两个五位数abcde和fghij,使得abcde/fghij的商为n,按顺序输出所有结果.如果没有找到则输出“There are no solut ...

  5. Java Hibernate事务并发控制

    在产品上线时发现当用户数量大并发性能差,经常发现数据库死锁,经诊断,是由于设置了不正确的事务隔离,可以做如下优级化(这里我们使用JTA事务): JTA具有的3个接口:UserTransaction接口 ...

  6. Delphi通过管道执行外部命令行程序(cmd)并获取返回结果

    该代码片段来自于: http://www.sharejs.com/codes/delphi/8999,发现好多代码,想用的时候找不到,记录一下备用 function RunDosCommand(Com ...

  7. 聊聊、Zookeeper 数据结构和操作命令

    Zookeeper 的视图结构跟标准的 Unix 文件系统很像,都有一个根节点 / .在根节点下面就是一个个的子节点,我们称为 ZNode.ZNode 是 Zookeeper 中最小数据单位,在 ZN ...

  8. 安装xz

    原地址: http://jingyan.baidu.com/album/8cdccae9416720315413cd9e.html 1 获取XZ的安装文件,网络下载xz-5.0.3.tar.bz2安装 ...

  9. 使用Eclipse Memory Analyzer进行内存泄漏分析三部曲

    源地址:http://seanhe.iteye.com/blog/898277 一.准备工作  分析较大的dump文件(根据我自己的经验2G以上的dump文件就需要使用以下介绍的方法,不然mat会出现 ...

  10. 如何DIY一个简单的反弹Shell脚本

    00起因 之前在一个服务器上做测试的时候需要从本地连到服务器上,但是服务器没有开ssh服务,但是有python环境,想着自己写一个脚本可以从自己本地连接到服务器,然后服务器端可以将处理完的请求结果返回 ...