1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20#include <linux/module.h>
21#include <linux/regmap.h>
22#include <linux/spi/spi.h>
23
24#include <linux/mfd/tps65912.h>
25
26static const struct of_device_id tps65912_spi_of_match_table[] = {
27 { .compatible = "ti,tps65912", },
28 { }
29};
30
31static int tps65912_spi_probe(struct spi_device *spi)
32{
33 struct tps65912 *tps;
34
35 tps = devm_kzalloc(&spi->dev, sizeof(*tps), GFP_KERNEL);
36 if (!tps)
37 return -ENOMEM;
38
39 spi_set_drvdata(spi, tps);
40 tps->dev = &spi->dev;
41 tps->irq = spi->irq;
42
43 tps->regmap = devm_regmap_init_spi(spi, &tps65912_regmap_config);
44 if (IS_ERR(tps->regmap)) {
45 dev_err(tps->dev, "Failed to initialize register map\n");
46 return PTR_ERR(tps->regmap);
47 }
48
49 return tps65912_device_init(tps);
50}
51
52static int tps65912_spi_remove(struct spi_device *spi)
53{
54 struct tps65912 *tps = spi_get_drvdata(spi);
55
56 return tps65912_device_exit(tps);
57}
58
59static const struct spi_device_id tps65912_spi_id_table[] = {
60 { "tps65912", 0 },
61 { }
62};
63MODULE_DEVICE_TABLE(spi, tps65912_spi_id_table);
64
65static struct spi_driver tps65912_spi_driver = {
66 .driver = {
67 .name = "tps65912",
68 .of_match_table = tps65912_spi_of_match_table,
69 },
70 .probe = tps65912_spi_probe,
71 .remove = tps65912_spi_remove,
72 .id_table = tps65912_spi_id_table,
73};
74module_spi_driver(tps65912_spi_driver);
75
76MODULE_AUTHOR("Andrew F. Davis <afd@ti.com>");
77MODULE_DESCRIPTION("TPS65912x SPI Interface Driver");
78MODULE_LICENSE("GPL v2");
79