From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2DABD37C93E for ; Wed, 4 Mar 2026 22:21:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772662892; cv=none; b=o6C2G7D6s3ABC6fkVX4ksaqOKk493BXTeTLn0pGRtAag14/8Pn0Ig3kqmqP/YG4bR+Q7arbX46cTEu1Pcm856tG9Ai+UxtT5clR3FwhP0FPmpiTAmkbibgsceKcRuy2EYx1rgXd63d0Rdt1gxYUbFXhhpd1/mM8aeIx82h08izA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772662892; c=relaxed/simple; bh=ZnLFRJR9SgstqYT5jTSnkzolgMIZQT16P4bRyPRE5n4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=k3NAD8EwJNuBvHMw0nRNb+PlbpSbyXR1RHpQyXYPnOvyu8QQqSUSRWmr1a0aEGu7ckJwCf+Q9coQFBZ9eD6ln9evhlpxEe9CTKRnrt0r+uxeYMpxZ41sKIeSnTHYiiSL73ZuOuaaNAMURlBfY9TH4CFFwpkYBG9E8P90VV8q4sg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=IDx90jzC; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=Mtt9Oa9W; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="IDx90jzC"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="Mtt9Oa9W" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1772662890; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5IdMjdarsoIwJ3LjCSMsVj14yfAGd7U/YMfplj+8xe4=; b=IDx90jzCuGvYCwrB8R5xPoYorKHrKcue5ZRfkKAQ/qELjj+q3iLNYpg9AF2kO9dG6GGQba 6saQIs32h4kdEGQqw8aA6zszWJIZ7cm2pEmNzsV2uLz8PDtAv+LYMhqEhBmhFQOiTOl/b4 pu+L+Op+xiJJvFV17Q4HRmJkwkViniM= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-55-SD6_Y6wPOu2II-7u_rZNBA-1; Wed, 04 Mar 2026 17:21:29 -0500 X-MC-Unique: SD6_Y6wPOu2II-7u_rZNBA-1 X-Mimecast-MFC-AGG-ID: SD6_Y6wPOu2II-7u_rZNBA_1772662888 Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-8cb4e37a796so4337008085a.2 for ; Wed, 04 Mar 2026 14:21:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1772662888; x=1773267688; darn=vger.kernel.org; h=user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=5IdMjdarsoIwJ3LjCSMsVj14yfAGd7U/YMfplj+8xe4=; b=Mtt9Oa9WFD9SJyxZHJt5YU28HPP68SCbO9xTv93FX7Srswa1xmIQjLk3+DnG9sw3mI +PhNSjsy3a33Tf9YmFz4quCTUJWLHEI/4+4KCngKKMIUoe+TOZyCpU2ewuF+T2WH0Ak6 OEsyLtiUgFgFEgKFR1S/nnIIujJE81MLcPfIoOFDr5tUg7DLANMF1JAKs+mIV1NH7dKI KfGzWcrtGkifosT7Vb4wZh6fSLdLOu6xDmegUzwbQq+blcYq5U/M/B7un3dCu9IJ96wz yRquo2iqMJCvgL6QkFg0j5sOkrQX5t4dQTUn9oayWe9c5150YQ5owE078LF1UA4T0Avj bWQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772662888; x=1773267688; h=user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=5IdMjdarsoIwJ3LjCSMsVj14yfAGd7U/YMfplj+8xe4=; b=IOKtQ9NUWs58JLNNU0YZv76GYw+E1eyXI3PMourDvPLZeKa1W5K750Jl/cI+DCp4Wq sm+DPciFhFoMCT5n1RrVYb5QGd/f5p4hcMAcIXIy3jQSgLLoVfacM4nD7FX65rNzkjA6 JvBYJLFtyERiSjDKj0FExV7kaCGVwAjSHQCmzoF29IE62p695w7ZRl42HdCOINcpwh8j OIrtMITxX6tx7uowMlbF1Fy6nFjeh/7OHFNKM+WgfDGWByX2SJlBWQashDQN9UbLDGWn yNpDmz4Jwsw1ZRyWMsg+ZjdLmo1CEUU6TLkU+jnZ7bLiIArYV9GWVhzMxnXa/PW/25jI 7ZUg== X-Forwarded-Encrypted: i=1; AJvYcCUJQZGSNTGxXDDVLVaT8xGB97/M0X291ta5A8i29gMPtsy1kdr7B/Z92OpDSrPUmDWwrxBhD88042lxV70=@vger.kernel.org X-Gm-Message-State: AOJu0YxskqvdVU/Y0unaQelslA2pjLW2wHJKaCxwlWxJJeXEk1xCVCPn 6ZOXC8rET3iQK/MAL14wHkAAHpzN0jW7bhjTnIVRWM6ogBPFZJ2udymkKfmd4CTrhjZ3V+u3y7q wtN4B0hxt8ddiPGFPoQGdwofQ5jHVA+O2qUFqxCXoZs2qv1o7U07sPFNm58ccTCh2QA== X-Gm-Gg: ATEYQzxQYBy1f1eiTuj5HGGiJ9pYJakbUAM9jt9T8L/46j4Fnp6XWcL/80ZqwxFwbSO Ur/OHB3YPp8Mu7e+VuF4cl6yUlBtPk0wqbo0S6xh3Vgs2w5kcdS89ZM/89vma9nKmnQCu2MYY0D XSAUsw2Sk7PkFSUCuNUMOFzu+Tm/gecYfLD4F4kC3wEYsvDrz6qw3PpGIIJn8iOSOFweG+HBl+t MVnl0cjBaWT1oPxCyf5+f0dqnl2E9lfawopUIoBwwkyOcpfkm3UsNDBuCcu1pCY3PRPJonvmk9B FdYWSG0te0mH/ITv8aTie9PGCaYduoFM0hpudG15rjP1Gnr2Z+4dT57S618STfUTu3nFJeDK0oN Mbn41jXCznO8F2aHpkbnk X-Received: by 2002:a05:620a:472a:b0:8cb:4d46:7a4b with SMTP id af79cd13be357-8cd5afcce10mr459513585a.81.1772662888511; Wed, 04 Mar 2026 14:21:28 -0800 (PST) X-Received: by 2002:a05:620a:472a:b0:8cb:4d46:7a4b with SMTP id af79cd13be357-8cd5afcce10mr459511385a.81.1772662887989; Wed, 04 Mar 2026 14:21:27 -0800 (PST) Received: from redhat.com ([2600:382:7705:162f:3db4:e16a:e5d8:352e]) by smtp.gmail.com with ESMTPSA id af79cd13be357-8cbbf66b9d9sm1740582885a.12.2026.03.04.14.21.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Mar 2026 14:21:27 -0800 (PST) Date: Wed, 4 Mar 2026 17:21:23 -0500 From: Brian Masney To: Anirudh Srinivasan Cc: Drew Fustini , Joel Stanley , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Michael Turquette , Stephen Boyd , Philipp Zabel , linux-riscv@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, joel@jms.id.au, fustini@kernel.org, mpe@kernel.org, mpe@oss.tenstorrent.com, npiggin@oss.tenstorrent.com, agross@kernel.org, agross@oss.tenstorrent.com, Krzysztof Kozlowski Subject: Re: [PATCH v7 3/3] clk: tenstorrent: Add Atlantis clock controller driver Message-ID: References: <20260303-atlantis-clocks-v7-0-415c9dda086a@oss.tenstorrent.com> <20260303-atlantis-clocks-v7-3-415c9dda086a@oss.tenstorrent.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/2.2.14 (2025-02-20) Hi Anirudh, On Wed, Mar 04, 2026 at 11:53:38AM -0600, Anirudh Srinivasan wrote: > Sorry for the follow up, but wanted to run something by you. > > On Wed, Mar 4, 2026 at 10:40 AM Anirudh Srinivasan < > asrinivasan@oss.tenstorrent.com> wrote: > > > > Hello Brian, > > > > On Tue, Mar 3, 2026 at 4:32 PM Brian Masney wrote: > > > > > > Hi Anirudh, > > > > > > Thanks for the patch. A few minor comments below with some minor > > > nitpicks, additional places to use FIELD_GET(), plus some suggestions > > > for additional regmap helpers to use. > > > > > > > > > + > > > > +static int atlantis_clk_pll_is_enabled(struct clk_hw *hw) > > > > +{ > > > > + struct atlantis_clk_pll *pll = hw_to_atlantis_pll(hw); > > > > + u32 val, en_val, cg_val; > > > > + > > > > + regmap_read(pll->common.regmap, pll->config.reg_offset, &val); > > > > + regmap_read(pll->common.regmap, pll->config.en_reg_offset, > &en_val); > > > > + regmap_read(pll->common.regmap, pll->config.cg_reg_offset, > &cg_val); > > > > + > > > > + /* Check if PLL is powered on, locked, not bypassed and Gate > clk is enabled */ > > > > + return !!(en_val & PLL_CFG_EN_BIT) && !!(val & > PLL_CFG_LOCK_BIT) && > > > > + (!pll->config.cg_reg_enable || (cg_val & > pll->config.cg_reg_enable)) && > > > > + !(val & PLL_CFG_BYPASS_BIT); > > > > > > Could regmap_test_bits() make this a bit cleaner? > > > > > > > +} > > > > + > > > > +static int atlantis_clk_pll_enable(struct clk_hw *hw) > > > > +{ > > > > + struct atlantis_clk_pll *pll = hw_to_atlantis_pll(hw); > > > > + u32 val, en_val, cg_val; > > > > + int ret; > > > > + > > > > + regmap_read(pll->common.regmap, pll->config.reg_offset, &val); > > > > + regmap_read(pll->common.regmap, pll->config.en_reg_offset, > &en_val); > > > > + regmap_read(pll->common.regmap, pll->config.cg_reg_offset, > &cg_val); > > > > + > > > > + /* Check if PLL is already enabled, locked, not bypassed and > Gate clk is enabled */ > > > > + if ((en_val & PLL_CFG_EN_BIT) && (val & PLL_CFG_LOCK_BIT) && > > > > + (!pll->config.cg_reg_enable || (cg_val & > pll->config.cg_reg_enable)) && > > > > + !(val & PLL_CFG_BYPASS_BIT)) { > > > > > > Same about regmap_test_bits() here. > > > > These instances have it reading 3 different registers (unlike almost > > all the other examples that just read one) and testing bits across > > them. But I guess it should be possible to use test_bits here too. I > > will update them. > > This ends up becoming like this. > > static int atlantis_clk_pll_is_enabled(struct clk_hw *hw) > > { > > struct atlantis_clk_pll *pll = hw_to_atlantis_pll(hw); > > > > > /* Check if PLL is powered on, locked, not bypassed and Gate clk is > enabled */ > return regmap_test_bits(pll->common.regmap, pll->config.reg_offset, > PLL_CFG_LOCK_BIT) && > > regmap_test_bits(pll->common.regmap, > pll->config.en_reg_offset, PLL_CFG_EN_BIT) && > > regmap_test_bits(pll->common.regmap, > pll->config.cg_reg_offset, pll->config.cg_reg_enable) && > > !regmap_test_bits(pll->common.regmap, > pll->config.reg_offset, PLL_CFG_BYPASS_BIT); > > } > > We can't use a single call of regmap_test_bits to the > pll->config.reg_offset register cause we need to check if PLL_CFG_LOCK_BIT > is set and PLL_CFG_BYPASS_BIT is unset. We end up needing to make 2 reads > to that register. > > Any thoughts on whether I should still be using regmap_test_bits here? If it's not looking good in practice once you implement it, then just fall back to the older behavior. It was just a suggestion. I haven't used this yet, however there are also the regmap_field_xxx() helpers that are also available. drivers/clk/mstar/clk-msc313-mpll.c uses these helpers. I don't know if it would help to simplify your code. Brian