From patchwork Tue Nov 1 06:11:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tinghan Shen X-Patchwork-Id: 13026667 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CA2AFC433FE for ; Tue, 1 Nov 2022 06:13:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=584Cfo4+yVgj09e1fMXGvDvb71O7dgEutdgi6HIO04A=; b=aUX+qQgpSztrlU cL5zxksxscRPvDGVwRA1bkrWE0tyqC1/4QbpYfi+GjLWtH+PEWFweUqKHozkAyxHE3/xzE2uB8EOQ JnFUUyySxGpuMKU0v/O2b9j9lmJ4yfJwDSKMxNWwb7h7crpk5GvJAI0jy5YZiP91r71mY2j0Sq/HU THKCjhzAfyaCk3vX7NowqTNJHctMFEEwpx9IrxhScjBmMi8mgLwELw6qtLdzp0VXKoh2mxI6i1a3m SIF9REVFKyObfnvyUn6/UAbuGFjJxGMrql6UxsXvPM3eTJmACGviHkRV1EKMbj9+PlFCrW7Kcy271 QE3F9Ovl+9eSqkBAY36A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1opkVW-002O0q-RH; Tue, 01 Nov 2022 06:12:18 +0000 Received: from mailgw01.mediatek.com ([216.200.240.184]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1opkVT-002O00-Fl; Tue, 01 Nov 2022 06:12:16 +0000 X-UUID: 8a2466c994c5412dbf37b08987575b91-20221031 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=kA5JNRTKDV1dAItHbDmK5oovg/tPz2PC0c+hpfEzm2c=; b=sCWJbizksz+qi5+bJn5rAGUPje8tRQ9RHy4Cytoaqy3AccI7HU02K8QBYYRp3UgxBmlyNR+fyXdzNnOXloSM3wPqMQAczE4hnGy9++i1l0wwc5ePChFDLF12/5F3/ApTwaRjKC7NkbAB6RDhbtVI1PMOyuYnUWARxjEpZaJbkIk=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.12,REQID:08191369-11b3-4016-9790-a4a0714709da,IP:0,U RL:0,TC:0,Content:-5,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION :release,TS:-5 X-CID-META: VersionHash:62cd327,CLOUDID:0c743e81-3116-4fbc-b86b-83475c3df513,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0 X-UUID: 8a2466c994c5412dbf37b08987575b91-20221031 Received: from mtkmbs11n2.mediatek.inc [(172.21.101.187)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 440183185; Mon, 31 Oct 2022 23:12:13 -0700 Received: from mtkmbs13n2.mediatek.inc (172.21.101.108) by mtkmbs11n2.mediatek.inc (172.21.101.187) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.15; Tue, 1 Nov 2022 14:11:39 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs13n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.15 via Frontend Transport; Tue, 1 Nov 2022 14:11:39 +0800 From: Tinghan Shen To: Rob Herring , Krzysztof Kozlowski , Matthias Brugger , Pierre-Louis Bossart , Liam Girdwood , Peter Ujfalusi , Bard Liao , Ranjani Sridharan , Kai Vehmanen , Daniel Baluta , Mark Brown , Jaroslav Kysela , Takashi Iwai , Tinghan Shen , Yaochun Hung CC: , , , , , , Subject: [PATCH v1 1/2] dt-bindings: dsp: mediatek: Add default clock sources for mt8186 dsp Date: Tue, 1 Nov 2022 14:11:36 +0800 Message-ID: <20221101061137.25731-2-tinghan.shen@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20221101061137.25731-1-tinghan.shen@mediatek.com> References: <20221101061137.25731-1-tinghan.shen@mediatek.com> MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221031_231215_549955_7183740C X-CRM114-Status: GOOD ( 10.92 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add the default clock sources used by mt8186 dsp. Signed-off-by: Tinghan Shen --- .../devicetree/bindings/dsp/mediatek,mt8186-dsp.yaml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/dsp/mediatek,mt8186-dsp.yaml b/Documentation/devicetree/bindings/dsp/mediatek,mt8186-dsp.yaml index 3e63f79890b4..4cc0634c876b 100644 --- a/Documentation/devicetree/bindings/dsp/mediatek,mt8186-dsp.yaml +++ b/Documentation/devicetree/bindings/dsp/mediatek,mt8186-dsp.yaml @@ -35,11 +35,15 @@ properties: items: - description: mux for audio dsp clock - description: mux for audio dsp local bus + - description: default clock source for dsp local bus + - description: default clock source for dsp core clock-names: items: - const: audiodsp - const: adsp_bus + - const: mainpll_d2_d2 + - const: clk26m power-domains: maxItems: 1 @@ -82,9 +86,11 @@ examples: <0x1068f000 0x1000>; reg-names = "cfg", "sram", "sec", "bus"; clocks = <&topckgen CLK_TOP_AUDIODSP>, - <&topckgen CLK_TOP_ADSP_BUS>; - clock-names = "audiodsp", - "adsp_bus"; + <&topckgen CLK_TOP_ADSP_BUS>, + <&topckgen CLK_TOP_MAINPLL_D2_D2>, + <&clk26m>; + clock-names = "audiodsp", "adsp_bus", + "mainpll_d2_d2", "clk26m"; power-domains = <&spm 6>; mbox-names = "rx", "tx"; mboxes = <&adsp_mailbox0>, <&adsp_mailbox1>; From patchwork Tue Nov 1 06:11:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tinghan Shen X-Patchwork-Id: 13026676 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 18C63C433FE for ; Tue, 1 Nov 2022 06:22:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=iv5BF0GbX7EQxI90ZcypelQJlTlkrM8P0l+oX7Fz+VU=; b=crzBCSwCjTxrwQ DT71vpc09xITz7cIm6faOIMkHDjGw8+oBQeKvGqajeNtVnbXJDA2L5hq1HZPQ1jyy70pwjHQcSh5O Ozr/DJQWlLfaYOXWimLD6c3MaXF5eRbuhdr67/xvfHDT5F/OCEW06tQRk78TbQN1ZMcUsJoHYzR8S 91tD5hWga0oiTQGIMKNtTHo9lSkyDL9gaECOHl03SeHe4DEPuNJF20EfO9A3GCyzJtNf0FZCxUUD0 SaS2pBkAAcSzm0mJVrZmRDMjHazw/A7tPJGKl5pRQYyodOBxhv3F93h35vPK3nPUeTktfdmSI6V07 1V/VdSiPf2zc4O7dBEgA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1opkek-002P2a-6i; Tue, 01 Nov 2022 06:21:50 +0000 Received: from mailgw01.mediatek.com ([216.200.240.184]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1opkeg-002P1a-Ui; Tue, 01 Nov 2022 06:21:48 +0000 X-UUID: 365ecabf187e429e81787c62b2504301-20221031 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=qKVQ5xUvwJLnVjPZU5c5Gw7oruotfGjxaq+qal/96R4=; b=GuUVMsDwkmDD7i5cWGFB/69htQfxwCVbR0tMncQU5xKaAHKhq6yFOuc7pscmKfUXtFN5G2HBslg3Cv/T8sS5Krjj1ZCyWPuyKXid8lWw7xrsZImXvY059WXCroPJEKpYYCk0Eo82McZrAq1WHYyDu0C3ejglmq7rv3eEPvNsTSY=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.12,REQID:eb488bdd-b2c4-46f6-bfed-8bd2cee1b305,IP:0,U RL:0,TC:0,Content:-25,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:-25 X-CID-META: VersionHash:62cd327,CLOUDID:70993590-1a78-4832-bd08-74b1519dcfbf,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0 X-UUID: 365ecabf187e429e81787c62b2504301-20221031 Received: from mtkmbs11n1.mediatek.inc [(172.21.101.185)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 49598375; Mon, 31 Oct 2022 23:21:42 -0700 Received: from mtkmbs13n2.mediatek.inc (172.21.101.108) by mtkmbs13n1.mediatek.inc (172.21.101.193) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.15; Tue, 1 Nov 2022 14:11:39 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs13n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.15 via Frontend Transport; Tue, 1 Nov 2022 14:11:39 +0800 From: Tinghan Shen To: Rob Herring , Krzysztof Kozlowski , Matthias Brugger , Pierre-Louis Bossart , Liam Girdwood , Peter Ujfalusi , Bard Liao , Ranjani Sridharan , Kai Vehmanen , Daniel Baluta , Mark Brown , Jaroslav Kysela , Takashi Iwai , Tinghan Shen , Yaochun Hung CC: , , , , , , Subject: [PATCH v1 2/2] ASoC: SOF: mediatek: Revise mt8186 ADSP clock driver Date: Tue, 1 Nov 2022 14:11:37 +0800 Message-ID: <20221101061137.25731-3-tinghan.shen@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20221101061137.25731-1-tinghan.shen@mediatek.com> References: <20221101061137.25731-1-tinghan.shen@mediatek.com> MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221031_232147_006021_583D3908 X-CRM114-Status: GOOD ( 13.97 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Initialize the required clocks for mt8186 ADSP. The ADSP core is expected booting with 26M clock, and using the mainpll_d2_d2 clock for ADSP bus. The enable/disable order of clocks is also revised. The clock should be enabled as mainpll_d2_d2 -> adsp bus -> adsp, and disabled in the reversed order. Fixes: 210b3ab932f7 ("ASoC: SOF: mediatek: Add mt8186 dsp clock support") Signed-off-by: Tinghan Shen --- sound/soc/sof/mediatek/mt8186/mt8186-clk.c | 35 +++++++++++++++++----- sound/soc/sof/mediatek/mt8186/mt8186-clk.h | 2 ++ 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/sound/soc/sof/mediatek/mt8186/mt8186-clk.c b/sound/soc/sof/mediatek/mt8186/mt8186-clk.c index 2df3b7ae1c6f..c86391aa7948 100644 --- a/sound/soc/sof/mediatek/mt8186/mt8186-clk.c +++ b/sound/soc/sof/mediatek/mt8186/mt8186-clk.c @@ -20,6 +20,8 @@ static const char *adsp_clks[ADSP_CLK_MAX] = { [CLK_TOP_AUDIODSP] = "audiodsp", [CLK_TOP_ADSP_BUS] = "adsp_bus", + [CLK_TOP_MAINPLL_D2_D2] = "mainpll_d2_d2", + [CLK_TOP_CLK26M] = "clk26m", }; int mt8186_adsp_init_clock(struct snd_sof_dev *sdev) @@ -48,18 +50,36 @@ static int adsp_enable_all_clock(struct snd_sof_dev *sdev) struct device *dev = sdev->dev; int ret; - ret = clk_prepare_enable(priv->clk[CLK_TOP_AUDIODSP]); + ret = clk_set_parent(priv->clk[CLK_TOP_AUDIODSP], priv->clk[CLK_TOP_CLK26M]); + if (ret) { + dev_err(dev, "set audiodsp clock fail %d\n", ret); + return ret; + } + + ret = clk_set_parent(priv->clk[CLK_TOP_ADSP_BUS], priv->clk[CLK_TOP_MAINPLL_D2_D2]); + if (ret) { + dev_err(dev, "set adsp bus clock fail %d\n", ret); + return ret; + } + + ret = clk_prepare_enable(priv->clk[CLK_TOP_MAINPLL_D2_D2]); if (ret) { - dev_err(dev, "%s clk_prepare_enable(audiodsp) fail %d\n", - __func__, ret); + dev_err(dev, "clk_prepare_enable(mainpll_d2_d2) fail %d\n", ret); return ret; } ret = clk_prepare_enable(priv->clk[CLK_TOP_ADSP_BUS]); if (ret) { - dev_err(dev, "%s clk_prepare_enable(adsp_bus) fail %d\n", - __func__, ret); - clk_disable_unprepare(priv->clk[CLK_TOP_AUDIODSP]); + dev_err(dev, "clk_prepare_enable(adsp_bus) fail %d\n", ret); + clk_disable_unprepare(priv->clk[CLK_TOP_MAINPLL_D2_D2]); + return ret; + } + + ret = clk_prepare_enable(priv->clk[CLK_TOP_AUDIODSP]); + if (ret) { + dev_err(dev, "clk_prepare_enable(audiodsp) fail %d\n", ret); + clk_disable_unprepare(priv->clk[CLK_TOP_MAINPLL_D2_D2]); + clk_disable_unprepare(priv->clk[CLK_TOP_ADSP_BUS]); return ret; } @@ -70,8 +90,9 @@ static void adsp_disable_all_clock(struct snd_sof_dev *sdev) { struct adsp_priv *priv = sdev->pdata->hw_pdata; - clk_disable_unprepare(priv->clk[CLK_TOP_ADSP_BUS]); clk_disable_unprepare(priv->clk[CLK_TOP_AUDIODSP]); + clk_disable_unprepare(priv->clk[CLK_TOP_ADSP_BUS]); + clk_disable_unprepare(priv->clk[CLK_TOP_MAINPLL_D2_D2]); } int mt8186_adsp_clock_on(struct snd_sof_dev *sdev) diff --git a/sound/soc/sof/mediatek/mt8186/mt8186-clk.h b/sound/soc/sof/mediatek/mt8186/mt8186-clk.h index 89c23caf0fee..37f5cfa2b230 100644 --- a/sound/soc/sof/mediatek/mt8186/mt8186-clk.h +++ b/sound/soc/sof/mediatek/mt8186/mt8186-clk.h @@ -15,6 +15,8 @@ struct snd_sof_dev; enum adsp_clk_id { CLK_TOP_AUDIODSP, CLK_TOP_ADSP_BUS, + CLK_TOP_MAINPLL_D2_D2, + CLK_TOP_CLK26M, ADSP_CLK_MAX };