xref: /openbmc/linux/sound/soc/codecs/pcm179x-spi.c (revision e3d786a3)
1 /*
2  * PCM179X ASoC SPI driver
3  *
4  * Copyright (c) Amarula Solutions B.V. 2013
5  *
6  *     Michael Trimarchi <michael@amarulasolutions.com>
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  */
18 
19 #include <linux/module.h>
20 #include <linux/of.h>
21 #include <linux/spi/spi.h>
22 #include <linux/regmap.h>
23 
24 #include "pcm179x.h"
25 
26 static int pcm179x_spi_probe(struct spi_device *spi)
27 {
28 	struct regmap *regmap;
29 	int ret;
30 
31 	regmap = devm_regmap_init_spi(spi, &pcm179x_regmap_config);
32 	if (IS_ERR(regmap)) {
33 		ret = PTR_ERR(regmap);
34 		dev_err(&spi->dev, "Failed to allocate regmap: %d\n", ret);
35 		return ret;
36 	}
37 
38 	return pcm179x_common_init(&spi->dev, regmap);
39 }
40 
41 static const struct of_device_id pcm179x_of_match[] = {
42 	{ .compatible = "ti,pcm1792a", },
43 	{ }
44 };
45 MODULE_DEVICE_TABLE(of, pcm179x_of_match);
46 
47 static const struct spi_device_id pcm179x_spi_ids[] = {
48 	{ "pcm179x", 0 },
49 	{ },
50 };
51 MODULE_DEVICE_TABLE(spi, pcm179x_spi_ids);
52 
53 static struct spi_driver pcm179x_spi_driver = {
54 	.driver = {
55 		.name = "pcm179x",
56 		.of_match_table = of_match_ptr(pcm179x_of_match),
57 	},
58 	.id_table = pcm179x_spi_ids,
59 	.probe = pcm179x_spi_probe,
60 };
61 
62 module_spi_driver(pcm179x_spi_driver);
63 
64 MODULE_DESCRIPTION("ASoC PCM179X SPI driver");
65 MODULE_AUTHOR("Michael Trimarchi <michael@amarulasolutions.com>");
66 MODULE_LICENSE("GPL");
67