18a1d95c3SAnnaliese McDermond /* SPDX-License-Identifier: GPL-2.0
23bcfd222SJeremy McDermond *
38a1d95c3SAnnaliese McDermond * Copyright 2011-2019 NW Digital Radio
43bcfd222SJeremy McDermond *
57297ba6cSAnnaliese McDermond * Author: Annaliese McDermond <nh6z@nh6z.net>
63bcfd222SJeremy McDermond *
73bcfd222SJeremy McDermond * Based on sound/soc/codecs/wm8974 and TI driver for kernel 2.6.27.
83bcfd222SJeremy McDermond *
93bcfd222SJeremy McDermond */
103bcfd222SJeremy McDermond
113bcfd222SJeremy McDermond #include <linux/i2c.h>
123bcfd222SJeremy McDermond #include <linux/module.h>
133bcfd222SJeremy McDermond #include <linux/of.h>
143bcfd222SJeremy McDermond #include <linux/regmap.h>
153bcfd222SJeremy McDermond #include <sound/soc.h>
163bcfd222SJeremy McDermond
173bcfd222SJeremy McDermond #include "tlv320aic32x4.h"
183bcfd222SJeremy McDermond
aic32x4_i2c_probe(struct i2c_client * i2c)19988e6870SStephen Kitt static int aic32x4_i2c_probe(struct i2c_client *i2c)
203bcfd222SJeremy McDermond {
213bcfd222SJeremy McDermond struct regmap *regmap;
223bcfd222SJeremy McDermond struct regmap_config config;
23cac1636eSBiju Das enum aic32x4_type type;
243bcfd222SJeremy McDermond
253bcfd222SJeremy McDermond config = aic32x4_regmap_config;
263bcfd222SJeremy McDermond config.reg_bits = 8;
273bcfd222SJeremy McDermond config.val_bits = 8;
283bcfd222SJeremy McDermond
293bcfd222SJeremy McDermond regmap = devm_regmap_init_i2c(i2c, &config);
30*d44f7bc9SBiju Das type = (uintptr_t)i2c_get_match_data(i2c);
31688d47cdSClaudius Heine
32cac1636eSBiju Das return aic32x4_probe(&i2c->dev, regmap, type);
333bcfd222SJeremy McDermond }
343bcfd222SJeremy McDermond
aic32x4_i2c_remove(struct i2c_client * i2c)35ed5c2f5fSUwe Kleine-König static void aic32x4_i2c_remove(struct i2c_client *i2c)
363bcfd222SJeremy McDermond {
370f884099SUwe Kleine-König aic32x4_remove(&i2c->dev);
383bcfd222SJeremy McDermond }
393bcfd222SJeremy McDermond
403bcfd222SJeremy McDermond static const struct i2c_device_id aic32x4_i2c_id[] = {
41688d47cdSClaudius Heine { "tlv320aic32x4", (kernel_ulong_t)AIC32X4_TYPE_AIC32X4 },
42688d47cdSClaudius Heine { "tlv320aic32x6", (kernel_ulong_t)AIC32X4_TYPE_AIC32X6 },
43b4525b61SClaudius Heine { "tas2505", (kernel_ulong_t)AIC32X4_TYPE_TAS2505 },
443bcfd222SJeremy McDermond { /* sentinel */ }
453bcfd222SJeremy McDermond };
463bcfd222SJeremy McDermond MODULE_DEVICE_TABLE(i2c, aic32x4_i2c_id);
473bcfd222SJeremy McDermond
483bcfd222SJeremy McDermond static const struct of_device_id aic32x4_of_id[] = {
49688d47cdSClaudius Heine { .compatible = "ti,tlv320aic32x4", .data = (void *)AIC32X4_TYPE_AIC32X4 },
50688d47cdSClaudius Heine { .compatible = "ti,tlv320aic32x6", .data = (void *)AIC32X4_TYPE_AIC32X6 },
51b4525b61SClaudius Heine { .compatible = "ti,tas2505", .data = (void *)AIC32X4_TYPE_TAS2505 },
523bcfd222SJeremy McDermond { /* senitel */ }
533bcfd222SJeremy McDermond };
543bcfd222SJeremy McDermond MODULE_DEVICE_TABLE(of, aic32x4_of_id);
553bcfd222SJeremy McDermond
563bcfd222SJeremy McDermond static struct i2c_driver aic32x4_i2c_driver = {
573bcfd222SJeremy McDermond .driver = {
583bcfd222SJeremy McDermond .name = "tlv320aic32x4",
593bcfd222SJeremy McDermond .of_match_table = aic32x4_of_id,
603bcfd222SJeremy McDermond },
619abcd240SUwe Kleine-König .probe = aic32x4_i2c_probe,
623bcfd222SJeremy McDermond .remove = aic32x4_i2c_remove,
633bcfd222SJeremy McDermond .id_table = aic32x4_i2c_id,
643bcfd222SJeremy McDermond };
653bcfd222SJeremy McDermond
663bcfd222SJeremy McDermond module_i2c_driver(aic32x4_i2c_driver);
673bcfd222SJeremy McDermond
683bcfd222SJeremy McDermond MODULE_DESCRIPTION("ASoC TLV320AIC32x4 codec driver I2C");
697297ba6cSAnnaliese McDermond MODULE_AUTHOR("Annaliese McDermond <nh6z@nh6z.net>");
703bcfd222SJeremy McDermond MODULE_LICENSE("GPL");
71