From patchwork Thu Apr 30 17:18:07 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 47870 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 91A7520553 for ; Thu, 30 Apr 2015 17:18:27 +0000 (UTC) Received: by layy10 with SMTP id y10sf17750294lay.0 for ; Thu, 30 Apr 2015 10:18:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=e3HsNw7mB7v+l12hH2qjALaovg6b/YId0NSdOx/6GTM=; b=IxhqkFpgSjQfY5tE00m7JO9+C2Y5odEto2eDmACzrFU6K9NpblCfF0hPoGVSnaJ3K7 MccGTCpRTKLPH6mfUJafU/wXEaKnCNq02hWzjYf+VIzbPIHsbiuuxPGO8AVuCrEqJk2R 4KzzRsKr2VlkDSEXo8oSKKq6uGK0pejrAYC2gDdV1Ba58Q1v5v73v/gu8QYGJwreb3K0 Myb4qZ+/yXP2DyZ73btI0nyfeyeEUxD/zFT3+7270LBA9NWqnUkWN087jPSOxdTsKuMT 9dvM5IuLNScGrjc4S63NrPSNOLimywNO0O3krSgH2Gq/L9vWQuN871SXNMB5HYem0SOW 3PjA== X-Gm-Message-State: ALoCoQlXFVerqTIq0Q4AbpVHgZ2iiWoQWXmcxG4cRBKnIiE6rIyVDfvXGVehsKJ+zyoEQycc0Z8L X-Received: by 10.152.8.17 with SMTP id n17mr3136267laa.0.1430414306595; Thu, 30 Apr 2015 10:18:26 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.43.129 with SMTP id w1ls490970lal.32.gmail; Thu, 30 Apr 2015 10:18:26 -0700 (PDT) X-Received: by 10.152.23.105 with SMTP id l9mr4825459laf.26.1430414306418; Thu, 30 Apr 2015 10:18:26 -0700 (PDT) Received: from mail-la0-f54.google.com (mail-la0-f54.google.com. [209.85.215.54]) by mx.google.com with ESMTPS id l5si2205518lbt.73.2015.04.30.10.18.26 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Apr 2015 10:18:26 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.54 as permitted sender) client-ip=209.85.215.54; Received: by lagv1 with SMTP id v1so49419691lag.3 for ; Thu, 30 Apr 2015 10:18:26 -0700 (PDT) X-Received: by 10.152.4.72 with SMTP id i8mr4994407lai.32.1430414305980; Thu, 30 Apr 2015 10:18:25 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.67.65 with SMTP id l1csp3243131lbt; Thu, 30 Apr 2015 10:18:24 -0700 (PDT) X-Received: by 10.70.129.106 with SMTP id nv10mr10357964pdb.160.1430414300189; Thu, 30 Apr 2015 10:18:20 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ot1si4337971pab.207.2015.04.30.10.18.19; Thu, 30 Apr 2015 10:18:20 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752684AbbD3RSR (ORCPT + 28 others); Thu, 30 Apr 2015 13:18:17 -0400 Received: from mail-wi0-f171.google.com ([209.85.212.171]:37402 "EHLO mail-wi0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752665AbbD3RSM (ORCPT ); Thu, 30 Apr 2015 13:18:12 -0400 Received: by widdi4 with SMTP id di4so25874890wid.0 for ; Thu, 30 Apr 2015 10:18:11 -0700 (PDT) X-Received: by 10.180.91.107 with SMTP id cd11mr7118223wib.51.1430414290928; Thu, 30 Apr 2015 10:18:10 -0700 (PDT) Received: from srini-ThinkPad-X1-Carbon-2nd.dlink.com (host-2-98-219-188.as13285.net. [2.98.219.188]) by mx.google.com with ESMTPSA id b1sm4163335wjs.17.2015.04.30.10.18.09 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 30 Apr 2015 10:18:10 -0700 (PDT) From: Srinivas Kandagatla To: Patrick Lai , Mark Brown Cc: Rob Herring , Pawel Moll , Ian Campbell , Kumar Gala , Banajit Goswami , Kenneth Westfield , Liam Girdwood , Jaroslav Kysela , Takashi Iwai , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, linux-arm-msm@vger.kernel.org, Srinivas Kandagatla Subject: [RFC PATCH 12/14] ASoC: qcom: add apq8016 sound card support Date: Thu, 30 Apr 2015 18:18:07 +0100 Message-Id: <1430414287-11384-1-git-send-email-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1430414148-10869-1-git-send-email-srinivas.kandagatla@linaro.org> References: <1430414148-10869-1-git-send-email-srinivas.kandagatla@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: srinivas.kandagatla@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.54 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , This patch adds apq8016 machine driver support. This patch was tested on two apq8016-sbc and msm8916-mtp board for both hdmi and analog audio features. Signed-off-by: Srinivas Kandagatla --- sound/soc/qcom/Kconfig | 9 ++ sound/soc/qcom/Makefile | 1 + sound/soc/qcom/apq8016.c | 214 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 224 insertions(+) create mode 100644 sound/soc/qcom/apq8016.c diff --git a/sound/soc/qcom/Kconfig b/sound/soc/qcom/Kconfig index 2a06d1e..7227383 100644 --- a/sound/soc/qcom/Kconfig +++ b/sound/soc/qcom/Kconfig @@ -35,3 +35,12 @@ config SND_SOC_STORM help Say Y or M if you want add support for SoC audio on the Qualcomm Technologies IPQ806X-based Storm board. + +config SND_SOC_APQ8016 + tristate "SoC Audio support for APQ8016 based platforms" + depends on SND_SOC_QCOM || ARCH_QCOM || COMPILE_TEST + select SND_SOC_LPASS_APQ8016 + help + Support for Qualcomm Technologies LPASS audio block in + APQ8016 SOC-based systems. + Say Y if you want to use audio devices on MI2S diff --git a/sound/soc/qcom/Makefile b/sound/soc/qcom/Makefile index ac76308..589ee9b 100644 --- a/sound/soc/qcom/Makefile +++ b/sound/soc/qcom/Makefile @@ -13,3 +13,4 @@ obj-$(CONFIG_SND_SOC_LPASS_APQ8016) += snd-soc-lpass-apq8016.o snd-soc-storm-objs := storm.o obj-$(CONFIG_SND_SOC_STORM) += snd-soc-storm.o +obj-$(CONFIG_SND_SOC_APQ8016) += apq8016.o diff --git a/sound/soc/qcom/apq8016.c b/sound/soc/qcom/apq8016.c new file mode 100644 index 0000000..cfb6930 --- /dev/null +++ b/sound/soc/qcom/apq8016.c @@ -0,0 +1,214 @@ +/* + * Copyright (c) 2015 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 +#include +#include +#include +#include +#include +#include +#include +#include + +struct apq8016_card_data { + void __iomem *mic_iomux; + void __iomem *spkr_iomux; + struct snd_soc_dai_link dai_link[]; /* dynamically allocated */ +}; + +#define MIC_CTRL_QUA_WS_SLAVE_SEL_10 BIT(17) +#define MIC_CTRL_TLMM_SCLK_EN BIT(1) +#define SPKR_CTL_PRI_WS_SLAVE_SEL_11 (BIT(17) | BIT(16)) + +static int msm_ext_mi2s_snd_startup(struct snd_pcm_substream *substream) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_card *card = rtd->card; + struct apq8016_card_data *pdata = snd_soc_card_get_drvdata(card); + + /* Configure the Quat MI2S to TLMM */ + writel(readl(pdata->mic_iomux) | + MIC_CTRL_QUA_WS_SLAVE_SEL_10 | + MIC_CTRL_TLMM_SCLK_EN, + pdata->mic_iomux); + + return 0; +} + +static int msm_int_mi2s_snd_startup(struct snd_pcm_substream *substream) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_card *card = rtd->card; + struct apq8016_card_data *pdata = snd_soc_card_get_drvdata(card); + + writel(readl(pdata->spkr_iomux) | SPKR_CTL_PRI_WS_SLAVE_SEL_11, + pdata->spkr_iomux); + + return 0; +} +static struct snd_soc_ops qcom_internal_codec_soc_ops = { + .startup = msm_int_mi2s_snd_startup, +}; + +static struct snd_soc_ops qcom_external_codec_soc_ops = { + .startup = msm_ext_mi2s_snd_startup, +}; + +static struct snd_soc_card qcom_soc_card = { + .name = "apq8016", +}; + +static struct apq8016_card_data *qcom_parse_of(struct snd_soc_card *card) +{ + int num_links; + struct device *dev = card->dev; + struct snd_soc_dai_link *dai_link; + struct device_node *np, *codec, *cpu, *node = dev->of_node; + struct apq8016_card_data *data; + char *name; + int ret; + + /* Populate links */ + num_links = of_get_child_count(node); + + /* Allocate the private data and the DAI link array */ + data = devm_kzalloc(dev, sizeof(*data) + sizeof(*dai_link) * num_links, + GFP_KERNEL); + if (!data) + return ERR_PTR(-ENOMEM); + + card->dai_link = &data->dai_link[0]; + card->num_links = num_links; + + dai_link = data->dai_link; + + for_each_child_of_node(node, np) { + cpu = of_get_child_by_name(np, "cpu"); + codec = of_get_child_by_name(np, "codec"); + + if (!cpu || !codec) { + dev_err(dev, "Can't find cpu/codec DT node\n"); + return ERR_PTR(-EINVAL); + } + + dai_link->cpu_of_node = of_parse_phandle(cpu, "sound-dai", 0); + if (!dai_link->cpu_of_node) { + dev_err(card->dev, "error getting cpu phandle\n"); + return ERR_PTR(-EINVAL); + } + + dai_link->codec_of_node = of_parse_phandle(codec, + "sound-dai", + 0); + if (!dai_link->codec_of_node) { + dev_err(card->dev, "error getting codec phandle\n"); + return ERR_PTR(-EINVAL); + } + + ret = snd_soc_of_get_dai_name(cpu, &dai_link->cpu_dai_name); + if (ret) + return ERR_PTR(ret); + + ret = snd_soc_of_get_dai_name(codec, &dai_link->codec_dai_name); + if (ret) + return ERR_PTR(ret); + + dai_link->platform_of_node = dai_link->cpu_of_node; + /* For now we only support playback */ + dai_link->playback_only = true; + + if (of_property_read_bool(np, "external")) { + name = "HDMI"; + dai_link->ops = &qcom_external_codec_soc_ops; + + } else { + name = "Headset"; + dai_link->ops = &qcom_internal_codec_soc_ops; + } + + dai_link->name = dai_link->stream_name = name; + + dai_link++; + } + + return data; +} + +static int qcom_platform_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct snd_soc_card *card = &qcom_soc_card; + struct apq8016_card_data *data; + struct resource *res; + int ret; + + card->dev = dev; + data = qcom_parse_of(card); + if (PTR_ERR(data)) { + dev_err(&pdev->dev, "Error resolving dai links: %d\n", + PTR_ERR(data)); + return PTR_ERR(data); + } + + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mic-iomux"); + data->mic_iomux = devm_ioremap_resource(dev, res); + if (IS_ERR(data->mic_iomux)) + return PTR_ERR(data->mic_iomux); + + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "spkr-iomux"); + data->spkr_iomux = devm_ioremap_resource(dev, res); + if (IS_ERR(data->spkr_iomux)) + return PTR_ERR(data->spkr_iomux); + + platform_set_drvdata(pdev, data); + snd_soc_card_set_drvdata(card, data); + + ret = snd_soc_of_parse_card_name(card, "qcom,model"); + if (ret) { + dev_err(&pdev->dev, "Error parsing card name: %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, "Error registering soundcard: %d\n", ret); + return ret; + } + + return 0; +} + +static const struct of_device_id qcom_device_id[] = { + { .compatible = "qcom,apq8016-sndcard" }, + {}, +}; +MODULE_DEVICE_TABLE(of, qcom_device_id); + +static struct platform_driver qcom_platform_driver = { + .driver = { + .name = "qcom-apq8016", + .of_match_table = of_match_ptr(qcom_device_id), + }, + .probe = qcom_platform_probe, +}; +module_platform_driver(qcom_platform_driver); + +MODULE_AUTHOR("Srinivas Kandagatla