From patchwork Mon Jan 16 00:33:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Minnekhanov X-Patchwork-Id: 1726857 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=postmarketos.org header.i=@postmarketos.org header.a=rsa-sha256 header.s=donut header.b=aLbtCj35; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NwD1M675zz23fp for ; Mon, 16 Jan 2023 11:49:11 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 29AA18555D; Mon, 16 Jan 2023 01:48:43 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=postmarketos.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=postmarketos.org header.i=@postmarketos.org header.b="aLbtCj35"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 10E4184F3E; Mon, 16 Jan 2023 01:33:57 +0100 (CET) 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_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from proxmox1.postmarketos.org (proxmox1.postmarketos.org [IPv6:2a01:4f8:a0:821d::2]) by phobos.denx.de (Postfix) with ESMTP id A114085258 for ; Mon, 16 Jan 2023 01:33:54 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=postmarketos.org Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=alexeymin@postmarketos.org Received: from localhost.localdomain (unknown [77.239.252.99]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by proxmox1.postmarketos.org (Postfix) with ESMTPSA id A591C1403D5; Mon, 16 Jan 2023 00:33:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=postmarketos.org; s=donut; t=1673829234; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OCiZ6hQOMqogYJdZ6FiDi3eNw/ck+9iezUioWCt6gzU=; b=aLbtCj35D6OHx/TG2zeyHtUsuh64JXFHVcpKikaOdiiFBifmTW8Tm8fpuvh02f6PBsZEqf 99Z2T8Out4+HoRBwi1CYaxlpLPhLRIY8LEIZaZzFLpf5S9bCBBEZ81KFRWh/JH79XRKjJA 3YzlvgiG5CRMOJNLSs0MO4ToNqJiIw4= From: Alexey Minnekhanov To: u-boot@lists.denx.de Cc: Sumit Garg , Dzmitry Sankouski , Ramon Fried , Mateusz Kulikowski , Alexey Minnekhanov Subject: [PATCH 2/5] spmi: msm: Fix parsing FDT and reading ARB version Date: Mon, 16 Jan 2023 03:33:12 +0300 Message-Id: <20230116003315.2325575-3-alexeymin@postmarketos.org> X-Mailer: git-send-email 2.38.2 In-Reply-To: <20230116003315.2325575-1-alexeymin@postmarketos.org> References: <20230116003315.2325575-1-alexeymin@postmarketos.org> MIME-Version: 1.0 X-Mailman-Approved-At: Mon, 16 Jan 2023 01:48:37 +0100 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.6 at phobos.denx.de X-Virus-Status: Clean First of all, use dev_read_addr_name() instead of dev_read_addr_index() to avoid confusion: most dts files have their regs specified in the wrong order, so driver is reading config reg and using it instead of core reg. Using names instead of indexes helps to avoid such errors. Second, same as Linux driver, use core reg to read version from [1]. This fixes reading incorrect arbiter version. Third, print addresses in hex, so it can be visually compared to values in DTS more easily. [1]: https://elixir.bootlin.com/linux/v6.1.6/source/drivers/spmi/spmi-pmic-arb.c#L1339 Signed-off-by: Alexey Minnekhanov Reviewed-by: Sumit Garg --- drivers/spmi/spmi-msm.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/spmi/spmi-msm.c b/drivers/spmi/spmi-msm.c index a9dcf5ab7f91..3df0f12c8b86 100644 --- a/drivers/spmi/spmi-msm.c +++ b/drivers/spmi/spmi-msm.c @@ -191,11 +191,12 @@ static int msm_spmi_probe(struct udevice *dev) u32 version; int i; - config_addr = dev_read_addr_index(dev, 0); - priv->spmi_core = dev_read_addr_index(dev, 1); - priv->spmi_obs = dev_read_addr_index(dev, 2); + /* DTS bindings: reg-names = "cnfg", "core", "obsrvr"; */ + config_addr = dev_read_addr_name(dev, "cnfg"); + priv->spmi_core = dev_read_addr_name(dev, "core"); + priv->spmi_obs = dev_read_addr_name(dev, "obsrvr"); - hw_ver = readl(config_addr + PMIC_ARB_VERSION); + hw_ver = readl(priv->spmi_core + PMIC_ARB_VERSION); if (hw_ver < PMIC_ARB_VERSION_V3_MIN) { priv->arb_ver = V2; @@ -218,9 +219,10 @@ static int msm_spmi_probe(struct udevice *dev) priv->spmi_obs == FDT_ADDR_T_NONE) return -EINVAL; - dev_dbg(dev, "priv->arb_chnl address (%llu)\n", priv->arb_chnl); - dev_dbg(dev, "priv->spmi_core address (%llu)\n", priv->spmi_core); - dev_dbg(dev, "priv->spmi_obs address (%llu)\n", priv->spmi_obs); + dev_dbg(dev, "priv->arb_chnl address (%llx)\n", priv->arb_chnl); + dev_dbg(dev, "priv->spmi_core address (%llx)\n", priv->spmi_core); + dev_dbg(dev, "priv->spmi_obs address (%llx)\n", priv->spmi_obs); + /* Scan peripherals connected to each SPMI channel */ for (i = 0; i < SPMI_MAX_PERIPH; i++) { uint32_t periph = readl(priv->arb_chnl + ARB_CHANNEL_OFFSET(i));