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,
};
containing the pointers to the basic functions like open, read, write etc...
I don't find these functions in http://lxr.free-electrons.com/source/drivers/spi/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,
};
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;