From patchwork Wed Mar 1 18:37:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Rokosov X-Patchwork-Id: 63029 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp3803929wrd; Wed, 1 Mar 2023 10:51:08 -0800 (PST) X-Google-Smtp-Source: AK7set8QLS8D6ePT1IptQv5k/6QnP66Wxm7IsRnSeDIIAnoF2B+utBL0O5vqxA3/yUl7BvN0qUvu X-Received: by 2002:a05:6402:4e:b0:4aa:a4f0:2c17 with SMTP id f14-20020a056402004e00b004aaa4f02c17mr9156036edu.4.1677696668306; Wed, 01 Mar 2023 10:51:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677696668; cv=none; d=google.com; s=arc-20160816; b=rwRhEkzfVYvP3EhG4oxfSn8FeIcTK4ygSGne1tN/2gnAlEIWe9cfVvSrUMLfViVSg/ GNi6a0fLFgvzqS+R3e6uvSag3lhU/qeLr9mP1VcKnJiodsSiiBmpvdbAwCOmMwvPdKo8 xGL+gIKDn3m5gVY1V7Hb/pdC1p/WYeDtBwKliGAH6L2+8TQoFApD/2Su5fzbN9LqFt5V JAUP8EB0ZgzP17KhsQDy7XlcipJpfzkrOJZNdjgAHzEgjJs4M1zTLbNykY9R3/6D1+XD 33rUWQ2a1pbTCqAooumVoJvX1b8tYD6rTQ8bgtQDCMtriVzqWFmGCPmY70l3hxpsu/EH BaTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=0kocuhoTDaz9h1jxIA/Jw2sp5SwkBuT+pW8CQZu+FkI=; b=LAC5ceHaFmXjjKkOk+0vf14OQ9WT6qvl8KSEO9nCS4RyeY5H2nynI83QJUM5RLXXig /KZivPZ1P6Dx+pGICjlwmW0/3EfhfLna/FMcmqr1BD+eXM/74N9dZpyGHtAH23y+mj9K MH9Zc4qlZTKZLS1DrKbCyPKXZagFAAee13j7ozZayAgbBSS4j+OWpBh3KJ40g45WJRt3 03EzAH1BrLbbmdTYRnoQbP7sCEeIGV1ic/8aMOx+I/zGnOtrHlcCUajZiKkFTddr5b7p 71ViX3LlRFwQ7bRALqeOC2QGqnI20znlQ+MODLc13+4JXDqwJERXtJIsXIvbSyfVmpkk 24oQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sberdevices.ru header.s=mail header.b=NLO7Knkp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=sberdevices.ru Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c16-20020aa7d610000000b004acc0bdcdf6si7101830edr.216.2023.03.01.10.50.40; Wed, 01 Mar 2023 10:51:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@sberdevices.ru header.s=mail header.b=NLO7Knkp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=sberdevices.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230003AbjCASi3 (ORCPT + 99 others); Wed, 1 Mar 2023 13:38:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229914AbjCASiZ (ORCPT ); Wed, 1 Mar 2023 13:38:25 -0500 Received: from mx.sberdevices.ru (mx.sberdevices.ru [45.89.227.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C70A46EB9; Wed, 1 Mar 2023 10:38:22 -0800 (PST) Received: from s-lin-edge02.sberdevices.ru (localhost [127.0.0.1]) by mx.sberdevices.ru (Postfix) with ESMTP id EC8B05FD79; Wed, 1 Mar 2023 21:38:19 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sberdevices.ru; s=mail; t=1677695900; bh=0kocuhoTDaz9h1jxIA/Jw2sp5SwkBuT+pW8CQZu+FkI=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; b=NLO7KnkpUh18PTGTgGFBmQtwPZed+65GMfDM2dRjY8TUOpmDaU2B/majDIwnFiG/i pp90tpA3cYOi2n06gpULFofjHqW5GE/3KwlGiQT6ZtsKVaOgqGzTMcyH0tnrWA5Lgi ZkxIlYOChlznk7x4niHMaLq/XCmQ28lHNKn3mdSJSTZmfhZT5ye6jNoGhUl+e7wUp2 aI0B5GburZa3elK/mQdvO5VGq4sdQGLcK2DfEMWafRp+W5Yr/7ijztUxDCe79okzJA fgXqbKwZKzZhW141636WQkWCVgm9h+wvOXYTBfqEMasJ/ac70eKNdPkWDhIC67meZk hh4FMsZ3+1wIA== Received: from S-MS-EXCH01.sberdevices.ru (S-MS-EXCH01.sberdevices.ru [172.16.1.4]) by mx.sberdevices.ru (Postfix) with ESMTP; Wed, 1 Mar 2023 21:38:19 +0300 (MSK) From: Dmitry Rokosov To: , , , , , , , CC: , , , , , , , , Dmitry Rokosov Subject: [PATCH v9 1/5] clk: meson: add support for A1 PLL clock ops Date: Wed, 1 Mar 2023 21:37:55 +0300 Message-ID: <20230301183759.16163-2-ddrokosov@sberdevices.ru> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20230301183759.16163-1-ddrokosov@sberdevices.ru> References: <20230301183759.16163-1-ddrokosov@sberdevices.ru> MIME-Version: 1.0 X-Originating-IP: [172.16.1.6] X-ClientProxiedBy: S-MS-EXCH01.sberdevices.ru (172.16.1.4) To S-MS-EXCH01.sberdevices.ru (172.16.1.4) X-KSMG-Rule-ID: 4 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Status: not scanned, disabled by settings X-KSMG-AntiSpam-Interceptor-Info: not scanned X-KSMG-AntiPhishing: not scanned, disabled by settings X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 1.1.2.30, bases: 2023/03/01 14:15:00 #20905952 X-KSMG-AntiVirus-Status: Clean, skipped X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759192461727499634?= X-GMAIL-MSGID: =?utf-8?q?1759192461727499634?= From: Jian Hu Modern meson PLL IPs are a little bit different from early known PLLs. The main difference is located in the init/enable/disable sequences; the rate logic is the same. Compared with the previous SoCs, self-adaption current module is newly added for A1, and there is no reset parameter except the fixed pll. In A1 PLL, the PLL enable sequence is different, using the new power-on sequence to enable the PLL. Signed-off-by: Jian Hu Acked-by: Martin Blumenstingl Signed-off-by: Dmitry Rokosov --- drivers/clk/meson/clk-pll.c | 47 +++++++++++++++++++++++++++++++------ drivers/clk/meson/clk-pll.h | 2 ++ 2 files changed, 42 insertions(+), 7 deletions(-) diff --git a/drivers/clk/meson/clk-pll.c b/drivers/clk/meson/clk-pll.c index afefeba6e458..56ec2210f1ad 100644 --- a/drivers/clk/meson/clk-pll.c +++ b/drivers/clk/meson/clk-pll.c @@ -295,10 +295,14 @@ static int meson_clk_pll_init(struct clk_hw *hw) struct meson_clk_pll_data *pll = meson_clk_pll_data(clk); if (pll->init_count) { - meson_parm_write(clk->map, &pll->rst, 1); + if (MESON_PARM_APPLICABLE(&pll->rst)) + meson_parm_write(clk->map, &pll->rst, 1); + regmap_multi_reg_write(clk->map, pll->init_regs, pll->init_count); - meson_parm_write(clk->map, &pll->rst, 0); + + if (MESON_PARM_APPLICABLE(&pll->rst)) + meson_parm_write(clk->map, &pll->rst, 0); } return 0; @@ -309,8 +313,11 @@ static int meson_clk_pll_is_enabled(struct clk_hw *hw) struct clk_regmap *clk = to_clk_regmap(hw); struct meson_clk_pll_data *pll = meson_clk_pll_data(clk); - if (meson_parm_read(clk->map, &pll->rst) || - !meson_parm_read(clk->map, &pll->en) || + if (MESON_PARM_APPLICABLE(&pll->rst) && + meson_parm_read(clk->map, &pll->rst)) + return 0; + + if (!meson_parm_read(clk->map, &pll->en) || !meson_parm_read(clk->map, &pll->l)) return 0; @@ -341,13 +348,34 @@ static int meson_clk_pll_enable(struct clk_hw *hw) return 0; /* Make sure the pll is in reset */ - meson_parm_write(clk->map, &pll->rst, 1); + if (MESON_PARM_APPLICABLE(&pll->rst)) + meson_parm_write(clk->map, &pll->rst, 1); /* Enable the pll */ meson_parm_write(clk->map, &pll->en, 1); /* Take the pll out reset */ - meson_parm_write(clk->map, &pll->rst, 0); + if (MESON_PARM_APPLICABLE(&pll->rst)) + meson_parm_write(clk->map, &pll->rst, 0); + + /* + * Compared with the previous SoCs, self-adaption current module + * is newly added for A1, keep the new power-on sequence to enable the + * PLL. The sequence is: + * 1. enable the pll, delay for 10us + * 2. enable the pll self-adaption current module, delay for 40us + * 3. enable the lock detect module + */ + if (MESON_PARM_APPLICABLE(&pll->current_en)) { + usleep_range(10, 20); + meson_parm_write(clk->map, &pll->current_en, 1); + usleep_range(40, 50); + }; + + if (MESON_PARM_APPLICABLE(&pll->l_detect)) { + meson_parm_write(clk->map, &pll->l_detect, 1); + meson_parm_write(clk->map, &pll->l_detect, 0); + } if (meson_clk_pll_wait_lock(hw)) return -EIO; @@ -361,10 +389,15 @@ static void meson_clk_pll_disable(struct clk_hw *hw) struct meson_clk_pll_data *pll = meson_clk_pll_data(clk); /* Put the pll is in reset */ - meson_parm_write(clk->map, &pll->rst, 1); + if (MESON_PARM_APPLICABLE(&pll->rst)) + meson_parm_write(clk->map, &pll->rst, 1); /* Disable the pll */ meson_parm_write(clk->map, &pll->en, 0); + + /* Disable PLL internal self-adaption current module */ + if (MESON_PARM_APPLICABLE(&pll->current_en)) + meson_parm_write(clk->map, &pll->current_en, 0); } static int meson_clk_pll_set_rate(struct clk_hw *hw, unsigned long rate, diff --git a/drivers/clk/meson/clk-pll.h b/drivers/clk/meson/clk-pll.h index 367efd0f6410..a2228c0fdce5 100644 --- a/drivers/clk/meson/clk-pll.h +++ b/drivers/clk/meson/clk-pll.h @@ -36,6 +36,8 @@ struct meson_clk_pll_data { struct parm frac; struct parm l; struct parm rst; + struct parm current_en; + struct parm l_detect; const struct reg_sequence *init_regs; unsigned int init_count; const struct pll_params_table *table;