From patchwork Sat Mar 12 07:11:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 1604612 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=wN8+/AnQ; dkim=pass (2048-bit key) header.d=denx.de header.i=@denx.de header.a=rsa-sha256 header.s=phobos-20191101 header.b=tgbVeYD+; 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) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KFvB21NKyz9sG2 for ; Sat, 12 Mar 2022 18:11:54 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9AF4683AE6; Sat, 12 Mar 2022 08:11:41 +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=1647069102; bh=EnX5jQiBITjGUmAvFZ5g0nZG81rWYonwZGJWf7J94/Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=wN8+/AnQGzrfmAVmNjNFgb7oNhY4EspthgpGie6KwPZQqrjBL0cOVrSdO5HfervQ1 b1pYUOLI/Speqd6RLvVvm3izk9e7m+MbPAOAHrqFe45a9psT6nY9lqx7ucNrBkX0bv yNGf2sfS3XqJXXZaX+yINVItGCpGRDynJYd4kZDasVty13uhb7ja41RHPT9ydH1Sf8 UPt5oj/edQjrR0eayg2odJ1qeXC3dEEXotzZa9pJ9lytfjo00BRlXQdmN9Qby+Slkc b79bMbTRedXSB2Nj7u1bLdaxLMitgWGj6XLgIhvkp0LIogI71bUJVfiUdGATWtnqYe PzIzncLNi/sDA== 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 D492783AE6; Sat, 12 Mar 2022 08:11:32 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1647069093; bh=EnX5jQiBITjGUmAvFZ5g0nZG81rWYonwZGJWf7J94/Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tgbVeYD+PvXXIr7LWItxdAMW0JvC0UG3ItB+x+75/oINp2Q0S0v7wIuA/pEDtoy4f IcPftnm+jRh/Y0nRCOFx1pBY5adDEqj/xTBC4k0OqCSqyPsNwO1iSWa7kNS6yT/c7b lwZCAFALdLPBeHkBMtA/RBksGNlMMIZOkb/RuE+1LHWmyA4MZGbf2Zv09kE1mHz8Sl Kt5xbqYjbjzUbRJF6Tcvlirfac+hZ7T9LV/ACwECcJMWaIbNPEtWfJ/m9msgdwZRgl DxVNcR5ZzTO/fKEkqZP5QTaFB7PWsBjwng7v/bj5Y3gHxvlPH7LPNKnC9VSV04GRUL WTPKCMIqIV1Pw== From: Lukasz Majewski To: Tom Rini , u-boot@lists.denx.de Cc: Lukasz Majewski , Bin Meng , Jaehoon Chung , =?utf-8?q?Marek_Beh=C3=BAn?= , Simon Glass Subject: [PATCH v2 2/3] power: pmic: Provide DM_PMIC support for tps65217 driver Date: Sat, 12 Mar 2022 08:11:11 +0100 Message-Id: <20220312071112.5276-2-lukma@denx.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220312071112.5276-1-lukma@denx.de> References: <20220312071112.5276-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. Signed-off-by: Lukasz Majewski Reviewed-by: Jaehoon Chung --- (no changes since v1) drivers/power/pmic/pmic_tps65217.c | 82 ++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) 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