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=-14.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 3A70EC433B4 for ; Tue, 4 May 2021 11:24:38 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 570ED611AE for ; Tue, 4 May 2021 11:24:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 570ED611AE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oss.nxp.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=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:In-Reply-To:References:Message-ID:Date: Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=JMitleXFW2/lM3UZVePtz+VrfADpmNk9iCQQZryorHA=; b=aGCT46+xRXMpo19ZPErvu7APu QikbQxGe+2SscN+3IGabkt17yMmSyxckFXwAL4k4UuzOIYaVvkNFRFKTS1yC3tjvkv8gI4+xgQNmX WOtAvmzxTDrJNV9KGqC5I8eo04iENdZRfoYZEs8VrOe6MRfMXgGIXgDtutBekzd62TK15wg9TzPql I5M9Udw3F8YBLZeVUCrFdNye6rFKvF8bqgmtEQOoUiyJo4j9MKFnyBzVHKAFaPxOKwzYccefQ68ve d4JncTal4xXWk+dxP2vZVMhq7c6C8ghT3UIRbtQDcU+HsNl4D5JMEIbCETLzTINap9n2EEiq3tGzX JVeD/sp1w==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1ldt8U-00G4CN-TB; Tue, 04 May 2021 11:22:43 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1ldt8Q-00G4Bw-Tw for linux-arm-kernel@desiato.infradead.org; Tue, 04 May 2021 11:22:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=MIME-Version: Content-Transfer-Encoding:Content-Type:In-Reply-To:References:Message-ID:Date :Subject:CC:To:From:Sender:Reply-To:Content-ID:Content-Description; bh=6XdyDav5RV2MWugUfE9/zBo4oaX6mLQHhkLHBzaHWiw=; b=xtI4AR4XibyWh81GtnTLK5kf5O MjmK0006UMuv6cP/UMO7yglTKPn7QEDhXzQvfoxrcw0W8wQvgKkEfPLDidnwQQoCMSO3c+fLR13Oa g+tKUp5zb9jkv1hto0hEtw1We5/8WRW1wzqR7GjnYj+GadNR9K9dIRj1J3b1TKTErxL/WvZIXoOEF WCLiXdglxio5j2YIXrOYF9UAMjghuJnplov8Y1dAHUhrHU7n/TsIadgMrXOuD69e8kWUJYE0li0SH ImJreczhEmENHyZuG3rV+gR6MViAEY9p0Lf3xMAJUeuH/+E54aEKhekwfKSsvspvBSxWEPdN00BEu ab8Ef3kA==; Received: from mail-eopbgr60054.outbound.protection.outlook.com ([40.107.6.54] helo=EUR04-DB3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1ldt8M-003vj9-Tq for linux-arm-kernel@lists.infradead.org; Tue, 04 May 2021 11:22:37 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JShI+xyC9WtGyGbSyDV6/EHTR6hODLR4Cje6KgcoA9UJ7yK9ZVp6aO4pHkF1x7QTo2NtcNi0/jJsPty7ADAksV7KYjs/mvZhxeVhekKLoRnDI4tBogTsm2UOC0bEVPMU+dUXo59fm4mmsmSi3il8KNJHTy2JCjNRRSBrcZ2gbiISkpc+XpW1yKjjHsDy2Pcc8p5JEE9E28dPG/2bzzZJ81lG3XWJRQzlhEc4NuCVTv6I0f8P0mOoszXSznOXXmWVyIxBLV1rlNVRJs4qu9wBpHqu4gQJx4i+VOpZTvNaboesbFmhMS+idAMlz4tZc6KibdwvD2PT2oPv8rCQPcsKLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6XdyDav5RV2MWugUfE9/zBo4oaX6mLQHhkLHBzaHWiw=; b=oCCHHvahRn8MhoO8nyogZnkBg6NmmtkGxtlkw3jzbNE+IHh8R0YyKeNbeTgEwJwCTPixJQXqRHflskQBEQ/tEaxYUdOb4t0USa6gwNc8rfsN6g8tnneQDH4dH2oYgFrt6uJrocSPl/PNlAL9dtX+iS8vDK+9zGCt8reFYRFs2wGL6aZYTIyEntdQOTvSuKxxMI3fRehd/erReIUPvG8nBSruitRWLBAdiMcv8z4bpQ/a07PyS6TDdfgQbfVnISsDBZig3WbbSKQJRDx4FyQRcW6IqD06R9JcUCoRhEIKHd6v2a2CnCpYxvT3Q2ybDlwmiKZ4UgyPkQ6/VLbrGoH53g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6XdyDav5RV2MWugUfE9/zBo4oaX6mLQHhkLHBzaHWiw=; b=ki35Ico4ptIlcmuJK3UMY3f9EyxAa8zA3eDlScVLDfG6eUkpSGVbzDD/FQTtnMFBKjH4u8+LfLXBPPDVj0nJhwNg7QDsrJEfivFG/LtxxV9S0T1OERP7tfEUdbv7Os0GF4ITjW0twaHgiBJKsTEmn71WAknDjo3xvdB67ARadz8= Received: from DB6PR0402MB2760.eurprd04.prod.outlook.com (2603:10a6:4:a1::14) by DB6PR04MB3125.eurprd04.prod.outlook.com (2603:10a6:6:11::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.23; Tue, 4 May 2021 11:22:30 +0000 Received: from DB6PR0402MB2760.eurprd04.prod.outlook.com ([fe80::45b9:c993:87ec:9a64]) by DB6PR0402MB2760.eurprd04.prod.outlook.com ([fe80::45b9:c993:87ec:9a64%8]) with mapi id 15.20.4065.039; Tue, 4 May 2021 11:22:30 +0000 From: "Peng Fan (OSS)" To: Frieder Schrempf , "Peng Fan (OSS)" , "robh+dt@kernel.org" , "shawnguo@kernel.org" , "s.hauer@pengutronix.de" CC: "kernel@pengutronix.de" , "festevam@gmail.com" , dl-linux-imx , "p.zabel@pengutronix.de" , "l.stach@pengutronix.de" , "krzk@kernel.org" , "agx@sigxcpu.org" , "marex@denx.de" , "andrew.smirnov@gmail.com" , "devicetree@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , Jacky Bai , "aford173@gmail.com" , Abel Vesa Subject: RE: [PATCH V2 3/4] soc: imx: Add generic blk-ctl driver Thread-Topic: [PATCH V2 3/4] soc: imx: Add generic blk-ctl driver Thread-Index: AQHXPX0aHcBK1GBQZ0W8UKii2MjDZarTIjWAgAARZIA= Date: Tue, 4 May 2021 11:22:30 +0000 Message-ID: References: <20210430052746.10815-1-peng.fan@oss.nxp.com> <20210430052746.10815-4-peng.fan@oss.nxp.com> <46b64f2f-4dfd-88d6-77ea-68bc844eee7e@kontron.de> In-Reply-To: <46b64f2f-4dfd-88d6-77ea-68bc844eee7e@kontron.de> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: kontron.de; dkim=none (message not signed) header.d=none;kontron.de; dmarc=none action=none header.from=oss.nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [58.223.139.112] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: ae50cd2b-1749-4865-69a2-08d90eeee7df x-ms-traffictypediagnostic: DB6PR04MB3125: x-ms-exchange-sharedmailbox-routingagent-processed: True x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:2887; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: max3OONHhesKDpGuTiuogQWmHExUNbh+y0yK3jywe8uA+yBCaPhh44QnC7hh8RdjeW7PutbTICe0n/rp5teSrHmS853Vx52WRDQOzmHjiNQdr7RBV986ifBfrkPHQ73ilTDZhTFni8KDtYW/mEe+wTnGFBlbLwX7H2AmNzJwVKWGKUhWUnE09DU4THNQCBm2CYuSzE55/AuWXVjkbR/bhAZVqyABFx1ZnIEU+8uPjw1bmtmko9+9q0t4V9c2NWBACtz4UsJSI29v+aTbwDBXBnRsudnTQwRViwpdoFm+PtD2wV9pYZp+EzUTcUxRqREpnEVvi49nA4kRjlqooWfH2a1PLWaY5aaM+pK2CPW4hXtDruj8m1JouRFNvWMGE6IHgFH35t6t1Cbje4nfFCaIoVZr9qz+B21ExUs5nXgqFEE7pCT3U+CNQGQQK4EzRyRH51KEVDXJSqub0RgchyzgRZp6/QAvvyu3bXZcZUDU+eYnB26Uo34kgR/7B/Wfe/l66rCzfjFfrDBWoTxGauhmeQnQOIk6ipqInWBIF/eDmA0WUcLmcQmhTNh4vfK8j0qTerySnpQjPyuAQ6suGRr0PANveiQWT1mSsVP+P1rxTLLAu1GrD7aVvH4VauSJgw1m8Nelr/9iodsARa9pRHaT4A== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB6PR0402MB2760.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(39860400002)(396003)(376002)(136003)(346002)(110136005)(5660300002)(52536014)(76116006)(54906003)(4326008)(9686003)(33656002)(8936002)(55016002)(53546011)(71200400001)(6506007)(316002)(122000001)(478600001)(2906002)(83380400001)(7696005)(66946007)(8676002)(66446008)(64756008)(30864003)(7416002)(66556008)(86362001)(66476007)(26005)(186003)(38100700002)(41533002); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata: =?utf-8?B?QWJDbmJ6MVIzdThBK3BPdFMvamxqYks0dzh3OURoUjIwREtaUHlHbFgrK01L?= =?utf-8?B?TnFvb2pDZ245amxqYUg4d0tpY2xRRmZTS0tjckc2eEsvZ0xZTU5yWDNWN2JL?= =?utf-8?B?dys2UzlQSmVoWVVwVDFxUG9KWmJyMVh5TkpucmwzdmhwaERtQjhBOFlXc1BK?= =?utf-8?B?SU9CSFNaS2h5UERuS2lFRWpKRGVRU3BISlhnbktqZTRBVGRvSlNZWWwxanBJ?= =?utf-8?B?VHJwbm1TcERYNlp2NTZvdzRiYWlPaDcwejZpd2poejBja0lxc1RUTlNnV2lm?= =?utf-8?B?ejJUbGFZc2dIZllJbDVTWmZsS1ZqSmNVMDBxTmZhQ0pxa3p2RUZGNUJpTHZ6?= =?utf-8?B?V0tQRG5DaFNBVDgwaXV1MmtqME9XVGYvZTBvQkZFbXQ1T3A2QitiL3gvRklB?= =?utf-8?B?K1lhb3lra3VLQTlqeW0wckJjN3JUYUNoRmluVHUzV0N3NG15KzFNbjV6eWpI?= =?utf-8?B?TU81ekgwSkdHYStYdTI4MDRQM082dUhOTWg4VFA4WUR1MzFqWTZtb0d3R3hm?= =?utf-8?B?bVJPUzZOQ0tlTE8xRHE5WGhlbUhKeEdnS0N5V3MrZWpPTnFOS0t4UGRYNVla?= =?utf-8?B?cmdiczhNK2Zrb3I4ektUc3hjaHl4Z0R5OC82MG91OFA4cGQxSnQ0VTVIYXdU?= =?utf-8?B?RkwrODJlblkwc1NYeXlnYzRidFd1c1RoV00wSU9wQUVYak5LbVFmY2JRYXBP?= =?utf-8?B?dVRPRzJ0aU8zdGszczNGb0x1VUFpZmI5SUVlOG5PWW5HNWxwZmt4MEg3QUt6?= =?utf-8?B?b0JrZnhXb3pJZlNyV1JKbFU2VllhV3JJcEdZN1NTVHNXV2tIWkhFcTNFNmhx?= =?utf-8?B?M2tPSXJhUXJWcjR2WDB4MUhiQVVEL3R0clJ6V2ZOOE9jZnpLbVlsQnVKNmZk?= =?utf-8?B?UGRFZ3VRcUxoaC9VZmtzVm00R2p4TU9oa0JHbkJubXpHVGpSdFMzLzFnQnNx?= =?utf-8?B?dU5sQVMybUtZT2hqYVdpaWFzQnpKTzJUUHczd0FnNm5jVmgra0k1U1VQd3VX?= =?utf-8?B?aDJqYlRKamxDSDdGeXdCUC8xYVZLWE5GVzhJY1hKQmtwOVhwbFJxSTdHajdj?= =?utf-8?B?NHlHdnVndERjNmRsTFNhMTFBMXVhSmVMVWhNRHJvN25tTTdoMnBWcVhoOVRO?= =?utf-8?B?M2lodG4xOUxodnR4aVA4SCtIL05qWjl0SUd4US9rQUV4bzNiSWc5NURtc3g3?= =?utf-8?B?QjFYUUtSTWVOa0toQTNNdTcveGREcWt3T1RhNmdLTVpqMC9pK1lKZmdpb1Vs?= =?utf-8?B?WXJVM0tLRG8xeEMvU29rZXpmSkRYTkpLSVQzU2lBWmdRWlBZTGt0YjJobGFs?= =?utf-8?B?bU9qbmd5OGY4MnZBOWVFQWlWRTBZSmRtMnI3NUN4SWpBTTRNM0N6VGM2dG9Y?= =?utf-8?B?ZkRjT2JQWEs5WmRLTXdhczRKdmZKeVhRRW9XbUNQNTdkQTBMZmNUQ0VtcGVW?= =?utf-8?B?VWt0QVYxNW9IeUwzcDlaNG9rL2M2alZtUXVsdmYvWW1zNGVweVlaMDgvRmhv?= =?utf-8?B?SExrVnU2QkM3clA1R0dRK01vRzZaNVdVWnExZ1VkQmc0aEQwVFlCeXRvV1BR?= =?utf-8?B?VnNhQmhWNjlDWnhLdGRBMm9GTURBbFFLV0dNVnNBSFRXdzFHU2x0ZDB6L1dx?= =?utf-8?B?bHRXcVVQeFlkY1hjYjZVWDFpUTFGRFhNZVZsQko3Y2xtTSs2d25rcjc5c3or?= =?utf-8?B?RHYxOU8rajltRTZDQ0t4MlBaa0hCZVJZNXhBK2hwV0U5SmpQUnp3V08zcGhD?= =?utf-8?Q?DUxuI9CVxNMyk5Dbo1nv9rsGo8hwcjzNovGONdo?= MIME-Version: 1.0 X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DB6PR0402MB2760.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: ae50cd2b-1749-4865-69a2-08d90eeee7df X-MS-Exchange-CrossTenant-originalarrivaltime: 04 May 2021 11:22:30.3250 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: LJKb1jL0NBtQ+xxmAcI7P6n5W0tQrnxZ0SWbfFzcEXoK8h056rYBydiDTxU2WnN+TFksX0aj7D4B+VWh50up4w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR04MB3125 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210504_042235_127598_DA100696 X-CRM114-Status: GOOD ( 32.23 ) 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 > Subject: Re: [PATCH V2 3/4] soc: imx: Add generic blk-ctl driver > > On 30.04.21 07:27, Peng Fan (OSS) wrote: > > From: Peng Fan > > > > The i.MX8MM introduces an IP named BLK_CTL and usually is comprised of > > some GPRs. > > > > The GPRs has some clock bits and reset bits, but here we take it as > > virtual PDs, because of the clock and power domain A/B lock issue when > > taking it as a clock controller. > > > > For some bits, it might be good to also make it as a reset controller, > > but to i.MX8MM, we not add that support for now. > > > > Signed-off-by: Peng Fan > > --- > > drivers/soc/imx/Makefile | 2 +- > > drivers/soc/imx/blk-ctl.c | 303 > ++++++++++++++++++++++++++++++++++++++ > > drivers/soc/imx/blk-ctl.h | 76 ++++++++++ > > 3 files changed, 380 insertions(+), 1 deletion(-) > > create mode 100644 drivers/soc/imx/blk-ctl.c > > create mode 100644 drivers/soc/imx/blk-ctl.h > > > > diff --git a/drivers/soc/imx/Makefile b/drivers/soc/imx/Makefile index > > 078dc918f4f3..d3d2b49a386c 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 > > +obj-$(CONFIG_SOC_IMX8M) += soc-imx8m.o blk-ctl.o > > diff --git a/drivers/soc/imx/blk-ctl.c b/drivers/soc/imx/blk-ctl.c new > > file mode 100644 index 000000000000..1f764dfd308d > > --- /dev/null > > +++ b/drivers/soc/imx/blk-ctl.c > > @@ -0,0 +1,303 @@ > > +// SPDX-License-Identifier: GPL-2.0 > > +/* > > + * Copyright 2021 NXP. > > + */ > > + > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > + > > +#include "blk-ctl.h" > > + > > +static inline struct imx_blk_ctl_domain *to_imx_blk_ctl_pd(struct > > +generic_pm_domain *genpd) { > > + return container_of(genpd, struct imx_blk_ctl_domain, pd); } > > + > > +static int imx_blk_ctl_enable_hsk(struct device *dev) { > > + struct imx_blk_ctl *blk_ctl = dev_get_drvdata(dev); > > + const struct imx_blk_ctl_hw *hw = &blk_ctl->dev_data->hw_hsk; > > + struct regmap *regmap = blk_ctl->regmap; > > + int ret; > > + > > + > > Only one blank line here. Fix in V3. > > > + if (hw->flags & IMX_BLK_CTL_PD_RESET) > > + ret = regmap_update_bits(regmap, hw->rst_offset, hw->rst_mask, > > +hw->rst_mask); > > The return value above gets discarded. Fix in V3. > > > + > > + ret = regmap_update_bits(regmap, hw->offset, hw->mask, hw->mask); > > + > > + /* Wait for handshake */ > > + udelay(5); > > + > > + return ret; > > +} > > + > > +int imx_blk_ctl_power_off(struct generic_pm_domain *domain) { > > + struct imx_blk_ctl_domain *pd; > > + struct imx_blk_ctl *blk_ctl; > > + const struct imx_blk_ctl_hw *hw; > > + struct regmap *regmap; > > + int ret; > > + > > + pd = to_imx_blk_ctl_pd(domain); > > + blk_ctl = pd->blk_ctl; > > + regmap = blk_ctl->regmap; > > + hw = &blk_ctl->dev_data->pds[pd->id]; > > You could include the assignments above in the declarations. Fix in V3. > > > + > > + ret = clk_bulk_prepare_enable(blk_ctl->num_clks, blk_ctl->clks); > > + if (ret) > > + return ret; > > + > > + ret = regmap_update_bits(regmap, hw->offset, hw->mask, 0); > > You could use regmap_clear_bits() here. Fix in V3. > > > + if (ret) > > + goto hsk_fail; > > + > > + if (hw->flags & IMX_BLK_CTL_PD_RESET) > > + ret = regmap_update_bits(regmap, hw->rst_offset, hw->rst_mask, > 0); > > You could use regmap_clear_bits() here. > And the return value of regmap_update_bits() potentially gets discarded. Fix in V3. > > > + > > + if (atomic_dec_and_test(&blk_ctl->power_count)) { > > + ret = imx_blk_ctl_enable_hsk(blk_ctl->dev); > > + if (ret) { > > + dev_err(blk_ctl->dev, "Hankshake fail\n"); > > s/Hankshake fail/Handshake failed/ Fix in V3. > > > + goto hsk_fail; > > This goto is redundant. Fix in V3. > > > + } > > + } > > + > > +hsk_fail: > > + clk_bulk_disable_unprepare(blk_ctl->num_clks, blk_ctl->clks); > > + > > + return ret; > > +} > > + > > +int imx_blk_ctl_power_on(struct generic_pm_domain *domain) { > > + struct imx_blk_ctl_domain *pd; > > + struct regmap *regmap; > > + const struct imx_blk_ctl_hw *hw; > > + int ret; > > + struct imx_blk_ctl *blk_ctl; > > + > > + pd = to_imx_blk_ctl_pd(domain); > > + blk_ctl = pd->blk_ctl; > > + regmap = blk_ctl->regmap; > > + hw = &blk_ctl->dev_data->pds[pd->id]; > > You could include the assignments above in the declarations. > > > + > > + ret = clk_bulk_prepare_enable(blk_ctl->num_clks, blk_ctl->clks); > > + if (ret) > > + return ret; > > + > > + if ((atomic_read(&blk_ctl->power_count) == 0)) { > > + ret = imx_blk_ctl_enable_hsk(blk_ctl->dev); > > + if (ret) { > > + dev_err(blk_ctl->dev, "Hankshake fail\n"); > > s/Hankshake fail/Handshake failed/ Fix in v3. > > > + goto disable_clk; > > + } > > + } > > + > > + if (hw->flags & IMX_BLK_CTL_PD_RESET) > > + ret = regmap_update_bits(regmap, hw->rst_offset, hw->rst_mask, > 0); > > You could use regmap_clear_bits() here. > And the return value of regmap_update_bits() gets discarded. Fix in v3. > > > + > > + /* Wait for reset propagate */ > > + udelay(5); > > + > > + if (hw->flags & IMX_BLK_CTL_PD_RESET) > > + ret = regmap_update_bits(regmap, hw->rst_offset, hw->rst_mask, > > +hw->rst_mask); > > The return value above gets discarded. Fix in V3. > > > + > > + ret = regmap_update_bits(regmap, hw->offset, hw->mask, hw->mask); > > + if (ret) > > + goto disable_clk; > > + > > + atomic_inc(&blk_ctl->power_count); > > + > > +disable_clk: > > + clk_bulk_disable_unprepare(blk_ctl->num_clks, blk_ctl->clks); > > + > > + return ret; > > +} > > + > > +static int imx_blk_ctl_attach_pd(struct device *dev, struct device **devs, > char **pd_names, > > + u32 num_pds) > > +{ > > + int i, ret; > > + > > + if (!pd_names) > > + return 0; > > + > > + if (dev->pm_domain) { > > + devs[0] = dev; > > + pm_runtime_enable(dev); > > + return 0; > > + } > > + > > + for (i = 0; i < num_pds; i++) { > > + devs[i] = dev_pm_domain_attach_by_name(dev, pd_names[i]); > > + if (IS_ERR_OR_NULL(devs[i])) { > > + ret = PTR_ERR(devs[i]) ? : -ENODATA; > > + goto detach_pm; > > + } > > + } > > + > > + return 0; > > + > > +detach_pm: > > + for (i--; i >= 0; i--) > > + dev_pm_domain_detach(devs[i], false); > > It looks like you should add pm_runtime_disable() in this error path to not > leave the pm_runtime_enable() unmatched. I might need to remove pm runtime, since no the ops callback here does nothing. > > > + > > + return ret; > > +} > > + > > +static int imx_blk_ctl_register_pd(struct device *dev) { > > + struct imx_blk_ctl *blk_ctl = dev_get_drvdata(dev); > > + const struct imx_blk_ctl_dev_data *dev_data = blk_ctl->dev_data; > > + int num = dev_data->pds_num; > > + struct imx_blk_ctl_domain *domain; > > + int i, ret; > > + > > + blk_ctl->onecell_data.num_domains = num; > > + blk_ctl->onecell_data.domains = devm_kcalloc(dev, num, > > + sizeof(struct generic_pm_domain *), > > + GFP_KERNEL); > > + > > + if (!blk_ctl->onecell_data.domains) > > + return -ENOMEM; > > + > > + for (i = 0; i < num; i++) { > > + domain = devm_kzalloc(dev, sizeof(*domain), GFP_KERNEL); > > + if (!domain) { > > + ret = -ENOMEM; > > + goto remove_genpd; > > + } > > + domain->pd.name = dev_data->pds[i].name; > > + domain->pd.power_off = imx_blk_ctl_power_off; > > + domain->pd.power_on = imx_blk_ctl_power_on; > > + domain->blk_ctl = blk_ctl; > > + domain->id = i; > > + > > + ret = pm_genpd_init(&domain->pd, NULL, true); > > + if (ret) > > + return ret; > > Looks like you should use the error path here and "goto remove_genpd" > instead of return. Fix in V3. > > > + > > + blk_ctl->onecell_data.domains[i] = &domain->pd; > > + } > > + > > + return 0; > > + > > +remove_genpd: > > + for (i = i - 1; i >= 0; i--) > > + pm_genpd_remove(blk_ctl->onecell_data.domains[i]); > > + > > + return ret; > > +} > > + > > +static int imx_blk_ctl_hook_pd(struct device *dev) { > > + struct imx_blk_ctl *blk_ctl = dev_get_drvdata(dev); > > + const struct imx_blk_ctl_dev_data *dev_data = blk_ctl->dev_data; > > + const struct imx_blk_ctl_hw *pds = dev_data->pds; > > + int num_active_pd = dev_data->num_active_pd; > > + int num = dev_data->pds_num; > > + struct generic_pm_domain *genpd, *child_genpd; > > + int ret; > > + int i, j; > > + > > + blk_ctl->active_pds = devm_kcalloc(dev, num_active_pd, sizeof(struct > device *), GFP_KERNEL); > > + if (!blk_ctl->active_pds) > > + return -ENOMEM; > > + > > + ret = imx_blk_ctl_attach_pd(dev, blk_ctl->active_pds, > dev_data->active_pd_names, > > + num_active_pd); > > + if (ret) { > > + if (ret == -EPROBE_DEFER) > > + return ret; > > + dev_err(dev, "Failed to attach active pd: %d\n", ret); > > + return ret; > > I think it would be better to do it the other way round: Fix in V3. > > if (ret != -EPROBE_DEFER) > dev_err(dev, "Failed to attach active pd: %d\n", ret); > return ret; > > > + } > > + > > + for (i = 0; i < num; i++) { > > + for (j = 0; j < num_active_pd; j++) { > > + genpd = pd_to_genpd(blk_ctl->active_pds[j]->pm_domain); > > + if (!strcmp(genpd->name, pds[i].parent_name)) > > + break; > > + } > > + > > + child_genpd = blk_ctl->onecell_data.domains[i]; > > + if (pm_genpd_add_subdomain(genpd, child_genpd)) > > + pr_warn("failed to add subdomain:\n"); > > Remove the colon add the end of the warning message or add something after > it. Fix in V3. Thanks, Peng. > > > + } > > + > > + return 0; > > +} > > + > > +int imx_blk_ctl_register(struct device *dev) { > > + struct imx_blk_ctl *blk_ctl = dev_get_drvdata(dev); > > + const struct imx_blk_ctl_dev_data *dev_data = blk_ctl->dev_data; > > + int num = dev_data->pds_num; > > + int i, ret; > > + > > + if (!blk_ctl) > > + return -ENODEV; > > + > > + ret = imx_blk_ctl_register_pd(dev); > > + if (ret) > > + return ret; > > + > > + ret = imx_blk_ctl_hook_pd(dev); > > + if (ret) > > + goto unregister_pd; > > + > > + ret = of_genpd_add_provider_onecell(dev->of_node, > &blk_ctl->onecell_data); > > + if (ret) > > + goto detach_pd; > > + > > + pm_runtime_get_noresume(dev); > > + pm_runtime_set_active(dev); > > + pm_runtime_enable(dev); > > + > > + pm_runtime_put(dev); > > + > > + return 0; > > + > > +detach_pd: > > + for (i = blk_ctl->dev_data->num_active_pd; i >= 0; i--) > > + dev_pm_domain_detach(blk_ctl->active_pds[i], false); > > +unregister_pd: > > + for (i = num - 1; i >= 0; i--) > > + pm_genpd_remove(blk_ctl->onecell_data.domains[i]); > > + > > + return ret; > > +} > > +EXPORT_SYMBOL_GPL(imx_blk_ctl_register); > > + > > +static int __maybe_unused imx_blk_ctl_runtime_suspend(struct device > > +*dev) { > > + return 0; > > +} > > + > > +static int __maybe_unused imx_blk_ctl_runtime_resume(struct device > > +*dev) { > > + return 0; > > +} > > + > > +const struct dev_pm_ops imx_blk_ctl_pm_ops = { > > + SET_RUNTIME_PM_OPS(imx_blk_ctl_runtime_suspend, > > + imx_blk_ctl_runtime_resume, NULL) > > + SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, > > + pm_runtime_force_resume) > > +}; > > +EXPORT_SYMBOL_GPL(imx_blk_ctl_pm_ops); > > diff --git a/drivers/soc/imx/blk-ctl.h b/drivers/soc/imx/blk-ctl.h new > > file mode 100644 index 000000000000..e736369406a1 > > --- /dev/null > > +++ b/drivers/soc/imx/blk-ctl.h > > @@ -0,0 +1,76 @@ > > +/* SPDX-License-Identifier: GPL-2.0 */ #ifndef __SOC_IMX_BLK_CTL_H > > +#define __SOC_IMX_BLK_CTL_H > > + > > +enum imx_blk_ctl_pd_type { > > + BLK_CTL_PD, > > +}; > > + > > +struct imx_blk_ctl_hw { > > + int type; > > + char *name; > > + char *parent_name; > > + u32 offset; > > + u32 mask; > > + u32 flags; > > + u32 id; > > + u32 rst_offset; > > + u32 rst_mask; > > +}; > > + > > +struct imx_blk_ctl_domain { > > + struct generic_pm_domain pd; > > + struct imx_blk_ctl *blk_ctl; > > + u32 id; > > +}; > > + > > +struct imx_blk_ctl_dev_data { > > + struct regmap_config config; > > + struct imx_blk_ctl_hw *pds; > > + struct imx_blk_ctl_hw hw_hsk; > > + u32 pds_num; > > + char **active_pd_names; > > + u32 num_active_pd; > > +}; > > + > > +struct imx_blk_ctl { > > + struct device *dev; > > + struct regmap *regmap; > > + struct device **active_pds; > > + u32 pds_num; > > + u32 active_pd_count; > > + struct genpd_onecell_data onecell_data; > > + const struct imx_blk_ctl_dev_data *dev_data; > > + struct clk_bulk_data *clks; > > + u32 num_clks; > > + > > + atomic_t power_count; > > +}; > > + > > +#define IMX_BLK_CTL(_type, _name, _parent_name, _id, _offset, _mask, > _rst_offset, _rst_mask, \ > > + _flags) \ > > + { \ > > + .type = _type, \ > > + .name = _name, \ > > + .parent_name = _parent_name, \ > > + .id = _id, \ > > + .offset = _offset, \ > > + .mask = _mask, \ > > + .flags = _flags, \ > > + .rst_offset = _rst_offset, \ > > + .rst_mask = _rst_mask, \ > > + } > > + > > +#define IMX_BLK_CTL_PD(_name, _parent_name, _id, _offset, _mask, > _rst_offset, _rst_mask, _flags) \ > > + IMX_BLK_CTL(BLK_CTL_PD, _name, _parent_name, _id, _offset, _mask, > _rst_offset, \ > > + _rst_mask, _flags) > > + > > +int imx_blk_ctl_register(struct device *dev); > > + > > +#define IMX_BLK_CTL_PD_HANDSHAKE BIT(0) > > +#define IMX_BLK_CTL_PD_RESET BIT(1) > > +#define IMX_BLK_CTL_PD_BUS BIT(2) > > + > > +const extern struct dev_pm_ops imx_blk_ctl_pm_ops; > > + > > +#endif > > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel