Lars-Peter Clausen | 6c3d713 | 2014-02-17 13:16:54 +0100 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | static int ad193x_spi_probe(struct spi_device *spi) |
| 18 | { |
Cyrille Pitchen | e5224f5 | 2015-09-29 16:41:43 +0200 | [diff] [blame] | 19 | const struct spi_device_id *id = spi_get_device_id(spi); |
Lars-Peter Clausen | 6c3d713 | 2014-02-17 13:16:54 +0100 | [diff] [blame] | 20 | 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 Pitchen | e5224f5 | 2015-09-29 16:41:43 +0200 | [diff] [blame] | 28 | return ad193x_probe(&spi->dev, devm_regmap_init_spi(spi, &config), |
| 29 | (enum ad193x_type)id->driver_data); |
Lars-Peter Clausen | 6c3d713 | 2014-02-17 13:16:54 +0100 | [diff] [blame] | 30 | } |
| 31 | |
| 32 | static int ad193x_spi_remove(struct spi_device *spi) |
| 33 | { |
| 34 | snd_soc_unregister_codec(&spi->dev); |
| 35 | return 0; |
| 36 | } |
| 37 | |
Cyrille Pitchen | e5224f5 | 2015-09-29 16:41:43 +0200 | [diff] [blame] | 38 | static const struct spi_device_id ad193x_spi_id[] = { |
| 39 | { "ad193x", AD193X }, |
| 40 | { "ad1933", AD1933 }, |
| 41 | { "ad1934", AD1934 }, |
Cyrille Pitchen | e5224f5 | 2015-09-29 16:41:43 +0200 | [diff] [blame] | 42 | { "ad1938", AD193X }, |
Axel Lin | d46183e | 2015-10-06 17:26:36 +0800 | [diff] [blame] | 43 | { "ad1939", AD193X }, |
Axel Lin | 355b27e | 2015-10-18 10:06:11 +0800 | [diff] [blame] | 44 | { "adau1328", AD193X }, |
Cyrille Pitchen | e5224f5 | 2015-09-29 16:41:43 +0200 | [diff] [blame] | 45 | { } |
| 46 | }; |
| 47 | MODULE_DEVICE_TABLE(spi, ad193x_spi_id); |
| 48 | |
Lars-Peter Clausen | 6c3d713 | 2014-02-17 13:16:54 +0100 | [diff] [blame] | 49 | static struct spi_driver ad193x_spi_driver = { |
| 50 | .driver = { |
| 51 | .name = "ad193x", |
Lars-Peter Clausen | 6c3d713 | 2014-02-17 13:16:54 +0100 | [diff] [blame] | 52 | }, |
| 53 | .probe = ad193x_spi_probe, |
| 54 | .remove = ad193x_spi_remove, |
Cyrille Pitchen | e5224f5 | 2015-09-29 16:41:43 +0200 | [diff] [blame] | 55 | .id_table = ad193x_spi_id, |
Lars-Peter Clausen | 6c3d713 | 2014-02-17 13:16:54 +0100 | [diff] [blame] | 56 | }; |
| 57 | module_spi_driver(ad193x_spi_driver); |
| 58 | |
| 59 | MODULE_DESCRIPTION("ASoC AD1938/AD1939 audio CODEC driver"); |
| 60 | MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>"); |
| 61 | MODULE_LICENSE("GPL"); |