Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp914657lqe; Sun, 7 Apr 2024 09:25:29 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX5w56v6/bNHZK+Y0coduyIl25kwExP+POkNBcX4JdbaZP+bmIhqJoVH1sr9GHyw1+smc4eDJ7wCTP2goen2XA7rMz9jJlXddUEww10FA== X-Google-Smtp-Source: AGHT+IFB6p2bPprHWTJ4IUJ2ey6OGfXI/irrB+JHwoViCnP0WvTQcYTDQmDEitnOAOHtZ/ij9EUQ X-Received: by 2002:a17:902:d583:b0:1e4:31e9:853c with SMTP id k3-20020a170902d58300b001e431e9853cmr118900plh.33.1712507128733; Sun, 07 Apr 2024 09:25:28 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712507128; cv=pass; d=google.com; s=arc-20160816; b=IY5VWVAzYHWaIdruWNtefXhyBb7oALfdDFfTb1738E/FRAVr+y7a8iaKSxA0Fycl57 YzPyJINIc1wmG3EpbDZOKgWPSC1SCHHwJrnX5u7aak4bzX4dfg9rT2kgqCaADQxrqdPP L/PqVH7E8JS5tT9ZYjiL+232EhxmQYNsZRjmj5u1YG4zeHNLzqc7BLzY486QLIhHNARP 8SoTqHwKRdvJae4nlDE+zw15pd9v+a7nSboNOEBZoxo+OP1kDfQW7IDBSlEVg1w4iW1A PVAh8jqXiQkCwcPaRIc69Vtfu1mZsKkcnnzCAvQiUtupVKGD+Rdad3YNyLfyYMplZevT 82gA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=OLN9WNUdytta+DCs//0H8ccz+F/CN1L2bvQTLnp2UBE=; fh=Rp5GEt53j0BJsywqNYiBSoSzn7kvLamELugVclZKrHc=; b=JBkiZuTrK3dEItPC9oRcNzMJWrUDTR4C658shCPFjcSSNSG8MkjAA9W1BOaGay1AHR D+HHxXiyXGtLUhEk5ElkTaU9Ut7OgUXRlP2jHPtzV6BQfuXSULzOusKXwDexNZB1Pu5O ck75ycKmS29uacHEkhMJ06U7+w0pZDNHUT8shQYPkYC9umgPIlnfnMLtR+aaIsEHAcN7 JFmUT+UulcMHVQcnGIIzX4qogXYxTzOUzywnnByolEeFTzkBybd5JZT3aEjFjW5Xhb6S Y+G46hQsrXVGnJ9Qpku6suVis+615BOeHjBeeDBE4vz5ewCNreRmCh7cBlGHoq/1P/x1 l/WA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=p7YbzZO8; 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-134548-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-134548-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 i6-20020a170902c94600b001e4063f59a9si1086419pla.107.2024.04.07.09.25.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Apr 2024 09:25:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-134548-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=p7YbzZO8; 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-134548-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-134548-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 C7160B214F2 for ; Sun, 7 Apr 2024 16:25:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B8C753FB2D; Sun, 7 Apr 2024 16:23:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="p7YbzZO8" Received: from mail-ej1-f54.google.com (mail-ej1-f54.google.com [209.85.218.54]) (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 3F2A63D0AF for ; Sun, 7 Apr 2024 16:23:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712507032; cv=none; b=b7iVa3HK06AUmekUwXwV7ksG3p25LosQ4tKHhyBNurYPFL2WU1Bp3JZKk7OEVti7TtVWKcZ88bhITLnxYGrFqRDMDtDqti18QSKdeaFzf7pjQRgzrxt3w9+H3ZDNsN8bCi5iCFzWy2Jr+WDdKd0iAwdCzpCEcKxKcmiSB2CmBMo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712507032; c=relaxed/simple; bh=O7cNoZmVJWFEFWJmtPJYuOXR0ryp+dBLUdbgokTOciQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=NKNnvLmLev2uXuKyzlSYcfBXfowEVDmG8TwSLDuoyRWWui1P/vXT1Ozj5z5skvDgvidz+5blYroWLN0w5wnxeVRzZVk0MGa5xpkHcFNfzLTNIoxnvwLh/A3+9ZIHwiPY5Fg5+uvM2BaJWXFJVn3CI2+vqNsFstOFPQfUX3Rcfn4= 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=p7YbzZO8; arc=none smtp.client-ip=209.85.218.54 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-ej1-f54.google.com with SMTP id a640c23a62f3a-a44f2d894b7so430633366b.1 for ; Sun, 07 Apr 2024 09:23:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712507028; x=1713111828; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=OLN9WNUdytta+DCs//0H8ccz+F/CN1L2bvQTLnp2UBE=; b=p7YbzZO8bBdqdwS5Cw4Es6ajGZExPXZXfowWoMjgUeHgc1FQ8UboTdNuAbwBJv5N28 GvVOFe4eh43uCZN7mhaFk6Y5E0K76rwp17V4N1VWsM76SjYXoGrDvrthVIpmxnu5kGZe gbZGKrFpId+eKto+qJ7CPrExgHLprUZ+ByGwedBljT2cdpY7A/EqplFNn7IKmuwuN15Q iRgluQuEdE8r4bdGSXLOjrlQF9xxRSn+PCM0aQoKwbg4CmuW5W7mnogKcFH/4cZyIXX9 DFKCsnNDViFHsTWlfZ/XasaZsYsjJBn6S2/0PJxdDp8x1MI2pbZhsnfbyHB+W9bsTkLM Yp4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712507028; x=1713111828; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OLN9WNUdytta+DCs//0H8ccz+F/CN1L2bvQTLnp2UBE=; b=HBJEGTgfACs2kH69n4gZcInFwafel1f5jCPQDyGpo5T3MH7AmDIrdj+e28MABrt3bD F5ofZBq+dv7AbCZKT05kmGYj4tOoDDjoAbprczM5BJYhkanP+93YzhwnysULFSAjXMzu odsmJ4am3qwXtovlbeYhSeyTVi0eSPNONF0iyspxNsL0VD3vShtZZuYw5p+Z+RP/JOco MQuB5Ip45izwxloe1G4hDTJgbDaDsHD2bFwoneKo5fCJnlYpTUr3ivy2YPDXpFILc+wM sngPPG6eJ2o3hp9VtjsJmy4sE9xe7NDw/6yJGSwKvJPHtQMH/jtWKlERjsQmMzVDbcvn CuGw== X-Forwarded-Encrypted: i=1; AJvYcCUAYkJH3m9eUZxnOUbO0V7xdzdfZ+1vqEyXBmLLWsZ19cXh3c9EghOksb1pJnnKv5D1ASGtkR+v4XJUR5rdj9pZEWgPv3jMIEltVHvE X-Gm-Message-State: AOJu0YyyxPnjVEx/TZ3uS0CdBp+FSz8TTEiSbfcVyI7IYWs+MOLNrYgq eNuCuHTdYKJ9S+o825KJRWRkkmH8Mt7Stn1W6VewcwK9zv7Zk4Xg+T4xZbYSWcc= X-Received: by 2002:a17:907:7208:b0:a51:ae39:d38d with SMTP id dr8-20020a170907720800b00a51ae39d38dmr4653628ejc.10.1712507028271; Sun, 07 Apr 2024 09:23:48 -0700 (PDT) Received: from [127.0.1.1] ([79.114.172.194]) by smtp.gmail.com with ESMTPSA id qs28-20020a170906459c00b00a51bed388a4sm1811626ejc.139.2024.04.07.09.23.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Apr 2024 09:23:47 -0700 (PDT) From: Abel Vesa Date: Sun, 07 Apr 2024 19:23:25 +0300 Subject: [PATCH v9 5/7] spmi: pmic-arb: Make core resources acquiring a version operation 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="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240407-spmi-multi-master-support-v9-5-fa151c1391f3@linaro.org> References: <20240407-spmi-multi-master-support-v9-0-fa151c1391f3@linaro.org> In-Reply-To: <20240407-spmi-multi-master-support-v9-0-fa151c1391f3@linaro.org> To: Stephen Boyd , Matthias Brugger , Bjorn Andersson , Konrad Dybcio , Dmitry Baryshkov , Neil Armstrong , AngeloGioacchino Del Regno , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: Srini Kandagatla , Johan Hovold , David Collins , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-mediatek@lists.infradead.org, devicetree@vger.kernel.org, Abel Vesa X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=8237; i=abel.vesa@linaro.org; h=from:subject:message-id; bh=O7cNoZmVJWFEFWJmtPJYuOXR0ryp+dBLUdbgokTOciQ=; b=owEBbQKS/ZANAwAKARtfRMkAlRVWAcsmYgBmEsiHRVshxalqChUDkXpbPZfYHay6Mb1g0yx9c YF1dylKjoOJAjMEAAEKAB0WIQRO8+4RTnqPKsqn0bgbX0TJAJUVVgUCZhLIhwAKCRAbX0TJAJUV VgsyD/9ZpGWLQ6fSHuT8lHcf6PLe92F1ZlUXh4snul1QIABFiN+lBE0c8KokFdOhwJBqlZ1sie6 HVvYPPERnGW6i9d9DFJpGCL/0vHkuaGTVZWwTwLZmu8qvby4chYCVYemuVtzA0vFwirB23uPU+n pK9nCspWsaAokwOuOe7h27NOSBZtzB1/WGWPE46tHKldNvM4ih5KKZOBeGwLE25IhsGR1ez+5wl wK+KrH7DPNd3q8mNw+NP4ql05HHkB6uolkhHQV3s616/4nPqAfT40jiAeBLVq+KXJvPmUKlXbf7 0kdBqAMNMZ+fZDm9fEJQGPoeGz+u8kjFD48BKWDqTVrPjZ5Ye3pRk4f+vlkIgfC8xQDKWdyGYJV 1yf+cl5+JCAU/9178+nru1f2mr2vfYD1hNqWm6ibeCu1Nk8HYEuIfZ+ReDE2iHdxxg84uoNylwc uds2OuwSIx6kL5CQZUJMzGusm4q3v/MUqpE5MVJty+Kmpv4el3XXWuafc5bk+o4Md2yE6SLY+0v yo8XEuo1T/uvUDAfjj8OAqejL7YvSO2nsWHxTUlFBiwGGSWQh955srLdNpREJrw9NbXk2t3tsED CifotkqfyFCH6j54QN5kLap9lDEbg4+UrgvrgljN2a0+T4FPMluwIsrK48DD4hy7eYbn1Xkivo5 gRaOgIeft6RcgRg== X-Developer-Key: i=abel.vesa@linaro.org; a=openpgp; fpr=6AFF162D57F4223A8770EF5AF7BF214136F41FAE 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. Since there are no current users of the second bus yet, drop the comment about why devm_platform_ioremap_resource can't be used in case of "core", as it is not applicable anymore. Don't switch to devm_platform_ioremap_resource though as we need to keep track of core size. Reviewed-by: Neil Armstrong Signed-off-by: Abel Vesa --- drivers/spmi/spmi-pmic-arb.c | 114 +++++++++++++++++++++++++++---------------- 1 file changed, 71 insertions(+), 43 deletions(-) diff --git a/drivers/spmi/spmi-pmic-arb.c b/drivers/spmi/spmi-pmic-arb.c index dc969f8bed18..ff777b4a6f33 100644 --- a/drivers/spmi/spmi-pmic-arb.c +++ b/drivers/spmi/spmi-pmic-arb.c @@ -186,6 +186,7 @@ struct spmi_pmic_arb { * struct pmic_arb_ver_ops - version dependent functionality. * * @ver_str: version string. + * @get_core_resources: initializes the core, observer and channels * @init_apid: finds the apid base and count * @ppid_to_apid: finds the apid for a given ppid. * @non_data_cmd: on v1 issues an spmi non-data command. @@ -206,6 +207,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 (*ppid_to_apid)(struct spmi_pmic_arb *pmic_arb, u16 ppid); /* spmi commands (read_cmd, write_cmd, cmd) functionality */ @@ -961,6 +963,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) { u32 *mapping_table; @@ -1062,6 +1077,33 @@ 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); + + pmic_arb->rd_base = devm_platform_ioremap_resource_byname(pdev, "obsrvr"); + if (IS_ERR(pmic_arb->rd_base)) + return PTR_ERR(pmic_arb->rd_base); + + pmic_arb->wr_base = devm_platform_ioremap_resource_byname(pdev, "chnls"); + if (IS_ERR(pmic_arb->wr_base)) + return PTR_ERR(pmic_arb->wr_base); + + return 0; +} + +static int pmic_arb_get_core_resources_v2(struct platform_device *pdev, + void __iomem *core) +{ + struct spmi_pmic_arb *pmic_arb = platform_get_drvdata(pdev); + + pmic_arb->core = core; + + pmic_arb->max_periphs = PMIC_ARB_MAX_PERIPHS; + + return pmic_arb_get_obsrvr_chnls_v2(pdev); +} + static int pmic_arb_ppid_to_apid_v2(struct spmi_pmic_arb *pmic_arb, u16 ppid) { u16 apid_valid; @@ -1239,6 +1281,18 @@ static int pmic_arb_offset_v5(struct spmi_pmic_arb *pmic_arb, u8 sid, u16 addr, return offset; } +static int pmic_arb_get_core_resources_v7(struct platform_device *pdev, + void __iomem *core) +{ + struct spmi_pmic_arb *pmic_arb = platform_get_drvdata(pdev); + + pmic_arb->core = core; + + pmic_arb->max_periphs = PMIC_ARB_MAX_PERIPHS_V7; + + return pmic_arb_get_obsrvr_chnls_v2(pdev); +} + /* * v7 offset per ee and per apid for observer channels and per apid for * read/write channels. @@ -1419,6 +1473,7 @@ pmic_arb_apid_owner_v7(struct spmi_pmic_arb *pmic_arb, u16 n) static const struct pmic_arb_ver_ops pmic_arb_v1 = { .ver_str = "v1", + .get_core_resources = pmic_arb_get_core_resources_v1, .init_apid = pmic_arb_init_apid_v1, .ppid_to_apid = pmic_arb_ppid_to_apid_v1, .non_data_cmd = pmic_arb_non_data_cmd_v1, @@ -1434,6 +1489,7 @@ static const struct pmic_arb_ver_ops pmic_arb_v1 = { static const struct pmic_arb_ver_ops pmic_arb_v2 = { .ver_str = "v2", + .get_core_resources = pmic_arb_get_core_resources_v2, .init_apid = pmic_arb_init_apid_v1, .ppid_to_apid = pmic_arb_ppid_to_apid_v2, .non_data_cmd = pmic_arb_non_data_cmd_v2, @@ -1449,6 +1505,7 @@ static const struct pmic_arb_ver_ops pmic_arb_v2 = { static const struct pmic_arb_ver_ops pmic_arb_v3 = { .ver_str = "v3", + .get_core_resources = pmic_arb_get_core_resources_v2, .init_apid = pmic_arb_init_apid_v1, .ppid_to_apid = pmic_arb_ppid_to_apid_v2, .non_data_cmd = pmic_arb_non_data_cmd_v2, @@ -1464,6 +1521,7 @@ static const struct pmic_arb_ver_ops pmic_arb_v3 = { static const struct pmic_arb_ver_ops pmic_arb_v5 = { .ver_str = "v5", + .get_core_resources = pmic_arb_get_core_resources_v2, .init_apid = pmic_arb_init_apid_v5, .ppid_to_apid = pmic_arb_ppid_to_apid_v5, .non_data_cmd = pmic_arb_non_data_cmd_v2, @@ -1479,6 +1537,7 @@ static const struct pmic_arb_ver_ops pmic_arb_v5 = { static const struct pmic_arb_ver_ops pmic_arb_v7 = { .ver_str = "v7", + .get_core_resources = pmic_arb_get_core_resources_v7, .init_apid = pmic_arb_init_apid_v5, .ppid_to_apid = pmic_arb_ppid_to_apid_v5, .non_data_cmd = pmic_arb_non_data_cmd_v2, @@ -1515,16 +1574,6 @@ static int spmi_pmic_arb_probe(struct platform_device *pdev) pmic_arb = spmi_controller_get_drvdata(ctrl); pmic_arb->spmic = ctrl; - /* - * 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. - */ res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "core"); core = devm_ioremap(&ctrl->dev, res->start, resource_size(res)); if (IS_ERR(core)) @@ -1534,44 +1583,23 @@ static int spmi_pmic_arb_probe(struct platform_device *pdev) hw_ver = readl_relaxed(core + PMIC_ARB_VERSION); - if (hw_ver < PMIC_ARB_VERSION_V2_MIN) { + if (hw_ver < PMIC_ARB_VERSION_V2_MIN) pmic_arb->ver_ops = &pmic_arb_v1; - pmic_arb->wr_base = core; - pmic_arb->rd_base = core; - } else { - pmic_arb->core = core; - - if (hw_ver < PMIC_ARB_VERSION_V3_MIN) - pmic_arb->ver_ops = &pmic_arb_v2; - else if (hw_ver < PMIC_ARB_VERSION_V5_MIN) - pmic_arb->ver_ops = &pmic_arb_v3; - else if (hw_ver < PMIC_ARB_VERSION_V7_MIN) - pmic_arb->ver_ops = &pmic_arb_v5; - else - pmic_arb->ver_ops = &pmic_arb_v7; - - res = platform_get_resource_byname(pdev, IORESOURCE_MEM, - "obsrvr"); - pmic_arb->rd_base = devm_ioremap(&ctrl->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(&ctrl->dev, res->start, - resource_size(res)); - if (IS_ERR(pmic_arb->wr_base)) - return PTR_ERR(pmic_arb->wr_base); - } + else if (hw_ver < PMIC_ARB_VERSION_V3_MIN) + pmic_arb->ver_ops = &pmic_arb_v2; + else if (hw_ver < PMIC_ARB_VERSION_V5_MIN) + pmic_arb->ver_ops = &pmic_arb_v3; + else if (hw_ver < PMIC_ARB_VERSION_V7_MIN) + pmic_arb->ver_ops = &pmic_arb_v5; + else + pmic_arb->ver_ops = &pmic_arb_v7; dev_info(&ctrl->dev, "PMIC arbiter version %s (0x%x)\n", pmic_arb->ver_ops->ver_str, hw_ver); - if (hw_ver < PMIC_ARB_VERSION_V7_MIN) - pmic_arb->max_periphs = PMIC_ARB_MAX_PERIPHS; - else - pmic_arb->max_periphs = PMIC_ARB_MAX_PERIPHS_V7; + err = pmic_arb->ver_ops->get_core_resources(pdev, core); + if (err) + return err; err = pmic_arb->ver_ops->init_apid(pmic_arb); if (err) -- 2.34.1