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 20184C6FD1D for ; Fri, 7 Apr 2023 13:34:21 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C497986147; Fri, 7 Apr 2023 15:34:03 +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="FHct9ToP"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7A06286113; Fri, 7 Apr 2023 15:33:57 +0200 (CEST) Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) (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 7B5A086078 for ; Fri, 7 Apr 2023 15:33:54 +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-wr1-x42b.google.com with SMTP id j1so3002753wrb.0 for ; Fri, 07 Apr 2023 06:33:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; t=1680874434; x=1683466434; 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=HBniy9kGaWeM+8XF9J/okEUitoqAX4tY2Bi+DimfGV4=; b=FHct9ToPol3y5po5etHWelv72SLdhWo75YaKqjOXZybotlR20XDd9jhtVpLlRnx2VA OrTSlOT03OEApCOvzDWX34F+imWXpUaUQwzbxk5voNJMsmyPlpRfovECJ6bKJ+dXRkSp 9J9YekeLt1P+gip586cghnhD4kRiUls1VIRj2NMjQNfLFVel/qmfAhVxxtz8MJ63nvtR /LAV+4WpIYjtfqz0aKZpqy9cwqhk4Cgf/OBKnu7Pr3gt/iEQTFYHi2tm6XHLnQ1YRha3 7v4oLRE2xeTyUlYzlXCf56kptTJk7vWtN00F3u7RAHWew5DfGJgYwyh832Qnu1jGfl53 RORA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680874434; x=1683466434; 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=HBniy9kGaWeM+8XF9J/okEUitoqAX4tY2Bi+DimfGV4=; b=mhgV2B+wUhMX5h8RIv0ojjBQTFIPAmeb/EWbSwz7PZgcFplN+p7BF99CK+Bu6K1V2e TV1916Ry1OzTjBzzo91dvb57sa1EpVd/ihnqA+FidVA5HdEM5jynUrdErHIiYXVmPwS2 8/03t9EdeWSMkkMWma0HIiIoyUioHg0gmjEEzeLoVnPEF3MYsF38261gemnwcP2bkMQT 8UcbCfBIm/THqmqQh/dfu3Yac67pC2zMorXsHeZ5gJJ7bCN1uFogdz4ecctvA/gHu3bh ju4ImLHIliguIz/CgeoUK7epD0CNCIdJI7bx6eCucDCfq/Op0fT9dQAZP0Jfj+23Kow2 O2qA== X-Gm-Message-State: AAQBX9cIzGvs0V4UT5UrvHkhglb+6uXCslgCUDH+iFzqf3eJrXA3YDQ2 5zDCxjIuzP+zbjZWyIYF94Y0Gg== X-Google-Smtp-Source: AKy350bT878C29lXcdGO2vMpVe5dbUl3QxpHKt+SvTj4WFUijxc5UG+c4rXe9t1DN8w5dbf1MnFL1A== X-Received: by 2002:adf:dd04:0:b0:2cf:eb86:bd90 with SMTP id a4-20020adfdd04000000b002cfeb86bd90mr1357779wrm.63.1680874433901; Fri, 07 Apr 2023 06:33:53 -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 z16-20020a5d4c90000000b002cf1c435afcsm4573138wrs.11.2023.04.07.06.33.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Apr 2023 06:33:53 -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 v2 01/13] drivers: pmic: TPS65941 add support for WD disable Date: Fri, 7 Apr 2023 15:33:35 +0200 Message-Id: <20230407133347.2957435-2-jneanne@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230407133347.2957435-1-jneanne@baylibre.com> References: <20230407133347.2957435-1-jneanne@baylibre.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 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.34.1