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=-18.8 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,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 F1B1FC433EF for ; Fri, 24 Sep 2021 08:45:47 +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 29D8260F41 for ; Fri, 24 Sep 2021 08:45:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 29D8260F41 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 2FBC68344A; Fri, 24 Sep 2021 10:45:44 +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="lOU3bqtK"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E656B83422; Fri, 24 Sep 2021 10:45:41 +0200 (CEST) Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) (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 EF9ED8344A for ; Fri, 24 Sep 2021 10:45:36 +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=alexandre.ghiti@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-0.canonical.com (Postfix) with ESMTPS id A0AEB402D9 for ; Fri, 24 Sep 2021 08:45:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1632473136; bh=/eom6XyE56McJFBDLSJ0U6EomGRax3dlVLaUQuRbHb0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=lOU3bqtKfFdO+YrCOGJ/yAocboi8yoTptNkHPYPLyhW4DKNsAnd5ogSjv0nB76+vk dZ5YrozIXvCkJ9LI2Iuf5OCM49+Yb5jUohFhoRH5J/YrJLNnWuQMRyynQ/F5gjCHCF yRdDtncyfuwNa5b+s6ebGSWAOULi9Y/ttG2gPHrWQLTjY+JSObgjwwgzg9HRUtKZ4M LmZ66p9jonGIRhl9AzYw39bCAkNFQ1KAoU4u2zbOIFb8MYm0O1lD3ik6o/xCCHhQnl VLRbUCeUTxS6Wnr2QklIAlDsNvOAA72tT4iXyfxXeP5qotqBkxxZesO078y9tis5IA 3LhODHewnm2vA== Received: by mail-wr1-f69.google.com with SMTP id l9-20020adfc789000000b00160111fd4e8so7435920wrg.17 for ; Fri, 24 Sep 2021 01:45:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/eom6XyE56McJFBDLSJ0U6EomGRax3dlVLaUQuRbHb0=; b=ZDvIHYGfNsKBg6ebpCMRZp6cG8wMGrYwiqB7kUDACEaXNt0uO8urpplpNzBpJhCRu6 UveerDLFZmBxdgZe8LQ6ojrycxYcWLeupWlz/oqhS+reWTxItY5t+14xctraEZAd1VuA a37AeZnZx04ny/7dADf4WhBo2fximmcS14jYZ6Os5etbHit70siEgSnjll16Hmn0Vk5Y VppM22CEUc2ikzlS4nHN8L8Agy+EweIgJUeHsAuHVSt4CzVYTFUQfLpUNuc2MsNqPCPc 8knTi6aT0c9roRf8TKIrCuu+1AbHrossr/jLsbRiQJQYCjvPpRJbWxaCKJoAUPF+a6N3 YoKA== X-Gm-Message-State: AOAM532tv9NqtEm25Y7lhPQTOdi1FkmiSSVhx4c+9G8p4HFc/W9qYJcr CIQ/M9grEyrogajnqwAfxW9k7JaQctZUZOzmIkGHU5k0osJ6QhQyJnIGmPYKY+6v1YdJzDCmsvq zTwxnxb62awox5VB9jkOYg2VBH+y3UIU= X-Received: by 2002:a7b:c842:: with SMTP id c2mr823937wml.93.1632473136301; Fri, 24 Sep 2021 01:45:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzWmKxK0DtxNpAcpMCNaxfFEmQEbv1Ml0UEddxTvqijGX6trXmCms3KcKa8t2BTx+YzYGlPUA== X-Received: by 2002:a7b:c842:: with SMTP id c2mr823922wml.93.1632473136087; Fri, 24 Sep 2021 01:45:36 -0700 (PDT) Received: from localhost.localdomain (lfbn-lyo-1-470-249.w2-7.abo.wanadoo.fr. [2.7.60.249]) by smtp.gmail.com with ESMTPSA id l26sm11608383wmi.25.2021.09.24.01.45.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 01:45:35 -0700 (PDT) From: Alexandre Ghiti To: Paul Walmsley , Pragnesh Patel , Green Wan , Jaehoon Chung , Heinrich Schuchardt , u-boot@lists.denx.de Cc: Alexandre Ghiti Subject: [PATCH v2 3/4] drivers: pmic: Add sysreset driver for da9063 PMIC Date: Fri, 24 Sep 2021 10:42:30 +0200 Message-Id: <20210924084231.3311216-4-alexandre.ghiti@canonical.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210924084231.3311216-1-alexandre.ghiti@canonical.com> References: <20210924084231.3311216-1-alexandre.ghiti@canonical.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Some da9063 chips can't use the watchdog as a restart means since the OTP does not set the AUTOBOOT bit [1]. So we need a new reset driver that implements a small i2c sequence that will allow to reset the boards that have this chip. [1] https://www.dialog-semiconductor.com/products/pmics?post_id=10052#tab-support_tab_content Signed-off-by: Alexandre Ghiti --- drivers/power/pmic/da9063.c | 51 ++++++++++++++++++++++++++++++++++++- include/power/da9063_pmic.h | 1 + 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/drivers/power/pmic/da9063.c b/drivers/power/pmic/da9063.c index 25101d18f7..eb470e4255 100644 --- a/drivers/power/pmic/da9063.c +++ b/drivers/power/pmic/da9063.c @@ -10,6 +10,8 @@ #include #include #include +#include +#include #include #include #include @@ -85,8 +87,9 @@ static int da9063_read(struct udevice *dev, uint reg, uint8_t *buff, int len) static int da9063_bind(struct udevice *dev) { - ofnode regulators_node; + ofnode regulators_node, reset_node; int children; + int ret; regulators_node = dev_read_subnode(dev, "regulators"); if (!ofnode_valid(regulators_node)) { @@ -101,6 +104,17 @@ static int da9063_bind(struct udevice *dev) if (!children) debug("%s: %s - no child found\n", __func__, dev->name); + if (CONFIG_IS_ENABLED(SYSRESET)) { + reset_node = dev_read_subnode(dev, "reset"); + if (ofnode_valid(reset_node)) { + ret = device_bind_driver(dev, DA9063_SYSRESET_DRIVER, + DA9063_SYSRESET_DRIVER, NULL); + if (ret) + pr_err("%s: %s - failed to bind sysreset driver\n", + __func__, dev->name); + } + } + /* Always return success for this device */ return 0; } @@ -129,3 +143,38 @@ U_BOOT_DRIVER(pmic_da9063) = { .probe = da9063_probe, .ops = &da9063_ops, }; + +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_DRIVER, + .id = UCLASS_SYSRESET, + .ops = &da9063_sysreset_ops, +}; diff --git a/include/power/da9063_pmic.h b/include/power/da9063_pmic.h index 273a07ef41..1c676c242a 100644 --- a/include/power/da9063_pmic.h +++ b/include/power/da9063_pmic.h @@ -304,6 +304,7 @@ /* Drivers name */ #define DA9063_LDO_DRIVER "da9063_ldo" #define DA9063_BUCK_DRIVER "da9063_buck" +#define DA9063_SYSRESET_DRIVER "da9063_sysreset" /* Regulator modes */ enum { -- 2.30.2