From patchwork Sat Nov 15 06:56:48 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Zhang X-Patchwork-Id: 5311011 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 92EEFC11AC for ; Sat, 15 Nov 2014 06:58:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 878BA201E4 for ; Sat, 15 Nov 2014 06:58:00 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 25305201C7 for ; Sat, 15 Nov 2014 06:57:59 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 127FF2605F6; Sat, 15 Nov 2014 07:57:58 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 6F523260595; Sat, 15 Nov 2014 07:57:23 +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 AE42F260593; Sat, 15 Nov 2014 07:57:20 +0100 (CET) Received: from mail-vc0-f202.google.com (mail-vc0-f202.google.com [209.85.220.202]) by alsa0.perex.cz (Postfix) with ESMTP id 58AA426058A for ; Sat, 15 Nov 2014 07:57:13 +0100 (CET) Received: by mail-vc0-f202.google.com with SMTP id hq12so368311vcb.3 for ; Fri, 14 Nov 2014 22:57:12 -0800 (PST) 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=Px8cHsZ5N+5tLNrTyiD19PoUnVNlr1hJrRpHkIY+zDs=; b=X7xnlskYp2ISIPVX3ioEUTiw/kGWbgN9tOHz5+psbkliZqRDLGH30oxuOK3Na8p2e1 Gre2fYRsTKFiMCJfGGQmHC5UtPU6tMXY1oylYWMG8hv8A0d4AohUjbXYMPY/1nJwG4Nr AakXFEFqsCMw02z/g9Z75SQovdDBsyIQm9G2+4k++4UhGbf0wTgc3AlcnGD+0otwxtOn s1dfoXvON26Qk9bvic78XLrGT8leAULd7hgJ8NsPq4wJIxv4OPdNEhP5zXjS+71koJbu brj/ix6GEPwiYdgK3TQjD9SL80XA3/Xy95z9S6auwsV0b69vYBt74pMdKz0ahFefUwB2 8LbQ== X-Gm-Message-State: ALoCoQmeXK56EWeoTrRMigUKDrhCbkUhlELL6WTBeW7zUsdmiziEVC3PkdIfH0IVM6qcCnyPKZr4tADwqLcIehhKJlIV0+IbblSF2Fqk5IeBNj2RUyYCorfhPyE6XpOQtaEMVFp7pNLudTbwdKQ/HhCD6e1GVqWPtErKUywoNuADviAVMsr2iiY= X-Received: by 10.236.216.14 with SMTP id f14mr53211131yhp.12.1416034632062; Fri, 14 Nov 2014 22:57:12 -0800 (PST) Received: from corpmail-nozzle1-2.hot.corp.google.com ([100.108.1.103]) by gmr-mx.google.com with ESMTPS id r6si1250469yhg.1.2014.11.14.22.57.11 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Nov 2014 22:57:12 -0800 (PST) Received: from benzh.mtv.corp.google.com ([172.22.65.67]) by corpmail-nozzle1-2.hot.corp.google.com with ESMTP id BDmNTtfN.1; Fri, 14 Nov 2014 22:57:11 -0800 Received: by benzh.mtv.corp.google.com (Postfix, from userid 215530) id CFA5CE09EB; Fri, 14 Nov 2014 22:57:10 -0800 (PST) From: Ben Zhang To: alsa-devel@alsa-project.org Date: Fri, 14 Nov 2014 22:56:48 -0800 Message-Id: <1416034608-24238-2-git-send-email-benzh@chromium.org> X-Mailer: git-send-email 2.1.0.rc2.206.gedb03e5 In-Reply-To: <1416034608-24238-1-git-send-email-benzh@chromium.org> References: <1416034608-24238-1-git-send-email-benzh@chromium.org> Cc: Oder Chiou , Liam Girdwood , linux-kernel@vger.kernel.org, Ben Zhang , Mark Brown , Anatol Pomozov , Bard Liao , Dylan Reid , flove@realtek.com Subject: [alsa-devel] [PATCH 2/2] ASoC: rt5677: add a platform config option for PDM clock divider 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 The PDM output clock can use a divider of 1/2/3/4 based on the system clock Signed-off-by: Ben Zhang --- Documentation/devicetree/bindings/sound/rt5677.txt | 5 +++++ include/sound/rt5677.h | 8 ++++++++ sound/soc/codecs/rt5677.c | 7 +++++++ 3 files changed, 20 insertions(+) diff --git a/Documentation/devicetree/bindings/sound/rt5677.txt b/Documentation/devicetree/bindings/sound/rt5677.txt index 740ff77..141f3e1 100644 --- a/Documentation/devicetree/bindings/sound/rt5677.txt +++ b/Documentation/devicetree/bindings/sound/rt5677.txt @@ -27,6 +27,10 @@ Optional properties: Boolean. Indicate MIC1/2 input and LOUT1/2/3 outputs are differential, rather than single-ended. +- realtek,pdm_clk_div + Select 0/1/2/3 as PDM clock divider 1/2/4/3 respectively. + PDM clock = system clock / PDM clock divider + - realtek,gpio-config Array of six 8bit elements that configures GPIO. 0 - floating (reset value) @@ -71,6 +75,7 @@ rt5677 { realtek,pow-ldo2-gpio = <&gpio TEGRA_GPIO(V, 3) GPIO_ACTIVE_HIGH>; realtek,in1-differential = "true"; + realtek,pdm_clk_div = <1> /* PDM clock = system clock / 2 */ realtek,gpio-config = /bits/ 8 <0 0 0 0 0 2>; /* pull up GPIO6 */ realtek,jd2-gpio = <3>; /* Enables Jack detection for GPIO6 */ }; diff --git a/include/sound/rt5677.h b/include/sound/rt5677.h index d9eb7d8..368aa33 100644 --- a/include/sound/rt5677.h +++ b/include/sound/rt5677.h @@ -17,6 +17,12 @@ enum rt5677_dmic2_clk { RT5677_DMIC_CLK2 = 1, }; +enum rt5677_pdm_clk_div { + RT5677_PDM_CLK_DIV1 = 0, + RT5677_PDM_CLK_DIV2 = 1, + RT5677_PDM_CLK_DIV4 = 2, + RT5677_PDM_CLK_DIV3 = 3, +}; struct rt5677_platform_data { /* IN1/IN2/LOUT1/LOUT2/LOUT3 can optionally be differential */ @@ -27,6 +33,8 @@ struct rt5677_platform_data { bool lout3_diff; /* DMIC2 clock source selection */ enum rt5677_dmic2_clk dmic2_clk_pin; + /* System clock to PDM filter divider */ + enum rt5677_pdm_clk_div pdm_clk_div; /* configures GPIO, 0 - floating, 1 - pulldown, 2 - pullup */ u8 gpio_config[6]; diff --git a/sound/soc/codecs/rt5677.c b/sound/soc/codecs/rt5677.c index 384281d..383cb61 100644 --- a/sound/soc/codecs/rt5677.c +++ b/sound/soc/codecs/rt5677.c @@ -4502,6 +4502,8 @@ static int rt5677_parse_dt(struct rt5677_priv *rt5677, struct device_node *np) "realtek,lout2-differential"); rt5677->pdata.lout3_diff = of_property_read_bool(np, "realtek,lout3-differential"); + of_property_read_u32(np, "realtek,pdm_clk_div", + &rt5677->pdata.pdm_clk_div); rt5677->pow_ldo2 = of_get_named_gpio(np, "realtek,pow-ldo2-gpio", 0); @@ -4548,6 +4550,8 @@ static void rt5677_parse_acpi(struct rt5677_priv *rt5677, struct device *dev) { rt5677->pdata.dmic2_clk_pin = (enum rt5677_dmic2_clk) rt5677_parse_acpi_entry(dev, "DCLK"); + rt5677->pdata.pdm_clk_div = (enum rt5677_pdm_clk_div) + rt5677_parse_acpi_entry(dev, "PCLK"); rt5677->pdata.in1_diff = (bool)rt5677_parse_acpi_entry(dev, "IN1"); rt5677->pdata.in2_diff = (bool)rt5677_parse_acpi_entry(dev, "IN2"); rt5677->pdata.lout1_diff = (bool)rt5677_parse_acpi_entry(dev, "OUT1"); @@ -4730,6 +4734,9 @@ static int rt5677_i2c_probe(struct i2c_client *i2c, RT5677_GPIO5_DIR_OUT); } + regmap_update_bits(rt5677->regmap, RT5677_PDM_DATA_CTRL1, + RT5677_PDM_DIV_MASK, rt5677->pdata.pdm_clk_div); + rt5677_init_gpio(i2c); rt5677_irq_init(i2c);