aboutsummaryrefslogtreecommitdiff
path: root/cds9k-mfd-spi.c
blob: 46d1c87a581cf525e5745cca5b20b04336150f62 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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 = {
	.max_register = 0x7f,
	.reg_bits = 8,
	.pad_bits = 8,
	.val_bits = 16,
};

static int david_cds9k_probe(struct spi_device *spi)
{
	const struct regmap_config *config;
	struct regmap *regmap;

	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");