1 // SPDX-License-Identifier: GPL-2.0-only
3 * Driver for ADAU1372 codec
5 * Copyright 2016 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>
12 #include <linux/spi/spi.h>
13 #include <sound/soc.h>
17 static void adau1372_spi_switch_mode(struct device *dev)
19 struct spi_device *spi = to_spi_device(dev);
22 * To get the device into SPI mode CLATCH has to be pulled low three
23 * times. Do this by issuing three dummy reads.
30 static int adau1372_spi_probe(struct spi_device *spi)
32 struct regmap_config config;
34 config = adau1372_regmap_config;
35 config.read_flag_mask = 0x1;
37 return adau1372_probe(&spi->dev,
38 devm_regmap_init_spi(spi, &config), adau1372_spi_switch_mode);
41 static const struct spi_device_id adau1372_spi_id[] = {
45 MODULE_DEVICE_TABLE(spi, adau1372_spi_id);
47 static struct spi_driver adau1372_spi_driver = {
51 .probe = adau1372_spi_probe,
52 .id_table = adau1372_spi_id,
54 module_spi_driver(adau1372_spi_driver);
56 MODULE_DESCRIPTION("ASoC ADAU1372 CODEC SPI driver");
57 MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");
58 MODULE_LICENSE("GPL v2");