From patchwork Wed Aug 24 21:19:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 9298371 X-Patchwork-Delegate: sboyd@codeaurora.org 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 6BC1960459 for ; Wed, 24 Aug 2016 21:21:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4C8692911D for ; Wed, 24 Aug 2016 21:21:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 40F9F29122; Wed, 24 Aug 2016 21:21:28 +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=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BA6032911D for ; Wed, 24 Aug 2016 21:21:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752745AbcHXVV1 (ORCPT ); Wed, 24 Aug 2016 17:21:27 -0400 Received: from mail-yw0-f193.google.com ([209.85.161.193]:35701 "EHLO mail-yw0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754181AbcHXVV0 (ORCPT ); Wed, 24 Aug 2016 17:21:26 -0400 Received: by mail-yw0-f193.google.com with SMTP id r9so1457548ywg.2 for ; Wed, 24 Aug 2016 14:20:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=RX4BEvw/kmMF45emenv4m5zwVv/Vt+Tqg0zqJgTxJao=; b=neHdp3V0CiXJhYd+WygPGJdh2niG6iZg+/uW4QIzWQtpJ+cBI7VtSH2TTYR0AzOZOq fiVBY87w6cChK5X9jWtGSC1TQ+ZGF7ierR6vCtbWiqXg3n8jwGGT/L2uSWqm+tsQ4Drl 1MnCN1wjkUu3yFtHrjIZLtUGA28fJe76e1HGvcpsT+RQTsief+7rNX5yS+w1/nMzVJRG OOkuwYJWUcuf7BR3R3RNXsx/fL7EcvP9Wj/c0mr1ZULJo2+Vmn5EYNqmdVhq0Qdp8hT1 cYWwOVz8s6uYgFoEAHfnj4hPjsabRbHxKo1Okfs74SYtZszq//4oGL7mP0o8Z37l4Frp NNzw== 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; bh=RX4BEvw/kmMF45emenv4m5zwVv/Vt+Tqg0zqJgTxJao=; b=d965YWq+Da6cqXusv2BMD1QFQaaTUuBWgk0A5vKJfifqG31JKnpusiLN+JmuZ26CmD X57nV0Exjz+F7a+VlWYvJaGSftlWmFMoBexIJfTyPqIrHSKD35QjHkwC85MTTiReMQMo e9l9Ujsv2vr0FKBGER/5GKt/IR0Ll0Vrq9dV8rz5tHYQyExo73ESM3d3QgWmF00Vgpvw RjwbqhSAPCl6dZpfA8c+2lDsTyrASbcFf2dD0EnUb/VBHu93hub0rdr+OGCmHGIwwinT zCgH2um6JLfusexy/3TO05gPBVO6b7/1Yzle1XCae0TYI++kAYDhB9s7jg6utFplXUi/ vkBQ== X-Gm-Message-State: AEkoouszTQleQgwLZpwNqWDHf3NwjdCoNkG7+SlsSJ/fGV5J5wKU1OpRYzeyUdzQYjLDPg== X-Received: by 10.129.49.205 with SMTP id x196mr4255408ywx.223.1472073605465; Wed, 24 Aug 2016 14:20:05 -0700 (PDT) Received: from localhost.localdomain ([179.159.165.150]) by smtp.gmail.com with ESMTPSA id u189sm6418821ywe.25.2016.08.24.14.20.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 24 Aug 2016 14:20:04 -0700 (PDT) From: Fabio Estevam To: sboyd@codeaurora.org Cc: shawnguo@kernel.org, linux-clk@vger.kernel.org, Fabio Estevam Subject: [PATCH] clk: imx7d: Add PLL_AUDIO_TEST_DIV/POST_DIV clocks Date: Wed, 24 Aug 2016 18:19:54 -0300 Message-Id: <1472073594-6501-1-git-send-email-festevam@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Fabio Estevam Currently we see the following error when using the SAI audio driver on mx7: Division by zero in kernel. CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.8.0-rc3-next-20160823 Hardware name: Freescale i.MX7 Dual (Device Tree) Backtrace: [] (dump_backtrace) from [] (show_stack+0x18) r6:60000013 r5:ffffffff r4:00000000 r3:00000000 [] (show_stack) from [] (dump_stack+0xb0/0xe) [] (dump_stack) from [] (__div0+0x18/0x20) r8:00000000 r7:ffffffff r6:ffffffff r5:00000000 r4:00000000 r3:0 [] (__div0) from [] (Ldiv0_64+0x8/0x18) [] (divider_get_val) from [] (clk_divider_se) This error happens due to the lack of definition of the IMX7D_PLL_AUDIO_TEST_DIV/IMX7D_PLL_AUDIO_POST_DIV clocks. Add support for them. Tested on a imx7s-warp board. Signed-off-by: Fabio Estevam --- drivers/clk/imx/clk-imx7d.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/drivers/clk/imx/clk-imx7d.c b/drivers/clk/imx/clk-imx7d.c index 6bafcaa..74c2df4 100644 --- a/drivers/clk/imx/clk-imx7d.c +++ b/drivers/clk/imx/clk-imx7d.c @@ -26,6 +26,22 @@ static u32 share_count_sai1; static u32 share_count_sai2; static u32 share_count_sai3; +static struct clk_div_table test_div_table[] = { + { .val = 3, .div = 1, }, + { .val = 2, .div = 1, }, + { .val = 1, .div = 2, }, + { .val = 0, .div = 4, }, + { } +}; + +static struct clk_div_table post_div_table[] = { + { .val = 3, .div = 4, }, + { .val = 2, .div = 1, }, + { .val = 1, .div = 2, }, + { .val = 0, .div = 1, }, + { } +}; + static struct clk *clks[IMX7D_CLK_END]; static const char *arm_a7_sel[] = { "osc", "pll_arm_main_clk", "pll_enet_500m_clk", "pll_dram_main_clk", @@ -431,9 +447,14 @@ static void __init imx7d_clocks_init(struct device_node *ccm_node) clks[IMX7D_PLL_ARM_MAIN_CLK] = imx_clk_gate("pll_arm_main_clk", "pll_arm_main_bypass", base + 0x60, 13); clks[IMX7D_PLL_DRAM_MAIN_CLK] = imx_clk_gate("pll_dram_main_clk", "pll_dram_main_bypass", base + 0x70, 13); clks[IMX7D_PLL_SYS_MAIN_CLK] = imx_clk_gate("pll_sys_main_clk", "pll_sys_main_bypass", base + 0xb0, 13); - clks[IMX7D_PLL_AUDIO_MAIN_CLK] = imx_clk_gate("pll_audio_main_clk", "pll_audio_main_bypass", base + 0xf0, 13); + clks[IMX7D_PLL_AUDIO_MAIN_CLK] = imx_clk_gate("pll_audio_main_clk", "pll_audio_test_div", base + 0xf0, 13); clks[IMX7D_PLL_VIDEO_MAIN_CLK] = imx_clk_gate("pll_video_main_clk", "pll_video_main_bypass", base + 0x130, 13); + clks[IMX7D_PLL_AUDIO_TEST_DIV] = clk_register_divider_table(NULL, "pll_audio_test_div", "pll_audio_main_bypass", + CLK_SET_RATE_PARENT | CLK_SET_RATE_GATE, base + 0xf0, 19, 2, 0, test_div_table, &imx_ccm_lock); + clks[IMX7D_PLL_AUDIO_POST_DIV] = clk_register_divider_table(NULL, "pll_audio_post_div", "pll_audio_main_clk", + CLK_SET_RATE_PARENT | CLK_SET_RATE_GATE, base + 0xf0, 22, 2, 0, post_div_table, &imx_ccm_lock); + clks[IMX7D_PLL_SYS_PFD0_392M_CLK] = imx_clk_pfd("pll_sys_pfd0_392m_clk", "pll_sys_main_clk", base + 0xc0, 0); clks[IMX7D_PLL_SYS_PFD1_332M_CLK] = imx_clk_pfd("pll_sys_pfd1_332m_clk", "pll_sys_main_clk", base + 0xc0, 1); clks[IMX7D_PLL_SYS_PFD2_270M_CLK] = imx_clk_pfd("pll_sys_pfd2_270m_clk", "pll_sys_main_clk", base + 0xc0, 2);