Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp348006rdb; Thu, 15 Feb 2024 01:51:41 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUsWRDs3Kazyr8C2SwRc4c6+jrZIcBYaYhkURRXRcbQszSiCHB4KWbQMeBEzBZPjbvtvtoTQLIwx7Ff2CeEEWws2cHpIlB1BiBVDpTm+w== X-Google-Smtp-Source: AGHT+IGpH80nmxxoEF3DS5s8dDGvRBt3SCHgpXeovV+ivOaOZG9MDB1tFi4pJmT8865S0azaCE/m X-Received: by 2002:a17:902:9a07:b0:1da:17fb:3021 with SMTP id v7-20020a1709029a0700b001da17fb3021mr1058641plp.6.1707990701708; Thu, 15 Feb 2024 01:51:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707990701; cv=pass; d=google.com; s=arc-20160816; b=wyAR+kD55iwirhyTBRkjPeX995HQZ+3x4g3hzRwKaBSqd14JxXLSsK5yI5QdvmY1fO 5J4plljB1gx2kRHryXbEGjovt3CH3Ldl5WgWUnpmMZi0aKt90MGbYbBqNyl5N2wu1TbO kyqo5UDpbCftR8NMUzDM4gd86wY6HAXHX+JwNBywSWAviOS3I7m40/PgftUU4aUZdiWi 0Qp5SRjHreC01vNI22o6w3fI3ilNWbQzAFV8K6RN3xv62dI7rQrJA0Ik9fJOkZFIjx03 6e527mfQ1iLsxmAfY1dSGm4WEzs1dP4oIfVMqOu8oD+zNv7RpFKJbSlwB+EWP6ZEeSmf krrw== 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=w5KcKTaCQn4pBwWr+P+bPuhSGEvM0dqpC2FO7BYBz7I=; fh=tyWrGgUQ2F0uWA6O7OR/xk9yc09NBlrOBxdM3KBG/rA=; b=XYk3TjLQBhPh6e6Y4Rno3i96owSFM9UNNFpxE6lAV849BCL3AsmpMN4d9l11kH7gA2 OGVezVTFkHT/xAhZPEYZ5D8Dc2FUB+hvbQNylex6xcR918MnmM6CVRkUPu7D8VHrNMj8 jJlPk24c6nSEJzn8SHXQUedx27KFTpLJ/k1MFT7mjoRxC2SMQNcGWDrb8PjBialUlhwh vzEM/RxjUTiVN7DG0jKiUXlUD6c2OnUxTU7uGM6hbk5JHfvpNZNeTSZdE09yNPAmpAwe 9/8XTHrsQCdYLHJaIEAX+JDvUPw3hTqhNE8e4mULAxOjxmpcoFnPxPGsgIY7Uh6Otlpz dR1Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hTzLhped; 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-66533-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66533-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 w15-20020a1709026f0f00b001d76501a1ecsi837039plk.469.2024.02.15.01.51.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 01:51:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-66533-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=hTzLhped; 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-66533-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66533-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 A2100B2CE6E for ; Thu, 15 Feb 2024 09:27:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 072401B286; Thu, 15 Feb 2024 09:26:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="hTzLhped" Received: from mail-ed1-f41.google.com (mail-ed1-f41.google.com [209.85.208.41]) (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 24FA3175BD for ; Thu, 15 Feb 2024 09:26:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707989214; cv=none; b=ZFKFE1l9jPwYCkkDrVRRvo91e9HuIzYA4JI8cwJpnIwHzvWwwLCLjXKFHMLQ0Fx/oKgEOy2vAuWHfPxox/8Jg7tt8qyEBGLcjDKv2JwoNxcFDKq3QASZWB+cEkpaXFpx9PYVZtde+wxQv6diRXkcMsDlsAqdOxqh/ll0uo7XrpY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707989214; c=relaxed/simple; bh=ecamQUc576R0epdKqjkRQszTyH7lrl46ZIPoPGR3oZc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ZwYD82fSGFMkXUCSzJDsa9xDbIsPSi/iSsr8BpBwL5CDhLlNBJIYZ26UWAtZU4ve4TaRLmB0bsmLDqt8GjIJsAg9UOJLXj+BVJNQ0KaZBU4V106j0vQo3fO+lpqPPoD94CxNL9STFVN4Hz41XTF5tPdVWDgKWHXXPPiBihMT+1o= 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=hTzLhped; arc=none smtp.client-ip=209.85.208.41 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-f41.google.com with SMTP id 4fb4d7f45d1cf-5610cc8cc1aso683717a12.1 for ; Thu, 15 Feb 2024 01:26:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707989211; x=1708594011; 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=w5KcKTaCQn4pBwWr+P+bPuhSGEvM0dqpC2FO7BYBz7I=; b=hTzLhpedxfvPm1+XZ+qDyo5GhvYoiebAWFD+PwrKQtJsfSGftXBPOBnvX9pvGMW744 FPRJNskhWd3BDdMXknCi2C+Q1tHJxlaJ9BfJlgE3XWsel5TtrNoz2N0fF1UGI4OEqPr2 dw2uBSwRhENB+FVhAfFEqIVYqo4H+KuTQskYqbBrpAiv7Pjq+DvREFsrYjaOvT4HoF70 bODEYujb55T0FvmXWOyynubpLOsMcfMxKjpG3LPOio1/Hzor/YPXSRaeCJuWI4CtXjYC zS6YF5yyoPKE+sVS9KUr+ktX8JD3mh0gJ2Feoi3a44j68xqE0FF79wCyqBLNt9dDdeD2 KpwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707989211; x=1708594011; 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=w5KcKTaCQn4pBwWr+P+bPuhSGEvM0dqpC2FO7BYBz7I=; b=omVKL8p/M/V0QG6YvMzWiw7PFiAhPRufwAZKtBSXGg1Efj/b5vMOCcpQdNwNVC78KD H0jdDhu5CBxfLOc87mI9gwptAom1EnMtH/dPOWcZAD5piQuq4JI0qrci6nfGd0aiR4A4 N1mGlA38n4nLXckhrjEjDCWS4nfns0zcHXUJVWJfsCjD90Su0CXpgg9HvlIq7akKtwBt NNAp6PNKeiQ6iXynTTh8ZPdqYh5ZvkeWPc/EPm4ZAdLGjPxaclg7/UX1u5ofSA4vQ3B4 BMEbhTU2nODREpebYt9O+FwOk3UabYqH2o9AzLMoA6N0T0wlr/zE9kEB/5kWFxIxxhDG fWhQ== X-Forwarded-Encrypted: i=1; AJvYcCXwhjosNzQdYFZ3JmZYvpkzo/wnPYv+6I7bvdO0I4uq1gXtLSxmoYYWSubZq8K3LnfZewqU1DsWDPsFZ2FT3yFgdeqaozGblS2/eVQr X-Gm-Message-State: AOJu0YxMDoj/7q+rIijIcpL6yM7xn+MuHVp0uqHxf4kmkW/yWa2ZIrhb OaADC3o9nkBde2cwIBGJ9QOuI5ZdBys28OL5lMw119lqZ0OQx6l/vrrn7qgfLQD2WPvAktElfOC p X-Received: by 2002:a17:906:5f89:b0:a3d:5e44:83aa with SMTP id a9-20020a1709065f8900b00a3d5e4483aamr848262eju.20.1707989211294; Thu, 15 Feb 2024 01:26:51 -0800 (PST) Received: from linaro.org ([188.24.162.93]) by smtp.gmail.com with ESMTPSA id bq14-20020a170906d0ce00b00a3d2157e267sm360824ejb.11.2024.02.15.01.26.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 01:26:50 -0800 (PST) Date: Thu, 15 Feb 2024 11:26:49 +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> <5e878fd9-8215-499d-ac1c-191cb5bfe798@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: <5e878fd9-8215-499d-ac1c-191cb5bfe798@linaro.org> On 24-02-14 22:44:55, Konrad Dybcio wrote: > On 14.02.2024 22: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 > > I meant line wrapping Oh, ok. Will do. > > > > >>> + "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. > > OK right, let's keep it. > > Konrad