From patchwork Wed Aug 17 13:14:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 598191 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2D3DFC32771 for ; Wed, 17 Aug 2022 13:14:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239802AbiHQNOs (ORCPT ); Wed, 17 Aug 2022 09:14:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239770AbiHQNOi (ORCPT ); Wed, 17 Aug 2022 09:14:38 -0400 Received: from mail-lj1-x22e.google.com (mail-lj1-x22e.google.com [IPv6:2a00:1450:4864:20::22e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 501564CA1B for ; Wed, 17 Aug 2022 06:14:29 -0700 (PDT) Received: by mail-lj1-x22e.google.com with SMTP id v4so253453ljg.0 for ; Wed, 17 Aug 2022 06:14:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=NUd8YryzxRUKn1lcURqTFfrnvxH9vHeWn1VsvKW9iig=; b=j8crz0TGC0TwfsN5OrJTRjy9ExfL2boMNIiIoZ1GY8DY2Wi8+8b5X5/lv2gqmY7V6o aG0tfYcAOL6OX55fn2TtvZjNbo4cbB98QqLI6hmhHXa0sJFp+4Pd3hGETSYGKooGCm69 i+J0aZOHrU0Gm+Avl9S6OpiDSVZGKzhpbo2W8t4jSJjmP6wfesLIgEK84+vqfZ6B559+ X0gwLCno8PNjo0efY5DtGg0dRn0mtlx988H4zpYMPU3XV3OB7Z1rpjE0ToYiWrO8C3EF 6h4nSwl1PdoWkcuKcYIzDm8rBZdZhVBCMF1EautAoqjbAWO147MRzL1Mp8x0z6ZxSZik H8xQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=NUd8YryzxRUKn1lcURqTFfrnvxH9vHeWn1VsvKW9iig=; b=eu8yq0/YXRUERRDqQerMbRG1dVmwt23bAHHSE9hTi7A9H/UYeNMoOoVATeDfVPiUF3 uJwsjw/PgJ6a2P8+BZytGspgXjCQckRPIpUPU6abND0YEzBGrZnXdwabnN+sVWM8Ch82 hK13d5ozu1I/lvBPGRTbgeD65UJ3C+/IU7znvxPeugj2qsyUO6DZhPQOheh04uvKpRXV +iks6XVQFRX8npbmKbqRUS+muvp3Y+JrZmVRayRpS7QVuXTLZ6NMZBQWRrn+NYMx9C+0 BPnIpzJ7jQLAKaKPnTVJYSzhR1jjwFTDiWfjOd9LsVTAMZT/N2YdmVFe8QMasneCBQw1 MMVw== X-Gm-Message-State: ACgBeo1MmAiy8U7CL42muqovq/ZwP8F/Xf4LcqBsXKQ8UTbwiGM2GPCW SHCBmM2ND/uFeCGSl3e92alCjQ== X-Google-Smtp-Source: AA6agR4ODr7SKicA1GAKwnAKK/adpoZpki8+XPbXTk8r1Ll36pXGE75J4H1rXOx4tDjMzSsB4QzPbA== X-Received: by 2002:a05:651c:154a:b0:25e:7b43:133f with SMTP id y10-20020a05651c154a00b0025e7b43133fmr8631623ljp.137.1660742068771; Wed, 17 Aug 2022 06:14:28 -0700 (PDT) Received: from krzk-bin.. (d15l54h48cw7vbh-qr4-4.rev.dnainternet.fi. [2001:14bb:ae:539c:1b1c:14b7:109b:ed76]) by smtp.gmail.com with ESMTPSA id k1-20020a2ea261000000b0026182f31aa0sm1411307ljm.1.2022.08.17.06.14.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Aug 2022 06:14:28 -0700 (PDT) From: Krzysztof Kozlowski To: Andy Gross , Bjorn Andersson , Konrad Dybcio , Ohad Ben-Cohen , Baolin Wang , Rob Herring , Krzysztof Kozlowski , Lee Jones , Vinod Koul , linux-arm-msm@vger.kernel.org, linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Krzysztof Kozlowski Subject: [RFT PATCH 05/12] hwspinlock: qcom: add support for MMIO on older SoCs Date: Wed, 17 Aug 2022 16:14:08 +0300 Message-Id: <20220817131415.714340-6-krzysztof.kozlowski@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220817131415.714340-1-krzysztof.kozlowski@linaro.org> References: <20220817131415.714340-1-krzysztof.kozlowski@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Older Qualcomm SoCs have TCSR mutex registers with 0x80 stride, instead of 0x1000. Add dedicated compatibles and regmap for such case. Signed-off-by: Krzysztof Kozlowski --- drivers/hwspinlock/qcom_hwspinlock.c | 42 +++++++++++++++++++++------- 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/drivers/hwspinlock/qcom_hwspinlock.c b/drivers/hwspinlock/qcom_hwspinlock.c index 9734e149d981..9cf186362ae2 100644 --- a/drivers/hwspinlock/qcom_hwspinlock.c +++ b/drivers/hwspinlock/qcom_hwspinlock.c @@ -22,6 +22,7 @@ struct qcom_hwspinlock_of_data { u32 offset; u32 stride; + const struct regmap_config *regmap_config; }; static int qcom_hwspinlock_trylock(struct hwspinlock *lock) @@ -73,15 +74,42 @@ static const struct qcom_hwspinlock_of_data of_sfpb_mutex = { .stride = 0x4, }; -/* All modern platform has offset 0 and stride of 4k */ +static const struct regmap_config tcsr_msm8226_mutex_config = { + .reg_bits = 32, + .reg_stride = 4, + .val_bits = 32, + .max_register = 0x1000, + .fast_io = true, +}; + +static const struct qcom_hwspinlock_of_data of_msm8226_tcsr_mutex = { + .offset = 0, + .stride = 0x80, + .regmap_config = &tcsr_msm8226_mutex_config, +}; + +static const struct regmap_config tcsr_mutex_config = { + .reg_bits = 32, + .reg_stride = 4, + .val_bits = 32, + .max_register = 0x20000, + .fast_io = true, +}; + static const struct qcom_hwspinlock_of_data of_tcsr_mutex = { .offset = 0, .stride = 0x1000, + .regmap_config = &tcsr_mutex_config, }; static const struct of_device_id qcom_hwspinlock_of_match[] = { { .compatible = "qcom,sfpb-mutex", .data = &of_sfpb_mutex }, { .compatible = "qcom,tcsr-mutex", .data = &of_tcsr_mutex }, + { .compatible = "qcom,apq8084-tcsr-mutex", .data = &of_msm8226_tcsr_mutex }, + { .compatible = "qcom,ipq6018-tcsr-mutex", .data = &of_msm8226_tcsr_mutex }, + { .compatible = "qcom,msm8226-tcsr-mutex", .data = &of_msm8226_tcsr_mutex }, + { .compatible = "qcom,msm8974-tcsr-mutex", .data = &of_msm8226_tcsr_mutex }, + { .compatible = "qcom,msm8994-tcsr-mutex", .data = &of_msm8226_tcsr_mutex }, { } }; MODULE_DEVICE_TABLE(of, qcom_hwspinlock_of_match); @@ -117,14 +145,6 @@ static struct regmap *qcom_hwspinlock_probe_syscon(struct platform_device *pdev, return regmap; } -static const struct regmap_config tcsr_mutex_config = { - .reg_bits = 32, - .reg_stride = 4, - .val_bits = 32, - .max_register = 0x20000, - .fast_io = true, -}; - static struct regmap *qcom_hwspinlock_probe_mmio(struct platform_device *pdev, u32 *offset, u32 *stride) { @@ -133,6 +153,8 @@ static struct regmap *qcom_hwspinlock_probe_mmio(struct platform_device *pdev, void __iomem *base; data = of_device_get_match_data(dev); + if (!data->regmap_config) + return ERR_PTR(-EINVAL); *offset = data->offset; *stride = data->stride; @@ -141,7 +163,7 @@ static struct regmap *qcom_hwspinlock_probe_mmio(struct platform_device *pdev, if (IS_ERR(base)) return ERR_CAST(base); - return devm_regmap_init_mmio(dev, base, &tcsr_mutex_config); + return devm_regmap_init_mmio(dev, base, data->regmap_config); } static int qcom_hwspinlock_probe(struct platform_device *pdev)