0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #include <linux/i2c.h>
0012 #include <linux/module.h>
0013 #include <linux/of.h>
0014 #include <linux/regmap.h>
0015 #include <sound/soc.h>
0016
0017 #include "tlv320aic32x4.h"
0018
0019 static const struct of_device_id aic32x4_of_id[];
0020 static const struct i2c_device_id aic32x4_i2c_id[];
0021
0022 static int aic32x4_i2c_probe(struct i2c_client *i2c)
0023 {
0024 struct regmap *regmap;
0025 struct regmap_config config;
0026
0027 config = aic32x4_regmap_config;
0028 config.reg_bits = 8;
0029 config.val_bits = 8;
0030
0031 regmap = devm_regmap_init_i2c(i2c, &config);
0032
0033 if (i2c->dev.of_node) {
0034 const struct of_device_id *oid;
0035
0036 oid = of_match_node(aic32x4_of_id, i2c->dev.of_node);
0037 dev_set_drvdata(&i2c->dev, (void *)oid->data);
0038 } else {
0039 const struct i2c_device_id *id;
0040
0041 id = i2c_match_id(aic32x4_i2c_id, i2c);
0042 dev_set_drvdata(&i2c->dev, (void *)id->driver_data);
0043 }
0044
0045 return aic32x4_probe(&i2c->dev, regmap);
0046 }
0047
0048 static int aic32x4_i2c_remove(struct i2c_client *i2c)
0049 {
0050 aic32x4_remove(&i2c->dev);
0051
0052 return 0;
0053 }
0054
0055 static const struct i2c_device_id aic32x4_i2c_id[] = {
0056 { "tlv320aic32x4", (kernel_ulong_t)AIC32X4_TYPE_AIC32X4 },
0057 { "tlv320aic32x6", (kernel_ulong_t)AIC32X4_TYPE_AIC32X6 },
0058 { "tas2505", (kernel_ulong_t)AIC32X4_TYPE_TAS2505 },
0059 { }
0060 };
0061 MODULE_DEVICE_TABLE(i2c, aic32x4_i2c_id);
0062
0063 static const struct of_device_id aic32x4_of_id[] = {
0064 { .compatible = "ti,tlv320aic32x4", .data = (void *)AIC32X4_TYPE_AIC32X4 },
0065 { .compatible = "ti,tlv320aic32x6", .data = (void *)AIC32X4_TYPE_AIC32X6 },
0066 { .compatible = "ti,tas2505", .data = (void *)AIC32X4_TYPE_TAS2505 },
0067 { }
0068 };
0069 MODULE_DEVICE_TABLE(of, aic32x4_of_id);
0070
0071 static struct i2c_driver aic32x4_i2c_driver = {
0072 .driver = {
0073 .name = "tlv320aic32x4",
0074 .of_match_table = aic32x4_of_id,
0075 },
0076 .probe_new = aic32x4_i2c_probe,
0077 .remove = aic32x4_i2c_remove,
0078 .id_table = aic32x4_i2c_id,
0079 };
0080
0081 module_i2c_driver(aic32x4_i2c_driver);
0082
0083 MODULE_DESCRIPTION("ASoC TLV320AIC32x4 codec driver I2C");
0084 MODULE_AUTHOR("Annaliese McDermond <nh6z@nh6z.net>");
0085 MODULE_LICENSE("GPL");