Lines Matching +full:audio +full:- +full:enable
1 // SPDX-License-Identifier: GPL-2.0-only
3 * MFD driver for twl4030 audio submodule, which contains an audio codec, and
21 #include <linux/mfd/twl4030-audio.h>
44 static int twl4030_audio_set_resource(enum twl4030_audio_res id, int enable) in twl4030_audio_set_resource() argument
46 struct twl4030_audio *audio = platform_get_drvdata(twl4030_audio_dev); in twl4030_audio_set_resource() local
50 audio->resource[id].reg); in twl4030_audio_set_resource()
52 if (enable) in twl4030_audio_set_resource()
53 val |= audio->resource[id].mask; in twl4030_audio_set_resource()
55 val &= ~audio->resource[id].mask; in twl4030_audio_set_resource()
58 val, audio->resource[id].reg); in twl4030_audio_set_resource()
65 struct twl4030_audio *audio = platform_get_drvdata(twl4030_audio_dev); in twl4030_audio_get_resource() local
69 audio->resource[id].reg); in twl4030_audio_get_resource()
75 * Enable the resource.
80 struct twl4030_audio *audio = platform_get_drvdata(twl4030_audio_dev); in twl4030_audio_enable_resource() local
84 dev_err(&twl4030_audio_dev->dev, in twl4030_audio_enable_resource()
86 return -EINVAL; in twl4030_audio_enable_resource()
89 mutex_lock(&audio->mutex); in twl4030_audio_enable_resource()
90 if (!audio->resource[id].request_count) in twl4030_audio_enable_resource()
91 /* Resource was disabled, enable it */ in twl4030_audio_enable_resource()
96 audio->resource[id].request_count++; in twl4030_audio_enable_resource()
97 mutex_unlock(&audio->mutex); in twl4030_audio_enable_resource()
109 struct twl4030_audio *audio = platform_get_drvdata(twl4030_audio_dev); in twl4030_audio_disable_resource() local
113 dev_err(&twl4030_audio_dev->dev, in twl4030_audio_disable_resource()
115 return -EINVAL; in twl4030_audio_disable_resource()
118 mutex_lock(&audio->mutex); in twl4030_audio_disable_resource()
119 if (!audio->resource[id].request_count) { in twl4030_audio_disable_resource()
120 dev_err(&twl4030_audio_dev->dev, in twl4030_audio_disable_resource()
122 mutex_unlock(&audio->mutex); in twl4030_audio_disable_resource()
123 return -EPERM; in twl4030_audio_disable_resource()
125 audio->resource[id].request_count--; in twl4030_audio_disable_resource()
127 if (!audio->resource[id].request_count) in twl4030_audio_disable_resource()
133 mutex_unlock(&audio->mutex); in twl4030_audio_disable_resource()
141 struct twl4030_audio *audio = platform_get_drvdata(twl4030_audio_dev); in twl4030_audio_get_mclk() local
143 return audio->audio_mclk; in twl4030_audio_get_mclk()
152 if (pdata && pdata->codec) in twl4030_audio_has_codec()
169 if (pdata && pdata->vibra) in twl4030_audio_has_vibra()
172 if (!of_property_read_u32(node, "ti,enable-vibra", &vibra) && vibra) in twl4030_audio_has_vibra()
180 struct twl4030_audio *audio; in twl4030_audio_probe() local
181 struct twl4030_audio_data *pdata = dev_get_platdata(&pdev->dev); in twl4030_audio_probe()
182 struct device_node *node = pdev->dev.of_node; in twl4030_audio_probe()
188 dev_err(&pdev->dev, "Platform data is missing\n"); in twl4030_audio_probe()
189 return -EINVAL; in twl4030_audio_probe()
192 audio = devm_kzalloc(&pdev->dev, sizeof(struct twl4030_audio), in twl4030_audio_probe()
194 if (!audio) in twl4030_audio_probe()
195 return -ENOMEM; in twl4030_audio_probe()
197 mutex_init(&audio->mutex); in twl4030_audio_probe()
198 audio->audio_mclk = twl_get_hfclk_rate(); in twl4030_audio_probe()
201 switch (audio->audio_mclk) { in twl4030_audio_probe()
212 dev_err(&pdev->dev, "Invalid audio_mclk\n"); in twl4030_audio_probe()
213 return -EINVAL; in twl4030_audio_probe()
218 audio->resource[TWL4030_AUDIO_RES_POWER].reg = TWL4030_REG_CODEC_MODE; in twl4030_audio_probe()
219 audio->resource[TWL4030_AUDIO_RES_POWER].mask = TWL4030_CODECPDZ; in twl4030_audio_probe()
222 audio->resource[TWL4030_AUDIO_RES_APLL].reg = TWL4030_REG_APLL_CTL; in twl4030_audio_probe()
223 audio->resource[TWL4030_AUDIO_RES_APLL].mask = TWL4030_APLL_EN; in twl4030_audio_probe()
226 cell = &audio->cells[childs]; in twl4030_audio_probe()
227 cell->name = "twl4030-codec"; in twl4030_audio_probe()
229 cell->platform_data = pdata->codec; in twl4030_audio_probe()
230 cell->pdata_size = sizeof(*pdata->codec); in twl4030_audio_probe()
235 cell = &audio->cells[childs]; in twl4030_audio_probe()
236 cell->name = "twl4030-vibra"; in twl4030_audio_probe()
238 cell->platform_data = pdata->vibra; in twl4030_audio_probe()
239 cell->pdata_size = sizeof(*pdata->vibra); in twl4030_audio_probe()
244 platform_set_drvdata(pdev, audio); in twl4030_audio_probe()
248 ret = mfd_add_devices(&pdev->dev, pdev->id, audio->cells, in twl4030_audio_probe()
251 dev_err(&pdev->dev, "No platform data found for childs\n"); in twl4030_audio_probe()
252 ret = -ENODEV; in twl4030_audio_probe()
263 mfd_remove_devices(&pdev->dev); in twl4030_audio_remove()
268 {.compatible = "ti,twl4030-audio", },
275 .name = "twl4030-audio",
285 MODULE_DESCRIPTION("TWL4030 audio block MFD driver");
286 MODULE_ALIAS("platform:twl4030-audio");