Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp515987rdb; Thu, 15 Feb 2024 07:09:00 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWeNwnYmlWxuoxgAI2/KF22ZDeOswUHxHbf2Befbpbb1K/FecK9XYU/QWP5J3nULoNywcd1A2asGM4ZN8jYU/9D28nmkV08zXf5EGc1JQ== X-Google-Smtp-Source: AGHT+IGNIM1zNKCh4WcCLk1wS5M5nhqmg24FReKEdbHm2xJcOYxgNnSOwRYhMXsf02FZinG7DmNi X-Received: by 2002:a17:902:d4c2:b0:1d9:1cb5:558b with SMTP id o2-20020a170902d4c200b001d91cb5558bmr2232560plg.15.1708009740682; Thu, 15 Feb 2024 07:09:00 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708009740; cv=pass; d=google.com; s=arc-20160816; b=RBpFBQV/KoeYpiCgfnNUThM66qukx01EAr9ZitK3P7wTuaCWEsc/D7WvtKxs4Dzp5M zm80PBrvxrd2cFF9tFGXusCug0MvCihquWMv8TSUrnXI0DqTvD81f/ltw56txHVsOfdh PGS2XwaTqssp+ms4dRC1x8M5F6gvpf6h5E/KZLAIxwqs8IsYX66HZYzcdxJg/rsd5DXa BNdKwGXnT2RBdBKTt6pA5D/9ezRwHPH4ifiMi74aQCGpBuBSyj62a9Vlbmil6m4Wb564 vrj3zw2Bf8c/790PBHe0YbmGAHRPa/s1ilcVZFrEbxXAwS9tQUtrPXe4SgPs7LJ+vlVy bC2Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=dAC16XHzjVY3XukbmOyTYofThyOnRxBkJl2MJq0kU/g=; fh=EsikhV+/v4Zb3J3xTlPF680V0eEkIK6FjVV3N6iPBDI=; b=DUAls8gxeDOz+RohJ93xhFrpUjoonqqRO7Dhy4W6C6l82JDAtCnEuNaZ3Zmdp81vk6 mbN1ZLFq8b8PexI0rYLUYtXbihKwvUm9Fso6H4U+WX5+1dcJ50LoRq57jcdEKT9KqPEn ArkcS+OYx5jIyEdbhuuRpGbMJtc2Qeb/D1qUUspKCea13g7msNSB7f2U/s020Js42ULa h7Tf1AJu7TzWboK/LNwPGCnLXYtTbaJBGZF4PgIgHW9v4dnrcWnfc1WI/T6lrEVI33OQ tppeLU9NvRtW2ZHCk2ffJADuJH+sb48NJxaNYU+vrbtkoiChJTrm+twhEF8BNdSBD+1B tmpA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iNcjrIxJ; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-67091-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67091-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id r11-20020a170902be0b00b001d9c70df558si1254647pls.218.2024.02.15.07.09.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 07:09:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-67091-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iNcjrIxJ; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-67091-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67091-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 899A0B249EB for ; Thu, 15 Feb 2024 14:42:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0693E132499; Thu, 15 Feb 2024 14:42:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="iNcjrIxJ" Received: from mail-yb1-f171.google.com (mail-yb1-f171.google.com [209.85.219.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EDDA7132496 for ; Thu, 15 Feb 2024 14:42:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708008135; cv=none; b=Lre+IJ/+JONRu3kXxS979Wt8I1DF5OiHJ9uxB/IZmxA8FEOsOPqQk63oK0OTEeaaIQ3cSBpSRyZ6XFIRhNmPPu3hc3W8cAiPAlAQGz7YwWX49saqX037yu+VoSexlNSnkvdtugQ/i+wLcw8Y8r5/ahOXpVfJn9c2TYj9dw2Q6Xw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708008135; c=relaxed/simple; bh=dS27jGD0fKVGB7XlaqNnfwFAlFDq82S6W3A7kwltT3w=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=gyjJM7NKI0PXy1HT0pyJYjhbV0yA6jitUAL9yBYPt6s+87qbOjM4DVcueB4vKohWigPCnj5KIYhZy1BOw1lU3HRJZ+endf26+IdzbqKsNh+GTOG9v7mUwZXJO76m2K7ZdbZpDloDbRDYQhtVoKVuQmQlGO2CAhD9i0hQIPkI+yc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=iNcjrIxJ; arc=none smtp.client-ip=209.85.219.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-yb1-f171.google.com with SMTP id 3f1490d57ef6-dcd9e34430cso898250276.1 for ; Thu, 15 Feb 2024 06:42:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708008132; x=1708612932; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=dAC16XHzjVY3XukbmOyTYofThyOnRxBkJl2MJq0kU/g=; b=iNcjrIxJ2xjPQk92cQBpUDREps7BpgVcGVshe0obIHnneQXtVx/00A2ag83axItwM3 P1y9dqqf2RkWgAOsaFM9vuqQHbxIR2/c1ATQKL7l9FIAC5ZTnCPqZexjGatoZVUunb/x z6X3SoOiXd0w2ePkxQSFCJGkBqneWWiS1cTHt8999yLh6wkVhZuzsePiGMJFl6BjEm9A 5aP2Wr24RvqTxdDcUomEh+/taRMW5QsYZ8y7llz0gPzWL3a069SsXncCHbnfT3kg+7MB nCagWrFEaanxoYg7knRsIqyL1mz4uqjDoavT/97iu6D2vhd70LGThnCenmVfbqqNxAu0 MOnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708008132; x=1708612932; 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=dAC16XHzjVY3XukbmOyTYofThyOnRxBkJl2MJq0kU/g=; b=Xjj5v32QZytZLd0UVhsnnw7okCpC27RUN9VzxYUQI2evpaRXE9XqeqARpZzw/aLNuN 2rmCgy9YF94rd4nnoQt6dXriLp0QE4uglnEI9xsuy4MMB1EX65muw5KXQ1/In+c5aaI+ Op4KZqb77MRBTyCXirS4jU8pZm+btF/HKBU66JGqq5DPEIQ+Hf7sRxR3uPmmN9wVvYFE HmUrqx12zj7RswEj92pmRDsALYb/hPBg4wmQHgfXM7gM2SBu5rm0G4gP7HBF+xmx3+BZ eP3CLvmoj4xrlK0OrRo2I1RftaaG4AXxalR0X4NXZkg2mfLxBOTK7r2Bv1Pqkb/75v9G 6fBg== X-Forwarded-Encrypted: i=1; AJvYcCV7M1yD7AyKO676EllmXhpRFCpY3SefW7GVpIIoM+GoMHBWV8CTGh3d6aQLxSvUfwKeUmNMpqFAWp+sylbau+nqP3LS4Tu4UFXhpbFB X-Gm-Message-State: AOJu0YyJ3pr4e0IEsJtFIXs9sGDJb7WH8X3PieyV8lRchmhMKg9TP9mL Mpsh1YmS8+47hm8Yv1RH3oUmp2hNM30M8qYg3bmioIwWHMo9T4Q8P0hVwEmfxQHXp19CmHoVT9H Uma6cXKnEqrAOfrbyiopAi0H4j3nZK8/OVzBeHA== X-Received: by 2002:a25:b282:0:b0:dc7:46ef:8b9e with SMTP id k2-20020a25b282000000b00dc746ef8b9emr1827807ybj.29.1708008131861; Thu, 15 Feb 2024 06:42:11 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240214-spmi-multi-master-support-v3-0-0bae0ef04faf@linaro.org> <20240214-spmi-multi-master-support-v3-3-0bae0ef04faf@linaro.org> In-Reply-To: From: Dmitry Baryshkov Date: Thu, 15 Feb 2024 16:42:00 +0200 Message-ID: Subject: Re: [PATCH RFC v3 3/4] spmi: pmic-arb: Make core resources acquiring a version operation To: Abel Vesa 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 Content-Type: text/plain; charset="UTF-8" On Thu, 15 Feb 2024 at 15:32, Abel Vesa wrote: > > 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. I think so. Let's drop it completely. And for the new sub-devices you perfectly know the bus ID. -- With best wishes Dmitry