Linux Audio

Check our new training course

Loading...
v6.13.7
 1// SPDX-License-Identifier: GPL-2.0-or-later
 2/*
 3 * PCM179X ASoC SPI driver
 4 *
 5 * Copyright (c) Amarula Solutions B.V. 2013
 6 *
 7 *     Michael Trimarchi <michael@amarulasolutions.com>
 
 
 
 
 
 
 
 
 
 
 8 */
 9
10#include <linux/module.h>
11#include <linux/of.h>
12#include <linux/spi/spi.h>
13#include <linux/regmap.h>
14
15#include "pcm179x.h"
16
17static int pcm179x_spi_probe(struct spi_device *spi)
18{
19	struct regmap *regmap;
20	int ret;
21
22	regmap = devm_regmap_init_spi(spi, &pcm179x_regmap_config);
23	if (IS_ERR(regmap)) {
24		ret = PTR_ERR(regmap);
25		dev_err(&spi->dev, "Failed to allocate regmap: %d\n", ret);
26		return ret;
27	}
28
29	return pcm179x_common_init(&spi->dev, regmap);
30}
31
32static const struct of_device_id pcm179x_of_match[] __maybe_unused = {
 
 
 
 
 
33	{ .compatible = "ti,pcm1792a", },
34	{ }
35};
36MODULE_DEVICE_TABLE(of, pcm179x_of_match);
37
38static const struct spi_device_id pcm179x_spi_ids[] = {
39	{ "pcm1792a", 0 },
40	{ "pcm179x", 0 },
41	{ },
42};
43MODULE_DEVICE_TABLE(spi, pcm179x_spi_ids);
44
45static struct spi_driver pcm179x_spi_driver = {
46	.driver = {
47		.name = "pcm179x",
48		.of_match_table = of_match_ptr(pcm179x_of_match),
49	},
50	.id_table = pcm179x_spi_ids,
51	.probe = pcm179x_spi_probe,
 
52};
53
54module_spi_driver(pcm179x_spi_driver);
55
56MODULE_DESCRIPTION("ASoC PCM179X SPI driver");
57MODULE_AUTHOR("Michael Trimarchi <michael@amarulasolutions.com>");
58MODULE_LICENSE("GPL");
v4.10.11
 
 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
26static 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
41static int pcm179x_spi_remove(struct spi_device *spi)
42{
43	return pcm179x_common_exit(&spi->dev);
44}
45
46static const struct of_device_id pcm179x_of_match[] = {
47	{ .compatible = "ti,pcm1792a", },
48	{ }
49};
50MODULE_DEVICE_TABLE(of, pcm179x_of_match);
51
52static const struct spi_device_id pcm179x_spi_ids[] = {
 
53	{ "pcm179x", 0 },
54	{ },
55};
56MODULE_DEVICE_TABLE(spi, pcm179x_spi_ids);
57
58static struct spi_driver pcm179x_spi_driver = {
59	.driver = {
60		.name = "pcm179x",
61		.of_match_table = of_match_ptr(pcm179x_of_match),
62	},
63	.id_table = pcm179x_spi_ids,
64	.probe = pcm179x_spi_probe,
65	.remove = pcm179x_spi_remove,
66};
67
68module_spi_driver(pcm179x_spi_driver);
69
70MODULE_DESCRIPTION("ASoC PCM179X SPI driver");
71MODULE_AUTHOR("Michael Trimarchi <michael@amarulasolutions.com>");
72MODULE_LICENSE("GPL");