blob: 3c1394a803b868d67f530214fc97e03891ea087f [file] [log] [blame]
Lars-Peter Clausen6c3d7132014-02-17 13:16:54 +01001/*
2 * AD1938/AD1939 audio driver
3 *
4 * Copyright 2014 Analog Devices Inc.
5 *
6 * Licensed under the GPL-2.
7 */
8
9#include <linux/module.h>
10#include <linux/spi/spi.h>
11#include <linux/regmap.h>
12
13#include <sound/soc.h>
14
15#include "ad193x.h"
16
17static int ad193x_spi_probe(struct spi_device *spi)
18{
Cyrille Pitchene5224f52015-09-29 16:41:43 +020019 const struct spi_device_id *id = spi_get_device_id(spi);
Lars-Peter Clausen6c3d7132014-02-17 13:16:54 +010020 struct regmap_config config;
21
22 config = ad193x_regmap_config;
23 config.val_bits = 8;
24 config.reg_bits = 16;
25 config.read_flag_mask = 0x09;
26 config.write_flag_mask = 0x08;
27
Cyrille Pitchene5224f52015-09-29 16:41:43 +020028 return ad193x_probe(&spi->dev, devm_regmap_init_spi(spi, &config),
29 (enum ad193x_type)id->driver_data);
Lars-Peter Clausen6c3d7132014-02-17 13:16:54 +010030}
31
Cyrille Pitchene5224f52015-09-29 16:41:43 +020032static const struct spi_device_id ad193x_spi_id[] = {
33 { "ad193x", AD193X },
34 { "ad1933", AD1933 },
35 { "ad1934", AD1934 },
Cyrille Pitchene5224f52015-09-29 16:41:43 +020036 { "ad1938", AD193X },
Axel Lind46183e2015-10-06 17:26:36 +080037 { "ad1939", AD193X },
Axel Lin355b27e2015-10-18 10:06:11 +080038 { "adau1328", AD193X },
Cyrille Pitchene5224f52015-09-29 16:41:43 +020039 { }
40};
41MODULE_DEVICE_TABLE(spi, ad193x_spi_id);
42
Lars-Peter Clausen6c3d7132014-02-17 13:16:54 +010043static struct spi_driver ad193x_spi_driver = {
44 .driver = {
45 .name = "ad193x",
Lars-Peter Clausen6c3d7132014-02-17 13:16:54 +010046 },
47 .probe = ad193x_spi_probe,
Cyrille Pitchene5224f52015-09-29 16:41:43 +020048 .id_table = ad193x_spi_id,
Lars-Peter Clausen6c3d7132014-02-17 13:16:54 +010049};
50module_spi_driver(ad193x_spi_driver);
51
52MODULE_DESCRIPTION("ASoC AD1938/AD1939 audio CODEC driver");
53MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>");
54MODULE_LICENSE("GPL");