From patchwork Sun Dec 3 20:41:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasily Khoruzhick X-Patchwork-Id: 10089389 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BF4026035E for ; Sun, 3 Dec 2017 20:43:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C83FF28DD1 for ; Sun, 3 Dec 2017 20:43:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BCF7628DE5; Sun, 3 Dec 2017 20:43:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 47A7728DD1 for ; Sun, 3 Dec 2017 20:43:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=7tLsJpKO1x/gd4uHtpe+9KFB74BVTjtmQWjuVshXCt4=; b=Z82w7XpkDq7GfR+nNukj72JpZv jUkUK9ZE9ZVsLMHCp+jmhW4Y2PxLQNU6Ghvqe5CGfxDmsfTL1k5fG/lxg5Mhi40Pskg1Tb+TleR8L xOx4YzB5+qVlkPOS4pdfcM25Oz6ZpZ71stVeZYY2tBc7TInkeUQrANkrtaBTXoR8YNdzYBGEuZemU ogv8sH06a8rqifLYkzPcIS/wZ+DpsxeNVUKdwpQQtry8ykC2Ko48XkaM0fY5QTOMvtMoceF+3d9ki t8ZXaOKlaIwd2LCspKKy9AM+ZZ2Hhr4zcm41c6ES7XIhM/SjmejYaJXOEPppVi45EB5j28yDK9Ccc qZdXJxhg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eLb6u-0008AK-9D; Sun, 03 Dec 2017 20:43:36 +0000 Received: from mail-pg0-x242.google.com ([2607:f8b0:400e:c05::242]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eLb5m-00070G-9Y for linux-arm-kernel@lists.infradead.org; Sun, 03 Dec 2017 20:42:28 +0000 Received: by mail-pg0-x242.google.com with SMTP id q20so6753800pgv.2 for ; Sun, 03 Dec 2017 12:42:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=KBNJ1xbjBOOdmkyK00VSqJsWYWyJOBIHy7K3KSGTHCw=; b=Tngt2kOu7U0Z51rpQvqOqlPnMIB5K+heGf5xkLmgG3D3a4Pz6ctRVuMml9Gsds4lxf lq/2+ImPpqcjoK9cukMU9UKxQTg6EPEPhf0CUBOBHIRnuzjLK7gIbHtRsh65EPtJv7y2 i10eE2bmF2PnIy0OR/dt8YLGPyaBQYsDH6etj06Ax1weCAHAhO3wMowmzJI++dp45X8M rf1AH2UlSK8hhz9jHdfgknGeqb3nl711XZ1wWP0iY9BFWrHiWHJkTJxw1jBgf+2UAA9j Vjd5ZojOUGaVtF0iUEf/ImVLI6pdzDotTbDls5fBPcZDxc2Y5GsByqSwX3/7ZOdFyu6j Dh/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=KBNJ1xbjBOOdmkyK00VSqJsWYWyJOBIHy7K3KSGTHCw=; b=tiRLs/t7DkPulX0secGF2pZpzEWgya7uEbmjoFkbunQWG5RIgNrDYTC9vMTS+Uad3E mK+Jkrr6YdrMTucwqZxKVMiAcjGCb/7onO84cbB8Rt2ORh2gu3Y3gnXp8MqrFEZ+HPdI qkn9wi8NH5cOc0Au5JGIP90OBb7SoJyNfPpn8/MKhmpN/eU/NhWZ/CQeKkdiIyINbxDZ gZaldvRdGHYqKy7G/GZ8Y2pZyCPi3/EBZ4cD/KPUE92wA7VLRoL9kmoqiV1PVj0yJo9F alxPGZOFj0kuPldTVEgDV0atKIWsuiBbaS7lyR9FPDEX+sckSVJieBKoitIlFaNZYgtQ d9jQ== X-Gm-Message-State: AJaThX7ERdCEWJ59I2I/zzIEIuW0XmkG8VLikTjFSdWl8RSXCJKxGS6L keA4kepDXUWAncvKurunPYmpOXQs X-Google-Smtp-Source: AGs4zMZf8h4RaS6cGe+8tQnrbaY9VkyKTdoXAXl2NXXOPOZZHJJyAqaidv/ZaJUuXwI677auBi+SHg== X-Received: by 10.159.250.138 with SMTP id k10mr12649648pls.307.1512333725091; Sun, 03 Dec 2017 12:42:05 -0800 (PST) Received: from anarsoul-thinkpad.lan (216-71-193-140.dyn.novuscom.net. [216.71.193.140]) by smtp.gmail.com with ESMTPSA id z25sm19264929pfe.121.2017.12.03.12.42.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 03 Dec 2017 12:42:04 -0800 (PST) From: Vasily Khoruzhick To: Liam Girdwood , Mark Brown , Maxime Ripard , Chen-Yu Tsai , Marcus Cooper , =?UTF-8?q?Myl=C3=A8ne=20Josserand?= , alsa-devel@alsa-project.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 3/9] ASoC: sun8i-codec: Add quirk to specify aif1_lrck_div value Date: Sun, 3 Dec 2017 12:41:51 -0800 Message-Id: <20171203204157.20829-4-anarsoul@gmail.com> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20171203204157.20829-1-anarsoul@gmail.com> References: <20171203204157.20829-1-anarsoul@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171203_124226_361245_B4AE44BF X-CRM114-Status: GOOD ( 13.36 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vasily Khoruzhick MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP LRCK divider for A64 differs from A33, so add a quirk to support that. Signed-off-by: Vasily Khoruzhick --- sound/soc/sunxi/sun8i-codec.c | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/sound/soc/sunxi/sun8i-codec.c b/sound/soc/sunxi/sun8i-codec.c index 3dd183be08a4..054201d1de03 100644 --- a/sound/soc/sunxi/sun8i-codec.c +++ b/sound/soc/sunxi/sun8i-codec.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -75,11 +76,22 @@ #define SUN8I_AIF1CLK_CTRL_AIF1_LRCK_DIV_MASK GENMASK(8, 6) #define SUN8I_AIF1CLK_CTRL_AIF1_BCLK_DIV_MASK GENMASK(12, 9) +/* + * struct sun8i_codec_quirks - Differences between SoC variants. + * + * @aif1_lrck_div: LRCK divider + */ +struct sun8i_codec_quirks { + unsigned int aif1_lrck_div; +}; + + struct sun8i_codec { - struct device *dev; - struct regmap *regmap; - struct clk *clk_module; - struct clk *clk_bus; + struct device *dev; + struct regmap *regmap; + struct clk *clk_module; + struct clk *clk_bus; + const struct sun8i_codec_quirks *variant; }; static int sun8i_codec_runtime_resume(struct device *dev) @@ -305,7 +317,7 @@ static int sun8i_codec_hw_params(struct snd_pcm_substream *substream, regmap_update_bits(scodec->regmap, SUN8I_AIF1CLK_CTRL, SUN8I_AIF1CLK_CTRL_AIF1_LRCK_DIV_MASK, - SUN8I_AIF1CLK_CTRL_AIF1_LRCK_DIV_16); + scodec->variant->aif1_lrck_div); sample_rate = sun8i_codec_get_hw_rate(params); if (sample_rate < 0) @@ -440,6 +452,10 @@ static const struct regmap_config sun8i_codec_regmap_config = { .cache_type = REGCACHE_FLAT, }; +static const struct sun8i_codec_quirks sun8i_a33_codec_quirks = { + .aif1_lrck_div = SUN8I_AIF1CLK_CTRL_AIF1_LRCK_DIV_16, +}; + static int sun8i_codec_probe(struct platform_device *pdev) { struct resource *res_base; @@ -453,6 +469,13 @@ static int sun8i_codec_probe(struct platform_device *pdev) scodec->dev = &pdev->dev; + scodec->variant = of_device_get_match_data(&pdev->dev); + if (!scodec->variant) { + dev_err(&pdev->dev, "Failed to determine the quirks to use\n"); + return -ENODEV; + } + + scodec->clk_module = devm_clk_get(&pdev->dev, "mod"); if (IS_ERR(scodec->clk_module)) { dev_err(&pdev->dev, "Failed to get the module clock\n"); @@ -524,7 +547,10 @@ static int sun8i_codec_remove(struct platform_device *pdev) } static const struct of_device_id sun8i_codec_of_match[] = { - { .compatible = "allwinner,sun8i-a33-codec" }, + { + .compatible = "allwinner,sun8i-a33-codec", + .data = &sun8i_a33_codec_quirks, + }, {} }; MODULE_DEVICE_TABLE(of, sun8i_codec_of_match);