From patchwork Wed Oct 26 19:43:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aidan MacDonald X-Patchwork-Id: 11417 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp453949wru; Wed, 26 Oct 2022 12:46:15 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7KvOvcg7WsP/tzt413Kh4RFC6ERBjh3RHZ6D9sizNqm9Kf1My3w3rfGplmssf7ebbpAXpe X-Received: by 2002:a17:907:3f28:b0:7ad:88f8:7644 with SMTP id hq40-20020a1709073f2800b007ad88f87644mr1073723ejc.738.1666813575673; Wed, 26 Oct 2022 12:46:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666813575; cv=none; d=google.com; s=arc-20160816; b=TcJlzMYfOE7lwwd52BM01t75E2gFHyfAlbWeTU4LAuhM/kWTtvv5zrj0fY0Jzd7rRs Hmz3TVKPGFPxzE+jXVo/67vWhF1nuHT2Wa0feaZrXCWbDkftJhlCfS5ttUI9L0EjqRlS /03lg/Wciy96WoDGbVWw633rrusm5yz9G5f2mGuxfxWaFRbGHadlRe09Ux1v4aune5gs 05A5pmlmzDwnDJ3PMCejxjK1VeTLdSPfNixtAPhf7EQAlE/6tkp4s+5m66C/NaOicGEk uOYyunwkVC8YViCcXSb4mU4GhFngVUkN86nadFtMEY/xMM5TMjOWdkw+IZKS6FWn20Bk eifw== 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=S3wzvnP281wsIY8W0hDmhg1Q7a/VEKLP9u/BDdUNrjY=; b=lcDbg8Y/J3H22pabgwa+Y2CnTlsLyCcmrtg9MtKRhqQ++fpaRbSMIyR7Tlv4Oagi6H hSi35crVrIB/9d53D8QyCn62vAzygOFWUpywzRiTW3K3/rziyJVRsbS/lgd8/A9nrB/N DzD/gZOxghinGegcwhbdRFpOHdigmy169AK+9QOdlx4YJ7akfxufTZjx+M4Axefqxl3B oS2ZdXQwkefF1CAayG4+fqhfqYxA4cDKCC0GwQY9Q/+A7pn9p/AjfqQbNvgmlJoUZ6y8 wHDrJnyO15LZXjduQRD2VXQ6lzdVnkIaaMoT4Y4ZfYfjdueNciA6645ci/uVY9nCsXw9 efdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=NVWODTQo; 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 dr18-20020a170907721200b0078e11a20640si3114704ejc.2.2022.10.26.12.45.51; Wed, 26 Oct 2022 12:46:15 -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=NVWODTQo; 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 S235206AbiJZTpA (ORCPT + 99 others); Wed, 26 Oct 2022 15:45:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234464AbiJZTo0 (ORCPT ); Wed, 26 Oct 2022 15:44:26 -0400 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF1E811702B; Wed, 26 Oct 2022 12:43:54 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id bh7-20020a05600c3d0700b003c6fb3b2052so2457415wmb.2; Wed, 26 Oct 2022 12:43:53 -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=S3wzvnP281wsIY8W0hDmhg1Q7a/VEKLP9u/BDdUNrjY=; b=NVWODTQo1MuSH/3YcKKl35yfcQ4wT6QhkgkloNMsK28VL5opem6b7V1Sji0nlnPNIE jvpUT+MnqIARPp47U9m7/6/Lu6I7bP508kdTsaKTQL1vzfqPZdzOLtMTAMJelPn59+bi uRi8keC05PeFdSpTs74oeP5Nocck+HxEmyeDBoVTd3uXwazQ1ijom5hbD1JFqHx1xOEj L2JwVKicPIt0LIEwmWwmQUCjtbtPpBMWEsIeS+ynMjgCZj8f5cg5B69ppk4zayQdqAZ6 fb7UjV/DVazK9+Vb0Rrdi8ENuliIhoT6k2pRnN++vXf48IJGDfwXDBGREGPOl4Wgt+7o UKLw== 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=S3wzvnP281wsIY8W0hDmhg1Q7a/VEKLP9u/BDdUNrjY=; b=0xs5cEtaQQxdQRaaETvu7DsKacBdOnNldJ+lKIFe/tf2jNndBDZtmyEzcQO8lEWWZ1 XrK+i9s4kkc5pqIPrAWdiIgQMivALkgEoIJBmgXdmz5wA/QU70UrYPCAU6iuNj2YKIL9 FFvER+o1/MI4O7ER029jk91arh2rOs7Rfzy5Wog+btgRtEyWK8b5kxM2ab8FJfZMtR3v 0bQ3ceFiIrgDt4yq5uFymc++8BDRqDFXvo4zl95b4M0L8DmGHym/knL3N7eBxwnbrr4W ovOCljJRFvu6Q1oVUqPclk4Q4H56xHgrPom7IZbq6I+ypW7eqUvmmqmv3CEBeFWybu1E FKxw== X-Gm-Message-State: ACrzQf3yG13hJQYyQ+eZSYmGrouZgkaIxWo7BXUI3PGiFQrkm7w25W8j 5MP6BDwEDsUkyL0OhkbrTBAnHm4rkqjMpQ== X-Received: by 2002:a05:600c:4e45:b0:3cf:3e69:9351 with SMTP id e5-20020a05600c4e4500b003cf3e699351mr3660796wmq.2.1666813432452; Wed, 26 Oct 2022 12:43:52 -0700 (PDT) Received: from localhost (188.28.0.84.threembb.co.uk. [188.28.0.84]) by smtp.gmail.com with ESMTPSA id a11-20020adfe5cb000000b0023655e51c33sm6070660wrn.4.2022.10.26.12.43.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Oct 2022 12:43:52 -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 1/6] clk: ingenic: Make PLL clock "od" field optional Date: Wed, 26 Oct 2022 20:43:40 +0100 Message-Id: <20221026194345.243007-2-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?1747780711799811788?= X-GMAIL-MSGID: =?utf-8?q?1747780711799811788?= Add support for defining PLL clocks with od_bits = 0, meaning that OD is fixed to 1 and there is no OD field in the register. In this case od_max must also be 0, which is enforced with BUG_ON(). Signed-off-by: Aidan MacDonald Reviewed-by: Paul Cercueil --- v1 -> v2: Simplify od lookup in ingenic_pll_recalc_rate() and enforce od_max == 0 when od_bits is zero. drivers/clk/ingenic/cgu.c | 21 +++++++++++++++------ drivers/clk/ingenic/cgu.h | 3 ++- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/drivers/clk/ingenic/cgu.c b/drivers/clk/ingenic/cgu.c index 861c50d6cb24..3481129114b1 100644 --- a/drivers/clk/ingenic/cgu.c +++ b/drivers/clk/ingenic/cgu.c @@ -83,7 +83,7 @@ ingenic_pll_recalc_rate(struct clk_hw *hw, unsigned long parent_rate) const struct ingenic_cgu_clk_info *clk_info = to_clk_info(ingenic_clk); struct ingenic_cgu *cgu = ingenic_clk->cgu; const struct ingenic_cgu_pll_info *pll_info; - unsigned m, n, od_enc, od; + unsigned m, n, od, od_enc = 0; bool bypass; u32 ctl; @@ -96,8 +96,11 @@ ingenic_pll_recalc_rate(struct clk_hw *hw, unsigned long parent_rate) m += pll_info->m_offset; n = (ctl >> pll_info->n_shift) & GENMASK(pll_info->n_bits - 1, 0); n += pll_info->n_offset; - od_enc = ctl >> pll_info->od_shift; - od_enc &= GENMASK(pll_info->od_bits - 1, 0); + + if (pll_info->od_bits > 0) { + od_enc = ctl >> pll_info->od_shift; + od_enc &= GENMASK(pll_info->od_bits - 1, 0); + } if (pll_info->bypass_bit >= 0) { ctl = readl(cgu->base + pll_info->bypass_reg); @@ -112,7 +115,11 @@ ingenic_pll_recalc_rate(struct clk_hw *hw, unsigned long parent_rate) if (pll_info->od_encoding[od] == od_enc) break; } - BUG_ON(od == pll_info->od_max); + /* if od_max = 0, od_bits should be 0 and od is fixed to 1. */ + if (pll_info->od_max == 0) + BUG_ON(pll_info->od_bits != 0); + else + BUG_ON(od == pll_info->od_max); od++; return div_u64((u64)parent_rate * m * pll_info->rate_multiplier, @@ -215,8 +222,10 @@ ingenic_pll_set_rate(struct clk_hw *hw, unsigned long req_rate, ctl &= ~(GENMASK(pll_info->n_bits - 1, 0) << pll_info->n_shift); ctl |= (n - pll_info->n_offset) << pll_info->n_shift; - ctl &= ~(GENMASK(pll_info->od_bits - 1, 0) << pll_info->od_shift); - ctl |= pll_info->od_encoding[od - 1] << pll_info->od_shift; + if (pll_info->od_bits > 0) { + ctl &= ~(GENMASK(pll_info->od_bits - 1, 0) << pll_info->od_shift); + ctl |= pll_info->od_encoding[od - 1] << pll_info->od_shift; + } writel(ctl, cgu->base + pll_info->reg); diff --git a/drivers/clk/ingenic/cgu.h b/drivers/clk/ingenic/cgu.h index 147b7df0d657..567142b584bb 100644 --- a/drivers/clk/ingenic/cgu.h +++ b/drivers/clk/ingenic/cgu.h @@ -33,7 +33,8 @@ * @od_shift: the number of bits to shift the post-VCO divider value by (ie. * the index of the lowest bit of the post-VCO divider value in * the PLL's control register) - * @od_bits: the size of the post-VCO divider field in bits + * @od_bits: the size of the post-VCO divider field in bits, or 0 if no + * OD field exists (then the OD is fixed to 1) * @od_max: the maximum post-VCO divider value * @od_encoding: a pointer to an array mapping post-VCO divider values to * their encoded values in the PLL control register, or -1 for From patchwork Wed Oct 26 19:43:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aidan MacDonald X-Patchwork-Id: 11420 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp454076wru; Wed, 26 Oct 2022 12:46:37 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5lRYTsYznebGvyjZL2eaegMpsxQKJz/xIHsg+46JrrPneigfNuBleAqaassdCHL3Txf9Ai X-Received: by 2002:a17:902:f545:b0:186:c372:7536 with SMTP id h5-20020a170902f54500b00186c3727536mr10159177plf.116.1666813597327; Wed, 26 Oct 2022 12:46:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666813597; cv=none; d=google.com; s=arc-20160816; b=ItE3q1phUqVWRGl3tdVolYmbOT8z3xFTzEc9BQSy0YLHT3E6msMUSmawtOMhKgAfl9 bNx7LSJ1v5a3eRXJzn3ZPHo0YIcDQy6/e/NenJMeTu0qcJfAf4VPG4PI03ipOBAIioJO A3Q286qEigaYMY3GiqrGaJo1c280/Q1PVtwb4jiXFHWcWvvjDfW7NZ4eyLd6iXJ0REID 1WQd70MsYWeywv8nXu06Hpj9gGgDHS2mU7CCwM+PMoSNlwQbbm2eW1IUwkXMstbSneFl fv7iwunXefQjTLpZUPCV7oGgoChfOPpnlbkvRW00eSwoc1Gain0J0PNipAcTbhXIUzOI lHWw== 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=zGJrn1iV918qT9icSbWslaEq4iQ5MQF0+KuFL8SD6t0=; b=OuGXIf0Ifi/n8m/60h3HAWuWyDyP5OFtBAW1Pr84lhQJQdMdQsmj963fsBwTJOAnmv jqYDpvRFfxTALDEhHN5GCwvUX1rA9S5DhPDPCVc6HHtp2I1nZw+e/7sUWWHxO5zRC9u+ LXRzC+fViCzifZpnDkKAeLR4yAk8YyhMSYKa0gG2sSOXdOt2wlmOh30hXLng7xxmDIKP aiGiSIT7Cm8SeBVF1zVmQoTtSCxovFoK8DVx/8c6HGWujPnn37ftVMGmzSJCggkzUdtk CZK6WzIKkwnxLBAguB3KRIxBQquYo1WHPvpK/jlzxyQ/oZshUvWIYT0M86W3yCDofRv+ OnOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=aSRXm7jj; 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 v3-20020a170902ca8300b001747ed48ee8si6477266pld.150.2022.10.26.12.46.24; Wed, 26 Oct 2022 12:46:37 -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=aSRXm7jj; 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 S234874AbiJZTpG (ORCPT + 99 others); Wed, 26 Oct 2022 15:45:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235009AbiJZTo3 (ORCPT ); Wed, 26 Oct 2022 15:44:29 -0400 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 228C4122755; Wed, 26 Oct 2022 12:43:55 -0700 (PDT) Received: by mail-wm1-x331.google.com with SMTP id c3-20020a1c3503000000b003bd21e3dd7aso2382373wma.1; Wed, 26 Oct 2022 12:43:55 -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=zGJrn1iV918qT9icSbWslaEq4iQ5MQF0+KuFL8SD6t0=; b=aSRXm7jjodvkIZM9W6xhX0/gt7SF1AXEejbEn22oKoTkAd4YKvJAdbQPPbbssgQxRh soTeFxML4/fdESdB4RneLROvcQITwypXYpR+HAWHhDmH7RHeEFRmpMTYVGJk6Ucg1bwj YwmpzwS8ThZKTgqhW8y9eK269D0kxcRduTzkTrxSk2qOzzirCKPblL6yY/P3oHwBMZjm lu8DPtSFPvoQa/dnlO4g3N7nPTbMOhB46NG1VLayLl/TGqKBgGMjJR5xJSAn0oyVdSxn 7yoiwr7ijdtSPZTx/TUoNff2evwB25lmitNroZE7Wdz/x7HP/ck+twk8vBJ0AapiTdWO u1Uw== 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=zGJrn1iV918qT9icSbWslaEq4iQ5MQF0+KuFL8SD6t0=; b=qGyqOKVKyaSMwilNn92jm7yCS6hgflZIuvZmRgxsEnz/zrgB24EuZRr8kEbdxcbSL1 +GvNoua/n+2ds5IHhdAgxPopRojGcat9Ai0dfn2hud8X7W7IxCyCuAs+4GePhj8heljs EnL0md5ScQlvF/GOafMAALq0iJLlFHmfN2bNTp0S7VjDblkfaozDm0+Cxe1/Jvu2HKPl ittueXPei+pYJGyTgnRbEiL+BMwmj/zeRaFwqm7feiqR3ELmQpHrP/81qRs1OSOzxF/n 8Qjo7QofMRXHVvSIW340wFlPSMXyoIDgHhx4xtLTjZYPWOa2sb34BOEX98Ds1pQ4bhP2 bVxw== X-Gm-Message-State: ACrzQf1+PaeIcGBkdoi59Z1IadRPS7xA++TSfUUk/50mtl3IJ+11wo3s bOgvBm+YB6C0xNCglgs4mAc= X-Received: by 2002:a05:600c:4691:b0:3c6:f154:fdc6 with SMTP id p17-20020a05600c469100b003c6f154fdc6mr3585705wmo.195.1666813433801; Wed, 26 Oct 2022 12:43:53 -0700 (PDT) Received: from localhost (188.28.0.84.threembb.co.uk. [188.28.0.84]) by smtp.gmail.com with ESMTPSA id f12-20020a05600c4e8c00b003c6c1686b10sm3212824wmq.7.2022.10.26.12.43.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Oct 2022 12:43:53 -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 2/6] clk: ingenic: Make PLL clock enable_bit and stable_bit optional Date: Wed, 26 Oct 2022 20:43:41 +0100 Message-Id: <20221026194345.243007-3-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?1747780734938586581?= X-GMAIL-MSGID: =?utf-8?q?1747780734938586581?= When the enable bit is undefined, the clock is assumed to be always on and enable/disable is a no-op. When the stable bit is undefined, the PLL stable check is a no-op. Signed-off-by: Aidan MacDonald Reviewed-by: Paul Cercueil --- drivers/clk/ingenic/cgu.c | 14 +++++++++++++- drivers/clk/ingenic/cgu.h | 10 ++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/drivers/clk/ingenic/cgu.c b/drivers/clk/ingenic/cgu.c index 3481129114b1..aea01b6b2764 100644 --- a/drivers/clk/ingenic/cgu.c +++ b/drivers/clk/ingenic/cgu.c @@ -189,6 +189,9 @@ static inline int ingenic_pll_check_stable(struct ingenic_cgu *cgu, { u32 ctl; + if (pll_info->stable_bit < 0) + return 0; + return readl_poll_timeout(cgu->base + pll_info->reg, ctl, ctl & BIT(pll_info->stable_bit), 0, 100 * USEC_PER_MSEC); @@ -230,7 +233,7 @@ ingenic_pll_set_rate(struct clk_hw *hw, unsigned long req_rate, writel(ctl, cgu->base + pll_info->reg); /* If the PLL is enabled, verify that it's stable */ - if (ctl & BIT(pll_info->enable_bit)) + if (pll_info->enable_bit >= 0 && (ctl & BIT(pll_info->enable_bit))) ret = ingenic_pll_check_stable(cgu, pll_info); spin_unlock_irqrestore(&cgu->lock, flags); @@ -248,6 +251,9 @@ static int ingenic_pll_enable(struct clk_hw *hw) int ret; u32 ctl; + if (pll_info->enable_bit < 0) + return 0; + spin_lock_irqsave(&cgu->lock, flags); if (pll_info->bypass_bit >= 0) { ctl = readl(cgu->base + pll_info->bypass_reg); @@ -278,6 +284,9 @@ static void ingenic_pll_disable(struct clk_hw *hw) unsigned long flags; u32 ctl; + if (pll_info->enable_bit < 0) + return; + spin_lock_irqsave(&cgu->lock, flags); ctl = readl(cgu->base + pll_info->reg); @@ -295,6 +304,9 @@ static int ingenic_pll_is_enabled(struct clk_hw *hw) const struct ingenic_cgu_pll_info *pll_info = &clk_info->pll; u32 ctl; + if (pll_info->enable_bit < 0) + return true; + ctl = readl(cgu->base + pll_info->reg); return !!(ctl & BIT(pll_info->enable_bit)); diff --git a/drivers/clk/ingenic/cgu.h b/drivers/clk/ingenic/cgu.h index 567142b584bb..a5e44ca7f969 100644 --- a/drivers/clk/ingenic/cgu.h +++ b/drivers/clk/ingenic/cgu.h @@ -42,8 +42,10 @@ * @bypass_reg: the offset of the bypass control register within the CGU * @bypass_bit: the index of the bypass bit in the PLL control register, or * -1 if there is no bypass bit - * @enable_bit: the index of the enable bit in the PLL control register - * @stable_bit: the index of the stable bit in the PLL control register + * @enable_bit: the index of the enable bit in the PLL control register, or + * -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 */ struct ingenic_cgu_pll_info { unsigned reg; @@ -54,8 +56,8 @@ struct ingenic_cgu_pll_info { u8 od_shift, od_bits, od_max; unsigned bypass_reg; s8 bypass_bit; - u8 enable_bit; - u8 stable_bit; + s8 enable_bit; + s8 stable_bit; 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); 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); }; /** From patchwork Wed Oct 26 19:43:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aidan MacDonald X-Patchwork-Id: 11418 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp454018wru; Wed, 26 Oct 2022 12:46:28 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5nNNPEUEXcR9wPycxepW+1odUjtCzUi7Ac0fgAX7Opusv+h4qJoBbm8R64sliiROfzjPXE X-Received: by 2002:a17:902:f602:b0:178:9818:48a4 with SMTP id n2-20020a170902f60200b00178981848a4mr45404844plg.148.1666813588058; Wed, 26 Oct 2022 12:46:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666813588; cv=none; d=google.com; s=arc-20160816; b=NmpF/OlYlauCI8cDvDiJ3BZRjLvy7DL1XI505OdKnlmaIioz1N9mpj6a9kegEsCx8a V9hDgUk4gGDBpq6sYSe6GhNM240RySEHfjshD3J7ESJnw8s5036TkVACAXIywlKCgLuT hW6QI1R7G8Nd2M2ukwVxzgke0YAY2cIep9kQ20kgmDt7/4Yo2I9jTlw8IeUKWr70B1+U 7qeIjObuv6rssRPcEDDUAFIDjClNFDNFZxANsp7ZsjKiiwy5BEZu2llf1ujO3stQjn9T b6E+oq/ZrPDBy+1VakyXQMbyLjSTKE9x18yEdxxSbpcQhsUeNQRqjiZknXN8SC5ipMBN es+A== 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=enN+JfcsaDXa2cFHCiOAb6Z57pSU23621zQPBj32zvs=; b=AC886cr+Fc/Mf8aP4HulVD6AurTS03x7Y8yTxM7PePxapg3Ks7EghSIEOa7+tiUs+A x6ILk+xcQbztx4idnN3Nn02k+Wl15I846vrTejYw68vUVIb3ZvGaRMEFS71BxorFOwJt HbAu1cikcscPCzI6lKaQVmK7ltpKS1Fh84XKeQIIhVsjp07dpow6gfrDL8n1VZI7rGb5 lw+13SBLRX6LICxAJYtIN8XOEsTo0j4I2NWMvaSwSs3OlAQU3KaTcAYPCHQQa2lp3Kmo QGxvKxPEBexNYaCuZ7UnNOM4JbjeYDCjbwQ7ebRf7cg90pC1Fv020MoCOsEK0mCXXYQw nndQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=LwdDy+ti; 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 j8-20020a17090a7e8800b002131bb4043asi3176668pjl.177.2022.10.26.12.46.13; Wed, 26 Oct 2022 12:46:28 -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=LwdDy+ti; 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 S235213AbiJZTpJ (ORCPT + 99 others); Wed, 26 Oct 2022 15:45:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235116AbiJZTog (ORCPT ); Wed, 26 Oct 2022 15:44:36 -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 13A0A1162C8; Wed, 26 Oct 2022 12:43:57 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id z14so14697245wrn.7; Wed, 26 Oct 2022 12:43:57 -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=enN+JfcsaDXa2cFHCiOAb6Z57pSU23621zQPBj32zvs=; b=LwdDy+tiu6RjxY0XYCCV76OkRNj/OrpUACc1xi+94nVr/cJouw4MpkEJJSth14qGI5 K5+69ycQeSwc5M25pQhco3ToA0kU41N7oStJLaVDBx01z9RKXVCFIXX9FsFinRlvZr2w RVbtMSdIQ1MDwBvkdF/0lEUV6xU6Xh5AHxX1GvlMvC9BklcUVjEHHpAxZqHkBg0bIGrf neTgNrm/fV9+AiV4awcbJM432ocDcdXRo+TuFXc+xfR7kB0ZQtEzCBjup8jmSsur9Jnb g2n09hiCL6gMRkqnR5yzvx8YmIPs4teVZU6XQl5ThhffLQpKKtYPJOup3wzKXdgZCWOY QLIA== 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=enN+JfcsaDXa2cFHCiOAb6Z57pSU23621zQPBj32zvs=; b=F4WGYfKDBI3moYC8/Y0evUJGW8p3fofTu0vMkj92d0X8sUT86+qMMht/t/fnWqu/Pz MBQk5c30LA4QpcJQYG25nCl5YIcpjaFgB9vL2Ul896hqvNGZOKFXtaoJObS051vOvFQQ raIfCbkwHXgCyB9yvMbmRtJvZPmHTtH8efobQYxZ1Ij5y9fPDVbqdAGkXLpxDk7gaFJ5 f4wiUed+F1p7uFgCH4BsT8XlZBlSCEIc30SE/TqudheFzNOJ4Dlrmr08iKP3MpN8n07f BQ4YP8CRVvbd3nh9ljE5b6uv2ZBvlI7ARnAG6qyk71MnKKiXHsn2IIGebgSIjcv7dEwV 1Gxw== X-Gm-Message-State: ACrzQf03pDDoBDjPhsTgWQL9m8m9539PIXchi1s4eaWBUBXpMe9K6CUf AuZeN1wn03kieWsqt9f33vLOkfG5kAwOSA== X-Received: by 2002:adf:e94a:0:b0:236:6f5a:e89b with SMTP id m10-20020adfe94a000000b002366f5ae89bmr12534700wrn.451.1666813436252; Wed, 26 Oct 2022 12:43:56 -0700 (PDT) Received: from localhost (188.28.0.84.threembb.co.uk. [188.28.0.84]) by smtp.gmail.com with ESMTPSA id bs14-20020a056000070e00b002366553eca7sm5658365wrb.83.2022.10.26.12.43.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Oct 2022 12:43:55 -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, Krzysztof Kozlowski Subject: [PATCH v2 4/6] dt-bindings: ingenic,x1000-cgu: Add audio clocks Date: Wed, 26 Oct 2022 20:43:43 +0100 Message-Id: <20221026194345.243007-5-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?1747780725186613361?= X-GMAIL-MSGID: =?utf-8?q?1747780725186613361?= Add bindings for audio-related clocks on the Ingenic X1000 SoC. Acked-by: Krzysztof Kozlowski Signed-off-by: Aidan MacDonald --- include/dt-bindings/clock/ingenic,x1000-cgu.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/dt-bindings/clock/ingenic,x1000-cgu.h b/include/dt-bindings/clock/ingenic,x1000-cgu.h index f187e0719fd3..78daf44b3514 100644 --- a/include/dt-bindings/clock/ingenic,x1000-cgu.h +++ b/include/dt-bindings/clock/ingenic,x1000-cgu.h @@ -50,5 +50,9 @@ #define X1000_CLK_PDMA 35 #define X1000_CLK_EXCLK_DIV512 36 #define X1000_CLK_RTC 37 +#define X1000_CLK_AIC 38 +#define X1000_CLK_I2SPLLMUX 39 +#define X1000_CLK_I2SPLL 40 +#define X1000_CLK_I2S 41 #endif /* __DT_BINDINGS_CLOCK_X1000_CGU_H__ */ From patchwork Wed Oct 26 19:43:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aidan MacDonald X-Patchwork-Id: 11422 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp454181wru; Wed, 26 Oct 2022 12:46:54 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6dnmbrwezHYfVifYmRGH6LNcUw7UAfgZSgHjulpb/VhgkBK3ICpNX74jmnTuuIxvCLUwS3 X-Received: by 2002:a65:4c0c:0:b0:45f:f12d:f46f with SMTP id u12-20020a654c0c000000b0045ff12df46fmr3933360pgq.579.1666813613925; Wed, 26 Oct 2022 12:46:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666813613; cv=none; d=google.com; s=arc-20160816; b=yD5eWyg7t7/TJIwvz3ocIdCpLjXkG6PAk+kxoc8jA0zco+jneWZzd/DmDnx+fMtKcI Fewbd77yP9BHVjnSL8bSk83b63Drr2GhixAc0qUFa1CFQc3S3gHxH6OsQ3ZCONtTwqdy OkeoZ/Up5GqzJ/gaT50wjiSCPAcIG8CK2OICIdvoDl48IcnIOKBcI55y1F6uxA1t53sb 3kh4w9YlI16JsoRhoKLxkWmyi+V6YWAEh0jAuBVix3026sWUlOwUETmuARwBkrtLEDwy PPYjD2PhXQ4QxLPsyLM0spCsv6j7W+atRUgw1npzyfxP5exejzRh+XhKRokN65dKZTFl wxvA== 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=lE6azSuCc8EUqYAerwdd+9S9IPnt0PRo5gKWCPKCQOE=; b=H1o2o8uQcHeO/fC9wL7ZkhJmOD2eqz1Y8P4n9QewZpHAOACY6nF2XDUv7lv2ba6fMI cMN03tIMhWlDk3N/SJR1XcsBOqNAz1hr/euPasne9x7ZRxoBZ2JZNJvggiNqLKHVPwwA wbsYjOLO7SdyThpBiHs0fFfLS99kSYfof31PWzFDDCYqka4YVbsH5Mo5Dd7Qvx3k3SZI 4/78bdWd7ICndXV5kWUrA1zqbk+eb9Oxkc8df5tCqucbCQ7MWNxvU+w5bvUq/Jdz2oY7 B/cuJOvraO1y+qOFX41e1k2vmPBEZVx77rKwBGedAp91vpJAjMn+DrF0bUOhoTxbZ71C ljDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ILlvEt42; 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 d15-20020a630e0f000000b0046439853c62si7881735pgl.127.2022.10.26.12.46.41; Wed, 26 Oct 2022 12:46:53 -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=ILlvEt42; 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 S235238AbiJZTpl (ORCPT + 99 others); Wed, 26 Oct 2022 15:45:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235042AbiJZTox (ORCPT ); Wed, 26 Oct 2022 15:44:53 -0400 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4A0A11A952; Wed, 26 Oct 2022 12:44:09 -0700 (PDT) Received: by mail-wr1-x434.google.com with SMTP id g12so15407491wrs.10; Wed, 26 Oct 2022 12:44:09 -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=lE6azSuCc8EUqYAerwdd+9S9IPnt0PRo5gKWCPKCQOE=; b=ILlvEt429LwkbGO7/in9jQqADis59od+azklEB/jfc98bCoKyKuCmRAB34MdGZh3Gy GsgNolEvGZSn5+u9LCTFWB9++W/XgkzyPw4cmH9DsVp90wuUTnEVtKkcc9YU+J377YpT eqAvzFFboYQDMh8TcHonaYtS1rRU3vq4AHd/MGTb1RNwCGR6TwMbN1IBJ9sLQ33M72j3 dpPQbC4+nlKDsJ2hfrwJKonBiuswwB9w6Tzv/xTQ+Tf/ye5EM/0npCwKA2dCjHgAxyHN /e4jS5lSyyP+uuFIcYw3Zdqv/u7Bw4fJZJDK8jB+DBeNEOdrE+wXW5ITSYgMwzPIe1DM OC1w== 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=lE6azSuCc8EUqYAerwdd+9S9IPnt0PRo5gKWCPKCQOE=; b=oVtjCt5bhubIlQWQEuxyUTbTDviMVYrsGQ4/4HtOAclu6xVwIerGVjPlEuofu9Pfn7 sr6uESrU3isVgQU8o+xlCm1z9yuMe6thRsGV0aNyfGhGPlM0Wqy2uRksicM18bIPeUhs 3qGsiGgFofK8c1S6BVs+wzH4EEbcRMD/L8y1iE/SWd1N3L83Axk02ukOmxY4Fepmw3z4 VvnU0zJ+1A7pAzodm5jquiSyMwaJq6ZDJBEEVaPbgQdn/Y4Dj7uIMMIOx4V25mxUlieJ dPldgtPei7va/hjARIGL6SdWsB+/O0uIlOePSl1+9w5vMis926mHzPjKf/s1d5TqwzSk 2/ZQ== X-Gm-Message-State: ACrzQf0T2eXTBmcDtpx5kz6H2Po6U9fO2VVTA7ibOPEjGzi9p6igalqg LEigoob2goAdTNi3LP7Yzs6NLtcLg/BaKg== X-Received: by 2002:a5d:6488:0:b0:22b:3b0b:5e72 with SMTP id o8-20020a5d6488000000b0022b3b0b5e72mr30550771wri.138.1666813437470; Wed, 26 Oct 2022 12:43:57 -0700 (PDT) Received: from localhost (188.28.0.84.threembb.co.uk. [188.28.0.84]) by smtp.gmail.com with ESMTPSA id m12-20020a05600c3b0c00b003b47ff307e1sm2754724wms.31.2022.10.26.12.43.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Oct 2022 12:43:57 -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 5/6] clk: ingenic: Add X1000 audio clocks Date: Wed, 26 Oct 2022 20:43:44 +0100 Message-Id: <20221026194345.243007-6-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?1747780752038378602?= X-GMAIL-MSGID: =?utf-8?q?1747780752038378602?= The X1000's CGU supplies the I2S system clock to the AIC module and ultimately the audio codec, represented by the "i2s" clock. It is a simple mux which can either pass through EXCLK or a PLL multiplied by a fractional divider (the "i2s_pll" clock). The AIC contains a separate 1/N divider controlled by the I2S driver, which generates the bit clock from the system clock. The frame clock is always fixed to 1/64th of the bit clock. Signed-off-by: Aidan MacDonald Reviewed-by: Paul Cercueil --- v1 -> v2: * Fix I2SCDR1 refresh to ensure the register is properly initialized and we don't rely on the reset value. Since the I2SDIV_D field can be automatically calculated by the hardware we don't need to provide it, writing 0 triggers the auto calculation. * Remove redundant -1 entries from parent clocks. drivers/clk/ingenic/x1000-cgu.c | 70 +++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/drivers/clk/ingenic/x1000-cgu.c b/drivers/clk/ingenic/x1000-cgu.c index b2ce3fb83f54..95d5e3a44cee 100644 --- a/drivers/clk/ingenic/x1000-cgu.c +++ b/drivers/clk/ingenic/x1000-cgu.c @@ -8,6 +8,7 @@ #include #include #include +#include #include @@ -168,6 +169,38 @@ static const struct clk_ops x1000_otg_phy_ops = { .is_enabled = x1000_usb_phy_is_enabled, }; +static void +x1000_i2spll_calc_m_n_od(const struct ingenic_cgu_pll_info *pll_info, + unsigned long rate, unsigned long parent_rate, + unsigned int *pm, unsigned int *pn, unsigned int *pod) +{ + const unsigned long m_max = GENMASK(pll_info->m_bits - 1, 0); + const unsigned long n_max = GENMASK(pll_info->n_bits - 1, 0); + unsigned long m, n; + + rational_best_approximation(rate, parent_rate, m_max, n_max, &m, &n); + + /* n should not be less than 2*m */ + if (n < 2 * m) + n = 2 * m; + + *pm = m; + *pn = n; + *pod = 1; +} + +static void +x1000_i2spll_set_rate_hook(const struct ingenic_cgu_pll_info *pll_info, + unsigned long rate, unsigned long parent_rate) +{ + /* + * Writing 0 causes I2SCDR1.I2SDIV_D to be automatically recalculated + * based on the current value of I2SCDR.I2SDIV_N, which is needed for + * the divider to function correctly. + */ + writel(0, cgu->base + CGU_REG_I2SCDR1); +} + static const s8 pll_od_encoding[8] = { 0x0, 0x1, -1, 0x2, -1, -1, -1, 0x3, }; @@ -319,6 +352,37 @@ static const struct ingenic_cgu_clk_info x1000_cgu_clocks[] = { .gate = { CGU_REG_CLKGR, 25 }, }, + [X1000_CLK_I2SPLLMUX] = { + "i2s_pll_mux", CGU_CLK_MUX, + .parents = { X1000_CLK_SCLKA, X1000_CLK_MPLL }, + .mux = { CGU_REG_I2SCDR, 31, 1 }, + }, + + [X1000_CLK_I2SPLL] = { + "i2s_pll", CGU_CLK_PLL, + .parents = { X1000_CLK_I2SPLLMUX }, + .pll = { + .reg = CGU_REG_I2SCDR, + .rate_multiplier = 1, + .m_shift = 13, + .m_bits = 9, + .n_shift = 0, + .n_bits = 13, + .calc_m_n_od = x1000_i2spll_calc_m_n_od, + .set_rate_hook = x1000_i2spll_set_rate_hook, + }, + }, + + [X1000_CLK_I2S] = { + "i2s", CGU_CLK_MUX, + .parents = { X1000_CLK_EXCLK, -1, -1, X1000_CLK_I2SPLL }, + /* + * NOTE: the mux is at bit 30; bit 29 enables the M/N divider. + * Therefore, the divider is disabled when EXCLK is selected. + */ + .mux = { CGU_REG_I2SCDR, 29, 2 }, + }, + [X1000_CLK_LCD] = { "lcd", CGU_CLK_MUX | CGU_CLK_DIV | CGU_CLK_GATE, .parents = { X1000_CLK_SCLKA, X1000_CLK_MPLL }, @@ -426,6 +490,12 @@ static const struct ingenic_cgu_clk_info x1000_cgu_clocks[] = { .gate = { CGU_REG_CLKGR, 9 }, }, + [X1000_CLK_AIC] = { + "aic", CGU_CLK_GATE, + .parents = { X1000_CLK_EXCLK }, + .gate = { CGU_REG_CLKGR, 11 }, + }, + [X1000_CLK_UART0] = { "uart0", CGU_CLK_GATE, .parents = { X1000_CLK_EXCLK, -1, -1, -1 }, From patchwork Wed Oct 26 19:43:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aidan MacDonald X-Patchwork-Id: 11421 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp454113wru; Wed, 26 Oct 2022 12:46:42 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7zrcuyvutfX4JEhJX3acE5d03wKVFUsB4Hn41Rzmw/6STAoAOyalgDwFwoD4YBdhzryOdT X-Received: by 2002:a17:907:6ea9:b0:794:8b93:2e44 with SMTP id sh41-20020a1709076ea900b007948b932e44mr34426170ejc.407.1666813602771; Wed, 26 Oct 2022 12:46:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666813602; cv=none; d=google.com; s=arc-20160816; b=SbcNAPRQLm2inPVFNZp3tjOex5+CdEwEqMDnhUbL11P+iDyiamTrajYmLIDRwM6rI6 dtFaRCcwW89ARpWamd3+pOOgeotwyuMJhaXZIbGK9jgyrz3u+MM9D6ruUUio7noi2K5c 43CsoXNM8KLob+ZGPFOLwXmJxOVBBj+7J5GKqVsMgoN1+743MAZa9TARiVdY0e9HqeNj +MGyNWeyMfnh1JwnVz3fnv47/OTI5+m8in7eW7QXUAXT7NdUuEzbAEMwwB8OoXZJBSHs 7S4SNTB55Id6ve1mdmOLoP3eI+5laM8E/KLU+V4s1IgbaH/flIDuGwmIWfFpY+WD5b1W agzw== 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=tgTbY0wb7NEE8wsfRVlRc/ObdS/WC2z2i1h/J+MWlCI=; b=LbuJVlVjCdH0SchwT82h8PmveVEpvcm6Pvl9iJVx8djt9ZLGsIqZavZHoyceITBauW vKRg37W2dw3GXLNAKRhkdaHu8mkXZ1OKL/RAAtWoUC79NpeEnoS0/gD1gbj7bFUu5wqa RPpVPMzX8CeycTKv7XwDpa/+smzR2pL7SHVFPXewb1g2AtyVJoqxcYQF3XKPEdnQ/SBv yW0rzrR4fAiCZxLDYJ36QZaNwozpIDf0X6e6Jnp8LI3TyfA2MYB3PxuxwrChFmPCn8Gu OMlF05JkjUegzBUCFtn8EyVQ8no7sohnAs2AmxGYcqZO2mXi8iZXcwPBHOdxXXM4cB6h gOAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=KY7cMPd1; 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 l26-20020aa7d95a000000b0045d25cf222csi6004781eds.362.2022.10.26.12.46.18; Wed, 26 Oct 2022 12:46:42 -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=KY7cMPd1; 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 S235140AbiJZTp0 (ORCPT + 99 others); Wed, 26 Oct 2022 15:45:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235139AbiJZTon (ORCPT ); Wed, 26 Oct 2022 15:44:43 -0400 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7537B119BFC; Wed, 26 Oct 2022 12:44:00 -0700 (PDT) Received: by mail-wm1-x336.google.com with SMTP id 5so3193306wmo.1; Wed, 26 Oct 2022 12:44:00 -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=tgTbY0wb7NEE8wsfRVlRc/ObdS/WC2z2i1h/J+MWlCI=; b=KY7cMPd1GFfcrGv0PtiHQ5CIfXDiI+sstPxdDLC0fKy9ZpCkfKTaukI07g1MBrNmVA zL77VTcV1eiCDazbQjF8hfvixA5jyXmPdIl6gJNgatTKiCOVq1IiLMVEjDlFQcxp9f+h Mw5VTwQ4zBarNl911bm/OChOqRHUH6l5cvtcqO/eErY8TeudrfdCiYhAUFADRTsRHH/r 8l8NxMwp6+PoKWUV2eKqZ9ZmQNj1HNXOB70qziXt9gVT1uvhJMfgfaEN+uv4hYwy8Ni1 PzRlDSBmUxYZhjJvVZhKB4Vy4haShFsol9Gy8MeNj7Udp9BMEaF7Usip/JLL1o3bi3CC H/5g== 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=tgTbY0wb7NEE8wsfRVlRc/ObdS/WC2z2i1h/J+MWlCI=; b=4tli4QnkRi8MQuFELRdII8TouQFPe5hCdRqzH5ROcD8FU/o8IUXK84V/1VCKqLKfH0 258XHVRdkUEXqWHv0N7nbOvgjNg1fX/mtHSDMx1RGjxYVoatdPKw0L/f7W4NVgPiPgRv BW34k802pxeXPgE9OTGrLojaJFzItZ11kBlLedgZKo5SrO0/VmUHycyoGzNPWPi7myj4 O4UYP3maaT2VQWA6fn4pBHUaFXLMJMxYXkM9GrUMzbFrlzsEO+6hu3bMYort+uaIFIjc zgn6WdYdYoFHT0dHcENUeswxuUGZrfbWqrOZazvhIjMLddzoXIoIYxgo+xtWi4V7+3w/ YNZg== X-Gm-Message-State: ACrzQf33E6HAvJN236fwVAPaAzxcjRZCA3WnMiDKbxwlJMiizk33M03p Y2dlSWeejKFjz9/4C9R1zZw= X-Received: by 2002:a05:600c:4e8f:b0:3c9:9657:9c0a with SMTP id f15-20020a05600c4e8f00b003c996579c0amr3725394wmq.157.1666813438756; Wed, 26 Oct 2022 12:43:58 -0700 (PDT) Received: from localhost (188.28.0.84.threembb.co.uk. [188.28.0.84]) by smtp.gmail.com with ESMTPSA id n5-20020a05600c304500b003a84375d0d1sm2492662wmh.44.2022.10.26.12.43.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Oct 2022 12:43:58 -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 6/6] clk: ingenic: Minor cosmetic fixups for X1000 Date: Wed, 26 Oct 2022 20:43:45 +0100 Message-Id: <20221026194345.243007-7-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?1747780740016912022?= X-GMAIL-MSGID: =?utf-8?q?1747780740016912022?= Remove redundant -1 entries from the parents array and fix a couple indentation / whitespace issues. Signed-off-by: Aidan MacDonald Reviewed-by: Paul Cercueil --- drivers/clk/ingenic/x1000-cgu.c | 49 ++++++++++++++++----------------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/drivers/clk/ingenic/x1000-cgu.c b/drivers/clk/ingenic/x1000-cgu.c index 95d5e3a44cee..feb03eed4fe8 100644 --- a/drivers/clk/ingenic/x1000-cgu.c +++ b/drivers/clk/ingenic/x1000-cgu.c @@ -216,7 +216,7 @@ static const struct ingenic_cgu_clk_info x1000_cgu_clocks[] = { [X1000_CLK_APLL] = { "apll", CGU_CLK_PLL, - .parents = { X1000_CLK_EXCLK, -1, -1, -1 }, + .parents = { X1000_CLK_EXCLK }, .pll = { .reg = CGU_REG_APLL, .rate_multiplier = 1, @@ -239,7 +239,7 @@ static const struct ingenic_cgu_clk_info x1000_cgu_clocks[] = { [X1000_CLK_MPLL] = { "mpll", CGU_CLK_PLL, - .parents = { X1000_CLK_EXCLK, -1, -1, -1 }, + .parents = { X1000_CLK_EXCLK }, .pll = { .reg = CGU_REG_MPLL, .rate_multiplier = 1, @@ -289,7 +289,7 @@ static const struct ingenic_cgu_clk_info x1000_cgu_clocks[] = { * system; mark it critical. */ .flags = CLK_IS_CRITICAL, - .parents = { X1000_CLK_CPUMUX, -1, -1, -1 }, + .parents = { X1000_CLK_CPUMUX }, .div = { CGU_REG_CPCCR, 0, 1, 4, 22, -1, -1 }, .gate = { CGU_REG_CLKGR, 30 }, }, @@ -301,7 +301,7 @@ static const struct ingenic_cgu_clk_info x1000_cgu_clocks[] = { * disabling it or any parent clocks will hang the system. */ .flags = CLK_IS_CRITICAL, - .parents = { X1000_CLK_CPUMUX, -1, -1, -1 }, + .parents = { X1000_CLK_CPUMUX }, .div = { CGU_REG_CPCCR, 4, 1, 4, 22, -1, -1 }, }, @@ -320,13 +320,13 @@ static const struct ingenic_cgu_clk_info x1000_cgu_clocks[] = { [X1000_CLK_AHB2] = { "ahb2", CGU_CLK_DIV, - .parents = { X1000_CLK_AHB2PMUX, -1, -1, -1 }, + .parents = { X1000_CLK_AHB2PMUX }, .div = { CGU_REG_CPCCR, 12, 1, 4, 20, -1, -1 }, }, [X1000_CLK_PCLK] = { "pclk", CGU_CLK_DIV | CGU_CLK_GATE, - .parents = { X1000_CLK_AHB2PMUX, -1, -1, -1 }, + .parents = { X1000_CLK_AHB2PMUX }, .div = { CGU_REG_CPCCR, 16, 1, 4, 20, -1, -1 }, .gate = { CGU_REG_CLKGR, 28 }, }, @@ -393,13 +393,13 @@ static const struct ingenic_cgu_clk_info x1000_cgu_clocks[] = { [X1000_CLK_MSCMUX] = { "msc_mux", CGU_CLK_MUX, - .parents = { X1000_CLK_SCLKA, X1000_CLK_MPLL}, + .parents = { X1000_CLK_SCLKA, X1000_CLK_MPLL }, .mux = { CGU_REG_MSC0CDR, 31, 1 }, }, [X1000_CLK_MSC0] = { "msc0", CGU_CLK_DIV | CGU_CLK_GATE, - .parents = { X1000_CLK_MSCMUX, -1, -1, -1 }, + .parents = { X1000_CLK_MSCMUX }, .div = { CGU_REG_MSC0CDR, 0, 2, 8, 29, 28, 27 }, .gate = { CGU_REG_CLKGR, 4 }, }, @@ -413,8 +413,7 @@ static const struct ingenic_cgu_clk_info x1000_cgu_clocks[] = { [X1000_CLK_OTG] = { "otg", CGU_CLK_DIV | CGU_CLK_GATE | CGU_CLK_MUX, - .parents = { X1000_CLK_EXCLK, -1, - X1000_CLK_APLL, X1000_CLK_MPLL }, + .parents = { X1000_CLK_EXCLK, -1, X1000_CLK_APLL, X1000_CLK_MPLL }, .mux = { CGU_REG_USBCDR, 30, 2 }, .div = { CGU_REG_USBCDR, 0, 1, 8, 29, 28, 27 }, .gate = { CGU_REG_CLKGR, 3 }, @@ -422,7 +421,7 @@ static const struct ingenic_cgu_clk_info x1000_cgu_clocks[] = { [X1000_CLK_SSIPLL] = { "ssi_pll", CGU_CLK_MUX | CGU_CLK_DIV, - .parents = { X1000_CLK_SCLKA, X1000_CLK_MPLL, -1, -1 }, + .parents = { X1000_CLK_SCLKA, X1000_CLK_MPLL }, .mux = { CGU_REG_SSICDR, 31, 1 }, .div = { CGU_REG_SSICDR, 0, 1, 8, 29, 28, 27 }, }, @@ -435,7 +434,7 @@ static const struct ingenic_cgu_clk_info x1000_cgu_clocks[] = { [X1000_CLK_SSIMUX] = { "ssi_mux", CGU_CLK_MUX, - .parents = { X1000_CLK_EXCLK, X1000_CLK_SSIPLL_DIV2, -1, -1 }, + .parents = { X1000_CLK_EXCLK, X1000_CLK_SSIPLL_DIV2 }, .mux = { CGU_REG_SSICDR, 30, 1 }, }, @@ -456,37 +455,37 @@ static const struct ingenic_cgu_clk_info x1000_cgu_clocks[] = { [X1000_CLK_EMC] = { "emc", CGU_CLK_GATE, - .parents = { X1000_CLK_AHB2, -1, -1, -1 }, + .parents = { X1000_CLK_AHB2 }, .gate = { CGU_REG_CLKGR, 0 }, }, [X1000_CLK_EFUSE] = { "efuse", CGU_CLK_GATE, - .parents = { X1000_CLK_AHB2, -1, -1, -1 }, + .parents = { X1000_CLK_AHB2 }, .gate = { CGU_REG_CLKGR, 1 }, }, [X1000_CLK_SFC] = { "sfc", CGU_CLK_GATE, - .parents = { X1000_CLK_SSIPLL, -1, -1, -1 }, + .parents = { X1000_CLK_SSIPLL }, .gate = { CGU_REG_CLKGR, 2 }, }, [X1000_CLK_I2C0] = { "i2c0", CGU_CLK_GATE, - .parents = { X1000_CLK_PCLK, -1, -1, -1 }, + .parents = { X1000_CLK_PCLK }, .gate = { CGU_REG_CLKGR, 7 }, }, [X1000_CLK_I2C1] = { "i2c1", CGU_CLK_GATE, - .parents = { X1000_CLK_PCLK, -1, -1, -1 }, + .parents = { X1000_CLK_PCLK }, .gate = { CGU_REG_CLKGR, 8 }, }, [X1000_CLK_I2C2] = { "i2c2", CGU_CLK_GATE, - .parents = { X1000_CLK_PCLK, -1, -1, -1 }, + .parents = { X1000_CLK_PCLK }, .gate = { CGU_REG_CLKGR, 9 }, }, @@ -498,43 +497,43 @@ static const struct ingenic_cgu_clk_info x1000_cgu_clocks[] = { [X1000_CLK_UART0] = { "uart0", CGU_CLK_GATE, - .parents = { X1000_CLK_EXCLK, -1, -1, -1 }, + .parents = { X1000_CLK_EXCLK }, .gate = { CGU_REG_CLKGR, 14 }, }, [X1000_CLK_UART1] = { "uart1", CGU_CLK_GATE, - .parents = { X1000_CLK_EXCLK, -1, -1, -1 }, + .parents = { X1000_CLK_EXCLK}, .gate = { CGU_REG_CLKGR, 15 }, }, [X1000_CLK_UART2] = { "uart2", CGU_CLK_GATE, - .parents = { X1000_CLK_EXCLK, -1, -1, -1 }, + .parents = { X1000_CLK_EXCLK }, .gate = { CGU_REG_CLKGR, 16 }, }, [X1000_CLK_TCU] = { "tcu", CGU_CLK_GATE, - .parents = { X1000_CLK_EXCLK, -1, -1, -1 }, + .parents = { X1000_CLK_EXCLK }, .gate = { CGU_REG_CLKGR, 18 }, }, [X1000_CLK_SSI] = { "ssi", CGU_CLK_GATE, - .parents = { X1000_CLK_SSIMUX, -1, -1, -1 }, + .parents = { X1000_CLK_SSIMUX }, .gate = { CGU_REG_CLKGR, 19 }, }, [X1000_CLK_OST] = { "ost", CGU_CLK_GATE, - .parents = { X1000_CLK_EXCLK, -1, -1, -1 }, + .parents = { X1000_CLK_EXCLK }, .gate = { CGU_REG_CLKGR, 20 }, }, [X1000_CLK_PDMA] = { "pdma", CGU_CLK_GATE, - .parents = { X1000_CLK_EXCLK, -1, -1, -1 }, + .parents = { X1000_CLK_EXCLK }, .gate = { CGU_REG_CLKGR, 21 }, }, };