2 * ads117x.c -- Driver for ads1174/8 ADC chips
4 * Copyright 2009 ShotSpotter Inc.
5 * Author: Graeme Gregory <gg@slimlogic.co.uk>
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.
13 #include <linux/kernel.h>
14 #include <linux/init.h>
15 #include <linux/device.h>
16 #include <sound/core.h>
17 #include <sound/pcm.h>
18 #include <sound/initval.h>
19 #include <sound/soc.h>
23 #define ADS117X_RATES (SNDRV_PCM_RATE_8000_48000)
25 #define ADS117X_FORMATS (SNDRV_PCM_FMTBIT_S16_LE)
27 struct snd_soc_dai ads117x_dai
= {
29 .name
= "ADS117X ADC",
32 .stream_name
= "Capture",
35 .rates
= ADS117X_RATES
,
36 .formats
= ADS117X_FORMATS
,},
38 EXPORT_SYMBOL_GPL(ads117x_dai
);
40 static int ads117x_probe(struct platform_device
*pdev
)
42 struct snd_soc_device
*socdev
= platform_get_drvdata(pdev
);
43 struct snd_soc_codec
*codec
;
46 codec
= kzalloc(sizeof(struct snd_soc_codec
), GFP_KERNEL
);
50 socdev
->card
->codec
= codec
;
51 mutex_init(&codec
->mutex
);
52 INIT_LIST_HEAD(&codec
->dapm_widgets
);
53 INIT_LIST_HEAD(&codec
->dapm_paths
);
54 codec
->name
= "ADS117X";
55 codec
->owner
= THIS_MODULE
;
56 codec
->dai
= &ads117x_dai
;
60 ret
= snd_soc_new_pcms(socdev
, SNDRV_DEFAULT_IDX1
, SNDRV_DEFAULT_STR1
);
62 printk(KERN_ERR
"ads117x: failed to create pcms\n");
70 static int ads117x_remove(struct platform_device
*pdev
)
72 struct snd_soc_device
*socdev
= platform_get_drvdata(pdev
);
73 struct snd_soc_codec
*codec
= socdev
->card
->codec
;
75 snd_soc_free_pcms(socdev
);
81 struct snd_soc_codec_device soc_codec_dev_ads117x
= {
82 .probe
= ads117x_probe
,
83 .remove
= ads117x_remove
,
85 EXPORT_SYMBOL_GPL(soc_codec_dev_ads117x
);
87 static __devinit
int ads117x_platform_probe(struct platform_device
*pdev
)
89 ads117x_dai
.dev
= &pdev
->dev
;
90 return snd_soc_register_dai(&ads117x_dai
);
93 static int __devexit
ads117x_platform_remove(struct platform_device
*pdev
)
95 snd_soc_unregister_dai(&ads117x_dai
);
99 static struct platform_driver ads117x_codec_driver
= {
102 .owner
= THIS_MODULE
,
105 .probe
= ads117x_platform_probe
,
106 .remove
= __devexit_p(ads117x_platform_remove
),
109 static int __init
ads117x_init(void)
111 return platform_driver_register(&ads117x_codec_driver
);
113 module_init(ads117x_init
);
115 static void __exit
ads117x_exit(void)
117 platform_driver_unregister(&ads117x_codec_driver
);
119 module_exit(ads117x_exit
);
121 MODULE_DESCRIPTION("ASoC ads117x driver");
122 MODULE_AUTHOR("Graeme Gregory");
123 MODULE_LICENSE("GPL");