Graeme Gregory | 2dcf9fb | 2009-11-04 17:49:22 +0000 | [diff] [blame] | 1 | /* |
| 2 | * ads117x.c -- Driver for ads1174/8 ADC chips |
| 3 | * |
| 4 | * Copyright 2009 ShotSpotter Inc. |
| 5 | * Author: Graeme Gregory <gg@slimlogic.co.uk> |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify it |
| 8 | * under the terms of the GNU General Public License as published by the |
| 9 | * Free Software Foundation; either version 2 of the License, or (at your |
| 10 | * option) any later version. |
| 11 | */ |
| 12 | |
| 13 | #include <linux/kernel.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 14 | #include <linux/slab.h> |
Graeme Gregory | 2dcf9fb | 2009-11-04 17:49:22 +0000 | [diff] [blame] | 15 | #include <linux/init.h> |
| 16 | #include <linux/device.h> |
Paul Gortmaker | da155d5 | 2011-07-15 12:38:28 -0400 | [diff] [blame] | 17 | #include <linux/module.h> |
Graeme Gregory | 2dcf9fb | 2009-11-04 17:49:22 +0000 | [diff] [blame] | 18 | #include <sound/core.h> |
| 19 | #include <sound/pcm.h> |
| 20 | #include <sound/initval.h> |
| 21 | #include <sound/soc.h> |
| 22 | |
Graeme Gregory | 2dcf9fb | 2009-11-04 17:49:22 +0000 | [diff] [blame] | 23 | #define ADS117X_RATES (SNDRV_PCM_RATE_8000_48000) |
Graeme Gregory | 2dcf9fb | 2009-11-04 17:49:22 +0000 | [diff] [blame] | 24 | #define ADS117X_FORMATS (SNDRV_PCM_FMTBIT_S16_LE) |
| 25 | |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 26 | static struct snd_soc_dai_driver ads117x_dai = { |
Graeme Gregory | 2dcf9fb | 2009-11-04 17:49:22 +0000 | [diff] [blame] | 27 | /* ADC */ |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 28 | .name = "ads117x-hifi", |
Graeme Gregory | 2dcf9fb | 2009-11-04 17:49:22 +0000 | [diff] [blame] | 29 | .capture = { |
| 30 | .stream_name = "Capture", |
| 31 | .channels_min = 1, |
| 32 | .channels_max = 32, |
| 33 | .rates = ADS117X_RATES, |
| 34 | .formats = ADS117X_FORMATS,}, |
| 35 | }; |
Graeme Gregory | 2dcf9fb | 2009-11-04 17:49:22 +0000 | [diff] [blame] | 36 | |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 37 | static struct snd_soc_codec_driver soc_codec_dev_ads117x; |
| 38 | |
| 39 | static __devinit int ads117x_probe(struct platform_device *pdev) |
Graeme Gregory | 2dcf9fb | 2009-11-04 17:49:22 +0000 | [diff] [blame] | 40 | { |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 41 | return snd_soc_register_codec(&pdev->dev, |
| 42 | &soc_codec_dev_ads117x, &ads117x_dai, 1); |
Graeme Gregory | 2dcf9fb | 2009-11-04 17:49:22 +0000 | [diff] [blame] | 43 | } |
| 44 | |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 45 | static int __devexit ads117x_remove(struct platform_device *pdev) |
Graeme Gregory | 2dcf9fb | 2009-11-04 17:49:22 +0000 | [diff] [blame] | 46 | { |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 47 | snd_soc_unregister_codec(&pdev->dev); |
Mark Brown | f3d0e82 | 2009-11-04 21:43:27 +0000 | [diff] [blame] | 48 | return 0; |
| 49 | } |
| 50 | |
| 51 | static struct platform_driver ads117x_codec_driver = { |
| 52 | .driver = { |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 53 | .name = "ads117x-codec", |
Mark Brown | f3d0e82 | 2009-11-04 21:43:27 +0000 | [diff] [blame] | 54 | .owner = THIS_MODULE, |
| 55 | }, |
| 56 | |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 57 | .probe = ads117x_probe, |
| 58 | .remove = __devexit_p(ads117x_remove), |
Mark Brown | f3d0e82 | 2009-11-04 21:43:27 +0000 | [diff] [blame] | 59 | }; |
| 60 | |
| 61 | static int __init ads117x_init(void) |
| 62 | { |
| 63 | return platform_driver_register(&ads117x_codec_driver); |
| 64 | } |
| 65 | module_init(ads117x_init); |
Graeme Gregory | 2dcf9fb | 2009-11-04 17:49:22 +0000 | [diff] [blame] | 66 | |
| 67 | static void __exit ads117x_exit(void) |
| 68 | { |
Mark Brown | f3d0e82 | 2009-11-04 21:43:27 +0000 | [diff] [blame] | 69 | platform_driver_unregister(&ads117x_codec_driver); |
Graeme Gregory | 2dcf9fb | 2009-11-04 17:49:22 +0000 | [diff] [blame] | 70 | } |
| 71 | module_exit(ads117x_exit); |
| 72 | |
| 73 | MODULE_DESCRIPTION("ASoC ads117x driver"); |
| 74 | MODULE_AUTHOR("Graeme Gregory"); |
| 75 | MODULE_LICENSE("GPL"); |