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.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 7842CC433DB for ; Wed, 3 Mar 2021 22:08:12 +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 B23AF64E2E for ; Wed, 3 Mar 2021 22:08:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B23AF64E2E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org 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-Type: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: In-Reply-To:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Reply-To:Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date :Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=nR777AKAhcGo9XdyeK1efGxIQWuEwZCELeQwtQkggeA=; b=R8c8y7p205bRBeJ/CkcpF5BO7 iuWc5usZmMU1p2YBmKJqPcv9J5/BSzrsXQOMSdHldK0jR+ChZCBQN0A5TSE4ldk9m/sxuDnLdGrvF d5xB1qqLLNT+zn+URTlb3oTet+BL/GW1mw39QCcMfiaYDpHxtLnAbxRmis6RdNuFHd/Fu54eH8KPS WlfzxL611dflIwjxNbf0+XOKfhyu30fr7dsBD5X+7D1H6gJHRSStaqVDzu71YUwSat364IOslr3Jc a0B4Ee2npM1SJYF6+xZGANvSBCflRUfCd+FcWiPhpQmz5BXuK1QVfih60PiB8Y+F8Qhe6V9xnutad /ErchNGLw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lHZbB-006h7P-35; Wed, 03 Mar 2021 22:04:05 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lHTAZ-005Kb6-5I for linux-arm-kernel@desiato.infradead.org; Wed, 03 Mar 2021 15:12:11 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=vBgFwCWhD91iqAKePJbEe6h/fkUeE5WW8owgq2twtpM=; b=R/dEviC53DmCC5/W7UCPrl3t9j zZdhszvaS5aH0f7Z7JPZoujChpArct8rNFfWFNA6fSh4FMyIcGyR3JU09i8Hrf8eQbBatfQmPK4AM /KtLUaEpMCTv6CXAl28oK16Rg013w1+iYSZNXJN86wQ0yN9rGOorb57svYl9w1SLddpshIokFD61i iZeqSIShhPgGRue0lr8+uoaKmCVlG+lSEuHRlLaU+8A5GWBywi5Hh+GBOOH1BtPyCSZxQmiEwoYS1 BXmUw34oCcPX9oK2wxjDHckLecqJVL9WcWtJB6n/fLiOykJycgoh4rEcCD0IMqAHCjL4GAOAAp0lo oJVNpMRg==; Received: from mail.kernel.org ([198.145.29.99]) by casper.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lH7O3-00HOTN-Vi for linux-arm-kernel@lists.infradead.org; Tue, 02 Mar 2021 15:56:43 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8EEC461494; Tue, 2 Mar 2021 15:44:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1614699848; bh=kHh3vq7lXBrXpC5+L7VOymgpayq/gSHEkCNJqpjL0WM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=khmnX+gBT2IjBaAK0PKFxGg5zqj9rnpIEZ3ThpL4vv7x7+b4l/vCl8k8bQPYTNBhB LRDmvyGaocgMN6j3rRqh0jYFqOyOB16rmktaulSoA2WchBsTM1Nqmji4BhA4wTa34F TEUdIEXZmp8V8b8OSTzEfQ/BjcBGKwtFE45B2JRbgwRiXGrmicS6hedVlY67q0lcVY 3eA9C3yrPpxZrO9hUBODi6KaAdGuWPhB8x0Cvd4AglFep+hFJ9lXT7UBEQgA2Qhlvy cZS/78yFSgw8URBZpPNVL1I6PkjVZYgc6XySSFzilp102kGcD1IYn/jII+6d4sCHYS YpeOUlY9HGrRg== Received: by earth.universe (Postfix, from userid 1000) id 6C8813C0C96; Tue, 2 Mar 2021 16:44:06 +0100 (CET) Date: Tue, 2 Mar 2021 16:44:06 +0100 From: Sebastian Reichel To: Geert Uytterhoeven Cc: Magnus Damm , Saravana Kannan , linux-renesas-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] soc: renesas: rmobile-sysc: Set OF_POPULATED and absorb reset handling Message-ID: <20210302154406.n4d6euiruwan4pm5@earth.universe> References: <20210205133319.1921108-1-geert+renesas@glider.be> MIME-Version: 1.0 In-Reply-To: <20210205133319.1921108-1-geert+renesas@glider.be> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210302_155643_129178_A611FF7D X-CRM114-Status: GOOD ( 34.15 ) 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: multipart/mixed; boundary="===============5394360547825019628==" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org --===============5394360547825019628== Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="pmkfhcgpktx5bhsd" Content-Disposition: inline --pmkfhcgpktx5bhsd Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi, On Fri, Feb 05, 2021 at 02:33:19PM +0100, Geert Uytterhoeven wrote: > Currently, there are two drivers binding to the R-Mobile System > Controller (SYSC): > - The rmobile-sysc driver registers PM domains from a core_initcall(), > and does not use a platform driver, > - The rmobile-reset driver registers a reset handler, and does use a > platform driver. >=20 > As fw_devlink only considers devices, it does not know that the > rmobile-sysc driver is ready. Hence if fw_devlink is enabled, probing > of on-chip devices that are part of the SYSC PM domain is deferred until > the optional rmobile-reset has been bound, which may happen too late > (for e.g. the system timer on SoCs lacking an ARM architectured or > global timer), or not at all, leading to complete system boot failures. >=20 > Fix this by: > 1. Setting the OF_POPULATED flag for the SYSC device node after > successful initialization. > This will make of_link_to_phandle() ignore the SYSC device node as > a dependency, making consumer devices probe again. > 2. Move reset handling from its own driver into the rmobile-sysc > driver. > This is needed because setting OF_POPULATED prevents the > rmobile-reset driver from binding against the same device. >=20 > Signed-off-by: Geert Uytterhoeven > --- > To be queued in renesas-devel for v5.13. Acked-by: Sebastian Reichel -- Sebastian >=20 > Tested on: > - SH-Mobile AG5 (KZM-A9-GT), > - R-Mobile APE6 (APE6-EVM), > - R-Mobile A1 (Armadillo-800 EVA). >=20 > drivers/power/reset/Kconfig | 7 --- > drivers/power/reset/Makefile | 1 - > drivers/power/reset/rmobile-reset.c | 88 ----------------------------- > drivers/soc/renesas/rmobile-sysc.c | 65 ++++++++++++++++++++- > 4 files changed, 64 insertions(+), 97 deletions(-) > delete mode 100644 drivers/power/reset/rmobile-reset.c >=20 > diff --git a/drivers/power/reset/Kconfig b/drivers/power/reset/Kconfig > index 1737e227b16e5136..417b112be3f660de 100644 > --- a/drivers/power/reset/Kconfig > +++ b/drivers/power/reset/Kconfig > @@ -251,13 +251,6 @@ config POWER_RESET_SYSCON_POWEROFF > help > Poweroff support for generic SYSCON mapped register poweroff. > =20 > -config POWER_RESET_RMOBILE > - tristate "Renesas R-Mobile reset driver" > - depends on ARCH_RMOBILE || COMPILE_TEST > - depends on HAS_IOMEM > - help > - Reboot support for Renesas R-Mobile and SH-Mobile SoCs. > - > config POWER_RESET_ZX > tristate "ZTE SoCs reset driver" > depends on ARCH_ZX || COMPILE_TEST > diff --git a/drivers/power/reset/Makefile b/drivers/power/reset/Makefile > index b4601c0a96ed26c7..77a57ca8e5300d60 100644 > --- a/drivers/power/reset/Makefile > +++ b/drivers/power/reset/Makefile > @@ -29,7 +29,6 @@ obj-$(CONFIG_POWER_RESET_XGENE) +=3D xgene-reboot.o > obj-$(CONFIG_POWER_RESET_KEYSTONE) +=3D keystone-reset.o > obj-$(CONFIG_POWER_RESET_SYSCON) +=3D syscon-reboot.o > obj-$(CONFIG_POWER_RESET_SYSCON_POWEROFF) +=3D syscon-poweroff.o > -obj-$(CONFIG_POWER_RESET_RMOBILE) +=3D rmobile-reset.o > obj-$(CONFIG_POWER_RESET_ZX) +=3D zx-reboot.o > obj-$(CONFIG_REBOOT_MODE) +=3D reboot-mode.o > obj-$(CONFIG_SYSCON_REBOOT_MODE) +=3D syscon-reboot-mode.o > diff --git a/drivers/power/reset/rmobile-reset.c b/drivers/power/reset/rm= obile-reset.c > deleted file mode 100644 > index bd3b396558e0df8c..0000000000000000 > --- a/drivers/power/reset/rmobile-reset.c > +++ /dev/null > @@ -1,88 +0,0 @@ > -// SPDX-License-Identifier: GPL-2.0 > -/* > - * Renesas R-Mobile Reset Driver > - * > - * Copyright (C) 2014 Glider bvba > - */ > - > -#include > -#include > -#include > -#include > -#include > -#include > -#include > - > -/* SYSC Register Bank 2 */ > -#define RESCNT2 0x20 /* Reset Control Register 2 */ > - > -/* Reset Control Register 2 */ > -#define RESCNT2_PRES 0x80000000 /* Soft power-on reset */ > - > -static void __iomem *sysc_base2; > - > -static int rmobile_reset_handler(struct notifier_block *this, > - unsigned long mode, void *cmd) > -{ > - pr_debug("%s %lu\n", __func__, mode); > - > - /* Let's assume we have acquired the HPB semaphore */ > - writel(RESCNT2_PRES, sysc_base2 + RESCNT2); > - > - return NOTIFY_DONE; > -} > - > -static struct notifier_block rmobile_reset_nb =3D { > - .notifier_call =3D rmobile_reset_handler, > - .priority =3D 192, > -}; > - > -static int rmobile_reset_probe(struct platform_device *pdev) > -{ > - int error; > - > - sysc_base2 =3D of_iomap(pdev->dev.of_node, 1); > - if (!sysc_base2) > - return -ENODEV; > - > - error =3D register_restart_handler(&rmobile_reset_nb); > - if (error) { > - dev_err(&pdev->dev, > - "cannot register restart handler (err=3D%d)\n", error); > - goto fail_unmap; > - } > - > - return 0; > - > -fail_unmap: > - iounmap(sysc_base2); > - return error; > -} > - > -static int rmobile_reset_remove(struct platform_device *pdev) > -{ > - unregister_restart_handler(&rmobile_reset_nb); > - iounmap(sysc_base2); > - return 0; > -} > - > -static const struct of_device_id rmobile_reset_of_match[] =3D { > - { .compatible =3D "renesas,sysc-rmobile", }, > - { /* sentinel */ } > -}; > -MODULE_DEVICE_TABLE(of, rmobile_reset_of_match); > - > -static struct platform_driver rmobile_reset_driver =3D { > - .probe =3D rmobile_reset_probe, > - .remove =3D rmobile_reset_remove, > - .driver =3D { > - .name =3D "rmobile_reset", > - .of_match_table =3D rmobile_reset_of_match, > - }, > -}; > - > -module_platform_driver(rmobile_reset_driver); > - > -MODULE_DESCRIPTION("Renesas R-Mobile Reset Driver"); > -MODULE_AUTHOR("Geert Uytterhoeven "); > -MODULE_LICENSE("GPL v2"); > diff --git a/drivers/soc/renesas/rmobile-sysc.c b/drivers/soc/renesas/rmo= bile-sysc.c > index bf64d052f9245db5..a8d85d111924d9ee 100644 > --- a/drivers/soc/renesas/rmobile-sysc.c > +++ b/drivers/soc/renesas/rmobile-sysc.c > @@ -1,10 +1,11 @@ > // SPDX-License-Identifier: GPL-2.0 > /* > - * rmobile power management support > + * R-Mobile power management and reset support > * > * Copyright (C) 2012 Renesas Solutions Corp. > * Copyright (C) 2012 Kuninori Morimoto > * Copyright (C) 2014 Glider bvba > + * Copyright (C) 2021 Glider bv > * > * based on pm-sh7372.c > * Copyright (C) 2011 Magnus Damm > @@ -12,11 +13,13 @@ > #include > #include > #include > +#include > #include > #include > #include > #include > #include > +#include > #include > =20 > #include > @@ -29,6 +32,11 @@ > #define PSTR_RETRIES 100 > #define PSTR_DELAY_US 10 > =20 > +/* SYSC Register Bank 2 */ > +#define RESCNT2 0x20 /* Reset Control Register 2 */ > + > +#define RESCNT2_PRES BIT(31) /* Soft power-on reset */ > + > struct rmobile_pm_domain { > struct generic_pm_domain genpd; > struct dev_power_governor *gov; > @@ -309,6 +317,54 @@ static int __init rmobile_add_pm_domains(void __iome= m *base, > return 0; > } > =20 > +struct rmobile_reset { > + void __iomem *base; > + struct notifier_block nb; > +}; > + > +static int rmobile_reset_handler(struct notifier_block *this, > + unsigned long mode, void *cmd) > +{ > + struct rmobile_reset *reset =3D container_of(this, struct rmobile_reset, > + nb); > + > + pr_debug("%s %lu\n", __func__, mode); > + > + /* Let's assume we have acquired the HPB semaphore */ > + writel(RESCNT2_PRES, reset->base + RESCNT2); > + > + return NOTIFY_DONE; > +} > + > +static int rmobile_reset_setup(struct device_node *np) > +{ > + struct rmobile_reset *reset; > + int error; > + > + reset =3D kzalloc(sizeof(*reset), GFP_KERNEL); > + if (!reset) > + return -ENOMEM; > + > + reset->base =3D of_iomap(np, 1); > + if (!reset->base) > + goto fail_free; > + > + reset->nb.notifier_call =3D rmobile_reset_handler; > + reset->nb.priority =3D 192; > + > + error =3D register_restart_handler(&reset->nb); > + if (error) > + goto fail_unmap; > + > + return 0; > + > +fail_unmap: > + iounmap(reset->base); > +fail_free: > + kfree(reset); > + return error; > +} > + > static int __init rmobile_init_pm_domains(void) > { > struct device_node *np, *pmd; > @@ -342,6 +398,13 @@ static int __init rmobile_init_pm_domains(void) > of_node_put(np); > break; > } > + > + of_node_set_flag(np, OF_POPULATED); > + > + ret =3D rmobile_reset_setup(np); > + if (ret) > + pr_err("%pOF: cannot register restart handler (%d)\n", > + np, ret); > } > =20 > put_special_pds(); > --=20 > 2.25.1 >=20 --pmkfhcgpktx5bhsd Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEE72YNB0Y/i3JqeVQT2O7X88g7+poFAmA+XTcACgkQ2O7X88g7 +ppCxA/+PoNIBxewxHZ00pMfN9/jD1SdXekNy7mpX2kieENnfOT/y+MnWgJVxI8k gvtJBDy8DywwKAEpDLisQ01zx6u+7B6OkFG3JX3thtUukvEdmqMZFLTT2Owr0HNJ cf74JdmbYG1n9cztoazhSVy6Uy/eadohKActXpHpxaZPXLpgivTzJZs7zZJpC+ve +nvWEZrRWcVYRF2ZyTjeAJ1Cbtd5XSnWzQCYMbvU0HcPw1ir1cnZvthJDjPivKGI ODc62Spk5T+pbyqvOxSQ8TyufeGWusM6j+QUVWD1yYnFdrwUFBQLsU/WG5AwRADo k1/7jPKkht4DGyRAf8I6FRebhizPwlDSVdXyl3ZO8xeQKvQoQkWolkSQaoeSW2aV hXAV7uNhF4T19O7ihiIZO+hzk/lTaEUnok1762QGeKAWawm6Ldx7HmFq1SSgT3u0 m3UJPlDyMo3znbaZ37Z2zIuh5NqKL5zCxn6U2+tiF0j7VTE/Zr/wSiTRNGP0du/e +7UFmIeOJTz735UOs71vEmkTBLbz95BYi0fmO8F885yPbdLlln652dzD1bmjl0qO n25TOpBZ/TVAkME4kkxTF9qXZZNjli+aaTsi9kHV2G7422PlfyxSvGKW52K8j14A eDhn2Yx54U0URgIUsJH9EmWwvcy7c0367969rqRGU+s0rEoqGOQ= =DzE0 -----END PGP SIGNATURE----- --pmkfhcgpktx5bhsd-- --===============5394360547825019628== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel --===============5394360547825019628==--