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 EF9C4C7618D for ; Thu, 6 Apr 2023 17:41:29 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DD2AF8609F; Thu, 6 Apr 2023 19:41:12 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=baylibre.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=baylibre-com.20210112.gappssmtp.com header.i=@baylibre-com.20210112.gappssmtp.com header.b="pcBwhGzd"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3115A86043; Thu, 6 Apr 2023 17:38:32 +0200 (CEST) Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) (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 012B086052 for ; Thu, 6 Apr 2023 17:38:28 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=jneanne@baylibre.com Received: by mail-wm1-x32e.google.com with SMTP id m6-20020a05600c3b0600b003ee6e324b19so23969173wms.1 for ; Thu, 06 Apr 2023 08:38:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; t=1680795508; x=1683387508; 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=CmdOexAfFzRuXmvjg6gX67VctusIFr/IriunDeFluao=; b=pcBwhGzdIurG2G5pASGRxeJP8c7ZZ3bBlPK4n636396RiCI6fMYwsMo4BrS+TljH8B m4kPW6CZGWo0lRjZO3N4kx8NoVlk63YfdeaQDidy1saoY4JLiUZepjFu+RQsbsEoDsyI RmUA+COmChyej6rKFdbK815+Lxz18GhG03V/iADrl93rg55kG+53XIZPq/3yeKhG6kbT p7XGCfPheEEvtGEUJ8xMJngK72MRYdmbMLNPQSjBKuNy+Jdr+diO7B8TmvIOmrrYMd+L vTHFe9R/jfbegn4FxZFEP7B/NtpGQFR3i+0t7nYtIGW6kxDN9J14SnTD4eTSGZX5PV6R FNWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680795508; x=1683387508; 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=CmdOexAfFzRuXmvjg6gX67VctusIFr/IriunDeFluao=; b=Wxn1+c95uaP89APiFW+tHK51fLe8k0S8HspImzxXZsB0XMpLHeQ0qBbj3ATaSv3Tln NxrBkaEBEnXeeF9hQhC1tuMuaNcxnqzEWD/f2RMIe0w20eSkANOBlOSNDIke2c5ji5Lg +XBy9WTeHZPRySY358C2rkWUS1SVxj1yIGZlSOe6HBbLwpO28RI/KfuW/1r7FanQEeiM O6mCe+KbLlsSwpERezkfo5YoadxFXd5FLaaDDcB4z8mw7mQOgpkcxPwE/l2AqLvVFfsq G1iUxtd0r61mmhnxTO7Gpe+4/anG6dPb9h4I0ZIi53/89KKo61kIsEh4lbg8vXGtGJCw PXNg== X-Gm-Message-State: AAQBX9cHWRwysAgo7P5snEiNQnbyWxCP47T6EsFRfeuH813kswRCSyo6 XVotzRdQupRWr0MGzbEOIfOyaQ== X-Google-Smtp-Source: AKy350bCTDHWb192R4vXOKWuAP7F7unP7X/6dQ7+3/+glTva3+F4XoW9VfCC/1fs1n/bTK3jaPzXlA== X-Received: by 2002:a05:600c:2059:b0:3ed:346d:4534 with SMTP id p25-20020a05600c205900b003ed346d4534mr4712348wmg.0.1680795508446; Thu, 06 Apr 2023 08:38:28 -0700 (PDT) Received: from localhost.localdomain (laubervilliers-658-1-213-31.w90-63.abo.wanadoo.fr. [90.63.244.31]) by smtp.gmail.com with ESMTPSA id m21-20020a7bcb95000000b003ee4e99a8f6sm1891760wmi.33.2023.04.06.08.38.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Apr 2023 08:38:27 -0700 (PDT) From: Jerome Neanne To: vigneshr@ti.com, bb@ti.com, jh80.chung@samsung.com, nm@ti.com, g-vlaev@ti.com, d-gerlach@ti.com, jpanis@baylibre.com, jneanne@baylibre.com, vaishnav.a@ti.com, michal.simek@amd.com, j-keerthy@ti.com Cc: u-boot@lists.denx.de, sterzik@ti.com, u-kumar1@ti.com, eblanc@baylibre.com, khilman@baylibre.com Subject: [PATCH v1 1/9] drivers: pmic: TPS65941 add support for WD disable Date: Thu, 6 Apr 2023 17:38:12 +0200 Message-Id: <20230406153820.2800054-2-jneanne@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230406153820.2800054-1-jneanne@baylibre.com> References: <20230406153820.2800054-1-jneanne@baylibre.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailman-Approved-At: Thu, 06 Apr 2023 19:41:06 +0200 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 This is not a proper WD driver because it's not planned to support WD driver for PMIC in u-boot at any time. The purpose is just WD disable. Signed-off-by: Jerome Neanne --- drivers/power/pmic/tps65941.c | 36 +++++++++++++++++++++++++++++++++++ include/power/tps65941.h | 25 ++++++++++++++++++++++-- 2 files changed, 59 insertions(+), 2 deletions(-) diff --git a/drivers/power/pmic/tps65941.c b/drivers/power/pmic/tps65941.c index 83d0f83c64..643ea6179c 100644 --- a/drivers/power/pmic/tps65941.c +++ b/drivers/power/pmic/tps65941.c @@ -47,6 +47,9 @@ static int tps65941_bind(struct udevice *dev) ofnode regulators_node; int children; + if (dev->driver_data == TPS65941_WD) + return 0; + regulators_node = dev_read_subnode(dev, "regulators"); if (!ofnode_valid(regulators_node)) { debug("%s: %s regulators subnode not found!\n", __func__, @@ -64,6 +67,36 @@ static int tps65941_bind(struct udevice *dev) return dm_scan_fdt_dev(dev); } +static int stop_watchdog(struct udevice *wd_i2c_dev) +{ + int ret; + + ret = dm_i2c_reg_read(wd_i2c_dev, TPS65941_WD_MODE_REG); + if (ret < 0) { + debug("failed to write i2c reg (%d)\n", ret); + return 0; + } + + ret &= ~TPS65941_WD_PWRHOLD_MASK; + ret |= TPS65941_WD_PWRHOLD_MASK; + ret = dm_i2c_reg_write(wd_i2c_dev, TPS65941_WD_MODE_REG, ret); + if (ret) + debug("%s: %s write WD disable fail!\n", __func__, wd_i2c_dev->name); + ret = dm_i2c_reg_read(wd_i2c_dev, TPS65941_WD_MODE_REG); + if (ret < 0) { + debug("failed to read back i2c reg (%d)\n", ret); + return 0; + } + return 0; +} + +static int tps65941_probe(struct udevice *dev) +{ + if (dev->driver_data == TPS65941_WD) + return stop_watchdog(dev); + return 0; +} + static struct dm_pmic_ops tps65941_ops = { .read = tps65941_read, .write = tps65941_write, @@ -73,7 +106,9 @@ static const struct udevice_id tps65941_ids[] = { { .compatible = "ti,tps659411", .data = TPS659411 }, { .compatible = "ti,tps659412", .data = TPS659411 }, { .compatible = "ti,tps659413", .data = TPS659413 }, + { .compatible = "ti,tps659312", .data = TPS659312 }, { .compatible = "ti,lp876441", .data = LP876441 }, + { .compatible = "ti,tps65941_watchdog", .data = TPS65941_WD }, { } }; @@ -82,5 +117,6 @@ U_BOOT_DRIVER(pmic_tps65941) = { .id = UCLASS_PMIC, .of_match = tps65941_ids, .bind = tps65941_bind, + .probe = tps65941_probe, .ops = &tps65941_ops, }; diff --git a/include/power/tps65941.h b/include/power/tps65941.h index a2bc6814ba..70c7274355 100644 --- a/include/power/tps65941.h +++ b/include/power/tps65941.h @@ -2,7 +2,9 @@ #define TPS659412 0x1 #define TPS659413 0x2 #define TPS659414 0x3 -#define LP876441 0x4 +#define TPS659312 0x4 +#define LP876441 0x5 +#define TPS65941_WD 0x20 /* I2C device address for pmic tps65941 */ #define TPS65941_I2C_ADDR (0x12 >> 1) @@ -18,10 +20,29 @@ #define TPS65941_BUCK_VOLT_MAX 3340000 #define TPS65941_BUCK_MODE_MASK 0x1 -#define TPS65941_LDO_VOLT_MASK 0x3E +#define TPS65941_LDO_VOLT_MASK 0x7F #define TPS65941_LDO_VOLT_MAX_HEX 0x3A #define TPS65941_LDO_VOLT_MIN_HEX 0x4 #define TPS65941_LDO_VOLT_MAX 3300000 #define TPS65941_LDO_MODE_MASK 0x1 #define TPS65941_LDO_BYPASS_EN 0x80 #define TP65941_BUCK_CONF_SLEW_MASK 0x7 + +/* BYPASS is bit7 of VOUT TPS65941_LDO_BYP_MASK */ +#define TPS65941_LDO123_BYP_CONFIG 7 + +#define TPS65941_LDO123_VOLT_BYP_MIN 1700000 +#define TPS65941_LDO123_VOLT_BYP_MAX 3600000 +#define TPS65941_LDO123_VOLT_MIN 600000 +#define TPS65941_LDO4_VOLT_MIN 1200000 +#define TPS65941_LDO4_VOLT_MIN 1200000 +#define TPS65941_LDO123_VSET_MIN 0x04 +#define TPS65941_LDO4_VSET_MIN 0x20 +#define TPS65941_LDO123_VSET_MAX 0x3A +#define TPS65941_LDO4_VSET_MAX 0x74 +#define TPS65941_LDO123_STEP 50000 +#define TPS65941_LDO4_STEP 25000 + +#define TPS65941_WD_MODE_REG 0x406 +#define TPS65941_WD_PWRHOLD_MASK BIT(2) + -- 2.25.1