Skip to content

Commit

Permalink
ASoC: Add support for ESS9018
Browse files Browse the repository at this point in the history
It adds a dummy codec driver (no controls) for ESS9018
and a corresponding machine driver for BCM2708.

Signed-off-by: Florian Meier <[email protected]>
  • Loading branch information
koalo committed May 8, 2013
1 parent f6e9fde commit ca53c99
Show file tree
Hide file tree
Showing 7 changed files with 215 additions and 0 deletions.
12 changes: 12 additions & 0 deletions arch/arm/mach-bcm2708/bcm2708.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
8 changes: 8 additions & 0 deletions sound/soc/bcm2708/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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

3 changes: 3 additions & 0 deletions sound/soc/bcm2708/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

93 changes: 93 additions & 0 deletions sound/soc/bcm2708/rpi-ess9018.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/*
* ASoC driver for ESS9018 codec
* connected to a Raspberry Pi
*
* Author: Florian Meier, <[email protected]>
* 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 <linux/module.h>
#include <linux/platform_device.h>

#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/soc.h>
#include <sound/jack.h>

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");

4 changes: 4 additions & 0 deletions sound/soc/codecs/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions sound/soc/codecs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
93 changes: 93 additions & 0 deletions sound/soc/codecs/ess9018.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/*
* Driver for the ESS9018 codec
* It is a dummy driver without any controls.
*
* Copyright 2013 Florian Meier <[email protected]>
*
* 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 <linux/init.h>
#include <linux/module.h>
#include <linux/platform_device.h>

#include <sound/soc.h>

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 <[email protected]>");
MODULE_DESCRIPTION("ASoC ESS9018 codec driver");
MODULE_LICENSE("GPL");

0 comments on commit ca53c99

Please sign in to comment.