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: 5459101 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id F18EABEEA8 for ; Mon, 8 Dec 2014 22:05:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0A0F520160 for ; Mon, 8 Dec 2014 22:05:56 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id DB93620155 for ; Mon, 8 Dec 2014 22:05:50 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 020DF26524F; Mon, 8 Dec 2014 23:05:49 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 78C2F26056A; Mon, 8 Dec 2014 23:02:29 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id C7039260606; Mon, 8 Dec 2014 23:02:28 +0100 (CET) Received: from smtp.codeaurora.org (smtp.codeaurora.org [198.145.11.231]) by alsa0.perex.cz (Postfix) with ESMTP id 65F4A26056A for ; Mon, 8 Dec 2014 23:01:57 +0100 (CET) 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) 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 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 Cc: Device Tree Mailing List , ALSA Mailing List , Kenneth Westfield , MSM Mailing List Subject: [alsa-devel] [Patch v2 07/11] ASoC: ipq806x: Add machine driver for IPQ806X SOC X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.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);