From patchwork Wed Dec 20 22:17:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 181795 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp42988dyi; Wed, 20 Dec 2023 14:18:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IGsppG9P3ih2WR37P5XIluC9n/aZ+1uwaaXh1QQ9H9puGx+O6cPJHu1mKqelIDQcSJsnbxr X-Received: by 2002:a17:907:da2:b0:a23:5db9:f4f4 with SMTP id go34-20020a1709070da200b00a235db9f4f4mr1810861ejc.88.1703110705902; Wed, 20 Dec 2023 14:18:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703110705; cv=none; d=google.com; s=arc-20160816; b=G9Qcv0f/FrPUh8i6BcZtQt2lUUreAWOPPKa9uxcCrZzQUoqG8MIVir7X4Yxq3i0kI3 5gkoZnP7EEaEhnPqOf2OVaYXCN7jSpvRQNO7QQiOGAO+ssDO8tT6qmkhboFqW0uRo7JX qY27UvhMUKXuPk2+gfiH1I08XfYdGMUVoFAaVCZ0kXwr2pSAZA5DKsLtg6ifLVJKTj69 80HfAGnsV//5YXUYhL0bjJwdNrYmdNN9ccPZAMs/KEgxRxkLcFRySOUJhnaiayIVKKND 7VIzz8j+Wwrf/DIiUYQyUlc9wsnXWEzJh/WW+fnZRV5Ken/objgn9NWtPQLIQVNXzgbM OJzw== ARC-Message-Signature: i=1; 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=1WXsTXt5tNNCO94Jfxptt1+xmo7JvqPD/4sHkvcR0pA=; fh=VhIJx+T3y1Q1fSF7BLeWIrn14SWi7FGH0iUWQ4VsPhk=; b=s3satBZkLiySWz241w3oCPcWM8k4V9MYmPQstDvhs82AGbvHJfInFZ62LMo708G1CJ 8lFkzhT6UhUGTYBAMutcFbTg6YEEqn1jzI/R78Weu/QpVq7NuFyQCGfk1wgxavAU61G2 U43+PP/+ugb3o8PkRl1U4V/hSm67LZEja0S1ZLdsHAgPa0hukrSFBEkPWb18oRKzfEyd cvLyIA9xtbGyTPBEmbhCecvK5nlCspjpJvdn/TqJATeaIq44uDDTOL1lsvWdlY4ZRIY4 tsiZxkhKg518C78q+L4gXvX0TND15/rjUi6KvQ8JtkR06n3MlajXuxBx6gHIdEowexkp TqbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=DGZXIz7s; spf=pass (google.com: domain of linux-kernel+bounces-7500-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7500-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a24-20020a1709065f9800b00a22e6dac442si226435eju.632.2023.12.20.14.18.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 14:18:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-7500-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=DGZXIz7s; spf=pass (google.com: domain of linux-kernel+bounces-7500-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7500-ouuuleilei=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 am.mirrors.kernel.org (Postfix) with ESMTPS id 2D1A01F23875 for ; Wed, 20 Dec 2023 22:18:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D782F4B145; Wed, 20 Dec 2023 22:17:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DGZXIz7s" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (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 AECBE498AE; Wed, 20 Dec 2023 22:17:48 +0000 (UTC) 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-wm1-f53.google.com with SMTP id 5b1f17b1804b1-40c2bb872e2so1808905e9.3; Wed, 20 Dec 2023 14:17:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703110667; x=1703715467; 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=1WXsTXt5tNNCO94Jfxptt1+xmo7JvqPD/4sHkvcR0pA=; b=DGZXIz7sUWvuJXG0L6rKkdfrf/Vs2zjuFyf5xApnhrgdxOS5i82FsfQh7vQWvVrFIV j3ZWNzdvLowYSzkfzmKiI9ZMw+h91R9y5xaBRbW+J1IzMOKgz5qa3OyrvbCaKx624e8y pe1bD23slB8bWIbv4ZxpoeR8nNfmGZrNGymkD66BbJUf4xJnmdMMtMhwjY6vXVz2EJpp uBR4hWxSPXAUS/9hVM6oZaZ9cORUp5lCSh9wAvWpRGrGdGUKUs2YnqdflGc3NTWc+nmQ oMp8VhnzTG//TBWmTTWI/hKocq9GLrQgjZ0hER//Hh8IQlpx2a4Uw6a3yCoLmXtW3HmP 2NGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703110667; x=1703715467; 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=1WXsTXt5tNNCO94Jfxptt1+xmo7JvqPD/4sHkvcR0pA=; b=dr8HqSvImoHMXwhHhPxR03IixwuGbKbJW98RugF2A3CIX1nfbCttE6xf6YhXFUynE+ gptquoKLGAHBW2a0+dB6BzhuCilOnE+QCi6hsS+b7nOK45pW7qcjjOAAUFve8uJlXiNZ TtoE96BuimYii//VnW9fdsauL+kJh4B4ZGFfvMPyBJlbvqanJrlaHjU3ipIoH71EstJG TW9SHA+gYLEXkkqs+1OKInVIKkt/XKXdbqTuKagHoklm5ThxFs6o4h+o9S1i4I39b0Jr qelfNd4MNFIa4eta2kCvu5RmP5TEl1/P6xloWbB/wgqn/NR5oJbuegMf6nEPHc8xA4xb /hDQ== X-Gm-Message-State: AOJu0YwwLGSnuW0rS7nEFbmaJ5hoIWCHAeReJnolNFiZp0RHWjPyN1eJ IL0EChD9Vzb9cnAFZpiWBdE9aE8mJuw= X-Received: by 2002:a05:600c:538a:b0:40c:6d53:601f with SMTP id hg10-20020a05600c538a00b0040c6d53601fmr86644wmb.337.1703110667010; Wed, 20 Dec 2023 14:17:47 -0800 (PST) Received: from localhost.localdomain (host-95-250-248-68.retail.telecomitalia.it. [95.250.248.68]) by smtp.googlemail.com with ESMTPSA id v14-20020a05600c444e00b0040c58e410a3sm8908826wmn.14.2023.12.20.14.17.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 14:17:46 -0800 (PST) From: Christian Marangi To: Bjorn Andersson , Konrad Dybcio , Michael Turquette , Stephen Boyd , linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Christian Marangi Subject: [PATCH v8 1/3] clk: qcom: clk-rcg: introduce support for multiple conf for same freq Date: Wed, 20 Dec 2023 23:17:22 +0100 Message-Id: <20231220221724.3822-2-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231220221724.3822-1-ansuelsmth@gmail.com> References: <20231220221724.3822-1-ansuelsmth@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785841011367521687 X-GMAIL-MSGID: 1785841011367521687 Some RCG frequency can be reached by multiple configuration. We currently declare multiple configuration for the same frequency but that is not supported and always the first configuration will be taken. These multiple configuration are needed as based on the current parent configuration, it may be needed to use a different configuration to reach the same frequency. To handle this introduce 3 new macro, C, FM and FMS: - C is used to declare a freq_conf where src, pre_div, m and n are provided. - FM is used to declare a freq_multi_tbl with the frequency and an array of confs to insert all the config for the provided frequency. - FMS is used to declare a freq_multi_tbl with the frequency and an array of a single conf with the provided src, pre_div, m and n. Struct clk_rcg2 is changed to add a union type to reference a simple freq_tbl or a complex freq_multi_tbl. Signed-off-by: Christian Marangi --- drivers/clk/qcom/clk-rcg.h | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/drivers/clk/qcom/clk-rcg.h b/drivers/clk/qcom/clk-rcg.h index e6d84c8c7989..c50e6616d02c 100644 --- a/drivers/clk/qcom/clk-rcg.h +++ b/drivers/clk/qcom/clk-rcg.h @@ -17,6 +17,23 @@ struct freq_tbl { u16 n; }; +#define C(s, h, m, n) { (s), (2 * (h) - 1), (m), (n) } +#define FM(f, confs) { (f), ARRAY_SIZE(confs), (confs) } +#define FMS(f, s, h, m, n) { (f), 1, (const struct freq_conf []){ C(s, h, m, n) } } + +struct freq_conf { + u8 src; + u8 pre_div; + u16 m; + u16 n; +}; + +struct freq_multi_tbl { + unsigned long freq; + size_t num_confs; + const struct freq_conf *confs; +}; + /** * struct mn - M/N:D counter * @mnctr_en_bit: bit to enable mn counter @@ -138,6 +155,7 @@ extern const struct clk_ops clk_dyn_rcg_ops; * @safe_src_index: safe src index value * @parent_map: map from software's parent index to hardware's src_sel field * @freq_tbl: frequency table + * @freq_multi_tbl: frequency table for clocks reachable with multiple RCGs conf * @clkr: regmap clock handle * @cfg_off: defines the cfg register offset from the CMD_RCGR + CFG_REG * @parked_cfg: cached value of the CFG register for parked RCGs @@ -149,7 +167,10 @@ struct clk_rcg2 { u8 hid_width; u8 safe_src_index; const struct parent_map *parent_map; - const struct freq_tbl *freq_tbl; + union { + const struct freq_tbl *freq_tbl; + const struct freq_multi_tbl *freq_multi_tbl; + }; struct clk_regmap clkr; u8 cfg_off; u32 parked_cfg; From patchwork Wed Dec 20 22:17:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 181796 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp43174dyi; Wed, 20 Dec 2023 14:18:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IEFsDd300Vjt3/0goBP1eLpg2kQSnn6FKcu/bmaNgEfN0kEOPf31QoZY6WfawrDm1Iq1tzd X-Received: by 2002:a05:620a:28c2:b0:77e:fba4:3a21 with SMTP id l2-20020a05620a28c200b0077efba43a21mr27268602qkp.119.1703110731121; Wed, 20 Dec 2023 14:18:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703110731; cv=none; d=google.com; s=arc-20160816; b=a/SEHrWKxtWZEvCDgXPoeaI3yZxYjElBGPoEYgksnZdtUhWD7NmnAIHawgKfHYV5Fm h8XG5pe3J7avJ64MPIXdL0YZFeT+9V5v3fUz00Wt6aYSXgcD9UwjuQDfobYxOPsRXtfQ vJDHzckwvWWfJhkPjcj6Ir+EUr2SM+H83p6kAqjo83FTwTgfxAVeMHLEk4bY8mHKqrWI GiRdhFphjetNLDNqSsy9WhEZXRzAkHtt47XW9pK+MKJxUOqjqmQo1JuQLaOg/mIdoqK8 lALzTaYEDgYZODn/LvowjNeWrZgWXelnQVGlQHsCGE5L/J6+qK+L72VPjPwzVxOv/Xxr 4lTA== ARC-Message-Signature: i=1; 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=jotW/smCHe43GFm6S3QgFxRqWUkfntNB5Eyd37F/QlU=; fh=rFqwUEBwuXP6Xpr78UMOhuGGyQ1Nc4PU93T31wkdJo8=; b=kiMh+dIfr34Z2icwQZb4NU98Yq7gm5b63DQ/TnwpaJrGuYYZsCjIqedJ2ijqXYzK1W oFoG4RFwc5QPtlF2TbvDp52RY6bBa9afSjz2M8VkEKeiAgskWCqOPXARS9HbCdDZ6J+w r/yeSvd7bRZnexI76XCskplqr5ZDDIq9Y25PeyboyqHlK4/XpuEzXSyX+6S63Bf+EKk0 JHJ5KLdLV0Idn1h10ddzCQZkCckPQc5vjgm1XK14vVjDGtWmcbv1cRTdGtkh/TZvRO/M Q47Voub3KAaCv87rF0HicrwOAj6UJY7m+Rm+gj1LUgXgwDKw+v7p2NN8G0t6d7oLIYu8 fVag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=DOECU5so; spf=pass (google.com: domain of linux-kernel+bounces-7501-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7501-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id g18-20020a05620a40d200b0077fad9a9febsi818283qko.154.2023.12.20.14.18.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 14:18:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-7501-ouuuleilei=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=DOECU5so; spf=pass (google.com: domain of linux-kernel+bounces-7501-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7501-ouuuleilei=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 D38D31C2267D for ; Wed, 20 Dec 2023 22:18:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E3AE54B5DD; Wed, 20 Dec 2023 22:17:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DOECU5so" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (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 8F1CA4A9AB; Wed, 20 Dec 2023 22:17:50 +0000 (UTC) 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-wm1-f54.google.com with SMTP id 5b1f17b1804b1-40d2764c0f2so2115135e9.2; Wed, 20 Dec 2023 14:17:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703110669; x=1703715469; 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=jotW/smCHe43GFm6S3QgFxRqWUkfntNB5Eyd37F/QlU=; b=DOECU5soZn21H0VU+A0jGZfUCQ8Ug14rMLbCAUTrHeKbQJdv6Jgt0b6JfTAj3W7dJE 62T0H9RYY/KL6nSlLKB+5nec+JIGddilFpKyabbBLlVtc1FZP14rBatWhiqOWo1e0H6G Tv9osLnz9e829JfzKX+4AmBmN4K1OXBexBFU9ezmxBZsUIKybpquBni2IvLKxG5Ue6xh eO/bunLaLStIsCVz9qRFr+PdDYi62gqT3a/sqtvZyvF5Z0oU/LvmyKE+q8hKSGgPcISj heSgdOEn/M4FJ5Cx1nAVK8YOFeUTGj0qXqindurKYLP5cCFN26F81mL8u2SLC9Y+QY1m cUlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703110669; x=1703715469; 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=jotW/smCHe43GFm6S3QgFxRqWUkfntNB5Eyd37F/QlU=; b=kQtTI282cneQ6MkF8VMfYwmKi9BQEukJfoCsLD9CcAcQCbKfGW9A4JSPiiBo/+ScEq V7KJz7qpDEXBY2MhbWGMs8usA47PZEjAWroaRpuxUs6eTJy/xWyV3Ah42lQrcUAcJGTb IgJ07Vl3idvz3T6Wk9YK451KoR0Cnd175WrARq9PT1mMyqQWtz1bfJTVcSEz1f4JIEW0 R67cCmu/wH73YuPhcBt68GIzXvYOtqMqjTqWsT/k0CneM3wNpFEm0EROmRJcc1oMVamN 2dXZLvQ1RIwyvAMzdD53iI/4GX/QlRgUNgSm6j7+H2TcCVeRtcG7VcOTybOiXcBZ8Dyv KCBw== X-Gm-Message-State: AOJu0Yw0WLmEPGQLhF5FUIF8+6jB8F0eAndOpJdocyyXr0dQrDfH5lZ7 2y3YViMqXPCteOZKqakhhk4= X-Received: by 2002:a05:600c:3ac7:b0:40d:190d:f36e with SMTP id d7-20020a05600c3ac700b0040d190df36emr177426wms.161.1703110668449; Wed, 20 Dec 2023 14:17:48 -0800 (PST) Received: from localhost.localdomain (host-95-250-248-68.retail.telecomitalia.it. [95.250.248.68]) by smtp.googlemail.com with ESMTPSA id v14-20020a05600c444e00b0040c58e410a3sm8908826wmn.14.2023.12.20.14.17.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 14:17:48 -0800 (PST) From: Christian Marangi To: Bjorn Andersson , Konrad Dybcio , Michael Turquette , Stephen Boyd , linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Christian Marangi , Wei Lei Subject: [PATCH v8 2/3] clk: qcom: clk-rcg2: add support for rcg2 freq multi ops Date: Wed, 20 Dec 2023 23:17:23 +0100 Message-Id: <20231220221724.3822-3-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231220221724.3822-1-ansuelsmth@gmail.com> References: <20231220221724.3822-1-ansuelsmth@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785841037832480597 X-GMAIL-MSGID: 1785841037832480597 Some RCG frequency can be reached by multiple configuration. Add clk_rcg2_fm_ops ops to support these special RCG configurations. These alternative ops will select the frequency using a CEIL policy. When the correct frequency is found, the correct config is selected by calculating the final rate (by checking the defined parent and values in the config that is being checked) and deciding based on the one that is less different than the requested one. These check are skipped if there is just one config for the requested freq. qcom_find_freq_multi is added to search the freq with the new struct freq_multi_tbl. __clk_rcg2_select_conf is used to select the correct conf by simulating the final clock. If a conf can't be found due to parent not reachable, a WARN is printed and -EINVAL is returned. Tested-by: Wei Lei Signed-off-by: Christian Marangi --- drivers/clk/qcom/clk-rcg.h | 1 + drivers/clk/qcom/clk-rcg2.c | 166 ++++++++++++++++++++++++++++++++++++ drivers/clk/qcom/common.c | 18 ++++ drivers/clk/qcom/common.h | 2 + 4 files changed, 187 insertions(+) diff --git a/drivers/clk/qcom/clk-rcg.h b/drivers/clk/qcom/clk-rcg.h index c50e6616d02c..d7414361e432 100644 --- a/drivers/clk/qcom/clk-rcg.h +++ b/drivers/clk/qcom/clk-rcg.h @@ -190,6 +190,7 @@ struct clk_rcg2_gfx3d { extern const struct clk_ops clk_rcg2_ops; extern const struct clk_ops clk_rcg2_floor_ops; +extern const struct clk_ops clk_rcg2_fm_ops; extern const struct clk_ops clk_rcg2_mux_closest_ops; extern const struct clk_ops clk_edp_pixel_ops; extern const struct clk_ops clk_byte_ops; diff --git a/drivers/clk/qcom/clk-rcg2.c b/drivers/clk/qcom/clk-rcg2.c index 5183c74b074f..9b3aaa7f20ac 100644 --- a/drivers/clk/qcom/clk-rcg2.c +++ b/drivers/clk/qcom/clk-rcg2.c @@ -260,6 +260,115 @@ static int _freq_tbl_determine_rate(struct clk_hw *hw, const struct freq_tbl *f, return 0; } +static const struct freq_conf * +__clk_rcg2_select_conf(struct clk_hw *hw, const struct freq_multi_tbl *f, + unsigned long req_rate) +{ + unsigned long rate_diff, best_rate_diff = ULONG_MAX; + const struct freq_conf *conf, *best_conf = NULL; + struct clk_rcg2 *rcg = to_clk_rcg2(hw); + const char *name = clk_hw_get_name(hw); + unsigned long parent_rate, rate; + struct clk_hw *p; + int index, i; + + /* Exit early if only one config is defined */ + if (f->num_confs == 1) { + best_conf = f->confs; + goto exit; + } + + /* Search in each provided config the one that is near the wanted rate */ + for (i = 0, conf = f->confs; i < f->num_confs; i++, conf++) { + index = qcom_find_src_index(hw, rcg->parent_map, conf->src); + if (index < 0) + continue; + + p = clk_hw_get_parent_by_index(hw, index); + if (!p) + continue; + + parent_rate = clk_hw_get_rate(p); + rate = calc_rate(parent_rate, conf->n, conf->m, conf->n, conf->pre_div); + + if (rate == req_rate) { + best_conf = conf; + goto exit; + } + + rate_diff = abs_diff(req_rate, rate); + if (rate_diff < best_rate_diff) { + best_rate_diff = rate_diff; + best_conf = conf; + } + } + + /* + * Very unlikely. Warn if we couldn't find a correct config + * due to parent not found in every config. + */ + if (unlikely(!best_conf)) { + WARN(1, "%s: can't find a configuration for rate %lu\n", + name, req_rate); + return ERR_PTR(-EINVAL); + } + +exit: + return best_conf; +} + +static int _freq_tbl_fm_determine_rate(struct clk_hw *hw, const struct freq_multi_tbl *f, + struct clk_rate_request *req) +{ + unsigned long clk_flags, rate = req->rate; + struct clk_rcg2 *rcg = to_clk_rcg2(hw); + const struct freq_conf *conf; + struct clk_hw *p; + int index; + + f = qcom_find_freq_multi(f, rate); + if (!f || !f->confs) + return -EINVAL; + + conf = __clk_rcg2_select_conf(hw, f, rate); + if (IS_ERR(conf)) + return PTR_ERR(conf); + index = qcom_find_src_index(hw, rcg->parent_map, conf->src); + if (index < 0) + return index; + + clk_flags = clk_hw_get_flags(hw); + p = clk_hw_get_parent_by_index(hw, index); + if (!p) + return -EINVAL; + + if (clk_flags & CLK_SET_RATE_PARENT) { + rate = f->freq; + if (conf->pre_div) { + if (!rate) + rate = req->rate; + rate /= 2; + rate *= conf->pre_div + 1; + } + + if (conf->n) { + u64 tmp = rate; + + tmp = tmp * conf->n; + do_div(tmp, conf->m); + rate = tmp; + } + } else { + rate = clk_hw_get_rate(p); + } + + req->best_parent_hw = p; + req->best_parent_rate = rate; + req->rate = f->freq; + + return 0; +} + static int clk_rcg2_determine_rate(struct clk_hw *hw, struct clk_rate_request *req) { @@ -276,6 +385,14 @@ static int clk_rcg2_determine_floor_rate(struct clk_hw *hw, return _freq_tbl_determine_rate(hw, rcg->freq_tbl, req, FLOOR); } +static int clk_rcg2_fm_determine_rate(struct clk_hw *hw, + struct clk_rate_request *req) +{ + struct clk_rcg2 *rcg = to_clk_rcg2(hw); + + return _freq_tbl_fm_determine_rate(hw, rcg->freq_multi_tbl, req); +} + static int __clk_rcg2_configure(struct clk_rcg2 *rcg, const struct freq_tbl *f, u32 *_cfg) { @@ -371,6 +488,30 @@ static int __clk_rcg2_set_rate(struct clk_hw *hw, unsigned long rate, return clk_rcg2_configure(rcg, f); } +static int __clk_rcg2_fm_set_rate(struct clk_hw *hw, unsigned long rate) +{ + struct clk_rcg2 *rcg = to_clk_rcg2(hw); + const struct freq_multi_tbl *f; + const struct freq_conf *conf; + struct freq_tbl f_tbl = {}; + + f = qcom_find_freq_multi(rcg->freq_multi_tbl, rate); + if (!f || !f->confs) + return -EINVAL; + + conf = __clk_rcg2_select_conf(hw, f, rate); + if (IS_ERR(conf)) + return PTR_ERR(conf); + + f_tbl.freq = f->freq; + f_tbl.src = conf->src; + f_tbl.pre_div = conf->pre_div; + f_tbl.m = conf->m; + f_tbl.n = conf->n; + + return clk_rcg2_configure(rcg, &f_tbl); +} + static int clk_rcg2_set_rate(struct clk_hw *hw, unsigned long rate, unsigned long parent_rate) { @@ -383,6 +524,12 @@ static int clk_rcg2_set_floor_rate(struct clk_hw *hw, unsigned long rate, return __clk_rcg2_set_rate(hw, rate, FLOOR); } +static int clk_rcg2_fm_set_rate(struct clk_hw *hw, unsigned long rate, + unsigned long parent_rate) +{ + return __clk_rcg2_fm_set_rate(hw, rate); +} + static int clk_rcg2_set_rate_and_parent(struct clk_hw *hw, unsigned long rate, unsigned long parent_rate, u8 index) { @@ -395,6 +542,12 @@ static int clk_rcg2_set_floor_rate_and_parent(struct clk_hw *hw, return __clk_rcg2_set_rate(hw, rate, FLOOR); } +static int clk_rcg2_fm_set_rate_and_parent(struct clk_hw *hw, + unsigned long rate, unsigned long parent_rate, u8 index) +{ + return __clk_rcg2_fm_set_rate(hw, rate); +} + static int clk_rcg2_get_duty_cycle(struct clk_hw *hw, struct clk_duty *duty) { struct clk_rcg2 *rcg = to_clk_rcg2(hw); @@ -505,6 +658,19 @@ const struct clk_ops clk_rcg2_floor_ops = { }; EXPORT_SYMBOL_GPL(clk_rcg2_floor_ops); +const struct clk_ops clk_rcg2_fm_ops = { + .is_enabled = clk_rcg2_is_enabled, + .get_parent = clk_rcg2_get_parent, + .set_parent = clk_rcg2_set_parent, + .recalc_rate = clk_rcg2_recalc_rate, + .determine_rate = clk_rcg2_fm_determine_rate, + .set_rate = clk_rcg2_fm_set_rate, + .set_rate_and_parent = clk_rcg2_fm_set_rate_and_parent, + .get_duty_cycle = clk_rcg2_get_duty_cycle, + .set_duty_cycle = clk_rcg2_set_duty_cycle, +}; +EXPORT_SYMBOL_GPL(clk_rcg2_fm_ops); + const struct clk_ops clk_rcg2_mux_closest_ops = { .determine_rate = __clk_mux_determine_rate_closest, .get_parent = clk_rcg2_get_parent, diff --git a/drivers/clk/qcom/common.c b/drivers/clk/qcom/common.c index 75f09e6e057e..48f81e3a5e80 100644 --- a/drivers/clk/qcom/common.c +++ b/drivers/clk/qcom/common.c @@ -41,6 +41,24 @@ struct freq_tbl *qcom_find_freq(const struct freq_tbl *f, unsigned long rate) } EXPORT_SYMBOL_GPL(qcom_find_freq); +const struct freq_multi_tbl *qcom_find_freq_multi(const struct freq_multi_tbl *f, + unsigned long rate) +{ + if (!f) + return NULL; + + if (!f->freq) + return f; + + for (; f->freq; f++) + if (rate <= f->freq) + return f; + + /* Default to our fastest rate */ + return f - 1; +} +EXPORT_SYMBOL_GPL(qcom_find_freq_multi); + const struct freq_tbl *qcom_find_freq_floor(const struct freq_tbl *f, unsigned long rate) { diff --git a/drivers/clk/qcom/common.h b/drivers/clk/qcom/common.h index 9c8f7b798d9f..2d4a8a837e6c 100644 --- a/drivers/clk/qcom/common.h +++ b/drivers/clk/qcom/common.h @@ -45,6 +45,8 @@ extern const struct freq_tbl *qcom_find_freq(const struct freq_tbl *f, unsigned long rate); extern const struct freq_tbl *qcom_find_freq_floor(const struct freq_tbl *f, unsigned long rate); +extern const struct freq_multi_tbl *qcom_find_freq_multi(const struct freq_multi_tbl *f, + unsigned long rate); extern void qcom_pll_set_fsm_mode(struct regmap *m, u32 reg, u8 bias_count, u8 lock_count); extern int qcom_find_src_index(struct clk_hw *hw, const struct parent_map *map, From patchwork Wed Dec 20 22:17:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 181797 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp46012dyi; Wed, 20 Dec 2023 14:25:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IF91gPsTNdrk/cteJNiESTVMrYRT7Jw849gR2bW3n3KUOp404pNJM5sJN+i17tPnwHpD8mN X-Received: by 2002:a05:6870:d88c:b0:202:ffc8:c6bb with SMTP id oe12-20020a056870d88c00b00202ffc8c6bbmr580516oac.4.1703111154092; Wed, 20 Dec 2023 14:25:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703111154; cv=none; d=google.com; s=arc-20160816; b=gTXl1yQFAce/iVykHlbtpN4UAT868oPlBA4X6P3p/7txRG4f/oworlixtLQOTyx4u6 wCsZgMITRVqCjJgrbMJKAcrphvUQ/w/wHOtcUXC5Im19bI2kaLW+o3B9bs7R1sV1Uj2j 0H5hRXoSuG/+UwCOf1ocf+EPFwR4z2gpDcXNQSdMpGlbdZ6nwzrtZHCumZmDU+72RwIO lL8P/d+QhIB+e/ofms1r61DuyH8U8W9dNtfWNkVaLEwpUxkLtU2PeAs+diWSpdQqL7tb f7rUNYv6iRFYUfualF/BNe7oHzo0FXG5/QxW4Z4zZQJdYCs2ZvdDHwZNkyauEdG1fM2e yfOA== ARC-Message-Signature: i=1; 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=XoL1IP5/8m1OxKspN+bDc7OtzceuHolddBcPNgOTtWM=; fh=VhIJx+T3y1Q1fSF7BLeWIrn14SWi7FGH0iUWQ4VsPhk=; b=P9SJI5tcl83OJxFTgeNLLCbjrpl7r72qRPxemGm2AighzDXM43KVPU54ZaxLH/aCHl 0Qf9pfGCB9G7/Vk1/zprxrDXNws9KfVxu7Q4ezpHomsEss4bBnY0iWvzITZn3EJ/1tT8 YYyHSCoTpUaTv7kHZqFLQDUExQ/yWxC2ZshnKJtWF4mZw5H+qfth5Q+yuKB6kPHnm3le E4Y7Y81kSpCKukbf74Z+9EgB/WhEUSOkcWzBqTQYUSEGpf/dFkiiiRZoNAjb7Pw9FbqV L4hC7a+suOKuCXP8nJIbkl5uQc6km14Emhk2HW7BBlZ/LyJbyd+K59w8OMKtaRrL6t5Z K8+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=ngynl445; spf=pass (google.com: domain of linux-kernel+bounces-7503-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7503-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id ca10-20020a056a02068a00b005b42f4443b7si453522pgb.653.2023.12.20.14.25.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 14:25:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-7503-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=ngynl445; spf=pass (google.com: domain of linux-kernel+bounces-7503-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7503-ouuuleilei=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id BD89F28D968 for ; Wed, 20 Dec 2023 22:19:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E5BB34BA98; Wed, 20 Dec 2023 22:17:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ngynl445" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (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 8F8B54AF79; Wed, 20 Dec 2023 22:17:51 +0000 (UTC) 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-wm1-f52.google.com with SMTP id 5b1f17b1804b1-40c6ea99429so1973885e9.3; Wed, 20 Dec 2023 14:17:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703110670; x=1703715470; 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=XoL1IP5/8m1OxKspN+bDc7OtzceuHolddBcPNgOTtWM=; b=ngynl4457z19gpXxH76QYfWp9U1eNp+i5c3vX/mO/AiDkpnnhUf7GnUS9GNoc1UBne e4brjdNqrkSshEVyLKnk4f4JgcpyicIkNIRY2UlYYk0UEXpzaO1AeoxikRugYXctXeVY ZGp+l0ItI9Nr0aCzYE1VfpFwSThzvJjy2yT+3CDXTV2mguETQOOx8ogy2tE3/GiM7Exu xcydqN8Cmti6P6wPywiRJ/FSOYGMAKOqWwVXJmi7oyubp12tl8w52HPhgJo+SzhjYj/t AAsr7UIsrVXVo2jt1AsuPsVpxqC5Pp3kHGWvACbapsFHQetWTHR1wZQeM1fvTZVLiVb7 +kqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703110670; x=1703715470; 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=XoL1IP5/8m1OxKspN+bDc7OtzceuHolddBcPNgOTtWM=; b=nAuhK/HEeOdD0kZgdGLGqh1Elkm0IwTkh+Cu8c8eBOR1yH8vi+eeH4dk0Tx74W8yCl 7KfMZXM2j4DSkoBqNLcsaR0KmJZU6Ht2dnmZ2AP65E14q3SIqGBMYXK7Yfh1jlROsH9q mTSmrIJdT7IQEwf7wXH8ED0BiJ7DBIJakD6qRdnVXSelvdmxX/nyLcKdB1KQdzVd10oh 6M34yqh70WM/r+kI2oFOWDAlI5VJ18oon9t+lZU0ZKh+v6rhPEY8HeVbhF7tYF1YEWJS 1h0h2fJWU7KYZ5W4c5qkj3jXxu64YE3Yss/3tuCztJr4qpNi4VKyYH1i5bMVuL3ocHz4 V3hg== X-Gm-Message-State: AOJu0YxClUp7sbtx/peSlnB9TYMVUlDdXLaDXU6Q8JTQFGO8b802gD0a qNQkGuJ8z6R0zz5mqZ5Z37w= X-Received: by 2002:a05:600c:19d3:b0:40b:5e1e:fb94 with SMTP id u19-20020a05600c19d300b0040b5e1efb94mr128343wmq.73.1703110669756; Wed, 20 Dec 2023 14:17:49 -0800 (PST) Received: from localhost.localdomain (host-95-250-248-68.retail.telecomitalia.it. [95.250.248.68]) by smtp.googlemail.com with ESMTPSA id v14-20020a05600c444e00b0040c58e410a3sm8908826wmn.14.2023.12.20.14.17.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 14:17:49 -0800 (PST) From: Christian Marangi To: Bjorn Andersson , Konrad Dybcio , Michael Turquette , Stephen Boyd , linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Christian Marangi Subject: [PATCH v8 3/3] clk: qcom: gcc-ipq8074: rework nss_port5/6 clock to multiple conf Date: Wed, 20 Dec 2023 23:17:24 +0100 Message-Id: <20231220221724.3822-4-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231220221724.3822-1-ansuelsmth@gmail.com> References: <20231220221724.3822-1-ansuelsmth@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785841481347103748 X-GMAIL-MSGID: 1785841481347103748 Rework nss_port5/6 to use the new multiple configuration implementation and correctly fix the clocks for these port under some corner case. This is particularly relevant for device that have 2.5G or 10G port connected to port5 or port 6 on ipq8074. As the parent are shared across multiple port it may be required to select the correct configuration to accomplish the desired clock. Without this patch such port doesn't work in some specific ethernet speed as the clock will be set to the wrong frequency as we just select the first configuration for the related frequency instead of selecting the best one. Signed-off-by: Christian Marangi --- drivers/clk/qcom/gcc-ipq8074.c | 120 +++++++++++++++++++++------------ 1 file changed, 76 insertions(+), 44 deletions(-) diff --git a/drivers/clk/qcom/gcc-ipq8074.c b/drivers/clk/qcom/gcc-ipq8074.c index b7faf12a511a..6f9ca10c29c5 100644 --- a/drivers/clk/qcom/gcc-ipq8074.c +++ b/drivers/clk/qcom/gcc-ipq8074.c @@ -1675,15 +1675,23 @@ static struct clk_regmap_div nss_port4_tx_div_clk_src = { }, }; -static const struct freq_tbl ftbl_nss_port5_rx_clk_src[] = { - F(19200000, P_XO, 1, 0, 0), - F(25000000, P_UNIPHY1_RX, 12.5, 0, 0), - F(25000000, P_UNIPHY0_RX, 5, 0, 0), - F(78125000, P_UNIPHY1_RX, 4, 0, 0), - F(125000000, P_UNIPHY1_RX, 2.5, 0, 0), - F(125000000, P_UNIPHY0_RX, 1, 0, 0), - F(156250000, P_UNIPHY1_RX, 2, 0, 0), - F(312500000, P_UNIPHY1_RX, 1, 0, 0), +static const struct freq_conf ftbl_nss_port5_rx_clk_src_25[] = { + C(P_UNIPHY1_RX, 12.5, 0, 0), + C(P_UNIPHY0_RX, 5, 0, 0), +}; + +static const struct freq_conf ftbl_nss_port5_rx_clk_src_125[] = { + C(P_UNIPHY1_RX, 2.5, 0, 0), + C(P_UNIPHY0_RX, 1, 0, 0), +}; + +static const struct freq_multi_tbl ftbl_nss_port5_rx_clk_src[] = { + FMS(19200000, P_XO, 1, 0, 0), + FM(25000000, ftbl_nss_port5_rx_clk_src_25), + FMS(78125000, P_UNIPHY1_RX, 4, 0, 0), + FM(125000000, ftbl_nss_port5_rx_clk_src_125), + FMS(156250000, P_UNIPHY1_RX, 2, 0, 0), + FMS(312500000, P_UNIPHY1_RX, 1, 0, 0), { } }; @@ -1710,14 +1718,14 @@ gcc_xo_uniphy0_rx_tx_uniphy1_rx_tx_ubi32_bias_map[] = { static struct clk_rcg2 nss_port5_rx_clk_src = { .cmd_rcgr = 0x68060, - .freq_tbl = ftbl_nss_port5_rx_clk_src, + .freq_multi_tbl = ftbl_nss_port5_rx_clk_src, .hid_width = 5, .parent_map = gcc_xo_uniphy0_rx_tx_uniphy1_rx_tx_ubi32_bias_map, .clkr.hw.init = &(struct clk_init_data){ .name = "nss_port5_rx_clk_src", .parent_data = gcc_xo_uniphy0_rx_tx_uniphy1_rx_tx_ubi32_bias, .num_parents = ARRAY_SIZE(gcc_xo_uniphy0_rx_tx_uniphy1_rx_tx_ubi32_bias), - .ops = &clk_rcg2_ops, + .ops = &clk_rcg2_fm_ops, }, }; @@ -1737,15 +1745,23 @@ static struct clk_regmap_div nss_port5_rx_div_clk_src = { }, }; -static const struct freq_tbl ftbl_nss_port5_tx_clk_src[] = { - F(19200000, P_XO, 1, 0, 0), - F(25000000, P_UNIPHY1_TX, 12.5, 0, 0), - F(25000000, P_UNIPHY0_TX, 5, 0, 0), - F(78125000, P_UNIPHY1_TX, 4, 0, 0), - F(125000000, P_UNIPHY1_TX, 2.5, 0, 0), - F(125000000, P_UNIPHY0_TX, 1, 0, 0), - F(156250000, P_UNIPHY1_TX, 2, 0, 0), - F(312500000, P_UNIPHY1_TX, 1, 0, 0), +static const struct freq_conf ftbl_nss_port5_tx_clk_src_25[] = { + C(P_UNIPHY1_TX, 12.5, 0, 0), + C(P_UNIPHY0_TX, 5, 0, 0), +}; + +static const struct freq_conf ftbl_nss_port5_tx_clk_src_125[] = { + C(P_UNIPHY1_TX, 2.5, 0, 0), + C(P_UNIPHY0_TX, 1, 0, 0), +}; + +static const struct freq_multi_tbl ftbl_nss_port5_tx_clk_src[] = { + FMS(19200000, P_XO, 1, 0, 0), + FM(25000000, ftbl_nss_port5_tx_clk_src_25), + FMS(78125000, P_UNIPHY1_TX, 4, 0, 0), + FM(125000000, ftbl_nss_port5_tx_clk_src_125), + FMS(156250000, P_UNIPHY1_TX, 2, 0, 0), + FMS(312500000, P_UNIPHY1_TX, 1, 0, 0), { } }; @@ -1772,14 +1788,14 @@ gcc_xo_uniphy0_tx_rx_uniphy1_tx_rx_ubi32_bias_map[] = { static struct clk_rcg2 nss_port5_tx_clk_src = { .cmd_rcgr = 0x68068, - .freq_tbl = ftbl_nss_port5_tx_clk_src, + .freq_multi_tbl = ftbl_nss_port5_tx_clk_src, .hid_width = 5, .parent_map = gcc_xo_uniphy0_tx_rx_uniphy1_tx_rx_ubi32_bias_map, .clkr.hw.init = &(struct clk_init_data){ .name = "nss_port5_tx_clk_src", .parent_data = gcc_xo_uniphy0_tx_rx_uniphy1_tx_rx_ubi32_bias, .num_parents = ARRAY_SIZE(gcc_xo_uniphy0_tx_rx_uniphy1_tx_rx_ubi32_bias), - .ops = &clk_rcg2_ops, + .ops = &clk_rcg2_fm_ops, }, }; @@ -1799,15 +1815,23 @@ static struct clk_regmap_div nss_port5_tx_div_clk_src = { }, }; -static const struct freq_tbl ftbl_nss_port6_rx_clk_src[] = { - F(19200000, P_XO, 1, 0, 0), - F(25000000, P_UNIPHY2_RX, 5, 0, 0), - F(25000000, P_UNIPHY2_RX, 12.5, 0, 0), - F(78125000, P_UNIPHY2_RX, 4, 0, 0), - F(125000000, P_UNIPHY2_RX, 1, 0, 0), - F(125000000, P_UNIPHY2_RX, 2.5, 0, 0), - F(156250000, P_UNIPHY2_RX, 2, 0, 0), - F(312500000, P_UNIPHY2_RX, 1, 0, 0), +static const struct freq_conf ftbl_nss_port6_rx_clk_src_25[] = { + C(P_UNIPHY2_RX, 5, 0, 0), + C(P_UNIPHY2_RX, 12.5, 0, 0), +}; + +static const struct freq_conf ftbl_nss_port6_rx_clk_src_125[] = { + C(P_UNIPHY2_RX, 1, 0, 0), + C(P_UNIPHY2_RX, 2.5, 0, 0), +}; + +static const struct freq_multi_tbl ftbl_nss_port6_rx_clk_src[] = { + FMS(19200000, P_XO, 1, 0, 0), + FM(25000000, ftbl_nss_port6_rx_clk_src_25), + FMS(78125000, P_UNIPHY2_RX, 4, 0, 0), + FM(125000000, ftbl_nss_port6_rx_clk_src_125), + FMS(156250000, P_UNIPHY2_RX, 2, 0, 0), + FMS(312500000, P_UNIPHY2_RX, 1, 0, 0), { } }; @@ -1829,14 +1853,14 @@ static const struct parent_map gcc_xo_uniphy2_rx_tx_ubi32_bias_map[] = { static struct clk_rcg2 nss_port6_rx_clk_src = { .cmd_rcgr = 0x68070, - .freq_tbl = ftbl_nss_port6_rx_clk_src, + .freq_multi_tbl = ftbl_nss_port6_rx_clk_src, .hid_width = 5, .parent_map = gcc_xo_uniphy2_rx_tx_ubi32_bias_map, .clkr.hw.init = &(struct clk_init_data){ .name = "nss_port6_rx_clk_src", .parent_data = gcc_xo_uniphy2_rx_tx_ubi32_bias, .num_parents = ARRAY_SIZE(gcc_xo_uniphy2_rx_tx_ubi32_bias), - .ops = &clk_rcg2_ops, + .ops = &clk_rcg2_fm_ops, }, }; @@ -1856,15 +1880,23 @@ static struct clk_regmap_div nss_port6_rx_div_clk_src = { }, }; -static const struct freq_tbl ftbl_nss_port6_tx_clk_src[] = { - F(19200000, P_XO, 1, 0, 0), - F(25000000, P_UNIPHY2_TX, 5, 0, 0), - F(25000000, P_UNIPHY2_TX, 12.5, 0, 0), - F(78125000, P_UNIPHY2_TX, 4, 0, 0), - F(125000000, P_UNIPHY2_TX, 1, 0, 0), - F(125000000, P_UNIPHY2_TX, 2.5, 0, 0), - F(156250000, P_UNIPHY2_TX, 2, 0, 0), - F(312500000, P_UNIPHY2_TX, 1, 0, 0), +static const struct freq_conf ftbl_nss_port6_tx_clk_src_25[] = { + C(P_UNIPHY2_TX, 5, 0, 0), + C(P_UNIPHY2_TX, 12.5, 0, 0), +}; + +static const struct freq_conf ftbl_nss_port6_tx_clk_src_125[] = { + C(P_UNIPHY2_TX, 1, 0, 0), + C(P_UNIPHY2_TX, 2.5, 0, 0), +}; + +static const struct freq_multi_tbl ftbl_nss_port6_tx_clk_src[] = { + FMS(19200000, P_XO, 1, 0, 0), + FM(25000000, ftbl_nss_port6_tx_clk_src_25), + FMS(78125000, P_UNIPHY1_RX, 4, 0, 0), + FM(125000000, ftbl_nss_port6_tx_clk_src_125), + FMS(156250000, P_UNIPHY1_RX, 2, 0, 0), + FMS(312500000, P_UNIPHY1_RX, 1, 0, 0), { } }; @@ -1886,14 +1918,14 @@ static const struct parent_map gcc_xo_uniphy2_tx_rx_ubi32_bias_map[] = { static struct clk_rcg2 nss_port6_tx_clk_src = { .cmd_rcgr = 0x68078, - .freq_tbl = ftbl_nss_port6_tx_clk_src, + .freq_multi_tbl = ftbl_nss_port6_tx_clk_src, .hid_width = 5, .parent_map = gcc_xo_uniphy2_tx_rx_ubi32_bias_map, .clkr.hw.init = &(struct clk_init_data){ .name = "nss_port6_tx_clk_src", .parent_data = gcc_xo_uniphy2_tx_rx_ubi32_bias, .num_parents = ARRAY_SIZE(gcc_xo_uniphy2_tx_rx_ubi32_bias), - .ops = &clk_rcg2_ops, + .ops = &clk_rcg2_fm_ops, }, };