summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sound/soc/omap/omap3h1.c44
1 files changed, 42 insertions, 2 deletions
diff --git a/sound/soc/omap/omap3h1.c b/sound/soc/omap/omap3h1.c
index 69d4b1abc06..f61949b295e 100644
--- a/sound/soc/omap/omap3h1.c
+++ b/sound/soc/omap/omap3h1.c
@@ -24,6 +24,8 @@
#define DEBUG
#include <linux/clk.h>
+#include <linux/gpio.h>
+#include <linux/of_gpio.h>
#include <linux/platform_device.h>
#include <linux/module.h>
#include <linux/of.h>
@@ -36,6 +38,10 @@
#include "omap-mcbsp.h"
+static struct clk *per_96m_fck;
+static unsigned long rate;
+static int mic_gpio_enable;
+
static int omap3h1_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params)
{
@@ -50,7 +56,7 @@ static int omap3h1_hw_params(struct snd_pcm_substream *substream,
// pr_info("ASoc OMAP3H1: setting system clock to: %d", freq);
ret = snd_soc_dai_set_sysclk(cpu_dai, OMAP_MCBSP_SYSCLK_CLKS_FCLK,
- 96000000, SND_SOC_CLOCK_OUT);
+ rate, SND_SOC_CLOCK_OUT);
if (ret < 0) {
printk(KERN_ERR "can't set DMIC cpu system clock\n");
return ret;
@@ -68,8 +74,22 @@ static int omap3h1_hw_params(struct snd_pcm_substream *substream,
return 0;
}
+static int omap3h1_startup(struct snd_pcm_substream *substream)
+{
+ gpio_set_value(mic_gpio_enable, 1);
+ return clk_enable(per_96m_fck);
+}
+
+static void omap3h1_shutdown(struct snd_pcm_substream *substream)
+{
+ gpio_set_value(mic_gpio_enable, 0);
+ clk_disable(per_96m_fck);
+}
+
static struct snd_soc_ops omap3h1_ops = {
.hw_params = omap3h1_hw_params,
+ .startup = omap3h1_startup,
+ .shutdown = omap3h1_shutdown,
};
//static const struct snd_soc_dapm_widget dmic_dapm_widgets[] = {
@@ -111,6 +131,7 @@ static int omap3h1_card_probe(struct platform_device *pdev)
struct device_node *node = pdev->dev.of_node;
struct snd_soc_card *card = &snd_soc_omap3h1;
int ret = 0;
+ int gpio;
#ifdef CONFIG_OF
if (node) {
@@ -128,6 +149,16 @@ static int omap3h1_card_probe(struct platform_device *pdev)
dev_err(&pdev->dev, "Missing node\n");
return -ENODEV;
}
+
+ gpio = of_get_named_gpio(node, "olio,mic_enable", 0);
+ ret = (gpio < 0) ? -ENODEV : gpio_request(gpio, "mic_enable");
+ if (ret) {
+ dev_err(&pdev->dev, "GPIO request error gpio=%d err=%d\n", gpio, ret);
+ return ret;
+ }
+ gpio_direction_output(gpio, 0);
+ mic_gpio_enable = gpio;
+
#endif
card->dev = &pdev->dev;
@@ -140,12 +171,21 @@ static int omap3h1_card_probe(struct platform_device *pdev)
return ret;
}
+ per_96m_fck = clk_get(&pdev->dev, "per_96m_fck");
+ if (IS_ERR(per_96m_fck)) {
+ dev_err(&pdev->dev, "could not get per_96m_fck clock\n");
+ return PTR_ERR(per_96m_fck);
+ }
+
+ rate = clk_get_rate(per_96m_fck);
+
return 0;
}
static int omap3h1_card_remove(struct platform_device *pdev)
{
struct snd_soc_card *card = platform_get_drvdata(pdev);
+ gpio_free(mic_gpio_enable);
snd_soc_unregister_card(card);
return 0;
@@ -196,7 +236,7 @@ static struct platform_driver omap3h1_driver = {
.driver = {
.name = "omap-soc-omap3h1",
.of_match_table = of_match_ptr(omap_soc_h1_of_match),
- .pm = &omap3h1_sound_pm_ops,
+ .pm = &snd_soc_pm_ops,
},
.probe = omap3h1_card_probe,
.remove = omap3h1_card_remove,