1 // SPDX-License-Identifier: GPL-2.0-only
3 * ADAU1977/ADAU1978/ADAU1979 driver
5 * Copyright 2014 Analog Devices Inc.
6 * Author: Lars-Peter Clausen <lars@metafoo.de>
9 #include <linux/mod_devicetable.h>
10 #include <linux/module.h>
11 #include <linux/regmap.h>
13 #include <linux/of_device.h>
14 #include <linux/spi/spi.h>
15 #include <sound/soc.h>
19 static void adau1977_spi_switch_mode(struct device
*dev
)
21 struct spi_device
*spi
= to_spi_device(dev
);
24 * To get the device into SPI mode CLATCH has to be pulled low three
25 * times. Do this by issuing three dummy reads.
32 static int adau1977_spi_probe(struct spi_device
*spi
)
34 const struct spi_device_id
*id
= spi_get_device_id(spi
);
35 struct regmap_config config
;
40 config
= adau1977_regmap_config
;
43 config
.read_flag_mask
= 0x1;
45 return adau1977_probe(&spi
->dev
,
46 devm_regmap_init_spi(spi
, &config
),
47 id
->driver_data
, adau1977_spi_switch_mode
);
50 static const struct spi_device_id adau1977_spi_ids
[] = {
51 { "adau1977", ADAU1977
},
52 { "adau1978", ADAU1978
},
53 { "adau1979", ADAU1978
},
56 MODULE_DEVICE_TABLE(spi
, adau1977_spi_ids
);
58 static const struct of_device_id adau1977_spi_of_match
[] = {
59 { .compatible
= "adi,adau1977" },
60 { .compatible
= "adi,adau1978" },
61 { .compatible
= "adi,adau1979" },
64 MODULE_DEVICE_TABLE(of
, adau1977_spi_of_match
);
66 static struct spi_driver adau1977_spi_driver
= {
69 .of_match_table
= of_match_ptr(adau1977_spi_of_match
),
71 .probe
= adau1977_spi_probe
,
72 .id_table
= adau1977_spi_ids
,
74 module_spi_driver(adau1977_spi_driver
);
76 MODULE_DESCRIPTION("ASoC ADAU1977/ADAU1978/ADAU1979 driver");
77 MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");
78 MODULE_LICENSE("GPL");