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 89453C48BC1 for ; Wed, 14 Feb 2024 21:36:47 +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=P0C8qMw0GyBAvor+98plTvFvPI9bKVZ8lBQGwDo4Um8=; b=xL3rc8irQnjuhi S8SZNABnGfreeI+f1bW54o6PIrFi80VwVzA/76YbIWSudkVHkdpt7zBoJ7E2uhyhsC6xQzmplSgTs enZiy2D0tvTTHh/ie8nndp+SLZ+tdvy/euJ1Wz6MtVfG5TkY4kT7d9HKFXHfpE+ky6hPbPWDYSqtq /3LFmBSPDvHRRjlFzY+UKWF2cRY2sXSnGiT1c4YwYkDHtQdXvB4tqPNSn77+Ys/Q0iwbFvyZseG+v 3ePwgXe1r6yTf/NWbF77uWUTUA3mSx94jha7hsTcnem9K8Eu6kg9U8jRMB9c3jiO/8eUN6k2Nl56p GCiV/8KFsF1EW0EonOrg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raMvk-0000000EK3w-1lts; Wed, 14 Feb 2024 21:36:36 +0000 Received: from mail-ed1-x52c.google.com ([2a00:1450:4864:20::52c]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raMvh-0000000EK3C-0k7A for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 21:36:34 +0000 Received: by mail-ed1-x52c.google.com with SMTP id 4fb4d7f45d1cf-55ad2a47b7aso276370a12.3 for ; Wed, 14 Feb 2024 13:36:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707946591; x=1708551391; 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=S3oz8EH0OKcpFhmwJDBLxrQIHGXnO+990Fll/VjYnZU=; b=LcmkWgLkXiThe7ie3YGc9A5w5O+GLiGzPnFbrg/vVtgWpY9XniDKKHGjo+Ym97Fha4 lVUI3o5lNHCybhVkEcwhYUZgvsQvI/6yfdFNC3IyumQZKl1ZlPvoJrGuWrzk01Zosehn V/WYJaM7sNbwcw/7KL1Htm3megTxxmyB4UotgYeTIzFDWkW0gtxXhzwh9TV6lezsicga ieCDJVsdpOGMLnRpkoLCChqp8KeorEbkVI3LWTqowfcCTtc0BsXmei6oER1Piz/93PBJ CqtP4taUgVGDYCJ4kw+EUuh5pGowQHxTD76hJIIQImAv0UQU8KlEya6o7q4tBWlqt7NG Km0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707946591; x=1708551391; 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=S3oz8EH0OKcpFhmwJDBLxrQIHGXnO+990Fll/VjYnZU=; b=S0jmladxx59QhZ89rSP8jRskCtmx01hP/tnBiDwLnjsE3YCulQWV3LgxXn4TTOvlBP gAvXmZMXVX/Q7wKJsr2oKgpa4SvWbWWGmJVTuC5chPjk/lxDT9LGDPTjM00b1Xr1GdaN b+Zt/acTUcLkd/zGYsOnNh7h66ErZn1uX3M40uw8Nm1lQZRXqSyYI4r/0p9ke6s6YaLl jfu/0PgN4/HXRgj3RlhO2Ygx7na06G/sUZm4n2+dGN52BBF642cZL0tQNH5YMRb2aytk V5gF+cSgzVb0J1oa+DM9qWjCsZ7+R9/o55p4CGzxLBDjD/+iA17oo6ewl71v3aL8RNgo Qw/A== X-Forwarded-Encrypted: i=1; AJvYcCWitZeIJIQPlrxSre9RPlOLUpDP1LqaaYpkBHyNQnxgKM0qA13CKNNLtGUm8iwvn+2tXnIWKm5KJ2Ze0gbKF3ueH0RQEQS3h6DfBhFTB91Ai0fsiyc= X-Gm-Message-State: AOJu0Yyg1w3vWePokZsRwNkz0TOwgW0CphC8SA0I87dKNIlvz6R1HW0W XX1dLdm8yjHkRhDvCgpP155SRm03d6zRWNgzGq3TobEP8bgLYGK7zYqaEW2EC9Q= X-Google-Smtp-Source: AGHT+IHl91PbeghiBa3dyQcytSfZSO2Uh1MXz9LvIQ+QvKdlDHPnH0w2engCYxWRpYz0JoSMhh3kqw== X-Received: by 2002:a05:6402:398:b0:562:1637:2d94 with SMTP id o24-20020a056402039800b0056216372d94mr2765447edv.8.1707946591185; Wed, 14 Feb 2024 13:36:31 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVx+5f51MvOnaR/HdfKjfiLoqtyiGaLlZVPu2bk7kiIoyXuHZHrEzhiWcnMeLMqYmIOzcUr6Zr3PuUVxKziQelRpsNO9SVFFMg4TNKA5I82ui9T2nsrkzQMPBbNzgOa5/ETe7VF63o2T1fNrbCnbibfSDu2zK3G2Zxd+0IaE6G+GiLKQKJax61uZ4uuy851w7fof3Hd3sCEHMwIWr/yQyq4V3mLU/B5mVqXIWsvxqur1fSqli64wYXvqbD/Y+3mH61ESpuLnVqQs9pfNIUGsdZ9rHNJqiZPy42wnB/wsMbZxx0/rQOw/8KxK6aXtNnj+x6bPYclGPf/e8iEZ0ZBJm192YP9O0NTX1xLZXCsmVHzWapNBDujmCBWMktXR0y8JFPQVT/Cd5VfjmPUKt6MIrdv9eDg6AoZLDBe148XfhQiJLVahIARDbLl56RQD/5T06pj6RcFOAPVLouGfXTApznQ26X5roY8PW52kVp4ce1i//uLrYR97g== Received: from linaro.org ([188.24.162.93]) by smtp.gmail.com with ESMTPSA id er13-20020a056402448d00b005607825b11bsm4968098edb.12.2024.02.14.13.36.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 13:36:30 -0800 (PST) Date: Wed, 14 Feb 2024 23:36:29 +0200 From: Abel Vesa To: Konrad Dybcio Cc: Stephen Boyd , Matthias Brugger , Bjorn Andersson , Dmitry Baryshkov , 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-20240214_133633_252720_7313E96E X-CRM114-Status: GOOD ( 25.08 ) 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-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. > > Konrad _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel