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 0A585C001B0 for ; Mon, 24 Jul 2023 10:24:15 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CE7F486888; Mon, 24 Jul 2023 12:23:29 +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="jF3x7xFx"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 96F7D86709; Mon, 24 Jul 2023 12:23:21 +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 8FB868686F for ; Mon, 24 Jul 2023 12:23:18 +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-4fba74870abso6125079e87.0 for ; Mon, 24 Jul 2023 03:23:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690194198; x=1690798998; 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=nXpH/PH73XN4/azY1VQluOb8zBuSHDZaA7OgqMgd+DY=; b=jF3x7xFxkH3WsCregshRQ5zOSMEKnmUU8XwwXWIncXzyyLqkaOhpS1cwzVnKKQ5VVK XP1qdJ96TS3muN/ZCqcEj68K8W6nDVUHlUzdr0k/XyrO9HjNKYvo7rl6WpRsa0s0kPgA wSnWehMeh/jHUGWonf7qei/uRSsUb4bk2f/Csw5bot/efvd9shlD8VvXsuR8aS0RPmdB M3TTzj+h0KfJOjDr7HiHadZI62lx19C5A3Pmmnba3uE9j6kpf02ZcOGFEfpWZ4W4dqeq UOcdO4f327nkrM15kqUTRqTcv8zbeGWPkzOZSw3YFjITxsHn/YB78CbM0I4fv01yc0GV kZEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690194198; x=1690798998; 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=nXpH/PH73XN4/azY1VQluOb8zBuSHDZaA7OgqMgd+DY=; b=IlbpUoXvV8371kHJ3L0Ypv46UG0hqwMTsJBTPsnE+3vyTCrqb4NLtcNMjQZsjs6/yi C89L6GDjjfJ+IsjGi0uCb8OgS/mJHPGmRrO+rNOEctht66itoKdi1++VrqBfVnzhUbJx hmbXEDs98s/cmzRAubumtILy80cRoP9vQaJCMzEWWgOgCj8YOdnlMoHSSO5ixIcZ08FU 5ela+P+2OYbtzCOlimQ/zQnIMGQbwBTkWOcP20y9vFu2q6/JoG8JsyPpGMXJpZ6HQTlU 3Y4qQxwhgPmZyIY2Q2RT4ilY/ITvJl/Dmn1NTYgPEK5BH3yRtqE/+Ru41z0vnGCq5rmv 6oUQ== X-Gm-Message-State: ABy/qLbF73cbCKsMQb/9aI/nj8Toi0q0PGalaNwIYp4iHQw8CnGKkG49 Gob2twOeicfNUZaCUGrwhTI= X-Google-Smtp-Source: APBJJlF78UfNK6KplsztMIyWI6KNxoxEVMR+noCM4qAoUrAFjE091z1LCSMFxN19W+jsQ/R+iVQmAQ== X-Received: by 2002:a05:6512:3295:b0:4fb:976f:c3ed with SMTP id p21-20020a056512329500b004fb976fc3edmr4107994lfe.69.1690194197670; Mon, 24 Jul 2023 03:23:17 -0700 (PDT) Received: from xeon.. ([188.163.112.48]) by smtp.gmail.com with ESMTPSA id q10-20020ac2510a000000b004fdc8b0ee13sm2147054lfb.172.2023.07.24.03.23.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jul 2023 03:23:17 -0700 (PDT) From: Svyatoslav Ryhel To: Jaehoon Chung , Simon Glass , Svyatoslav Ryhel Cc: u-boot@lists.denx.de Subject: [PATCH v4 6/7] power: pmic: tps65910: add TPS65911 PMIC support Date: Mon, 24 Jul 2023 13:22:43 +0300 Message-Id: <20230724102244.14747-7-clamor95@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230724102244.14747-1-clamor95@gmail.com> References: <20230724102244.14747-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 Add support to bind the regulators/child nodes with the pmic. Also adds the pmic i2c based read/write functions to access pmic registers. Signed-off-by: Svyatoslav Ryhel Reviewed-by: Simon Glass --- doc/device-tree-bindings/pmic/tps65911.txt | 78 ++++++++++++++++++++++ drivers/power/pmic/pmic_tps65910_dm.c | 26 +++++++- include/power/tps65910_pmic.h | 47 +++++++++++++ 3 files changed, 148 insertions(+), 3 deletions(-) create mode 100644 doc/device-tree-bindings/pmic/tps65911.txt diff --git a/doc/device-tree-bindings/pmic/tps65911.txt b/doc/device-tree-bindings/pmic/tps65911.txt new file mode 100644 index 0000000000..29270efbfe --- /dev/null +++ b/doc/device-tree-bindings/pmic/tps65911.txt @@ -0,0 +1,78 @@ +Texas Instruments, TPS65911 PMIC + +This device uses two drivers: +- drivers/power/pmic/tps65910.c (for parent device) +- drivers/power/regulator/tps65911_regulator.c (for child regulators) + +This chapter describes the binding info for the PMIC driver and regulators. + +Required properties for PMIC: +- compatible: "ti,tps65911" +- reg: 0x2d + +With those two properties, the pmic device can be used for read/write only. +To bind each regulator, the optional regulators subnode should exists. + +Optional subnode: +- name: regulators (subnode list of each device's regulator) + +Regulators subnode contains set on supported regulators. + +Required properties: +- regulator-name: used for regulator uclass platform data '.name', + +List of supported regulator nodes names for tps65911: +- vdd1, vdd2, vddctrl, vddio +- ldo1, ldo2, ldo3, ldo4, ldo5, ldo6, ldo7, ldo8 + +vddio in datasheet is referred as vio, but for reduction of code and +unification of smps regulators it is named vddio. + +Optional: +- regulator-min-microvolt: minimum allowed Voltage to set +- regulator-max-microvolt: minimum allowed Voltage to set +- regulator-always-on: regulator should be never disabled +- regulator-boot-on: regulator should be enabled by the bootloader + +Example: + +tps65911@2d { + compatible = "ti,tps65911"; + reg = <0x2d>; + + regulators { + vdd1 { + regulator-name = "vdd_1v2_backlight"; + regulator-min-microvolt = <1200000>; + regulator-max-microvolt = <1200000>; + regulator-always-on; + regulator-boot-on; + }; + + ... + + vddio { + regulator-name = "vdd_1v8_gen"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + regulator-always-on; + regulator-boot-on; + }; + + ldo1 { + regulator-name = "vdd_emmc_core"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + regulator-always-on; + regulator-boot-on; + }; + + ... + + ldo8 { + regulator-name = "vdd_ddr_hs"; + regulator-min-microvolt = <1000000>; + regulator-max-microvolt = <1000000>; + }; + }; +}; diff --git a/drivers/power/pmic/pmic_tps65910_dm.c b/drivers/power/pmic/pmic_tps65910_dm.c index e03ddc98d7..ff63c502d0 100644 --- a/drivers/power/pmic/pmic_tps65910_dm.c +++ b/drivers/power/pmic/pmic_tps65910_dm.c @@ -11,13 +11,19 @@ #include #include -static const struct pmic_child_info pmic_children_info[] = { +static const struct pmic_child_info tps65910_children_info[] = { { .prefix = "ldo_", .driver = TPS65910_LDO_DRIVER }, { .prefix = "buck_", .driver = TPS65910_BUCK_DRIVER }, { .prefix = "boost_", .driver = TPS65910_BOOST_DRIVER }, { }, }; +static const struct pmic_child_info tps65911_children_info[] = { + { .prefix = "ldo", .driver = TPS65911_LDO_DRIVER }, + { .prefix = "vdd", .driver = TPS65911_VDD_DRIVER }, + { }, +}; + static int pmic_tps65910_reg_count(struct udevice *dev) { return TPS65910_NUM_REGS; @@ -51,6 +57,7 @@ static int pmic_tps65910_bind(struct udevice *dev) { ofnode regulators_node; int children; + int type = dev_get_driver_data(dev); regulators_node = dev_read_subnode(dev, "regulators"); if (!ofnode_valid(regulators_node)) { @@ -58,7 +65,19 @@ static int pmic_tps65910_bind(struct udevice *dev) return -EINVAL; } - children = pmic_bind_children(dev, regulators_node, pmic_children_info); + switch (type) { + case TPS65910: + children = pmic_bind_children(dev, regulators_node, + tps65910_children_info); + break; + case TPS65911: + children = pmic_bind_children(dev, regulators_node, + tps65911_children_info); + break; + default: + log_err("unknown PMIC type\n"); + } + if (!children) debug("%s has no children (regulators)\n", dev->name); @@ -82,7 +101,8 @@ static struct dm_pmic_ops pmic_tps65910_ops = { }; static const struct udevice_id pmic_tps65910_match[] = { - { .compatible = "ti,tps65910" }, + { .compatible = "ti,tps65910", .data = TPS65910 }, + { .compatible = "ti,tps65911", .data = TPS65911 }, { /* sentinel */ } }; diff --git a/include/power/tps65910_pmic.h b/include/power/tps65910_pmic.h index 66214786d3..10fe02b81a 100644 --- a/include/power/tps65910_pmic.h +++ b/include/power/tps65910_pmic.h @@ -6,6 +6,9 @@ #ifndef __TPS65910_PMIC_H_ #define __TPS65910_PMIC_H_ +#define TPS65910 1 +#define TPS65911 2 + #define TPS65910_I2C_SEL_MASK (0x1 << 4) #define TPS65910_VDD_SR_MASK (0x1 << 7) #define TPS65910_GAIN_SEL_MASK (0x3 << 6) @@ -126,4 +129,48 @@ struct tps65910_regulator_pdata { #define TPS65910_BOOST_DRIVER "tps65910_boost" #define TPS65910_LDO_DRIVER "tps65910_ldo" +/* tps65911 i2c registers */ +enum { + TPS65911_REG_VIO = 0x20, + TPS65911_REG_VDD1, + TPS65911_REG_VDD1_OP, + TPS65911_REG_VDD1_SR, + TPS65911_REG_VDD2, + TPS65911_REG_VDD2_OP, + TPS65911_REG_VDD2_SR, + TPS65911_REG_VDDCTRL, + TPS65911_REG_VDDCTRL_OP, + TPS65911_REG_VDDCTRL_SR, + TPS65911_REG_LDO1 = 0x30, + TPS65911_REG_LDO2, + TPS65911_REG_LDO5, + TPS65911_REG_LDO8, + TPS65911_REG_LDO7, + TPS65911_REG_LDO6, + TPS65911_REG_LDO4, + TPS65911_REG_LDO3, +}; + +#define TPS65911_VDD_NUM 4 +#define TPS65911_LDO_NUM 8 + +#define TPS65911_VDD_VOLT_MAX 1500000 +#define TPS65911_VDD_VOLT_MIN 600000 +#define TPS65911_VDD_VOLT_BASE 562500 + +#define TPS65911_LDO_VOLT_MAX 3300000 +#define TPS65911_LDO_VOLT_BASE 800000 + +#define TPS65911_LDO_SEL_MASK (0x3f << 2) + +#define TPS65911_LDO124_VOLT_MAX_HEX 0x32 +#define TPS65911_LDO358_VOLT_MAX_HEX 0x19 +#define TPS65911_LDO358_VOLT_MIN_HEX 0x02 + +#define TPS65911_LDO124_VOLT_STEP 50000 +#define TPS65911_LDO358_VOLT_STEP 100000 + +#define TPS65911_VDD_DRIVER "tps65911_vdd" +#define TPS65911_LDO_DRIVER "tps65911_ldo" + #endif /* __TPS65910_PMIC_H_ */ -- 2.39.2