From patchwork Wed Apr 27 11:28:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 1622971 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=baylibre-com.20210112.gappssmtp.com header.i=@baylibre-com.20210112.gappssmtp.com header.a=rsa-sha256 header.s=20210112 header.b=oOZ3hn7U; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KpGjD6ZpVz9s3q for ; Wed, 27 Apr 2022 21:28:48 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6E8C483E15; Wed, 27 Apr 2022 13:28:45 +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="oOZ3hn7U"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2CC4C83C05; Wed, 27 Apr 2022 13:28:29 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 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 4AEEE83D3D for ; Wed, 27 Apr 2022 13:28:25 +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=narmstrong@baylibre.com Received: by mail-wr1-x42b.google.com with SMTP id e24so2037657wrc.9 for ; Wed, 27 Apr 2022 04:28:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GWu4PuE0OLhX6ez4WasiUpS7u/QoUQRROpTewumoq48=; b=oOZ3hn7UiTGM2XO0hlEOoYoWTcZB1RPXiQ09UObjRnv+ZZPngCwUwgrKC5Mrp9Fz/+ I3yI25p+UkpNYFXupCK9IWk7OqvYK9CHSNkDIgoneLquvQhqDBbj4gBAnnN8BNFP90Rj JA9Kln6X1kXUlrHDPYR6cEiqO2+UKqQH809tbGHHXXRNdcwh3DFJVsugcJ6z5H8HgLjt 25Nmd3wjq+RqjJEQo/e1iveRpU0gtWidvp7r4T0grBnk0r8GfSsjM3XoRW59QMdJKRuM uLTb623TSKSgTWu9S3tqktTL2mIn03zF966ykhsP0mnaC99tXGg2g6JvSRPVKlKO1QHI XVyA== 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=GWu4PuE0OLhX6ez4WasiUpS7u/QoUQRROpTewumoq48=; b=SNMDOtFJJY40o0jyzpByKwandeIvvA4IPE2bcaJ3Zf6sJd0rHx3sf0CtoCHZ6JGy0U iLfK5IH2pr5a9A1Pb4PWbCVVv/Q+u61LZo4n/6jX6/k0PvGlnRXm/vgMTpyWFBRgV1jR HHu9Y6+tk2/sfN/OGA9LMXeQYOFZJC47tjxNJKj0gVXvz7nn/5pfullQeCJCHIb9u6n0 6qCa4hlQNjf5bDknF78Ww9b3XabFqN/CiNcuHSa/L+L2Eb1vKNpBfdGkbVNGdVrXyT2B kPa//KNnhF/ljohPiV7cjcgGvBySc1YNnGmjgj2gEJzqnY7UYd6LoAMBgUAtH12phusn mHFw== X-Gm-Message-State: AOAM533wxEh1I6bDouzMHCy7zNyxWw4ORizWMDCHvlRYUhSya6Gh930/ WApwZXknW/LXkA5y8/VPa1JE7d49FJOWUw== X-Google-Smtp-Source: ABdhPJxlNCLxVY3DCHNuNv5IX1w5UMkl2sFssTnLmK7rt45XL+xl7ApQeP7spDXQ/5I/mcznD2e5Bw== X-Received: by 2002:adf:f4c5:0:b0:20a:ece1:1e91 with SMTP id h5-20020adff4c5000000b0020aece11e91mr3090864wrp.172.1651058904769; Wed, 27 Apr 2022 04:28:24 -0700 (PDT) Received: from localhost.localdomain ([2001:861:44c0:66c0:b735:88a0:c43a:20c8]) by smtp.gmail.com with ESMTPSA id u19-20020a05600c19d300b00393f081d49fsm1452622wmq.2.2022.04.27.04.28.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 04:28:23 -0700 (PDT) From: Neil Armstrong To: d-gerlach@ti.com, jh80.chung@samsung.com Cc: u-boot@lists.denx.de, khilman@baylibre.com, Neil Armstrong Subject: [PATCH 1/4] power: add driver for the TPS65219 PMIC Date: Wed, 27 Apr 2022 13:28:09 +0200 Message-Id: <20220427112812.2991816-2-narmstrong@baylibre.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220427112812.2991816-1-narmstrong@baylibre.com> References: <20220427112812.2991816-1-narmstrong@baylibre.com> MIME-Version: 1.0 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.5 at phobos.denx.de X-Virus-Status: Clean The TPS65219 I2S PMIC features 3 Buck converters and 4 linear regulators, 2 GPOs, 1 GPIO, and 3 multi-function-pin. This adds the PMIC driver, loading the regulator sub-nodes. Signed-off-by: Neil Armstrong --- drivers/power/pmic/Kconfig | 6 +++ drivers/power/pmic/Makefile | 1 + drivers/power/pmic/tps65219.c | 88 +++++++++++++++++++++++++++++++++++ include/power/tps65219.h | 46 ++++++++++++++++++ 4 files changed, 141 insertions(+) create mode 100644 drivers/power/pmic/tps65219.c create mode 100644 include/power/tps65219.h diff --git a/drivers/power/pmic/Kconfig b/drivers/power/pmic/Kconfig index 953c92e212..bb3960020d 100644 --- a/drivers/power/pmic/Kconfig +++ b/drivers/power/pmic/Kconfig @@ -367,6 +367,12 @@ config PMIC_TPS65941 The TPS65941 is a PMIC containing a bunch of SMPS & LDOs. This driver binds the pmic children. +config PMIC_TPS65219 + bool "Enable driver for Texas Instruments TPS65219 PMIC" + depends on DM_PMIC + help + The TPS65219 is a PMIC containing a bunch of SMPS & LDOs. + This driver binds the pmic children. endif config PMIC_TPS65217 diff --git a/drivers/power/pmic/Makefile b/drivers/power/pmic/Makefile index 584d6e0e78..f73b326255 100644 --- a/drivers/power/pmic/Makefile +++ b/drivers/power/pmic/Makefile @@ -43,3 +43,4 @@ obj-$(CONFIG_POWER_TPS65910) += pmic_tps65910.o obj-$(CONFIG_POWER_HI6553) += pmic_hi6553.o obj-$(CONFIG_POWER_MC34VR500) += pmic_mc34vr500.o obj-$(CONFIG_PMIC_TPS65941) += tps65941.o +obj-$(CONFIG_PMIC_TPS65219) += tps65219.o diff --git a/drivers/power/pmic/tps65219.c b/drivers/power/pmic/tps65219.c new file mode 100644 index 0000000000..9462afee77 --- /dev/null +++ b/drivers/power/pmic/tps65219.c @@ -0,0 +1,88 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * (C) Copyright 2022 BayLibre, SAS + * Author: Neil Armstrong + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static const struct pmic_child_info pmic_children_info[] = { + { .prefix = "ldo", .driver = TPS65219_LDO_DRIVER }, + { .prefix = "buck", .driver = TPS65219_BUCK_DRIVER }, + { }, +}; + +static int tps65219_reg_count(struct udevice *dev) +{ + return 0x41; +} + +static int tps65219_write(struct udevice *dev, uint reg, const uint8_t *buff, + int len) +{ + if (dm_i2c_write(dev, reg, buff, len)) { + pr_err("write error to device: %p register: %#x!\n", dev, reg); + return -EIO; + } + + return 0; +} + +static int tps65219_read(struct udevice *dev, uint reg, uint8_t *buff, int len) +{ + if (dm_i2c_read(dev, reg, buff, len)) { + pr_err("read error from device: %p register: %#x!\n", dev, reg); + return -EIO; + } + + return 0; +} + +static int tps65219_bind(struct udevice *dev) +{ + ofnode regulators_node; + int children; + + regulators_node = dev_read_subnode(dev, "regulators"); + if (!ofnode_valid(regulators_node)) { + debug("%s: %s regulators subnode not found!\n", __func__, + dev->name); + } + + debug("%s: '%s' - found regulators subnode\n", __func__, dev->name); + + children = pmic_bind_children(dev, regulators_node, pmic_children_info); + if (!children) + printf("%s: %s - no child found\n", __func__, dev->name); + + /* Probe all the child devices */ + return dm_scan_fdt_dev(dev); +} + +static struct dm_pmic_ops tps65219_ops = { + .reg_count = tps65219_reg_count, + .read = tps65219_read, + .write = tps65219_write, +}; + +static const struct udevice_id tps65219_ids[] = { + { .compatible = "ti,tps65219" }, + { } +}; + +U_BOOT_DRIVER(pmic_tps65219) = { + .name = "tps65219_pmic", + .id = UCLASS_PMIC, + .of_match = tps65219_ids, + .bind = tps65219_bind, + .ops = &tps65219_ops, +}; diff --git a/include/power/tps65219.h b/include/power/tps65219.h new file mode 100644 index 0000000000..aa81b92266 --- /dev/null +++ b/include/power/tps65219.h @@ -0,0 +1,46 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * (C) Copyright 2022 BayLibre, SAS + * Author: Neil Armstrong + */ + +#ifndef TPS65219_H +#define TPS65219_H + +/* I2C device address for pmic tps65219 */ +#define TPS65219_I2C_ADDR 0x30 +#define TPS65219_LDO_NUM 4 +#define TPS65219_BUCK_NUM 3 + +/* Drivers name */ +#define TPS65219_LDO_DRIVER "tps65219_ldo" +#define TPS65219_BUCK_DRIVER "tps65219_buck" + +#define TPS65219_VOLT_MASK 0x3F +#define TPS65219_BUCK_VOLT_MAX 3400000 + +#define TPS65219_ENABLE_CTRL_REG 0x2 + +#define TPS65219_BUCK1_VOUT_REG 0xa +#define TPS65219_BUCK2_VOUT_REG 0x9 +#define TPS65219_BUCK3_VOUT_REG 0x8 + +#define TPS65219_LDO1_VOUT_REG 0x7 +#define TPS65219_LDO2_VOUT_REG 0x6 + +#define TPS65219_LDO12_BYP_CONFIG 6 + +#define TPS65219_LDO3_VOUT_REG 0x5 +#define TPS65219_LDO4_VOUT_REG 0x4 + +#define TPS65219_LDO12_VOLT_BYP_MIN 1500000 +#define TPS65219_LDO12_VOLT_MIN 600000 +#define TPS65219_LDO12_VOLT_MAX 3400000 +#define TPS65219_LDO12_VOLT_REG_MIN 0 +#define TPS65219_LDO12_VOLT_REG_MAX 0x56 +#define TPS65219_LDO34_VOLT_MIN 1200000 +#define TPS65219_LDO34_VOLT_MAX 3300000 +#define TPS65219_LDO34_VOLT_REG_MIN 0x12 +#define TPS65219_LDO34_VOLT_REG_MAX 0x54 + +#endif /* TPS65219_H */