Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp2018435lqz; Tue, 2 Apr 2024 05:09:23 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXUSVR6V9B4JqXQeLKvaCGdhRJebLGiG4+CdHxLPSpe+GwXEsbwVlkd9MwIj5AuH3uyljY/0NiBGpRcoOK75XaboY9YKGkR5vpZt/GxBQ== X-Google-Smtp-Source: AGHT+IHLru4cS69vwbKG2SDRAbfRgrepNHeWtaqlb/urX43JAFrdN36EsWAXIW9NVS1C53XHvfwZ X-Received: by 2002:a05:6122:390a:b0:4d3:3952:1d1a with SMTP id ep10-20020a056122390a00b004d339521d1amr8967137vkb.4.1712059763256; Tue, 02 Apr 2024 05:09:23 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712059763; cv=pass; d=google.com; s=arc-20160816; b=fKMYS61Wpp5NUUUm06XG+3fJck8SodSZtE/Px3POjuH9UiNhOTUBk0/RP7wl5IOMQK wRmP37D0mT9c7kKrQntmH+ETlUAyrLxM56AcakN+EVLeiuNUisAkBKePYczBYK4RgNVj IW1qdx1nuBmFvX+5CZLTT8Nw+MCljpbcA6tCKheGUUCldVpB/Q4b6ovhz/mmtg2o/z/r hUyuFfpV5OxTeF5wCpWhP2LHePCBXWP8z8CbBHwRH8QAxBzJuLNHZM+7vfhXync8weHD CrVINwAYqB+YfmYtWARTZSqLvC9lrhhZwor+gGdwSawSTDNEyvfUY1HOwyf5OIRKgYmC yaNQ== 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=/uNbQR0zF0VsAKrw3zD4GC8QTQxPAbo2fyLYoHQMFlY=; b=JXMO4ocGiFGaPWNhZl4jAipjya3sbybuAdpfWVeAx/msFEb5pO3UG0pEH6FsSwhPHz HvZFULkcFRxKdcm0wtueOIkSD27TgoRvoUaeu46mVHjvbnX0de7HLEAWsegtEiQjM5+t YMtlaS6NPUzr+gIArJm7UWLM9Ns9hOT97U1wYr/OKcrVBk5sHlx78A8+uKcf2ONHHjan qaHWhOebsXGP1RfjP55JbW8nBGB6VkveAzbC/5oBNYpsTJBEpX2adW2pRrMJjcGwADuQ WZjZdQsa0n9tW7XjsVDaf95OTMJlbTvCbhXfr1+1AFu9OaHOa6pXVkRevJITKQZpJaxA p7lA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yJ7gpiI+; 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-127901-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-127901-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id dp20-20020a05612225d400b004d8b9df3638si1432506vkb.87.2024.04.02.05.09.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Apr 2024 05:09:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-127901-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yJ7gpiI+; 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-127901-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-127901-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id DBF5F1C213F3 for ; Tue, 2 Apr 2024 12:09:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8D9A5839FF; Tue, 2 Apr 2024 12:08:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="yJ7gpiI+" Received: from mail-ej1-f50.google.com (mail-ej1-f50.google.com [209.85.218.50]) (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 0FFC97FBA0 for ; Tue, 2 Apr 2024 12:08:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712059688; cv=none; b=CI+Fp5fWGQc8BzF4DWjylcNZ4lBT1x9d0YuAVa1XtDn3/LPQgvurH7oprfesuu0fmMErF2BPNjiu1IRR9reDeZdSP4O4K5kKQnBTkzA3thff/Glnlix+S5gIzm3xYeTGWMvYvArTbI9MrKUIDaAr6KvPAa/DqXOJQy7dbhqM8Sg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712059688; c=relaxed/simple; bh=O7cNoZmVJWFEFWJmtPJYuOXR0ryp+dBLUdbgokTOciQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=rFzzBJO0gHAqHajomfV76FQ5YW3V3KCVVm2Wl5qNbNjNKSMRX76Iy5Qjx3h7QjMRTo2C1ySqFOBx48P92ZXsUKBf7mbORWMWAzCS2ZYVdsKD4cOESHzXYMyfLnrNPEOA5y9IeZ5gSEC21YiZsASP0v/zq5W/DdI+/XewYPGixUY= 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=yJ7gpiI+; arc=none smtp.client-ip=209.85.218.50 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-f50.google.com with SMTP id a640c23a62f3a-a4715991c32so634360466b.1 for ; Tue, 02 Apr 2024 05:08:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712059684; x=1712664484; 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=yJ7gpiI+97oa7+iJhOskoktzV+EL0sC6ERGJA0paiimfPKdjdAolw6JSGMHGo/ZmDm u050v8LNg7FDBwO60mc0IegIiBRkzk2i2VBV49+5WQjPrxzyGdv/PSKoqQDmrfRScXF/ U5TM1FlhaFtgpdzTv2MTplwZgiwdangE8X9keOu5cpbay30iZoEBC74beKWp6QQV1LDZ dhpyLz9LKsAq0nt9noUEAi+NAkgi5BC708GDIZ2udsl+Y2/N6dYXkNzhNo4Ade95FNfw Hgi9tDNKMW2+qmcCq4EmO5dLDH41G6dlbC7CA3nRRQlCPXmcg2zQRyp/nKx8/qhfQK2G /kjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712059684; x=1712664484; 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=lj9+mKG+4eHUpCs+gNTrNRovWqadX2BMY5gMPhjWxAW+HaZO1Zm7Z7dy1kZWAcRwzr egS4rYK657OXaoijJ6F23B0wMEPn6TT/SYNHuHjs7w6lv4QzEVt+BSwySM1vnrLWyEEP 0jTZco9ogWRra9IUUT5cEibkB0f0Xkm7bR+C/JzCP24ZKG380sH0LA9aYukqSV5CrIuZ NcJ4pGMSxhMEiadKc5QzxDxJfelYfl0dxHrBJkoyc3jRFGvxafA+mEHo7r3I+A+GaMQP YGQ/y0WbFlb2rJK2yiL/KYMv2L6iEvzVEewoFBQImTEzXzk5cdXZfObjQqgAPjSfu4u5 YBMw== X-Forwarded-Encrypted: i=1; AJvYcCUHOeOXvCxfnM74vQKRBT0RNZrXb6GPS8WDN5KNlVqUHAxdr0vhNPxqA5HGP9TwdmBJ5ixp1lmvMu8UwyRAE4vOrFkWt6RDeuHM3XxP X-Gm-Message-State: AOJu0Yzv3hGSTODuwQi7wk9ZLX3x6ml/GpevjRayhw81yRghUQyMQ0/E ktLmomXENmUEoE4S3sIwG6V2OfvZViBg4Wu38GtvZwmm2PFyRTKHdUQ1VVdfI6s= X-Received: by 2002:a17:906:f0cc:b0:a47:3428:2b2f with SMTP id dk12-20020a170906f0cc00b00a4734282b2fmr7437788ejb.64.1712059684163; Tue, 02 Apr 2024 05:08:04 -0700 (PDT) Received: from [127.0.1.1] ([79.114.172.194]) by smtp.gmail.com with ESMTPSA id l13-20020a1709065a8d00b00a4df251a601sm6519384ejq.77.2024.04.02.05.08.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Apr 2024 05:08:03 -0700 (PDT) From: Abel Vesa Date: Tue, 02 Apr 2024 15:07:34 +0300 Subject: [PATCH v8 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: <20240402-spmi-multi-master-support-v8-5-ce6f2d14a058@linaro.org> References: <20240402-spmi-multi-master-support-v8-0-ce6f2d14a058@linaro.org> In-Reply-To: <20240402-spmi-multi-master-support-v8-0-ce6f2d14a058@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 , 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/ZANAwAKARtfRMkAlRVWAcsmYgBmC/UW/l9NfW87+6fhsij0uYti2odDmCnO7Rr5g RIiXvqys2aJAjMEAAEKAB0WIQRO8+4RTnqPKsqn0bgbX0TJAJUVVgUCZgv1FgAKCRAbX0TJAJUV VgKhD/4kjFXwwb70eAQh4aH2yC5sviEPNz2a0eR8CzUhs0oWyBdP3MqvcBwLhdWDgnXV2Uv2VnB qV4fTiKbFJJKgZ2anVsJjuJN4KzmF3xD4y47NwXIiYMpzfKxfSm0kOXbJvRNTRlWuNDjdjHQ5s8 33V/Rq1hA/f1U/92uicRL9aBoBV94FIhRMp7ifJnjeGt+DJIq5BkDljB0PqFl0J8g8DHrqBgaIo GHU0H2B4B0JQPlQKz0JZjiXyaISI0z1tLhXIIuyzXZgs2O293ApFVzchkz0EUwjFCYPOk2vOc63 a0doCCaSbfZJQaqjadKV6MdcB37aSWbwl2pV9Msg4nMNtA1RqWKJv/H1G792sFfV0Lu6wPRoqs+ p8bf7h6rJpw5J0wdppny3kDfqEL887w08ZapP/Z7nGb7D5kLxsGYCp2KQ7nILl7maEDeSg3VhFv b4mhTOwtosRMdWazFvpWWIL3kv0AIvStXx9op6O95QPoFJKEizTVkC+3urdwr75GzilCWipAFIs azeXQWRpgUCGR06jCVUcwNg8q6I0bf9CDkoJfF4+jQMlK6iXsoz4xRlAsm/HkwcWooVVX3dAIeB MLwcNlDwYEfhp0MX5uJoLPpMXLRL3Oa0FEK2v4XA1RB1f1/YVV2qiTPc3NRKd8tAx9YxbfJtvJX AipvK/ZjarLADHA== 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