1 | // SPDX-License-Identifier: GPL-2.0-only |
2 | /* |
3 | * SPI access driver for TI TPS65912x PMICs |
4 | * |
5 | * Copyright (C) 2015 Texas Instruments Incorporated - https://www.ti.com/ |
6 | * Andrew F. Davis <afd@ti.com> |
7 | * |
8 | * Based on the TPS65218 driver and the previous TPS65912 driver by |
9 | * Margarita Olaya Cabrera <magi@slimlogic.co.uk> |
10 | */ |
11 | |
12 | #include <linux/module.h> |
13 | #include <linux/regmap.h> |
14 | #include <linux/spi/spi.h> |
15 | |
16 | #include <linux/mfd/tps65912.h> |
17 | |
18 | static const struct of_device_id tps65912_spi_of_match_table[] = { |
19 | { .compatible = "ti,tps65912" , }, |
20 | { /* sentinel */ } |
21 | }; |
22 | MODULE_DEVICE_TABLE(of, tps65912_spi_of_match_table); |
23 | |
24 | static int tps65912_spi_probe(struct spi_device *spi) |
25 | { |
26 | struct tps65912 *tps; |
27 | |
28 | tps = devm_kzalloc(dev: &spi->dev, size: sizeof(*tps), GFP_KERNEL); |
29 | if (!tps) |
30 | return -ENOMEM; |
31 | |
32 | spi_set_drvdata(spi, data: tps); |
33 | tps->dev = &spi->dev; |
34 | tps->irq = spi->irq; |
35 | |
36 | tps->regmap = devm_regmap_init_spi(spi, &tps65912_regmap_config); |
37 | if (IS_ERR(ptr: tps->regmap)) { |
38 | dev_err(tps->dev, "Failed to initialize register map\n" ); |
39 | return PTR_ERR(ptr: tps->regmap); |
40 | } |
41 | |
42 | return tps65912_device_init(tps); |
43 | } |
44 | |
45 | static void tps65912_spi_remove(struct spi_device *spi) |
46 | { |
47 | struct tps65912 *tps = spi_get_drvdata(spi); |
48 | |
49 | tps65912_device_exit(tps); |
50 | } |
51 | |
52 | static const struct spi_device_id tps65912_spi_id_table[] = { |
53 | { "tps65912" , 0 }, |
54 | { /* sentinel */ } |
55 | }; |
56 | MODULE_DEVICE_TABLE(spi, tps65912_spi_id_table); |
57 | |
58 | static struct spi_driver tps65912_spi_driver = { |
59 | .driver = { |
60 | .name = "tps65912" , |
61 | .of_match_table = tps65912_spi_of_match_table, |
62 | }, |
63 | .probe = tps65912_spi_probe, |
64 | .remove = tps65912_spi_remove, |
65 | .id_table = tps65912_spi_id_table, |
66 | }; |
67 | module_spi_driver(tps65912_spi_driver); |
68 | |
69 | MODULE_AUTHOR("Andrew F. Davis <afd@ti.com>" ); |
70 | MODULE_DESCRIPTION("TPS65912x SPI Interface Driver" ); |
71 | MODULE_LICENSE("GPL v2" ); |
72 | |