Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2195223/?format=api
{ "id": 2195223, "url": "http://patchwork.ozlabs.org/api/patches/2195223/?format=api", "web_url": "http://patchwork.ozlabs.org/project/uboot/patch/20260210151459.2348758-16-raymondmaoca@gmail.com/", "project": { "id": 18, "url": "http://patchwork.ozlabs.org/api/projects/18/?format=api", "name": "U-Boot", "link_name": "uboot", "list_id": "u-boot.lists.denx.de", "list_email": "u-boot@lists.denx.de", "web_url": null, "scm_url": null, "webscm_url": null, "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20260210151459.2348758-16-raymondmaoca@gmail.com>", "list_archive_url": null, "date": "2026-02-10T15:14:58", "name": "[v2,15/16] power: regulator: add support for Spacemit P1 SoC", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "59a0f43a7f8285fe7bbfaa287b22e3e40227b7ee", "submitter": { "id": 91989, "url": "http://patchwork.ozlabs.org/api/people/91989/?format=api", "name": "Raymond Mao", "email": "raymondmaoca@gmail.com" }, "delegate": { "id": 20174, "url": "http://patchwork.ozlabs.org/api/users/20174/?format=api", "username": "Andes", "first_name": "Andes", "last_name": "", "email": "uboot@andestech.com" }, "mbox": "http://patchwork.ozlabs.org/project/uboot/patch/20260210151459.2348758-16-raymondmaoca@gmail.com/mbox/", "series": [ { "id": 491690, "url": "http://patchwork.ozlabs.org/api/series/491690/?format=api", "web_url": "http://patchwork.ozlabs.org/project/uboot/list/?series=491690", "date": "2026-02-10T15:14:43", "name": "Add board support for Spacemit K1 SoC in SPL", "version": 2, "mbox": "http://patchwork.ozlabs.org/series/491690/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2195223/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2195223/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<u-boot-bounces@lists.denx.de>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@legolas.ozlabs.org", "Authentication-Results": [ "legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256\n header.s=20230601 header.b=dccDsxPe;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de\n (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de;\n envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org)", "phobos.denx.de;\n dmarc=pass (p=none dis=none) header.from=gmail.com", "phobos.denx.de;\n spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de", "phobos.denx.de;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=gmail.com header.i=@gmail.com header.b=\"dccDsxPe\";\n\tdkim-atps=neutral", "phobos.denx.de;\n dmarc=pass (p=none dis=none) header.from=gmail.com", "phobos.denx.de;\n spf=pass smtp.mailfrom=raymondmaoca@gmail.com" ], "Received": [ "from phobos.denx.de (phobos.denx.de\n [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4f9QDP5bJYz1xwG\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 11 Feb 2026 02:17:57 +1100 (AEDT)", "from h2850616.stratoserver.net (localhost [IPv6:::1])\n\tby phobos.denx.de (Postfix) with ESMTP id D45E383E83;\n\tTue, 10 Feb 2026 16:15:57 +0100 (CET)", "by phobos.denx.de (Postfix, from userid 109)\n id E186F83E83; Tue, 10 Feb 2026 16:15:56 +0100 (CET)", "from mail-qv1-xf2d.google.com (mail-qv1-xf2d.google.com\n [IPv6:2607:f8b0:4864:20::f2d])\n (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits))\n (No client certificate requested)\n by phobos.denx.de (Postfix) with ESMTPS id 75C7683CF3\n for <u-boot@lists.denx.de>; Tue, 10 Feb 2026 16:15:54 +0100 (CET)", "by mail-qv1-xf2d.google.com with SMTP id\n 6a1803df08f44-896f632d206so27473086d6.0\n for <u-boot@lists.denx.de>; Tue, 10 Feb 2026 07:15:54 -0800 (PST)", "from ubuntu.localdomain (174-138-202-16.cpe.distributel.net.\n [174.138.202.16]) by smtp.gmail.com with ESMTPSA id\n 6a1803df08f44-8953c057751sm101019286d6.43.2026.02.10.07.15.51\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Tue, 10 Feb 2026 07:15:52 -0800 (PST)" ], "X-Spam-Checker-Version": "SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de", "X-Spam-Level": "", "X-Spam-Status": "No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,\n DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_GMAIL_RCVD,FREEMAIL_FROM,\n RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=no\n autolearn_force=no version=3.4.2", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=gmail.com; s=20230601; t=1770736553; x=1771341353; darn=lists.denx.de;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:from:to:cc:subject:date\n :message-id:reply-to;\n bh=fAetLzgLBQ1yxUG2kf9nroCVFI+O5nNhtfX8H4GbgYA=;\n b=dccDsxPeoaYEebF3fVA7hBY9syPB111uQBaM9iXWJylS6zycKSv5G4kzgxWlKpcsph\n S03DGpMk4vrCqbhb8JARwyxOFZ/gkb8oTA/1VRFRca8dfwl2XY9PW6sopRrft2gM81mf\n TaJM94NaeOL0QZmat0c839hn5N9IAzWdFuRl+MTXFNUiK6G2g9RF+kc5MfZ6lLmoX6U5\n Q4cS5RITyzAF7v2WBd2/wyH4GRtyYqAWZC5fD1agZjwlBiygsWzyNkmqLRnzLM4F3w7z\n tG+Phh66j0wseospZPqTeHAHS1MpwYNwOmmKbnCKmwPrNsH+sboXtW6qHSOp4zIOdKKZ\n 6sfw==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20230601; t=1770736553; x=1771341353;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from\n :to:cc:subject:date:message-id:reply-to;\n bh=fAetLzgLBQ1yxUG2kf9nroCVFI+O5nNhtfX8H4GbgYA=;\n b=a+oglbNFDa3V++Il/O3sHuYZbXNgzB4hhZSVEoWHVQ+yniR1mcxDRCsLyHnPG89LXa\n ZlxYYoRyrv0+2oXKhOyEoNcQQjhRnfW+iRwSMUE6P7h6xhBp7ZgBcOmb3gt2P66KaoGj\n nvU9baryNsMJo8VPcRIUNUoqlGR/we5lK6wd1piozGi3AG1Dl+ZdE2Y7f+2d6QQ4WucK\n iDCdVrakMGfxUDxr30mukgENLGCbPd+lZE8IWtS7HmYT6p1RGWYL8YCi6fZtbvce0HUu\n yrS1DBhA89swCxGRE9Y6TfhnfRw1gk0wTb3/y6Uk9Sed3hEKqpUHh+G1IJCQPlS13mKd\n KG7A==", "X-Gm-Message-State": "AOJu0YzsudbzINW8Nh9el4wJcW9svwhCr2c2u0w8i0QiPoyULB8Qutjh\n NssQXbKgmzRU5G5hUK90F9wzkx8p6TsTzWOZDIh0zDO7e2kaWI684EgXd/GPiw==", "X-Gm-Gg": "AZuq6aLRwS0GrV6Nr3eN9Ee6IwTjQtCpx7RTSZnfnNiKumJtX8kUN8yy4XefAkpw2rK\n PP4dothMhdipY/zU1XlZUfRgya7vFzuIzyYkXZdS9x7n2vZzW2KaRl59mGRo4A0wzZvB+Gp3dGz\n T1s5EV3L9WbIXNC7olKTrfC+iQ84pVyATJzV3CatQpAFbHDdpzMooVwzSB4Osl01Ty9hDxxho00\n CX62O5EOPeSF/zTJMiGD9skO/RBsgAeDqV9mDtX/fxgHmbkJFeCNkGWRAk9i1PAwue4lEqRxurg\n drVARZk21dqnoIjFVYSdajLb3uh+dWq7kx6Ax8RYnP4f295HldZecBV2ZD9BZnYK/vrXXXSiqxg\n fNFV+k2yKTl3PotyQ0vGoIbInVU3/pMQjm9P+Osh1s/2Vx66+BGZl0pVHAFUBtcbVoZtE2V6eo1\n JgoOeJJFvfKCrVGYGpgI4CjS7gMsae3OuT+MPHR2d5gEdEXjiMJPUojVYGqriWvxdeAwYcY/Zd3\n aF59nn01n8=", "X-Received": "by 2002:a05:6214:1d29:b0:895:d679:ecde with SMTP id\n 6a1803df08f44-8970d8bbc5cmr35102096d6.27.1770736552990;\n Tue, 10 Feb 2026 07:15:52 -0800 (PST)", "From": "Raymond Mao <raymondmaoca@gmail.com>", "To": "u-boot@lists.denx.de", "Cc": "uboot@riscstar.com, u-boot-spacemit@groups.io, raymond.mao@riscstar.com,\n rick@andestech.com, ycliang@andestech.com, trini@konsulko.com,\n lukma@denx.de, hs@nabladev.com, jh80.chung@samsung.com, peng.fan@nxp.com,\n xypron.glpk@gmx.de, randolph@andestech.com, dlan@gentoo.org,\n junhui.liu@pigmoral.tech, neil.armstrong@linaro.org,\n quentin.schulz@cherry.de, samuel@sholland.org, raymondmaoca@gmail.com", "Subject": "[PATCH v2 15/16] power: regulator: add support for Spacemit P1 SoC", "Date": "Tue, 10 Feb 2026 10:14:58 -0500", "Message-Id": "<20260210151459.2348758-16-raymondmaoca@gmail.com>", "X-Mailer": "git-send-email 2.25.1", "In-Reply-To": "<20260210151459.2348758-1-raymondmaoca@gmail.com>", "References": "<20260210151459.2348758-1-raymondmaoca@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 <u-boot.lists.denx.de>", "List-Unsubscribe": "<https://lists.denx.de/options/u-boot>,\n <mailto:u-boot-request@lists.denx.de?subject=unsubscribe>", "List-Archive": "<https://lists.denx.de/pipermail/u-boot/>", "List-Post": "<mailto:u-boot@lists.denx.de>", "List-Help": "<mailto:u-boot-request@lists.denx.de?subject=help>", "List-Subscribe": "<https://lists.denx.de/listinfo/u-boot>,\n <mailto:u-boot-request@lists.denx.de?subject=subscribe>", "Errors-To": "u-boot-bounces@lists.denx.de", "Sender": "\"U-Boot\" <u-boot-bounces@lists.denx.de>", "X-Virus-Scanned": "clamav-milter 0.103.8 at phobos.denx.de", "X-Virus-Status": "Clean" }, "content": "From: Raymond Mao <raymond.mao@riscstar.com>\n\nSupport voltage regulator for Spacemit P1 SoC. It contains 6 BUCKs\nand 11 LDOs.\n\nSigned-off-by: Raymond Mao <raymond.mao@riscstar.com>\n---\n drivers/power/regulator/Kconfig | 15 +\n drivers/power/regulator/Makefile | 1 +\n .../power/regulator/spacemit_p1_regulator.c | 460 ++++++++++++++++++\n 3 files changed, 476 insertions(+)\n create mode 100644 drivers/power/regulator/spacemit_p1_regulator.c", "diff": "diff --git a/drivers/power/regulator/Kconfig b/drivers/power/regulator/Kconfig\nindex c6da459a212..182510581c0 100644\n--- a/drivers/power/regulator/Kconfig\n+++ b/drivers/power/regulator/Kconfig\n@@ -520,3 +520,18 @@ config DM_REGULATOR_CPCAP\n \tREGULATOR CPCAP. The driver supports both DC-to-DC Step-Down Switching\n \t(SW) Regulators and Low-Dropout Linear (LDO) Regulators\tfound in CPCAP\n \tPMIC and implements get/set api for voltage and state.\n+\n+config DM_REGULATOR_SPACEMIT_P1\n+\tbool \"Enable driver for Spacemit P1 PMIC regulators\"\n+\tdepends on DM_REGULATOR && PMIC_SPACEMIT_P1\n+\thelp\n+\t Enable implementation of driver-model regulator uclass features\n+\t for regulator P1. The driver supports BUCKs, LDOs and SWITCHes.\n+\n+config SPL_DM_REGULATOR_SPACEMIT_P1\n+\tbool \"Enable driver for Spacemit P1 PMIC regulators in SPL\"\n+\tdepends on SPL_DM_REGULATOR && SPL_PMIC_SPACEMIT_P1\n+\thelp\n+\t Enable implementation of driver-model regulator uclass features\n+\t for regulator P1 in SPL. The driver supports BUCKs, LDOs and\n+\t SWITCHes.\ndiff --git a/drivers/power/regulator/Makefile b/drivers/power/regulator/Makefile\nindex ee8f56ea3b9..2a586e42f5c 100644\n--- a/drivers/power/regulator/Makefile\n+++ b/drivers/power/regulator/Makefile\n@@ -47,3 +47,4 @@ obj-$(CONFIG_$(PHASE_)DM_REGULATOR_ANATOP) += anatop_regulator.o\n obj-$(CONFIG_DM_REGULATOR_TPS65219) += tps65219_regulator.o\n obj-$(CONFIG_REGULATOR_RZG2L_USBPHY) += rzg2l-usbphy-regulator.o\n obj-$(CONFIG_$(PHASE_)DM_REGULATOR_CPCAP) += cpcap_regulator.o\n+obj-$(CONFIG_$(PHASE_)DM_REGULATOR_SPACEMIT_P1) += spacemit_p1_regulator.o\ndiff --git a/drivers/power/regulator/spacemit_p1_regulator.c b/drivers/power/regulator/spacemit_p1_regulator.c\nnew file mode 100644\nindex 00000000000..ab3ca489f0b\n--- /dev/null\n+++ b/drivers/power/regulator/spacemit_p1_regulator.c\n@@ -0,0 +1,460 @@\n+// SPDX-License-Identifier: GPL-2.0+\n+/*\n+ * Copyright (C) 2025-2026 RISCstar Ltd.\n+ */\n+\n+#include <dm.h>\n+#include <dm/lists.h>\n+#include <errno.h>\n+#include <log.h>\n+#include <power/pmic.h>\n+#include <power/regulator.h>\n+#include <power/spacemit_p1.h>\n+\n+struct p1_reg_info {\n+\tuint min_uv;\n+\tuint step_uv;\n+\tu8 vsel_reg;\n+\tu8 vsel_sleep_reg;\n+\tu8 config_reg;\n+\tu8 vsel_mask;\n+\tu8 min_sel;\n+\tu8 max_sel;\n+};\n+\n+static const struct p1_reg_info p1_bucks[] = {\n+\t/* BUCK 1 */\n+\t{ 500000, 5000, P1_BUCK_VSEL(1), P1_BUCK_SVSEL(1), P1_BUCK_CTRL(1),\n+\t BUCK_VSEL_MASK, 0x00, 0xaa },\n+\t{ 1375000, 25000, P1_BUCK_VSEL(1), P1_BUCK_SVSEL(1), P1_BUCK_CTRL(1),\n+\t BUCK_VSEL_MASK, 0xab, 0xfe },\n+\t/* BUCK 2 */\n+\t{ 500000, 5000, P1_BUCK_VSEL(2), P1_BUCK_SVSEL(2), P1_BUCK_CTRL(2),\n+\t BUCK_VSEL_MASK, 0x00, 0xaa },\n+\t{ 1375000, 25000, P1_BUCK_VSEL(2), P1_BUCK_SVSEL(2), P1_BUCK_CTRL(2),\n+\t BUCK_VSEL_MASK, 0xab, 0xfe },\n+\t/* BUCK 3 */\n+\t{ 500000, 5000, P1_BUCK_VSEL(3), P1_BUCK_SVSEL(3), P1_BUCK_CTRL(3),\n+\t BUCK_VSEL_MASK, 0x00, 0xaa },\n+\t{ 1375000, 25000, P1_BUCK_VSEL(3), P1_BUCK_SVSEL(3), P1_BUCK_CTRL(3),\n+\t BUCK_VSEL_MASK, 0xab, 0xfe },\n+\t/* BUCK 4 */\n+\t{ 500000, 5000, P1_BUCK_VSEL(4), P1_BUCK_SVSEL(4), P1_BUCK_CTRL(4),\n+\t BUCK_VSEL_MASK, 0x00, 0xaa },\n+\t{ 1375000, 25000, P1_BUCK_VSEL(4), P1_BUCK_SVSEL(4), P1_BUCK_CTRL(4),\n+\t BUCK_VSEL_MASK, 0xab, 0xfe },\n+\t/* BUCK 5 */\n+\t{ 500000, 5000, P1_BUCK_VSEL(5), P1_BUCK_SVSEL(5), P1_BUCK_CTRL(5),\n+\t BUCK_VSEL_MASK, 0x00, 0xaa },\n+\t{ 1375000, 25000, P1_BUCK_VSEL(5), P1_BUCK_SVSEL(5), P1_BUCK_CTRL(5),\n+\t BUCK_VSEL_MASK, 0xab, 0xfe },\n+\t/* BUCK 6 */\n+\t{ 500000, 5000, P1_BUCK_VSEL(6), P1_BUCK_SVSEL(6), P1_BUCK_CTRL(6),\n+\t BUCK_VSEL_MASK, 0x00, 0xaa },\n+\t{ 1375000, 25000, P1_BUCK_VSEL(6), P1_BUCK_SVSEL(6), P1_BUCK_CTRL(6),\n+\t BUCK_VSEL_MASK, 0xab, 0xfe },\n+};\n+\n+static const struct p1_reg_info p1_aldos[] = {\n+\t/* ALDO 1 */\n+\t{ 500000, 25000, P1_ALDO_VOLT(1), P1_ALDO_SVOLT(1), P1_ALDO_CTRL(1),\n+\t ALDO_VSEL_MASK, 0x0b, 0x7f },\n+\t/* ALDO 2 */\n+\t{ 500000, 25000, P1_ALDO_VOLT(2), P1_ALDO_SVOLT(2), P1_ALDO_CTRL(2),\n+\t ALDO_VSEL_MASK, 0x0b, 0x7f },\n+\t/* ALDO 3 */\n+\t{ 500000, 25000, P1_ALDO_VOLT(3), P1_ALDO_SVOLT(3), P1_ALDO_CTRL(3),\n+\t ALDO_VSEL_MASK, 0x0b, 0x7f },\n+\t/* ALDO 4 */\n+\t{ 500000, 25000, P1_ALDO_VOLT(4), P1_ALDO_SVOLT(4), P1_ALDO_CTRL(4),\n+\t ALDO_VSEL_MASK, 0x0b, 0x7f },\n+};\n+\n+static const struct p1_reg_info p1_dldos[] = {\n+\t/* DLDO 1 */\n+\t{ 500000, 25000, P1_DLDO_VOLT(1), P1_DLDO_SVOLT(1), P1_DLDO_CTRL(1),\n+\t ALDO_VSEL_MASK, 0x0b, 0x7f },\n+\t/* DLDO 2 */\n+\t{ 500000, 25000, P1_DLDO_VOLT(2), P1_DLDO_SVOLT(2), P1_DLDO_CTRL(2),\n+\t ALDO_VSEL_MASK, 0x0b, 0x7f },\n+\t/* DLDO 3 */\n+\t{ 500000, 25000, P1_DLDO_VOLT(3), P1_DLDO_SVOLT(3), P1_DLDO_CTRL(3),\n+\t ALDO_VSEL_MASK, 0x0b, 0x7f },\n+\t/* DLDO 4 */\n+\t{ 500000, 25000, P1_DLDO_VOLT(4), P1_DLDO_SVOLT(4), P1_DLDO_CTRL(4),\n+\t ALDO_VSEL_MASK, 0x0b, 0x7f },\n+\t/* DLDO 5 */\n+\t{ 500000, 25000, P1_DLDO_VOLT(5), P1_DLDO_SVOLT(5), P1_DLDO_CTRL(5),\n+\t ALDO_VSEL_MASK, 0x0b, 0x7f },\n+\t/* DLDO 6 */\n+\t{ 500000, 25000, P1_DLDO_VOLT(6), P1_DLDO_SVOLT(6), P1_DLDO_CTRL(6),\n+\t ALDO_VSEL_MASK, 0x0b, 0x7f },\n+\t/* DLDO 7 */\n+\t{ 500000, 25000, P1_DLDO_VOLT(7), P1_DLDO_SVOLT(7), P1_DLDO_CTRL(7),\n+\t ALDO_VSEL_MASK, 0x0b, 0x7f },\n+};\n+\n+static const struct p1_reg_info *get_buck_reg(struct udevice *pmic,\n+\t\t\t\t\t int idx, int uvolt)\n+{\n+\tif (idx < 0)\n+\t\treturn NULL;\n+\tif (uvolt < 1375000)\n+\t\treturn &p1_bucks[(idx - 1) * 2 + 0];\n+\treturn &p1_bucks[(idx - 1) * 2 + 1];\n+}\n+\n+static const struct p1_reg_info *get_aldo_reg(struct udevice *pmic,\n+\t\t\t\t\t int idx, int uvolt)\n+{\n+\treturn &p1_aldos[idx];\n+}\n+\n+static const struct p1_reg_info *get_dldo_reg(struct udevice *pmic,\n+\t\t\t\t\t int idx, int uvolt)\n+{\n+\treturn &p1_dldos[idx];\n+}\n+\n+static int buck_get_value(struct udevice *dev)\n+{\n+\tconst struct dm_pmic_ops *ops = device_get_ops(dev->parent);\n+\tconst struct p1_reg_info *info;\n+\tuint val;\n+\tint ret;\n+\n+\tif (!ops || !ops->read)\n+\t\treturn -ENOSYS;\n+\n+\tinfo = get_buck_reg(dev->parent, dev->driver_data, 0);\n+\tif (!info)\n+\t\treturn -ENOENT;\n+\tret = pmic_reg_read(dev->parent, info->vsel_reg);\n+\tif (ret < 0)\n+\t\treturn ret;\n+\tval = ret & info->vsel_mask;\n+\twhile (val > info->max_sel)\n+\t\tinfo++;\n+\n+\treturn info->min_uv + (val - info->min_sel) * info->step_uv;\n+}\n+\n+static int buck_set_value(struct udevice *dev, int uvolt)\n+{\n+\tconst struct dm_pmic_ops *ops = device_get_ops(dev->parent);\n+\tconst struct p1_reg_info *info;\n+\tuint val;\n+\tint ret;\n+\n+\tif (!ops || !ops->write)\n+\t\treturn -ENOSYS;\n+\n+\tinfo = get_buck_reg(dev->parent, dev->driver_data, uvolt);\n+\tif (!info)\n+\t\treturn -ENOENT;\n+\tval = (uvolt - info->min_uv);\n+\tval = val / info->step_uv;\n+\tval += info->min_sel;\n+\tret = pmic_reg_write(dev->parent, info->vsel_reg, val);\n+\tif (ret < 0)\n+\t\treturn ret;\n+\treturn 0;\n+}\n+\n+static int buck_get_enable(struct udevice *dev)\n+{\n+\tconst struct p1_reg_info *info;\n+\tint ret;\n+\n+\tinfo = get_buck_reg(dev->parent, dev->driver_data, 0);\n+\tif (!info)\n+\t\treturn -ENOENT;\n+\n+\tret = pmic_reg_read(dev->parent, info->config_reg);\n+\tif (ret < 0)\n+\t\treturn ret;\n+\treturn ret & BUCK_EN_MASK;\n+}\n+\n+static int buck_set_enable(struct udevice *dev, bool enable)\n+{\n+\tconst struct p1_reg_info *info;\n+\tuint val;\n+\tint ret;\n+\n+\tinfo = get_buck_reg(dev->parent, dev->driver_data, 0);\n+\tif (!info)\n+\t\treturn -ENOENT;\n+\n+\tret = pmic_reg_read(dev->parent, info->config_reg);\n+\tif (ret < 0)\n+\t\treturn ret;\n+\tval = (unsigned int)ret;\n+\tval &= BUCK_EN_MASK;\n+\n+\tif (enable == val)\n+\t\treturn 0;\n+\n+\tval = enable;\n+\tret = pmic_clrsetbits(dev->parent, info->config_reg, BUCK_EN_MASK, val);\n+\tif (ret < 0)\n+\t\treturn ret;\n+\n+\treturn 0;\n+}\n+\n+static const struct dm_regulator_ops p1_buck_ops = {\n+\t.get_value = buck_get_value,\n+\t.set_value = buck_set_value,\n+\t.get_enable = buck_get_enable,\n+\t.set_enable = buck_set_enable,\n+};\n+\n+static int p1_buck_probe(struct udevice *dev)\n+{\n+\tstruct dm_regulator_uclass_plat *uc_pdata;\n+\n+\tuc_pdata = dev_get_uclass_plat(dev);\n+\n+\tuc_pdata->type = REGULATOR_TYPE_BUCK;\n+\tuc_pdata->mode_count = 0;\n+\n+\treturn 0;\n+}\n+\n+U_BOOT_DRIVER(p1_buck) = {\n+\t.name\t\t= P1_BUCK_DRIVER,\n+\t.id\t\t= UCLASS_REGULATOR,\n+\t.ops\t\t= &p1_buck_ops,\n+\t.probe\t\t= p1_buck_probe,\n+};\n+\n+static int aldo_get_value(struct udevice *dev)\n+{\n+\tconst struct dm_pmic_ops *ops = device_get_ops(dev->parent);\n+\tconst struct p1_reg_info *info;\n+\tuint val;\n+\tint ret;\n+\n+\tif (!ops || !ops->read)\n+\t\treturn -ENOSYS;\n+\n+\tinfo = get_aldo_reg(dev->parent, dev->driver_data, 0);\n+\tif (!info)\n+\t\treturn -ENOENT;\n+\n+\tret = pmic_reg_read(dev->parent, info->vsel_reg);\n+\tif (ret < 0)\n+\t\treturn ret;\n+\n+\tval = ret & info->vsel_mask;\n+\twhile (val > info->max_sel)\n+\t\tinfo++;\n+\n+\treturn info->min_uv + (val - info->min_sel) * info->step_uv;\n+}\n+\n+static int aldo_set_value(struct udevice *dev, int uvolt)\n+{\n+\tconst struct dm_pmic_ops *ops = device_get_ops(dev->parent);\n+\tconst struct p1_reg_info *info;\n+\tuint val;\n+\tint ret;\n+\n+\tif (!ops || !ops->write)\n+\t\treturn -ENOSYS;\n+\n+\tinfo = get_aldo_reg(dev->parent, dev->driver_data, uvolt);\n+\tif (!info)\n+\t\treturn -ENOENT;\n+\tval = (uvolt - info->min_uv);\n+\tval = val / info->step_uv;\n+\tval += info->min_sel;\n+\tret = pmic_reg_write(dev->parent, info->vsel_reg, val);\n+\tif (ret < 0)\n+\t\treturn ret;\n+\treturn 0;\n+}\n+\n+static int aldo_get_enable(struct udevice *dev)\n+{\n+\tconst struct p1_reg_info *info;\n+\tint ret;\n+\n+\tinfo = get_aldo_reg(dev->parent, dev->driver_data, 0);\n+\tif (!info)\n+\t\treturn -ENOENT;\n+\n+\tret = pmic_reg_read(dev->parent, info->config_reg);\n+\tif (ret < 0)\n+\t\treturn ret;\n+\treturn ret & ALDO_EN_MASK;\n+}\n+\n+static int aldo_set_enable(struct udevice *dev, bool enable)\n+{\n+\tconst struct p1_reg_info *info;\n+\tuint val;\n+\tint ret;\n+\n+\tinfo = get_aldo_reg(dev->parent, dev->driver_data, 0);\n+\tif (!info)\n+\t\treturn -ENOENT;\n+\n+\tret = pmic_reg_read(dev->parent, info->config_reg);\n+\tif (ret < 0)\n+\t\treturn ret;\n+\tval = (unsigned int)ret;\n+\tval &= ALDO_EN_MASK;\n+\n+\tif (enable == val)\n+\t\treturn 0;\n+\n+\tval = enable;\n+\tret = pmic_clrsetbits(dev->parent, info->config_reg, ALDO_EN_MASK, val);\n+\tif (ret < 0)\n+\t\treturn ret;\n+\n+\treturn 0;\n+}\n+\n+static const struct dm_regulator_ops p1_aldo_ops = {\n+\t.get_value\t= aldo_get_value,\n+\t.set_value\t= aldo_set_value,\n+\t.get_enable\t= aldo_get_enable,\n+\t.set_enable\t= aldo_set_enable,\n+};\n+\n+static int p1_aldo_probe(struct udevice *dev)\n+{\n+\tstruct dm_regulator_uclass_plat *uc_pdata;\n+\n+\tuc_pdata = dev_get_uclass_plat(dev);\n+\n+\tuc_pdata->type = REGULATOR_TYPE_LDO;\n+\tuc_pdata->mode_count = 0;\n+\n+\treturn 0;\n+}\n+\n+U_BOOT_DRIVER(p1_aldo) = {\n+\t.name\t\t= P1_ALDO_DRIVER,\n+\t.id\t\t= UCLASS_REGULATOR,\n+\t.ops\t\t= &p1_aldo_ops,\n+\t.probe\t\t= p1_aldo_probe,\n+};\n+\n+static int dldo_get_value(struct udevice *dev)\n+{\n+\tconst struct dm_pmic_ops *ops = device_get_ops(dev->parent);\n+\tconst struct p1_reg_info *info;\n+\tuint val;\n+\tint ret;\n+\n+\tif (!ops || !ops->read)\n+\t\treturn -ENOSYS;\n+\n+\tinfo = get_dldo_reg(dev->parent, dev->driver_data, 0);\n+\tif (!info)\n+\t\treturn -ENOENT;\n+\n+\tret = pmic_reg_read(dev->parent, info->vsel_reg);\n+\tif (ret < 0)\n+\t\treturn ret;\n+\n+\tval = ret & info->vsel_mask;\n+\twhile (val > info->max_sel)\n+\t\tinfo++;\n+\n+\treturn info->min_uv + (val - info->min_sel) * info->step_uv;\n+}\n+\n+static int dldo_set_value(struct udevice *dev, int uvolt)\n+{\n+\tconst struct dm_pmic_ops *ops = device_get_ops(dev->parent);\n+\tconst struct p1_reg_info *info;\n+\tuint val;\n+\tint ret;\n+\n+\tif (!ops || !ops->write)\n+\t\treturn -ENOSYS;\n+\n+\tinfo = get_dldo_reg(dev->parent, dev->driver_data, uvolt);\n+\tif (!info)\n+\t\treturn -ENOENT;\n+\tval = (uvolt - info->min_uv);\n+\tval = val / info->step_uv;\n+\tval += info->min_sel;\n+\tret = pmic_reg_write(dev->parent, info->vsel_reg, val);\n+\tif (ret < 0)\n+\t\treturn ret;\n+\treturn 0;\n+}\n+\n+static int dldo_get_enable(struct udevice *dev)\n+{\n+\tconst struct p1_reg_info *info;\n+\tint ret;\n+\n+\tinfo = get_dldo_reg(dev->parent, dev->driver_data, 0);\n+\tif (!info)\n+\t\treturn -ENOENT;\n+\n+\tret = pmic_reg_read(dev->parent, info->config_reg);\n+\tif (ret < 0)\n+\t\treturn ret;\n+\treturn ret & DLDO_EN_MASK;\n+}\n+\n+static int dldo_set_enable(struct udevice *dev, bool enable)\n+{\n+\tconst struct p1_reg_info *info;\n+\tuint val;\n+\tint ret;\n+\n+\tinfo = get_dldo_reg(dev->parent, dev->driver_data, 0);\n+\tif (!info)\n+\t\treturn -ENOENT;\n+\n+\tret = pmic_reg_read(dev->parent, info->config_reg);\n+\tif (ret < 0)\n+\t\treturn ret;\n+\tval = (unsigned int)ret;\n+\tval &= DLDO_EN_MASK;\n+\n+\tif (enable == val)\n+\t\treturn 0;\n+\n+\tval = enable;\n+\tret = pmic_clrsetbits(dev->parent, info->config_reg, DLDO_EN_MASK, val);\n+\tif (ret < 0)\n+\t\treturn ret;\n+\n+\treturn 0;\n+}\n+\n+static const struct dm_regulator_ops p1_dldo_ops = {\n+\t.get_value\t= dldo_get_value,\n+\t.set_value\t= dldo_set_value,\n+\t.get_enable\t= dldo_get_enable,\n+\t.set_enable\t= dldo_set_enable,\n+};\n+\n+static int p1_dldo_probe(struct udevice *dev)\n+{\n+\tstruct dm_regulator_uclass_plat *uc_pdata;\n+\n+\tuc_pdata = dev_get_uclass_plat(dev);\n+\n+\tuc_pdata->type = REGULATOR_TYPE_LDO;\n+\tuc_pdata->mode_count = 0;\n+\n+\treturn 0;\n+}\n+\n+U_BOOT_DRIVER(p1_dldo) = {\n+\t.name\t\t= P1_DLDO_DRIVER,\n+\t.id\t\t= UCLASS_REGULATOR,\n+\t.ops\t\t= &p1_dldo_ops,\n+\t.probe\t\t= p1_dldo_probe,\n+};\n", "prefixes": [ "v2", "15/16" ] }