From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4E1B71E505 for ; Sat, 25 Jan 2025 12:51:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737809514; cv=none; b=nEjk7WQR0NLmuVJQv21/Bgnn292p0ZDkTbt5VxOC8NiDMBJW9nsls/xu6MFcR2C2B/d4VUdjAjeruAEn88SZmJyfV8FBFc+Naswce4ydDhe2IhcVZXE1Vzps0MHChEkwAfCUeiuNOzCDm9QPAyPzNw1RwiuzUA7kr41UJjXHqn8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737809514; c=relaxed/simple; bh=86QVJcp7+Wpb1h56kTcVv3nN2lg8fSxxUT5DE2OEIwY=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Ccj8N5clmJVtOThJN03yW5pY99Y/Fq1Nx3ry3kwzR/FaOrU94wTSXmxMSvYjw0JA7tK3TUanJraIlSWzhAOVQhG9bu77B64inYVIfu+aX1o1B1VBs92a2BuoUv3/duE/6vbGSVWfARSu9yglVhPIfH++oE4EpfBATyBHW6J0GAY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=FiqXKMm0; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="FiqXKMm0" Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 50PCpqHv011738; Sat, 25 Jan 2025 12:51:52 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= CWziA7aUdOr4gS8lvvWsqKbJ5Nzxb5TboxzkZ56gBtY=; b=FiqXKMm0wQShkz4q nOQOWrda0vMsz9UXlynj2imlecUhsyfA1AjKKzT3TfpIxHFKnosRakQogRolApnR Xc7AFDFACBEcQiL3Qzn2EGKmKChuLRcbU2Me8JrpxfKD07cAJhGjzhfWDbYppVxz g4hZUpmT0Q2DxCkKsEJMroa2HYdPtZYYD95fx+cNKE90FRjrcc/69UFwxQkxqPtm ysIalOZnBlYjLA9bIGTCfZ691n4lghATUUNTfkU/XxIx4O4V7MEojXvGZ+WPGQm8 DEfYY8eF+JLXpCIp7FbR/75htxmWemu0F1QgbA+b0iaNqpBRP70Oc1i0d+XO2z9w A8bL+g== Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 44cs0d0grm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Sat, 25 Jan 2025 12:51:52 +0000 (GMT) Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-7b6f85325c3so45621785a.1 for ; Sat, 25 Jan 2025 04:51:52 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737809511; x=1738414311; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=CWziA7aUdOr4gS8lvvWsqKbJ5Nzxb5TboxzkZ56gBtY=; b=aR35OZnWBtxdN63E5CDuDJ7pNiCz/dHIaWlM2ZMo69ptQTklOHzrRluZiKJgN/rBgp kTTZpNgAtUHe+HE4EFUzDYHlBC2/PCXP5k35YSCWPa4xMnG2Z/CnyDB+Wr0vsi0PlCa0 1eHIdSCTDxBb9gUEKFV6fVJE8UB1w0RDCoaEva3BzJ+VPclWu5YZivUpHlxiKHajPwua q5ES54Q/7fDOeFoXkG70imVhb/+QYcz0QzTeemKM1SqysHLRGTdixM5IJg26ewmdXAyR VllMKDnxXQ9KxUwFtzi1aGOTU54nWjU040vlZFJsGfdpPuJsjhgYE9J18WXC9iWhy75z O1rQ== X-Forwarded-Encrypted: i=1; AJvYcCVhEPGV1vwAgFDLVteBDlRSwv2u3886ZnKkqwNJUZcY6bEDIBVAq4/dvt3WTMn/F6CJ/iDCqH78GV+EAJ0=@vger.kernel.org X-Gm-Message-State: AOJu0YygGnL/HeP3yVCuvreLAv5DpE0l+N7Np+3BTWD4N9bocPGbFbWw ZiGKVt4FZLSkiE64aKyfca3CbcPG5tIUQWrMKqTVxeFVOfxuuD6GQEW17PNKLEV9EWWFGcll9r6 5kpS7eOJutBxdDqVHyadhfX6FoOFeHitNh6912I41ZAfw0tSmpIxbttqAdP2AtoA= X-Gm-Gg: ASbGncsYR2bVfZNjGEf+DDjG1DWTnp4BC9vAIyfM/QTNZGBMyy05d5MX3BI4XD1gU/k B5p5weEwpMtLdAkILnq6nuxDq0TAqaEYqeYs5M9ncdr5yJkyQs73orPa/nbYJILf/yg/44y/2Ty OiI+Eot8wqfRHAG4+RD/6Y902wFDlIQZaxZF9WDVjswG/iw9r5tReUWdGeM3sLpI3d8pwjlFyDK RdsrvCyIjpoUoj8HRsF49f3iXc61Do7VwOxLeOc7JlqxtF2Uf4+f4fGULNj5i8gJJB6TTd7YlsQ BzXCVAeraxrgf6NK1mfEqsWxy0/lPxiItXxRHmgD4cewx72ZuxqSc2RHD/g= X-Received: by 2002:a05:620a:450e:b0:7b6:dc5c:de5 with SMTP id af79cd13be357-7be631e6b5emr2052214685a.1.1737809511567; Sat, 25 Jan 2025 04:51:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IF+UQrv1kM0ZKAZiqODKXjGLwGCixqQRdnXMHLQHxrdyBaXBM/t1cXrqvIOKkD+dJIF7eR9gA== X-Received: by 2002:a05:620a:450e:b0:7b6:dc5c:de5 with SMTP id af79cd13be357-7be631e6b5emr2052211885a.1.1737809511100; Sat, 25 Jan 2025 04:51:51 -0800 (PST) Received: from [192.168.65.90] (078088045245.garwolin.vectranet.pl. [78.88.45.245]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5dc18640df4sm2507590a12.48.2025.01.25.04.51.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 25 Jan 2025 04:51:49 -0800 (PST) Message-ID: <653c86f8-30d3-4ffe-aa2d-ffb37b7b5bb2@oss.qualcomm.com> Date: Sat, 25 Jan 2025 13:51:46 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4 2/4] PCI: of: Add API to retrieve equalization presets from device tree To: Konrad Dybcio , Krishna Chaitanya Chundru , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Bjorn Helgaas , Jingoo Han , Manivannan Sadhasivam , Lorenzo Pieralisi , =?UTF-8?Q?Krzysztof_Wilczy=C5=84ski?= Cc: linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, quic_mrana@quicinc.com, quic_vbadigan@quicinc.com, Bjorn Andersson , Konrad Dybcio References: <20250124-preset_v2-v4-0-0b512cad08e1@oss.qualcomm.com> <20250124-preset_v2-v4-2-0b512cad08e1@oss.qualcomm.com> <79281aca-c275-4055-8d2c-d2407b0f9811@oss.qualcomm.com> Content-Language: en-US From: Konrad Dybcio In-Reply-To: <79281aca-c275-4055-8d2c-d2407b0f9811@oss.qualcomm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Proofpoint-ORIG-GUID: KoaqIMK5JKCcjLeiMZN3R68LubPk2UYT X-Proofpoint-GUID: KoaqIMK5JKCcjLeiMZN3R68LubPk2UYT X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-01-25_05,2025-01-23_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 bulkscore=0 phishscore=0 malwarescore=0 adultscore=0 suspectscore=0 priorityscore=1501 spamscore=0 mlxlogscore=999 lowpriorityscore=0 clxscore=1015 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2411120000 definitions=main-2501250093 On 25.01.2025 1:47 PM, Konrad Dybcio wrote: > On 24.01.2025 12:22 PM, Krishna Chaitanya Chundru wrote: >> PCIe equalization presets are predefined settings used to optimize >> signal integrity by compensating for signal loss and distortion in >> high-speed data transmission. >> >> As per PCIe spec 6.0.1 revision section 8.3.3.3 & 4.2.4 for data rates >> of 8.0 GT/s, 16.0 GT/s, 32.0 GT/s, and 64.0 GT/s, there is a way to >> configure lane equalization presets for each lane to enhance the PCIe >> link reliability. Each preset value represents a different combination >> of pre-shoot and de-emphasis values. For each data rate, different >> registers are defined: for 8.0 GT/s, registers are defined in section >> 7.7.3.4; for 16.0 GT/s, in section 7.7.5.9, etc. The 8.0 GT/s rate has >> an extra receiver preset hint, requiring 16 bits per lane, while the >> remaining data rates use 8 bits per lane. >> >> Based on the number of lanes and the supported data rate, this function >> reads the device tree property and stores in the presets structure. >> >> Signed-off-by: Krishna Chaitanya Chundru >> --- >> drivers/pci/of.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ >> drivers/pci/pci.h | 24 +++++++++++++++++++++++- >> 2 files changed, 70 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/pci/of.c b/drivers/pci/of.c >> index dacea3fc5128..7aa17c0042c5 100644 >> --- a/drivers/pci/of.c >> +++ b/drivers/pci/of.c >> @@ -826,3 +826,50 @@ u32 of_pci_get_slot_power_limit(struct device_node *node, >> return slot_power_limit_mw; >> } >> EXPORT_SYMBOL_GPL(of_pci_get_slot_power_limit); >> + >> +/** >> + * of_pci_get_equalization_presets - Parses the "eq-presets-ngts" property. >> + * >> + * @dev: Device containing the properties. >> + * @presets: Pointer to store the parsed data. >> + * @num_lanes: Maximum number of lanes supported. >> + * >> + * If the property is present read and store the data in the preset structure >> + * assign default value 0xff to indicate property is not present. >> + * >> + * If the property is not found or is invalid, returns 0. >> + */ >> +int of_pci_get_equalization_presets(struct device *dev, >> + struct pci_eq_presets *presets, >> + int num_lanes) >> +{ >> + char name[20]; >> + int ret; >> + >> + presets->eq_presets_8gts[0] = 0xff; Also please #define 0xff as a reserved value Konrad >> + if (of_property_present(dev->of_node, "eq-presets-8gts")) { >> + ret = of_property_read_u16_array(dev->of_node, "eq-presets-8gts", >> + presets->eq_presets_8gts, num_lanes); >> + if (ret) { >> + dev_err(dev, "Error reading eq-presets-8gts %d\n", ret); >> + return ret; >> + } >> + } >> + >> + for (int i = 0; i < EQ_PRESET_TYPE_MAX; i++) { >> + presets->eq_presets_Ngts[i][0] = 0xff; >> + snprintf(name, sizeof(name), "eq-presets-%dgts", 8 << (i + 1)); >> + if (of_property_present(dev->of_node, name)) { > > of_property_count_u8_elems returns -EINVAL if the property does not exist > > you can then drop a level of indentation: > > ret = of_property_read_u8_array...; > if (ret == -EINVAL) { > continue; > } else { > ... > } > > > similarly above for 8gts > > Konrad