blob: 8402854ec15e30b320d31e1416896ced2f964850 [file] [log] [blame]
Graeme Gregory2dcf9fb2009-11-04 17:49:22 +00001/*
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 Heo5a0e3ad2010-03-24 17:04:11 +090014#include <linux/slab.h>
Graeme Gregory2dcf9fb2009-11-04 17:49:22 +000015#include <linux/init.h>
16#include <linux/device.h>
17#include <sound/core.h>
18#include <sound/pcm.h>
19#include <sound/initval.h>
20#include <sound/soc.h>
21
Graeme Gregory2dcf9fb2009-11-04 17:49:22 +000022#define ADS117X_RATES (SNDRV_PCM_RATE_8000_48000)
Graeme Gregory2dcf9fb2009-11-04 17:49:22 +000023#define ADS117X_FORMATS (SNDRV_PCM_FMTBIT_S16_LE)
24
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000025static struct snd_soc_dai_driver ads117x_dai = {
Graeme Gregory2dcf9fb2009-11-04 17:49:22 +000026/* ADC */
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000027 .name = "ads117x-hifi",
Graeme Gregory2dcf9fb2009-11-04 17:49:22 +000028 .capture = {
29 .stream_name = "Capture",
30 .channels_min = 1,
31 .channels_max = 32,
32 .rates = ADS117X_RATES,
33 .formats = ADS117X_FORMATS,},
34};
Graeme Gregory2dcf9fb2009-11-04 17:49:22 +000035
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000036static struct snd_soc_codec_driver soc_codec_dev_ads117x;
37
38static __devinit int ads117x_probe(struct platform_device *pdev)
Graeme Gregory2dcf9fb2009-11-04 17:49:22 +000039{
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000040 return snd_soc_register_codec(&pdev->dev,
41 &soc_codec_dev_ads117x, &ads117x_dai, 1);
Graeme Gregory2dcf9fb2009-11-04 17:49:22 +000042}
43
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000044static int __devexit ads117x_remove(struct platform_device *pdev)
Graeme Gregory2dcf9fb2009-11-04 17:49:22 +000045{
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000046 snd_soc_unregister_codec(&pdev->dev);
Mark Brownf3d0e822009-11-04 21:43:27 +000047 return 0;
48}
49
50static struct platform_driver ads117x_codec_driver = {
51 .driver = {
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000052 .name = "ads117x-codec",
Mark Brownf3d0e822009-11-04 21:43:27 +000053 .owner = THIS_MODULE,
54 },
55
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000056 .probe = ads117x_probe,
57 .remove = __devexit_p(ads117x_remove),
Mark Brownf3d0e822009-11-04 21:43:27 +000058};
59
60static int __init ads117x_init(void)
61{
62 return platform_driver_register(&ads117x_codec_driver);
63}
64module_init(ads117x_init);
Graeme Gregory2dcf9fb2009-11-04 17:49:22 +000065
66static void __exit ads117x_exit(void)
67{
Mark Brownf3d0e822009-11-04 21:43:27 +000068 platform_driver_unregister(&ads117x_codec_driver);
Graeme Gregory2dcf9fb2009-11-04 17:49:22 +000069}
70module_exit(ads117x_exit);
71
72MODULE_DESCRIPTION("ASoC ads117x driver");
73MODULE_AUTHOR("Graeme Gregory");
74MODULE_LICENSE("GPL");