0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #include <linux/spi/spi.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 int aic3x_spi_probe(struct spi_device *spi)
0021 {
0022 struct regmap *regmap;
0023 struct regmap_config config;
0024 const struct spi_device_id *id = spi_get_device_id(spi);
0025
0026 config = aic3x_regmap;
0027 config.reg_bits = 7;
0028 config.pad_bits = 1;
0029 config.val_bits = 8;
0030 config.read_flag_mask = 0x01;
0031
0032 dev_dbg(&spi->dev, "probing tlv320aic3x spi device\n");
0033
0034 regmap = devm_regmap_init_spi(spi, &config);
0035 return aic3x_probe(&spi->dev, regmap, id->driver_data);
0036 }
0037
0038 static void aic3x_spi_remove(struct spi_device *spi)
0039 {
0040 aic3x_remove(&spi->dev);
0041 }
0042
0043 static const struct spi_device_id aic3x_spi_id[] = {
0044 { "tlv320aic3x", AIC3X_MODEL_3X },
0045 { "tlv320aic33", AIC3X_MODEL_33 },
0046 { "tlv320aic3007", AIC3X_MODEL_3007 },
0047 { "tlv320aic3104", AIC3X_MODEL_3104 },
0048 { "tlv320aic3106", AIC3X_MODEL_3106 },
0049 { }
0050 };
0051 MODULE_DEVICE_TABLE(spi, aic3x_spi_id);
0052
0053 static const struct of_device_id aic3x_of_id[] = {
0054 { .compatible = "ti,tlv320aic3x", },
0055 { .compatible = "ti,tlv320aic33" },
0056 { .compatible = "ti,tlv320aic3007" },
0057 { .compatible = "ti,tlv320aic3104" },
0058 { .compatible = "ti,tlv320aic3106" },
0059 {},
0060 };
0061 MODULE_DEVICE_TABLE(of, aic3x_of_id);
0062
0063 static struct spi_driver aic3x_spi_driver = {
0064 .driver = {
0065 .name = "tlv320aic3x",
0066 .owner = THIS_MODULE,
0067 .of_match_table = aic3x_of_id,
0068 },
0069 .probe = aic3x_spi_probe,
0070 .remove = aic3x_spi_remove,
0071 .id_table = aic3x_spi_id,
0072 };
0073
0074 module_spi_driver(aic3x_spi_driver);
0075
0076 MODULE_DESCRIPTION("ASoC TLV320AIC3x codec driver SPI");
0077 MODULE_AUTHOR("Arun KS <arunks@mistralsolutions.com>");
0078 MODULE_LICENSE("GPL");