From patchwork Wed Aug 2 09:14:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Komal Bajaj X-Patchwork-Id: 129732 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f41:0:b0:3e4:2afc:c1 with SMTP id v1csp336290vqx; Wed, 2 Aug 2023 02:53:03 -0700 (PDT) X-Google-Smtp-Source: APBJJlFqpBAjQzPl4puik3IeTxqjdIRgxebt3ELiZhRUv3L6VydAwSC1SVlLnhmFwH+qURELEEuo X-Received: by 2002:a05:6a20:26a5:b0:13e:72c9:fd9d with SMTP id h37-20020a056a2026a500b0013e72c9fd9dmr3345849pze.51.1690969982684; Wed, 02 Aug 2023 02:53:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690969982; cv=none; d=google.com; s=arc-20160816; b=Gc7RNLhmuk9C53jijzSm4BxPPPIRZP5rVh9uH/Zdvr7RnR6gjIXILbwtP2bGsSnkVo GIUWVSZSV3qlZ5LYVbFuM5mpov4kn4W8VMgGZjQDam4vBd2xYYDo82TrREkwVYwDkDBW n0/ylLrZZDAxr9htX+M2cHdQItH+fNyEtBRN6mPsDldjh3D0oZ5nog13F3Nq6BsLPCH0 PDEljBWTz2PWkGbJalzmX/q0Z1vzPcvsmlIyKf8liOnLFTx9u3So8RA1OnOmjGA+4mGL Efh5Y+W+O6WTl3aeVHHoJ6q9gXhbGGHOG0IecAtjwPXgZhg/JRYkdFNJzp7NKBhwR4/X BGjg== 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=Of1hk5YPkxFWMY6d7ba6dP4mkb8IkG1kOQrgfD2oLR0=; fh=+vUcU9Ka/zutQtgnWdg0fu+fF6W3G4xdx8y/5nL/YjU=; b=HF8pKuttdWMlqA+6KtU5+dMYvsw6r54fOtyUPzqlTOZd75qgJjryy4lzyALmlKXXN9 oyrregKTwqJ0rVEMmle6OCqBtfDARBSFAU3XYkgvOqa2msv17i1zMkVbdIeGGRyJr5oo p3oRzZvtE9KnK9j6dk0GZgQFSPxfyKr8kcD/nKrqaoZ7vzFOAlJUZuOpnxrFK6ykCkY5 7a0dyDAOMguncWYTRrg/a7jQ3/npSw/LVzp2DBdhElPayqBJjIMYKYAEh2L9BcaSQAnh 4G/UWuUifGGhJx7Zxn7Rq1glFFHZgAFc1OPc2MH7l6UyS2DsE1H6ReycJwM3AANKdWx6 SJcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=oUNZQ7s5; 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 lk3-20020a17090308c300b001b9e29fe870si983943plb.62.2023.08.02.02.52.48; Wed, 02 Aug 2023 02:53:02 -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=oUNZQ7s5; 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 S234116AbjHBJPk (ORCPT + 99 others); Wed, 2 Aug 2023 05:15:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234082AbjHBJPU (ORCPT ); Wed, 2 Aug 2023 05:15:20 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2564130F2; Wed, 2 Aug 2023 02:15:14 -0700 (PDT) Received: from pps.filterd (m0279862.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3723mMkR029434; Wed, 2 Aug 2023 09:15:10 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 : content-type; s=qcppdkim1; bh=Of1hk5YPkxFWMY6d7ba6dP4mkb8IkG1kOQrgfD2oLR0=; b=oUNZQ7s522rtEFWiJ2KD6FC2WftYihNh5fNxDh2yHnUnmme/eA897cjHTslnOm0mGlp9 F8aj6kT+zfNpdxU3hEtbwRBvLh9DUpguqTnM/NQBqooVN3YxZY6KFUafz8gcmNYooMlK NGHh24Tb2WU1gEHlqN/IEz/uLR811xQcfdshl4FmADhPj6g7FQuYi11Lbsje3ifpZFYH WIYEBQRDJkmop2AKS/AT8cAflHbd1qkVlpEAD3MXOYVJ3M1Dhcx/Jtr+Vl9QTBZqoQ+C 02CZbhqTNsCB6jUUV28Vk01T1yw5ony+ZLqSu/KNPxmDYaj0zz7UWvWLtQWI9pOA/oHc Qw== Received: from nasanppmta01.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3s6yq4asrx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 02 Aug 2023 09:15:10 +0000 Received: from nasanex01b.na.qualcomm.com (nasanex01b.na.qualcomm.com [10.46.141.250]) by NASANPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 3729F9B2018842 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 2 Aug 2023 09:15:09 GMT Received: from hu-kbajaj-hyd.qualcomm.com (10.80.80.8) by nasanex01b.na.qualcomm.com (10.46.141.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.30; Wed, 2 Aug 2023 02:15:06 -0700 From: Komal Bajaj To: , , , , , , CC: , , , Komal Bajaj Subject: [PATCH v6 4/6] soc: qcom: Add LLCC support for multi channel DDR Date: Wed, 2 Aug 2023 14:44:26 +0530 Message-ID: <20230802091429.20892-5-quic_kbajaj@quicinc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230802091429.20892-1-quic_kbajaj@quicinc.com> References: <20230802091429.20892-1-quic_kbajaj@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nasanex01b.na.qualcomm.com (10.46.141.250) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: nNr468XHOjoAbRJvf13iYPVMpADLXHWI X-Proofpoint-GUID: nNr468XHOjoAbRJvf13iYPVMpADLXHWI X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-08-02_04,2023-08-01_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 mlxscore=0 malwarescore=0 bulkscore=0 priorityscore=1501 lowpriorityscore=0 impostorscore=0 phishscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2308020082 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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: INBOX X-GMAIL-THRID: 1773110540529730124 X-GMAIL-MSGID: 1773110540529730124 Add LLCC support for multi channel DDR configuration based on a feature register. Signed-off-by: Komal Bajaj --- drivers/soc/qcom/llcc-qcom.c | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) -- 2.41.0 diff --git a/drivers/soc/qcom/llcc-qcom.c b/drivers/soc/qcom/llcc-qcom.c index 808c5aaa7407..f6ed4e4aaf3b 100644 --- a/drivers/soc/qcom/llcc-qcom.c +++ b/drivers/soc/qcom/llcc-qcom.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -999,6 +1000,26 @@ static int qcom_llcc_cfg_program(struct platform_device *pdev, return ret; } +static int qcom_llcc_get_cfg_index(struct platform_device *pdev, u8 *cfg_index, int num_config) +{ + int ret; + + ret = nvmem_cell_read_u8(&pdev->dev, "multi-chan-ddr", cfg_index); + if (ret == -ENOENT || ret == -EOPNOTSUPP) { + if (num_config != DEFAULT_CONFIG) { + ret = -EINVAL; + return ret; + } + *cfg_index = DEFAULT_CONFIG - 1; + return 0; + } + + if (!ret && *cfg_index >= num_config) + ret = -EINVAL; + + return ret; +} + static int qcom_llcc_remove(struct platform_device *pdev) { /* Set the global pointer to a error code to avoid referencing it */ @@ -1035,6 +1056,7 @@ static int qcom_llcc_probe(struct platform_device *pdev) const struct qcom_llcc_config *cfg; const struct llcc_slice_config *llcc_cfg; u32 sz; + u8 cfg_index; u32 version; struct regmap *regmap; @@ -1052,11 +1074,11 @@ static int qcom_llcc_probe(struct platform_device *pdev) } cfgs = of_device_get_match_data(&pdev->dev); - if (cfgs->num_config != DEFAULT_CONFIG) { - ret = -EINVAL; + ret = qcom_llcc_get_cfg_index(pdev, &cfg_index, cfgs->num_config); + if (ret) goto err; - } - cfg = &cfgs->llcc_config[DEFAULT_CONFIG - 1]; + + cfg = &cfgs->llcc_config[cfg_index]; ret = regmap_read(regmap, cfg->reg_offset[LLCC_COMMON_STATUS0], &num_banks); if (ret)