Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp162828pxb; Thu, 30 Sep 2021 03:28:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzhNWWZz1Fe81Lwu48EfQD20zByUOe3UU1t0vNeRM9wtcu4bHRNtHnoa4hNpyFlfP4ASTMB X-Received: by 2002:a05:6a00:1a4c:b0:44b:1fa6:532c with SMTP id h12-20020a056a001a4c00b0044b1fa6532cmr4832453pfv.64.1632997728286; Thu, 30 Sep 2021 03:28:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632997728; cv=none; d=google.com; s=arc-20160816; b=zCIMqxzgScS32ywuV84yTaxa9WxqcbkEN9g//7iHVtrwvc0lP1XB1a/WNpF4BypJSp M7ezJlqnjVzitYWCENpV+vKi31dL/DEE3VTr6tv08m5L3hfjILrzWUezGp0o6J6CsEpF UrtahSH4nswYwI4EiZo+NR4VWKS47IzIX2QItGJ/1okrxXjmZcN/gbBqmNUEF/NpQtSS QcI9NWfk2OfQWh58IEGvxxLDvHcMwbC4H+VrNYdm2lhxJZQ4v0MjaSOi//Oj41S9ZHtc 93+BRyLigawBXAWbbfr/Tf3tBdQO19ZmswSveUts5oSv3ILYw86Z+sJbaXbvbKGsuKOp W4Dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=6bJ/KKwRD3P6cVHXUuBeJPUvhLBCys6Z5e/DGfI2INI=; b=GQMmkNe+QuycdrePWnDMHvJZTh4CooOb6Z4eYaXXXY5t0auW91UVxn0ss9+C6jNxg9 Ab/5EDKQ/LMZXSB/qMGfaSWWxCICTRphJ4CtsmoVfz9TwuicDdy3QZgTE6cBmqMfsVwv JQUBMV7ohcXSzeM288+OKRG+zeC5ANlyRCzgdo5+eEIP/ssP5AifPkKF2Mrwa4nXUyW0 zBkdZmZaYMtLTmOyIqpxCRKetMHEHpfXhga4y8wAIbxl0/EZ8glkBmwxn0ZLXiiUiVNy kaalsiWSNtzex0wmvPjkOhzy4Y8r3vqEXA4+ync6jGs0eNjJfptKrDA68i94t98j+Gv0 KGJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=GVFUAZ21; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r9si3103560pgv.331.2021.09.30.03.28.33; Thu, 30 Sep 2021 03:28:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=GVFUAZ21; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349918AbhI3K12 (ORCPT + 99 others); Thu, 30 Sep 2021 06:27:28 -0400 Received: from smtp-relay-internal-0.canonical.com ([185.125.188.122]:38048 "EHLO smtp-relay-internal-0.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349893AbhI3K1V (ORCPT ); Thu, 30 Sep 2021 06:27:21 -0400 Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) (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-0.canonical.com (Postfix) with ESMTPS id 70C9840279 for ; Thu, 30 Sep 2021 10:25:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1632997533; bh=6bJ/KKwRD3P6cVHXUuBeJPUvhLBCys6Z5e/DGfI2INI=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=GVFUAZ21PZLYIHyCVQhJ7yuptL7lyHHD/KOqDZFH1u4gqVVTTlEM5WfMOZ6I0cPmZ GNiI3Eb6SBAznR+nEbqeLgMyvu6JPsDlg5lLtMFD8vkpiTurFlUo5QsHSOXk18pisz cuTErTBAY3NGz7ROfFm0akTGcZBqKzRpAXvPffWLgLAMtxz618kQiC/Bg2M+ZjfEs1 hMqnzokHqgubMx6WdDyCMrbEyrFjltRn+XFogVRlWYZg/2GMhST07kQbH6M57/a/NA T0lDFA8CWCsTKIAjMs6EKv6qLns0p43FiWVNEsQ1puvjXXmfz0z9kJSVeZxOuUJp1V jsnXXPMzbvWKA== Received: by mail-ed1-f72.google.com with SMTP id x7-20020a50ba87000000b003dabd8354f1so1109230ede.7 for ; Thu, 30 Sep 2021 03:25:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=6bJ/KKwRD3P6cVHXUuBeJPUvhLBCys6Z5e/DGfI2INI=; b=GM2lhYuAk1aMeHObMQ5M4mMi9BIV5bUXGdQQmZHQYjXy+MozgS+OZF910UHlUbcUK1 UvELBfk8jsSE3bOAZTIyqKYHSTlrA2tyv3VJOzb9Yjk/4ecCKHgzPe9W/TdIfwx1KVHh /3hDo4+R5NGKNn0x/6RwnITtSXKwwu4Pvwrsfu0ccNu6hw7TasCA++riStzjLIYFMd1n MbwLfXZV6okh7BEhitc2VDB5Lh4q7ZijGO3suPOvygD7DoFKHSTo9gEKED/f9Syq26aC jBobR4vPm01wXQIrUWBEIItDC8mm/AI43TnYrjQiPNsws6r3ze76KJLIWPbh4Nq0mDrI bveQ== X-Gm-Message-State: AOAM5323M9TQHygew2PGdCk4PgPeazfsH9Zqx1PwdJhjz3Gj3d8Pjogk DZem49vrdxOuc+xG6OYILSQLTPmSVp1DS7HrFgCxHqegXBGnF1T5LI0Zxz1ug/YfN4qpEX/DURW VwMqaphhrNJ7axCswmM8225NiaZcNKmMw3uzCU4AL4I4OZrxGv0zjRQD8Cg== X-Received: by 2002:a50:da49:: with SMTP id a9mr6232271edk.281.1632997533093; Thu, 30 Sep 2021 03:25:33 -0700 (PDT) X-Received: by 2002:a50:da49:: with SMTP id a9mr6232248edk.281.1632997532879; Thu, 30 Sep 2021 03:25:32 -0700 (PDT) MIME-Version: 1.0 References: <20210921053356.1705833-1-alexandre.ghiti@canonical.com> In-Reply-To: From: Alexandre Ghiti Date: Thu, 30 Sep 2021 12:25:22 +0200 Message-ID: Subject: Re: [PATCH] drivers: mfd: da9063: Add restart notifier implementation To: David Abdurachmanov Cc: Adam Thomson , Support Opensource , Lee Jones , "linux-riscv@lists.infradead.org" , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi David, On Thu, Sep 30, 2021 at 9:51 AM David Abdurachmanov wrote: > > On Wed, Sep 29, 2021 at 4:36 PM Adam Thomson > wrote: > > > > On 24 September 2021 17:17, Alexandre Ghiti wrote: > > > > > > > +static int da9063_restart_notify(struct notifier_block *this, > > > > > + unsigned long mode, void *cmd) > > > > > +{ > > > > > + struct da9063 *da9063 = container_of(this, struct da9063, > > > > > restart_handler); > > > > > + > > > > > + regmap_write(da9063->regmap, DA9063_REG_PAGE_CON, 0x00); > > > > > + regmap_write(da9063->regmap, DA9063_REG_CONTROL_F, 0x04); > > > > > + regmap_write(da9063->regmap, DA9063_REG_CONTROL_A, 0x68); > > > > > + > > > > > + return NOTIFY_DONE; > > > > > +} > > > > > > > > I will talk with our HW team to clarify, but this sequence looks to be very > > > > specific to the needs of the platform in question which doesn't feel right to > > > > me. As was mentioned on another thread as well, the watchdog driver already > > > has > > > > a restart function to reset the device (and thus the system), so I don't believe > > > > we should have multiple of these. > > > > > > From the discussion that happened here > > > https://www.dialog-semiconductor.com/products/pmics?post_id=10052#tab- > > > support_tab_content, > > > it does not seem possible to use the watchdog on a chip whose OTP does > > > not set AUTOBOOT. But anyway, I'm looking forward to hearing from the > > > HW team :) > > > > So I've discussed this internally and so far it's not completely clear how the > > sequence you provided actually performs the reset as you suggest. It certainly > > doesn't look like it should, so maybe this relates to an external pin somehow > > triggering the restart in this particular scenario? I'd be interested to > > understand which event bits are set when the board does restart to understand > > what did actually trigger the boot-up. > > > > Regardless of this though, the consensus right now would be to use the RTC as a > > wake event to restart the platform. An alarm can be set for a couple of seconds > > into the future (or longer if required) and that would provide the event > > required to come up from powerdown/shutdown, in the absence of AUTOBOOT being > > set in OTP. I believe this would be the safest route to take in this case. You > > can then just use the SHUTDOWN bit on CONTROL_F to take down the board. > > Today I was looking into OpenBSD DA9063 drivers and they might be > doing what you described for the reset. > > dev/fdt/dapmic.c > > [..] > 241 void > 242 dapmic_reset(void) > 243 { > 244 struct dapmic_softc *sc = dapmic_cd.cd_devs[0]; > 245 uint8_t reg; > 246 > 247 /* Enable tick alarm wakeup with a one second interval. */ > 248 reg = dapmic_reg_read(sc, ALARM_MO); > 249 reg &= ~ALARM_MO_TICK_TYPE; > 250 reg |= ALARM_MO_TICK_WAKE; > 251 dapmic_reg_write(sc, ALARM_MO, reg); > 252 > 253 /* Enable tick function. */ > 254 reg = dapmic_reg_read(sc, ALARM_Y); > 255 reg |= ALARM_Y_TICK_ON; > 256 dapmic_reg_write(sc, ALARM_Y, reg); > 257 > 258 /* Clear events such that we wake up again. */ > 259 dapmic_reg_write(sc, EVENT_A, dapmic_reg_read(sc, EVENT_A)); > 260 dapmic_reg_write(sc, CONTROL_F, CONTROL_F_SHUTDOWN); > 261 } > [..] > Thanks for the pointer! I have just tested this sequence from the u-boot shell, it resets the board correctly. But then if we try to power down the board by a long press to the corresponding button on the board within 16 seconds, it resets the board: so we cannot shutdown the board in the next 16 seconds that follow this sequence. Maybe that can be resolved by using the one-shot alarm as described by Adam, I'll try to find that in the datasheet. Thanks Alex > > > > To reiterate, I believe this should be made a board specific quirk, rather than > > as part of the generic MFD core of DA9063, as the timings may vary for other > > platforms. > > Agree. Currently it seems Linux drivers expect DA9063 boards to have > AUTOBOOT ON set in OTP, which is not the case for SiFive Unmatched > (thus issues with reset and WDT). > > david > > > _______________________________________________ > > linux-riscv mailing list > > linux-riscv@lists.infradead.org > > http://lists.infradead.org/mailman/listinfo/linux-riscv