Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 050ECEB64DC for ; Thu, 20 Jul 2023 08:48:42 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1355A8672B; Thu, 20 Jul 2023 10:48:34 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.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=gmail.com header.i=@gmail.com header.b="f6CEhpvV"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id CD41585C49; Thu, 20 Jul 2023 10:48:29 +0200 (CEST) Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [IPv6:2a00:1450:4864:20::12f]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 75DBC85E44 for ; Thu, 20 Jul 2023 10:48:27 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=clamor95@gmail.com Received: by mail-lf1-x12f.google.com with SMTP id 2adb3069b0e04-4fddd4e942eso513453e87.3 for ; Thu, 20 Jul 2023 01:48:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689842907; x=1690447707; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hX1ZSh4JN3vnYvM2vBuWKEG52ksu8+xf6dU6NMwZznI=; b=f6CEhpvVGgedpx8J3YS9fVRBosT3lUYWDpzAGChRbOpJhC5ybiPE9qmQIr6JgoYEgW cbOn+ZurCd2pxM/tkLc710swdPKSqQbWBoxV6DZDxI6pyZise7UuQzMyJesM+PNBdc/a KsVLi88Dc5v9QPGPx4kbi4pl804QIUxMBwjJncvG71N1VbTdqQbORBT7MLuyxSJXYNgZ 0dxqbWDfV3lujTtOsVkSRKNQbqBsYkd2jUqCCgQULBxCNnAvLPd2qWvtl5hNO58NqQig hxqAbPcY18rUqrgszFr3eyeRcyw6ggUcXsczP70tShe8wTb1051wMAsrbsa6+hprvP+n XEvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689842907; x=1690447707; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hX1ZSh4JN3vnYvM2vBuWKEG52ksu8+xf6dU6NMwZznI=; b=FxkDA7YMa6GjHKxQ/n6RrKbLWEV7gmwgN+/O9mdeT2y/M5vgldws9/LXeCSsN1nx6U IXnM3AsS38JbXoXGzCsN6F21gHTeMdgixq9sZfr8wtyfed8AY8Y+xt8md+kOdk7li6fh H1GKtn3RzP2ymgM17mG2pN79FLXwJjb2DaHI2Uwsf/Ap2S6EUH1dl5QIslWJo7k2g1kK 1CHqer1w1cjCyhR5fJVmdXkukRjacc7vtTe98TFA1snK16BKXYrp5NpYMzprpWiINJTg UYqaA5iY9Kypc0RI9IIgRDJCa4aAwSqzKlHp8ixnhmHK+tLJ1cRit8GP5SMcc1XaMC0H qyTA== X-Gm-Message-State: ABy/qLZMVZxipBNZrJWDdcIOyqUecMUu2W3xSMgtETKTsUodC+zW74B0 yjL1ZuUmiGWm3YYguNdRtNY= X-Google-Smtp-Source: APBJJlHvpqRDDJKPhvhBQXmR/3ov/5aiZYZnYysTeQzFE8+v5tN03IttvlHPl8tUooQRuMrXpHV22A== X-Received: by 2002:a19:2d0f:0:b0:4fb:772a:af12 with SMTP id k15-20020a192d0f000000b004fb772aaf12mr1080219lfj.21.1689842906676; Thu, 20 Jul 2023 01:48:26 -0700 (PDT) Received: from xeon.. ([188.163.112.64]) by smtp.gmail.com with ESMTPSA id x5-20020a19f605000000b004f21f196701sm94287lfe.203.2023.07.20.01.48.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Jul 2023 01:48:26 -0700 (PDT) From: Svyatoslav Ryhel To: Jaehoon Chung , Simon Glass , Svyatoslav Ryhel Cc: u-boot@lists.denx.de Subject: [PATCH v2 1/9] power: pmic-uclass: implement poweroff ops Date: Thu, 20 Jul 2023 11:47:56 +0300 Message-Id: <20230720084804.77666-2-clamor95@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230720084804.77666-1-clamor95@gmail.com> References: <20230720084804.77666-1-clamor95@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.8 at phobos.denx.de X-Virus-Status: Clean PMICs are responsible for device poweroff sequence so lets implement this function. Signed-off-by: Svyatoslav Ryhel --- drivers/power/pmic/pmic-uclass.c | 12 ++++++++++++ include/power/pmic.h | 13 +++++++++++++ 2 files changed, 25 insertions(+) diff --git a/drivers/power/pmic/pmic-uclass.c b/drivers/power/pmic/pmic-uclass.c index 0e2f5e1f41..23803bc96a 100644 --- a/drivers/power/pmic/pmic-uclass.c +++ b/drivers/power/pmic/pmic-uclass.c @@ -99,6 +99,18 @@ int pmic_get(const char *name, struct udevice **devp) return uclass_get_device_by_name(UCLASS_PMIC, name, devp); } +int pmic_poweroff(struct udevice *dev) +{ + const struct dm_pmic_ops *ops = dev_get_driver_ops(dev); + struct uc_pmic_priv *priv = dev_get_uclass_priv(dev); + + if (!ops || !ops->poweroff || + !priv->sys_pow_ctrl) + return -ENOSYS; + + return ops->poweroff(dev); +} + int pmic_reg_count(struct udevice *dev) { const struct dm_pmic_ops *ops = dev_get_driver_ops(dev); diff --git a/include/power/pmic.h b/include/power/pmic.h index 636221692d..d8dd1ceaa3 100644 --- a/include/power/pmic.h +++ b/include/power/pmic.h @@ -157,11 +157,13 @@ struct pmic { * Should be implemented by UCLASS_PMIC device drivers. The standard * device operations provides the I/O interface for it's childs. * + * @poweroff: perform poweroff sequence * @reg_count: device's register count * @read: read 'len' bytes at "reg" and store it into the 'buffer' * @write: write 'len' bytes from the 'buffer' to the register at 'reg' address */ struct dm_pmic_ops { + int (*poweroff)(struct udevice *dev); int (*reg_count)(struct udevice *dev); int (*read)(struct udevice *dev, uint reg, uint8_t *buffer, int len); int (*write)(struct udevice *dev, uint reg, const uint8_t *buffer, @@ -242,6 +244,16 @@ int pmic_bind_children(struct udevice *pmic, ofnode parent, */ int pmic_get(const char *name, struct udevice **devp); +/** + * pmic_poweroff: call the pmic poweroff sequence + * + * The required pmic device can be obtained by 'pmic_get()' + * + * @dev - pointer to the UCLASS_PMIC device + * Return: device turns off or negative value of errno. + */ +int pmic_poweroff(struct udevice *dev); + /** * pmic_reg_count: get the pmic register count * @@ -306,6 +318,7 @@ int pmic_clrsetbits(struct udevice *dev, uint reg, uint clr, uint set); */ struct uc_pmic_priv { uint trans_len; + bool sys_pow_ctrl; }; #endif /* DM_PMIC */ -- 2.39.2