ARM: dts: omap5: Add bus_dma_limit for L3 bus
[linux/fpc-iii.git] / sound / soc / codecs / adau1977-spi.c
blob8370bec27a9cc750da947b6de5e88b3cfc37056b
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * ADAU1977/ADAU1978/ADAU1979 driver
5 * Copyright 2014 Analog Devices Inc.
6 * Author: Lars-Peter Clausen <lars@metafoo.de>
7 */
9 #include <linux/mod_devicetable.h>
10 #include <linux/module.h>
11 #include <linux/regmap.h>
12 #include <linux/of.h>
13 #include <linux/of_device.h>
14 #include <linux/spi/spi.h>
15 #include <sound/soc.h>
17 #include "adau1977.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.
27 spi_w8r8(spi, 0x00);
28 spi_w8r8(spi, 0x00);
29 spi_w8r8(spi, 0x00);
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;
37 if (!id)
38 return -EINVAL;
40 config = adau1977_regmap_config;
41 config.val_bits = 8;
42 config.reg_bits = 16;
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 },
54 { }
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" },
62 { },
64 MODULE_DEVICE_TABLE(of, adau1977_spi_of_match);
66 static struct spi_driver adau1977_spi_driver = {
67 .driver = {
68 .name = "adau1977",
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");