79 lines
1.8 KiB
C
79 lines
1.8 KiB
C
#include <linux/init.h>
|
|
#include <linux/dma-mapping.h>
|
|
#include <linux/module.h>
|
|
#include <linux/kernel.h>
|
|
#include <linux/delay.h>
|
|
#include <linux/spi/spi.h>
|
|
#include <linux/of_device.h>
|
|
#include <linux/gpio/consumer.h>
|
|
#include <linux/interrupt.h>
|
|
|
|
/*
|
|
* irq in general: https://notes.shichao.io/lkd/ch7/
|
|
* raspi irqs: http://morethanuser.blogspot.com/2013/04/raspberry-pi-gpio-interrupts-in-kernel.html
|
|
* kdoc devtree irq: https://www.kernel.org/doc/Documentation/devicetree/bindings/interrupt-controller/interrupts.txt
|
|
* GPIOD doc (including irq): https://www.kernel.org/doc/Documentation/gpio/consumer.txt
|
|
*/
|
|
|
|
MODULE_LICENSE("GPL");
|
|
MODULE_AUTHOR("Markus Koch");
|
|
MODULE_DESCRIPTION("LW35 I/O Controller Driver");
|
|
MODULE_VERSION("0.1");
|
|
|
|
static char *testparam = "param";
|
|
module_param(testparam, charp, S_IRUGO);
|
|
MODULE_PARM_DESC(testparam, "A test parameter");
|
|
|
|
static struct of_device_id lw35ioc_dt_ids[] = {
|
|
{ .compatible = "brother,lw35", },
|
|
{ /* sentinel */ }
|
|
};
|
|
MODULE_DEVICE_TABLE(of, lw35ioc_dt_ids);
|
|
|
|
struct lw35ioc_priv {
|
|
struct spi_device *spi;
|
|
|
|
// USER VARS HERE
|
|
};
|
|
|
|
static int lw35ioc_probe(struct spi_device *spi)
|
|
{
|
|
struct lw35ioc_priv *priv = NULL;
|
|
|
|
printk(KERN_INFO "lw35ioc: probe\n");
|
|
|
|
priv = devm_kzalloc(&spi->dev,
|
|
sizeof(struct lw35ioc_priv),
|
|
GFP_KERNEL);
|
|
if (!priv)
|
|
return -ENOMEM;
|
|
spi_set_drvdata(spi, priv);
|
|
|
|
priv->spi = spi;
|
|
|
|
printk(KERN_INFO "lw35ioc: Loaded driver\n");
|
|
|
|
return 0;
|
|
|
|
// Error handlers go here
|
|
}
|
|
|
|
static int lw35ioc_remove(struct spi_device *spi)
|
|
{
|
|
struct lw35ioc_priv *priv = spi_get_drvdata(spi);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static struct spi_driver lw35ioc_driver = {
|
|
.probe = lw35ioc_probe,
|
|
.remove = lw35ioc_remove,
|
|
.driver = {
|
|
.name = "lw35ioc",
|
|
.owner = THIS_MODULE,
|
|
.of_match_table = lw35ioc_dt_ids,
|
|
},
|
|
};
|
|
module_spi_driver(lw35ioc_driver);
|
|
|