Received: by 2002:ab2:7a55:0:b0:1f4:4a7d:290d with SMTP id u21csp555134lqp; Fri, 5 Apr 2024 01:42:08 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVIozPTCa1T0yJi3vdFvIqWCpx9GDdRDL3chUgXy1X6HS9UFoTBeXbE0y1Ywg1cmNGnVIHexMT17BrN5+9UwGWEQYUbrhwzVBYQ8RwMGw== X-Google-Smtp-Source: AGHT+IGQtqwAvBHlX0WguSs0YmcklU+yL4n7D3D5qJpoYbtbl0olxsXWPdBmsU9o5knAdUI0GS6O X-Received: by 2002:a05:620a:8016:b0:78d:3b20:663e with SMTP id ee22-20020a05620a801600b0078d3b20663emr836786qkb.66.1712306528624; Fri, 05 Apr 2024 01:42:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712306528; cv=pass; d=google.com; s=arc-20160816; b=a6K8ltZT0KVUBDZaRnhTj4n7KlLxVbmCZIDQC6k4C02nZiDshKLqsATCNGHiPV7bWk iBtpH2qI7JqLGe8/qSNQ8olVwdSEWApaoXizlDVKzPNniwWJugODSVb2uOLA8T0pOdtP aM6AIqjAiEFUyR6SZeQtN4s8s5WK7D/u0YMWX2+CLM/uVbVGc6SEbwQHYDskc8n0Mdty JYnoVI4aeH+fI5TFRzVWI1BHexzt0/sccu6SwCqZYiAEaHCSPGMZZd9gSaEutMZoCvih mL83FHItIJD632C2ShPBLRkN6HuyQDQm2TjkSBynq3UCSHUKHOf+DnwESuOxDL5U+iwn ePmA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=hrz6dTaTK0KlWdsP16Esc0J5gm77xoC0tsefEzseqJI=; fh=V3bt1mYZOAAeEpbh8of+RDf2DLcK2sLHW9ew3FyJE5M=; b=oV/JiBg4tKny/IQrfk7Lpaek6TsJzzfKyyluEehdPv4xoygcQ/vNuX5iKEf29KaDYZ xgtFELWKbOuCaGllBcpuPmFPzSIy0lhfSqk0OGgT7Hn03NCgA4VhNdlezEAq2c3rtU2u Fpx1KByxGAl94N4baiuZgY37FpOLMYJi8DD1raNOy9mIWJpg3yH8oHABCMkInkq3rgOX zZb/20+GMr9g5JjqAz+e5Iqy+kb2KPeaAmjixbnr1ry7sA6ZskqNjD4wWsMQlaDZWyih USe3XfIS7QCkdrtdWgbM0MmTQqN1PcgGLuPUMnrlU+cSvpvPWczxrIDKyeDFksP993eM wOMA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZhC0TEd4; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-132664-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-132664-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id k8-20020a05620a0b8800b0078d3b5a8387si1262277qkh.417.2024.04.05.01.42.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 01:42:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-132664-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZhC0TEd4; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-132664-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-132664-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 4F85E1C211D2 for ; Fri, 5 Apr 2024 08:42:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B6B9315F3EF; Fri, 5 Apr 2024 08:41:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="ZhC0TEd4" Received: from mail-lj1-f177.google.com (mail-lj1-f177.google.com [209.85.208.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DE70E15FA76 for ; Fri, 5 Apr 2024 08:41:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712306499; cv=none; b=k4K0Af5t4mjgHvWgGLwNLW4zPiq/nVEaFXRFLJ7fWxdF0/qKrI9u+nbEltjRntg3lxdldpHKR9Y1eqo4H2LSo2rFurpILzs1xm0y7BLsHVFsygAdHjlsSJ3/v3Y0CVTWrgXIEifxmGqcOyf+aX2ORfZJrGBjPHMsqClZGz8jILY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712306499; c=relaxed/simple; bh=LuuIzVsI75M9BD4RB9Xpg8kuNSHIGgEeoiwcYByrbOc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=c5LgTRY6AboPUmSMBSrYkXxv84kbo/rB5oy2T2FLOZryXjoXuV3OM25CcCKIMJCTP1EQQhaaMJU8eW5OV+2M5uPJeZp36WNqbNeLm65Zc4inRAi1A7CR1u7N/IXGS6K0WXzRXgXF0qwGbE/Iw+DcS+uhCAzjnkwVffnuqe/dvWg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=ZhC0TEd4; arc=none smtp.client-ip=209.85.208.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-lj1-f177.google.com with SMTP id 38308e7fff4ca-2d4360ab3daso21356401fa.3 for ; Fri, 05 Apr 2024 01:41:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712306496; x=1712911296; darn=vger.kernel.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=hrz6dTaTK0KlWdsP16Esc0J5gm77xoC0tsefEzseqJI=; b=ZhC0TEd4+e81u48ovoHh4FgJ4xUAgfsR+mRFhgv6xQtLynN65KWbfiH/HjD5P4nva5 vMyo/ZAX9cfliBEQQmSy6DRLqJefUuLrIZySV8zyQGXopJ6R9FlRmBxqUoyslQEc6mg8 38Jyv2lJRDG/T/mIgy7Blw0+LYXcNlrRe3KfyGiUUmfHKr79288B7jiP75BOZcOqdLO2 w6xgrG8OiMj+EYrTFwAhLv6IEikQip4K7AdZeZWUBzSmtpq8FU2ag1NLotxvIZADXwl0 5LhhGDg8Kg3y9P0l8buLlqO1kqQjMCGqL1X3EKpF34QWin+yqTo6WbkayGPqYmlsYU8B VCVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712306496; x=1712911296; 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=hrz6dTaTK0KlWdsP16Esc0J5gm77xoC0tsefEzseqJI=; b=m5NPqQ+VdLMPCm4PayU+/eFBfV+i5pVP78+GUCZiEK6WXdA/Z38TWVVGAm+LucVNxE 5ojKNUP+1uGQ7ZSo/I2TkkPluFy+HVtSafG+USlxTPEc5+a7KiS34qGwWIaZGms2ocBN Pxaq7MhdXkxal7pkfssex70srGbPaoqwwzyZPsr73dxrPSApYG0jYQuDF8aTYFllNk4L SEWb8/lZYbZfij5Ew7gl2wapbuEBNhvfKFvICg33QPSpH/b++5wYeaDcf+UZwWXUFAr6 O8x59XSLF3f2WK+GqE3OXeeg4/G6nK34sLSpnHsB74ulqI9eGxbhFajY7aGKal8IQ64k 4BXw== X-Forwarded-Encrypted: i=1; AJvYcCVhRqbTRtsz66ACQ5rS5BOPf2Nz9tchnn1JIEn3qKZBK+KmUt5eHQ5ZJWE85wlt7Talo6nSjhC20+BElqO5VBB2Lf5vyAhyXPpzTcPW X-Gm-Message-State: AOJu0YzrjCAMScdWeAQcdOhGZiDABakzMV7B0uxuYL+ufBzhW3/PKfqt YMzyhrtXG1LJ9oMh1iba+//jt/RfJbI03pUjD0fVpZK+cewunkDf6kUR3bGvW38= X-Received: by 2002:a2e:9658:0:b0:2d8:68ad:1e87 with SMTP id z24-20020a2e9658000000b002d868ad1e87mr671436ljh.18.1712306496187; Fri, 05 Apr 2024 01:41:36 -0700 (PDT) Received: from [127.0.1.1] (netpanel-87-246-222-101.pol.akademiki.lublin.pl. [87.246.222.101]) by smtp.gmail.com with ESMTPSA id y3-20020a05651c020300b002d429304a20sm116880ljn.8.2024.04.05.01.41.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 01:41:35 -0700 (PDT) From: Konrad Dybcio Date: Fri, 05 Apr 2024 10:41:30 +0200 Subject: [PATCH 2/6] soc: qcom: smem: Add pcode/fcode getters Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240405-topic-smem_speedbin-v1-2-ce2b864251b1@linaro.org> References: <20240405-topic-smem_speedbin-v1-0-ce2b864251b1@linaro.org> In-Reply-To: <20240405-topic-smem_speedbin-v1-0-ce2b864251b1@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.13-dev-0438c Introduce getters for SoC product and feature codes and export them. Signed-off-by: Konrad Dybcio --- drivers/soc/qcom/smem.c | 66 +++++++++++++++++++++++++++++++++++++++++++ include/linux/soc/qcom/smem.h | 2 ++ 2 files changed, 68 insertions(+) diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c index 7191fa0c087f..e89b4d26877a 100644 --- a/drivers/soc/qcom/smem.c +++ b/drivers/soc/qcom/smem.c @@ -795,6 +795,72 @@ 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 + * @id: On success, we 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 -EINVAL; + + raw_code = __le32_to_cpu(info->feature_code); + + /* Ensure the value makes sense */ + if (raw_code >= SOCINFO_FC_INT_RESERVE) + raw_code = SOCINFO_FC_UNKNOWN; + + *code = raw_code; + + return 0; +} +EXPORT_SYMBOL_GPL(qcom_smem_get_feature_code); + +/** + * qcom_smem_get_product_code() - return the product code + * @id: On success, we return the product code here. + * + * Look up feature code identifier from SMEM and return it. + * + * Return: 0 on success, negative errno on failure. + */ +int qcom_smem_get_product_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 -EINVAL; + + raw_code = __le32_to_cpu(info->pcode); + + /* Ensure the value makes sense */ + if (raw_code >= SOCINFO_FC_INT_RESERVE) + raw_code = SOCINFO_FC_UNKNOWN; + + *code = raw_code; + + return 0; +} +EXPORT_SYMBOL_GPL(qcom_smem_get_product_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..aef8c9fc6c08 100644 --- a/include/linux/soc/qcom/smem.h +++ b/include/linux/soc/qcom/smem.h @@ -13,5 +13,7 @@ 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); +int qcom_smem_get_product_code(u32 *code); #endif -- 2.40.1