blob: 8961e095ae730ca4c76ade1f8e163614ccea6e2e [file] [log] [blame]
Kirill Marinushkin6ee47d42018-08-21 18:52:46 +02001// SPDX-License-Identifier: GPL-2.0
2/*
3 * PCM3060 SPI driver
4 *
5 * Copyright (C) 2018 Kirill Marinushkin <kmarinushkin@birdec.tech>
6 */
7
8#include <linux/module.h>
9#include <linux/spi/spi.h>
10#include <sound/soc.h>
11
12#include "pcm3060.h"
13
14static int pcm3060_spi_probe(struct spi_device *spi)
15{
16 struct pcm3060_priv *priv;
17
18 priv = devm_kzalloc(&spi->dev, sizeof(*priv), GFP_KERNEL);
19 if (!priv)
20 return -ENOMEM;
21
22 spi_set_drvdata(spi, priv);
23
24 priv->regmap = devm_regmap_init_spi(spi, &pcm3060_regmap);
25 if (IS_ERR(priv->regmap))
26 return PTR_ERR(priv->regmap);
27
28 return pcm3060_probe(&spi->dev);
29}
30
31static const struct spi_device_id pcm3060_spi_id[] = {
32 { .name = "pcm3060" },
33 { },
34};
35MODULE_DEVICE_TABLE(spi, pcm3060_spi_id);
36
37#ifdef CONFIG_OF
38static const struct of_device_id pcm3060_of_match[] = {
39 { .compatible = "ti,pcm3060" },
40 { },
41};
42MODULE_DEVICE_TABLE(of, pcm3060_of_match);
43#endif /* CONFIG_OF */
44
45static struct spi_driver pcm3060_spi_driver = {
46 .driver = {
47 .name = "pcm3060",
48#ifdef CONFIG_OF
49 .of_match_table = pcm3060_of_match,
50#endif /* CONFIG_OF */
51 },
52 .id_table = pcm3060_spi_id,
53 .probe = pcm3060_spi_probe,
54};
55
56module_spi_driver(pcm3060_spi_driver);
57
58MODULE_DESCRIPTION("PCM3060 SPI driver");
59MODULE_AUTHOR("Kirill Marinushkin <kmarinushkin@birdec.tech>");
60MODULE_LICENSE("GPL v2");