Blame view

drivers/mfd/tps65912-spi.c 2.16 KB
796f5692d   Andrew F. Davis   mfd: tps65912: Ad...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
  /*
   * SPI access driver for TI TPS65912x PMICs
   *
   * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/
   *	Andrew F. Davis <afd@ti.com>
   *
   * This program is free software; you can redistribute it and/or
   * modify it under the terms of the GNU General Public License version 2 as
   * published by the Free Software Foundation.
   *
   * This program is distributed "as is" WITHOUT ANY WARRANTY of any
   * kind, whether expressed or implied; without even the implied warranty
   * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   * GNU General Public License version 2 for more details.
   *
   * Based on the TPS65218 driver and the previous TPS65912 driver by
   * Margarita Olaya Cabrera <magi@slimlogic.co.uk>
   */
  
  #include <linux/module.h>
  #include <linux/regmap.h>
  #include <linux/spi/spi.h>
  
  #include <linux/mfd/tps65912.h>
  
  static const struct of_device_id tps65912_spi_of_match_table[] = {
  	{ .compatible = "ti,tps65912", },
  	{ /* sentinel */ }
  };
9e364e87a   Daniel Gomez   mfd: tps65912-spi...
30
  MODULE_DEVICE_TABLE(of, tps65912_spi_of_match_table);
796f5692d   Andrew F. Davis   mfd: tps65912: Ad...
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
  
  static int tps65912_spi_probe(struct spi_device *spi)
  {
  	struct tps65912 *tps;
  
  	tps = devm_kzalloc(&spi->dev, sizeof(*tps), GFP_KERNEL);
  	if (!tps)
  		return -ENOMEM;
  
  	spi_set_drvdata(spi, tps);
  	tps->dev = &spi->dev;
  	tps->irq = spi->irq;
  
  	tps->regmap = devm_regmap_init_spi(spi, &tps65912_regmap_config);
  	if (IS_ERR(tps->regmap)) {
  		dev_err(tps->dev, "Failed to initialize register map
  ");
  		return PTR_ERR(tps->regmap);
  	}
  
  	return tps65912_device_init(tps);
  }
0ec69542a   Andrew F. Davis   mfd: tps65912: Fi...
53
  static int tps65912_spi_remove(struct spi_device *spi)
796f5692d   Andrew F. Davis   mfd: tps65912: Ad...
54
  {
0ec69542a   Andrew F. Davis   mfd: tps65912: Fi...
55
  	struct tps65912 *tps = spi_get_drvdata(spi);
796f5692d   Andrew F. Davis   mfd: tps65912: Ad...
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
  
  	return tps65912_device_exit(tps);
  }
  
  static const struct spi_device_id tps65912_spi_id_table[] = {
  	{ "tps65912", 0 },
  	{ /* sentinel */ }
  };
  MODULE_DEVICE_TABLE(spi, tps65912_spi_id_table);
  
  static struct spi_driver tps65912_spi_driver = {
  	.driver		= {
  		.name	= "tps65912",
  		.of_match_table = tps65912_spi_of_match_table,
  	},
  	.probe		= tps65912_spi_probe,
  	.remove		= tps65912_spi_remove,
  	.id_table       = tps65912_spi_id_table,
  };
  module_spi_driver(tps65912_spi_driver);
  
  MODULE_AUTHOR("Andrew F. Davis <afd@ti.com>");
  MODULE_DESCRIPTION("TPS65912x SPI Interface Driver");
  MODULE_LICENSE("GPL v2");