blob: 506d474c4d2227372b6b8e4a6743ca8f67ef7da3 [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>
Paul Gortmakerda155d52011-07-15 12:38:28 -040017#include <linux/module.h>
Graeme Gregory2dcf9fb2009-11-04 17:49:22 +000018#include <sound/core.h>
19#include <sound/pcm.h>
20#include <sound/initval.h>
21#include <sound/soc.h>
22
Graeme Gregory2dcf9fb2009-11-04 17:49:22 +000023#define ADS117X_RATES (SNDRV_PCM_RATE_8000_48000)
Graeme Gregory2dcf9fb2009-11-04 17:49:22 +000024#define ADS117X_FORMATS (SNDRV_PCM_FMTBIT_S16_LE)
25
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000026static struct snd_soc_dai_driver ads117x_dai = {
Graeme Gregory2dcf9fb2009-11-04 17:49:22 +000027/* ADC */
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000028 .name = "ads117x-hifi",
Graeme Gregory2dcf9fb2009-11-04 17:49:22 +000029 .capture = {
30 .stream_name = "Capture",
31 .channels_min = 1,
32 .channels_max = 32,
33 .rates = ADS117X_RATES,
34 .formats = ADS117X_FORMATS,},
35};
Graeme Gregory2dcf9fb2009-11-04 17:49:22 +000036
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000037static struct snd_soc_codec_driver soc_codec_dev_ads117x;
38
Bill Pemberton7a79e942012-12-07 09:26:37 -050039static int ads117x_probe(struct platform_device *pdev)
Graeme Gregory2dcf9fb2009-11-04 17:49:22 +000040{
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000041 return snd_soc_register_codec(&pdev->dev,
42 &soc_codec_dev_ads117x, &ads117x_dai, 1);
Graeme Gregory2dcf9fb2009-11-04 17:49:22 +000043}
44
Bill Pemberton7a79e942012-12-07 09:26:37 -050045static int ads117x_remove(struct platform_device *pdev)
Graeme Gregory2dcf9fb2009-11-04 17:49:22 +000046{
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000047 snd_soc_unregister_codec(&pdev->dev);
Mark Brownf3d0e822009-11-04 21:43:27 +000048 return 0;
49}
50
51static struct platform_driver ads117x_codec_driver = {
52 .driver = {
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000053 .name = "ads117x-codec",
Mark Brownf3d0e822009-11-04 21:43:27 +000054 .owner = THIS_MODULE,
55 },
56
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000057 .probe = ads117x_probe,
Bill Pemberton7a79e942012-12-07 09:26:37 -050058 .remove = ads117x_remove,
Mark Brownf3d0e822009-11-04 21:43:27 +000059};
60
Mark Brown5bbcc3c2011-11-23 22:52:08 +000061module_platform_driver(ads117x_codec_driver);
Graeme Gregory2dcf9fb2009-11-04 17:49:22 +000062
63MODULE_DESCRIPTION("ASoC ads117x driver");
64MODULE_AUTHOR("Graeme Gregory");
65MODULE_LICENSE("GPL");