我需要从头开始为omap4编写spi驱动程序。 我指的是http://lxr.free-electrons.com/source/drivers/spi/spi-omap2-mcspi.c驱动程序代码。 但是,我无法理解在此驱动程序代码中如何处理基本设备操作。 例如,char驱动程序具有结构
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等...
我找不到这些功能 http://lxr.free-electrons.com/source/drivers/spi/spi-omap2-mcspi.c
有人请帮我确定设备如何打开,阅读和放大write在spi-omap2-mcspi.c代码中提供。
答案 0 :(得分:1)
如果查看帖子中链接的文件的底部,您将看到基本平台驱动程序操作的处理。
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特定操作:
/* 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;