SPI驱动程序中的基本设备操作 [英] Basic device operations in spi driver

查看:140
本文介绍了SPI驱动程序中的基本设备操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从头开始为omap4编写一个spi驱动程序. 我指的是http://lxr.free-electrons.com/source/drivers/spi/spi-omap2-mcspi.c驱动程序代码. 但是,我无法理解此驱动程序代码中如何处理基本设备操作. 例如,char驱动程序的结构为

I need to write an spi driver for omap4 from scratch. I am referring http://lxr.free-electrons.com/source/drivers/spi/spi-omap2-mcspi.c driver code. But, I am unable to understand how basic device operations are handled in this driver code. For example a char driver has the structure

struct file_operations scull_fops = {
.owner = THIS_MODULE,
.llseek = scull_llseek,
.read = scull_read,
.write = scull_write,
.ioctl = scull_ioctl,
.open = scull_open,
.release = scull_release,
};

包含指向诸如open,read,write等基本功能的指针.

containing the pointers to the basic functions like open, read, write etc...

我在以下位置找不到这些功能 http://lxr.free-electrons.com/source/drivers/spi/spi-omap2-mcspi.c

I don't find these functions in http://lxr.free-electrons.com/source/drivers/spi/spi-omap2-mcspi.c

请有人帮助我确定设备的打开方式,阅读方式和内容. spi-omap2-mcspi.c代码中提供了写操作.

Somebody please help me identify how the device open, read & write are provided in the spi-omap2-mcspi.c code.

推荐答案

如果您查看帖子中链接的文件的底部,将会看到基本平台驱动程序操作的处理方式.

If you look at the bottom of the file you linked in your post, you will see the handling for the basic platform driver operations.

static const struct dev_pm_ops omap2_mcspi_pm_ops = {
        .resume = omap2_mcspi_resume,
        .runtime_resume = omap_mcspi_runtime_resume,
};

static struct platform_driver omap2_mcspi_driver = {
       .driver = {
                .name =         "omap2_mcspi",
                .owner =        THIS_MODULE,
                .pm =           &omap2_mcspi_pm_ops,
                .of_match_table = omap_mcspi_of_match,
       },
       .probe =        omap2_mcspi_probe,
       .remove =       omap2_mcspi_remove,
};

probe操作中,您可以看到此驱动程序的spi特定操作的设置:

In the probe operation there you can see the setup of the spi specific operations for this driver:

     /* the spi->mode bits understood by this driver: */
     master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH;
     master->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 32);
     master->setup = omap2_mcspi_setup;
     master->auto_runtime_pm = true;
     master->transfer_one_message = omap2_mcspi_transfer_one_message;
     master->cleanup = omap2_mcspi_cleanup;
     master->dev.of_node = node;

这篇关于SPI驱动程序中的基本设备操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆