From patchwork Fri Mar 30 10:04:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akshu Agrawal X-Patchwork-Id: 10317561 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 A000960467 for ; Fri, 30 Mar 2018 10:05:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8E6A02A572 for ; Fri, 30 Mar 2018 10:05:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 834102A584; Fri, 30 Mar 2018 10:05:35 +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=-1.8 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, RCVD_IN_DNSWL_NONE, T_DKIM_INVALID autolearn=no version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7C6532A572 for ; Fri, 30 Mar 2018 10:05:34 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id E4D18267219; Fri, 30 Mar 2018 12:05:26 +0200 (CEST) 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 A00B326720A; Fri, 30 Mar 2018 12:05:22 +0200 (CEST) Received: from NAM01-BY2-obe.outbound.protection.outlook.com (mail-by2nam01on0044.outbound.protection.outlook.com [104.47.34.44]) by alsa0.perex.cz (Postfix) with ESMTP id 983702671F9 for ; Fri, 30 Mar 2018 12:05:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=sQUMKCHhPHD95IIkQ6pFHExsJ/0u/jOC9GFn176T2+o=; b=oyo9b27dylDV8KLrxFfqx8G8gKu7mDnwLipJb6Ry4n8n6MaV6H1MQqBJzXABdkubcm8P0gfwThQh063oYpy2bxX0b2M+Fz008p7wcXexLrBqeUyAVaSff30XbSa2lQQaGKH5fHpSkSxwBJySwINv6yCREgmSIR8vDYaC6q0q9Ss= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Akshu.Agrawal@amd.com; Received: from akshu-HP-EliteBook-745-G2.mshome.net (203.93.97.130) by CY4PR1201MB0182.namprd12.prod.outlook.com (2603:10b6:910:1d::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.631.10; Fri, 30 Mar 2018 10:05:15 +0000 From: Akshu Agrawal To: broonie@kernel.org, alsa-devel@alsa-project.org Date: Fri, 30 Mar 2018 15:34:57 +0530 Message-Id: <1522404297-7555-2-git-send-email-akshu.agrawal@amd.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1522404297-7555-1-git-send-email-akshu.agrawal@amd.com> References: <1522404297-7555-1-git-send-email-akshu.agrawal@amd.com> MIME-Version: 1.0 X-Originating-IP: [203.93.97.130] X-ClientProxiedBy: HK2PR02CA0164.apcprd02.prod.outlook.com (2603:1096:201:1f::24) To CY4PR1201MB0182.namprd12.prod.outlook.com (2603:10b6:910:1d::11) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: ee9b97e5-419e-4788-8a0c-08d59625bd5e X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:CY4PR1201MB0182; X-Microsoft-Exchange-Diagnostics: 1; CY4PR1201MB0182; 3:xAvvHqwQuS5HtZUHu6rwMx3ocKNHKA01uzhky/vFIndZ9NMEn55ufa3njW1pnk92r+3qr5BcM8F7yuMya8N46peQALx8XB2G6eFzbVivnP8w02S14PYXwqzZKvlmu1Sq1Uk7iyZyYPU1tvCqz3xLqkzfDC35DtqijoxUqspgNi8K+AsvkxX+fmf6VkBk6yvd4Yi0YiI/vH3Z03r8Swuh37G67jlzLITreP9nGPsFooZHr8g6/vyGKzGV+UrsSpGt; 25:HlzhNCecTYF19ymJh0+CiFCddC3tsS70TsNOaTk0+lURKw7gzim52zab5FY//IsWgwszZcaTnFuYmMSndpe0Ep4Y4+t7ZRBLHd0vhhS80U5WTX2ymmgBR4Jzb6/gxGGFymHv3y8ixK2L0U12nh/UZwOduScPNDchT6PhNevx3Fz5gdSKiYlym9yGtgoEfJQhxwAEJOuVRdKlUYFpXZrzZC6tE9NHqC0W0rXSCDhPx2hZtcxK/f/5ui0FqN4/1/iqB55QB3ii7yGf+buSwvrKlS2S2i3UDqMlXvmjDjgpC83I1fSsLA0nRrcr/GRiYDewRcg1uKHGtWgE6eonZQ7V5A==; 31:vrl7nDNlQvGjImli50ho7Tcta0SBn5l3rvWoX349dsuJM2yKOnxf0YsPz6dCtI9ArXNHvUkVyUk4hD6KHMSKczL1D8KpBnJyi3DcqFsfS6Yo9ppCWWJNUCzwVXapR3stN9D48LlY5UmSToEYBJF1BeJx5NLlFWwpVw6jJkOUnt5Lyz43jHN5BcVpND+AYzfEX5oua0ui9TtEGxBZeuz6HPlkNzkVJRaCMJEwUt1EIew= X-MS-TrafficTypeDiagnostic: CY4PR1201MB0182: X-Microsoft-Exchange-Diagnostics: 1; CY4PR1201MB0182; 20:wH5eJzmF4N2YcPr7FamowYxUwLsk9CYPPEL0TlRgFWAoGmc+I5/01zOnQpZYv1P+vlwQLdhmiWMG2s8rX9Zvsl6adVaccDGzkCpq3NONEcFvvk1jQXq8PBNPc86V3argK79G0a1BCXZ8PrPtHjErkg3UWoNFuv8PigKB0FSz5y8DVpgm5xzVQjrqZgx9Xnq5ue/osQF7lfH/fiy8FOjjaaQa/MBmPDtuDT8NEY38oSZVerS5O1A8Hv15p+SNCEDWinzwPLRtVYD1Q+I6Q1VIBL7MNbqwx0g8BOhP4jEmysIosOGJQDGUjHOXwqUf5KD0LLkAjXFWEO4Htf3lIJs8RWwYP36cpaPtSdKRoGWMPR4hOUCl+SNyK9LIy7SF1Xl1j/ogxj65aYUQhCJHvCKhohG8bW4Cgb+wLuh4ZFUrhvnJ6BEKT73vx8ZJn2M9DSf800QGqrYZl63RtFPpaKS2Vm5Oyg99yzjNv0cnueMjWV8j9cDxzcFwDnXmkf/zcp6T; 4:jsmHQ/SXZqwrOvh7zyBbGziOzv97zWMXW1OG6LVPOlYI5x3WASsyMbycHWNuejmshn6Zij4Aan3m6Z1GkdjDLbI9dXByu3NiVvN9BUsgL2rvCF/SFradugBp+vCEb9lIm9O7tJM71E8z1faxFMyYPPGL6Pt1zvDLiCwccwkW2ifXsrpuyfQ3nqH6ssVppH6+jzFS1f4ZZ1aNVC37OUh7BmJFIaGj77PL2/2NBQ4wfub8T7M5W3zWVNXbVhZ0jwEfnqDU93hSCcFLCGpCCjKIYXeX6VK+vNZbdv+NCRymPiK1fiXX27k3q7ctZUFE33c4 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3231221)(944501327)(52105095)(93006095)(93001095)(10201501046)(3002001)(6055026)(6041310)(20161123562045)(20161123558120)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:CY4PR1201MB0182; BCL:0; PCL:0; RULEID:; SRVR:CY4PR1201MB0182; X-Forefront-PRVS: 06274D1C43 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39860400002)(39380400002)(366004)(376002)(346002)(396003)(189003)(199004)(66066001)(105586002)(4326008)(25786009)(478600001)(48376002)(53416004)(72206003)(50466002)(7736002)(305945005)(39060400002)(8936002)(2616005)(59450400001)(8676002)(11346002)(50226002)(69596002)(3846002)(81156014)(956004)(6116002)(52116002)(47776003)(51416003)(81166006)(76176011)(446003)(16526019)(6512007)(186003)(53936002)(5660300001)(2906002)(6506007)(386003)(26005)(106356001)(6666003)(316002)(86362001)(6486002)(486005)(486005)(68736007)(97736004)(16586007)(476003)(36756003); DIR:OUT; SFP:1101; SCL:1; SRVR:CY4PR1201MB0182; H:akshu-HP-EliteBook-745-G2.mshome.net; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY4PR1201MB0182; 23:C+6X1UMtwhc0pjWGgKSiGUeNiEWfTyXonABjnvN?= =?us-ascii?Q?yNtvRDolIOgNxKhp9O6E75sUaJSoLERECcZUAjjJu6PQTG5fqhC5V2/Le/wp?= =?us-ascii?Q?4JDDiM7k03US9I3/u/+MKWUsOGgbuuhVuwrHuO85slr94NTFWBn9quAieQoc?= =?us-ascii?Q?jZ3miw8qOC2QGKyiX1OnwOSvG7N93v1/W0QdUI1S3i4lqeLgTguO8JxImvO7?= =?us-ascii?Q?iJVcZNgOneDaOTimhBaNi8ldj8PkgC5Tp/H0yQppwpoV0JHN1e1MrnblQR8D?= =?us-ascii?Q?iJ56k47FkWIu1R8LgVj7qGWcMBh8iZ8NWct2aY+kub4CvxbfDCxh2YSX/cUZ?= =?us-ascii?Q?lu6BvALU4G+N2KKzN1NeN7H+FwrOyYd2jdBFlwueoxeGGKm8bUmWzYBXrlLc?= =?us-ascii?Q?ZZ+4prdwfA5RaueIFE3c6a1JDPdzRiEcZoBsu9zl7aeOo61E7ezD/dIgmje2?= =?us-ascii?Q?6yJTg5o8bv37rzYSndYrMAQmCDwfVYQFFu7Rf2URmpMA8/X6D1GEUUGvq0JR?= =?us-ascii?Q?26penQ3+v7HWYPYks5VLThQhKFhvx9L4kx7HThl9I7oZxfHe99MgJtJrK7h2?= =?us-ascii?Q?EnR3OfRDhh7Hr5lN8NxVStOarFwmEWaGw9VyVuVqrFfyjXZb56qKGo87qWpn?= =?us-ascii?Q?3EukPMNZ/2KnHvEF3Ik4rzz3SnZgGD0HigOA9p7wu5oMHRACL+COY3nsRAUx?= =?us-ascii?Q?r64PB+nrjrvJtoVvi3MoukTyREw/VY9+lD3mG3K3CJ3F9GrXKDGWXo+sFJmI?= =?us-ascii?Q?TsBzhEI4/MFTG5d6YTEMqt6xY9RsGY1DZLHBgAhcNbtmDCWO76aFKyXB4Wta?= =?us-ascii?Q?1yj0pE0UybvUZUzMKZGQDSydRCEJ9i+n/6bS+UMrbx74lWB1boTyKl2Ftjp7?= =?us-ascii?Q?GS0eM2MtLhuJ0V0InVKN6Cm+axOczNaZVOXSYYA93JKMZZHSDXzrowqCZD6E?= =?us-ascii?Q?z5+RszYB/mGjG1twEfBcZ9frx/MFksnsdwe/dL0GwNdWXsuqOrEg0KJOL7lp?= =?us-ascii?Q?HuufEx97sZRBVw3lvC2oZzErYGJhS0AznTyGkOVOhMlHohaiiyJHeJLM0mwH?= =?us-ascii?Q?rgx3J2jp6BkZirkmdHZMZfIqf1ag4mw9RR0uXY3VUwvhmXef12NcB8Y5I6O4?= =?us-ascii?Q?Y57s66iaCKLblvxBc9JbaZrq51c0FYpE2rhNLly8sd1Vtekvd0Yyiy71UW2+?= =?us-ascii?Q?JtiqZ6Rz0kA5RFa8j2hQ+K5k+SHUy8eGp8ZVKuuJ6kEzFpaWcl/FGGhBRkuG?= =?us-ascii?Q?Lh+I2usFhHWStTa+JapQ7OFOP1bNumAESv/tXqosptuDOHgEHHstlswgkrTy?= =?us-ascii?Q?fCA=3D=3D?= X-Microsoft-Antispam-Message-Info: aN+aza8/t7O1WAw/DnZVf/S4NiF5PqG7XYrXLaHpGieT2+XAZeoa9EXJhzVlglYSNuPIdV7BC9MK4SzARxNHR4o1GJymZWiIScp58e9HIcgJ3xingRA62HYsCBbiYiFKaSP7FnXPFjG9nycG9T4t2N4svz4HGTGaakxzSWAmoHI579F5GRaKcttKWU2Jd2+0 X-Microsoft-Exchange-Diagnostics: 1; CY4PR1201MB0182; 6:wjFbl5RLFALTvnsUXNGMHLvSV/n+dqLK3EGuJjN/ZlYsSZ+s1CPrQY2wzro3wQZ4asCk2VSV8IwL9d6tqMtAOigHfckjanp0j5ojrdqGd/6of4DAiMxxAQNnw02jb0l+8gQDaaVunO4ryyJfqL0r9/pKiBEv5lj5xdjWnh4xObkUeCoIBdraXUI4I5ynRolxe9CiaIgDz71Fxbes4oBvRHSNizc+1w6JOKDJjDAca99Joe5xuqN4Pv0tw7WHO8+NDRlsMP/eBNLTAHnhZKbXXwavk9+Koj4bx7WQudGutjw5CNQ0f/ROkrt5qmwoP3Xqm4S2ia4BzMnafGkrV4EWiRuOLYkItu3XxeQMQIO2i52cxrOFqzHlrqmHIBa4lLygRU0A0PTecruPOyQCX76HkOemj+NUAy8sldkGV30Qi6QZ3t6nA29gzU6ieWNdAjypAZaLsJfB2Fd/SW4SoznQAw==; 5:5W0FocNXkt3VFl6KmOMDdJ8qzm66jktxYpX28mEAyHS1jwUjQX3XrGIyW3+pkuVMadBuaiTNqC7QJazfWoMbAcgtV1abkWuxN+hWM4RuzrTrUg/7Q9euPW645jli/h8U4bWjiaSRcY3Mfjpxpx2/d05ZcpFMZn55bANh/Z80ABo=; 24:HslqPHRCuVBOo+uB1W8h4poQwtaX+lXIlf/CU/r6/a6xoFbjdXR0KxCQCU7Wc7p8XBUaFZh5bjrMt+MqFrPySfb7p67kQM8jLw0oGXdSXyg= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY4PR1201MB0182; 7:UVSe2KmfHWbEPWK6KWCQEmA+naR7car15r69zDRlFNDjJOyi0d0upHN4LW0lDdE1XTPwZ1vLA8SLNJBbEuqBQ+YVpt5UiJq01GkBR6mJ3fg2C6uzqK+iSXBtUDuCH0hgfgqruTvsYekkU2g9TDHCYBN822itKDNRK5ylqkwxwLZNAFXkpzsHWmLFLHyqAvFfDK3EszwlV22TL70Z7nsF75OBAYIQCkg/vCq8/Gxn+OcaJljExAGyk7MiNKZUr5wi; 20:7tPVO1JP7kicKDzzH/7XEMLIhCNPGewHSmo3OB1Hz5gjFwPqY7Hz8PnRsMhiWvjlor48BtqXZ1fuxY8mpBzVVzpAwfxu2hy5GELchoUGamkRGEgGtp43duU54g3Kauuy7L+yYUIPqX4GngeFWIjbYb0JZw2raqsE+9nhukEr+5wT2R5AaRkvB5ztqybPQcfPcQ87OtsJVSsy1LUXh6S1cHoBAa8g1SpbhLS9X02Wr8amJuxAKurLEd+80ge+vTm+ X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2018 10:05:15.8620 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ee9b97e5-419e-4788-8a0c-08d59625bd5e X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR1201MB0182 Cc: tiwai@suse.de, Alexander.Deucher@amd.com, lgirdwood@gmail.com, djkurtz@chromium.org, akshu.agrawal@amd.com Subject: [alsa-devel] [PATCH 2/2] ASoC: AMD: Enable/Disable auxiliary clock via common clock framework 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP This enables/disables and sets auxiliary clock at 25Mhz. It uses common clock framework for proper ref counting. This approach will save power in comparison to keeping it always On in firmware. TEST= aplay -vv check register to see clock enabled kill aplay check register to see clock disabled Signed-off-by: Akshu Agrawal Acked-by: Alex Deucher --- V2: Correcting the pin to OSCOUT1 from OSCOUT2 V3: Fix error/warnings from kbuild test V4: Fix build errors for platform which do not support CONFIG_COMMON_CLK V5: Review comments by Dan and Sriram sound/soc/amd/acp-da7219-max98357a.c | 159 ++++++++++++++++++++++++++++++++++- 1 file changed, 157 insertions(+), 2 deletions(-) diff --git a/sound/soc/amd/acp-da7219-max98357a.c b/sound/soc/amd/acp-da7219-max98357a.c index d9491e1..9e649c3 100644 --- a/sound/soc/amd/acp-da7219-max98357a.c +++ b/sound/soc/amd/acp-da7219-max98357a.c @@ -30,19 +30,41 @@ #include #include #include +#include +#include #include #include #include #include #include +#include #include "../codecs/da7219.h" #include "../codecs/da7219-aad.h" -#define CZ_PLAT_CLK 24000000 +#define CZ_PLAT_CLK 25000000 #define MCLK_RATE 24576000 #define DUAL_CHANNEL 2 +/* Clock Driving Strength 2 register */ +#define CLKDRVSTR2 0x28 +/* Clock Control 1 register */ +#define MISCCLKCNTL1 0x40 +/* Auxiliary clock1 enable bit */ +#define OSCCLKENB 2 +/* 25Mhz auxiliary output clock freq bit */ +#define OSCOUT1CLK25MHZ 16 + +struct cz_clock { + const char* acp_clks_name; +#ifdef CONFIG_COMMON_CLK + struct clk_hw acp_clks_hw; +#endif + struct clk_lookup *acp_clks_lookup; + struct clk *acp_clks; + void __iomem *res_base; +}; + static struct snd_soc_jack cz_jack; struct clk *da7219_dai_clk; @@ -98,6 +120,8 @@ static int cz_da7219_hw_params(struct snd_pcm_substream *substream, { int ret = 0; struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_card *card = rtd->card; + struct clk *acpd7219_clk; ret = clk_prepare_enable(da7219_dai_clk); if (ret < 0) { @@ -105,13 +129,37 @@ static int cz_da7219_hw_params(struct snd_pcm_substream *substream, return ret; } + acpd7219_clk = clk_get(card->dev, "acpd7219-clks"); + if (IS_ERR(acpd7219_clk)) { + dev_err(rtd->dev, "failed to get clock: %ld\n", + PTR_ERR(acpd7219_clk)); + return PTR_ERR(acpd7219_clk); + } + + ret = clk_prepare_enable(acpd7219_clk); + if (ret < 0) + dev_err(rtd->dev, "can't enable oscillator clock %d\n", ret); + return ret; } static int cz_da7219_hw_free(struct snd_pcm_substream *substream) { + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_card *card = rtd->card; + struct clk *acpd7219_clk; + clk_disable_unprepare(da7219_dai_clk); + acpd7219_clk = clk_get(card->dev, "acpd7219-clks"); + if (IS_ERR(acpd7219_clk)) { + dev_err(rtd->dev, "failed to get clock: %ld\n", + PTR_ERR(acpd7219_clk)); + return PTR_ERR(acpd7219_clk); + } + + clk_disable_unprepare(acpd7219_clk); + return 0; } @@ -244,6 +292,112 @@ static int cz_fe_startup(struct snd_pcm_substream *substream) .num_controls = ARRAY_SIZE(cz_mc_controls), }; +#ifdef CONFIG_COMMON_CLK +static int acpd7219_clks_enable(struct clk_hw *hw) +{ + u32 reg_val; + struct cz_clock *cz_clock_obj = + container_of(hw, struct cz_clock, acp_clks_hw); + void __iomem *base = cz_clock_obj->res_base; + + reg_val = readl(base + MISCCLKCNTL1); + reg_val &= ~(0x1 << OSCCLKENB); + writel(reg_val, base + MISCCLKCNTL1); + reg_val = readl(base + CLKDRVSTR2); + reg_val |= (0x1 << OSCOUT1CLK25MHZ); + writel(reg_val, base + CLKDRVSTR2); + + return 0; +} + +static void acpd7219_clks_disable(struct clk_hw *hw) +{ + u32 reg_val; + struct cz_clock *cz_clock_obj = + container_of(hw, struct cz_clock, acp_clks_hw); + void __iomem *base = cz_clock_obj->res_base; + + reg_val = readl(base + MISCCLKCNTL1); + reg_val |= (0x1 << OSCCLKENB); + writel(reg_val, base + MISCCLKCNTL1); +} + +static int acpd7219_clks_is_enabled(struct clk_hw *hw) +{ + u32 reg_val; + struct cz_clock *cz_clock_obj = + container_of(hw, struct cz_clock, acp_clks_hw); + void __iomem *base = cz_clock_obj->res_base; + + reg_val = readl(base + MISCCLKCNTL1); + + return !(reg_val & OSCCLKENB); +} + +static const struct clk_ops acpd7219_clks_ops = { + .enable = acpd7219_clks_enable, + .disable = acpd7219_clks_disable, + .is_enabled = acpd7219_clks_is_enabled, +}; + +static int register_acpd7219_clocks(struct platform_device *pdev) +{ + struct clk *acp_clks; + struct clk_lookup *acp_clks_lookup; + struct cz_clock *cz_clock_obj; + struct resource *res; + struct device dev = pdev->dev; + static const struct clk_init_data init = { + .name = "acpd7219-clks", + .ops = &acpd7219_clks_ops, + }; + + cz_clock_obj = kzalloc(sizeof(struct cz_clock), GFP_KERNEL); + if (!cz_clock_obj) + return -ENOMEM; + + cz_clock_obj->acp_clks_name = "acpd7219-clks"; + + cz_clock_obj->acp_clks_hw.init = &init; + + acp_clks = devm_clk_register(&dev, &cz_clock_obj->acp_clks_hw); + if (IS_ERR(acp_clks)) + { + dev_err(&dev, "Failed to register DAI clocks: %ld\n", + PTR_ERR(acp_clks)); + return PTR_ERR(acp_clks); + } + cz_clock_obj->acp_clks = acp_clks; + + acp_clks_lookup = clkdev_create(acp_clks, cz_clock_obj->acp_clks_name, + "%s", dev_name(&dev)); + if (!acp_clks_lookup) + dev_warn(&dev, "Failed to create DAI clkdev"); + else + cz_clock_obj->acp_clks_lookup = acp_clks_lookup; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) { + dev_err(&pdev->dev, "Failed to get misc io resource.\n"); + clkdev_drop(acp_clks_lookup); + return -EINVAL; + } + cz_clock_obj->res_base = devm_ioremap_nocache(&pdev->dev, res->start, + resource_size(res)); + if (!cz_clock_obj->res_base) { + clkdev_drop(acp_clks_lookup); + return -ENOMEM; + } + + return 0; +} +#else +static int register_acpd7219_clocks(struct platform_device *pdev) +{ + return 0; +} +#endif /* CONFIG_COMMON_CLK */ + static int cz_probe(struct platform_device *pdev) { int ret; @@ -259,7 +413,8 @@ static int cz_probe(struct platform_device *pdev) cz_card.name, ret); return ret; } - return 0; + + return register_acpd7219_clocks(pdev); } static const struct acpi_device_id cz_audio_acpi_match[] = {