blob: d701926aa46e67826b8086f88fbb86143d97e378 [file] [log] [blame]
Andrew F. Davis796f5692016-01-25 09:43:45 -06001/*
2 * SPI access driver for TI TPS65912x PMICs
3 *
Alexander A. Klimov4f4ed4542020-07-22 21:24:54 +02004 * Copyright (C) 2015 Texas Instruments Incorporated - https://www.ti.com/
Andrew F. Davis796f5692016-01-25 09:43:45 -06005 * Andrew F. Davis <afd@ti.com>
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 *
11 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
12 * kind, whether expressed or implied; without even the implied warranty
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License version 2 for more details.
15 *
16 * Based on the TPS65218 driver and the previous TPS65912 driver by
17 * Margarita Olaya Cabrera <magi@slimlogic.co.uk>
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 { /* sentinel */ }
29};
Daniel Gomez9e364e82019-04-22 21:09:50 +020030MODULE_DEVICE_TABLE(of, tps65912_spi_of_match_table);
Andrew F. Davis796f5692016-01-25 09:43:45 -060031
32static int tps65912_spi_probe(struct spi_device *spi)
33{
34 struct tps65912 *tps;
35
36 tps = devm_kzalloc(&spi->dev, sizeof(*tps), GFP_KERNEL);
37 if (!tps)
38 return -ENOMEM;
39
40 spi_set_drvdata(spi, tps);
41 tps->dev = &spi->dev;
42 tps->irq = spi->irq;
43
44 tps->regmap = devm_regmap_init_spi(spi, &tps65912_regmap_config);
45 if (IS_ERR(tps->regmap)) {
46 dev_err(tps->dev, "Failed to initialize register map\n");
47 return PTR_ERR(tps->regmap);
48 }
49
50 return tps65912_device_init(tps);
51}
52
Andrew F. Davis0ec69542017-03-15 12:05:34 -050053static int tps65912_spi_remove(struct spi_device *spi)
Andrew F. Davis796f5692016-01-25 09:43:45 -060054{
Andrew F. Davis0ec69542017-03-15 12:05:34 -050055 struct tps65912 *tps = spi_get_drvdata(spi);
Andrew F. Davis796f5692016-01-25 09:43:45 -060056
Uwe Kleine-Königec14d902021-10-12 17:39:35 +020057 tps65912_device_exit(tps);
58
59 return 0;
Andrew F. Davis796f5692016-01-25 09:43:45 -060060}
61
62static const struct spi_device_id tps65912_spi_id_table[] = {
63 { "tps65912", 0 },
64 { /* sentinel */ }
65};
66MODULE_DEVICE_TABLE(spi, tps65912_spi_id_table);
67
68static struct spi_driver tps65912_spi_driver = {
69 .driver = {
70 .name = "tps65912",
71 .of_match_table = tps65912_spi_of_match_table,
72 },
73 .probe = tps65912_spi_probe,
74 .remove = tps65912_spi_remove,
75 .id_table = tps65912_spi_id_table,
76};
77module_spi_driver(tps65912_spi_driver);
78
79MODULE_AUTHOR("Andrew F. Davis <afd@ti.com>");
80MODULE_DESCRIPTION("TPS65912x SPI Interface Driver");
81MODULE_LICENSE("GPL v2");