Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp476051rdb; Thu, 15 Feb 2024 06:08:37 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVg2nE9VsXWU/kVyqvVkNPZsgrKQezFPOHG0pNtsjM3pecsaf5vTbHeUUGXwBwaV+IYcgzKwzYClnpAEbYWaA/k7R2V/iqjZO0sw0pHwA== X-Google-Smtp-Source: AGHT+IF16aOQIFpjXMY2oteCl9kyS3P+iuASkVlCfz1cljSdyZKjC7hOuDb94EhpiugeiOigkL9K X-Received: by 2002:a05:6a00:2d27:b0:6e0:4b09:a9c4 with SMTP id fa39-20020a056a002d2700b006e04b09a9c4mr2994876pfb.2.1708006117513; Thu, 15 Feb 2024 06:08:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708006117; cv=pass; d=google.com; s=arc-20160816; b=LT4oIhDwLgvu9RSKGtgFzZxcxuOSxg9IQRohFRiXhcbtkr252ihwHiPYCf9eV9mjxG u2CHijZW3ptU2aDPUOKt7g3yVeSW32wf05d14vpmP9OvNuYckf6DqwaxH7iqi3572sKS y1M5OP9X/YY8pvw69ie3mxJyrnje3eMxIGVDwezRZ4f3X/pNTQi02y4RT1eYGH/SzHrA 49oeeZtizIQHUVL8VpeG0r89qL12BBnEOkt3XGUwgcy1flAGRrwXjv8DeClHSdwD7a3l uIIVPErCKYnvDCHUQZgLz656nMPuHD/wL6vmgmZZ3I+VPlf7QHaKNpqQtA6KSkRjHN4c GyKA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=itPC4yjw+MZTTzalNg7Ob1FeA2iLjpKFIQ9B9VJV75g=; fh=lbb+x9IchiCYQldE8wg2FEXz61TSTt9PGvDtLTUxYaM=; b=vxjZc3kJ6f/o+ZMIOm5JD9ctAdEg2aA7QX/xth7pTUUCjTy1NZmLM2JZM4W7nyvFo7 jdW5ULuA9cjus7WPf4jCys+7Ici8GSiLdSrzMYkqG7ijNxxShgRMQD8lOuSbfn8CQ3i7 1JCZ+0kYLXfYbT+GdB5w8r3X7JE4DQlPM6I4L2B2qCzC1o5K4pYSlv3XKfGppB1I+gxh Pj+f8YGfQ+mIfcG+XZ8RODoqedvWfoc5Oeji6CHJHg5Jj1zxmmvaXmXIMbncvuA2zxRd A/4h++Il4dpBP7hhiLYZaNLJhkOjOpVFAdSBxJfopPr16RhBLDv8OrqKj2rApihHiizf YZ9g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=e2nnmTpY; 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-66983-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66983-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. [147.75.48.161]) by mx.google.com with ESMTPS id e7-20020aa798c7000000b006e0ec20e238si1167213pfm.393.2024.02.15.06.08.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 06:08:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-66983-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=e2nnmTpY; 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-66983-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66983-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 54657B2E707 for ; Thu, 15 Feb 2024 13:32:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CD7CB130E58; Thu, 15 Feb 2024 13:32:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="e2nnmTpY" Received: from mail-ed1-f52.google.com (mail-ed1-f52.google.com [209.85.208.52]) (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 069D4130AEC for ; Thu, 15 Feb 2024 13:32:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708003933; cv=none; b=qkplfkDvF/XBZao5xR4qqXXiAdoAnlV/yA8GSLmTVKvykvuPtOT5jMlefpuRyOF+Hv1+45LoxhdNLeV96I3cRAZUgd1lOuXAB2F7sUohpKiJSTSczpetSXdcKAlvr698oLOblyp+lhdi3/uMpqxUOAOBSuSQ02dh0JtVlXSGZts= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708003933; c=relaxed/simple; bh=m8hYdh+/UVrqtVPhk6AGLID+nWtFtpRf/uvN+uMW/6c=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=qW2bASTxF5Y3t1rGia+JQzbe+PYsXLzHQ7htrlrNYQfnM0fO2A7Nm8iQuBFDwCLLdABaK1e4uTD+4AC4Knzg07oeYO4IRuKJ7enagiaHirbXhLhX80ILpzPbBZQP66NJPXCYCDsSzopSwEPUl6inD0pEg8HITOgAARFBIc47cB0= 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=e2nnmTpY; arc=none smtp.client-ip=209.85.208.52 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-ed1-f52.google.com with SMTP id 4fb4d7f45d1cf-563d017696eso112896a12.0 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=vger.kernel.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=e2nnmTpYpaMea6mnpaWIiXu5yIg1UrDGSKXkeRzKMDt4SsnMlgMgaDWhNt9bIq77m5 OC32/A6KKguXvLbuatMyWRD3CSyImw7RGsxYiVKuK/w/H1Ffs4pXdKdEEFxx8PDTCTuo 624Y6m9uGHmwfBxfMe45Bz1K+VoakhATvQjg6RlkebMZH2XSp680OyYpqNCwBcECd9BB LK2noxnvwLyH7SSupf3YvVZaCT5fwmMEFYmftZT5R7LNhzd9YbpqmV4gtsoukchq6z5E c3oZw2xU0johSl178KKpnmqdj6zUvBMyfatigK97RAsPV4RpVSFGUjHT5GOgBk2yoWzX HJxA== 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=C/aUbKofMtsesbaHDwyuN+D3afb2q0x/XYx4riQUo3eNm5bbKWMS2aGcnnoicKh6Jb STKGTbUNvY0w9AAMQCoMmL9EiKMHrTg9bTaXNd8JwAbA1Uw4uXURycpGzFo3MIRL/Qmh UT/SljDQCT1NXu02HW4y33sJOK2ga3P+WWrd0YKZwZPdSzsKanhHKiohwORwXNdQMo+j au+HrRaKypfUXjhqNS2eROPlqQl0ZHFfb+W93dRehp5r2NJ9yxkHDsHr2gBgZZHAKuvK G6jjMGR/o+F0U+DUxhy6RgttjHHyxJeMrCFoYBw+qAUSxS0VZhtCrfRhjPviARjYFsN6 1qeg== X-Forwarded-Encrypted: i=1; AJvYcCVo6fChHGma/dIc5OvqJwjagMxlqUW6YeojmGtlXrSkLXMMZszvZMxhkPf4mXPPn/e/uQXLbQ/868tWBv3s6plQIIcyKRbQrFkPDfJe X-Gm-Message-State: AOJu0YzsYD1e75mTKqbI9IuwxrsSWPjiAr5J1v3M/S0ECMRrjKBnhGXt ogdSrzsLThRcRYSvEG9P9MeMdgfugwHzUtf9XKfcQ0L1yxJDuSE+u5UhBP0NR8b3No3LtTTcbHZ H 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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