18a1d95c3SAnnaliese McDermond /* SPDX-License-Identifier: GPL-2.0
2125bc681SJeremy McDermond *
38a1d95c3SAnnaliese McDermond * Copyright 2011-2019 NW Digital Radio
4125bc681SJeremy McDermond *
57297ba6cSAnnaliese McDermond * Author: Annaliese McDermond <nh6z@nh6z.net>
6125bc681SJeremy McDermond *
7125bc681SJeremy McDermond * Based on sound/soc/codecs/wm8974 and TI driver for kernel 2.6.27.
8125bc681SJeremy McDermond *
9125bc681SJeremy McDermond */
10125bc681SJeremy McDermond
11125bc681SJeremy McDermond #include <linux/spi/spi.h>
12125bc681SJeremy McDermond #include <linux/module.h>
13125bc681SJeremy McDermond #include <linux/of.h>
14125bc681SJeremy McDermond #include <linux/regmap.h>
15125bc681SJeremy McDermond #include <sound/soc.h>
16125bc681SJeremy McDermond
17125bc681SJeremy McDermond #include "tlv320aic32x4.h"
18125bc681SJeremy McDermond
aic32x4_spi_probe(struct spi_device * spi)19125bc681SJeremy McDermond static int aic32x4_spi_probe(struct spi_device *spi)
20125bc681SJeremy McDermond {
21125bc681SJeremy McDermond struct regmap *regmap;
22125bc681SJeremy McDermond struct regmap_config config;
23cac1636eSBiju Das enum aic32x4_type type;
24125bc681SJeremy McDermond
25125bc681SJeremy McDermond config = aic32x4_regmap_config;
26125bc681SJeremy McDermond config.reg_bits = 7;
27125bc681SJeremy McDermond config.pad_bits = 1;
28125bc681SJeremy McDermond config.val_bits = 8;
29125bc681SJeremy McDermond config.read_flag_mask = 0x01;
30125bc681SJeremy McDermond
31125bc681SJeremy McDermond regmap = devm_regmap_init_spi(spi, &config);
32*c6d86149SBiju Das type = (uintptr_t)spi_get_device_match_data(spi);
33688d47cdSClaudius Heine
34cac1636eSBiju Das return aic32x4_probe(&spi->dev, regmap, type);
35125bc681SJeremy McDermond }
36125bc681SJeremy McDermond
aic32x4_spi_remove(struct spi_device * spi)37a0386bbaSUwe Kleine-König static void aic32x4_spi_remove(struct spi_device *spi)
38125bc681SJeremy McDermond {
390f884099SUwe Kleine-König aic32x4_remove(&spi->dev);
40125bc681SJeremy McDermond }
41125bc681SJeremy McDermond
42125bc681SJeremy McDermond static const struct spi_device_id aic32x4_spi_id[] = {
43688d47cdSClaudius Heine { "tlv320aic32x4", (kernel_ulong_t)AIC32X4_TYPE_AIC32X4 },
44688d47cdSClaudius Heine { "tlv320aic32x6", (kernel_ulong_t)AIC32X4_TYPE_AIC32X6 },
45125bc681SJeremy McDermond { /* sentinel */ }
46125bc681SJeremy McDermond };
47125bc681SJeremy McDermond MODULE_DEVICE_TABLE(spi, aic32x4_spi_id);
48125bc681SJeremy McDermond
49125bc681SJeremy McDermond static const struct of_device_id aic32x4_of_id[] = {
50688d47cdSClaudius Heine { .compatible = "ti,tlv320aic32x4", .data = (void *)AIC32X4_TYPE_AIC32X4 },
51688d47cdSClaudius Heine { .compatible = "ti,tlv320aic32x6", .data = (void *)AIC32X4_TYPE_AIC32X6 },
52125bc681SJeremy McDermond { /* senitel */ }
53125bc681SJeremy McDermond };
54125bc681SJeremy McDermond MODULE_DEVICE_TABLE(of, aic32x4_of_id);
55125bc681SJeremy McDermond
56125bc681SJeremy McDermond static struct spi_driver aic32x4_spi_driver = {
57125bc681SJeremy McDermond .driver = {
58125bc681SJeremy McDermond .name = "tlv320aic32x4",
59125bc681SJeremy McDermond .of_match_table = aic32x4_of_id,
60125bc681SJeremy McDermond },
61125bc681SJeremy McDermond .probe = aic32x4_spi_probe,
62125bc681SJeremy McDermond .remove = aic32x4_spi_remove,
63125bc681SJeremy McDermond .id_table = aic32x4_spi_id,
64125bc681SJeremy McDermond };
65125bc681SJeremy McDermond
66125bc681SJeremy McDermond module_spi_driver(aic32x4_spi_driver);
67125bc681SJeremy McDermond
68125bc681SJeremy McDermond MODULE_DESCRIPTION("ASoC TLV320AIC32x4 codec driver SPI");
697297ba6cSAnnaliese McDermond MODULE_AUTHOR("Annaliese McDermond <nh6z@nh6z.net>");
70125bc681SJeremy McDermond MODULE_LICENSE("GPL");
71