1993a3450SAndreas Dannenberg // SPDX-License-Identifier: GPL-2.0
2993a3450SAndreas Dannenberg /*
3993a3450SAndreas Dannenberg * Texas Instruments PCM186x Universal Audio ADC - SPI
4993a3450SAndreas Dannenberg *
55856d8bdSAlexander A. Klimov * Copyright (C) 2015-2017 Texas Instruments Incorporated - https://www.ti.com
6993a3450SAndreas Dannenberg * Andreas Dannenberg <dannenberg@ti.com>
7993a3450SAndreas Dannenberg * Andrew F. Davis <afd@ti.com>
8993a3450SAndreas Dannenberg */
9993a3450SAndreas Dannenberg
10993a3450SAndreas Dannenberg #include <linux/init.h>
11993a3450SAndreas Dannenberg #include <linux/module.h>
12993a3450SAndreas Dannenberg #include <linux/spi/spi.h>
13993a3450SAndreas Dannenberg
14993a3450SAndreas Dannenberg #include "pcm186x.h"
15993a3450SAndreas Dannenberg
16993a3450SAndreas Dannenberg static const struct of_device_id pcm186x_of_match[] = {
17993a3450SAndreas Dannenberg { .compatible = "ti,pcm1862", .data = (void *)PCM1862 },
18993a3450SAndreas Dannenberg { .compatible = "ti,pcm1863", .data = (void *)PCM1863 },
19993a3450SAndreas Dannenberg { .compatible = "ti,pcm1864", .data = (void *)PCM1864 },
20993a3450SAndreas Dannenberg { .compatible = "ti,pcm1865", .data = (void *)PCM1865 },
21993a3450SAndreas Dannenberg { }
22993a3450SAndreas Dannenberg };
23993a3450SAndreas Dannenberg MODULE_DEVICE_TABLE(of, pcm186x_of_match);
24993a3450SAndreas Dannenberg
pcm186x_spi_probe(struct spi_device * spi)25993a3450SAndreas Dannenberg static int pcm186x_spi_probe(struct spi_device *spi)
26993a3450SAndreas Dannenberg {
27993a3450SAndreas Dannenberg const enum pcm186x_type type =
28993a3450SAndreas Dannenberg (enum pcm186x_type)spi_get_device_id(spi)->driver_data;
29993a3450SAndreas Dannenberg int irq = spi->irq;
30993a3450SAndreas Dannenberg struct regmap *regmap;
31993a3450SAndreas Dannenberg
32993a3450SAndreas Dannenberg regmap = devm_regmap_init_spi(spi, &pcm186x_regmap);
33993a3450SAndreas Dannenberg if (IS_ERR(regmap))
34993a3450SAndreas Dannenberg return PTR_ERR(regmap);
35993a3450SAndreas Dannenberg
36993a3450SAndreas Dannenberg return pcm186x_probe(&spi->dev, type, irq, regmap);
37993a3450SAndreas Dannenberg }
38993a3450SAndreas Dannenberg
39993a3450SAndreas Dannenberg static const struct spi_device_id pcm186x_spi_id[] = {
40993a3450SAndreas Dannenberg { "pcm1862", PCM1862 },
41993a3450SAndreas Dannenberg { "pcm1863", PCM1863 },
42993a3450SAndreas Dannenberg { "pcm1864", PCM1864 },
43993a3450SAndreas Dannenberg { "pcm1865", PCM1865 },
44993a3450SAndreas Dannenberg { }
45993a3450SAndreas Dannenberg };
46993a3450SAndreas Dannenberg MODULE_DEVICE_TABLE(spi, pcm186x_spi_id);
47993a3450SAndreas Dannenberg
48993a3450SAndreas Dannenberg static struct spi_driver pcm186x_spi_driver = {
49993a3450SAndreas Dannenberg .probe = pcm186x_spi_probe,
50993a3450SAndreas Dannenberg .id_table = pcm186x_spi_id,
51993a3450SAndreas Dannenberg .driver = {
52993a3450SAndreas Dannenberg .name = "pcm186x",
53993a3450SAndreas Dannenberg .of_match_table = pcm186x_of_match,
54993a3450SAndreas Dannenberg },
55993a3450SAndreas Dannenberg };
56993a3450SAndreas Dannenberg module_spi_driver(pcm186x_spi_driver);
57993a3450SAndreas Dannenberg
58993a3450SAndreas Dannenberg MODULE_AUTHOR("Andreas Dannenberg <dannenberg@ti.com>");
59993a3450SAndreas Dannenberg MODULE_AUTHOR("Andrew F. Davis <afd@ti.com>");
60993a3450SAndreas Dannenberg MODULE_DESCRIPTION("PCM186x Universal Audio ADC SPI Interface Driver");
61993a3450SAndreas Dannenberg MODULE_LICENSE("GPL v2");
62