From patchwork Tue Feb 22 08:03:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 1595870 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=denx.de header.i=@denx.de header.a=rsa-sha256 header.s=phobos-20191101 header.b=T5L4vpYs; dkim=pass (2048-bit key) header.d=denx.de header.i=@denx.de header.a=rsa-sha256 header.s=phobos-20191101 header.b=lPTlYZxn; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 4K2sC94hRtz9sGG for ; Tue, 22 Feb 2022 19:04:37 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 573B483C36; Tue, 22 Feb 2022 09:04:25 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1645517065; bh=l76Gx8q5Gnjl2m7cBK1i1VXVcBparFhfeajXPnjo5Ug=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=T5L4vpYsuw3zWJ8WW1wbg0pnIJPPZ60VvHJ+xWman/7MDIC9h+5EMcuEnJyRMcNNS 99Vf1HoY/HT4FE3MqkYR2JUfg0vffeK06RjetgqJkQj+2edPSosW6qUj3ef+m/UnEU u1FwiZaOHUpxdrj/e5SpR7ZDblmEys+Xawn8ZJQ4I8guLguZ0IWmi8Uiw0F7FU5GUX StIq8FNZTB8WVSgbFonOq7WLN44JVnYCU3UwS7Gcg4go3hoBV+/M4Z3ckuUhRxFXYj dbD1gaEy1VInvJW681lWoBRP9Wy39pcwgRQM+ru4ycpIMqNvoTIHSpqgAULcRaYorw lXoeyclTTHJ5g== Received: from localhost.localdomain (85-222-111-42.dynamic.chello.pl [85.222.111.42]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: lukma@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id E4A1F83C36; Tue, 22 Feb 2022 09:04:19 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1645517060; bh=l76Gx8q5Gnjl2m7cBK1i1VXVcBparFhfeajXPnjo5Ug=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lPTlYZxnT2CWDem3xia+GcF6Y3wthCEUW+1Y4u4i00FkecXsw2j0MqPY6pqt4Lu+e WPj6dH2MtK+fawAGWpMy3AQwCMvpMsLIh+mw+w0vAb2yHt6M/DwiwhRzU595x4PdES xczlMktDyS2sXE4OLyEJMDHDDIpBOdXB1suPqeas0tGSRmQ/jDxOc4EQd4XTccz/GH fKErYYmnjJyzWSp806Ibh+eRe7U01R5d3Jxu257ZrzMxHnYTLiE9JZxLhhp8uAh0lX BlWJCVSMbStRTO1QaE2AhQwGNLE15xppoGXUPnL3X74c3yyaXc3OGwpZpH8ZWckio+ j4a/N6/Pq+30Q== From: Lukasz Majewski To: Tom Rini , u-boot@lists.denx.de Cc: Lukasz Majewski , Andre Przywara , Bin Meng , Jaehoon Chung , =?utf-8?q?Marek_Beh=C3=BAn?= , Quentin Schulz , Samuel Holland , Simon Glass , Stephan Gerhold Subject: [PATCH 2/3] power: pmic: Provide DM_PMIC support for tps65217 driver Date: Tue, 22 Feb 2022 09:03:59 +0100 Message-Id: <20220222080401.6859-2-lukma@denx.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220222080401.6859-1-lukma@denx.de> References: <20220222080401.6859-1-lukma@denx.de> 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 tps65217 PMIC driver is used with am335x SoC based designs. It is used in the SPL (MLO) as well, so the DM conversion only is for u-boot proper. This driver only allows simple reading/writing/dumping of the content of its registers and requires the DM_I2C for proper operation. Moreover, new CONFIG_PMIC_TPS65217 has been introduced in Kconfig to be used with boards, which both support DM_PMIC and DM_I2C. Signed-off-by: Lukasz Majewski Reviewed-by: Jaehoon Chung --- drivers/power/pmic/Kconfig | 8 +++ drivers/power/pmic/pmic_tps65217.c | 82 ++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+) diff --git a/drivers/power/pmic/Kconfig b/drivers/power/pmic/Kconfig index ce0adb18a4..c7739228da 100644 --- a/drivers/power/pmic/Kconfig +++ b/drivers/power/pmic/Kconfig @@ -306,6 +306,14 @@ config PMIC_TPS65090 only, and you can enable the regulator/charger drivers separately if required. +config PMIC_TPS65217 + bool "Enable driver for Texas Instruments TPS65217 PMIC" + ---help--- + The TPS65217 is a PMIC containing several LDOs, DC to DC convertors, + FETs and a battery charger. This driver provides register access + only, and you can enable the regulator/charger drivers separately if + required. + config PMIC_PALMAS bool "Enable driver for Texas Instruments PALMAS PMIC" ---help--- diff --git a/drivers/power/pmic/pmic_tps65217.c b/drivers/power/pmic/pmic_tps65217.c index c7f532df4d..ccbf223593 100644 --- a/drivers/power/pmic/pmic_tps65217.c +++ b/drivers/power/pmic/pmic_tps65217.c @@ -6,8 +6,13 @@ #include #include +#include +#include +#include +#include #include +#if !CONFIG_IS_ENABLED(DM_PMIC) struct udevice *tps65217_dev __section(".data") = NULL; /** @@ -148,3 +153,80 @@ int power_tps65217_init(unsigned char bus) #endif return 0; } +#else /* CONFIG_IS_ENABLED(DM_PMIC) */ +static const struct pmic_child_info pmic_children_info[] = { + { .prefix = "ldo", .driver = "tps65217_ldo" }, + { }, +}; + +static int tps65217_reg_count(struct udevice *dev) +{ + return TPS65217_PMIC_NUM_OF_REGS; +} + +static int tps65217_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 tps65217_read(struct udevice *dev, uint reg, uint8_t *buff, int len) +{ + int ret; + + ret = dm_i2c_read(dev, reg, buff, len); + if (ret) { + pr_err("read error %d from device: %p register: %#x!\n", ret, + dev, reg); + return -EIO; + } + + return 0; +} + +static int tps65217_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); + return -ENXIO; + } + + debug("%s: '%s' - found regulators subnode\n", __func__, dev->name); + + children = pmic_bind_children(dev, regulators_node, pmic_children_info); + if (!children) + debug("%s: %s - no child found\n", __func__, dev->name); + + /* Always return success for this device */ + return 0; +} + +static struct dm_pmic_ops tps65217_ops = { + .reg_count = tps65217_reg_count, + .read = tps65217_read, + .write = tps65217_write, +}; + +static const struct udevice_id tps65217_ids[] = { + { .compatible = "ti,tps65217" }, + { } +}; + +U_BOOT_DRIVER(pmic_tps65217) = { + .name = "tps65217 pmic", + .id = UCLASS_PMIC, + .of_match = tps65217_ids, + .bind = tps65217_bind, + .ops = &tps65217_ops, +}; +#endif