mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-23 09:19:51 +00:00
ASoC: smdk_wm8994: Configure the MCLK1 rate based on the board
Make the code more generally applicable by refactoring so that the MCLK1 rate can be selected based on the compatible string provided by the device tree, allowing use on other boards which have different rates or use other information sources. Signed-off-by: Mark Brown <broonie@linaro.org>
This commit is contained in:
parent
f6ecf50b5e
commit
d30c148bb1
1 changed files with 29 additions and 8 deletions
|
@ -11,6 +11,7 @@
|
||||||
#include <sound/pcm_params.h>
|
#include <sound/pcm_params.h>
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/of.h>
|
#include <linux/of.h>
|
||||||
|
#include <linux/of_device.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Default CFG switch settings to use this driver:
|
* Default CFG switch settings to use this driver:
|
||||||
|
@ -37,6 +38,15 @@
|
||||||
/* SMDK has a 16.934MHZ crystal attached to WM8994 */
|
/* SMDK has a 16.934MHZ crystal attached to WM8994 */
|
||||||
#define SMDK_WM8994_FREQ 16934000
|
#define SMDK_WM8994_FREQ 16934000
|
||||||
|
|
||||||
|
struct smdk_wm8994_data {
|
||||||
|
int mclk1_rate;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Default SMDKs */
|
||||||
|
static struct smdk_wm8994_data smdk_board_data = {
|
||||||
|
.mclk1_rate = SMDK_WM8994_FREQ,
|
||||||
|
};
|
||||||
|
|
||||||
static int smdk_hw_params(struct snd_pcm_substream *substream,
|
static int smdk_hw_params(struct snd_pcm_substream *substream,
|
||||||
struct snd_pcm_hw_params *params)
|
struct snd_pcm_hw_params *params)
|
||||||
{
|
{
|
||||||
|
@ -141,15 +151,28 @@ static struct snd_soc_card smdk = {
|
||||||
.num_links = ARRAY_SIZE(smdk_dai),
|
.num_links = ARRAY_SIZE(smdk_dai),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef CONFIG_OF
|
||||||
|
static const struct of_device_id samsung_wm8994_of_match[] = {
|
||||||
|
{ .compatible = "samsung,smdk-wm8994", .data = &smdk_board_data },
|
||||||
|
{},
|
||||||
|
};
|
||||||
|
MODULE_DEVICE_TABLE(of, samsung_wm8994_of_match);
|
||||||
|
#endif /* CONFIG_OF */
|
||||||
|
|
||||||
static int smdk_audio_probe(struct platform_device *pdev)
|
static int smdk_audio_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
struct device_node *np = pdev->dev.of_node;
|
struct device_node *np = pdev->dev.of_node;
|
||||||
struct snd_soc_card *card = &smdk;
|
struct snd_soc_card *card = &smdk;
|
||||||
|
struct smdk_wm8994_data *board;
|
||||||
|
const struct of_device_id *id;
|
||||||
|
|
||||||
card->dev = &pdev->dev;
|
card->dev = &pdev->dev;
|
||||||
|
|
||||||
|
board = devm_kzalloc(&pdev->dev, sizeof(*board), GFP_KERNEL);
|
||||||
|
if (!board)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
if (np) {
|
if (np) {
|
||||||
smdk_dai[0].cpu_dai_name = NULL;
|
smdk_dai[0].cpu_dai_name = NULL;
|
||||||
smdk_dai[0].cpu_of_node = of_parse_phandle(np,
|
smdk_dai[0].cpu_of_node = of_parse_phandle(np,
|
||||||
|
@ -164,6 +187,12 @@ static int smdk_audio_probe(struct platform_device *pdev)
|
||||||
smdk_dai[0].platform_of_node = smdk_dai[0].cpu_of_node;
|
smdk_dai[0].platform_of_node = smdk_dai[0].cpu_of_node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
id = of_match_device(samsung_wm8994_of_match, &pdev->dev);
|
||||||
|
if (id)
|
||||||
|
*board = *((struct smdk_wm8994_data *)id->data);
|
||||||
|
|
||||||
|
platform_set_drvdata(pdev, board);
|
||||||
|
|
||||||
ret = snd_soc_register_card(card);
|
ret = snd_soc_register_card(card);
|
||||||
|
|
||||||
if (ret)
|
if (ret)
|
||||||
|
@ -181,14 +210,6 @@ static int smdk_audio_remove(struct platform_device *pdev)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_OF
|
|
||||||
static const struct of_device_id samsung_wm8994_of_match[] = {
|
|
||||||
{ .compatible = "samsung,smdk-wm8994", },
|
|
||||||
{},
|
|
||||||
};
|
|
||||||
MODULE_DEVICE_TABLE(of, samsung_wm8994_of_match);
|
|
||||||
#endif /* CONFIG_OF */
|
|
||||||
|
|
||||||
static struct platform_driver smdk_audio_driver = {
|
static struct platform_driver smdk_audio_driver = {
|
||||||
.driver = {
|
.driver = {
|
||||||
.name = "smdk-audio-wm8894",
|
.name = "smdk-audio-wm8894",
|
||||||
|
|
Loading…
Reference in a new issue