From patchwork Tue Oct 15 15:53:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Beckett X-Patchwork-Id: 1177141 X-Patchwork-Delegate: sbabic@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=collabora.com Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 46t0mZ1gK0z9sP7 for ; Wed, 16 Oct 2019 03:11:42 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id CDA0EC21E8A; Tue, 15 Oct 2019 16:01:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=SPF_HELO_PASS, UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 1C976C21C57; Tue, 15 Oct 2019 15:58:57 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 35A6EC21C93; Tue, 15 Oct 2019 15:55:34 +0000 (UTC) Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by lists.denx.de (Postfix) with ESMTPS id EFC4BC21DB5 for ; Tue, 15 Oct 2019 15:55:31 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: bbeckett) with ESMTPSA id 7347828A1AC From: Robert Beckett To: U-Boot Mailing List Date: Tue, 15 Oct 2019 16:53:50 +0100 Message-Id: X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Cc: Ian Ray Subject: [U-Boot] [PATCH 37/37] board: ge: bx50v3: use DM PMIC driver X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 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" Convert the generic i2c PMIC init code to use the new da9063 driver. Signed-off-by: Robert Beckett --- board/ge/bx50v3/bx50v3.c | 81 ++++++++++--------------------------- configs/ge_bx50v3_defconfig | 3 ++ 2 files changed, 24 insertions(+), 60 deletions(-) diff --git a/board/ge/bx50v3/bx50v3.c b/board/ge/bx50v3/bx50v3.c index aa4a3598c6..69057ede19 100644 --- a/board/ge/bx50v3/bx50v3.c +++ b/board/ge/bx50v3/bx50v3.c @@ -13,7 +13,6 @@ #include #include #include -#include #include #include #include @@ -26,7 +25,8 @@ #include #include #include -#include +#include +#include #include #include #include @@ -460,65 +460,26 @@ static const struct boot_mode board_boot_modes[] = { void pmic_init(void) { -#define DA9063_I2C_ADDR 0x58 -#define DA9063_REG_BCORE2_CFG 0x9D -#define DA9063_REG_BCORE1_CFG 0x9E -#define DA9063_REG_BPRO_CFG 0x9F -#define DA9063_REG_BIO_CFG 0xA0 -#define DA9063_REG_BMEM_CFG 0xA1 -#define DA9063_REG_BPERI_CFG 0xA2 -#define DA9063_BUCK_MODE_MASK 0xC0 -#define DA9063_BUCK_MODE_MANUAL 0x00 -#define DA9063_BUCK_MODE_SLEEP 0x40 -#define DA9063_BUCK_MODE_SYNC 0x80 -#define DA9063_BUCK_MODE_AUTO 0xC0 - - uchar val; - struct udevice *dev, *bus; - int ret; - - // TODO: Add a da9063 DM PMIC driver and use that. - ret = uclass_get_device_by_name(UCLASS_I2C, "i2c@21a8000", &bus); - if (ret) { - printf("%s: Unable to get I2C bus: %d\n", __func__, ret); - return; - } - - ret = dm_i2c_probe(bus, DA9063_I2C_ADDR, 0, &dev); - if (ret) { - printf("%s: Unable to get PMIC device: %d\n", __func__, ret); - return; + struct udevice *reg; + int ret, i; + static const char * const bucks[] = { + "bcore1", + "bcore2", + "bpro", + "bmem", + "bio", + "bperi", + }; + + for (i = 0; i < ARRAY_SIZE(bucks); i++) { + ret = regulator_get_by_devname(bucks[i], ®); + if (reg < 0) { + printf("%s(): Unable to get regulator %s: %d\n", + __func__, bucks[i], ret); + continue; + } + regulator_set_mode(reg, DA9063_OPMODE_SYNC); } - - dm_i2c_read(dev, DA9063_REG_BCORE2_CFG, &val, 1); - val &= ~DA9063_BUCK_MODE_MASK; - val |= DA9063_BUCK_MODE_SYNC; - dm_i2c_write(dev, DA9063_REG_BCORE2_CFG, &val, 1); - - dm_i2c_read(dev, DA9063_REG_BCORE1_CFG, &val, 1); - val &= ~DA9063_BUCK_MODE_MASK; - val |= DA9063_BUCK_MODE_SYNC; - dm_i2c_write(dev, DA9063_REG_BCORE1_CFG, &val, 1); - - dm_i2c_read(dev, DA9063_REG_BPRO_CFG, &val, 1); - val &= ~DA9063_BUCK_MODE_MASK; - val |= DA9063_BUCK_MODE_SYNC; - dm_i2c_write(dev, DA9063_REG_BPRO_CFG, &val, 1); - - dm_i2c_read(dev, DA9063_REG_BIO_CFG, &val, 1); - val &= ~DA9063_BUCK_MODE_MASK; - val |= DA9063_BUCK_MODE_SYNC; - dm_i2c_write(dev, DA9063_REG_BIO_CFG, &val, 1); - - dm_i2c_read(dev, DA9063_REG_BMEM_CFG, &val, 1); - val &= ~DA9063_BUCK_MODE_MASK; - val |= DA9063_BUCK_MODE_SYNC; - dm_i2c_write(dev, DA9063_REG_BMEM_CFG, &val, 1); - - dm_i2c_read(dev, DA9063_REG_BPERI_CFG, &val, 1); - val &= ~DA9063_BUCK_MODE_MASK; - val |= DA9063_BUCK_MODE_SYNC; - dm_i2c_write(dev, DA9063_REG_BPERI_CFG, &val, 1); } int board_late_init(void) diff --git a/configs/ge_bx50v3_defconfig b/configs/ge_bx50v3_defconfig index 8acb41c046..e9ef2de24f 100644 --- a/configs/ge_bx50v3_defconfig +++ b/configs/ge_bx50v3_defconfig @@ -61,8 +61,11 @@ CONFIG_PINCTRL=y CONFIG_PINCTRL_IMX6=y CONFIG_PWM_IMX=y CONFIG_DM_PWM=y +CONFIG_DM_PMIC=y +CONFIG_DM_PMIC_DA9063=y CONFIG_DM_REGULATOR=y CONFIG_DM_REGULATOR_FIXED=y +CONFIG_DM_REGULATOR_DA9063=y CONFIG_DM_RTC=y CONFIG_RTC_RX8010SJ=y # CONFIG_REQUIRE_SERIAL_CONSOLE is not set