diff options
author | David Phillips <david@yeah.nah.nz> | 2021-05-01 21:37:29 +1200 |
---|---|---|
committer | David Phillips <david@yeah.nah.nz> | 2021-05-01 21:37:29 +1200 |
commit | ed609a3eb31f99ee02f7dbfbd6067a288e56b0b1 (patch) | |
tree | 2c2448f72c265d783039eaf94326417686a1617c | |
download | cds9k-ed609a3eb31f99ee02f7dbfbd6067a288e56b0b1.tar.xz |
Initial
-rw-r--r-- | Makefile | 15 | ||||
-rw-r--r-- | simple-mfd-spi.c | 47 |
2 files changed, 62 insertions, 0 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..5e23f84 --- /dev/null +++ b/Makefile @@ -0,0 +1,15 @@ +obj-m := simple-mfd-spi.o +obj-m += cds9k-gpio.o + +SRC := $(shell pwd) + +all: + $(MAKE) -C $(KERNEL_SRC) M=$(SRC) + +clean: + rm -f *.o core .depend .*.cmd *.ko *.mod.c + rm -f Module.markers Module.symvers modules.order + rm -rf .tmp_versions Modules.symvers + +modules_install: + $(MAKE) -C $(KERNEL_SRC) M=$(SRC) modules_install diff --git a/simple-mfd-spi.c b/simple-mfd-spi.c new file mode 100644 index 0000000..e63dc24 --- /dev/null +++ b/simple-mfd-spi.c @@ -0,0 +1,47 @@ +#include <linux/spi/spi.h> +#include <linux/module.h> +#include <linux/of_platform.h> +#include <linux/regmap.h> + +static const struct regmap_config simple_regmap_config = { + .reg_bits = 8, + .val_bits = 8, +}; + +static int david_cds9k_probe(struct spi_device *spi) +{ + const struct regmap_config *config; + struct regmap *regmap; + + printk("Bing bong\n"); + + config = device_get_match_data(&spi->dev); + if (!config) + config = &simple_regmap_config; + + regmap = devm_regmap_init_spi(spi, config); + if (IS_ERR(regmap)) + return PTR_ERR(regmap); + + return devm_of_platform_populate(&spi->dev); +} + + +static const struct of_device_id david_cds9k_of_match[] = { + { .compatible = "david,cds9k" }, + {} +}; +MODULE_DEVICE_TABLE(of, david_cds9k_of_match); + +static struct spi_driver david_cds9k_spi_driver = { + .probe = david_cds9k_probe, + .driver = { + .name = "david_cds9k", + .of_match_table = david_cds9k_of_match, + }, +}; +module_spi_driver(david_cds9k_spi_driver); + +MODULE_AUTHOR("David Phillips <david@yeah.nah.nz>"); +MODULE_DESCRIPTION("MFD driver for the CDS9K board controller"); +MODULE_LICENSE("GPL v2"); |