From patchwork Mon Jul 15 10:08:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 812601 Delivered-To: patch@linaro.org Received: by 2002:adf:fac3:0:b0:367:895a:4699 with SMTP id a3csp1723913wrs; Mon, 15 Jul 2024 03:08:24 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWWjU8eK2a2jpTqeezowTMAogWf/+6V8Mm8r4bc26n/gJZTYvNZSBx7iIcg2jiXVtqUNJKHI2n1P81+ZHmJYThV X-Google-Smtp-Source: AGHT+IE9ytFRXhXmNQqj7yn3R0UtQCs5g8vV0u+4XClCN6VK4We1hooQ7WsuO7o9mDWW4191SRbY X-Received: by 2002:a17:906:5fc1:b0:a77:d7f1:42eb with SMTP id a640c23a62f3a-a780b6b2034mr1197444766b.23.1721038104372; Mon, 15 Jul 2024 03:08:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721038104; cv=none; d=google.com; s=arc-20160816; b=yFzDyhyIU/Zg+ywp+vmlvdY9N9GlBN+OBofAf6soJI2wMBkasD/uoZQW/+6vfBagxo StxMRBoayD/M6vGh4vt3IdNELxK1l8MoSjooEqz7S8sEyAExY/h86Yzj/hqtnBYOcyI2 CTOkDHzGKM6o1zqb0O/DoNTC+1TOLSakrri9yAFET5PWfZnlEFw6BQ/FhJE0H4R+Pw2s sjEXIWVpMjy2ZjJ4OL6R8w1gbXRv8lAeyC65EndSl7khzzVMs1jvWtXMaphd/yQ+hXPc gOyWtDL+2gtStGBmn/7lv839ccrHf9VKovYuZ2AizVaMoIuFIPyUtaSOK0vgypbr7SzZ UMGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:cc:to:in-reply-to:references :message-id:content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=TmBsez8SJ4gp3OXyLBaZGeolHr60Zn+8FMmZ9V7Bb4k=; fh=zcTfjI3NycJyTuuOJ9uzXxS7wfOr4sYKS7eKveHEFzw=; b=R+0XKTdQ5L73Am2FZQu0iJm9uEnYiE9C7THKmUhYBXXTa9aPwFnVNLInwv3Bl91wAK VjOwSuXHVrbFalg/tcCcrJ0VKNOLTrwVeSG6X9+w3Efw4TbkmSZKePf9cgYsLMOPHHIa 3CQxd7aYqfiyszkDPzCp5u+B9pTbXy0lQiQYh0mPqwqeZ27JTaIgCGSRnOw7e7M0JQk8 sUNb0VTlyT5oN9rVq24ydQTtjtuVMduUEZTMiUYDoSBDyNRWl0cZtQtVuQ0k01TdDj7f X17qs22c3ECuEoa82+ge3uyEbCrrS0PXWVQIzTi1YcKRgco9DM7JuaRR7tP5pxGbnvju YXIw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nyQKkXdu; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id a640c23a62f3a-a79bc7c16b9si223217466b.382.2024.07.15.03.08.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 03:08:24 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nyQKkXdu; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4E6C8887FD; Mon, 15 Jul 2024 12:08:14 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org 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=linaro.org header.i=@linaro.org header.b="nyQKkXdu"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 123BE886A7; Mon, 15 Jul 2024 12:08:13 +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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) (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 C7F81886A7 for ; Mon, 15 Jul 2024 12:08:10 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=caleb.connolly@linaro.org Received: by mail-ed1-x52b.google.com with SMTP id 4fb4d7f45d1cf-58ba3e38027so4283907a12.1 for ; Mon, 15 Jul 2024 03:08:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721038090; x=1721642890; darn=lists.denx.de; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=TmBsez8SJ4gp3OXyLBaZGeolHr60Zn+8FMmZ9V7Bb4k=; b=nyQKkXduGvSmTC4Zo5DG4Xeif8QVO5jbP6uAHb40piBaWcWPAjbe30cA6UrjWf00H0 ojJDhiQ1ogzg0tzgnOPG/BtPToYR69vTltbACdSzzg2K1X3H1cUiVLt8VMiCvROmQJRL uW9Wy9jaFSI3wo7TuwiREh9cB3QhnxdRcpauwOkoWECyl7Yr13XyKhxQymV8iqyeA273 +rQBaHvg67g5O5/GkZpsqy+TR5dplFd0vMoQvqnSU87mvoo7gR0FtuZX3g9R5VcixUTr qRP3SpG3htsk1/Nd4iNZvQLHyeE7gpS1HKb5APeNl7svw7NJYeHtOC7SpKZw9swwhrUJ QFjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721038090; x=1721642890; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TmBsez8SJ4gp3OXyLBaZGeolHr60Zn+8FMmZ9V7Bb4k=; b=NiOGtUuXAcORXjmYS31RvKlNQ5gismOt6bdOMkHRy3Vd5mu0lK+coex5tlSwF/rH7H pMUduoRmev+TcOO92+GgwezuLe7biYPDnzcSIVR5bwgDuDbrQcvKqbxaJJGgB1o7enCN e08oan+5gNRKMRu+0CTNJbLBEOTERtqCf2yoXTHdryD6iwdMu0ZOTMZ1WG5wQIpP0vgb 9JrgpLK/3eeRkkK3Om6vB3CzpinEmgZxfpb58iMIiva553DXV6RiSY3r8zMUsTVRbW6U Cnkp2cMW1yXfo14Fi22NpZuAlARGvKJ8TC6yR7fbCWTHYaqdUh1d9EH4mNvyMJGPK9aR lajw== X-Gm-Message-State: AOJu0YyPI1RzmnrX6rZBfurdpiYbQ3Iqqk/UAv8PNkMEWwl4O0nSaCWb TDRHwqk2lbo2yF2K8O1mJr/O+XBhwnSSszcSqgNov95gyS6iMAd6GAF3QQkhm41RJyA4EJDlvRj ABpE= X-Received: by 2002:a17:906:6c93:b0:a72:6e13:a4b6 with SMTP id a640c23a62f3a-a780b88276bmr1238512766b.58.1721038090261; Mon, 15 Jul 2024 03:08:10 -0700 (PDT) Received: from [192.168.0.113] ([2a02:8109:aa0d:be00::7424]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a79bc5b7eb4sm198102266b.60.2024.07.15.03.08.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 03:08:09 -0700 (PDT) From: Caleb Connolly Date: Mon, 15 Jul 2024 12:08:00 +0200 Subject: [PATCH v6 01/24] dm: core: scan reserved-memory nodes MIME-Version: 1.0 Message-Id: <20240715-b4-qcom-rpmh-v6-1-0c948a25d018@linaro.org> References: <20240715-b4-qcom-rpmh-v6-0-0c948a25d018@linaro.org> In-Reply-To: <20240715-b4-qcom-rpmh-v6-0-0c948a25d018@linaro.org> To: Tom Rini , Caleb Connolly , Neil Armstrong , Sumit Garg , Jaehoon Chung , Simon Glass Cc: u-boot@lists.denx.de, u-boot-qcom@groups.io X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=1031; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=PKEZ2Kyos2XwfSr6YrxzmuKdb9zzBCK2fAEKAd2yAJ8=; b=owEBbQKS/ZANAwAIAQWDMSsZX2S2AcsmYgBmlPUFlJ1jrr59HMtxhLRDzKa1jmQVb6a5QLuEW rYBpuWfFjGJAjMEAAEIAB0WIQS2UaFGPGq+0GkMVc0FgzErGV9ktgUCZpT1BQAKCRAFgzErGV9k tihdEACVwuCnh20wgkVW/XP5whnjW0te7bNghtDZuPuntfVMc53e0MjZuD2BACxJdC9kn2UePde u4fhSOfQFflp2uhqVA8syDjmHlBN6Y8cvkS6lzfzS1nScbZXLbTeYYMGz+jwwTaAtp8SVfjTvQv aYDcBxhnUbMsdIIL/KTsBlbxrGsLp9YiqTM/L3r+d75GLYdCWPndPJoli/KmEv9MW1/SukgVJ0l Y+iivJ6AMYuHAEBuH+RWLs9o522Na0FpUTxLMjndkKWai89WktmVeVoY53aV7aE1xjuCSIfPFGe +6wX6qWETZhx3yu6p2XXfoLIhGUenC6pGnl25LJfZbLCkpZtI2lnV+M5gH/ItN1p4miV8Xh9NV1 rT+zunN8aMRt30fnWrCtKSGiJdiTat+KDQS3V65iYuK0vP1WJJnD3Babb8K1rGMMiZ6OPBJwNMD /HvvL3QzubLdOYlGhMUQUkuWxwuTRoLRmoc8d+LPI89wVxBMgWrmNY+K0n/KtkL6YA2dYVB3Xnl 8ewdEKongysJy4uWHCr+oCrTiQkckpKBPH8mI6u0iZ/KtD6YnogPKi9dJuuDBr6Kby7ZP48sOf3 eAWN8v3YeyV8IAYfDLMTW7KX9xn/neFlGNPMG15aEg5Px42QYamRbWkA1XotnAqeZLRoHrKMdjL wkSkp8Qe0zHz3lA== X-Developer-Key: i=caleb.connolly@linaro.org; a=openpgp; fpr=83B24DA7FE145076BC38BB250CD904EB673A7C47 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.8 at phobos.denx.de X-Virus-Status: Clean Qualcomm platforms may have drivers that bind to reserved memory nodes (cmd-db [1] and smem [2]) which are relevant to U-Boot. Include /reserved-memory in dm_extended_scan() so that these will be handled correctly. [1]: https://www.kernel.org/doc/Documentation/devicetree/bindings/reserved-memory/qcom%2Ccmd-db.yaml [2]: https://www.kernel.org/doc/Documentation/devicetree/bindings/soc/qcom/qcom%2Csmem.yaml Signed-off-by: Caleb Connolly Reviewed-by: Simon Glass --- To: Simon Glass --- drivers/core/root.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/core/root.c b/drivers/core/root.c index 7cf6607a9b7b..7a714f5478a9 100644 --- a/drivers/core/root.c +++ b/drivers/core/root.c @@ -242,9 +242,10 @@ int dm_extended_scan(bool pre_reloc_only) int ret, i; const char * const nodes[] = { "/chosen", "/clocks", - "/firmware" + "/firmware", + "/reserved-memory", }; ret = dm_scan_fdt(pre_reloc_only); if (ret) { From patchwork Mon Jul 15 10:08:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 812602 Delivered-To: patch@linaro.org Received: by 2002:adf:fac3:0:b0:367:895a:4699 with SMTP id a3csp1723960wrs; Mon, 15 Jul 2024 03:08:34 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWUHeh8iwNQrh3RdxGmqDf6LXecqumb1D/FXRLkkXMBFm6OTowy3AsgK74haSMC3TWVTh4PsngKKrPcHtIOWOvi X-Google-Smtp-Source: AGHT+IEx6hzwV8tV7hlhZnCUZg5xbOSDU6YMV8M0KY+N12NIGcbqmvVrKnUrXH28JCejCifYbbwI X-Received: by 2002:a17:907:9711:b0:a77:b0a4:7d88 with SMTP id a640c23a62f3a-a780b689270mr1826985066b.10.1721038114570; Mon, 15 Jul 2024 03:08:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721038114; cv=none; d=google.com; s=arc-20160816; b=bw5J4Y0PSFmc1itTn0Ux/EU59FrFlqNm4MIV5wdh6E//R0ffCpiZMXthQUPsBet3Sd 4KlLLeBlRBk01Tgf6bnOV7smOk4hYgrvVP+FyZSXvjHGbXGYb/2yCQFyYi4DU8pZqcsU WWDO8Liujuf6IkeRHFSrS/vVj2D1NUR07IzCBDVV2cYdw1O2DAfmEY0Ma+FIuFEarW4X Q4mBPtV5RckVbn8G3HXcLCkKKv7HoCTV8sdxklJMNb0L6ufdSZD4Z18ohxfRz2dHS9n1 0QjiInb+UfpFwOtYxzoRLZE9lzk9RXjAOqgaV2qoOE2L9rsGhQDJ/ErVA7F0B7yYBV8p WErQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:cc:to:in-reply-to:references :message-id:content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=bcZVa+VDuJji/8aNFxPP1iBM+h15a7B0d/YaMGub7Uw=; fh=zcTfjI3NycJyTuuOJ9uzXxS7wfOr4sYKS7eKveHEFzw=; b=SGs/5rQAAKuLLiBaDBhh9BfwWl/FW4/YMJQ4Og40fGDeL7Hg5V4m+8cXApisuaj/g5 Tx3P8gNh2cJhjsK+lWwJIEGHhp1y0boi1ERn6n1ZBbqNs+grUPBRhrepUcDOZr8e4Ee9 IfoR1WQ0rCtXiJlBZ1sWluJ3d011UwmI2GmYsWUUR5JyxdZAwKQHsxPxAIvyXBTRB3X8 sDhSMAMae/gWU7HmQ+Rt1GycUb/TkrJm6dvGeqUXibfudE0BeNfYbYuqy+XT36KuF8mM TnctVcl8Fi64HwOzu2uKkZ/U69gj1kSBR9an7719wl2gSaYrx590Bg6CsU6y1eU568Ow MDgA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DHW3iEPM; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id a640c23a62f3a-a79bc58ad92si240390066b.88.2024.07.15.03.08.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 03:08:34 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DHW3iEPM; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A6F1D8880E; Mon, 15 Jul 2024 12:08:14 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org 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=linaro.org header.i=@linaro.org header.b="DHW3iEPM"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2225E887FD; Mon, 15 Jul 2024 12:08:14 +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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) (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 EC0E088753 for ; Mon, 15 Jul 2024 12:08:11 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=caleb.connolly@linaro.org Received: by mail-ed1-x533.google.com with SMTP id 4fb4d7f45d1cf-59559ea9cfdso5121214a12.0 for ; Mon, 15 Jul 2024 03:08:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721038091; x=1721642891; darn=lists.denx.de; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=bcZVa+VDuJji/8aNFxPP1iBM+h15a7B0d/YaMGub7Uw=; b=DHW3iEPMWk3B3FigX3j65+fjOFULv6TjT21bvhUE9AQ4/bjIj1Xlqu+Hys8WUVRkrW CM6ieWI/uzfohF1umuGYJz3SjYXtWhAkpHZbISodGQ0IOg1Z5qvfCGbElbozn5fkUqXv TCiSS6IaQvxMb9Vc9AxqP6kRYYW0zlAe5da7Zsof4ZmdXHawNjc+/polCk/P9QsH7p7L /+oG49xUAFpyDfdmk86W3roGWz+9TpzYmFriyYrZ0Fw1HdWal/tVoVuFBazvE9+aoV4w 4vkTOQEfu032V6HMwmMjOkfIZk87byOYanSGvPhA2xSS9hOLeoUk7P6tmNc/uqTMGSoJ zpiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721038091; x=1721642891; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bcZVa+VDuJji/8aNFxPP1iBM+h15a7B0d/YaMGub7Uw=; b=A1V1SqgzdnTSyOy+InhlG/ZjnQiCmNFACFJ1K2oX5lYSZycBqAIdEmiOVneU0ewrOd jmnp8XDRsuH5QH9rOQlxhJv2YGFE7c0ANKOX6E8lUz9H4jlQt/iRjZx7K1vj5cXmu38A yeNNVJGIKKouN7pgxw7ozOxY4oT6rwwcI49LyEQDBQegy259g7jq4G22FOg2F6E3hNkp Qn0ID3UHYJMiVdMEnHuSPbX44F4FN4xYI4t56vOcLvJqmVSXhuRfgBTI864pK8AB63yb khVNUyFRFDLbZV0xE7OtIwuJoK8wo+QzaGfqIeNomjFwBh/nsPLMrL1V8XrGFVHyrlxJ Iugg== X-Gm-Message-State: AOJu0YzJzHJiKOzMph/anmkYv07qAHH035/QVpQZSwlC4p0QAkxPGaVD mUARf8bPGgNqF+gTwyM+Xbc9WUi4RSArnL4EQzG6EBzIkXBM5SwDC5qahTy7Hok= X-Received: by 2002:a17:907:9711:b0:a77:b0a4:7d88 with SMTP id a640c23a62f3a-a780b689270mr1826883166b.10.1721038091298; Mon, 15 Jul 2024 03:08:11 -0700 (PDT) Received: from [192.168.0.113] ([2a02:8109:aa0d:be00::7424]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a79bc5b7eb4sm198102266b.60.2024.07.15.03.08.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 03:08:10 -0700 (PDT) From: Caleb Connolly Date: Mon, 15 Jul 2024 12:08:01 +0200 Subject: [PATCH v6 02/24] linux/bitmap.h: add bitmap_empty helper MIME-Version: 1.0 Message-Id: <20240715-b4-qcom-rpmh-v6-2-0c948a25d018@linaro.org> References: <20240715-b4-qcom-rpmh-v6-0-0c948a25d018@linaro.org> In-Reply-To: <20240715-b4-qcom-rpmh-v6-0-0c948a25d018@linaro.org> To: Tom Rini , Caleb Connolly , Neil Armstrong , Sumit Garg , Jaehoon Chung , Simon Glass Cc: u-boot@lists.denx.de, u-boot-qcom@groups.io X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=986; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=PxfbD3T2xPQP1uXV5S6na22BOVQpSqa42vcVud4EfCI=; b=owEBbQKS/ZANAwAIAQWDMSsZX2S2AcsmYgBmlPUFr19Fc8y1LQnF9K196NjB0jt+ShmdGkyg8 3HZeMtMcsCJAjMEAAEIAB0WIQS2UaFGPGq+0GkMVc0FgzErGV9ktgUCZpT1BQAKCRAFgzErGV9k tjwBD/4wAiZ8umvoqwpJ+r1PSKZmt0UQm0PG3MJjoZRyCN/D+dh3lovxC0YAFMCySa+gxpHzcIM oc+Ea20B4V9J1dROfKYySKHXa8ZWIVbtN5RaO/5hfQrZXo6ZLPHkwoKkslBQq9mfS4O+v4705AH 7GiNPxbGRTxGw6PxM3Ri7M+iw8zrIM4HnuPLM8rGNtXUzglY/oUqOS/WIXy+kfcE8i3rsxc7XYG rfUs3yEcq9TzKPDmJsNF+o189ZekSPT0S5s2cdODeQmF1fWJYirHZEc/GvPkP2Z19U1ER18Re7W O7avYYj8VmLGeSoIj4b1KWajUBfCDk4mhKtgFoG86XcMDzdrv3SuteGEa9YQgUn7o6lK1Gjt9fe hOu6Q5BZJnfGZCkMtRl87Y+vCJiKy69/VQYfiIPzl+D/VWtJDYiYqMKKubYpSAjg/bfsOo2L098 wFzElQem23xwvITz/T1d7KS+U1FM4yW0bPzWT2irTv3lGJgXG3wbI0xFM2PMrUZBWGOVbCsHwc3 7DojMb9cPRIxP1ycpO5FQ5ei3JzJCnQi8kTe+Q5lkCQ0plt4WP7huzYy4tX6B7kWzgJi25Wku8Q hpqlgoQwXAPyXn6N1JnT08HA7p8htSDde20M52GNVCV+JWtHRbCmoMBrR3SGAem0fUZ4ue55C7V VoQOQlPRWp4Ey9g== X-Developer-Key: i=caleb.connolly@linaro.org; a=openpgp; fpr=83B24DA7FE145076BC38BB250CD904EB673A7C47 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.8 at phobos.denx.de X-Virus-Status: Clean Import this function from Linux as of 6.10-rc6 Reviewed-by: Tom Rini Acked-by: Sumit Garg Signed-off-by: Caleb Connolly --- include/linux/bitmap.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h index 0a8503af9f14..40ca2212cb40 100644 --- a/include/linux/bitmap.h +++ b/include/linux/bitmap.h @@ -195,8 +195,16 @@ static inline void bitmap_fill(unsigned long *dst, unsigned int nbits) memset(dst, 0xff, len); } } +static inline bool bitmap_empty(const unsigned long *src, unsigned int nbits) +{ + if (small_const_nbits(nbits)) + return !(*src & BITMAP_LAST_WORD_MASK(nbits)); + + return find_first_bit(src, nbits) == nbits; +} + static inline void bitmap_or(unsigned long *dst, const unsigned long *src1, const unsigned long *src2, unsigned int nbits) { if (small_const_nbits(nbits)) From patchwork Mon Jul 15 10:08:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 812604 Delivered-To: patch@linaro.org Received: by 2002:adf:fac3:0:b0:367:895a:4699 with SMTP id a3csp1724081wrs; Mon, 15 Jul 2024 03:08:56 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVdy95TV5z2XsBMrJV2Azp1144P2H5m0ykQ52hty+i1YhWOdt706U1WA9LArVEsbdXeMiq5tgcaKKam8TrCKKCK X-Google-Smtp-Source: AGHT+IGPHtWo4imYYib0Vyzeofzqt7q8H68RQUfwIQm5Hk9EI/iTKhRIjZkezVpKLMbmk/gL89Yy X-Received: by 2002:a17:906:414e:b0:a6e:fad9:6dbb with SMTP id a640c23a62f3a-a780b52abb4mr1080650766b.0.1721038135810; Mon, 15 Jul 2024 03:08:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721038135; cv=none; d=google.com; s=arc-20160816; b=rVebRhKYcbE/pa3NkD8msnvd5upaCuORyxicbljy2Qi6fdUfdfN+jsbPO2//wDRGUn PNfkkpC1tHeRJppUYeFUryouClqkkfiQe8eAfRuTcFgxaMMs9W0AkbvZ13eBml25JkUt WdVIjiAjhiIjo1Mn6hhqN26S2hYUBWMyJcFtl3KFE7PUh6Fxat1VP+WrlMGNtje94oIw u0ELnmcak0CtPI7GIZxwo9pBmGModJEWM4+1Y2XFOCrbvCBivuE0zJeAM2TWzxDZuU7P NkWRQ9+w/BXMU4tdyuCFsspMf0Jh8ka1Q5f4sjsbgrEMOERhUji30LtrgVDvBrqNA55L C3lQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:cc:to:in-reply-to:references :message-id:content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=LGtG0s6nmLHr4BvHMAcmPrelydo6f2iwLj0bkugnz5M=; fh=zcTfjI3NycJyTuuOJ9uzXxS7wfOr4sYKS7eKveHEFzw=; b=HXt+dBF568mdxy8bPkAbaeOZrslq49x45QduEMhKsnrj0GAvxWMN9AnqgF/+r0+R9C /33kXh+LjSxUG00ilK2InVqsBLCmZf1L5Nit3C5mnTVaxaMwHCcdiTltoPDMdpka256R vHxi9DvZNo2ahZyFxRH/RvUtquPbsIxfbaJ/EpddZ8Qkad1axtKSrV3kCoqBLqqmhRga pGG7gQv+vAA3lKLgDRvxqrKFQASgLdHNl2XUUfwBCLqqHGJ386JJ5WEExFJnFqPtcZz5 xdRxmuBYdP7RIOnPy2MI/HJjgLicgKzNJlSYWRAsmoTKGm+XRq+6rtc4lCpI95EBXF39 vpcQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BdHtl4c4; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id a640c23a62f3a-a79bc5aaae5si243745566b.236.2024.07.15.03.08.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 03:08:55 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BdHtl4c4; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 763A48882C; Mon, 15 Jul 2024 12:08:18 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org 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=linaro.org header.i=@linaro.org header.b="BdHtl4c4"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id CB06788820; Mon, 15 Jul 2024 12:08:17 +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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) (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 1047688747 for ; Mon, 15 Jul 2024 12:08:14 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=caleb.connolly@linaro.org Received: by mail-ed1-x529.google.com with SMTP id 4fb4d7f45d1cf-58b447c5112so5512793a12.3 for ; Mon, 15 Jul 2024 03:08:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721038093; x=1721642893; darn=lists.denx.de; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=LGtG0s6nmLHr4BvHMAcmPrelydo6f2iwLj0bkugnz5M=; b=BdHtl4c4oHUn6lV/2doBMUkSR82fpOP0fqHao1FRmszQ/7dkXjBH9HSTkumPBTwIBJ 63lhNHJ9p+kHb9qhj5yMZNAkl26KEcaTS4kdHN2cXCA1GctaIeLOm0Jy2dwYuPyiSR69 JzZQfLxe0tX5U8/GFkl4u0bXluGTKAELqJ2L2k0C15FB5o5GikoEpEtsWQ5L2OpA1c+M LcZ8EYQff5D3K1H1RdLTRnknoVm4S4ka+AiYE2jUwerY+uUQkLRzfK8CswGYEIr9Ehq5 KnaRwXQ0fdoAyhz8GjLi/uRQL+88uKzt7wdxmuSXp92fbVEaFqE7tJzbTqz2bYWMdiWd 3O8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721038093; x=1721642893; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LGtG0s6nmLHr4BvHMAcmPrelydo6f2iwLj0bkugnz5M=; b=KwQ6Y8WpQlfREdpT2EoB0CzcHedRFEo8UiTal8Mv5oXSpSy30VqlbmbWgK8cV/wjHc 1+ipoWpu6keP4p1OGL3vGYqIke4PtMfEpXv2TXjZLrvJ1uXshJHzKU6e8kqodnPCQPpC b448S0HtyI4e6cafE583sSxq/5dXdxQGEoqrMijc1jvn+bJZcJwthebl/CIFRi22dIUH /+iJJhV2HQxWtXIkokioggGgDUAnvqLyEf/LNn0I8M8guKpBsAz/wGO7kSOF5PNmesdR he1iXYsJ7DdKcCvqwD9fbWZbBcsr8RnueY+eykI4IEoXi4Jnj1Puex5ZnWZ4RNMcbSwa 2QKQ== X-Gm-Message-State: AOJu0Yyc2ZR/Y4Gg7rBRnASdnKItdUdPJrJKUdu22GVFu6QCNLQ2hR+N 5sNnl9G2XdxTHd9gYgvN7iAIIhqWy9Rubaf328RILJmWZRAGIGbasN6WKTkKtY8= X-Received: by 2002:a17:907:2dab:b0:a77:d481:d69f with SMTP id a640c23a62f3a-a780b89e7cemr1387388666b.70.1721038092856; Mon, 15 Jul 2024 03:08:12 -0700 (PDT) Received: from [192.168.0.113] ([2a02:8109:aa0d:be00::7424]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a79bc5b7eb4sm198102266b.60.2024.07.15.03.08.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 03:08:12 -0700 (PDT) From: Caleb Connolly Date: Mon, 15 Jul 2024 12:08:02 +0200 Subject: [PATCH v6 03/24] soc: qcom: import rpmh and cmd-db drivers from Linux MIME-Version: 1.0 Message-Id: <20240715-b4-qcom-rpmh-v6-3-0c948a25d018@linaro.org> References: <20240715-b4-qcom-rpmh-v6-0-0c948a25d018@linaro.org> In-Reply-To: <20240715-b4-qcom-rpmh-v6-0-0c948a25d018@linaro.org> To: Tom Rini , Caleb Connolly , Neil Armstrong , Sumit Garg , Jaehoon Chung , Simon Glass Cc: u-boot@lists.denx.de, u-boot-qcom@groups.io X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=73900; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=J5HfNh9TDquIoZ0tBMm9qco9of33jZ8J4i+0rbqWmf8=; b=owEBbQKS/ZANAwAIAQWDMSsZX2S2AcsmYgBmlPUFucnHtiiFTIHHNTGTN6JA3hFCJfUTEpHcE eJWg0TkGZ+JAjMEAAEIAB0WIQS2UaFGPGq+0GkMVc0FgzErGV9ktgUCZpT1BQAKCRAFgzErGV9k tm6PD/494INRzPswg8UyTsjOSKQzb8lCtoM8EdtTYn9ae/Ej+aiLtdLpGwD/zTJoC1vRwFOxTcC iYovtyBZCQfimpsc8pU1U/0quO+fF3f1NDswL3sa+BmYnubdLwaXXWj8a42yhO6Tqx/SOoAyGg+ Q8zqVz5rv5nmE4L/62FGJfIymzuvhf1MHh9r4VEJgxb+J4ofO6lbGmQTHSTWH8c3tlgHqKR1QiG Ow2Q5WbaRwkqTxWVEGOzLWIYqqptLkRSoQw/1iQlgyCQlvWGnqNG+4amzLiluMJiszjOH4K06fj zS0uI4gQDb2yhDyqbYNhWnkSJLW8eyCMPWUoGD3dZmGWEfS+5pTg+OkJdGmh6vlhqTuYu57Y3fY FosunXch3r46GtY6Rj9ZmUDB8uP7QVhgzU8lfBSc9ZJirjKWB2eEcfRsbKk4azkgPnLWhkMxSxN Ep5qmL5scXcgTFYcM/vSBakSpbc+so5f5zSpfVBtHxxGXdE2jYRUi0yxl+d/bupnhkfNsRJ14X1 287oTASjOWyO+3aQqnj+Vj1g5D03Fg++TJkR63gyaT4knD7VF6QL8gN44aHcuw6AwqkdthZixQ3 hiyQ7uR1qbEA7zp6aGdO3bC4gvpYMK6MPl2106fnIM218BSKZ0qeocwkMce79PJftvoSzou5ZBw NyDiMC5gafoRmHw== X-Developer-Key: i=caleb.connolly@linaro.org; a=openpgp; fpr=83B24DA7FE145076BC38BB250CD904EB673A7C47 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.8 at phobos.denx.de X-Virus-Status: Clean Import RPMh and cmd-db framework from Linux 6.10-rc6. Acked-by: Sumit Garg Signed-off-by: Caleb Connolly --- drivers/soc/qcom/cmd-db.c | 393 +++++++++++++ drivers/soc/qcom/rpmh-internal.h | 148 +++++ drivers/soc/qcom/rpmh-rsc.c | 1162 ++++++++++++++++++++++++++++++++++++++ drivers/soc/qcom/rpmh.c | 502 ++++++++++++++++ include/soc/qcom/cmd-db.h | 48 ++ include/soc/qcom/rpmh.h | 47 ++ include/soc/qcom/tcs.h | 81 +++ 7 files changed, 2381 insertions(+) diff --git a/drivers/soc/qcom/cmd-db.c b/drivers/soc/qcom/cmd-db.c new file mode 100644 index 000000000000..d84572662017 --- /dev/null +++ b/drivers/soc/qcom/cmd-db.c @@ -0,0 +1,393 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (c) 2016-2018, 2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2024, Qualcomm Innovation Center, Inc. All rights reserved. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#define NUM_PRIORITY 2 +#define MAX_SLV_ID 8 +#define SLAVE_ID_MASK 0x7 +#define SLAVE_ID_SHIFT 16 +#define SLAVE_ID(addr) FIELD_GET(GENMASK(19, 16), addr) +#define VRM_ADDR(addr) FIELD_GET(GENMASK(19, 4), addr) + +/** + * struct entry_header: header for each entry in cmddb + * + * @id: resource's identifier + * @priority: unused + * @addr: the address of the resource + * @len: length of the data + * @offset: offset from :@data_offset, start of the data + */ +struct entry_header { + u8 id[8]; + __le32 priority[NUM_PRIORITY]; + __le32 addr; + __le16 len; + __le16 offset; +}; + +/** + * struct rsc_hdr: resource header information + * + * @slv_id: id for the resource + * @header_offset: entry's header at offset from the end of the cmd_db_header + * @data_offset: entry's data at offset from the end of the cmd_db_header + * @cnt: number of entries for HW type + * @version: MSB is major, LSB is minor + * @reserved: reserved for future use. + */ +struct rsc_hdr { + __le16 slv_id; + __le16 header_offset; + __le16 data_offset; + __le16 cnt; + __le16 version; + __le16 reserved[3]; +}; + +/** + * struct cmd_db_header: The DB header information + * + * @version: The cmd db version + * @magic: constant expected in the database + * @header: array of resources + * @checksum: checksum for the header. Unused. + * @reserved: reserved memory + * @data: driver specific data + */ +struct cmd_db_header { + __le32 version; + u8 magic[4]; + struct rsc_hdr header[MAX_SLV_ID]; + __le32 checksum; + __le32 reserved; + u8 data[]; +}; + +/** + * DOC: Description of the Command DB database. + * + * At the start of the command DB memory is the cmd_db_header structure. + * The cmd_db_header holds the version, checksum, magic key as well as an + * array for header for each slave (depicted by the rsc_header). Each h/w + * based accelerator is a 'slave' (shared resource) and has slave id indicating + * the type of accelerator. The rsc_header is the header for such individual + * slaves of a given type. The entries for each of these slaves begin at the + * rsc_hdr.header_offset. In addition each slave could have auxiliary data + * that may be needed by the driver. The data for the slave starts at the + * entry_header.offset to the location pointed to by the rsc_hdr.data_offset. + * + * Drivers have a stringified key to a slave/resource. They can query the slave + * information and get the slave id and the auxiliary data and the length of the + * data. Using this information, they can format the request to be sent to the + * h/w accelerator and request a resource state. + */ + +static const u8 CMD_DB_MAGIC[] = { 0xdb, 0x30, 0x03, 0x0c }; + +static bool cmd_db_magic_matches(const struct cmd_db_header *header) +{ + const u8 *magic = header->magic; + + return memcmp(magic, CMD_DB_MAGIC, ARRAY_SIZE(CMD_DB_MAGIC)) == 0; +} + +static struct cmd_db_header *cmd_db_header; + +static inline const void *rsc_to_entry_header(const struct rsc_hdr *hdr) +{ + u16 offset = le16_to_cpu(hdr->header_offset); + + return cmd_db_header->data + offset; +} + +static inline void * +rsc_offset(const struct rsc_hdr *hdr, const struct entry_header *ent) +{ + u16 offset = le16_to_cpu(hdr->data_offset); + u16 loffset = le16_to_cpu(ent->offset); + + return cmd_db_header->data + offset + loffset; +} + +/** + * cmd_db_ready - Indicates if command DB is available + * + * Return: 0 on success, errno otherwise + */ +int cmd_db_ready(void) +{ + if (cmd_db_header == NULL) + return -EPROBE_DEFER; + else if (!cmd_db_magic_matches(cmd_db_header)) + return -EINVAL; + + return 0; +} +EXPORT_SYMBOL_GPL(cmd_db_ready); + +static int cmd_db_get_header(const char *id, const struct entry_header **eh, + const struct rsc_hdr **rh) +{ + const struct rsc_hdr *rsc_hdr; + const struct entry_header *ent; + int ret, i, j; + u8 query[sizeof(ent->id)] __nonstring; + + ret = cmd_db_ready(); + if (ret) + return ret; + + strtomem_pad(query, id, 0); + + for (i = 0; i < MAX_SLV_ID; i++) { + rsc_hdr = &cmd_db_header->header[i]; + if (!rsc_hdr->slv_id) + break; + + ent = rsc_to_entry_header(rsc_hdr); + for (j = 0; j < le16_to_cpu(rsc_hdr->cnt); j++, ent++) { + if (memcmp(ent->id, query, sizeof(ent->id)) == 0) { + if (eh) + *eh = ent; + if (rh) + *rh = rsc_hdr; + return 0; + } + } + } + + return -ENODEV; +} + +/** + * cmd_db_read_addr() - Query command db for resource id address. + * + * @id: resource id to query for address + * + * Return: resource address on success, 0 on error + * + * This is used to retrieve resource address based on resource + * id. + */ +u32 cmd_db_read_addr(const char *id) +{ + int ret; + const struct entry_header *ent; + + ret = cmd_db_get_header(id, &ent, NULL); + + return ret < 0 ? 0 : le32_to_cpu(ent->addr); +} +EXPORT_SYMBOL_GPL(cmd_db_read_addr); + +/** + * cmd_db_read_aux_data() - Query command db for aux data. + * + * @id: Resource to retrieve AUX Data on + * @len: size of data buffer returned + * + * Return: pointer to data on success, error pointer otherwise + */ +const void *cmd_db_read_aux_data(const char *id, size_t *len) +{ + int ret; + const struct entry_header *ent; + const struct rsc_hdr *rsc_hdr; + + ret = cmd_db_get_header(id, &ent, &rsc_hdr); + if (ret) + return ERR_PTR(ret); + + if (len) + *len = le16_to_cpu(ent->len); + + return rsc_offset(rsc_hdr, ent); +} +EXPORT_SYMBOL_GPL(cmd_db_read_aux_data); + +/** + * cmd_db_match_resource_addr() - Compare if both Resource addresses are same + * + * @addr1: Resource address to compare + * @addr2: Resource address to compare + * + * Return: true if two addresses refer to the same resource, false otherwise + */ +bool cmd_db_match_resource_addr(u32 addr1, u32 addr2) +{ + /* + * Each RPMh VRM accelerator resource has 3 or 4 contiguous 4-byte + * aligned addresses associated with it. Ignore the offset to check + * for VRM requests. + */ + if (addr1 == addr2) + return true; + else if (SLAVE_ID(addr1) == CMD_DB_HW_VRM && VRM_ADDR(addr1) == VRM_ADDR(addr2)) + return true; + + return false; +} +EXPORT_SYMBOL_GPL(cmd_db_match_resource_addr); + +/** + * cmd_db_read_slave_id - Get the slave ID for a given resource address + * + * @id: Resource id to query the DB for version + * + * Return: cmd_db_hw_type enum on success, CMD_DB_HW_INVALID on error + */ +enum cmd_db_hw_type cmd_db_read_slave_id(const char *id) +{ + int ret; + const struct entry_header *ent; + u32 addr; + + ret = cmd_db_get_header(id, &ent, NULL); + if (ret < 0) + return CMD_DB_HW_INVALID; + + addr = le32_to_cpu(ent->addr); + return (addr >> SLAVE_ID_SHIFT) & SLAVE_ID_MASK; +} +EXPORT_SYMBOL_GPL(cmd_db_read_slave_id); + +#ifdef CONFIG_DEBUG_FS +static int cmd_db_debugfs_dump(struct seq_file *seq, void *p) +{ + int i, j; + const struct rsc_hdr *rsc; + const struct entry_header *ent; + const char *name; + u16 len, version; + u8 major, minor; + + seq_puts(seq, "Command DB DUMP\n"); + + for (i = 0; i < MAX_SLV_ID; i++) { + rsc = &cmd_db_header->header[i]; + if (!rsc->slv_id) + break; + + switch (le16_to_cpu(rsc->slv_id)) { + case CMD_DB_HW_ARC: + name = "ARC"; + break; + case CMD_DB_HW_VRM: + name = "VRM"; + break; + case CMD_DB_HW_BCM: + name = "BCM"; + break; + default: + name = "Unknown"; + break; + } + + version = le16_to_cpu(rsc->version); + major = version >> 8; + minor = version; + + seq_printf(seq, "Slave %s (v%u.%u)\n", name, major, minor); + seq_puts(seq, "-------------------------\n"); + + ent = rsc_to_entry_header(rsc); + for (j = 0; j < le16_to_cpu(rsc->cnt); j++, ent++) { + seq_printf(seq, "0x%05x: %*pEp", le32_to_cpu(ent->addr), + (int)strnlen(ent->id, sizeof(ent->id)), ent->id); + + len = le16_to_cpu(ent->len); + if (len) { + seq_printf(seq, " [%*ph]", + len, rsc_offset(rsc, ent)); + } + seq_putc(seq, '\n'); + } + } + + return 0; +} + +static int open_cmd_db_debugfs(struct inode *inode, struct file *file) +{ + return single_open(file, cmd_db_debugfs_dump, inode->i_private); +} +#endif + +static const struct file_operations cmd_db_debugfs_ops = { +#ifdef CONFIG_DEBUG_FS + .open = open_cmd_db_debugfs, +#endif + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; + +static int cmd_db_dev_probe(struct platform_device *pdev) +{ + struct reserved_mem *rmem; + int ret = 0; + + rmem = of_reserved_mem_lookup(pdev->dev.of_node); + if (!rmem) { + dev_err(&pdev->dev, "failed to acquire memory region\n"); + return -EINVAL; + } + + cmd_db_header = memremap(rmem->base, rmem->size, MEMREMAP_WB); + if (!cmd_db_header) { + ret = -ENOMEM; + cmd_db_header = NULL; + return ret; + } + + if (!cmd_db_magic_matches(cmd_db_header)) { + dev_err(&pdev->dev, "Invalid Command DB Magic\n"); + return -EINVAL; + } + + debugfs_create_file("cmd-db", 0400, NULL, NULL, &cmd_db_debugfs_ops); + + device_set_pm_not_required(&pdev->dev); + + return 0; +} + +static const struct of_device_id cmd_db_match_table[] = { + { .compatible = "qcom,cmd-db" }, + { } +}; +MODULE_DEVICE_TABLE(of, cmd_db_match_table); + +static struct platform_driver cmd_db_dev_driver = { + .probe = cmd_db_dev_probe, + .driver = { + .name = "cmd-db", + .of_match_table = cmd_db_match_table, + .suppress_bind_attrs = true, + }, +}; + +static int __init cmd_db_device_init(void) +{ + return platform_driver_register(&cmd_db_dev_driver); +} +core_initcall(cmd_db_device_init); + +MODULE_DESCRIPTION("Qualcomm Technologies, Inc. Command DB Driver"); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/soc/qcom/rpmh-internal.h b/drivers/soc/qcom/rpmh-internal.h new file mode 100644 index 000000000000..e3cf1beff803 --- /dev/null +++ b/drivers/soc/qcom/rpmh-internal.h @@ -0,0 +1,148 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (c) 2016-2018, The Linux Foundation. All rights reserved. + */ + + +#ifndef __RPM_INTERNAL_H__ +#define __RPM_INTERNAL_H__ + +#include +#include +#include + +#define TCS_TYPE_NR 4 +#define MAX_CMDS_PER_TCS 16 +#define MAX_TCS_PER_TYPE 3 +#define MAX_TCS_NR (MAX_TCS_PER_TYPE * TCS_TYPE_NR) +#define MAX_TCS_SLOTS (MAX_CMDS_PER_TCS * MAX_TCS_PER_TYPE) + +struct rsc_drv; + +/** + * struct tcs_group: group of Trigger Command Sets (TCS) to send state requests + * to the controller + * + * @drv: The controller. + * @type: Type of the TCS in this group - active, sleep, wake. + * @mask: Mask of the TCSes relative to all the TCSes in the RSC. + * @offset: Start of the TCS group relative to the TCSes in the RSC. + * @num_tcs: Number of TCSes in this type. + * @ncpt: Number of commands in each TCS. + * @req: Requests that are sent from the TCS; only used for ACTIVE_ONLY + * transfers (could be on a wake/sleep TCS if we are borrowing for + * an ACTIVE_ONLY transfer). + * Start: grab drv->lock, set req, set tcs_in_use, drop drv->lock, + * trigger + * End: get irq, access req, + * grab drv->lock, clear tcs_in_use, drop drv->lock + * @slots: Indicates which of @cmd_addr are occupied; only used for + * SLEEP / WAKE TCSs. Things are tightly packed in the + * case that (ncpt < MAX_CMDS_PER_TCS). That is if ncpt = 2 and + * MAX_CMDS_PER_TCS = 16 then bit[2] = the first bit in 2nd TCS. + */ +struct tcs_group { + struct rsc_drv *drv; + int type; + u32 mask; + u32 offset; + int num_tcs; + int ncpt; + const struct tcs_request *req[MAX_TCS_PER_TYPE]; + DECLARE_BITMAP(slots, MAX_TCS_SLOTS); +}; + +/** + * struct rpmh_request: the message to be sent to rpmh-rsc + * + * @msg: the request + * @cmd: the payload that will be part of the @msg + * @completion: triggered when request is done + * @dev: the device making the request + * @needs_free: check to free dynamically allocated request object + */ +struct rpmh_request { + struct tcs_request msg; + struct tcs_cmd cmd[MAX_RPMH_PAYLOAD]; + struct completion *completion; + const struct device *dev; + bool needs_free; +}; + +/** + * struct rpmh_ctrlr: our representation of the controller + * + * @cache: the list of cached requests + * @cache_lock: synchronize access to the cache data + * @dirty: was the cache updated since flush + * @batch_cache: Cache sleep and wake requests sent as batch + */ +struct rpmh_ctrlr { + struct list_head cache; + spinlock_t cache_lock; + bool dirty; + struct list_head batch_cache; +}; + +struct rsc_ver { + u32 major; + u32 minor; +}; + +/** + * struct rsc_drv: the Direct Resource Voter (DRV) of the + * Resource State Coordinator controller (RSC) + * + * @name: Controller identifier. + * @base: Start address of the DRV registers in this controller. + * @tcs_base: Start address of the TCS registers in this controller. + * @id: Instance id in the controller (Direct Resource Voter). + * @num_tcs: Number of TCSes in this DRV. + * @rsc_pm: CPU PM notifier for controller. + * Used when solver mode is not present. + * @cpus_in_pm: Number of CPUs not in idle power collapse. + * Used when solver mode and "power-domains" is not present. + * @genpd_nb: PM Domain notifier for cluster genpd notifications. + * @tcs: TCS groups. + * @tcs_in_use: S/W state of the TCS; only set for ACTIVE_ONLY + * transfers, but might show a sleep/wake TCS in use if + * it was borrowed for an active_only transfer. You + * must hold the lock in this struct (AKA drv->lock) in + * order to update this. + * @lock: Synchronize state of the controller. If RPMH's cache + * lock will also be held, the order is: drv->lock then + * cache_lock. + * @tcs_wait: Wait queue used to wait for @tcs_in_use to free up a + * slot + * @client: Handle to the DRV's client. + * @dev: RSC device. + */ +struct rsc_drv { + const char *name; + void __iomem *base; + void __iomem *tcs_base; + int id; + int num_tcs; + struct notifier_block rsc_pm; + struct notifier_block genpd_nb; + atomic_t cpus_in_pm; + struct tcs_group tcs[TCS_TYPE_NR]; + DECLARE_BITMAP(tcs_in_use, MAX_TCS_NR); + spinlock_t lock; + wait_queue_head_t tcs_wait; + struct rpmh_ctrlr client; + struct device *dev; + struct rsc_ver ver; + u32 *regs; +}; + +int rpmh_rsc_send_data(struct rsc_drv *drv, const struct tcs_request *msg); +int rpmh_rsc_write_ctrl_data(struct rsc_drv *drv, + const struct tcs_request *msg); +void rpmh_rsc_invalidate(struct rsc_drv *drv); +void rpmh_rsc_write_next_wakeup(struct rsc_drv *drv); + +void rpmh_tx_done(const struct tcs_request *msg); +int rpmh_flush(struct rpmh_ctrlr *ctrlr); + +#endif /* __RPM_INTERNAL_H__ */ diff --git a/drivers/soc/qcom/rpmh-rsc.c b/drivers/soc/qcom/rpmh-rsc.c new file mode 100644 index 000000000000..de86009ecd91 --- /dev/null +++ b/drivers/soc/qcom/rpmh-rsc.c @@ -0,0 +1,1162 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2016-2018, The Linux Foundation. All rights reserved. + * Copyright (c) 2023-2024, Qualcomm Innovation Center, Inc. All rights reserved. + */ + +#define pr_fmt(fmt) "%s " fmt, KBUILD_MODNAME + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "rpmh-internal.h" + +#define CREATE_TRACE_POINTS +#include "trace-rpmh.h" + + +#define RSC_DRV_ID 0 + +#define MAJOR_VER_MASK 0xFF +#define MAJOR_VER_SHIFT 16 +#define MINOR_VER_MASK 0xFF +#define MINOR_VER_SHIFT 8 + +enum { + RSC_DRV_TCS_OFFSET, + RSC_DRV_CMD_OFFSET, + DRV_SOLVER_CONFIG, + DRV_PRNT_CHLD_CONFIG, + RSC_DRV_IRQ_ENABLE, + RSC_DRV_IRQ_STATUS, + RSC_DRV_IRQ_CLEAR, + RSC_DRV_CMD_WAIT_FOR_CMPL, + RSC_DRV_CONTROL, + RSC_DRV_STATUS, + RSC_DRV_CMD_ENABLE, + RSC_DRV_CMD_MSGID, + RSC_DRV_CMD_ADDR, + RSC_DRV_CMD_DATA, + RSC_DRV_CMD_STATUS, + RSC_DRV_CMD_RESP_DATA, +}; + +/* DRV HW Solver Configuration Information Register */ +#define DRV_HW_SOLVER_MASK 1 +#define DRV_HW_SOLVER_SHIFT 24 + +/* DRV TCS Configuration Information Register */ +#define DRV_NUM_TCS_MASK 0x3F +#define DRV_NUM_TCS_SHIFT 6 +#define DRV_NCPT_MASK 0x1F +#define DRV_NCPT_SHIFT 27 + +/* Offsets for CONTROL TCS Registers */ +#define RSC_DRV_CTL_TCS_DATA_HI 0x38 +#define RSC_DRV_CTL_TCS_DATA_HI_MASK 0xFFFFFF +#define RSC_DRV_CTL_TCS_DATA_HI_VALID BIT(31) +#define RSC_DRV_CTL_TCS_DATA_LO 0x40 +#define RSC_DRV_CTL_TCS_DATA_LO_MASK 0xFFFFFFFF +#define RSC_DRV_CTL_TCS_DATA_SIZE 32 + +#define TCS_AMC_MODE_ENABLE BIT(16) +#define TCS_AMC_MODE_TRIGGER BIT(24) + +/* TCS CMD register bit mask */ +#define CMD_MSGID_LEN 8 +#define CMD_MSGID_RESP_REQ BIT(8) +#define CMD_MSGID_WRITE BIT(16) +#define CMD_STATUS_ISSUED BIT(8) +#define CMD_STATUS_COMPL BIT(16) + +/* + * Here's a high level overview of how all the registers in RPMH work + * together: + * + * - The main rpmh-rsc address is the base of a register space that can + * be used to find overall configuration of the hardware + * (DRV_PRNT_CHLD_CONFIG). Also found within the rpmh-rsc register + * space are all the TCS blocks. The offset of the TCS blocks is + * specified in the device tree by "qcom,tcs-offset" and used to + * compute tcs_base. + * - TCS blocks come one after another. Type, count, and order are + * specified by the device tree as "qcom,tcs-config". + * - Each TCS block has some registers, then space for up to 16 commands. + * Note that though address space is reserved for 16 commands, fewer + * might be present. See ncpt (num cmds per TCS). + * + * Here's a picture: + * + * +---------------------------------------------------+ + * |RSC | + * | ctrl | + * | | + * | Drvs: | + * | +-----------------------------------------------+ | + * | |DRV0 | | + * | | ctrl/config | | + * | | IRQ | | + * | | | | + * | | TCSes: | | + * | | +------------------------------------------+ | | + * | | |TCS0 | | | | | | | | | | | | | | | + * | | | ctrl | 0| 1| 2| 3| 4| 5| .| .| .| .|14|15| | | + * | | | | | | | | | | | | | | | | | | + * | | +------------------------------------------+ | | + * | | +------------------------------------------+ | | + * | | |TCS1 | | | | | | | | | | | | | | | + * | | | ctrl | 0| 1| 2| 3| 4| 5| .| .| .| .|14|15| | | + * | | | | | | | | | | | | | | | | | | + * | | +------------------------------------------+ | | + * | | +------------------------------------------+ | | + * | | |TCS2 | | | | | | | | | | | | | | | + * | | | ctrl | 0| 1| 2| 3| 4| 5| .| .| .| .|14|15| | | + * | | | | | | | | | | | | | | | | | | + * | | +------------------------------------------+ | | + * | | ...... | | + * | +-----------------------------------------------+ | + * | +-----------------------------------------------+ | + * | |DRV1 | | + * | | (same as DRV0) | | + * | +-----------------------------------------------+ | + * | ...... | + * +---------------------------------------------------+ + */ + +#define USECS_TO_CYCLES(time_usecs) \ + xloops_to_cycles((time_usecs) * 0x10C7UL) + +static inline unsigned long xloops_to_cycles(u64 xloops) +{ + return (xloops * loops_per_jiffy * HZ) >> 32; +} + +static u32 rpmh_rsc_reg_offset_ver_2_7[] = { + [RSC_DRV_TCS_OFFSET] = 672, + [RSC_DRV_CMD_OFFSET] = 20, + [DRV_SOLVER_CONFIG] = 0x04, + [DRV_PRNT_CHLD_CONFIG] = 0x0C, + [RSC_DRV_IRQ_ENABLE] = 0x00, + [RSC_DRV_IRQ_STATUS] = 0x04, + [RSC_DRV_IRQ_CLEAR] = 0x08, + [RSC_DRV_CMD_WAIT_FOR_CMPL] = 0x10, + [RSC_DRV_CONTROL] = 0x14, + [RSC_DRV_STATUS] = 0x18, + [RSC_DRV_CMD_ENABLE] = 0x1C, + [RSC_DRV_CMD_MSGID] = 0x30, + [RSC_DRV_CMD_ADDR] = 0x34, + [RSC_DRV_CMD_DATA] = 0x38, + [RSC_DRV_CMD_STATUS] = 0x3C, + [RSC_DRV_CMD_RESP_DATA] = 0x40, +}; + +static u32 rpmh_rsc_reg_offset_ver_3_0[] = { + [RSC_DRV_TCS_OFFSET] = 672, + [RSC_DRV_CMD_OFFSET] = 24, + [DRV_SOLVER_CONFIG] = 0x04, + [DRV_PRNT_CHLD_CONFIG] = 0x0C, + [RSC_DRV_IRQ_ENABLE] = 0x00, + [RSC_DRV_IRQ_STATUS] = 0x04, + [RSC_DRV_IRQ_CLEAR] = 0x08, + [RSC_DRV_CMD_WAIT_FOR_CMPL] = 0x20, + [RSC_DRV_CONTROL] = 0x24, + [RSC_DRV_STATUS] = 0x28, + [RSC_DRV_CMD_ENABLE] = 0x2C, + [RSC_DRV_CMD_MSGID] = 0x34, + [RSC_DRV_CMD_ADDR] = 0x38, + [RSC_DRV_CMD_DATA] = 0x3C, + [RSC_DRV_CMD_STATUS] = 0x40, + [RSC_DRV_CMD_RESP_DATA] = 0x44, +}; + +static inline void __iomem * +tcs_reg_addr(const struct rsc_drv *drv, int reg, int tcs_id) +{ + return drv->tcs_base + drv->regs[RSC_DRV_TCS_OFFSET] * tcs_id + reg; +} + +static inline void __iomem * +tcs_cmd_addr(const struct rsc_drv *drv, int reg, int tcs_id, int cmd_id) +{ + return tcs_reg_addr(drv, reg, tcs_id) + drv->regs[RSC_DRV_CMD_OFFSET] * cmd_id; +} + +static u32 read_tcs_cmd(const struct rsc_drv *drv, int reg, int tcs_id, + int cmd_id) +{ + return readl_relaxed(tcs_cmd_addr(drv, reg, tcs_id, cmd_id)); +} + +static u32 read_tcs_reg(const struct rsc_drv *drv, int reg, int tcs_id) +{ + return readl_relaxed(tcs_reg_addr(drv, reg, tcs_id)); +} + +static void write_tcs_cmd(const struct rsc_drv *drv, int reg, int tcs_id, + int cmd_id, u32 data) +{ + writel_relaxed(data, tcs_cmd_addr(drv, reg, tcs_id, cmd_id)); +} + +static void write_tcs_reg(const struct rsc_drv *drv, int reg, int tcs_id, + u32 data) +{ + writel_relaxed(data, tcs_reg_addr(drv, reg, tcs_id)); +} + +static void write_tcs_reg_sync(const struct rsc_drv *drv, int reg, int tcs_id, + u32 data) +{ + int i; + + writel(data, tcs_reg_addr(drv, reg, tcs_id)); + + /* + * Wait until we read back the same value. Use a counter rather than + * ktime for timeout since this may be called after timekeeping stops. + */ + for (i = 0; i < USEC_PER_SEC; i++) { + if (readl(tcs_reg_addr(drv, reg, tcs_id)) == data) + return; + udelay(1); + } + pr_err("%s: error writing %#x to %d:%#x\n", drv->name, + data, tcs_id, reg); +} + +/** + * tcs_invalidate() - Invalidate all TCSes of the given type (sleep or wake). + * @drv: The RSC controller. + * @type: SLEEP_TCS or WAKE_TCS + * + * This will clear the "slots" variable of the given tcs_group and also + * tell the hardware to forget about all entries. + * + * The caller must ensure that no other RPMH actions are happening when this + * function is called, since otherwise the device may immediately become + * used again even before this function exits. + */ +static void tcs_invalidate(struct rsc_drv *drv, int type) +{ + int m; + struct tcs_group *tcs = &drv->tcs[type]; + + /* Caller ensures nobody else is running so no lock */ + if (bitmap_empty(tcs->slots, MAX_TCS_SLOTS)) + return; + + for (m = tcs->offset; m < tcs->offset + tcs->num_tcs; m++) + write_tcs_reg_sync(drv, drv->regs[RSC_DRV_CMD_ENABLE], m, 0); + + bitmap_zero(tcs->slots, MAX_TCS_SLOTS); +} + +/** + * rpmh_rsc_invalidate() - Invalidate sleep and wake TCSes. + * @drv: The RSC controller. + * + * The caller must ensure that no other RPMH actions are happening when this + * function is called, since otherwise the device may immediately become + * used again even before this function exits. + */ +void rpmh_rsc_invalidate(struct rsc_drv *drv) +{ + tcs_invalidate(drv, SLEEP_TCS); + tcs_invalidate(drv, WAKE_TCS); +} + +/** + * get_tcs_for_msg() - Get the tcs_group used to send the given message. + * @drv: The RSC controller. + * @msg: The message we want to send. + * + * This is normally pretty straightforward except if we are trying to send + * an ACTIVE_ONLY message but don't have any active_only TCSes. + * + * Return: A pointer to a tcs_group or an ERR_PTR. + */ +static struct tcs_group *get_tcs_for_msg(struct rsc_drv *drv, + const struct tcs_request *msg) +{ + int type; + struct tcs_group *tcs; + + switch (msg->state) { + case RPMH_ACTIVE_ONLY_STATE: + type = ACTIVE_TCS; + break; + case RPMH_WAKE_ONLY_STATE: + type = WAKE_TCS; + break; + case RPMH_SLEEP_STATE: + type = SLEEP_TCS; + break; + default: + return ERR_PTR(-EINVAL); + } + + /* + * If we are making an active request on a RSC that does not have a + * dedicated TCS for active state use, then re-purpose a wake TCS to + * send active votes. This is safe because we ensure any active-only + * transfers have finished before we use it (maybe by running from + * the last CPU in PM code). + */ + tcs = &drv->tcs[type]; + if (msg->state == RPMH_ACTIVE_ONLY_STATE && !tcs->num_tcs) + tcs = &drv->tcs[WAKE_TCS]; + + return tcs; +} + +/** + * get_req_from_tcs() - Get a stashed request that was xfering on the given TCS. + * @drv: The RSC controller. + * @tcs_id: The global ID of this TCS. + * + * For ACTIVE_ONLY transfers we want to call back into the client when the + * transfer finishes. To do this we need the "request" that the client + * originally provided us. This function grabs the request that we stashed + * when we started the transfer. + * + * This only makes sense for ACTIVE_ONLY transfers since those are the only + * ones we track sending (the only ones we enable interrupts for and the only + * ones we call back to the client for). + * + * Return: The stashed request. + */ +static const struct tcs_request *get_req_from_tcs(struct rsc_drv *drv, + int tcs_id) +{ + struct tcs_group *tcs; + int i; + + for (i = 0; i < TCS_TYPE_NR; i++) { + tcs = &drv->tcs[i]; + if (tcs->mask & BIT(tcs_id)) + return tcs->req[tcs_id - tcs->offset]; + } + + return NULL; +} + +/** + * __tcs_set_trigger() - Start xfer on a TCS or unset trigger on a borrowed TCS + * @drv: The controller. + * @tcs_id: The global ID of this TCS. + * @trigger: If true then untrigger/retrigger. If false then just untrigger. + * + * In the normal case we only ever call with "trigger=true" to start a + * transfer. That will un-trigger/disable the TCS from the last transfer + * then trigger/enable for this transfer. + * + * If we borrowed a wake TCS for an active-only transfer we'll also call + * this function with "trigger=false" to just do the un-trigger/disable + * before using the TCS for wake purposes again. + * + * Note that the AP is only in charge of triggering active-only transfers. + * The AP never triggers sleep/wake values using this function. + */ +static void __tcs_set_trigger(struct rsc_drv *drv, int tcs_id, bool trigger) +{ + u32 enable; + u32 reg = drv->regs[RSC_DRV_CONTROL]; + + /* + * HW req: Clear the DRV_CONTROL and enable TCS again + * While clearing ensure that the AMC mode trigger is cleared + * and then the mode enable is cleared. + */ + enable = read_tcs_reg(drv, reg, tcs_id); + enable &= ~TCS_AMC_MODE_TRIGGER; + write_tcs_reg_sync(drv, reg, tcs_id, enable); + enable &= ~TCS_AMC_MODE_ENABLE; + write_tcs_reg_sync(drv, reg, tcs_id, enable); + + if (trigger) { + /* Enable the AMC mode on the TCS and then trigger the TCS */ + enable = TCS_AMC_MODE_ENABLE; + write_tcs_reg_sync(drv, reg, tcs_id, enable); + enable |= TCS_AMC_MODE_TRIGGER; + write_tcs_reg(drv, reg, tcs_id, enable); + } +} + +/** + * enable_tcs_irq() - Enable or disable interrupts on the given TCS. + * @drv: The controller. + * @tcs_id: The global ID of this TCS. + * @enable: If true then enable; if false then disable + * + * We only ever call this when we borrow a wake TCS for an active-only + * transfer. For active-only TCSes interrupts are always left enabled. + */ +static void enable_tcs_irq(struct rsc_drv *drv, int tcs_id, bool enable) +{ + u32 data; + u32 reg = drv->regs[RSC_DRV_IRQ_ENABLE]; + + data = readl_relaxed(drv->tcs_base + reg); + if (enable) + data |= BIT(tcs_id); + else + data &= ~BIT(tcs_id); + writel_relaxed(data, drv->tcs_base + reg); +} + +/** + * tcs_tx_done() - TX Done interrupt handler. + * @irq: The IRQ number (ignored). + * @p: Pointer to "struct rsc_drv". + * + * Called for ACTIVE_ONLY transfers (those are the only ones we enable the + * IRQ for) when a transfer is done. + * + * Return: IRQ_HANDLED + */ +static irqreturn_t tcs_tx_done(int irq, void *p) +{ + struct rsc_drv *drv = p; + int i; + unsigned long irq_status; + const struct tcs_request *req; + + irq_status = readl_relaxed(drv->tcs_base + drv->regs[RSC_DRV_IRQ_STATUS]); + + for_each_set_bit(i, &irq_status, BITS_PER_TYPE(u32)) { + req = get_req_from_tcs(drv, i); + if (WARN_ON(!req)) + goto skip; + + trace_rpmh_tx_done(drv, i, req); + + /* + * If wake tcs was re-purposed for sending active + * votes, clear AMC trigger & enable modes and + * disable interrupt for this TCS + */ + if (!drv->tcs[ACTIVE_TCS].num_tcs) + __tcs_set_trigger(drv, i, false); +skip: + /* Reclaim the TCS */ + write_tcs_reg(drv, drv->regs[RSC_DRV_CMD_ENABLE], i, 0); + writel_relaxed(BIT(i), drv->tcs_base + drv->regs[RSC_DRV_IRQ_CLEAR]); + spin_lock(&drv->lock); + clear_bit(i, drv->tcs_in_use); + /* + * Disable interrupt for WAKE TCS to avoid being + * spammed with interrupts coming when the solver + * sends its wake votes. + */ + if (!drv->tcs[ACTIVE_TCS].num_tcs) + enable_tcs_irq(drv, i, false); + spin_unlock(&drv->lock); + wake_up(&drv->tcs_wait); + if (req) + rpmh_tx_done(req); + } + + return IRQ_HANDLED; +} + +/** + * __tcs_buffer_write() - Write to TCS hardware from a request; don't trigger. + * @drv: The controller. + * @tcs_id: The global ID of this TCS. + * @cmd_id: The index within the TCS to start writing. + * @msg: The message we want to send, which will contain several addr/data + * pairs to program (but few enough that they all fit in one TCS). + * + * This is used for all types of transfers (active, sleep, and wake). + */ +static void __tcs_buffer_write(struct rsc_drv *drv, int tcs_id, int cmd_id, + const struct tcs_request *msg) +{ + u32 msgid; + u32 cmd_msgid = CMD_MSGID_LEN | CMD_MSGID_WRITE; + u32 cmd_enable = 0; + struct tcs_cmd *cmd; + int i, j; + + /* Convert all commands to RR when the request has wait_for_compl set */ + cmd_msgid |= msg->wait_for_compl ? CMD_MSGID_RESP_REQ : 0; + + for (i = 0, j = cmd_id; i < msg->num_cmds; i++, j++) { + cmd = &msg->cmds[i]; + cmd_enable |= BIT(j); + msgid = cmd_msgid; + /* + * Additionally, if the cmd->wait is set, make the command + * response reqd even if the overall request was fire-n-forget. + */ + msgid |= cmd->wait ? CMD_MSGID_RESP_REQ : 0; + + write_tcs_cmd(drv, drv->regs[RSC_DRV_CMD_MSGID], tcs_id, j, msgid); + write_tcs_cmd(drv, drv->regs[RSC_DRV_CMD_ADDR], tcs_id, j, cmd->addr); + write_tcs_cmd(drv, drv->regs[RSC_DRV_CMD_DATA], tcs_id, j, cmd->data); + trace_rpmh_send_msg(drv, tcs_id, msg->state, j, msgid, cmd); + } + + cmd_enable |= read_tcs_reg(drv, drv->regs[RSC_DRV_CMD_ENABLE], tcs_id); + write_tcs_reg(drv, drv->regs[RSC_DRV_CMD_ENABLE], tcs_id, cmd_enable); +} + +/** + * check_for_req_inflight() - Look to see if conflicting cmds are in flight. + * @drv: The controller. + * @tcs: A pointer to the tcs_group used for ACTIVE_ONLY transfers. + * @msg: The message we want to send, which will contain several addr/data + * pairs to program (but few enough that they all fit in one TCS). + * + * This will walk through the TCSes in the group and check if any of them + * appear to be sending to addresses referenced in the message. If it finds + * one it'll return -EBUSY. + * + * Only for use for active-only transfers. + * + * Must be called with the drv->lock held since that protects tcs_in_use. + * + * Return: 0 if nothing in flight or -EBUSY if we should try again later. + * The caller must re-enable interrupts between tries since that's + * the only way tcs_in_use will ever be updated and the only way + * RSC_DRV_CMD_ENABLE will ever be cleared. + */ +static int check_for_req_inflight(struct rsc_drv *drv, struct tcs_group *tcs, + const struct tcs_request *msg) +{ + unsigned long curr_enabled; + u32 addr; + int j, k; + int i = tcs->offset; + + for_each_set_bit_from(i, drv->tcs_in_use, tcs->offset + tcs->num_tcs) { + curr_enabled = read_tcs_reg(drv, drv->regs[RSC_DRV_CMD_ENABLE], i); + + for_each_set_bit(j, &curr_enabled, MAX_CMDS_PER_TCS) { + addr = read_tcs_cmd(drv, drv->regs[RSC_DRV_CMD_ADDR], i, j); + for (k = 0; k < msg->num_cmds; k++) { + if (cmd_db_match_resource_addr(msg->cmds[k].addr, addr)) + return -EBUSY; + } + } + } + + return 0; +} + +/** + * find_free_tcs() - Find free tcs in the given tcs_group; only for active. + * @tcs: A pointer to the active-only tcs_group (or the wake tcs_group if + * we borrowed it because there are zero active-only ones). + * + * Must be called with the drv->lock held since that protects tcs_in_use. + * + * Return: The first tcs that's free or -EBUSY if all in use. + */ +static int find_free_tcs(struct tcs_group *tcs) +{ + const struct rsc_drv *drv = tcs->drv; + unsigned long i; + unsigned long max = tcs->offset + tcs->num_tcs; + + i = find_next_zero_bit(drv->tcs_in_use, max, tcs->offset); + if (i >= max) + return -EBUSY; + + return i; +} + +/** + * claim_tcs_for_req() - Claim a tcs in the given tcs_group; only for active. + * @drv: The controller. + * @tcs: The tcs_group used for ACTIVE_ONLY transfers. + * @msg: The data to be sent. + * + * Claims a tcs in the given tcs_group while making sure that no existing cmd + * is in flight that would conflict with the one in @msg. + * + * Context: Must be called with the drv->lock held since that protects + * tcs_in_use. + * + * Return: The id of the claimed tcs or -EBUSY if a matching msg is in flight + * or the tcs_group is full. + */ +static int claim_tcs_for_req(struct rsc_drv *drv, struct tcs_group *tcs, + const struct tcs_request *msg) +{ + int ret; + + /* + * The h/w does not like if we send a request to the same address, + * when one is already in-flight or being processed. + */ + ret = check_for_req_inflight(drv, tcs, msg); + if (ret) + return ret; + + return find_free_tcs(tcs); +} + +/** + * rpmh_rsc_send_data() - Write / trigger active-only message. + * @drv: The controller. + * @msg: The data to be sent. + * + * NOTES: + * - This is only used for "ACTIVE_ONLY" since the limitations of this + * function don't make sense for sleep/wake cases. + * - To do the transfer, we will grab a whole TCS for ourselves--we don't + * try to share. If there are none available we'll wait indefinitely + * for a free one. + * - This function will not wait for the commands to be finished, only for + * data to be programmed into the RPMh. See rpmh_tx_done() which will + * be called when the transfer is fully complete. + * - This function must be called with interrupts enabled. If the hardware + * is busy doing someone else's transfer we need that transfer to fully + * finish so that we can have the hardware, and to fully finish it needs + * the interrupt handler to run. If the interrupts is set to run on the + * active CPU this can never happen if interrupts are disabled. + * + * Return: 0 on success, -EINVAL on error. + */ +int rpmh_rsc_send_data(struct rsc_drv *drv, const struct tcs_request *msg) +{ + struct tcs_group *tcs; + int tcs_id; + + might_sleep(); + + tcs = get_tcs_for_msg(drv, msg); + if (IS_ERR(tcs)) + return PTR_ERR(tcs); + + spin_lock_irq(&drv->lock); + + /* Wait forever for a free tcs. It better be there eventually! */ + wait_event_lock_irq(drv->tcs_wait, + (tcs_id = claim_tcs_for_req(drv, tcs, msg)) >= 0, + drv->lock); + + tcs->req[tcs_id - tcs->offset] = msg; + set_bit(tcs_id, drv->tcs_in_use); + if (msg->state == RPMH_ACTIVE_ONLY_STATE && tcs->type != ACTIVE_TCS) { + /* + * Clear previously programmed WAKE commands in selected + * repurposed TCS to avoid triggering them. tcs->slots will be + * cleaned from rpmh_flush() by invoking rpmh_rsc_invalidate() + */ + write_tcs_reg_sync(drv, drv->regs[RSC_DRV_CMD_ENABLE], tcs_id, 0); + enable_tcs_irq(drv, tcs_id, true); + } + spin_unlock_irq(&drv->lock); + + /* + * These two can be done after the lock is released because: + * - We marked "tcs_in_use" under lock. + * - Once "tcs_in_use" has been marked nobody else could be writing + * to these registers until the interrupt goes off. + * - The interrupt can't go off until we trigger w/ the last line + * of __tcs_set_trigger() below. + */ + __tcs_buffer_write(drv, tcs_id, 0, msg); + __tcs_set_trigger(drv, tcs_id, true); + + return 0; +} + +/** + * find_slots() - Find a place to write the given message. + * @tcs: The tcs group to search. + * @msg: The message we want to find room for. + * @tcs_id: If we return 0 from the function, we return the global ID of the + * TCS to write to here. + * @cmd_id: If we return 0 from the function, we return the index of + * the command array of the returned TCS where the client should + * start writing the message. + * + * Only for use on sleep/wake TCSes since those are the only ones we maintain + * tcs->slots for. + * + * Return: -ENOMEM if there was no room, else 0. + */ +static int find_slots(struct tcs_group *tcs, const struct tcs_request *msg, + int *tcs_id, int *cmd_id) +{ + int slot, offset; + int i = 0; + + /* Do over, until we can fit the full payload in a single TCS */ + do { + slot = bitmap_find_next_zero_area(tcs->slots, MAX_TCS_SLOTS, + i, msg->num_cmds, 0); + if (slot >= tcs->num_tcs * tcs->ncpt) + return -ENOMEM; + i += tcs->ncpt; + } while (slot + msg->num_cmds - 1 >= i); + + bitmap_set(tcs->slots, slot, msg->num_cmds); + + offset = slot / tcs->ncpt; + *tcs_id = offset + tcs->offset; + *cmd_id = slot % tcs->ncpt; + + return 0; +} + +/** + * rpmh_rsc_write_ctrl_data() - Write request to controller but don't trigger. + * @drv: The controller. + * @msg: The data to be written to the controller. + * + * This should only be called for sleep/wake state, never active-only + * state. + * + * The caller must ensure that no other RPMH actions are happening and the + * controller is idle when this function is called since it runs lockless. + * + * Return: 0 if no error; else -error. + */ +int rpmh_rsc_write_ctrl_data(struct rsc_drv *drv, const struct tcs_request *msg) +{ + struct tcs_group *tcs; + int tcs_id = 0, cmd_id = 0; + int ret; + + tcs = get_tcs_for_msg(drv, msg); + if (IS_ERR(tcs)) + return PTR_ERR(tcs); + + /* find the TCS id and the command in the TCS to write to */ + ret = find_slots(tcs, msg, &tcs_id, &cmd_id); + if (!ret) + __tcs_buffer_write(drv, tcs_id, cmd_id, msg); + + return ret; +} + +/** + * rpmh_rsc_ctrlr_is_busy() - Check if any of the AMCs are busy. + * @drv: The controller + * + * Checks if any of the AMCs are busy in handling ACTIVE sets. + * This is called from the last cpu powering down before flushing + * SLEEP and WAKE sets. If AMCs are busy, controller can not enter + * power collapse, so deny from the last cpu's pm notification. + * + * Context: Must be called with the drv->lock held. + * + * Return: + * * False - AMCs are idle + * * True - AMCs are busy + */ +static bool rpmh_rsc_ctrlr_is_busy(struct rsc_drv *drv) +{ + unsigned long set; + const struct tcs_group *tcs = &drv->tcs[ACTIVE_TCS]; + unsigned long max; + + /* + * If we made an active request on a RSC that does not have a + * dedicated TCS for active state use, then re-purposed wake TCSes + * should be checked for not busy, because we used wake TCSes for + * active requests in this case. + */ + if (!tcs->num_tcs) + tcs = &drv->tcs[WAKE_TCS]; + + max = tcs->offset + tcs->num_tcs; + set = find_next_bit(drv->tcs_in_use, max, tcs->offset); + + return set < max; +} + +/** + * rpmh_rsc_write_next_wakeup() - Write next wakeup in CONTROL_TCS. + * @drv: The controller + * + * Writes maximum wakeup cycles when called from suspend. + * Writes earliest hrtimer wakeup when called from idle. + */ +void rpmh_rsc_write_next_wakeup(struct rsc_drv *drv) +{ + ktime_t now, wakeup; + u64 wakeup_us, wakeup_cycles = ~0; + u32 lo, hi; + + if (!drv->tcs[CONTROL_TCS].num_tcs || !drv->genpd_nb.notifier_call) + return; + + /* Set highest time when system (timekeeping) is suspended */ + if (system_state == SYSTEM_SUSPEND) + goto exit; + + /* Find the earliest hrtimer wakeup from online cpus */ + wakeup = dev_pm_genpd_get_next_hrtimer(drv->dev); + + /* Find the relative wakeup in kernel time scale */ + now = ktime_get(); + wakeup = ktime_sub(wakeup, now); + wakeup_us = ktime_to_us(wakeup); + + /* Convert the wakeup to arch timer scale */ + wakeup_cycles = USECS_TO_CYCLES(wakeup_us); + wakeup_cycles += arch_timer_read_counter(); + +exit: + lo = wakeup_cycles & RSC_DRV_CTL_TCS_DATA_LO_MASK; + hi = wakeup_cycles >> RSC_DRV_CTL_TCS_DATA_SIZE; + hi &= RSC_DRV_CTL_TCS_DATA_HI_MASK; + hi |= RSC_DRV_CTL_TCS_DATA_HI_VALID; + + writel_relaxed(lo, drv->base + RSC_DRV_CTL_TCS_DATA_LO); + writel_relaxed(hi, drv->base + RSC_DRV_CTL_TCS_DATA_HI); +} + +/** + * rpmh_rsc_cpu_pm_callback() - Check if any of the AMCs are busy. + * @nfb: Pointer to the notifier block in struct rsc_drv. + * @action: CPU_PM_ENTER, CPU_PM_ENTER_FAILED, or CPU_PM_EXIT. + * @v: Unused + * + * This function is given to cpu_pm_register_notifier so we can be informed + * about when CPUs go down. When all CPUs go down we know no more active + * transfers will be started so we write sleep/wake sets. This function gets + * called from cpuidle code paths and also at system suspend time. + * + * If its last CPU going down and AMCs are not busy then writes cached sleep + * and wake messages to TCSes. The firmware then takes care of triggering + * them when entering deepest low power modes. + * + * Return: See cpu_pm_register_notifier() + */ +static int rpmh_rsc_cpu_pm_callback(struct notifier_block *nfb, + unsigned long action, void *v) +{ + struct rsc_drv *drv = container_of(nfb, struct rsc_drv, rsc_pm); + int ret = NOTIFY_OK; + int cpus_in_pm; + + switch (action) { + case CPU_PM_ENTER: + cpus_in_pm = atomic_inc_return(&drv->cpus_in_pm); + /* + * NOTE: comments for num_online_cpus() point out that it's + * only a snapshot so we need to be careful. It should be OK + * for us to use, though. It's important for us not to miss + * if we're the last CPU going down so it would only be a + * problem if a CPU went offline right after we did the check + * AND that CPU was not idle AND that CPU was the last non-idle + * CPU. That can't happen. CPUs would have to come out of idle + * before the CPU could go offline. + */ + if (cpus_in_pm < num_online_cpus()) + return NOTIFY_OK; + break; + case CPU_PM_ENTER_FAILED: + case CPU_PM_EXIT: + atomic_dec(&drv->cpus_in_pm); + return NOTIFY_OK; + default: + return NOTIFY_DONE; + } + + /* + * It's likely we're on the last CPU. Grab the drv->lock and write + * out the sleep/wake commands to RPMH hardware. Grabbing the lock + * means that if we race with another CPU coming up we are still + * guaranteed to be safe. If another CPU came up just after we checked + * and has grabbed the lock or started an active transfer then we'll + * notice we're busy and abort. If another CPU comes up after we start + * flushing it will be blocked from starting an active transfer until + * we're done flushing. If another CPU starts an active transfer after + * we release the lock we're still OK because we're no longer the last + * CPU. + */ + if (spin_trylock(&drv->lock)) { + if (rpmh_rsc_ctrlr_is_busy(drv) || rpmh_flush(&drv->client)) + ret = NOTIFY_BAD; + spin_unlock(&drv->lock); + } else { + /* Another CPU must be up */ + return NOTIFY_OK; + } + + if (ret == NOTIFY_BAD) { + /* Double-check if we're here because someone else is up */ + if (cpus_in_pm < num_online_cpus()) + ret = NOTIFY_OK; + else + /* We won't be called w/ CPU_PM_ENTER_FAILED */ + atomic_dec(&drv->cpus_in_pm); + } + + return ret; +} + +/** + * rpmh_rsc_pd_callback() - Check if any of the AMCs are busy. + * @nfb: Pointer to the genpd notifier block in struct rsc_drv. + * @action: GENPD_NOTIFY_PRE_OFF, GENPD_NOTIFY_OFF, GENPD_NOTIFY_PRE_ON or GENPD_NOTIFY_ON. + * @v: Unused + * + * This function is given to dev_pm_genpd_add_notifier() so we can be informed + * about when cluster-pd is going down. When cluster go down we know no more active + * transfers will be started so we write sleep/wake sets. This function gets + * called from cpuidle code paths and also at system suspend time. + * + * If AMCs are not busy then writes cached sleep and wake messages to TCSes. + * The firmware then takes care of triggering them when entering deepest low power modes. + * + * Return: + * * NOTIFY_OK - success + * * NOTIFY_BAD - failure + */ +static int rpmh_rsc_pd_callback(struct notifier_block *nfb, + unsigned long action, void *v) +{ + struct rsc_drv *drv = container_of(nfb, struct rsc_drv, genpd_nb); + + /* We don't need to lock as genpd on/off are serialized */ + if ((action == GENPD_NOTIFY_PRE_OFF) && + (rpmh_rsc_ctrlr_is_busy(drv) || rpmh_flush(&drv->client))) + return NOTIFY_BAD; + + return NOTIFY_OK; +} + +static int rpmh_rsc_pd_attach(struct rsc_drv *drv, struct device *dev) +{ + int ret; + + pm_runtime_enable(dev); + drv->genpd_nb.notifier_call = rpmh_rsc_pd_callback; + ret = dev_pm_genpd_add_notifier(dev, &drv->genpd_nb); + if (ret) + pm_runtime_disable(dev); + + return ret; +} + +static int rpmh_probe_tcs_config(struct platform_device *pdev, struct rsc_drv *drv) +{ + struct tcs_type_config { + u32 type; + u32 n; + } tcs_cfg[TCS_TYPE_NR] = { { 0 } }; + struct device_node *dn = pdev->dev.of_node; + u32 config, max_tcs, ncpt, offset; + int i, ret, n, st = 0; + struct tcs_group *tcs; + + ret = of_property_read_u32(dn, "qcom,tcs-offset", &offset); + if (ret) + return ret; + drv->tcs_base = drv->base + offset; + + config = readl_relaxed(drv->base + drv->regs[DRV_PRNT_CHLD_CONFIG]); + + max_tcs = config; + max_tcs &= DRV_NUM_TCS_MASK << (DRV_NUM_TCS_SHIFT * drv->id); + max_tcs = max_tcs >> (DRV_NUM_TCS_SHIFT * drv->id); + + ncpt = config & (DRV_NCPT_MASK << DRV_NCPT_SHIFT); + ncpt = ncpt >> DRV_NCPT_SHIFT; + + n = of_property_count_u32_elems(dn, "qcom,tcs-config"); + if (n != 2 * TCS_TYPE_NR) + return -EINVAL; + + for (i = 0; i < TCS_TYPE_NR; i++) { + ret = of_property_read_u32_index(dn, "qcom,tcs-config", + i * 2, &tcs_cfg[i].type); + if (ret) + return ret; + if (tcs_cfg[i].type >= TCS_TYPE_NR) + return -EINVAL; + + ret = of_property_read_u32_index(dn, "qcom,tcs-config", + i * 2 + 1, &tcs_cfg[i].n); + if (ret) + return ret; + if (tcs_cfg[i].n > MAX_TCS_PER_TYPE) + return -EINVAL; + } + + for (i = 0; i < TCS_TYPE_NR; i++) { + tcs = &drv->tcs[tcs_cfg[i].type]; + if (tcs->drv) + return -EINVAL; + tcs->drv = drv; + tcs->type = tcs_cfg[i].type; + tcs->num_tcs = tcs_cfg[i].n; + tcs->ncpt = ncpt; + + if (!tcs->num_tcs || tcs->type == CONTROL_TCS) + continue; + + if (st + tcs->num_tcs > max_tcs || + st + tcs->num_tcs >= BITS_PER_BYTE * sizeof(tcs->mask)) + return -EINVAL; + + tcs->mask = ((1 << tcs->num_tcs) - 1) << st; + tcs->offset = st; + st += tcs->num_tcs; + } + + drv->num_tcs = st; + + return 0; +} + +static int rpmh_rsc_probe(struct platform_device *pdev) +{ + struct device_node *dn = pdev->dev.of_node; + struct rsc_drv *drv; + char drv_id[10] = {0}; + int ret, irq; + u32 solver_config; + u32 rsc_id; + + /* + * Even though RPMh doesn't directly use cmd-db, all of its children + * do. To avoid adding this check to our children we'll do it now. + */ + ret = cmd_db_ready(); + if (ret) { + if (ret != -EPROBE_DEFER) + dev_err(&pdev->dev, "Command DB not available (%d)\n", + ret); + return ret; + } + + drv = devm_kzalloc(&pdev->dev, sizeof(*drv), GFP_KERNEL); + if (!drv) + return -ENOMEM; + + ret = of_property_read_u32(dn, "qcom,drv-id", &drv->id); + if (ret) + return ret; + + drv->name = of_get_property(dn, "label", NULL); + if (!drv->name) + drv->name = dev_name(&pdev->dev); + + snprintf(drv_id, ARRAY_SIZE(drv_id), "drv-%d", drv->id); + drv->base = devm_platform_ioremap_resource_byname(pdev, drv_id); + if (IS_ERR(drv->base)) + return PTR_ERR(drv->base); + + rsc_id = readl_relaxed(drv->base + RSC_DRV_ID); + drv->ver.major = rsc_id & (MAJOR_VER_MASK << MAJOR_VER_SHIFT); + drv->ver.major >>= MAJOR_VER_SHIFT; + drv->ver.minor = rsc_id & (MINOR_VER_MASK << MINOR_VER_SHIFT); + drv->ver.minor >>= MINOR_VER_SHIFT; + + if (drv->ver.major == 3) + drv->regs = rpmh_rsc_reg_offset_ver_3_0; + else + drv->regs = rpmh_rsc_reg_offset_ver_2_7; + + ret = rpmh_probe_tcs_config(pdev, drv); + if (ret) + return ret; + + spin_lock_init(&drv->lock); + init_waitqueue_head(&drv->tcs_wait); + bitmap_zero(drv->tcs_in_use, MAX_TCS_NR); + + irq = platform_get_irq(pdev, drv->id); + if (irq < 0) + return irq; + + ret = devm_request_irq(&pdev->dev, irq, tcs_tx_done, + IRQF_TRIGGER_HIGH | IRQF_NO_SUSPEND, + drv->name, drv); + if (ret) + return ret; + + /* + * CPU PM/genpd notification are not required for controllers that support + * 'HW solver' mode where they can be in autonomous mode executing low + * power mode to power down. + */ + solver_config = readl_relaxed(drv->base + drv->regs[DRV_SOLVER_CONFIG]); + solver_config &= DRV_HW_SOLVER_MASK << DRV_HW_SOLVER_SHIFT; + solver_config = solver_config >> DRV_HW_SOLVER_SHIFT; + if (!solver_config) { + if (pdev->dev.pm_domain) { + ret = rpmh_rsc_pd_attach(drv, &pdev->dev); + if (ret) + return ret; + } else { + drv->rsc_pm.notifier_call = rpmh_rsc_cpu_pm_callback; + cpu_pm_register_notifier(&drv->rsc_pm); + } + } + + /* Enable the active TCS to send requests immediately */ + writel_relaxed(drv->tcs[ACTIVE_TCS].mask, + drv->tcs_base + drv->regs[RSC_DRV_IRQ_ENABLE]); + + spin_lock_init(&drv->client.cache_lock); + INIT_LIST_HEAD(&drv->client.cache); + INIT_LIST_HEAD(&drv->client.batch_cache); + + dev_set_drvdata(&pdev->dev, drv); + drv->dev = &pdev->dev; + + ret = devm_of_platform_populate(&pdev->dev); + if (ret && pdev->dev.pm_domain) { + dev_pm_genpd_remove_notifier(&pdev->dev); + pm_runtime_disable(&pdev->dev); + } + + return ret; +} + +static const struct of_device_id rpmh_drv_match[] = { + { .compatible = "qcom,rpmh-rsc", }, + { } +}; +MODULE_DEVICE_TABLE(of, rpmh_drv_match); + +static struct platform_driver rpmh_driver = { + .probe = rpmh_rsc_probe, + .driver = { + .name = "rpmh", + .of_match_table = rpmh_drv_match, + .suppress_bind_attrs = true, + }, +}; + +static int __init rpmh_driver_init(void) +{ + return platform_driver_register(&rpmh_driver); +} +core_initcall(rpmh_driver_init); + +MODULE_DESCRIPTION("Qualcomm Technologies, Inc. RPMh Driver"); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/soc/qcom/rpmh.c b/drivers/soc/qcom/rpmh.c new file mode 100644 index 000000000000..8903ed956312 --- /dev/null +++ b/drivers/soc/qcom/rpmh.c @@ -0,0 +1,502 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2016-2018, The Linux Foundation. All rights reserved. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "rpmh-internal.h" + +#define RPMH_TIMEOUT_MS msecs_to_jiffies(10000) + +#define DEFINE_RPMH_MSG_ONSTACK(device, s, q, name) \ + struct rpmh_request name = { \ + .msg = { \ + .state = s, \ + .cmds = name.cmd, \ + .num_cmds = 0, \ + .wait_for_compl = true, \ + }, \ + .cmd = { { 0 } }, \ + .completion = q, \ + .dev = device, \ + .needs_free = false, \ + } + +#define ctrlr_to_drv(ctrlr) container_of(ctrlr, struct rsc_drv, client) + +/** + * struct cache_req: the request object for caching + * + * @addr: the address of the resource + * @sleep_val: the sleep vote + * @wake_val: the wake vote + * @list: linked list obj + */ +struct cache_req { + u32 addr; + u32 sleep_val; + u32 wake_val; + struct list_head list; +}; + +/** + * struct batch_cache_req - An entry in our batch catch + * + * @list: linked list obj + * @count: number of messages + * @rpm_msgs: the messages + */ + +struct batch_cache_req { + struct list_head list; + int count; + struct rpmh_request rpm_msgs[]; +}; + +static struct rpmh_ctrlr *get_rpmh_ctrlr(const struct device *dev) +{ + struct rsc_drv *drv = dev_get_drvdata(dev->parent); + + return &drv->client; +} + +void rpmh_tx_done(const struct tcs_request *msg) +{ + struct rpmh_request *rpm_msg = container_of(msg, struct rpmh_request, + msg); + struct completion *compl = rpm_msg->completion; + bool free = rpm_msg->needs_free; + + if (!compl) + goto exit; + + /* Signal the blocking thread we are done */ + complete(compl); + +exit: + if (free) + kfree(rpm_msg); +} + +static struct cache_req *__find_req(struct rpmh_ctrlr *ctrlr, u32 addr) +{ + struct cache_req *p, *req = NULL; + + list_for_each_entry(p, &ctrlr->cache, list) { + if (p->addr == addr) { + req = p; + break; + } + } + + return req; +} + +static struct cache_req *cache_rpm_request(struct rpmh_ctrlr *ctrlr, + enum rpmh_state state, + struct tcs_cmd *cmd) +{ + struct cache_req *req; + unsigned long flags; + u32 old_sleep_val, old_wake_val; + + spin_lock_irqsave(&ctrlr->cache_lock, flags); + req = __find_req(ctrlr, cmd->addr); + if (req) + goto existing; + + req = kzalloc(sizeof(*req), GFP_ATOMIC); + if (!req) { + req = ERR_PTR(-ENOMEM); + goto unlock; + } + + req->addr = cmd->addr; + req->sleep_val = req->wake_val = UINT_MAX; + list_add_tail(&req->list, &ctrlr->cache); + +existing: + old_sleep_val = req->sleep_val; + old_wake_val = req->wake_val; + + switch (state) { + case RPMH_ACTIVE_ONLY_STATE: + case RPMH_WAKE_ONLY_STATE: + req->wake_val = cmd->data; + break; + case RPMH_SLEEP_STATE: + req->sleep_val = cmd->data; + break; + } + + ctrlr->dirty |= (req->sleep_val != old_sleep_val || + req->wake_val != old_wake_val) && + req->sleep_val != UINT_MAX && + req->wake_val != UINT_MAX; + +unlock: + spin_unlock_irqrestore(&ctrlr->cache_lock, flags); + + return req; +} + +/** + * __rpmh_write: Cache and send the RPMH request + * + * @dev: The device making the request + * @state: Active/Sleep request type + * @rpm_msg: The data that needs to be sent (cmds). + * + * Cache the RPMH request and send if the state is ACTIVE_ONLY. + * SLEEP/WAKE_ONLY requests are not sent to the controller at + * this time. Use rpmh_flush() to send them to the controller. + */ +static int __rpmh_write(const struct device *dev, enum rpmh_state state, + struct rpmh_request *rpm_msg) +{ + struct rpmh_ctrlr *ctrlr = get_rpmh_ctrlr(dev); + int ret = -EINVAL; + struct cache_req *req; + int i; + + /* Cache the request in our store and link the payload */ + for (i = 0; i < rpm_msg->msg.num_cmds; i++) { + req = cache_rpm_request(ctrlr, state, &rpm_msg->msg.cmds[i]); + if (IS_ERR(req)) + return PTR_ERR(req); + } + + if (state == RPMH_ACTIVE_ONLY_STATE) { + ret = rpmh_rsc_send_data(ctrlr_to_drv(ctrlr), &rpm_msg->msg); + } else { + /* Clean up our call by spoofing tx_done */ + ret = 0; + rpmh_tx_done(&rpm_msg->msg); + } + + return ret; +} + +static int __fill_rpmh_msg(struct rpmh_request *req, enum rpmh_state state, + const struct tcs_cmd *cmd, u32 n) +{ + if (!cmd || !n || n > MAX_RPMH_PAYLOAD) + return -EINVAL; + + memcpy(req->cmd, cmd, n * sizeof(*cmd)); + + req->msg.state = state; + req->msg.cmds = req->cmd; + req->msg.num_cmds = n; + + return 0; +} + +/** + * rpmh_write_async: Write a set of RPMH commands + * + * @dev: The device making the request + * @state: Active/sleep set + * @cmd: The payload data + * @n: The number of elements in payload + * + * Write a set of RPMH commands, the order of commands is maintained + * and will be sent as a single shot. + */ +int rpmh_write_async(const struct device *dev, enum rpmh_state state, + const struct tcs_cmd *cmd, u32 n) +{ + struct rpmh_request *rpm_msg; + int ret; + + rpm_msg = kzalloc(sizeof(*rpm_msg), GFP_ATOMIC); + if (!rpm_msg) + return -ENOMEM; + rpm_msg->needs_free = true; + + ret = __fill_rpmh_msg(rpm_msg, state, cmd, n); + if (ret) { + kfree(rpm_msg); + return ret; + } + + return __rpmh_write(dev, state, rpm_msg); +} +EXPORT_SYMBOL_GPL(rpmh_write_async); + +/** + * rpmh_write: Write a set of RPMH commands and block until response + * + * @dev: The device making the request + * @state: Active/sleep set + * @cmd: The payload data + * @n: The number of elements in @cmd + * + * May sleep. Do not call from atomic contexts. + */ +int rpmh_write(const struct device *dev, enum rpmh_state state, + const struct tcs_cmd *cmd, u32 n) +{ + DECLARE_COMPLETION_ONSTACK(compl); + DEFINE_RPMH_MSG_ONSTACK(dev, state, &compl, rpm_msg); + int ret; + + ret = __fill_rpmh_msg(&rpm_msg, state, cmd, n); + if (ret) + return ret; + + ret = __rpmh_write(dev, state, &rpm_msg); + if (ret) + return ret; + + ret = wait_for_completion_timeout(&compl, RPMH_TIMEOUT_MS); + WARN_ON(!ret); + return (ret > 0) ? 0 : -ETIMEDOUT; +} +EXPORT_SYMBOL_GPL(rpmh_write); + +static void cache_batch(struct rpmh_ctrlr *ctrlr, struct batch_cache_req *req) +{ + unsigned long flags; + + spin_lock_irqsave(&ctrlr->cache_lock, flags); + list_add_tail(&req->list, &ctrlr->batch_cache); + ctrlr->dirty = true; + spin_unlock_irqrestore(&ctrlr->cache_lock, flags); +} + +static int flush_batch(struct rpmh_ctrlr *ctrlr) +{ + struct batch_cache_req *req; + const struct rpmh_request *rpm_msg; + int ret = 0; + int i; + + /* Send Sleep/Wake requests to the controller, expect no response */ + list_for_each_entry(req, &ctrlr->batch_cache, list) { + for (i = 0; i < req->count; i++) { + rpm_msg = req->rpm_msgs + i; + ret = rpmh_rsc_write_ctrl_data(ctrlr_to_drv(ctrlr), + &rpm_msg->msg); + if (ret) + break; + } + } + + return ret; +} + +/** + * rpmh_write_batch: Write multiple sets of RPMH commands and wait for the + * batch to finish. + * + * @dev: the device making the request + * @state: Active/sleep set + * @cmd: The payload data + * @n: The array of count of elements in each batch, 0 terminated. + * + * Write a request to the RSC controller without caching. If the request + * state is ACTIVE, then the requests are treated as completion request + * and sent to the controller immediately. The function waits until all the + * commands are complete. If the request was to SLEEP or WAKE_ONLY, then the + * request is sent as fire-n-forget and no ack is expected. + * + * May sleep. Do not call from atomic contexts for ACTIVE_ONLY requests. + */ +int rpmh_write_batch(const struct device *dev, enum rpmh_state state, + const struct tcs_cmd *cmd, u32 *n) +{ + struct batch_cache_req *req; + struct rpmh_request *rpm_msgs; + struct completion *compls; + struct rpmh_ctrlr *ctrlr = get_rpmh_ctrlr(dev); + unsigned long time_left; + int count = 0; + int ret, i; + void *ptr; + + if (!cmd || !n) + return -EINVAL; + + while (n[count] > 0) + count++; + if (!count) + return -EINVAL; + + ptr = kzalloc(sizeof(*req) + + count * (sizeof(req->rpm_msgs[0]) + sizeof(*compls)), + GFP_ATOMIC); + if (!ptr) + return -ENOMEM; + + req = ptr; + compls = ptr + sizeof(*req) + count * sizeof(*rpm_msgs); + + req->count = count; + rpm_msgs = req->rpm_msgs; + + for (i = 0; i < count; i++) { + __fill_rpmh_msg(rpm_msgs + i, state, cmd, n[i]); + cmd += n[i]; + } + + if (state != RPMH_ACTIVE_ONLY_STATE) { + cache_batch(ctrlr, req); + return 0; + } + + for (i = 0; i < count; i++) { + struct completion *compl = &compls[i]; + + init_completion(compl); + rpm_msgs[i].completion = compl; + ret = rpmh_rsc_send_data(ctrlr_to_drv(ctrlr), &rpm_msgs[i].msg); + if (ret) { + pr_err("Error(%d) sending RPMH message addr=%#x\n", + ret, rpm_msgs[i].msg.cmds[0].addr); + break; + } + } + + time_left = RPMH_TIMEOUT_MS; + while (i--) { + time_left = wait_for_completion_timeout(&compls[i], time_left); + if (!time_left) { + /* + * Better hope they never finish because they'll signal + * the completion that we're going to free once + * we've returned from this function. + */ + WARN_ON(1); + ret = -ETIMEDOUT; + goto exit; + } + } + +exit: + kfree(ptr); + + return ret; +} +EXPORT_SYMBOL_GPL(rpmh_write_batch); + +static int is_req_valid(struct cache_req *req) +{ + return (req->sleep_val != UINT_MAX && + req->wake_val != UINT_MAX && + req->sleep_val != req->wake_val); +} + +static int send_single(struct rpmh_ctrlr *ctrlr, enum rpmh_state state, + u32 addr, u32 data) +{ + DEFINE_RPMH_MSG_ONSTACK(NULL, state, NULL, rpm_msg); + + /* Wake sets are always complete and sleep sets are not */ + rpm_msg.msg.wait_for_compl = (state == RPMH_WAKE_ONLY_STATE); + rpm_msg.cmd[0].addr = addr; + rpm_msg.cmd[0].data = data; + rpm_msg.msg.num_cmds = 1; + + return rpmh_rsc_write_ctrl_data(ctrlr_to_drv(ctrlr), &rpm_msg.msg); +} + +/** + * rpmh_flush() - Flushes the buffered sleep and wake sets to TCSes + * + * @ctrlr: Controller making request to flush cached data + * + * Return: + * * 0 - Success + * * Error code - Otherwise + */ +int rpmh_flush(struct rpmh_ctrlr *ctrlr) +{ + struct cache_req *p; + int ret = 0; + + lockdep_assert_irqs_disabled(); + + /* + * Currently rpmh_flush() is only called when we think we're running + * on the last processor. If the lock is busy it means another + * processor is up and it's better to abort than spin. + */ + if (!spin_trylock(&ctrlr->cache_lock)) + return -EBUSY; + + if (!ctrlr->dirty) { + pr_debug("Skipping flush, TCS has latest data.\n"); + goto write_next_wakeup; + } + + /* Invalidate the TCSes first to avoid stale data */ + rpmh_rsc_invalidate(ctrlr_to_drv(ctrlr)); + + /* First flush the cached batch requests */ + ret = flush_batch(ctrlr); + if (ret) + goto exit; + + list_for_each_entry(p, &ctrlr->cache, list) { + if (!is_req_valid(p)) { + pr_debug("%s: skipping RPMH req: a:%#x s:%#x w:%#x", + __func__, p->addr, p->sleep_val, p->wake_val); + continue; + } + ret = send_single(ctrlr, RPMH_SLEEP_STATE, p->addr, + p->sleep_val); + if (ret) + goto exit; + ret = send_single(ctrlr, RPMH_WAKE_ONLY_STATE, p->addr, + p->wake_val); + if (ret) + goto exit; + } + + ctrlr->dirty = false; + +write_next_wakeup: + rpmh_rsc_write_next_wakeup(ctrlr_to_drv(ctrlr)); +exit: + spin_unlock(&ctrlr->cache_lock); + return ret; +} + +/** + * rpmh_invalidate: Invalidate sleep and wake sets in batch_cache + * + * @dev: The device making the request + * + * Invalidate the sleep and wake values in batch_cache. + */ +void rpmh_invalidate(const struct device *dev) +{ + struct rpmh_ctrlr *ctrlr = get_rpmh_ctrlr(dev); + struct batch_cache_req *req, *tmp; + unsigned long flags; + + spin_lock_irqsave(&ctrlr->cache_lock, flags); + list_for_each_entry_safe(req, tmp, &ctrlr->batch_cache, list) + kfree(req); + INIT_LIST_HEAD(&ctrlr->batch_cache); + ctrlr->dirty = true; + spin_unlock_irqrestore(&ctrlr->cache_lock, flags); +} +EXPORT_SYMBOL_GPL(rpmh_invalidate); diff --git a/include/soc/qcom/cmd-db.h b/include/soc/qcom/cmd-db.h new file mode 100644 index 000000000000..47a6cab75e63 --- /dev/null +++ b/include/soc/qcom/cmd-db.h @@ -0,0 +1,48 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (c) 2016-2018, The Linux Foundation. All rights reserved. + * Copyright (c) 2024, Qualcomm Innovation Center, Inc. All rights reserved. + */ + +#ifndef __QCOM_COMMAND_DB_H__ +#define __QCOM_COMMAND_DB_H__ + +#include + +enum cmd_db_hw_type { + CMD_DB_HW_INVALID = 0, + CMD_DB_HW_MIN = 3, + CMD_DB_HW_ARC = CMD_DB_HW_MIN, + CMD_DB_HW_VRM = 4, + CMD_DB_HW_BCM = 5, + CMD_DB_HW_MAX = CMD_DB_HW_BCM, + CMD_DB_HW_ALL = 0xff, +}; + +#if IS_ENABLED(CONFIG_QCOM_COMMAND_DB) +u32 cmd_db_read_addr(const char *resource_id); + +const void *cmd_db_read_aux_data(const char *resource_id, size_t *len); + +bool cmd_db_match_resource_addr(u32 addr1, u32 addr2); + +enum cmd_db_hw_type cmd_db_read_slave_id(const char *resource_id); + +int cmd_db_ready(void); +#else +static inline u32 cmd_db_read_addr(const char *resource_id) +{ return 0; } + +static inline const void *cmd_db_read_aux_data(const char *resource_id, size_t *len) +{ return ERR_PTR(-ENODEV); } + +static inline bool cmd_db_match_resource_addr(u32 addr1, u32 addr2) +{ return false; } + +static inline enum cmd_db_hw_type cmd_db_read_slave_id(const char *resource_id) +{ return -ENODEV; } + +static inline int cmd_db_ready(void) +{ return -ENODEV; } +#endif /* CONFIG_QCOM_COMMAND_DB */ +#endif /* __QCOM_COMMAND_DB_H__ */ diff --git a/include/soc/qcom/rpmh.h b/include/soc/qcom/rpmh.h new file mode 100644 index 000000000000..bdbee1a97d36 --- /dev/null +++ b/include/soc/qcom/rpmh.h @@ -0,0 +1,47 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (c) 2016-2018, The Linux Foundation. All rights reserved. + */ + +#ifndef __SOC_QCOM_RPMH_H__ +#define __SOC_QCOM_RPMH_H__ + +#include +#include + + +#if IS_ENABLED(CONFIG_QCOM_RPMH) +int rpmh_write(const struct device *dev, enum rpmh_state state, + const struct tcs_cmd *cmd, u32 n); + +int rpmh_write_async(const struct device *dev, enum rpmh_state state, + const struct tcs_cmd *cmd, u32 n); + +int rpmh_write_batch(const struct device *dev, enum rpmh_state state, + const struct tcs_cmd *cmd, u32 *n); + +void rpmh_invalidate(const struct device *dev); + +#else + +static inline int rpmh_write(const struct device *dev, enum rpmh_state state, + const struct tcs_cmd *cmd, u32 n) +{ return -ENODEV; } + +static inline int rpmh_write_async(const struct device *dev, + enum rpmh_state state, + const struct tcs_cmd *cmd, u32 n) +{ return -ENODEV; } + +static inline int rpmh_write_batch(const struct device *dev, + enum rpmh_state state, + const struct tcs_cmd *cmd, u32 *n) +{ return -ENODEV; } + +static inline void rpmh_invalidate(const struct device *dev) +{ +} + +#endif /* CONFIG_QCOM_RPMH */ + +#endif /* __SOC_QCOM_RPMH_H__ */ diff --git a/include/soc/qcom/tcs.h b/include/soc/qcom/tcs.h new file mode 100644 index 000000000000..3acca067c72b --- /dev/null +++ b/include/soc/qcom/tcs.h @@ -0,0 +1,81 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (c) 2016-2019, The Linux Foundation. All rights reserved. + */ + +#ifndef __SOC_QCOM_TCS_H__ +#define __SOC_QCOM_TCS_H__ + +#define MAX_RPMH_PAYLOAD 16 + +/** + * rpmh_state: state for the request + * + * RPMH_SLEEP_STATE: State of the resource when the processor subsystem + * is powered down. There is no client using the + * resource actively. + * RPMH_WAKE_ONLY_STATE: Resume resource state to the value previously + * requested before the processor was powered down. + * RPMH_ACTIVE_ONLY_STATE: Active or AMC mode requests. Resource state + * is aggregated immediately. + */ +enum rpmh_state { + RPMH_SLEEP_STATE, + RPMH_WAKE_ONLY_STATE, + RPMH_ACTIVE_ONLY_STATE, +}; + +/** + * struct tcs_cmd: an individual request to RPMH. + * + * @addr: the address of the resource slv_id:18:16 | offset:0:15 + * @data: the resource state request + * @wait: ensure that this command is complete before returning. + * Setting "wait" here only makes sense during rpmh_write_batch() for + * active-only transfers, this is because: + * rpmh_write() - Always waits. + * (DEFINE_RPMH_MSG_ONSTACK will set .wait_for_compl) + * rpmh_write_async() - Never waits. + * (There's no request completion callback) + */ +struct tcs_cmd { + u32 addr; + u32 data; + u32 wait; +}; + +/** + * struct tcs_request: A set of tcs_cmds sent together in a TCS + * + * @state: state for the request. + * @wait_for_compl: wait until we get a response from the h/w accelerator + * (same as setting cmd->wait for all commands in the request) + * @num_cmds: the number of @cmds in this request + * @cmds: an array of tcs_cmds + */ +struct tcs_request { + enum rpmh_state state; + u32 wait_for_compl; + u32 num_cmds; + struct tcs_cmd *cmds; +}; + +#define BCM_TCS_CMD_COMMIT_SHFT 30 +#define BCM_TCS_CMD_COMMIT_MASK 0x40000000 +#define BCM_TCS_CMD_VALID_SHFT 29 +#define BCM_TCS_CMD_VALID_MASK 0x20000000 +#define BCM_TCS_CMD_VOTE_X_SHFT 14 +#define BCM_TCS_CMD_VOTE_MASK 0x3fff +#define BCM_TCS_CMD_VOTE_Y_SHFT 0 +#define BCM_TCS_CMD_VOTE_Y_MASK 0xfffc000 + +/* Construct a Bus Clock Manager (BCM) specific TCS command */ +#define BCM_TCS_CMD(commit, valid, vote_x, vote_y) \ + (((commit) << BCM_TCS_CMD_COMMIT_SHFT) | \ + ((valid) << BCM_TCS_CMD_VALID_SHFT) | \ + ((cpu_to_le32(vote_x) & \ + BCM_TCS_CMD_VOTE_MASK) << BCM_TCS_CMD_VOTE_X_SHFT) | \ + ((cpu_to_le32(vote_y) & \ + BCM_TCS_CMD_VOTE_MASK) << BCM_TCS_CMD_VOTE_Y_SHFT)) + +#endif /* __SOC_QCOM_TCS_H__ */ From patchwork Mon Jul 15 10:08:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 812603 Delivered-To: patch@linaro.org Received: by 2002:adf:fac3:0:b0:367:895a:4699 with SMTP id a3csp1724017wrs; Mon, 15 Jul 2024 03:08:45 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUw1Lptt/sK4akm2Nwjftqd+BFGEAwlr3FC91bljz3ih/Zfau0IwFI9zVObcU5w7IaDIOwWy0xPhII89H1fbWgk X-Google-Smtp-Source: AGHT+IGzCTzKc3t3CI6cuoSHZUQ5Y3/hsD9uqFtkzRENldrE4uIcQAJ4YCshHEwwsOXdySF8HxUo X-Received: by 2002:a17:907:9809:b0:a77:c314:d621 with SMTP id a640c23a62f3a-a780b68a2f8mr1618206666b.13.1721038125023; Mon, 15 Jul 2024 03:08:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721038125; cv=none; d=google.com; s=arc-20160816; b=Qp/u736v8BWOTcCKzHlUDdqTfiooleO1jd/DR27D+n77hGwi7z0ghSVQQIllcAQuIr O9Qcy4vzNcBmsY3syM4H4nzuRc4aZFGku8+u9SdmLtDSoGll3l+Z8f1qcSdOnN6e+Orn WVXR24qI/kOs5FH43J2llahXAguEt+QiZBIBERxjTzHUSsL+mxNO2iq+f6Y0bbI3wHaZ mtsHRXc72ZTm8yiEUqPMhv4DX7ljx69SIk3uZfJZgTMXd6Nv/AE1XmxzirmV8QMRpB0d sDMENIB1omv7MDXspSu/Mqp48MkDO6AJujDi4SHAhntvbPR+askmEB0bFuhLlPx2ieQy Cn6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:cc:to:in-reply-to:references :message-id:content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=ltZEpYWPL6a/RXFmFUmPQKBWq/KTJ3u1HmWmvStedEY=; fh=zcTfjI3NycJyTuuOJ9uzXxS7wfOr4sYKS7eKveHEFzw=; b=XCcMBDAVJKxTzF5Mx7qsTJ8pHP49Y65fNftoNYg6rcDXaehhgafSm7dt/4N7N5afeq BgyRGBz+C5fkq6jPCS7H2J19998TyGCfmbONJq1vHk+mIHEo1oT6MkjL6XHjzjVn9Jei 9u4TdyjGksIYEALwiJt3tDBkHzLWsZ+qX+L/xKFPgjmGAFe7tO5QDb0ZgKzlzl4WhOyn DM/0lz1qWG41AtMZLYb8u/kxoyd5uVI3sR9UvPn7+zrL6u7/pcqe41HKEEm+ImVANm7R vjaLYsZEBCAyEfPt55/aypJB2IvH7toQhOc11PjoVXcVUWtZVYqxZjazFqaBO5vUf4Mh u/pg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bSWfSOUP; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id a640c23a62f3a-a79bc805da2si234302466b.776.2024.07.15.03.08.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 03:08:44 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bSWfSOUP; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1ABE488823; Mon, 15 Jul 2024 12:08:18 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org 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=linaro.org header.i=@linaro.org header.b="bSWfSOUP"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3FBCF8881C; Mon, 15 Jul 2024 12:08:16 +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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) (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 565C5887FE for ; Mon, 15 Jul 2024 12:08:14 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=caleb.connolly@linaro.org Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-a77e85cb9b4so465205366b.0 for ; Mon, 15 Jul 2024 03:08:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721038094; x=1721642894; darn=lists.denx.de; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=ltZEpYWPL6a/RXFmFUmPQKBWq/KTJ3u1HmWmvStedEY=; b=bSWfSOUPH6cCQ32+xPPFlmamU3NusOi0aqXmtttFtFAh0yBFOxG7UeE6FCg31Wjnzp kxY4lCovA7PI4UgLPHWx3BQ8mIhkK+uM0pmHnGQlWjFEs31suPztY4rH908VKyjAIu+v hoM55GPwizbQtCC3Yfj3goDc5MKSXh1NS8gbTpbkoWxMNCmmtlDJhMlR+2dnq6lxxCpC RH5b+V71ANR15H5gnumhS9afBh0tp30Qhw7pGA5Z/GMFsEA2h2Lgayh1xMB0h2gPRlFw axizAZ+oukeu07micPoLySVoGumNLnNFlaZ3o9xxRaZ/le4e30nKE+Ng5znpd5EEDKV3 JFkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721038094; x=1721642894; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ltZEpYWPL6a/RXFmFUmPQKBWq/KTJ3u1HmWmvStedEY=; b=egwWzWKYpN1yS43wVpWF4iqICi4lpaKBPRdSe3oEtpU1N0L76xaNfYT3sjvfWGeOo7 dIKlWVKwPqJCVSxlwdm1RV5pG+SeijtpD/zZRCRLpi7qGW9SkR8OSsnGyMqjAOKtiS95 /LBVhkbULKGCito4ZWNiBzXuJOa82kCX3BGKU6Y6k1cpWl18k1em2VluSFuF8VkQ/7f1 IWW8kTcQLxh/9IfNPp8JBNCsbwsAu1MUUpWErqEW58b0v2H9IoBu+vcRzr8MIb+tTJk1 3w+T11Q3+Fd50Nlzd0EfowhM+pWjynznJf+isf4Kr0Y3z2sJFnjdW5UGkWWBWArVoMp8 D12w== X-Gm-Message-State: AOJu0YzNscYafbIbSBRW5JUio8aX1fN2U51QQw/72RVRNZQZpJeqoVDL QXCuwgVcnoiX6EDD+ptxjq73XbZRvs1UYMCSSqDf07nIzEiNzPnB/svlLivWgsQ= X-Received: by 2002:a17:906:e56:b0:a77:e7b9:fda0 with SMTP id a640c23a62f3a-a780b68a231mr1188082566b.14.1721038093838; Mon, 15 Jul 2024 03:08:13 -0700 (PDT) Received: from [192.168.0.113] ([2a02:8109:aa0d:be00::7424]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a79bc5b7eb4sm198102266b.60.2024.07.15.03.08.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 03:08:13 -0700 (PDT) From: Caleb Connolly Date: Mon, 15 Jul 2024 12:08:03 +0200 Subject: [PATCH v6 04/24] soc: qcom: cmd-db: adjust headers for U-Boot MIME-Version: 1.0 Message-Id: <20240715-b4-qcom-rpmh-v6-4-0c948a25d018@linaro.org> References: <20240715-b4-qcom-rpmh-v6-0-0c948a25d018@linaro.org> In-Reply-To: <20240715-b4-qcom-rpmh-v6-0-0c948a25d018@linaro.org> To: Tom Rini , Caleb Connolly , Neil Armstrong , Sumit Garg , Jaehoon Chung , Simon Glass Cc: u-boot@lists.denx.de, u-boot-qcom@groups.io X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=1217; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=KqQWvKqWen77D+Indz1qnmLFZFG0noaBAnSGS2eyqtI=; b=owEBbQKS/ZANAwAIAQWDMSsZX2S2AcsmYgBmlPUFwf6qiWJedRZvvYn71V0TamJZ9SZRgA6Pz F6UGKt5WfeJAjMEAAEIAB0WIQS2UaFGPGq+0GkMVc0FgzErGV9ktgUCZpT1BQAKCRAFgzErGV9k ts+dD/46T3glAfvA/L8zQ7PDW1uW8XObvJ16SMxJh1svSlSykI1v/DvdiMv7mMBt/ex4iZCN7Vu Ee9QW+8D89a2D1pE8LFO3dN37QT7jIHth8IUQdOa3hhr+7FbkzV05GyCaOdLDFRdPkxIcNqd+Zw P3nPrUYnD78ImPruvIJGnVfXfiRYEyLE+K7/ySU22tuD8PQ2PNcqm2RW8cm/HD8R0kkHg9yzP9a bmvqPbc+hIwuWWJQ2U4qTpoeSO4W7c4KpB//IIfvvp+0VCzGepqJkuoCRxpGjlUgoiPaucoeAu+ S0J9dOeqburIba2NFsIVo25dRYX8ZJBESE2CBqGhZAm4AsUudrp8YmIgz5whQjyu6hh42l+0kHz cWFz1oHez+sJp2mwkXTOxQqxG9KRMgBX+5eeTkwHcpoqQ8SRIq6t+SeJi/hEX7LE4XCfJ7wWqRE 4YvEOkt2S3hal7i7qooy3P6g0+mN6brHIO09E1Xxfu1GXul6KWV7XIDJ5eGElDdmEMzjLmxsc0v /bXkUmtPkVl9KKSRiFpUhJL+bKeVgBPkCRFgjLU37YkX4wYPgEyTScNjSd1aE50nFEWYzEQG80A IkI0C2pwpgG/tJHEwrWswJhoL83bywazgrsbrbDbSXaLsgFRm2EFPBn1wLaWpJy8hTMo+gnWdsk EtVtXJ9Ck4oLang== X-Developer-Key: i=caleb.connolly@linaro.org; a=openpgp; fpr=83B24DA7FE145076BC38BB250CD904EB673A7C47 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.8 at phobos.denx.de X-Virus-Status: Clean Replace unused/unsupported Linux headers with appropriate U-Boot alternatives. Acked-by: Sumit Garg Signed-off-by: Caleb Connolly --- drivers/soc/qcom/cmd-db.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/soc/qcom/cmd-db.c b/drivers/soc/qcom/cmd-db.c index d84572662017..b25f3549c18f 100644 --- a/drivers/soc/qcom/cmd-db.c +++ b/drivers/soc/qcom/cmd-db.c @@ -3,18 +3,17 @@ * Copyright (c) 2016-2018, 2020, The Linux Foundation. All rights reserved. * Copyright (c) 2024, Qualcomm Innovation Center, Inc. All rights reserved. */ -#include -#include +#define pr_fmt(fmt) "cmd-db: " fmt + +#include +#include +#include #include -#include -#include -#include -#include -#include -#include #include +#include +#include #include #define NUM_PRIORITY 2 From patchwork Mon Jul 15 10:08:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 812605 Delivered-To: patch@linaro.org Received: by 2002:adf:fac3:0:b0:367:895a:4699 with SMTP id a3csp1724144wrs; Mon, 15 Jul 2024 03:09:08 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX+4cTGjQu4HSaOaGfTdglVMse6nn14sOtcxSSrGOtF7kWJzW73bgRBjPejyz46h+0Ddlz16B+MBqX707Vk7eWB X-Google-Smtp-Source: AGHT+IEq3Nwk93frO6A8rPdJ7rVgHKPG5picpKjfWh+y67Ck3rcXSEfG1PXfKHbCLDnAi1Qjdmxz X-Received: by 2002:a17:907:3f08:b0:a6f:e699:a9f8 with SMTP id a640c23a62f3a-a799cc6ab1amr891891466b.18.1721038148167; Mon, 15 Jul 2024 03:09:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721038148; cv=none; d=google.com; s=arc-20160816; b=yOCLKDfk3oa4XShfKgzvJNNgeQtDBKThOI+ez1yLPxEYw1+XyeVaP99RSaHxjT0XY3 FHn684OkVsNAMEzxl7xLYS5ieCHjOOE/n4KDS8W/XohoROndPS46Z+gNTlDQkTqY46z1 b5eyPHv4WaYFJnzyDEvTck1p3y9gmMQvkj0XwKqHv/zoVUsxkUObB4d+3VJwUt14a79U pKSjPE8GBHFWONvEZ0mA2EjXskNDm5qSVN/v2SfOMMUShSpMJdmeziLkhUOUZBrlAwjI 4LDBchrhpdDMWPIdL/AZQ29Mv77n03Yx++vFMBUN85rKvmHo70XlnZ9vs5lNty9fMEk/ vjKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:cc:to:in-reply-to:references :message-id:content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=EetdYxlnzuo/xnHDci9N39KEjBvIEc/fp8D9uzOBkPE=; fh=zcTfjI3NycJyTuuOJ9uzXxS7wfOr4sYKS7eKveHEFzw=; b=L6FgwsU5xajDXvFLoi0W56JPS93hPMnzOgEZoySPKYarPvhvfLGz8NnsrvtF85zkus q2aO5wUPbTfRLUySZFlcDNHMnVNY2arwYqdKNPeyAFWBkLUzF11VUps0ssiI30l7nUcQ e+KHDfMRVVdnynslYMMk0h/d88+uSXXf9Mb6g1maqBNosdYTsLkDRchaPZEgfu8XqmvE Oh1orfMRxt7NcZLbABtG8RWyjtfP3OrZUrkvH0cqL0HgVaiFi1t+tgZlnUOIQdcxYz0b zqVB3J+oMuTuxI8cvI5iyFsK0WgobTO/quvGAGxYJTNyVHvIBbF4U2TMQ4CyUb/jcDkZ fSsg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FSDwdlKH; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id a640c23a62f3a-a79bc824253si228618466b.843.2024.07.15.03.09.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 03:09:08 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FSDwdlKH; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D24BA88805; Mon, 15 Jul 2024 12:08:20 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org 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=linaro.org header.i=@linaro.org header.b="FSDwdlKH"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 43D00887FE; Mon, 15 Jul 2024 12:08:18 +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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) (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 53BDA88815 for ; Mon, 15 Jul 2024 12:08:15 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=caleb.connolly@linaro.org Received: by mail-ej1-x632.google.com with SMTP id a640c23a62f3a-a77d85f7fa3so642855666b.0 for ; Mon, 15 Jul 2024 03:08:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721038095; x=1721642895; darn=lists.denx.de; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=EetdYxlnzuo/xnHDci9N39KEjBvIEc/fp8D9uzOBkPE=; b=FSDwdlKHQqsT7qifVUo+9sMn3oE7+jAfY+QgE6/tECWsORO5FHbN7US3Z9618JPire qlEdKArs6Ba9Ftj9eenAXqiaYMRf/APOULVfHMsqZCfhYT14/L3MeCGwdid7S5R4RKSr LPW0iM1gAXvQ+clFr0q7JawdP6EpGCQbOFcX4qTOQqGuqbAhRhaW1DXBJZapsB6G7Zsq WbJWmkQ0nZTuYX0ZMt1+FYWPdio+XkrpISKaEDdOBy8Yx2SMaiRNabAsUD0591MW9Oje V/LgXkmq7lGADsMynBAx7tWfF0jIRjAs/gF4xneqNlav1L4g5DIxtTk0uMB/8jyjIZZM Bt6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721038095; x=1721642895; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EetdYxlnzuo/xnHDci9N39KEjBvIEc/fp8D9uzOBkPE=; b=eIBw0ivdNw8FTzwUhZxK2oXuDHIyhCP/+A9Aw++njEZwoWp3v/YuHHyhYGWq/7RL3g gQVU0yufXCH2mnp9l6yR9aGOEdXVl5KIOnwDnVUiDqmt8RdQvw1CoaPeLFfavdqfdN4/ rUS2ENUugBHzmoUaWpKWwOHVJOu58BvKynENOvWd7ZkiOsyGHu5hrLiNZpjrVBJvY+zk r/HxqAw0LKA/+PVYe4fpAPyG34x9aw50cMmjIHfCtEi2Sh+FGF6In3kjbgyrL6grhbgv EipbNGr0KqZd5DtrW6r9X6ic3MLaM9j8u7yx9ghRHWaFA+uoInAikZW86YReSPyF3Qe/ h/YQ== X-Gm-Message-State: AOJu0Ywv4vRil6Rbi08z3dEWLYMt91QSS8BPyBwqF8VTEo7guIu6sk6B 0KH+2unTuMz1UWNqYBsbg1rc5KXSwXIxAEI2O+EJxSOwQmz2v+fFgIoPAH7nsSI= X-Received: by 2002:a17:907:7210:b0:a77:ecf0:84e5 with SMTP id a640c23a62f3a-a799d339b14mr881523366b.14.1721038094856; Mon, 15 Jul 2024 03:08:14 -0700 (PDT) Received: from [192.168.0.113] ([2a02:8109:aa0d:be00::7424]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a79bc5b7eb4sm198102266b.60.2024.07.15.03.08.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 03:08:14 -0700 (PDT) From: Caleb Connolly Date: Mon, 15 Jul 2024 12:08:04 +0200 Subject: [PATCH v6 05/24] soc: qcom: cmd-db: drop unused functions MIME-Version: 1.0 Message-Id: <20240715-b4-qcom-rpmh-v6-5-0c948a25d018@linaro.org> References: <20240715-b4-qcom-rpmh-v6-0-0c948a25d018@linaro.org> In-Reply-To: <20240715-b4-qcom-rpmh-v6-0-0c948a25d018@linaro.org> To: Tom Rini , Caleb Connolly , Neil Armstrong , Sumit Garg , Jaehoon Chung , Simon Glass Cc: u-boot@lists.denx.de, u-boot-qcom@groups.io X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=5776; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=WCVxepS5QQJhuc2cv98lalhlDGnsvsp23vf8bNaYEdc=; b=owEBbQKS/ZANAwAIAQWDMSsZX2S2AcsmYgBmlPUF6wxTVFMSfznc9mZwctdlBnBx2DT7rT0cR 64q4yoQiUeJAjMEAAEIAB0WIQS2UaFGPGq+0GkMVc0FgzErGV9ktgUCZpT1BQAKCRAFgzErGV9k ts+sD/4ivU2O7LsmerxTe6Qhsh48RlWsidxOTvwACk5St9RyYSnTgeL60x7hEalLtLvyO1B1vhF cdEy0c8iSMAGsmBo2K9j6twNo9IO+D6lcdc2PLm1dQ6LK0sIgnH/OwUL996pNNwb1/l6LCDGPTx iLWXRXSSGeO2Nhv/DcV2AMda+xNl7iup2EWeTanA3udYwv3TcecsC8n0VZoPs0zTOrvVbL+UMQV /keFIvfLNjk0N369k/Vt+w37Oyc3un8DOcCEbn5NSAK06eCn6ykNSSXg5XtLv8qEWEXlyn5MIf9 EF/rGMnqiKpvVzprUFEnxWDp8LmCXH0m+mTMecK83x8Y4rx0YASRPTQlMNyGt740T18ZVvRFNLy APNdJRgxEbliJpk2JlPJNtJfC4TQZC8wwm2Ua4fj/f3Iy1GN6rjvMnSQeFwrTOCfE4dTJiPSYkT dq60n4JqI3r8bi8csoxJPANUEFSX6OwAgzGqh7gS1WrkT54Io0o84brQeNo1/2SE3QK1a+bswpf Q8UZvChPHnxCNxlBqRqaAFJpPh73QNQ+AuBNa/MiADB/fChV1HkATsVH4P+8IKGsdebHD3Xitns ZQV7BpEfAyP0M5HGz0IRgHrb4amAcpoUM8W+HwUI0u5ThC9Y/6DdTs30vUkwXfSc1/f/A5QR1D0 O/yUkCdc83j7RyQ== X-Developer-Key: i=caleb.connolly@linaro.org; a=openpgp; fpr=83B24DA7FE145076BC38BB250CD904EB673A7C47 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.8 at phobos.denx.de X-Virus-Status: Clean Due to our simpler rpmh-rsc driver and lack of debugfs, we don't need quite a few cmd-db functions, just drop them. Acked-by: Sumit Garg Signed-off-by: Caleb Connolly --- drivers/soc/qcom/cmd-db.c | 144 ---------------------------------------------- include/soc/qcom/cmd-db.h | 15 ----- 2 files changed, 159 deletions(-) diff --git a/drivers/soc/qcom/cmd-db.c b/drivers/soc/qcom/cmd-db.c index b25f3549c18f..4317310d0bcd 100644 --- a/drivers/soc/qcom/cmd-db.c +++ b/drivers/soc/qcom/cmd-db.c @@ -194,150 +194,8 @@ u32 cmd_db_read_addr(const char *id) return ret < 0 ? 0 : le32_to_cpu(ent->addr); } EXPORT_SYMBOL_GPL(cmd_db_read_addr); -/** - * cmd_db_read_aux_data() - Query command db for aux data. - * - * @id: Resource to retrieve AUX Data on - * @len: size of data buffer returned - * - * Return: pointer to data on success, error pointer otherwise - */ -const void *cmd_db_read_aux_data(const char *id, size_t *len) -{ - int ret; - const struct entry_header *ent; - const struct rsc_hdr *rsc_hdr; - - ret = cmd_db_get_header(id, &ent, &rsc_hdr); - if (ret) - return ERR_PTR(ret); - - if (len) - *len = le16_to_cpu(ent->len); - - return rsc_offset(rsc_hdr, ent); -} -EXPORT_SYMBOL_GPL(cmd_db_read_aux_data); - -/** - * cmd_db_match_resource_addr() - Compare if both Resource addresses are same - * - * @addr1: Resource address to compare - * @addr2: Resource address to compare - * - * Return: true if two addresses refer to the same resource, false otherwise - */ -bool cmd_db_match_resource_addr(u32 addr1, u32 addr2) -{ - /* - * Each RPMh VRM accelerator resource has 3 or 4 contiguous 4-byte - * aligned addresses associated with it. Ignore the offset to check - * for VRM requests. - */ - if (addr1 == addr2) - return true; - else if (SLAVE_ID(addr1) == CMD_DB_HW_VRM && VRM_ADDR(addr1) == VRM_ADDR(addr2)) - return true; - - return false; -} -EXPORT_SYMBOL_GPL(cmd_db_match_resource_addr); - -/** - * cmd_db_read_slave_id - Get the slave ID for a given resource address - * - * @id: Resource id to query the DB for version - * - * Return: cmd_db_hw_type enum on success, CMD_DB_HW_INVALID on error - */ -enum cmd_db_hw_type cmd_db_read_slave_id(const char *id) -{ - int ret; - const struct entry_header *ent; - u32 addr; - - ret = cmd_db_get_header(id, &ent, NULL); - if (ret < 0) - return CMD_DB_HW_INVALID; - - addr = le32_to_cpu(ent->addr); - return (addr >> SLAVE_ID_SHIFT) & SLAVE_ID_MASK; -} -EXPORT_SYMBOL_GPL(cmd_db_read_slave_id); - -#ifdef CONFIG_DEBUG_FS -static int cmd_db_debugfs_dump(struct seq_file *seq, void *p) -{ - int i, j; - const struct rsc_hdr *rsc; - const struct entry_header *ent; - const char *name; - u16 len, version; - u8 major, minor; - - seq_puts(seq, "Command DB DUMP\n"); - - for (i = 0; i < MAX_SLV_ID; i++) { - rsc = &cmd_db_header->header[i]; - if (!rsc->slv_id) - break; - - switch (le16_to_cpu(rsc->slv_id)) { - case CMD_DB_HW_ARC: - name = "ARC"; - break; - case CMD_DB_HW_VRM: - name = "VRM"; - break; - case CMD_DB_HW_BCM: - name = "BCM"; - break; - default: - name = "Unknown"; - break; - } - - version = le16_to_cpu(rsc->version); - major = version >> 8; - minor = version; - - seq_printf(seq, "Slave %s (v%u.%u)\n", name, major, minor); - seq_puts(seq, "-------------------------\n"); - - ent = rsc_to_entry_header(rsc); - for (j = 0; j < le16_to_cpu(rsc->cnt); j++, ent++) { - seq_printf(seq, "0x%05x: %*pEp", le32_to_cpu(ent->addr), - (int)strnlen(ent->id, sizeof(ent->id)), ent->id); - - len = le16_to_cpu(ent->len); - if (len) { - seq_printf(seq, " [%*ph]", - len, rsc_offset(rsc, ent)); - } - seq_putc(seq, '\n'); - } - } - - return 0; -} - -static int open_cmd_db_debugfs(struct inode *inode, struct file *file) -{ - return single_open(file, cmd_db_debugfs_dump, inode->i_private); -} -#endif - -static const struct file_operations cmd_db_debugfs_ops = { -#ifdef CONFIG_DEBUG_FS - .open = open_cmd_db_debugfs, -#endif - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; - static int cmd_db_dev_probe(struct platform_device *pdev) { struct reserved_mem *rmem; int ret = 0; @@ -359,10 +217,8 @@ static int cmd_db_dev_probe(struct platform_device *pdev) dev_err(&pdev->dev, "Invalid Command DB Magic\n"); return -EINVAL; } - debugfs_create_file("cmd-db", 0400, NULL, NULL, &cmd_db_debugfs_ops); - device_set_pm_not_required(&pdev->dev); return 0; } diff --git a/include/soc/qcom/cmd-db.h b/include/soc/qcom/cmd-db.h index 47a6cab75e63..753c7923f8e5 100644 --- a/include/soc/qcom/cmd-db.h +++ b/include/soc/qcom/cmd-db.h @@ -21,28 +21,13 @@ enum cmd_db_hw_type { #if IS_ENABLED(CONFIG_QCOM_COMMAND_DB) u32 cmd_db_read_addr(const char *resource_id); -const void *cmd_db_read_aux_data(const char *resource_id, size_t *len); - -bool cmd_db_match_resource_addr(u32 addr1, u32 addr2); - -enum cmd_db_hw_type cmd_db_read_slave_id(const char *resource_id); - int cmd_db_ready(void); #else static inline u32 cmd_db_read_addr(const char *resource_id) { return 0; } -static inline const void *cmd_db_read_aux_data(const char *resource_id, size_t *len) -{ return ERR_PTR(-ENODEV); } - -static inline bool cmd_db_match_resource_addr(u32 addr1, u32 addr2) -{ return false; } - -static inline enum cmd_db_hw_type cmd_db_read_slave_id(const char *resource_id) -{ return -ENODEV; } - static inline int cmd_db_ready(void) { return -ENODEV; } #endif /* CONFIG_QCOM_COMMAND_DB */ #endif /* __QCOM_COMMAND_DB_H__ */ From patchwork Mon Jul 15 10:08:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 812606 Delivered-To: patch@linaro.org Received: by 2002:adf:fac3:0:b0:367:895a:4699 with SMTP id a3csp1724209wrs; Mon, 15 Jul 2024 03:09:19 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXJLxWWDC4EuhTJAHIhD0SM/bib10qR1nCQ0h59GFObIx5zR6z0tLEnRKnZjWvZRqYC6KtIZJ7LyGXosQ79yZjb X-Google-Smtp-Source: AGHT+IEGqVNTbJRz4+/xegX37CRL133o9H0xx0G5MAz9I8QlkiSSWkOJNltjWsWdzpMx9/asCAkK X-Received: by 2002:a17:906:fcb1:b0:a6f:bf5d:b365 with SMTP id a640c23a62f3a-a780b6fe485mr1406304666b.33.1721038159311; Mon, 15 Jul 2024 03:09:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721038159; cv=none; d=google.com; s=arc-20160816; b=HFHjNk/iY/UNx30yzWM5okbJtW944BmCLFYdnD41OQ8SXMJgXlMRpsdQxV7f/tMr9z IB5c7tM8zYUH7yVPfT97PYMSPR+H06zaiM+HOSBqVDSy4wldV7Dkhtt3BJSwUR+FP7lj /qBL6QvrvmA3Z7o9cJFeQw+DF6/w16AzLf55+woN+FhgCTxlubwJ3nGRmSBAOOMAgntr nhIs8m/4rq2eb0nbkMBia/XsmMfJ8jMQBpyqBeushJvfHSaev1+m1Cy3n1UU9RBEQHvV kkvAco7jhki94/QhHQ4gkqPX34MtQyy/adg4PGvQsCSj1euNKq6T4FYZPXx5oorGRDdU UHJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:cc:to:in-reply-to:references :message-id:content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=RHMZ1aGv0AWg6leyUS+oq0I1+1UFtza/U4QEs22fWM8=; fh=zcTfjI3NycJyTuuOJ9uzXxS7wfOr4sYKS7eKveHEFzw=; b=Coys51s9Gu3UTtCzj5t1IlPGRxXP8tWmrJa9209dTamqlI976RxmLCQy20xHd+llqq LUKBy15DHvfU0dH2K8QqkalFZfUn2dAHj/xTIvhn/PskmORvNnuI6M3jnmQWf+YFr4hV s6W7mHQknnVVi7E0kPAt45WlXXQzmaPUA+gDAhsz1Rvxcij/eQHLEBAfqz3kQTcJ6H0M AWJdn83VtL8rs0L0Gn2CyWt1OTK21d/USW0+as+nqf3xes55EvmpxL8PMw0HP5ovXOiA 3wyFkNdjgf7Aq3bn4l6DZ23y5ZBDrCTsd4THw5kC52A/5MnrlYCryOanWs7EK+KLbsvH O4+g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="X/DI4Xko"; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id a640c23a62f3a-a79bc7c2402si225629166b.461.2024.07.15.03.09.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 03:09:19 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="X/DI4Xko"; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3E3248881F; Mon, 15 Jul 2024 12:08:21 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org 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=linaro.org header.i=@linaro.org header.b="X/DI4Xko"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 40AA888835; Mon, 15 Jul 2024 12:08:19 +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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) (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 34EC988805 for ; Mon, 15 Jul 2024 12:08:17 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=caleb.connolly@linaro.org Received: by mail-ej1-x630.google.com with SMTP id a640c23a62f3a-a7527afa23cso487697666b.2 for ; Mon, 15 Jul 2024 03:08:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721038097; x=1721642897; darn=lists.denx.de; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=RHMZ1aGv0AWg6leyUS+oq0I1+1UFtza/U4QEs22fWM8=; b=X/DI4Xkokq+dRuGB1jgur1u4qd013KVMTg7McErppAWKOvfa2QvQiaS9PGQjXzT1tw uoy6V4GQcrvb4BBX9YAZxm8JWgvgdEuBRgN+oQD7WWmy0rnCgZxi+ih7DC5bSQWYTfGl 3VxCC7AvA5yA/A3viq7E+lg7jDpxQNCq/SLor0oeN5gSlHYX3r9rISkQXlXpdJqaYI9Q TKIXD/AymSWzTNxV7pRxE06TTCVtn8glrGagMKf9ddrsS6heU7QFoZkxxlq6B1oMuU3K +CbiteCXB1JCA9xT4i0jhcU8eLbQUWQ/qYjfaFBkpz6KyCJ27Wfs7yy+7vH65n4qWYBn 8XIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721038097; x=1721642897; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RHMZ1aGv0AWg6leyUS+oq0I1+1UFtza/U4QEs22fWM8=; b=eJLvmiOnYmuPDDI9tsyl5W+skuH6Rn0ovo7x85Oifqu6+KbYUiC3Jzo1cBd8b9rhcZ I979qptQnWQ160U5mB0WjF1vs5E4SroilCO1Yu8uvwoUuGhuZ1WwPAmnVwE9483CKmya g8Lg3MbumDHxw7jkjD47bPm0VwLYQU47zaokXfrtkQ/uZRbcXiOt5Bs7igEmZWzdiogb V76iVFM/MuvWrZTKdAr+D6DZ2Vk9PUczXV2TtzgTLoZWbUMsBplhWfsSA10KsqMUByYF cGXldvf6aZWL8vORCgSBOgSymTMlZONmsBVz0HA744nvxdQYJ2Bqj+zs/mQMI906qE7u Lz3g== X-Gm-Message-State: AOJu0YzjTURDh3bBx4UI9XD2h3gptKkoRKZ0cILSkS2KU8iRwVZp2L1i tV118ggPYTOBRLS6pyZ7ZDkqOTq63K73OJn2JgEZ4qQrWdO6aePpABN5WQA6cIc= X-Received: by 2002:a17:906:d7a2:b0:a6f:af8e:b75d with SMTP id a640c23a62f3a-a780b689418mr1373989866b.8.1721038096571; Mon, 15 Jul 2024 03:08:16 -0700 (PDT) Received: from [192.168.0.113] ([2a02:8109:aa0d:be00::7424]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a79bc5b7eb4sm198102266b.60.2024.07.15.03.08.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 03:08:15 -0700 (PDT) From: Caleb Connolly Date: Mon, 15 Jul 2024 12:08:05 +0200 Subject: [PATCH v6 06/24] soc: qcom: cmd-db: adjust probe for U-Boot MIME-Version: 1.0 Message-Id: <20240715-b4-qcom-rpmh-v6-6-0c948a25d018@linaro.org> References: <20240715-b4-qcom-rpmh-v6-0-0c948a25d018@linaro.org> In-Reply-To: <20240715-b4-qcom-rpmh-v6-0-0c948a25d018@linaro.org> To: Tom Rini , Caleb Connolly , Neil Armstrong , Sumit Garg , Jaehoon Chung , Simon Glass Cc: u-boot@lists.denx.de, u-boot-qcom@groups.io X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=4418; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=M/Dy+drxY6JdtVT4jABYKrj/IbLuNhF6hCcK6DPC5uM=; b=owEBbAKT/ZANAwAIAQWDMSsZX2S2AcsmYgBmlPUF9gCiqmXpNfh6YwKhXCTs6iLO5NGngPUhO IPtVc8xoDCJAjIEAAEIAB0WIQS2UaFGPGq+0GkMVc0FgzErGV9ktgUCZpT1BQAKCRAFgzErGV9k tpOHD/j+YzTC2eYhanmq67g7IKXddPGaSicgZHqF46/GVPs8U+bAaEUwMcAw/qjfAblPNZF/cS4 2uUhJme4nkCaz77x5ofJym3m98jcPptwJMX6MiFIl7VuP+VXtdVkO2p4LVL9Xl3T2BTK3rgpe5j 1yjGqeTJN8pBCtI1egOfUN4V0vY7638gDeQjcIoJHG0vofQLDlHk3CrLfFxSATEx4jo5kgcP4Pf UgqyBvif6jCw4gdG6KquTcJQrvwBEV9GI7wcCf4itx6bJkuTMMoljga8Q4sef6Sf4I17Um3Insx JnJE5rLS6j8AP2Yj2INgUTdsSWWHaT0i6mWeK5yeGbT1fvkT421nHJhBlk2EDDNBZ/4jsoWwcAk UvHbtx7dLbUeCT/aYAOvDMceQROqnafHMUQM8XtoMor3w37PcSVhUQZZDlgAYHRO7wW5zCQS9yy nH1840QC2G9kGOE3sBsYHi6saixMhiECSXLmkV4Ui8TIKQOgd4D8hnnLkiWyL+AO+QxAAmAZJA8 /7K82WKallnyOHtz+7hZnBt3YxZB9OnN7ggy07iecjfbIofuhxN/5TRnbLEANYXOJWoVgfgacfY O3C/efa44wSTyORudHAEli/CJb4aDVMNOU3UNYlHzBZXAPIewk6E6q35h9NXvGEbEjy5CLO48j0 TLz4vWOxQe/YS X-Developer-Key: i=caleb.connolly@linaro.org; a=openpgp; fpr=83B24DA7FE145076BC38BB250CD904EB673A7C47 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.8 at phobos.denx.de X-Virus-Status: Clean Integrate cmd-db into the U-Boot driver model. This is just a wrapper around an in-memory database, so we just need to get the address and validate that cmd-db is there. Since cmd_db_header will be stored in the .data section we can skip bind if it's already set. Signed-off-by: Caleb Connolly Reviewed-by: Simon Glass --- To: Simon Glass --- drivers/soc/qcom/cmd-db.c | 72 +++++++++++++++-------------------------------- include/soc/qcom/cmd-db.h | 3 -- 2 files changed, 23 insertions(+), 52 deletions(-) diff --git a/drivers/soc/qcom/cmd-db.c b/drivers/soc/qcom/cmd-db.c index 4317310d0bcd..f707aed59adf 100644 --- a/drivers/soc/qcom/cmd-db.c +++ b/drivers/soc/qcom/cmd-db.c @@ -105,9 +105,9 @@ static bool cmd_db_magic_matches(const struct cmd_db_header *header) return memcmp(magic, CMD_DB_MAGIC, ARRAY_SIZE(CMD_DB_MAGIC)) == 0; } -static struct cmd_db_header *cmd_db_header; +static struct cmd_db_header *cmd_db_header __section(".data") = NULL; static inline const void *rsc_to_entry_header(const struct rsc_hdr *hdr) { u16 offset = le16_to_cpu(hdr->header_offset); @@ -123,24 +123,8 @@ rsc_offset(const struct rsc_hdr *hdr, const struct entry_header *ent) return cmd_db_header->data + offset + loffset; } -/** - * cmd_db_ready - Indicates if command DB is available - * - * Return: 0 on success, errno otherwise - */ -int cmd_db_ready(void) -{ - if (cmd_db_header == NULL) - return -EPROBE_DEFER; - else if (!cmd_db_magic_matches(cmd_db_header)) - return -EINVAL; - - return 0; -} -EXPORT_SYMBOL_GPL(cmd_db_ready); - static int cmd_db_get_header(const char *id, const struct entry_header **eh, const struct rsc_hdr **rh) { const struct rsc_hdr *rsc_hdr; @@ -194,55 +178,45 @@ u32 cmd_db_read_addr(const char *id) return ret < 0 ? 0 : le32_to_cpu(ent->addr); } EXPORT_SYMBOL_GPL(cmd_db_read_addr); -static int cmd_db_dev_probe(struct platform_device *pdev) +int cmd_db_bind(struct udevice *dev) { - struct reserved_mem *rmem; - int ret = 0; + void __iomem *base; + ofnode node; - rmem = of_reserved_mem_lookup(pdev->dev.of_node); - if (!rmem) { - dev_err(&pdev->dev, "failed to acquire memory region\n"); - return -EINVAL; - } - - cmd_db_header = memremap(rmem->base, rmem->size, MEMREMAP_WB); - if (!cmd_db_header) { - ret = -ENOMEM; - cmd_db_header = NULL; - return ret; + if (cmd_db_header) + return 0; + + node = dev_ofnode(dev); + + debug("%s(%s)\n", __func__, ofnode_get_name(node)); + + base = (void __iomem *)ofnode_get_addr(node); + if ((fdt_addr_t)base == FDT_ADDR_T_NONE) { + log_err("%s: Failed to read base address\n", __func__); + return -ENOENT; } + cmd_db_header = base; if (!cmd_db_magic_matches(cmd_db_header)) { - dev_err(&pdev->dev, "Invalid Command DB Magic\n"); + log_err("%s: Invalid Command DB Magic\n", __func__); return -EINVAL; } - device_set_pm_not_required(&pdev->dev); - return 0; } -static const struct of_device_id cmd_db_match_table[] = { +static const struct udevice_id cmd_db_ids[] = { { .compatible = "qcom,cmd-db" }, { } }; -MODULE_DEVICE_TABLE(of, cmd_db_match_table); -static struct platform_driver cmd_db_dev_driver = { - .probe = cmd_db_dev_probe, - .driver = { - .name = "cmd-db", - .of_match_table = cmd_db_match_table, - .suppress_bind_attrs = true, - }, +U_BOOT_DRIVER(qcom_cmd_db) = { + .name = "qcom_cmd_db", + .id = UCLASS_MISC, + .probe = cmd_db_bind, + .of_match = cmd_db_ids, }; -static int __init cmd_db_device_init(void) -{ - return platform_driver_register(&cmd_db_dev_driver); -} -core_initcall(cmd_db_device_init); - MODULE_DESCRIPTION("Qualcomm Technologies, Inc. Command DB Driver"); MODULE_LICENSE("GPL v2"); diff --git a/include/soc/qcom/cmd-db.h b/include/soc/qcom/cmd-db.h index 753c7923f8e5..1190f2c22cab 100644 --- a/include/soc/qcom/cmd-db.h +++ b/include/soc/qcom/cmd-db.h @@ -21,13 +21,10 @@ enum cmd_db_hw_type { #if IS_ENABLED(CONFIG_QCOM_COMMAND_DB) u32 cmd_db_read_addr(const char *resource_id); -int cmd_db_ready(void); #else static inline u32 cmd_db_read_addr(const char *resource_id) { return 0; } -static inline int cmd_db_ready(void) -{ return -ENODEV; } #endif /* CONFIG_QCOM_COMMAND_DB */ #endif /* __QCOM_COMMAND_DB_H__ */ From patchwork Mon Jul 15 10:08:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 812607 Delivered-To: patch@linaro.org Received: by 2002:adf:fac3:0:b0:367:895a:4699 with SMTP id a3csp1724282wrs; Mon, 15 Jul 2024 03:09:30 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV7x1CC4QySTIKQgATBTR7ZWcUfP9pJcYQERk4ohHg3Kykiq9oeW6S9ImmOoVIm00ve6NklDUfQCJ9sF4kndCXv X-Google-Smtp-Source: AGHT+IGeQ25a2viH/XoKkO7rUKPZ/GG/2KANvUdO0X7XNBCxEzso1KHfplPR7Sz0VHy4GZ5yKyxi X-Received: by 2002:a05:6402:50c8:b0:58e:3501:5c25 with SMTP id 4fb4d7f45d1cf-594baf8d6dbmr14876400a12.13.1721038170529; Mon, 15 Jul 2024 03:09:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721038170; cv=none; d=google.com; s=arc-20160816; b=gMkeAk8fgM683iGEanhPZvJTaeNZwIvskQrq5XDBwr3XL03YKfTtTP7Zz67Xzu2+wN lFua03miq0MY7vYdxasz0GVPhIQ8QEGQQMzKQ4iM/DJMEgVsj0fO2WB+tvsH6pQleUem abQbX+4ZqzoLVfLrWLtHxJU8HePZjOTq5roPe14iaBzyUyzqUZTtX7OtneXx3boCQktY sFfxo27wiMxlYKNz7k+IEr0z3gyLuaYFxKjhbac5ZnNaQVhrdnX03h+Eu9HypLYRN0NG bpoDrpe0X2T2qXWMJGNbl4830YnyrMkbBDrcWVssIJtgSqc8EYIxEdISZ5XKa+wVu4WZ 7jXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:cc:to:in-reply-to:references :message-id:content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=RHqpSx9PbuP1dN/L/vtPhpQ9a+6UvvgJ8uEY9WKCVS8=; fh=zcTfjI3NycJyTuuOJ9uzXxS7wfOr4sYKS7eKveHEFzw=; b=zevWCD+3iE6sVqzVEKM6f1JMH/eN6EIaO2p0b3J+gN22H+sJWH/acG4tfAeQWjDopz Y3YE/8CSoXWNPA9y2pfFgpCVxbgHyIVLeE1kyZsRFmVnsiG/zGVuyllAShV9bAmxRfiI AF03eQIITfodfY1ri3cbV2Gc+zeSt6wtzSHXZDtUM4Bi45BFKjUShs9dvLCKyznIkjYw KLs2uAHpDjrXzds/tAFXzzUCh6PM5WSHkzXmZjsrgJoFfwAvVAZMnq7JA2WNnXN0pGOS iYgBjK/xbEOw3k1qXIy+dmI5yeBO/REGzn0HKGudVRgtl7PvOPJrQ3ELYmAl1jVnBAYU IMCw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AwOursey; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-59b2504b82fsi2321583a12.179.2024.07.15.03.09.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 03:09:30 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AwOursey; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BA05F88837; Mon, 15 Jul 2024 12:08:21 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org 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=linaro.org header.i=@linaro.org header.b="AwOursey"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5D028887EB; Mon, 15 Jul 2024 12:08:20 +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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) (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 5EF91887FE for ; Mon, 15 Jul 2024 12:08:18 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=caleb.connolly@linaro.org Received: by mail-ej1-x629.google.com with SMTP id a640c23a62f3a-a77b60cafecso489476766b.1 for ; Mon, 15 Jul 2024 03:08:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721038098; x=1721642898; darn=lists.denx.de; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=RHqpSx9PbuP1dN/L/vtPhpQ9a+6UvvgJ8uEY9WKCVS8=; b=AwOursey5cO/AzSr9jPKSMp/xxYQOM+RxRuGxF7JlXeuf9OvxzLYKcMcYhnyjeIooh iENy6ua5dOFR/wjF+8lupy2yArz1jQ7e1Neo5TwyDIoMMeORVIi8bMwNJQp9b5yqCfO5 xPLa+MxoysyXF+eE8s3KP7RXXAl7JEIgPFgR0UgemPCGGjKXBJDcxj0ROGzy40qd7qOE UgwzapXXd+LbF0MIG5B/Z+G8mTqdo8f1GFSW/KvQtYgwEPzBQjXw8+460kUZAFmfa3AP R7aShyNm2JIu7ZCwjQvCyr6Xfbk7NhtIWWMIktmq+HBHR/OSyPNkbPSBHjKMzjW5SYXM +sdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721038098; x=1721642898; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RHqpSx9PbuP1dN/L/vtPhpQ9a+6UvvgJ8uEY9WKCVS8=; b=kYgLvl6agVr0dE2oRCn4wHScvwypftzht7tLoGNkaWUaKl8ReP8eQmN/ltEoduYSYW UkYUG9V/wRpo92z+Gph3B/Ub5RcDSeB12/JKHnZKVMJMq9/UkBOEnzhvFtoyZV/at7mo YVxQlBhHcy5mCFYv7tj8mgsbXCxOlErmaGzrrxDxPdKg8r7OYunwCmzs/DG9NApgqgPy FFspsj7fC7ZstDyJMV6DwqeAwfy2/LYaOhaBKJbfhNNc0dP2JGor8m3srlnYsfykiJRU RNnkW1SehatgqPydJYNHcVDhdAW2ghnJs6dTtXVaNjcu+DWsaXx84oh8q+UjIRiJX/1W x25Q== X-Gm-Message-State: AOJu0YzMuk5Hhagy075KdpGguwafe7+EOCjOfKOYKIdjbOs7VXPyeG1R im1+0fzqiQSNlH9YebHVtEnYtTv/c2hYpF93IHodG9/T/wGHHVFtD1pibpaKJy0= X-Received: by 2002:a17:906:378b:b0:a77:dd1c:6270 with SMTP id a640c23a62f3a-a780b688911mr1220668566b.5.1721038097904; Mon, 15 Jul 2024 03:08:17 -0700 (PDT) Received: from [192.168.0.113] ([2a02:8109:aa0d:be00::7424]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a79bc5b7eb4sm198102266b.60.2024.07.15.03.08.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 03:08:17 -0700 (PDT) From: Caleb Connolly Date: Mon, 15 Jul 2024 12:08:06 +0200 Subject: [PATCH v6 07/24] soc: qcom: cmd-db: adjust for U-Boot API MIME-Version: 1.0 Message-Id: <20240715-b4-qcom-rpmh-v6-7-0c948a25d018@linaro.org> References: <20240715-b4-qcom-rpmh-v6-0-0c948a25d018@linaro.org> In-Reply-To: <20240715-b4-qcom-rpmh-v6-0-0c948a25d018@linaro.org> To: Tom Rini , Caleb Connolly , Neil Armstrong , Sumit Garg , Jaehoon Chung , Simon Glass Cc: u-boot@lists.denx.de, u-boot-qcom@groups.io X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=1904; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=bTTuKRxBXP5aXiwFaAEhLtRRXg5TW/UvCLhmytDgYzo=; b=owEBbQKS/ZANAwAIAQWDMSsZX2S2AcsmYgBmlPUFtF0QSNzCcQmzyK10IpMRj4+5pl3QRWNqb e/jsEPdgO+JAjMEAAEIAB0WIQS2UaFGPGq+0GkMVc0FgzErGV9ktgUCZpT1BQAKCRAFgzErGV9k tqZaD/wLtT6L5J75nkLeTKZBXAwzzv20qKKBhAUgyL55U/jDSjlQ5cuiWSegaxfvgkXCSmSvAfT cDAq95ahZ/dvtgtsDeDpyFdol9FajWYVqMi3x4D2iTs2EhfSZcsvlH7Z3hYwFlfhJVquNfMInHs Dd7yN17IT599NsjnmktJT6D/+CSgm4zd+p/bMjoLSQZ/7AJ+M93zi1qNvRHTV8ct11YOOPxsf3P 15ZAVzOqhVZsQNRNLQRjQCeLUKv4zFH9/a4Ow6Kn1nrz19w1sE3r+lLhmVokcUHH2Ura9hqeLsm mXYv6kBTWzi/hgryvGc3hylF/YO6i0J2sYDDF1vfIMNJTthn2JIrfqbyedlXrc9srz+h6Lp6M/L VJ7WeDyxT+GQFNdI3fvMUlua4p6QCwqob58ESqYGgzLOPhq+COk90GRvTKzm/xH4VLmdqEtZufY qcQ4ld5SLEqDKNx0jjC8X5sSTZXar0If7kfS4KSp/GIOypcz3zAINhXuyReKHgfIeNsI6E3VSmI sqh2aqSKxHjBGS9wUK/GtCkR9EZP5UNlgprkeui4fcubQkZoYoDf4KgTqwXaV4Mt4gG9unWyvQ0 r912phoBxICOp7EJvzV34wBylRlaFmZEU7H4WcwirBH6HBigXuLBr62jzWOWGH1stTMwZGR0tkt MEihvyi/6wQWrCw== X-Developer-Key: i=caleb.connolly@linaro.org; a=openpgp; fpr=83B24DA7FE145076BC38BB250CD904EB673A7C47 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.8 at phobos.denx.de X-Virus-Status: Clean Keep the header pointer in the .data section so we don't initialize it again after relocation, adjust cmd_db_get_header() to work with the U-Boot API, and skip validating the header since all cmd-db users are children of the rpmh-rsc and those children will only probe if cmd-db initializes successfully. Acked-by: Sumit Garg Signed-off-by: Caleb Connolly --- drivers/soc/qcom/cmd-db.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/soc/qcom/cmd-db.c b/drivers/soc/qcom/cmd-db.c index f707aed59adf..08736ea936ae 100644 --- a/drivers/soc/qcom/cmd-db.c +++ b/drivers/soc/qcom/cmd-db.c @@ -128,16 +128,12 @@ static int cmd_db_get_header(const char *id, const struct entry_header **eh, const struct rsc_hdr **rh) { const struct rsc_hdr *rsc_hdr; const struct entry_header *ent; - int ret, i, j; + int i, j; u8 query[sizeof(ent->id)] __nonstring; - ret = cmd_db_ready(); - if (ret) - return ret; - - strtomem_pad(query, id, 0); + strncpy(query, id, sizeof(query)); for (i = 0; i < MAX_SLV_ID; i++) { rsc_hdr = &cmd_db_header->header[i]; if (!rsc_hdr->slv_id) @@ -172,8 +168,15 @@ u32 cmd_db_read_addr(const char *id) { int ret; const struct entry_header *ent; + debug("%s(%s)\n", __func__, id); + + if (!cmd_db_header) { + log_err("%s: Command DB not initialized\n", __func__); + return 0; + } + ret = cmd_db_get_header(id, &ent, NULL); return ret < 0 ? 0 : le32_to_cpu(ent->addr); } @@ -213,9 +216,9 @@ static const struct udevice_id cmd_db_ids[] = { U_BOOT_DRIVER(qcom_cmd_db) = { .name = "qcom_cmd_db", .id = UCLASS_MISC, - .probe = cmd_db_bind, + .bind = cmd_db_bind, .of_match = cmd_db_ids, }; MODULE_DESCRIPTION("Qualcomm Technologies, Inc. Command DB Driver"); From patchwork Mon Jul 15 10:08:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 812608 Delivered-To: patch@linaro.org Received: by 2002:adf:fac3:0:b0:367:895a:4699 with SMTP id a3csp1724335wrs; Mon, 15 Jul 2024 03:09:41 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWRAH1rMsP684H2v9P7+YlIQvDTRVmVV6NlnvlAGyvm2Z0fP0rC9OED4xI+fquL+ZRfg2qp0O+L6M5QnPGXkMrb X-Google-Smtp-Source: AGHT+IEC4TcJoa31b0FLIJ0/aNmLRMCrk78WvvrCyNaebzptfN8MlQS5CzCBPUF9lasPcn1wF+Cv X-Received: by 2002:a17:906:e0d1:b0:a77:cf09:9c54 with SMTP id a640c23a62f3a-a780b70538fmr1086694466b.37.1721038180905; Mon, 15 Jul 2024 03:09:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721038180; cv=none; d=google.com; s=arc-20160816; b=Oh5NSM32fOrLXFSB6pA0NqJzTKszngkFTBs4TLFLMBlVZy3t42A33YXuJvamlRy6dq VbO4Uc8kEDqtlVFe8YwbJaMRN/BV+MBIqBPIlnMJJYTH1+dEfv4BSDF1Gvu2mnqo4qFd U1AGWyFq37WoErHG9L/Rpmrz58IF6x8aOyQVp8jKVJ0qjguGmMCrcZfmL5gI+iBCd+H8 PqMNcvpVoxPbgdRCBWJFMyBA35UuV4XG6B3cyjk3UkK0g8ZST6fOyVtgBy5J9kygZiFe VRoio9YGPpR169u5bDXV4JpcAddfDUGYMRMaskr5ULikAIP9sCNOr17gD0T1C8VuLnwM GQ0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:cc:to:in-reply-to:references :message-id:content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=MLpnN4uCLS9UTMgH3jmW6XCVAZA1mkabcby0SWjzMys=; fh=zcTfjI3NycJyTuuOJ9uzXxS7wfOr4sYKS7eKveHEFzw=; b=zznTY9UGUc5LK2IQUPAfl/7L9iXU4chRZ74o8b9lD1sToAUrmvzihbG1IzNctkFLWy a//q4mC9D5vx/GKlMMUzb4rIUptwhH2mfHXIf0SpmlUE6BehECN2GCg90lrfHl1XSh6M aRbKnzlhF0zGBegzW9bfJg80KxR7oHR4VDvgEBkIPDDykI9ACq3KAVRw5Sbh4XqGF7Ev +MChbDUoD+SDwgJaWykzfytYTXNuIsgtwY+tK7oMXJO+Pr+Shp7FN4/Xjd+Fk54la+aN s7e+8XrMSN5sheIAy2/6AYmZj6ZZamxRs5skd56xxhYA+Ssy82abVOZIC8e9FCiJCw5+ weuA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=shS0PPy8; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id a640c23a62f3a-a79bc7f619csi235391766b.534.2024.07.15.03.09.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 03:09:40 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=shS0PPy8; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2783D88747; Mon, 15 Jul 2024 12:08:23 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org 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=linaro.org header.i=@linaro.org header.b="shS0PPy8"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7C8168883F; Mon, 15 Jul 2024 12:08:22 +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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) (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 0C4C088747 for ; Mon, 15 Jul 2024 12:08:20 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=caleb.connolly@linaro.org Received: by mail-ed1-x52f.google.com with SMTP id 4fb4d7f45d1cf-595850e7e11so5050694a12.1 for ; Mon, 15 Jul 2024 03:08:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721038099; x=1721642899; darn=lists.denx.de; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=MLpnN4uCLS9UTMgH3jmW6XCVAZA1mkabcby0SWjzMys=; b=shS0PPy8/myDkBkd9AM2Uovs+FAXclv5KWFFWfbwiOlN7kFPvgHJEz8fXc1rQL0zUb suPmfUuL8jEx0GDx5ACrFIPakOuiYJbhWqkwfCL3J1k4vp8/wpkvOyv5nGWSHXJc5sgI pBwytRoEhBGuAJ1ybXdVwXwAyTWwCQ8xPDnssAwIVxgLc8cQLvWZQ3AVU6bFn3sRVyik 9jAGHUV61THX57KNZvI1J7V1BtvBqyV/tmFnB7x1ILDDEynCqQU5ZV1f56y5csXUrVfO TMzftsGKEZCtVpEyjxuFV/g0UOyAnmpQxhYjwHf5gNfYbC0FHqWK44ly/ZyrMMEZNK0h Z/5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721038099; x=1721642899; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MLpnN4uCLS9UTMgH3jmW6XCVAZA1mkabcby0SWjzMys=; b=qZHeNbjRcMmcdykR2tvR/Lt2igE7Exy7rbbdp3The6SXm+YCv+wmCYT/ylDe9OEXXO Y62VAsFSW3XnnfygUJsCGHhwvYEym7bIaQzPjsOBoH6zi6O9TaZJb1l9tI3UHJ6yOUe6 utoH1Ej4zgIRT5eHL9OvtfZsKEr2mqyhYzum3bDbPsYh5mhrBVh+/YgTuJCKD/NjX2cR gF5ETz5nG5LVCT93WnI2paoQ9rVyMqQSjZ316K0o6FXqFdprRn7QE85tXy/Jz6M1h0Pl JJLqPdFNUtgBOWuN0t1MSZXHPMcMa4p65SIDg1QxhTk9+RkezWwgmsA0ku9NH7G549Fv 6AEw== X-Gm-Message-State: AOJu0YxR7mg+U20EM8J7gO7sWWYliIUakD5TETam3PNl016AFmEiku1x q3mSPbNCMmzI9zEx/Z+iuvmudYBazGCZH0waE+pVYOiGHqqEc0qW5/3qsnKxL9k= X-Received: by 2002:a17:906:59b:b0:a77:e0ed:8c4 with SMTP id a640c23a62f3a-a780b68a3f0mr1153030666b.7.1721038099259; Mon, 15 Jul 2024 03:08:19 -0700 (PDT) Received: from [192.168.0.113] ([2a02:8109:aa0d:be00::7424]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a79bc5b7eb4sm198102266b.60.2024.07.15.03.08.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 03:08:18 -0700 (PDT) From: Caleb Connolly Date: Mon, 15 Jul 2024 12:08:07 +0200 Subject: [PATCH v6 08/24] soc: qcom: rpmh-rsc: drop unused multi-threading and non-active TCS support MIME-Version: 1.0 Message-Id: <20240715-b4-qcom-rpmh-v6-8-0c948a25d018@linaro.org> References: <20240715-b4-qcom-rpmh-v6-0-0c948a25d018@linaro.org> In-Reply-To: <20240715-b4-qcom-rpmh-v6-0-0c948a25d018@linaro.org> To: Tom Rini , Caleb Connolly , Neil Armstrong , Sumit Garg , Jaehoon Chung , Simon Glass Cc: u-boot@lists.denx.de, u-boot-qcom@groups.io X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=21761; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=VwQpJx5J3ndBDeO8ELX1G51IpAqZT+iASYLc8q6fJkk=; b=owEBbQKS/ZANAwAIAQWDMSsZX2S2AcsmYgBmlPUFbdMWyiW+ONVRJePuJo5vMQbAItNT+lSBr PIlQXfvteqJAjMEAAEIAB0WIQS2UaFGPGq+0GkMVc0FgzErGV9ktgUCZpT1BQAKCRAFgzErGV9k thQ5D/sEOU34buBkffyOP8hg7iBkdeYH3dZ3h+I94Fb7wTPzKxpUcrfT0JJZ0Nl3aXpfrQWnIfw OrePz5N2P/Q7Po0wExtKuZRV/L3GgEyC8teD1MjW1lBOFCzVOQ6MW0CBr9TLeBtOV5YPB1w4VAV /tZNKG2Q1/wmzZ93xWE0+67WwuvcvuUfaL8RUDm9M5CogzPX00JA5kDqjeswIZUpvGpUh9g/wQD hjNWK2JlovFFrLTMAH075MUfk+BRTKLMRGtN5fT2dPkvSBMk2vsSBkwPx018wZ7tDTQetagdfXO iRg6gZar1U1XG5RLu9Xp66P9ru/uTHp27XuB862CMfqBxa/0MyuK+AB6IGPlRZ40IhGsKt9XzHH QS9lQQvRNtRdM7/IsYExrxbqJ0tYLj/OjioakkffEOgnIO68xaeKDuefkCRR2p3ycUi0dr8XqGA ad7HL88n9UQDqwrxLRu2BNYTkbFc+m/SzSsl+6H8cxJMo7Vn2CuP5TKIIioa41JQoityKRLLyr8 TXLaj69/pjX1jQRKDzN0GpC0xj/Ykli2UPHIF1DgW2onL86HctSXiKQVaQFLsiAdyc851oN2Ise NwoI/FiVzBj+vOX+T26+9FxU9DBKLGuIQgn2duRW8BUkh18gItZMnA2yi9IRZvDcdiKKT9j+TRc WlH50cwjxpNXt8g== X-Developer-Key: i=caleb.connolly@linaro.org; a=openpgp; fpr=83B24DA7FE145076BC38BB250CD904EB673A7C47 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.8 at phobos.denx.de X-Virus-Status: Clean Since U-Boot is single threaded, we can avoid most of the complexity that comes with handling more than one in-flight TCS. Drop all the rpmh code associated with multi-threading as we'll instead wait for a response on each TCS. Acked-by: Sumit Garg Signed-off-by: Caleb Connolly --- drivers/soc/qcom/rpmh-internal.h | 4 - drivers/soc/qcom/rpmh-rsc.c | 562 --------------------------------------- 2 files changed, 566 deletions(-) diff --git a/drivers/soc/qcom/rpmh-internal.h b/drivers/soc/qcom/rpmh-internal.h index e3cf1beff803..12c5b8d9cf86 100644 --- a/drivers/soc/qcom/rpmh-internal.h +++ b/drivers/soc/qcom/rpmh-internal.h @@ -139,10 +139,6 @@ struct rsc_drv { int rpmh_rsc_send_data(struct rsc_drv *drv, const struct tcs_request *msg); int rpmh_rsc_write_ctrl_data(struct rsc_drv *drv, const struct tcs_request *msg); void rpmh_rsc_invalidate(struct rsc_drv *drv); -void rpmh_rsc_write_next_wakeup(struct rsc_drv *drv); - -void rpmh_tx_done(const struct tcs_request *msg); -int rpmh_flush(struct rpmh_ctrlr *ctrlr); #endif /* __RPM_INTERNAL_H__ */ diff --git a/drivers/soc/qcom/rpmh-rsc.c b/drivers/soc/qcom/rpmh-rsc.c index de86009ecd91..fc8321bf208f 100644 --- a/drivers/soc/qcom/rpmh-rsc.c +++ b/drivers/soc/qcom/rpmh-rsc.c @@ -246,49 +246,8 @@ static void write_tcs_reg_sync(const struct rsc_drv *drv, int reg, int tcs_id, pr_err("%s: error writing %#x to %d:%#x\n", drv->name, data, tcs_id, reg); } -/** - * tcs_invalidate() - Invalidate all TCSes of the given type (sleep or wake). - * @drv: The RSC controller. - * @type: SLEEP_TCS or WAKE_TCS - * - * This will clear the "slots" variable of the given tcs_group and also - * tell the hardware to forget about all entries. - * - * The caller must ensure that no other RPMH actions are happening when this - * function is called, since otherwise the device may immediately become - * used again even before this function exits. - */ -static void tcs_invalidate(struct rsc_drv *drv, int type) -{ - int m; - struct tcs_group *tcs = &drv->tcs[type]; - - /* Caller ensures nobody else is running so no lock */ - if (bitmap_empty(tcs->slots, MAX_TCS_SLOTS)) - return; - - for (m = tcs->offset; m < tcs->offset + tcs->num_tcs; m++) - write_tcs_reg_sync(drv, drv->regs[RSC_DRV_CMD_ENABLE], m, 0); - - bitmap_zero(tcs->slots, MAX_TCS_SLOTS); -} - -/** - * rpmh_rsc_invalidate() - Invalidate sleep and wake TCSes. - * @drv: The RSC controller. - * - * The caller must ensure that no other RPMH actions are happening when this - * function is called, since otherwise the device may immediately become - * used again even before this function exits. - */ -void rpmh_rsc_invalidate(struct rsc_drv *drv) -{ - tcs_invalidate(drv, SLEEP_TCS); - tcs_invalidate(drv, WAKE_TCS); -} - /** * get_tcs_for_msg() - Get the tcs_group used to send the given message. * @drv: The RSC controller. * @msg: The message we want to send. @@ -331,158 +290,8 @@ static struct tcs_group *get_tcs_for_msg(struct rsc_drv *drv, return tcs; } -/** - * get_req_from_tcs() - Get a stashed request that was xfering on the given TCS. - * @drv: The RSC controller. - * @tcs_id: The global ID of this TCS. - * - * For ACTIVE_ONLY transfers we want to call back into the client when the - * transfer finishes. To do this we need the "request" that the client - * originally provided us. This function grabs the request that we stashed - * when we started the transfer. - * - * This only makes sense for ACTIVE_ONLY transfers since those are the only - * ones we track sending (the only ones we enable interrupts for and the only - * ones we call back to the client for). - * - * Return: The stashed request. - */ -static const struct tcs_request *get_req_from_tcs(struct rsc_drv *drv, - int tcs_id) -{ - struct tcs_group *tcs; - int i; - - for (i = 0; i < TCS_TYPE_NR; i++) { - tcs = &drv->tcs[i]; - if (tcs->mask & BIT(tcs_id)) - return tcs->req[tcs_id - tcs->offset]; - } - - return NULL; -} - -/** - * __tcs_set_trigger() - Start xfer on a TCS or unset trigger on a borrowed TCS - * @drv: The controller. - * @tcs_id: The global ID of this TCS. - * @trigger: If true then untrigger/retrigger. If false then just untrigger. - * - * In the normal case we only ever call with "trigger=true" to start a - * transfer. That will un-trigger/disable the TCS from the last transfer - * then trigger/enable for this transfer. - * - * If we borrowed a wake TCS for an active-only transfer we'll also call - * this function with "trigger=false" to just do the un-trigger/disable - * before using the TCS for wake purposes again. - * - * Note that the AP is only in charge of triggering active-only transfers. - * The AP never triggers sleep/wake values using this function. - */ -static void __tcs_set_trigger(struct rsc_drv *drv, int tcs_id, bool trigger) -{ - u32 enable; - u32 reg = drv->regs[RSC_DRV_CONTROL]; - - /* - * HW req: Clear the DRV_CONTROL and enable TCS again - * While clearing ensure that the AMC mode trigger is cleared - * and then the mode enable is cleared. - */ - enable = read_tcs_reg(drv, reg, tcs_id); - enable &= ~TCS_AMC_MODE_TRIGGER; - write_tcs_reg_sync(drv, reg, tcs_id, enable); - enable &= ~TCS_AMC_MODE_ENABLE; - write_tcs_reg_sync(drv, reg, tcs_id, enable); - - if (trigger) { - /* Enable the AMC mode on the TCS and then trigger the TCS */ - enable = TCS_AMC_MODE_ENABLE; - write_tcs_reg_sync(drv, reg, tcs_id, enable); - enable |= TCS_AMC_MODE_TRIGGER; - write_tcs_reg(drv, reg, tcs_id, enable); - } -} - -/** - * enable_tcs_irq() - Enable or disable interrupts on the given TCS. - * @drv: The controller. - * @tcs_id: The global ID of this TCS. - * @enable: If true then enable; if false then disable - * - * We only ever call this when we borrow a wake TCS for an active-only - * transfer. For active-only TCSes interrupts are always left enabled. - */ -static void enable_tcs_irq(struct rsc_drv *drv, int tcs_id, bool enable) -{ - u32 data; - u32 reg = drv->regs[RSC_DRV_IRQ_ENABLE]; - - data = readl_relaxed(drv->tcs_base + reg); - if (enable) - data |= BIT(tcs_id); - else - data &= ~BIT(tcs_id); - writel_relaxed(data, drv->tcs_base + reg); -} - -/** - * tcs_tx_done() - TX Done interrupt handler. - * @irq: The IRQ number (ignored). - * @p: Pointer to "struct rsc_drv". - * - * Called for ACTIVE_ONLY transfers (those are the only ones we enable the - * IRQ for) when a transfer is done. - * - * Return: IRQ_HANDLED - */ -static irqreturn_t tcs_tx_done(int irq, void *p) -{ - struct rsc_drv *drv = p; - int i; - unsigned long irq_status; - const struct tcs_request *req; - - irq_status = readl_relaxed(drv->tcs_base + drv->regs[RSC_DRV_IRQ_STATUS]); - - for_each_set_bit(i, &irq_status, BITS_PER_TYPE(u32)) { - req = get_req_from_tcs(drv, i); - if (WARN_ON(!req)) - goto skip; - - trace_rpmh_tx_done(drv, i, req); - - /* - * If wake tcs was re-purposed for sending active - * votes, clear AMC trigger & enable modes and - * disable interrupt for this TCS - */ - if (!drv->tcs[ACTIVE_TCS].num_tcs) - __tcs_set_trigger(drv, i, false); -skip: - /* Reclaim the TCS */ - write_tcs_reg(drv, drv->regs[RSC_DRV_CMD_ENABLE], i, 0); - writel_relaxed(BIT(i), drv->tcs_base + drv->regs[RSC_DRV_IRQ_CLEAR]); - spin_lock(&drv->lock); - clear_bit(i, drv->tcs_in_use); - /* - * Disable interrupt for WAKE TCS to avoid being - * spammed with interrupts coming when the solver - * sends its wake votes. - */ - if (!drv->tcs[ACTIVE_TCS].num_tcs) - enable_tcs_irq(drv, i, false); - spin_unlock(&drv->lock); - wake_up(&drv->tcs_wait); - if (req) - rpmh_tx_done(req); - } - - return IRQ_HANDLED; -} - /** * __tcs_buffer_write() - Write to TCS hardware from a request; don't trigger. * @drv: The controller. * @tcs_id: The global ID of this TCS. @@ -523,104 +332,8 @@ static void __tcs_buffer_write(struct rsc_drv *drv, int tcs_id, int cmd_id, cmd_enable |= read_tcs_reg(drv, drv->regs[RSC_DRV_CMD_ENABLE], tcs_id); write_tcs_reg(drv, drv->regs[RSC_DRV_CMD_ENABLE], tcs_id, cmd_enable); } -/** - * check_for_req_inflight() - Look to see if conflicting cmds are in flight. - * @drv: The controller. - * @tcs: A pointer to the tcs_group used for ACTIVE_ONLY transfers. - * @msg: The message we want to send, which will contain several addr/data - * pairs to program (but few enough that they all fit in one TCS). - * - * This will walk through the TCSes in the group and check if any of them - * appear to be sending to addresses referenced in the message. If it finds - * one it'll return -EBUSY. - * - * Only for use for active-only transfers. - * - * Must be called with the drv->lock held since that protects tcs_in_use. - * - * Return: 0 if nothing in flight or -EBUSY if we should try again later. - * The caller must re-enable interrupts between tries since that's - * the only way tcs_in_use will ever be updated and the only way - * RSC_DRV_CMD_ENABLE will ever be cleared. - */ -static int check_for_req_inflight(struct rsc_drv *drv, struct tcs_group *tcs, - const struct tcs_request *msg) -{ - unsigned long curr_enabled; - u32 addr; - int j, k; - int i = tcs->offset; - - for_each_set_bit_from(i, drv->tcs_in_use, tcs->offset + tcs->num_tcs) { - curr_enabled = read_tcs_reg(drv, drv->regs[RSC_DRV_CMD_ENABLE], i); - - for_each_set_bit(j, &curr_enabled, MAX_CMDS_PER_TCS) { - addr = read_tcs_cmd(drv, drv->regs[RSC_DRV_CMD_ADDR], i, j); - for (k = 0; k < msg->num_cmds; k++) { - if (cmd_db_match_resource_addr(msg->cmds[k].addr, addr)) - return -EBUSY; - } - } - } - - return 0; -} - -/** - * find_free_tcs() - Find free tcs in the given tcs_group; only for active. - * @tcs: A pointer to the active-only tcs_group (or the wake tcs_group if - * we borrowed it because there are zero active-only ones). - * - * Must be called with the drv->lock held since that protects tcs_in_use. - * - * Return: The first tcs that's free or -EBUSY if all in use. - */ -static int find_free_tcs(struct tcs_group *tcs) -{ - const struct rsc_drv *drv = tcs->drv; - unsigned long i; - unsigned long max = tcs->offset + tcs->num_tcs; - - i = find_next_zero_bit(drv->tcs_in_use, max, tcs->offset); - if (i >= max) - return -EBUSY; - - return i; -} - -/** - * claim_tcs_for_req() - Claim a tcs in the given tcs_group; only for active. - * @drv: The controller. - * @tcs: The tcs_group used for ACTIVE_ONLY transfers. - * @msg: The data to be sent. - * - * Claims a tcs in the given tcs_group while making sure that no existing cmd - * is in flight that would conflict with the one in @msg. - * - * Context: Must be called with the drv->lock held since that protects - * tcs_in_use. - * - * Return: The id of the claimed tcs or -EBUSY if a matching msg is in flight - * or the tcs_group is full. - */ -static int claim_tcs_for_req(struct rsc_drv *drv, struct tcs_group *tcs, - const struct tcs_request *msg) -{ - int ret; - - /* - * The h/w does not like if we send a request to the same address, - * when one is already in-flight or being processed. - */ - ret = check_for_req_inflight(drv, tcs, msg); - if (ret) - return ret; - - return find_free_tcs(tcs); -} - /** * rpmh_rsc_send_data() - Write / trigger active-only message. * @drv: The controller. * @msg: The data to be sent. @@ -668,9 +381,8 @@ int rpmh_rsc_send_data(struct rsc_drv *drv, const struct tcs_request *msg) * repurposed TCS to avoid triggering them. tcs->slots will be * cleaned from rpmh_flush() by invoking rpmh_rsc_invalidate() */ write_tcs_reg_sync(drv, drv->regs[RSC_DRV_CMD_ENABLE], tcs_id, 0); - enable_tcs_irq(drv, tcs_id, true); } spin_unlock_irq(&drv->lock); /* @@ -681,286 +393,12 @@ int rpmh_rsc_send_data(struct rsc_drv *drv, const struct tcs_request *msg) * - The interrupt can't go off until we trigger w/ the last line * of __tcs_set_trigger() below. */ __tcs_buffer_write(drv, tcs_id, 0, msg); - __tcs_set_trigger(drv, tcs_id, true); return 0; } -/** - * find_slots() - Find a place to write the given message. - * @tcs: The tcs group to search. - * @msg: The message we want to find room for. - * @tcs_id: If we return 0 from the function, we return the global ID of the - * TCS to write to here. - * @cmd_id: If we return 0 from the function, we return the index of - * the command array of the returned TCS where the client should - * start writing the message. - * - * Only for use on sleep/wake TCSes since those are the only ones we maintain - * tcs->slots for. - * - * Return: -ENOMEM if there was no room, else 0. - */ -static int find_slots(struct tcs_group *tcs, const struct tcs_request *msg, - int *tcs_id, int *cmd_id) -{ - int slot, offset; - int i = 0; - - /* Do over, until we can fit the full payload in a single TCS */ - do { - slot = bitmap_find_next_zero_area(tcs->slots, MAX_TCS_SLOTS, - i, msg->num_cmds, 0); - if (slot >= tcs->num_tcs * tcs->ncpt) - return -ENOMEM; - i += tcs->ncpt; - } while (slot + msg->num_cmds - 1 >= i); - - bitmap_set(tcs->slots, slot, msg->num_cmds); - - offset = slot / tcs->ncpt; - *tcs_id = offset + tcs->offset; - *cmd_id = slot % tcs->ncpt; - - return 0; -} - -/** - * rpmh_rsc_write_ctrl_data() - Write request to controller but don't trigger. - * @drv: The controller. - * @msg: The data to be written to the controller. - * - * This should only be called for sleep/wake state, never active-only - * state. - * - * The caller must ensure that no other RPMH actions are happening and the - * controller is idle when this function is called since it runs lockless. - * - * Return: 0 if no error; else -error. - */ -int rpmh_rsc_write_ctrl_data(struct rsc_drv *drv, const struct tcs_request *msg) -{ - struct tcs_group *tcs; - int tcs_id = 0, cmd_id = 0; - int ret; - - tcs = get_tcs_for_msg(drv, msg); - if (IS_ERR(tcs)) - return PTR_ERR(tcs); - - /* find the TCS id and the command in the TCS to write to */ - ret = find_slots(tcs, msg, &tcs_id, &cmd_id); - if (!ret) - __tcs_buffer_write(drv, tcs_id, cmd_id, msg); - - return ret; -} - -/** - * rpmh_rsc_ctrlr_is_busy() - Check if any of the AMCs are busy. - * @drv: The controller - * - * Checks if any of the AMCs are busy in handling ACTIVE sets. - * This is called from the last cpu powering down before flushing - * SLEEP and WAKE sets. If AMCs are busy, controller can not enter - * power collapse, so deny from the last cpu's pm notification. - * - * Context: Must be called with the drv->lock held. - * - * Return: - * * False - AMCs are idle - * * True - AMCs are busy - */ -static bool rpmh_rsc_ctrlr_is_busy(struct rsc_drv *drv) -{ - unsigned long set; - const struct tcs_group *tcs = &drv->tcs[ACTIVE_TCS]; - unsigned long max; - - /* - * If we made an active request on a RSC that does not have a - * dedicated TCS for active state use, then re-purposed wake TCSes - * should be checked for not busy, because we used wake TCSes for - * active requests in this case. - */ - if (!tcs->num_tcs) - tcs = &drv->tcs[WAKE_TCS]; - - max = tcs->offset + tcs->num_tcs; - set = find_next_bit(drv->tcs_in_use, max, tcs->offset); - - return set < max; -} - -/** - * rpmh_rsc_write_next_wakeup() - Write next wakeup in CONTROL_TCS. - * @drv: The controller - * - * Writes maximum wakeup cycles when called from suspend. - * Writes earliest hrtimer wakeup when called from idle. - */ -void rpmh_rsc_write_next_wakeup(struct rsc_drv *drv) -{ - ktime_t now, wakeup; - u64 wakeup_us, wakeup_cycles = ~0; - u32 lo, hi; - - if (!drv->tcs[CONTROL_TCS].num_tcs || !drv->genpd_nb.notifier_call) - return; - - /* Set highest time when system (timekeeping) is suspended */ - if (system_state == SYSTEM_SUSPEND) - goto exit; - - /* Find the earliest hrtimer wakeup from online cpus */ - wakeup = dev_pm_genpd_get_next_hrtimer(drv->dev); - - /* Find the relative wakeup in kernel time scale */ - now = ktime_get(); - wakeup = ktime_sub(wakeup, now); - wakeup_us = ktime_to_us(wakeup); - - /* Convert the wakeup to arch timer scale */ - wakeup_cycles = USECS_TO_CYCLES(wakeup_us); - wakeup_cycles += arch_timer_read_counter(); - -exit: - lo = wakeup_cycles & RSC_DRV_CTL_TCS_DATA_LO_MASK; - hi = wakeup_cycles >> RSC_DRV_CTL_TCS_DATA_SIZE; - hi &= RSC_DRV_CTL_TCS_DATA_HI_MASK; - hi |= RSC_DRV_CTL_TCS_DATA_HI_VALID; - - writel_relaxed(lo, drv->base + RSC_DRV_CTL_TCS_DATA_LO); - writel_relaxed(hi, drv->base + RSC_DRV_CTL_TCS_DATA_HI); -} - -/** - * rpmh_rsc_cpu_pm_callback() - Check if any of the AMCs are busy. - * @nfb: Pointer to the notifier block in struct rsc_drv. - * @action: CPU_PM_ENTER, CPU_PM_ENTER_FAILED, or CPU_PM_EXIT. - * @v: Unused - * - * This function is given to cpu_pm_register_notifier so we can be informed - * about when CPUs go down. When all CPUs go down we know no more active - * transfers will be started so we write sleep/wake sets. This function gets - * called from cpuidle code paths and also at system suspend time. - * - * If its last CPU going down and AMCs are not busy then writes cached sleep - * and wake messages to TCSes. The firmware then takes care of triggering - * them when entering deepest low power modes. - * - * Return: See cpu_pm_register_notifier() - */ -static int rpmh_rsc_cpu_pm_callback(struct notifier_block *nfb, - unsigned long action, void *v) -{ - struct rsc_drv *drv = container_of(nfb, struct rsc_drv, rsc_pm); - int ret = NOTIFY_OK; - int cpus_in_pm; - - switch (action) { - case CPU_PM_ENTER: - cpus_in_pm = atomic_inc_return(&drv->cpus_in_pm); - /* - * NOTE: comments for num_online_cpus() point out that it's - * only a snapshot so we need to be careful. It should be OK - * for us to use, though. It's important for us not to miss - * if we're the last CPU going down so it would only be a - * problem if a CPU went offline right after we did the check - * AND that CPU was not idle AND that CPU was the last non-idle - * CPU. That can't happen. CPUs would have to come out of idle - * before the CPU could go offline. - */ - if (cpus_in_pm < num_online_cpus()) - return NOTIFY_OK; - break; - case CPU_PM_ENTER_FAILED: - case CPU_PM_EXIT: - atomic_dec(&drv->cpus_in_pm); - return NOTIFY_OK; - default: - return NOTIFY_DONE; - } - - /* - * It's likely we're on the last CPU. Grab the drv->lock and write - * out the sleep/wake commands to RPMH hardware. Grabbing the lock - * means that if we race with another CPU coming up we are still - * guaranteed to be safe. If another CPU came up just after we checked - * and has grabbed the lock or started an active transfer then we'll - * notice we're busy and abort. If another CPU comes up after we start - * flushing it will be blocked from starting an active transfer until - * we're done flushing. If another CPU starts an active transfer after - * we release the lock we're still OK because we're no longer the last - * CPU. - */ - if (spin_trylock(&drv->lock)) { - if (rpmh_rsc_ctrlr_is_busy(drv) || rpmh_flush(&drv->client)) - ret = NOTIFY_BAD; - spin_unlock(&drv->lock); - } else { - /* Another CPU must be up */ - return NOTIFY_OK; - } - - if (ret == NOTIFY_BAD) { - /* Double-check if we're here because someone else is up */ - if (cpus_in_pm < num_online_cpus()) - ret = NOTIFY_OK; - else - /* We won't be called w/ CPU_PM_ENTER_FAILED */ - atomic_dec(&drv->cpus_in_pm); - } - - return ret; -} - -/** - * rpmh_rsc_pd_callback() - Check if any of the AMCs are busy. - * @nfb: Pointer to the genpd notifier block in struct rsc_drv. - * @action: GENPD_NOTIFY_PRE_OFF, GENPD_NOTIFY_OFF, GENPD_NOTIFY_PRE_ON or GENPD_NOTIFY_ON. - * @v: Unused - * - * This function is given to dev_pm_genpd_add_notifier() so we can be informed - * about when cluster-pd is going down. When cluster go down we know no more active - * transfers will be started so we write sleep/wake sets. This function gets - * called from cpuidle code paths and also at system suspend time. - * - * If AMCs are not busy then writes cached sleep and wake messages to TCSes. - * The firmware then takes care of triggering them when entering deepest low power modes. - * - * Return: - * * NOTIFY_OK - success - * * NOTIFY_BAD - failure - */ -static int rpmh_rsc_pd_callback(struct notifier_block *nfb, - unsigned long action, void *v) -{ - struct rsc_drv *drv = container_of(nfb, struct rsc_drv, genpd_nb); - - /* We don't need to lock as genpd on/off are serialized */ - if ((action == GENPD_NOTIFY_PRE_OFF) && - (rpmh_rsc_ctrlr_is_busy(drv) || rpmh_flush(&drv->client))) - return NOTIFY_BAD; - - return NOTIFY_OK; -} - -static int rpmh_rsc_pd_attach(struct rsc_drv *drv, struct device *dev) -{ - int ret; - - pm_runtime_enable(dev); - drv->genpd_nb.notifier_call = rpmh_rsc_pd_callback; - ret = dev_pm_genpd_add_notifier(dev, &drv->genpd_nb); - if (ret) - pm_runtime_disable(dev); - - return ret; -} - static int rpmh_probe_tcs_config(struct platform_device *pdev, struct rsc_drv *drv) { struct tcs_type_config { u32 type; From patchwork Mon Jul 15 10:08:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 812610 Delivered-To: patch@linaro.org Received: by 2002:adf:fac3:0:b0:367:895a:4699 with SMTP id a3csp1724483wrs; Mon, 15 Jul 2024 03:10:03 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXPMzGBk8q00bHj1wdofRMFXP1GceYa00HmdPeNHrZAaRq81c1RWYn2BHRlbnhvorSZY2AItIPZ8LrBGqQAmooB X-Google-Smtp-Source: AGHT+IFV4O4bsQcdXxOeoE5tAPsKaXPZMOE4ijTDK5tWWRno7jSDg7llGz5VXpT/7TuslyttMqUk X-Received: by 2002:a05:6402:1d54:b0:58c:804a:6f03 with SMTP id 4fb4d7f45d1cf-594bb58078bmr13520616a12.24.1721038203734; Mon, 15 Jul 2024 03:10:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721038203; cv=none; d=google.com; s=arc-20160816; b=W0mly67usNTIOw+M2Elblx6Ny4ei+BbWe5GnsBX8YUNADSoBkvDY/mYMr44xCDIZ6U nQEqdEZhIDqpIPKdBm/z6OS4MWWcUTTD80ZTzyT6V3qHOeW3AqF8MQCOb+clfgwFr77O l4cW/a7l9m11nAqrnbPqTriGMKmT4+vbHTjwrr7IeoRy6lHTgGcJxBVkt16Uc+HiGJI8 TNUfV8j0GS8XFYFodrFXx89LovIttKcT7Ws30HObiWsLCOf2RXyKzAvQwpVgYvBRnJ20 q4Putq+Syqrm86fqtYET8XIGSNJ9kZMoRvTfXgXKr8YQybXh50MV1eEerKi0KfQGFHv+ wHYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:cc:to:in-reply-to:references :message-id:content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=z5Jhey9+f1ctZXJj4kj8dZl2T5kKcAZR8OhsfmJbg6g=; fh=zcTfjI3NycJyTuuOJ9uzXxS7wfOr4sYKS7eKveHEFzw=; b=r7pHtT5jhc0QICMxY7IPBLTO8KUXa3DRT6PYoeyQgNM2ejM8Cn3QjnUYl6anMy8Vc1 flkEBj38RH0cAyn0sqy47BAGj14DylON0zLHn3YgQH/9u/9q3w0/FWjvYin9tg2s6pAD 39xitF3JgYOzMXYGGmahymfPF6Fzg7pNPTjJX25jxI/U55Wtr/Pzp+kbfIIoEar93T1G C0lo2yLBXLhHF2JCKRpr0MAThc3cAQcar0FVdwYWUsZCGti3kATVr40zSlkQ/dsFZDdj GjGSacgYKsnmJVwMXiyrvb7QoDEMpzK6rcjvszCUbINIA8iD5rQ4jcCnvXTLe+X7sFY0 pKxg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AxM9Styu; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-59b27629a43si2437445a12.599.2024.07.15.03.09.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 03:10:03 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AxM9Styu; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 84783887EE; Mon, 15 Jul 2024 12:08:24 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org 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=linaro.org header.i=@linaro.org header.b="AxM9Styu"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2D9B5887FE; Mon, 15 Jul 2024 12:08:23 +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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) (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 2752C8881B for ; Mon, 15 Jul 2024 12:08:21 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=caleb.connolly@linaro.org Received: by mail-ed1-x530.google.com with SMTP id 4fb4d7f45d1cf-58b0beaf703so5082155a12.2 for ; Mon, 15 Jul 2024 03:08:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721038100; x=1721642900; darn=lists.denx.de; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=z5Jhey9+f1ctZXJj4kj8dZl2T5kKcAZR8OhsfmJbg6g=; b=AxM9StyuInNgJxlBEvfwsvwqwlIikW2MvLqaHjh4hWU2iRuvJL3fkeQQ5QwO+8ql/k 8wEPtbRzooZGhQT0UmsdXPjzk0zkJxb7Z4xYdcPek/sREmxEkyNbE35CJG/LKLUbz/EZ 0zYLBKCswm4vLVGkSVs4IXsOShdbpTubq5Te6aJEYY9mGhIOIsV0YfGgYEopG+Qc8fn+ KoM3Enu5PBbQGpE3Javf3+1GxcVa4GeOnE9wxV16O7Fjtm6fcqWDbNhyNCyS18hWB8es 8yHL/tVDjVzt6vb4zVMpjpK5CHus1R7HPT2fNEgy3YlaiBsoNXxhyoWKDiTYdCfdsmCQ 8ozA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721038100; x=1721642900; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=z5Jhey9+f1ctZXJj4kj8dZl2T5kKcAZR8OhsfmJbg6g=; b=B0370XrGTd1WUpPyOKfgxW2q3JqtlSFjJeJcHGkjhS/YaCA2239q6q4nslPbSz/iIV VP/+lgoIIGzC0LeoVvcsVmVd7D7429E6IzrRNVof0EDMAhSnta78PjyRal0coMU1llZv PssZNh4T5u/KbLfmKFqw4ISoPS2ytG9plVzn2B0mIa1eLl5zPS8XegifkVyJzHRQUE0Y SznYn9knuCHeEAmo0McL0ajmzm0R6bUHOXQPKM0UioyRkwqsKR9mgIsJecDA106F64Yl 6ae78aUgwuvEK+by4zhoJ1n4YGoteE4iGihC0hInLFBuO+GRxYRjCS1JuFjUglWjyuyE FR4Q== X-Gm-Message-State: AOJu0Yz+M90gi0hVLbSi6kQxXCiPbcaWr+x8APos9s4eOxL58p+pkTBR 7TZAkQ4hcy0jcTVgth+2WISASunl3TvmwpPiEzYsaG0r6hWGrW16ioh4YvSFVWTf2BtG17l2KDy 7kZQ= X-Received: by 2002:a17:907:9687:b0:a79:81a4:faff with SMTP id a640c23a62f3a-a7981a4fd08mr1224527666b.66.1721038100688; Mon, 15 Jul 2024 03:08:20 -0700 (PDT) Received: from [192.168.0.113] ([2a02:8109:aa0d:be00::7424]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a79bc5b7eb4sm198102266b.60.2024.07.15.03.08.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 03:08:19 -0700 (PDT) From: Caleb Connolly Date: Mon, 15 Jul 2024 12:08:08 +0200 Subject: [PATCH v6 09/24] soc: qcom: rpmh-rsc: adjust headers for U-Boot MIME-Version: 1.0 Message-Id: <20240715-b4-qcom-rpmh-v6-9-0c948a25d018@linaro.org> References: <20240715-b4-qcom-rpmh-v6-0-0c948a25d018@linaro.org> In-Reply-To: <20240715-b4-qcom-rpmh-v6-0-0c948a25d018@linaro.org> To: Tom Rini , Caleb Connolly , Neil Armstrong , Sumit Garg , Jaehoon Chung , Simon Glass Cc: u-boot@lists.denx.de, u-boot-qcom@groups.io X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=1744; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=OluQtwpeX7wRycFAM1tC9sPPwIq/cXlzKqKVg+yAZLo=; b=owEBbQKS/ZANAwAIAQWDMSsZX2S2AcsmYgBmlPUGfMKlwDr1WUaAJQmLhdlRzTXl0SLGnRr4z OsqIyOYzb2JAjMEAAEIAB0WIQS2UaFGPGq+0GkMVc0FgzErGV9ktgUCZpT1BgAKCRAFgzErGV9k tjsUD/9Jjp2q5n85u2//+8uHOvijprzSHW1XFDT0AlJD8vYScjxk/WnbAFRjKy75i9qLenoOn6R kjHAskT1TY0M4WJU8W3dXZTiQ4LF7NzVcaNalR5HUzdDB01xyyyVJaGSYZtHThi3punQZ1NLhTS OFEG5GeBYJ5tBzrQ8bg0fuYkQ5h/EIbbcCancHSY2kNVcL/GOd+LRqB4HXa+ynVg0YwSKQ0d/as wd13gH3CQixkfV+d7rdEUhCwIwdpKN18eVk77wghAr67WoMDSoOZjZUBAhnNI4p/7AH2U6D0HwG 68VeiS18CnoTGjtsZPdCVCcnWepIvIcGRrBHlmYs7zUW0bt8tGb1uWuMMwnYDEWfzHoz+z/6bQJ lZ7jY3f2j/AnrWA/8dio7HFdqkXxZPjkBi+dsDleSIRfpQESGOQGri5cAtFCga/LlBtMfug85Lz PmBARtGmGij9TXK8ZldifQ8RDXCNMZpkxRYyj0xHGmlK+LQwD09nerbzpfbboGSzUzyfGEwvt0n rP6uk3NugS424PKFBFcgG4yBJ+mGp5uxXiykRYc6t1W/8sFesS9FXWnrpSeBP/hqS3TXYTU8F2D rbqvyfGiWs4hs2YyBH++/Vv22wfVFQhIjS9z/Y0wY8KHs3EGSqDwmuUEpY/oWYp33wdIgDT7dKK iLowfYfg7n1Lj7A== X-Developer-Key: i=caleb.connolly@linaro.org; a=openpgp; fpr=83B24DA7FE145076BC38BB250CD904EB673A7C47 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.8 at phobos.denx.de X-Virus-Status: Clean Remove unsupported / unused Linux headers and add those needed for U-Boot. Acked-by: Sumit Garg Signed-off-by: Caleb Connolly --- drivers/soc/qcom/rpmh-rsc.c | 36 ++++++++++++------------------------ 1 file changed, 12 insertions(+), 24 deletions(-) diff --git a/drivers/soc/qcom/rpmh-rsc.c b/drivers/soc/qcom/rpmh-rsc.c index fc8321bf208f..6b47c8001cac 100644 --- a/drivers/soc/qcom/rpmh-rsc.c +++ b/drivers/soc/qcom/rpmh-rsc.c @@ -5,39 +5,27 @@ */ #define pr_fmt(fmt) "%s " fmt, KBUILD_MODNAME -#include -#include +#include +#include +#include +#include +#include +#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include + +#include -#include -#include #include #include #include "rpmh-internal.h" -#define CREATE_TRACE_POINTS -#include "trace-rpmh.h" - #define RSC_DRV_ID 0 #define MAJOR_VER_MASK 0xFF From patchwork Mon Jul 15 10:08:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 812609 Delivered-To: patch@linaro.org Received: by 2002:adf:fac3:0:b0:367:895a:4699 with SMTP id a3csp1724466wrs; Mon, 15 Jul 2024 03:10:02 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWP/9DFCHfY2nuugscshbARj3u7JuNjbyFpKTASoIqV4729Hr3nMbN1K1dD/i2imzfHnRQP4rRhW6QtZ0tj3ofz X-Google-Smtp-Source: AGHT+IGofE6fOmF1oKP5saF01/6Y9IEf9jAbY1YT2g0hyp/QobERzlJ70DkiTG/M8W91S+VHGoAo X-Received: by 2002:a17:906:2819:b0:a77:a415:f815 with SMTP id a640c23a62f3a-a780b6b1f41mr1098860666b.20.1721038202303; Mon, 15 Jul 2024 03:10:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721038202; cv=none; d=google.com; s=arc-20160816; b=TjjT7JUR2IYnJxok9FK1VuAWhNo/aN1BA4unKESpqnznGqhhl3xanWS6dV7kJ9Xtcf eFan/3Iq8Sm4HmE7k5vMnTYwsvCCJ7Z7b+0INPxHu8fvzuS/0HcKvLCrFgA+9o3uD9x6 YFUrpdiFJMO5MEO4b+3gdcPvIEOd5v0JYsLglViAKgkOTDajuB59jyGd8wrWCG2y4ygU PvPygiU/h+ZD5fNJkWT9mFcQGtya4k+4nKLfuFWtLT71ENH5jNj1mryeWvUbLTQMB6Qs ScDlAOwvvXOBpC45f5Kxu1BVmDKZPycQG4O4NtGiY4imAmGge2nSsJdvSlVnOOAr757g /m+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:cc:to:in-reply-to:references :message-id:content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=1hmytS4Unti8N4UWz0So7iJZshWMA6yLHRXiaZMt67I=; fh=zcTfjI3NycJyTuuOJ9uzXxS7wfOr4sYKS7eKveHEFzw=; b=WNT741ECXxzCR3P3NjIu9MDw4VrZWMeBg3/h0SI+pGr7ZrzowwIyQlXicZnJhoxdeY 8vW5JL24jbB7I4w3eXrMovE8wHF4c2Irup4HiudOmWOOdPVbg+ltOL4TD1+3NyxLGeiG icq12eLW2OKipKxaEBKQRnLGGWgzBX2DG2smnWAXsZ5U3/KGEpFf4N+2fCWw4AAH/kR6 0E/pTkWroq7Ov8j/gUcRg1kbGAKvukCZkb32SC4wTY0XVjcvp3mD9jrXwKLjMi+0GFKB DlqDhuQHw6V/PmzZtdmDWbiZnI9ddHorbtu5MLbXJ9ZqgOf8BkrA64hGfZ0DCLGnD3g5 kFBw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pgIH7o2l; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id a640c23a62f3a-a79bc802d1dsi222713066b.662.2024.07.15.03.10.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 03:10:02 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pgIH7o2l; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E558188846; Mon, 15 Jul 2024 12:08:45 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org 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=linaro.org header.i=@linaro.org header.b="pgIH7o2l"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5581188853; Mon, 15 Jul 2024 12:08:44 +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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) (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 3E620887EB for ; Mon, 15 Jul 2024 12:08:42 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=caleb.connolly@linaro.org Received: by mail-ej1-x62c.google.com with SMTP id a640c23a62f3a-a77d9217e6fso481006766b.2 for ; Mon, 15 Jul 2024 03:08:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721038122; x=1721642922; darn=lists.denx.de; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=1hmytS4Unti8N4UWz0So7iJZshWMA6yLHRXiaZMt67I=; b=pgIH7o2lYa4DH/yyLq2v52a7OsCx1lLm6fIAfbVy18NapoH0BWBuFcvZy0wyJpB0Cg UBQR++ZHNxMjoH/sIh3oiqT5ilv44PmFWqTX3Sfc4l0VWsCQgBiEKZbNWvZdjI07Qk7d UQ3fliwxkMFnnjeyqDi6GlDNwq77x5zxFF/O2B5e+SpwmMLIzVVLlgoEmUJZGuCWPvKR C3XFhsjo54mqz8sU39FRRuI3Kvps9/dmPWa4HNiFEru0oQengchwFUUJ4MfK+sOKu6cA gwteLtX6oJl1R08LP6y4vXdiKK9M2fG49EFcx9KhZ8JXrpwKYPt4RuH103clIL0m0eH7 QEww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721038122; x=1721642922; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1hmytS4Unti8N4UWz0So7iJZshWMA6yLHRXiaZMt67I=; b=UkPtM/Sk4hqzr/sGT9htrkhNZd2h78WlO2ivtxJTJV5xS9yq5Qzl6RC+UfZIaIgIeL vueaJTgMe0RXxzxTZLzUayMIe/Y5xNaMsSlaJwo5s8sZOctfX05BuinLxj19vErj2Ibf vLZgszZmfklJzpA7RVkWQrZ1ep3lMDO1+nTXhmlwIe5t0YjPbVRPXfnnMOGVL5NkQfmT 8+GZcfRBJ54v92ddJARJ4J91IFeUvvWkhOQqOOjdqv/ECyBoSMZmjhyoQGSMmBzHG00A WqNSmq14MKUFr74C2byjf3DpaqJkvuXj5/+RfD++z+1tdA5eIdo6jbulntKmHiPJauLa mZFg== X-Gm-Message-State: AOJu0Yx2wv3EAubQCfn+Q7EGmRJUjuxjhZpfHwEiIm+86elbKTJ00nrQ oTUNCgHuzNGaVNRwtajWnpXWztGTnOqAfSYksz+HPsmR0abTRcBSlx5Rx7/QSCc= X-Received: by 2002:a17:907:d8a:b0:a72:7c0d:8fdc with SMTP id a640c23a62f3a-a780b68a311mr1502838266b.14.1721038101749; Mon, 15 Jul 2024 03:08:21 -0700 (PDT) Received: from [192.168.0.113] ([2a02:8109:aa0d:be00::7424]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a79bc5b7eb4sm198102266b.60.2024.07.15.03.08.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 03:08:21 -0700 (PDT) From: Caleb Connolly Date: Mon, 15 Jul 2024 12:08:09 +0200 Subject: [PATCH v6 10/24] soc: qcom: rpmh-rsc: adjust probe for U-Boot MIME-Version: 1.0 Message-Id: <20240715-b4-qcom-rpmh-v6-10-0c948a25d018@linaro.org> References: <20240715-b4-qcom-rpmh-v6-0-0c948a25d018@linaro.org> In-Reply-To: <20240715-b4-qcom-rpmh-v6-0-0c948a25d018@linaro.org> To: Tom Rini , Caleb Connolly , Neil Armstrong , Sumit Garg , Jaehoon Chung , Simon Glass Cc: u-boot@lists.denx.de, u-boot-qcom@groups.io X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=8474; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=4iKCVU52KhaCwwKEXjpNER/MziLXX/Du2ZD98VxXPgU=; b=owEBbQKS/ZANAwAIAQWDMSsZX2S2AcsmYgBmlPUGsKFgU3ccGaJ8lT7Vskh4anmY2sFNIQq8I Hceh1k+8dOJAjMEAAEIAB0WIQS2UaFGPGq+0GkMVc0FgzErGV9ktgUCZpT1BgAKCRAFgzErGV9k tqOlD/9T+s9hMFEtnMKrYsyR+gzIG8GFet38AHcJbRVgFiLAfm4JDFze5OJWgpE5cjd+t5TE1KD yfyIb+itC8r+L0brUyw6mwIGZTAc9dSbWefSCE0FjO7RgFpXJZ86DE6Ho81tXTawvnfxG3Lwlxh s4lKIk3GT1StxvSkOwxU8Zh4tTNdd2Phf6wDHLrMg3uG7atScJtJRh0VNeqn8zErvZGfLm3Nf+1 bmjJGzGGPr5vujLnAaJz1tmxVu6WlQsgi5hSgJn1+mLrY6ZZ5ha5T2v7gwDR5UsVuZ1yOSA9GAd kpuydTf2xbjT8tH2FugsWxb+dlPKghxuyp2Np0oJkAPWc0UoX+B4aVTPeqK4VCL35WlUT8eAXAU 3ruawXIo8KbbEQ/jkPFd/TSkdKSSJdXM4zhm//2OONlwBfpiEUrYiKRi8EXzCaIGQiG3uVL2vw5 UlLF1g0dV+0Iev9W2EpPDR32gvlTMhJPJYrcnZNhtYjDg/a/aFcGQH0Awu73KVgNRrSdFaasBTz bI5zOvqULImepS3wDzQFv2Av9IihGnfBnwiGaW2XIZO80LyHrlOVtzOw/j8LmgjqEuc74YUNBvF sgECVM+vFHPHN/aK/CUhQN4cTUNwhrU2AnPQJ4wJ4s546Eol6Eq9dTo4KcTzU6YzzVffGjzBP26 MA4VgwfjgPe/3Qw== X-Developer-Key: i=caleb.connolly@linaro.org; a=openpgp; fpr=83B24DA7FE145076BC38BB250CD904EB673A7C47 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.8 at phobos.denx.de X-Virus-Status: Clean Rework the rpmh-rsc initialization to use U-Boot's driver model and initialize cmd-db. Acked-by: Sumit Garg Signed-off-by: Caleb Connolly --- drivers/soc/qcom/rpmh-internal.h | 14 ++--- drivers/soc/qcom/rpmh-rsc.c | 123 ++++++++++----------------------------- 2 files changed, 34 insertions(+), 103 deletions(-) diff --git a/drivers/soc/qcom/rpmh-internal.h b/drivers/soc/qcom/rpmh-internal.h index 12c5b8d9cf86..ac8f6c35a7a4 100644 --- a/drivers/soc/qcom/rpmh-internal.h +++ b/drivers/soc/qcom/rpmh-internal.h @@ -7,17 +7,18 @@ #ifndef __RPM_INTERNAL_H__ #define __RPM_INTERNAL_H__ #include -#include #include #define TCS_TYPE_NR 4 #define MAX_CMDS_PER_TCS 16 #define MAX_TCS_PER_TYPE 3 #define MAX_TCS_NR (MAX_TCS_PER_TYPE * TCS_TYPE_NR) #define MAX_TCS_SLOTS (MAX_CMDS_PER_TCS * MAX_TCS_PER_TYPE) +#define USEC_PER_SEC 1000000UL + struct rsc_drv; /** * struct tcs_group: group of Trigger Command Sets (TCS) to send state requests @@ -63,10 +64,9 @@ struct tcs_group { */ struct rpmh_request { struct tcs_request msg; struct tcs_cmd cmd[MAX_RPMH_PAYLOAD]; - struct completion *completion; - const struct device *dev; + const struct udevice *dev; bool needs_free; }; /** @@ -78,9 +78,8 @@ struct rpmh_request { * @batch_cache: Cache sleep and wake requests sent as batch */ struct rpmh_ctrlr { struct list_head cache; - spinlock_t cache_lock; bool dirty; struct list_head batch_cache; }; @@ -122,17 +121,12 @@ struct rsc_drv { void __iomem *base; void __iomem *tcs_base; int id; int num_tcs; - struct notifier_block rsc_pm; - struct notifier_block genpd_nb; - atomic_t cpus_in_pm; struct tcs_group tcs[TCS_TYPE_NR]; DECLARE_BITMAP(tcs_in_use, MAX_TCS_NR); - spinlock_t lock; - wait_queue_head_t tcs_wait; struct rpmh_ctrlr client; - struct device *dev; + struct udevice *dev; struct rsc_ver ver; u32 *regs; }; diff --git a/drivers/soc/qcom/rpmh-rsc.c b/drivers/soc/qcom/rpmh-rsc.c index 6b47c8001cac..2afe5005facf 100644 --- a/drivers/soc/qcom/rpmh-rsc.c +++ b/drivers/soc/qcom/rpmh-rsc.c @@ -385,20 +385,20 @@ int rpmh_rsc_send_data(struct rsc_drv *drv, const struct tcs_request *msg) return 0; } -static int rpmh_probe_tcs_config(struct platform_device *pdev, struct rsc_drv *drv) +static int rpmh_probe_tcs_config(struct udevice *dev, struct rsc_drv *drv) { struct tcs_type_config { u32 type; u32 n; } tcs_cfg[TCS_TYPE_NR] = { { 0 } }; - struct device_node *dn = pdev->dev.of_node; + ofnode dn = dev_ofnode(dev); u32 config, max_tcs, ncpt, offset; int i, ret, n, st = 0; struct tcs_group *tcs; - ret = of_property_read_u32(dn, "qcom,tcs-offset", &offset); + ret = ofnode_read_u32(dn, "qcom,tcs-offset", &offset); if (ret) return ret; drv->tcs_base = drv->base + offset; @@ -410,24 +410,15 @@ static int rpmh_probe_tcs_config(struct platform_device *pdev, struct rsc_drv *d ncpt = config & (DRV_NCPT_MASK << DRV_NCPT_SHIFT); ncpt = ncpt >> DRV_NCPT_SHIFT; - n = of_property_count_u32_elems(dn, "qcom,tcs-config"); - if (n != 2 * TCS_TYPE_NR) - return -EINVAL; + n = ofnode_read_u32_array(dn, "qcom,tcs-config", (u32 *)tcs_cfg, 2 * TCS_TYPE_NR); + if (n < 0) { + log_err("RPMh: %s: error reading qcom,tcs-config %d\n", dev->name, n); + return n; + } for (i = 0; i < TCS_TYPE_NR; i++) { - ret = of_property_read_u32_index(dn, "qcom,tcs-config", - i * 2, &tcs_cfg[i].type); - if (ret) - return ret; - if (tcs_cfg[i].type >= TCS_TYPE_NR) - return -EINVAL; - - ret = of_property_read_u32_index(dn, "qcom,tcs-config", - i * 2 + 1, &tcs_cfg[i].n); - if (ret) - return ret; if (tcs_cfg[i].n > MAX_TCS_PER_TYPE) return -EINVAL; } @@ -456,43 +447,28 @@ static int rpmh_probe_tcs_config(struct platform_device *pdev, struct rsc_drv *d return 0; } -static int rpmh_rsc_probe(struct platform_device *pdev) +static int rpmh_rsc_probe(struct udevice *dev) { - struct device_node *dn = pdev->dev.of_node; + ofnode dn = dev_ofnode(dev); struct rsc_drv *drv; char drv_id[10] = {0}; - int ret, irq; - u32 solver_config; + int ret; u32 rsc_id; - /* - * Even though RPMh doesn't directly use cmd-db, all of its children - * do. To avoid adding this check to our children we'll do it now. - */ - ret = cmd_db_ready(); - if (ret) { - if (ret != -EPROBE_DEFER) - dev_err(&pdev->dev, "Command DB not available (%d)\n", - ret); - return ret; - } + drv = dev_get_priv(dev); - drv = devm_kzalloc(&pdev->dev, sizeof(*drv), GFP_KERNEL); - if (!drv) - return -ENOMEM; - - ret = of_property_read_u32(dn, "qcom,drv-id", &drv->id); + ret = ofnode_read_u32(dn, "qcom,drv-id", &drv->id); if (ret) return ret; - drv->name = of_get_property(dn, "label", NULL); + drv->name = ofnode_get_property(dn, "label", NULL); if (!drv->name) - drv->name = dev_name(&pdev->dev); + drv->name = dev->name; snprintf(drv_id, ARRAY_SIZE(drv_id), "drv-%d", drv->id); - drv->base = devm_platform_ioremap_resource_byname(pdev, drv_id); + drv->base = (void __iomem *)dev_read_addr_name(dev, drv_id); if (IS_ERR(drv->base)) return PTR_ERR(drv->base); rsc_id = readl_relaxed(drv->base + RSC_DRV_ID); @@ -505,84 +481,45 @@ static int rpmh_rsc_probe(struct platform_device *pdev) drv->regs = rpmh_rsc_reg_offset_ver_3_0; else drv->regs = rpmh_rsc_reg_offset_ver_2_7; - ret = rpmh_probe_tcs_config(pdev, drv); + ret = rpmh_probe_tcs_config(dev, drv); if (ret) return ret; spin_lock_init(&drv->lock); init_waitqueue_head(&drv->tcs_wait); bitmap_zero(drv->tcs_in_use, MAX_TCS_NR); - irq = platform_get_irq(pdev, drv->id); - if (irq < 0) - return irq; - - ret = devm_request_irq(&pdev->dev, irq, tcs_tx_done, - IRQF_TRIGGER_HIGH | IRQF_NO_SUSPEND, - drv->name, drv); - if (ret) - return ret; - - /* - * CPU PM/genpd notification are not required for controllers that support - * 'HW solver' mode where they can be in autonomous mode executing low - * power mode to power down. - */ - solver_config = readl_relaxed(drv->base + drv->regs[DRV_SOLVER_CONFIG]); - solver_config &= DRV_HW_SOLVER_MASK << DRV_HW_SOLVER_SHIFT; - solver_config = solver_config >> DRV_HW_SOLVER_SHIFT; - if (!solver_config) { - if (pdev->dev.pm_domain) { - ret = rpmh_rsc_pd_attach(drv, &pdev->dev); - if (ret) - return ret; - } else { - drv->rsc_pm.notifier_call = rpmh_rsc_cpu_pm_callback; - cpu_pm_register_notifier(&drv->rsc_pm); - } - } - /* Enable the active TCS to send requests immediately */ writel_relaxed(drv->tcs[ACTIVE_TCS].mask, drv->tcs_base + drv->regs[RSC_DRV_IRQ_ENABLE]); spin_lock_init(&drv->client.cache_lock); INIT_LIST_HEAD(&drv->client.cache); INIT_LIST_HEAD(&drv->client.batch_cache); - dev_set_drvdata(&pdev->dev, drv); - drv->dev = &pdev->dev; + dev_set_drvdata(dev, drv); + drv->dev = dev; - ret = devm_of_platform_populate(&pdev->dev); - if (ret && pdev->dev.pm_domain) { - dev_pm_genpd_remove_notifier(&pdev->dev); - pm_runtime_disable(&pdev->dev); - } + log_debug("RPMh: %s: v%d.%d\n", dev->name, drv->ver.major, drv->ver.minor); return ret; } -static const struct of_device_id rpmh_drv_match[] = { - { .compatible = "qcom,rpmh-rsc", }, +static const struct udevice_id qcom_rpmh_ids[] = { + { .compatible = "qcom,rpmh-rsc" }, { } }; -MODULE_DEVICE_TABLE(of, rpmh_drv_match); -static struct platform_driver rpmh_driver = { - .probe = rpmh_rsc_probe, - .driver = { - .name = "rpmh", - .of_match_table = rpmh_drv_match, - .suppress_bind_attrs = true, - }, +U_BOOT_DRIVER(qcom_rpmh_rsc) = { + .name = "qcom_rpmh_rsc", + .id = UCLASS_MISC, + .priv_auto = sizeof(struct rsc_drv), + .probe = rpmh_rsc_probe, + .of_match = qcom_rpmh_ids, + /* rpmh is under CLUSTER_PD which we don't support, so skip trying to enable PDs */ + .flags = DM_FLAG_DEFAULT_PD_CTRL_OFF, }; -static int __init rpmh_driver_init(void) -{ - return platform_driver_register(&rpmh_driver); -} -core_initcall(rpmh_driver_init); - MODULE_DESCRIPTION("Qualcomm Technologies, Inc. RPMh Driver"); MODULE_LICENSE("GPL v2"); From patchwork Mon Jul 15 10:08:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 812611 Delivered-To: patch@linaro.org Received: by 2002:adf:fac3:0:b0:367:895a:4699 with SMTP id a3csp1724540wrs; Mon, 15 Jul 2024 03:10:12 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUZyapWbyOyIxQOg9guR4TeOYuwC6DHrFz81K4PxWAUMekLhoFDOYvT+lrBcqymOZOjm9ItufX2wJybyutTak+f X-Google-Smtp-Source: AGHT+IHTIH8iXw8Y5zoXXvFDa+zhV7aUtR7Q0qzZLYipEBvtmsINjPV0P2TNwRXF+J764V5ZJoBq X-Received: by 2002:a05:6402:50cc:b0:57d:15ee:3d18 with SMTP id 4fb4d7f45d1cf-594bb580547mr14248289a12.20.1721038212346; Mon, 15 Jul 2024 03:10:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721038212; cv=none; d=google.com; s=arc-20160816; b=mLZUde7y7uBGbwCeGNglffjNLCwKaVDgGG6sdFPbUEgUWPJLA0KvOCcqM8zNe+ms4B 25LbFl3vrAxW0HtZ0bOQLi6BXkVz85NCKADdhvoUXIacOGyGbwgiC3o1BBS2NQyvqAFm m1d0adE/KQ77rrpuN5hzEmxACbnSlFA7q8YAzf8WogyC1zrfHJ/wfdUSdPKJWBEETug5 MxMyMyz/Z+scsmbbH1phCPFzt63F2XI87o+ELYoRJ4IT7NSFF5/BfSW6Rp9NIQulki7Z j2em23337OWJDEGyPAHO0esD0zg/xaLFj6nZctbADxjFMIfWRaq1+X5dER23x1XtepPR HcTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:cc:to:in-reply-to:references :message-id:content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=Ho62e0Tm9bGB47FP/3QVxl2QmsI4RW2Ee7v1Gczir1c=; fh=zcTfjI3NycJyTuuOJ9uzXxS7wfOr4sYKS7eKveHEFzw=; b=j9ADj18bxO2fjmWTOJxAJTq/zy6EH8uHjRy3RmKblDStfzc4qupflAiK7YWALWEp5S MjVIX4CJHpH9EAxmOMqcVIU3+Z8ipfRBGcW2sOG5WnrW0zOzcHVZyVCEBsTrOoaD4P6v DJPdkd30b+e43F1ZnxMW5X7bbWjwo6PsAVjc7OHKXMps0b57K3mg226m1K9si+y3YJYc 0KJxqfmmuP+LjGokui6WgckH9YOF3orvVALqiRHmf4KbtkTn40Ze/jQDx+j+cPcQNN/r O3e3uG0ll/hEe0IdbSlF+yK7ZtHfA04ucTEZ7ova0RZU/jEH9R1MIrLdDPt5/ZcYNbI3 YkEw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JenKtg7k; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-59b2705ad26si2269930a12.462.2024.07.15.03.10.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 03:10:12 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JenKtg7k; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4DA0C88845; Mon, 15 Jul 2024 12:08:48 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org 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=linaro.org header.i=@linaro.org header.b="JenKtg7k"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 50D8788842; Mon, 15 Jul 2024 12:08:45 +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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) (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 456F088845 for ; Mon, 15 Jul 2024 12:08:43 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=caleb.connolly@linaro.org Received: by mail-ed1-x52f.google.com with SMTP id 4fb4d7f45d1cf-58f9874aeb4so5194174a12.0 for ; Mon, 15 Jul 2024 03:08:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721038123; x=1721642923; darn=lists.denx.de; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=Ho62e0Tm9bGB47FP/3QVxl2QmsI4RW2Ee7v1Gczir1c=; b=JenKtg7kuTawStRshQZF/IHsAWmxEi5upE99wK6uzpQ2oD9NzTLNq7vR/4wKe5eU9/ Fvm/VhmLRmx6zmQbOlGAXxtNB9MwPFD8YPZXB9COWK8V1or5Z0G3IWffHCi3ZkOUZ/Ek Ml5RapAT7C+2H68s+pP9wd1eQwskMI0a0FotctfthitSl1EbwtnA0JHKb8qqdI6yC0wo j2CilBGuiu6I6eMheP+GSdcA5kDSVz0Fc9DNL/xAdMFfBtjyVanBFP7xsKRXNXUyONMq eZM+pYV5vzBMELOKPMof30RGMNXDUGYBnj1ILu7UOFCFzG8K4t/kZVCEXTbZO349JL2e TKlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721038123; x=1721642923; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ho62e0Tm9bGB47FP/3QVxl2QmsI4RW2Ee7v1Gczir1c=; b=jOElzRHDEOYyVk4ct2HGvKVHqVJfXUiQcqHry0PKnF74q8pIl2d1CyODX6GFS6Xz2j vw2sxmxKFBx5L2kNtCUm/5BEkc4K4sTz7raex4iajKUwaP6I76p0A7LY4mRk5ANOuiFp SMHNQfdQTPv6kz7UgQ1lmAFbzbGHjCosH9oya9D0/tYI2NPJ+ycBfeRsz/kw5oLvZyqD TAoHlm+XWk5/ZbcUVcQdkDd3IGwMdRA+eiObpqwRTTvxdlY280t3uiOrOyeptBuWVZNw oCp62/KsO3gXduoZo+nGOFQE2wEAYJcTcLzpKcpUHKQ3u8Y6oGHzobEzzrMWBEKC8VIn 2aqw== X-Gm-Message-State: AOJu0YxTS8cnj5kpnf2FQTyXTI3y8AJbX17rxvL/R77v7QuiXwpfiWCj yjDChMSJ+9tOUb9+NOpD7PQKDrd31BCj0eZH0aEpvwd3VAvkL4EjnOIxms7Ryj8= X-Received: by 2002:a17:906:66c9:b0:a77:cf9d:f497 with SMTP id a640c23a62f3a-a780b70513emr1205003666b.40.1721038122807; Mon, 15 Jul 2024 03:08:42 -0700 (PDT) Received: from [192.168.0.113] ([2a02:8109:aa0d:be00::7424]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a79bc5b7eb4sm198102266b.60.2024.07.15.03.08.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 03:08:42 -0700 (PDT) From: Caleb Connolly Date: Mon, 15 Jul 2024 12:08:10 +0200 Subject: [PATCH v6 11/24] soc: qcom: rpmh-rsc: remaining U-Boot API changes MIME-Version: 1.0 Message-Id: <20240715-b4-qcom-rpmh-v6-11-0c948a25d018@linaro.org> References: <20240715-b4-qcom-rpmh-v6-0-0c948a25d018@linaro.org> In-Reply-To: <20240715-b4-qcom-rpmh-v6-0-0c948a25d018@linaro.org> To: Tom Rini , Caleb Connolly , Neil Armstrong , Sumit Garg , Jaehoon Chung , Simon Glass Cc: u-boot@lists.denx.de, u-boot-qcom@groups.io X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=5823; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=ceejJWEJy6z1xebitvHMIbJYyb9bWOSzAlEpUwbMOdI=; b=owEBbQKS/ZANAwAIAQWDMSsZX2S2AcsmYgBmlPUG4hFlFvnDbPBYZ6KjHfDvMZ5VozVfOcYaq Ad+FoC6NZSJAjMEAAEIAB0WIQS2UaFGPGq+0GkMVc0FgzErGV9ktgUCZpT1BgAKCRAFgzErGV9k trczEACmlQ4ljhgpxOVcN/eRNVax0hJlLefUF21BRyYqEQdY47Rpjlmq46nimi+7wAZ9hUInz/n 7VCIL5ccebJC4F4FEV3+f0URW6hJ2e/IO86G9PSJc6rJOKt0b8a7zZwDcVe3pCQvo4sTszB6uSN e62VV4hZf5JP80ndeBNlWqCTQpubrgw7BcUJRY2UT22QsEZwr9ogRiIaDJ9oug5/Km0glbPBwXF XJcmQEogPDykgLN+W1i5LDZNlsfxG5iDu1ah4tH+XCTG2cXAmwAaIwLcqhH6ZkQ2UmSwzlUIMsQ J4+blGZ8UvBZfMLUwBZy0FEO99wa87eKOyy5QrXfG5UCYnVj3FCRa36n5SR17+/QS5JiitqtWma 4e25DNNUeNXs8e4cb/KAQmQsn3briK5WVjAnLeUzCX0lbTjNpS4Am7GKxhHf+sr3lluUTpKdU+S YGOCCCqIOigbGyqSfNKAqJFfsRMjzoq1FLOjaEJf7rosuvL5sc1T1Rff6ZdClGuyz9rK+sRXenA 5JS8lBbKgfloP2jPYEgeakbkZ0pVf1AyYkgL9cdrV3cYVuQqm0FWeVgtoATyq8bS865bH5d4ly0 mg/4KQup3IWiRurBdilIJRurZgALiCIYNn9sKElN1Ny4SjIRNqoiPYVRY54IXtnoybzHghrE33F Y2p+z9tqQWavHYw== X-Developer-Key: i=caleb.connolly@linaro.org; a=openpgp; fpr=83B24DA7FE145076BC38BB250CD904EB673A7C47 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.8 at phobos.denx.de X-Virus-Status: Clean Minor adjustments to fix building with U-Boot and work correctly as a synchronous driver without interrupts. RPMh is fast enough that we can get away with just firing off requests and assuming they complete. U-Boot behaviour changes are annotated with a "U-Boot:" comment. Acked-by: Sumit Garg Signed-off-by: Caleb Connolly --- drivers/soc/qcom/rpmh-rsc.c | 78 +++++++++++++++++---------------------------- 1 file changed, 29 insertions(+), 49 deletions(-) diff --git a/drivers/soc/qcom/rpmh-rsc.c b/drivers/soc/qcom/rpmh-rsc.c index 2afe5005facf..61fb2e695587 100644 --- a/drivers/soc/qcom/rpmh-rsc.c +++ b/drivers/soc/qcom/rpmh-rsc.c @@ -133,16 +133,8 @@ enum { * | ...... | * +---------------------------------------------------+ */ -#define USECS_TO_CYCLES(time_usecs) \ - xloops_to_cycles((time_usecs) * 0x10C7UL) - -static inline unsigned long xloops_to_cycles(u64 xloops) -{ - return (xloops * loops_per_jiffy * HZ) >> 32; -} - static u32 rpmh_rsc_reg_offset_ver_2_7[] = { [RSC_DRV_TCS_OFFSET] = 672, [RSC_DRV_CMD_OFFSET] = 20, [DRV_SOLVER_CONFIG] = 0x04, @@ -247,37 +239,18 @@ static void write_tcs_reg_sync(const struct rsc_drv *drv, int reg, int tcs_id, */ static struct tcs_group *get_tcs_for_msg(struct rsc_drv *drv, const struct tcs_request *msg) { - int type; - struct tcs_group *tcs; - - switch (msg->state) { - case RPMH_ACTIVE_ONLY_STATE: - type = ACTIVE_TCS; - break; - case RPMH_WAKE_ONLY_STATE: - type = WAKE_TCS; - break; - case RPMH_SLEEP_STATE: - type = SLEEP_TCS; - break; - default: + /* + * U-Boot: since we're single threaded and running synchronously we can + * just always used the first active TCS. + */ + if (msg->state != RPMH_ACTIVE_ONLY_STATE) { + log_err("WARN: only ACTIVE_ONLY state supported\n"); return ERR_PTR(-EINVAL); } - /* - * If we are making an active request on a RSC that does not have a - * dedicated TCS for active state use, then re-purpose a wake TCS to - * send active votes. This is safe because we ensure any active-only - * transfers have finished before we use it (maybe by running from - * the last CPU in PM code). - */ - tcs = &drv->tcs[type]; - if (msg->state == RPMH_ACTIVE_ONLY_STATE && !tcs->num_tcs) - tcs = &drv->tcs[WAKE_TCS]; - - return tcs; + return &drv->tcs[ACTIVE_TCS]; } /** * __tcs_buffer_write() - Write to TCS hardware from a request; don't trigger. @@ -297,11 +270,8 @@ static void __tcs_buffer_write(struct rsc_drv *drv, int tcs_id, int cmd_id, u32 cmd_enable = 0; struct tcs_cmd *cmd; int i, j; - /* Convert all commands to RR when the request has wait_for_compl set */ - cmd_msgid |= msg->wait_for_compl ? CMD_MSGID_RESP_REQ : 0; - for (i = 0, j = cmd_id; i < msg->num_cmds; i++, j++) { cmd = &msg->cmds[i]; cmd_enable |= BIT(j); msgid = cmd_msgid; @@ -313,9 +283,11 @@ static void __tcs_buffer_write(struct rsc_drv *drv, int tcs_id, int cmd_id, write_tcs_cmd(drv, drv->regs[RSC_DRV_CMD_MSGID], tcs_id, j, msgid); write_tcs_cmd(drv, drv->regs[RSC_DRV_CMD_ADDR], tcs_id, j, cmd->addr); write_tcs_cmd(drv, drv->regs[RSC_DRV_CMD_DATA], tcs_id, j, cmd->data); - trace_rpmh_send_msg(drv, tcs_id, msg->state, j, msgid, cmd); + debug("tcs(m): %d [%s] cmd(n): %d msgid: %#x addr: %#x data: %#x complete: %d\n", + tcs_id, msg->state == RPMH_ACTIVE_ONLY_STATE ? "active" : "?", j, msgid, + cmd->addr, cmd->data, cmd->wait); } cmd_enable |= read_tcs_reg(drv, drv->regs[RSC_DRV_CMD_ENABLE], tcs_id); write_tcs_reg(drv, drv->regs[RSC_DRV_CMD_ENABLE], tcs_id, cmd_enable); @@ -345,34 +317,28 @@ static void __tcs_buffer_write(struct rsc_drv *drv, int tcs_id, int cmd_id, */ int rpmh_rsc_send_data(struct rsc_drv *drv, const struct tcs_request *msg) { struct tcs_group *tcs; - int tcs_id; - - might_sleep(); + int tcs_id, i; + u32 addr; tcs = get_tcs_for_msg(drv, msg); if (IS_ERR(tcs)) return PTR_ERR(tcs); - spin_lock_irq(&drv->lock); - - /* Wait forever for a free tcs. It better be there eventually! */ - wait_event_lock_irq(drv->tcs_wait, - (tcs_id = claim_tcs_for_req(drv, tcs, msg)) >= 0, - drv->lock); + /* u-boot is single-threaded, always use the first TCS as we'll never conflict */ + tcs_id = tcs->offset; tcs->req[tcs_id - tcs->offset] = msg; - set_bit(tcs_id, drv->tcs_in_use); + generic_set_bit(tcs_id, drv->tcs_in_use); if (msg->state == RPMH_ACTIVE_ONLY_STATE && tcs->type != ACTIVE_TCS) { /* * Clear previously programmed WAKE commands in selected * repurposed TCS to avoid triggering them. tcs->slots will be * cleaned from rpmh_flush() by invoking rpmh_rsc_invalidate() */ write_tcs_reg_sync(drv, drv->regs[RSC_DRV_CMD_ENABLE], tcs_id, 0); } - spin_unlock_irq(&drv->lock); /* * These two can be done after the lock is released because: * - We marked "tcs_in_use" under lock. @@ -382,8 +348,22 @@ int rpmh_rsc_send_data(struct rsc_drv *drv, const struct tcs_request *msg) * of __tcs_set_trigger() below. */ __tcs_buffer_write(drv, tcs_id, 0, msg); + /* U-Boot: Now wait for the TCS to be cleared, indicating that we're done */ + for (i = 0; i < USEC_PER_SEC; i++) { + addr = read_tcs_cmd(drv, drv->regs[RSC_DRV_CMD_ADDR], i, 0); + if (addr != msg->cmds[0].addr) + break; + udelay(1); + } + + if (i == USEC_PER_SEC) { + log_err("%s: error writing %#x to %d:%#x\n", drv->name, + msg->cmds[0].addr, tcs_id, drv->regs[RSC_DRV_CMD_ADDR]); + return -EINVAL; + } + return 0; } static int rpmh_probe_tcs_config(struct udevice *dev, struct rsc_drv *drv) From patchwork Mon Jul 15 10:08:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 812612 Delivered-To: patch@linaro.org Received: by 2002:adf:fac3:0:b0:367:895a:4699 with SMTP id a3csp1724615wrs; Mon, 15 Jul 2024 03:10:23 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVK7D2hVNDBT4aM0+3Po/kd63rKNju41OmHqfM8cTS4TGkLLD7WXDQqNDF6BKF1TMkIfxXtN3bhJhQ4zsy3RDER X-Google-Smtp-Source: AGHT+IEmscucHpeCJ+aQz+2oYDH5IGSw4mnDSPMP19qNk/0Us4+uGi1C0Q9yr14Vw9O50215pFtn X-Received: by 2002:aa7:c495:0:b0:57d:669:caf2 with SMTP id 4fb4d7f45d1cf-594bbb4b2d5mr13870760a12.25.1721038223711; Mon, 15 Jul 2024 03:10:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721038223; cv=none; d=google.com; s=arc-20160816; b=AK8T2YxeZFQxOZncm+bpl4J3cdzvKeGhlubqIeYDGd05D9M4m5JyfX7XBUdmiL3dwx J+nztSRhlPbVXKiLm1nm8J4P+UdROITh9X1+taAf3OznFVbq9sRWYh1eG0kFzErVTQ28 jCr4osn1vUku6fjdW6Sof/nCKA2wwfkUI6rMWytUF7pvVgciTSbA+gIAUsjirwqPRPyi REJziEVTMe2bOUKtYl1/K9x9/RcXAFnNUE/4bHvvmkxxQJuQv8bKDWfssoj8lE3WCCOT F2oxmqcjejlarOGiEzJvTlUpzbPW3OlcEPjKN8TbkAxgJAB2r57dGBhUgzlsBG3HYGA0 HX9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:cc:to:in-reply-to:references :message-id:content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=SKvlBpz8RmPSM+u1cdQpsDXjklLDQjoXQk7ECpqhhF4=; fh=zcTfjI3NycJyTuuOJ9uzXxS7wfOr4sYKS7eKveHEFzw=; b=utEG7j0zN92SZBxvA1a8kftmfCFjjdY7do3E6iRpt8Ip/ajyEfCvtNhjnlXDYGx84P p1bdR9TyWdA8Q/dB7Q1/NZ3p74Ek0Ve8Lg/B6Axs2GymZxkcacVk9YPOILUMde1wVuHi x+XX9Js8C/tO6JgHDT2RmrERT/qnOYqUv9r0zN979kc6e2rO3e0lgVAcz6FuK+SaTMdL LeBD+Wz+ziLjYFLcNsuwy94Ta1/kGjvS0iYdE6wmttgrz+S9X1oEP6qOrhJ6B1Q97vnj HrnoipUCmQ0xMenrnzUT52pqG6iqSMHPt3mgckx/xsAm9dBh6nTSK/qU67RTnhS772c6 gyHg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CpiXug5m; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id a640c23a62f3a-a79bc5a8c60si236922966b.266.2024.07.15.03.10.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 03:10:23 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CpiXug5m; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id AEA898884A; Mon, 15 Jul 2024 12:08:48 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org 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=linaro.org header.i=@linaro.org header.b="CpiXug5m"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7895188853; Mon, 15 Jul 2024 12:08:46 +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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) (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 8347E887EB for ; Mon, 15 Jul 2024 12:08:44 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=caleb.connolly@linaro.org Received: by mail-lf1-x12c.google.com with SMTP id 2adb3069b0e04-52e97e5a84bso5644134e87.2 for ; Mon, 15 Jul 2024 03:08:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721038124; x=1721642924; darn=lists.denx.de; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=SKvlBpz8RmPSM+u1cdQpsDXjklLDQjoXQk7ECpqhhF4=; b=CpiXug5mhS+Q2eIy2rdDAPhOqxHI86pUEUPKiHUv3HxE49srcAeHu0xe7+geS/qbus WqsDUqiNy1s1TpVVBpFM0mZm4E4PulV+KaR+bQIp0/SYAq+qr0DPXSSWz5iO+2tz2Jiz isCT/hzDkeIJGtr0HBj6rJT4yYplLaKCB2sXzQg1e9kiCwlyIMEzCYfAHHKk77W8MlxC Lm0HLDUqfZO94UIYMo9Ags7gbmyyspyUEihPjkdXhH83/Akviz3rJisBmFw81FtdqCWL m4RfPoF2Q2ueQNbozUGAgoKcKhftSsdcBRgpXAOWJfyGt6+esVeJVE5Zh/G7hxprToU3 EXvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721038124; x=1721642924; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SKvlBpz8RmPSM+u1cdQpsDXjklLDQjoXQk7ECpqhhF4=; b=l2gGFeLiqrpo+ZupXsvlQSzo0H5kAep/wmF5F4NCyDeQKxRXQzviTCbOwmkqlSMwCD VkrLGZGiUpKBP4Z0n2CSWllXC8CtavgOS5KJ99nmpwiPgu93mx8xTWLT6XbfmWxAD1bW VExswVEeqy+ZB8JZA6+RwddRQvsj260DhNdhZwTSMWjuSNgEZ30K+MfX2wc2NKTeuE/q SFqMsVz8A3XXM66XIT2CsBGwwtdQVf7Knrmq6xQn8N9J2u6qiT1QLlrMAEANbaO/Ee3o WqtTyZTwGu3265794PswDjWIfsZafQMgI3mOcnQhKVkKFSblq61yFvTtEV7i8bxzziX5 y7Ug== X-Gm-Message-State: AOJu0YzoZ+rqBI9lQEhWxYdPExzRt/dVwR2+oCbvdFE9dPD5svRrLYjJ stGO3a3QjlJkLktk5DuQ21pYkFDEOoXKTa+NRj5UNG17AOf0ie6cGP7DwIp0Vh8= X-Received: by 2002:a05:6512:b18:b0:52c:dd25:9ac6 with SMTP id 2adb3069b0e04-52eb99a3439mr15718017e87.29.1721038123863; Mon, 15 Jul 2024 03:08:43 -0700 (PDT) Received: from [192.168.0.113] ([2a02:8109:aa0d:be00::7424]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a79bc5b7eb4sm198102266b.60.2024.07.15.03.08.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 03:08:43 -0700 (PDT) From: Caleb Connolly Date: Mon, 15 Jul 2024 12:08:11 +0200 Subject: [PATCH v6 12/24] soc: qcom: rpmh: adjust headers for U-Boot MIME-Version: 1.0 Message-Id: <20240715-b4-qcom-rpmh-v6-12-0c948a25d018@linaro.org> References: <20240715-b4-qcom-rpmh-v6-0-0c948a25d018@linaro.org> In-Reply-To: <20240715-b4-qcom-rpmh-v6-0-0c948a25d018@linaro.org> To: Tom Rini , Caleb Connolly , Neil Armstrong , Sumit Garg , Jaehoon Chung , Simon Glass Cc: u-boot@lists.denx.de, u-boot-qcom@groups.io X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=1083; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=BrfeN3hYmP1FAjbb3m96AmdP4rR3yrnmrzgBmWKL9Ts=; b=owEBbQKS/ZANAwAIAQWDMSsZX2S2AcsmYgBmlPUGcCuaDOCEaO9Gd6rcsBI4Kjn0IiHw98wN5 /uMGcgLe5+JAjMEAAEIAB0WIQS2UaFGPGq+0GkMVc0FgzErGV9ktgUCZpT1BgAKCRAFgzErGV9k tpooD/0eY2PNJ3mlcQDj5vxdi7rSgQJDmWtRlKX3zKqQsIrYkZVbyVKB36IKgeEEZCE0ISCCgji bYi7vrPhY6jSpZSVsYcdeBnWaJl9hNa6Eq5NQCBs3K7f2SVE4IvYYakY+52iVRUvEjjTeizEk/P 29bLg96E4jvN6nJGTp8qpNXnhCBYYvTT82iIgNeBxn2iuTFTKx+ZsmNld/zCwu6RSzkOcBo00/m 5yMmqyRkSb05qyuaRvf6p9yPNqY3EMd0pP0vkMQGZ6lrS4DW8ufnmI/mFJtRJwEG1prJ0NxB0EU /gFdrYE8LNUKjt2dHH9CWMlqXqRmf5naklcVwZLhuy7i4Hyqwhdai5X/8PaygV/BNkF2qf2P2vM 50Q/AhwDu4ySztrWinofR2CZhzIQK0kTsvtPwtiFuKPhmaniv4pGz+Ionpu5KEr06O5P65LsghW G9wt7O+J4gjWCrGuTcHXrM4hKkgiUNFuQoAhHlvYO+6/++b4SWp8/lRUd5YrDZoI0iv0cytBC3M qD+mMrfwbHXEM6A3eDRPFd20ObemBm0L694HGVFLg+cGWIDBqbrTozHgftRbJ36RVg8yrUbv/+Y ECEYvVO1x3WU4Sj7/6V65mpkO5qxVRSX6pWrkUeCwqudqBLV5vBWseqNQ5wLp46NW/JPlWOQi64 QJJ+pte08tKF1yQ== X-Developer-Key: i=caleb.connolly@linaro.org; a=openpgp; fpr=83B24DA7FE145076BC38BB250CD904EB673A7C47 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.8 at phobos.denx.de X-Virus-Status: Clean Drop unused/unsupported Linux headers and add dm/device.h for U-Boot. Acked-by: Sumit Garg Signed-off-by: Caleb Connolly --- drivers/soc/qcom/rpmh.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/soc/qcom/rpmh.c b/drivers/soc/qcom/rpmh.c index 8903ed956312..03ef4106c9a6 100644 --- a/drivers/soc/qcom/rpmh.c +++ b/drivers/soc/qcom/rpmh.c @@ -2,22 +2,14 @@ /* * Copyright (c) 2016-2018, The Linux Foundation. All rights reserved. */ -#include +#include +#include #include -#include -#include #include #include -#include -#include -#include -#include -#include -#include #include -#include #include #include "rpmh-internal.h" From patchwork Mon Jul 15 10:08:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 812613 Delivered-To: patch@linaro.org Received: by 2002:adf:fac3:0:b0:367:895a:4699 with SMTP id a3csp1724658wrs; Mon, 15 Jul 2024 03:10:33 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWuGmK51vHoWJZ1OY9PFbh7WdHqZuxbPw3hKd7jc27zfIbvHHdJpZqeNW5Dg37AdCVYQVqmGBikFTUxs26uOTMn X-Google-Smtp-Source: AGHT+IHuILRfemWT03hB6YLxaNEt54vJ8TUljYWPOpX5ZZwtL0tulGJDMRHPGoknoWqTHlEUgU9d X-Received: by 2002:a05:6512:3499:b0:52e:936e:a237 with SMTP id 2adb3069b0e04-52eb999b382mr11558895e87.16.1721038233352; Mon, 15 Jul 2024 03:10:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721038233; cv=none; d=google.com; s=arc-20160816; b=vwab3lDnfPHKQVx+Chhkwz41fA6g8m/piXn7OHysny062A5qNeU37PizEUhxRSyl/7 dx7QLjFpAv4BjqvsBKD5DhbpVzCHwjVjCY9uZonFhgqYFD4LoCvEpY+BUN0yQy63OhHW RI2y3J8HmLbPl7WT8i6DFGdFq6G2hm+Zd97t8tRy1kKxWx//R2u5Vn6jaHsz2EhgmLsC vVXQIxthqcP1Om4MDchCTcPv8lPwwbLNb2d3ozzJW6sNWCW4G7s1OhZdQi9gV7NPsrjj ptdos64qAETUAszYjw9EjYzzxotL0HEbkyLabQkGHCb848BYJLojK5PDtB4fKTKWAVW3 tA9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:cc:to:in-reply-to:references :message-id:content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=uG0yeXPjYJbgCl1X/zbvHqsKJshfjohIdYI3Cg6jDpQ=; fh=zcTfjI3NycJyTuuOJ9uzXxS7wfOr4sYKS7eKveHEFzw=; b=o1zsjqvForeqG3jFTrJL1OZkhoykXA1k330hI4JIAnmw2MafkYxDgDXkXrbBA6m9fz icOfnzZZZ3lrVcVFGMZVpdfgTNOKbqLTLtQl/ZuENPiXoEW7YAxaV/UYS+TRjdb3HMXC rJO+hRMs/QDMe/cpE3pKbLzk4rc+f+oR6sgdwjIFOUZlSbqmBj+i9hx9U41jH6mMQxnV SlOUbqajt9Qsvtpv0T2sSFmiD5Y9Q90S5EA80mMl22iQXkmKHMKLLsZSO0anO1Z+csoP QNwHxk8txN7ixLFk2EzZt69Zyk7x1TobVvu+TlC04Ql5DMi6OXLD46HUJa9aap0kv9cJ PKVg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eELpGUci; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id a640c23a62f3a-a79bc8033c9si231815566b.717.2024.07.15.03.10.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 03:10:33 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eELpGUci; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1E59688877; Mon, 15 Jul 2024 12:08:50 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org 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=linaro.org header.i=@linaro.org header.b="eELpGUci"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DBEE18885C; Mon, 15 Jul 2024 12:08:47 +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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-lf1-x133.google.com (mail-lf1-x133.google.com [IPv6:2a00:1450:4864:20::133]) (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 9D6C388842 for ; Mon, 15 Jul 2024 12:08:45 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=caleb.connolly@linaro.org Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-52ea929ea56so7561970e87.0 for ; Mon, 15 Jul 2024 03:08:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721038125; x=1721642925; darn=lists.denx.de; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=uG0yeXPjYJbgCl1X/zbvHqsKJshfjohIdYI3Cg6jDpQ=; b=eELpGUcinrorB//o/eY87qC/YCQbbgToysjYX6j/V3GkeuXVxrXDfqbrtAaYsP8a9t 9rFMSBe41ckDdK9cyls+ieiAJ1sMqQFWRFZ3k9OBpYQYHGyki1LLY/+9goJObLzp1J8F ngyQdiP2p+Nsv7PJhJu/Zxfd1czGd1KokMokyO6pCDSe39IhafQ+UpFynkTnJthlnQ0k 5kqcqO5g7gvVUXJyEhEaEXf0vFf+RET0tM10XVs7kz//PixdJjxL7jqqt6LqIPrlVs4g 7LT61S5RwyxsAVxm8J4+G7Hu3a+ar3GBktR1ppYM9p93QBZWyvUxn5OIwX5SvRcxYX6j nW/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721038125; x=1721642925; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uG0yeXPjYJbgCl1X/zbvHqsKJshfjohIdYI3Cg6jDpQ=; b=pchEZQ1mO3kiDtZR5dtN5NDS35i9wk+NwxoU85PvjvnH6GUmkPWFdM3sdVe7GAmCV0 3+Ttr2g2O5aW0hfUfPhwKoszgR1M/Ko04tKULjrDjpNRG2Jwol1sMS5IfppdobNFOX7Y VejtQa3oP3coeTzkdUzyipg7IMnCLUt0ZH9P1eSMzHHCGn+tWFqNcKdrdKL/nmyXs/2e zLh3BiQ+8jdtfI9NDkU5hH1KCc24RsL4iGUVVy+hyKAUZmJW2gpY8q+q2GVtiVzIWy1J zjF3VNVcg+YXmJn/Sh8dncoMyrtnn8dovA9XO91PfAlr1fj/ZLeZid3lBn1TBhqm4kVH 0V3w== X-Gm-Message-State: AOJu0YxEJHVIXx9LfZENhpO6hl96414M5wjeE8zOS4JrfKpIEI1n5RQF eqFuyCxk/QMhPXYkqjvwvLkxk20zr2S8OLYf59/U95fV5N8T6EKcPsfYyW/cd4Q= X-Received: by 2002:a19:8c05:0:b0:52c:8909:bd35 with SMTP id 2adb3069b0e04-52eb9991eb3mr13328177e87.10.1721038124925; Mon, 15 Jul 2024 03:08:44 -0700 (PDT) Received: from [192.168.0.113] ([2a02:8109:aa0d:be00::7424]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a79bc5b7eb4sm198102266b.60.2024.07.15.03.08.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 03:08:44 -0700 (PDT) From: Caleb Connolly Date: Mon, 15 Jul 2024 12:08:12 +0200 Subject: [PATCH v6 13/24] soc: qcom: rpmh: drop unused functions MIME-Version: 1.0 Message-Id: <20240715-b4-qcom-rpmh-v6-13-0c948a25d018@linaro.org> References: <20240715-b4-qcom-rpmh-v6-0-0c948a25d018@linaro.org> In-Reply-To: <20240715-b4-qcom-rpmh-v6-0-0c948a25d018@linaro.org> To: Tom Rini , Caleb Connolly , Neil Armstrong , Sumit Garg , Jaehoon Chung , Simon Glass Cc: u-boot@lists.denx.de, u-boot-qcom@groups.io X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=12286; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=1RcEbGhTRCvxL78q80ivcA+VWpX0uhznCXCB7s81n00=; b=owEBbQKS/ZANAwAIAQWDMSsZX2S2AcsmYgBmlPUGtdYKzxPBA14rnZCqdFTuRG81IVE8z7Ap/ h+z1a3Y8TWJAjMEAAEIAB0WIQS2UaFGPGq+0GkMVc0FgzErGV9ktgUCZpT1BgAKCRAFgzErGV9k tp2ND/4xuBrMkYHg2qcRzEiOqdBWeP9w2QY3gAdGgTu0JduIv++3ZYVJQV/y/WXZnW+UoRbz/KD dZ70Wh8bi/z4qtE4ToptH2c9IiW0xCYtePItEnMD+V+zTfB429mVfIr3mFy/0+Yt5TP8iBI14JZ t6z9Gnjk5Dq2pJfZJ3x+RoZSZBfGpKiLlpvm9d3iVk+xE5ICItRDwY6+z4KESe/EIx4Vgb+Ex4K 60o/v0t+OdjQag89fsfN4E3viLFgILpGDXqY7GljZR++uVG0whFvgUkdBMoqYQojCVqrr342XBR JEZXU0LzxfWPfPXk9fO5UJCnTCV86WYpVNGIZ/jWXy+zbpdl3NlQ2N8x7bgKNHMoO52SH4SW/Vz I/PN2gFkTEmz5iVsj8upnoHx5HvcMZmWGwGyeQG1wtzpqn+vftIe1VpXIAP4jn4n9nm9x/vqTQw ZaujeHZ1jUFdzijO6DQndtMKvFv7qpqNfCAkco4XSCAOrrW6tPAdH4gJz70Kl6snz/YzR4v1v4J j2rLLvOSKLR3D6vUhZLTKGGfiW9jmk6Ui0skMmC8Wh5nTRE/EpkLJRXsqnE86Q+6hDp8qMPSNcl 1fNuR5roX/NmR5Vq6aQqjwECnV+C9I3Mnxom081w3k9Je8cBFNr59kVhjvlmw6/8hCLm+0UV74U mgXOLake2LYcpxQ== X-Developer-Key: i=caleb.connolly@linaro.org; a=openpgp; fpr=83B24DA7FE145076BC38BB250CD904EB673A7C47 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.8 at phobos.denx.de X-Virus-Status: Clean A lot of the features in here are only relevant when running multi-threaded with interrupts. Drop everything except what we need to run single-threaded with a single TCS (which is all the rpmh-rsc framework in U-Boot supports). Keep rpmh_write_async() for simplicity and make it wrap the regular rpmh_write(). Acked-by: Sumit Garg Signed-off-by: Caleb Connolly --- drivers/soc/qcom/rpmh.c | 371 ------------------------------------------------ include/soc/qcom/rpmh.h | 25 +--- 2 files changed, 3 insertions(+), 393 deletions(-) diff --git a/drivers/soc/qcom/rpmh.c b/drivers/soc/qcom/rpmh.c index 03ef4106c9a6..22605e0291a1 100644 --- a/drivers/soc/qcom/rpmh.c +++ b/drivers/soc/qcom/rpmh.c @@ -31,124 +31,15 @@ } #define ctrlr_to_drv(ctrlr) container_of(ctrlr, struct rsc_drv, client) -/** - * struct cache_req: the request object for caching - * - * @addr: the address of the resource - * @sleep_val: the sleep vote - * @wake_val: the wake vote - * @list: linked list obj - */ -struct cache_req { - u32 addr; - u32 sleep_val; - u32 wake_val; - struct list_head list; -}; - -/** - * struct batch_cache_req - An entry in our batch catch - * - * @list: linked list obj - * @count: number of messages - * @rpm_msgs: the messages - */ - -struct batch_cache_req { - struct list_head list; - int count; - struct rpmh_request rpm_msgs[]; -}; - static struct rpmh_ctrlr *get_rpmh_ctrlr(const struct device *dev) { struct rsc_drv *drv = dev_get_drvdata(dev->parent); return &drv->client; } -void rpmh_tx_done(const struct tcs_request *msg) -{ - struct rpmh_request *rpm_msg = container_of(msg, struct rpmh_request, - msg); - struct completion *compl = rpm_msg->completion; - bool free = rpm_msg->needs_free; - - if (!compl) - goto exit; - - /* Signal the blocking thread we are done */ - complete(compl); - -exit: - if (free) - kfree(rpm_msg); -} - -static struct cache_req *__find_req(struct rpmh_ctrlr *ctrlr, u32 addr) -{ - struct cache_req *p, *req = NULL; - - list_for_each_entry(p, &ctrlr->cache, list) { - if (p->addr == addr) { - req = p; - break; - } - } - - return req; -} - -static struct cache_req *cache_rpm_request(struct rpmh_ctrlr *ctrlr, - enum rpmh_state state, - struct tcs_cmd *cmd) -{ - struct cache_req *req; - unsigned long flags; - u32 old_sleep_val, old_wake_val; - - spin_lock_irqsave(&ctrlr->cache_lock, flags); - req = __find_req(ctrlr, cmd->addr); - if (req) - goto existing; - - req = kzalloc(sizeof(*req), GFP_ATOMIC); - if (!req) { - req = ERR_PTR(-ENOMEM); - goto unlock; - } - - req->addr = cmd->addr; - req->sleep_val = req->wake_val = UINT_MAX; - list_add_tail(&req->list, &ctrlr->cache); - -existing: - old_sleep_val = req->sleep_val; - old_wake_val = req->wake_val; - - switch (state) { - case RPMH_ACTIVE_ONLY_STATE: - case RPMH_WAKE_ONLY_STATE: - req->wake_val = cmd->data; - break; - case RPMH_SLEEP_STATE: - req->sleep_val = cmd->data; - break; - } - - ctrlr->dirty |= (req->sleep_val != old_sleep_val || - req->wake_val != old_wake_val) && - req->sleep_val != UINT_MAX && - req->wake_val != UINT_MAX; - -unlock: - spin_unlock_irqrestore(&ctrlr->cache_lock, flags); - - return req; -} - /** * __rpmh_write: Cache and send the RPMH request * * @dev: The device making the request @@ -199,40 +90,8 @@ static int __fill_rpmh_msg(struct rpmh_request *req, enum rpmh_state state, return 0; } -/** - * rpmh_write_async: Write a set of RPMH commands - * - * @dev: The device making the request - * @state: Active/sleep set - * @cmd: The payload data - * @n: The number of elements in payload - * - * Write a set of RPMH commands, the order of commands is maintained - * and will be sent as a single shot. - */ -int rpmh_write_async(const struct device *dev, enum rpmh_state state, - const struct tcs_cmd *cmd, u32 n) -{ - struct rpmh_request *rpm_msg; - int ret; - - rpm_msg = kzalloc(sizeof(*rpm_msg), GFP_ATOMIC); - if (!rpm_msg) - return -ENOMEM; - rpm_msg->needs_free = true; - - ret = __fill_rpmh_msg(rpm_msg, state, cmd, n); - if (ret) { - kfree(rpm_msg); - return ret; - } - - return __rpmh_write(dev, state, rpm_msg); -} -EXPORT_SYMBOL_GPL(rpmh_write_async); - /** * rpmh_write: Write a set of RPMH commands and block until response * * @dev: The device making the request @@ -261,234 +120,4 @@ int rpmh_write(const struct device *dev, enum rpmh_state state, WARN_ON(!ret); return (ret > 0) ? 0 : -ETIMEDOUT; } EXPORT_SYMBOL_GPL(rpmh_write); - -static void cache_batch(struct rpmh_ctrlr *ctrlr, struct batch_cache_req *req) -{ - unsigned long flags; - - spin_lock_irqsave(&ctrlr->cache_lock, flags); - list_add_tail(&req->list, &ctrlr->batch_cache); - ctrlr->dirty = true; - spin_unlock_irqrestore(&ctrlr->cache_lock, flags); -} - -static int flush_batch(struct rpmh_ctrlr *ctrlr) -{ - struct batch_cache_req *req; - const struct rpmh_request *rpm_msg; - int ret = 0; - int i; - - /* Send Sleep/Wake requests to the controller, expect no response */ - list_for_each_entry(req, &ctrlr->batch_cache, list) { - for (i = 0; i < req->count; i++) { - rpm_msg = req->rpm_msgs + i; - ret = rpmh_rsc_write_ctrl_data(ctrlr_to_drv(ctrlr), - &rpm_msg->msg); - if (ret) - break; - } - } - - return ret; -} - -/** - * rpmh_write_batch: Write multiple sets of RPMH commands and wait for the - * batch to finish. - * - * @dev: the device making the request - * @state: Active/sleep set - * @cmd: The payload data - * @n: The array of count of elements in each batch, 0 terminated. - * - * Write a request to the RSC controller without caching. If the request - * state is ACTIVE, then the requests are treated as completion request - * and sent to the controller immediately. The function waits until all the - * commands are complete. If the request was to SLEEP or WAKE_ONLY, then the - * request is sent as fire-n-forget and no ack is expected. - * - * May sleep. Do not call from atomic contexts for ACTIVE_ONLY requests. - */ -int rpmh_write_batch(const struct device *dev, enum rpmh_state state, - const struct tcs_cmd *cmd, u32 *n) -{ - struct batch_cache_req *req; - struct rpmh_request *rpm_msgs; - struct completion *compls; - struct rpmh_ctrlr *ctrlr = get_rpmh_ctrlr(dev); - unsigned long time_left; - int count = 0; - int ret, i; - void *ptr; - - if (!cmd || !n) - return -EINVAL; - - while (n[count] > 0) - count++; - if (!count) - return -EINVAL; - - ptr = kzalloc(sizeof(*req) + - count * (sizeof(req->rpm_msgs[0]) + sizeof(*compls)), - GFP_ATOMIC); - if (!ptr) - return -ENOMEM; - - req = ptr; - compls = ptr + sizeof(*req) + count * sizeof(*rpm_msgs); - - req->count = count; - rpm_msgs = req->rpm_msgs; - - for (i = 0; i < count; i++) { - __fill_rpmh_msg(rpm_msgs + i, state, cmd, n[i]); - cmd += n[i]; - } - - if (state != RPMH_ACTIVE_ONLY_STATE) { - cache_batch(ctrlr, req); - return 0; - } - - for (i = 0; i < count; i++) { - struct completion *compl = &compls[i]; - - init_completion(compl); - rpm_msgs[i].completion = compl; - ret = rpmh_rsc_send_data(ctrlr_to_drv(ctrlr), &rpm_msgs[i].msg); - if (ret) { - pr_err("Error(%d) sending RPMH message addr=%#x\n", - ret, rpm_msgs[i].msg.cmds[0].addr); - break; - } - } - - time_left = RPMH_TIMEOUT_MS; - while (i--) { - time_left = wait_for_completion_timeout(&compls[i], time_left); - if (!time_left) { - /* - * Better hope they never finish because they'll signal - * the completion that we're going to free once - * we've returned from this function. - */ - WARN_ON(1); - ret = -ETIMEDOUT; - goto exit; - } - } - -exit: - kfree(ptr); - - return ret; -} -EXPORT_SYMBOL_GPL(rpmh_write_batch); - -static int is_req_valid(struct cache_req *req) -{ - return (req->sleep_val != UINT_MAX && - req->wake_val != UINT_MAX && - req->sleep_val != req->wake_val); -} - -static int send_single(struct rpmh_ctrlr *ctrlr, enum rpmh_state state, - u32 addr, u32 data) -{ - DEFINE_RPMH_MSG_ONSTACK(NULL, state, NULL, rpm_msg); - - /* Wake sets are always complete and sleep sets are not */ - rpm_msg.msg.wait_for_compl = (state == RPMH_WAKE_ONLY_STATE); - rpm_msg.cmd[0].addr = addr; - rpm_msg.cmd[0].data = data; - rpm_msg.msg.num_cmds = 1; - - return rpmh_rsc_write_ctrl_data(ctrlr_to_drv(ctrlr), &rpm_msg.msg); -} - -/** - * rpmh_flush() - Flushes the buffered sleep and wake sets to TCSes - * - * @ctrlr: Controller making request to flush cached data - * - * Return: - * * 0 - Success - * * Error code - Otherwise - */ -int rpmh_flush(struct rpmh_ctrlr *ctrlr) -{ - struct cache_req *p; - int ret = 0; - - lockdep_assert_irqs_disabled(); - - /* - * Currently rpmh_flush() is only called when we think we're running - * on the last processor. If the lock is busy it means another - * processor is up and it's better to abort than spin. - */ - if (!spin_trylock(&ctrlr->cache_lock)) - return -EBUSY; - - if (!ctrlr->dirty) { - pr_debug("Skipping flush, TCS has latest data.\n"); - goto write_next_wakeup; - } - - /* Invalidate the TCSes first to avoid stale data */ - rpmh_rsc_invalidate(ctrlr_to_drv(ctrlr)); - - /* First flush the cached batch requests */ - ret = flush_batch(ctrlr); - if (ret) - goto exit; - - list_for_each_entry(p, &ctrlr->cache, list) { - if (!is_req_valid(p)) { - pr_debug("%s: skipping RPMH req: a:%#x s:%#x w:%#x", - __func__, p->addr, p->sleep_val, p->wake_val); - continue; - } - ret = send_single(ctrlr, RPMH_SLEEP_STATE, p->addr, - p->sleep_val); - if (ret) - goto exit; - ret = send_single(ctrlr, RPMH_WAKE_ONLY_STATE, p->addr, - p->wake_val); - if (ret) - goto exit; - } - - ctrlr->dirty = false; - -write_next_wakeup: - rpmh_rsc_write_next_wakeup(ctrlr_to_drv(ctrlr)); -exit: - spin_unlock(&ctrlr->cache_lock); - return ret; -} - -/** - * rpmh_invalidate: Invalidate sleep and wake sets in batch_cache - * - * @dev: The device making the request - * - * Invalidate the sleep and wake values in batch_cache. - */ -void rpmh_invalidate(const struct device *dev) -{ - struct rpmh_ctrlr *ctrlr = get_rpmh_ctrlr(dev); - struct batch_cache_req *req, *tmp; - unsigned long flags; - - spin_lock_irqsave(&ctrlr->cache_lock, flags); - list_for_each_entry_safe(req, tmp, &ctrlr->batch_cache, list) - kfree(req); - INIT_LIST_HEAD(&ctrlr->batch_cache); - ctrlr->dirty = true; - spin_unlock_irqrestore(&ctrlr->cache_lock, flags); -} -EXPORT_SYMBOL_GPL(rpmh_invalidate); diff --git a/include/soc/qcom/rpmh.h b/include/soc/qcom/rpmh.h index bdbee1a97d36..9a5c5d992e04 100644 --- a/include/soc/qcom/rpmh.h +++ b/include/soc/qcom/rpmh.h @@ -13,35 +13,16 @@ #if IS_ENABLED(CONFIG_QCOM_RPMH) int rpmh_write(const struct device *dev, enum rpmh_state state, const struct tcs_cmd *cmd, u32 n); -int rpmh_write_async(const struct device *dev, enum rpmh_state state, - const struct tcs_cmd *cmd, u32 n); - -int rpmh_write_batch(const struct device *dev, enum rpmh_state state, - const struct tcs_cmd *cmd, u32 *n); - -void rpmh_invalidate(const struct device *dev); - #else static inline int rpmh_write(const struct device *dev, enum rpmh_state state, const struct tcs_cmd *cmd, u32 n) { return -ENODEV; } -static inline int rpmh_write_async(const struct device *dev, - enum rpmh_state state, - const struct tcs_cmd *cmd, u32 n) -{ return -ENODEV; } - -static inline int rpmh_write_batch(const struct device *dev, - enum rpmh_state state, - const struct tcs_cmd *cmd, u32 *n) -{ return -ENODEV; } - -static inline void rpmh_invalidate(const struct device *dev) -{ -} - #endif /* CONFIG_QCOM_RPMH */ +/* u-boot: no multithreading */ +#define rpmh_write_async(dev, state, cmd, n) rpmh_write(dev, state, cmd, n) + #endif /* __SOC_QCOM_RPMH_H__ */ From patchwork Mon Jul 15 10:08:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 812614 Delivered-To: patch@linaro.org Received: by 2002:adf:fac3:0:b0:367:895a:4699 with SMTP id a3csp1724716wrs; Mon, 15 Jul 2024 03:10:44 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWK+NSHq5xRCYFkU9kLBWkD7bjatm+Zr0XiTN7v3wRvJJgn0hanVH+hvhBKqPpqx+j7xWt1TcIMO+TkAK09rgcs X-Google-Smtp-Source: AGHT+IH9WerZM+2nFWai5SJIaDr0vjnE8MArcKjnBTC43cSFbPTQ3HeJJjrcFJSkGDQfLPtUCRA4 X-Received: by 2002:a50:d518:0:b0:585:437c:d7fc with SMTP id 4fb4d7f45d1cf-594bc7c7e61mr11249281a12.32.1721038244060; Mon, 15 Jul 2024 03:10:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721038244; cv=none; d=google.com; s=arc-20160816; b=T9OFQ2Fue1p6pD78DomsyNhkl1nwU1YmiHYhPwy5cVGdJAKd9dWqaV/7cmSVtYSBMy LxnJFoV3TJRvPD0ukofvIXQqjCG61GRK/xB1gydWmyEtZOw2yJvUCzKbmgH7+FmXkhU9 zjyRDh3CONDeA3TpvvXeRb/+Zss6rzKLPCtOTUsIt9B9sfo/80iTQ14kT+E4JhHVqu3l 8+ElKjHC1xZCIZVIrGHx0HsprqxAlHogkyQkjJcn6xE8jRyS5Uo1czgsxsJsuQd8c0FR jG65CFl6kOxJvitP0Vu1copxEpNSOGiCv9Y7hZzngBYKezkGX5TzE5TOxzMbrwiJlAsS QRuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:cc:to:in-reply-to:references :message-id:content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=dJaGTgWa9/FxJkGCdJJNpQpycUtWvWdlTFBYrGhJ9co=; fh=zcTfjI3NycJyTuuOJ9uzXxS7wfOr4sYKS7eKveHEFzw=; b=OoefN3zcwru8RB5/EX99eExyRyaYtRYL1r+FL3VaQIigdWnPtmr8U/AwvIXjeGW1Kk SFJSu5V3Fgr7qGGdAj27wdF9cHa3GcdF6d6WeK64YprwmZMdMs+sYbpjbmtPoeyg57pk vS/bGQ4KcRRUDI6UzL62l+2Tf1Vs6OeTa6Hxef2LrmmZVJ/t+Ut/lCV16aryz+C3u7Vt 8cQj1Ry+rENAnmOEMfpe91IXj2Al+Jc3h657DW6D5IzE/QGzqaHkG0YLNoYeXKl2mRy2 a3IQA4/fFQza9kyjeA8GAWN+FOqRY/GKPCDPVEvTewZUhZ36LGNYke/azKZn71+xkYyp lLnw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PHLmL9I0; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-59b2762874dsi2387148a12.492.2024.07.15.03.10.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 03:10:44 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PHLmL9I0; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 762878887D; Mon, 15 Jul 2024 12:08:50 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org 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=linaro.org header.i=@linaro.org header.b="PHLmL9I0"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 985B78885E; Mon, 15 Jul 2024 12:08:48 +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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) (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 94802887EB for ; Mon, 15 Jul 2024 12:08:46 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=caleb.connolly@linaro.org Received: by mail-ej1-x635.google.com with SMTP id a640c23a62f3a-a77c7d3e8bcso514701666b.1 for ; Mon, 15 Jul 2024 03:08:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721038126; x=1721642926; darn=lists.denx.de; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=dJaGTgWa9/FxJkGCdJJNpQpycUtWvWdlTFBYrGhJ9co=; b=PHLmL9I0Wmxk4jLXLYsgV9nOyGoWiKklruo3nJ1ZFPttXRsv1XinEqMCN3A1alUp4A v3vPBnuaXi19zXZWEJSm5bVSTapQ/HGsz4S/PqypsVv5Ji8CeeZHJT4bgee4qZBoDV/6 MGC0GcmA1934yT/uB0quPBr1HXYY7JC963pj7D2+55ZEVGTV4rzFBp0vbZowybGIsqYf mVDUF8NZLyOrOq72jOmGShzUqfD1/2BpIVkbmXzTdsZzVmqM2RStjoSqhIvz+7mRuas+ 0hd8zt67nbTxwhd284FmMk4nfCn6Motj4w7Bi/vSVnPPAah3fhM69v2iAyGdh6ZQ7KQX wtAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721038126; x=1721642926; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dJaGTgWa9/FxJkGCdJJNpQpycUtWvWdlTFBYrGhJ9co=; b=TwjcTW1LilWCO/duIJF7ODERVwNXE15iZa45RFv1HPubNM9kuw8hiesE9WCGiakspN gLyU8Ims6PXkVMP5IBYR+QRGCHmdCceEAMbLlVre14w1c+UHGxu3wqEiSgyA5OUcdGdv 4bWP6OTevpX1H96MgnH8hYWUafuy2eBZzkCb2409PdCce6ZzVvaDSkp1RgH89jMMxoH7 SoQF+dN2LDD0C1SqGGf4K2DgmCB0quGXWdcwZTeW4TtjXI6hOFbvLDkzFGqyiXRn9Mj8 7hlJuAQ3WPmQ34tDyTEzDrC1dkZGDYFTu+z3I70uB5QCwVpCJaULEc+/8X4J0mvTfMEi FpiQ== X-Gm-Message-State: AOJu0YxRoIGHTkKUtcdrbx5s8OjhryhCI1Kd3TetYtSinVx7Z+a6FFPD jXRlhm0XxBzNMkiwGZ9hZPRnp5lL9hToazH+Af8kzyHCW6xua1rK+Ink43/gVkP4WvgvCFUPmYS mYmI= X-Received: by 2002:a17:906:31c1:b0:a77:cc6f:e791 with SMTP id a640c23a62f3a-a780b705299mr1059446266b.38.1721038126041; Mon, 15 Jul 2024 03:08:46 -0700 (PDT) Received: from [192.168.0.113] ([2a02:8109:aa0d:be00::7424]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a79bc5b7eb4sm198102266b.60.2024.07.15.03.08.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 03:08:45 -0700 (PDT) From: Caleb Connolly Date: Mon, 15 Jul 2024 12:08:13 +0200 Subject: [PATCH v6 14/24] soc: qcom: rpmh: U-Boot API changes MIME-Version: 1.0 Message-Id: <20240715-b4-qcom-rpmh-v6-14-0c948a25d018@linaro.org> References: <20240715-b4-qcom-rpmh-v6-0-0c948a25d018@linaro.org> In-Reply-To: <20240715-b4-qcom-rpmh-v6-0-0c948a25d018@linaro.org> To: Tom Rini , Caleb Connolly , Neil Armstrong , Sumit Garg , Jaehoon Chung , Simon Glass Cc: u-boot@lists.denx.de, u-boot-qcom@groups.io X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=4758; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=camnfp1HM4gJk6LZyxdzL5PXbyXYt46syEdY1LHofyA=; b=owEBbQKS/ZANAwAIAQWDMSsZX2S2AcsmYgBmlPUGF/TeruIzt/PDlt+bz9nxQ0QPXD8YGNV/Q fYctBLTjDGJAjMEAAEIAB0WIQS2UaFGPGq+0GkMVc0FgzErGV9ktgUCZpT1BgAKCRAFgzErGV9k tlJED/0X29eKQSO0K3+35bhR68VMD8sQFtchFgwUjrjZN/74J/4Mxcfg0ES7eO+gqGMLikDzoky Yrj2xgzYg7UbUNHg3t8/bGQm2wSiDm0Hj1h1leYv1A4BZAVLMNxLtaex9GcUqDgm+PCWduYaJ/6 tAmIp9QPQsWxaWmJjB/0bTfuTxzJ03odPI+SIs5tFCa35Rwk9I6zA45zyyEpUhyypPylGduhgXm ik7ghqgIAZYej9cUrRWxS+fGhq5s2LafbZg5GXt4LsNFxTkmOE6r9X2dijzLwaOTuqlER/DSoPY 8nmwn4WFWnU+MLvovu7nukjJB+RytFBMkWe4AI1zPhbXzu5rNTfzdWUGOLhJkQ11AE+EsgtdpGl PC4mSMmtLIIkNdLqa7z7KfUpLjuA5JqPV4bxCO8gsDMf0uHFkmnCpWyn+oXyZJ+y4HgeO4eUEC3 rvLFGGqr/sCMAMBfy6rLlPqJonHrcz5TR1qmfA+SiSvhdDLWK4jVtLZTvwh1t8hVeDN2l/G86Eg mGBO7ylXg1zddFD3KbBeECEDNZskwmVbKMZM8UDpJV9i4l+AxSPCaNygrsy8fEMY+9CnuS7MinI EQyU/5ovEriDurflJmUuMJECMw+haikasZ97jy7hNM7RJ3NGdlAq3D3UNsexLvPYkLM6tuZKBrS AACOK/GVPn5YDTQ== X-Developer-Key: i=caleb.connolly@linaro.org; a=openpgp; fpr=83B24DA7FE145076BC38BB250CD904EB673A7C47 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.8 at phobos.denx.de X-Virus-Status: Clean Fix build errors, add some debug logging. Acked-by: Sumit Garg Signed-off-by: Caleb Connolly --- drivers/soc/qcom/rpmh.c | 53 +++++++++++++++++++------------------------------ include/soc/qcom/rpmh.h | 4 ++-- 2 files changed, 22 insertions(+), 35 deletions(-) diff --git a/drivers/soc/qcom/rpmh.c b/drivers/soc/qcom/rpmh.c index 22605e0291a1..96f14a9afdf2 100644 --- a/drivers/soc/qcom/rpmh.c +++ b/drivers/soc/qcom/rpmh.c @@ -15,27 +15,30 @@ #include "rpmh-internal.h" #define RPMH_TIMEOUT_MS msecs_to_jiffies(10000) -#define DEFINE_RPMH_MSG_ONSTACK(device, s, q, name) \ +#define DEFINE_RPMH_MSG_ONSTACK(device, s, name) \ struct rpmh_request name = { \ .msg = { \ .state = s, \ .cmds = name.cmd, \ .num_cmds = 0, \ - .wait_for_compl = true, \ }, \ .cmd = { { 0 } }, \ - .completion = q, \ .dev = device, \ - .needs_free = false, \ + .needs_free = false, \ } #define ctrlr_to_drv(ctrlr) container_of(ctrlr, struct rsc_drv, client) -static struct rpmh_ctrlr *get_rpmh_ctrlr(const struct device *dev) +static struct rpmh_ctrlr *get_rpmh_ctrlr(const struct udevice *dev) { - struct rsc_drv *drv = dev_get_drvdata(dev->parent); + struct rsc_drv *drv = (struct rsc_drv *)dev_get_priv(dev->parent); + + if (!drv) { + log_err("BUG: no RPMh driver for %s (parent %s)\n", dev->name, dev->parent->name); + BUG(); + } return &drv->client; } @@ -49,36 +52,23 @@ static struct rpmh_ctrlr *get_rpmh_ctrlr(const struct device *dev) * Cache the RPMH request and send if the state is ACTIVE_ONLY. * SLEEP/WAKE_ONLY requests are not sent to the controller at * this time. Use rpmh_flush() to send them to the controller. */ -static int __rpmh_write(const struct device *dev, enum rpmh_state state, +static int __rpmh_write(const struct udevice *dev, enum rpmh_state state, struct rpmh_request *rpm_msg) { struct rpmh_ctrlr *ctrlr = get_rpmh_ctrlr(dev); - int ret = -EINVAL; - struct cache_req *req; - int i; - /* Cache the request in our store and link the payload */ - for (i = 0; i < rpm_msg->msg.num_cmds; i++) { - req = cache_rpm_request(ctrlr, state, &rpm_msg->msg.cmds[i]); - if (IS_ERR(req)) - return PTR_ERR(req); + if (state != RPMH_ACTIVE_ONLY_STATE) { + log_err("only ACTIVE_ONLY state supported\n"); + return -EINVAL; } - if (state == RPMH_ACTIVE_ONLY_STATE) { - ret = rpmh_rsc_send_data(ctrlr_to_drv(ctrlr), &rpm_msg->msg); - } else { - /* Clean up our call by spoofing tx_done */ - ret = 0; - rpmh_tx_done(&rpm_msg->msg); - } - - return ret; + return rpmh_rsc_send_data(ctrlr_to_drv(ctrlr), &rpm_msg->msg); } static int __fill_rpmh_msg(struct rpmh_request *req, enum rpmh_state state, - const struct tcs_cmd *cmd, u32 n) + const struct tcs_cmd *cmd, u32 n) { if (!cmd || !n || n > MAX_RPMH_PAYLOAD) return -EINVAL; @@ -87,8 +77,10 @@ static int __fill_rpmh_msg(struct rpmh_request *req, enum rpmh_state state, req->msg.state = state; req->msg.cmds = req->cmd; req->msg.num_cmds = n; + debug("rpmh_msg: %d, %d cmds [first %#x/%#x]\n", state, n, cmd->addr, cmd->data); + return 0; } /** @@ -100,24 +92,19 @@ static int __fill_rpmh_msg(struct rpmh_request *req, enum rpmh_state state, * @n: The number of elements in @cmd * * May sleep. Do not call from atomic contexts. */ -int rpmh_write(const struct device *dev, enum rpmh_state state, +int rpmh_write(const struct udevice *dev, enum rpmh_state state, const struct tcs_cmd *cmd, u32 n) { - DECLARE_COMPLETION_ONSTACK(compl); - DEFINE_RPMH_MSG_ONSTACK(dev, state, &compl, rpm_msg); + DEFINE_RPMH_MSG_ONSTACK(dev, state, rpm_msg); int ret; ret = __fill_rpmh_msg(&rpm_msg, state, cmd, n); if (ret) return ret; ret = __rpmh_write(dev, state, &rpm_msg); - if (ret) - return ret; - ret = wait_for_completion_timeout(&compl, RPMH_TIMEOUT_MS); - WARN_ON(!ret); - return (ret > 0) ? 0 : -ETIMEDOUT; + return ret; } EXPORT_SYMBOL_GPL(rpmh_write); diff --git a/include/soc/qcom/rpmh.h b/include/soc/qcom/rpmh.h index 9a5c5d992e04..3421fbf1ee3e 100644 --- a/include/soc/qcom/rpmh.h +++ b/include/soc/qcom/rpmh.h @@ -5,14 +5,14 @@ #ifndef __SOC_QCOM_RPMH_H__ #define __SOC_QCOM_RPMH_H__ +#include #include -#include #if IS_ENABLED(CONFIG_QCOM_RPMH) -int rpmh_write(const struct device *dev, enum rpmh_state state, +int rpmh_write(const struct udevice *dev, enum rpmh_state state, const struct tcs_cmd *cmd, u32 n); #else From patchwork Mon Jul 15 10:08:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 812615 Delivered-To: patch@linaro.org Received: by 2002:adf:fac3:0:b0:367:895a:4699 with SMTP id a3csp1724762wrs; Mon, 15 Jul 2024 03:10:55 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXTtUFFwOaSeHmk0uStkNssPmP90dSy5c3MmBcqobR1RT/bUu+N8w2ouvmmR0XemjmMx34Z2noNfsEJ+QmC6xQd X-Google-Smtp-Source: AGHT+IHlSW3J4SgU0ZUjz3WPnp9EKUxcr+uZZz37b3HNIp2Gd0Af4xgzKWkaWEubgQuPHhibLT1j X-Received: by 2002:a17:907:7e82:b0:a77:bf32:b91e with SMTP id a640c23a62f3a-a780b8848e7mr1376542366b.49.1721038254784; Mon, 15 Jul 2024 03:10:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721038254; cv=none; d=google.com; s=arc-20160816; b=fEDjLrOS5QWOwTtG9ZKvqXU31RuXgW+PQIXkNib2ytU5bf4GthmIXBOAo9u0lrLStq 7FHXaFE3E70VylirOeURXVzHtlyHgcpi+klqkJDik4k/be+QQP6Cov9ctRYjywPAAhMT QLqS9vHF6hip7beG+HhLmSoErITOnWqmGT8tpJGIgUVHOf9u7XnLjUsKGK7w6B9xianR e2/iPzGaok8RF0uZc1aseptE4D3c9RpftQfoh/1P2UBVSVfGeO81sIxQ7kSP4QUbRsj8 ms8ETyq06yjTcUWeZqkSrZF/tnGT5p3gN+ZtsFy1u2tmkfaRgdsE3JMuTduJexGpVL3q AsRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:cc:to:in-reply-to:references :message-id:content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=EI1m/5KlruCoT6RpfHcQgeJV034qnLNtuNds708jBqM=; fh=zcTfjI3NycJyTuuOJ9uzXxS7wfOr4sYKS7eKveHEFzw=; b=VJI2aa8vmMYyogxjBeT08Ml0lsLgVYi2y4EnZiCha52euVQKZM1W+SQBTHk5f9X17u TE6KiQDU0k4l18VutMH+PTrpkRuRd0LIBGjKYndqxx0+EVp+rAXKQOn+kMygSVexpixw eV1x1gy6NCYWdWVGCZu8K6GXACdi5HMOKlTdQIdC8UJPXaMbwbN1LAGIqIJGTHrrf/Cc OSZhB+wBwhSAweR6Qji9X96jXyjRwXjmcGn+f7KhKL16oPInaiF5Vn3RWanE1As+wa5T 2j/DsgjASD2tH16P1zumC+MFi6B1qEJfLuUZJOkZG0La4joOjKL9/mx73ExunwIKT3np 4gMA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LcXsUO0a; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id a640c23a62f3a-a79bc5aac74si238499966b.243.2024.07.15.03.10.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 03:10:54 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LcXsUO0a; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CBAC688860; Mon, 15 Jul 2024 12:08:52 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org 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=linaro.org header.i=@linaro.org header.b="LcXsUO0a"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C582388875; Mon, 15 Jul 2024 12:08:49 +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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) (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 9088888856 for ; Mon, 15 Jul 2024 12:08:47 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=caleb.connolly@linaro.org Received: by mail-ed1-x534.google.com with SMTP id 4fb4d7f45d1cf-59a47d5c22aso3923151a12.1 for ; Mon, 15 Jul 2024 03:08:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721038127; x=1721642927; darn=lists.denx.de; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=EI1m/5KlruCoT6RpfHcQgeJV034qnLNtuNds708jBqM=; b=LcXsUO0aLKZzd+kgBiPpHcxKQpPVqgZnWzpL9OMo0xNFTFRPLxel0oRR/pLCU62IGF CfJYgr0ARYFAtOKdlK2Mzz8EvNO0A43cjRG1dvGlfA8rKXTYXNYpx73IRy1IDwnFnyx9 jjrV3mktRFgfgioKcFnUeosB+gMtremgZAJCfB6Iq3Ys8EREIzwAA3V+QQkg9174ggmv NDlLaFxClcalfVKL+Gx36fPbpyK2skD/JaYCuMduI7xxLMnx+8ndTe7RcuxvwgdwkXkE SxbQztBVht3XrfMrYBJiHBmJCC2fkNOAtwJhubD84sCZYrA8GwR34GdEfMRRxMyO8hvs SCdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721038127; x=1721642927; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EI1m/5KlruCoT6RpfHcQgeJV034qnLNtuNds708jBqM=; b=QZKrKUAp5t+CkjB94oXNzgwhXI44vDDcyU6GuzoZcPxzpETGBGfs8KokPdz2pwfJM+ l9GXE9A/oTpIOhS5FtoTTymWH4d754buJKxcjHVUyAuzhPXC1Rl5xQeVhAfgRt3mnYEC Cq32PpDZSRl55kz2R3y1HNGB1vLJtwkeJFloHR6aBh/E1Y1TR95NzP39H23f77+judcW xCM93gH3x+o1tD5/93QZzPbBkN4utk58w6xi2VQR7pI2rytDsj5av8zaJswqhDPESaks WvakO4YmyoGTUCsT4OFGtSJ1GuNYUrI7CHDS6Qeh45mJ0LdbwxoggzBZhCIpoTXb23MQ K9vg== X-Gm-Message-State: AOJu0YwxnDzmVPa+aSy30thRsQV/Z5PA1KnHjKUm7lXoypRvxhikj/2L ueqPyaFtcg13YZaoZKgjQTCmrbnUUxapVJl23qd3frs3PGFDmjqbKmQfBfhzEAE= X-Received: by 2002:a17:906:37d6:b0:a77:db36:1ccc with SMTP id a640c23a62f3a-a780b6b2f58mr1139255666b.24.1721038127069; Mon, 15 Jul 2024 03:08:47 -0700 (PDT) Received: from [192.168.0.113] ([2a02:8109:aa0d:be00::7424]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a79bc5b7eb4sm198102266b.60.2024.07.15.03.08.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 03:08:46 -0700 (PDT) From: Caleb Connolly Date: Mon, 15 Jul 2024 12:08:14 +0200 Subject: [PATCH v6 15/24] soc: qcom: add build infrastructure MIME-Version: 1.0 Message-Id: <20240715-b4-qcom-rpmh-v6-15-0c948a25d018@linaro.org> References: <20240715-b4-qcom-rpmh-v6-0-0c948a25d018@linaro.org> In-Reply-To: <20240715-b4-qcom-rpmh-v6-0-0c948a25d018@linaro.org> To: Tom Rini , Caleb Connolly , Neil Armstrong , Sumit Garg , Jaehoon Chung , Simon Glass Cc: u-boot@lists.denx.de, u-boot-qcom@groups.io X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2682; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=XGgpCAr8XHdPFMKI5HuxXuToi062u+tLuE4azL5XNXs=; b=owEBbQKS/ZANAwAIAQWDMSsZX2S2AcsmYgBmlPUG26XiR04MWK1RiWSUEYen/dhXKFe+PgQ+3 iZnnoWwaMGJAjMEAAEIAB0WIQS2UaFGPGq+0GkMVc0FgzErGV9ktgUCZpT1BgAKCRAFgzErGV9k thK1EACHpV9p29oJTuQ/NjSWozR5aV2oSdl3ODZTcN1LNOOawBKMnrwGjT36d6DF4GLIjxUBcdM efTV3epqr7ExQk1ASnqSUHkxFJfe0utEivRqWfsdS4xNwSA9xHrPKx5sfweJL27GkiQ+ZuwvC66 cBSD96KfJMvjytqCrH8tfn+HeXfxora/VZV/2HSdLPqq3jKcSLFM3cbDuNmAi2lWpF8+sUyY5wi aHBHuBOV4PaTHcN8ByeGohmAzLRq1yghHRRsQSEn4o05SFlAGnCByptEDZCYW4vzf3iggyN7S1s EgSoEg6a3p3L2nL1E4ch07ZL/flHmchMFw19Ao0KF86IlYKWTtrCu+mgpNYzqndJZ7/zaJUkaRJ 0JoJNUkZigSIP0Jnx9/lJi8vKys9faV9uUsNk/OW/nsiicm6ogvceZSsGKUc+8OWgRcFVaXPAO9 /wse2RxXcRv4o4a4hJxJ9932lXj87LP9EcMEnn6ONk8dfaFRfSE0BToJ4T4vBDm46gwrpVpr/07 fi9MC6RH8enfX+7QhnsxXkpkhQ3kJTny/f6AhXk6Uxuwtn/ymaCOb6jOmBKwia4xFKNKYs3OJbh oH7lxjuXgspDg9CI9ZHECbhqWa0Qgstdl5UWNCn4EVEFsqPntjRnP9DmpfoM420ZKnYkg6H1Sq8 bPDkDfggPGO0SKA== X-Developer-Key: i=caleb.connolly@linaro.org; a=openpgp; fpr=83B24DA7FE145076BC38BB250CD904EB673A7C47 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.8 at phobos.denx.de X-Virus-Status: Clean Add Kconfig / Makefiles to build rpmh and cmd-db drivers. Signed-off-by: Caleb Connolly Reviewed-by: Neil Armstrong --- drivers/soc/Kconfig | 1 + drivers/soc/Makefile | 1 + drivers/soc/qcom/Kconfig | 27 +++++++++++++++++++++++++++ drivers/soc/qcom/Makefile | 4 ++++ 4 files changed, 33 insertions(+) diff --git a/drivers/soc/Kconfig b/drivers/soc/Kconfig index cee506fe4747..8ef408d9ba1b 100644 --- a/drivers/soc/Kconfig +++ b/drivers/soc/Kconfig @@ -47,8 +47,9 @@ config SOC_XILINX_VERSAL_NET Enable this option to select SoC device id driver for Xilinx Versal NET. This allows other drivers to verify the SoC familiy & revision using matching SoC attributes. +source "drivers/soc/qcom/Kconfig" source "drivers/soc/samsung/Kconfig" source "drivers/soc/ti/Kconfig" endmenu diff --git a/drivers/soc/Makefile b/drivers/soc/Makefile index 5ec89a053165..00e6a5ac8e2b 100644 --- a/drivers/soc/Makefile +++ b/drivers/soc/Makefile @@ -2,8 +2,9 @@ # # Makefile for the U-Boot SOC specific device drivers. obj-$(CONFIG_SOC_AMD_VERSAL2) += soc_amd_versal2.o +obj-$(CONFIG_SOC_QCOM) += qcom/ obj-$(CONFIG_SOC_SAMSUNG) += samsung/ obj-$(CONFIG_SOC_TI) += ti/ obj-$(CONFIG_SOC_DEVICE) += soc-uclass.o obj-$(CONFIG_SOC_DEVICE_TI_K3) += soc_ti_k3.o diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig new file mode 100644 index 000000000000..4aa7833930c7 --- /dev/null +++ b/drivers/soc/qcom/Kconfig @@ -0,0 +1,27 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# QCOM Soc drivers +# +menuconfig SOC_QCOM + bool "Qualcomm SOC drivers support" + help + Say Y here if you want to enable Qualcomm SOC drivers support. + +if SOC_QCOM + +config QCOM_COMMAND_DB + bool "Qualcomm Command DB" + help + Command DB queries shared memory by key string for shared system + resources. Platform drivers that require to set state of a shared + resource on a RPM-hardened platform must use this database to get + SoC specific identifier and information for the shared resources. + +config QCOM_RPMH + bool "Qualcomm RPMh support" + depends on QCOM_COMMAND_DB + help + Say y here to support the Qualcomm RPMh (resource peripheral manager) + if you need to control regulators on Qualcomm platforms, say y here. + +endif # SOC_QCOM diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile new file mode 100644 index 000000000000..78fae8bbfa16 --- /dev/null +++ b/drivers/soc/qcom/Makefile @@ -0,0 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0+ + +obj-$(CONFIG_QCOM_COMMAND_DB) += cmd-db.o +obj-$(CONFIG_QCOM_RPMH) += rpmh-rsc.o rpmh.o From patchwork Mon Jul 15 10:08:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 812619 Delivered-To: patch@linaro.org Received: by 2002:adf:fac3:0:b0:367:895a:4699 with SMTP id a3csp1725005wrs; Mon, 15 Jul 2024 03:11:37 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWDkrm4b8fqdqz35O0wFEYFtbNTzdcMizO3KqjAIRGj6GhHdqzKAMCSAUPO248n8gVPk7f+FZMOCXzwmvrEzKRR X-Google-Smtp-Source: AGHT+IH0A9zc4en5WZ4Fju3Lf6TfiWz52votoNNnU2m/b+Kk9D8EuBqcKdaRsRtyAZUMoSCow9KX X-Received: by 2002:a17:906:fa08:b0:a72:b811:4d43 with SMTP id a640c23a62f3a-a780b883462mr1081047566b.59.1721038297082; Mon, 15 Jul 2024 03:11:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721038297; cv=none; d=google.com; s=arc-20160816; b=XakuX0wlInE5hIXBZLUBszdsbTTtHpewQSz8Zi1ZCMXYzs1FM2VYZac4T2pv1Y9hNw UsOAdCROjTjbTCrmaogiYo3zkrE8Dqtlm/N097zfO1eMeEvqy5xbH5B1o5jyKCjOhbVu a1sQSitdB+aiyPFlE/Bd+bh8ZD/B44QJe6VBYH9zA2jiLwAhGC4Agzb0hfMLn9TvWq0u C42Bd3Ojyr25dYqAH9RiYzIICRdZ/1w4Sx9BDd4Vhb0M2LQMruDQDMgHSA773Ru0K6Hu Q1tVOHKzYnAaJe0BPSYyRPYWlwHAKihoFT4a5oW6hH6Rnc2A/Eq4yXmYnQparwBnkj3p KayA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:cc:to:in-reply-to:references :message-id:content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=NUDJ2m3YuzzIxQIx4kuWPdCOj/Tzyinqg9fuYKkjde8=; fh=zcTfjI3NycJyTuuOJ9uzXxS7wfOr4sYKS7eKveHEFzw=; b=DSAWFYpoqK1W2rqBADRXG6oiWr2vpD7UawAxPiAJ32fPgRH7iMVS5b8PDBqlLBZKkN 3PiiBwyx4E+TOv42nYVN5YXUJUb6GI+vMXOcwBzJKRIR280MPnPlVEMjcrvF94HOszPO lP6mF3D/Lp2CJN9EOkz4zZzA0UVVm6UWG2wCePmb+z8FUKucXv1XQ+zXajCLjIjqekd5 yTXNv9MqFw93zQbg7KEepX+txLhBMPZ3/Jf2c8i6eZRt7zWoBMUnD2WBK66f6i0/ySLC cqtM3l3V2i7ytN1YaZ7LYBLcAC+7Ei6x3tzbleppg+kNrvjfGrhFnsSiWJOakY/dEsYE 7FqQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=W5QJzQ89; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id a640c23a62f3a-a79bc7c2350si231383266b.466.2024.07.15.03.11.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 03:11:37 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=W5QJzQ89; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 63C918888F; Mon, 15 Jul 2024 12:08:56 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org 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=linaro.org header.i=@linaro.org header.b="W5QJzQ89"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4686D88867; Mon, 15 Jul 2024 12:08:54 +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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) (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 46A1F88855 for ; Mon, 15 Jul 2024 12:08:49 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=caleb.connolly@linaro.org Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-a77e2f51496so491938466b.0 for ; Mon, 15 Jul 2024 03:08:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721038129; x=1721642929; darn=lists.denx.de; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=NUDJ2m3YuzzIxQIx4kuWPdCOj/Tzyinqg9fuYKkjde8=; b=W5QJzQ89MThWPUna04ble4pgCbTepoZD5JtKVN7a8GshE4zVT1+TeRkURVXdnF4Cix xFWhEOPxK2X5QXlro2XByzAdWD2NwNRnrCXufI6h8pTkSkoaJDeI8gJtgDnKhnR1Heoq qfjQir76Mr8K3yjnmOxap066S0xrVVqj6p1ujy+nUW8CRZmrGd6jus2IiesyvOIfshgo ycrjj+vf2i3gqhEEErEalFQKRvcAcl6CwXMl/Y7VNvjN5h6SZ13LrmAIqNu6PeueGZAB dYczBrMWAGMIthHwFk8IrObpMbISywgbyMteMurCWr0NpfSB8orxoG3fMiO3d4GGYSLm fIqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721038129; x=1721642929; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NUDJ2m3YuzzIxQIx4kuWPdCOj/Tzyinqg9fuYKkjde8=; b=KD5sKO7S6eevuwmbhLcklxq3/NcGgKAD2KW8f/NrBkc493uo3Fnd4FtLWLql6QgG4G yINxR6eHbOVKCWT6cRfHAutq5l9+dc93ZEsIXXqKc8bGhnQPPaVlCVKJgo6QQ4QMu+gO CX6UoYm7eLD5qhHfFAsJ+xcfHLPNS9YQl1P995nqBUDd15nETfxG33grHp1+iRKZ53zD yePDspXJ5Cq2jv/g3QLA8F1mfOEzFHOfCn2zPf0/pFH7X1pnzMcSUbET7vnBp/6ovFn8 Kj+IjcDmySeHYuo37Fmn82XtEdiMa+v+7gMWBGXH98hBQe2tLOENxvdX+rHZDer40c6C +dzg== X-Gm-Message-State: AOJu0Yz5BtLRQ4hH+VGZFH0yW3lasnzbdMCCFhXvahgm5AYtQf1PxwoW d2xeZxWhnpFngm8DIMiPKs543XOAkldi+p2VOM7cFaGel9sDkbbTlsZ+t4laL0c= X-Received: by 2002:a17:906:6b01:b0:a77:dbf0:d29 with SMTP id a640c23a62f3a-a780b705373mr1128362066b.46.1721038128361; Mon, 15 Jul 2024 03:08:48 -0700 (PDT) Received: from [192.168.0.113] ([2a02:8109:aa0d:be00::7424]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a79bc5b7eb4sm198102266b.60.2024.07.15.03.08.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 03:08:47 -0700 (PDT) From: Caleb Connolly Date: Mon, 15 Jul 2024 12:08:15 +0200 Subject: [PATCH v6 16/24] power: regulator: import qcom-rpmh-regulator from Linux MIME-Version: 1.0 Message-Id: <20240715-b4-qcom-rpmh-v6-16-0c948a25d018@linaro.org> References: <20240715-b4-qcom-rpmh-v6-0-0c948a25d018@linaro.org> In-Reply-To: <20240715-b4-qcom-rpmh-v6-0-0c948a25d018@linaro.org> To: Tom Rini , Caleb Connolly , Neil Armstrong , Sumit Garg , Jaehoon Chung , Simon Glass Cc: u-boot@lists.denx.de, u-boot-qcom@groups.io X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=69095; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=h8jevjf6kjbCKfCc0P7+Ljnftzw4YW/zftvKSOtmtao=; b=owEBbQKS/ZANAwAIAQWDMSsZX2S2AcsmYgBmlPUHhbewuZBuzM4iGhcsLIqzHsGYsuOxcE5f6 /vwxB1oiJGJAjMEAAEIAB0WIQS2UaFGPGq+0GkMVc0FgzErGV9ktgUCZpT1BwAKCRAFgzErGV9k tt/FD/457CXg3iSIK6HjQR6lH1odSUVejv6w/bGNmYZ7F3LEWDR+LCFonZ5wAwAx7miSmiy2+GW SS9h92/dD6d0i2sdk7MVe0QOJXWcl4kxiuDnRTm60Pr8sJ4jpzcGq/0byWEiSbxx9lf0zpbHSQJ YsRTpiNEBIBtuxnhVpA53vV+1gPxruzf9eCKvoTJCtdFmg6qugcY1WeHO7A+b2i4IMCfK6UrL46 zktAlwryv1jVw2D8C/nHB0mmfufNuQAEid7KXGEbX7j6AErdlznn608DfhQXdnGCrCEK0JL6EBW OuNfX5sUaEQCJ59qYb62VANg1fs9lHqRtU+cFBLfDE+Eaq/Ut6yRcDMoTEIUuf47xOjFQ1Dzgpz XPZs6TThdRPav7JOy386r5u8vjVZ7X4a9dTZmvQXGyZXt1EtL0zF3Urdbrip275Pif5s0UW/OYa SudWkrhz/h9dHGz57tDnyKB1TvjsIbBFKskW76CHBwrCNyCCY5LAW9opp8ITfJJ2Z7iQ4j/KHgl MWriYLZwXll4i356BgZTdlxSVdW2W/XwqYiJtT7V97cf8kwnfP0teZMpbOukia8Ata8mJZZWGhF btfnJqmBXYPHbumajUsRyiGOa2BZeIF4mmJp+TqOMvmR2xvBA4NtilaMYkV7WP7O1WZM4cNEs9i FBgfXIfP607CzHw== X-Developer-Key: i=caleb.connolly@linaro.org; a=openpgp; fpr=83B24DA7FE145076BC38BB250CD904EB673A7C47 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.8 at phobos.denx.de X-Virus-Status: Clean Import the driver from Linux 6.10-rc6. Acked-by: Sumit Garg Signed-off-by: Caleb Connolly --- drivers/power/regulator/qcom-rpmh-regulator.c | 1709 +++++++++++++++++++++++++ 1 file changed, 1709 insertions(+) diff --git a/drivers/power/regulator/qcom-rpmh-regulator.c b/drivers/power/regulator/qcom-rpmh-regulator.c new file mode 100644 index 000000000000..80e304711345 --- /dev/null +++ b/drivers/power/regulator/qcom-rpmh-regulator.c @@ -0,0 +1,1709 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright (c) 2018-2021, The Linux Foundation. All rights reserved. +// Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. + +#define pr_fmt(fmt) "%s: " fmt, __func__ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +/** + * enum rpmh_regulator_type - supported RPMh accelerator types + * @VRM: RPMh VRM accelerator which supports voting on enable, voltage, + * and mode of LDO, SMPS, and BOB type PMIC regulators. + * @XOB: RPMh XOB accelerator which supports voting on the enable state + * of PMIC regulators. + */ +enum rpmh_regulator_type { + VRM, + XOB, +}; + +#define RPMH_REGULATOR_REG_VRM_VOLTAGE 0x0 +#define RPMH_REGULATOR_REG_ENABLE 0x4 +#define RPMH_REGULATOR_REG_VRM_MODE 0x8 + +#define PMIC4_LDO_MODE_RETENTION 4 +#define PMIC4_LDO_MODE_LPM 5 +#define PMIC4_LDO_MODE_HPM 7 + +#define PMIC4_SMPS_MODE_RETENTION 4 +#define PMIC4_SMPS_MODE_PFM 5 +#define PMIC4_SMPS_MODE_AUTO 6 +#define PMIC4_SMPS_MODE_PWM 7 + +#define PMIC4_BOB_MODE_PASS 0 +#define PMIC4_BOB_MODE_PFM 1 +#define PMIC4_BOB_MODE_AUTO 2 +#define PMIC4_BOB_MODE_PWM 3 + +#define PMIC5_LDO_MODE_RETENTION 3 +#define PMIC5_LDO_MODE_LPM 4 +#define PMIC5_LDO_MODE_HPM 7 + +#define PMIC5_SMPS_MODE_RETENTION 3 +#define PMIC5_SMPS_MODE_PFM 4 +#define PMIC5_SMPS_MODE_AUTO 6 +#define PMIC5_SMPS_MODE_PWM 7 + +#define PMIC5_BOB_MODE_PASS 2 +#define PMIC5_BOB_MODE_PFM 4 +#define PMIC5_BOB_MODE_AUTO 6 +#define PMIC5_BOB_MODE_PWM 7 + +/** + * struct rpmh_vreg_hw_data - RPMh regulator hardware configurations + * @regulator_type: RPMh accelerator type used to manage this + * regulator + * @ops: Pointer to regulator ops callback structure + * @voltage_ranges: The possible ranges of voltages supported by this + * PMIC regulator type + * @n_linear_ranges: Number of entries in voltage_ranges + * @n_voltages: The number of unique voltage set points defined + * by voltage_ranges + * @hpm_min_load_uA: Minimum load current in microamps that requires + * high power mode (HPM) operation. This is used + * for LDO hardware type regulators only. + * @pmic_mode_map: Array indexed by regulator framework mode + * containing PMIC hardware modes. Must be large + * enough to index all framework modes supported + * by this regulator hardware type. + * @of_map_mode: Maps an RPMH_REGULATOR_MODE_* mode value defined + * in device tree to a regulator framework mode + */ +struct rpmh_vreg_hw_data { + enum rpmh_regulator_type regulator_type; + const struct regulator_ops *ops; + const struct linear_range *voltage_ranges; + int n_linear_ranges; + int n_voltages; + int hpm_min_load_uA; + const int *pmic_mode_map; + unsigned int (*of_map_mode)(unsigned int mode); +}; + +/** + * struct rpmh_vreg - individual RPMh regulator data structure encapsulating a + * single regulator device + * @dev: Device pointer for the top-level PMIC RPMh + * regulator parent device. This is used as a + * handle in RPMh write requests. + * @addr: Base address of the regulator resource within + * an RPMh accelerator + * @rdesc: Regulator descriptor + * @hw_data: PMIC regulator configuration data for this RPMh + * regulator + * @always_wait_for_ack: Boolean flag indicating if a request must always + * wait for an ACK from RPMh before continuing even + * if it corresponds to a strictly lower power + * state (e.g. enabled --> disabled). + * @enabled: Flag indicating if the regulator is enabled or + * not + * @bypassed: Boolean indicating if the regulator is in + * bypass (pass-through) mode or not. This is + * only used by BOB rpmh-regulator resources. + * @voltage_selector: Selector used for get_voltage_sel() and + * set_voltage_sel() callbacks + * @mode: RPMh VRM regulator current framework mode + */ +struct rpmh_vreg { + struct device *dev; + u32 addr; + struct regulator_desc rdesc; + const struct rpmh_vreg_hw_data *hw_data; + bool always_wait_for_ack; + + int enabled; + bool bypassed; + int voltage_selector; + unsigned int mode; +}; + +/** + * struct rpmh_vreg_init_data - initialization data for an RPMh regulator + * @name: Name for the regulator which also corresponds + * to the device tree subnode name of the regulator + * @resource_name: RPMh regulator resource name format string. + * This must include exactly one field: '%s' which + * is filled at run-time with the PMIC ID provided + * by device tree property qcom,pmic-id. Example: + * "ldo%s1" for RPMh resource "ldoa1". + * @supply_name: Parent supply regulator name + * @hw_data: Configuration data for this PMIC regulator type + */ +struct rpmh_vreg_init_data { + const char *name; + const char *resource_name; + const char *supply_name; + const struct rpmh_vreg_hw_data *hw_data; +}; + +/** + * rpmh_regulator_send_request() - send the request to RPMh + * @vreg: Pointer to the RPMh regulator + * @cmd: Pointer to the RPMh command to send + * @wait_for_ack: Boolean indicating if execution must wait until the + * request has been acknowledged as complete + * + * Return: 0 on success, errno on failure + */ +static int rpmh_regulator_send_request(struct rpmh_vreg *vreg, + struct tcs_cmd *cmd, bool wait_for_ack) +{ + int ret; + + if (wait_for_ack || vreg->always_wait_for_ack) + ret = rpmh_write(vreg->dev, RPMH_ACTIVE_ONLY_STATE, cmd, 1); + else + ret = rpmh_write_async(vreg->dev, RPMH_ACTIVE_ONLY_STATE, cmd, + 1); + + return ret; +} + +static int _rpmh_regulator_vrm_set_voltage_sel(struct regulator_dev *rdev, + unsigned int selector, bool wait_for_ack) +{ + struct rpmh_vreg *vreg = rdev_get_drvdata(rdev); + struct tcs_cmd cmd = { + .addr = vreg->addr + RPMH_REGULATOR_REG_VRM_VOLTAGE, + }; + int ret; + + /* VRM voltage control register is set with voltage in millivolts. */ + cmd.data = DIV_ROUND_UP(regulator_list_voltage_linear_range(rdev, + selector), 1000); + + ret = rpmh_regulator_send_request(vreg, &cmd, wait_for_ack); + if (!ret) + vreg->voltage_selector = selector; + + return ret; +} + +static int rpmh_regulator_vrm_set_voltage_sel(struct regulator_dev *rdev, + unsigned int selector) +{ + struct rpmh_vreg *vreg = rdev_get_drvdata(rdev); + + if (vreg->enabled == -EINVAL) { + /* + * Cache the voltage and send it later when the regulator is + * enabled or disabled. + */ + vreg->voltage_selector = selector; + return 0; + } + + return _rpmh_regulator_vrm_set_voltage_sel(rdev, selector, + selector > vreg->voltage_selector); +} + +static int rpmh_regulator_vrm_get_voltage_sel(struct regulator_dev *rdev) +{ + struct rpmh_vreg *vreg = rdev_get_drvdata(rdev); + + return vreg->voltage_selector; +} + +static int rpmh_regulator_is_enabled(struct regulator_dev *rdev) +{ + struct rpmh_vreg *vreg = rdev_get_drvdata(rdev); + + return vreg->enabled; +} + +static int rpmh_regulator_set_enable_state(struct regulator_dev *rdev, + bool enable) +{ + struct rpmh_vreg *vreg = rdev_get_drvdata(rdev); + struct tcs_cmd cmd = { + .addr = vreg->addr + RPMH_REGULATOR_REG_ENABLE, + .data = enable, + }; + int ret; + + if (vreg->enabled == -EINVAL && + vreg->voltage_selector != -ENOTRECOVERABLE) { + ret = _rpmh_regulator_vrm_set_voltage_sel(rdev, + vreg->voltage_selector, true); + if (ret < 0) + return ret; + } + + ret = rpmh_regulator_send_request(vreg, &cmd, enable); + if (!ret) + vreg->enabled = enable; + + return ret; +} + +static int rpmh_regulator_enable(struct regulator_dev *rdev) +{ + return rpmh_regulator_set_enable_state(rdev, true); +} + +static int rpmh_regulator_disable(struct regulator_dev *rdev) +{ + return rpmh_regulator_set_enable_state(rdev, false); +} + +static int rpmh_regulator_vrm_set_mode_bypass(struct rpmh_vreg *vreg, + unsigned int mode, bool bypassed) +{ + struct tcs_cmd cmd = { + .addr = vreg->addr + RPMH_REGULATOR_REG_VRM_MODE, + }; + int pmic_mode; + + if (mode > REGULATOR_MODE_STANDBY) + return -EINVAL; + + pmic_mode = vreg->hw_data->pmic_mode_map[mode]; + if (pmic_mode < 0) + return pmic_mode; + + if (bypassed) + cmd.data = PMIC4_BOB_MODE_PASS; + else + cmd.data = pmic_mode; + + return rpmh_regulator_send_request(vreg, &cmd, true); +} + +static int rpmh_regulator_vrm_set_mode(struct regulator_dev *rdev, + unsigned int mode) +{ + struct rpmh_vreg *vreg = rdev_get_drvdata(rdev); + int ret; + + if (mode == vreg->mode) + return 0; + + ret = rpmh_regulator_vrm_set_mode_bypass(vreg, mode, vreg->bypassed); + if (!ret) + vreg->mode = mode; + + return ret; +} + +static unsigned int rpmh_regulator_vrm_get_mode(struct regulator_dev *rdev) +{ + struct rpmh_vreg *vreg = rdev_get_drvdata(rdev); + + return vreg->mode; +} + +/** + * rpmh_regulator_vrm_get_optimum_mode() - get the mode based on the load + * @rdev: Regulator device pointer for the rpmh-regulator + * @input_uV: Input voltage + * @output_uV: Output voltage + * @load_uA: Aggregated load current in microamps + * + * This function is used in the regulator_ops for VRM type RPMh regulator + * devices. + * + * Return: 0 on success, errno on failure + */ +static unsigned int rpmh_regulator_vrm_get_optimum_mode( + struct regulator_dev *rdev, int input_uV, int output_uV, int load_uA) +{ + struct rpmh_vreg *vreg = rdev_get_drvdata(rdev); + + if (load_uA >= vreg->hw_data->hpm_min_load_uA) + return REGULATOR_MODE_NORMAL; + else + return REGULATOR_MODE_IDLE; +} + +static int rpmh_regulator_vrm_set_bypass(struct regulator_dev *rdev, + bool enable) +{ + struct rpmh_vreg *vreg = rdev_get_drvdata(rdev); + int ret; + + if (vreg->bypassed == enable) + return 0; + + ret = rpmh_regulator_vrm_set_mode_bypass(vreg, vreg->mode, enable); + if (!ret) + vreg->bypassed = enable; + + return ret; +} + +static int rpmh_regulator_vrm_get_bypass(struct regulator_dev *rdev, + bool *enable) +{ + struct rpmh_vreg *vreg = rdev_get_drvdata(rdev); + + *enable = vreg->bypassed; + + return 0; +} + +static const struct regulator_ops rpmh_regulator_vrm_ops = { + .enable = rpmh_regulator_enable, + .disable = rpmh_regulator_disable, + .is_enabled = rpmh_regulator_is_enabled, + .set_voltage_sel = rpmh_regulator_vrm_set_voltage_sel, + .get_voltage_sel = rpmh_regulator_vrm_get_voltage_sel, + .list_voltage = regulator_list_voltage_linear_range, + .set_mode = rpmh_regulator_vrm_set_mode, + .get_mode = rpmh_regulator_vrm_get_mode, +}; + +static const struct regulator_ops rpmh_regulator_vrm_drms_ops = { + .enable = rpmh_regulator_enable, + .disable = rpmh_regulator_disable, + .is_enabled = rpmh_regulator_is_enabled, + .set_voltage_sel = rpmh_regulator_vrm_set_voltage_sel, + .get_voltage_sel = rpmh_regulator_vrm_get_voltage_sel, + .list_voltage = regulator_list_voltage_linear_range, + .set_mode = rpmh_regulator_vrm_set_mode, + .get_mode = rpmh_regulator_vrm_get_mode, + .get_optimum_mode = rpmh_regulator_vrm_get_optimum_mode, +}; + +static const struct regulator_ops rpmh_regulator_vrm_bypass_ops = { + .enable = rpmh_regulator_enable, + .disable = rpmh_regulator_disable, + .is_enabled = rpmh_regulator_is_enabled, + .set_voltage_sel = rpmh_regulator_vrm_set_voltage_sel, + .get_voltage_sel = rpmh_regulator_vrm_get_voltage_sel, + .list_voltage = regulator_list_voltage_linear_range, + .set_mode = rpmh_regulator_vrm_set_mode, + .get_mode = rpmh_regulator_vrm_get_mode, + .set_bypass = rpmh_regulator_vrm_set_bypass, + .get_bypass = rpmh_regulator_vrm_get_bypass, +}; + +static const struct regulator_ops rpmh_regulator_xob_ops = { + .enable = rpmh_regulator_enable, + .disable = rpmh_regulator_disable, + .is_enabled = rpmh_regulator_is_enabled, +}; + +/** + * rpmh_regulator_init_vreg() - initialize all attributes of an rpmh-regulator + * @vreg: Pointer to the individual rpmh-regulator resource + * @dev: Pointer to the top level rpmh-regulator PMIC device + * @node: Pointer to the individual rpmh-regulator resource + * device node + * @pmic_id: String used to identify the top level rpmh-regulator + * PMIC device on the board + * @pmic_rpmh_data: Pointer to a null-terminated array of rpmh-regulator + * resources defined for the top level PMIC device + * + * Return: 0 on success, errno on failure + */ +static int rpmh_regulator_init_vreg(struct rpmh_vreg *vreg, struct device *dev, + struct device_node *node, const char *pmic_id, + const struct rpmh_vreg_init_data *pmic_rpmh_data) +{ + struct regulator_config reg_config = {}; + char rpmh_resource_name[20] = ""; + const struct rpmh_vreg_init_data *rpmh_data; + struct regulator_init_data *init_data; + struct regulator_dev *rdev; + int ret; + + vreg->dev = dev; + + for (rpmh_data = pmic_rpmh_data; rpmh_data->name; rpmh_data++) + if (of_node_name_eq(node, rpmh_data->name)) + break; + + if (!rpmh_data->name) { + dev_err(dev, "Unknown regulator %pOFn\n", node); + return -EINVAL; + } + + scnprintf(rpmh_resource_name, sizeof(rpmh_resource_name), + rpmh_data->resource_name, pmic_id); + + vreg->addr = cmd_db_read_addr(rpmh_resource_name); + if (!vreg->addr) { + dev_err(dev, "%pOFn: could not find RPMh address for resource %s\n", + node, rpmh_resource_name); + return -ENODEV; + } + + vreg->rdesc.name = rpmh_data->name; + vreg->rdesc.supply_name = rpmh_data->supply_name; + vreg->hw_data = rpmh_data->hw_data; + + vreg->enabled = -EINVAL; + vreg->voltage_selector = -ENOTRECOVERABLE; + vreg->mode = REGULATOR_MODE_INVALID; + + if (rpmh_data->hw_data->n_voltages) { + vreg->rdesc.linear_ranges = rpmh_data->hw_data->voltage_ranges; + vreg->rdesc.n_linear_ranges = rpmh_data->hw_data->n_linear_ranges; + vreg->rdesc.n_voltages = rpmh_data->hw_data->n_voltages; + } + + vreg->always_wait_for_ack = of_property_read_bool(node, + "qcom,always-wait-for-ack"); + + vreg->rdesc.owner = THIS_MODULE; + vreg->rdesc.type = REGULATOR_VOLTAGE; + vreg->rdesc.ops = vreg->hw_data->ops; + vreg->rdesc.of_map_mode = vreg->hw_data->of_map_mode; + + init_data = of_get_regulator_init_data(dev, node, &vreg->rdesc); + if (!init_data) + return -ENOMEM; + + if (rpmh_data->hw_data->regulator_type == XOB && + init_data->constraints.min_uV && + init_data->constraints.min_uV == init_data->constraints.max_uV) { + vreg->rdesc.fixed_uV = init_data->constraints.min_uV; + vreg->rdesc.n_voltages = 1; + } + + reg_config.dev = dev; + reg_config.init_data = init_data; + reg_config.of_node = node; + reg_config.driver_data = vreg; + + rdev = devm_regulator_register(dev, &vreg->rdesc, ®_config); + if (IS_ERR(rdev)) { + ret = PTR_ERR(rdev); + dev_err(dev, "%pOFn: devm_regulator_register() failed, ret=%d\n", + node, ret); + return ret; + } + + dev_dbg(dev, "%pOFn regulator registered for RPMh resource %s @ 0x%05X\n", + node, rpmh_resource_name, vreg->addr); + + return 0; +} + +static const int pmic_mode_map_pmic4_ldo[REGULATOR_MODE_STANDBY + 1] = { + [REGULATOR_MODE_INVALID] = -EINVAL, + [REGULATOR_MODE_STANDBY] = PMIC4_LDO_MODE_RETENTION, + [REGULATOR_MODE_IDLE] = PMIC4_LDO_MODE_LPM, + [REGULATOR_MODE_NORMAL] = PMIC4_LDO_MODE_HPM, + [REGULATOR_MODE_FAST] = -EINVAL, +}; + +static const int pmic_mode_map_pmic5_ldo[REGULATOR_MODE_STANDBY + 1] = { + [REGULATOR_MODE_INVALID] = -EINVAL, + [REGULATOR_MODE_STANDBY] = PMIC5_LDO_MODE_RETENTION, + [REGULATOR_MODE_IDLE] = PMIC5_LDO_MODE_LPM, + [REGULATOR_MODE_NORMAL] = PMIC5_LDO_MODE_HPM, + [REGULATOR_MODE_FAST] = -EINVAL, +}; + +static const int pmic_mode_map_pmic5_ldo_hpm[REGULATOR_MODE_STANDBY + 1] = { + [REGULATOR_MODE_INVALID] = -EINVAL, + [REGULATOR_MODE_STANDBY] = -EINVAL, + [REGULATOR_MODE_IDLE] = -EINVAL, + [REGULATOR_MODE_NORMAL] = PMIC5_LDO_MODE_HPM, + [REGULATOR_MODE_FAST] = -EINVAL, +}; + +static unsigned int rpmh_regulator_pmic4_ldo_of_map_mode(unsigned int rpmh_mode) +{ + unsigned int mode; + + switch (rpmh_mode) { + case RPMH_REGULATOR_MODE_HPM: + mode = REGULATOR_MODE_NORMAL; + break; + case RPMH_REGULATOR_MODE_LPM: + mode = REGULATOR_MODE_IDLE; + break; + case RPMH_REGULATOR_MODE_RET: + mode = REGULATOR_MODE_STANDBY; + break; + default: + mode = REGULATOR_MODE_INVALID; + break; + } + + return mode; +} + +static const int pmic_mode_map_pmic4_smps[REGULATOR_MODE_STANDBY + 1] = { + [REGULATOR_MODE_INVALID] = -EINVAL, + [REGULATOR_MODE_STANDBY] = PMIC4_SMPS_MODE_RETENTION, + [REGULATOR_MODE_IDLE] = PMIC4_SMPS_MODE_PFM, + [REGULATOR_MODE_NORMAL] = PMIC4_SMPS_MODE_AUTO, + [REGULATOR_MODE_FAST] = PMIC4_SMPS_MODE_PWM, +}; + +static const int pmic_mode_map_pmic5_smps[REGULATOR_MODE_STANDBY + 1] = { + [REGULATOR_MODE_INVALID] = -EINVAL, + [REGULATOR_MODE_STANDBY] = PMIC5_SMPS_MODE_RETENTION, + [REGULATOR_MODE_IDLE] = PMIC5_SMPS_MODE_PFM, + [REGULATOR_MODE_NORMAL] = PMIC5_SMPS_MODE_AUTO, + [REGULATOR_MODE_FAST] = PMIC5_SMPS_MODE_PWM, +}; + +static unsigned int +rpmh_regulator_pmic4_smps_of_map_mode(unsigned int rpmh_mode) +{ + unsigned int mode; + + switch (rpmh_mode) { + case RPMH_REGULATOR_MODE_HPM: + mode = REGULATOR_MODE_FAST; + break; + case RPMH_REGULATOR_MODE_AUTO: + mode = REGULATOR_MODE_NORMAL; + break; + case RPMH_REGULATOR_MODE_LPM: + mode = REGULATOR_MODE_IDLE; + break; + case RPMH_REGULATOR_MODE_RET: + mode = REGULATOR_MODE_STANDBY; + break; + default: + mode = REGULATOR_MODE_INVALID; + break; + } + + return mode; +} + +static const int pmic_mode_map_pmic4_bob[REGULATOR_MODE_STANDBY + 1] = { + [REGULATOR_MODE_INVALID] = -EINVAL, + [REGULATOR_MODE_STANDBY] = -EINVAL, + [REGULATOR_MODE_IDLE] = PMIC4_BOB_MODE_PFM, + [REGULATOR_MODE_NORMAL] = PMIC4_BOB_MODE_AUTO, + [REGULATOR_MODE_FAST] = PMIC4_BOB_MODE_PWM, +}; + +static const int pmic_mode_map_pmic5_bob[REGULATOR_MODE_STANDBY + 1] = { + [REGULATOR_MODE_INVALID] = -EINVAL, + [REGULATOR_MODE_STANDBY] = -EINVAL, + [REGULATOR_MODE_IDLE] = PMIC5_BOB_MODE_PFM, + [REGULATOR_MODE_NORMAL] = PMIC5_BOB_MODE_AUTO, + [REGULATOR_MODE_FAST] = PMIC5_BOB_MODE_PWM, +}; + +static unsigned int rpmh_regulator_pmic4_bob_of_map_mode(unsigned int rpmh_mode) +{ + unsigned int mode; + + switch (rpmh_mode) { + case RPMH_REGULATOR_MODE_HPM: + mode = REGULATOR_MODE_FAST; + break; + case RPMH_REGULATOR_MODE_AUTO: + mode = REGULATOR_MODE_NORMAL; + break; + case RPMH_REGULATOR_MODE_LPM: + mode = REGULATOR_MODE_IDLE; + break; + default: + mode = REGULATOR_MODE_INVALID; + break; + } + + return mode; +} + +static const struct rpmh_vreg_hw_data pmic4_pldo = { + .regulator_type = VRM, + .ops = &rpmh_regulator_vrm_drms_ops, + .voltage_ranges = (struct linear_range[]) { + REGULATOR_LINEAR_RANGE(1664000, 0, 255, 8000), + }, + .n_linear_ranges = 1, + .n_voltages = 256, + .hpm_min_load_uA = 10000, + .pmic_mode_map = pmic_mode_map_pmic4_ldo, + .of_map_mode = rpmh_regulator_pmic4_ldo_of_map_mode, +}; + +static const struct rpmh_vreg_hw_data pmic4_pldo_lv = { + .regulator_type = VRM, + .ops = &rpmh_regulator_vrm_drms_ops, + .voltage_ranges = (struct linear_range[]) { + REGULATOR_LINEAR_RANGE(1256000, 0, 127, 8000), + }, + .n_linear_ranges = 1, + .n_voltages = 128, + .hpm_min_load_uA = 10000, + .pmic_mode_map = pmic_mode_map_pmic4_ldo, + .of_map_mode = rpmh_regulator_pmic4_ldo_of_map_mode, +}; + +static const struct rpmh_vreg_hw_data pmic4_nldo = { + .regulator_type = VRM, + .ops = &rpmh_regulator_vrm_drms_ops, + .voltage_ranges = (struct linear_range[]) { + REGULATOR_LINEAR_RANGE(312000, 0, 127, 8000), + }, + .n_linear_ranges = 1, + .n_voltages = 128, + .hpm_min_load_uA = 30000, + .pmic_mode_map = pmic_mode_map_pmic4_ldo, + .of_map_mode = rpmh_regulator_pmic4_ldo_of_map_mode, +}; + +static const struct rpmh_vreg_hw_data pmic4_hfsmps3 = { + .regulator_type = VRM, + .ops = &rpmh_regulator_vrm_ops, + .voltage_ranges = (struct linear_range[]) { + REGULATOR_LINEAR_RANGE(320000, 0, 215, 8000), + }, + .n_linear_ranges = 1, + .n_voltages = 216, + .pmic_mode_map = pmic_mode_map_pmic4_smps, + .of_map_mode = rpmh_regulator_pmic4_smps_of_map_mode, +}; + +static const struct rpmh_vreg_hw_data pmic4_ftsmps426 = { + .regulator_type = VRM, + .ops = &rpmh_regulator_vrm_ops, + .voltage_ranges = (struct linear_range[]) { + REGULATOR_LINEAR_RANGE(320000, 0, 258, 4000), + }, + .n_linear_ranges = 1, + .n_voltages = 259, + .pmic_mode_map = pmic_mode_map_pmic4_smps, + .of_map_mode = rpmh_regulator_pmic4_smps_of_map_mode, +}; + +static const struct rpmh_vreg_hw_data pmic4_bob = { + .regulator_type = VRM, + .ops = &rpmh_regulator_vrm_bypass_ops, + .voltage_ranges = (struct linear_range[]) { + REGULATOR_LINEAR_RANGE(1824000, 0, 83, 32000), + }, + .n_linear_ranges = 1, + .n_voltages = 84, + .pmic_mode_map = pmic_mode_map_pmic4_bob, + .of_map_mode = rpmh_regulator_pmic4_bob_of_map_mode, +}; + +static const struct rpmh_vreg_hw_data pmic4_lvs = { + .regulator_type = XOB, + .ops = &rpmh_regulator_xob_ops, + /* LVS hardware does not support voltage or mode configuration. */ +}; + +static const struct rpmh_vreg_hw_data pmic5_pldo = { + .regulator_type = VRM, + .ops = &rpmh_regulator_vrm_drms_ops, + .voltage_ranges = (struct linear_range[]) { + REGULATOR_LINEAR_RANGE(1504000, 0, 255, 8000), + }, + .n_linear_ranges = 1, + .n_voltages = 256, + .hpm_min_load_uA = 10000, + .pmic_mode_map = pmic_mode_map_pmic5_ldo, + .of_map_mode = rpmh_regulator_pmic4_ldo_of_map_mode, +}; + +static const struct rpmh_vreg_hw_data pmic5_pldo_lv = { + .regulator_type = VRM, + .ops = &rpmh_regulator_vrm_drms_ops, + .voltage_ranges = (struct linear_range[]) { + REGULATOR_LINEAR_RANGE(1504000, 0, 62, 8000), + }, + .n_linear_ranges = 1, + .n_voltages = 63, + .hpm_min_load_uA = 10000, + .pmic_mode_map = pmic_mode_map_pmic5_ldo, + .of_map_mode = rpmh_regulator_pmic4_ldo_of_map_mode, +}; + +static const struct rpmh_vreg_hw_data pmic5_pldo515_mv = { + .regulator_type = VRM, + .ops = &rpmh_regulator_vrm_drms_ops, + .voltage_ranges = (struct linear_range[]) { + REGULATOR_LINEAR_RANGE(1800000, 0, 187, 8000), + }, + .n_linear_ranges = 1, + .n_voltages = 188, + .hpm_min_load_uA = 10000, + .pmic_mode_map = pmic_mode_map_pmic5_ldo, + .of_map_mode = rpmh_regulator_pmic4_ldo_of_map_mode, +}; + +static const struct rpmh_vreg_hw_data pmic5_pldo502 = { + .regulator_type = VRM, + .ops = &rpmh_regulator_vrm_ops, + .voltage_ranges = (struct linear_range[]) { + REGULATOR_LINEAR_RANGE(1504000, 0, 255, 8000), + }, + .n_linear_ranges = 1, + .n_voltages = 256, + .pmic_mode_map = pmic_mode_map_pmic5_ldo_hpm, + .of_map_mode = rpmh_regulator_pmic4_ldo_of_map_mode, +}; + +static const struct rpmh_vreg_hw_data pmic5_pldo502ln = { + .regulator_type = VRM, + .ops = &rpmh_regulator_vrm_ops, + .voltage_ranges = (struct linear_range[]) { + REGULATOR_LINEAR_RANGE(1800000, 0, 2, 200000), + REGULATOR_LINEAR_RANGE(2608000, 3, 28, 16000), + REGULATOR_LINEAR_RANGE(3104000, 29, 30, 96000), + REGULATOR_LINEAR_RANGE(3312000, 31, 31, 0), + }, + .n_linear_ranges = 4, + .n_voltages = 32, + .pmic_mode_map = pmic_mode_map_pmic5_ldo_hpm, + .of_map_mode = rpmh_regulator_pmic4_ldo_of_map_mode, +}; + +static const struct rpmh_vreg_hw_data pmic5_nldo = { + .regulator_type = VRM, + .ops = &rpmh_regulator_vrm_drms_ops, + .voltage_ranges = (struct linear_range[]) { + REGULATOR_LINEAR_RANGE(320000, 0, 123, 8000), + }, + .n_linear_ranges = 1, + .n_voltages = 124, + .hpm_min_load_uA = 30000, + .pmic_mode_map = pmic_mode_map_pmic5_ldo, + .of_map_mode = rpmh_regulator_pmic4_ldo_of_map_mode, +}; + +static const struct rpmh_vreg_hw_data pmic5_nldo515 = { + .regulator_type = VRM, + .ops = &rpmh_regulator_vrm_drms_ops, + .voltage_ranges = (struct linear_range[]) { + REGULATOR_LINEAR_RANGE(320000, 0, 210, 8000), + }, + .n_linear_ranges = 1, + .n_voltages = 211, + .hpm_min_load_uA = 30000, + .pmic_mode_map = pmic_mode_map_pmic5_ldo, + .of_map_mode = rpmh_regulator_pmic4_ldo_of_map_mode, +}; + +static const struct rpmh_vreg_hw_data pmic5_nldo502 = { + .regulator_type = VRM, + .ops = &rpmh_regulator_vrm_drms_ops, + .voltage_ranges = (struct linear_range[]) { + REGULATOR_LINEAR_RANGE(528000, 0, 127, 8000), + }, + .n_linear_ranges = 1, + .n_voltages = 128, + .hpm_min_load_uA = 30000, + .pmic_mode_map = pmic_mode_map_pmic5_ldo, + .of_map_mode = rpmh_regulator_pmic4_ldo_of_map_mode, +}; + +static const struct rpmh_vreg_hw_data pmic5_hfsmps510 = { + .regulator_type = VRM, + .ops = &rpmh_regulator_vrm_ops, + .voltage_ranges = (struct linear_range[]) { + REGULATOR_LINEAR_RANGE(320000, 0, 215, 8000), + }, + .n_linear_ranges = 1, + .n_voltages = 216, + .pmic_mode_map = pmic_mode_map_pmic5_smps, + .of_map_mode = rpmh_regulator_pmic4_smps_of_map_mode, +}; + +static const struct rpmh_vreg_hw_data pmic5_ftsmps510 = { + .regulator_type = VRM, + .ops = &rpmh_regulator_vrm_ops, + .voltage_ranges = (struct linear_range[]) { + REGULATOR_LINEAR_RANGE(300000, 0, 263, 4000), + }, + .n_linear_ranges = 1, + .n_voltages = 264, + .pmic_mode_map = pmic_mode_map_pmic5_smps, + .of_map_mode = rpmh_regulator_pmic4_smps_of_map_mode, +}; + +static const struct rpmh_vreg_hw_data pmic5_ftsmps520 = { + .regulator_type = VRM, + .ops = &rpmh_regulator_vrm_ops, + .voltage_ranges = (struct linear_range[]) { + REGULATOR_LINEAR_RANGE(300000, 0, 263, 4000), + }, + .n_linear_ranges = 1, + .n_voltages = 264, + .pmic_mode_map = pmic_mode_map_pmic5_smps, + .of_map_mode = rpmh_regulator_pmic4_smps_of_map_mode, +}; + +static const struct rpmh_vreg_hw_data pmic5_ftsmps525_lv = { + .regulator_type = VRM, + .ops = &rpmh_regulator_vrm_ops, + .voltage_ranges = (struct linear_range[]) { + REGULATOR_LINEAR_RANGE(300000, 0, 267, 4000), + }, + .n_linear_ranges = 1, + .n_voltages = 268, + .pmic_mode_map = pmic_mode_map_pmic5_smps, + .of_map_mode = rpmh_regulator_pmic4_smps_of_map_mode, +}; + +static const struct rpmh_vreg_hw_data pmic5_ftsmps525_mv = { + .regulator_type = VRM, + .ops = &rpmh_regulator_vrm_ops, + .voltage_ranges = (struct linear_range[]) { + REGULATOR_LINEAR_RANGE(600000, 0, 267, 8000), + }, + .n_linear_ranges = 1, + .n_voltages = 268, + .pmic_mode_map = pmic_mode_map_pmic5_smps, + .of_map_mode = rpmh_regulator_pmic4_smps_of_map_mode, +}; + +static const struct rpmh_vreg_hw_data pmic5_ftsmps527 = { + .regulator_type = VRM, + .ops = &rpmh_regulator_vrm_ops, + .voltage_ranges = (struct linear_range[]) { + REGULATOR_LINEAR_RANGE(320000, 0, 215, 8000), + }, + .n_linear_ranges = 1, + .n_voltages = 215, + .pmic_mode_map = pmic_mode_map_pmic5_smps, + .of_map_mode = rpmh_regulator_pmic4_smps_of_map_mode, +}; + +static const struct rpmh_vreg_hw_data pmic5_hfsmps515 = { + .regulator_type = VRM, + .ops = &rpmh_regulator_vrm_ops, + .voltage_ranges = (struct linear_range[]) { + REGULATOR_LINEAR_RANGE(320000, 0, 235, 16000), + }, + .n_linear_ranges = 1, + .n_voltages = 236, + .pmic_mode_map = pmic_mode_map_pmic5_smps, + .of_map_mode = rpmh_regulator_pmic4_smps_of_map_mode, +}; + +static const struct rpmh_vreg_hw_data pmic5_hfsmps515_1 = { + .regulator_type = VRM, + .ops = &rpmh_regulator_vrm_ops, + .voltage_ranges = (struct linear_range[]) { + REGULATOR_LINEAR_RANGE(900000, 0, 4, 16000), + }, + .n_linear_ranges = 1, + .n_voltages = 5, + .pmic_mode_map = pmic_mode_map_pmic5_smps, + .of_map_mode = rpmh_regulator_pmic4_smps_of_map_mode, +}; + +static const struct rpmh_vreg_hw_data pmic5_bob = { + .regulator_type = VRM, + .ops = &rpmh_regulator_vrm_bypass_ops, + .voltage_ranges = (struct linear_range[]) { + REGULATOR_LINEAR_RANGE(3000000, 0, 31, 32000), + }, + .n_linear_ranges = 1, + .n_voltages = 32, + .pmic_mode_map = pmic_mode_map_pmic5_bob, + .of_map_mode = rpmh_regulator_pmic4_bob_of_map_mode, +}; + +#define RPMH_VREG(_name, _resource_name, _hw_data, _supply_name) \ +{ \ + .name = _name, \ + .resource_name = _resource_name, \ + .hw_data = _hw_data, \ + .supply_name = _supply_name, \ +} + +static const struct rpmh_vreg_init_data pm8998_vreg_data[] = { + RPMH_VREG("smps1", "smp%s1", &pmic4_ftsmps426, "vdd-s1"), + RPMH_VREG("smps2", "smp%s2", &pmic4_ftsmps426, "vdd-s2"), + RPMH_VREG("smps3", "smp%s3", &pmic4_hfsmps3, "vdd-s3"), + RPMH_VREG("smps4", "smp%s4", &pmic4_hfsmps3, "vdd-s4"), + RPMH_VREG("smps5", "smp%s5", &pmic4_hfsmps3, "vdd-s5"), + RPMH_VREG("smps6", "smp%s6", &pmic4_ftsmps426, "vdd-s6"), + RPMH_VREG("smps7", "smp%s7", &pmic4_ftsmps426, "vdd-s7"), + RPMH_VREG("smps8", "smp%s8", &pmic4_ftsmps426, "vdd-s8"), + RPMH_VREG("smps9", "smp%s9", &pmic4_ftsmps426, "vdd-s9"), + RPMH_VREG("smps10", "smp%s10", &pmic4_ftsmps426, "vdd-s10"), + RPMH_VREG("smps11", "smp%s11", &pmic4_ftsmps426, "vdd-s11"), + RPMH_VREG("smps12", "smp%s12", &pmic4_ftsmps426, "vdd-s12"), + RPMH_VREG("smps13", "smp%s13", &pmic4_ftsmps426, "vdd-s13"), + RPMH_VREG("ldo1", "ldo%s1", &pmic4_nldo, "vdd-l1-l27"), + RPMH_VREG("ldo2", "ldo%s2", &pmic4_nldo, "vdd-l2-l8-l17"), + RPMH_VREG("ldo3", "ldo%s3", &pmic4_nldo, "vdd-l3-l11"), + RPMH_VREG("ldo4", "ldo%s4", &pmic4_nldo, "vdd-l4-l5"), + RPMH_VREG("ldo5", "ldo%s5", &pmic4_nldo, "vdd-l4-l5"), + RPMH_VREG("ldo6", "ldo%s6", &pmic4_pldo, "vdd-l6"), + RPMH_VREG("ldo7", "ldo%s7", &pmic4_pldo_lv, "vdd-l7-l12-l14-l15"), + RPMH_VREG("ldo8", "ldo%s8", &pmic4_nldo, "vdd-l2-l8-l17"), + RPMH_VREG("ldo9", "ldo%s9", &pmic4_pldo, "vdd-l9"), + RPMH_VREG("ldo10", "ldo%s10", &pmic4_pldo, "vdd-l10-l23-l25"), + RPMH_VREG("ldo11", "ldo%s11", &pmic4_nldo, "vdd-l3-l11"), + RPMH_VREG("ldo12", "ldo%s12", &pmic4_pldo_lv, "vdd-l7-l12-l14-l15"), + RPMH_VREG("ldo13", "ldo%s13", &pmic4_pldo, "vdd-l13-l19-l21"), + RPMH_VREG("ldo14", "ldo%s14", &pmic4_pldo_lv, "vdd-l7-l12-l14-l15"), + RPMH_VREG("ldo15", "ldo%s15", &pmic4_pldo_lv, "vdd-l7-l12-l14-l15"), + RPMH_VREG("ldo16", "ldo%s16", &pmic4_pldo, "vdd-l16-l28"), + RPMH_VREG("ldo17", "ldo%s17", &pmic4_nldo, "vdd-l2-l8-l17"), + RPMH_VREG("ldo18", "ldo%s18", &pmic4_pldo, "vdd-l18-l22"), + RPMH_VREG("ldo19", "ldo%s19", &pmic4_pldo, "vdd-l13-l19-l21"), + RPMH_VREG("ldo20", "ldo%s20", &pmic4_pldo, "vdd-l20-l24"), + RPMH_VREG("ldo21", "ldo%s21", &pmic4_pldo, "vdd-l13-l19-l21"), + RPMH_VREG("ldo22", "ldo%s22", &pmic4_pldo, "vdd-l18-l22"), + RPMH_VREG("ldo23", "ldo%s23", &pmic4_pldo, "vdd-l10-l23-l25"), + RPMH_VREG("ldo24", "ldo%s24", &pmic4_pldo, "vdd-l20-l24"), + RPMH_VREG("ldo25", "ldo%s25", &pmic4_pldo, "vdd-l10-l23-l25"), + RPMH_VREG("ldo26", "ldo%s26", &pmic4_nldo, "vdd-l26"), + RPMH_VREG("ldo27", "ldo%s27", &pmic4_nldo, "vdd-l1-l27"), + RPMH_VREG("ldo28", "ldo%s28", &pmic4_pldo, "vdd-l16-l28"), + RPMH_VREG("lvs1", "vs%s1", &pmic4_lvs, "vin-lvs-1-2"), + RPMH_VREG("lvs2", "vs%s2", &pmic4_lvs, "vin-lvs-1-2"), + {} +}; + +static const struct rpmh_vreg_init_data pmg1110_vreg_data[] = { + RPMH_VREG("smps1", "smp%s1", &pmic5_ftsmps510, "vdd-s1"), + {} +}; + +static const struct rpmh_vreg_init_data pmi8998_vreg_data[] = { + RPMH_VREG("bob", "bob%s1", &pmic4_bob, "vdd-bob"), + {} +}; + +static const struct rpmh_vreg_init_data pm8005_vreg_data[] = { + RPMH_VREG("smps1", "smp%s1", &pmic4_ftsmps426, "vdd-s1"), + RPMH_VREG("smps2", "smp%s2", &pmic4_ftsmps426, "vdd-s2"), + RPMH_VREG("smps3", "smp%s3", &pmic4_ftsmps426, "vdd-s3"), + RPMH_VREG("smps4", "smp%s4", &pmic4_ftsmps426, "vdd-s4"), + {} +}; + +static const struct rpmh_vreg_init_data pm8150_vreg_data[] = { + RPMH_VREG("smps1", "smp%s1", &pmic5_ftsmps510, "vdd-s1"), + RPMH_VREG("smps2", "smp%s2", &pmic5_ftsmps510, "vdd-s2"), + RPMH_VREG("smps3", "smp%s3", &pmic5_ftsmps510, "vdd-s3"), + RPMH_VREG("smps4", "smp%s4", &pmic5_hfsmps510, "vdd-s4"), + RPMH_VREG("smps5", "smp%s5", &pmic5_hfsmps510, "vdd-s5"), + RPMH_VREG("smps6", "smp%s6", &pmic5_ftsmps510, "vdd-s6"), + RPMH_VREG("smps7", "smp%s7", &pmic5_ftsmps510, "vdd-s7"), + RPMH_VREG("smps8", "smp%s8", &pmic5_ftsmps510, "vdd-s8"), + RPMH_VREG("smps9", "smp%s9", &pmic5_ftsmps510, "vdd-s9"), + RPMH_VREG("smps10", "smp%s10", &pmic5_ftsmps510, "vdd-s10"), + RPMH_VREG("ldo1", "ldo%s1", &pmic5_nldo, "vdd-l1-l8-l11"), + RPMH_VREG("ldo2", "ldo%s2", &pmic5_pldo, "vdd-l2-l10"), + RPMH_VREG("ldo3", "ldo%s3", &pmic5_nldo, "vdd-l3-l4-l5-l18"), + RPMH_VREG("ldo4", "ldo%s4", &pmic5_nldo, "vdd-l3-l4-l5-l18"), + RPMH_VREG("ldo5", "ldo%s5", &pmic5_nldo, "vdd-l3-l4-l5-l18"), + RPMH_VREG("ldo6", "ldo%s6", &pmic5_nldo, "vdd-l6-l9"), + RPMH_VREG("ldo7", "ldo%s7", &pmic5_pldo, "vdd-l7-l12-l14-l15"), + RPMH_VREG("ldo8", "ldo%s8", &pmic5_nldo, "vdd-l1-l8-l11"), + RPMH_VREG("ldo9", "ldo%s9", &pmic5_nldo, "vdd-l6-l9"), + RPMH_VREG("ldo10", "ldo%s10", &pmic5_pldo, "vdd-l2-l10"), + RPMH_VREG("ldo11", "ldo%s11", &pmic5_nldo, "vdd-l1-l8-l11"), + RPMH_VREG("ldo12", "ldo%s12", &pmic5_pldo_lv, "vdd-l7-l12-l14-l15"), + RPMH_VREG("ldo13", "ldo%s13", &pmic5_pldo, "vdd-l13-l16-l17"), + RPMH_VREG("ldo14", "ldo%s14", &pmic5_pldo_lv, "vdd-l7-l12-l14-l15"), + RPMH_VREG("ldo15", "ldo%s15", &pmic5_pldo_lv, "vdd-l7-l12-l14-l15"), + RPMH_VREG("ldo16", "ldo%s16", &pmic5_pldo, "vdd-l13-l16-l17"), + RPMH_VREG("ldo17", "ldo%s17", &pmic5_pldo, "vdd-l13-l16-l17"), + RPMH_VREG("ldo18", "ldo%s18", &pmic5_nldo, "vdd-l3-l4-l5-l18"), + {} +}; + +static const struct rpmh_vreg_init_data pm8150l_vreg_data[] = { + RPMH_VREG("smps1", "smp%s1", &pmic5_ftsmps510, "vdd-s1"), + RPMH_VREG("smps2", "smp%s2", &pmic5_ftsmps510, "vdd-s2"), + RPMH_VREG("smps3", "smp%s3", &pmic5_ftsmps510, "vdd-s3"), + RPMH_VREG("smps4", "smp%s4", &pmic5_ftsmps510, "vdd-s4"), + RPMH_VREG("smps5", "smp%s5", &pmic5_ftsmps510, "vdd-s5"), + RPMH_VREG("smps6", "smp%s6", &pmic5_ftsmps510, "vdd-s6"), + RPMH_VREG("smps7", "smp%s7", &pmic5_ftsmps510, "vdd-s7"), + RPMH_VREG("smps8", "smp%s8", &pmic5_hfsmps510, "vdd-s8"), + RPMH_VREG("ldo1", "ldo%s1", &pmic5_pldo_lv, "vdd-l1-l8"), + RPMH_VREG("ldo2", "ldo%s2", &pmic5_nldo, "vdd-l2-l3"), + RPMH_VREG("ldo3", "ldo%s3", &pmic5_nldo, "vdd-l2-l3"), + RPMH_VREG("ldo4", "ldo%s4", &pmic5_pldo, "vdd-l4-l5-l6"), + RPMH_VREG("ldo5", "ldo%s5", &pmic5_pldo, "vdd-l4-l5-l6"), + RPMH_VREG("ldo6", "ldo%s6", &pmic5_pldo, "vdd-l4-l5-l6"), + RPMH_VREG("ldo7", "ldo%s7", &pmic5_pldo, "vdd-l7-l11"), + RPMH_VREG("ldo8", "ldo%s8", &pmic5_pldo_lv, "vdd-l1-l8"), + RPMH_VREG("ldo9", "ldo%s9", &pmic5_pldo, "vdd-l9-l10"), + RPMH_VREG("ldo10", "ldo%s10", &pmic5_pldo, "vdd-l9-l10"), + RPMH_VREG("ldo11", "ldo%s11", &pmic5_pldo, "vdd-l7-l11"), + RPMH_VREG("bob", "bob%s1", &pmic5_bob, "vdd-bob"), + {} +}; + +static const struct rpmh_vreg_init_data pmm8155au_vreg_data[] = { + RPMH_VREG("smps1", "smp%s1", &pmic5_ftsmps510, "vdd-s1"), + RPMH_VREG("smps2", "smp%s2", &pmic5_ftsmps510, "vdd-s2"), + RPMH_VREG("smps3", "smp%s3", &pmic5_ftsmps510, "vdd-s3"), + RPMH_VREG("smps4", "smp%s4", &pmic5_hfsmps510, "vdd-s4"), + RPMH_VREG("smps5", "smp%s5", &pmic5_hfsmps510, "vdd-s5"), + RPMH_VREG("smps6", "smp%s6", &pmic5_ftsmps510, "vdd-s6"), + RPMH_VREG("smps7", "smp%s7", &pmic5_ftsmps510, "vdd-s7"), + RPMH_VREG("smps8", "smp%s8", &pmic5_ftsmps510, "vdd-s8"), + RPMH_VREG("smps9", "smp%s9", &pmic5_ftsmps510, "vdd-s9"), + RPMH_VREG("smps10", "smp%s10", &pmic5_ftsmps510, "vdd-s10"), + RPMH_VREG("ldo1", "ldo%s1", &pmic5_nldo, "vdd-l1-l8-l11"), + RPMH_VREG("ldo2", "ldo%s2", &pmic5_pldo, "vdd-l2-l10"), + RPMH_VREG("ldo3", "ldo%s3", &pmic5_nldo, "vdd-l3-l4-l5-l18"), + RPMH_VREG("ldo4", "ldo%s4", &pmic5_nldo, "vdd-l3-l4-l5-l18"), + RPMH_VREG("ldo5", "ldo%s5", &pmic5_nldo, "vdd-l3-l4-l5-l18"), + RPMH_VREG("ldo6", "ldo%s6", &pmic5_nldo, "vdd-l6-l9"), + RPMH_VREG("ldo7", "ldo%s7", &pmic5_pldo_lv, "vdd-l7-l12-l14-l15"), + RPMH_VREG("ldo8", "ldo%s8", &pmic5_nldo, "vdd-l1-l8-l11"), + RPMH_VREG("ldo9", "ldo%s9", &pmic5_nldo, "vdd-l6-l9"), + RPMH_VREG("ldo10", "ldo%s10", &pmic5_pldo, "vdd-l2-l10"), + RPMH_VREG("ldo11", "ldo%s11", &pmic5_nldo, "vdd-l1-l8-l11"), + RPMH_VREG("ldo12", "ldo%s12", &pmic5_pldo_lv, "vdd-l7-l12-l14-l15"), + RPMH_VREG("ldo13", "ldo%s13", &pmic5_pldo, "vdd-l13-l16-l17"), + RPMH_VREG("ldo14", "ldo%s14", &pmic5_pldo_lv, "vdd-l7-l12-l14-l15"), + RPMH_VREG("ldo15", "ldo%s15", &pmic5_pldo_lv, "vdd-l7-l12-l14-l15"), + RPMH_VREG("ldo16", "ldo%s16", &pmic5_pldo, "vdd-l13-l16-l17"), + RPMH_VREG("ldo17", "ldo%s17", &pmic5_pldo, "vdd-l13-l16-l17"), + RPMH_VREG("ldo18", "ldo%s18", &pmic5_nldo, "vdd-l3-l4-l5-l18"), + {} +}; + +static const struct rpmh_vreg_init_data pmm8654au_vreg_data[] = { + RPMH_VREG("smps1", "smp%s1", &pmic5_ftsmps527, "vdd-s1"), + RPMH_VREG("smps2", "smp%s2", &pmic5_ftsmps527, "vdd-s2"), + RPMH_VREG("smps3", "smp%s3", &pmic5_ftsmps527, "vdd-s3"), + RPMH_VREG("smps4", "smp%s4", &pmic5_ftsmps527, "vdd-s4"), + RPMH_VREG("smps5", "smp%s5", &pmic5_ftsmps527, "vdd-s5"), + RPMH_VREG("smps6", "smp%s6", &pmic5_ftsmps527, "vdd-s6"), + RPMH_VREG("smps7", "smp%s7", &pmic5_ftsmps527, "vdd-s7"), + RPMH_VREG("smps8", "smp%s8", &pmic5_ftsmps527, "vdd-s8"), + RPMH_VREG("smps9", "smp%s9", &pmic5_ftsmps527, "vdd-s9"), + RPMH_VREG("ldo1", "ldo%s1", &pmic5_nldo515, "vdd-s9"), + RPMH_VREG("ldo2", "ldo%s2", &pmic5_nldo515, "vdd-l2-l3"), + RPMH_VREG("ldo3", "ldo%s3", &pmic5_nldo515, "vdd-l2-l3"), + RPMH_VREG("ldo4", "ldo%s4", &pmic5_nldo515, "vdd-s9"), + RPMH_VREG("ldo5", "ldo%s5", &pmic5_nldo515, "vdd-s9"), + RPMH_VREG("ldo6", "ldo%s6", &pmic5_nldo515, "vdd-l6-l7"), + RPMH_VREG("ldo7", "ldo%s7", &pmic5_nldo515, "vdd-l6-l7"), + RPMH_VREG("ldo8", "ldo%s8", &pmic5_pldo515_mv, "vdd-l8-l9"), + RPMH_VREG("ldo9", "ldo%s9", &pmic5_pldo, "vdd-l8-l9"), + {} +}; + +static const struct rpmh_vreg_init_data pm8350_vreg_data[] = { + RPMH_VREG("smps1", "smp%s1", &pmic5_ftsmps510, "vdd-s1"), + RPMH_VREG("smps2", "smp%s2", &pmic5_ftsmps510, "vdd-s2"), + RPMH_VREG("smps3", "smp%s3", &pmic5_ftsmps510, "vdd-s3"), + RPMH_VREG("smps4", "smp%s4", &pmic5_ftsmps510, "vdd-s4"), + RPMH_VREG("smps5", "smp%s5", &pmic5_ftsmps510, "vdd-s5"), + RPMH_VREG("smps6", "smp%s6", &pmic5_ftsmps510, "vdd-s6"), + RPMH_VREG("smps7", "smp%s7", &pmic5_ftsmps510, "vdd-s7"), + RPMH_VREG("smps8", "smp%s8", &pmic5_ftsmps510, "vdd-s8"), + RPMH_VREG("smps9", "smp%s9", &pmic5_ftsmps510, "vdd-s9"), + RPMH_VREG("smps10", "smp%s10", &pmic5_hfsmps510, "vdd-s10"), + RPMH_VREG("smps11", "smp%s11", &pmic5_hfsmps510, "vdd-s11"), + RPMH_VREG("smps12", "smp%s12", &pmic5_hfsmps510, "vdd-s12"), + RPMH_VREG("ldo1", "ldo%s1", &pmic5_nldo, "vdd-l1-l4"), + RPMH_VREG("ldo2", "ldo%s2", &pmic5_pldo, "vdd-l2-l7"), + RPMH_VREG("ldo3", "ldo%s3", &pmic5_nldo, "vdd-l3-l5"), + RPMH_VREG("ldo4", "ldo%s4", &pmic5_nldo, "vdd-l1-l4"), + RPMH_VREG("ldo5", "ldo%s5", &pmic5_nldo, "vdd-l3-l5"), + RPMH_VREG("ldo6", "ldo%s6", &pmic5_nldo, "vdd-l6-l9-l10"), + RPMH_VREG("ldo7", "ldo%s7", &pmic5_pldo, "vdd-l2-l7"), + RPMH_VREG("ldo8", "ldo%s8", &pmic5_nldo, "vdd-l8"), + RPMH_VREG("ldo9", "ldo%s9", &pmic5_nldo, "vdd-l6-l9-l10"), + RPMH_VREG("ldo10", "ldo%s10", &pmic5_nldo, "vdd-l6-l9-l10"), + {} +}; + +static const struct rpmh_vreg_init_data pm8350c_vreg_data[] = { + RPMH_VREG("smps1", "smp%s1", &pmic5_hfsmps515, "vdd-s1"), + RPMH_VREG("smps2", "smp%s2", &pmic5_ftsmps510, "vdd-s2"), + RPMH_VREG("smps3", "smp%s3", &pmic5_ftsmps510, "vdd-s3"), + RPMH_VREG("smps4", "smp%s4", &pmic5_ftsmps510, "vdd-s4"), + RPMH_VREG("smps5", "smp%s5", &pmic5_ftsmps510, "vdd-s5"), + RPMH_VREG("smps6", "smp%s6", &pmic5_ftsmps510, "vdd-s6"), + RPMH_VREG("smps7", "smp%s7", &pmic5_ftsmps510, "vdd-s7"), + RPMH_VREG("smps8", "smp%s8", &pmic5_ftsmps510, "vdd-s8"), + RPMH_VREG("smps9", "smp%s9", &pmic5_ftsmps510, "vdd-s9"), + RPMH_VREG("smps10", "smp%s10", &pmic5_ftsmps510, "vdd-s10"), + RPMH_VREG("ldo1", "ldo%s1", &pmic5_pldo_lv, "vdd-l1-l12"), + RPMH_VREG("ldo2", "ldo%s2", &pmic5_pldo_lv, "vdd-l2-l8"), + RPMH_VREG("ldo3", "ldo%s3", &pmic5_pldo, "vdd-l3-l4-l5-l7-l13"), + RPMH_VREG("ldo4", "ldo%s4", &pmic5_pldo, "vdd-l3-l4-l5-l7-l13"), + RPMH_VREG("ldo5", "ldo%s5", &pmic5_pldo, "vdd-l3-l4-l5-l7-l13"), + RPMH_VREG("ldo6", "ldo%s6", &pmic5_pldo, "vdd-l6-l9-l11"), + RPMH_VREG("ldo7", "ldo%s7", &pmic5_pldo, "vdd-l3-l4-l5-l7-l13"), + RPMH_VREG("ldo8", "ldo%s8", &pmic5_pldo_lv, "vdd-l2-l8"), + RPMH_VREG("ldo9", "ldo%s9", &pmic5_pldo, "vdd-l6-l9-l11"), + RPMH_VREG("ldo10", "ldo%s10", &pmic5_nldo, "vdd-l10"), + RPMH_VREG("ldo11", "ldo%s11", &pmic5_pldo, "vdd-l6-l9-l11"), + RPMH_VREG("ldo12", "ldo%s12", &pmic5_pldo_lv, "vdd-l1-l12"), + RPMH_VREG("ldo13", "ldo%s13", &pmic5_pldo, "vdd-l3-l4-l5-l7-l13"), + RPMH_VREG("bob", "bob%s1", &pmic5_bob, "vdd-bob"), + {} +}; + +static const struct rpmh_vreg_init_data pm8450_vreg_data[] = { + RPMH_VREG("smps1", "smp%s1", &pmic5_ftsmps520, "vdd-s1"), + RPMH_VREG("smps2", "smp%s2", &pmic5_ftsmps520, "vdd-s2"), + RPMH_VREG("smps3", "smp%s3", &pmic5_ftsmps520, "vdd-s3"), + RPMH_VREG("smps4", "smp%s4", &pmic5_ftsmps520, "vdd-s4"), + RPMH_VREG("smps5", "smp%s5", &pmic5_ftsmps520, "vdd-s5"), + RPMH_VREG("smps6", "smp%s6", &pmic5_ftsmps520, "vdd-s6"), + RPMH_VREG("ldo1", "ldo%s1", &pmic5_nldo, "vdd-l1"), + RPMH_VREG("ldo2", "ldo%s2", &pmic5_nldo, "vdd-l2"), + RPMH_VREG("ldo3", "ldo%s3", &pmic5_nldo, "vdd-l3"), + RPMH_VREG("ldo4", "ldo%s4", &pmic5_pldo_lv, "vdd-l4"), + {} +}; + +static const struct rpmh_vreg_init_data pm8550_vreg_data[] = { + RPMH_VREG("ldo1", "ldo%s1", &pmic5_nldo515, "vdd-l1-l4-l10"), + RPMH_VREG("ldo2", "ldo%s2", &pmic5_pldo, "vdd-l2-l13-l14"), + RPMH_VREG("ldo3", "ldo%s3", &pmic5_nldo515, "vdd-l3"), + RPMH_VREG("ldo4", "ldo%s4", &pmic5_nldo515, "vdd-l1-l4-l10"), + RPMH_VREG("ldo5", "ldo%s5", &pmic5_pldo, "vdd-l5-l16"), + RPMH_VREG("ldo6", "ldo%s6", &pmic5_pldo, "vdd-l6-l7"), + RPMH_VREG("ldo7", "ldo%s7", &pmic5_pldo, "vdd-l6-l7"), + RPMH_VREG("ldo8", "ldo%s8", &pmic5_pldo, "vdd-l8-l9"), + RPMH_VREG("ldo9", "ldo%s9", &pmic5_pldo, "vdd-l8-l9"), + RPMH_VREG("ldo10", "ldo%s10", &pmic5_nldo515, "vdd-l1-l4-l10"), + RPMH_VREG("ldo11", "ldo%s11", &pmic5_nldo515, "vdd-l11"), + RPMH_VREG("ldo12", "ldo%s12", &pmic5_nldo515, "vdd-l12"), + RPMH_VREG("ldo13", "ldo%s13", &pmic5_pldo, "vdd-l2-l13-l14"), + RPMH_VREG("ldo14", "ldo%s14", &pmic5_pldo, "vdd-l2-l13-l14"), + RPMH_VREG("ldo15", "ldo%s15", &pmic5_nldo515, "vdd-l15"), + RPMH_VREG("ldo16", "ldo%s16", &pmic5_pldo, "vdd-l5-l16"), + RPMH_VREG("ldo17", "ldo%s17", &pmic5_pldo, "vdd-l17"), + RPMH_VREG("bob1", "bob%s1", &pmic5_bob, "vdd-bob1"), + RPMH_VREG("bob2", "bob%s2", &pmic5_bob, "vdd-bob2"), + {} +}; + +static const struct rpmh_vreg_init_data pm8550vs_vreg_data[] = { + RPMH_VREG("smps1", "smp%s1", &pmic5_ftsmps525_lv, "vdd-s1"), + RPMH_VREG("smps2", "smp%s2", &pmic5_ftsmps525_lv, "vdd-s2"), + RPMH_VREG("smps3", "smp%s3", &pmic5_ftsmps525_lv, "vdd-s3"), + RPMH_VREG("smps4", "smp%s4", &pmic5_ftsmps525_lv, "vdd-s4"), + RPMH_VREG("smps5", "smp%s5", &pmic5_ftsmps525_lv, "vdd-s5"), + RPMH_VREG("smps6", "smp%s6", &pmic5_ftsmps525_mv, "vdd-s6"), + RPMH_VREG("ldo1", "ldo%s1", &pmic5_nldo515, "vdd-l1"), + RPMH_VREG("ldo2", "ldo%s2", &pmic5_nldo515, "vdd-l2"), + RPMH_VREG("ldo3", "ldo%s3", &pmic5_nldo515, "vdd-l3"), + {} +}; + +static const struct rpmh_vreg_init_data pm8550ve_vreg_data[] = { + RPMH_VREG("smps1", "smp%s1", &pmic5_ftsmps525_lv, "vdd-s1"), + RPMH_VREG("smps2", "smp%s2", &pmic5_ftsmps525_lv, "vdd-s2"), + RPMH_VREG("smps3", "smp%s3", &pmic5_ftsmps525_lv, "vdd-s3"), + RPMH_VREG("smps4", "smp%s4", &pmic5_ftsmps525_mv, "vdd-s4"), + RPMH_VREG("smps5", "smp%s5", &pmic5_ftsmps525_lv, "vdd-s5"), + RPMH_VREG("smps6", "smp%s6", &pmic5_ftsmps525_lv, "vdd-s6"), + RPMH_VREG("smps7", "smp%s7", &pmic5_ftsmps525_lv, "vdd-s7"), + RPMH_VREG("smps8", "smp%s8", &pmic5_ftsmps525_lv, "vdd-s8"), + RPMH_VREG("ldo1", "ldo%s1", &pmic5_nldo515, "vdd-l1"), + RPMH_VREG("ldo2", "ldo%s2", &pmic5_nldo515, "vdd-l2"), + RPMH_VREG("ldo3", "ldo%s3", &pmic5_nldo515, "vdd-l3"), + {} +}; + +static const struct rpmh_vreg_init_data pmc8380_vreg_data[] = { + RPMH_VREG("smps1", "smp%s1", &pmic5_ftsmps525_lv, "vdd-s1"), + RPMH_VREG("smps2", "smp%s2", &pmic5_ftsmps525_lv, "vdd-s2"), + RPMH_VREG("smps3", "smp%s3", &pmic5_ftsmps525_lv, "vdd-s3"), + RPMH_VREG("smps4", "smp%s4", &pmic5_ftsmps525_mv, "vdd-s4"), + RPMH_VREG("smps5", "smp%s5", &pmic5_ftsmps525_lv, "vdd-s5"), + RPMH_VREG("smps6", "smp%s6", &pmic5_ftsmps525_lv, "vdd-s6"), + RPMH_VREG("smps7", "smp%s7", &pmic5_ftsmps525_lv, "vdd-s7"), + RPMH_VREG("smps8", "smp%s8", &pmic5_ftsmps525_lv, "vdd-s8"), + RPMH_VREG("ldo1", "ldo%s1", &pmic5_nldo515, "vdd-l1"), + RPMH_VREG("ldo2", "ldo%s2", &pmic5_nldo515, "vdd-l2"), + RPMH_VREG("ldo3", "ldo%s3", &pmic5_nldo515, "vdd-l3"), + {} +}; + +static const struct rpmh_vreg_init_data pm8009_vreg_data[] = { + RPMH_VREG("smps1", "smp%s1", &pmic5_hfsmps510, "vdd-s1"), + RPMH_VREG("smps2", "smp%s2", &pmic5_hfsmps515, "vdd-s2"), + RPMH_VREG("ldo1", "ldo%s1", &pmic5_nldo, "vdd-l1"), + RPMH_VREG("ldo2", "ldo%s2", &pmic5_nldo, "vdd-l2"), + RPMH_VREG("ldo3", "ldo%s3", &pmic5_nldo, "vdd-l3"), + RPMH_VREG("ldo4", "ldo%s4", &pmic5_nldo, "vdd-l4"), + RPMH_VREG("ldo5", "ldo%s5", &pmic5_pldo, "vdd-l5-l6"), + RPMH_VREG("ldo6", "ldo%s6", &pmic5_pldo, "vdd-l5-l6"), + RPMH_VREG("ldo7", "ldo%s7", &pmic5_pldo_lv, "vdd-l7"), + {} +}; + +static const struct rpmh_vreg_init_data pm8009_1_vreg_data[] = { + RPMH_VREG("smps1", "smp%s1", &pmic5_hfsmps510, "vdd-s1"), + RPMH_VREG("smps2", "smp%s2", &pmic5_hfsmps515_1, "vdd-s2"), + RPMH_VREG("ldo1", "ldo%s1", &pmic5_nldo, "vdd-l1"), + RPMH_VREG("ldo2", "ldo%s2", &pmic5_nldo, "vdd-l2"), + RPMH_VREG("ldo3", "ldo%s3", &pmic5_nldo, "vdd-l3"), + RPMH_VREG("ldo4", "ldo%s4", &pmic5_nldo, "vdd-l4"), + RPMH_VREG("ldo5", "ldo%s5", &pmic5_pldo, "vdd-l5-l6"), + RPMH_VREG("ldo6", "ldo%s6", &pmic5_pldo, "vdd-l5-l6"), + RPMH_VREG("ldo7", "ldo%s7", &pmic5_pldo_lv, "vdd-l7"), + {} +}; + +static const struct rpmh_vreg_init_data pm8010_vreg_data[] = { + RPMH_VREG("ldo1", "ldo%s1", &pmic5_nldo502, "vdd-l1-l2"), + RPMH_VREG("ldo2", "ldo%s2", &pmic5_nldo502, "vdd-l1-l2"), + RPMH_VREG("ldo3", "ldo%s3", &pmic5_pldo502ln, "vdd-l3-l4"), + RPMH_VREG("ldo4", "ldo%s4", &pmic5_pldo502ln, "vdd-l3-l4"), + RPMH_VREG("ldo5", "ldo%s5", &pmic5_pldo502, "vdd-l5"), + RPMH_VREG("ldo6", "ldo%s6", &pmic5_pldo502ln, "vdd-l6"), + RPMH_VREG("ldo7", "ldo%s7", &pmic5_pldo502, "vdd-l7"), +}; + +static const struct rpmh_vreg_init_data pm6150_vreg_data[] = { + RPMH_VREG("smps1", "smp%s1", &pmic5_ftsmps510, "vdd-s1"), + RPMH_VREG("smps2", "smp%s2", &pmic5_ftsmps510, "vdd-s2"), + RPMH_VREG("smps3", "smp%s3", &pmic5_ftsmps510, "vdd-s3"), + RPMH_VREG("smps4", "smp%s4", &pmic5_hfsmps510, "vdd-s4"), + RPMH_VREG("smps5", "smp%s5", &pmic5_hfsmps510, "vdd-s5"), + RPMH_VREG("ldo1", "ldo%s1", &pmic5_nldo, "vdd-l1"), + RPMH_VREG("ldo2", "ldo%s2", &pmic5_nldo, "vdd-l2-l3"), + RPMH_VREG("ldo3", "ldo%s3", &pmic5_nldo, "vdd-l2-l3"), + RPMH_VREG("ldo4", "ldo%s4", &pmic5_nldo, "vdd-l4-l7-l8"), + RPMH_VREG("ldo5", "ldo%s5", &pmic5_pldo, "vdd-l5-l16-l17-l18-l19"), + RPMH_VREG("ldo6", "ldo%s6", &pmic5_nldo, "vdd-l6"), + RPMH_VREG("ldo7", "ldo%s7", &pmic5_nldo, "vdd-l4-l7-l8"), + RPMH_VREG("ldo8", "ldo%s8", &pmic5_nldo, "vdd-l4-l7-l8"), + RPMH_VREG("ldo9", "ldo%s9", &pmic5_nldo, "vdd-l9"), + RPMH_VREG("ldo10", "ldo%s10", &pmic5_pldo_lv, "vdd-l10-l14-l15"), + RPMH_VREG("ldo11", "ldo%s11", &pmic5_pldo_lv, "vdd-l11-l12-l13"), + RPMH_VREG("ldo12", "ldo%s12", &pmic5_pldo_lv, "vdd-l11-l12-l13"), + RPMH_VREG("ldo13", "ldo%s13", &pmic5_pldo_lv, "vdd-l11-l12-l13"), + RPMH_VREG("ldo14", "ldo%s14", &pmic5_pldo_lv, "vdd-l10-l14-l15"), + RPMH_VREG("ldo15", "ldo%s15", &pmic5_pldo_lv, "vdd-l10-l14-l15"), + RPMH_VREG("ldo16", "ldo%s16", &pmic5_pldo, "vdd-l5-l16-l17-l18-l19"), + RPMH_VREG("ldo17", "ldo%s17", &pmic5_pldo, "vdd-l5-l16-l17-l18-l19"), + RPMH_VREG("ldo18", "ldo%s18", &pmic5_pldo, "vdd-l5-l16-l17-l18-l19"), + RPMH_VREG("ldo19", "ldo%s19", &pmic5_pldo, "vdd-l5-l16-l17-l18-l19"), + {} +}; + +static const struct rpmh_vreg_init_data pm6150l_vreg_data[] = { + RPMH_VREG("smps1", "smp%s1", &pmic5_ftsmps510, "vdd-s1"), + RPMH_VREG("smps2", "smp%s2", &pmic5_ftsmps510, "vdd-s2"), + RPMH_VREG("smps3", "smp%s3", &pmic5_ftsmps510, "vdd-s3"), + RPMH_VREG("smps4", "smp%s4", &pmic5_ftsmps510, "vdd-s4"), + RPMH_VREG("smps5", "smp%s5", &pmic5_ftsmps510, "vdd-s5"), + RPMH_VREG("smps6", "smp%s6", &pmic5_ftsmps510, "vdd-s6"), + RPMH_VREG("smps7", "smp%s7", &pmic5_ftsmps510, "vdd-s7"), + RPMH_VREG("smps8", "smp%s8", &pmic5_hfsmps510, "vdd-s8"), + RPMH_VREG("ldo1", "ldo%s1", &pmic5_pldo_lv, "vdd-l1-l8"), + RPMH_VREG("ldo2", "ldo%s2", &pmic5_nldo, "vdd-l2-l3"), + RPMH_VREG("ldo3", "ldo%s3", &pmic5_nldo, "vdd-l2-l3"), + RPMH_VREG("ldo4", "ldo%s4", &pmic5_pldo, "vdd-l4-l5-l6"), + RPMH_VREG("ldo5", "ldo%s5", &pmic5_pldo, "vdd-l4-l5-l6"), + RPMH_VREG("ldo6", "ldo%s6", &pmic5_pldo, "vdd-l4-l5-l6"), + RPMH_VREG("ldo7", "ldo%s7", &pmic5_pldo, "vdd-l7-l11"), + RPMH_VREG("ldo8", "ldo%s8", &pmic5_pldo, "vdd-l1-l8"), + RPMH_VREG("ldo9", "ldo%s9", &pmic5_pldo, "vdd-l9-l10"), + RPMH_VREG("ldo10", "ldo%s10", &pmic5_pldo, "vdd-l9-l10"), + RPMH_VREG("ldo11", "ldo%s11", &pmic5_pldo, "vdd-l7-l11"), + RPMH_VREG("bob", "bob%s1", &pmic5_bob, "vdd-bob"), + {} +}; + +static const struct rpmh_vreg_init_data pm6350_vreg_data[] = { + RPMH_VREG("smps1", "smp%s1", &pmic5_ftsmps510, NULL), + RPMH_VREG("smps2", "smp%s2", &pmic5_hfsmps510, NULL), + /* smps3 - smps5 not configured */ + RPMH_VREG("ldo1", "ldo%s1", &pmic5_nldo, NULL), + RPMH_VREG("ldo2", "ldo%s2", &pmic5_pldo, NULL), + RPMH_VREG("ldo3", "ldo%s3", &pmic5_pldo, NULL), + RPMH_VREG("ldo4", "ldo%s4", &pmic5_nldo, NULL), + RPMH_VREG("ldo5", "ldo%s5", &pmic5_pldo, NULL), + RPMH_VREG("ldo6", "ldo%s6", &pmic5_pldo, NULL), + RPMH_VREG("ldo7", "ldo%s7", &pmic5_pldo, NULL), + RPMH_VREG("ldo8", "ldo%s8", &pmic5_pldo, NULL), + RPMH_VREG("ldo9", "ldo%s9", &pmic5_pldo, NULL), + RPMH_VREG("ldo10", "ldo%s10", &pmic5_pldo, NULL), + RPMH_VREG("ldo11", "ldo%s11", &pmic5_pldo, NULL), + RPMH_VREG("ldo12", "ldo%s12", &pmic5_pldo, NULL), + RPMH_VREG("ldo13", "ldo%s13", &pmic5_nldo, NULL), + RPMH_VREG("ldo14", "ldo%s14", &pmic5_pldo, NULL), + RPMH_VREG("ldo15", "ldo%s15", &pmic5_nldo, NULL), + RPMH_VREG("ldo16", "ldo%s16", &pmic5_nldo, NULL), + /* ldo17 not configured */ + RPMH_VREG("ldo18", "ldo%s18", &pmic5_nldo, NULL), + RPMH_VREG("ldo19", "ldo%s19", &pmic5_nldo, NULL), + RPMH_VREG("ldo20", "ldo%s20", &pmic5_nldo, NULL), + RPMH_VREG("ldo21", "ldo%s21", &pmic5_nldo, NULL), + RPMH_VREG("ldo22", "ldo%s22", &pmic5_nldo, NULL), +}; + +static const struct rpmh_vreg_init_data pmx55_vreg_data[] = { + RPMH_VREG("smps1", "smp%s1", &pmic5_ftsmps510, "vdd-s1"), + RPMH_VREG("smps2", "smp%s2", &pmic5_hfsmps510, "vdd-s2"), + RPMH_VREG("smps3", "smp%s3", &pmic5_hfsmps510, "vdd-s3"), + RPMH_VREG("smps4", "smp%s4", &pmic5_hfsmps510, "vdd-s4"), + RPMH_VREG("smps5", "smp%s5", &pmic5_hfsmps510, "vdd-s5"), + RPMH_VREG("smps6", "smp%s6", &pmic5_ftsmps510, "vdd-s6"), + RPMH_VREG("smps7", "smp%s7", &pmic5_hfsmps510, "vdd-s7"), + RPMH_VREG("ldo1", "ldo%s1", &pmic5_nldo, "vdd-l1-l2"), + RPMH_VREG("ldo2", "ldo%s2", &pmic5_nldo, "vdd-l1-l2"), + RPMH_VREG("ldo3", "ldo%s3", &pmic5_nldo, "vdd-l3-l9"), + RPMH_VREG("ldo4", "ldo%s4", &pmic5_nldo, "vdd-l4-l12"), + RPMH_VREG("ldo5", "ldo%s5", &pmic5_pldo, "vdd-l5-l6"), + RPMH_VREG("ldo6", "ldo%s6", &pmic5_pldo, "vdd-l5-l6"), + RPMH_VREG("ldo7", "ldo%s7", &pmic5_nldo, "vdd-l7-l8"), + RPMH_VREG("ldo8", "ldo%s8", &pmic5_nldo, "vdd-l7-l8"), + RPMH_VREG("ldo9", "ldo%s9", &pmic5_nldo, "vdd-l3-l9"), + RPMH_VREG("ldo10", "ldo%s10", &pmic5_pldo, "vdd-l10-l11-l13"), + RPMH_VREG("ldo11", "ldo%s11", &pmic5_pldo, "vdd-l10-l11-l13"), + RPMH_VREG("ldo12", "ldo%s12", &pmic5_nldo, "vdd-l4-l12"), + RPMH_VREG("ldo13", "ldo%s13", &pmic5_pldo, "vdd-l10-l11-l13"), + RPMH_VREG("ldo14", "ldo%s14", &pmic5_nldo, "vdd-l14"), + RPMH_VREG("ldo15", "ldo%s15", &pmic5_nldo, "vdd-l15"), + RPMH_VREG("ldo16", "ldo%s16", &pmic5_pldo, "vdd-l16"), + {} +}; + +static const struct rpmh_vreg_init_data pmx65_vreg_data[] = { + RPMH_VREG("smps1", "smp%s1", &pmic5_ftsmps510, "vdd-s1"), + RPMH_VREG("smps2", "smp%s2", &pmic5_hfsmps510, "vdd-s2"), + RPMH_VREG("smps3", "smp%s3", &pmic5_hfsmps510, "vdd-s3"), + RPMH_VREG("smps4", "smp%s4", &pmic5_hfsmps510, "vdd-s4"), + RPMH_VREG("smps5", "smp%s5", &pmic5_hfsmps510, "vdd-s5"), + RPMH_VREG("smps6", "smp%s6", &pmic5_ftsmps510, "vdd-s6"), + RPMH_VREG("smps7", "smp%s7", &pmic5_hfsmps510, "vdd-s7"), + RPMH_VREG("smps8", "smp%s8", &pmic5_hfsmps510, "vdd-s8"), + RPMH_VREG("ldo1", "ldo%s1", &pmic5_nldo, "vdd-l1"), + RPMH_VREG("ldo2", "ldo%s2", &pmic5_nldo, "vdd-l2-l18"), + RPMH_VREG("ldo3", "ldo%s3", &pmic5_nldo, "vdd-l3"), + RPMH_VREG("ldo4", "ldo%s4", &pmic5_nldo, "vdd-l4"), + RPMH_VREG("ldo5", "ldo%s5", &pmic5_pldo, "vdd-l5-l6-l16"), + RPMH_VREG("ldo6", "ldo%s6", &pmic5_pldo, "vdd-l5-l6-l16"), + RPMH_VREG("ldo7", "ldo%s7", &pmic5_nldo, "vdd-l7"), + RPMH_VREG("ldo8", "ldo%s8", &pmic5_nldo, "vdd-l8-l9"), + RPMH_VREG("ldo9", "ldo%s9", &pmic5_nldo, "vdd-l8-l9"), + RPMH_VREG("ldo10", "ldo%s10", &pmic5_pldo, "vdd-l10"), + RPMH_VREG("ldo11", "ldo%s11", &pmic5_pldo, "vdd-l11-l13"), + RPMH_VREG("ldo12", "ldo%s12", &pmic5_nldo, "vdd-l12"), + RPMH_VREG("ldo13", "ldo%s13", &pmic5_pldo, "vdd-l11-l13"), + RPMH_VREG("ldo14", "ldo%s14", &pmic5_nldo, "vdd-l14"), + RPMH_VREG("ldo15", "ldo%s15", &pmic5_nldo, "vdd-l15"), + RPMH_VREG("ldo16", "ldo%s16", &pmic5_pldo, "vdd-l5-l6-l16"), + RPMH_VREG("ldo17", "ldo%s17", &pmic5_nldo, "vdd-l17"), + /* ldo18 not configured */ + RPMH_VREG("ldo19", "ldo%s19", &pmic5_nldo, "vdd-l19"), + RPMH_VREG("ldo20", "ldo%s20", &pmic5_nldo, "vdd-l20"), + RPMH_VREG("ldo21", "ldo%s21", &pmic5_nldo, "vdd-l21"), + {} +}; + +static const struct rpmh_vreg_init_data pmx75_vreg_data[] = { + RPMH_VREG("smps1", "smp%s1", &pmic5_ftsmps525_lv, "vdd-s1"), + RPMH_VREG("smps2", "smp%s2", &pmic5_ftsmps525_lv, "vdd-s2"), + RPMH_VREG("smps3", "smp%s3", &pmic5_ftsmps525_lv, "vdd-s3"), + RPMH_VREG("smps4", "smp%s4", &pmic5_ftsmps525_mv, "vdd-s4"), + RPMH_VREG("smps5", "smp%s5", &pmic5_ftsmps525_lv, "vdd-s5"), + RPMH_VREG("smps6", "smp%s6", &pmic5_ftsmps525_lv, "vdd-s6"), + RPMH_VREG("smps7", "smp%s7", &pmic5_ftsmps525_lv, "vdd-s7"), + RPMH_VREG("smps8", "smp%s8", &pmic5_ftsmps525_lv, "vdd-s8"), + RPMH_VREG("smps9", "smp%s9", &pmic5_ftsmps525_lv, "vdd-s9"), + RPMH_VREG("smps10", "smp%s10", &pmic5_ftsmps525_lv, "vdd-s10"), + RPMH_VREG("ldo1", "ldo%s1", &pmic5_nldo515, "vdd-l1"), + RPMH_VREG("ldo2", "ldo%s2", &pmic5_nldo515, "vdd-l2-18"), + RPMH_VREG("ldo3", "ldo%s3", &pmic5_nldo515, "vdd-l3"), + RPMH_VREG("ldo4", "ldo%s4", &pmic5_nldo515, "vdd-l4-l16"), + RPMH_VREG("ldo5", "ldo%s5", &pmic5_pldo_lv, "vdd-l5-l6"), + RPMH_VREG("ldo6", "ldo%s6", &pmic5_pldo_lv, "vdd-l5-l6"), + RPMH_VREG("ldo7", "ldo%s7", &pmic5_nldo515, "vdd-l7"), + RPMH_VREG("ldo8", "ldo%s8", &pmic5_nldo515, "vdd-l8-l9"), + RPMH_VREG("ldo9", "ldo%s9", &pmic5_nldo515, "vdd-l8-l9"), + RPMH_VREG("ldo10", "ldo%s10", &pmic5_pldo, "vdd-l10"), + RPMH_VREG("ldo11", "ldo%s11", &pmic5_pldo, "vdd-l11-l13"), + RPMH_VREG("ldo12", "ldo%s12", &pmic5_nldo515, "vdd-l12"), + RPMH_VREG("ldo13", "ldo%s13", &pmic5_pldo, "vdd-l11-l13"), + RPMH_VREG("ldo14", "ldo%s14", &pmic5_nldo515, "vdd-l14"), + RPMH_VREG("ldo15", "ldo%s15", &pmic5_nldo515, "vdd-l15"), + RPMH_VREG("ldo16", "ldo%s16", &pmic5_nldo515, "vdd-l4-l16"), + RPMH_VREG("ldo17", "ldo%s17", &pmic5_nldo515, "vdd-l17"), + /* ldo18 not configured */ + RPMH_VREG("ldo19", "ldo%s19", &pmic5_nldo515, "vdd-l19"), + RPMH_VREG("ldo20", "ldo%s20", &pmic5_nldo515, "vdd-l20-l21"), + RPMH_VREG("ldo21", "ldo%s21", &pmic5_nldo515, "vdd-l20-l21"), +}; + +static const struct rpmh_vreg_init_data pm7325_vreg_data[] = { + RPMH_VREG("smps1", "smp%s1", &pmic5_hfsmps510, "vdd-s1"), + RPMH_VREG("smps2", "smp%s2", &pmic5_ftsmps520, "vdd-s2"), + RPMH_VREG("smps3", "smp%s3", &pmic5_ftsmps520, "vdd-s3"), + RPMH_VREG("smps4", "smp%s4", &pmic5_ftsmps520, "vdd-s4"), + RPMH_VREG("smps5", "smp%s5", &pmic5_ftsmps520, "vdd-s5"), + RPMH_VREG("smps6", "smp%s6", &pmic5_ftsmps520, "vdd-s6"), + RPMH_VREG("smps7", "smp%s7", &pmic5_ftsmps520, "vdd-s7"), + RPMH_VREG("smps8", "smp%s8", &pmic5_hfsmps510, "vdd-s8"), + RPMH_VREG("ldo1", "ldo%s1", &pmic5_nldo, "vdd-l1-l4-l12-l15"), + RPMH_VREG("ldo2", "ldo%s2", &pmic5_pldo, "vdd-l2-l7"), + RPMH_VREG("ldo3", "ldo%s3", &pmic5_nldo, "vdd-l3"), + RPMH_VREG("ldo4", "ldo%s4", &pmic5_nldo, "vdd-l1-l4-l12-l15"), + RPMH_VREG("ldo5", "ldo%s5", &pmic5_nldo, "vdd-l5"), + RPMH_VREG("ldo6", "ldo%s6", &pmic5_nldo, "vdd-l6-l9-l10"), + RPMH_VREG("ldo7", "ldo%s7", &pmic5_pldo, "vdd-l2-l7"), + RPMH_VREG("ldo8", "ldo%s8", &pmic5_nldo, "vdd-l8"), + RPMH_VREG("ldo9", "ldo%s9", &pmic5_nldo, "vdd-l6-l9-l10"), + RPMH_VREG("ldo10", "ldo%s10", &pmic5_nldo, "vdd-l6-l9-l10"), + RPMH_VREG("ldo11", "ldo%s11", &pmic5_pldo_lv, "vdd-l11-l17-l18-l19"), + RPMH_VREG("ldo12", "ldo%s12", &pmic5_nldo, "vdd-l1-l4-l12-l15"), + RPMH_VREG("ldo13", "ldo%s13", &pmic5_nldo, "vdd-l13"), + RPMH_VREG("ldo14", "ldo%s14", &pmic5_nldo, "vdd-l14-l16"), + RPMH_VREG("ldo15", "ldo%s15", &pmic5_nldo, "vdd-l1-l4-l12-l15"), + RPMH_VREG("ldo16", "ldo%s16", &pmic5_nldo, "vdd-l14-l16"), + RPMH_VREG("ldo17", "ldo%s17", &pmic5_pldo_lv, "vdd-l11-l17-l18-l19"), + RPMH_VREG("ldo18", "ldo%s18", &pmic5_pldo_lv, "vdd-l11-l17-l18-l19"), + RPMH_VREG("ldo19", "ldo%s19", &pmic5_pldo_lv, "vdd-l11-l17-l18-l19"), + {} +}; + +static const struct rpmh_vreg_init_data pmr735a_vreg_data[] = { + RPMH_VREG("smps1", "smp%s1", &pmic5_ftsmps520, "vdd-s1"), + RPMH_VREG("smps2", "smp%s2", &pmic5_ftsmps520, "vdd-s2"), + RPMH_VREG("smps3", "smp%s3", &pmic5_hfsmps515, "vdd-s3"), + RPMH_VREG("ldo1", "ldo%s1", &pmic5_nldo, "vdd-l1-l2"), + RPMH_VREG("ldo2", "ldo%s2", &pmic5_nldo, "vdd-l1-l2"), + RPMH_VREG("ldo3", "ldo%s3", &pmic5_nldo, "vdd-l3"), + RPMH_VREG("ldo4", "ldo%s4", &pmic5_pldo_lv, "vdd-l4"), + RPMH_VREG("ldo5", "ldo%s5", &pmic5_nldo, "vdd-l5-l6"), + RPMH_VREG("ldo6", "ldo%s6", &pmic5_nldo, "vdd-l5-l6"), + RPMH_VREG("ldo7", "ldo%s7", &pmic5_pldo, "vdd-l7-bob"), + {} +}; + +static const struct rpmh_vreg_init_data pm660_vreg_data[] = { + RPMH_VREG("smps1", "smp%s1", &pmic4_ftsmps426, "vdd-s1"), + RPMH_VREG("smps2", "smp%s2", &pmic4_ftsmps426, "vdd-s2"), + RPMH_VREG("smps3", "smp%s3", &pmic4_ftsmps426, "vdd-s3"), + RPMH_VREG("smps4", "smp%s4", &pmic4_hfsmps3, "vdd-s4"), + RPMH_VREG("smps5", "smp%s5", &pmic4_hfsmps3, "vdd-s5"), + RPMH_VREG("smps6", "smp%s6", &pmic4_hfsmps3, "vdd-s6"), + RPMH_VREG("ldo1", "ldo%s1", &pmic4_nldo, "vdd-l1-l6-l7"), + RPMH_VREG("ldo2", "ldo%s2", &pmic4_nldo, "vdd-l2-l3"), + RPMH_VREG("ldo3", "ldo%s3", &pmic4_nldo, "vdd-l2-l3"), + /* ldo4 is inaccessible on PM660 */ + RPMH_VREG("ldo5", "ldo%s5", &pmic4_nldo, "vdd-l5"), + RPMH_VREG("ldo6", "ldo%s6", &pmic4_nldo, "vdd-l1-l6-l7"), + RPMH_VREG("ldo7", "ldo%s7", &pmic4_nldo, "vdd-l1-l6-l7"), + RPMH_VREG("ldo8", "ldo%s8", &pmic4_pldo_lv, "vdd-l8-l9-l10-l11-l12-l13-l14"), + RPMH_VREG("ldo9", "ldo%s9", &pmic4_pldo_lv, "vdd-l8-l9-l10-l11-l12-l13-l14"), + RPMH_VREG("ldo10", "ldo%s10", &pmic4_pldo_lv, "vdd-l8-l9-l10-l11-l12-l13-l14"), + RPMH_VREG("ldo11", "ldo%s11", &pmic4_pldo_lv, "vdd-l8-l9-l10-l11-l12-l13-l14"), + RPMH_VREG("ldo12", "ldo%s12", &pmic4_pldo_lv, "vdd-l8-l9-l10-l11-l12-l13-l14"), + RPMH_VREG("ldo13", "ldo%s13", &pmic4_pldo_lv, "vdd-l8-l9-l10-l11-l12-l13-l14"), + RPMH_VREG("ldo14", "ldo%s14", &pmic4_pldo_lv, "vdd-l8-l9-l10-l11-l12-l13-l14"), + RPMH_VREG("ldo15", "ldo%s15", &pmic4_pldo, "vdd-l15-l16-l17-l18-l19"), + RPMH_VREG("ldo16", "ldo%s16", &pmic4_pldo, "vdd-l15-l16-l17-l18-l19"), + RPMH_VREG("ldo17", "ldo%s17", &pmic4_pldo, "vdd-l15-l16-l17-l18-l19"), + RPMH_VREG("ldo18", "ldo%s18", &pmic4_pldo, "vdd-l15-l16-l17-l18-l19"), + RPMH_VREG("ldo19", "ldo%s19", &pmic4_pldo, "vdd-l15-l16-l17-l18-l19"), + {} +}; + +static const struct rpmh_vreg_init_data pm660l_vreg_data[] = { + RPMH_VREG("smps1", "smp%s1", &pmic4_ftsmps426, "vdd-s1"), + RPMH_VREG("smps2", "smp%s2", &pmic4_ftsmps426, "vdd-s2"), + RPMH_VREG("smps3", "smp%s3", &pmic4_ftsmps426, "vdd-s3-s4"), + RPMH_VREG("smps5", "smp%s5", &pmic4_ftsmps426, "vdd-s5"), + RPMH_VREG("ldo1", "ldo%s1", &pmic4_nldo, "vdd-l1-l9-l10"), + RPMH_VREG("ldo2", "ldo%s2", &pmic4_pldo, "vdd-l2"), + RPMH_VREG("ldo3", "ldo%s3", &pmic4_pldo, "vdd-l3-l5-l7-l8"), + RPMH_VREG("ldo4", "ldo%s4", &pmic4_pldo, "vdd-l4-l6"), + RPMH_VREG("ldo5", "ldo%s5", &pmic4_pldo, "vdd-l3-l5-l7-l8"), + RPMH_VREG("ldo6", "ldo%s6", &pmic4_pldo, "vdd-l4-l6"), + RPMH_VREG("ldo7", "ldo%s7", &pmic4_pldo, "vdd-l3-l5-l7-l8"), + RPMH_VREG("ldo8", "ldo%s8", &pmic4_pldo, "vdd-l3-l5-l7-l8"), + RPMH_VREG("bob", "bob%s1", &pmic4_bob, "vdd-bob"), + {} +}; + +static int rpmh_regulator_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + const struct rpmh_vreg_init_data *vreg_data; + struct device_node *node; + struct rpmh_vreg *vreg; + const char *pmic_id; + int ret; + + vreg_data = of_device_get_match_data(dev); + if (!vreg_data) + return -ENODEV; + + ret = of_property_read_string(dev->of_node, "qcom,pmic-id", &pmic_id); + if (ret < 0) { + dev_err(dev, "qcom,pmic-id missing in DT node\n"); + return ret; + } + + for_each_available_child_of_node(dev->of_node, node) { + vreg = devm_kzalloc(dev, sizeof(*vreg), GFP_KERNEL); + if (!vreg) { + of_node_put(node); + return -ENOMEM; + } + + ret = rpmh_regulator_init_vreg(vreg, dev, node, pmic_id, + vreg_data); + if (ret < 0) { + of_node_put(node); + return ret; + } + } + + return 0; +} + +static const struct of_device_id __maybe_unused rpmh_regulator_match_table[] = { + { + .compatible = "qcom,pm8005-rpmh-regulators", + .data = pm8005_vreg_data, + }, + { + .compatible = "qcom,pm8009-rpmh-regulators", + .data = pm8009_vreg_data, + }, + { + .compatible = "qcom,pm8009-1-rpmh-regulators", + .data = pm8009_1_vreg_data, + }, + { + .compatible = "qcom,pm8010-rpmh-regulators", + .data = pm8010_vreg_data, + }, + { + .compatible = "qcom,pm8150-rpmh-regulators", + .data = pm8150_vreg_data, + }, + { + .compatible = "qcom,pm8150l-rpmh-regulators", + .data = pm8150l_vreg_data, + }, + { + .compatible = "qcom,pm8350-rpmh-regulators", + .data = pm8350_vreg_data, + }, + { + .compatible = "qcom,pm8350c-rpmh-regulators", + .data = pm8350c_vreg_data, + }, + { + .compatible = "qcom,pm8450-rpmh-regulators", + .data = pm8450_vreg_data, + }, + { + .compatible = "qcom,pm8550-rpmh-regulators", + .data = pm8550_vreg_data, + }, + { + .compatible = "qcom,pm8550ve-rpmh-regulators", + .data = pm8550ve_vreg_data, + }, + { + .compatible = "qcom,pm8550vs-rpmh-regulators", + .data = pm8550vs_vreg_data, + }, + { + .compatible = "qcom,pm8998-rpmh-regulators", + .data = pm8998_vreg_data, + }, + { + .compatible = "qcom,pmg1110-rpmh-regulators", + .data = pmg1110_vreg_data, + }, + { + .compatible = "qcom,pmi8998-rpmh-regulators", + .data = pmi8998_vreg_data, + }, + { + .compatible = "qcom,pm6150-rpmh-regulators", + .data = pm6150_vreg_data, + }, + { + .compatible = "qcom,pm6150l-rpmh-regulators", + .data = pm6150l_vreg_data, + }, + { + .compatible = "qcom,pm6350-rpmh-regulators", + .data = pm6350_vreg_data, + }, + { + .compatible = "qcom,pmc8180-rpmh-regulators", + .data = pm8150_vreg_data, + }, + { + .compatible = "qcom,pmc8180c-rpmh-regulators", + .data = pm8150l_vreg_data, + }, + { + .compatible = "qcom,pmc8380-rpmh-regulators", + .data = pmc8380_vreg_data, + }, + { + .compatible = "qcom,pmm8155au-rpmh-regulators", + .data = pmm8155au_vreg_data, + }, + { + .compatible = "qcom,pmm8654au-rpmh-regulators", + .data = pmm8654au_vreg_data, + }, + { + .compatible = "qcom,pmx55-rpmh-regulators", + .data = pmx55_vreg_data, + }, + { + .compatible = "qcom,pmx65-rpmh-regulators", + .data = pmx65_vreg_data, + }, + { + .compatible = "qcom,pmx75-rpmh-regulators", + .data = pmx75_vreg_data, + }, + { + .compatible = "qcom,pm7325-rpmh-regulators", + .data = pm7325_vreg_data, + }, + { + .compatible = "qcom,pmr735a-rpmh-regulators", + .data = pmr735a_vreg_data, + }, + { + .compatible = "qcom,pm660-rpmh-regulators", + .data = pm660_vreg_data, + }, + { + .compatible = "qcom,pm660l-rpmh-regulators", + .data = pm660l_vreg_data, + }, + {} +}; +MODULE_DEVICE_TABLE(of, rpmh_regulator_match_table); + +static struct platform_driver rpmh_regulator_driver = { + .driver = { + .name = "qcom-rpmh-regulator", + .probe_type = PROBE_PREFER_ASYNCHRONOUS, + .of_match_table = of_match_ptr(rpmh_regulator_match_table), + }, + .probe = rpmh_regulator_probe, +}; +module_platform_driver(rpmh_regulator_driver); + +MODULE_DESCRIPTION("Qualcomm RPMh regulator driver"); +MODULE_LICENSE("GPL v2"); From patchwork Mon Jul 15 10:08:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 812616 Delivered-To: patch@linaro.org Received: by 2002:adf:fac3:0:b0:367:895a:4699 with SMTP id a3csp1724837wrs; Mon, 15 Jul 2024 03:11:07 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVSj3Dm9hEMkitHBQFWgeai35lmhWc7Bdts0FtCH04y1ddXGSQJ2HkNkYOeA3RH7L2n8CXM0OVqH50g9zT0GTnp X-Google-Smtp-Source: AGHT+IEHzDOgc8zCnNcDl+piSrd5zpLtVDW3bk83k0AikJdAJMWGDpbsELu3gvceiZIORkHPDVXS X-Received: by 2002:a17:906:f958:b0:a6f:12:8c45 with SMTP id a640c23a62f3a-a780b89ed22mr1212282666b.72.1721038266845; Mon, 15 Jul 2024 03:11:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721038266; cv=none; d=google.com; s=arc-20160816; b=BGfHynVfIZp5OhVx0jVLJP8J/F0Qdw/EAmdF78TEg5hfNJYMIB9G6ZavL0mD2deX04 fKYXeVuA8CP6Oi3ivXKcgf6BGCD1oRt0PlkF+SBlrKeFJv6sqHpkzUKPBxKLXDpxDBSh tpL+Gb94BmpM44ld2qPnFMU2x0V8SvXRBkW+c3Wm23BsZ2Od+v5Z0FSxl8tdSmPHN9Wk L0LUXfFeBz3Vbjd5ZALF7NAQBxbtx+uUSRXKtuc5H1mDZleEd3HOLjsnWyTBsyF15o4G dKFw740k2ikbuGotfA+A5Oj9ENVO0r6H9WbOJDhcjLqhS8LZYI/957yD10UU6Q5pcGmG +Nuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:cc:to:in-reply-to:references :message-id:content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=J2Xb8QGSmLC3HVEoB3mz/KYofOPaOn10RTD7PCXi0JM=; fh=zcTfjI3NycJyTuuOJ9uzXxS7wfOr4sYKS7eKveHEFzw=; b=qcgxa253rIS90U59mwfuFU7j2DYoLdO187F1V3m+wUyT+AOZapTSuk+z7mtXOIPgHb PPnKumEKwhbPGX6gV+kMDk2nC2E0FusOL4umeNB2x7VUugW+JkUmoinoCRJQsuNV59cb H4KXYNqEcOFOwPP+RM0pI0CbjLrMtwS/2buCKa58YZB6FKv0SVFS3L2p2zE9zJJaZvOQ NaUndO9PQrFRVSNtjOFK6z8ycxVk+U+/bMohP/0JVWxfTohO32gO3U3ejowfgxYzrlka UJqT0+oYlVTv7YBWCFkYFKbVTOb453I8ZNBNB0hz6zEJNuP1v/BU9w9iAI5ulNpCo4zu Z9Kg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Xu7ASPxL; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id a640c23a62f3a-a79bc7c165fsi229208966b.306.2024.07.15.03.11.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 03:11:06 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Xu7ASPxL; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3A24588872; Mon, 15 Jul 2024 12:08:54 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org 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=linaro.org header.i=@linaro.org header.b="Xu7ASPxL"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D0C0E88863; Mon, 15 Jul 2024 12:08:52 +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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) (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 D2CD588856 for ; Mon, 15 Jul 2024 12:08:49 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=caleb.connolly@linaro.org Received: by mail-ed1-x52c.google.com with SMTP id 4fb4d7f45d1cf-58c947a6692so5207011a12.0 for ; Mon, 15 Jul 2024 03:08:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721038129; x=1721642929; darn=lists.denx.de; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=J2Xb8QGSmLC3HVEoB3mz/KYofOPaOn10RTD7PCXi0JM=; b=Xu7ASPxLVYm4DqhgyV6YfszH8tXGOOHxWvSiIPSDf7VKa0gP4HOsHoKpzJ6sUVdBw/ 14W+Cespe5crxDNDpuEVswYrutAWo3v86CDJF7sjtQjoepYAWUHJj+Uci8JINRlNgcM7 MIz5U9jX4XZKNK9SBuzN4qSV/biY9gDlLm1xp38pK6AafRDVliHez/kpODEIJVDiVNDj 0l6MT1s1njdEGYAfd3u8tu/x6lDmzG6Ma9cJq7PBYsQojo9/lXqKXAc+ird5TkzQEAtP HZS8GlqbIOsV5EO0mr+/oaMAK1CAKFOYgX6X5ARt5sQnbRas940SJzrAR+ZM4hGF418V ZzyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721038129; x=1721642929; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=J2Xb8QGSmLC3HVEoB3mz/KYofOPaOn10RTD7PCXi0JM=; b=Vnh2aP6j4KO0kbZvfc/uszI24cXPGRk8CDp7Kio0JZ1TymTbfJGSk8mwmWAg4KCAZU UhTEK7uMaZkq6gilOQHNU1jAhUhP0WkHvS0tIvX89q/hhuhpqayL6/n4dpdXBJ8TXico 0DlzJcF4wsBnRZcZ6T5GT4QF/vJDrDAogdLuCrfMpJUg/QX2mNHaGwZeIhfYuZdzezF6 o4mWGtG4h2BMc9akUJCX07fDhcJmPhX8i9cqGz5aBE/wfv67nq9iSb+Muv8fTZWtk63w PT1hLPVkrN7K+ZrZP3Lf4RwOdkB3zcWIAQszkhlimRZmKIPtlCoHAlyhix2nOyZjoeJl cX6Q== X-Gm-Message-State: AOJu0YzvV744QMjA9Z9n+AyH82YSs9vnW0uLkuZqc0BQN070SZ51buwU akx5PoMuSYJCc2N0AnlKyKmpZI7WH2B36e+RdXNVF9o+G+LFMYR+y/A3pK+mhEk= X-Received: by 2002:a17:907:9492:b0:a77:dd1c:627a with SMTP id a640c23a62f3a-a780b68a25fmr1690203566b.8.1721038129341; Mon, 15 Jul 2024 03:08:49 -0700 (PDT) Received: from [192.168.0.113] ([2a02:8109:aa0d:be00::7424]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a79bc5b7eb4sm198102266b.60.2024.07.15.03.08.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 03:08:48 -0700 (PDT) From: Caleb Connolly Date: Mon, 15 Jul 2024 12:08:16 +0200 Subject: [PATCH v6 17/24] power: regulator: qcom-rpmh-regulator: adjust headers for U-Boot MIME-Version: 1.0 Message-Id: <20240715-b4-qcom-rpmh-v6-17-0c948a25d018@linaro.org> References: <20240715-b4-qcom-rpmh-v6-0-0c948a25d018@linaro.org> In-Reply-To: <20240715-b4-qcom-rpmh-v6-0-0c948a25d018@linaro.org> To: Tom Rini , Caleb Connolly , Neil Armstrong , Sumit Garg , Jaehoon Chung , Simon Glass Cc: u-boot@lists.denx.de, u-boot-qcom@groups.io X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=1182; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=Oc4JtpqXYn1MXtM0lGX9maQ83ydNTHJPWFTQLcLax0I=; b=owEBbQKS/ZANAwAIAQWDMSsZX2S2AcsmYgBmlPUHlFmTGZ/ivsNkcWEqRiVwKr6guKPPhhgxW m29hRrzjUyJAjMEAAEIAB0WIQS2UaFGPGq+0GkMVc0FgzErGV9ktgUCZpT1BwAKCRAFgzErGV9k toocD/9fWy048IDH4ZZlmps5+t235/UG60MFHzNkrEPfnaStyUV2eDo3HHVv/gUiW65nLKan6nS i6uFtYJIWE5GPmLkGUVXq/w1r5lkIBZc3rwfFsi+Y1dilCkxPLVvM4jt6iuQDLhL9qIvIofn7A8 7+3IbkG9I5YrrsP1JpUKUbq7oZ0NJrBrFYkA8C7sj5hAPz4lsX3XuJtKbglZTKqmkUe73/E05ws 685v/PgpA14e21SYHhQzxsYyPmJTTXu0ws/tH8m1DzXc7eNCr7eXQAxWVSY/cJ8LpI1c9eeGCoW unDQs5LjUqT1hqxhJpV5QxGI6JK7XBz8vdgkebVwKxdVJuP1u9g+Rfc4AY4LvSuLoEA3EnfvsZ/ Y+VyIfzMUnT1kX8tK0g0LcPGYeTkPBpSwv839A/68zJNeXaOpyI/aXxkNsu531KJ6RCpK7pnXob zwzGqxBNryAVGECEbQqG+vvNVmxOZetTAwOvgBHWzmyD6lhPQpHOPPZwx6a5XDTXhwateO88L4b U/e2/Q+G0RVubTTTXtnbfeOwrMtA5GUtu4hzcHwFyLpVW/aMMVXCgIeoy/3zr4avlgHozT+A8Ae S+nJin97gHSos99S5xF9iZbzaiozQpifSG4ki03IYjWOdSw8ZjnbC6wrUpUELahK3G6WaLSmkGl WlknYzwPLR6CX9g== X-Developer-Key: i=caleb.connolly@linaro.org; a=openpgp; fpr=83B24DA7FE145076BC38BB250CD904EB673A7C47 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.8 at phobos.denx.de X-Virus-Status: Clean Remove unused/unsupported Linux headers and add necessary U-Boot ones. Acked-by: Sumit Garg Signed-off-by: Caleb Connolly --- drivers/power/regulator/qcom-rpmh-regulator.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/drivers/power/regulator/qcom-rpmh-regulator.c b/drivers/power/regulator/qcom-rpmh-regulator.c index 80e304711345..5f522de44734 100644 --- a/drivers/power/regulator/qcom-rpmh-regulator.c +++ b/drivers/power/regulator/qcom-rpmh-regulator.c @@ -4,17 +4,14 @@ #define pr_fmt(fmt) "%s: " fmt, __func__ #include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include #include From patchwork Mon Jul 15 10:08:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 812617 Delivered-To: patch@linaro.org Received: by 2002:adf:fac3:0:b0:367:895a:4699 with SMTP id a3csp1724916wrs; Mon, 15 Jul 2024 03:11:17 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXlKe/OTVv66r24BZLCUJqzOKUukCBVlF9dZweJEh2hZzfxDrokDoucYgGZTRqkcTAhbLy4fr/7UkuMirRHcLu5 X-Google-Smtp-Source: AGHT+IG9rSxkpKFttpLVUfGSxuwV+U2/LCA2ibw8Z9/Ylz5DjwHvxhIRtHz19GTEqW3cuJ057tZI X-Received: by 2002:a05:6402:3551:b0:586:57c:2373 with SMTP id 4fb4d7f45d1cf-594b6eda294mr15411141a12.0.1721038277105; Mon, 15 Jul 2024 03:11:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721038277; cv=none; d=google.com; s=arc-20160816; b=KA1bO2b8797Q773rKYEyAP4b0/kKuZUs+a65MM0GlvIf0BBMdpSb69u05A8HxnXwCn 1mohG+TBNpgTfjh7Fgcuv/Sz4GHkkqsEj+SyEyRJMVH0GhmNLyFEKcE0cggXIHed7aj1 VVCBobuBotzFetZaMuTB86DUFpKvn1QBj91UhJNM6U4xFwSHpbHsYHCrcR16D2biI7sK ptmYwOkNB1FkEBhQqAnz/T+ZqwHH2ZVK76BRi6s5w+9CdluadQXc5+ifZ2r6A/FADmsV Rnj6tiZgZQsBbxOS+LJ7T16Ja+2m3FYlFIgghthr+XmueeoPPaq+qJsM41Ayh2RWXEP5 peug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:cc:to:in-reply-to:references :message-id:content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=N9IT/zALEh7mKodPKHns820h3aA7IvXfqWmQ85Fiq50=; fh=zcTfjI3NycJyTuuOJ9uzXxS7wfOr4sYKS7eKveHEFzw=; b=FGFynHox78iu8maU2YvFr6EAXmr86JlymuDQNDKG/ZwK9L1ETvSx3W81t32p9A7kwW rpJiTSLTo/Mq/UXVek+ip56aLyTdNGcOq5jiv8d86TbU+yZFZjlDrvVuRpGb8ZFOVKJY NyE5Fyauq4FxEKvvAJcPuj45QT34fZdoz6vm5uMwaauUtL3xwK76fIoaAkOeWiEBGUYD qpqL005i67HQsRFEd7bo4KogMlsNtPQdG2IK1x0TSEAlm3DDVf0GK/hHz3RmaQ0DUHKL YfU07+z7QpcI/IwH/Ajntx/33ZXHEHnEU9QoL7UFBWaiIhBWlrKcd5k7/+2YkTrOUJ1N N+iQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Cjfh3jpk; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-59b2705ac6dsi2347737a12.417.2024.07.15.03.11.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 03:11:17 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Cjfh3jpk; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9CEC688874; Mon, 15 Jul 2024 12:08:54 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org 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=linaro.org header.i=@linaro.org header.b="Cjfh3jpk"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E4DE488859; Mon, 15 Jul 2024 12:08:52 +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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) (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 B85B988883 for ; Mon, 15 Jul 2024 12:08:50 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=caleb.connolly@linaro.org Received: by mail-ej1-x62e.google.com with SMTP id a640c23a62f3a-a77e392f59fso488147366b.1 for ; Mon, 15 Jul 2024 03:08:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721038130; x=1721642930; darn=lists.denx.de; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=N9IT/zALEh7mKodPKHns820h3aA7IvXfqWmQ85Fiq50=; b=Cjfh3jpkxDUXV/i8UYQpOfe3s8YpB+SswhKiqb5qhvxOcZLf9QnbdrMgGm9gITRkio H2sAMs5L/Y4FCCm5BM288ga0BQDbJXbY9LfV2iqPKF4tJcUd7YizGt7tgtG4J7RtJ88G p811Xw1h1OMACJt0SXcnqLj4i5tSihbE1LgEoRqFHlXO3U+1fFupx9PYAoMzNDq38OpH 2WIJ+CxKmn2E2N7lDO8G+j8mrz950EbehSYXWZ/tEmrLBCMIHHVgimlDdN0q7z7Lpw+K FyyB5b33rc56Jm/HMFXqsA3+/1+iIpCvNeRU6SvR45FjbNVPEzfhoj8tYUnZHmeMUtNJ 7blw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721038130; x=1721642930; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=N9IT/zALEh7mKodPKHns820h3aA7IvXfqWmQ85Fiq50=; b=rxef7+p3tiuxv12sj0tZwLGCiD96QVrsBMeChaadNRPXLhwCEBq+cr9m2ORqilIv/g 2JtD3ukHh96HljgxVNNZKpBBrEpgPhnKw8EYfTJKLdFX3ETCoGCYfPdTXCV3wMFmiZO8 q0nz63Yhd3ma7QENCaVKcxnMNU1GIovA0SliygMGnma7/8a4HQ+wpdPqqtdkDTQ9TS75 BsEXT+JWQLVuSzHD/skMJTk4RDdlaw+zdEVvMJHzfdejqgRMdR9UstrZGzWMVlmUGnaz LGynd+cztKXEf0Lbx6JDi6Umot0h2j8elXB8ceN5GFOqvzgdsY98hNlANp75YTUK7lEH mXLw== X-Gm-Message-State: AOJu0YwnwmB32QiYypDTLzUTzkc4ZQpAVJb8mNOExeSwloB3t12UHEjW 4fODLeKZVzqyG2+D83f3UJw6nnEwtWx0kvrhbImWvxYmbSM1aOzs92/zM2SIJsc= X-Received: by 2002:a17:907:6d0c:b0:a72:450f:6045 with SMTP id a640c23a62f3a-a780b6b1e47mr1419147966b.21.1721038130298; Mon, 15 Jul 2024 03:08:50 -0700 (PDT) Received: from [192.168.0.113] ([2a02:8109:aa0d:be00::7424]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a79bc5b7eb4sm198102266b.60.2024.07.15.03.08.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 03:08:49 -0700 (PDT) From: Caleb Connolly Date: Mon, 15 Jul 2024 12:08:17 +0200 Subject: [PATCH v6 18/24] power: regulator: qcom-rpmh-regulator: port over lineage_range helpers MIME-Version: 1.0 Message-Id: <20240715-b4-qcom-rpmh-v6-18-0c948a25d018@linaro.org> References: <20240715-b4-qcom-rpmh-v6-0-0c948a25d018@linaro.org> In-Reply-To: <20240715-b4-qcom-rpmh-v6-0-0c948a25d018@linaro.org> To: Tom Rini , Caleb Connolly , Neil Armstrong , Sumit Garg , Jaehoon Chung , Simon Glass Cc: u-boot@lists.denx.de, u-boot-qcom@groups.io X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2125; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=T2PdM3mGDz1+DKxROesAPumWj6fK3RvayA6EpoqfUCo=; b=owEBbQKS/ZANAwAIAQWDMSsZX2S2AcsmYgBmlPUHRKgneCu/8lejQZ/QZlLhjeC1Z+QNGsqOh tn9AsRPJyCJAjMEAAEIAB0WIQS2UaFGPGq+0GkMVc0FgzErGV9ktgUCZpT1BwAKCRAFgzErGV9k ti0ID/972vxpjKjO1yCV6UdmAVExyR0Wjj/ImR5e3m9QtJDam9MRQnsIBxPFgy7h3eNauPWSsj+ ylOGVafgnVZFDsiNzFvKDyMjichV8jn8b5/pyH9vsQbrBq897PAX43UOA17wMLAts0paJaTV3qA V2Df8NpmoHH81AxVU+7sg6M1MwLDysnpnKXJ1zTxHBgF3PfyMdYrmGnguaplzg9DDnkl57xCMYG 5z6XZ2UOrfCeF0npn/qZAi7PowXb1Rb0CVu6QC12EcPymq+4P7455ftMj+g9FUw57WUh89yFrz5 E1c7B5j6OjpCi9Jhzq4HisxuHvhtKTBXWKWSc5TE3CzrqqPssbBX+YbVEaYQS51rT2t+jezDtKb OieODFMm4iUSCu2g+Id37qEA6c08Om5awybtpAndZ1E2AXzI7XMAzvkBSJ6ND7YPnXX6FnsdLVB AtYbBnbTaCPBp1cSVmkv2Eqf5+wK0K4MByjuiA7uk9sipZWK/VIdYmPkFj4TO0oRxnuA0mq0RoL TjAXrt+1GO0pYrfSAsbU0sasvqIINtLHroYVCqL8dEMVJdjyWulKZO2Nkp0co2CdvSknvu3eE/P CmoX3ymftwnppcry8ZdeRPzKMMFeC/bvHoBgO8v+W5tmnBCJwtHpH5FMjLgacAcZxzCrKJFylDI T4RIWZt8O15ngig== X-Developer-Key: i=caleb.connolly@linaro.org; a=openpgp; fpr=83B24DA7FE145076BC38BB250CD904EB673A7C47 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.8 at phobos.denx.de X-Virus-Status: Clean Import struct linear_range() and builder macro from Linux regulator core. Acked-by: Sumit Garg Signed-off-by: Caleb Connolly --- drivers/power/regulator/qcom-rpmh-regulator.c | 37 +++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/drivers/power/regulator/qcom-rpmh-regulator.c b/drivers/power/regulator/qcom-rpmh-regulator.c index 5f522de44734..d0acee9f558e 100644 --- a/drivers/power/regulator/qcom-rpmh-regulator.c +++ b/drivers/power/regulator/qcom-rpmh-regulator.c @@ -28,8 +28,15 @@ enum rpmh_regulator_type { VRM, XOB, }; +enum rpmh_regulator_mode { + REGULATOR_MODE_RETENTION, + REGULATOR_MODE_LPM, + REGULATOR_MODE_AUTO, + REGULATOR_MODE_HPM, +}; + #define RPMH_REGULATOR_REG_VRM_VOLTAGE 0x0 #define RPMH_REGULATOR_REG_ENABLE 0x4 #define RPMH_REGULATOR_REG_VRM_MODE 0x8 @@ -60,8 +67,38 @@ enum rpmh_regulator_type { #define PMIC5_BOB_MODE_PFM 4 #define PMIC5_BOB_MODE_AUTO 6 #define PMIC5_BOB_MODE_PWM 7 + +/** + * struct linear_range - table of selector - value pairs + * + * Define a lookup-table for range of values. Intended to help when looking + * for a register value matching certaing physical measure (like voltage). + * Usable when increment of one in register always results a constant increment + * of the physical measure (like voltage). + * + * @min: Lowest value in range + * @min_sel: Lowest selector for range + * @max_sel: Highest selector for range + * @step: Value step size + */ +struct linear_range { + unsigned int min; + unsigned int min_sel; + unsigned int max_sel; + unsigned int step; +}; + +/* Initialize struct linear_range for regulators */ +#define REGULATOR_LINEAR_RANGE(_min_uV, _min_sel, _max_sel, _step_uV) \ +{ \ + .min = _min_uV, \ + .min_sel = _min_sel, \ + .max_sel = _max_sel, \ + .step = _step_uV, \ +} + /** * struct rpmh_vreg_hw_data - RPMh regulator hardware configurations * @regulator_type: RPMh accelerator type used to manage this * regulator From patchwork Mon Jul 15 10:08:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 812618 Delivered-To: patch@linaro.org Received: by 2002:adf:fac3:0:b0:367:895a:4699 with SMTP id a3csp1724954wrs; Mon, 15 Jul 2024 03:11:27 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVfBELG6aKSUK33ucOmYFgMx7DE50yzItoMqC45mzCqz1U5pF0k4nLBQ8juHLuYEfWPzXvL3sT7F0HaYoRUqXrc X-Google-Smtp-Source: AGHT+IFgczZFwR7eZ1IbrnE/3SRek7Gyfu9LA5hBil9RNh0zAfq76cu69ROWJ6eRkfn+mSuf/gIT X-Received: by 2002:a17:907:e90:b0:a77:e55a:9e77 with SMTP id a640c23a62f3a-a780b68aa02mr1495437966b.7.1721038286782; Mon, 15 Jul 2024 03:11:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721038286; cv=none; d=google.com; s=arc-20160816; b=WlUKu2e9cVT8xWY5ljNgMF1ZloHXlXkK6OzYTc7TnoxjF6futsmNCzY2g6bU4ndqKL LrOKiksHn5OLp7oQanZW9RF+FrB0poDU//4/5WVUuyKMOFadU8KrJnQJtR6nE/zNLG5H YPwwZk5A7Fi/0SHuy7kr9WODzJzO9M72msRKohLIrUfVeO6j0kv+meUMd/zeX+B5uAfF xUPe394LAuqPr7MC9aPc6EXKx7rTtH/cdn4+I4Ld9ys6KUmot/4KsO7MhTe47EJLGvWl wLpqYCErxFLs/B0fIrm+3VZMwF9ZFgPssd5CQAxGB0eDEi/tspTw1YvTUrxSZyvJKAzN mUlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:cc:to:in-reply-to:references :message-id:content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=GRz+XTlCpnsYYi0KK9pzBnfO6FEF2vig2L6TEuG8pO8=; fh=zcTfjI3NycJyTuuOJ9uzXxS7wfOr4sYKS7eKveHEFzw=; b=rcIBKIvuV5YJoTZx7TuIqAL3uMxBjYCnOcC0Pia4pukykk/mc3V1SixIrkOPRkvdeJ eDriQjKYZ4fAHcep+UT6e18Yst9A7jTjXKMcjZy1U/DiCoTSIq7gOLkArro2RN+6h0vI U8uylmcbguhwG0h9TP3tN7F4kfr1IMn9RmH3X32T0KRkccJRXS0PfGNT53fglYi6r9N6 jK2XXvJ6QFgf1TFn8Zgp8hWKcfjbGZ6NFygJml9NMlFKSDcgjjzkJOMk88TYTIt+Q3LI cOcVbE/UeAX8simUinYt4/8a3Zv5toxnoGqdVUWKcyU4xp/tSsNSp5vAjz8L95yILsjZ x5/Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lxHYyaxW; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id a640c23a62f3a-a79bc58c39dsi223508266b.18.2024.07.15.03.11.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 03:11:26 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lxHYyaxW; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 073E188820; Mon, 15 Jul 2024 12:08:56 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org 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=linaro.org header.i=@linaro.org header.b="lxHYyaxW"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B00D988867; Mon, 15 Jul 2024 12:08:53 +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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) (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 B671288840 for ; Mon, 15 Jul 2024 12:08:51 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=caleb.connolly@linaro.org Received: by mail-ed1-x52e.google.com with SMTP id 4fb4d7f45d1cf-595712c49ebso4926581a12.0 for ; Mon, 15 Jul 2024 03:08:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721038131; x=1721642931; darn=lists.denx.de; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=GRz+XTlCpnsYYi0KK9pzBnfO6FEF2vig2L6TEuG8pO8=; b=lxHYyaxWZJ8vFsE33K1LSq2BxRUlUpETRxkFNB7t/LjuTWCeorGSZT6JRruqLXLF+O T1zU6VhiKJHGJJLcDwD+JwiMeQWthV3YN38KxmAI3MRJK31iBW1+GwCPtIpIW/xyccGh nayXj7SiErS4+UMbas1FwWQsFcqGHaH4JQlInnc1ovI6k+0V0rVGrvwAYVDZ1NHIa6ms IrNDwCuGpXxz04hiRaFhsY6zfoZfrESOv9XTQMAyviFOMFnICqyPTczLmQ1OhX4FbMMG 8oEeri/l6VtcloAyVMwTyB4e0fPZxFs/NANmDgl/0W6q2C0uX8pDJ5JVWjwQ0zgRKR3R UzMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721038131; x=1721642931; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GRz+XTlCpnsYYi0KK9pzBnfO6FEF2vig2L6TEuG8pO8=; b=vIyOebwf9cZIGDWIHb+JFT89odXb2ZHGCnKLUhtGJU3siNQBtr2YWwqJNlGfk/X+HT Gg4i9MjEkcb7aLEqfSZkPIiAm9tcu7p8g6tGf4cKrWyztABFVWWgeNhHBBLQtZ8Aey4u AFXj+RmkEiezzBghyb+53c6bo60cTvfVaFcEi+iYlLY9AuirFtDRnJLstFlPwaaUOXhO i79EK8tADOFBVrkQx2PFr8u3L6DLCZHL578m1fOwXKbhMATZHY0rSd/kxFufw2TmVZGB ts7GP7Kd9cPw+y8qpusO4OEnZZkQEO+6otDCavALCnPmQzEBSEa/u/oeCMvwOFqN/Een hG3g== X-Gm-Message-State: AOJu0Yzg667y0A2IkRYv5rnBIzU2X25kkDnmDxXzzZFbJVO1rg8mEDXY 3s5Wtk/HIjFreZ9hrH3YRpHsAtTODiYScZeGaf8yJv0X5AVTn1bYsenv0mCXULxKEg6vjLVS4bP 0lsM= X-Received: by 2002:a17:907:2d2c:b0:a77:dc70:b35f with SMTP id a640c23a62f3a-a780b883d8amr1588066966b.58.1721038131293; Mon, 15 Jul 2024 03:08:51 -0700 (PDT) Received: from [192.168.0.113] ([2a02:8109:aa0d:be00::7424]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a79bc5b7eb4sm198102266b.60.2024.07.15.03.08.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 03:08:50 -0700 (PDT) From: Caleb Connolly Date: Mon, 15 Jul 2024 12:08:18 +0200 Subject: [PATCH v6 19/24] power: regulator: qcom-rpmh-regulator: adjust structs for U-Boot MIME-Version: 1.0 Message-Id: <20240715-b4-qcom-rpmh-v6-19-0c948a25d018@linaro.org> References: <20240715-b4-qcom-rpmh-v6-0-0c948a25d018@linaro.org> In-Reply-To: <20240715-b4-qcom-rpmh-v6-0-0c948a25d018@linaro.org> To: Tom Rini , Caleb Connolly , Neil Armstrong , Sumit Garg , Jaehoon Chung , Simon Glass Cc: u-boot@lists.denx.de, u-boot-qcom@groups.io X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=3076; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=U6yGComMBKaDzfG1OpRVhDZGEEuD6iB3cAcmWsZo69M=; b=owEBbQKS/ZANAwAIAQWDMSsZX2S2AcsmYgBmlPUHPp/DLeYKNG/EoHourpkS4Q7DVbyVpp+Ah 0fztWFUtMKJAjMEAAEIAB0WIQS2UaFGPGq+0GkMVc0FgzErGV9ktgUCZpT1BwAKCRAFgzErGV9k toOzD/44/Nckpaeq/xvcbZeq5n2eoXt+Sb7fwuJHkyIuq2R1THFP9S2lR0Z1hPEPS59JGzrDyGh edFsqVIoHwUg497twRg+Oafpz5LEiRSbEc+GOmb4ozAR8qkWgj+PYeJFT5wT5mUgv0554Yd0yPa HLKCTWa9PVrypKPWk0YQBPU/DrKZ14sRBAr3+DisMJ7+K3axfQwSpMtncfYbHznovK0AvIiQ7sy X3GYmR8//4OST9vyjf/e/Su+vedvruhmnG+OQ6fqBXAMu0jZDfrmIi378AiiLExIG+MLR+2e0tw k4DHyeZdfhegYgn0Pun+BeqWtP9EMgRkkL2PUTFv2aBfN+I5WqRIiKa3er8iPscP+8bM/Ppj+2C 3/vHBntDaM0PEFzxoLygW6XVNKffCwVOAlBnlxa8XO21gz7D+fRwWebN8zW25P1z+gZkhMB6gvt kfIg9beWvmxoa5QYSQTCrGuyVUkl705vredE7jqBuUmxcUA7Scd50gtlrvUlAP8fckrUmoBECBa /jqjJbYNw8KgrU/1OAI+vCC+GryQJkXm69jkWnpnKblcOZyiwTUubcBLnnmRL8G8rAY3kvThegS C2PM+K/nsXHMjMLznSa39g0bkEM1AJFXF01Zk1kG2cOQUsgQTDg3SVlmRCU35l5OMLYA+f+I8xm 75b0uJcYk//UJWQ== X-Developer-Key: i=caleb.connolly@linaro.org; a=openpgp; fpr=83B24DA7FE145076BC38BB250CD904EB673A7C47 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.8 at phobos.denx.de X-Virus-Status: Clean Switch to our linear_range helpers and remove unused/unsupported linux-isms. Acked-by: Sumit Garg Signed-off-by: Caleb Connolly --- drivers/power/regulator/qcom-rpmh-regulator.c | 28 +++++++++++++-------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/drivers/power/regulator/qcom-rpmh-regulator.c b/drivers/power/regulator/qcom-rpmh-regulator.c index d0acee9f558e..089623f3a2b9 100644 --- a/drivers/power/regulator/qcom-rpmh-regulator.c +++ b/drivers/power/regulator/qcom-rpmh-regulator.c @@ -102,13 +102,12 @@ struct linear_range { * struct rpmh_vreg_hw_data - RPMh regulator hardware configurations * @regulator_type: RPMh accelerator type used to manage this * regulator * @ops: Pointer to regulator ops callback structure - * @voltage_ranges: The possible ranges of voltages supported by this - * PMIC regulator type - * @n_linear_ranges: Number of entries in voltage_ranges + * @voltage_range: The single range of voltages supported by this + * PMIC regulator type * @n_voltages: The number of unique voltage set points defined - * by voltage_ranges + * by voltage_range * @hpm_min_load_uA: Minimum load current in microamps that requires * high power mode (HPM) operation. This is used * for LDO hardware type regulators only. * @pmic_mode_map: Array indexed by regulator framework mode @@ -119,15 +118,15 @@ struct linear_range { * in device tree to a regulator framework mode */ struct rpmh_vreg_hw_data { enum rpmh_regulator_type regulator_type; - const struct regulator_ops *ops; - const struct linear_range *voltage_ranges; - int n_linear_ranges; + const struct dm_regulator_ops *ops; + struct linear_range voltage_range; int n_voltages; int hpm_min_load_uA; - const int *pmic_mode_map; - unsigned int (*of_map_mode)(unsigned int mode); + struct dm_regulator_mode *pmic_mode_map; + int n_modes; + unsigned int (*of_map_mode)(unsigned int mode); }; /** * struct rpmh_vreg - individual RPMh regulator data structure encapsulating a @@ -148,23 +147,22 @@ struct rpmh_vreg_hw_data { * not * @bypassed: Boolean indicating if the regulator is in * bypass (pass-through) mode or not. This is * only used by BOB rpmh-regulator resources. - * @voltage_selector: Selector used for get_voltage_sel() and - * set_voltage_sel() callbacks + * @uv: Selector used for get_voltage_sel() and + * set_value() callbacks * @mode: RPMh VRM regulator current framework mode */ struct rpmh_vreg { - struct device *dev; + struct udevice *dev; u32 addr; - struct regulator_desc rdesc; const struct rpmh_vreg_hw_data *hw_data; bool always_wait_for_ack; int enabled; bool bypassed; - int voltage_selector; - unsigned int mode; + int uv; + int mode; }; /** * struct rpmh_vreg_init_data - initialization data for an RPMh regulator From patchwork Mon Jul 15 10:08:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 812621 Delivered-To: patch@linaro.org Received: by 2002:adf:fac3:0:b0:367:895a:4699 with SMTP id a3csp1725138wrs; Mon, 15 Jul 2024 03:12:00 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXmRCw/DevL1XmKd1rUPOCG4/tRf8iiaNFdHBAqEKYOVNGU2i4cI5NdOxr/F708TJ+cSfxCyHirbs0qOdC+MvUt X-Google-Smtp-Source: AGHT+IEwVvvRsPNN4RAiZGtdnRMKr4vD9xoOW+1tlJdpt+gbEf7FCCe8LQ7ziFgNLtnc00lonDXG X-Received: by 2002:aa7:ce1a:0:b0:57c:5f77:1136 with SMTP id 4fb4d7f45d1cf-594bb7745f7mr14889686a12.24.1721038320563; Mon, 15 Jul 2024 03:12:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721038320; cv=none; d=google.com; s=arc-20160816; b=yYDbJWK3lQxNPFiWCP3v2Fmfm7U5nEB+jxzelqUT26nYeTMTmo2VLYeGvcTQMlWD2A KKhyhlVNcK1qH+pNJzaIchZrdaj+pQXJcjGTLZeotEXnRRVmSvQBbbmUPxxhtNd2h9nl LYuMeu61KS6UVfK89hauFBCR3iHPGG9TlB1z0DxqV+jCHDLUD6bmzgQzMqswOzTJzg0F TMs3YtD2sBAW6MMrY0JyVq1+Qmb6InvsLPg0LSh4qss3mD3vKRM6i0b2AT6GOo6GJLLH Geo6FWoGIhz1LedGlc467xqp1Deuw0ebpYyO20QzFJ4E0sEDxy0nU87q/JFoY0XpuLq8 5ymQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:cc:to:in-reply-to:references :message-id:content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=ofdKYirthuegY9qkvWeyoLHb60MJ4R3ImJ1DqFs1kEM=; fh=zcTfjI3NycJyTuuOJ9uzXxS7wfOr4sYKS7eKveHEFzw=; b=pWfwUsap2+dFQpC39L83YP44m2J2l0itokFOBUYzFeUADUOwX8KkcEb1aD+RWaECQP elH2A1IKimp34QAWsp6LWGN5nMCR/iieM1KbfwOC6tTGjwUV4Ss1Nl7RyHHOjd+LrWNI MGHiVj1u+/nrbFtW+VO/iqja9m0R93DJW/T6XKm2slIv4HllHDwYaIO3V+lboncgL7pc 4+5N+noJoNjUiICARY8oiiw8lLTTtZf7mcUw3F5VWAQGx815TYwSlbNKJ9PExWZg5zvx W9iTkexyBo+F0NZdOjin7rHn1/S33fWePG1E6NfHOPSOdZJZV1ncrqnTAZMxwIuba5AW jJ8Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=c+wQfzEc; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-59b26a8da49si2325882a12.206.2024.07.15.03.11.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 03:12:00 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=c+wQfzEc; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2A2DE88863; Mon, 15 Jul 2024 12:09:00 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org 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=linaro.org header.i=@linaro.org header.b="c+wQfzEc"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id EAE9488894; Mon, 15 Jul 2024 12:08:56 +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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) (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 A36E988863 for ; Mon, 15 Jul 2024 12:08:53 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=caleb.connolly@linaro.org Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-52ea929ea56so7562207e87.0 for ; Mon, 15 Jul 2024 03:08:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721038133; x=1721642933; darn=lists.denx.de; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=ofdKYirthuegY9qkvWeyoLHb60MJ4R3ImJ1DqFs1kEM=; b=c+wQfzEclc8gm1wa3IegG7/w7euLIQIABKPG31IZ8X60SjMJMKJTRDmc309lX5lvVS xaI9nHMk8EjChdIqTrG6StdtJpsLu7kvTjvQrDPDAF5vfC66K26ARKM5u0jE0pYPM0cR ELKGy0s3VWNUJhiOQjANlKanD7f26SXDWarHB4C4pzkNpDUEGGuqi5W4oTBD8Spi+chv 80KKgnVRld3rix/HuYl2l+IVQNkYHou8QsCcVWdVAqYO2gbuu2Ys0n9YOlfFr+W7rvyZ 37v4MIXIjAcdFThNQ290eEwHZx5+n1JjiAj/Bz82WZ+4fVYA6T+OPW7a9PO6QI4lsHu5 mkOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721038133; x=1721642933; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ofdKYirthuegY9qkvWeyoLHb60MJ4R3ImJ1DqFs1kEM=; b=SvNBvooAo5gcncoTXQCVC8vaTxNJJqbz8+20hMWWa/wo4SH2kJ9//d0As2yXbaFgDa Z9cfxc9FL3kGQmFiVNiIt9qsjons5QcX8Upq/VjSWyr+nj+RhdnzhzptZ5uXURiFlBGI RoaMtLAbAatEWzhoMrQqx+CIj4yZs0YgxxyFCqoHUGJy1VIfn4VIV4FQD0CyqWcTDbhp Ua8NfrpBetV6lzDpO6umNwl5cOQ5SqIg01rhTGIQzHqEi0VepQVvhioT49m8tvtnZxpR FlODLml53LLNE/kLZZhXYNZlLYZYqhBCDPM/bQEaHZoyBXI46hwGRcZZyWdZnxLDGPVE o+UQ== X-Gm-Message-State: AOJu0Yxn6gkeRsFO7eO3t2Aio8NRVwVJdQeDE7OmvjI1DLgoqK9F5S5G gOZEsFV8Lb3wWM/Wim4StFjm3wNjV+S0gOzH0Fx/5WLckrnJpT0fQd5qlLKDWd0= X-Received: by 2002:a05:6512:3e22:b0:52e:9808:3f48 with SMTP id 2adb3069b0e04-52eb999c2f2mr16225518e87.21.1721038132594; Mon, 15 Jul 2024 03:08:52 -0700 (PDT) Received: from [192.168.0.113] ([2a02:8109:aa0d:be00::7424]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a79bc5b7eb4sm198102266b.60.2024.07.15.03.08.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 03:08:51 -0700 (PDT) From: Caleb Connolly Date: Mon, 15 Jul 2024 12:08:19 +0200 Subject: [PATCH v6 20/24] power: regulator: qcom-rpmh-regulator: remove unused regulators MIME-Version: 1.0 Message-Id: <20240715-b4-qcom-rpmh-v6-20-0c948a25d018@linaro.org> References: <20240715-b4-qcom-rpmh-v6-0-0c948a25d018@linaro.org> In-Reply-To: <20240715-b4-qcom-rpmh-v6-0-0c948a25d018@linaro.org> To: Tom Rini , Caleb Connolly , Neil Armstrong , Sumit Garg , Jaehoon Chung , Simon Glass Cc: u-boot@lists.denx.de, u-boot-qcom@groups.io X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=58163; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=XhzOyUuKpsEPoKbYoHeEFsJciR8wlCTaWqzBbDXW5Jc=; b=owEBbQKS/ZANAwAIAQWDMSsZX2S2AcsmYgBmlPUH34T8JQOHaoGsYhKkG5ukCJcjoNAQNcsZS qVE8HQBrV+JAjMEAAEIAB0WIQS2UaFGPGq+0GkMVc0FgzErGV9ktgUCZpT1BwAKCRAFgzErGV9k tgXPEACUXA2B7wcUracp9OzOpMuw5prA1DU+TrHqZoFaDVKXsvGqHIASwpFIc1Exe02KY4f2ci3 kWgNMddbo5YgsAUlLrfUiXgqHVzKIII/vo6Xw+uG2523iA7qhiQPE2lzzI9juGUv5AqGmQgBf7m hel37hChbjjqBKxHbPC7IzKQuhx/lTFMLgvb3Y592Glh0XYFV3KORVJbp/Zk00uiI/BEjsCxWtE QRRCtRxij5i2j6RTh3ERVfkkYtcZZgO88YisDacH722+3sOMHOkJUbztBdLDx81zXsM/nIeFtMA VpyArD4X8wTGjTD8E9cCKlR+nBsj0ld9lqb+0pxUZBkZI291zIZe0TsyWououQNbJKA59HloxBD LgJCCi6gGDvRpzmpISRdfS7/43Tb8ZVlk7tX+sOVt5GaVma4srVB4J7Mea3TwMRGSs3Jvd+tQ26 G5D1C+W/oYQzW/zV6tMr0cMBLXGHiAhVMUMR3MIqXGR15l6VdcRgRaBHarwWSJRbNnpr+dFvusH swlobuLpedw6O7n2dJ4B8fJsTnTHvmeFet1i8XK7Rliw8SQjfCAVos/7RX6zMxEq/ISolCPCOk+ AfscV6W59qek3sVSGPFlUaf5wz2HBlg4NU1HAUTmpCLCxDcEKSxi+picyI+4bclQc7aUeUhnwuh QDSI2w3WrSV7Qzw== X-Developer-Key: i=caleb.connolly@linaro.org; a=openpgp; fpr=83B24DA7FE145076BC38BB250CD904EB673A7C47 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.8 at phobos.denx.de X-Virus-Status: Clean Initially just include the few regulators needed for the RB5 board. Others can be added back as-needed. Acked-by: Sumit Garg Signed-off-by: Caleb Connolly --- drivers/power/regulator/qcom-rpmh-regulator.c | 1281 ------------------------- 1 file changed, 1281 deletions(-) diff --git a/drivers/power/regulator/qcom-rpmh-regulator.c b/drivers/power/regulator/qcom-rpmh-regulator.c index 089623f3a2b9..2a8e8f9ac444 100644 --- a/drivers/power/regulator/qcom-rpmh-regulator.c +++ b/drivers/power/regulator/qcom-rpmh-regulator.c @@ -338,68 +338,8 @@ static unsigned int rpmh_regulator_vrm_get_mode(struct regulator_dev *rdev) return vreg->mode; } -/** - * rpmh_regulator_vrm_get_optimum_mode() - get the mode based on the load - * @rdev: Regulator device pointer for the rpmh-regulator - * @input_uV: Input voltage - * @output_uV: Output voltage - * @load_uA: Aggregated load current in microamps - * - * This function is used in the regulator_ops for VRM type RPMh regulator - * devices. - * - * Return: 0 on success, errno on failure - */ -static unsigned int rpmh_regulator_vrm_get_optimum_mode( - struct regulator_dev *rdev, int input_uV, int output_uV, int load_uA) -{ - struct rpmh_vreg *vreg = rdev_get_drvdata(rdev); - - if (load_uA >= vreg->hw_data->hpm_min_load_uA) - return REGULATOR_MODE_NORMAL; - else - return REGULATOR_MODE_IDLE; -} - -static int rpmh_regulator_vrm_set_bypass(struct regulator_dev *rdev, - bool enable) -{ - struct rpmh_vreg *vreg = rdev_get_drvdata(rdev); - int ret; - - if (vreg->bypassed == enable) - return 0; - - ret = rpmh_regulator_vrm_set_mode_bypass(vreg, vreg->mode, enable); - if (!ret) - vreg->bypassed = enable; - - return ret; -} - -static int rpmh_regulator_vrm_get_bypass(struct regulator_dev *rdev, - bool *enable) -{ - struct rpmh_vreg *vreg = rdev_get_drvdata(rdev); - - *enable = vreg->bypassed; - - return 0; -} - -static const struct regulator_ops rpmh_regulator_vrm_ops = { - .enable = rpmh_regulator_enable, - .disable = rpmh_regulator_disable, - .is_enabled = rpmh_regulator_is_enabled, - .set_voltage_sel = rpmh_regulator_vrm_set_voltage_sel, - .get_voltage_sel = rpmh_regulator_vrm_get_voltage_sel, - .list_voltage = regulator_list_voltage_linear_range, - .set_mode = rpmh_regulator_vrm_set_mode, - .get_mode = rpmh_regulator_vrm_get_mode, -}; - static const struct regulator_ops rpmh_regulator_vrm_drms_ops = { .enable = rpmh_regulator_enable, .disable = rpmh_regulator_disable, .is_enabled = rpmh_regulator_is_enabled, @@ -410,331 +350,8 @@ static const struct regulator_ops rpmh_regulator_vrm_drms_ops = { .get_mode = rpmh_regulator_vrm_get_mode, .get_optimum_mode = rpmh_regulator_vrm_get_optimum_mode, }; -static const struct regulator_ops rpmh_regulator_vrm_bypass_ops = { - .enable = rpmh_regulator_enable, - .disable = rpmh_regulator_disable, - .is_enabled = rpmh_regulator_is_enabled, - .set_voltage_sel = rpmh_regulator_vrm_set_voltage_sel, - .get_voltage_sel = rpmh_regulator_vrm_get_voltage_sel, - .list_voltage = regulator_list_voltage_linear_range, - .set_mode = rpmh_regulator_vrm_set_mode, - .get_mode = rpmh_regulator_vrm_get_mode, - .set_bypass = rpmh_regulator_vrm_set_bypass, - .get_bypass = rpmh_regulator_vrm_get_bypass, -}; - -static const struct regulator_ops rpmh_regulator_xob_ops = { - .enable = rpmh_regulator_enable, - .disable = rpmh_regulator_disable, - .is_enabled = rpmh_regulator_is_enabled, -}; - -/** - * rpmh_regulator_init_vreg() - initialize all attributes of an rpmh-regulator - * @vreg: Pointer to the individual rpmh-regulator resource - * @dev: Pointer to the top level rpmh-regulator PMIC device - * @node: Pointer to the individual rpmh-regulator resource - * device node - * @pmic_id: String used to identify the top level rpmh-regulator - * PMIC device on the board - * @pmic_rpmh_data: Pointer to a null-terminated array of rpmh-regulator - * resources defined for the top level PMIC device - * - * Return: 0 on success, errno on failure - */ -static int rpmh_regulator_init_vreg(struct rpmh_vreg *vreg, struct device *dev, - struct device_node *node, const char *pmic_id, - const struct rpmh_vreg_init_data *pmic_rpmh_data) -{ - struct regulator_config reg_config = {}; - char rpmh_resource_name[20] = ""; - const struct rpmh_vreg_init_data *rpmh_data; - struct regulator_init_data *init_data; - struct regulator_dev *rdev; - int ret; - - vreg->dev = dev; - - for (rpmh_data = pmic_rpmh_data; rpmh_data->name; rpmh_data++) - if (of_node_name_eq(node, rpmh_data->name)) - break; - - if (!rpmh_data->name) { - dev_err(dev, "Unknown regulator %pOFn\n", node); - return -EINVAL; - } - - scnprintf(rpmh_resource_name, sizeof(rpmh_resource_name), - rpmh_data->resource_name, pmic_id); - - vreg->addr = cmd_db_read_addr(rpmh_resource_name); - if (!vreg->addr) { - dev_err(dev, "%pOFn: could not find RPMh address for resource %s\n", - node, rpmh_resource_name); - return -ENODEV; - } - - vreg->rdesc.name = rpmh_data->name; - vreg->rdesc.supply_name = rpmh_data->supply_name; - vreg->hw_data = rpmh_data->hw_data; - - vreg->enabled = -EINVAL; - vreg->voltage_selector = -ENOTRECOVERABLE; - vreg->mode = REGULATOR_MODE_INVALID; - - if (rpmh_data->hw_data->n_voltages) { - vreg->rdesc.linear_ranges = rpmh_data->hw_data->voltage_ranges; - vreg->rdesc.n_linear_ranges = rpmh_data->hw_data->n_linear_ranges; - vreg->rdesc.n_voltages = rpmh_data->hw_data->n_voltages; - } - - vreg->always_wait_for_ack = of_property_read_bool(node, - "qcom,always-wait-for-ack"); - - vreg->rdesc.owner = THIS_MODULE; - vreg->rdesc.type = REGULATOR_VOLTAGE; - vreg->rdesc.ops = vreg->hw_data->ops; - vreg->rdesc.of_map_mode = vreg->hw_data->of_map_mode; - - init_data = of_get_regulator_init_data(dev, node, &vreg->rdesc); - if (!init_data) - return -ENOMEM; - - if (rpmh_data->hw_data->regulator_type == XOB && - init_data->constraints.min_uV && - init_data->constraints.min_uV == init_data->constraints.max_uV) { - vreg->rdesc.fixed_uV = init_data->constraints.min_uV; - vreg->rdesc.n_voltages = 1; - } - - reg_config.dev = dev; - reg_config.init_data = init_data; - reg_config.of_node = node; - reg_config.driver_data = vreg; - - rdev = devm_regulator_register(dev, &vreg->rdesc, ®_config); - if (IS_ERR(rdev)) { - ret = PTR_ERR(rdev); - dev_err(dev, "%pOFn: devm_regulator_register() failed, ret=%d\n", - node, ret); - return ret; - } - - dev_dbg(dev, "%pOFn regulator registered for RPMh resource %s @ 0x%05X\n", - node, rpmh_resource_name, vreg->addr); - - return 0; -} - -static const int pmic_mode_map_pmic4_ldo[REGULATOR_MODE_STANDBY + 1] = { - [REGULATOR_MODE_INVALID] = -EINVAL, - [REGULATOR_MODE_STANDBY] = PMIC4_LDO_MODE_RETENTION, - [REGULATOR_MODE_IDLE] = PMIC4_LDO_MODE_LPM, - [REGULATOR_MODE_NORMAL] = PMIC4_LDO_MODE_HPM, - [REGULATOR_MODE_FAST] = -EINVAL, -}; - -static const int pmic_mode_map_pmic5_ldo[REGULATOR_MODE_STANDBY + 1] = { - [REGULATOR_MODE_INVALID] = -EINVAL, - [REGULATOR_MODE_STANDBY] = PMIC5_LDO_MODE_RETENTION, - [REGULATOR_MODE_IDLE] = PMIC5_LDO_MODE_LPM, - [REGULATOR_MODE_NORMAL] = PMIC5_LDO_MODE_HPM, - [REGULATOR_MODE_FAST] = -EINVAL, -}; - -static const int pmic_mode_map_pmic5_ldo_hpm[REGULATOR_MODE_STANDBY + 1] = { - [REGULATOR_MODE_INVALID] = -EINVAL, - [REGULATOR_MODE_STANDBY] = -EINVAL, - [REGULATOR_MODE_IDLE] = -EINVAL, - [REGULATOR_MODE_NORMAL] = PMIC5_LDO_MODE_HPM, - [REGULATOR_MODE_FAST] = -EINVAL, -}; - -static unsigned int rpmh_regulator_pmic4_ldo_of_map_mode(unsigned int rpmh_mode) -{ - unsigned int mode; - - switch (rpmh_mode) { - case RPMH_REGULATOR_MODE_HPM: - mode = REGULATOR_MODE_NORMAL; - break; - case RPMH_REGULATOR_MODE_LPM: - mode = REGULATOR_MODE_IDLE; - break; - case RPMH_REGULATOR_MODE_RET: - mode = REGULATOR_MODE_STANDBY; - break; - default: - mode = REGULATOR_MODE_INVALID; - break; - } - - return mode; -} - -static const int pmic_mode_map_pmic4_smps[REGULATOR_MODE_STANDBY + 1] = { - [REGULATOR_MODE_INVALID] = -EINVAL, - [REGULATOR_MODE_STANDBY] = PMIC4_SMPS_MODE_RETENTION, - [REGULATOR_MODE_IDLE] = PMIC4_SMPS_MODE_PFM, - [REGULATOR_MODE_NORMAL] = PMIC4_SMPS_MODE_AUTO, - [REGULATOR_MODE_FAST] = PMIC4_SMPS_MODE_PWM, -}; - -static const int pmic_mode_map_pmic5_smps[REGULATOR_MODE_STANDBY + 1] = { - [REGULATOR_MODE_INVALID] = -EINVAL, - [REGULATOR_MODE_STANDBY] = PMIC5_SMPS_MODE_RETENTION, - [REGULATOR_MODE_IDLE] = PMIC5_SMPS_MODE_PFM, - [REGULATOR_MODE_NORMAL] = PMIC5_SMPS_MODE_AUTO, - [REGULATOR_MODE_FAST] = PMIC5_SMPS_MODE_PWM, -}; - -static unsigned int -rpmh_regulator_pmic4_smps_of_map_mode(unsigned int rpmh_mode) -{ - unsigned int mode; - - switch (rpmh_mode) { - case RPMH_REGULATOR_MODE_HPM: - mode = REGULATOR_MODE_FAST; - break; - case RPMH_REGULATOR_MODE_AUTO: - mode = REGULATOR_MODE_NORMAL; - break; - case RPMH_REGULATOR_MODE_LPM: - mode = REGULATOR_MODE_IDLE; - break; - case RPMH_REGULATOR_MODE_RET: - mode = REGULATOR_MODE_STANDBY; - break; - default: - mode = REGULATOR_MODE_INVALID; - break; - } - - return mode; -} - -static const int pmic_mode_map_pmic4_bob[REGULATOR_MODE_STANDBY + 1] = { - [REGULATOR_MODE_INVALID] = -EINVAL, - [REGULATOR_MODE_STANDBY] = -EINVAL, - [REGULATOR_MODE_IDLE] = PMIC4_BOB_MODE_PFM, - [REGULATOR_MODE_NORMAL] = PMIC4_BOB_MODE_AUTO, - [REGULATOR_MODE_FAST] = PMIC4_BOB_MODE_PWM, -}; - -static const int pmic_mode_map_pmic5_bob[REGULATOR_MODE_STANDBY + 1] = { - [REGULATOR_MODE_INVALID] = -EINVAL, - [REGULATOR_MODE_STANDBY] = -EINVAL, - [REGULATOR_MODE_IDLE] = PMIC5_BOB_MODE_PFM, - [REGULATOR_MODE_NORMAL] = PMIC5_BOB_MODE_AUTO, - [REGULATOR_MODE_FAST] = PMIC5_BOB_MODE_PWM, -}; - -static unsigned int rpmh_regulator_pmic4_bob_of_map_mode(unsigned int rpmh_mode) -{ - unsigned int mode; - - switch (rpmh_mode) { - case RPMH_REGULATOR_MODE_HPM: - mode = REGULATOR_MODE_FAST; - break; - case RPMH_REGULATOR_MODE_AUTO: - mode = REGULATOR_MODE_NORMAL; - break; - case RPMH_REGULATOR_MODE_LPM: - mode = REGULATOR_MODE_IDLE; - break; - default: - mode = REGULATOR_MODE_INVALID; - break; - } - - return mode; -} - -static const struct rpmh_vreg_hw_data pmic4_pldo = { - .regulator_type = VRM, - .ops = &rpmh_regulator_vrm_drms_ops, - .voltage_ranges = (struct linear_range[]) { - REGULATOR_LINEAR_RANGE(1664000, 0, 255, 8000), - }, - .n_linear_ranges = 1, - .n_voltages = 256, - .hpm_min_load_uA = 10000, - .pmic_mode_map = pmic_mode_map_pmic4_ldo, - .of_map_mode = rpmh_regulator_pmic4_ldo_of_map_mode, -}; - -static const struct rpmh_vreg_hw_data pmic4_pldo_lv = { - .regulator_type = VRM, - .ops = &rpmh_regulator_vrm_drms_ops, - .voltage_ranges = (struct linear_range[]) { - REGULATOR_LINEAR_RANGE(1256000, 0, 127, 8000), - }, - .n_linear_ranges = 1, - .n_voltages = 128, - .hpm_min_load_uA = 10000, - .pmic_mode_map = pmic_mode_map_pmic4_ldo, - .of_map_mode = rpmh_regulator_pmic4_ldo_of_map_mode, -}; - -static const struct rpmh_vreg_hw_data pmic4_nldo = { - .regulator_type = VRM, - .ops = &rpmh_regulator_vrm_drms_ops, - .voltage_ranges = (struct linear_range[]) { - REGULATOR_LINEAR_RANGE(312000, 0, 127, 8000), - }, - .n_linear_ranges = 1, - .n_voltages = 128, - .hpm_min_load_uA = 30000, - .pmic_mode_map = pmic_mode_map_pmic4_ldo, - .of_map_mode = rpmh_regulator_pmic4_ldo_of_map_mode, -}; - -static const struct rpmh_vreg_hw_data pmic4_hfsmps3 = { - .regulator_type = VRM, - .ops = &rpmh_regulator_vrm_ops, - .voltage_ranges = (struct linear_range[]) { - REGULATOR_LINEAR_RANGE(320000, 0, 215, 8000), - }, - .n_linear_ranges = 1, - .n_voltages = 216, - .pmic_mode_map = pmic_mode_map_pmic4_smps, - .of_map_mode = rpmh_regulator_pmic4_smps_of_map_mode, -}; - -static const struct rpmh_vreg_hw_data pmic4_ftsmps426 = { - .regulator_type = VRM, - .ops = &rpmh_regulator_vrm_ops, - .voltage_ranges = (struct linear_range[]) { - REGULATOR_LINEAR_RANGE(320000, 0, 258, 4000), - }, - .n_linear_ranges = 1, - .n_voltages = 259, - .pmic_mode_map = pmic_mode_map_pmic4_smps, - .of_map_mode = rpmh_regulator_pmic4_smps_of_map_mode, -}; - -static const struct rpmh_vreg_hw_data pmic4_bob = { - .regulator_type = VRM, - .ops = &rpmh_regulator_vrm_bypass_ops, - .voltage_ranges = (struct linear_range[]) { - REGULATOR_LINEAR_RANGE(1824000, 0, 83, 32000), - }, - .n_linear_ranges = 1, - .n_voltages = 84, - .pmic_mode_map = pmic_mode_map_pmic4_bob, - .of_map_mode = rpmh_regulator_pmic4_bob_of_map_mode, -}; - -static const struct rpmh_vreg_hw_data pmic4_lvs = { - .regulator_type = XOB, - .ops = &rpmh_regulator_xob_ops, - /* LVS hardware does not support voltage or mode configuration. */ -}; - static const struct rpmh_vreg_hw_data pmic5_pldo = { .regulator_type = VRM, .ops = &rpmh_regulator_vrm_drms_ops, .voltage_ranges = (struct linear_range[]) { @@ -759,810 +376,24 @@ static const struct rpmh_vreg_hw_data pmic5_pldo_lv = { .pmic_mode_map = pmic_mode_map_pmic5_ldo, .of_map_mode = rpmh_regulator_pmic4_ldo_of_map_mode, }; -static const struct rpmh_vreg_hw_data pmic5_pldo515_mv = { - .regulator_type = VRM, - .ops = &rpmh_regulator_vrm_drms_ops, - .voltage_ranges = (struct linear_range[]) { - REGULATOR_LINEAR_RANGE(1800000, 0, 187, 8000), - }, - .n_linear_ranges = 1, - .n_voltages = 188, - .hpm_min_load_uA = 10000, - .pmic_mode_map = pmic_mode_map_pmic5_ldo, - .of_map_mode = rpmh_regulator_pmic4_ldo_of_map_mode, -}; - -static const struct rpmh_vreg_hw_data pmic5_pldo502 = { - .regulator_type = VRM, - .ops = &rpmh_regulator_vrm_ops, - .voltage_ranges = (struct linear_range[]) { - REGULATOR_LINEAR_RANGE(1504000, 0, 255, 8000), - }, - .n_linear_ranges = 1, - .n_voltages = 256, - .pmic_mode_map = pmic_mode_map_pmic5_ldo_hpm, - .of_map_mode = rpmh_regulator_pmic4_ldo_of_map_mode, -}; - -static const struct rpmh_vreg_hw_data pmic5_pldo502ln = { - .regulator_type = VRM, - .ops = &rpmh_regulator_vrm_ops, - .voltage_ranges = (struct linear_range[]) { - REGULATOR_LINEAR_RANGE(1800000, 0, 2, 200000), - REGULATOR_LINEAR_RANGE(2608000, 3, 28, 16000), - REGULATOR_LINEAR_RANGE(3104000, 29, 30, 96000), - REGULATOR_LINEAR_RANGE(3312000, 31, 31, 0), - }, - .n_linear_ranges = 4, - .n_voltages = 32, - .pmic_mode_map = pmic_mode_map_pmic5_ldo_hpm, - .of_map_mode = rpmh_regulator_pmic4_ldo_of_map_mode, -}; - -static const struct rpmh_vreg_hw_data pmic5_nldo = { - .regulator_type = VRM, - .ops = &rpmh_regulator_vrm_drms_ops, - .voltage_ranges = (struct linear_range[]) { - REGULATOR_LINEAR_RANGE(320000, 0, 123, 8000), - }, - .n_linear_ranges = 1, - .n_voltages = 124, - .hpm_min_load_uA = 30000, - .pmic_mode_map = pmic_mode_map_pmic5_ldo, - .of_map_mode = rpmh_regulator_pmic4_ldo_of_map_mode, -}; - -static const struct rpmh_vreg_hw_data pmic5_nldo515 = { - .regulator_type = VRM, - .ops = &rpmh_regulator_vrm_drms_ops, - .voltage_ranges = (struct linear_range[]) { - REGULATOR_LINEAR_RANGE(320000, 0, 210, 8000), - }, - .n_linear_ranges = 1, - .n_voltages = 211, - .hpm_min_load_uA = 30000, - .pmic_mode_map = pmic_mode_map_pmic5_ldo, - .of_map_mode = rpmh_regulator_pmic4_ldo_of_map_mode, -}; - -static const struct rpmh_vreg_hw_data pmic5_nldo502 = { - .regulator_type = VRM, - .ops = &rpmh_regulator_vrm_drms_ops, - .voltage_ranges = (struct linear_range[]) { - REGULATOR_LINEAR_RANGE(528000, 0, 127, 8000), - }, - .n_linear_ranges = 1, - .n_voltages = 128, - .hpm_min_load_uA = 30000, - .pmic_mode_map = pmic_mode_map_pmic5_ldo, - .of_map_mode = rpmh_regulator_pmic4_ldo_of_map_mode, -}; - -static const struct rpmh_vreg_hw_data pmic5_hfsmps510 = { - .regulator_type = VRM, - .ops = &rpmh_regulator_vrm_ops, - .voltage_ranges = (struct linear_range[]) { - REGULATOR_LINEAR_RANGE(320000, 0, 215, 8000), - }, - .n_linear_ranges = 1, - .n_voltages = 216, - .pmic_mode_map = pmic_mode_map_pmic5_smps, - .of_map_mode = rpmh_regulator_pmic4_smps_of_map_mode, -}; - -static const struct rpmh_vreg_hw_data pmic5_ftsmps510 = { - .regulator_type = VRM, - .ops = &rpmh_regulator_vrm_ops, - .voltage_ranges = (struct linear_range[]) { - REGULATOR_LINEAR_RANGE(300000, 0, 263, 4000), - }, - .n_linear_ranges = 1, - .n_voltages = 264, - .pmic_mode_map = pmic_mode_map_pmic5_smps, - .of_map_mode = rpmh_regulator_pmic4_smps_of_map_mode, -}; - -static const struct rpmh_vreg_hw_data pmic5_ftsmps520 = { - .regulator_type = VRM, - .ops = &rpmh_regulator_vrm_ops, - .voltage_ranges = (struct linear_range[]) { - REGULATOR_LINEAR_RANGE(300000, 0, 263, 4000), - }, - .n_linear_ranges = 1, - .n_voltages = 264, - .pmic_mode_map = pmic_mode_map_pmic5_smps, - .of_map_mode = rpmh_regulator_pmic4_smps_of_map_mode, -}; - -static const struct rpmh_vreg_hw_data pmic5_ftsmps525_lv = { - .regulator_type = VRM, - .ops = &rpmh_regulator_vrm_ops, - .voltage_ranges = (struct linear_range[]) { - REGULATOR_LINEAR_RANGE(300000, 0, 267, 4000), - }, - .n_linear_ranges = 1, - .n_voltages = 268, - .pmic_mode_map = pmic_mode_map_pmic5_smps, - .of_map_mode = rpmh_regulator_pmic4_smps_of_map_mode, -}; - -static const struct rpmh_vreg_hw_data pmic5_ftsmps525_mv = { - .regulator_type = VRM, - .ops = &rpmh_regulator_vrm_ops, - .voltage_ranges = (struct linear_range[]) { - REGULATOR_LINEAR_RANGE(600000, 0, 267, 8000), - }, - .n_linear_ranges = 1, - .n_voltages = 268, - .pmic_mode_map = pmic_mode_map_pmic5_smps, - .of_map_mode = rpmh_regulator_pmic4_smps_of_map_mode, -}; - -static const struct rpmh_vreg_hw_data pmic5_ftsmps527 = { - .regulator_type = VRM, - .ops = &rpmh_regulator_vrm_ops, - .voltage_ranges = (struct linear_range[]) { - REGULATOR_LINEAR_RANGE(320000, 0, 215, 8000), - }, - .n_linear_ranges = 1, - .n_voltages = 215, - .pmic_mode_map = pmic_mode_map_pmic5_smps, - .of_map_mode = rpmh_regulator_pmic4_smps_of_map_mode, -}; - -static const struct rpmh_vreg_hw_data pmic5_hfsmps515 = { - .regulator_type = VRM, - .ops = &rpmh_regulator_vrm_ops, - .voltage_ranges = (struct linear_range[]) { - REGULATOR_LINEAR_RANGE(320000, 0, 235, 16000), - }, - .n_linear_ranges = 1, - .n_voltages = 236, - .pmic_mode_map = pmic_mode_map_pmic5_smps, - .of_map_mode = rpmh_regulator_pmic4_smps_of_map_mode, -}; - -static const struct rpmh_vreg_hw_data pmic5_hfsmps515_1 = { - .regulator_type = VRM, - .ops = &rpmh_regulator_vrm_ops, - .voltage_ranges = (struct linear_range[]) { - REGULATOR_LINEAR_RANGE(900000, 0, 4, 16000), - }, - .n_linear_ranges = 1, - .n_voltages = 5, - .pmic_mode_map = pmic_mode_map_pmic5_smps, - .of_map_mode = rpmh_regulator_pmic4_smps_of_map_mode, -}; - -static const struct rpmh_vreg_hw_data pmic5_bob = { - .regulator_type = VRM, - .ops = &rpmh_regulator_vrm_bypass_ops, - .voltage_ranges = (struct linear_range[]) { - REGULATOR_LINEAR_RANGE(3000000, 0, 31, 32000), - }, - .n_linear_ranges = 1, - .n_voltages = 32, - .pmic_mode_map = pmic_mode_map_pmic5_bob, - .of_map_mode = rpmh_regulator_pmic4_bob_of_map_mode, -}; - #define RPMH_VREG(_name, _resource_name, _hw_data, _supply_name) \ { \ .name = _name, \ .resource_name = _resource_name, \ .hw_data = _hw_data, \ .supply_name = _supply_name, \ } -static const struct rpmh_vreg_init_data pm8998_vreg_data[] = { - RPMH_VREG("smps1", "smp%s1", &pmic4_ftsmps426, "vdd-s1"), - RPMH_VREG("smps2", "smp%s2", &pmic4_ftsmps426, "vdd-s2"), - RPMH_VREG("smps3", "smp%s3", &pmic4_hfsmps3, "vdd-s3"), - RPMH_VREG("smps4", "smp%s4", &pmic4_hfsmps3, "vdd-s4"), - RPMH_VREG("smps5", "smp%s5", &pmic4_hfsmps3, "vdd-s5"), - RPMH_VREG("smps6", "smp%s6", &pmic4_ftsmps426, "vdd-s6"), - RPMH_VREG("smps7", "smp%s7", &pmic4_ftsmps426, "vdd-s7"), - RPMH_VREG("smps8", "smp%s8", &pmic4_ftsmps426, "vdd-s8"), - RPMH_VREG("smps9", "smp%s9", &pmic4_ftsmps426, "vdd-s9"), - RPMH_VREG("smps10", "smp%s10", &pmic4_ftsmps426, "vdd-s10"), - RPMH_VREG("smps11", "smp%s11", &pmic4_ftsmps426, "vdd-s11"), - RPMH_VREG("smps12", "smp%s12", &pmic4_ftsmps426, "vdd-s12"), - RPMH_VREG("smps13", "smp%s13", &pmic4_ftsmps426, "vdd-s13"), - RPMH_VREG("ldo1", "ldo%s1", &pmic4_nldo, "vdd-l1-l27"), - RPMH_VREG("ldo2", "ldo%s2", &pmic4_nldo, "vdd-l2-l8-l17"), - RPMH_VREG("ldo3", "ldo%s3", &pmic4_nldo, "vdd-l3-l11"), - RPMH_VREG("ldo4", "ldo%s4", &pmic4_nldo, "vdd-l4-l5"), - RPMH_VREG("ldo5", "ldo%s5", &pmic4_nldo, "vdd-l4-l5"), - RPMH_VREG("ldo6", "ldo%s6", &pmic4_pldo, "vdd-l6"), - RPMH_VREG("ldo7", "ldo%s7", &pmic4_pldo_lv, "vdd-l7-l12-l14-l15"), - RPMH_VREG("ldo8", "ldo%s8", &pmic4_nldo, "vdd-l2-l8-l17"), - RPMH_VREG("ldo9", "ldo%s9", &pmic4_pldo, "vdd-l9"), - RPMH_VREG("ldo10", "ldo%s10", &pmic4_pldo, "vdd-l10-l23-l25"), - RPMH_VREG("ldo11", "ldo%s11", &pmic4_nldo, "vdd-l3-l11"), - RPMH_VREG("ldo12", "ldo%s12", &pmic4_pldo_lv, "vdd-l7-l12-l14-l15"), - RPMH_VREG("ldo13", "ldo%s13", &pmic4_pldo, "vdd-l13-l19-l21"), - RPMH_VREG("ldo14", "ldo%s14", &pmic4_pldo_lv, "vdd-l7-l12-l14-l15"), - RPMH_VREG("ldo15", "ldo%s15", &pmic4_pldo_lv, "vdd-l7-l12-l14-l15"), - RPMH_VREG("ldo16", "ldo%s16", &pmic4_pldo, "vdd-l16-l28"), - RPMH_VREG("ldo17", "ldo%s17", &pmic4_nldo, "vdd-l2-l8-l17"), - RPMH_VREG("ldo18", "ldo%s18", &pmic4_pldo, "vdd-l18-l22"), - RPMH_VREG("ldo19", "ldo%s19", &pmic4_pldo, "vdd-l13-l19-l21"), - RPMH_VREG("ldo20", "ldo%s20", &pmic4_pldo, "vdd-l20-l24"), - RPMH_VREG("ldo21", "ldo%s21", &pmic4_pldo, "vdd-l13-l19-l21"), - RPMH_VREG("ldo22", "ldo%s22", &pmic4_pldo, "vdd-l18-l22"), - RPMH_VREG("ldo23", "ldo%s23", &pmic4_pldo, "vdd-l10-l23-l25"), - RPMH_VREG("ldo24", "ldo%s24", &pmic4_pldo, "vdd-l20-l24"), - RPMH_VREG("ldo25", "ldo%s25", &pmic4_pldo, "vdd-l10-l23-l25"), - RPMH_VREG("ldo26", "ldo%s26", &pmic4_nldo, "vdd-l26"), - RPMH_VREG("ldo27", "ldo%s27", &pmic4_nldo, "vdd-l1-l27"), - RPMH_VREG("ldo28", "ldo%s28", &pmic4_pldo, "vdd-l16-l28"), - RPMH_VREG("lvs1", "vs%s1", &pmic4_lvs, "vin-lvs-1-2"), - RPMH_VREG("lvs2", "vs%s2", &pmic4_lvs, "vin-lvs-1-2"), - {} -}; - -static const struct rpmh_vreg_init_data pmg1110_vreg_data[] = { - RPMH_VREG("smps1", "smp%s1", &pmic5_ftsmps510, "vdd-s1"), - {} -}; - -static const struct rpmh_vreg_init_data pmi8998_vreg_data[] = { - RPMH_VREG("bob", "bob%s1", &pmic4_bob, "vdd-bob"), - {} -}; - -static const struct rpmh_vreg_init_data pm8005_vreg_data[] = { - RPMH_VREG("smps1", "smp%s1", &pmic4_ftsmps426, "vdd-s1"), - RPMH_VREG("smps2", "smp%s2", &pmic4_ftsmps426, "vdd-s2"), - RPMH_VREG("smps3", "smp%s3", &pmic4_ftsmps426, "vdd-s3"), - RPMH_VREG("smps4", "smp%s4", &pmic4_ftsmps426, "vdd-s4"), - {} -}; - static const struct rpmh_vreg_init_data pm8150_vreg_data[] = { - RPMH_VREG("smps1", "smp%s1", &pmic5_ftsmps510, "vdd-s1"), - RPMH_VREG("smps2", "smp%s2", &pmic5_ftsmps510, "vdd-s2"), - RPMH_VREG("smps3", "smp%s3", &pmic5_ftsmps510, "vdd-s3"), - RPMH_VREG("smps4", "smp%s4", &pmic5_hfsmps510, "vdd-s4"), - RPMH_VREG("smps5", "smp%s5", &pmic5_hfsmps510, "vdd-s5"), - RPMH_VREG("smps6", "smp%s6", &pmic5_ftsmps510, "vdd-s6"), - RPMH_VREG("smps7", "smp%s7", &pmic5_ftsmps510, "vdd-s7"), - RPMH_VREG("smps8", "smp%s8", &pmic5_ftsmps510, "vdd-s8"), - RPMH_VREG("smps9", "smp%s9", &pmic5_ftsmps510, "vdd-s9"), - RPMH_VREG("smps10", "smp%s10", &pmic5_ftsmps510, "vdd-s10"), - RPMH_VREG("ldo1", "ldo%s1", &pmic5_nldo, "vdd-l1-l8-l11"), - RPMH_VREG("ldo2", "ldo%s2", &pmic5_pldo, "vdd-l2-l10"), - RPMH_VREG("ldo3", "ldo%s3", &pmic5_nldo, "vdd-l3-l4-l5-l18"), - RPMH_VREG("ldo4", "ldo%s4", &pmic5_nldo, "vdd-l3-l4-l5-l18"), - RPMH_VREG("ldo5", "ldo%s5", &pmic5_nldo, "vdd-l3-l4-l5-l18"), - RPMH_VREG("ldo6", "ldo%s6", &pmic5_nldo, "vdd-l6-l9"), - RPMH_VREG("ldo7", "ldo%s7", &pmic5_pldo, "vdd-l7-l12-l14-l15"), - RPMH_VREG("ldo8", "ldo%s8", &pmic5_nldo, "vdd-l1-l8-l11"), - RPMH_VREG("ldo9", "ldo%s9", &pmic5_nldo, "vdd-l6-l9"), - RPMH_VREG("ldo10", "ldo%s10", &pmic5_pldo, "vdd-l2-l10"), - RPMH_VREG("ldo11", "ldo%s11", &pmic5_nldo, "vdd-l1-l8-l11"), - RPMH_VREG("ldo12", "ldo%s12", &pmic5_pldo_lv, "vdd-l7-l12-l14-l15"), RPMH_VREG("ldo13", "ldo%s13", &pmic5_pldo, "vdd-l13-l16-l17"), - RPMH_VREG("ldo14", "ldo%s14", &pmic5_pldo_lv, "vdd-l7-l12-l14-l15"), - RPMH_VREG("ldo15", "ldo%s15", &pmic5_pldo_lv, "vdd-l7-l12-l14-l15"), - RPMH_VREG("ldo16", "ldo%s16", &pmic5_pldo, "vdd-l13-l16-l17"), - RPMH_VREG("ldo17", "ldo%s17", &pmic5_pldo, "vdd-l13-l16-l17"), - RPMH_VREG("ldo18", "ldo%s18", &pmic5_nldo, "vdd-l3-l4-l5-l18"), {} }; static const struct rpmh_vreg_init_data pm8150l_vreg_data[] = { - RPMH_VREG("smps1", "smp%s1", &pmic5_ftsmps510, "vdd-s1"), - RPMH_VREG("smps2", "smp%s2", &pmic5_ftsmps510, "vdd-s2"), - RPMH_VREG("smps3", "smp%s3", &pmic5_ftsmps510, "vdd-s3"), - RPMH_VREG("smps4", "smp%s4", &pmic5_ftsmps510, "vdd-s4"), - RPMH_VREG("smps5", "smp%s5", &pmic5_ftsmps510, "vdd-s5"), - RPMH_VREG("smps6", "smp%s6", &pmic5_ftsmps510, "vdd-s6"), - RPMH_VREG("smps7", "smp%s7", &pmic5_ftsmps510, "vdd-s7"), - RPMH_VREG("smps8", "smp%s8", &pmic5_hfsmps510, "vdd-s8"), RPMH_VREG("ldo1", "ldo%s1", &pmic5_pldo_lv, "vdd-l1-l8"), - RPMH_VREG("ldo2", "ldo%s2", &pmic5_nldo, "vdd-l2-l3"), - RPMH_VREG("ldo3", "ldo%s3", &pmic5_nldo, "vdd-l2-l3"), - RPMH_VREG("ldo4", "ldo%s4", &pmic5_pldo, "vdd-l4-l5-l6"), - RPMH_VREG("ldo5", "ldo%s5", &pmic5_pldo, "vdd-l4-l5-l6"), - RPMH_VREG("ldo6", "ldo%s6", &pmic5_pldo, "vdd-l4-l5-l6"), - RPMH_VREG("ldo7", "ldo%s7", &pmic5_pldo, "vdd-l7-l11"), - RPMH_VREG("ldo8", "ldo%s8", &pmic5_pldo_lv, "vdd-l1-l8"), - RPMH_VREG("ldo9", "ldo%s9", &pmic5_pldo, "vdd-l9-l10"), - RPMH_VREG("ldo10", "ldo%s10", &pmic5_pldo, "vdd-l9-l10"), RPMH_VREG("ldo11", "ldo%s11", &pmic5_pldo, "vdd-l7-l11"), - RPMH_VREG("bob", "bob%s1", &pmic5_bob, "vdd-bob"), - {} -}; - -static const struct rpmh_vreg_init_data pmm8155au_vreg_data[] = { - RPMH_VREG("smps1", "smp%s1", &pmic5_ftsmps510, "vdd-s1"), - RPMH_VREG("smps2", "smp%s2", &pmic5_ftsmps510, "vdd-s2"), - RPMH_VREG("smps3", "smp%s3", &pmic5_ftsmps510, "vdd-s3"), - RPMH_VREG("smps4", "smp%s4", &pmic5_hfsmps510, "vdd-s4"), - RPMH_VREG("smps5", "smp%s5", &pmic5_hfsmps510, "vdd-s5"), - RPMH_VREG("smps6", "smp%s6", &pmic5_ftsmps510, "vdd-s6"), - RPMH_VREG("smps7", "smp%s7", &pmic5_ftsmps510, "vdd-s7"), - RPMH_VREG("smps8", "smp%s8", &pmic5_ftsmps510, "vdd-s8"), - RPMH_VREG("smps9", "smp%s9", &pmic5_ftsmps510, "vdd-s9"), - RPMH_VREG("smps10", "smp%s10", &pmic5_ftsmps510, "vdd-s10"), - RPMH_VREG("ldo1", "ldo%s1", &pmic5_nldo, "vdd-l1-l8-l11"), - RPMH_VREG("ldo2", "ldo%s2", &pmic5_pldo, "vdd-l2-l10"), - RPMH_VREG("ldo3", "ldo%s3", &pmic5_nldo, "vdd-l3-l4-l5-l18"), - RPMH_VREG("ldo4", "ldo%s4", &pmic5_nldo, "vdd-l3-l4-l5-l18"), - RPMH_VREG("ldo5", "ldo%s5", &pmic5_nldo, "vdd-l3-l4-l5-l18"), - RPMH_VREG("ldo6", "ldo%s6", &pmic5_nldo, "vdd-l6-l9"), - RPMH_VREG("ldo7", "ldo%s7", &pmic5_pldo_lv, "vdd-l7-l12-l14-l15"), - RPMH_VREG("ldo8", "ldo%s8", &pmic5_nldo, "vdd-l1-l8-l11"), - RPMH_VREG("ldo9", "ldo%s9", &pmic5_nldo, "vdd-l6-l9"), - RPMH_VREG("ldo10", "ldo%s10", &pmic5_pldo, "vdd-l2-l10"), - RPMH_VREG("ldo11", "ldo%s11", &pmic5_nldo, "vdd-l1-l8-l11"), - RPMH_VREG("ldo12", "ldo%s12", &pmic5_pldo_lv, "vdd-l7-l12-l14-l15"), - RPMH_VREG("ldo13", "ldo%s13", &pmic5_pldo, "vdd-l13-l16-l17"), - RPMH_VREG("ldo14", "ldo%s14", &pmic5_pldo_lv, "vdd-l7-l12-l14-l15"), - RPMH_VREG("ldo15", "ldo%s15", &pmic5_pldo_lv, "vdd-l7-l12-l14-l15"), - RPMH_VREG("ldo16", "ldo%s16", &pmic5_pldo, "vdd-l13-l16-l17"), - RPMH_VREG("ldo17", "ldo%s17", &pmic5_pldo, "vdd-l13-l16-l17"), - RPMH_VREG("ldo18", "ldo%s18", &pmic5_nldo, "vdd-l3-l4-l5-l18"), - {} -}; - -static const struct rpmh_vreg_init_data pmm8654au_vreg_data[] = { - RPMH_VREG("smps1", "smp%s1", &pmic5_ftsmps527, "vdd-s1"), - RPMH_VREG("smps2", "smp%s2", &pmic5_ftsmps527, "vdd-s2"), - RPMH_VREG("smps3", "smp%s3", &pmic5_ftsmps527, "vdd-s3"), - RPMH_VREG("smps4", "smp%s4", &pmic5_ftsmps527, "vdd-s4"), - RPMH_VREG("smps5", "smp%s5", &pmic5_ftsmps527, "vdd-s5"), - RPMH_VREG("smps6", "smp%s6", &pmic5_ftsmps527, "vdd-s6"), - RPMH_VREG("smps7", "smp%s7", &pmic5_ftsmps527, "vdd-s7"), - RPMH_VREG("smps8", "smp%s8", &pmic5_ftsmps527, "vdd-s8"), - RPMH_VREG("smps9", "smp%s9", &pmic5_ftsmps527, "vdd-s9"), - RPMH_VREG("ldo1", "ldo%s1", &pmic5_nldo515, "vdd-s9"), - RPMH_VREG("ldo2", "ldo%s2", &pmic5_nldo515, "vdd-l2-l3"), - RPMH_VREG("ldo3", "ldo%s3", &pmic5_nldo515, "vdd-l2-l3"), - RPMH_VREG("ldo4", "ldo%s4", &pmic5_nldo515, "vdd-s9"), - RPMH_VREG("ldo5", "ldo%s5", &pmic5_nldo515, "vdd-s9"), - RPMH_VREG("ldo6", "ldo%s6", &pmic5_nldo515, "vdd-l6-l7"), - RPMH_VREG("ldo7", "ldo%s7", &pmic5_nldo515, "vdd-l6-l7"), - RPMH_VREG("ldo8", "ldo%s8", &pmic5_pldo515_mv, "vdd-l8-l9"), - RPMH_VREG("ldo9", "ldo%s9", &pmic5_pldo, "vdd-l8-l9"), - {} -}; - -static const struct rpmh_vreg_init_data pm8350_vreg_data[] = { - RPMH_VREG("smps1", "smp%s1", &pmic5_ftsmps510, "vdd-s1"), - RPMH_VREG("smps2", "smp%s2", &pmic5_ftsmps510, "vdd-s2"), - RPMH_VREG("smps3", "smp%s3", &pmic5_ftsmps510, "vdd-s3"), - RPMH_VREG("smps4", "smp%s4", &pmic5_ftsmps510, "vdd-s4"), - RPMH_VREG("smps5", "smp%s5", &pmic5_ftsmps510, "vdd-s5"), - RPMH_VREG("smps6", "smp%s6", &pmic5_ftsmps510, "vdd-s6"), - RPMH_VREG("smps7", "smp%s7", &pmic5_ftsmps510, "vdd-s7"), - RPMH_VREG("smps8", "smp%s8", &pmic5_ftsmps510, "vdd-s8"), - RPMH_VREG("smps9", "smp%s9", &pmic5_ftsmps510, "vdd-s9"), - RPMH_VREG("smps10", "smp%s10", &pmic5_hfsmps510, "vdd-s10"), - RPMH_VREG("smps11", "smp%s11", &pmic5_hfsmps510, "vdd-s11"), - RPMH_VREG("smps12", "smp%s12", &pmic5_hfsmps510, "vdd-s12"), - RPMH_VREG("ldo1", "ldo%s1", &pmic5_nldo, "vdd-l1-l4"), - RPMH_VREG("ldo2", "ldo%s2", &pmic5_pldo, "vdd-l2-l7"), - RPMH_VREG("ldo3", "ldo%s3", &pmic5_nldo, "vdd-l3-l5"), - RPMH_VREG("ldo4", "ldo%s4", &pmic5_nldo, "vdd-l1-l4"), - RPMH_VREG("ldo5", "ldo%s5", &pmic5_nldo, "vdd-l3-l5"), - RPMH_VREG("ldo6", "ldo%s6", &pmic5_nldo, "vdd-l6-l9-l10"), - RPMH_VREG("ldo7", "ldo%s7", &pmic5_pldo, "vdd-l2-l7"), - RPMH_VREG("ldo8", "ldo%s8", &pmic5_nldo, "vdd-l8"), - RPMH_VREG("ldo9", "ldo%s9", &pmic5_nldo, "vdd-l6-l9-l10"), - RPMH_VREG("ldo10", "ldo%s10", &pmic5_nldo, "vdd-l6-l9-l10"), - {} -}; - -static const struct rpmh_vreg_init_data pm8350c_vreg_data[] = { - RPMH_VREG("smps1", "smp%s1", &pmic5_hfsmps515, "vdd-s1"), - RPMH_VREG("smps2", "smp%s2", &pmic5_ftsmps510, "vdd-s2"), - RPMH_VREG("smps3", "smp%s3", &pmic5_ftsmps510, "vdd-s3"), - RPMH_VREG("smps4", "smp%s4", &pmic5_ftsmps510, "vdd-s4"), - RPMH_VREG("smps5", "smp%s5", &pmic5_ftsmps510, "vdd-s5"), - RPMH_VREG("smps6", "smp%s6", &pmic5_ftsmps510, "vdd-s6"), - RPMH_VREG("smps7", "smp%s7", &pmic5_ftsmps510, "vdd-s7"), - RPMH_VREG("smps8", "smp%s8", &pmic5_ftsmps510, "vdd-s8"), - RPMH_VREG("smps9", "smp%s9", &pmic5_ftsmps510, "vdd-s9"), - RPMH_VREG("smps10", "smp%s10", &pmic5_ftsmps510, "vdd-s10"), - RPMH_VREG("ldo1", "ldo%s1", &pmic5_pldo_lv, "vdd-l1-l12"), - RPMH_VREG("ldo2", "ldo%s2", &pmic5_pldo_lv, "vdd-l2-l8"), - RPMH_VREG("ldo3", "ldo%s3", &pmic5_pldo, "vdd-l3-l4-l5-l7-l13"), - RPMH_VREG("ldo4", "ldo%s4", &pmic5_pldo, "vdd-l3-l4-l5-l7-l13"), - RPMH_VREG("ldo5", "ldo%s5", &pmic5_pldo, "vdd-l3-l4-l5-l7-l13"), - RPMH_VREG("ldo6", "ldo%s6", &pmic5_pldo, "vdd-l6-l9-l11"), - RPMH_VREG("ldo7", "ldo%s7", &pmic5_pldo, "vdd-l3-l4-l5-l7-l13"), - RPMH_VREG("ldo8", "ldo%s8", &pmic5_pldo_lv, "vdd-l2-l8"), - RPMH_VREG("ldo9", "ldo%s9", &pmic5_pldo, "vdd-l6-l9-l11"), - RPMH_VREG("ldo10", "ldo%s10", &pmic5_nldo, "vdd-l10"), - RPMH_VREG("ldo11", "ldo%s11", &pmic5_pldo, "vdd-l6-l9-l11"), - RPMH_VREG("ldo12", "ldo%s12", &pmic5_pldo_lv, "vdd-l1-l12"), - RPMH_VREG("ldo13", "ldo%s13", &pmic5_pldo, "vdd-l3-l4-l5-l7-l13"), - RPMH_VREG("bob", "bob%s1", &pmic5_bob, "vdd-bob"), - {} -}; - -static const struct rpmh_vreg_init_data pm8450_vreg_data[] = { - RPMH_VREG("smps1", "smp%s1", &pmic5_ftsmps520, "vdd-s1"), - RPMH_VREG("smps2", "smp%s2", &pmic5_ftsmps520, "vdd-s2"), - RPMH_VREG("smps3", "smp%s3", &pmic5_ftsmps520, "vdd-s3"), - RPMH_VREG("smps4", "smp%s4", &pmic5_ftsmps520, "vdd-s4"), - RPMH_VREG("smps5", "smp%s5", &pmic5_ftsmps520, "vdd-s5"), - RPMH_VREG("smps6", "smp%s6", &pmic5_ftsmps520, "vdd-s6"), - RPMH_VREG("ldo1", "ldo%s1", &pmic5_nldo, "vdd-l1"), - RPMH_VREG("ldo2", "ldo%s2", &pmic5_nldo, "vdd-l2"), - RPMH_VREG("ldo3", "ldo%s3", &pmic5_nldo, "vdd-l3"), - RPMH_VREG("ldo4", "ldo%s4", &pmic5_pldo_lv, "vdd-l4"), - {} -}; - -static const struct rpmh_vreg_init_data pm8550_vreg_data[] = { - RPMH_VREG("ldo1", "ldo%s1", &pmic5_nldo515, "vdd-l1-l4-l10"), - RPMH_VREG("ldo2", "ldo%s2", &pmic5_pldo, "vdd-l2-l13-l14"), - RPMH_VREG("ldo3", "ldo%s3", &pmic5_nldo515, "vdd-l3"), - RPMH_VREG("ldo4", "ldo%s4", &pmic5_nldo515, "vdd-l1-l4-l10"), - RPMH_VREG("ldo5", "ldo%s5", &pmic5_pldo, "vdd-l5-l16"), - RPMH_VREG("ldo6", "ldo%s6", &pmic5_pldo, "vdd-l6-l7"), - RPMH_VREG("ldo7", "ldo%s7", &pmic5_pldo, "vdd-l6-l7"), - RPMH_VREG("ldo8", "ldo%s8", &pmic5_pldo, "vdd-l8-l9"), - RPMH_VREG("ldo9", "ldo%s9", &pmic5_pldo, "vdd-l8-l9"), - RPMH_VREG("ldo10", "ldo%s10", &pmic5_nldo515, "vdd-l1-l4-l10"), - RPMH_VREG("ldo11", "ldo%s11", &pmic5_nldo515, "vdd-l11"), - RPMH_VREG("ldo12", "ldo%s12", &pmic5_nldo515, "vdd-l12"), - RPMH_VREG("ldo13", "ldo%s13", &pmic5_pldo, "vdd-l2-l13-l14"), - RPMH_VREG("ldo14", "ldo%s14", &pmic5_pldo, "vdd-l2-l13-l14"), - RPMH_VREG("ldo15", "ldo%s15", &pmic5_nldo515, "vdd-l15"), - RPMH_VREG("ldo16", "ldo%s16", &pmic5_pldo, "vdd-l5-l16"), - RPMH_VREG("ldo17", "ldo%s17", &pmic5_pldo, "vdd-l17"), - RPMH_VREG("bob1", "bob%s1", &pmic5_bob, "vdd-bob1"), - RPMH_VREG("bob2", "bob%s2", &pmic5_bob, "vdd-bob2"), - {} -}; - -static const struct rpmh_vreg_init_data pm8550vs_vreg_data[] = { - RPMH_VREG("smps1", "smp%s1", &pmic5_ftsmps525_lv, "vdd-s1"), - RPMH_VREG("smps2", "smp%s2", &pmic5_ftsmps525_lv, "vdd-s2"), - RPMH_VREG("smps3", "smp%s3", &pmic5_ftsmps525_lv, "vdd-s3"), - RPMH_VREG("smps4", "smp%s4", &pmic5_ftsmps525_lv, "vdd-s4"), - RPMH_VREG("smps5", "smp%s5", &pmic5_ftsmps525_lv, "vdd-s5"), - RPMH_VREG("smps6", "smp%s6", &pmic5_ftsmps525_mv, "vdd-s6"), - RPMH_VREG("ldo1", "ldo%s1", &pmic5_nldo515, "vdd-l1"), - RPMH_VREG("ldo2", "ldo%s2", &pmic5_nldo515, "vdd-l2"), - RPMH_VREG("ldo3", "ldo%s3", &pmic5_nldo515, "vdd-l3"), - {} -}; - -static const struct rpmh_vreg_init_data pm8550ve_vreg_data[] = { - RPMH_VREG("smps1", "smp%s1", &pmic5_ftsmps525_lv, "vdd-s1"), - RPMH_VREG("smps2", "smp%s2", &pmic5_ftsmps525_lv, "vdd-s2"), - RPMH_VREG("smps3", "smp%s3", &pmic5_ftsmps525_lv, "vdd-s3"), - RPMH_VREG("smps4", "smp%s4", &pmic5_ftsmps525_mv, "vdd-s4"), - RPMH_VREG("smps5", "smp%s5", &pmic5_ftsmps525_lv, "vdd-s5"), - RPMH_VREG("smps6", "smp%s6", &pmic5_ftsmps525_lv, "vdd-s6"), - RPMH_VREG("smps7", "smp%s7", &pmic5_ftsmps525_lv, "vdd-s7"), - RPMH_VREG("smps8", "smp%s8", &pmic5_ftsmps525_lv, "vdd-s8"), - RPMH_VREG("ldo1", "ldo%s1", &pmic5_nldo515, "vdd-l1"), - RPMH_VREG("ldo2", "ldo%s2", &pmic5_nldo515, "vdd-l2"), - RPMH_VREG("ldo3", "ldo%s3", &pmic5_nldo515, "vdd-l3"), - {} -}; - -static const struct rpmh_vreg_init_data pmc8380_vreg_data[] = { - RPMH_VREG("smps1", "smp%s1", &pmic5_ftsmps525_lv, "vdd-s1"), - RPMH_VREG("smps2", "smp%s2", &pmic5_ftsmps525_lv, "vdd-s2"), - RPMH_VREG("smps3", "smp%s3", &pmic5_ftsmps525_lv, "vdd-s3"), - RPMH_VREG("smps4", "smp%s4", &pmic5_ftsmps525_mv, "vdd-s4"), - RPMH_VREG("smps5", "smp%s5", &pmic5_ftsmps525_lv, "vdd-s5"), - RPMH_VREG("smps6", "smp%s6", &pmic5_ftsmps525_lv, "vdd-s6"), - RPMH_VREG("smps7", "smp%s7", &pmic5_ftsmps525_lv, "vdd-s7"), - RPMH_VREG("smps8", "smp%s8", &pmic5_ftsmps525_lv, "vdd-s8"), - RPMH_VREG("ldo1", "ldo%s1", &pmic5_nldo515, "vdd-l1"), - RPMH_VREG("ldo2", "ldo%s2", &pmic5_nldo515, "vdd-l2"), - RPMH_VREG("ldo3", "ldo%s3", &pmic5_nldo515, "vdd-l3"), - {} -}; - -static const struct rpmh_vreg_init_data pm8009_vreg_data[] = { - RPMH_VREG("smps1", "smp%s1", &pmic5_hfsmps510, "vdd-s1"), - RPMH_VREG("smps2", "smp%s2", &pmic5_hfsmps515, "vdd-s2"), - RPMH_VREG("ldo1", "ldo%s1", &pmic5_nldo, "vdd-l1"), - RPMH_VREG("ldo2", "ldo%s2", &pmic5_nldo, "vdd-l2"), - RPMH_VREG("ldo3", "ldo%s3", &pmic5_nldo, "vdd-l3"), - RPMH_VREG("ldo4", "ldo%s4", &pmic5_nldo, "vdd-l4"), - RPMH_VREG("ldo5", "ldo%s5", &pmic5_pldo, "vdd-l5-l6"), - RPMH_VREG("ldo6", "ldo%s6", &pmic5_pldo, "vdd-l5-l6"), - RPMH_VREG("ldo7", "ldo%s7", &pmic5_pldo_lv, "vdd-l7"), - {} -}; - -static const struct rpmh_vreg_init_data pm8009_1_vreg_data[] = { - RPMH_VREG("smps1", "smp%s1", &pmic5_hfsmps510, "vdd-s1"), - RPMH_VREG("smps2", "smp%s2", &pmic5_hfsmps515_1, "vdd-s2"), - RPMH_VREG("ldo1", "ldo%s1", &pmic5_nldo, "vdd-l1"), - RPMH_VREG("ldo2", "ldo%s2", &pmic5_nldo, "vdd-l2"), - RPMH_VREG("ldo3", "ldo%s3", &pmic5_nldo, "vdd-l3"), - RPMH_VREG("ldo4", "ldo%s4", &pmic5_nldo, "vdd-l4"), - RPMH_VREG("ldo5", "ldo%s5", &pmic5_pldo, "vdd-l5-l6"), - RPMH_VREG("ldo6", "ldo%s6", &pmic5_pldo, "vdd-l5-l6"), - RPMH_VREG("ldo7", "ldo%s7", &pmic5_pldo_lv, "vdd-l7"), - {} -}; - -static const struct rpmh_vreg_init_data pm8010_vreg_data[] = { - RPMH_VREG("ldo1", "ldo%s1", &pmic5_nldo502, "vdd-l1-l2"), - RPMH_VREG("ldo2", "ldo%s2", &pmic5_nldo502, "vdd-l1-l2"), - RPMH_VREG("ldo3", "ldo%s3", &pmic5_pldo502ln, "vdd-l3-l4"), - RPMH_VREG("ldo4", "ldo%s4", &pmic5_pldo502ln, "vdd-l3-l4"), - RPMH_VREG("ldo5", "ldo%s5", &pmic5_pldo502, "vdd-l5"), - RPMH_VREG("ldo6", "ldo%s6", &pmic5_pldo502ln, "vdd-l6"), - RPMH_VREG("ldo7", "ldo%s7", &pmic5_pldo502, "vdd-l7"), -}; - -static const struct rpmh_vreg_init_data pm6150_vreg_data[] = { - RPMH_VREG("smps1", "smp%s1", &pmic5_ftsmps510, "vdd-s1"), - RPMH_VREG("smps2", "smp%s2", &pmic5_ftsmps510, "vdd-s2"), - RPMH_VREG("smps3", "smp%s3", &pmic5_ftsmps510, "vdd-s3"), - RPMH_VREG("smps4", "smp%s4", &pmic5_hfsmps510, "vdd-s4"), - RPMH_VREG("smps5", "smp%s5", &pmic5_hfsmps510, "vdd-s5"), - RPMH_VREG("ldo1", "ldo%s1", &pmic5_nldo, "vdd-l1"), - RPMH_VREG("ldo2", "ldo%s2", &pmic5_nldo, "vdd-l2-l3"), - RPMH_VREG("ldo3", "ldo%s3", &pmic5_nldo, "vdd-l2-l3"), - RPMH_VREG("ldo4", "ldo%s4", &pmic5_nldo, "vdd-l4-l7-l8"), - RPMH_VREG("ldo5", "ldo%s5", &pmic5_pldo, "vdd-l5-l16-l17-l18-l19"), - RPMH_VREG("ldo6", "ldo%s6", &pmic5_nldo, "vdd-l6"), - RPMH_VREG("ldo7", "ldo%s7", &pmic5_nldo, "vdd-l4-l7-l8"), - RPMH_VREG("ldo8", "ldo%s8", &pmic5_nldo, "vdd-l4-l7-l8"), - RPMH_VREG("ldo9", "ldo%s9", &pmic5_nldo, "vdd-l9"), - RPMH_VREG("ldo10", "ldo%s10", &pmic5_pldo_lv, "vdd-l10-l14-l15"), - RPMH_VREG("ldo11", "ldo%s11", &pmic5_pldo_lv, "vdd-l11-l12-l13"), - RPMH_VREG("ldo12", "ldo%s12", &pmic5_pldo_lv, "vdd-l11-l12-l13"), - RPMH_VREG("ldo13", "ldo%s13", &pmic5_pldo_lv, "vdd-l11-l12-l13"), - RPMH_VREG("ldo14", "ldo%s14", &pmic5_pldo_lv, "vdd-l10-l14-l15"), - RPMH_VREG("ldo15", "ldo%s15", &pmic5_pldo_lv, "vdd-l10-l14-l15"), - RPMH_VREG("ldo16", "ldo%s16", &pmic5_pldo, "vdd-l5-l16-l17-l18-l19"), - RPMH_VREG("ldo17", "ldo%s17", &pmic5_pldo, "vdd-l5-l16-l17-l18-l19"), - RPMH_VREG("ldo18", "ldo%s18", &pmic5_pldo, "vdd-l5-l16-l17-l18-l19"), - RPMH_VREG("ldo19", "ldo%s19", &pmic5_pldo, "vdd-l5-l16-l17-l18-l19"), - {} -}; - -static const struct rpmh_vreg_init_data pm6150l_vreg_data[] = { - RPMH_VREG("smps1", "smp%s1", &pmic5_ftsmps510, "vdd-s1"), - RPMH_VREG("smps2", "smp%s2", &pmic5_ftsmps510, "vdd-s2"), - RPMH_VREG("smps3", "smp%s3", &pmic5_ftsmps510, "vdd-s3"), - RPMH_VREG("smps4", "smp%s4", &pmic5_ftsmps510, "vdd-s4"), - RPMH_VREG("smps5", "smp%s5", &pmic5_ftsmps510, "vdd-s5"), - RPMH_VREG("smps6", "smp%s6", &pmic5_ftsmps510, "vdd-s6"), - RPMH_VREG("smps7", "smp%s7", &pmic5_ftsmps510, "vdd-s7"), - RPMH_VREG("smps8", "smp%s8", &pmic5_hfsmps510, "vdd-s8"), - RPMH_VREG("ldo1", "ldo%s1", &pmic5_pldo_lv, "vdd-l1-l8"), - RPMH_VREG("ldo2", "ldo%s2", &pmic5_nldo, "vdd-l2-l3"), - RPMH_VREG("ldo3", "ldo%s3", &pmic5_nldo, "vdd-l2-l3"), - RPMH_VREG("ldo4", "ldo%s4", &pmic5_pldo, "vdd-l4-l5-l6"), - RPMH_VREG("ldo5", "ldo%s5", &pmic5_pldo, "vdd-l4-l5-l6"), - RPMH_VREG("ldo6", "ldo%s6", &pmic5_pldo, "vdd-l4-l5-l6"), - RPMH_VREG("ldo7", "ldo%s7", &pmic5_pldo, "vdd-l7-l11"), - RPMH_VREG("ldo8", "ldo%s8", &pmic5_pldo, "vdd-l1-l8"), - RPMH_VREG("ldo9", "ldo%s9", &pmic5_pldo, "vdd-l9-l10"), - RPMH_VREG("ldo10", "ldo%s10", &pmic5_pldo, "vdd-l9-l10"), - RPMH_VREG("ldo11", "ldo%s11", &pmic5_pldo, "vdd-l7-l11"), - RPMH_VREG("bob", "bob%s1", &pmic5_bob, "vdd-bob"), - {} -}; - -static const struct rpmh_vreg_init_data pm6350_vreg_data[] = { - RPMH_VREG("smps1", "smp%s1", &pmic5_ftsmps510, NULL), - RPMH_VREG("smps2", "smp%s2", &pmic5_hfsmps510, NULL), - /* smps3 - smps5 not configured */ - RPMH_VREG("ldo1", "ldo%s1", &pmic5_nldo, NULL), - RPMH_VREG("ldo2", "ldo%s2", &pmic5_pldo, NULL), - RPMH_VREG("ldo3", "ldo%s3", &pmic5_pldo, NULL), - RPMH_VREG("ldo4", "ldo%s4", &pmic5_nldo, NULL), - RPMH_VREG("ldo5", "ldo%s5", &pmic5_pldo, NULL), - RPMH_VREG("ldo6", "ldo%s6", &pmic5_pldo, NULL), - RPMH_VREG("ldo7", "ldo%s7", &pmic5_pldo, NULL), - RPMH_VREG("ldo8", "ldo%s8", &pmic5_pldo, NULL), - RPMH_VREG("ldo9", "ldo%s9", &pmic5_pldo, NULL), - RPMH_VREG("ldo10", "ldo%s10", &pmic5_pldo, NULL), - RPMH_VREG("ldo11", "ldo%s11", &pmic5_pldo, NULL), - RPMH_VREG("ldo12", "ldo%s12", &pmic5_pldo, NULL), - RPMH_VREG("ldo13", "ldo%s13", &pmic5_nldo, NULL), - RPMH_VREG("ldo14", "ldo%s14", &pmic5_pldo, NULL), - RPMH_VREG("ldo15", "ldo%s15", &pmic5_nldo, NULL), - RPMH_VREG("ldo16", "ldo%s16", &pmic5_nldo, NULL), - /* ldo17 not configured */ - RPMH_VREG("ldo18", "ldo%s18", &pmic5_nldo, NULL), - RPMH_VREG("ldo19", "ldo%s19", &pmic5_nldo, NULL), - RPMH_VREG("ldo20", "ldo%s20", &pmic5_nldo, NULL), - RPMH_VREG("ldo21", "ldo%s21", &pmic5_nldo, NULL), - RPMH_VREG("ldo22", "ldo%s22", &pmic5_nldo, NULL), -}; - -static const struct rpmh_vreg_init_data pmx55_vreg_data[] = { - RPMH_VREG("smps1", "smp%s1", &pmic5_ftsmps510, "vdd-s1"), - RPMH_VREG("smps2", "smp%s2", &pmic5_hfsmps510, "vdd-s2"), - RPMH_VREG("smps3", "smp%s3", &pmic5_hfsmps510, "vdd-s3"), - RPMH_VREG("smps4", "smp%s4", &pmic5_hfsmps510, "vdd-s4"), - RPMH_VREG("smps5", "smp%s5", &pmic5_hfsmps510, "vdd-s5"), - RPMH_VREG("smps6", "smp%s6", &pmic5_ftsmps510, "vdd-s6"), - RPMH_VREG("smps7", "smp%s7", &pmic5_hfsmps510, "vdd-s7"), - RPMH_VREG("ldo1", "ldo%s1", &pmic5_nldo, "vdd-l1-l2"), - RPMH_VREG("ldo2", "ldo%s2", &pmic5_nldo, "vdd-l1-l2"), - RPMH_VREG("ldo3", "ldo%s3", &pmic5_nldo, "vdd-l3-l9"), - RPMH_VREG("ldo4", "ldo%s4", &pmic5_nldo, "vdd-l4-l12"), - RPMH_VREG("ldo5", "ldo%s5", &pmic5_pldo, "vdd-l5-l6"), - RPMH_VREG("ldo6", "ldo%s6", &pmic5_pldo, "vdd-l5-l6"), - RPMH_VREG("ldo7", "ldo%s7", &pmic5_nldo, "vdd-l7-l8"), - RPMH_VREG("ldo8", "ldo%s8", &pmic5_nldo, "vdd-l7-l8"), - RPMH_VREG("ldo9", "ldo%s9", &pmic5_nldo, "vdd-l3-l9"), - RPMH_VREG("ldo10", "ldo%s10", &pmic5_pldo, "vdd-l10-l11-l13"), - RPMH_VREG("ldo11", "ldo%s11", &pmic5_pldo, "vdd-l10-l11-l13"), - RPMH_VREG("ldo12", "ldo%s12", &pmic5_nldo, "vdd-l4-l12"), - RPMH_VREG("ldo13", "ldo%s13", &pmic5_pldo, "vdd-l10-l11-l13"), - RPMH_VREG("ldo14", "ldo%s14", &pmic5_nldo, "vdd-l14"), - RPMH_VREG("ldo15", "ldo%s15", &pmic5_nldo, "vdd-l15"), - RPMH_VREG("ldo16", "ldo%s16", &pmic5_pldo, "vdd-l16"), - {} -}; - -static const struct rpmh_vreg_init_data pmx65_vreg_data[] = { - RPMH_VREG("smps1", "smp%s1", &pmic5_ftsmps510, "vdd-s1"), - RPMH_VREG("smps2", "smp%s2", &pmic5_hfsmps510, "vdd-s2"), - RPMH_VREG("smps3", "smp%s3", &pmic5_hfsmps510, "vdd-s3"), - RPMH_VREG("smps4", "smp%s4", &pmic5_hfsmps510, "vdd-s4"), - RPMH_VREG("smps5", "smp%s5", &pmic5_hfsmps510, "vdd-s5"), - RPMH_VREG("smps6", "smp%s6", &pmic5_ftsmps510, "vdd-s6"), - RPMH_VREG("smps7", "smp%s7", &pmic5_hfsmps510, "vdd-s7"), - RPMH_VREG("smps8", "smp%s8", &pmic5_hfsmps510, "vdd-s8"), - RPMH_VREG("ldo1", "ldo%s1", &pmic5_nldo, "vdd-l1"), - RPMH_VREG("ldo2", "ldo%s2", &pmic5_nldo, "vdd-l2-l18"), - RPMH_VREG("ldo3", "ldo%s3", &pmic5_nldo, "vdd-l3"), - RPMH_VREG("ldo4", "ldo%s4", &pmic5_nldo, "vdd-l4"), - RPMH_VREG("ldo5", "ldo%s5", &pmic5_pldo, "vdd-l5-l6-l16"), - RPMH_VREG("ldo6", "ldo%s6", &pmic5_pldo, "vdd-l5-l6-l16"), - RPMH_VREG("ldo7", "ldo%s7", &pmic5_nldo, "vdd-l7"), - RPMH_VREG("ldo8", "ldo%s8", &pmic5_nldo, "vdd-l8-l9"), - RPMH_VREG("ldo9", "ldo%s9", &pmic5_nldo, "vdd-l8-l9"), - RPMH_VREG("ldo10", "ldo%s10", &pmic5_pldo, "vdd-l10"), - RPMH_VREG("ldo11", "ldo%s11", &pmic5_pldo, "vdd-l11-l13"), - RPMH_VREG("ldo12", "ldo%s12", &pmic5_nldo, "vdd-l12"), - RPMH_VREG("ldo13", "ldo%s13", &pmic5_pldo, "vdd-l11-l13"), - RPMH_VREG("ldo14", "ldo%s14", &pmic5_nldo, "vdd-l14"), - RPMH_VREG("ldo15", "ldo%s15", &pmic5_nldo, "vdd-l15"), - RPMH_VREG("ldo16", "ldo%s16", &pmic5_pldo, "vdd-l5-l6-l16"), - RPMH_VREG("ldo17", "ldo%s17", &pmic5_nldo, "vdd-l17"), - /* ldo18 not configured */ - RPMH_VREG("ldo19", "ldo%s19", &pmic5_nldo, "vdd-l19"), - RPMH_VREG("ldo20", "ldo%s20", &pmic5_nldo, "vdd-l20"), - RPMH_VREG("ldo21", "ldo%s21", &pmic5_nldo, "vdd-l21"), - {} -}; - -static const struct rpmh_vreg_init_data pmx75_vreg_data[] = { - RPMH_VREG("smps1", "smp%s1", &pmic5_ftsmps525_lv, "vdd-s1"), - RPMH_VREG("smps2", "smp%s2", &pmic5_ftsmps525_lv, "vdd-s2"), - RPMH_VREG("smps3", "smp%s3", &pmic5_ftsmps525_lv, "vdd-s3"), - RPMH_VREG("smps4", "smp%s4", &pmic5_ftsmps525_mv, "vdd-s4"), - RPMH_VREG("smps5", "smp%s5", &pmic5_ftsmps525_lv, "vdd-s5"), - RPMH_VREG("smps6", "smp%s6", &pmic5_ftsmps525_lv, "vdd-s6"), - RPMH_VREG("smps7", "smp%s7", &pmic5_ftsmps525_lv, "vdd-s7"), - RPMH_VREG("smps8", "smp%s8", &pmic5_ftsmps525_lv, "vdd-s8"), - RPMH_VREG("smps9", "smp%s9", &pmic5_ftsmps525_lv, "vdd-s9"), - RPMH_VREG("smps10", "smp%s10", &pmic5_ftsmps525_lv, "vdd-s10"), - RPMH_VREG("ldo1", "ldo%s1", &pmic5_nldo515, "vdd-l1"), - RPMH_VREG("ldo2", "ldo%s2", &pmic5_nldo515, "vdd-l2-18"), - RPMH_VREG("ldo3", "ldo%s3", &pmic5_nldo515, "vdd-l3"), - RPMH_VREG("ldo4", "ldo%s4", &pmic5_nldo515, "vdd-l4-l16"), - RPMH_VREG("ldo5", "ldo%s5", &pmic5_pldo_lv, "vdd-l5-l6"), - RPMH_VREG("ldo6", "ldo%s6", &pmic5_pldo_lv, "vdd-l5-l6"), - RPMH_VREG("ldo7", "ldo%s7", &pmic5_nldo515, "vdd-l7"), - RPMH_VREG("ldo8", "ldo%s8", &pmic5_nldo515, "vdd-l8-l9"), - RPMH_VREG("ldo9", "ldo%s9", &pmic5_nldo515, "vdd-l8-l9"), - RPMH_VREG("ldo10", "ldo%s10", &pmic5_pldo, "vdd-l10"), - RPMH_VREG("ldo11", "ldo%s11", &pmic5_pldo, "vdd-l11-l13"), - RPMH_VREG("ldo12", "ldo%s12", &pmic5_nldo515, "vdd-l12"), - RPMH_VREG("ldo13", "ldo%s13", &pmic5_pldo, "vdd-l11-l13"), - RPMH_VREG("ldo14", "ldo%s14", &pmic5_nldo515, "vdd-l14"), - RPMH_VREG("ldo15", "ldo%s15", &pmic5_nldo515, "vdd-l15"), - RPMH_VREG("ldo16", "ldo%s16", &pmic5_nldo515, "vdd-l4-l16"), - RPMH_VREG("ldo17", "ldo%s17", &pmic5_nldo515, "vdd-l17"), - /* ldo18 not configured */ - RPMH_VREG("ldo19", "ldo%s19", &pmic5_nldo515, "vdd-l19"), - RPMH_VREG("ldo20", "ldo%s20", &pmic5_nldo515, "vdd-l20-l21"), - RPMH_VREG("ldo21", "ldo%s21", &pmic5_nldo515, "vdd-l20-l21"), -}; - -static const struct rpmh_vreg_init_data pm7325_vreg_data[] = { - RPMH_VREG("smps1", "smp%s1", &pmic5_hfsmps510, "vdd-s1"), - RPMH_VREG("smps2", "smp%s2", &pmic5_ftsmps520, "vdd-s2"), - RPMH_VREG("smps3", "smp%s3", &pmic5_ftsmps520, "vdd-s3"), - RPMH_VREG("smps4", "smp%s4", &pmic5_ftsmps520, "vdd-s4"), - RPMH_VREG("smps5", "smp%s5", &pmic5_ftsmps520, "vdd-s5"), - RPMH_VREG("smps6", "smp%s6", &pmic5_ftsmps520, "vdd-s6"), - RPMH_VREG("smps7", "smp%s7", &pmic5_ftsmps520, "vdd-s7"), - RPMH_VREG("smps8", "smp%s8", &pmic5_hfsmps510, "vdd-s8"), - RPMH_VREG("ldo1", "ldo%s1", &pmic5_nldo, "vdd-l1-l4-l12-l15"), - RPMH_VREG("ldo2", "ldo%s2", &pmic5_pldo, "vdd-l2-l7"), - RPMH_VREG("ldo3", "ldo%s3", &pmic5_nldo, "vdd-l3"), - RPMH_VREG("ldo4", "ldo%s4", &pmic5_nldo, "vdd-l1-l4-l12-l15"), - RPMH_VREG("ldo5", "ldo%s5", &pmic5_nldo, "vdd-l5"), - RPMH_VREG("ldo6", "ldo%s6", &pmic5_nldo, "vdd-l6-l9-l10"), - RPMH_VREG("ldo7", "ldo%s7", &pmic5_pldo, "vdd-l2-l7"), - RPMH_VREG("ldo8", "ldo%s8", &pmic5_nldo, "vdd-l8"), - RPMH_VREG("ldo9", "ldo%s9", &pmic5_nldo, "vdd-l6-l9-l10"), - RPMH_VREG("ldo10", "ldo%s10", &pmic5_nldo, "vdd-l6-l9-l10"), - RPMH_VREG("ldo11", "ldo%s11", &pmic5_pldo_lv, "vdd-l11-l17-l18-l19"), - RPMH_VREG("ldo12", "ldo%s12", &pmic5_nldo, "vdd-l1-l4-l12-l15"), - RPMH_VREG("ldo13", "ldo%s13", &pmic5_nldo, "vdd-l13"), - RPMH_VREG("ldo14", "ldo%s14", &pmic5_nldo, "vdd-l14-l16"), - RPMH_VREG("ldo15", "ldo%s15", &pmic5_nldo, "vdd-l1-l4-l12-l15"), - RPMH_VREG("ldo16", "ldo%s16", &pmic5_nldo, "vdd-l14-l16"), - RPMH_VREG("ldo17", "ldo%s17", &pmic5_pldo_lv, "vdd-l11-l17-l18-l19"), - RPMH_VREG("ldo18", "ldo%s18", &pmic5_pldo_lv, "vdd-l11-l17-l18-l19"), - RPMH_VREG("ldo19", "ldo%s19", &pmic5_pldo_lv, "vdd-l11-l17-l18-l19"), - {} -}; - -static const struct rpmh_vreg_init_data pmr735a_vreg_data[] = { - RPMH_VREG("smps1", "smp%s1", &pmic5_ftsmps520, "vdd-s1"), - RPMH_VREG("smps2", "smp%s2", &pmic5_ftsmps520, "vdd-s2"), - RPMH_VREG("smps3", "smp%s3", &pmic5_hfsmps515, "vdd-s3"), - RPMH_VREG("ldo1", "ldo%s1", &pmic5_nldo, "vdd-l1-l2"), - RPMH_VREG("ldo2", "ldo%s2", &pmic5_nldo, "vdd-l1-l2"), - RPMH_VREG("ldo3", "ldo%s3", &pmic5_nldo, "vdd-l3"), - RPMH_VREG("ldo4", "ldo%s4", &pmic5_pldo_lv, "vdd-l4"), - RPMH_VREG("ldo5", "ldo%s5", &pmic5_nldo, "vdd-l5-l6"), - RPMH_VREG("ldo6", "ldo%s6", &pmic5_nldo, "vdd-l5-l6"), - RPMH_VREG("ldo7", "ldo%s7", &pmic5_pldo, "vdd-l7-bob"), - {} -}; - -static const struct rpmh_vreg_init_data pm660_vreg_data[] = { - RPMH_VREG("smps1", "smp%s1", &pmic4_ftsmps426, "vdd-s1"), - RPMH_VREG("smps2", "smp%s2", &pmic4_ftsmps426, "vdd-s2"), - RPMH_VREG("smps3", "smp%s3", &pmic4_ftsmps426, "vdd-s3"), - RPMH_VREG("smps4", "smp%s4", &pmic4_hfsmps3, "vdd-s4"), - RPMH_VREG("smps5", "smp%s5", &pmic4_hfsmps3, "vdd-s5"), - RPMH_VREG("smps6", "smp%s6", &pmic4_hfsmps3, "vdd-s6"), - RPMH_VREG("ldo1", "ldo%s1", &pmic4_nldo, "vdd-l1-l6-l7"), - RPMH_VREG("ldo2", "ldo%s2", &pmic4_nldo, "vdd-l2-l3"), - RPMH_VREG("ldo3", "ldo%s3", &pmic4_nldo, "vdd-l2-l3"), - /* ldo4 is inaccessible on PM660 */ - RPMH_VREG("ldo5", "ldo%s5", &pmic4_nldo, "vdd-l5"), - RPMH_VREG("ldo6", "ldo%s6", &pmic4_nldo, "vdd-l1-l6-l7"), - RPMH_VREG("ldo7", "ldo%s7", &pmic4_nldo, "vdd-l1-l6-l7"), - RPMH_VREG("ldo8", "ldo%s8", &pmic4_pldo_lv, "vdd-l8-l9-l10-l11-l12-l13-l14"), - RPMH_VREG("ldo9", "ldo%s9", &pmic4_pldo_lv, "vdd-l8-l9-l10-l11-l12-l13-l14"), - RPMH_VREG("ldo10", "ldo%s10", &pmic4_pldo_lv, "vdd-l8-l9-l10-l11-l12-l13-l14"), - RPMH_VREG("ldo11", "ldo%s11", &pmic4_pldo_lv, "vdd-l8-l9-l10-l11-l12-l13-l14"), - RPMH_VREG("ldo12", "ldo%s12", &pmic4_pldo_lv, "vdd-l8-l9-l10-l11-l12-l13-l14"), - RPMH_VREG("ldo13", "ldo%s13", &pmic4_pldo_lv, "vdd-l8-l9-l10-l11-l12-l13-l14"), - RPMH_VREG("ldo14", "ldo%s14", &pmic4_pldo_lv, "vdd-l8-l9-l10-l11-l12-l13-l14"), - RPMH_VREG("ldo15", "ldo%s15", &pmic4_pldo, "vdd-l15-l16-l17-l18-l19"), - RPMH_VREG("ldo16", "ldo%s16", &pmic4_pldo, "vdd-l15-l16-l17-l18-l19"), - RPMH_VREG("ldo17", "ldo%s17", &pmic4_pldo, "vdd-l15-l16-l17-l18-l19"), - RPMH_VREG("ldo18", "ldo%s18", &pmic4_pldo, "vdd-l15-l16-l17-l18-l19"), - RPMH_VREG("ldo19", "ldo%s19", &pmic4_pldo, "vdd-l15-l16-l17-l18-l19"), - {} -}; - -static const struct rpmh_vreg_init_data pm660l_vreg_data[] = { - RPMH_VREG("smps1", "smp%s1", &pmic4_ftsmps426, "vdd-s1"), - RPMH_VREG("smps2", "smp%s2", &pmic4_ftsmps426, "vdd-s2"), - RPMH_VREG("smps3", "smp%s3", &pmic4_ftsmps426, "vdd-s3-s4"), - RPMH_VREG("smps5", "smp%s5", &pmic4_ftsmps426, "vdd-s5"), - RPMH_VREG("ldo1", "ldo%s1", &pmic4_nldo, "vdd-l1-l9-l10"), - RPMH_VREG("ldo2", "ldo%s2", &pmic4_pldo, "vdd-l2"), - RPMH_VREG("ldo3", "ldo%s3", &pmic4_pldo, "vdd-l3-l5-l7-l8"), - RPMH_VREG("ldo4", "ldo%s4", &pmic4_pldo, "vdd-l4-l6"), - RPMH_VREG("ldo5", "ldo%s5", &pmic4_pldo, "vdd-l3-l5-l7-l8"), - RPMH_VREG("ldo6", "ldo%s6", &pmic4_pldo, "vdd-l4-l6"), - RPMH_VREG("ldo7", "ldo%s7", &pmic4_pldo, "vdd-l3-l5-l7-l8"), - RPMH_VREG("ldo8", "ldo%s8", &pmic4_pldo, "vdd-l3-l5-l7-l8"), - RPMH_VREG("bob", "bob%s1", &pmic4_bob, "vdd-bob"), {} }; static int rpmh_regulator_probe(struct platform_device *pdev) @@ -1602,128 +433,16 @@ static int rpmh_regulator_probe(struct platform_device *pdev) return 0; } static const struct of_device_id __maybe_unused rpmh_regulator_match_table[] = { - { - .compatible = "qcom,pm8005-rpmh-regulators", - .data = pm8005_vreg_data, - }, - { - .compatible = "qcom,pm8009-rpmh-regulators", - .data = pm8009_vreg_data, - }, - { - .compatible = "qcom,pm8009-1-rpmh-regulators", - .data = pm8009_1_vreg_data, - }, - { - .compatible = "qcom,pm8010-rpmh-regulators", - .data = pm8010_vreg_data, - }, { .compatible = "qcom,pm8150-rpmh-regulators", .data = pm8150_vreg_data, }, { .compatible = "qcom,pm8150l-rpmh-regulators", .data = pm8150l_vreg_data, }, - { - .compatible = "qcom,pm8350-rpmh-regulators", - .data = pm8350_vreg_data, - }, - { - .compatible = "qcom,pm8350c-rpmh-regulators", - .data = pm8350c_vreg_data, - }, - { - .compatible = "qcom,pm8450-rpmh-regulators", - .data = pm8450_vreg_data, - }, - { - .compatible = "qcom,pm8550-rpmh-regulators", - .data = pm8550_vreg_data, - }, - { - .compatible = "qcom,pm8550ve-rpmh-regulators", - .data = pm8550ve_vreg_data, - }, - { - .compatible = "qcom,pm8550vs-rpmh-regulators", - .data = pm8550vs_vreg_data, - }, - { - .compatible = "qcom,pm8998-rpmh-regulators", - .data = pm8998_vreg_data, - }, - { - .compatible = "qcom,pmg1110-rpmh-regulators", - .data = pmg1110_vreg_data, - }, - { - .compatible = "qcom,pmi8998-rpmh-regulators", - .data = pmi8998_vreg_data, - }, - { - .compatible = "qcom,pm6150-rpmh-regulators", - .data = pm6150_vreg_data, - }, - { - .compatible = "qcom,pm6150l-rpmh-regulators", - .data = pm6150l_vreg_data, - }, - { - .compatible = "qcom,pm6350-rpmh-regulators", - .data = pm6350_vreg_data, - }, - { - .compatible = "qcom,pmc8180-rpmh-regulators", - .data = pm8150_vreg_data, - }, - { - .compatible = "qcom,pmc8180c-rpmh-regulators", - .data = pm8150l_vreg_data, - }, - { - .compatible = "qcom,pmc8380-rpmh-regulators", - .data = pmc8380_vreg_data, - }, - { - .compatible = "qcom,pmm8155au-rpmh-regulators", - .data = pmm8155au_vreg_data, - }, - { - .compatible = "qcom,pmm8654au-rpmh-regulators", - .data = pmm8654au_vreg_data, - }, - { - .compatible = "qcom,pmx55-rpmh-regulators", - .data = pmx55_vreg_data, - }, - { - .compatible = "qcom,pmx65-rpmh-regulators", - .data = pmx65_vreg_data, - }, - { - .compatible = "qcom,pmx75-rpmh-regulators", - .data = pmx75_vreg_data, - }, - { - .compatible = "qcom,pm7325-rpmh-regulators", - .data = pm7325_vreg_data, - }, - { - .compatible = "qcom,pmr735a-rpmh-regulators", - .data = pmr735a_vreg_data, - }, - { - .compatible = "qcom,pm660-rpmh-regulators", - .data = pm660_vreg_data, - }, - { - .compatible = "qcom,pm660l-rpmh-regulators", - .data = pm660l_vreg_data, - }, {} }; MODULE_DEVICE_TABLE(of, rpmh_regulator_match_table); From patchwork Mon Jul 15 10:08:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 812620 Delivered-To: patch@linaro.org Received: by 2002:adf:fac3:0:b0:367:895a:4699 with SMTP id a3csp1725089wrs; Mon, 15 Jul 2024 03:11:50 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVE7AD/614gIbXi6Ciw1lNm0IGDPp24bwfR4/USpQbIK3xftlbMt4hh4S2cmiBR44QEi1xCSOJmOYSVXBdABV+H X-Google-Smtp-Source: AGHT+IHU5yTJj5yt90G3e2lHwEjLUX17ZUcWuyXODfR1RC/bwBWOWsDkQfzP7i+j15XuFgfJU+Dq X-Received: by 2002:a17:906:8c3:b0:a74:e717:4259 with SMTP id a640c23a62f3a-a780b704f06mr1094683666b.41.1721038310374; Mon, 15 Jul 2024 03:11:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721038310; cv=none; d=google.com; s=arc-20160816; b=vXt4vXepkkk0gBCnC3bPYfYHbBGJ0sjpjh5CcMN9ZC5euJ/I4F55R3lC77nSf0+GWI O4+vOl1lh7KP5223NkB325pqfNHs5DEk/aPlfUcRwYWbiXWd0BLiIBF6f2NQ/1rUqdX0 +S32xkFU77M9e57+efWG8Z1u0u7x9e/cL5pzCtKBjWVkbcQ2yqyqCNFzGwJdJitvp0Sn /lsOZmqBkniYJ/g9pMBPnhHEzG0ektqe1JjzcLtMTfr1eCUJi4Zt/lRodOgnOCsqRadZ l/oBqwX1DYfHTbBqsd4o9CRO6t4A9tTnGtf/yBn0zKoLun8llC90CsAYeCv6CcbgfnDu iChw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:cc:to:in-reply-to:references :message-id:content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=ucK3zIA7EbO5G9x/Ruo1tW04nQP6COUjq51be8zAaoM=; fh=zcTfjI3NycJyTuuOJ9uzXxS7wfOr4sYKS7eKveHEFzw=; b=EpDJqNdYHBDlVKkamI4JRsTnsrW6zFA6hH3kkKK/uUdZiqQzpTDFL4qH5i07+kbyVa fzl8RnIw7FXGHj4iXBQ4MZPzlQLW0jytRv67zzp2/D8Gz94wKlwgVlupKYEeroclycQo 9EwCw2uz87GRZlvxdkkNqlEQ0PkMJ3bfYJn7eE20DGy/34trmXbMyUBCAKmk9f+YLkfY dp3JMR4PXIQRwYikA39+XmJrfK0eHFHw7K4Y4BuF0LXncS9CYWu3YyxOt4NqkaBdFv80 fGB6oHFLJGIuRAFQpjMSYA4tuCJNA8zU2Sj/X/munZl7kV1uTw0aALsBRV7MpcKYHi3U 8XbQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XJtxTrnv; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id a640c23a62f3a-a79bc7c1b93si241192866b.404.2024.07.15.03.11.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 03:11:50 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XJtxTrnv; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C2DB3887EB; Mon, 15 Jul 2024 12:08:57 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org 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=linaro.org header.i=@linaro.org header.b="XJtxTrnv"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3B6D788889; Mon, 15 Jul 2024 12:08:56 +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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) (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 2250988853 for ; Mon, 15 Jul 2024 12:08:54 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=caleb.connolly@linaro.org Received: by mail-ed1-x531.google.com with SMTP id 4fb4d7f45d1cf-58b447c5112so5513951a12.3 for ; Mon, 15 Jul 2024 03:08:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721038133; x=1721642933; darn=lists.denx.de; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=ucK3zIA7EbO5G9x/Ruo1tW04nQP6COUjq51be8zAaoM=; b=XJtxTrnvle24H8r9XxzABa058eVDVrJXLzK5pfF3zDGqs3VUbh9WHv7dVtoMhaqOTK Sn1KCX67Pa7gZ5djcACIEGrHa18D7IioWKvCSpG9COB9oxfu6ouXi6M3O3IyEucj1FYE shPPfvoXOYxUayUXtz1IGB/l12D5I5GR9KtYp29DuOyaiKQZm0FPQ4eS+4wz5nbaoSIF IA7US2mg9LuIMsgtVdYaq2VJVLumGHwgPLxstB97AUNXPUSuGzH0PbpA6GExGuneimcd df5vvvFlRc3lbysDG3+bgMLiU/5kWemUffS1NxU0FQJMqoL75T63QoLAj4aowIJuahoD 6QKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721038133; x=1721642933; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ucK3zIA7EbO5G9x/Ruo1tW04nQP6COUjq51be8zAaoM=; b=kZdot4Z4anWpC8C3qxvURzVpTQAgHJvD6TWc+Js6VgJSMNxR9Tcr+b0u9lfERLhRE8 T7A5tDVke1Qw+6k2rjmnY2S3JJg+TPkNhVH4HBxViXYT56/K4d8AoHHiICRdk1y8DGfz PzRMHCzNn5kzpUhnMV94dYXHwNENxij+NPoHJRCe6TXNR+SRjkqwbYySzG4WBqb2goHM 2RJ5STUXx37W+ZMvUj+MusEJC6Gcu3lRnpK5WeQ82lhjKCAauaD2F5DXowUOgYkcZ1vz EKaLiV1E5uE61xFbP20HqzVLfmcIW5/v+kWGUCzqoo/1Qw6IVrV5DStaYaKyBsgwSsP5 QwWg== X-Gm-Message-State: AOJu0Yy9hpJynz4TX1BGDuvMX4zaVGSpIhAXvFqkk88NAIyuLiAP4jGZ Ok0N3ZLz/AfCY0XlnB9rHMpmSV3CIYVBWGxsKjQ5EnmWkB2i5rm/AzLvd1bbGsI= X-Received: by 2002:a17:906:260f:b0:a77:c364:c4e9 with SMTP id a640c23a62f3a-a780b705312mr1153496366b.45.1721038133637; Mon, 15 Jul 2024 03:08:53 -0700 (PDT) Received: from [192.168.0.113] ([2a02:8109:aa0d:be00::7424]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a79bc5b7eb4sm198102266b.60.2024.07.15.03.08.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 03:08:53 -0700 (PDT) From: Caleb Connolly Date: Mon, 15 Jul 2024 12:08:20 +0200 Subject: [PATCH v6 21/24] power: regulator: qcom-rpmh-regulator: port ops to U-Boot MIME-Version: 1.0 Message-Id: <20240715-b4-qcom-rpmh-v6-21-0c948a25d018@linaro.org> References: <20240715-b4-qcom-rpmh-v6-0-0c948a25d018@linaro.org> In-Reply-To: <20240715-b4-qcom-rpmh-v6-0-0c948a25d018@linaro.org> To: Tom Rini , Caleb Connolly , Neil Armstrong , Sumit Garg , Jaehoon Chung , Simon Glass Cc: u-boot@lists.denx.de, u-boot-qcom@groups.io X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=9430; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=Sr0fFMnSXPacpM/eQM/aMYto6EZyS+TqU9f8AYSIiQo=; b=owEBbQKS/ZANAwAIAQWDMSsZX2S2AcsmYgBmlPUHbSlTEoMX7ImK3gvEe1IcJtYQt28bsTmVk mnB1jZam5mJAjMEAAEIAB0WIQS2UaFGPGq+0GkMVc0FgzErGV9ktgUCZpT1BwAKCRAFgzErGV9k tlIHD/9uD7JWzLBa10h2TOYs5GcKshYSudboEC5332SwmpBfcG9Wv8WgKSTyL3uSKZ0KqlpeU6M /j8C9C90wEhFajTaIlTBPF88F77VEUoHD2pI7RM/8gDNIKpbqrKE25asTY0wh1VlfH52O0cx4S0 Q/7gN7n+nl75e5M54AK8D8zpgeUiRPFfPwZdrArA9mj56WnLbEMFMwlONaa2vEmGU1vr3PYnGUv kMdr04OxvGXJnUGNPI2BSHzWib5p1EnR1caLxHINZcdAQTY9QNPBYhioeGOIlgXbb781P1kjJbR zTkskBaO449WEb7ZbRWErDqfMRDc9ELtQG0sapWcWW70Y0h516lYXnYMdvTmu/Rt9fDfUXBxY3u UhLqH4WLwcFLHFTZP5wp1Lj3KVNzphNzfKw3bHF85MzGLeSpNapwKVDvc9LaiRYJV0yziWypqAx zawSVWMSNXcspIbYe4w2bUiqjz7LDqX2lTiHHWQCeVJMs30XjNEsvpavZse1hzf/jDtjGdmlVkr WeQC5Dw/HfftcdRRnwCBEZBRBMJDvu6ZjhGKguOD8GtoDoX7dWChBYZWI1Tpma2Hrb7EXxNZZty 9MIDzxI21jdy1Q326/hvdxvm+v6s4he994P2hyFavbjONL1gwyJCSc+3Ac4P0dIKADuIbBHdzE9 Vjy3NkfPzSrI9zw== X-Developer-Key: i=caleb.connolly@linaro.org; a=openpgp; fpr=83B24DA7FE145076BC38BB250CD904EB673A7C47 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.8 at phobos.denx.de X-Virus-Status: Clean Port over the regulator ops to U-Boot's regulator API. Add back the pmic5 mode map using U-Boot dm_regulator_mode API and adjust the pmic5_pldo and pmic5_pldo_lv definitions. No functional changes. Acked-by: Sumit Garg Signed-off-by: Caleb Connolly --- drivers/power/regulator/qcom-rpmh-regulator.c | 158 ++++++++++++++------------ 1 file changed, 87 insertions(+), 71 deletions(-) diff --git a/drivers/power/regulator/qcom-rpmh-regulator.c b/drivers/power/regulator/qcom-rpmh-regulator.c index 2a8e8f9ac444..b716b380c148 100644 --- a/drivers/power/regulator/qcom-rpmh-regulator.c +++ b/drivers/power/regulator/qcom-rpmh-regulator.c @@ -192,87 +192,96 @@ struct rpmh_vreg_init_data { * * Return: 0 on success, errno on failure */ static int rpmh_regulator_send_request(struct rpmh_vreg *vreg, - struct tcs_cmd *cmd, bool wait_for_ack) + const struct tcs_cmd *cmd, bool wait_for_ack) { int ret; if (wait_for_ack || vreg->always_wait_for_ack) - ret = rpmh_write(vreg->dev, RPMH_ACTIVE_ONLY_STATE, cmd, 1); + ret = rpmh_write(vreg->dev->parent, RPMH_ACTIVE_ONLY_STATE, cmd, 1); else - ret = rpmh_write_async(vreg->dev, RPMH_ACTIVE_ONLY_STATE, cmd, - 1); + ret = rpmh_write_async(vreg->dev->parent, RPMH_ACTIVE_ONLY_STATE, cmd, 1); return ret; } -static int _rpmh_regulator_vrm_set_voltage_sel(struct regulator_dev *rdev, - unsigned int selector, bool wait_for_ack) +static int _rpmh_regulator_vrm_set_value(struct udevice *rdev, + int uv, bool wait_for_ack) { - struct rpmh_vreg *vreg = rdev_get_drvdata(rdev); + struct rpmh_vreg *vreg = dev_get_priv(rdev); struct tcs_cmd cmd = { .addr = vreg->addr + RPMH_REGULATOR_REG_VRM_VOLTAGE, }; int ret; + unsigned int selector; - /* VRM voltage control register is set with voltage in millivolts. */ - cmd.data = DIV_ROUND_UP(regulator_list_voltage_linear_range(rdev, - selector), 1000); + selector = (uv - vreg->hw_data->voltage_range.min) / vreg->hw_data->voltage_range.step; + cmd.data = DIV_ROUND_UP(vreg->hw_data->voltage_range.min + + selector * vreg->hw_data->voltage_range.step, 1000); ret = rpmh_regulator_send_request(vreg, &cmd, wait_for_ack); if (!ret) - vreg->voltage_selector = selector; + vreg->uv = cmd.data * 1000; return ret; } -static int rpmh_regulator_vrm_set_voltage_sel(struct regulator_dev *rdev, - unsigned int selector) +static int rpmh_regulator_vrm_set_value(struct udevice *rdev, + int uv) { - struct rpmh_vreg *vreg = rdev_get_drvdata(rdev); + struct rpmh_vreg *vreg = dev_get_priv(rdev); + + debug("%s: set_value %d (current %d)\n", rdev->name, uv, vreg->uv); if (vreg->enabled == -EINVAL) { /* * Cache the voltage and send it later when the regulator is * enabled or disabled. */ - vreg->voltage_selector = selector; + vreg->uv = uv; return 0; } - return _rpmh_regulator_vrm_set_voltage_sel(rdev, selector, - selector > vreg->voltage_selector); + return _rpmh_regulator_vrm_set_value(rdev, uv, + uv > vreg->uv); } -static int rpmh_regulator_vrm_get_voltage_sel(struct regulator_dev *rdev) +static int rpmh_regulator_vrm_get_value(struct udevice *rdev) { - struct rpmh_vreg *vreg = rdev_get_drvdata(rdev); + struct rpmh_vreg *vreg = dev_get_priv(rdev); - return vreg->voltage_selector; + debug("%s: get_value %d\n", rdev->name, vreg->uv); + + return vreg->uv; } -static int rpmh_regulator_is_enabled(struct regulator_dev *rdev) +static int rpmh_regulator_is_enabled(struct udevice *rdev) { - struct rpmh_vreg *vreg = rdev_get_drvdata(rdev); + struct rpmh_vreg *vreg = dev_get_priv(rdev); - return vreg->enabled; + debug("%s: is_enabled %d\n", rdev->name, vreg->enabled); + + return vreg->enabled > 0; } -static int rpmh_regulator_set_enable_state(struct regulator_dev *rdev, - bool enable) +static int rpmh_regulator_set_enable_state(struct udevice *rdev, + bool enable) { - struct rpmh_vreg *vreg = rdev_get_drvdata(rdev); + struct rpmh_vreg *vreg = dev_get_priv(rdev); struct tcs_cmd cmd = { .addr = vreg->addr + RPMH_REGULATOR_REG_ENABLE, .data = enable, }; int ret; + debug("%s: set_enable %d (current %d)\n", rdev->name, enable, + vreg->enabled); + if (vreg->enabled == -EINVAL && - vreg->voltage_selector != -ENOTRECOVERABLE) { - ret = _rpmh_regulator_vrm_set_voltage_sel(rdev, - vreg->voltage_selector, true); + vreg->uv != -ENOTRECOVERABLE) { + ret = _rpmh_regulator_vrm_set_value(rdev, + vreg->uv, true); if (ret < 0) return ret; } @@ -282,47 +291,46 @@ static int rpmh_regulator_set_enable_state(struct regulator_dev *rdev, return ret; } -static int rpmh_regulator_enable(struct regulator_dev *rdev) -{ - return rpmh_regulator_set_enable_state(rdev, true); -} - -static int rpmh_regulator_disable(struct regulator_dev *rdev) -{ - return rpmh_regulator_set_enable_state(rdev, false); -} - static int rpmh_regulator_vrm_set_mode_bypass(struct rpmh_vreg *vreg, - unsigned int mode, bool bypassed) + unsigned int mode, bool bypassed) { struct tcs_cmd cmd = { .addr = vreg->addr + RPMH_REGULATOR_REG_VRM_MODE, }; - int pmic_mode; + struct dm_regulator_mode *pmic_mode; + int i; - if (mode > REGULATOR_MODE_STANDBY) + if (mode > REGULATOR_MODE_HPM) return -EINVAL; - pmic_mode = vreg->hw_data->pmic_mode_map[mode]; - if (pmic_mode < 0) - return pmic_mode; + for (i = 0; i < vreg->hw_data->n_modes; i++) { + pmic_mode = &vreg->hw_data->pmic_mode_map[i]; + if (pmic_mode->id == mode) + break; + } + if (pmic_mode->id != mode) { + printf("Invalid mode %d\n", mode); + return -EINVAL; + } if (bypassed) cmd.data = PMIC4_BOB_MODE_PASS; else - cmd.data = pmic_mode; + cmd.data = pmic_mode->id; return rpmh_regulator_send_request(vreg, &cmd, true); } -static int rpmh_regulator_vrm_set_mode(struct regulator_dev *rdev, - unsigned int mode) +static int rpmh_regulator_vrm_set_mode(struct udevice *rdev, + int mode) { - struct rpmh_vreg *vreg = rdev_get_drvdata(rdev); + struct rpmh_vreg *vreg = dev_get_priv(rdev); int ret; + debug("%s: set_mode %d (current %d)\n", rdev->name, mode, vreg->mode); + if (mode == vreg->mode) return 0; ret = rpmh_regulator_vrm_set_mode_bypass(vreg, mode, vreg->bypassed); @@ -331,51 +339,59 @@ static int rpmh_regulator_vrm_set_mode(struct regulator_dev *rdev, return ret; } -static unsigned int rpmh_regulator_vrm_get_mode(struct regulator_dev *rdev) +static int rpmh_regulator_vrm_get_mode(struct udevice *rdev) { - struct rpmh_vreg *vreg = rdev_get_drvdata(rdev); + struct rpmh_vreg *vreg = dev_get_priv(rdev); + + debug("%s: get_mode %d\n", rdev->name, vreg->mode); return vreg->mode; } +static const struct dm_regulator_ops rpmh_regulator_vrm_drms_ops = { + .get_value = rpmh_regulator_vrm_get_value, + .set_value = rpmh_regulator_vrm_set_value, + .set_enable = rpmh_regulator_set_enable_state, + .get_enable = rpmh_regulator_is_enabled, + .set_mode = rpmh_regulator_vrm_set_mode, + .get_mode = rpmh_regulator_vrm_get_mode, +}; -static const struct regulator_ops rpmh_regulator_vrm_drms_ops = { - .enable = rpmh_regulator_enable, - .disable = rpmh_regulator_disable, - .is_enabled = rpmh_regulator_is_enabled, - .set_voltage_sel = rpmh_regulator_vrm_set_voltage_sel, - .get_voltage_sel = rpmh_regulator_vrm_get_voltage_sel, - .list_voltage = regulator_list_voltage_linear_range, - .set_mode = rpmh_regulator_vrm_set_mode, - .get_mode = rpmh_regulator_vrm_get_mode, - .get_optimum_mode = rpmh_regulator_vrm_get_optimum_mode, +static struct dm_regulator_mode pmic_mode_map_pmic5_ldo[] = { + { + .id = REGULATOR_MODE_RETENTION, + .register_value = PMIC5_LDO_MODE_RETENTION, + .name = "PMIC5_LDO_MODE_RETENTION" + }, { + .id = REGULATOR_MODE_LPM, + .register_value = PMIC5_LDO_MODE_LPM, + .name = "PMIC5_LDO_MODE_LPM" + }, { + .id = REGULATOR_MODE_HPM, + .register_value = PMIC5_LDO_MODE_HPM, + .name = "PMIC5_LDO_MODE_HPM" + }, }; static const struct rpmh_vreg_hw_data pmic5_pldo = { .regulator_type = VRM, .ops = &rpmh_regulator_vrm_drms_ops, - .voltage_ranges = (struct linear_range[]) { - REGULATOR_LINEAR_RANGE(1504000, 0, 255, 8000), - }, - .n_linear_ranges = 1, + .voltage_range = REGULATOR_LINEAR_RANGE(1504000, 0, 255, 8000), .n_voltages = 256, .hpm_min_load_uA = 10000, .pmic_mode_map = pmic_mode_map_pmic5_ldo, - .of_map_mode = rpmh_regulator_pmic4_ldo_of_map_mode, + .n_modes = ARRAY_SIZE(pmic_mode_map_pmic5_ldo), }; static const struct rpmh_vreg_hw_data pmic5_pldo_lv = { .regulator_type = VRM, .ops = &rpmh_regulator_vrm_drms_ops, - .voltage_ranges = (struct linear_range[]) { - REGULATOR_LINEAR_RANGE(1504000, 0, 62, 8000), - }, - .n_linear_ranges = 1, + .voltage_range = REGULATOR_LINEAR_RANGE(1504000, 0, 62, 8000), .n_voltages = 63, .hpm_min_load_uA = 10000, .pmic_mode_map = pmic_mode_map_pmic5_ldo, - .of_map_mode = rpmh_regulator_pmic4_ldo_of_map_mode, + .n_modes = ARRAY_SIZE(pmic_mode_map_pmic5_ldo), }; #define RPMH_VREG(_name, _resource_name, _hw_data, _supply_name) \ { \ From patchwork Mon Jul 15 10:08:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 812622 Delivered-To: patch@linaro.org Received: by 2002:adf:fac3:0:b0:367:895a:4699 with SMTP id a3csp1725208wrs; Mon, 15 Jul 2024 03:12:12 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWc9+krKCTEsqZ74qRFrEQ5eYEWIltHH6lTQndyqTTfDdhcyP170R+04bv0sjx+6f6L34/5LYwKyfAjgE4ObK2H X-Google-Smtp-Source: AGHT+IHHalHHoCkunL6CKihr4eU+agJkd5TFdX3DH0dQryKw1KY44GsJHTk0EisWhms5gRYp5hjy X-Received: by 2002:a50:a457:0:b0:572:9962:7f0 with SMTP id 4fb4d7f45d1cf-594bc7c802bmr11055020a12.34.1721038332466; Mon, 15 Jul 2024 03:12:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721038332; cv=none; d=google.com; s=arc-20160816; b=Ggh2DVf4PjT9vcCpKW6qy/rcbOtKH5JdWkn4zB1SoAjwgOokarl2L5KHh7ZA0O0Xe8 +bCAfdphZ69o4QRYjOpwfRYQVnHfhXMK2uikziVbmO1A7PalbCMXIQOx0KIb87a//w74 QRIMonlLicuUKwyOoWsGkZkJhk9N8aA24DppML5MUdCYo50FcgXAorotKV5lIxezarpa 39tEpUMNJ0YoX5aaWDwlUz5ust3/gViIVdSvVqJaV9YRO5bpgfB6NNnSLjGVaT6n1Ncm oxRvKq0Cdf9+i/IsXxujp6BHVmf7Tq2pqb5Vc26ecgumT86GbiK+yi2PsMB0ngEuU/wk 6kjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:cc:to:in-reply-to:references :message-id:content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=ykNwaqwHkPIApVOJLoxhbPlmMoTloM+XmuakNGCqPoo=; fh=zcTfjI3NycJyTuuOJ9uzXxS7wfOr4sYKS7eKveHEFzw=; b=WMQ9LV1HGvkqTRR6lw0P95EYmiZf6yb5t94OEUcxLyy+MQfB6FUyxSY8XlDZ8ARbPv /EJyUqxevWg7uXXDBsj90EwMnc6hiERQm5bW0tOV5BzRi7+mbA9CsvVnbEbJr53hbvOT NGgvNWIR8SUZ4SJGLUgM6M0nXZ0djBKObNSXgwuygSKIAbzEN5q3lzqJz9z9OrF7rIVS yJbAQQf60cjX7eWE81wGkVO22wrEXXz+2Us3vqQIfpryZY2b02C6sgXfhJIVyB6flPFw 8Eef5o1c3L3H+yuGUE5/ctP2D9GqPGUv8CL7Nbl4ipVSru6Cq6d+MSQNsQX7iaM07MUG Ee0A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CrNiPCpN; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-59b26a8d8casi2364065a12.215.2024.07.15.03.12.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 03:12:12 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CrNiPCpN; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A9BA18889C; Mon, 15 Jul 2024 12:09:00 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org 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=linaro.org header.i=@linaro.org header.b="CrNiPCpN"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6E84488873; Mon, 15 Jul 2024 12:08:57 +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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) (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 633C988655 for ; Mon, 15 Jul 2024 12:08:55 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=caleb.connolly@linaro.org Received: by mail-ej1-x629.google.com with SMTP id a640c23a62f3a-a77e6dd7f72so494259166b.3 for ; Mon, 15 Jul 2024 03:08:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721038135; x=1721642935; darn=lists.denx.de; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=ykNwaqwHkPIApVOJLoxhbPlmMoTloM+XmuakNGCqPoo=; b=CrNiPCpNdJStWokfG2y+IluHDvMeTPo7TwfZw9I6wY1a5FXCIpmaryZQ5BRAOb4mdV n7PvQe3eaeXim8NQ0XPt/WI1RiS493ZM2GUjp+1WtgPwTv/CsGC3dsiDtBGFsqp51muz LxC1ns5CIDEJIjqkyfNYHrooogeTFuu4S0i9gNShejiae2IbGlXnOZ+rDeU1ZSwX+3Da iQVE0XUGYZR6189Cd+w5bdTQ0NnXVDsKqLyAYb7+sml6f2nfdYDMJAF0+yjM9cotKy33 OjoMxGrRDOupm734vnEIi+6zSRp8ii7JzXi/OSQI2IKL4FZvIg9+Ip+ikkIUQUPf9wZl TH4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721038135; x=1721642935; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ykNwaqwHkPIApVOJLoxhbPlmMoTloM+XmuakNGCqPoo=; b=IWbbYUUQ1Z2729POefH8ebZRnqJvfoMKrv2DfJF9C5Gd7/zyf8rEy9R98HwOMYhhpm zeAytwpamTinaA3uj2Xo3knZLjcir92SX54pWNVbuhgpaCqegnctIPpePyNEMBpQXPTB zUSZiuoP9KkYziktxdiz2FJ0EJlAs2zoHOmqPpmJ492alVsfGJv8xlEoakPEwFdDistV 3tdzIElsqVZtXRXDh0HwD5KEhumZ/3iwD3EWsq/rFTK/UbpvE9P8YpxxFnttMrjABnlM xBBEB5kXse53KpN0JoeP4WyjNQqGYFizxX1IWkdvoabLLw6M9MWCtl2Q2ud7o4SndkIG ptdg== X-Gm-Message-State: AOJu0YyI49dXo2DaY3yM3mRW5t0sz0TKOmvxYq4sz65V6rffgSUvDKBH XatZ3hUeuXNKgKcQ+7+QfO0BjYMYWjxk8+MBYyRqEuoRyOIB49JZULL9s0+/HfA= X-Received: by 2002:a17:906:7d1:b0:a6f:e47d:a965 with SMTP id a640c23a62f3a-a780b6ff0ecmr1178911266b.41.1721038134903; Mon, 15 Jul 2024 03:08:54 -0700 (PDT) Received: from [192.168.0.113] ([2a02:8109:aa0d:be00::7424]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a79bc5b7eb4sm198102266b.60.2024.07.15.03.08.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 03:08:54 -0700 (PDT) From: Caleb Connolly Date: Mon, 15 Jul 2024 12:08:21 +0200 Subject: [PATCH v6 22/24] power: regulator: qcom-rpmh-regulator: adjust probe for U-Boot MIME-Version: 1.0 Message-Id: <20240715-b4-qcom-rpmh-v6-22-0c948a25d018@linaro.org> References: <20240715-b4-qcom-rpmh-v6-0-0c948a25d018@linaro.org> In-Reply-To: <20240715-b4-qcom-rpmh-v6-0-0c948a25d018@linaro.org> To: Tom Rini , Caleb Connolly , Neil Armstrong , Sumit Garg , Jaehoon Chung , Simon Glass Cc: u-boot@lists.denx.de, u-boot-qcom@groups.io X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=5762; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=w5wfaxbbfnG/DU1q1d1PAsyrg5lHl41WCxBF+lLEiQs=; b=owEBbQKS/ZANAwAIAQWDMSsZX2S2AcsmYgBmlPUHmNUevwISHw+h3WpELnzo/Tl72K6ZpVCjn jVnaIAFUnKJAjMEAAEIAB0WIQS2UaFGPGq+0GkMVc0FgzErGV9ktgUCZpT1BwAKCRAFgzErGV9k tj5vD/0TttS8q1iwDNF7Knm8e7+FaBxfb0dA/yWpqFPondoKd+jXjSg5TQMcIZBJRhEt0myOGsJ XerUbK70trXfTYFBRW4eKTwujU1WPE7abLOEfp7Yqv9S1Mf9xEWwxGXWYwx+ObZQ0OLoJQ/d1FV 770wj7Rml5YE5DhiGVbBL5sogJtznFq+5Y84JZ2Y1mBYpMcMG2uUsI/3wOX4fGpkl33cziiaDym i9uC973VQ55dBWYuu9KZ9vHaZrRo4oq0MKn9L9hnIgMGY7Ihtgk4RFQ2vmXTlcyuFZMU3RX5ctU 5K3NkkacyXjHkMp+A5ZgLKWgeZhzSkir9eWN/8VANjsjn5t9I13alvJztQNkuX5Ba+UFKrtdIch C/MkJ9PYnboGjzn37uXuThFUF8Lgzxa54Xj/e6mUNCpPGOXyuuuyiLxZbX8TfrEkOdYqxo6tzhF h/39B58xTmT0LkXrKZmzULRfI80MNtiZLrSRrAQIAfYe0jFUu04xf11MhdBaxtDaX47zAuSiVZM dTo8EVByZdI4YB3zACovFqTGzfsEHgOFpKFQuAb6FOHhzV+PpnsprPFZdaB/+l3MnM96nUowUD4 nuGGX7IIXdw3zuDMLGMpD/qaQYhesr8VT+w5ejQ9QMMGPPPVlnFpRerMc01O3wuoxuIknKrIYJH M0r46QFdhd4nT4Q== X-Developer-Key: i=caleb.connolly@linaro.org; a=openpgp; fpr=83B24DA7FE145076BC38BB250CD904EB673A7C47 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.8 at phobos.denx.de X-Virus-Status: Clean Refactor initialization to use U-Boot's driver model and API. Acked-by: Sumit Garg Signed-off-by: Caleb Connolly --- drivers/power/regulator/qcom-rpmh-regulator.c | 136 +++++++++++++++++++------- 1 file changed, 102 insertions(+), 34 deletions(-) diff --git a/drivers/power/regulator/qcom-rpmh-regulator.c b/drivers/power/regulator/qcom-rpmh-regulator.c index b716b380c148..06fd3f31956f 100644 --- a/drivers/power/regulator/qcom-rpmh-regulator.c +++ b/drivers/power/regulator/qcom-rpmh-regulator.c @@ -411,66 +411,134 @@ static const struct rpmh_vreg_init_data pm8150l_vreg_data[] = { RPMH_VREG("ldo11", "ldo%s11", &pmic5_pldo, "vdd-l7-l11"), {} }; -static int rpmh_regulator_probe(struct platform_device *pdev) +/* probe an individual regulator */ +static int rpmh_regulator_probe(struct udevice *dev) { - struct device *dev = &pdev->dev; - const struct rpmh_vreg_init_data *vreg_data; - struct device_node *node; - struct rpmh_vreg *vreg; - const char *pmic_id; - int ret; + const struct rpmh_vreg_init_data *init_data; + struct rpmh_vreg *priv; + struct dm_regulator_uclass_plat *plat_data; - vreg_data = of_device_get_match_data(dev); - if (!vreg_data) + init_data = (const struct rpmh_vreg_init_data *)dev_get_driver_data(dev); + priv = dev_get_priv(dev); + plat_data = dev_get_uclass_plat(dev); + + priv->dev = dev; + priv->addr = cmd_db_read_addr(dev->name); + if (!priv->addr) { + dev_err(dev, "Failed to read RPMh address for %s\n", dev->name); return -ENODEV; - - ret = of_property_read_string(dev->of_node, "qcom,pmic-id", &pmic_id); - if (ret < 0) { - dev_err(dev, "qcom,pmic-id missing in DT node\n"); - return ret; } - for_each_available_child_of_node(dev->of_node, node) { - vreg = devm_kzalloc(dev, sizeof(*vreg), GFP_KERNEL); - if (!vreg) { - of_node_put(node); + priv->hw_data = init_data->hw_data; + priv->enabled = -EINVAL; + priv->uv = -ENOTRECOVERABLE; + if (ofnode_read_u32(dev_ofnode(dev), "regulator-initial-mode", &priv->mode)) + priv->mode = -EINVAL; + + plat_data->mode = priv->hw_data->pmic_mode_map; + plat_data->mode_count = priv->hw_data->n_modes; + + return 0; +} + +/* for non-drm, xob, or bypass regulators add additional driver definitions */ +U_BOOT_DRIVER(rpmh_regulator_drm) = { + .name = "rpmh_regulator_drm", + .id = UCLASS_REGULATOR, + .probe = rpmh_regulator_probe, + .priv_auto = sizeof(struct rpmh_vreg), + .ops = &rpmh_regulator_vrm_drms_ops, +}; + +/* This driver intentionally only supports a subset of the available regulators. + * This function checks to see if a given regulator node in DT matches a regulator + * defined in the driver. + */ +static const struct rpmh_vreg_init_data * +vreg_get_init_data(const struct rpmh_vreg_init_data *init_data, ofnode node) +{ + const struct rpmh_vreg_init_data *data; + + for (data = init_data; data->name; data++) { + if (!strcmp(data->name, ofnode_get_name(node))) + return data; + } + + return NULL; +} + +static int rpmh_regulators_bind(struct udevice *dev) +{ + const struct rpmh_vreg_init_data *init_data, *data; + const char *pmic_id; + char *name; + struct driver *drv; + ofnode node; + int ret; + size_t namelen; + + init_data = (const struct rpmh_vreg_init_data *)dev_get_driver_data(dev); + if (!init_data) { + dev_err(dev, "No RPMh regulator init data\n"); + return -ENODEV; + } + + pmic_id = ofnode_read_string(dev_ofnode(dev), "qcom,pmic-id"); + if (!pmic_id) { + dev_err(dev, "No PMIC ID\n"); + return -ENODEV; + } + + drv = lists_driver_lookup_name("rpmh_regulator_drm"); + + ofnode_for_each_subnode(node, dev_ofnode(dev)) { + data = vreg_get_init_data(init_data, node); + if (!data) + continue; + + /* %s is replaced with pmic_id, so subtract 2, then add 1 for the null terminator */ + namelen = strlen(data->resource_name) + strlen(pmic_id) - 1; + name = devm_kzalloc(dev, namelen, GFP_KERNEL); + ret = snprintf(name, namelen, data->resource_name, pmic_id); + if (ret < 0 || ret >= namelen) { + dev_err(dev, "Failed to create RPMh regulator name\n"); return -ENOMEM; } - ret = rpmh_regulator_init_vreg(vreg, dev, node, pmic_id, - vreg_data); + ret = device_bind_with_driver_data(dev, drv, name, (ulong)data, + node, NULL); if (ret < 0) { - of_node_put(node); + dev_err(dev, "Failed to bind RPMh regulator %s: %d\n", name, ret); return ret; } } return 0; } -static const struct of_device_id __maybe_unused rpmh_regulator_match_table[] = { +static const struct udevice_id rpmh_regulator_ids[] = { { .compatible = "qcom,pm8150-rpmh-regulators", - .data = pm8150_vreg_data, + .data = (ulong)pm8150_vreg_data, }, { .compatible = "qcom,pm8150l-rpmh-regulators", - .data = pm8150l_vreg_data, + .data = (ulong)pm8150l_vreg_data, }, - {} + { /* sentinal */ }, }; -MODULE_DEVICE_TABLE(of, rpmh_regulator_match_table); -static struct platform_driver rpmh_regulator_driver = { - .driver = { - .name = "qcom-rpmh-regulator", - .probe_type = PROBE_PREFER_ASYNCHRONOUS, - .of_match_table = of_match_ptr(rpmh_regulator_match_table), - }, - .probe = rpmh_regulator_probe, +/* Driver for a 'bank' of regulators. This creates devices for each + * individual regulator + */ +U_BOOT_DRIVER(rpmh_regulators) = { + .name = "rpmh_regulators", + .id = UCLASS_MISC, + .bind = rpmh_regulators_bind, + .of_match = rpmh_regulator_ids, + .ops = &rpmh_regulator_vrm_drms_ops, }; -module_platform_driver(rpmh_regulator_driver); MODULE_DESCRIPTION("Qualcomm RPMh regulator driver"); MODULE_LICENSE("GPL v2"); From patchwork Mon Jul 15 10:08:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 812623 Delivered-To: patch@linaro.org Received: by 2002:adf:fac3:0:b0:367:895a:4699 with SMTP id a3csp1725247wrs; Mon, 15 Jul 2024 03:12:23 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWLwCqMYVBYvMGCvwQJWMe3xGy5V9a5fQ28Pk/gp88ChVXnqQuY1jcEpBtSFeYbZ6wvXvJcH6QGsP7jCwMqevaB X-Google-Smtp-Source: AGHT+IFjWJo5n6lLj/hwCFU+XdwzxM5LRmyBFaPwXF/kzBASDlDT8r645PWMEyJFVs38GFY8dGck X-Received: by 2002:a17:906:1782:b0:a77:f2c5:84c4 with SMTP id a640c23a62f3a-a780b68a1d4mr1146188766b.12.1721038343482; Mon, 15 Jul 2024 03:12:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721038343; cv=none; d=google.com; s=arc-20160816; b=pAbxas1spRFxhemz5tRRh+c3ZWviNzGctqB60vneRAUgncmfqRIeDfy0YDgPR/XGvk s0cBkhzG55DjI29xr1Ji2DE1U+Gk5I3gP+uFMiLrKSJ85WnwbNtJ4XR4jacd+eacA433 nSSuAqhNMe7NSvZb+pTlGJQrwNa5O5Sc5GovmN6AAqSwJVcIGJDlKSYhfow+sM+Xq4Xu oDJhX8qHnXvSLJa65ExicV8j82wiYyu99q5AQaw9wQe7Obx94LctmtHut5enlsGSjdHM ZNHQgO+u4miOdF5Ot4dWfbypFweHO9EywsRDd7eDZEyn+Zt/dd/enGegnSX4onHmyg46 d6aA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:cc:to:in-reply-to:references :message-id:content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=OF76tLlohvDjPr8qGLbtCRZpdV9zcWQISuqlg021S0o=; fh=zcTfjI3NycJyTuuOJ9uzXxS7wfOr4sYKS7eKveHEFzw=; b=MlkH9tyjfpV08xFN8DaAGRk6qO3vSb8eeO3X6+lIHH6r4GGVqMh3MB75eLpvQhr1bW tSUAr3WCNuI4TnxXnmzz7XR1LwxlwZjS4+VFIe8dVAI0u82E2B5VuYWMCXABn0ZbQ0/Q yf1QQcHBdwyX5+GsLyBx54eHI5XZ6UJ0VDAcyWNNeuFuz/eEk4pA4RIUWk3slH5ZlFVy 3HrhBZwB/cLOFPOqaw/o6ywrhJzOqRdrQUFoI76YgHuiVi/2I9giBFdNCRwU0pQCCKRp rk2tKYMNvk8gGziM44zIIz3hZNxbMOb8JI/AkD64vNfXNLMyo00y3rtb0IKqho4W41Az dI3w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=susHVvLV; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id a640c23a62f3a-a79bc803ebbsi227211166b.699.2024.07.15.03.12.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 03:12:23 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=susHVvLV; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 65FB3888AC; Mon, 15 Jul 2024 12:09:01 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org 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=linaro.org header.i=@linaro.org header.b="susHVvLV"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 38C2288897; Mon, 15 Jul 2024 12:08:58 +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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) (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 451B088853 for ; Mon, 15 Jul 2024 12:08:56 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=caleb.connolly@linaro.org Received: by mail-ed1-x536.google.com with SMTP id 4fb4d7f45d1cf-58c947a6692so5207191a12.0 for ; Mon, 15 Jul 2024 03:08:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721038136; x=1721642936; darn=lists.denx.de; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=OF76tLlohvDjPr8qGLbtCRZpdV9zcWQISuqlg021S0o=; b=susHVvLV1Ib0h5XAck+GylMCLiT+15E7jUO9QQ608if39mNeS/fN9M7ntXtj9dV0ij slz/755yvPvftGn5DsGsS8MtEk8wXGd74JMNLy0kQtvjRmhWh8MXzw6NzSYwvzhqI5xf IwBM7n1RMS/EasA4tCn4QzylbDSGC3llR3GZSIxqipilDF9ravlhZ7TX+qOsirxHYckz 6VVG969hqVU4So+8Z07LS+vmW2c77bfbO0SKedVAf8S8uEDKYDZhoi3uadnJMdLaz8+9 S6ryMWAB+m/W9nt792ifR2mHIPjKTqvISWdeN8Kw2FHPXchlzqXQbey9jKwAq0TxOSof w+Gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721038136; x=1721642936; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OF76tLlohvDjPr8qGLbtCRZpdV9zcWQISuqlg021S0o=; b=hEaUvvGjYM/1ajvk00HPcxUcz98NTpzauKhDhmw6Hw8DuydQ8+FcVGq/mohH4V8en5 gld6aqfhAT2oD0yfUHcwmsD1H0gQxEJ/B2wGMjLEkqVpxfQnTYKDm7LiC9pr59JPrP7N NA62zYTyqt6Mm0yaIB4dZD5zXLC19ZU+o5An33nqtS22M+uC8vhvHwM1DYhw6+I1ERBL 2E7/D1mPKgdrG7kEbDcjQjw8jKd/tcLcEjJv4h00wi/+egRrepaozSxpoBLngTWUrwlQ 4+imq77DRqs7zJC+cqkHi+qBwiMK6evU/i9rvzXa9WBbB5/vqHmEY9z1oVVcDIf2oiTY 7AAw== X-Gm-Message-State: AOJu0Yy+KAgdbeBypYLRVt2GnJC6DBmuYKu8aSXxwMQt1KiG3tvFCIi0 b1UlGoT1PByj4YTHdmyGW4R72rL6++ft5ATglIPKmzxFgYHYTZBIOGbBaFHBJ7o= X-Received: by 2002:a17:906:4f01:b0:a6f:2ee7:b21a with SMTP id a640c23a62f3a-a780b89f406mr1261780766b.65.1721038135867; Mon, 15 Jul 2024 03:08:55 -0700 (PDT) Received: from [192.168.0.113] ([2a02:8109:aa0d:be00::7424]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a79bc5b7eb4sm198102266b.60.2024.07.15.03.08.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 03:08:55 -0700 (PDT) From: Caleb Connolly Date: Mon, 15 Jul 2024 12:08:22 +0200 Subject: [PATCH v6 23/24] power: regulator: qcom-rpmh-regulator: add build infra MIME-Version: 1.0 Message-Id: <20240715-b4-qcom-rpmh-v6-23-0c948a25d018@linaro.org> References: <20240715-b4-qcom-rpmh-v6-0-0c948a25d018@linaro.org> In-Reply-To: <20240715-b4-qcom-rpmh-v6-0-0c948a25d018@linaro.org> To: Tom Rini , Caleb Connolly , Neil Armstrong , Sumit Garg , Jaehoon Chung , Simon Glass Cc: u-boot@lists.denx.de, u-boot-qcom@groups.io X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=1943; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=Pso8b/uVAl+mlHoL5Qsl7woxZlxMQtfdivEwIMBQyfo=; b=owEBbQKS/ZANAwAIAQWDMSsZX2S2AcsmYgBmlPUHMVeLzjpThGvy6F+v5iPAgNRxeR4Zb3vCz IHsJtSL0zCJAjMEAAEIAB0WIQS2UaFGPGq+0GkMVc0FgzErGV9ktgUCZpT1BwAKCRAFgzErGV9k thHTD/9mE6vCqg7ptB2SxBRarFyg78cM6eKgD/SfCefmalLQgljV/exyjkfRIKT7pGN4ecbrqN7 5TSd1bdLaiFznRU50SYfu5FoORcxonwGC8r80U+vhp4/nE+VqHu31hFcwkXAMO8lAsBxsppUBvo 0dKly7vXHbyk++q1iJZdbzk+zWQAs7gjvgWcPS5fNY38AmUfPnxTV/1xSqsfibPTuA4XdXv1G4b TRtb/YafYJ77uYtXOLZxjTnmV0iOtoR3bTjpdnUjuAaac+rzsr0tSNgY6QXpoHMZLmyXwYMls7m xC2nD8RL5aTS45BIyJHhYW0lH6CQnmuCyZ8anj58X2VQIZfo6Qu5aE3sE9IZ9vxnshD9sFIjutq LkULwlHyye/uYTtH9rqjGI6a5TPcoPgE6g6r//VZSqxiTOdaEh/X9EGcFW4wXy5Q64h0tqnJQEZ 6nCcHxPlfH85+KPv6YtzNw54/3ClW+Dc+nsjN3Lyv7Y1X6MXjs5D9c+z/yQ7W7eI3PbB6bRYXfd glZJY471VAEtHBkEX37cCcmUCWSg8w+q6K5qsV1GOHBHKer6YRESeCK1N7q1DHzPjq4vj0e2FyY vHb5nGSxa9vNuVQXV4vZsqO9/4NmT8y1x5LO/024u+4wwjw7BKxiGvBJSH1M854Lwnd+rsPMfs1 meoV1q8vr6d0KCg== X-Developer-Key: i=caleb.connolly@linaro.org; a=openpgp; fpr=83B24DA7FE145076BC38BB250CD904EB673A7C47 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.8 at phobos.denx.de X-Virus-Status: Clean Add Kconfig and Makefile entries for this driver now that it can build for U-Boot. Signed-off-by: Caleb Connolly Reviewed-by: Neil Armstrong --- drivers/power/regulator/Kconfig | 8 ++++++++ drivers/power/regulator/Makefile | 1 + 2 files changed, 9 insertions(+) diff --git a/drivers/power/regulator/Kconfig b/drivers/power/regulator/Kconfig index 102ec7bc5f89..bc061c20d75e 100644 --- a/drivers/power/regulator/Kconfig +++ b/drivers/power/regulator/Kconfig @@ -215,8 +215,16 @@ config DM_REGULATOR_GPIO This config enables implementation of driver-model regulator uclass features for gpio regulators. The driver implements get/set for voltage value. +config DM_REGULATOR_QCOM_RPMH + bool "Enable driver model for Qualcomm RPMh regulator" + depends on DM_REGULATOR && QCOM_RPMH + ---help--- + Enable support for the Qualcomm RPMh regulator. The driver + implements get/set api for a limited set of regulators used + by u-boot. + config SPL_DM_REGULATOR_GPIO bool "Enable Driver Model for GPIO REGULATOR in SPL" depends on DM_REGULATOR_GPIO && SPL_GPIO select SPL_DM_REGULATOR_COMMON diff --git a/drivers/power/regulator/Makefile b/drivers/power/regulator/Makefile index f79932d83307..56a527612b74 100644 --- a/drivers/power/regulator/Makefile +++ b/drivers/power/regulator/Makefile @@ -20,8 +20,9 @@ obj-$(CONFIG_$(SPL_)REGULATOR_PWM) += pwm_regulator.o obj-$(CONFIG_$(SPL_)DM_REGULATOR_FAN53555) += fan53555.o obj-$(CONFIG_$(SPL_)DM_REGULATOR_COMMON) += regulator_common.o obj-$(CONFIG_$(SPL_)DM_REGULATOR_FIXED) += fixed.o obj-$(CONFIG_$(SPL_)DM_REGULATOR_GPIO) += gpio-regulator.o +obj-$(CONFIG_DM_REGULATOR_QCOM_RPMH) += qcom-rpmh-regulator.o obj-$(CONFIG_$(SPL_TPL_)REGULATOR_RK8XX) += rk8xx.o obj-$(CONFIG_DM_REGULATOR_S2MPS11) += s2mps11_regulator.o obj-$(CONFIG_REGULATOR_S5M8767) += s5m8767.o obj-$(CONFIG_DM_REGULATOR_SANDBOX) += sandbox.o From patchwork Mon Jul 15 10:08:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 812624 Delivered-To: patch@linaro.org Received: by 2002:adf:fac3:0:b0:367:895a:4699 with SMTP id a3csp1725287wrs; Mon, 15 Jul 2024 03:12:33 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXftUiL8+RAOna5VvuPcNV/b+lMmZ0c2UE4oFnVVZT6jnV5bEy6o1Ko8BQUgeJFlbOXFSHcGNHJKMRGIwMufjMu X-Google-Smtp-Source: AGHT+IFG7fWH9tfmL0gNGSbEAs0kiQ1UI53I6YXPr+/zK0iKhwk5Ip+gkjdz6DX9hoMniquMmhuT X-Received: by 2002:a50:955a:0:b0:599:8fef:3ee0 with SMTP id 4fb4d7f45d1cf-5998fef3f1emr5828691a12.36.1721038353236; Mon, 15 Jul 2024 03:12:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721038353; cv=none; d=google.com; s=arc-20160816; b=r5NBjhvTAQiGZQFZ7NIsr8FX5QDi4F+kL0NJs4nnwBwez6f2fUslG+gzA9QP7wxg4U eVtWFe7FaHleRAxfoMiFMhfuuBvCAOCgqzy2ZdhEGWod8lQdrxHWjFfuHct4nmO1pVwK wmBv0kmIbQClGnfdGfRtmUVQktiwi+ai/8MwsYXT3jvLJJqBLFU/q8ouEKrNRy39LARg YF/+ZCPC7KwniGTsOwGxC4Yhlsq9J8tVW/nVNz27/b5EMsSd1nfbifntV/1uFnieRRZY OJRNlDjTi2ExgCYbOSb962JD53BG8kCuSety1rrbwauJZrWlZBw6Xg6UWjydGZd6CmfP wngw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:cc:to:in-reply-to:references :message-id:content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=9fS17EJfpRajXdHZM+aigrI8s0lABvMSNi6Hs5iNv8s=; fh=zcTfjI3NycJyTuuOJ9uzXxS7wfOr4sYKS7eKveHEFzw=; b=AyfvRwxRPCNkuUhIOjNJ9lFyvIMoqukr06fnl4UdHor7DRZqgDYiZa0RytsMnkXk6F +g6gaKeSQT6uB5YpEQtlCUKC8PXnYcxI1GyKJS6MMBrVrYIUtHGFGdWC2hyfyMaJax/i P6NZ0Z9BoJdd/T05z+VvAV1/uhtvFOLNBEeAbuCpAd9ryreszTVEodggDRHStKe7QkQm iVJQW6VgIOl5HkoiYrlNLylnuSD/BzXS64PSg7a3JxrlxsI1aPJybuiYUY/2BBbr/fnr 79gRJPwzjEKqVxmShBirKNs4P2UU9yk2ggRXE8G2fnxm9Fwdyn6f+np36aE/fKU62KgV Odfw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=J1yMZI1x; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-59b26f656easi2333356a12.348.2024.07.15.03.12.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 03:12:33 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=J1yMZI1x; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9665C888B3; Mon, 15 Jul 2024 12:09:02 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org 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=linaro.org header.i=@linaro.org header.b="J1yMZI1x"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2884188897; Mon, 15 Jul 2024 12:08:59 +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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, UPPERCASE_50_75 autolearn=no autolearn_force=no version=3.4.2 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) (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 3D52288840 for ; Mon, 15 Jul 2024 12:08:57 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=caleb.connolly@linaro.org Received: by mail-ej1-x62c.google.com with SMTP id a640c23a62f3a-a77c4309fc8so525902766b.3 for ; Mon, 15 Jul 2024 03:08:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721038137; x=1721642937; darn=lists.denx.de; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=9fS17EJfpRajXdHZM+aigrI8s0lABvMSNi6Hs5iNv8s=; b=J1yMZI1x0HS9XfHP3SstVBP4fAjJbXa6XyexMX8EOT6jv1VT3Qkw7LCq4pABDFkP4i dUcGzm17GFQp44TCrygXFfo/MqGwU3mpQhoSp+Zkcjq/7XduvopvZK66BmIXPE8ZYoHK sljzSSsSYTuW8Wtl5Z1FqK03jtXTeJeW+SbsevYBQdB0BRZbYr+xX3njXo1FycNxQ13Z 49xMUilYgdHCM8WlPLlAc5tpdPeOuuaZoNUsLUoL8diPaVr7gRQEkjnlBwqXaWrk9sXu EjbUtTgxPHkWDOPP+DH/r8oTjiYvtDPSpRCmIdimo6u3w6aYzBjQ5IgctQ5TW5GGh0Ed 8/6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721038137; x=1721642937; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9fS17EJfpRajXdHZM+aigrI8s0lABvMSNi6Hs5iNv8s=; b=pP9LL9N4yQMNoH6jesfrhUTEZn1EbrNUQw9ncO6DKrVIM0Wks/+IeT8ei0YBpfyqGZ OKFovK/AXep6vo2EHTW8SuI7JNNqZGTNknCV4Esi8jA2i/GqW2AVYDKxJ/cwhSoOaw2+ 0X5/aLzFgLNS9cXWgWDyx/dBIR10H96rG5e98TRrPCTCaBIziMvNF/hCWUtI3p78rcc0 G1+DbIKP4hu4eEHHyKiIExK6T7qoG83ikZBQMwKq6xVMMR7Te6na7kk/Sp6BWdSCWBop Ik9kTFCvY0Dp2SI83NnnrcJLyf24Fi3WMsv6Je9TGautzN0mBxhbQS9eC057/NuOvAh6 GLPg== X-Gm-Message-State: AOJu0YyRYLC9eqfOTXJslV465bQijFHC59iEVQ9HrBrNNG/AX/a5sxDC oU5BNXHFMTv6Qfe5Zqt+3Iq/YgmPv857UKGksa3vZi0s9/HkAoTEsC0faxurdwM= X-Received: by 2002:a17:906:8c3:b0:a74:e717:4259 with SMTP id a640c23a62f3a-a780b704f06mr1094240866b.41.1721038136787; Mon, 15 Jul 2024 03:08:56 -0700 (PDT) Received: from [192.168.0.113] ([2a02:8109:aa0d:be00::7424]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a79bc5b7eb4sm198102266b.60.2024.07.15.03.08.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 03:08:56 -0700 (PDT) From: Caleb Connolly Date: Mon, 15 Jul 2024 12:08:23 +0200 Subject: [PATCH v6 24/24] qcom_defconfig: enable rpmh regulators MIME-Version: 1.0 Message-Id: <20240715-b4-qcom-rpmh-v6-24-0c948a25d018@linaro.org> References: <20240715-b4-qcom-rpmh-v6-0-0c948a25d018@linaro.org> In-Reply-To: <20240715-b4-qcom-rpmh-v6-0-0c948a25d018@linaro.org> To: Tom Rini , Caleb Connolly , Neil Armstrong , Sumit Garg , Jaehoon Chung , Simon Glass Cc: u-boot@lists.denx.de, u-boot-qcom@groups.io X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=1068; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=L0Z3UjALgAoIr8Xjx+Xnl++TWCG7gLgrnDFM/1FfGKY=; b=owEBbQKS/ZANAwAIAQWDMSsZX2S2AcsmYgBmlPUIakXZaY5tkFwRidvYEkF1JjwE5+/k3Cf0j cgICpHtJ9iJAjMEAAEIAB0WIQS2UaFGPGq+0GkMVc0FgzErGV9ktgUCZpT1CAAKCRAFgzErGV9k tro5EACi+BQKT6M5zFel4Ze8ksflYfzcHUl5Itu4nbCb8PF6MFTQ1Y5olEA9K5VCUvOTKdjZWr4 5qmZHJ08DCKkV/mteSKqF1TCWVtc+E8a9a2afLHMyqG58/QIkR1ePYyGyN3pPiHR2SK3STMDsWo 65SaMzcRCeG7jqgT+BWegiBi38TjvZ0nh82a9Wc7FbvvydnR6YpCxECTx1Xcdm0cfdTMKIAzSi2 JHl+DqIgsajEhmjOGOko3sxhAnPnfBPWNqHE/0z6hXxqRwpgfNyqVHUifGeBAElwr+4q7muboH3 nY7HXtYGS5VBiBJ3u+Uh6s7KXi9CcvipTWAa6+H4xGGZQiFjL+Kwpy29nO4Vm64n/ssm1u9R2kC S11N9ObgSMvQlFOulnaofrB6sFekj1SOVzeRFfBH0t6D4cxhLRTl1B4doq+jjRkqmtImteoHRpm Vnmap8Lyy0FDUDrFvHFZvHuD07vY34TxaRKrWvj5fCr3rHpVk+JVFiTt3PQOilepfTXJqo1AGe+ 5MKeam3Lp43gTump2OKkHdPZp/fkAcITk9rp7MFqHrPACRuFoQx29Mr0R7KMsunWirrsyODNbRR kXpLgQMYqISJGS4tUO/56zY5WHfg0vIlg9P/0GOpwWBZVgtxGf0TmmMFnbjOMVVrv1ZdQFpdB/v dy11tyhwRaaf87Q== X-Developer-Key: i=caleb.connolly@linaro.org; a=openpgp; fpr=83B24DA7FE145076BC38BB250CD904EB673A7C47 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.8 at phobos.denx.de X-Virus-Status: Clean Enable RPMh, cmd-db, and RPMh regulators. Additionally enable CMD_REGULATOR for debugging. Acked-by: Sumit Garg Signed-off-by: Caleb Connolly --- configs/qcom_defconfig | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/configs/qcom_defconfig b/configs/qcom_defconfig index ac5ffe772ade..1cbad9db72eb 100644 --- a/configs/qcom_defconfig +++ b/configs/qcom_defconfig @@ -35,8 +35,9 @@ CONFIG_CMD_UFS=y CONFIG_CMD_USB=y CONFIG_CMD_CAT=y CONFIG_CMD_BMP=y CONFIG_CMD_EFIDEBUG=y +CONFIG_CMD_REGULATOR=y CONFIG_CMD_LOG=y CONFIG_OF_LIVE=y CONFIG_BUTTON_QCOM_PMIC=y CONFIG_CLK=y @@ -90,11 +91,15 @@ CONFIG_PINCTRL_QCOM_SM8650=y CONFIG_DM_PMIC=y CONFIG_PMIC_QCOM=y CONFIG_DM_REGULATOR=y CONFIG_DM_REGULATOR_FIXED=y +CONFIG_DM_REGULATOR_QCOM_RPMH=y CONFIG_SCSI=y CONFIG_MSM_SERIAL=y CONFIG_MSM_GENI_SERIAL=y +CONFIG_SOC_QCOM=y +CONFIG_QCOM_COMMAND_DB=y +CONFIG_QCOM_RPMH=y CONFIG_SPMI_MSM=y CONFIG_SYSINFO=y CONFIG_SYSINFO_SMBIOS=y CONFIG_USB=y