12dcf9fb9SGraeme Gregory /* 22dcf9fb9SGraeme Gregory * ads117x.c -- Driver for ads1174/8 ADC chips 32dcf9fb9SGraeme Gregory * 42dcf9fb9SGraeme Gregory * Copyright 2009 ShotSpotter Inc. 52dcf9fb9SGraeme Gregory * Author: Graeme Gregory <gg@slimlogic.co.uk> 62dcf9fb9SGraeme Gregory * 72dcf9fb9SGraeme Gregory * This program is free software; you can redistribute it and/or modify it 82dcf9fb9SGraeme Gregory * under the terms of the GNU General Public License as published by the 92dcf9fb9SGraeme Gregory * Free Software Foundation; either version 2 of the License, or (at your 102dcf9fb9SGraeme Gregory * option) any later version. 112dcf9fb9SGraeme Gregory */ 122dcf9fb9SGraeme Gregory 132dcf9fb9SGraeme Gregory #include <linux/kernel.h> 145a0e3ad6STejun Heo #include <linux/slab.h> 152dcf9fb9SGraeme Gregory #include <linux/init.h> 162dcf9fb9SGraeme Gregory #include <linux/device.h> 17da155d5bSPaul Gortmaker #include <linux/module.h> 182dcf9fb9SGraeme Gregory #include <sound/core.h> 192dcf9fb9SGraeme Gregory #include <sound/pcm.h> 202dcf9fb9SGraeme Gregory #include <sound/initval.h> 212dcf9fb9SGraeme Gregory #include <sound/soc.h> 222dcf9fb9SGraeme Gregory 234f2bf0acSFlorian Vaussard #include <linux/of.h> 244f2bf0acSFlorian Vaussard 252dcf9fb9SGraeme Gregory #define ADS117X_RATES (SNDRV_PCM_RATE_8000_48000) 262dcf9fb9SGraeme Gregory #define ADS117X_FORMATS (SNDRV_PCM_FMTBIT_S16_LE) 272dcf9fb9SGraeme Gregory 2845a14a8bSMark Brown static const struct snd_soc_dapm_widget ads117x_dapm_widgets[] = { 2945a14a8bSMark Brown SND_SOC_DAPM_INPUT("Input1"), 3045a14a8bSMark Brown SND_SOC_DAPM_INPUT("Input2"), 3145a14a8bSMark Brown SND_SOC_DAPM_INPUT("Input3"), 3245a14a8bSMark Brown SND_SOC_DAPM_INPUT("Input4"), 3345a14a8bSMark Brown SND_SOC_DAPM_INPUT("Input5"), 3445a14a8bSMark Brown SND_SOC_DAPM_INPUT("Input6"), 3545a14a8bSMark Brown SND_SOC_DAPM_INPUT("Input7"), 3645a14a8bSMark Brown SND_SOC_DAPM_INPUT("Input8"), 3745a14a8bSMark Brown }; 3845a14a8bSMark Brown 3945a14a8bSMark Brown static const struct snd_soc_dapm_route ads117x_dapm_routes[] = { 4045a14a8bSMark Brown { "Capture", NULL, "Input1" }, 4145a14a8bSMark Brown { "Capture", NULL, "Input2" }, 4245a14a8bSMark Brown { "Capture", NULL, "Input3" }, 4345a14a8bSMark Brown { "Capture", NULL, "Input4" }, 4445a14a8bSMark Brown { "Capture", NULL, "Input5" }, 4545a14a8bSMark Brown { "Capture", NULL, "Input6" }, 4645a14a8bSMark Brown { "Capture", NULL, "Input7" }, 4745a14a8bSMark Brown { "Capture", NULL, "Input8" }, 4845a14a8bSMark Brown }; 4945a14a8bSMark Brown 50f0fba2adSLiam Girdwood static struct snd_soc_dai_driver ads117x_dai = { 512dcf9fb9SGraeme Gregory /* ADC */ 52f0fba2adSLiam Girdwood .name = "ads117x-hifi", 532dcf9fb9SGraeme Gregory .capture = { 542dcf9fb9SGraeme Gregory .stream_name = "Capture", 552dcf9fb9SGraeme Gregory .channels_min = 1, 562dcf9fb9SGraeme Gregory .channels_max = 32, 572dcf9fb9SGraeme Gregory .rates = ADS117X_RATES, 582dcf9fb9SGraeme Gregory .formats = ADS117X_FORMATS,}, 592dcf9fb9SGraeme Gregory }; 602dcf9fb9SGraeme Gregory 61*93101617SKuninori Morimoto static const struct snd_soc_component_driver soc_component_dev_ads117x = { 6245a14a8bSMark Brown .dapm_widgets = ads117x_dapm_widgets, 6345a14a8bSMark Brown .num_dapm_widgets = ARRAY_SIZE(ads117x_dapm_widgets), 6445a14a8bSMark Brown .dapm_routes = ads117x_dapm_routes, 6545a14a8bSMark Brown .num_dapm_routes = ARRAY_SIZE(ads117x_dapm_routes), 66*93101617SKuninori Morimoto .idle_bias_on = 1, 67*93101617SKuninori Morimoto .use_pmdown_time = 1, 68*93101617SKuninori Morimoto .endianness = 1, 69*93101617SKuninori Morimoto .non_legacy_dai_naming = 1, 7045a14a8bSMark Brown }; 71f0fba2adSLiam Girdwood 727a79e94eSBill Pemberton static int ads117x_probe(struct platform_device *pdev) 732dcf9fb9SGraeme Gregory { 74*93101617SKuninori Morimoto return devm_snd_soc_register_component(&pdev->dev, 75*93101617SKuninori Morimoto &soc_component_dev_ads117x, &ads117x_dai, 1); 76f3d0e82fSMark Brown } 77f3d0e82fSMark Brown 784f2bf0acSFlorian Vaussard #if defined(CONFIG_OF) 794f2bf0acSFlorian Vaussard static const struct of_device_id ads117x_dt_ids[] = { 804f2bf0acSFlorian Vaussard { .compatible = "ti,ads1174" }, 814f2bf0acSFlorian Vaussard { .compatible = "ti,ads1178" }, 824f2bf0acSFlorian Vaussard { }, 834f2bf0acSFlorian Vaussard }; 844f2bf0acSFlorian Vaussard MODULE_DEVICE_TABLE(of, ads117x_dt_ids); 854f2bf0acSFlorian Vaussard #endif 864f2bf0acSFlorian Vaussard 87f3d0e82fSMark Brown static struct platform_driver ads117x_codec_driver = { 88f3d0e82fSMark Brown .driver = { 89f0fba2adSLiam Girdwood .name = "ads117x-codec", 904f2bf0acSFlorian Vaussard .of_match_table = of_match_ptr(ads117x_dt_ids), 91f3d0e82fSMark Brown }, 92f3d0e82fSMark Brown 93f0fba2adSLiam Girdwood .probe = ads117x_probe, 94f3d0e82fSMark Brown }; 95f3d0e82fSMark Brown 965bbcc3c0SMark Brown module_platform_driver(ads117x_codec_driver); 972dcf9fb9SGraeme Gregory 982dcf9fb9SGraeme Gregory MODULE_DESCRIPTION("ASoC ads117x driver"); 992dcf9fb9SGraeme Gregory MODULE_AUTHOR("Graeme Gregory"); 1002dcf9fb9SGraeme Gregory MODULE_LICENSE("GPL"); 101