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=-17.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 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 90298C433FE for ; Tue, 21 Sep 2021 07:24:02 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D70FC610A0 for ; Tue, 21 Sep 2021 07:24:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org D70FC610A0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=canonical.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7AAD883270; Tue, 21 Sep 2021 09:23:59 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=canonical.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.b="uOADvuNT"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 393F383270; Tue, 21 Sep 2021 09:23:57 +0200 (CEST) Received: from smtp-relay-internal-1.canonical.com (smtp-relay-internal-1.canonical.com [185.125.188.123]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 6B31882EDA for ; Tue, 21 Sep 2021 09:23:53 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=canonical.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=heinrich.schuchardt@canonical.com Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 337033F331 for ; Tue, 21 Sep 2021 07:23:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1632209032; bh=MFmBq1fD+Bn5QYRwGpM146cxKULJC6+yOULkTU8qMUU=; h=Subject:To:References:From:Message-ID:Date:MIME-Version: In-Reply-To:Content-Type; b=uOADvuNTKdJiJGBKsaeRQ7ioNrA5kzEuq8Lm8wNWizOMdxf/ORiXVYaMmV90mNEoL 10iGLnDcOzQeII3BWwytgLUlJIiJFfc7XMXJpQa+/yb0nex5bQ0WVGrtFPsI4XKwg+ zAxzYGdBhfMBPfIoMC1irTGHNXwvpj7dpsGDWoM3uasHJ7d4q13cvA7bgOdKeYHadP cveyGoCJdLaeTKu5zdwlzAnwHG9C0hkozZv0vEpV8pb1nHpel9Q77WAQp9kye8M70R lA6bZJnbkJHYe1Th2TJKoIdiKFhI4khR3vWJnryv+QElj9rgktOHsvYhMNt7LXieij rvddVYu05OgTw== Received: by mail-wr1-f69.google.com with SMTP id x2-20020a5d54c2000000b0015dfd2b4e34so8045040wrv.6 for ; Tue, 21 Sep 2021 00:23:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=MFmBq1fD+Bn5QYRwGpM146cxKULJC6+yOULkTU8qMUU=; b=6V22YqULKBDTi4KcGeBUmnY8myphezEIy7JufrL+0oFoSjcQsUW0G0ABlEC418y+BC AFHSGZuQBEDUrZByxvgKQ6kBQb5UmwYlMBWkeBfpVRSHL+vF+Cf18i21C7vxnnr2Siis tvzE529y+kQ2JrN1HV3cMFI4xfjo1METjlufSGLqXonT6B7fGp1MJp3tTAdGswQVbppE Q/y+dQwEvDBwELJMDUBkXIKUSByDGvfaZdWYVCEJikKRhTxcvwg7gbu/NRhSvuzYYkSA PHjxyepQfm+GwTsbBcKy+9iUH2ebAS8CCtcLjCxd5rOZlZmOiCmwIZekUsJ/gR0BIVkK b1PQ== X-Gm-Message-State: AOAM533+HvHBU8WNLdcK3ICKRoBAkRnKH5YT+78l/67SUHZqq96mt4Oj AGA6PdCZIEZm/mBRQp3DiMlNogbtiJ2JPogXWsGIOIX6Udh8O9QSTWFFFz4w4xCL98hFh1XrLzi +KFHFAlra0Jcp9iYZcQVzxciu08mHhzA= X-Received: by 2002:adf:f188:: with SMTP id h8mr32302446wro.269.1632209031916; Tue, 21 Sep 2021 00:23:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxoPVuFKw7nmAX+M10k6ObH+7Hxq1KmI/Wvk0+1L1O350etGQJzs82cQW9VllImQjvGYpEFTw== X-Received: by 2002:adf:f188:: with SMTP id h8mr32302427wro.269.1632209031712; Tue, 21 Sep 2021 00:23:51 -0700 (PDT) Received: from [192.168.123.35] (ip-88-152-144-157.hsi03.unitymediagroup.de. [88.152.144.157]) by smtp.gmail.com with ESMTPSA id z79sm1932677wmc.17.2021.09.21.00.23.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 21 Sep 2021 00:23:51 -0700 (PDT) Subject: Re: [PATCH] drivers: pmic: Add sysreset driver to da9063 pmic device To: Alexandre Ghiti , Paul Walmsley , Pragnesh Patel , Green Wan , Jaehoon Chung , u-boot@lists.denx.de References: <20210920154809.1695453-1-alexandre.ghiti@canonical.com> From: Heinrich Schuchardt Message-ID: <396c1517-b871-5768-40f8-8e312879041f@canonical.com> Date: Tue, 21 Sep 2021 09:23:50 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <20210920154809.1695453-1-alexandre.ghiti@canonical.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean On 9/20/21 5:48 PM, Alexandre Ghiti wrote: > This pmic device is present on the SiFive Unmatched board and this > new driver adds the possibility to reset it. > > Signed-off-by: Alexandre Ghiti > --- > configs/sifive_unmatched_defconfig | 2 ++ > drivers/power/pmic/da9063.c | 49 ++++++++++++++++++++++++++++++ > 2 files changed, 51 insertions(+) > > diff --git a/configs/sifive_unmatched_defconfig b/configs/sifive_unmatched_defconfig > index 978818b688..9ab058be39 100644 > --- a/configs/sifive_unmatched_defconfig > +++ b/configs/sifive_unmatched_defconfig > @@ -43,3 +43,5 @@ CONFIG_DM_USB=y > CONFIG_USB_XHCI_HCD=y > CONFIG_USB_XHCI_PCI=y > CONFIG_BOARD_EARLY_INIT_F=y > +CONFIG_DM_PMIC=y > +CONFIG_DM_PMIC_DA9063=y > diff --git a/drivers/power/pmic/da9063.c b/drivers/power/pmic/da9063.c > index 25101d18f7..b04879d9c5 100644 > --- a/drivers/power/pmic/da9063.c > +++ b/drivers/power/pmic/da9063.c > @@ -10,6 +10,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -87,6 +88,7 @@ static int da9063_bind(struct udevice *dev) > { > ofnode regulators_node; > int children; > + int ret; > > regulators_node = dev_read_subnode(dev, "regulators"); > if (!ofnode_valid(regulators_node)) { > @@ -101,6 +103,14 @@ static int da9063_bind(struct udevice *dev) > if (!children) > debug("%s: %s - no child found\n", __func__, dev->name); > > + if (CONFIG_IS_ENABLED(SYSRESET)) { Thank you for addressing the missing reset driver for the SiFive Unmatched board. I imagine some existing or future boards using the DA9063 will have a GPIO for system reset. Should all boards having a DA9063 PMIC implement system reset via the power management IC? We could instead use the devicetree to identify if a board shall use the DA9063 for system reset. > + ret = device_bind_driver(dev, "da9063-sysreset", > + "da9063-sysreset", NULL); > + if (ret) > + debug("%s: %s - failed to bind sysreset driver\n", > + __func__, dev->name); > + } > + > /* Always return success for this device */ > return 0; > } > @@ -129,3 +139,42 @@ U_BOOT_DRIVER(pmic_da9063) = { > .probe = da9063_probe, > .ops = &da9063_ops, > }; > + > +#ifdef CONFIG_SYSRESET The linker will remove functions that are not used automatically. We have tended to not enclose functions in #ifdef but instead allow the compiler to check the code. > +#include Please, keep includes at the top of the code. > + Even though this is a static function I would add a Sphinx style comment here. Cf. https://www.kernel.org/doc/html/latest/doc-guide/kernel-doc.html#function-documentation Best regards Heinrich > +static int da9063_sysreset_request(struct udevice *dev, enum sysreset_t type) > +{ > + struct udevice *pmic_dev = dev->parent; > + uint ret; > + > + if (type != SYSRESET_WARM && type != SYSRESET_COLD) > + return -EPROTONOSUPPORT; > + > + ret = pmic_reg_write(pmic_dev, DA9063_REG_PAGE_CON, 0x00); > + if (ret < 0) > + return ret; > + > + /* Sets the WAKE_UP bit */ > + ret = pmic_reg_write(pmic_dev, DA9063_REG_CONTROL_F, 0x04); > + if (ret < 0) > + return ret; > + > + /* Powerdown! */ > + ret = pmic_reg_write(pmic_dev, DA9063_REG_CONTROL_A, 0x68); > + if (ret < 0) > + return ret; > + > + return -EINPROGRESS; > +} > + > +static struct sysreset_ops da9063_sysreset_ops = { > + .request = da9063_sysreset_request, > +}; > + > +U_BOOT_DRIVER(da9063_sysreset) = { > + .name = "da9063-sysreset", > + .id = UCLASS_SYSRESET, > + .ops = &da9063_sysreset_ops, > +}; > +#endif >