Skip to content

Commit

Permalink
Ported CTAG Face 2|4 drivers for BBB and BBAI
Browse files Browse the repository at this point in the history
  • Loading branch information
NiklasWan authored and RobertCNelson committed Mar 8, 2022
1 parent 9b75b93 commit 0c40a4f
Show file tree
Hide file tree
Showing 7 changed files with 415 additions and 10 deletions.
1 change: 1 addition & 0 deletions sound/soc/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ source "sound/soc/atmel/Kconfig"
source "sound/soc/au1x/Kconfig"
source "sound/soc/bcm/Kconfig"
source "sound/soc/cirrus/Kconfig"
source "sound/soc/ctag/Kconfig"
source "sound/soc/dwc/Kconfig"
source "sound/soc/fsl/Kconfig"
source "sound/soc/hisilicon/Kconfig"
Expand Down
1 change: 1 addition & 0 deletions sound/soc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ obj-$(CONFIG_SND_SOC) += atmel/
obj-$(CONFIG_SND_SOC) += au1x/
obj-$(CONFIG_SND_SOC) += bcm/
obj-$(CONFIG_SND_SOC) += cirrus/
obj-$(CONFIG_SND_SOC) += ctag/
obj-$(CONFIG_SND_SOC) += dwc/
obj-$(CONFIG_SND_SOC) += fsl/
obj-$(CONFIG_SND_SOC) += hisilicon/
Expand Down
50 changes: 41 additions & 9 deletions sound/soc/codecs/ad193x.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
#include <linux/device.h>
#include <linux/regmap.h>
#include <linux/slab.h>
#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/of_gpio.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
Expand All @@ -20,13 +23,6 @@

#include "ad193x.h"

/* codec private data */
struct ad193x_priv {
struct regmap *regmap;
enum ad193x_type type;
int sysclk;
};

/*
* AD193X volume/mute/de-emphasis etc. controls
*/
Expand Down Expand Up @@ -351,12 +347,29 @@ static struct snd_soc_dai_driver ad193x_dai = {
.ops = &ad193x_dai_ops,
};

static int ad193x_reset(struct snd_soc_component *component)
{
struct ad193x_priv *ad193x = snd_soc_component_get_drvdata(component);

if (gpio_is_valid(ad193x->reset_gpio)) {
gpio_direction_output(ad193x->reset_gpio, 0);
mdelay(1);
gpio_set_value(ad193x->reset_gpio, 1);
mdelay(1);
}

return 0;
}

static int ad193x_component_probe(struct snd_soc_component *component)
{
struct ad193x_priv *ad193x = snd_soc_component_get_drvdata(component);
struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
int num, ret;


/* Reset codec */
ad193x_reset(component);

/* default setting for ad193x */

/* unmute dac channels */
Expand Down Expand Up @@ -427,17 +440,36 @@ const struct regmap_config ad193x_regmap_config = {
};
EXPORT_SYMBOL_GPL(ad193x_regmap_config);


static const struct of_device_id ad193x_spi_dt_ids[] = {
{ .compatible = "analog,ad1938", },
{/*sentinel*/},
};
MODULE_DEVICE_TABLE(of, ad193x_spi_dt_ids);

int ad193x_probe(struct device *dev, struct regmap *regmap,
enum ad193x_type type)
{
struct ad193x_priv *ad193x;
int ret = 0;

if (IS_ERR(regmap))
return PTR_ERR(regmap);

ad193x = devm_kzalloc(dev, sizeof(*ad193x), GFP_KERNEL);
if (ad193x == NULL)
return -ENOMEM;

if (of_match_device(ad193x_spi_dt_ids, dev))
ad193x->reset_gpio = of_get_named_gpio(dev->of_node, "reset-gpio", 0);

if (gpio_is_valid(ad193x->reset_gpio)) {
ret = devm_gpio_request(dev, ad193x->reset_gpio,
"AD193x Reset");
if (ret < 0)
return ret;
}


ad193x->regmap = regmap;
ad193x->type = type;
Expand All @@ -451,4 +483,4 @@ EXPORT_SYMBOL_GPL(ad193x_probe);

MODULE_DESCRIPTION("ASoC ad193x driver");
MODULE_AUTHOR("Barry Song <[email protected]>");
MODULE_LICENSE("GPL");
MODULE_LICENSE("GPL");
10 changes: 9 additions & 1 deletion sound/soc/codecs/ad193x.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ enum ad193x_type {
AD1934,
};

/* codec private data */
struct ad193x_priv {
struct regmap *regmap;
enum ad193x_type type;
int sysclk;
int reset_gpio;
};

extern const struct regmap_config ad193x_regmap_config;
int ad193x_probe(struct device *dev, struct regmap *regmap,
enum ad193x_type type);
Expand Down Expand Up @@ -96,4 +104,4 @@ int ad193x_probe(struct device *dev, struct regmap *regmap,

#define AD193X_NUM_REGS 17

#endif
#endif
6 changes: 6 additions & 0 deletions sound/soc/ctag/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
config SND_DAVINCI_SOC_CTAG_FACE_2_4
tristate "SoC Audio Support for CTAG face-2-4 Audio Card (AD1938)"
depends on SND_SOC_DAVINCI_MCASP
select SND_SOC_AD193X_SPI
help
Say Y if you want to add support for CTAG face-2-4 Audio Card
4 changes: 4 additions & 0 deletions sound/soc/ctag/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# SPDX-License-Identifier: GPL-2.0
snd-soc-davinci-ctag-face-2-4-objs := davinci-ctag-face-2-4.o

obj-$(CONFIG_SND_DAVINCI_SOC_CTAG_FACE_2_4) += snd-soc-davinci-ctag-face-2-4.o
Loading

0 comments on commit 0c40a4f

Please sign in to comment.