2 * SPI access driver for TI TPS65912x PMICs
4 * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/
5 * Andrew F. Davis <afd@ti.com>
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.
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.
16 * Based on the TPS65218 driver and the previous TPS65912 driver by
17 * Margarita Olaya Cabrera <magi@slimlogic.co.uk>
20 #include <linux/module.h>
21 #include <linux/regmap.h>
22 #include <linux/spi/spi.h>
24 #include <linux/mfd/tps65912.h>
26 static const struct of_device_id tps65912_spi_of_match_table[] = {
27 { .compatible = "ti,tps65912", },
31 static int tps65912_spi_probe(struct spi_device *spi)
35 tps = devm_kzalloc(&spi->dev, sizeof(*tps), GFP_KERNEL);
39 spi_set_drvdata(spi, tps);
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);
49 return tps65912_device_init(tps);
52 static int tps65912_spi_remove(struct spi_device *spi)
54 struct tps65912 *tps = spi_get_drvdata(spi);
56 return tps65912_device_exit(tps);
59 static const struct spi_device_id tps65912_spi_id_table[] = {
63 MODULE_DEVICE_TABLE(spi, tps65912_spi_id_table);
65 static struct spi_driver tps65912_spi_driver = {
68 .of_match_table = tps65912_spi_of_match_table,
70 .probe = tps65912_spi_probe,
71 .remove = tps65912_spi_remove,
72 .id_table = tps65912_spi_id_table,
74 module_spi_driver(tps65912_spi_driver);
76 MODULE_AUTHOR("Andrew F. Davis <afd@ti.com>");
77 MODULE_DESCRIPTION("TPS65912x SPI Interface Driver");
78 MODULE_LICENSE("GPL v2");