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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 16B8FC48BEB for ; Thu, 15 Feb 2024 13:32:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=PWeRkMqyAZQbKrKX8zBQEl9O4PCvwbIyGs87+Po0Exc=; b=lJRKv6lf/fZ/Zb EbGrTOraXYL8+JR+SEXjZuTgpir07URxj1T2tWUkcVbTTXn+/GHK/+mj3LHibDB1viI+4xrvBc1kJ cDDBdtiPjQfuMuleyfCtVfu3+LsuZT+yn9Xn2Gk7ARw0WKxVbBCLvKGPz6oAbJainYTDlMUK7FhoC 8hR4LgzQ1f0Z28CZVYmms5x9xTYp/MOFr84PiLfiOSA5gpHZbA/DtdsAMxfnaANy9KrwZDqd5PP/d 4fH/dZSjU9zC6yScm8688/4YtBokpj6fBt9ZgKTOkE3HG+9KO3S4Xrze5Rm+9u3FSa6c0H0AhrWnN O2FR+0a4EUqLAqOwMiag==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rabqY-0000000GORi-2dUd; Thu, 15 Feb 2024 13:32:14 +0000 Received: from mail-ed1-x529.google.com ([2a00:1450:4864:20::529]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rabqW-0000000GOQk-0qUd for linux-arm-kernel@lists.infradead.org; Thu, 15 Feb 2024 13:32:13 +0000 Received: by mail-ed1-x529.google.com with SMTP id 4fb4d7f45d1cf-5610cc8cc1aso959119a12.1 for ; Thu, 15 Feb 2024 05:32:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708003930; x=1708608730; darn=lists.infradead.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=itPC4yjw+MZTTzalNg7Ob1FeA2iLjpKFIQ9B9VJV75g=; b=lv4iX7k1gzLHpNuzZrJvh3ODarohCmhs+sCK3is9unsa7V/Y+BxiNbkAMFnEhTGrDz dYBE42bEQX6T8t6DtWORK13du3N1ijcV2AEaiREuO13a86f6pHf5MZVXuPLIHQol9HIG 34Ch9cELjQjsY+1rweGpr2WaOtmBmBxGf0ENOqcpEhNVxPhpF4i023V3gqsFsxOgfDTz zu482fDLtLMaAquDgWYscuqggAQH4vUocFZ+htJlgo7UBzZOt+g8vIdWfgegNS9hT0Py Sg7KcxrZxz+lPMI4A9IP0kfyv/eTeRGsqMK5B86Az/Xm0/5UqAINywFdBcdpGQijXyl2 87gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708003930; x=1708608730; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=itPC4yjw+MZTTzalNg7Ob1FeA2iLjpKFIQ9B9VJV75g=; b=ANrgPInKnZ2m1l+zclf9bmyqJPRWY/b69yCq4LD2Ot9SGHryyTCMliso02ZK1QECY6 OHn4DdAl8d3akoJThySoDUZJYsyx91ndAAaKXiKPGBr0GVv0PPS7UxWJrEUH1+Hkp9mA sUdgVPlZMbvmkV1iOVdVHztdENDlLOviJzOJ58gLrDhACu3T/zkdHFlh7sOHzhZOpnBU 39M0RCKmUvYn3V6oVEAAW7ctUePLHMZO9yu5vILGcyK/tOVzngGqGcrfTlszqwruDKOu ga2WSz7JifsXe59+YuC98FtFR8cNVHokRB8uCNmsbCt0VbdLkf92fMDWLyD2SV51TxNv 9YRQ== X-Forwarded-Encrypted: i=1; AJvYcCVc2Yg/nYcYBbfTdVJYVi+YJja+dxeY/NtgUxPC+q6jEwsjH71FTudnZrJtAqsVnYF6HqusdnjqTNkTY6TsHuCduZSbE8nhQ+saJYVBUyDi/17i070= X-Gm-Message-State: AOJu0YwuMKjbJal/GBO969xjbnpTd8OgrJArb9pm/+Dj3tFHHqoBjQAw TtcvfmGSLSSGwkZKJ71/1782iCBJj8l2+f11l9bJy5zLSUCI4+dlykXRhuufkZc= X-Google-Smtp-Source: AGHT+IE7pGrmIuos0u7FslcOP5vVFjySkiA6nt4+X/E67cQyceQ3AtGt6cC5RO+cNGVYo8uyVRvA8w== X-Received: by 2002:a05:6402:287:b0:561:4238:e6d3 with SMTP id l7-20020a056402028700b005614238e6d3mr1513003edv.2.1708003930158; Thu, 15 Feb 2024 05:32:10 -0800 (PST) Received: from linaro.org ([188.24.162.93]) by smtp.gmail.com with ESMTPSA id p3-20020a05640243c300b00563c22abac2sm228295edc.61.2024.02.15.05.32.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 05:32:09 -0800 (PST) Date: Thu, 15 Feb 2024 15:32:08 +0200 From: Abel Vesa To: Dmitry Baryshkov Cc: Konrad Dybcio , Stephen Boyd , Matthias Brugger , Bjorn Andersson , Neil Armstrong , AngeloGioacchino Del Regno , Srini Kandagatla , Johan Hovold , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-mediatek@lists.infradead.org Subject: Re: [PATCH RFC v3 3/4] spmi: pmic-arb: Make core resources acquiring a version operation Message-ID: References: <20240214-spmi-multi-master-support-v3-0-0bae0ef04faf@linaro.org> <20240214-spmi-multi-master-support-v3-3-0bae0ef04faf@linaro.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240215_053212_299437_6E16E5B2 X-CRM114-Status: GOOD ( 36.42 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 24-02-15 11:30:23, Dmitry Baryshkov wrote: > On Wed, 14 Feb 2024 at 23:36, Abel Vesa wrote: > > > > On 24-02-14 22:18:33, Konrad Dybcio wrote: > > > On 14.02.2024 22:13, Abel Vesa wrote: > > > > Rather than setting up the core, obsrv and chnls in probe by using > > > > version specific conditionals, add a dedicated "get_core_resources" > > > > version specific op and move the acquiring in there. > > > > > > > > Signed-off-by: Abel Vesa > > > > --- > > > > drivers/spmi/spmi-pmic-arb.c | 111 ++++++++++++++++++++++++++++++------------- > > > > 1 file changed, 78 insertions(+), 33 deletions(-) > > > > > > > > diff --git a/drivers/spmi/spmi-pmic-arb.c b/drivers/spmi/spmi-pmic-arb.c > > > > index 23939c0d225f..489556467a4c 100644 > > > > --- a/drivers/spmi/spmi-pmic-arb.c > > > > +++ b/drivers/spmi/spmi-pmic-arb.c > > > > @@ -203,6 +203,7 @@ struct spmi_pmic_arb { > > > > */ > > > > struct pmic_arb_ver_ops { > > > > const char *ver_str; > > > > + int (*get_core_resources)(struct platform_device *pdev, void __iomem *core); > > > > int (*init_apid)(struct spmi_pmic_arb *pmic_arb, int index); > > > > int (*ppid_to_apid)(struct spmi_pmic_arb *pmic_arb, u16 ppid); > > > > /* spmi commands (read_cmd, write_cmd, cmd) functionality */ > > > > @@ -956,6 +957,19 @@ static int pmic_arb_init_apid_min_max(struct spmi_pmic_arb *pmic_arb) > > > > return 0; > > > > } > > > > > > > > +static int pmic_arb_get_core_resources_v1(struct platform_device *pdev, > > > > + void __iomem *core) > > > > +{ > > > > + struct spmi_pmic_arb *pmic_arb = platform_get_drvdata(pdev); > > > > + > > > > + pmic_arb->wr_base = core; > > > > + pmic_arb->rd_base = core; > > > > + > > > > + pmic_arb->max_periphs = PMIC_ARB_MAX_PERIPHS; > > > > + > > > > + return 0; > > > > +} > > > > + > > > > static int pmic_arb_init_apid_v1(struct spmi_pmic_arb *pmic_arb, int index) > > > > { > > > > u32 *mapping_table; > > > > @@ -1063,6 +1077,41 @@ static u16 pmic_arb_find_apid(struct spmi_pmic_arb *pmic_arb, u16 ppid) > > > > return apid; > > > > } > > > > > > > > +static int pmic_arb_get_obsrvr_chnls_v2(struct platform_device *pdev) > > > > +{ > > > > + struct spmi_pmic_arb *pmic_arb = platform_get_drvdata(pdev); > > > > + struct device *dev = &pdev->dev; > > > > + struct resource *res; > > > > + > > > > + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, > > > > > > It's no longer indented to deep, no need to keep such aggressive wrapping > > > > > > > The pmic_arb_get_obsrvr_chnls_v2 is used by both: > > pmic_arb_get_core_resources_v2 > > pmic_arb_get_core_resources_v7 > > > > > > + "obsrvr"); > > > > + pmic_arb->rd_base = devm_ioremap(dev, res->start, > > > > + resource_size(res)); > > > > + if (IS_ERR(pmic_arb->rd_base)) > > > > + return PTR_ERR(pmic_arb->rd_base); > > > > + > > > > + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, > > > > + "chnls"); > > > > + pmic_arb->wr_base = devm_ioremap(dev, res->start, > > > > + resource_size(res)); > > > > + if (IS_ERR(pmic_arb->wr_base)) > > > > + return PTR_ERR(pmic_arb->wr_base); > > > > > > Could probably make it "devm_platform_get_and_ioremap_resource " > > > > The reason this needs to stay as is is because of reason explained by > > the following comment found in probe: > > > > /* > > * Please don't replace this with devm_platform_ioremap_resource() or > > * devm_ioremap_resource(). These both result in a call to > > * devm_request_mem_region() which prevents multiple mappings of this > > * register address range. SoCs with PMIC arbiter v7 may define two > > * arbiter devices, for the two physical SPMI interfaces, which share > > * some register address ranges (i.e. "core", "obsrvr", and "chnls"). > > * Ensure that both devices probe successfully by calling devm_ioremap() > > * which does not result in a devm_request_mem_region() call. > > */ > > > > Even though, AFAICT, there is no platform that adds a second node for > > the second bus, currently, in mainline, we should probably allow the > > "legacy" approach to still work. > > If there were no DT files which used two SPMI devices, I think we > should drop this comment and use existing helpers. We must keep > compatibility with the existing DTs, not with the _possible_ device > trees. Sure. Should I drop the qcom,bus-id from the driver as well? It is optional after all. > > > > > > > > > Konrad > > > > -- > With best wishes > Dmitry _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel