From patchwork Wed Jul 3 09:05:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Trimarchi X-Patchwork-Id: 3156 Return-Path: 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 ED7F63F102 for ; Wed, 3 Jul 2024 11:05:18 +0200 (CEST) Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-57c6979daf7sf1966493a12.1 for ; Wed, 03 Jul 2024 02:05:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1719997518; cv=pass; d=google.com; s=arc-20160816; b=JVh1N87geEdUmivE+65ZzAenr+BMTwVtkHQAiUYDAHIMussISUBXTYVaCyaPtCJ+gA rJR2ypDGFOT0TUZjhehF+G4A3mgQ6r+jcGfg9HEhMXTrSEmpk8kigKCudTB76MMkh7O3 Gu5l/whB6ty/WdvI+TqlmtUJrGax5tQ5UpcDqSjoZspIRHoMULd5yEZpp+ClqE9Rtmbj zQuQ7ON5eTJYWnT8JC0b7g7zY9cB2huFxRnwvyoJ3Q/4i/yeYnqrvzH7vU/JalOUxAGG yV4Q75F8kfsf8qjR/PkDy9pOFyLpGtrHUBctoY/0N3hKfwrsHI6yBJxW5DD2Jp+o9t05 TqvQ== 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=y5CjqY2yv4Fo8Hyqvd3RHbNff0xOZYrkX9X+0pPNkoA=; fh=czNANGcxggG/UA/dlDdRLqHVYTcUEYdGiGWtN9vI80Q=; b=g6P9euSTmnI5zF0+NHus4nDaQZPoaxWSXQSnWVGNW5U2ri096ZA2Du3KXNrbcbyAGN aNOM7neTU8nvWdr0/5Cz7unB6H9uytPmtz136MwXn4RGGI9aJLt+e0lBhPPYWANJH62O AeSvpmPUObVJ3i/sjOwW79LHKOGPX36YTamF5EIgiR1pUnXJi0Y0k1oq9LpOhOaytNch mSg2gv1ATOM/3OVN+eFN6bjRDr20jXR0ZkmK37v8qd2oyb/dZTdd25EwN8jPFt7yIKIp UqXvWSPBN/YCAA3cex67FeR2wRZlkqQXFCKqBOvWPS1DBia0enmgeJWucSyYu1M+1cIo NftA==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=doUiLnBT; 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=1719997518; x=1720602318; 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=y5CjqY2yv4Fo8Hyqvd3RHbNff0xOZYrkX9X+0pPNkoA=; b=afD8fxgK38MJjpSHftmOpQay8N8dPXwkSAOkOxo5lu3SRiROAd4T1+2+l70NvlaPdC 94xkx7byODjpeoEIMLn6+Y2sqZGbvHsMchnLm8Tw3oP/VHshy9pr2rAGl+ec3Ik3gtJF idRqu7vJjoYFlbhn5qeB2gFY8jwKB9y3ZtsPs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719997518; x=1720602318; 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=y5CjqY2yv4Fo8Hyqvd3RHbNff0xOZYrkX9X+0pPNkoA=; b=m7rPIGDPqXwi8+fwKKIUlNFcTZNJLrbrN8CyyojIS3lkdJgL/ulSI61YgkIwE6voHm vtfwMXF5Up3TEyhJUv0aqiI25gXnycnqDy/oWTFxb4xDQtJCwzuLYdv454DzB5P3YFmH cCNVQkjRjNNOttlnSKPlr5hS9uzjaRFi2WRKkL3GvqqByYyWLgSXuELf2S8/rVp78jnE s++eKKBaxpntpjtbbC4jQZEwqTcw6tjHO4R6YzeJL891474Olup56FAHTgYLOIU4OKSL bvrvzFE3eKoknQPBkL0VGskphy4q+GIBOcsvx8NLWNTHZv/ZJJkYHnbkX3w5mkc56sd5 x+hA== X-Forwarded-Encrypted: i=2; AJvYcCWPZDVRyuCiB2Gy1wmaG749byaBuDA/tc6a8Cdm0eFj+a26fE2WLHgstjeWPSD6oBrV0LmkcDd3m27py2AgQLAXZqGJu/tx0IqBxEFMqkxBOQCXJxTul46+kXDWzg== X-Gm-Message-State: AOJu0YyNDr9lXvlDxPY/dwRnrlp2fm+hZQ4S/gAlTlJnld4L+rr6LCUt 7TiUihLjZZWxyIpt79nznncg5MwG7UiTrlLHNBWgC596MolWhgKod046UEG08LXCoQ== X-Google-Smtp-Source: AGHT+IEmqUDUq7iNTcwlm3kdTLVhVSsmODgie9d0bqKMmypgHNf5amLaNis68/jf0WTHUofTFtSOxA== X-Received: by 2002:a05:6402:14d8:b0:58d:7b30:bef6 with SMTP id 4fb4d7f45d1cf-58d7b30c07cmr11281a12.37.1719997518459; Wed, 03 Jul 2024 02:05:18 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6402:14:b0:584:e611:3b90 with SMTP id 4fb4d7f45d1cf-58645a65156ls2673907a12.2.-pod-prod-09-eu; Wed, 03 Jul 2024 02:05:17 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWIfUT+62si6gNGEGTGxrVGBBVHtw8H4zGi9NlFIE9aQJQz9YAHKeEE9GZUGDr3+7XwIVcTYVTexxblgbDzHoFldpXFjzlhGXVw2Dj3mh/FgWEj X-Received: by 2002:a17:906:a091:b0:a6f:49eb:31a5 with SMTP id a640c23a62f3a-a75144b67a4mr545666566b.77.1719997516696; Wed, 03 Jul 2024 02:05:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719997516; cv=none; d=google.com; s=arc-20160816; b=b1iS2biniki/ROPw6mx1f68/iTbkfimzyIkDLE0dEbGLzHMkD7YrFPMkp5pFccrWej vqHgGhbOYvbw9/FnJb5mn4zRpDcIjYshoyWmvkcYbf7HFiQW8nJKHQgXM4R0/uSdRFso VJWTFguBmCai56GTk2hXulS+vmg0mpw6XmS9Qrr8jzB0hKacqO2dboFEnp6lII9wO6u4 ZI/vxxepL2LOg6sXyxtACKP2uXrOJu8xsa3dkERq7OD0F41dj93hZjUZFiDcglk62rFr qy5vJHo1W8tuJEJWS60FRXm/fSKKSD7OqdxlLvp52P8blJululwJ8B4n3G8DzHQgrUiD 8l5w== 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=LjmTckBV+07wWKN3HJ+3wUh9ZFw51lqArJvINqyjWlI=; fh=zDlYtxkavpla5AtZNQQrJK1SbhJLdxG6VDZoc6O0Up8=; b=PVfWh5Hx1wWBnvNM2yfPgAPVTEZvZ3cO3EA9Do1xrgQPDaF0F2kyKnwJlTtsrRN3o9 viI8gtd11OVwiJwXgSeks4iv4vAxL8P55NP8beih/iAYzlkGByoCGoqfh5B36MkhKRw+ LyrPsif+qf3UYB9IoD8zLPCd5by/5F9cUjjiaN+VfVp8WT+yZNwbP8XTOPvPA80uN8fA 3U0gBF1Vx3MGbLNogiGZGOD3BsuRXmRmz37kwS9VR+r+TrkKVvI3WrwawoNtlGM67RzG GyVy2yjVxdPqd74MuJTVlSObIF3Juzpnw9uCMHJmAVIPaB2bi9rvB24EouljeXMdStts g7Vw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=doUiLnBT; 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-a72ab1d6c08sor341279066b.12.2024.07.03.02.05.16 for (Google Transport Security); Wed, 03 Jul 2024 02:05:16 -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; AJvYcCXy0/G3KFlYP3xFF0wBKCiTsCmxDMGVjW/SaHTjUT0R9nYzGfXRc5QrDfCR8tiIJ59G+IrKAvLzMARQlve8jAyrtiAoKREE+zKYmmiB+vuf0J3S X-Received: by 2002:a17:906:5d1:b0:a72:b804:566f with SMTP id a640c23a62f3a-a75144a2809mr649662266b.52.1719997516143; Wed, 03 Jul 2024 02:05:16 -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.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 02:05:15 -0700 (PDT) From: Michael Trimarchi To: Lukasz Majewski , Sean Anderson Cc: Tom Rini , linux-amarula@amarulasolutions.com, u-boot@lists.denx.de, Dario Binacchi , Michael Trimarchi Subject: [PATCH 1/2] clk: clk-mux: Make public the clk_fetch_parent_index Date: Wed, 3 Jul 2024 11:05:10 +0200 Message-ID: <20240703090512.92636-2-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=doUiLnBT; 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: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Make public the clk_fetch_parent_index and rename it. This allow us to be reused in driver specialization Signed-off-by: Michael Trimarchi --- drivers/clk/clk-mux.c | 5 ++--- include/linux/clk-provider.h | 1 + 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/clk/clk-mux.c b/drivers/clk/clk-mux.c index f410518461e..e3481be95fa 100644 --- a/drivers/clk/clk-mux.c +++ b/drivers/clk/clk-mux.c @@ -102,8 +102,7 @@ u8 clk_mux_get_parent(struct clk *clk) return clk_mux_val_to_index(clk, mux->table, mux->flags, val); } -static int clk_fetch_parent_index(struct clk *clk, - struct clk *parent) +int clk_mux_fetch_parent_index(struct clk *clk, struct clk *parent) { struct clk_mux *mux = to_clk_mux(clk); @@ -127,7 +126,7 @@ static int clk_mux_set_parent(struct clk *clk, struct clk *parent) u32 val; u32 reg; - index = clk_fetch_parent_index(clk, parent); + index = clk_mux_fetch_parent_index(clk, parent); if (index < 0) { log_err("Could not fetch index\n"); return index; diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h index b8acacd49ee..59f9c241b84 100644 --- a/include/linux/clk-provider.h +++ b/include/linux/clk-provider.h @@ -74,6 +74,7 @@ struct clk_mux { #define to_clk_mux(_clk) container_of(_clk, struct clk_mux, clk) extern const struct clk_ops clk_mux_ops; u8 clk_mux_get_parent(struct clk *clk); +int clk_mux_fetch_parent_index(struct clk *clk, struct clk *parent); /** * clk_mux_index_to_val() - Convert the parent index to the register value From patchwork Wed Jul 3 09:05:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Trimarchi X-Patchwork-Id: 3157 Return-Path: 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 ; Wed, 3 Jul 2024 11:05:19 +0200 (CEST) Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-58d6fdee657sf49917a12.2 for ; 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 (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 To: Lukasz Majewski , Sean Anderson Cc: Tom Rini , linux-amarula@amarulasolutions.com, u-boot@lists.denx.de, Dario Binacchi , Michael Trimarchi 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: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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 --- drivers/clk/imx/clk-composite-8m.c | 37 +++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) 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))