/* * zylonite.c -- SoC audio for Zylonite * * Copyright 2008 Wolfson Microelectronics PLC. * Author: Mark Brown * * 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 #include #include #include #include #include #include "../codecs/wm9713.h" #include "pxa2xx-ac97.h" #include "pxa-ssp.h" /* * There is a physical switch SW15 on the board which changes the MCLK * for the WM9713 between the standard AC97 master clock and the * output of the CLK_POUT signal from the PXA. */ static int clk_pout; module_param(clk_pout, int, 0); MODULE_PARM_DESC(clk_pout, "Use CLK_POUT as WM9713 MCLK (SW15 on board)."); static struct clk *pout; static struct snd_soc_card zylonite; static const struct snd_soc_dapm_widget zylonite_dapm_widgets[] = { SND_SOC_DAPM_HP("Headphone", NULL), SND_SOC_DAPM_MIC("Headset Microphone", NULL), SND_SOC_DAPM_MIC("Handset Microphone", NULL), SND_SOC_DAPM_SPK("Multiactor", NULL), SND_SOC_DAPM_SPK("Headset Earpiece", NULL), }; /* Currently supported audio map */ static const struct snd_soc_dapm_route audio_map[] = { /* Headphone output connected to HPL/HPR */ { "Headphone", NULL, "HPL" }, { "Headphone", NULL, "HPR" }, /* On-board earpiece */ { "Headset Earpiece", NULL, "OUT3" }, /* Headphone mic */ { "MIC2A", NULL, "Mic Bias" }, { "Mic Bias", NULL, "Headset Microphone" }, /* On-board mic */ { "MIC1", NULL, "Mic Bias" }, { "Mic Bias", NULL, "Handset Microphone" }, /* Multiactor differentially connected over SPKL/SPKR */ { "Multiactor", NULL, "SPKL" }, { "Multiactor", NULL, "SPKR" }, }; static int zylonite_wm9713_init(struct snd_soc_pcm_runtime *rtd) { if (clk_pout) snd_soc_dai_set_pll(rtd->codec_dai, 0, 0, clk_get_rate(pout), 0); return 0; } static int zylonite_voice_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *codec_dai = rtd->codec_dai; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; unsigned int pll_out = 0; unsigned int wm9713_div = 0; int ret = 0; int rate = params_rate(params); int width = snd_pcm_format_physical_width(params_format(params)); /* Only support ratios that we can generate neatly from the AC97 * based master clock - in particular, this excludes 44.1kHz. * In most applications the voice DAC will be used for telephony * data so multiples of 8kHz will be the common case. */ switch (rate) { case 8000: wm9713_div = 12; break; case 16000: wm9713_div = 6; break; case 48000: wm9713_div = 2; break; default: /* Don't support OSS emulation */ return -EINVAL; } /* Add 1 to the width for the leading clock cycle */ pll_out = rate * (width + 1) * 8; ret = snd_soc_dai_set_sysclk(cpu_dai, PXA_SSP_CLK_AUDIO, 0, 1); if (ret < 0) return ret; ret = snd_soc_dai_set_pll(cpu_dai, 0, 0, 0, pll_out); if (ret < 0) return ret; if (clk_pout) ret = snd_soc_dai_set_clkdiv(codec_dai, WM9713_PCMCLK_PLL_DIV, WM9713_PCMDIV(wm9713_div)); else ret = snd_soc_dai_set_clkdiv(codec_dai, WM9713_PCMCLK_DIV, WM9713_PCMDIV(wm9713_div)); if (ret < 0) return ret; return 0; } static struct snd_soc_ops zylonite_voice_ops = { .hw_params = zylonite_voice_hw_params, }; static struct snd_soc_dai_link zylonite_dai[] = { { .name = "AC97", .stream_name = "AC97 HiFi", .codec_name = "wm9713-codec", .platform_name = "pxa-pcm-audio", .cpu_dai_name = "pxa2xx-ac97", .codec_dai_name = "wm9713-hifi", .init = zylonite_wm9713_init, }, { .name = "AC97 Aux", .stream_name = "AC97 Aux", .codec_name = "wm9713-codec", .platform_name = "pxa-pcm-audio", .cpu_dai_name = "pxa2xx-ac97-aux", .codec_dai_name = "wm9713-aux", }, { .name = "WM9713 Voice", .stream_name = "WM9713 Voice", .codec_name = "wm9713-codec", .platform_name = "pxa-pcm-audio", .cpu_dai_name = "pxa-ssp-dai.2", .codec_dai_name = "wm9713-voice", .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS, .ops = &zylonite_voice_ops, }, }; static int zylonite_probe(struct snd_soc_card *card) { int ret; if (clk_pout) { pout = clk_get(NULL, "CLK_POUT"); if (IS_ERR(pout)) { dev_err(card->dev, "Unable to obtain CLK_POUT: %ld\n", PTR_ERR(pout)); return PTR_ERR(pout); } ret = clk_enable(pout); if (ret != 0) { dev_err(card->dev, "Unable to enable CLK_POUT: %d\n", ret); clk_put(pout); return ret; } dev_dbg(card->dev, "MCLK enabled at %luHz\n", clk_get_rate(pout)); } return 0; } static int zylonite_remove(struct snd_soc_card *card) { if (clk_pout) { clk_disable(pout); clk_put(pout); } return 0; } static int zylonite_suspend_post(struct snd_soc_card *card) { if (clk_pout) clk_disable(pout); return 0; } static int zylonite_resume_pre(struct snd_soc_card *card) { int ret = 0; if (clk_pout) { ret = clk_enable(pout); if (ret != 0) dev_err(card->dev, "Unable to enable CLK_POUT: %d\n", ret); } return ret; } static struct snd_soc_card zylonite = { .name = "Zylonite", .owner = THIS_MODULE, .probe = &zylonite_probe, .remove = &zylonite_remove, .suspend_post = &zylonite_suspend_post, .resume_pre = &zylonite_resume_pre, .dai_link = zylonite_dai, .num_links = ARRAY_SIZE(zylonite_dai), .dapm_widgets = zylonite_dapm_widgets, .num_dapm_widgets = ARRAY_SIZE(zylonite_dapm_widgets), .dapm_routes = audio_map, .num_dapm_routes = ARRAY_SIZE(audio_map), }; static struct platform_device *zylonite_snd_ac97_device; static int __init zylonite_init(void) { int ret; zylonite_snd_ac97_device = platform_device_alloc("soc-audio", -1); if (!zylonite_snd_ac97_device) return -ENOMEM; platform_set_drvdata(zylonite_snd_ac97_device, &zylonite); ret = platform_device_add(zylonite_snd_ac97_device); if (ret != 0) platform_device_put(zylonite_snd_ac97_device); return ret; } static void __exit zylonite_exit(void) { platform_device_unregister(zylonite_snd_ac97_device); } module_init(zylonite_init); module_exit(zylonite_exit); MODULE_AUTHOR("Mark Brown "); MODULE_DESCRIPTION("ALSA SoC WM9713 Zylonite"); MODULE_LICENSE("GPL"); y, then sockets should be freed only after one RCU grace period. Recent kernels could use sock_set_flag(sk, SOCK_RCU_FREE), but let's ease stable backports with the following fix instead. [1] BUG: unable to handle kernel NULL pointer dereference at (null) IP: [<ffffffff81495e25>] selinux_socket_sock_rcv_skb+0x65/0x2a0 Call Trace: <IRQ> [<ffffffff81485d8c>] security_sock_rcv_skb+0x4c/0x60 [<ffffffff81d55771>] sk_filter+0x41/0x210 [<ffffffff81d12913>] sock_queue_rcv_skb+0x53/0x3a0 [<ffffffff81f0a2b3>] raw_rcv+0x2a3/0x3c0 [<ffffffff81f06eab>] can_rcv_filter+0x12b/0x370 [<ffffffff81f07af9>] can_receive+0xd9/0x120 [<ffffffff81f07beb>] can_rcv+0xab/0x100 [<ffffffff81d362ac>] __netif_receive_skb_core+0xd8c/0x11f0 [<ffffffff81d36734>] __netif_receive_skb+0x24/0xb0 [<ffffffff81d37f67>] process_backlog+0x127/0x280 [<ffffffff81d36f7b>] net_rx_action+0x33b/0x4f0 [<ffffffff810c88d4>] __do_softirq+0x184/0x440 [<ffffffff81f9e86c>] do_softirq_own_stack+0x1c/0x30 <EOI> [<ffffffff810c76fb>] do_softirq.part.18+0x3b/0x40 [<ffffffff810c8bed>] do_softirq+0x1d/0x20 [<ffffffff81d30085>] netif_rx_ni+0xe5/0x110 [<ffffffff8199cc87>] slcan_receive_buf+0x507/0x520 [<ffffffff8167ef7c>] flush_to_ldisc+0x21c/0x230 [<ffffffff810e3baf>] process_one_work+0x24f/0x670 [<ffffffff810e44ed>] worker_thread+0x9d/0x6f0 [<ffffffff810e4450>] ? rescuer_thread+0x480/0x480 [<ffffffff810ebafc>] kthread+0x12c/0x150 [<ffffffff81f9ccef>] ret_from_fork+0x3f/0x70 Reported-by: Zhang Yanmin <yanmin.zhang@intel.com> Signed-off-by: Eric Dumazet <edumazet@google.com> Acked-by: Oliver Hartkopp <socketcan@hartkopp.net> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/usb/dwc2')