Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp341291rdb; Thu, 15 Feb 2024 01:32:14 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWLMk58gJ/gbUB7VPfETFAqVQDtZtm0SnG0JpBqddgoBcxRhE+C9qa3D1avtEJk8bH5V2CsGv3qGX6wl+3ZXDhc6s7LqocZxTTll6Hd9w== X-Google-Smtp-Source: AGHT+IH1o2UBBS8Zr7itXbVZc/bVi43pQTUhiqv4ClQQLvVxMO2t+5jSO9k3tjxXJPcx3tHB4YF6 X-Received: by 2002:a17:903:495:b0:1d9:7941:2274 with SMTP id jj21-20020a170903049500b001d979412274mr998046plb.4.1707989534617; Thu, 15 Feb 2024 01:32:14 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707989534; cv=pass; d=google.com; s=arc-20160816; b=dOzw2nrdJy/q0w7vXwcSMzFQy4TmIB2Gz+ztWgv9uLAMi1QFuRR30MHg8O+ci4yPuF /JLrDAYVJWhf3kzsGflMnJNELjatvYjk09iTN3+Jcy/Sxm8Rl4Yb1fabMQi/Nxjqh1oH MZoWjjTD3hmR6bmz+F4ugbrUEEEQoPRYcUxO5e/oZH9v7mDRzhgLhcexb5ZmuCG4vvbT Sye09JiwOqKSoxqd/OXKUReY4RtR9RjW0cr+ocSRlm6Zs8VgGj9T+s/9WkRGUeLT5bLN atCrFB+tFnKJ0V4zMLnKtlNKwz5kZQBfltjnzPQ40SoAaW5qZPp+h3N/Y8c3klmIEqBV 2z+Q== 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=SqzXrRkWgTenwMOEsO3xos6cCOi/pxIviEw1f9bRtNs=; fh=8GSJPsnIl0i2Ux/B0znQyec89/HnEYsPq1KlT09CO6w=; b=bc5ssvBg0RDAoLbcV2xHPR1Adj5NHFw/IlFTBUmZjRtBz3ow1CFx/h+xBTxTqR5PaR xEGmm/CzpvVJdNrlCbjGF2f+mqmX13r8Qx3U/eoe5KZ3GgFl4a55I3I2M5n3GQkQy9ov cnbyn13oWbsqoWFnoqtwqESqEClFI3sT/CiO8BXsGQp9G/fC/hAm5jPeYCcHDSq6zaNN W+ebuBHtak6p0LxpwU7xvuDmhTdEDGghdoWO20zjy+arezHZ+PYLcCZdmQq1ud8uVWw7 5a88wTHUWRm4wbs67ra//Lo4/T4H6D4qfhHAzTWnGZTu3qZtlzxPTQgZynmGSUxzr76a UaWw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vDcjdr+Q; 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-66544-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66544-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id s13-20020a17090302cd00b001d9f2674008si876880plk.118.2024.02.15.01.32.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 01:32:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-66544-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vDcjdr+Q; 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-66544-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66544-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 76D6C2902EA for ; Thu, 15 Feb 2024 09:31:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 054571B81A; Thu, 15 Feb 2024 09:30:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="vDcjdr+Q" Received: from mail-yw1-f178.google.com (mail-yw1-f178.google.com [209.85.128.178]) (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 6B2231B7FC for ; Thu, 15 Feb 2024 09:30:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707989437; cv=none; b=lKKhsV+c2sv8fNrAWzkClfdIBjkHeHi9+NQmsqlRhOhRsWjd6lUo14CvNNXYvLHIWb2qhpLq74noYbiOwzDQ/PxJ+I6DB9GtR8v4TzRZMznhV/i3xZblxTTEvKy+49HwXfK8M9y1k8wJZi/zNKOzWW2iud5w3951C8TPHLoO6ns= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707989437; c=relaxed/simple; bh=YaSJ7gazrtN6SokXNtrsQiLpcqC0xCghqf5npFEhCJ4=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=U0h2prul6bhObaGPfRUzaX+3PoUixuMAk2TlEP3+NtbxUGbTn+9zQw9RJSv6gcJRhd3fTacDzTxPSLNH5iUkmrBRIOmmurJRK0s9p5369BHdcQRfRhHq+chzyxhuvUwkmoAJmjW8n4hNh3cMMPi2NkkG/LgDpaixG3ulOA28IMI= 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=vDcjdr+Q; arc=none smtp.client-ip=209.85.128.178 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-yw1-f178.google.com with SMTP id 00721157ae682-60495209415so6872297b3.3 for ; Thu, 15 Feb 2024 01:30:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707989434; x=1708594234; 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=SqzXrRkWgTenwMOEsO3xos6cCOi/pxIviEw1f9bRtNs=; b=vDcjdr+QsMbJ8cR52cNmWS9pVVVAfQrwRkFGR/4UjIj6124G65VHE2dT90yi/LipWu ERCQgMvTVX1RA3eFkmtmFYVsmt0WGVdNeqv3RNxP7xNLtoOvb4q4rk2wp6i78nvDAiX/ 7mK8mma8EET6B78aaYxOENanIF11Dx83j+MPPY+f2FM9VGw+APi4Gh0es3vRu6KLWBYQ dH40bNUdWnseEQWFMsdDlCVnIye+Z5BlzRXH0WRcpjZ/2fdzaCsKfm/+XZG05J2ytn7k Qwj3/EvD8/MerQgv1lAgqvRcLO5s1pW6XxmW0Qa3Tyyj/5Wsa1ob7SiDTEs1kcT7q6ZU oyxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707989434; x=1708594234; 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=SqzXrRkWgTenwMOEsO3xos6cCOi/pxIviEw1f9bRtNs=; b=t1dUZ0B/3gUQhW6Cppok/on5GY04jW441m27V/RHWjmP9imYGKi9TVt1QZL1wEz2sv y/cm6hPu3qZRMYncWpX7sw87MkYITv+PW/Repc7ynQ3caFavWo+NPqbJhfWpAucKGHsT 3tfwRfJzHa6FZ3EYezbq+SXELerLw2zB2UoDlEjrGhqXPkiR/ybKw/Bmaq4vi16xV58c 8CpRG2LCdNuLFJfqdTJc3KU90FBaJIlN6rXCMnIF1Ox1k517scjCKhKH+KS4W+ppG92u MRm2fIBWw74DiJryQCisqRhKH/AsmZBZBHrCNSy9Uluhbi2XOObrIolzZIqL47SPbmpT CSDg== X-Forwarded-Encrypted: i=1; AJvYcCWfwFs43WTrx7E2C7nrn64KK7KZc7+N8HZKFJhzCcMLyFjRzJGsZAvV/BErbgBXCVMLMcac0J+sUe3jpNW8A/E5FcIz4/D+EI+e3hKz X-Gm-Message-State: AOJu0Yy5hxV1MmzdwblqggishN65KupmhhLB4StxsFbov29Pb5wZdL7/ m/jMhYhf9JBdGQqTiGZQnK8kBTkzrE395LI6Xwshy1h1Z94Jio2qVSCOPT681vnr3KsRU5541N1 e+hO/Cx4/KWPgc6dJEbH4IIAPj9Mlq88xPf9QLQ== X-Received: by 2002:a81:7184:0:b0:604:230a:a823 with SMTP id m126-20020a817184000000b00604230aa823mr1117501ywc.50.1707989434409; Thu, 15 Feb 2024 01:30:34 -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 11:30:23 +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 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. > > > > > Konrad -- With best wishes Dmitry