tps65912-spi.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 <[email protected]>
  7. *
  8. * Based on the TPS65218 driver and the previous TPS65912 driver by
  9. * Margarita Olaya Cabrera <[email protected]>
  10. */
  11. #include <linux/module.h>
  12. #include <linux/regmap.h>
  13. #include <linux/spi/spi.h>
  14. #include <linux/mfd/tps65912.h>
  15. static const struct of_device_id tps65912_spi_of_match_table[] = {
  16. { .compatible = "ti,tps65912", },
  17. { /* sentinel */ }
  18. };
  19. MODULE_DEVICE_TABLE(of, tps65912_spi_of_match_table);
  20. static int tps65912_spi_probe(struct spi_device *spi)
  21. {
  22. struct tps65912 *tps;
  23. tps = devm_kzalloc(&spi->dev, sizeof(*tps), GFP_KERNEL);
  24. if (!tps)
  25. return -ENOMEM;
  26. spi_set_drvdata(spi, tps);
  27. tps->dev = &spi->dev;
  28. tps->irq = spi->irq;
  29. tps->regmap = devm_regmap_init_spi(spi, &tps65912_regmap_config);
  30. if (IS_ERR(tps->regmap)) {
  31. dev_err(tps->dev, "Failed to initialize register map\n");
  32. return PTR_ERR(tps->regmap);
  33. }
  34. return tps65912_device_init(tps);
  35. }
  36. static void tps65912_spi_remove(struct spi_device *spi)
  37. {
  38. struct tps65912 *tps = spi_get_drvdata(spi);
  39. tps65912_device_exit(tps);
  40. }
  41. static const struct spi_device_id tps65912_spi_id_table[] = {
  42. { "tps65912", 0 },
  43. { /* sentinel */ }
  44. };
  45. MODULE_DEVICE_TABLE(spi, tps65912_spi_id_table);
  46. static struct spi_driver tps65912_spi_driver = {
  47. .driver = {
  48. .name = "tps65912",
  49. .of_match_table = tps65912_spi_of_match_table,
  50. },
  51. .probe = tps65912_spi_probe,
  52. .remove = tps65912_spi_remove,
  53. .id_table = tps65912_spi_id_table,
  54. };
  55. module_spi_driver(tps65912_spi_driver);
  56. MODULE_AUTHOR("Andrew F. Davis <[email protected]>");
  57. MODULE_DESCRIPTION("TPS65912x SPI Interface Driver");
  58. MODULE_LICENSE("GPL v2");