Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp1928881lql; Wed, 13 Mar 2024 12:07:23 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWhUurkFncA3rP4jIPcz2pq/PxbiMLzg8LOZjCsGT4T0NXYyO7I3Pn3goNGKFhEwORv09ZryowcE83fxU/kMbe+7IS1VCk7fPqbp574vw== X-Google-Smtp-Source: AGHT+IGky3sazewjrLGbLgVL4ampdq1HLvLgDT59XrrCo2zCfGHcR8Kg7q42CaDS39JLYfkv8wtr X-Received: by 2002:a05:620a:4089:b0:788:1a1c:dcb6 with SMTP id f9-20020a05620a408900b007881a1cdcb6mr995505qko.5.1710356843116; Wed, 13 Mar 2024 12:07:23 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710356843; cv=pass; d=google.com; s=arc-20160816; b=sz8mdDb3Ye2jSzRuzhrdCG32RLfFMLmyje3zAz/vzyaoHs6C+p/EQkbn9OugsqTRYC urVKZIGxAhUCDtHs7+m5UwThOmnPQX1CerM7evVKqsP5LLhmzmy29dwikR4HrEbXJ5sZ llAlvRPnpxGGrMtRiA8gC6HcY7yiTdDoZdHfXGRh+/tVSvkFiIFa41Ji5l6Ed7qYSqCw C6pw5tyQw/M2aS/NrfjEBWb6yKTTwiwvahvrMf+REa68L6mMYie4YH1iA+CZE5HnkWpA n2+KH6clK3kkVq2jvsY9hQo022sZoofC9z+x2TmvI4TlVg81ZF5y40HBHBVkd2D3OHNz 9Ypg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=dxB79hpmOYEV/Wa5xEjs3BbB8JPGXY5M54cM2DcOGjk=; fh=V0scr7V+J8JzhXx8rSScwVE7rXzbE/Qa0tRy/HfBQco=; b=T41IdsgPYBzeEkZMUn83sYxgL2etUkAOtc+eaDm0/SpxfvovIujS7Jqk3McQK0CjwC tnyJKmsZCon5TIhD2dEnzsN/GdWokw3Pwzucrhv5b3BUu0ixmjN8JL+IiiRn5kiXtumT glgnXe5oU76U05/P74R421c7FaR5CUJRuqsHCnHTjcRBkW5QDRZvVAScz2VMWCnyVuyI 7vskcXz1AZOv5C46mvlcVXo+zvmX+ddMrD0nia9yo5am6GSkS3bTQHQO7j3adCsDxqi/ wBth4kURsUrEKjx6uyzMdMgwRyfpZ87gfj2/2azbarWVmdGvP6f1xT/xO6mPrXh5b6JT 3ATw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=DanZVOf+; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-102342-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-102342-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id l1-20020a05620a210100b00787c111fddasi10225989qkl.486.2024.03.13.12.07.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 12:07:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-102342-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=DanZVOf+; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-102342-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-102342-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 0C97F1C26B12 for ; Wed, 13 Mar 2024 19:05:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4DC4060B8E; Wed, 13 Mar 2024 18:17:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DanZVOf+" Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 98D1D60877; Wed, 13 Mar 2024 18:17:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710353869; cv=none; b=T/S81gDU80s33Ed+IiTExC7jr01PI73hF7G9VB6T6AbCFszSVslmBfzUm5GLecjyKRiz+2ysqcZlZhAbBWcW0RdF8X1C7R3f2YzQFBjupu1oqF6bIHAKeC2Xbqf9WnQq3VBcvT2ujjemMt16fwmBImXTUm+5GquVnY1VygEcqQk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710353869; c=relaxed/simple; bh=SyVMnZvS/ZnHg0qyb832r9jYPgwDvt2Fg5Z/R12KPYM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=POhERabFimGMZylOxxjDrgZ4pvs80SjueB5/CoHNqnaIMUhFF449Ii1iitjvkXH89hPc+WRVnhMsJdzooPErOYdWiPQr5Jw/NcGJrPMkF6WbWyDz/qez/gJWL50P5rJLw2F5lA7wBEeDRj6doupkeLNjr5N5DMNmm2o69cvUqN8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=DanZVOf+; arc=none smtp.client-ip=209.85.221.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-33e94c12f33so43102f8f.3; Wed, 13 Mar 2024 11:17:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710353866; x=1710958666; darn=vger.kernel.org; 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=dxB79hpmOYEV/Wa5xEjs3BbB8JPGXY5M54cM2DcOGjk=; b=DanZVOf+j3V4oBl3usOH/HLXylzxsRgldm0cK2Ynj7Te71j6NFxOF27deeAntMu+Nh 8yO5VnNLrNLKXAD4jShxHHXDhayWmd4zXNgMb4GBPs9xZN/y/vU14nskmsIiBTYWbg58 inVRXWY+lgyzycUVt6TLfQfg/ob65WwY/RPleJJms42VXJl2xFZgH4LGU40uycdnMFY/ imoZ/4VGtZI+JGmtpVJPKAIweSbApg/yoN0lA+VK1MOSEqqMjOD+k5dRvfFGebNQj6g0 3laoraQy85nSrUJlKBcQoY6CFH8QwpnrxXKdKDVtEISAk9TJqvswYM1eQOSSIuWcl39Z WODw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710353866; x=1710958666; 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=dxB79hpmOYEV/Wa5xEjs3BbB8JPGXY5M54cM2DcOGjk=; b=F6IQu+e0hN82AV1zN0ntavaNPnxPT/6KYYaanZm9nQY9bC0LFKb2FMk0yd/QJo8+K5 3h2whb6+MoOQ/nPflqC8hPtz3wH092qITfFYCXK9uoInbLT7tfpAY6heEZVR5/XSCYSq ov+6ubIbVmLkhx8e9Fsot5FJ5RIKfiGm/x75NnDi6YrFWwlZdIpsdmK0BeyT+ga4uirK nyWeN458LdK/lkKLanMMgqFIwJDD5V2xTGqNMqS4wxr3bZ4Vw8KaTqd/DeY9sxDmnJjL 15nYcF7V3Gqxhoui1BILOPkl0PU/xl4PiKk9/cnGH/W1JcDX8e7R7Y8sdRlOErt2J/DA OT6g== X-Forwarded-Encrypted: i=1; AJvYcCXaQlIwUqkeaGNY932ja8F7jRnu515OBujl7+BdQuKVw0JnUYsycEWBRyVVFQVeRe1nPjJ7QLLlwj4+vQzCUY0gp8yFu3t3mgAojbGa0Qiud7pWV0G7ynKCth5/HJzbAr+eNOgzctF3SkvD3l8Yta86djQ4KJOsTO9oLkPi5KeGoQ== X-Gm-Message-State: AOJu0YwvGWFdUcnl/j/o2An7D9vStQ2yS0zHSlp8X+p8LF9Rl1TEnNO4 IfCyhP8UOEY6SuKAAaoQne9hDi2E/V46GlekNAmDCG5N6VMDSWZq X-Received: by 2002:a5d:644d:0:b0:33e:7896:a9d7 with SMTP id d13-20020a5d644d000000b0033e7896a9d7mr2108713wrw.67.1710353865784; Wed, 13 Mar 2024 11:17:45 -0700 (PDT) Received: from jernej-laptop.localnet (86-58-6-171.dynamic.telemach.net. [86.58.6.171]) by smtp.gmail.com with ESMTPSA id ch9-20020a5d5d09000000b0033eab3520a9sm4381264wrb.43.2024.03.13.11.17.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 11:17:45 -0700 (PDT) From: Jernej =?utf-8?B?xaBrcmFiZWM=?= To: Michael Turquette , Stephen Boyd , Chen-Yu Tsai , Samuel Holland , Guido =?ISO-8859-1?Q?G=FCnther?= , Purism Kernel Team , Ondrej Jirman , Neil Armstrong , Jessica Zhang , Sam Ravnborg , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Frank Oltmanns Cc: linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, Frank Oltmanns , stable@vger.kernel.org Subject: Re: [PATCH v4 1/5] clk: sunxi-ng: common: Support minimum and maximum rate Date: Wed, 13 Mar 2024 19:17:43 +0100 Message-ID: <3210009.5fSG56mABF@jernej-laptop> In-Reply-To: <20240310-pinephone-pll-fixes-v4-1-46fc80c83637@oltmanns.dev> References: <20240310-pinephone-pll-fixes-v4-0-46fc80c83637@oltmanns.dev> <20240310-pinephone-pll-fixes-v4-1-46fc80c83637@oltmanns.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="utf-8" Dne nedelja, 10. marec 2024 ob 14:21:11 CET je Frank Oltmanns napisal(a): > The Allwinner SoC's typically have an upper and lower limit for their > clocks' rates. Up until now, support for that has been implemented > separately for each clock type. > > Implement that functionality in the sunxi-ng's common part making use of > the CCF rate liming capabilities, so that it is available for all clock > types. > > Suggested-by: Maxime Ripard > Signed-off-by: Frank Oltmanns > Cc: stable@vger.kernel.org This looks pretty nice now. Reviewed-by: Jernej Skrabec Best regards, Jernej > --- > drivers/clk/sunxi-ng/ccu_common.c | 19 +++++++++++++++++++ > drivers/clk/sunxi-ng/ccu_common.h | 3 +++ > 2 files changed, 22 insertions(+) > > diff --git a/drivers/clk/sunxi-ng/ccu_common.c b/drivers/clk/sunxi-ng/ccu_common.c > index 8babce55302f..ac0091b4ce24 100644 > --- a/drivers/clk/sunxi-ng/ccu_common.c > +++ b/drivers/clk/sunxi-ng/ccu_common.c > @@ -44,6 +44,16 @@ bool ccu_is_better_rate(struct ccu_common *common, > unsigned long current_rate, > unsigned long best_rate) > { > + unsigned long min_rate, max_rate; > + > + clk_hw_get_rate_range(&common->hw, &min_rate, &max_rate); > + > + if (current_rate > max_rate) > + return false; > + > + if (current_rate < min_rate) > + return false; > + > if (common->features & CCU_FEATURE_CLOSEST_RATE) > return abs(current_rate - target_rate) < abs(best_rate - target_rate); > > @@ -122,6 +132,7 @@ static int sunxi_ccu_probe(struct sunxi_ccu *ccu, struct device *dev, > > for (i = 0; i < desc->hw_clks->num ; i++) { > struct clk_hw *hw = desc->hw_clks->hws[i]; > + struct ccu_common *common = hw_to_ccu_common(hw); > const char *name; > > if (!hw) > @@ -136,6 +147,14 @@ static int sunxi_ccu_probe(struct sunxi_ccu *ccu, struct device *dev, > pr_err("Couldn't register clock %d - %s\n", i, name); > goto err_clk_unreg; > } > + > + if (common->max_rate) > + clk_hw_set_rate_range(hw, common->min_rate, > + common->max_rate); > + else > + WARN(common->min_rate, > + "No max_rate, ignoring min_rate of clock %d - %s\n", > + i, name); > } > > ret = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, > diff --git a/drivers/clk/sunxi-ng/ccu_common.h b/drivers/clk/sunxi-ng/ccu_common.h > index 942a72c09437..329734f8cf42 100644 > --- a/drivers/clk/sunxi-ng/ccu_common.h > +++ b/drivers/clk/sunxi-ng/ccu_common.h > @@ -31,6 +31,9 @@ struct ccu_common { > u16 lock_reg; > u32 prediv; > > + unsigned long min_rate; > + unsigned long max_rate; > + > unsigned long features; > spinlock_t *lock; > struct clk_hw hw; > >