@@ -16,6 +16,7 @@ struct mtk_soc_card_data {
const struct mtk_sof_priv *sof_priv;
struct list_head sof_dai_link_list;
struct mtk_platform_card_data *card_data;
+ struct snd_soc_component *accdet;
void *mach_priv;
};
@@ -8,6 +8,7 @@
#include <linux/module.h>
#include <linux/of.h>
+#include <linux/of_platform.h>
#include <sound/soc.h>
#include "mtk-dsp-sof-common.h"
@@ -192,7 +193,9 @@ EXPORT_SYMBOL_GPL(mtk_soundcard_common_capture_ops);
int mtk_soundcard_common_probe(struct platform_device *pdev)
{
- struct device_node *platform_node, *adsp_node;
+ struct device_node *platform_node, *adsp_node, *accdet_node;
+ struct snd_soc_component *accdet_comp;
+ struct platform_device *accdet_pdev;
const struct mtk_soundcard_pdata *pdata;
struct mtk_soc_card_data *soc_card_data;
struct snd_soc_dai_link *orig_dai_link, *dai_link;
@@ -250,6 +253,16 @@ int mtk_soundcard_common_probe(struct platform_device *pdev)
soc_card_data->card_data->jacks = jacks;
+ accdet_node = of_parse_phandle(pdev->dev.of_node, "mediatek,accdet", 0);
+ if (!IS_ERR(accdet_node)) {
+ accdet_pdev = of_find_device_by_node(accdet_node);
+ if (!IS_ERR(accdet_pdev)) {
+ accdet_comp = snd_soc_lookup_component(&accdet_pdev->dev, NULL);
+ if (!IS_ERR(accdet_comp))
+ soc_card_data->accdet = accdet_comp;
+ }
+ }
+
platform_node = of_parse_phandle(pdev->dev.of_node, "mediatek,platform", 0);
if (!platform_node)
return dev_err_probe(&pdev->dev, -EINVAL,
Handle the optional mediatek,accdet property. When present, retrieve the sound component from its phandle, so the machine sound driver can use it to register the audio jack and initialize the MT6359 ACCDET for jack detection. Signed-off-by: NĂcolas F. R. A. Prado <nfraprado@collabora.com> --- sound/soc/mediatek/common/mtk-soc-card.h | 1 + sound/soc/mediatek/common/mtk-soundcard-driver.c | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-)