2 * ADAU1977/ADAU1978/ADAU1979 driver
4 * Copyright 2014 Analog Devices Inc.
5 * Author: Lars-Peter Clausen <lars@metafoo.de>
7 * Licensed under the GPL-2.
10 #include <linux/mod_devicetable.h>
11 #include <linux/module.h>
12 #include <linux/regmap.h>
14 #include <linux/of_device.h>
15 #include <linux/spi/spi.h>
16 #include <sound/soc.h>
20 static void adau1977_spi_switch_mode(struct device *dev)
22 struct spi_device *spi = to_spi_device(dev);
25 * To get the device into SPI mode CLATCH has to be pulled low three
26 * times. Do this by issuing three dummy reads.
33 static int adau1977_spi_probe(struct spi_device *spi)
35 const struct spi_device_id *id = spi_get_device_id(spi);
36 struct regmap_config config;
41 config = adau1977_regmap_config;
44 config.read_flag_mask = 0x1;
46 return adau1977_probe(&spi->dev,
47 devm_regmap_init_spi(spi, &config),
48 id->driver_data, adau1977_spi_switch_mode);
51 static const struct spi_device_id adau1977_spi_ids[] = {
52 { "adau1977", ADAU1977 },
53 { "adau1978", ADAU1978 },
54 { "adau1979", ADAU1978 },
57 MODULE_DEVICE_TABLE(spi, adau1977_spi_ids);
59 static const struct of_device_id adau1977_spi_of_match[] = {
60 { .compatible = "adi,adau1977" },
61 { .compatible = "adi,adau1978" },
62 { .compatible = "adi,adau1979" },
65 MODULE_DEVICE_TABLE(of, adau1977_spi_of_match);
67 static struct spi_driver adau1977_spi_driver = {
70 .of_match_table = of_match_ptr(adau1977_spi_of_match),
72 .probe = adau1977_spi_probe,
73 .id_table = adau1977_spi_ids,
75 module_spi_driver(adau1977_spi_driver);
77 MODULE_DESCRIPTION("ASoC ADAU1977/ADAU1978/ADAU1979 driver");
78 MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");
79 MODULE_LICENSE("GPL");