From patchwork Mon Dec 8 22:01:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kenneth Westfield X-Patchwork-Id: 5458991 Return-Path: X-Original-To: patchwork-linux-arm-msm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0D24F9F30B for ; Mon, 8 Dec 2014 22:02:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 45E9820115 for ; Mon, 8 Dec 2014 22:02:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 819A120172 for ; Mon, 8 Dec 2014 22:02:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755157AbaLHWB5 (ORCPT ); Mon, 8 Dec 2014 17:01:57 -0500 Received: from smtp.codeaurora.org ([198.145.11.231]:42990 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754998AbaLHWB5 (ORCPT ); Mon, 8 Dec 2014 17:01:57 -0500 Received: from smtp.codeaurora.org (localhost [127.0.0.1]) by smtp.codeaurora.org (Postfix) with ESMTP id AD577140638; Mon, 8 Dec 2014 22:01:56 +0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 486) id 9F48014063B; Mon, 8 Dec 2014 22:01:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from localhost (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: kwestfie@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 16990140638; Mon, 8 Dec 2014 22:01:56 +0000 (UTC) From: Kenneth Westfield To: Mark Brown , Takashi Iwai , Liam Girdwood , David Brown , Bryan Huntsman , Rob Herring , Greg KH , Patrick Lai , Banajit Goswami Cc: ALSA Mailing List , Device Tree Mailing List , MSM Mailing List , Kenneth Westfield Subject: [Patch v2 07/11] ASoC: ipq806x: Add machine driver for IPQ806X SOC Date: Mon, 8 Dec 2014 14:01:09 -0800 Message-Id: <1418076073-12623-8-git-send-email-kwestfie@codeaurora.org> X-Mailer: git-send-email 1.8.2.1 In-Reply-To: <1418076073-12623-1-git-send-email-kwestfie@codeaurora.org> References: <1418076073-12623-1-git-send-email-kwestfie@codeaurora.org> X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Kenneth Westfield Add machine driver for the IPQ806X LPASS SOC. Signed-off-by: Kenneth Westfield Acked-by: Banajit Goswami --- sound/soc/qcom/ipq806x.c | 127 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 sound/soc/qcom/ipq806x.c diff --git a/sound/soc/qcom/ipq806x.c b/sound/soc/qcom/ipq806x.c new file mode 100644 index 0000000000000000000000000000000000000000..58bc64105ce6176cbe9408e5a75e4a7d7be437a1 --- /dev/null +++ b/sound/soc/qcom/ipq806x.c @@ -0,0 +1,127 @@ +/* + * Copyright (c) 2010-2011,2013-2014 The Linux Foundation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 and + * only version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include +#include + +#define DRV_NAME "ipq806x-machine" + +static struct snd_soc_dai_link ipq806x_machine_dai_link = { + .name = "IPQ806x Media1", + .stream_name = "MultiMedia1", +}; + +static int ipq806x_populate_dai_link_of_nodes(struct snd_soc_card *card) +{ + int ret; + struct device *cdev = card->dev; + struct snd_soc_dai_link *dai_link = card->dai_link; + struct device_node *np; + + np = of_parse_phandle(cdev->of_node, "platform", 0); + if (!np) { + dev_err(cdev, "%s: no phandle for platform driver\n", + __func__); + return -ENODEV; + } + dai_link->platform_of_node = np; + + np = of_parse_phandle(cdev->of_node, "cpu", 0); + if (!np) { + dev_err(cdev, "%s: no phandle for cpu-dai driver\n", __func__); + return -ENODEV; + } + dai_link->cpu_of_node = np; + + np = of_parse_phandle(cdev->of_node, "codec", 0); + if (!np) { + dev_err(cdev, "%s: no phandle for codec driver\n", __func__); + return -ENODEV; + } + dai_link->codec_of_node = np; + + ret = of_property_read_string(cdev->of_node, "codec-dai", + &dai_link->codec_dai_name); + if (ret) { + dev_err(cdev, "%s: no name for codec dai\n", __func__); + return ret; + } + + return 0; +} + +static struct snd_soc_card ipq806x_machine_soc_card = { + .name = DRV_NAME, + .dev = NULL, +}; + +static int ipq806x_machine_platform_probe(struct platform_device *pdev) +{ + int ret; + struct snd_soc_card *card = &ipq806x_machine_soc_card; + + if (card->dev) { + dev_err(&pdev->dev, "soundcard instance already created\n"); + return -ENODEV; + } + + card->dev = &pdev->dev; + platform_set_drvdata(pdev, card); + + ret = snd_soc_of_parse_card_name(card, "qcom,model"); + if (ret) { + dev_err(&pdev->dev, "parse card name failed, err:%d\n", ret); + return ret; + } + + card->dai_link = &ipq806x_machine_dai_link; + card->num_links = 1; + + ret = ipq806x_populate_dai_link_of_nodes(card); + if (ret) { + dev_err(&pdev->dev, "could not resolve dai links, err:%d\n", + ret); + return ret; + } + + ret = devm_snd_soc_register_card(&pdev->dev, card); + if (ret == -EPROBE_DEFER) { + card->dev = NULL; + return ret; + } else if (ret) { + dev_err(&pdev->dev, "snd_soc_register_card failed: %d\n", ret); + return ret; + } + + return 0; +} + +static const struct of_device_id ipq806x_machine_dt_match[] = { + { .compatible = "qcom,ipq806x-snd-card", }, + {}, +}; + +static struct platform_driver ipq806x_machine_platform_driver = { + .driver = { + .name = DRV_NAME, + .of_match_table = ipq806x_machine_dt_match, + .pm = &snd_soc_pm_ops, + }, + .probe = ipq806x_machine_platform_probe, +}; +module_platform_driver(ipq806x_machine_platform_driver); + +MODULE_DESCRIPTION("QCOM IPQ806X MACHINE DRIVER"); +MODULE_LICENSE("GPL v2"); +MODULE_ALIAS("platform:" DRV_NAME); +MODULE_DEVICE_TABLE(of, ipq806x_asoc_machine_of_match);