| Message ID | 20240703090512.92636-3-michael@amarulasolutions.com |
|---|---|
| State | New |
| Headers |
Return-Path:
<linux-amarula+bncBCXK73FY3AFRBT5ISS2AMGQE4ZDIYUI@amarulasolutions.com>
X-Original-To: linux-amarula@patchwork.amarulasolutions.com
Delivered-To: linux-amarula@patchwork.amarulasolutions.com
Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com
[209.85.208.70])
by ganimede.amarulasolutions.com (Postfix) with ESMTPS id BB9623F151
for <linux-amarula@patchwork.amarulasolutions.com>;
Wed, 3 Jul 2024 11:05:19 +0200 (CEST)
Received: by mail-ed1-f70.google.com with SMTP id
4fb4d7f45d1cf-58d6fdee657sf49917a12.2
for <linux-amarula@patchwork.amarulasolutions.com>;
Wed, 03 Jul 2024 02:05:19 -0700 (PDT)
ARC-Seal: i=2; a=rsa-sha256; t=1719997519; cv=pass;
d=google.com; s=arc-20160816;
b=Fgd9CZQQQYK6ZgEjYQlHuaRqo7jT+qwTWKNATg7OAIdqwghzP4kM+9AvpSUWtK5FBc
nzIUw7gZ5xgxM6dk7wm0ptS3qQKCt6o8ps4l4jrtvaS/smwgnUuRV1HQM2i1eNwqNqKB
MOL/7oBQXaYAptFbFyson37UYrH2HeMKFtqVu/okDna7ZXyCYsyT1D84Oc0tPMBH9z0e
wTaPNQzVq+I4zp6eyJ6AXwxDt/H9+JTg2bzIJedxZabRGbdp3yUkEhaK/HGim/IkMkSG
5nPc8BIdn+2mcBu/r3a6VBvpAwCqgAFcHK2LGvR4kjDLUAqq71F5YSbRuQUK57Qi4dKx
sOpw==
ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com;
s=arc-20160816;
h=list-unsubscribe:list-archive:list-help:list-post:list-id
:mailing-list:precedence:mime-version:references:in-reply-to
:message-id:date:subject:cc:to:from:dkim-signature;
bh=44y4riQ2jcuaRcS9wOzWNj9fC+jZe8RTg8yD4fikfhk=;
fh=9gFL2UAnfMmVNbgCKJA6qP8RFFVx6De55Y/+zvjc4JM=;
b=N3slyLe2PoPF2Xydh7MUHEjuv1S0QAq643zkLPRs86eLkCUT6uttVMbTtn4dpI2B8M
1cqcCn7Oa8dcLWwEFsrwj31JO73OZ0iHS1FRchD3XY3ykaH4db6dwowmnhTAZ9mIZjWh
6qz+rX/8vYBxM8rsMRcEvFY4yKygC79//b+95PeyM715TEVa+8mJq/OcVCPQD55kXHeA
yMLN3iXAo//jw+gyf5Kt2pBUk+jZ5l1InmWdbkJv6seqPS/HYiEx3OwSDFCucOYOqlqm
ErFYrgR7/AM+Ep7hfjRtZ84QcVgROE1ZYiRVoym1V3cawU8m3l7UZ4s1c26+xif7HNTU
qgVA==;
darn=patchwork.amarulasolutions.com
ARC-Authentication-Results: i=2; mx.google.com;
dkim=pass header.i=@amarulasolutions.com header.s=google
header.b=jvJIqebC;
spf=pass (google.com: domain of michael@amarulasolutions.com designates
209.85.220.41 as permitted sender)
smtp.mailfrom=michael@amarulasolutions.com;
dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com;
dara=pass header.i=@amarulasolutions.com
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=amarulasolutions.com; s=google; t=1719997519; x=1720602319;
darn=patchwork.amarulasolutions.com;
h=list-unsubscribe:list-archive:list-help:list-post:list-id
:mailing-list:precedence:x-original-authentication-results
:x-original-sender:mime-version:references:in-reply-to:message-id
:date:subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to;
bh=44y4riQ2jcuaRcS9wOzWNj9fC+jZe8RTg8yD4fikfhk=;
b=QgNg1dFqI6VWw/nDRPErv7SONnAslq2sTqC9krvSwDlVWkUJMaNtrZQUPhtKpIRtyU
kVN7Xj4y820C/kJEijy0sfwJ+ZUnxwKAoRhKlgu5QKo6RJHhiEq/CccWI+gbh64uhUP7
UFiBFmbFHd/9Wy9jf5jwmF+C0sFFj9SbaBaeg=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20230601; t=1719997519; x=1720602319;
h=list-unsubscribe:list-archive:list-help:list-post
:x-spam-checked-in-group:list-id:mailing-list:precedence
:x-original-authentication-results:x-original-sender:mime-version
:references:in-reply-to:message-id:date:subject:cc:to:from
:x-beenthere:x-gm-message-state:from:to:cc:subject:date:message-id
:reply-to;
bh=44y4riQ2jcuaRcS9wOzWNj9fC+jZe8RTg8yD4fikfhk=;
b=Hq0cpW3NezVLQZ5MYuGCDTqpgj11rfMi6zQAPTQgnqOPaPT+lsPHCvI1onqoEMU/zg
1WtcR9r1kHKfh4Dbx+MYIjGfjG+CBtNhVI73pq1y0c5IQVCOKAhRr8XkkOz5UD2dzRG2
h2yiMSnf3HWAvLKl4iGW4Pfa1r/est4NL+wFA7MufkfFzzFXmnpz4UAbn9Aq5giNP7o1
6EDAQmfy4dLaMru65R1wSd3wCWaQlr0K/U9f9WYOKrLQbOoNfgMjlIEX4pZtZZ7NT0iO
dUeFOgyDt/itvsWe5b0Jt3L8pWpPwQRB+bSHbHmXD0FHRJDBW9X6AcCbITVJf7vlnnrq
CbEQ==
X-Forwarded-Encrypted: i=2;
AJvYcCVRz+w05T7kGMIoa6WhmLQ7/y+Jb8hIDLwImr3XOr0YFxel0ATXk5GMuX4miemArCSSItmYtqIlHsZX64H0Gol0G6Tj77TqbWw/yObWAgDsDBQC8S9HRLsIuTMoIA==
X-Gm-Message-State: AOJu0YzVrv11GXZuK7MaQUUTtbpMNc/2DkQ0UvGs0Mb97phavxbQU8xp
Nh8U977TMH02XKKRxisjawNtUbGfOEINXanTo+L/Sj/HatBiB/FYcJIBBnwwOm76CQ==
X-Google-Smtp-Source:
AGHT+IFPEy1Us1DNFwacO9rENZxLk5cW39qd6VY0Y2swsor6mQQmg2pqflHBgNa80aQf1p8zDM5ntg==
X-Received: by 2002:a05:6402:90e:b0:57c:abf9:e6ab with SMTP id
4fb4d7f45d1cf-587a0bfc706mr8367869a12.31.1719997519492;
Wed, 03 Jul 2024 02:05:19 -0700 (PDT)
X-BeenThere: linux-amarula@amarulasolutions.com
Received: by 2002:aa7:db43:0:b0:58b:b493:fcc9 with SMTP id
4fb4d7f45d1cf-58bb49403ffls736158a12.0.-pod-prod-03-eu;
Wed, 03 Jul 2024 02:05:18 -0700 (PDT)
X-Forwarded-Encrypted: i=2;
AJvYcCW9Uqg8h1ZFCk+vcH12aPV5w1HTl4zdjleGEUKX28aORocDzYY8mVgNc6kiNxzmd+/L+LiXVNYA3xVLly8zkJ7+wlqJe2JzsmKkL5vYV/86qYrj
X-Received: by 2002:a17:906:da85:b0:a6f:33d6:2d49 with SMTP id
a640c23a62f3a-a75144bade6mr789008366b.52.1719997517644;
Wed, 03 Jul 2024 02:05:17 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1719997517; cv=none;
d=google.com; s=arc-20160816;
b=Ckp3cQLwHbxFs8KtxRAj8b/qIc9DOCqFneFDM7nof23b5/h63I4QnJB90pth2kwRE+
x7gDz/tniLglcQBq37jr7lwIMOW+cG6JSoD0SEn9nlsantEG0VCN/Vo78A6FHSTa1JNN
+81zHGleN7pUqSBPiaCllwSD6Y4VDRgiR5nt6i1ScxFHoO0DtFdhI1Q3lZZFTsN581wQ
yOHwQw9BXgv5/D+qeBTLqYlRgMmplUpdEMN7gXC/JXuFB2+wCXLgQFaRVf8NDSp2hUof
qcTEZeYU+1uarF6e8wu9qr0WxUaNjYqwNmIMmUeJfJRlesp0aS4h3XmXq5zzn4PmRtRC
ZXQg==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com;
s=arc-20160816;
h=content-transfer-encoding:mime-version:references:in-reply-to
:message-id:date:subject:cc:to:from:dkim-signature;
bh=nTKyPOiZSdTeRWSurS/BWFcqhEtBNgG2EpnrpWfnasU=;
fh=bGIUGJs3Ag4YVOjJYshOrmBcHMSYDBIhqXi+beT5aYk=;
b=iVHRe1ha+yIHY96LjavQHTF5LQlghSxaase58lt/Xsl8wLtoFFGwiq9B2p4SlRY5go
NnlXnCKc38Nka1YuD0CI6PnsAQ5sc+XEav0IqshF8atjRs525CTmQ6Y1x6KJKMzjfsmz
qSQvBu9hzcoLJR753bk2efSj+AfcF4hUEFoiEmnkitF2oDnXCPpIVtptlEd4agHAM+mz
GFO37g5Cur1v/I4XslIa7ym2UxnslA/xe3btcawpJGqIbIqKjIkWWm07v4QL9D74pH3H
yDTtbljbjiIsbbYM9zxQBQDqqa5uLRJktNgubAGj+5oj/fv7kJtikATP91Z70L7X20pU
WB2w==;
dara=google.com
ARC-Authentication-Results: i=1; mx.google.com;
dkim=pass header.i=@amarulasolutions.com header.s=google
header.b=jvJIqebC;
spf=pass (google.com: domain of michael@amarulasolutions.com designates
209.85.220.41 as permitted sender)
smtp.mailfrom=michael@amarulasolutions.com;
dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com;
dara=pass header.i=@amarulasolutions.com
Received: from mail-sor-f41.google.com (mail-sor-f41.google.com.
[209.85.220.41])
by mx.google.com with SMTPS id
a640c23a62f3a-a729d8950c5sor396705266b.2.2024.07.03.02.05.17
for <linux-amarula@amarulasolutions.com>
(Google Transport Security);
Wed, 03 Jul 2024 02:05:17 -0700 (PDT)
Received-SPF: pass (google.com: domain of michael@amarulasolutions.com
designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41;
X-Forwarded-Encrypted: i=1;
AJvYcCUKDYXEpH/tU8765DYxk0yz/YHGCvVDVLX2HOJeJ0WtInk/qudN1X+HXweigyESZnYip9Nhbs+zJMjSy+N4MwmHotq19lv76o3S4dQ8mIOMtpXV
X-Received: by 2002:a17:907:2d22:b0:a6f:4b5b:4ba7 with SMTP id
a640c23a62f3a-a75144dea19mr816420266b.67.1719997517158;
Wed, 03 Jul 2024 02:05:17 -0700 (PDT)
Received: from panicking.amarulasolutions.com
([2001:b07:6474:ebbf:d622:a7f3:7832:9423])
by smtp.gmail.com with ESMTPSA id
a640c23a62f3a-a72aaf1bb6bsm491186866b.30.2024.07.03.02.05.16
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Wed, 03 Jul 2024 02:05:16 -0700 (PDT)
From: Michael Trimarchi <michael@amarulasolutions.com>
To: Lukasz Majewski <lukma@denx.de>,
Sean Anderson <seanga2@gmail.com>
Cc: Tom Rini <trini@konsulko.com>,
linux-amarula@amarulasolutions.com,
u-boot@lists.denx.de,
Dario Binacchi <dario.binacchi@amarulasolutions.com>,
Michael Trimarchi <michael@amarulasolutions.com>
Subject: [PATCH 2/2] clk: imx: add mux ops for i.MX8M composite clk
Date: Wed, 3 Jul 2024 11:05:11 +0200
Message-ID: <20240703090512.92636-3-michael@amarulasolutions.com>
X-Mailer: git-send-email 2.43.0
In-Reply-To: <20240703090512.92636-1-michael@amarulasolutions.com>
References: <20240703090512.92636-1-michael@amarulasolutions.com>
MIME-Version: 1.0
X-Original-Sender: michael@amarulasolutions.com
X-Original-Authentication-Results: mx.google.com; dkim=pass
header.i=@amarulasolutions.com header.s=google header.b=jvJIqebC;
spf=pass (google.com: domain of michael@amarulasolutions.com designates
209.85.220.41 as permitted sender)
smtp.mailfrom=michael@amarulasolutions.com;
dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com;
dara=pass header.i=@amarulasolutions.com
Content-Type: text/plain; charset="UTF-8"
Precedence: list
Mailing-list: list linux-amarula@amarulasolutions.com;
contact linux-amarula+owners@amarulasolutions.com
List-ID: <linux-amarula.amarulasolutions.com>
X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com
X-Google-Group-Id: 476853432473
List-Post:
<https://groups.google.com/a/amarulasolutions.com/group/linux-amarula/post>,
<mailto:linux-amarula@amarulasolutions.com>
List-Help:
<https://support.google.com/a/amarulasolutions.com/bin/topic.py?topic=25838>,
<mailto:linux-amarula+help@amarulasolutions.com>
List-Archive:
<https://groups.google.com/a/amarulasolutions.com/group/linux-amarula/>
List-Unsubscribe:
<mailto:googlegroups-manage+476853432473+unsubscribe@googlegroups.com>,
<https://groups.google.com/a/amarulasolutions.com/group/linux-amarula/subscribe>
|
| Series |
Support imx8m composite mux
|
|
Commit Message
Michael Trimarchi
July 3, 2024, 9:05 a.m. UTC
Upstream Linux commit f90b68d6c8b0.
The CORE/BUS root slice has following design, simplied graph:
The difference is core not have pre_div block.
A composite core/bus clk has 8 inputs for mux to select, saying clk[0-7].
It support target(smart) interface and normal interface. Target interface
is exported for programmer easy to configure ccm root. Normal interface
is also exported, but we not use it in our driver, because it will
introduce more complexity compared with target interface.
The normal interface simplified as below:
SEL_A GA
+--+ +-+
| +->+ +------+
CLK[0-7]--->+ | +-+ |
| | | +----v---+ +----+
| +--+ |pre_diva+----> | +---------+
| +--------+ |mux +--+post_div |
| +--+ |pre_divb+--->+ | +---------+
| | | +----^---+ +----+
+--->+ | +-+ |
| +->+ +------+
+--+ +-+
SEL_B GB
The mux in the upper pic is not the target interface MUX, target
interface MUX is hiding SEL_A and SEL_B. When you choose clk[0-7],
you are actually writing SEL_A or SEL_B depends on the internal
counter which will also control the internal "mux".
The target interface simplified as below which is used by Linux Kernel:
CLK[0-7]--->MUX-->Gate-->pre_div-->post_div
A requirement of the Target Interface's software is that the
target clock source is active, it means when setting SEL_A, the
current input clk to SEL_A must be active, same to SEL_B.
We touch target interface, but hardware logic actually also need
configure normal interface.
There will be system hang, when doing the following steps:
The initial state:
SEL_A/SEL_B are both sourcing from clk0, the internal counter
choose SEL_A.
1. switch mux from clk0 to clk1
The hardware logic will choose SEL_B and configure SEL_B to clk1.
SEL_A no changed.
2. gate off clk0
Disable clk0, then the input to SEL_A is off.
3. switch from clk1 to clk2
The hardware logic will choose SEL_A and configure SEL_A to clk2,
however the current SEL_A input clk0 is off, the system hang.
The solution to fix the issue is in step 1, write twice to
target interface MUX, it will make SEL_A/SEL_B both sources
from clk1, then no need to care about the state of clk0. And
finally system performs well.
Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
---
drivers/clk/imx/clk-composite-8m.c | 37 +++++++++++++++++++++++++++++-
1 file changed, 36 insertions(+), 1 deletion(-)
Comments
Hi Michael, On Wed, Jul 3, 2024 at 6:15 AM Michael Trimarchi <michael@amarulasolutions.com> wrote: > > Upstream Linux commit f90b68d6c8b0. .... > The CORE/BUS root slice has following design, simplied graph: > The difference is core not have pre_div block. > A composite core/bus clk has 8 inputs for mux to select, saying clk[0-7]. > > It support target(smart) interface and normal interface. Target interface > is exported for programmer easy to configure ccm root. Normal interface > is also exported, but we not use it in our driver, because it will > introduce more complexity compared with target interface. > > The normal interface simplified as below: > SEL_A GA > +--+ +-+ > | +->+ +------+ > CLK[0-7]--->+ | +-+ | > | | | +----v---+ +----+ > | +--+ |pre_diva+----> | +---------+ > | +--------+ |mux +--+post_div | > | +--+ |pre_divb+--->+ | +---------+ > | | | +----^---+ +----+ > +--->+ | +-+ | > | +->+ +------+ > +--+ +-+ > SEL_B GB > > The mux in the upper pic is not the target interface MUX, target > interface MUX is hiding SEL_A and SEL_B. When you choose clk[0-7], > you are actually writing SEL_A or SEL_B depends on the internal > counter which will also control the internal "mux". > > The target interface simplified as below which is used by Linux Kernel: > CLK[0-7]--->MUX-->Gate-->pre_div-->post_div > > A requirement of the Target Interface's software is that the > target clock source is active, it means when setting SEL_A, the > current input clk to SEL_A must be active, same to SEL_B. > > We touch target interface, but hardware logic actually also need > configure normal interface. > > There will be system hang, when doing the following steps: > The initial state: > SEL_A/SEL_B are both sourcing from clk0, the internal counter > choose SEL_A. > 1. switch mux from clk0 to clk1 > The hardware logic will choose SEL_B and configure SEL_B to clk1. > SEL_A no changed. > 2. gate off clk0 > Disable clk0, then the input to SEL_A is off. > 3. switch from clk1 to clk2 > The hardware logic will choose SEL_A and configure SEL_A to clk2, > however the current SEL_A input clk0 is off, the system hang. > > The solution to fix the issue is in step 1, write twice to > target interface MUX, it will make SEL_A/SEL_B both sources > from clk1, then no need to care about the state of clk0. And > finally system performs well. Shouldn't this also contain the original kernel commit author's Signed-off-by? > Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com> To unsubscribe from this group and stop receiving emails from it, send an email to linux-amarula+unsubscribe@amarulasolutions.com.
Hi Fabio On Wed, Jul 3, 2024 at 3:44 PM Fabio Estevam <festevam@gmail.com> wrote: > > Hi Michael, > > On Wed, Jul 3, 2024 at 6:15 AM Michael Trimarchi > <michael@amarulasolutions.com> wrote: > > > > Upstream Linux commit f90b68d6c8b0. > .... > > > The CORE/BUS root slice has following design, simplied graph: > > The difference is core not have pre_div block. > > A composite core/bus clk has 8 inputs for mux to select, saying clk[0-7]. > > > > It support target(smart) interface and normal interface. Target interface > > is exported for programmer easy to configure ccm root. Normal interface > > is also exported, but we not use it in our driver, because it will > > introduce more complexity compared with target interface. > > > > The normal interface simplified as below: > > SEL_A GA > > +--+ +-+ > > | +->+ +------+ > > CLK[0-7]--->+ | +-+ | > > | | | +----v---+ +----+ > > | +--+ |pre_diva+----> | +---------+ > > | +--------+ |mux +--+post_div | > > | +--+ |pre_divb+--->+ | +---------+ > > | | | +----^---+ +----+ > > +--->+ | +-+ | > > | +->+ +------+ > > +--+ +-+ > > SEL_B GB > > > > The mux in the upper pic is not the target interface MUX, target > > interface MUX is hiding SEL_A and SEL_B. When you choose clk[0-7], > > you are actually writing SEL_A or SEL_B depends on the internal > > counter which will also control the internal "mux". > > > > The target interface simplified as below which is used by Linux Kernel: > > CLK[0-7]--->MUX-->Gate-->pre_div-->post_div > > > > A requirement of the Target Interface's software is that the > > target clock source is active, it means when setting SEL_A, the > > current input clk to SEL_A must be active, same to SEL_B. > > > > We touch target interface, but hardware logic actually also need > > configure normal interface. > > > > There will be system hang, when doing the following steps: > > The initial state: > > SEL_A/SEL_B are both sourcing from clk0, the internal counter > > choose SEL_A. > > 1. switch mux from clk0 to clk1 > > The hardware logic will choose SEL_B and configure SEL_B to clk1. > > SEL_A no changed. > > 2. gate off clk0 > > Disable clk0, then the input to SEL_A is off. > > 3. switch from clk1 to clk2 > > The hardware logic will choose SEL_A and configure SEL_A to clk2, > > however the current SEL_A input clk0 is off, the system hang. > > > > The solution to fix the issue is in step 1, write twice to > > target interface MUX, it will make SEL_A/SEL_B both sources > > from clk1, then no need to care about the state of clk0. And > > finally system performs well. > > Shouldn't this also contain the original kernel commit author's Signed-off-by? > > > Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com> Fine to me to add. I made a mistake. Let's wait on other reviews Michael To unsubscribe from this group and stop receiving emails from it, send an email to linux-amarula+unsubscribe@amarulasolutions.com.
diff --git a/drivers/clk/imx/clk-composite-8m.c b/drivers/clk/imx/clk-composite-8m.c index 560d74aac80..2cb7d135000 100644 --- a/drivers/clk/imx/clk-composite-8m.c +++ b/drivers/clk/imx/clk-composite-8m.c @@ -117,6 +117,41 @@ static const struct clk_ops imx8m_clk_composite_divider_ops = { .set_rate = imx8m_clk_composite_divider_set_rate, }; +static int imx8m_clk_mux_set_parent(struct clk *clk, struct clk *parent) +{ + struct clk_mux *mux = to_clk_mux(clk); + int index; + u32 val; + u32 reg; + + index = clk_mux_fetch_parent_index(clk, parent); + if (index < 0) { + log_err("Could not fetch index\n"); + return index; + } + + val = clk_mux_index_to_val(mux->table, mux->flags, index); + + reg = readl(mux->reg); + reg &= ~(mux->mask << mux->shift); + val = val << mux->shift; + reg |= val; + + /* + * write twice to make sure non-target interface + * SEL_A/B point the same clk input. + */ + writel(reg, mux->reg); + writel(reg, mux->reg); + + return 0; +} + +const struct clk_ops imx8m_clk_mux_ops = { + .get_rate = clk_generic_get_rate, + .set_parent = imx8m_clk_mux_set_parent, +}; + struct clk *imx8m_clk_composite_flags(const char *name, const char * const *parent_names, int num_parents, void __iomem *reg, @@ -155,7 +190,7 @@ struct clk *imx8m_clk_composite_flags(const char *name, clk = clk_register_composite(NULL, name, parent_names, num_parents, - &mux->clk, &clk_mux_ops, &div->clk, + &mux->clk, &imx8m_clk_mux_ops, &div->clk, &imx8m_clk_composite_divider_ops, &gate->clk, &clk_gate_ops, flags); if (IS_ERR(clk))