From patchwork Sun Oct 23 14:56:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aidan MacDonald X-Patchwork-Id: 8043 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp27791wru; Sun, 23 Oct 2022 08:01:07 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7t/BXDmQpDlg1YB91Hu2Hfo1CyJjpz+BY1fktI4okDsiP4/Meb//311DBPxvEZVnazwLzJ X-Received: by 2002:a05:6402:3484:b0:45d:2f59:fae1 with SMTP id v4-20020a056402348400b0045d2f59fae1mr26487682edc.237.1666537267068; Sun, 23 Oct 2022 08:01:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666537267; cv=none; d=google.com; s=arc-20160816; b=mrcD3L9cQ3jBZtMa1zHBfDT0FE0PKitsonVMGdv/D5OKKOy5Lftu34YoX+hmrz/8Gi rHqfsLabeqFv8psvakW5QvBa/7bOauMAMNXvELf+hWbCn/yzFF8oCS8VACk6ZqMy2ijY ZdB9e70KmDq4qbZx5kOWJTDq/J7QY5nrLb0NzHGsDg98mQB5/lltOV3brU5TkItheUGv m/ZwA9tpJFJTeaiGrVjDr23efACONkruNK2abiCF/M3vIlYdVwSTdXyazaKQ9ttyn1iz kNepNlZRhiXgQHs9sNYnl21qM8zFdHvLl58Gcj1B54JsfBx/hkYOMgWq3EwbOaaWB2G1 YVsQ== 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=Megb+EEQ+42EwfPZKfmRdUWZPZjTpyMy4vvWz7+p9e0=; b=kTdew9NFF7T/EK3RFHKO2CGIzEQW273lATUGRfgPGdP2bO7szBj3fhkVwmdCAMF3KS bbGz7pGTOz1aERQrgScRJnKcerZFGuV28G1ZRBO542A8XDd4pN52lTQ5c0JWXFXskmAP FXmObrCyK7PG98OFwH3aTxRRXY3QEUwlNCkY+VzESkHoXBeh0f38kSVUvf4pRijjoeeg a4yf/dt9q7wYOftNgvLgu3m90eKu2bn4Itv+s73ZCkWIrCbtr/8Quoy7d4St+y2TZjTq dJykaIWRugxihexkveyR1XaulTUEfrDMvx60MRQoVL3Jbia3DhRy3j4DBSV6yzEgPvAq /qdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=oItMR1ON; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id md5-20020a170906ae8500b00783c42d2da2si20620478ejb.415.2022.10.23.08.00.41; Sun, 23 Oct 2022 08:01:07 -0700 (PDT) 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=@gmail.com header.s=20210112 header.b=oItMR1ON; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230345AbiJWO5N (ORCPT + 99 others); Sun, 23 Oct 2022 10:57:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229515AbiJWO5J (ORCPT ); Sun, 23 Oct 2022 10:57:09 -0400 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 781F75D0C2; Sun, 23 Oct 2022 07:57:06 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id k8so3200229wrh.1; Sun, 23 Oct 2022 07:57:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Megb+EEQ+42EwfPZKfmRdUWZPZjTpyMy4vvWz7+p9e0=; b=oItMR1ONDqqX6HzyaBT/Azz2BaW1CA6mIhZhtTK0SZ+LRng8mlK5cgeBsExzuODo2p 543JHHhUZCEDttvrHHQga0rFTLsDudRpsuEerG6QRvLRfQKoOG3Cyffb90hrWx5QCWEh qnumNnm1EeVvzRmhEVlmnC8IQqgI72+gZntPT3zTBfCM4mDM97jALJa685OXbN7FM30U bXR3I3sy2nPv8AR2ZuHoLVFjGXTuHymYho2IHZJZ+7VMAGOgGNq2DerDjScqZeofoZmj EO5tMnUkbzNEGqVJo/GYo4Spnp0v2TCq+ykbISkX6K6gfH3KYpvbaVeW+gdQCdG7kxQP YgEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Megb+EEQ+42EwfPZKfmRdUWZPZjTpyMy4vvWz7+p9e0=; b=nRSMuTV8syTaPmpVrnOhzKpw6aZ/PDtGbFkWOZ3wk2vHce8hCy8EigQfr+qXleQUq6 KBJEhsgGZnjUrG6PIwIDRWqRPtVa3wgvyM8Bk0aykDjKn7QyG9MYhcJaITxO/AmlwFpU Q7emr/Ht2iSLXbwqpuT2wX15S4sL6FXqkzSc3CQfL7jw7UxYMEESMWUzDn+z/gx/T0IE efVVgTSCybi0lb7cMVDzL8PAtaQaTqNNpRKlFF+UMwg3dLRiVWFjxWwX8so4k6+y84Bf 9aC30YDF6pFU1TNLKGDwPFnSUr4ajfjZmEVCjibPDIFHY1cV6p6MBC7xaxB/XxtRMTcP 5/XQ== X-Gm-Message-State: ACrzQf1XaSxZV3k1X5/qsQVJ2K3wBIrWkxdEVmsuONFCN4e6ExSTm+D1 6YZjXBQHZ49Dom3QPX/IBGw= X-Received: by 2002:adf:f68a:0:b0:236:6e9b:dc91 with SMTP id v10-20020adff68a000000b002366e9bdc91mr1303344wrp.207.1666537026122; Sun, 23 Oct 2022 07:57:06 -0700 (PDT) Received: from localhost (94.197.10.75.threembb.co.uk. [94.197.10.75]) by smtp.gmail.com with ESMTPSA id r6-20020a5d52c6000000b00228dbf15072sm23603166wrv.62.2022.10.23.07.57.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Oct 2022 07:57:05 -0700 (PDT) From: Aidan MacDonald To: paul@crapouillou.net, mturquette@baylibre.com, sboyd@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org Cc: zhouyu@wanyeetech.com, linux-mips@vger.kernel.org, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 3/5] clk: ingenic: Add .set_rate_hook() for PLL clocks Date: Sun, 23 Oct 2022 15:56:51 +0100 Message-Id: <20221023145653.177234-4-aidanmacdonald.0x0@gmail.com> In-Reply-To: <20221023145653.177234-1-aidanmacdonald.0x0@gmail.com> References: <20221023145653.177234-1-aidanmacdonald.0x0@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,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?1747490981478146553?= X-GMAIL-MSGID: =?utf-8?q?1747490981478146553?= The set rate hook is called immediately after updating the clock register but before the spinlock is released. This allows another register to be updated alongside the main one, which is needed to handle the I2S divider on some SoCs. Signed-off-by: Aidan MacDonald --- drivers/clk/ingenic/cgu.c | 3 +++ drivers/clk/ingenic/cgu.h | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/drivers/clk/ingenic/cgu.c b/drivers/clk/ingenic/cgu.c index bbb55e8d8b55..574d5fe10fdf 100644 --- a/drivers/clk/ingenic/cgu.c +++ b/drivers/clk/ingenic/cgu.c @@ -233,6 +233,9 @@ ingenic_pll_set_rate(struct clk_hw *hw, unsigned long req_rate, writel(ctl, cgu->base + pll_info->reg); + if (pll_info->set_rate_hook) + pll_info->set_rate_hook(pll_info, rate, parent_rate); + /* If the PLL is enabled, verify that it's stable */ if (pll_info->enable_bit >= 0 && (ctl & BIT(pll_info->enable_bit))) ret = ingenic_pll_check_stable(cgu, pll_info); diff --git a/drivers/clk/ingenic/cgu.h b/drivers/clk/ingenic/cgu.h index a5e44ca7f969..99da9bd86e63 100644 --- a/drivers/clk/ingenic/cgu.h +++ b/drivers/clk/ingenic/cgu.h @@ -46,6 +46,8 @@ * -1 if there is no enable bit (ie, the PLL is always on) * @stable_bit: the index of the stable bit in the PLL control register, or * -1 if there is no stable bit + * @set_rate_hook: hook called immediately after updating the CGU register, + * before releasing the spinlock */ struct ingenic_cgu_pll_info { unsigned reg; @@ -61,6 +63,8 @@ struct ingenic_cgu_pll_info { void (*calc_m_n_od)(const struct ingenic_cgu_pll_info *pll_info, unsigned long rate, unsigned long parent_rate, unsigned int *m, unsigned int *n, unsigned int *od); + void (*set_rate_hook)(const struct ingenic_cgu_pll_info *pll_info, + unsigned long rate, unsigned long parent_rate); }; /**