Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only
0002  *
0003  * ALSA SoC TLV320AIC3x codec driver I2C interface
0004  *
0005  * Author:      Arun KS, <arunks@mistralsolutions.com>
0006  * Copyright:   (C) 2008 Mistral Solutions Pvt Ltd.,
0007  *
0008  * Based on sound/soc/codecs/wm8731.c by Richard Purdie
0009  *
0010  */
0011 
0012 #include <linux/i2c.h>
0013 #include <linux/module.h>
0014 #include <linux/of.h>
0015 #include <linux/regmap.h>
0016 #include <sound/soc.h>
0017 
0018 #include "tlv320aic3x.h"
0019 
0020 static const struct i2c_device_id aic3x_i2c_id[] = {
0021     { "tlv320aic3x", AIC3X_MODEL_3X },
0022     { "tlv320aic33", AIC3X_MODEL_33 },
0023     { "tlv320aic3007", AIC3X_MODEL_3007 },
0024     { "tlv320aic3104", AIC3X_MODEL_3104 },
0025     { "tlv320aic3106", AIC3X_MODEL_3106 },
0026     { }
0027 };
0028 MODULE_DEVICE_TABLE(i2c, aic3x_i2c_id);
0029 
0030 static int aic3x_i2c_probe(struct i2c_client *i2c)
0031 {
0032     struct regmap *regmap;
0033     struct regmap_config config;
0034     const struct i2c_device_id *id = i2c_match_id(aic3x_i2c_id, i2c);
0035 
0036     config = aic3x_regmap;
0037     config.reg_bits = 8;
0038     config.val_bits = 8;
0039 
0040     regmap = devm_regmap_init_i2c(i2c, &config);
0041     return aic3x_probe(&i2c->dev, regmap, id->driver_data);
0042 }
0043 
0044 static int aic3x_i2c_remove(struct i2c_client *i2c)
0045 {
0046     aic3x_remove(&i2c->dev);
0047 
0048     return 0;
0049 }
0050 
0051 static const struct of_device_id aic3x_of_id[] = {
0052     { .compatible = "ti,tlv320aic3x", },
0053     { .compatible = "ti,tlv320aic33" },
0054     { .compatible = "ti,tlv320aic3007" },
0055     { .compatible = "ti,tlv320aic3104" },
0056     { .compatible = "ti,tlv320aic3106" },
0057     {},
0058 };
0059 MODULE_DEVICE_TABLE(of, aic3x_of_id);
0060 
0061 static struct i2c_driver aic3x_i2c_driver = {
0062     .driver = {
0063         .name = "tlv320aic3x",
0064         .of_match_table = aic3x_of_id,
0065     },
0066     .probe_new = aic3x_i2c_probe,
0067     .remove = aic3x_i2c_remove,
0068     .id_table = aic3x_i2c_id,
0069 };
0070 
0071 module_i2c_driver(aic3x_i2c_driver);
0072 
0073 MODULE_DESCRIPTION("ASoC TLV320AIC3x codec driver I2C");
0074 MODULE_AUTHOR("Arun KS <arunks@mistralsolutions.com>");
0075 MODULE_LICENSE("GPL");