Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp2018731lqz; Tue, 2 Apr 2024 05:09:50 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWuOlVgw+TSQvk5gN1kX5eR/t9MjGySlHjlGNNJFxcBw/7uJA58MhGbaysBvzg8EGRxpvXuh5MuqYTvFA9QkqxQxvm7dKaYGk4lgdkBCw== X-Google-Smtp-Source: AGHT+IGEOCC3CrB8Qd1Gg7AA5I+KKRyO179Q9tAGWSBp721SZXYmp6YrShKRHgYgQg+Ds6y2YHiF X-Received: by 2002:a17:902:e852:b0:1e0:94a1:95c1 with SMTP id t18-20020a170902e85200b001e094a195c1mr12731086plg.29.1712059789712; Tue, 02 Apr 2024 05:09:49 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712059789; cv=pass; d=google.com; s=arc-20160816; b=zpU/P9AKYtM4ZWjfDuwIN4+MHciKm0oTMorQtMjkaPSECKzPLTL1/S7ZULNxupbe0o XFf/ejYUniypbUWDOhcyvgr0UvZhm06kYO9KP7YFe7zq1/nmwAYQ8rY+GmFwi/sKgtTh 8mrJ1oxrrBhU1A5SNFHLqbThbyeQOGW36cXg2AuoviUlN3rnebl0kJUnhKChyflQx6UP h4XzzuEWBIsOfWrJBFLUWmctMIHtUc1woaosV977JXWXOvbl4+Iwh3niRR23xMHIakR4 lRoFWrtDcDR44XrHZCu46oDKpD92W6Bykz3D3QcbSWJw9Sf5q1XR1Vs9SvGtTlQj0mxo SNsA== 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=Z7Pnr6PoGhceBp/MkaACIjm9COgBNW2tpmbpLJHir3Y=; fh=H+bYkb1mIpuG5v7Y8C6YS+vZbepy7XJnaKHk7Gne9i4=; b=0Qv/kz4i/1/L3Bh9pc33qwHcQGOZknz5YpKf5Bp5+DeHjMEYIpyNKKEv3O6Txgr0p9 JQBe7p04PJxG3Rkw/wy/fz9PLtQimDWxBveHmD/pNKjKEwMY57CXs80ZVvjK8ptqHpCC XWo5MKHOW0bXJ0I9jw5b+h6LOh66va+6BdvMDfX60mB7OieDEJf/t7e/K1Lg1xkP4aS/ oKG5WBu6X2+PANT0GcDCDj/8UbTJNaao9eBvuTlFIZ32VDDOTsvyyw35I4Y+kZsLIram BIuBwMCDrkzR4AwDRND9J8aHydHILgNZdZ9kI5jkIDkcu1BsP8MStK2rihZ/OS+mXk02 CkMw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XbKokDz6; 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-127900-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-127900-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id i4-20020a170902c94400b001dd8ea56a15si11416984pla.121.2024.04.02.05.09.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Apr 2024 05:09:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-127900-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XbKokDz6; 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-127900-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-127900-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 08719286FE1 for ; Tue, 2 Apr 2024 12:09:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CA6158172E; Tue, 2 Apr 2024 12:08:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="XbKokDz6" Received: from mail-ej1-f44.google.com (mail-ej1-f44.google.com [209.85.218.44]) (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 530AE7A15A for ; Tue, 2 Apr 2024 12:08:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712059686; cv=none; b=gIB5ln4DLWMoyMM1OXQXD/03bTLeXkpKsu0cy14+zRWmmO79QK2sgIjEAaFG/ZVPObihJhz+/iFvL5k3YG+Iqu1ZYvd+2qrCtHqaxXksiftP4DnfpYslvM6WKn9Zlj6J1AxlvWFzrjGZbNWlsc0N8uGoFiOCPDCESg9AzdatPsA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712059686; c=relaxed/simple; bh=0hIdOnPxC6/IlNZDC4oQnGBBsSrIsuVpzjKgCwMCAOo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=eDQBJ0ipOzVb/ptEDWQbaeMwXTwKBoQ0y2b344rvAOLlqK2FdsC3KjEqBzWQ/Syy3o6aoIZCikeExNY9Jh/8w9oL1zE9leNECmVyl4RYHjUr56N9mTgQrSHkUuYNPBpxxCEt0qpbQd9iIino2X6bS+Jq6UuXp+sCw4yxuhx1ZWs= 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=XbKokDz6; arc=none smtp.client-ip=209.85.218.44 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-f44.google.com with SMTP id a640c23a62f3a-a46a7208eedso657550066b.0 for ; Tue, 02 Apr 2024 05:08:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712059683; x=1712664483; 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=Z7Pnr6PoGhceBp/MkaACIjm9COgBNW2tpmbpLJHir3Y=; b=XbKokDz6h+01q0jdLpPMELXEtqOmEqkIo8gL5pajNnz1l5kV8UnrvcfLyGDfNkZS0h f5+DI3ZK1JrEQGuAPOe4y9e6EhOruq6cYwmeIoKH8b7xxMpCVPhHPWorVO7cYc7op1Lw cfHnpRCiHlJ2ftwo/5fE6Jj8/lcfZCkK2Mkf+2OgwFfRXfxU7WksJ93T5qtMaA91lQhG 46d7vupERK7xG0ZMNX+R4+xX/jYojy6+JSqqKG24r18MdUgT3mrp0Qq8HJwJI++YpiVg d2cNVTUaAV7HJDILV9gtzSmxI4HdsBQfS7X8kfFo1aw7n/FqGX6vCEHRVcxggw5mNFXs rF9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712059683; x=1712664483; 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=Z7Pnr6PoGhceBp/MkaACIjm9COgBNW2tpmbpLJHir3Y=; b=Hb/4T+2/d/sUXR4ifJOXYR8tMWLYwzkDcwPlqFgZU+PDPdOEYfgv8NPaRpn1QOZunv L388yDEyA2yvoam6Yc/2khTvPj/hxc32WH2Pd9o3yuyuJleSh9thxH4JUQdmkBKmtKEt WO1D+mbNnoBTpnUJKAji8lwffxRO8PeDoBq8e0wQTbSKfIPI+4JjhSX3Z8Ma8oYPxQqP hBVJXK63f6ftLagsxCNk5dVFyXVhCiHLTUjqtzysrWoB6fL6gyjhoRdi3pfBVyMIjrQF Xj/attH7FfXgyYo8bzSb7IC0j0UabxlVN7Ra/omSnUBk4RDl/NAyJODccSou4od7rHme dfGg== X-Forwarded-Encrypted: i=1; AJvYcCWZ46uTCDJ1Cif8ayIsnftfYEBJW/gZM3QrKVuevFonAneqNybe2JnHhh8JhJwAEgd5ITzW1zC8xqCEDyjNSHDpg7AgYDiDkVqbMS9T X-Gm-Message-State: AOJu0YxJhiqdJoXoWXRoCLG82F7AfzrwUzQE49Ol1U0mDmVwqkMh4Oq6 WWqQ5KudvlQYnsQb4lHGtC0CWB+MPot3Pxju8pK88qSLIsaXsCGj6D3L7a5f5T8= X-Received: by 2002:a17:906:f754:b0:a47:183d:6c82 with SMTP id jp20-20020a170906f75400b00a47183d6c82mr7038780ejb.31.1712059682557; Tue, 02 Apr 2024 05:08:02 -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.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Apr 2024 05:08:02 -0700 (PDT) From: Abel Vesa Date: Tue, 02 Apr 2024 15:07:33 +0300 Subject: [PATCH v8 4/7] spmi: pmic-arb: Make the APID init 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-4-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=9054; i=abel.vesa@linaro.org; h=from:subject:message-id; bh=0hIdOnPxC6/IlNZDC4oQnGBBsSrIsuVpzjKgCwMCAOo=; b=owEBbQKS/ZANAwAKARtfRMkAlRVWAcsmYgBmC/UU4XmfotH+ILXtrDAyYAY2eFzmgr0ENVhS/ xJc3ChnLoaJAjMEAAEKAB0WIQRO8+4RTnqPKsqn0bgbX0TJAJUVVgUCZgv1FAAKCRAbX0TJAJUV Vh4WEACJIpSwO9kKQF5zttWad6DOjL+Pj235726jT1wwuv1gTQaf62i4YIDB8Jpav1yAwls/F73 h59aK4lBjqnBcV9JetxIMKPYW/nsCAaWGydvquEC58diCZTY2xqItu41zyMaiSBAx3ovU1LJGwH I8KbKjYdUrZdpCYnbnVYkuhCo+AK096bXmEyV8I47kErU1zjo3ZJ/heV67mFY9qeNI91L5ojUHr f4J0BcHBfLQuk/Qm6uaNfOt3oUFzZrI8JgSoWNfxBIhCkPwM8Tkoe4EhgzH6SXKXiDE4LHY2/4Q 3ToAQGR1axG8seUfE3/+QivgMlZTT9KLyns59xfNrn30Bi2TIoooeJ/Txp4eM8Yv/rnR7+GiSJa vRbBa23cH4wzVFFkBCq3SKCxk6+tozUpkDuZrgVFKbnpQ0jpCCgKC91YN/A3YHu4t13X5hG6Vvq 2jKbS8Y7aYIbpnbyAA02jaCOUZMYuwDIpDE4JKyl3Id5kRxvekF3LqHqY9pA7ll6KtvLmJhxL+Q iKfZ9rr1wUIkbwSyz8cqwbjMtV+fientogkNtzwK3l6utP0D7CZRTWdTGL09Wj9xIeW8idY6RE1 3TBDhFu6ma/Ta+xys3lIzkjfphGhQc54QsR9rCx5MZvdR8nTphD3P690PQoRbEX9dciciazE5u6 Q/O/WuwAriDT5tg== X-Developer-Key: i=abel.vesa@linaro.org; a=openpgp; fpr=6AFF162D57F4223A8770EF5AF7BF214136F41FAE Rather than using conditionals in probe function, add the APID init as a version specific operation. Due to v7, which supports multiple buses, pass on the bus index to be used for sorting out the apid base and count. Reviewed-by: Neil Armstrong Signed-off-by: Abel Vesa --- drivers/spmi/spmi-pmic-arb.c | 144 +++++++++++++++++++++---------------------- 1 file changed, 69 insertions(+), 75 deletions(-) diff --git a/drivers/spmi/spmi-pmic-arb.c b/drivers/spmi/spmi-pmic-arb.c index 704fd4506971..dc969f8bed18 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. + * @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. * on v2 no HW support, returns -EOPNOTSUPP. @@ -205,6 +206,7 @@ struct spmi_pmic_arb { */ struct pmic_arb_ver_ops { const char *ver_str; + 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 */ int (*offset)(struct spmi_pmic_arb *pmic_arb, u8 sid, u16 addr, @@ -947,6 +949,32 @@ static int qpnpint_irq_domain_alloc(struct irq_domain *domain, return 0; } +static int pmic_arb_init_apid_min_max(struct spmi_pmic_arb *pmic_arb) +{ + /* + * Initialize max_apid/min_apid to the opposite bounds, during + * the irq domain translation, we are sure to update these + */ + pmic_arb->max_apid = 0; + pmic_arb->min_apid = pmic_arb->max_periphs - 1; + + return 0; +} + +static int pmic_arb_init_apid_v1(struct spmi_pmic_arb *pmic_arb) +{ + u32 *mapping_table; + + mapping_table = devm_kcalloc(&pmic_arb->spmic->dev, pmic_arb->max_periphs, + sizeof(*mapping_table), GFP_KERNEL); + if (!mapping_table) + return -ENOMEM; + + pmic_arb->mapping_table = mapping_table; + + return pmic_arb_init_apid_min_max(pmic_arb); +} + static int pmic_arb_ppid_to_apid_v1(struct spmi_pmic_arb *pmic_arb, u16 ppid) { u32 *mapping_table = pmic_arb->mapping_table; @@ -1149,6 +1177,34 @@ static int pmic_arb_offset_v2(struct spmi_pmic_arb *pmic_arb, u8 sid, u16 addr, return 0x1000 * pmic_arb->ee + 0x8000 * apid; } +static int pmic_arb_init_apid_v5(struct spmi_pmic_arb *pmic_arb) +{ + int ret; + + pmic_arb->base_apid = 0; + pmic_arb->apid_count = readl_relaxed(pmic_arb->core + PMIC_ARB_FEATURES) & + PMIC_ARB_FEATURES_PERIPH_MASK; + + if (pmic_arb->base_apid + pmic_arb->apid_count > pmic_arb->max_periphs) { + dev_err(&pmic_arb->spmic->dev, "Unsupported APID count %d detected\n", + pmic_arb->base_apid + pmic_arb->apid_count); + return -EINVAL; + } + + ret = pmic_arb_init_apid_min_max(pmic_arb); + if (ret) + return ret; + + ret = pmic_arb_read_apid_map_v5(pmic_arb); + if (ret) { + dev_err(&pmic_arb->spmic->dev, "could not read APID->PPID mapping table, rc= %d\n", + ret); + return ret; + } + + return 0; +} + /* * v5 offset per ee and per apid for observer channels and per apid for * read/write channels. @@ -1363,6 +1419,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", + .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, .offset = pmic_arb_offset_v1, @@ -1377,6 +1434,7 @@ static const struct pmic_arb_ver_ops pmic_arb_v1 = { static const struct pmic_arb_ver_ops pmic_arb_v2 = { .ver_str = "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, .offset = pmic_arb_offset_v2, @@ -1391,6 +1449,7 @@ static const struct pmic_arb_ver_ops pmic_arb_v2 = { static const struct pmic_arb_ver_ops pmic_arb_v3 = { .ver_str = "v3", + .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, .offset = pmic_arb_offset_v2, @@ -1405,6 +1464,7 @@ static const struct pmic_arb_ver_ops pmic_arb_v3 = { static const struct pmic_arb_ver_ops pmic_arb_v5 = { .ver_str = "v5", + .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, .offset = pmic_arb_offset_v5, @@ -1419,6 +1479,7 @@ static const struct pmic_arb_ver_ops pmic_arb_v5 = { static const struct pmic_arb_ver_ops pmic_arb_v7 = { .ver_str = "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, .offset = pmic_arb_offset_v7, @@ -1444,7 +1505,6 @@ static int spmi_pmic_arb_probe(struct platform_device *pdev) struct spmi_controller *ctrl; struct resource *res; void __iomem *core; - u32 *mapping_table; u32 channel, ee, hw_ver; int err; @@ -1472,12 +1532,6 @@ static int spmi_pmic_arb_probe(struct platform_device *pdev) pmic_arb->core_size = resource_size(res); - pmic_arb->ppid_to_apid = devm_kcalloc(&ctrl->dev, PMIC_ARB_MAX_PPID, - sizeof(*pmic_arb->ppid_to_apid), - GFP_KERNEL); - if (!pmic_arb->ppid_to_apid) - return -ENOMEM; - hw_ver = readl_relaxed(core + PMIC_ARB_VERSION); if (hw_ver < PMIC_ARB_VERSION_V2_MIN) { @@ -1511,58 +1565,17 @@ static int spmi_pmic_arb_probe(struct platform_device *pdev) return PTR_ERR(pmic_arb->wr_base); } - pmic_arb->max_periphs = PMIC_ARB_MAX_PERIPHS; + 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) { + 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; - /* Optional property for v7: */ - of_property_read_u32(pdev->dev.of_node, "qcom,bus-id", - &pmic_arb->bus_instance); - if (pmic_arb->bus_instance > 1) { - dev_err(&pdev->dev, "invalid bus instance (%u) specified\n", - pmic_arb->bus_instance); - return -EINVAL; - } - if (pmic_arb->bus_instance == 0) { - pmic_arb->base_apid = 0; - pmic_arb->apid_count = - readl_relaxed(core + PMIC_ARB_FEATURES) & - PMIC_ARB_FEATURES_PERIPH_MASK; - } else { - pmic_arb->base_apid = - readl_relaxed(core + PMIC_ARB_FEATURES) & - PMIC_ARB_FEATURES_PERIPH_MASK; - pmic_arb->apid_count = - readl_relaxed(core + PMIC_ARB_FEATURES1) & - PMIC_ARB_FEATURES_PERIPH_MASK; - } - - if (pmic_arb->base_apid + pmic_arb->apid_count > pmic_arb->max_periphs) { - dev_err(&pdev->dev, "Unsupported APID count %d detected\n", - pmic_arb->base_apid + pmic_arb->apid_count); - return -EINVAL; - } - } else if (hw_ver >= PMIC_ARB_VERSION_V5_MIN) { - pmic_arb->base_apid = 0; - pmic_arb->apid_count = readl_relaxed(core + PMIC_ARB_FEATURES) & - PMIC_ARB_FEATURES_PERIPH_MASK; - - if (pmic_arb->apid_count > pmic_arb->max_periphs) { - dev_err(&pdev->dev, "Unsupported APID count %d detected\n", - pmic_arb->apid_count); - return -EINVAL; - } - } - - pmic_arb->apid_data = devm_kcalloc(&ctrl->dev, pmic_arb->max_periphs, - sizeof(*pmic_arb->apid_data), - GFP_KERNEL); - if (!pmic_arb->apid_data) - return -ENOMEM; - - dev_info(&ctrl->dev, "PMIC arbiter version %s (0x%x)\n", - pmic_arb->ver_ops->ver_str, hw_ver); + err = pmic_arb->ver_ops->init_apid(pmic_arb); + if (err) + return err; res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "intr"); pmic_arb->intr = devm_ioremap_resource(&ctrl->dev, res); @@ -1604,16 +1617,6 @@ static int spmi_pmic_arb_probe(struct platform_device *pdev) } pmic_arb->ee = ee; - mapping_table = devm_kcalloc(&ctrl->dev, pmic_arb->max_periphs, - sizeof(*mapping_table), GFP_KERNEL); - if (!mapping_table) - return -ENOMEM; - - pmic_arb->mapping_table = mapping_table; - /* Initialize max_apid/min_apid to the opposite bounds, during - * the irq domain translation, we are sure to update these */ - pmic_arb->max_apid = 0; - pmic_arb->min_apid = pmic_arb->max_periphs - 1; platform_set_drvdata(pdev, ctrl); raw_spin_lock_init(&pmic_arb->lock); @@ -1622,15 +1625,6 @@ static int spmi_pmic_arb_probe(struct platform_device *pdev) ctrl->read_cmd = pmic_arb_read_cmd; ctrl->write_cmd = pmic_arb_write_cmd; - if (hw_ver >= PMIC_ARB_VERSION_V5_MIN) { - err = pmic_arb_read_apid_map_v5(pmic_arb); - if (err) { - dev_err(&pdev->dev, "could not read APID->PPID mapping table, rc= %d\n", - err); - return err; - } - } - dev_dbg(&pdev->dev, "adding irq domain\n"); pmic_arb->domain = irq_domain_add_tree(pdev->dev.of_node, &pmic_arb_irq_domain_ops, pmic_arb); -- 2.34.1