~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/sound/soc/sof/mediatek/mt8186/mt8186-clk.c

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
  2 //
  3 // Copyright(c) 2022 Mediatek Corporation. All rights reserved.
  4 //
  5 // Author: Allen-KH Cheng <allen-kh.cheng@mediatek.com>
  6 //         Tinghan Shen <tinghan.shen@mediatek.com>
  7 //
  8 // Hardware interface for mt8186 DSP clock
  9 
 10 #include <linux/clk.h>
 11 #include <linux/io.h>
 12 
 13 #include "../../sof-audio.h"
 14 #include "../../ops.h"
 15 #include "../adsp_helper.h"
 16 #include "mt8186.h"
 17 #include "mt8186-clk.h"
 18 
 19 static const char *adsp_clks[ADSP_CLK_MAX] = {
 20         [CLK_TOP_AUDIODSP] = "audiodsp",
 21         [CLK_TOP_ADSP_BUS] = "adsp_bus",
 22 };
 23 
 24 int mt8186_adsp_init_clock(struct snd_sof_dev *sdev)
 25 {
 26         struct adsp_priv *priv = sdev->pdata->hw_pdata;
 27         struct device *dev = sdev->dev;
 28         int i;
 29 
 30         priv->clk = devm_kcalloc(dev, ADSP_CLK_MAX, sizeof(*priv->clk), GFP_KERNEL);
 31         if (!priv->clk)
 32                 return -ENOMEM;
 33 
 34         for (i = 0; i < ADSP_CLK_MAX; i++) {
 35                 priv->clk[i] = devm_clk_get(dev, adsp_clks[i]);
 36 
 37                 if (IS_ERR(priv->clk[i]))
 38                         return PTR_ERR(priv->clk[i]);
 39         }
 40 
 41         return 0;
 42 }
 43 
 44 static int adsp_enable_all_clock(struct snd_sof_dev *sdev)
 45 {
 46         struct adsp_priv *priv = sdev->pdata->hw_pdata;
 47         struct device *dev = sdev->dev;
 48         int ret;
 49 
 50         ret = clk_prepare_enable(priv->clk[CLK_TOP_AUDIODSP]);
 51         if (ret) {
 52                 dev_err(dev, "%s clk_prepare_enable(audiodsp) fail %d\n",
 53                         __func__, ret);
 54                 return ret;
 55         }
 56 
 57         ret = clk_prepare_enable(priv->clk[CLK_TOP_ADSP_BUS]);
 58         if (ret) {
 59                 dev_err(dev, "%s clk_prepare_enable(adsp_bus) fail %d\n",
 60                         __func__, ret);
 61                 clk_disable_unprepare(priv->clk[CLK_TOP_AUDIODSP]);
 62                 return ret;
 63         }
 64 
 65         return 0;
 66 }
 67 
 68 static void adsp_disable_all_clock(struct snd_sof_dev *sdev)
 69 {
 70         struct adsp_priv *priv = sdev->pdata->hw_pdata;
 71 
 72         clk_disable_unprepare(priv->clk[CLK_TOP_ADSP_BUS]);
 73         clk_disable_unprepare(priv->clk[CLK_TOP_AUDIODSP]);
 74 }
 75 
 76 int mt8186_adsp_clock_on(struct snd_sof_dev *sdev)
 77 {
 78         struct device *dev = sdev->dev;
 79         int ret;
 80 
 81         ret = adsp_enable_all_clock(sdev);
 82         if (ret) {
 83                 dev_err(dev, "failed to adsp_enable_clock: %d\n", ret);
 84                 return ret;
 85         }
 86         snd_sof_dsp_write(sdev, DSP_REG_BAR, ADSP_CK_EN,
 87                           UART_EN | DMA_EN | TIMER_EN | COREDBG_EN | CORE_CLK_EN);
 88         snd_sof_dsp_write(sdev, DSP_REG_BAR, ADSP_UART_CTRL,
 89                           UART_BCLK_CG | UART_RSTN);
 90 
 91         return 0;
 92 }
 93 
 94 void mt8186_adsp_clock_off(struct snd_sof_dev *sdev)
 95 {
 96         snd_sof_dsp_write(sdev, DSP_REG_BAR, ADSP_CK_EN, 0);
 97         snd_sof_dsp_write(sdev, DSP_REG_BAR, ADSP_UART_CTRL, 0);
 98         adsp_disable_all_clock(sdev);
 99 }
100 
101 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php