forked from Minki/linux
47cf84e17e
The commit1abe729
(ASoC: fsl: Add missing pm to current machine drivers) enables pm support for a few IMX machine drivers. But it does not update dev drvdata to be the pointer to 'card'. This causes the kernel dump below in system suspend, because snd_soc_suspend() expects that the dev drvdata points to 'card', while it still points to the private data of machine driver. This patch fixes imx-sgtl5000 and imx-wm8962 by attaching 'card' to dev drvdata and private data to card drvdata. For imx-mc13783, I simply revert the pm change because it must be broken for the same reason and I don't have hardware to test pm enabling code. $ echo mem > /sys/power/state PM: Syncing filesystems ... done. PM: Preparing system for mem sleep mmc1: card e624 removed Freezing user space processes ... (elapsed 0.002 seconds) done. Freezing remaining freezable tasks ... (elapsed 0.002 seconds) done. PM: Entering mem sleep INFO: trying to register non-static key. the code is fine but needs lockdep annotation. turning off the locking correctness validator. CPU: 0 PID: 1861 Comm: bash Not tainted 3.14.0-rc1+ #1648 Backtrace: [<80012144>] (dump_backtrace) from [<800122e4>] (show_stack+0x18/0x1c) r6:8079c77c r5:00000c5a r4:00000000 r3:00000000 [<800122cc>] (show_stack) from [<80637ac0>] (dump_stack+0x78/0x94) [<80637a48>] (dump_stack) from [<80028918>] (warn_slowpath_common+0x6c/0x8c) r4:bdb21c38 r3:be62df00 [<800288ac>] (warn_slowpath_common) from [<800289dc>] (warn_slowpath_fmt+0x38/0x40) r8:be62e3a8 r7:bf122960 r6:00000005 r5:00000000 r4:00000000 [<800289a8>] (warn_slowpath_fmt) from [<8006518c>] (__lock_acquire+0x1ae0/0x1ce0) r3:8079d598 r2:80799e70 [<800636ac>] (__lock_acquire) from [<80065894>] (lock_acquire+0x68/0x7c) r10:bdb20000 r9:be62df00 r8:00000000 r7:00000000 r6:60000013 r5:bdb20000 r4:00000000 [<8006582c>] (lock_acquire) from [<8063c938>] (mutex_lock_nested+0x5c/0x3b8) r7:00000000 r6:80dfc78c r5:804be444 r4:bf122928 [<8063c8dc>] (mutex_lock_nested) from [<804be444>] (snd_soc_suspend+0x34/0x42c) r10:00000000 r9:00000000 r8:00000000 r7:bf1c4444 r6:bf1c4410 r5:be978150 r4:be978010 [<804be410>] (snd_soc_suspend) from [<8034392c>] (platform_pm_suspend+0x34/0x64) r10:00000000 r8:00000000 r7:bf1c4444 r6:bf1c4410 r5:803438f8 r4:bf1c4410 [<803438f8>] (platform_pm_suspend) from [<80348e18>] (dpm_run_callback.isra.7+0x34/0x6c) [<80348de4>] (dpm_run_callback.isra.7) from [<80349354>] (__device_suspend+0x10c/0x220) r9:808dd974 r8:808c4a5c r6:00000002 r5:80e5001c r4:bf1c4410 [<80349248>] (__device_suspend) from [<8034a338>] (dpm_suspend+0x60/0x220) r7:bf1c4410 r6:808dd90c r5:80e5001c r4:bf1c44c0 [<8034a2d8>] (dpm_suspend) from [<8034a790>] (dpm_suspend_start+0x60/0x68) r10:8079a818 r9:00000000 r8:00000004 r7:80dfbe90 r6:80641eec r5:00000000 r4:00000002 [<8034a730>] (dpm_suspend_start) from [<8006a788>] (suspend_devices_and_enter+0x74/0x318) r4:00000003 r3:80dfbe98 [<8006a714>] (suspend_devices_and_enter) from [<8006abd8>] (pm_suspend+0x1ac/0x244) r10:8079a818 r8:00000004 r7:00000003 r6:80641eec r5:00000000 r4:00000003 [<8006aa2c>] (pm_suspend) from [<80069a4c>] (state_store+0x70/0xc0) r5:00000003 r4:bd85ea40 [<800699dc>] (state_store) from [<80294034>] (kobj_attr_store+0x1c/0x28) r10:beb9fe08 r8:00000000 r7:bdb21f78 r6:bd85ea40 r5:00000004 r4:beb9fe00 [<80294018>] (kobj_attr_store) from [<80140f90>] (sysfs_kf_write+0x54/0x58) [<80140f3c>] (sysfs_kf_write) from [<8014474c>] (kernfs_fop_write+0xc4/0x160) r6:bd85ea40 r5:beb9fe00 r4:00000004 r3:80140f3c [<80144688>] (kernfs_fop_write) from [<800dfa14>] (vfs_write+0xbc/0x184) r10:00000000 r9:00000000 r8:00000000 r7:bdb21f78 r6:00500c08 r5:00000004 r4:be782600 [<800df958>] (vfs_write) from [<800dfe00>] (SyS_write+0x48/0x70) r10:00000000 r8:00000000 r7:00000004 r6:00500c08 r5:00000000 r4:be782600 [<800dfdb8>] (SyS_write) from [<8000e800>] (ret_fast_syscall+0x0/0x48) r9:bdb20000 r8:8000e9c4 r7:00000004 r6:00500c08 r5:00000004 r4:76eb65e0 Fixes:1abe729
(ASoC: fsl: Add missing pm to current machine drivers) Cc: stable@vger.kernel.org Signed-off-by: Shawn Guo <shawn.guo@linaro.org> Signed-off-by: Mark Brown <broonie@linaro.org>
175 lines
4.8 KiB
C
175 lines
4.8 KiB
C
/*
|
|
* imx-mc13783.c -- SoC audio for imx based boards with mc13783 codec
|
|
*
|
|
* Copyright 2012 Philippe Retornaz, <philippe.retornaz@epfl.ch>
|
|
*
|
|
* Heavly based on phycore-mc13783:
|
|
* Copyright 2009 Sascha Hauer, Pengutronix <s.hauer@pengutronix.de>
|
|
*
|
|
* 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/module.h>
|
|
#include <linux/moduleparam.h>
|
|
#include <linux/device.h>
|
|
#include <sound/core.h>
|
|
#include <sound/pcm.h>
|
|
#include <sound/soc.h>
|
|
#include <sound/soc-dapm.h>
|
|
#include <asm/mach-types.h>
|
|
|
|
#include "../codecs/mc13783.h"
|
|
#include "imx-ssi.h"
|
|
#include "imx-audmux.h"
|
|
|
|
#define FMT_SSI (SND_SOC_DAIFMT_DSP_A | SND_SOC_DAIFMT_NB_NF | \
|
|
SND_SOC_DAIFMT_CBM_CFM)
|
|
|
|
static int imx_mc13783_hifi_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 *cpu_dai = rtd->cpu_dai;
|
|
struct snd_soc_dai *codec_dai = rtd->codec_dai;
|
|
int ret;
|
|
|
|
ret = snd_soc_dai_set_tdm_slot(codec_dai, 0xfffffffc, 0xfffffffc,
|
|
4, 16);
|
|
if (ret)
|
|
return ret;
|
|
|
|
ret = snd_soc_dai_set_sysclk(codec_dai, MC13783_CLK_CLIA, 26000000, 0);
|
|
if (ret)
|
|
return ret;
|
|
|
|
ret = snd_soc_dai_set_tdm_slot(cpu_dai, 0x0, 0xfffffffc, 2, 16);
|
|
if (ret)
|
|
return ret;
|
|
|
|
return 0;
|
|
}
|
|
|
|
static struct snd_soc_ops imx_mc13783_hifi_ops = {
|
|
.hw_params = imx_mc13783_hifi_hw_params,
|
|
};
|
|
|
|
static struct snd_soc_dai_link imx_mc13783_dai_mc13783[] = {
|
|
{
|
|
.name = "MC13783",
|
|
.stream_name = "Sound",
|
|
.codec_dai_name = "mc13783-hifi",
|
|
.codec_name = "mc13783-codec",
|
|
.cpu_dai_name = "imx-ssi.0",
|
|
.platform_name = "imx-ssi.0",
|
|
.ops = &imx_mc13783_hifi_ops,
|
|
.symmetric_rates = 1,
|
|
.dai_fmt = FMT_SSI,
|
|
},
|
|
};
|
|
|
|
static const struct snd_soc_dapm_widget imx_mc13783_widget[] = {
|
|
SND_SOC_DAPM_MIC("Mic", NULL),
|
|
SND_SOC_DAPM_HP("Headphone", NULL),
|
|
SND_SOC_DAPM_SPK("Speaker", NULL),
|
|
};
|
|
|
|
static const struct snd_soc_dapm_route imx_mc13783_routes[] = {
|
|
{"Speaker", NULL, "LSP"},
|
|
{"Headphone", NULL, "HSL"},
|
|
{"Headphone", NULL, "HSR"},
|
|
|
|
{"MC1LIN", NULL, "MC1 Bias"},
|
|
{"MC2IN", NULL, "MC2 Bias"},
|
|
{"MC1 Bias", NULL, "Mic"},
|
|
{"MC2 Bias", NULL, "Mic"},
|
|
};
|
|
|
|
static struct snd_soc_card imx_mc13783 = {
|
|
.name = "imx_mc13783",
|
|
.owner = THIS_MODULE,
|
|
.dai_link = imx_mc13783_dai_mc13783,
|
|
.num_links = ARRAY_SIZE(imx_mc13783_dai_mc13783),
|
|
.dapm_widgets = imx_mc13783_widget,
|
|
.num_dapm_widgets = ARRAY_SIZE(imx_mc13783_widget),
|
|
.dapm_routes = imx_mc13783_routes,
|
|
.num_dapm_routes = ARRAY_SIZE(imx_mc13783_routes),
|
|
};
|
|
|
|
static int imx_mc13783_probe(struct platform_device *pdev)
|
|
{
|
|
int ret;
|
|
|
|
imx_mc13783.dev = &pdev->dev;
|
|
|
|
ret = snd_soc_register_card(&imx_mc13783);
|
|
if (ret) {
|
|
dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n",
|
|
ret);
|
|
return ret;
|
|
}
|
|
|
|
if (machine_is_mx31_3ds() || machine_is_mx31moboard()) {
|
|
imx_audmux_v2_configure_port(MX31_AUDMUX_PORT4_SSI_PINS_4,
|
|
IMX_AUDMUX_V2_PTCR_SYN,
|
|
IMX_AUDMUX_V2_PDCR_RXDSEL(MX31_AUDMUX_PORT1_SSI0) |
|
|
IMX_AUDMUX_V2_PDCR_MODE(1) |
|
|
IMX_AUDMUX_V2_PDCR_INMMASK(0xfc));
|
|
imx_audmux_v2_configure_port(MX31_AUDMUX_PORT1_SSI0,
|
|
IMX_AUDMUX_V2_PTCR_SYN |
|
|
IMX_AUDMUX_V2_PTCR_TFSDIR |
|
|
IMX_AUDMUX_V2_PTCR_TFSEL(MX31_AUDMUX_PORT4_SSI_PINS_4) |
|
|
IMX_AUDMUX_V2_PTCR_TCLKDIR |
|
|
IMX_AUDMUX_V2_PTCR_TCSEL(MX31_AUDMUX_PORT4_SSI_PINS_4) |
|
|
IMX_AUDMUX_V2_PTCR_RFSDIR |
|
|
IMX_AUDMUX_V2_PTCR_RFSEL(MX31_AUDMUX_PORT4_SSI_PINS_4) |
|
|
IMX_AUDMUX_V2_PTCR_RCLKDIR |
|
|
IMX_AUDMUX_V2_PTCR_RCSEL(MX31_AUDMUX_PORT4_SSI_PINS_4),
|
|
IMX_AUDMUX_V2_PDCR_RXDSEL(MX31_AUDMUX_PORT4_SSI_PINS_4));
|
|
} else if (machine_is_mx27_3ds()) {
|
|
imx_audmux_v1_configure_port(MX27_AUDMUX_HPCR1_SSI0,
|
|
IMX_AUDMUX_V1_PCR_SYN |
|
|
IMX_AUDMUX_V1_PCR_TFSDIR |
|
|
IMX_AUDMUX_V1_PCR_TCLKDIR |
|
|
IMX_AUDMUX_V1_PCR_RFSDIR |
|
|
IMX_AUDMUX_V1_PCR_RCLKDIR |
|
|
IMX_AUDMUX_V1_PCR_TFCSEL(MX27_AUDMUX_HPCR3_SSI_PINS_4) |
|
|
IMX_AUDMUX_V1_PCR_RFCSEL(MX27_AUDMUX_HPCR3_SSI_PINS_4) |
|
|
IMX_AUDMUX_V1_PCR_RXDSEL(MX27_AUDMUX_HPCR3_SSI_PINS_4)
|
|
);
|
|
imx_audmux_v1_configure_port(MX27_AUDMUX_HPCR3_SSI_PINS_4,
|
|
IMX_AUDMUX_V1_PCR_SYN |
|
|
IMX_AUDMUX_V1_PCR_RXDSEL(MX27_AUDMUX_HPCR1_SSI0)
|
|
);
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
static int imx_mc13783_remove(struct platform_device *pdev)
|
|
{
|
|
snd_soc_unregister_card(&imx_mc13783);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static struct platform_driver imx_mc13783_audio_driver = {
|
|
.driver = {
|
|
.name = "imx_mc13783",
|
|
.owner = THIS_MODULE,
|
|
},
|
|
.probe = imx_mc13783_probe,
|
|
.remove = imx_mc13783_remove
|
|
};
|
|
|
|
module_platform_driver(imx_mc13783_audio_driver);
|
|
|
|
MODULE_AUTHOR("Sascha Hauer <s.hauer@pengutronix.de>");
|
|
MODULE_AUTHOR("Philippe Retornaz <philippe.retornaz@epfl.ch");
|
|
MODULE_DESCRIPTION("imx with mc13783 codec ALSA SoC driver");
|
|
MODULE_LICENSE("GPL");
|
|
MODULE_ALIAS("platform:imx_mc13783");
|