diff --git a/arch/arm/mach-bcm2708/bcm2708.c b/arch/arm/mach-bcm2708/bcm2708.c index aaffe8df4195ce..a10abb0dd3f158 100644 --- a/arch/arm/mach-bcm2708/bcm2708.c +++ b/arch/arm/mach-bcm2708/bcm2708.c @@ -704,6 +704,14 @@ static struct platform_device snd_rpi_proto_device = { }; #endif +#ifdef CONFIG_SND_BCM2708_SOC_RPI_CODEC_ESS9018_MODULE +static struct platform_device snd_rpi_ess9018_device = { + .name = "snd-rpi-ess9018", + .id = 0, + .num_resources = 0, +}; +#endif + int __init bcm_register_device(struct platform_device *pdev) { int ret; @@ -814,6 +822,10 @@ void __init bcm2708_init(void) bcm_register_device(&snd_rpi_proto_device); #endif +#ifdef CONFIG_SND_BCM2708_SOC_RPI_CODEC_ESS9018_MODULE + bcm_register_device(&snd_rpi_ess9018_device); +#endif + for (i = 0; i < ARRAY_SIZE(amba_devs); i++) { struct amba_device *d = amba_devs[i]; amba_device_register(d, &iomem_resource); diff --git a/sound/soc/bcm2708/Kconfig b/sound/soc/bcm2708/Kconfig index e490bc35b826c2..d806650f4a11c4 100644 --- a/sound/soc/bcm2708/Kconfig +++ b/sound/soc/bcm2708/Kconfig @@ -36,3 +36,11 @@ config SND_BCM2708_SOC_RPI_CODEC_PROTO help Say Y if you want to add support for Audio Codec Board - PROTO (WM8731) +config SND_BCM2708_SOC_RPI_CODEC_ESS9018 + tristate "Support for ESS9018" + depends on SND_BCM2708_SOC + select SND_BCM2708_SOC_I2S + select SND_SOC_ESS9018 + help + Say Y if you want to add support for ESS9018 + diff --git a/sound/soc/bcm2708/Makefile b/sound/soc/bcm2708/Makefile index 14e5dd73209262..ff6e727caaa5ae 100644 --- a/sound/soc/bcm2708/Makefile +++ b/sound/soc/bcm2708/Makefile @@ -4,6 +4,7 @@ snd-soc-bcm2708-i2s-objs := bcm2708-i2s.o snd-soc-rpi-mbed-objs := rpi-mbed.o snd-soc-rpi-tda1541a-objs := rpi-tda1541a.o snd-soc-rpi-proto-objs := rpi-proto.o +snd-soc-rpi-ess9018-objs := rpi-ess9018.o obj-$(CONFIG_SND_BCM2708_SOC) += snd-soc-bcm2708.o obj-$(CONFIG_SND_BCM2708_SOC_I2S) += snd-soc-bcm2708-i2s.o @@ -12,3 +13,5 @@ obj-$(CONFIG_SND_BCM2708_SOC_I2S) += snd-soc-bcm2708-i2s.o obj-$(CONFIG_SND_BCM2708_SOC_RPI_CODEC_MBED) += snd-soc-rpi-mbed.o obj-$(CONFIG_SND_BCM2708_SOC_RPI_CODEC_TDA1541A) += snd-soc-rpi-tda1541a.o obj-$(CONFIG_SND_BCM2708_SOC_RPI_CODEC_PROTO) += snd-soc-rpi-proto.o +obj-$(CONFIG_SND_BCM2708_SOC_RPI_CODEC_ESS9018) += snd-soc-rpi-ess9018.o + diff --git a/sound/soc/bcm2708/rpi-ess9018.c b/sound/soc/bcm2708/rpi-ess9018.c new file mode 100644 index 00000000000000..57c58c2110057e --- /dev/null +++ b/sound/soc/bcm2708/rpi-ess9018.c @@ -0,0 +1,93 @@ +/* + * ASoC driver for ESS9018 codec + * connected to a Raspberry Pi + * + * Author: Florian Meier, + * Copyright 2013 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include +#include + +#include +#include +#include +#include + +static int snd_rpi_ess9018_init(struct snd_soc_pcm_runtime *rtd) +{ + return 0; +} + +static int snd_rpi_ess9018_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) +{ + return 0; +} + +/* machine stream operations */ +static struct snd_soc_ops snd_rpi_ess9018_ops = { + .hw_params = snd_rpi_ess9018_hw_params, +}; + +static struct snd_soc_dai_link snd_rpi_ess9018_dai[] = { +{ + .name = "ESS9018", + .stream_name = "ESS9018 HiFi", + .cpu_dai_name = "bcm2708-i2s.0", + .codec_dai_name = "ess9018-hifi", + .platform_name = "bcm2708-pcm-audio.0", + .codec_name = "ess9018-codec", + .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_CBS_CFS, + .ops = &snd_rpi_ess9018_ops, + .init = snd_rpi_ess9018_init, +}, +}; + +/* audio machine driver */ +static struct snd_soc_card snd_rpi_ess9018 = { + .name = "snd_rpi_ess9018", + .dai_link = snd_rpi_ess9018_dai, + .num_links = ARRAY_SIZE(snd_rpi_ess9018_dai), +}; + +static int snd_rpi_ess9018_probe(struct platform_device *pdev) +{ + int ret = 0; + + snd_rpi_ess9018.dev = &pdev->dev; + ret = snd_soc_register_card(&snd_rpi_ess9018); + if (ret) + { + dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", ret); + } + + return ret; +} + + +static int snd_rpi_ess9018_remove(struct platform_device *pdev) +{ + return snd_soc_unregister_card(&snd_rpi_ess9018); +} + +static struct platform_driver snd_rpi_ess9018_driver = { + .driver = { + .name = "snd-rpi-ess9018", + .owner = THIS_MODULE, + }, + .probe = snd_rpi_ess9018_probe, + .remove = snd_rpi_ess9018_remove, +}; + +module_platform_driver(snd_rpi_ess9018_driver); + +MODULE_AUTHOR("Florian Meier"); +MODULE_DESCRIPTION("ASoC Driver for Raspberry Pi connected to a ESS9018"); +MODULE_LICENSE("GPL"); + diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index 3bf6973fb00510..2be53bfb384dd1 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -39,6 +39,7 @@ config SND_SOC_ALL_CODECS select SND_SOC_DA732X if I2C select SND_SOC_DA9055 if I2C select SND_SOC_DFBMCS320 + select SND_SOC_ESS9018 select SND_SOC_ISABELLE if I2C select SND_SOC_JZ4740_CODEC select SND_SOC_LM4857 if I2C @@ -238,6 +239,9 @@ config SND_SOC_CS4271 config SND_SOC_CX20442 tristate +config SND_SOC_ESS9018 + tristate + config SND_SOC_JZ4740_CODEC select REGMAP_MMIO tristate diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index 9af906564958be..9d2f300895f345 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile @@ -27,6 +27,7 @@ snd-soc-da732x-objs := da732x.o snd-soc-da9055-objs := da9055.o snd-soc-dfbmcs320-objs := dfbmcs320.o snd-soc-dmic-objs := dmic.o +snd-soc-ess9018-objs := ess9018.o snd-soc-isabelle-objs := isabelle.o snd-soc-jz4740-codec-objs := jz4740.o snd-soc-l3-objs := l3.o @@ -152,6 +153,7 @@ obj-$(CONFIG_SND_SOC_DA732X) += snd-soc-da732x.o obj-$(CONFIG_SND_SOC_DA9055) += snd-soc-da9055.o obj-$(CONFIG_SND_SOC_DFBMCS320) += snd-soc-dfbmcs320.o obj-$(CONFIG_SND_SOC_DMIC) += snd-soc-dmic.o +obj-$(CONFIG_SND_SOC_ESS9018) += snd-soc-ess9018.o obj-$(CONFIG_SND_SOC_ISABELLE) += snd-soc-isabelle.o obj-$(CONFIG_SND_SOC_JZ4740_CODEC) += snd-soc-jz4740-codec.o obj-$(CONFIG_SND_SOC_L3) += snd-soc-l3.o diff --git a/sound/soc/codecs/ess9018.c b/sound/soc/codecs/ess9018.c new file mode 100644 index 00000000000000..d2c731af0c62c6 --- /dev/null +++ b/sound/soc/codecs/ess9018.c @@ -0,0 +1,93 @@ +/* + * Driver for the ESS9018 codec + * It is a dummy driver without any controls. + * + * Copyright 2013 Florian Meier + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + */ + +#include +#include +#include + +#include + +static struct snd_soc_dai_driver ess9018_dai = { + .name = "ess9018-hifi", + .playback = { + .channels_min = 1, + .channels_max = 8, + .rates = SNDRV_PCM_RATE_8000_192000, + .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE + }, +}; + +static struct snd_soc_codec_driver soc_codec_dev_ess9018; + +static int ess9018_probe(struct platform_device *pdev) +{ + return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_ess9018, + &ess9018_dai, 1); +} + +static int ess9018_remove(struct platform_device *pdev) +{ + snd_soc_unregister_codec(&pdev->dev); + + return 0; +} + +static struct platform_driver ess9018_driver = { + .driver = { + .name = "ess9018-codec", + .owner = THIS_MODULE, + }, + .probe = ess9018_probe, + .remove = ess9018_remove, +}; + +/* + * Register driver and device + * + * TODO This is not the best solution, but it is ok for now. + * Later this should be handled by the device tree. + */ + +static struct platform_device *pdev; + +static const struct platform_device_info ess9018_dev_info = { + .name = "ess9018-codec", + .id = -1, +}; + +static int ess9018_init(void) +{ + int rc = platform_driver_register(&ess9018_driver); + + if (rc == 0) { + pdev = platform_device_register_full(&ess9018_dev_info); + if (IS_ERR(pdev)) { + platform_driver_unregister(&ess9018_driver); + rc = PTR_ERR(pdev); + } + } + return rc; +} +subsys_initcall(ess9018_init); + +static void __exit ess9018_exit(void) +{ + platform_device_unregister(pdev); + platform_driver_unregister(&ess9018_driver); +} +module_exit(ess9018_exit); + +MODULE_AUTHOR("Florian Meier "); +MODULE_DESCRIPTION("ASoC ESS9018 codec driver"); +MODULE_LICENSE("GPL"); +