From patchwork Tue Feb 16 17:32:41 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 8329841 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id BAB7DC02AA for ; Tue, 16 Feb 2016 17:33:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B592020260 for ; Tue, 16 Feb 2016 17:33:56 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 654F5202AE for ; Tue, 16 Feb 2016 17:33:55 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 8402126661E; Tue, 16 Feb 2016 18:33:54 +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.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_NONE, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 604362657C2; Tue, 16 Feb 2016 18:33:06 +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 4C9D1265960; Tue, 16 Feb 2016 18:33:05 +0100 (CET) Received: from mail-wm0-f52.google.com (mail-wm0-f52.google.com [74.125.82.52]) by alsa0.perex.cz (Postfix) with ESMTP id F19C32610B0 for ; Tue, 16 Feb 2016 18:32:44 +0100 (CET) Received: by mail-wm0-f52.google.com with SMTP id g62so119721621wme.1 for ; Tue, 16 Feb 2016 09:32:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=AkW9ZZjzlZTuDPpf+QmHoN0+CPhPzQSdFaorz/y8omw=; b=eRJ1Yg71fc7PHo+JkFzaJsmI/zq6MqOMYPCYJvf86IWTt5LfSY49yBIjdp2J2qkxIB fiPVfbqBytebqrOuFaEhVXjqn/kmBrUmdhmX9ORpgpYe94IZkZHTC9Ut9IA/RD9jIJJa Rti1IkRibIz136BwBGFG/qo3l1KldlfZaGA0w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=AkW9ZZjzlZTuDPpf+QmHoN0+CPhPzQSdFaorz/y8omw=; b=fTRfkhRqpBlvrKq0xfvUBqLxtwWnqv8QXt9HRUxcW0IqRR5UKWXkkA0l0Z1mGzihJn VGCWQJEs/NN9aNll1dolUECD2YSKpp72HyMRN23VTr/DTkea7qXD6086qQRpKhguu73p 2QzxGusq7yPOjOQvugonCOY37UGzgMNZAb4zQSaNSn5Q5Xx0KeHrv6iEEexMK6I/Gazo MKZV24Pf8xnUS/LxjSj/m1dFdsMAjBufnGkXUm2kq6DmtZwCPJCl0vaDGfzLhFxfg9dV pTUHS8P913LlAgdKB06dmW3zi5HyLb9ka8huPZW9YjYdGspFJmBOP2BUnpO+GLfST3T8 y0wg== X-Gm-Message-State: AG10YOSHJ4fLP5mIrzbzxV7PWORUyTfkm5eY/k/eHcOlx9J+y2R+yzFGq5SClhjOaL1dXaQ7 X-Received: by 10.28.51.74 with SMTP id z71mr19618010wmz.15.1455643964708; Tue, 16 Feb 2016 09:32:44 -0800 (PST) Received: from localhost.localdomain (host-92-17-247-99.as13285.net. [92.17.247.99]) by smtp.gmail.com with ESMTPSA id t8sm29857181wjy.41.2016.02.16.09.32.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 16 Feb 2016 09:32:44 -0800 (PST) From: Srinivas Kandagatla To: alsa-devel@alsa-project.org, Mark Brown Date: Tue, 16 Feb 2016 17:32:41 +0000 Message-Id: <1455643961-1700-1-git-send-email-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1455643880-1611-1-git-send-email-srinivas.kandagatla@linaro.org> References: <1455643880-1611-1-git-send-email-srinivas.kandagatla@linaro.org> Cc: Mark Rutland , kwestfie@codeaurora.org, Pawel Moll , linux-kernel@vger.kernel.org, Patrick Lai , Takashi Iwai , Liam Girdwood , Rob Herring , Srinivas Kandagatla , linux-arm-msm@vger.kernel.org Subject: [alsa-devel] [RFC v1 2/9] ASoC: msm8x16: add driver structure 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 This patch adds device driver structure for msm8x16 codec. Signed-off-by: Srinivas Kandagatla --- sound/soc/codecs/Kconfig | 4 ++ sound/soc/codecs/Makefile | 3 +- sound/soc/codecs/msm8x16-wcd.c | 152 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 158 insertions(+), 1 deletion(-) create mode 100644 sound/soc/codecs/msm8x16-wcd.c diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index 62b62fe..2611d3f 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -528,6 +528,10 @@ config SND_SOC_MAX98925 config SND_SOC_MAX9850 tristate +config SND_SOC_MSM8x16_WCD + tristate "Qualcomm MSM8x16 WCD" + depends on SPMI && MFD_SYSCON + config SND_SOC_PCM1681 tristate "Texas Instruments PCM1681 CODEC" depends on I2C diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index 5f7b002..40ffae7 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile @@ -78,6 +78,7 @@ snd-soc-max98925-objs := max98925.o snd-soc-max9850-objs := max9850.o snd-soc-mc13783-objs := mc13783.o snd-soc-ml26124-objs := ml26124.o +snd-soc-msm8x16-objs := msm8x16-wcd.o snd-soc-nau8825-objs := nau8825.o snd-soc-hdmi-codec-objs := hdmi-codec.o snd-soc-pcm1681-objs := pcm1681.o @@ -195,7 +196,6 @@ snd-soc-wm9705-objs := wm9705.o snd-soc-wm9712-objs := wm9712.o snd-soc-wm9713-objs := wm9713.o snd-soc-wm-hubs-objs := wm_hubs.o - # Amp snd-soc-max9877-objs := max9877.o snd-soc-tpa6130a2-objs := tpa6130a2.o @@ -283,6 +283,7 @@ obj-$(CONFIG_SND_SOC_MAX98925) += snd-soc-max98925.o obj-$(CONFIG_SND_SOC_MAX9850) += snd-soc-max9850.o obj-$(CONFIG_SND_SOC_MC13783) += snd-soc-mc13783.o obj-$(CONFIG_SND_SOC_ML26124) += snd-soc-ml26124.o +obj-$(CONFIG_SND_SOC_MSM8x16_WCD) +=snd-soc-msm8x16.o obj-$(CONFIG_SND_SOC_NAU8825) += snd-soc-nau8825.o obj-$(CONFIG_SND_SOC_HDMI_CODEC) += snd-soc-hdmi-codec.o obj-$(CONFIG_SND_SOC_PCM1681) += snd-soc-pcm1681.o diff --git a/sound/soc/codecs/msm8x16-wcd.c b/sound/soc/codecs/msm8x16-wcd.c new file mode 100644 index 0000000..99217ab --- /dev/null +++ b/sound/soc/codecs/msm8x16-wcd.c @@ -0,0 +1,152 @@ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct msm8x16_wcd_chip { + struct regmap *analog_map; + struct regmap *digital_map; + unsigned int analog_base; + u16 pmic_rev; + u16 codec_version; + + struct clk *mclk; + struct regulator *vddio; + struct regulator *vdd_cp; + struct regulator *vdd_hph; + struct regulator *vdd_tx_rx; + struct regulator *vdd_micbias; + + u32 mute_mask; + u32 rx_bias_count; + bool spk_boost_set; + bool ear_pa_boost_set; + bool micbias1_cap_mode; + bool micbias2_cap_mode; +}; + + +static int msm8x16_wcd_codec_parse_dt(struct platform_device *pdev, + struct msm8x16_wcd_chip *chip) +{ + struct device *dev = &pdev->dev; + struct device_node *np = dev->of_node; + int ret; + struct regulator_bulk_data regs[5]; + const char *ext1_cap = "qcom,micbias1-ext-cap"; + const char *ext2_cap = "qcom,micbias2-ext-cap"; + + u32 res[2]; + + ret = of_property_read_u32_array(np, "reg", res, 2); + if (ret < 0) + return ret; + + + chip->micbias1_cap_mode = + (of_property_read_bool(pdev->dev.of_node, ext1_cap) ? + MICBIAS_EXT_BYP_CAP : MICBIAS_NO_EXT_BYP_CAP); + + chip->micbias2_cap_mode = + (of_property_read_bool(pdev->dev.of_node, ext2_cap) ? + MICBIAS_EXT_BYP_CAP : MICBIAS_NO_EXT_BYP_CAP); + + chip->analog_base = res[0]; + + chip->digital_map = syscon_regmap_lookup_by_phandle(np, + "qcom,lpass-codec-core"); + if (IS_ERR(chip->digital_map)) + return PTR_ERR(chip->digital_map); + + chip->mclk = devm_clk_get(dev, "mclk"); + if (IS_ERR(chip->mclk)) { + dev_err(dev, "failed to get mclk\n"); + return PTR_ERR(chip->mclk); + } + + regs[0].supply = "vddio"; + regs[1].supply = "vdd-cp"; + regs[2].supply = "vdd-hph"; + regs[3].supply = "vdd-tx-rx"; + regs[4].supply = "vdd-micbias"; + + ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(regs), regs); + if (ret) { + dev_err(dev, "Failed to get regulator supplies %d\n", ret); + return ret; + } + chip->vddio = regs[0].consumer; + chip->vdd_cp = regs[1].consumer; + chip->vdd_hph = regs[2].consumer; + chip->vdd_tx_rx = regs[3].consumer; + chip->vdd_micbias = regs[4].consumer; + + return 0; +} + +static struct snd_soc_dai_driver msm8x16_wcd_codec_dai[] = { +}; + +static struct snd_soc_codec_driver msm8x16_wcd_codec = { +}; + +static int msm8x16_wcd_probe(struct platform_device *pdev) +{ + struct msm8x16_wcd_chip *chip; + struct device *dev = &pdev->dev; + int ret; + + chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL); + if (!chip) + return -ENOMEM; + + chip->analog_map = dev_get_regmap(dev->parent, NULL); + if (!chip->analog_map) + return -ENXIO; + + ret = msm8x16_wcd_codec_parse_dt(pdev, chip); + if (IS_ERR_VALUE(ret)) + return ret; + + clk_prepare_enable(chip->mclk); + + dev_set_drvdata(dev, chip); + + return snd_soc_register_codec(dev, &msm8x16_wcd_codec, + msm8x16_wcd_codec_dai, + ARRAY_SIZE(msm8x16_wcd_codec_dai)); +} + +static int msm8x16_wcd_remove(struct platform_device *pdev) +{ + snd_soc_unregister_codec(&pdev->dev); + return 0; +} + +static const struct of_device_id msm8x16_wcd_match_table[] = { + { .compatible = "qcom,msm8x16-wcd-codec" }, + { } +}; +MODULE_DEVICE_TABLE(of, msm8x16_wcd_match_table); + +static struct platform_driver msm8x16_wcd_driver = { + .driver = { + .name = "msm8x16-wcd-codec", + .of_match_table = msm8x16_wcd_match_table, + }, + .probe = msm8x16_wcd_probe, + .remove = msm8x16_wcd_remove, +}; +module_platform_driver(msm8x16_wcd_driver); + +MODULE_ALIAS("platform:spmi-wcd-codec"); +MODULE_DESCRIPTION("SPMI PMIC WCD codec driver"); +MODULE_LICENSE("GPL v2");