0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <linux/mod_devicetable.h>
0010 #include <linux/module.h>
0011 #include <linux/regmap.h>
0012 #include <linux/spi/spi.h>
0013 #include <sound/soc.h>
0014
0015 #include "adau1781.h"
0016
0017 static void adau1781_spi_switch_mode(struct device *dev)
0018 {
0019 struct spi_device *spi = to_spi_device(dev);
0020
0021
0022
0023
0024
0025 spi_w8r8(spi, 0x00);
0026 spi_w8r8(spi, 0x00);
0027 spi_w8r8(spi, 0x00);
0028 }
0029
0030 static int adau1781_spi_probe(struct spi_device *spi)
0031 {
0032 const struct spi_device_id *id = spi_get_device_id(spi);
0033 struct regmap_config config;
0034
0035 if (!id)
0036 return -EINVAL;
0037
0038 config = adau1781_regmap_config;
0039 config.val_bits = 8;
0040 config.reg_bits = 24;
0041 config.read_flag_mask = 0x1;
0042
0043 return adau1781_probe(&spi->dev,
0044 devm_regmap_init_spi(spi, &config),
0045 id->driver_data, adau1781_spi_switch_mode);
0046 }
0047
0048 static void adau1781_spi_remove(struct spi_device *spi)
0049 {
0050 adau17x1_remove(&spi->dev);
0051 }
0052
0053 static const struct spi_device_id adau1781_spi_id[] = {
0054 { "adau1381", ADAU1381 },
0055 { "adau1781", ADAU1781 },
0056 { }
0057 };
0058 MODULE_DEVICE_TABLE(spi, adau1781_spi_id);
0059
0060 #if defined(CONFIG_OF)
0061 static const struct of_device_id adau1781_spi_dt_ids[] = {
0062 { .compatible = "adi,adau1381", },
0063 { .compatible = "adi,adau1781", },
0064 { },
0065 };
0066 MODULE_DEVICE_TABLE(of, adau1781_spi_dt_ids);
0067 #endif
0068
0069 static struct spi_driver adau1781_spi_driver = {
0070 .driver = {
0071 .name = "adau1781",
0072 .of_match_table = of_match_ptr(adau1781_spi_dt_ids),
0073 },
0074 .probe = adau1781_spi_probe,
0075 .remove = adau1781_spi_remove,
0076 .id_table = adau1781_spi_id,
0077 };
0078 module_spi_driver(adau1781_spi_driver);
0079
0080 MODULE_DESCRIPTION("ASoC ADAU1381/ADAU1781 CODEC SPI driver");
0081 MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");
0082 MODULE_LICENSE("GPL");