Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2148028lqt; Mon, 22 Apr 2024 02:54:07 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVKV8hnMdv3bBc2KZCmgKpPjmy03e02x870uWH8R1Wxb+VH3gLAZfIA7m27JdG03xk0KfRkpOTB9hldAunrntziGVN1+cK1uGILBsN4fA== X-Google-Smtp-Source: AGHT+IGxg+a4LnX+dzfn6Nyy6eDRktACd8TV2E1Kr1eb0Wn2iDv3p7KoMsYpIWHKCD5Z1hNqzuN6 X-Received: by 2002:a05:620a:2692:b0:78f:1bef:6dc0 with SMTP id c18-20020a05620a269200b0078f1bef6dc0mr10926249qkp.18.1713779647328; Mon, 22 Apr 2024 02:54:07 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713779647; cv=pass; d=google.com; s=arc-20160816; b=Z/gbdMyPU9ryqjrckrwtDy3z8ExIFLHlQkf8r/1p6HyetEFeS2hgeIKrTufxtEOdHb syVHyesxA+vUHhZrABTfV9KgNnq308ojJ6Gc5W9GLAntCNwM69lmaMiu/tZsrlyWkgHJ F6MbETfV1cIgVNhA23C9vTzABtQfZhJBUpF7C/qOUJFC066qYZ6ga0/bIezvN6vPGMXO fWQdsy779oYLf/XgTezzbpBD04ItK7aX2mjhnP8DoyiFxFCD7cNfHXsgi+UCcOr+GXXX lW4T4Q/oBFqHIgFj2w/9b0OmxM/6tjJQGEmklr74tOi+Ebo/+dFpHaZSTWm1FpLHPOxE FNAw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=d2uumArb564F2HWCEnPtPYvaUcc8ViHiyMPm3V2MaMY=; fh=by23ctmwkH25TvogGucgXFe0hS1FQxZCRmAK45g4Ywk=; b=x/cOkc6SDfOdTBG7bEyT4Asgf23TdsxSnbGHOiOaBTohZnlTLLkgzteYdjOYWhaQiz 4wZu1KyW7jyxYwTX/MMNAcZlnKUu6k/3U+4f83KCZH4KQg/vCRTEjfuj/Y09gREZY4qf 4pWSfdhtrG5xhHaOMIzVzrGylqcmQnRfYdhgaDojeddUnHP6oFFUM1MCuJtzyrohYchR RhAw2JPrQxO6ToMxp/Wt558JxC7RNhLrBm/GPIWPLT/Ja5gME0OC1mDR3EEf2xef+PGt YzrM6pc8dgpikwnGTHFiHGMJOP0OfIejerZvwf5TEkIoRCT47dWJ2Jd0D90p1KM1GH4X Igdw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=X1GE8NQW; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-153129-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-153129-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id de32-20020a05620a372000b0078bbed562c9si11235432qkb.255.2024.04.22.02.54.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 02:54:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-153129-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=X1GE8NQW; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-153129-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-153129-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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 E16D51C213D9 for ; Mon, 22 Apr 2024 09:54:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AD91413DB83; Mon, 22 Apr 2024 09:53:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="X1GE8NQW" Received: from mail-ej1-f46.google.com (mail-ej1-f46.google.com [209.85.218.46]) (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 2B08513D8BB for ; Mon, 22 Apr 2024 09:53:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713779636; cv=none; b=gS84/jX/c7pz/s3KDZlJsNo9/gXkwbyNC7HHNfV6mrUahZGW0fSKOQda83wdSDvFdl1AYR6uId0LEm5QUiC3BdNzE15izQLI4HLrtOWoqnylPuxBKSE3/e5JaglPhv5zEt5v25bMYuj+RDqddY4ubdxk/fb+yN8lDRlGeE658jM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713779636; c=relaxed/simple; bh=N1vyexUJTOQeKTD1hVlxVmzss+1ZNvL8gjrDrN9+c5A=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=foU1sSsqRMoz8kKBA4wy+qnlLgGqxszRCuso+OBJ7UwcPwbx4E5McuQFNgQ9hJHT+TrcLPbmcBc0ZRI7bSSUPtrviav65TSo23cbCmDsBqI8JC92icjvnTr4bKG8k50ECoJnaA5qvHrzcOYuRjTSzHEaeB2jMSXNXKTcfU2jxoM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=X1GE8NQW; arc=none smtp.client-ip=209.85.218.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-ej1-f46.google.com with SMTP id a640c23a62f3a-a51a7d4466bso443840866b.2 for ; Mon, 22 Apr 2024 02:53:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713779631; x=1714384431; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=d2uumArb564F2HWCEnPtPYvaUcc8ViHiyMPm3V2MaMY=; b=X1GE8NQWIup58JzNcWE9ZNhMnQr9sUdVs+K8IahuPD7CcrSvTOoayqkpTzhHwClZ2m ZtVay9YgUkgqv7I9q6om+Mh4aARQ9uyTgWy6eBWalRaRhJ2ERJ/5EG/BMu/UqHVptamg ZC+jSGQ9m1ezs4VPcNDhXMvp+19c29B1xVW3hcPgEbifJ1so5SBwkAb4icbCXiph7pjA bInWqgYl2xkGmW+Smz7pZbhxJrzcHOKt6C3G+OUwjg0vY308ABa7HJ68VbaYhpcwYYfR P6N6K9/jPVaA3qq7/VGLwuWg7JrFGwEdnjlo+BI94GmcBGM1vPghtuaWF5g1IlZdT3lx JFkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713779631; x=1714384431; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=d2uumArb564F2HWCEnPtPYvaUcc8ViHiyMPm3V2MaMY=; b=J4I2pe7fWAHu9vwQtblp1dUJNxl0+8IHoMAk8XDqR70Xud3B6Hx3PEP6yLVvIndnrq GiAACaYFT0xj2I6Ziwod3oykTAodxcLRBNj12e82XaJMmhCoDnJ9dcprTWO2+MKSNrXO HKJAsU0RTBPxd4ytlsOo8QpIEe9jCoJ+RKA6TIsuYgWbxKMoaJv5jPEv+EOOYYOcuV3a dDTNYxnxZL2LwZPUV7N1RwYBZW/NIyU1hV2+4sm9j0gX5BPt7Yq9KgExA/TUH/L3XA8C THx4FSKzotyUr/0QSG0MCDv+br8ZSeyNtoSYBV2zM58P8vjynw48dR4MK/b2HwRg/DKd 2blg== X-Forwarded-Encrypted: i=1; AJvYcCU2FLv9Y5nqucobMFPOd/e3+EF2ZM38j6sK8UQL6P2p+D3RITOChLOMwjE6G54X/8lHXORc2laylELwIp8lVzWjTdjqreaX1STKdWSd X-Gm-Message-State: AOJu0Yybn0rU//fri5gxtn8cKlsP1TbZCCzgcDrqHAD1hNKTmf9b++EX I/4aTpp/RGRbkDLHlw5mdV+BJ7qaGdzWxv0QOwbgVj6AjBoUuVWU7PODHtoCTRI= X-Received: by 2002:a17:906:f292:b0:a55:5eb0:6f2d with SMTP id gu18-20020a170906f29200b00a555eb06f2dmr5754405ejb.56.1713779630981; Mon, 22 Apr 2024 02:53:50 -0700 (PDT) Received: from linaro.org ([62.231.100.236]) by smtp.gmail.com with ESMTPSA id m18-20020a1709060d9200b00a5561456fa8sm5534335eji.21.2024.04.22.02.53.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 02:53:50 -0700 (PDT) Date: Mon, 22 Apr 2024 12:53:48 +0300 From: Abel Vesa To: "Peng Fan (OSS)" Cc: Michael Turquette , Stephen Boyd , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Abel Vesa , linux-clk@vger.kernel.org, devicetree@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Peng Fan Subject: Re: [PATCH v6 4/4] clk: imx: add i.MX95 BLK CTL clk driver Message-ID: References: <20240401-imx95-blk-ctl-v6-0-84d4eca1e759@nxp.com> <20240401-imx95-blk-ctl-v6-4-84d4eca1e759@nxp.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=us-ascii Content-Disposition: inline In-Reply-To: <20240401-imx95-blk-ctl-v6-4-84d4eca1e759@nxp.com> On 24-04-01 21:28:18, Peng Fan (OSS) wrote: > From: Peng Fan > > i.MX95 has BLK CTL modules in various MIXes, the BLK CTL modules > support clock features such as mux/gate/div. This patch > is to add the clock feature of BLK CTL modules > > Signed-off-by: Peng Fan Reviewed-by: Abel Vesa > --- > drivers/clk/imx/Kconfig | 7 + > drivers/clk/imx/Makefile | 1 + > drivers/clk/imx/clk-imx95-blk-ctl.c | 438 ++++++++++++++++++++++++++++++++++++ > 3 files changed, 446 insertions(+) > > diff --git a/drivers/clk/imx/Kconfig b/drivers/clk/imx/Kconfig > index db3bca5f4ec9..6da0fba68225 100644 > --- a/drivers/clk/imx/Kconfig > +++ b/drivers/clk/imx/Kconfig > @@ -114,6 +114,13 @@ config CLK_IMX93 > help > Build the driver for i.MX93 CCM Clock Driver > > +config CLK_IMX95_BLK_CTL > + tristate "IMX95 Clock Driver for BLK CTL" > + depends on ARCH_MXC || COMPILE_TEST > + select MXC_CLK > + help > + Build the clock driver for i.MX95 BLK CTL > + > config CLK_IMXRT1050 > tristate "IMXRT1050 CCM Clock Driver" > depends on SOC_IMXRT || COMPILE_TEST > diff --git a/drivers/clk/imx/Makefile b/drivers/clk/imx/Makefile > index d4b8e10b1970..03f2b2a1ab63 100644 > --- a/drivers/clk/imx/Makefile > +++ b/drivers/clk/imx/Makefile > @@ -31,6 +31,7 @@ obj-$(CONFIG_CLK_IMX8MP) += clk-imx8mp.o clk-imx8mp-audiomix.o > obj-$(CONFIG_CLK_IMX8MQ) += clk-imx8mq.o > > obj-$(CONFIG_CLK_IMX93) += clk-imx93.o > +obj-$(CONFIG_CLK_IMX95_BLK_CTL) += clk-imx95-blk-ctl.o > > obj-$(CONFIG_MXC_CLK_SCU) += clk-imx-scu.o clk-imx-lpcg-scu.o clk-imx-acm.o > clk-imx-scu-$(CONFIG_CLK_IMX8QXP) += clk-scu.o clk-imx8qxp.o \ > diff --git a/drivers/clk/imx/clk-imx95-blk-ctl.c b/drivers/clk/imx/clk-imx95-blk-ctl.c > new file mode 100644 > index 000000000000..74f595f9e5e3 > --- /dev/null > +++ b/drivers/clk/imx/clk-imx95-blk-ctl.c > @@ -0,0 +1,438 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * Copyright 2024 NXP > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +enum { > + CLK_GATE, > + CLK_DIVIDER, > + CLK_MUX, > +}; > + > +struct imx95_blk_ctl { > + struct device *dev; > + spinlock_t lock; > + struct clk *clk_apb; > + > + void __iomem *base; > + /* clock gate register */ > + u32 clk_reg_restore; > +}; > + > +struct imx95_blk_ctl_clk_dev_data { > + const char *name; > + const char * const *parent_names; > + u32 num_parents; > + u32 reg; > + u32 bit_idx; > + u32 bit_width; > + u32 clk_type; > + u32 flags; > + u32 flags2; > + u32 type; > +}; > + > +struct imx95_blk_ctl_dev_data { > + const struct imx95_blk_ctl_clk_dev_data *clk_dev_data; > + u32 num_clks; > + bool rpm_enabled; > + u32 clk_reg_offset; > +}; > + > +static const struct imx95_blk_ctl_clk_dev_data vpublk_clk_dev_data[] = { > + [IMX95_CLK_VPUBLK_WAVE] = { > + .name = "vpublk_wave_vpu", > + .parent_names = (const char *[]){ "vpu", }, > + .num_parents = 1, > + .reg = 8, > + .bit_idx = 0, > + .type = CLK_GATE, > + .flags = CLK_SET_RATE_PARENT, > + .flags2 = CLK_GATE_SET_TO_DISABLE, > + }, > + [IMX95_CLK_VPUBLK_JPEG_ENC] = { > + .name = "vpublk_jpeg_enc", > + .parent_names = (const char *[]){ "vpujpeg", }, > + .num_parents = 1, > + .reg = 8, > + .bit_idx = 1, > + .type = CLK_GATE, > + .flags = CLK_SET_RATE_PARENT, > + .flags2 = CLK_GATE_SET_TO_DISABLE, > + }, > + [IMX95_CLK_VPUBLK_JPEG_DEC] = { > + .name = "vpublk_jpeg_dec", > + .parent_names = (const char *[]){ "vpujpeg", }, > + .num_parents = 1, > + .reg = 8, > + .bit_idx = 2, > + .type = CLK_GATE, > + .flags = CLK_SET_RATE_PARENT, > + .flags2 = CLK_GATE_SET_TO_DISABLE, > + } > +}; > + > +static const struct imx95_blk_ctl_dev_data vpublk_dev_data = { > + .num_clks = ARRAY_SIZE(vpublk_clk_dev_data), > + .clk_dev_data = vpublk_clk_dev_data, > + .rpm_enabled = true, > + .clk_reg_offset = 8, > +}; > + > +static const struct imx95_blk_ctl_clk_dev_data camblk_clk_dev_data[] = { > + [IMX95_CLK_CAMBLK_CSI2_FOR0] = { > + .name = "camblk_csi2_for0", > + .parent_names = (const char *[]){ "camisi", }, > + .num_parents = 1, > + .reg = 0, > + .bit_idx = 0, > + .type = CLK_GATE, > + .flags = CLK_SET_RATE_PARENT, > + .flags2 = CLK_GATE_SET_TO_DISABLE, > + }, > + [IMX95_CLK_CAMBLK_CSI2_FOR1] = { > + .name = "camblk_csi2_for1", > + .parent_names = (const char *[]){ "camisi", }, > + .num_parents = 1, > + .reg = 0, > + .bit_idx = 1, > + .type = CLK_GATE, > + .flags = CLK_SET_RATE_PARENT, > + .flags2 = CLK_GATE_SET_TO_DISABLE, > + }, > + [IMX95_CLK_CAMBLK_ISP_AXI] = { > + .name = "camblk_isp_axi", > + .parent_names = (const char *[]){ "camaxi", }, > + .num_parents = 1, > + .reg = 0, > + .bit_idx = 4, > + .type = CLK_GATE, > + .flags = CLK_SET_RATE_PARENT, > + .flags2 = CLK_GATE_SET_TO_DISABLE, > + }, > + [IMX95_CLK_CAMBLK_ISP_PIXEL] = { > + .name = "camblk_isp_pixel", > + .parent_names = (const char *[]){ "camisi", }, > + .num_parents = 1, > + .reg = 0, > + .bit_idx = 5, > + .type = CLK_GATE, > + .flags = CLK_SET_RATE_PARENT, > + .flags2 = CLK_GATE_SET_TO_DISABLE, > + }, > + [IMX95_CLK_CAMBLK_ISP] = { > + .name = "camblk_isp", > + .parent_names = (const char *[]){ "camisi", }, > + .num_parents = 1, > + .reg = 0, > + .bit_idx = 6, > + .type = CLK_GATE, > + .flags = CLK_SET_RATE_PARENT, > + .flags2 = CLK_GATE_SET_TO_DISABLE, > + } > +}; > + > +static const struct imx95_blk_ctl_dev_data camblk_dev_data = { > + .num_clks = ARRAY_SIZE(camblk_clk_dev_data), > + .clk_dev_data = camblk_clk_dev_data, > + .clk_reg_offset = 0, > +}; > + > +static const struct imx95_blk_ctl_clk_dev_data lvds_clk_dev_data[] = { > + [IMX95_CLK_DISPMIX_LVDS_PHY_DIV] = { > + .name = "ldb_phy_div", > + .parent_names = (const char *[]){ "ldbpll", }, > + .num_parents = 1, > + .reg = 0, > + .bit_idx = 0, > + .bit_width = 1, > + .type = CLK_DIVIDER, > + .flags2 = CLK_DIVIDER_POWER_OF_TWO, > + }, > + [IMX95_CLK_DISPMIX_LVDS_CH0_GATE] = { > + .name = "lvds_ch0_gate", > + .parent_names = (const char *[]){ "ldb_phy_div", }, > + .num_parents = 1, > + .reg = 0, > + .bit_idx = 1, > + .bit_width = 1, > + .type = CLK_GATE, > + .flags = CLK_SET_RATE_PARENT, > + .flags2 = CLK_GATE_SET_TO_DISABLE, > + }, > + [IMX95_CLK_DISPMIX_LVDS_CH1_GATE] = { > + .name = "lvds_ch1_gate", > + .parent_names = (const char *[]){ "ldb_phy_div", }, > + .num_parents = 1, > + .reg = 0, > + .bit_idx = 2, > + .bit_width = 1, > + .type = CLK_GATE, > + .flags = CLK_SET_RATE_PARENT, > + .flags2 = CLK_GATE_SET_TO_DISABLE, > + }, > + [IMX95_CLK_DISPMIX_PIX_DI0_GATE] = { > + .name = "lvds_di0_gate", > + .parent_names = (const char *[]){ "ldb_pll_div7", }, > + .num_parents = 1, > + .reg = 0, > + .bit_idx = 3, > + .bit_width = 1, > + .type = CLK_GATE, > + .flags = CLK_SET_RATE_PARENT, > + .flags2 = CLK_GATE_SET_TO_DISABLE, > + }, > + [IMX95_CLK_DISPMIX_PIX_DI1_GATE] = { > + .name = "lvds_di1_gate", > + .parent_names = (const char *[]){ "ldb_pll_div7", }, > + .num_parents = 1, > + .reg = 0, > + .bit_idx = 4, > + .bit_width = 1, > + .type = CLK_GATE, > + .flags = CLK_SET_RATE_PARENT, > + .flags2 = CLK_GATE_SET_TO_DISABLE, > + }, > +}; > + > +static const struct imx95_blk_ctl_dev_data lvds_csr_dev_data = { > + .num_clks = ARRAY_SIZE(lvds_clk_dev_data), > + .clk_dev_data = lvds_clk_dev_data, > + .clk_reg_offset = 0, > +}; > + > +static const struct imx95_blk_ctl_clk_dev_data dispmix_csr_clk_dev_data[] = { > + [IMX95_CLK_DISPMIX_ENG0_SEL] = { > + .name = "disp_engine0_sel", > + .parent_names = (const char *[]){"videopll1", "dsi_pll", "ldb_pll_div7", }, > + .num_parents = 4, > + .reg = 0, > + .bit_idx = 0, > + .bit_width = 2, > + .type = CLK_MUX, > + .flags = CLK_SET_RATE_NO_REPARENT | CLK_SET_RATE_PARENT, > + }, > + [IMX95_CLK_DISPMIX_ENG1_SEL] = { > + .name = "disp_engine1_sel", > + .parent_names = (const char *[]){"videopll1", "dsi_pll", "ldb_pll_div7", }, > + .num_parents = 4, > + .reg = 0, > + .bit_idx = 2, > + .bit_width = 2, > + .type = CLK_MUX, > + .flags = CLK_SET_RATE_NO_REPARENT | CLK_SET_RATE_PARENT, > + } > +}; > + > +static const struct imx95_blk_ctl_dev_data dispmix_csr_dev_data = { > + .num_clks = ARRAY_SIZE(dispmix_csr_clk_dev_data), > + .clk_dev_data = dispmix_csr_clk_dev_data, > + .clk_reg_offset = 0, > +}; > + > +static int imx95_bc_probe(struct platform_device *pdev) > +{ > + struct device *dev = &pdev->dev; > + const struct imx95_blk_ctl_dev_data *bc_data; > + struct imx95_blk_ctl *bc; > + struct clk_hw_onecell_data *clk_hw_data; > + struct clk_hw **hws; > + void __iomem *base; > + int i, ret; > + > + bc = devm_kzalloc(dev, sizeof(*bc), GFP_KERNEL); > + if (!bc) > + return -ENOMEM; > + bc->dev = dev; > + dev_set_drvdata(&pdev->dev, bc); > + > + spin_lock_init(&bc->lock); > + > + base = devm_platform_ioremap_resource(pdev, 0); > + if (IS_ERR(base)) > + return PTR_ERR(base); > + > + bc->base = base; > + bc->clk_apb = devm_clk_get(dev, NULL); > + if (IS_ERR(bc->clk_apb)) > + return dev_err_probe(dev, PTR_ERR(bc->clk_apb), "failed to get APB clock\n"); > + > + ret = clk_prepare_enable(bc->clk_apb); > + if (ret) { > + dev_err(dev, "failed to enable apb clock: %d\n", ret); > + return ret; > + } > + > + bc_data = of_device_get_match_data(dev); > + if (!bc_data) > + return devm_of_platform_populate(dev); > + > + clk_hw_data = devm_kzalloc(dev, struct_size(clk_hw_data, hws, bc_data->num_clks), > + GFP_KERNEL); > + if (!clk_hw_data) > + return -ENOMEM; > + > + if (bc_data->rpm_enabled) > + pm_runtime_enable(&pdev->dev); > + > + clk_hw_data->num = bc_data->num_clks; > + hws = clk_hw_data->hws; > + > + for (i = 0; i < bc_data->num_clks; i++) { > + const struct imx95_blk_ctl_clk_dev_data *data = &bc_data->clk_dev_data[i]; > + void __iomem *reg = base + data->reg; > + > + if (data->type == CLK_MUX) { > + hws[i] = clk_hw_register_mux(dev, data->name, data->parent_names, > + data->num_parents, data->flags, reg, > + data->bit_idx, data->bit_width, > + data->flags2, &bc->lock); > + } else if (data->type == CLK_DIVIDER) { > + hws[i] = clk_hw_register_divider(dev, data->name, data->parent_names[0], > + data->flags, reg, data->bit_idx, > + data->bit_width, data->flags2, &bc->lock); > + } else { > + hws[i] = clk_hw_register_gate(dev, data->name, data->parent_names[0], > + data->flags, reg, data->bit_idx, > + data->flags2, &bc->lock); > + } > + if (IS_ERR(hws[i])) { > + ret = PTR_ERR(hws[i]); > + dev_err(dev, "failed to register: %s:%d\n", data->name, ret); > + goto cleanup; > + } > + } > + > + ret = of_clk_add_hw_provider(dev->of_node, of_clk_hw_onecell_get, clk_hw_data); > + if (ret) > + goto cleanup; > + > + ret = devm_of_platform_populate(dev); > + if (ret) { > + of_clk_del_provider(dev->of_node); > + goto cleanup; > + } > + > + if (pm_runtime_enabled(bc->dev)) > + clk_disable_unprepare(bc->clk_apb); > + > + return 0; > + > +cleanup: > + for (i = 0; i < bc_data->num_clks; i++) { > + if (IS_ERR_OR_NULL(hws[i])) > + continue; > + clk_hw_unregister(hws[i]); > + } > + > + if (bc_data->rpm_enabled) > + pm_runtime_disable(&pdev->dev); > + > + return ret; > +} > + > +#ifdef CONFIG_PM > +static int imx95_bc_runtime_suspend(struct device *dev) > +{ > + struct imx95_blk_ctl *bc = dev_get_drvdata(dev); > + > + clk_disable_unprepare(bc->clk_apb); > + return 0; > +} > + > +static int imx95_bc_runtime_resume(struct device *dev) > +{ > + struct imx95_blk_ctl *bc = dev_get_drvdata(dev); > + > + return clk_prepare_enable(bc->clk_apb); > +} > +#endif > + > +#ifdef CONFIG_PM_SLEEP > +static int imx95_bc_suspend(struct device *dev) > +{ > + struct imx95_blk_ctl *bc = dev_get_drvdata(dev); > + const struct imx95_blk_ctl_dev_data *bc_data; > + int ret; > + > + bc_data = of_device_get_match_data(dev); > + if (!bc_data) > + return 0; > + > + if (bc_data->rpm_enabled) { > + ret = pm_runtime_get_sync(bc->dev); > + if (ret < 0) { > + pm_runtime_put_noidle(bc->dev); > + return ret; > + } > + } > + > + bc->clk_reg_restore = readl(bc->base + bc_data->clk_reg_offset); > + > + return 0; > +} > + > +static int imx95_bc_resume(struct device *dev) > +{ > + struct imx95_blk_ctl *bc = dev_get_drvdata(dev); > + const struct imx95_blk_ctl_dev_data *bc_data; > + > + bc_data = of_device_get_match_data(dev); > + if (!bc_data) > + return 0; > + > + writel(bc->clk_reg_restore, bc->base + bc_data->clk_reg_offset); > + > + if (bc_data->rpm_enabled) > + pm_runtime_put(bc->dev); > + > + return 0; > +} > +#endif > + > +static const struct dev_pm_ops imx95_bc_pm_ops = { > + SET_RUNTIME_PM_OPS(imx95_bc_runtime_suspend, imx95_bc_runtime_resume, NULL) > + SET_SYSTEM_SLEEP_PM_OPS(imx95_bc_suspend, imx95_bc_resume) > +}; > + > +static const struct of_device_id imx95_bc_of_match[] = { > + { .compatible = "nxp,imx95-camera-csr", .data = &camblk_dev_data }, > + { .compatible = "nxp,imx95-display-master-csr", }, > + { .compatible = "nxp,imx95-lvds-csr", .data = &lvds_csr_dev_data }, > + { .compatible = "nxp,imx95-display-csr", .data = &dispmix_csr_dev_data }, > + { .compatible = "nxp,imx95-vpu-csr", .data = &vpublk_dev_data }, > + { /* Sentinel */ }, > +}; > +MODULE_DEVICE_TABLE(of, imx95_bc_of_match); > + > +static struct platform_driver imx95_bc_driver = { > + .probe = imx95_bc_probe, > + .driver = { > + .name = "imx95-blk-ctl", > + .of_match_table = imx95_bc_of_match, > + .pm = &imx95_bc_pm_ops, > + }, > +}; > +module_platform_driver(imx95_bc_driver); > + > +MODULE_DESCRIPTION("NXP i.MX95 blk ctl driver"); > +MODULE_AUTHOR("Peng Fan "); > +MODULE_LICENSE("GPL"); > > -- > 2.37.1 >