// SPDX-License-Identifier: GPL-2.0-only /* * MFD driver for twl4030 audio submodule, which contains an audio codec, and * the vibra control. * * Author: Peter Ujfalusi <peter.ujfalusi@ti.com> * * Copyright: (C) 2009 Nokia Corporation
*/
/* * Modify the resource, the function returns the content of the register * after the modification.
*/ staticint twl4030_audio_set_resource(enum twl4030_audio_res id, int enable)
{ struct twl4030_audio *audio = platform_get_drvdata(twl4030_audio_dev);
u8 val;
/* * Enable the resource. * The function returns with error or the content of the register
*/ int twl4030_audio_enable_resource(enum twl4030_audio_res id)
{ struct twl4030_audio *audio = platform_get_drvdata(twl4030_audio_dev); int val;
if (id >= TWL4030_AUDIO_RES_MAX) {
dev_err(&twl4030_audio_dev->dev, "Invalid resource ID (%u)\n", id); return -EINVAL;
}
mutex_lock(&audio->mutex); if (!audio->resource[id].request_count) /* Resource was disabled, enable it */
val = twl4030_audio_set_resource(id, 1); else
val = twl4030_audio_get_resource(id);
/* * Disable the resource. * The function returns with error or the content of the register
*/ int twl4030_audio_disable_resource(enum twl4030_audio_res id)
{ struct twl4030_audio *audio = platform_get_drvdata(twl4030_audio_dev); int val;
if (id >= TWL4030_AUDIO_RES_MAX) {
dev_err(&twl4030_audio_dev->dev, "Invalid resource ID (%u)\n", id); return -EINVAL;
}
mutex_lock(&audio->mutex); if (!audio->resource[id].request_count) {
dev_err(&twl4030_audio_dev->dev, "Resource has been disabled already (%u)\n", id);
mutex_unlock(&audio->mutex); return -EPERM;
}
audio->resource[id].request_count--;
if (!audio->resource[id].request_count) /* Resource can be disabled now */
val = twl4030_audio_set_resource(id, 0); else
val = twl4030_audio_get_resource(id);
/* Configure APLL_INFREQ and disable APLL if enabled */ switch (audio->audio_mclk) { case 19200000:
val = TWL4030_APLL_INFREQ_19200KHZ; break; case 26000000:
val = TWL4030_APLL_INFREQ_26000KHZ; break; case 38400000:
val = TWL4030_APLL_INFREQ_38400KHZ; break; default:
dev_err(&pdev->dev, "Invalid audio_mclk\n"); return -EINVAL;
}
twl_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE, val, TWL4030_REG_APLL_CTL);
/* Codec power */
audio->resource[TWL4030_AUDIO_RES_POWER].reg = TWL4030_REG_CODEC_MODE;
audio->resource[TWL4030_AUDIO_RES_POWER].mask = TWL4030_CODECPDZ;
if (childs)
ret = mfd_add_devices(&pdev->dev, pdev->id, audio->cells,
childs, NULL, 0, NULL); else {
dev_err(&pdev->dev, "No platform data found for childs\n");
ret = -ENODEV;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.