From patchwork Wed Oct 26 19:43:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aidan MacDonald X-Patchwork-Id: 11423 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp454252wru; Wed, 26 Oct 2022 12:47:05 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4QZU4XhZIV4aTQtIdmRTziEGI1T5l5xMTpdcqHC822HJZnVpv2nPrFslWytsBmspHAvyXU X-Received: by 2002:a17:90a:4e85:b0:213:13f2:162b with SMTP id o5-20020a17090a4e8500b0021313f2162bmr6037638pjh.228.1666813625378; Wed, 26 Oct 2022 12:47:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666813625; cv=none; d=google.com; s=arc-20160816; b=YTlvEATMbqhPQHQ5CYiORb34gOonh37hKFbDfqfsXrgaD2Df+aLORSTfq+dX4DPLZ/ 3qlVDe3BqjK1Tk1OOKsAYOfD9kNADESt2HwXt6p/Y0YVZkmguW0HexQLLiq/E6ntDv2Y 9aQPDMaGX70gZo3NiLjIIJSk6zuVRkIAuWHjLc8hhSabIoBh68gZsD+swcFyBQxs8tmc rucnKzGkV4FeuD2reZs6pTPw61/MM07GNRQqW5whEEKBlehvHD+CxGPKtyO496Col8iZ X5Dolhdhp+RkpqwuLXNi+w2DP0iSDmyCLEJZrORPAvyTgFMRBCV3AnVcq401mAVZM9Hu HcBA== 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=20uxWCRsvxDQKcFPgK2zgFTA1dEWAdkZ4yr2nsg4cVM=; b=D0j98Rt2EvlBgTh4qGon0C/U107GymIyECgH+O6mNXVca6RpDP5MhisQVhnGQXe/Fp QKsckdPJ8EBxXMMrqOiS6HfLMuNST+cjhGCPKZwhDt9vsHCOLIEWmbbHWYczA/FDLWvO kFUp00GHVtLBWbYkqWAt86Ii6ChGWMUHbQUVBCvLnE/7ebWw+vYnCZ56IF6uOyZBMBw8 EQQNzxiCxlJPuucDyGVOmxArHiSfvCCoUpOlMf2hE+NcRHCMQfAx2gFFfyKWLgwlnM+K fdZi4hlzOvRlzHmdpuy949HnBg7jpn/ln73ghZJQG/+TTH5xwmF6FyPZ8XLUhnAopt6D kGiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=YUeEywwS; 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 q22-20020a170902789600b0017680ae3a9csi7200442pll.534.2022.10.26.12.46.52; Wed, 26 Oct 2022 12:47:05 -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=YUeEywwS; 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 S235218AbiJZTpN (ORCPT + 99 others); Wed, 26 Oct 2022 15:45:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235117AbiJZToh (ORCPT ); Wed, 26 Oct 2022 15:44:37 -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 134FB1217E7; Wed, 26 Oct 2022 12:43:56 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id y16so17741662wrt.12; Wed, 26 Oct 2022 12:43:56 -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=20uxWCRsvxDQKcFPgK2zgFTA1dEWAdkZ4yr2nsg4cVM=; b=YUeEywwSsDDC6VKwfhGJmdXAAkKNE9LeiHly+HMRUKJAVljKOXdhd7nqIbqyrNQTTI ZiF/V3W4Qw+gZXk7Gu1o3qK1w7/chrfcaWCgrtmA5E6C3Gwxq307tvC45ZOkb2VyrAuG +YTxSnA5xW6fCYA66HRGBtmRXq4jxlVa5yCn9p0hnKU6SfhedBWjYjr6+oAaLMWtA0QU R3775UnYGGf+h5kxKpTtUn8yAiEapUE9yeIY8siSl8F+6pJrGeDdWzcdGXdeTeOHxBUP 7YXB9FgvYVqIQRwJY+mKRMZFgLqcNbUn8veS0Z+KHThvhgl4SxVOnt6HMPRwFQpaDDSi 6zIw== 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=20uxWCRsvxDQKcFPgK2zgFTA1dEWAdkZ4yr2nsg4cVM=; b=RcKAA7QPI0MHqBwRoLPMGYPfUVlU/8SXSmYq1IPNPM9AyrV4dpcvHOxOnQC8rPSy3B 1cO5fayvLpeL8+GHiiPaafi8HmCvcVYnog+Bmt5KRfdOcYCx6NwmgrsCy5LCqj6wHjGt w5l9VEZq2kWOpzTdnggzMzdO1EQ5SdDref4ebGE5iXxgsy/d6w1F+gXWKNJIkRYcNgQD vIx6A5tOXLEukbEW0fHsP2cuO+9XpxpB+Z2fGw8YdtA4ntB4E1FsOv4M0l7ftXKp/HIT P1AbbG09U5ZIWtU7NqkcA0rME9CXHVwt/JoNP1Kz32TRwd385G5acycHAPfmcJW6gyHC nogQ== X-Gm-Message-State: ACrzQf1PsETkjL6KaDjBMK45Nz/sYewcObXMLgMyV0RlnT8pDrQ82/mh QXXm/t6NWXVVXycMxjqSenk= X-Received: by 2002:a5d:6e8e:0:b0:21d:ea5:710f with SMTP id k14-20020a5d6e8e000000b0021d0ea5710fmr30102020wrz.48.1666813435011; Wed, 26 Oct 2022 12:43:55 -0700 (PDT) Received: from localhost (188.28.0.84.threembb.co.uk. [188.28.0.84]) by smtp.gmail.com with ESMTPSA id m1-20020a5d6241000000b00228cd9f6349sm5756508wrv.106.2022.10.26.12.43.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Oct 2022 12:43:54 -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 v2 3/6] clk: ingenic: Add .set_rate_hook() for PLL clocks Date: Wed, 26 Oct 2022 20:43:42 +0100 Message-Id: <20221026194345.243007-4-aidanmacdonald.0x0@gmail.com> In-Reply-To: <20221026194345.243007-1-aidanmacdonald.0x0@gmail.com> References: <20221026194345.243007-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?1747780764361874236?= X-GMAIL-MSGID: =?utf-8?q?1747780764361874236?= 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 Reviewed-by: Paul Cercueil --- 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 aea01b6b2764..b6a4d4236c16 100644 --- a/drivers/clk/ingenic/cgu.c +++ b/drivers/clk/ingenic/cgu.c @@ -232,6 +232,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); }; /**