From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C3001C2B9F4 for ; Mon, 14 Jun 2021 19:31:25 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7DBEC61001 for ; Mon, 14 Jun 2021 19:31:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7DBEC61001 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=6cY+h5DXpQ46jGLQjUFQi3REokYnjugBEp5t9pbKeW8=; b=unUxPoce9xzNG1 dfe7Hgc3Y4WZtLgxWj5P8MMNKD43DHSEgauZ1KyzoYBxxnqzSwnOlLSb/3ZD+ou8PFxMRcz/wHF7U 5rT8xAH776iivp/AFnKEjRYRRgdYGgoosQEDPUlfZ0VYi5SlBJgo6FM5On5ynxEZZg/aPr4/9aXp2 /BcjDaJwSmAb++rXxnYQJo4waQhuY3/o6S9ptOOU9DAfdHyDb52t3IbZ1ZSW4Vc14FJVGHFrRf00S EaEn5SiCAypV5vgA3MCzcI5e2zs35ktFeGDgFXSNqerebHZ0TdrJbjfcwjQiGDDM4TqL0+A7iCrrI gXX0m2Lyf0WkEIvnANhA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lssGx-00Fs5q-Go; Mon, 14 Jun 2021 19:29:23 +0000 Received: from mail-ej1-x629.google.com ([2a00:1450:4864:20::629]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lssGt-00Fs54-Ao for linux-arm-kernel@lists.infradead.org; Mon, 14 Jun 2021 19:29:21 +0000 Received: by mail-ej1-x629.google.com with SMTP id g20so18548478ejt.0 for ; Mon, 14 Jun 2021 12:29:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=NSpnw+tTY8+Kyz/sVjltk30bkCcnr49vv8cnl01H+2g=; b=u3uz5ayPQt6Ko6lD/4N9IPjiIfUk/aztJpMTPza3WAmYzG0aaNdNQKs/Ofso8g8HjK Ph/z1CROjhSCcMbl5t5smYJU9Wie465duhKElXvGt2hD/CGV9pnig/2ti65TUEntsqgb Pv4b51bWexzMLHDf/z7FBs6pibRzuBVA9nPvUGpqyyVc0mNNFGyyWBRljp9YWtmx7eCQ XiKqf2a2Lf7wM+eHzXqwZBuSu+FfDhK5fmo0xmwbeblFIauO9wLwdY/qrZKb+Y0o/wRX nVpU0YmR6WXoGscirc7UNxd4wDG7PcFSV1Icuo5cfhzZLLqcxB6JCEkZ1bAFpUUDlHBm Ihrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=NSpnw+tTY8+Kyz/sVjltk30bkCcnr49vv8cnl01H+2g=; b=s2Yj0YrO+T1RAnpCgpxRcx6nlODFFijfIVPhkFzqkcSme+1UWjRRCmlyVDC1bINL+u uhD/N/J2YI96Gvs8+eXNxVQ0ogA57kohqso38BjQlugYlMVftQ7fMqgI6GaxKFjF4sV/ HEM/JGPT+xLDq2KDuAAcSgi7bQ4yGSiJUBKRgzmoayRMg1fZrreXdeJcxvOxbGIsDuP/ qBhJNztKluKw8KsLzfO9JaHw+Ud0esqJS1F5D9s9Rsj9Cvd30Eg43Y398SL+zgPdw+41 CkjY59/tGMkVCnyRN1QWkBsC+M6b3qDalbvpQz/s5nngn0B8AhOYoB1zdHVxSk7DEKrM Tn7g== X-Gm-Message-State: AOAM533PijwgyCE9RSD6eisi6v1pWvmXL6e5EQRK2pf/sADYJcxTS05x PlE1W1+bdj2jEMiHo2CEacsRg42IH0RTg3ViZE0= X-Google-Smtp-Source: ABdhPJw8IYTIfAj68hdl2jyoR72c87eC1VvHHBjtRgofO0TBkO0YEdojGvJt5eFypteniN48sjD/c0cfODSonbitXhc= X-Received: by 2002:a17:907:70d3:: with SMTP id yk19mr10228672ejb.450.1623698957355; Mon, 14 Jun 2021 12:29:17 -0700 (PDT) MIME-Version: 1.0 References: <20210612133134.2738-1-peng.fan@oss.nxp.com> <20210612133134.2738-5-peng.fan@oss.nxp.com> In-Reply-To: From: Adam Ford Date: Mon, 14 Jun 2021 14:29:06 -0500 Message-ID: Subject: Re: [PATCH V7 4/4] soc: imx: Add blk-ctl driver for i.MX8MM To: "Peng Fan (OSS)" Cc: Rob Herring , Shawn Guo , Sascha Hauer , Sascha Hauer , Fabio Estevam , NXP Linux Team , Philipp Zabel , Lucas Stach , Krzysztof Kozlowski , =?UTF-8?Q?Guido_G=C3=BCnther?= , Marek Vasut , Andrey Smirnov , devicetree , arm-soc , Linux Kernel Mailing List , Jacky Bai , Schrempf Frieder , Abel Vesa , Peng Fan X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210614_122919_417165_77E90696 X-CRM114-Status: GOOD ( 41.30 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Jun 14, 2021 at 1:07 PM Adam Ford wrote: > > On Sat, Jun 12, 2021 at 7:58 AM Peng Fan (OSS) wrote: > > > > From: Peng Fan > > > > The i.MX8MM SoC has dispmix BLK-CTL and vpumix BLK-CTL, so we add > > that support in this driver. > > > > Reviewed-by: Abel Vesa > > Signed-off-by: Peng Fan > > Maybe my TF-A is too old, but I am not able to wake the device from > suspend-to-ram with this series. I used the device tree from [1] to > enable both the GPCv2 and the blk-ctl stuff. > > [1] - https://patchwork.kernel.org/project/linux-arm-kernel/patch/20210604111005.6804-1-peng.fan@oss.nxp.com/ > > I based both off Shawn's for-next branch. I tried to enable USB with the GPCv2 stuff pulled into Shawn's for-next branch, and my board hangs when USB is loaded, but USB doesn't use blk-ctl, it just uses GPCv2. I looked at some of the changes with GPCv2, and I noticed a comment in the GPCv2 function called imx_pgc_power_up. The comment reads: /* * ret = regmap_read_poll_timeout(domain->regmap, GPC_PU_PWRHSK, reg_val, * (reg_val & domain->bits.hskack), 0, * USEC_PER_MSEC); * Technically we need the commented code to wait handshake. But that needs * the BLK-CTL module BUS clk-en bit being set. * * There is a separate BLK-CTL module and we will have such a driver for it, * that driver will set the BUS clk-en bit and handshake will be triggered * automatically there. Just add a delay and suppose the handshake finish * after that. */ I didn't see a delay here despite the comment saying we should add one. With the blk-ctl enabled, I attempted to uncomment the above line of code without much success in preventing the board from hanging. If BUS clk-en bit needs to be set in order for the handshake to work, should all these power domains reference it to bring it up? If we decide against using the BUS clk-en bit, what should this delay be? adam > > adam > > > --- > > drivers/soc/imx/Makefile | 2 +- > > drivers/soc/imx/blk-ctl-imx8mm.c | 139 +++++++++++++++++++++++++++++++ > > 2 files changed, 140 insertions(+), 1 deletion(-) > > create mode 100644 drivers/soc/imx/blk-ctl-imx8mm.c > > > > diff --git a/drivers/soc/imx/Makefile b/drivers/soc/imx/Makefile > > index d3d2b49a386c..c260b962f495 100644 > > --- a/drivers/soc/imx/Makefile > > +++ b/drivers/soc/imx/Makefile > > @@ -4,4 +4,4 @@ obj-$(CONFIG_ARCH_MXC) += soc-imx.o > > endif > > obj-$(CONFIG_HAVE_IMX_GPC) += gpc.o > > obj-$(CONFIG_IMX_GPCV2_PM_DOMAINS) += gpcv2.o > > -obj-$(CONFIG_SOC_IMX8M) += soc-imx8m.o blk-ctl.o > > +obj-$(CONFIG_SOC_IMX8M) += soc-imx8m.o blk-ctl.o blk-ctl-imx8mm.o > > diff --git a/drivers/soc/imx/blk-ctl-imx8mm.c b/drivers/soc/imx/blk-ctl-imx8mm.c > > new file mode 100644 > > index 000000000000..59443588f892 > > --- /dev/null > > +++ b/drivers/soc/imx/blk-ctl-imx8mm.c > > @@ -0,0 +1,139 @@ > > +// SPDX-License-Identifier: GPL-2.0 > > +/* > > + * Copyright 2021 NXP > > + */ > > + > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > + > > +#include "blk-ctl.h" > > + > > +#define MEDIA_BLK_BUS_RSTN_BLK_SYNC_SFT_EN BIT(6) > > +#define MEDIA_BLK_MIPI_DSI_I_PRESETN_SFT_EN BIT(5) > > +#define MEDIA_BLK_MIPI_CSI_I_PRESETN_SFT_EN BIT(4) > > +#define MEDIA_BLK_CAMERA_PIXEL_RESET_N_SFT_EN BIT(3) > > +#define MEDIA_BLK_CSI_BRIDGE_SFT_EN GENMASK(2, 0) > > + > > +#define MEDIA_BLK_BUS_PD_MASK BIT(12) > > +#define MEDIA_BLK_MIPI_CSI_PD_MASK GENMASK(11, 10) > > +#define MEDIA_BLK_MIPI_DSI_PD_MASK GENMASK(9, 8) > > +#define MEDIA_BLK_LCDIF_PD_MASK GENMASK(7, 6) > > +#define MEDIA_BLK_CSI_BRIDGE_PD_MASK GENMASK(5, 0) > > + > > +static struct imx_blk_ctl_hw imx8mm_dispmix_blk_ctl_pds[] = { > > + IMX_BLK_CTL_PD("CSI_BRIDGE", NULL, IMX8MM_BLK_CTL_PD_DISPMIX_CSI_BRIDGE, 0x4, > > + MEDIA_BLK_CSI_BRIDGE_PD_MASK, 0, MEDIA_BLK_CSI_BRIDGE_SFT_EN, > > + IMX_BLK_CTL_PD_RESET), > > + IMX_BLK_CTL_PD("LCDIF", NULL, IMX8MM_BLK_CTL_PD_DISPMIX_LCDIF, 0x4, > > + MEDIA_BLK_LCDIF_PD_MASK, -1, -1, 0), > > + IMX_BLK_CTL_PD("MIPI_DSI", "mipi", IMX8MM_BLK_CTL_PD_DISPMIX_MIPI_DSI, 0x4, > > + MEDIA_BLK_MIPI_DSI_PD_MASK, 0, MEDIA_BLK_MIPI_DSI_I_PRESETN_SFT_EN, > > + IMX_BLK_CTL_PD_RESET), > > + IMX_BLK_CTL_PD("MIPI_CSI", "mipi", IMX8MM_BLK_CTL_PD_DISPMIX_MIPI_CSI, 0x4, > > + MEDIA_BLK_MIPI_CSI_PD_MASK, 0, > > + MEDIA_BLK_MIPI_CSI_I_PRESETN_SFT_EN | MEDIA_BLK_CAMERA_PIXEL_RESET_N_SFT_EN, > > + IMX_BLK_CTL_PD_RESET), > > + IMX_BLK_CTL_PD("DISPMIX_BUS", "dispmix", IMX8MM_BLK_CTL_PD_DISPMIX_BUS, 0x4, > > + MEDIA_BLK_BUS_PD_MASK, 0, MEDIA_BLK_BUS_RSTN_BLK_SYNC_SFT_EN, > > + IMX_BLK_CTL_PD_HANDSHAKE | IMX_BLK_CTL_PD_RESET) > > +}; > > + > > +static struct imx_blk_ctl_hw imx8mm_vpumix_blk_ctl_pds[] = { > > + IMX_BLK_CTL_PD("VPU_BLK_CTL_G2", "vpu-g2", IMX8MM_BLK_CTL_PD_VPU_G2, 0x4, > > + BIT(0), 0, BIT(0), IMX_BLK_CTL_PD_RESET), > > + IMX_BLK_CTL_PD("VPU_BLK_CTL_G1", "vpu-g1", IMX8MM_BLK_CTL_PD_VPU_G1, 0x4, > > + BIT(1), 0, BIT(1), IMX_BLK_CTL_PD_RESET), > > + IMX_BLK_CTL_PD("VPU_BLK_CTL_H1", "vpu-h1", IMX8MM_BLK_CTL_PD_VPU_H1, 0x4, > > + BIT(2), 0, BIT(2), IMX_BLK_CTL_PD_RESET), > > + IMX_BLK_CTL_PD("VPU_BLK_CTL_BUS", "vpumix", IMX8MM_BLK_CTL_PD_VPU_BUS, 0x4, > > + BIT(2), 0, BIT(2), IMX_BLK_CTL_PD_HANDSHAKE | IMX_BLK_CTL_PD_RESET) > > +}; > > + > > +static const struct regmap_config imx8mm_blk_ctl_regmap_config = { > > + .reg_bits = 32, > > + .reg_stride = 4, > > + .val_bits = 32, > > + .max_register = 0x30, > > + .fast_io = true, > > +}; > > + > > +static const struct imx_blk_ctl_dev_data imx8mm_vpumix_blk_ctl_dev_data = { > > + .pds = imx8mm_vpumix_blk_ctl_pds, > > + .pds_num = ARRAY_SIZE(imx8mm_vpumix_blk_ctl_pds), > > + .max_num = IMX8MM_BLK_CTL_PD_VPU_MAX, > > + .hw_hsk = &imx8mm_vpumix_blk_ctl_pds[3], > > + .config = imx8mm_blk_ctl_regmap_config, > > + .name = "imx-vpumix-blk-ctl", > > +}; > > + > > +static const struct imx_blk_ctl_dev_data imx8mm_dispmix_blk_ctl_dev_data = { > > + .pds = imx8mm_dispmix_blk_ctl_pds, > > + .pds_num = ARRAY_SIZE(imx8mm_dispmix_blk_ctl_pds), > > + .max_num = IMX8MM_BLK_CTL_PD_DISPMIX_MAX, > > + .hw_hsk = &imx8mm_dispmix_blk_ctl_pds[4], > > + .config = imx8mm_blk_ctl_regmap_config, > > + .name = "imx-dispmix-blk-ctl", > > +}; > > + > > +static int imx8mm_blk_ctl_probe(struct platform_device *pdev) > > +{ > > + struct device *dev = &pdev->dev; > > + const struct imx_blk_ctl_dev_data *dev_data = of_device_get_match_data(dev); > > + struct regmap *regmap; > > + struct imx_blk_ctl *ctl; > > + void __iomem *base; > > + > > + ctl = devm_kzalloc(dev, sizeof(*ctl), GFP_KERNEL); > > + if (!ctl) > > + return -ENOMEM; > > + > > + base = devm_platform_ioremap_resource(pdev, 0); > > + if (IS_ERR(base)) > > + return PTR_ERR(base); > > + > > + regmap = devm_regmap_init_mmio(dev, base, &dev_data->config); > > + if (IS_ERR(regmap)) > > + return PTR_ERR(regmap); > > + > > + ctl->regmap = regmap; > > + ctl->dev = dev; > > + mutex_init(&ctl->lock); > > + > > + ctl->num_clks = devm_clk_bulk_get_all(dev, &ctl->clks); > > + if (ctl->num_clks < 0) > > + return ctl->num_clks; > > + > > + dev_set_drvdata(dev, ctl); > > + ctl->dev_data = dev_data; > > + > > + return imx_blk_ctl_register(dev); > > +} > > + > > +static const struct of_device_id imx_blk_ctl_of_match[] = { > > + { .compatible = "fsl,imx8mm-vpumix-blk-ctl", .data = &imx8mm_vpumix_blk_ctl_dev_data }, > > + { .compatible = "fsl,imx8mm-dispmix-blk-ctl", .data = &imx8mm_dispmix_blk_ctl_dev_data }, > > + { /* Sentinel */ } > > +}; > > +MODULE_DEVICE_TABLE(of, imx_blk_ctl_of_match); > > + > > +static struct platform_driver imx_blk_ctl_driver = { > > + .probe = imx8mm_blk_ctl_probe, > > + .driver = { > > + .name = "imx8mm-blk-ctl", > > + .of_match_table = of_match_ptr(imx_blk_ctl_of_match), > > + .pm = &imx_blk_ctl_pm_ops, > > + }, > > +}; > > +module_platform_driver(imx_blk_ctl_driver); > > -- > > 2.30.0 > > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel