From patchwork Mon Mar 13 07:13:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Komal Bajaj X-Patchwork-Id: 68647 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1041913wrd; Mon, 13 Mar 2023 00:17:30 -0700 (PDT) X-Google-Smtp-Source: AK7set9GrvH1OnX5NGq6M6NZWBYjiWf2L4vNCTxZolEiz3JzNJV9b22j8/8ggBgHymbd15QnxtYw X-Received: by 2002:a17:90a:bc85:b0:237:aade:444 with SMTP id x5-20020a17090abc8500b00237aade0444mr33171400pjr.42.1678691850240; Mon, 13 Mar 2023 00:17:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678691850; cv=none; d=google.com; s=arc-20160816; b=mmVopOHJ8IBUDqgHau+DzdHetvrLseEJe+ANv34YDOKmE7TCu8cmZ2Grw0dFXsZwUg F7rBhrLmwQ3n0MwkRHGNBzPYejXuYBHNZS8qCCxTp+tx9bU4R335ONEKwLlW6wxuSqPg gfj/y/ulmqHzXAQjrCX+bE+ImM3dZyyLCOVtmP4BjwNBfMVY0diEBIwh/DKJrbFWOgnv 1bMAmX0GbU8lY1KPc67G8BK+Yu7o0tEj5+qxiMa4BI+4kZV+4P7qHI04q3GZj1dBnJMB Kz9NByHuTA3BEr3+z/NMPCBcENmveIhQVwzM3zdZf1pmuS00PgkV7469lGwvBaRUA1Kq ETjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=PsVrBKdM/JhYSf1jgy6wK+sv0ULCM3EIwVlOEFeyaDM=; b=rKtlvHStXg/06PrMhSEbawbeAisPPIa+x5V8HPc2mjf1cDg2IsF9DPIAOsoCXdsASO bt9EQTVsI9OadiSVAkvlXn5m8r2pXQPIsftDb0x6OkE9Rdm/rn8YMLNkpYNnjchnVY9b f3hvaMVl5Ul04byW9EAY145iqGal6tynYhl9QhhS8u8akDIpOtt529VmkBRkjBN7IWh4 YmCqS1SfKsOKOEctXN6Xs22w4ADAwI4e1rWnoOMlHvNp9Ckyl9azmyRnAU4HX9gCnm87 KpbVgMEA0BqVEjej/+Dx+6QrbUNzSf4o8zjjluAdsft2zRySAGwczkKt2iSTW3nq1YgY cWAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=lOgZqGC3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ks3-20020a170903084300b001a055028d22si495590plb.334.2023.03.13.00.17.15; Mon, 13 Mar 2023 00:17:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=lOgZqGC3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229831AbjCMHO4 (ORCPT + 99 others); Mon, 13 Mar 2023 03:14:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55570 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230017AbjCMHOd (ORCPT ); Mon, 13 Mar 2023 03:14:33 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2294B360A8; Mon, 13 Mar 2023 00:14:23 -0700 (PDT) Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32D4qSJg000599; Mon, 13 Mar 2023 07:13:53 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=qcppdkim1; bh=PsVrBKdM/JhYSf1jgy6wK+sv0ULCM3EIwVlOEFeyaDM=; b=lOgZqGC3mvY9ScRgdvI8hgVT8kAUv2a0tYwVqpXq3E6zbO7ikhNGIpeEUx44UwzQpHqP PhXKZ2o3mtGIWxp/N38g9H5YyAI88vqbZssOag2TvaoZzC/dKoyYXa6qshq1AocpIsg3 8u9wzRGtw2z6mt4hqzt0JkwvuDQfrbM3steqYFMlNnmFvsU5xHQWvVMmje42E1rH9ugw K7onXzw/L1bG560Ed++r8A5klJxRU8Wr7qzyd2MSUKf/GHg30PvAC1cfvRGZTrL6R1ry qsKjnj3HyAVT/Z4r3+ADfx1FxUMqZRLhI6SL7kXiWOIzuYMbdAyPOECy7Gu74Y+akKql rA== Received: from apblrppmta01.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.18.19]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3p8gnq42hv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 13 Mar 2023 07:13:53 +0000 Received: from pps.filterd (APBLRPPMTA01.qualcomm.com [127.0.0.1]) by APBLRPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 32D7DoaS032170; Mon, 13 Mar 2023 07:13:50 GMT Received: from pps.reinject (localhost [127.0.0.1]) by APBLRPPMTA01.qualcomm.com (PPS) with ESMTP id 3p8jqkkym3-1; Mon, 13 Mar 2023 07:13:50 +0000 Received: from APBLRPPMTA01.qualcomm.com (APBLRPPMTA01.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 32D7DfF3032092; Mon, 13 Mar 2023 07:13:50 GMT Received: from kbajaj-linux.qualcomm.com (kbajaj-linux.qualcomm.com [10.214.66.129]) by APBLRPPMTA01.qualcomm.com (PPS) with ESMTP id 32D7Dofw032164; Mon, 13 Mar 2023 07:13:50 +0000 Received: from kbajaj-linux.qualcomm.com (localhost [127.0.0.1]) by kbajaj-linux.qualcomm.com (Postfix) with ESMTP id 3E506D8; Mon, 13 Mar 2023 12:43:49 +0530 (IST) From: Komal Bajaj To: Rob Herring , Bjorn Andersson , Konrad Dybcio , Abel Vesa , Rishabh Bhatnagar , Prakash Ranjan , Krzysztof Kozlowski , Andy Gross Cc: Komal Bajaj , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH 4/5] soc: qcom: Add LLCC support for multi channel DDR Date: Mon, 13 Mar 2023 12:43:24 +0530 Message-Id: <20230313071325.21605-5-quic_kbajaj@quicinc.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230313071325.21605-1-quic_kbajaj@quicinc.com> References: <20230313071325.21605-1-quic_kbajaj@quicinc.com> MIME-Version: 1.0 X-QCInternal: smtphost X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: rpXNHzAvefbvs2akCBvHgDkYg4FIBGLL X-Proofpoint-ORIG-GUID: rpXNHzAvefbvs2akCBvHgDkYg4FIBGLL X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-12_10,2023-03-10_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 bulkscore=0 mlxlogscore=999 spamscore=0 phishscore=0 suspectscore=0 lowpriorityscore=0 priorityscore=1501 adultscore=0 impostorscore=0 clxscore=1015 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303130058 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760235985086084972?= X-GMAIL-MSGID: =?utf-8?q?1760235985086084972?= Add LLCC support for multi channel DDR configurations based off of a feature register. Signed-off-by: Komal Bajaj --- drivers/soc/qcom/llcc-qcom.c | 56 ++++++++++++++++++++++++++++-- include/linux/soc/qcom/llcc-qcom.h | 2 ++ 2 files changed, 55 insertions(+), 3 deletions(-) diff --git a/drivers/soc/qcom/llcc-qcom.c b/drivers/soc/qcom/llcc-qcom.c index 00699a0c047e..696f1f46dd61 100644 --- a/drivers/soc/qcom/llcc-qcom.c +++ b/drivers/soc/qcom/llcc-qcom.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #define ACTIVATE BIT(0) @@ -924,6 +925,40 @@ static int qcom_llcc_cfg_program(struct platform_device *pdev, return ret; } +static int qcom_llcc_get_cfg_index(struct platform_device *pdev, u32 *cfg_index) +{ + struct device *dev = &pdev->dev; + struct resource *ch_res = NULL; + + u32 ch_reg_sz; + u32 ch_reg_off; + u32 val; + int ret = 0; + + ch_res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "multi_channel_register"); + if (ch_res) { + if (of_property_read_u32(dev->of_node, "multi-ch-bit-off", &ch_reg_off)) { + dev_err(&pdev->dev, + "Couldn't get offset for multi channel feature register\n"); + return -ENODEV; + } + if (of_property_read_u32_index(dev->of_node, "multi-ch-bit-off", 1, &ch_reg_sz)) { + dev_err(&pdev->dev, + "Couldn't get size of multi channel feature register\n"); + return -ENODEV; + } + + if (qcom_scm_io_readl(ch_res->start, &val)) { + dev_err(&pdev->dev, "Couldn't access multi channel feature register\n"); + ret = -EINVAL; + } + *cfg_index = (val >> ch_reg_off) & ((1 << ch_reg_sz) - 1); + } else + *cfg_index = 0; + + return ret; +} + static int qcom_llcc_remove(struct platform_device *pdev) { /* Set the global pointer to a error code to avoid referencing it */ @@ -956,10 +991,13 @@ static int qcom_llcc_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; int ret, i; struct platform_device *llcc_edac; - const struct qcom_llcc_config *cfg; + const struct qcom_llcc_config *cfg, *entry; const struct llcc_slice_config *llcc_cfg; + u32 sz; + u32 cfg_index; u32 version; + u32 no_of_entries = 0; drv_data = devm_kzalloc(dev, sizeof(*drv_data), GFP_KERNEL); if (!drv_data) { @@ -999,8 +1037,20 @@ static int qcom_llcc_probe(struct platform_device *pdev) num_banks >>= LLCC_LB_CNT_SHIFT; drv_data->num_banks = num_banks; - llcc_cfg = cfg[0].sct_data; - sz = cfg[0].size; + ret = qcom_llcc_get_cfg_index(pdev, &cfg_index); + if (ret) + goto err; + + for (entry = cfg; entry->sct_data; entry++, no_of_entries++) + ; + if (cfg_index >= no_of_entries) { + ret = -EINVAL; + goto err; + } + + drv_data->cfg_index = cfg_index; + llcc_cfg = cfg[cfg_index].sct_data; + sz = cfg[cfg_index].size; for (i = 0; i < sz; i++) if (llcc_cfg[i].slice_id > drv_data->max_slices) diff --git a/include/linux/soc/qcom/llcc-qcom.h b/include/linux/soc/qcom/llcc-qcom.h index ad1fd718169d..225891a02f5d 100644 --- a/include/linux/soc/qcom/llcc-qcom.h +++ b/include/linux/soc/qcom/llcc-qcom.h @@ -125,6 +125,7 @@ struct llcc_edac_reg_offset { * @cfg: pointer to the data structure for slice configuration * @edac_reg_offset: Offset of the LLCC EDAC registers * @lock: mutex associated with each slice + * @cfg_index: index of config table if multiple configs present for a target * @cfg_size: size of the config data table * @max_slices: max slices as read from device tree * @num_banks: Number of llcc banks @@ -139,6 +140,7 @@ struct llcc_drv_data { const struct llcc_slice_config *cfg; const struct llcc_edac_reg_offset *edac_reg_offset; struct mutex lock; + u32 cfg_index; u32 cfg_size; u32 max_slices; u32 num_banks;