From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C0BCCC00A5A for ; Thu, 19 Jan 2023 08:36:21 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 47C9B8561D; Thu, 19 Jan 2023 09:36:19 +0100 (CET) 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="uiu0kuef"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E5F728561D; Thu, 19 Jan 2023 09:36:17 +0100 (CET) Received: from mail-vk1-xa2c.google.com (mail-vk1-xa2c.google.com [IPv6:2607:f8b0:4864:20::a2c]) (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 B35C085600 for ; Thu, 19 Jan 2023 09:36:14 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sumit.garg@linaro.org Received: by mail-vk1-xa2c.google.com with SMTP id q21so594588vka.3 for ; Thu, 19 Jan 2023 00:36:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=Bw1asiqoP0QqbtMPNs5TMXL3Q8nACQEP6vpFWn0iTRk=; b=uiu0kuefYALtnNh02dSwJ6umKv48jnULJerkhu+wnm7sEsQWKZMNNbUX/vEYgYs3bq V3tUFiNEsiJtMUJ4BKETqK6mAkJOcxg4NGdWh8JwHUbt2rgXiijQpgsVvDBA3r5wWbxW VlVkcEOjaguZ204S+6h8K/Sc8aMr9wsHGcNEdTEdpCtAdBQWO2eGoP2Zf/Ef9DxhuupE Af0hgxF92DzXvnh71e46SDqvzh/bXNePwKWL24s/kflEkFUDF4FkE11jxVUml3DuLVAY srPJNfotc1x58cm/sHuMgqFoAGzWs9gpCYsTU640M4NGBVz3NzQPPWief2pqCJq4oIqf MeHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Bw1asiqoP0QqbtMPNs5TMXL3Q8nACQEP6vpFWn0iTRk=; b=0Sv4HJwrkHBKc7hAm9xaqKf3qVc2o+ctsDrVM2kUNvsl6fB8wos25FKByIjSgicquA Ler1tlUffriWYPrffuafc/iMf5qCc+gCnuvjJ5AqEwZQbacqmbkJyyidNt+0UqC9cfJy hIzX7nk7fkeupMtiXESDhMhNx0Fu+PQ6N9qyUsCPPdy39Q0JantiuPLFAeJeBV3fuAPc +uksTyMowDxTHbsmm00cw0wW9nBCu/XbV9UNv+PFrEbd4mkF2xgLvXUFUOKmsWbshzD/ 8R+6/wYsL3R/sIzjIhoqooS77lns5lol1OcbB1kt0jkczSseilR96QGwVplXBtGYgaYM lRZA== X-Gm-Message-State: AFqh2ko0Xt0GrwMJ7Mowcob+lGBiqsWh9OA15nkDk8AFL0H3E5+vSMVm cxMyFpkGggtJAOO3xlCN2n5n/FmwjIDOlnm2HFw+Ew== X-Google-Smtp-Source: AMrXdXvMxJx+Oky/DjnUO4uaOGQzroSFivo0+lUGxSW5hLhs3lTfuBOy24A/TkJgnjuAnQPlzBmQuYmiy8aCqcIde3Q= X-Received: by 2002:a1f:fec5:0:b0:3d5:3549:d569 with SMTP id l188-20020a1ffec5000000b003d53549d569mr1292221vki.4.1674117373163; Thu, 19 Jan 2023 00:36:13 -0800 (PST) MIME-Version: 1.0 References: <20230116003315.2325575-1-alexeymin@postmarketos.org> <20230116003315.2325575-3-alexeymin@postmarketos.org> In-Reply-To: <20230116003315.2325575-3-alexeymin@postmarketos.org> From: Sumit Garg Date: Thu, 19 Jan 2023 14:06:02 +0530 Message-ID: Subject: Re: [PATCH 2/5] spmi: msm: Fix parsing FDT and reading ARB version To: Alexey Minnekhanov Cc: u-boot@lists.denx.de, Dzmitry Sankouski , Ramon Fried , Mateusz Kulikowski Content-Type: text/plain; charset="UTF-8" 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 On Mon, 16 Jan 2023 at 06:03, Alexey Minnekhanov wrote: > > 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 > --- > drivers/spmi/spmi-msm.c | 16 +++++++++------- > 1 file changed, 9 insertions(+), 7 deletions(-) Apart from nit below, feel free to add: Reviewed-by: Sumit Garg > > 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"; */ nit: this comment is redundant as there is already DT bindings documentation to look at. -Sumit > + 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)); > -- > 2.38.2 >