mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-10 21:07:02 +09:00
change for wm8994
This commit is contained in:
@@ -25,6 +25,9 @@
|
||||
#include <linux/mfd/wm8994/core.h>
|
||||
#include <linux/mfd/wm8994/pdata.h>
|
||||
#include <linux/mfd/wm8994/registers.h>
|
||||
#include <mach/gpio.h>
|
||||
|
||||
#define WM_PW_EN RK29_PIN5_PA1
|
||||
|
||||
static int wm8994_read(struct wm8994 *wm8994, unsigned short reg,
|
||||
int bytes, void *dest)
|
||||
@@ -43,7 +46,6 @@ static int wm8994_read(struct wm8994 *wm8994, unsigned short reg,
|
||||
dev_vdbg(wm8994->dev, "Read %04x from R%d(0x%x)\n",
|
||||
be16_to_cpu(buf[i]), reg + i, reg + i);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -107,7 +109,6 @@ static int wm8994_write(struct wm8994 *wm8994, unsigned short reg,
|
||||
dev_vdbg(wm8994->dev, "Write %04x to R%d(0x%x)\n",
|
||||
be16_to_cpu(buf[i]), reg + i, reg + i);
|
||||
}
|
||||
|
||||
return wm8994->write_dev(wm8994, reg, bytes, src);
|
||||
}
|
||||
|
||||
@@ -266,18 +267,17 @@ static const char *wm8958_main_supplies[] = {
|
||||
};
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
static int wm8994_suspend(struct device *dev)
|
||||
int wm8994_suspend(struct wm8994 *wm8994)
|
||||
{
|
||||
struct wm8994 *wm8994 = dev_get_drvdata(dev);
|
||||
int ret;
|
||||
|
||||
/* Don't actually go through with the suspend if the CODEC is
|
||||
* still active (eg, for audio passthrough from CP. */
|
||||
ret = wm8994_reg_read(wm8994, WM8994_POWER_MANAGEMENT_1);
|
||||
if (ret < 0) {
|
||||
dev_err(dev, "Failed to read power status: %d\n", ret);
|
||||
dev_err(wm8994->dev, "Failed to read power status: %d\n", ret);
|
||||
} else if (ret & WM8994_VMID_SEL_MASK) {
|
||||
dev_dbg(dev, "CODEC still active, ignoring suspend\n");
|
||||
dev_dbg(wm8994->dev, "CODEC still active, ignoring suspend\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -288,13 +288,13 @@ static int wm8994_suspend(struct device *dev)
|
||||
ret = wm8994_read(wm8994, WM8994_GPIO_1, WM8994_NUM_GPIO_REGS * 2,
|
||||
&wm8994->gpio_regs);
|
||||
if (ret < 0)
|
||||
dev_err(dev, "Failed to save GPIO registers: %d\n", ret);
|
||||
dev_err(wm8994->dev, "Failed to save GPIO registers: %d\n", ret);
|
||||
|
||||
/* For similar reasons we also stash the regulator states */
|
||||
ret = wm8994_read(wm8994, WM8994_LDO_1, WM8994_NUM_LDO_REGS * 2,
|
||||
&wm8994->ldo_regs);
|
||||
if (ret < 0)
|
||||
dev_err(dev, "Failed to save LDO registers: %d\n", ret);
|
||||
dev_err(wm8994->dev, "Failed to save LDO registers: %d\n", ret);
|
||||
|
||||
/* Explicitly put the device into reset in case regulators
|
||||
* don't get disabled in order to ensure consistent restart.
|
||||
@@ -303,46 +303,51 @@ static int wm8994_suspend(struct device *dev)
|
||||
|
||||
wm8994->suspended = true;
|
||||
|
||||
ret = regulator_bulk_disable(wm8994->num_supplies,
|
||||
/* ret = regulator_bulk_disable(wm8994->num_supplies,
|
||||
wm8994->supplies);
|
||||
if (ret != 0) {
|
||||
dev_err(dev, "Failed to disable supplies: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
*/
|
||||
|
||||
gpio_set_value(WM_PW_EN, GPIO_LOW);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int wm8994_resume(struct device *dev)
|
||||
int wm8994_resume(struct wm8994 *wm8994)
|
||||
{
|
||||
struct wm8994 *wm8994 = dev_get_drvdata(dev);
|
||||
int ret;
|
||||
|
||||
/* We may have lied to the PM core about suspending */
|
||||
if (!wm8994->suspended)
|
||||
return 0;
|
||||
|
||||
ret = regulator_bulk_enable(wm8994->num_supplies,
|
||||
gpio_set_value(WM_PW_EN, GPIO_HIGH);
|
||||
msleep(50);
|
||||
|
||||
/* ret = regulator_bulk_enable(wm8994->num_supplies,
|
||||
wm8994->supplies);
|
||||
if (ret != 0) {
|
||||
dev_err(dev, "Failed to enable supplies: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
*/
|
||||
ret = wm8994_write(wm8994, WM8994_INTERRUPT_STATUS_1_MASK,
|
||||
WM8994_NUM_IRQ_REGS * 2, &wm8994->irq_masks_cur);
|
||||
if (ret < 0)
|
||||
dev_err(dev, "Failed to restore interrupt masks: %d\n", ret);
|
||||
dev_err(wm8994->dev, "Failed to restore interrupt masks: %d\n", ret);
|
||||
|
||||
ret = wm8994_write(wm8994, WM8994_LDO_1, WM8994_NUM_LDO_REGS * 2,
|
||||
&wm8994->ldo_regs);
|
||||
if (ret < 0)
|
||||
dev_err(dev, "Failed to restore LDO registers: %d\n", ret);
|
||||
dev_err(wm8994->dev, "Failed to restore LDO registers: %d\n", ret);
|
||||
|
||||
ret = wm8994_write(wm8994, WM8994_GPIO_1, WM8994_NUM_GPIO_REGS * 2,
|
||||
&wm8994->gpio_regs);
|
||||
if (ret < 0)
|
||||
dev_err(dev, "Failed to restore GPIO registers: %d\n", ret);
|
||||
dev_err(wm8994->dev, "Failed to restore GPIO registers: %d\n", ret);
|
||||
|
||||
wm8994->suspended = false;
|
||||
|
||||
@@ -394,7 +399,7 @@ static int wm8994_device_init(struct wm8994 *wm8994, int irq)
|
||||
goto err;
|
||||
}
|
||||
|
||||
switch (wm8994->type) {
|
||||
/* switch (wm8994->type) {
|
||||
case WM8994:
|
||||
wm8994->num_supplies = ARRAY_SIZE(wm8994_main_supplies);
|
||||
break;
|
||||
@@ -441,7 +446,7 @@ static int wm8994_device_init(struct wm8994 *wm8994, int irq)
|
||||
dev_err(wm8994->dev, "Failed to enable supplies: %d\n", ret);
|
||||
goto err_get;
|
||||
}
|
||||
|
||||
*/
|
||||
ret = wm8994_reg_read(wm8994, WM8994_SOFTWARE_RESET);
|
||||
if (ret < 0) {
|
||||
dev_err(wm8994->dev, "Failed to read ID register\n");
|
||||
@@ -537,12 +542,12 @@ static int wm8994_device_init(struct wm8994 *wm8994, int irq)
|
||||
err_irq:
|
||||
wm8994_irq_exit(wm8994);
|
||||
err_enable:
|
||||
regulator_bulk_disable(wm8994->num_supplies,
|
||||
wm8994->supplies);
|
||||
// regulator_bulk_disable(wm8994->num_supplies,
|
||||
// wm8994->supplies);
|
||||
err_get:
|
||||
regulator_bulk_free(wm8994->num_supplies, wm8994->supplies);
|
||||
// regulator_bulk_free(wm8994->num_supplies, wm8994->supplies);
|
||||
err_supplies:
|
||||
kfree(wm8994->supplies);
|
||||
// kfree(wm8994->supplies);
|
||||
err:
|
||||
mfd_remove_devices(wm8994->dev);
|
||||
kfree(wm8994);
|
||||
@@ -554,10 +559,10 @@ static void wm8994_device_exit(struct wm8994 *wm8994)
|
||||
pm_runtime_disable(wm8994->dev);
|
||||
mfd_remove_devices(wm8994->dev);
|
||||
wm8994_irq_exit(wm8994);
|
||||
regulator_bulk_disable(wm8994->num_supplies,
|
||||
wm8994->supplies);
|
||||
regulator_bulk_free(wm8994->num_supplies, wm8994->supplies);
|
||||
kfree(wm8994->supplies);
|
||||
// regulator_bulk_disable(wm8994->num_supplies,
|
||||
// wm8994->supplies);
|
||||
// regulator_bulk_free(wm8994->num_supplies, wm8994->supplies);
|
||||
// kfree(wm8994->supplies);
|
||||
kfree(wm8994);
|
||||
}
|
||||
|
||||
@@ -595,11 +600,13 @@ static int wm8994_i2c_write_device(struct wm8994 *wm8994, unsigned short reg,
|
||||
xfer[0].flags = 0;
|
||||
xfer[0].len = 2;
|
||||
xfer[0].buf = (char *)®
|
||||
xfer[0].scl_rate = 100 * 1000;
|
||||
|
||||
xfer[1].addr = i2c->addr;
|
||||
xfer[1].flags = I2C_M_NOSTART;
|
||||
xfer[1].len = bytes;
|
||||
xfer[1].buf = (char *)src;
|
||||
xfer[1].scl_rate = 100 * 1000;
|
||||
|
||||
ret = i2c_transfer(i2c->adapter, xfer, 2);
|
||||
if (ret < 0)
|
||||
@@ -610,11 +617,16 @@ static int wm8994_i2c_write_device(struct wm8994 *wm8994, unsigned short reg,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int wm8994_i2c_probe(struct i2c_client *i2c,
|
||||
const struct i2c_device_id *id)
|
||||
int wm8994_probe(struct i2c_client *i2c,
|
||||
const struct i2c_device_id *id)
|
||||
{
|
||||
struct wm8994 *wm8994;
|
||||
|
||||
gpio_request(WM_PW_EN, NULL);
|
||||
gpio_direction_output(WM_PW_EN, GPIO_HIGH);
|
||||
|
||||
msleep(50);
|
||||
|
||||
wm8994 = kzalloc(sizeof(struct wm8994), GFP_KERNEL);
|
||||
if (wm8994 == NULL)
|
||||
return -ENOMEM;
|
||||
@@ -630,7 +642,7 @@ static int wm8994_i2c_probe(struct i2c_client *i2c,
|
||||
return wm8994_device_init(wm8994, i2c->irq);
|
||||
}
|
||||
|
||||
static int wm8994_i2c_remove(struct i2c_client *i2c)
|
||||
int wm8994_remove(struct i2c_client *i2c)
|
||||
{
|
||||
struct wm8994 *wm8994 = i2c_get_clientdata(i2c);
|
||||
|
||||
@@ -638,46 +650,6 @@ static int wm8994_i2c_remove(struct i2c_client *i2c)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct i2c_device_id wm8994_i2c_id[] = {
|
||||
{ "wm8994", WM8994 },
|
||||
{ "wm8958", WM8958 },
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(i2c, wm8994_i2c_id);
|
||||
|
||||
static UNIVERSAL_DEV_PM_OPS(wm8994_pm_ops, wm8994_suspend, wm8994_resume,
|
||||
NULL);
|
||||
|
||||
static struct i2c_driver wm8994_i2c_driver = {
|
||||
.driver = {
|
||||
.name = "WM8994",
|
||||
.owner = THIS_MODULE,
|
||||
.pm = &wm8994_pm_ops,
|
||||
},
|
||||
.probe = wm8994_i2c_probe,
|
||||
.remove = wm8994_i2c_remove,
|
||||
.id_table = wm8994_i2c_id,
|
||||
};
|
||||
|
||||
static int __init wm8994_i2c_init(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = i2c_add_driver(&wm8994_i2c_driver);
|
||||
if (ret != 0)
|
||||
pr_err("Failed to register wm8994 I2C driver: %d\n", ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
module_init(wm8994_i2c_init);
|
||||
|
||||
static void __exit wm8994_i2c_exit(void)
|
||||
{
|
||||
i2c_del_driver(&wm8994_i2c_driver);
|
||||
}
|
||||
module_exit(wm8994_i2c_exit);
|
||||
|
||||
MODULE_DESCRIPTION("Core support for the WM8994 audio CODEC");
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>");
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#define __MFD_WM8994_CORE_H__
|
||||
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/i2c.h>
|
||||
|
||||
enum wm8994_type {
|
||||
WM8994 = 0,
|
||||
@@ -113,4 +114,10 @@ static inline void wm8994_free_irq(struct wm8994 *wm8994, int irq, void *data)
|
||||
int wm8994_irq_init(struct wm8994 *wm8994);
|
||||
void wm8994_irq_exit(struct wm8994 *wm8994);
|
||||
|
||||
int wm8994_suspend(struct wm8994 *wm8994);
|
||||
int wm8994_resume(struct wm8994 *wm8994);
|
||||
|
||||
int wm8994_probe(struct i2c_client *i2c, const struct i2c_device_id *id);
|
||||
int wm8994_remove(struct i2c_client *i2c);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -41,6 +41,8 @@
|
||||
#define WM8994_NUM_DRC 3
|
||||
#define WM8994_NUM_EQ 3
|
||||
|
||||
struct wm8994 *wm8994_control;
|
||||
|
||||
static int wm8994_drc_base[] = {
|
||||
WM8994_AIF1_DRC1_1,
|
||||
WM8994_AIF1_DRC2_1,
|
||||
@@ -2329,6 +2331,32 @@ static int wm8994_set_tristate(struct snd_soc_dai *codec_dai, int tristate)
|
||||
return snd_soc_update_bits(codec, reg, mask, val);
|
||||
}
|
||||
|
||||
struct snd_soc_codec *wm8994_regshow_codec;
|
||||
|
||||
static ssize_t wm8994_index_reg_show(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
#define IDX_REG_FMT "reg 0x%04x value 0x%04x\n"
|
||||
unsigned int val;
|
||||
int cnt = 0, i;
|
||||
|
||||
cnt += sprintf(buf, "WM8994 index register\n");
|
||||
for (i = 0; i < WM8994_CACHE_SIZE; i++) {
|
||||
if (!wm8994_readable(wm8994_regshow_codec, i) || wm8994_volatile(wm8994_regshow_codec, i))
|
||||
continue;
|
||||
val = wm8994_reg_read(wm8994_control, i);
|
||||
if (!val)
|
||||
continue;
|
||||
cnt += sprintf(buf + cnt, IDX_REG_FMT, i, val);
|
||||
}
|
||||
|
||||
if (cnt >= PAGE_SIZE)
|
||||
cnt = PAGE_SIZE - 1;
|
||||
|
||||
return cnt;
|
||||
}
|
||||
static DEVICE_ATTR(index_reg, 0444, wm8994_index_reg_show, NULL);
|
||||
|
||||
#define WM8994_RATES SNDRV_PCM_RATE_8000_96000
|
||||
|
||||
#define WM8994_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\
|
||||
@@ -2418,7 +2446,7 @@ static struct snd_soc_dai_driver wm8994_dai[] = {
|
||||
};
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
static int wm8994_suspend(struct snd_soc_codec *codec, pm_message_t state)
|
||||
static int wm8994_codec_suspend(struct snd_soc_codec *codec, pm_message_t state)
|
||||
{
|
||||
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
|
||||
struct wm8994 *control = codec->control_data;
|
||||
@@ -2445,16 +2473,20 @@ static int wm8994_suspend(struct snd_soc_codec *codec, pm_message_t state)
|
||||
|
||||
wm8994_set_bias_level(codec, SND_SOC_BIAS_OFF);
|
||||
|
||||
wm8994_suspend(control);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int wm8994_resume(struct snd_soc_codec *codec)
|
||||
static int wm8994_codec_resume(struct snd_soc_codec *codec)
|
||||
{
|
||||
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
|
||||
struct wm8994 *control = codec->control_data;
|
||||
int i, ret;
|
||||
unsigned int val, mask;
|
||||
|
||||
wm8994_resume(control);
|
||||
|
||||
if (wm8994->revision < 4) {
|
||||
/* force a HW read */
|
||||
val = wm8994_reg_read(codec->control_data,
|
||||
@@ -2857,15 +2889,22 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec)
|
||||
struct snd_soc_dapm_context *dapm = &codec->dapm;
|
||||
int ret, i;
|
||||
|
||||
codec->control_data = dev_get_drvdata(codec->dev->parent);
|
||||
if (wm8994_control == NULL) {
|
||||
pr_err("wm8994_codec_probe:wm8994_control is NULL!");
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
codec->control_data = wm8994_control;//dev_get_drvdata(codec->dev->parent);
|
||||
control = codec->control_data;
|
||||
|
||||
wm8994_regshow_codec = codec;
|
||||
|
||||
wm8994 = kzalloc(sizeof(struct wm8994_priv), GFP_KERNEL);
|
||||
if (wm8994 == NULL)
|
||||
return -ENOMEM;
|
||||
snd_soc_codec_set_drvdata(codec, wm8994);
|
||||
|
||||
wm8994->pdata = dev_get_platdata(codec->dev->parent);
|
||||
wm8994->pdata = wm8994_control->dev->platform_data;//dev_get_platdata(codec->dev->parent);
|
||||
wm8994->codec = codec;
|
||||
|
||||
if (wm8994->pdata && wm8994->pdata->micdet_irq)
|
||||
@@ -3145,6 +3184,13 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec)
|
||||
break;
|
||||
}
|
||||
|
||||
ret = device_create_file(codec->dev, &dev_attr_index_reg);
|
||||
if (ret != 0) {
|
||||
dev_err(codec->dev,
|
||||
"Failed to create index_reg sysfs files: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
err_irq:
|
||||
@@ -3200,8 +3246,8 @@ static int wm8994_codec_remove(struct snd_soc_codec *codec)
|
||||
static struct snd_soc_codec_driver soc_codec_dev_wm8994 = {
|
||||
.probe = wm8994_codec_probe,
|
||||
.remove = wm8994_codec_remove,
|
||||
.suspend = wm8994_suspend,
|
||||
.resume = wm8994_resume,
|
||||
.suspend = wm8994_codec_suspend,
|
||||
.resume = wm8994_codec_resume,
|
||||
.read = wm8994_read,
|
||||
.write = wm8994_write,
|
||||
.readable_register = wm8994_readable,
|
||||
@@ -3214,39 +3260,69 @@ static struct snd_soc_codec_driver soc_codec_dev_wm8994 = {
|
||||
.compress_type = SND_SOC_RBTREE_COMPRESSION,
|
||||
};
|
||||
|
||||
static int __devinit wm8994_probe(struct platform_device *pdev)
|
||||
static int wm8994_i2c_probe(struct i2c_client *i2c,
|
||||
const struct i2c_device_id *id)
|
||||
{
|
||||
return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_wm8994,
|
||||
wm8994_dai, ARRAY_SIZE(wm8994_dai));
|
||||
int ret;
|
||||
|
||||
ret = wm8994_probe(i2c, id);
|
||||
if (ret < 0) {
|
||||
pr_err("wm8994_i2c_probe error!");
|
||||
return ret;
|
||||
}
|
||||
|
||||
wm8994_control = i2c_get_clientdata(i2c);
|
||||
|
||||
return snd_soc_register_codec(&i2c->dev, &soc_codec_dev_wm8994,
|
||||
wm8994_dai, ARRAY_SIZE(wm8994_dai));
|
||||
}
|
||||
|
||||
static int __devexit wm8994_remove(struct platform_device *pdev)
|
||||
static int wm8994_i2c_remove(struct i2c_client *i2c)
|
||||
{
|
||||
snd_soc_unregister_codec(&pdev->dev);
|
||||
wm8994_remove(i2c);
|
||||
snd_soc_unregister_codec(&i2c->dev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct platform_driver wm8994_codec_driver = {
|
||||
static const struct i2c_device_id wm8994_i2c_id[] = {
|
||||
{ "wm8994", WM8994 },
|
||||
// { "wm8958", WM8958 },
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(i2c, wm8994_i2c_id);
|
||||
|
||||
//static UNIVERSAL_DEV_PM_OPS(wm8994_pm_ops, wm8994_suspend, wm8994_resume,
|
||||
// NULL);
|
||||
|
||||
static struct i2c_driver wm8994_i2c_driver = {
|
||||
.driver = {
|
||||
.name = "WM8994",
|
||||
.owner = THIS_MODULE,
|
||||
},
|
||||
.probe = wm8994_probe,
|
||||
.remove = __devexit_p(wm8994_remove),
|
||||
.name = "WM8994",
|
||||
.owner = THIS_MODULE,
|
||||
//.pm = &wm8994_pm_ops,
|
||||
},
|
||||
.probe = wm8994_i2c_probe,
|
||||
.remove = wm8994_i2c_remove,
|
||||
.id_table = wm8994_i2c_id,
|
||||
};
|
||||
|
||||
static __init int wm8994_init(void)
|
||||
static int __init wm8994_i2c_init(void)
|
||||
{
|
||||
return platform_driver_register(&wm8994_codec_driver);
|
||||
}
|
||||
module_init(wm8994_init);
|
||||
int ret;
|
||||
|
||||
static __exit void wm8994_exit(void)
|
||||
ret = i2c_add_driver(&wm8994_i2c_driver);
|
||||
if (ret != 0)
|
||||
pr_err("Failed to register wm8994 I2C driver: %d\n", ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
module_init(wm8994_i2c_init);
|
||||
|
||||
static void __exit wm8994_i2c_exit(void)
|
||||
{
|
||||
platform_driver_unregister(&wm8994_codec_driver);
|
||||
i2c_del_driver(&wm8994_i2c_driver);
|
||||
}
|
||||
module_exit(wm8994_exit);
|
||||
|
||||
module_exit(wm8994_i2c_exit);
|
||||
|
||||
MODULE_DESCRIPTION("ASoC WM8994 driver");
|
||||
MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>");
|
||||
|
||||
@@ -42,9 +42,7 @@ static int rk29_aif1_hw_params(struct snd_pcm_substream *substream,
|
||||
struct snd_soc_dai *codec_dai = rtd->codec_dai;
|
||||
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
|
||||
unsigned int pll_out = 0;
|
||||
int div_bclk,div_mclk;
|
||||
int ret;
|
||||
struct clk *general_pll;
|
||||
|
||||
DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
|
||||
|
||||
@@ -107,38 +105,17 @@ static int rk29_aif1_hw_params(struct snd_pcm_substream *substream,
|
||||
|
||||
DBG("Enter:%s, %d, rate=%d\n",__FUNCTION__,__LINE__,params_rate(params));
|
||||
|
||||
#if defined (CONFIG_SND_RK29_CODEC_SOC_MASTER)
|
||||
ret = snd_soc_dai_set_sysclk(codec_dai, WM8994_SYSCLK_MCLK1, pll_out, 0);
|
||||
if (ret < 0) {
|
||||
DBG("rk29_hw_params_wm8994:failed to set the sysclk for codec side\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
snd_soc_dai_set_sysclk(cpu_dai, 0, pll_out, 0);
|
||||
#endif
|
||||
|
||||
#if defined (CONFIG_SND_RK29_CODEC_SOC_SLAVE)
|
||||
general_pll=clk_get(NULL, "general_pll");
|
||||
|
||||
if(clk_get_rate(general_pll)>260000000) {
|
||||
div_bclk=(pll_out/4)/params_rate(params)-1;
|
||||
div_mclk=3;
|
||||
}
|
||||
else if(clk_get_rate(general_pll)>130000000)
|
||||
{
|
||||
div_bclk=(pll_out/2)/params_rate(params)-1;
|
||||
div_mclk=1;
|
||||
}
|
||||
else
|
||||
{
|
||||
pll_out=pll_out/4;
|
||||
div_bclk=(pll_out)/params_rate(params)-1;
|
||||
div_mclk=0;
|
||||
}
|
||||
DBG("func is%s,gpll=%ld,pll_out=%d,div_mclk=%d\n",
|
||||
__FUNCTION__,clk_get_rate(general_pll),pll_out,div_mclk);
|
||||
snd_soc_dai_set_sysclk(cpu_dai, 0, pll_out, 0);
|
||||
snd_soc_dai_set_clkdiv(cpu_dai, ROCKCHIP_DIV_BCLK,div_bclk);
|
||||
snd_soc_dai_set_clkdiv(cpu_dai, ROCKCHIP_DIV_MCLK, div_mclk);
|
||||
|
||||
if(div_mclk == 3)
|
||||
snd_soc_dai_set_sysclk(codec_dai, WM8994_SYSCLK_MCLK1, pll_out, 0);
|
||||
else
|
||||
snd_soc_dai_set_sysclk(codec_dai, WM8994_SYSCLK_FLL1, pll_out, 0);
|
||||
snd_soc_dai_set_clkdiv(cpu_dai, ROCKCHIP_DIV_BCLK, (pll_out/4)/params_rate(params)-1);
|
||||
snd_soc_dai_set_clkdiv(cpu_dai, ROCKCHIP_DIV_MCLK, 3);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
@@ -192,36 +169,17 @@ static int rk29_aif2_hw_params(struct snd_pcm_substream *substream,
|
||||
|
||||
DBG("Enter:%s, %d, rate=%d\n",__FUNCTION__,__LINE__,params_rate(params));
|
||||
|
||||
#if defined (CONFIG_SND_RK29_CODEC_SOC_MASTER)
|
||||
ret = snd_soc_dai_set_sysclk(codec_dai, WM8994_SYSCLK_MCLK1, pll_out, 0);
|
||||
if (ret < 0) {
|
||||
DBG("rk29_hw_params_wm8994:failed to set the sysclk for codec side\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
snd_soc_dai_set_sysclk(cpu_dai, 0, pll_out, 0);
|
||||
#endif
|
||||
|
||||
#if defined (CONFIG_SND_RK29_CODEC_SOC_SLAVE)
|
||||
general_pll=clk_get(NULL, "general_pll");
|
||||
|
||||
if(clk_get_rate(general_pll)>260000000) {
|
||||
div_bclk=(pll_out/4)/params_rate(params)-1;
|
||||
div_mclk=3;
|
||||
}
|
||||
else if(clk_get_rate(general_pll)>130000000)
|
||||
{
|
||||
div_bclk=(pll_out/2)/params_rate(params)-1;
|
||||
div_mclk=1;
|
||||
}
|
||||
else
|
||||
{
|
||||
pll_out=pll_out/4;
|
||||
div_bclk=(pll_out)/params_rate(params)-1;
|
||||
div_mclk=0;
|
||||
}
|
||||
DBG("func is%s,gpll=%ld,pll_out=%d,div_mclk=%d\n",
|
||||
__FUNCTION__,clk_get_rate(general_pll),pll_out,div_mclk);
|
||||
snd_soc_dai_set_sysclk(cpu_dai, 0, pll_out, 0);
|
||||
|
||||
if(div_mclk == 3)
|
||||
snd_soc_dai_set_sysclk(codec_dai, WM8994_SYSCLK_MCLK1, pll_out, 0);
|
||||
else
|
||||
snd_soc_dai_set_sysclk(codec_dai, WM8994_SYSCLK_FLL1, pll_out, 0);
|
||||
snd_soc_dai_set_clkdiv(cpu_dai, ROCKCHIP_DIV_BCLK, (pll_out/4)/params_rate(params)-1);
|
||||
snd_soc_dai_set_clkdiv(cpu_dai, ROCKCHIP_DIV_MCLK, 3);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
@@ -269,30 +227,18 @@ static int rk29_aif3_hw_params(struct snd_pcm_substream *substream,
|
||||
|
||||
DBG("Enter:%s, %d, rate=%d\n",__FUNCTION__,__LINE__,params_rate(params));
|
||||
|
||||
ret = snd_soc_dai_set_sysclk(codec_dai, WM8994_SYSCLK_MCLK1, pll_out, 0);
|
||||
if (ret < 0) {
|
||||
DBG("rk29_hw_params_wm8994:failed to set the sysclk for codec side\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
snd_soc_dai_set_sysclk(cpu_dai, 0, pll_out, 0);
|
||||
|
||||
general_pll=clk_get(NULL, "general_pll");
|
||||
|
||||
if(clk_get_rate(general_pll)>260000000) {
|
||||
div_bclk=(pll_out/4)/params_rate(params)-1;
|
||||
div_mclk=3;
|
||||
}
|
||||
else if(clk_get_rate(general_pll)>130000000)
|
||||
{
|
||||
div_bclk=(pll_out/2)/params_rate(params)-1;
|
||||
div_mclk=1;
|
||||
}
|
||||
else
|
||||
{
|
||||
pll_out=pll_out/4;
|
||||
div_bclk=(pll_out)/params_rate(params)-1;
|
||||
div_mclk=0;
|
||||
}
|
||||
|
||||
if(div_mclk == 3)
|
||||
snd_soc_dai_set_sysclk(codec_dai, WM8994_SYSCLK_MCLK1, pll_out, 0);
|
||||
else
|
||||
snd_soc_dai_set_sysclk(codec_dai, WM8994_SYSCLK_FLL1, pll_out, 0);
|
||||
#if defined (CONFIG_SND_RK29_CODEC_SOC_SLAVE)
|
||||
snd_soc_dai_set_clkdiv(cpu_dai, ROCKCHIP_DIV_BCLK, (pll_out/4)/params_rate(params)-1);
|
||||
snd_soc_dai_set_clkdiv(cpu_dai, ROCKCHIP_DIV_MCLK, 3);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -315,34 +261,6 @@ static const struct snd_soc_dapm_route audio_map[]= {
|
||||
{"Micp", NULL, "LINPUT2"},
|
||||
};
|
||||
*/
|
||||
/*
|
||||
* Logic for a wm8994 as connected on a rockchip board.
|
||||
*/
|
||||
static int rk29_wm8994_init(struct snd_soc_pcm_runtime *rtd)
|
||||
{
|
||||
struct snd_soc_dai *codec_dai = rtd->codec_dai;
|
||||
struct snd_soc_codec *codec = rtd->codec;
|
||||
struct snd_soc_dapm_context *dapm = &codec->dapm;
|
||||
int ret;
|
||||
|
||||
DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
|
||||
|
||||
ret = snd_soc_dai_set_sysclk(codec_dai, 0,
|
||||
12000000, SND_SOC_CLOCK_IN);
|
||||
if (ret < 0) {
|
||||
printk(KERN_ERR "Failed to set WM8994 SYSCLK: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Add specific widgets */
|
||||
// snd_soc_dapm_new_controls(dapm, rk2818_dapm_widgets,
|
||||
// ARRAY_SIZE(rk2818_dapm_widgets));
|
||||
/* Set up specific audio path audio_mapnects */
|
||||
// snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map));
|
||||
// snd_soc_dapm_sync(codec);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct snd_soc_ops rk29_aif1_ops = {
|
||||
.hw_params = rk29_aif1_hw_params,
|
||||
@@ -358,33 +276,30 @@ static struct snd_soc_ops rk29_aif3_ops = {
|
||||
|
||||
static struct snd_soc_dai_link rk29_dai[] = {
|
||||
{
|
||||
.name = "WM8994",
|
||||
.stream_name = "WM8994 I2S1",
|
||||
.name = "WM8994 I2S1",
|
||||
.stream_name = "WM8994 PCM",
|
||||
.codec_name = "WM8994.0-001a",
|
||||
.platform_name = "rockchip-audio",
|
||||
.cpu_dai_name = "rk29_i2s.0",
|
||||
.codec_dai_name = "wm8994-aif1",
|
||||
.init = rk29_wm8994_init,
|
||||
.ops = &rk29_aif1_ops,
|
||||
},
|
||||
{
|
||||
.name = "WM8994",
|
||||
.stream_name = "WM8994 I2S2",
|
||||
.codec_name = "WM8994.1-001a",
|
||||
.name = "WM8994 I2S2",
|
||||
.stream_name = "WM8994 PCM",
|
||||
.codec_name = "WM8994.0-001a",
|
||||
.platform_name = "rockchip-audio",
|
||||
.cpu_dai_name = "rk29_i2s.0",
|
||||
.codec_dai_name = "wm8994-aif2",
|
||||
.init = rk29_wm8994_init,
|
||||
.ops = &rk29_aif2_ops,
|
||||
},
|
||||
{
|
||||
.name = "WM8994",
|
||||
.stream_name = "WM8994 I2S3",
|
||||
.codec_name = "WM8994.2-001a",
|
||||
.name = "WM8994 I2S3",
|
||||
.stream_name = "WM8994 PCM",
|
||||
.codec_name = "WM8994.0-001a",
|
||||
.platform_name = "rockchip-audio",
|
||||
.cpu_dai_name = "rk29_i2s.0",
|
||||
.codec_dai_name = "wm8994-aif3",
|
||||
.init = rk29_wm8994_init,
|
||||
.ops = &rk29_aif3_ops,
|
||||
},
|
||||
};
|
||||
@@ -405,15 +320,14 @@ static int __init audio_card_init(void)
|
||||
|
||||
rk29_snd_device = platform_device_alloc("soc-audio", -1);
|
||||
if (!rk29_snd_device) {
|
||||
DBG("platform device allocation failed\n");
|
||||
ret = -ENOMEM;
|
||||
return ret;
|
||||
printk("platform device allocation failed\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
platform_set_drvdata(rk29_snd_device, &snd_soc_card_rk29);
|
||||
ret = platform_device_add(rk29_snd_device);
|
||||
if (ret) {
|
||||
DBG("platform device add failed\n");
|
||||
printk("platform device add failed\n");
|
||||
|
||||
platform_device_put(rk29_snd_device);
|
||||
return ret;
|
||||
|
||||
Reference in New Issue
Block a user