From patchwork Wed Apr 17 20:02:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Dybcio X-Patchwork-Id: 13633803 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E20ECC04FFE for ; Wed, 17 Apr 2024 20:03:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 506BB1137B9; Wed, 17 Apr 2024 20:03:11 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="BPD1NCXX"; dkim-atps=neutral Received: from mail-ed1-f43.google.com (mail-ed1-f43.google.com [209.85.208.43]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3F1051137BA for ; Wed, 17 Apr 2024 20:03:09 +0000 (UTC) Received: by mail-ed1-f43.google.com with SMTP id 4fb4d7f45d1cf-570c9f49a67so111626a12.1 for ; Wed, 17 Apr 2024 13:03:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713384187; x=1713988987; darn=lists.freedesktop.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=SV6J30CfPASoymdIFYzV0/TP7ddiAe5RpBl3EgHS6Xs=; b=BPD1NCXXMC4k2l9zyKCwvWMfMZIzeiPu7Rh+pjp+wHycbv5SvB6SiTLEha9xLmug2B TwyXKTMd51iq66Gs1fpfimncoKMq98utDtxJlEm8zkyY6U7sj3+EWWguuSnJ2/PTt387 NWVn5CYVxFDxe2L9kblZKXC3xbFF22YSPLJza8fhkER5PuGSqK870gidb4rH+Sx/BAGV wyeR3fIiZbhy9r3PYXqVjpp6qDKwpWU3d+8sh41KwhsPKgXhgOq1D/Frot+/sLbPRgQE dZob8TpPlxpBoZ7HyCyzhio/DJ4w+kO9qOkEAXbe7QO2rDLf1zdukfYQ6XoOaWtE1eWs MHnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713384187; x=1713988987; 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=SV6J30CfPASoymdIFYzV0/TP7ddiAe5RpBl3EgHS6Xs=; b=Uke1N1xAj4Yd2UoR9D2z0pyAmQq87z90UlT2RQPrYnPEWpondsZ6FxtwLlTng4m1/B osW4vp8aNIztwjqyWFjuykSP/yIGEA+JZNUp1mRyuSp+r0jjQaU2KXo5v7BwveFHz+9g 5xM91hBYWKAbLl7n2AtF1vbZKjtmCcwCPryEfIgsKcyNdeM8QDCeVhalsywUtLSykCWr mtEp6Uz/pzyu2kc9jxPCAgSjDRlknc03fULiybOJZw8VtVqvwipCZN1sHX1UDWHDYIhe j8JfD9oVGdacHVnauqCZCdJkWFt0ZB8CxwRkiCinoWvQz+jL8wzeob/S1QkjVauvy0qZ 1ZmA== X-Forwarded-Encrypted: i=1; AJvYcCWDlY9Io7Lcvc05D7piV5PTtyRz11DzN8IiUAqxl28KWfnAHSBI0AX00+hlBeoiVh+IKOj8650PiB5cr7lDW1j+rQFfzOgOy3LbGfC5DWnm X-Gm-Message-State: AOJu0Yx5NVeCYAgfE6wL6Bs2DX9n68E8Odzne/I00xFjtdTzgp/H/yMf 9PnoPnqW14uZhCqxv8W+HrymmPvpcuUisNfA170C/XXcR0vHqd6PO6Ogb0/nXbQ= X-Google-Smtp-Source: AGHT+IEE4rTTfC2fS5MHSJv6KjEvvVOGWI1pShDXOcYNXGfN81YBcLHlG9LDzJPJpVmh0BPlqwuEww== X-Received: by 2002:a17:907:10c3:b0:a55:5c04:89a4 with SMTP id rv3-20020a17090710c300b00a555c0489a4mr334635ejb.21.1713384187494; Wed, 17 Apr 2024 13:03:07 -0700 (PDT) Received: from [192.168.45.55] (078088045141.garwolin.vectranet.pl. [78.88.45.141]) by smtp.gmail.com with ESMTPSA id xa4-20020a170906fd8400b00a5252e69c7dsm5905590ejb.160.2024.04.17.13.03.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 13:03:07 -0700 (PDT) From: Konrad Dybcio Date: Wed, 17 Apr 2024 22:02:54 +0200 Subject: [PATCH v2 2/7] soc: qcom: smem: Add a feature code getter MIME-Version: 1.0 Message-Id: <20240404-topic-smem_speedbin-v2-2-c84f820b7e5b@linaro.org> References: <20240404-topic-smem_speedbin-v2-0-c84f820b7e5b@linaro.org> In-Reply-To: <20240404-topic-smem_speedbin-v2-0-c84f820b7e5b@linaro.org> To: Bjorn Andersson , Rob Clark , Abhinav Kumar , Dmitry Baryshkov , Sean Paul , Marijn Suijten , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, devicetree@vger.kernel.org, Neil Armstrong , Konrad Dybcio X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1713384181; l=3440; i=konrad.dybcio@linaro.org; s=20230215; h=from:subject:message-id; bh=9J7bTJW6Z2MeNhnVPByhcl4m6t24a8dv3hQEs4RW/1Q=; b=4u/Mox1Q9N+V2KjoOOEjCZhuqpOUYbZD0oDyrWik5Dmyg03vy2l1Q8Y0YqOLyj0NsQdNoc2OR RXZWLV7bdp3CPY7/5IZlWwlKkSrH2MKosezQc/9nA71wDribMonE9+u X-Developer-Key: i=konrad.dybcio@linaro.org; a=ed25519; pk=iclgkYvtl2w05SSXO5EjjSYlhFKsJ+5OSZBjOkQuEms= X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Recent (SM8550+ ish) Qualcomm SoCs have a new mechanism for precisely identifying the specific SKU and the precise speed bin (in the general meaning of this word, anyway): a pair of values called Product Code and Feature Code. Based on this information, we can deduce the available frequencies for things such as Adreno. In the case of Adreno specifically, Pcode is useless for non-prototype SoCs. Introduce a getter for the feature code and export it. Signed-off-by: Konrad Dybcio Reviewed-by: Dmitry Baryshkov --- drivers/soc/qcom/smem.c | 33 +++++++++++++++++++++++++++++++++ include/linux/soc/qcom/smem.h | 1 + include/linux/soc/qcom/socinfo.h | 26 ++++++++++++++++++++++++++ 3 files changed, 60 insertions(+) diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c index 7191fa0c087f..29e708789eec 100644 --- a/drivers/soc/qcom/smem.c +++ b/drivers/soc/qcom/smem.c @@ -795,6 +795,39 @@ int qcom_smem_get_soc_id(u32 *id) } EXPORT_SYMBOL_GPL(qcom_smem_get_soc_id); +/** + * qcom_smem_get_feature_code() - return the feature code + * @code: On success, return the feature code here. + * + * Look up the feature code identifier from SMEM and return it. + * + * Return: 0 on success, negative errno on failure. + */ +int qcom_smem_get_feature_code(u32 *code) +{ + struct socinfo *info; + u32 raw_code; + + info = qcom_smem_get(QCOM_SMEM_HOST_ANY, SMEM_HW_SW_BUILD_ID, NULL); + if (IS_ERR(info)) + return PTR_ERR(info); + + /* This only makes sense for socinfo >= 16 */ + if (__le32_to_cpu(info->fmt) < SOCINFO_VERSION(0, 16)) + return -EOPNOTSUPP; + + raw_code = __le32_to_cpu(info->feature_code); + + /* Ensure the value makes sense */ + if (raw_code >= SOCINFO_FC_INT_MAX) + raw_code = SOCINFO_FC_UNKNOWN; + + *code = raw_code; + + return 0; +} +EXPORT_SYMBOL_GPL(qcom_smem_get_feature_code); + static int qcom_smem_get_sbl_version(struct qcom_smem *smem) { struct smem_header *header; diff --git a/include/linux/soc/qcom/smem.h b/include/linux/soc/qcom/smem.h index a36a3b9d4929..0943bf419e11 100644 --- a/include/linux/soc/qcom/smem.h +++ b/include/linux/soc/qcom/smem.h @@ -13,5 +13,6 @@ int qcom_smem_get_free_space(unsigned host); phys_addr_t qcom_smem_virt_to_phys(void *p); int qcom_smem_get_soc_id(u32 *id); +int qcom_smem_get_feature_code(u32 *code); #endif diff --git a/include/linux/soc/qcom/socinfo.h b/include/linux/soc/qcom/socinfo.h index 10e0a4c287f4..52439f48428f 100644 --- a/include/linux/soc/qcom/socinfo.h +++ b/include/linux/soc/qcom/socinfo.h @@ -3,6 +3,8 @@ #ifndef __QCOM_SOCINFO_H__ #define __QCOM_SOCINFO_H__ +#include + /* * SMEM item id, used to acquire handles to respective * SMEM region. @@ -82,4 +84,28 @@ struct socinfo { __le32 boot_core; }; +/* Internal feature codes */ +enum qcom_socinfo_feature_code { + /* External feature codes */ + SOCINFO_FC_UNKNOWN = 0x0, + SOCINFO_FC_AA, + SOCINFO_FC_AB, + SOCINFO_FC_AC, + SOCINFO_FC_AD, + SOCINFO_FC_AE, + SOCINFO_FC_AF, + SOCINFO_FC_AG, + SOCINFO_FC_AH, +}; + +/* Internal feature codes */ +/* Valid values: 0 <= n <= 0xf */ +#define SOCINFO_FC_Yn(n) (0xf1 + n) +#define SOCINFO_FC_INT_MAX SOCINFO_FC_Yn(0x10) + +/* Product codes */ +#define SOCINFO_PC_UNKNOWN 0 +#define SOCINFO_PCn(n) (n + 1) +#define SOCINFO_PC_RESERVE (BIT(31) - 1) + #endif