xref: /OK3568_Linux_fs/kernel/sound/soc/codecs/tlv320aic32x4-i2c.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0
2*4882a593Smuzhiyun  *
3*4882a593Smuzhiyun  * Copyright 2011-2019 NW Digital Radio
4*4882a593Smuzhiyun  *
5*4882a593Smuzhiyun  * Author: Annaliese McDermond <nh6z@nh6z.net>
6*4882a593Smuzhiyun  *
7*4882a593Smuzhiyun  * Based on sound/soc/codecs/wm8974 and TI driver for kernel 2.6.27.
8*4882a593Smuzhiyun  *
9*4882a593Smuzhiyun  */
10*4882a593Smuzhiyun 
11*4882a593Smuzhiyun #include <linux/i2c.h>
12*4882a593Smuzhiyun #include <linux/module.h>
13*4882a593Smuzhiyun #include <linux/of.h>
14*4882a593Smuzhiyun #include <linux/regmap.h>
15*4882a593Smuzhiyun #include <sound/soc.h>
16*4882a593Smuzhiyun 
17*4882a593Smuzhiyun #include "tlv320aic32x4.h"
18*4882a593Smuzhiyun 
aic32x4_i2c_probe(struct i2c_client * i2c,const struct i2c_device_id * id)19*4882a593Smuzhiyun static int aic32x4_i2c_probe(struct i2c_client *i2c,
20*4882a593Smuzhiyun 			     const struct i2c_device_id *id)
21*4882a593Smuzhiyun {
22*4882a593Smuzhiyun 	struct regmap *regmap;
23*4882a593Smuzhiyun 	struct regmap_config config;
24*4882a593Smuzhiyun 
25*4882a593Smuzhiyun 	config = aic32x4_regmap_config;
26*4882a593Smuzhiyun 	config.reg_bits = 8;
27*4882a593Smuzhiyun 	config.val_bits = 8;
28*4882a593Smuzhiyun 
29*4882a593Smuzhiyun 	regmap = devm_regmap_init_i2c(i2c, &config);
30*4882a593Smuzhiyun 	return aic32x4_probe(&i2c->dev, regmap);
31*4882a593Smuzhiyun }
32*4882a593Smuzhiyun 
aic32x4_i2c_remove(struct i2c_client * i2c)33*4882a593Smuzhiyun static int aic32x4_i2c_remove(struct i2c_client *i2c)
34*4882a593Smuzhiyun {
35*4882a593Smuzhiyun 	return aic32x4_remove(&i2c->dev);
36*4882a593Smuzhiyun }
37*4882a593Smuzhiyun 
38*4882a593Smuzhiyun static const struct i2c_device_id aic32x4_i2c_id[] = {
39*4882a593Smuzhiyun 	{ "tlv320aic32x4", 0 },
40*4882a593Smuzhiyun 	{ "tlv320aic32x6", 1 },
41*4882a593Smuzhiyun 	{ /* sentinel */ }
42*4882a593Smuzhiyun };
43*4882a593Smuzhiyun MODULE_DEVICE_TABLE(i2c, aic32x4_i2c_id);
44*4882a593Smuzhiyun 
45*4882a593Smuzhiyun static const struct of_device_id aic32x4_of_id[] = {
46*4882a593Smuzhiyun 	{ .compatible = "ti,tlv320aic32x4", },
47*4882a593Smuzhiyun 	{ .compatible = "ti,tlv320aic32x6", },
48*4882a593Smuzhiyun 	{ /* senitel */ }
49*4882a593Smuzhiyun };
50*4882a593Smuzhiyun MODULE_DEVICE_TABLE(of, aic32x4_of_id);
51*4882a593Smuzhiyun 
52*4882a593Smuzhiyun static struct i2c_driver aic32x4_i2c_driver = {
53*4882a593Smuzhiyun 	.driver = {
54*4882a593Smuzhiyun 		.name = "tlv320aic32x4",
55*4882a593Smuzhiyun 		.of_match_table = aic32x4_of_id,
56*4882a593Smuzhiyun 	},
57*4882a593Smuzhiyun 	.probe =    aic32x4_i2c_probe,
58*4882a593Smuzhiyun 	.remove =   aic32x4_i2c_remove,
59*4882a593Smuzhiyun 	.id_table = aic32x4_i2c_id,
60*4882a593Smuzhiyun };
61*4882a593Smuzhiyun 
62*4882a593Smuzhiyun module_i2c_driver(aic32x4_i2c_driver);
63*4882a593Smuzhiyun 
64*4882a593Smuzhiyun MODULE_DESCRIPTION("ASoC TLV320AIC32x4 codec driver I2C");
65*4882a593Smuzhiyun MODULE_AUTHOR("Annaliese McDermond <nh6z@nh6z.net>");
66*4882a593Smuzhiyun MODULE_LICENSE("GPL");
67