Message ID | 20230525210214.78235-3-robimarko@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp48586vqr; Thu, 25 May 2023 14:15:11 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5he0QazKwLBEMwkecXYDw2rNEbDTa9bhBhhJxMkVIMbu7EVnC1sYdYG1tFrDNGv35f360T X-Received: by 2002:a05:6a21:3293:b0:10b:9dc1:c5e5 with SMTP id yt19-20020a056a21329300b0010b9dc1c5e5mr18715343pzb.34.1685049311550; Thu, 25 May 2023 14:15:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685049311; cv=none; d=google.com; s=arc-20160816; b=JVe0FwqOFvAxzyFYkeRFVLjPncDtK5iDcOxkdMmAudgIHxhiS5nelvoZIKDSPuIPfo 0oeuiL2+bCdTok5VaSHmrfMcIAx9bezwp5SuwFLYU4gTw9MCCD7rs35IR8wU4Rciu1vu SVnj8G3egmVkD8eaiEEukB7k3CTRN5V8O4dAHhZOYztt+5GxncCzF7fbvfUoLF4hBKrA xGnLjmre7+rAOCPMt0d4jvXHlbH5ifBlN7TzLwU0nuEMwpx20j1bwV2e/PGlNFtqSRkr Fhggq3YvQQu2KqYbSN3X3BYw23fcvNV744kpxLob4UDd7oEWxMdqq+7M3Cnlrv6Hy7XO Z6fw== 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=zQtz6v7Hj5j1tfmowjTsEjjYvDTSsmx54tvIW02KIzE=; b=juuTqdWQzRmYlK07/762XcL+6uFPrK17cvHRIueP4EO54qsoZOdk1NW2LGgSfE08jk 9hg48tuyT4PShsicqBh92yQydVpK1DxxNMsA2BiOYr69bDh9aTs+5Wo6Spvl/g7SgOrH Nh+HIL8j5aVCPa+O3RGaRKWtJOwZzk5AK7a9spjD3mV4+bmEiQgSitRaOOmpY/YAPR0M iaacUdQrMRffCVu125BlDPp0lK6Xck21tt7+9VZzZa7DGkHtnskkKH07Z77xlmzwiD0H 6s5+V1sgcsZnX6afyzV1+bmHdaPQwaQ3El39s4hccPVTqL+7kty3lt2Z8sRxx52oNX3E Sj5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=BgR3QBva; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l185-20020a6391c2000000b00528d90d40e2si1984672pge.891.2023.05.25.14.14.58; Thu, 25 May 2023 14:15:11 -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=@gmail.com header.s=20221208 header.b=BgR3QBva; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241601AbjEYVC4 (ORCPT <rfc822;ahmedalshaiji.dev@gmail.com> + 99 others); Thu, 25 May 2023 17:02:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234025AbjEYVCu (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 25 May 2023 17:02:50 -0400 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4FCF199; Thu, 25 May 2023 14:02:21 -0700 (PDT) Received: by mail-ed1-x529.google.com with SMTP id 4fb4d7f45d1cf-510e419d701so5687375a12.1; Thu, 25 May 2023 14:02:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685048539; x=1687640539; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zQtz6v7Hj5j1tfmowjTsEjjYvDTSsmx54tvIW02KIzE=; b=BgR3QBvaOti23Wx+ddMulO5QO8k+UajcZBC+FwQS8tgAsD9oUdoxRDNQQAO2/N5O/E m40TonwXHFwM0FmymmxGGxAQAKadR69sfcEmx5N5HhCIXPN9sizvgHc29El4F8fJnJvy DNM+k/WW93t6ya/5ha1gLvxaK5o/YxFo+Xn6Hn/Ze2qQJyr2M8clRAqDt3DxZJbz0g6k 4VVuruCe8TK84SvDrOQ0nRHzBkco4CUeszGDYD2sfzXIwyXmPycEzWVSsIgDGRosYSvi sxVZFPHXKaYos7wapvAVp9xLgwiGCf5dMblMznYTR9q1cSkocYb/HnpKBIGi1ECyzHc8 B30w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685048539; x=1687640539; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zQtz6v7Hj5j1tfmowjTsEjjYvDTSsmx54tvIW02KIzE=; b=kuWDbUcwoe7t1Cq0w2TtESDV3DJY80c8hFNg+ltg0ps2xQSdrd1KLz1PRZ29FN8XUV D+slVfzpEmV/sVtMx6a8k+ilmWACBDHMtEOqJcDDQAAZwky6LE2XYN4PHRwmVdkNIVCT RrhMRgNCZT1O3L9QrzV6zpwC+0iFbk2NI2D1mN69JAk+SO5zHoHlXxvX9Fyhzay6x2ST FHa1ltLhyXtGh7ODz0M1VvZUWGy3S99JDrkjE2e96NIQn/XVZ3LuY8D1NcZy2WlHvroz /kNS9DEfo7dUSKoAdzJyhgZwROPwAthbDXw1DPyEh02848NSeCyKER8aRTCEBGWbrwYO ir3A== X-Gm-Message-State: AC+VfDxfuCWxh5QSiBmPcoW6UOFdgkYwNqC6Xs2BMa9hdTpYoyCsC6Ol jI5wQxNLL181iBgg2D9ZXWE= X-Received: by 2002:aa7:c688:0:b0:510:dd3e:86cd with SMTP id n8-20020aa7c688000000b00510dd3e86cdmr5994877edq.20.1685048539533; Thu, 25 May 2023 14:02:19 -0700 (PDT) Received: from fedora.. ([213.149.38.146]) by smtp.googlemail.com with ESMTPSA id c25-20020aa7df19000000b0050e04125a46sm913010edy.10.2023.05.25.14.02.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 May 2023 14:02:19 -0700 (PDT) From: Robert Marko <robimarko@gmail.com> To: agross@kernel.org, andersson@kernel.org, konrad.dybcio@linaro.org, ilia.lin@kernel.org, rafael@kernel.org, viresh.kumar@linaro.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-pm@vger.kernel.org Cc: ansuelsmth@gmail.com, Robert Marko <robimarko@gmail.com> Subject: [PATCH v4 3/5] soc: qcom: smem: introduce qcom_smem_get_soc_id() Date: Thu, 25 May 2023 23:02:12 +0200 Message-Id: <20230525210214.78235-3-robimarko@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230525210214.78235-1-robimarko@gmail.com> References: <20230525210214.78235-1-robimarko@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766902266955919056?= X-GMAIL-MSGID: =?utf-8?q?1766902266955919056?= |
Series |
[v4,1/5] soc: qcom: socinfo: move SMEM item struct and defines to a header
|
|
Commit Message
Robert Marko
May 25, 2023, 9:02 p.m. UTC
Introduce a helper to return the SoC SMEM ID, which is used to identify the
exact SoC model as there may be differences in the same SoC family.
Currently, cpufreq-nvmem does this completely in the driver and there has
been more interest expresed for other drivers to use this information so
lets expose a common helper to prevent redoing it in individual drivers
since this field is present on every SMEM table version.
Signed-off-by: Robert Marko <robimarko@gmail.com>
---
Changes in v4:
* Change helper name to qcom_smem_get_soc_id()
* Remove len and just pass NULL, that is sufficient here
Changes in v3:
* Change export to EXPORT_SYMBOL_GPL
* Use an argument for returning SoC ID
* Update kerneldoc
---
drivers/soc/qcom/smem.c | 23 +++++++++++++++++++++++
include/linux/soc/qcom/smem.h | 2 ++
2 files changed, 25 insertions(+)
Comments
On 25.05.2023 23:02, Robert Marko wrote: > Introduce a helper to return the SoC SMEM ID, which is used to identify the > exact SoC model as there may be differences in the same SoC family. > > Currently, cpufreq-nvmem does this completely in the driver and there has > been more interest expresed for other drivers to use this information so > lets expose a common helper to prevent redoing it in individual drivers > since this field is present on every SMEM table version. > > Signed-off-by: Robert Marko <robimarko@gmail.com> > --- > Changes in v4: > * Change helper name to qcom_smem_get_soc_id() > * Remove len and just pass NULL, that is sufficient here > > Changes in v3: > * Change export to EXPORT_SYMBOL_GPL > * Use an argument for returning SoC ID > * Update kerneldoc > --- > drivers/soc/qcom/smem.c | 23 +++++++++++++++++++++++ > include/linux/soc/qcom/smem.h | 2 ++ > 2 files changed, 25 insertions(+) > > diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c > index bc98520c4969..78cf79ea4924 100644 > --- a/drivers/soc/qcom/smem.c > +++ b/drivers/soc/qcom/smem.c > @@ -14,6 +14,7 @@ > #include <linux/sizes.h> > #include <linux/slab.h> > #include <linux/soc/qcom/smem.h> > +#include <linux/soc/qcom/socinfo.h> > > /* > * The Qualcomm shared memory system is a allocate only heap structure that > @@ -772,6 +773,28 @@ phys_addr_t qcom_smem_virt_to_phys(void *p) > } > EXPORT_SYMBOL_GPL(qcom_smem_virt_to_phys); > > +/** > + * qcom_smem_get_soc_id() - return the SoC ID > + * @id: On success, we return the SoC ID here. > + * > + * Look up SoC ID from HW/SW build ID and return it. > + * > + * Return: 0 on success, negative errno on failure. > + */ > +int qcom_smem_get_soc_id(u32 *id) __le32 *id LGTM otherwise! Konrad > +{ > + struct socinfo *info; > + > + info = qcom_smem_get(QCOM_SMEM_HOST_ANY, SMEM_HW_SW_BUILD_ID, NULL); > + if (IS_ERR(info)) > + return PTR_ERR(info); > + > + *id = info->id; > + > + return 0; > +} > +EXPORT_SYMBOL_GPL(qcom_smem_get_soc_id); > + > 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 86e1b358688a..223db6a9c733 100644 > --- a/include/linux/soc/qcom/smem.h > +++ b/include/linux/soc/qcom/smem.h > @@ -11,4 +11,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); > + > #endif
On Fri, May 26, 2023 at 01:18:17AM +0200, Konrad Dybcio wrote: > > > On 25.05.2023 23:02, Robert Marko wrote: > > Introduce a helper to return the SoC SMEM ID, which is used to identify the > > exact SoC model as there may be differences in the same SoC family. > > > > Currently, cpufreq-nvmem does this completely in the driver and there has > > been more interest expresed for other drivers to use this information so > > lets expose a common helper to prevent redoing it in individual drivers > > since this field is present on every SMEM table version. > > > > Signed-off-by: Robert Marko <robimarko@gmail.com> > > --- > > Changes in v4: > > * Change helper name to qcom_smem_get_soc_id() > > * Remove len and just pass NULL, that is sufficient here > > > > Changes in v3: > > * Change export to EXPORT_SYMBOL_GPL > > * Use an argument for returning SoC ID > > * Update kerneldoc > > --- > > drivers/soc/qcom/smem.c | 23 +++++++++++++++++++++++ > > include/linux/soc/qcom/smem.h | 2 ++ > > 2 files changed, 25 insertions(+) > > > > diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c > > index bc98520c4969..78cf79ea4924 100644 > > --- a/drivers/soc/qcom/smem.c > > +++ b/drivers/soc/qcom/smem.c > > @@ -14,6 +14,7 @@ > > #include <linux/sizes.h> > > #include <linux/slab.h> > > #include <linux/soc/qcom/smem.h> > > +#include <linux/soc/qcom/socinfo.h> > > > > /* > > * The Qualcomm shared memory system is a allocate only heap structure that > > @@ -772,6 +773,28 @@ phys_addr_t qcom_smem_virt_to_phys(void *p) > > } > > EXPORT_SYMBOL_GPL(qcom_smem_virt_to_phys); > > > > +/** > > + * qcom_smem_get_soc_id() - return the SoC ID > > + * @id: On success, we return the SoC ID here. > > + * > > + * Look up SoC ID from HW/SW build ID and return it. > > + * > > + * Return: 0 on success, negative errno on failure. > > + */ > > +int qcom_smem_get_soc_id(u32 *id) > __le32 *id > Why do you want this passed back to the user in little endian? When is it not going to be compared to a cpu-endian constant? > LGTM otherwise! > > Konrad > > +{ > > + struct socinfo *info; > > + > > + info = qcom_smem_get(QCOM_SMEM_HOST_ANY, SMEM_HW_SW_BUILD_ID, NULL); > > + if (IS_ERR(info)) > > + return PTR_ERR(info); > > + > > + *id = info->id; This should be __le32_to_cpu() though... Regards, Bjorn > > + > > + return 0; > > +} > > +EXPORT_SYMBOL_GPL(qcom_smem_get_soc_id); > > + > > 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 86e1b358688a..223db6a9c733 100644 > > --- a/include/linux/soc/qcom/smem.h > > +++ b/include/linux/soc/qcom/smem.h > > @@ -11,4 +11,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); > > + > > #endif
On 26.05.2023 04:33, Bjorn Andersson wrote: > On Fri, May 26, 2023 at 01:18:17AM +0200, Konrad Dybcio wrote: >> >> >> On 25.05.2023 23:02, Robert Marko wrote: >>> Introduce a helper to return the SoC SMEM ID, which is used to identify the >>> exact SoC model as there may be differences in the same SoC family. >>> >>> Currently, cpufreq-nvmem does this completely in the driver and there has >>> been more interest expresed for other drivers to use this information so >>> lets expose a common helper to prevent redoing it in individual drivers >>> since this field is present on every SMEM table version. >>> >>> Signed-off-by: Robert Marko <robimarko@gmail.com> >>> --- >>> Changes in v4: >>> * Change helper name to qcom_smem_get_soc_id() >>> * Remove len and just pass NULL, that is sufficient here >>> >>> Changes in v3: >>> * Change export to EXPORT_SYMBOL_GPL >>> * Use an argument for returning SoC ID >>> * Update kerneldoc >>> --- >>> drivers/soc/qcom/smem.c | 23 +++++++++++++++++++++++ >>> include/linux/soc/qcom/smem.h | 2 ++ >>> 2 files changed, 25 insertions(+) >>> >>> diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c >>> index bc98520c4969..78cf79ea4924 100644 >>> --- a/drivers/soc/qcom/smem.c >>> +++ b/drivers/soc/qcom/smem.c >>> @@ -14,6 +14,7 @@ >>> #include <linux/sizes.h> >>> #include <linux/slab.h> >>> #include <linux/soc/qcom/smem.h> >>> +#include <linux/soc/qcom/socinfo.h> >>> >>> /* >>> * The Qualcomm shared memory system is a allocate only heap structure that >>> @@ -772,6 +773,28 @@ phys_addr_t qcom_smem_virt_to_phys(void *p) >>> } >>> EXPORT_SYMBOL_GPL(qcom_smem_virt_to_phys); >>> >>> +/** >>> + * qcom_smem_get_soc_id() - return the SoC ID >>> + * @id: On success, we return the SoC ID here. >>> + * >>> + * Look up SoC ID from HW/SW build ID and return it. >>> + * >>> + * Return: 0 on success, negative errno on failure. >>> + */ >>> +int qcom_smem_get_soc_id(u32 *id) >> __le32 *id >> > > Why do you want this passed back to the user in little endian? When is > it not going to be compared to a cpu-endian constant? Ugh. You're right. This makes no sense. Konrad > >> LGTM otherwise! >> >> Konrad >>> +{ >>> + struct socinfo *info; >>> + >>> + info = qcom_smem_get(QCOM_SMEM_HOST_ANY, SMEM_HW_SW_BUILD_ID, NULL); >>> + if (IS_ERR(info)) >>> + return PTR_ERR(info); >>> + >>> + *id = info->id; > > This should be __le32_to_cpu() though... > > Regards, > Bjorn > >>> + >>> + return 0; >>> +} >>> +EXPORT_SYMBOL_GPL(qcom_smem_get_soc_id); >>> + >>> 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 86e1b358688a..223db6a9c733 100644 >>> --- a/include/linux/soc/qcom/smem.h >>> +++ b/include/linux/soc/qcom/smem.h >>> @@ -11,4 +11,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); >>> + >>> #endif
On Thu, May 25, 2023 at 11:02:12PM +0200, Robert Marko wrote: > Introduce a helper to return the SoC SMEM ID, which is used to identify the > exact SoC model as there may be differences in the same SoC family. > > Currently, cpufreq-nvmem does this completely in the driver and there has > been more interest expresed for other drivers to use this information so > lets expose a common helper to prevent redoing it in individual drivers > since this field is present on every SMEM table version. > > Signed-off-by: Robert Marko <robimarko@gmail.com> > --- > Changes in v4: > * Change helper name to qcom_smem_get_soc_id() > * Remove len and just pass NULL, that is sufficient here > > Changes in v3: > * Change export to EXPORT_SYMBOL_GPL > * Use an argument for returning SoC ID > * Update kerneldoc > --- > drivers/soc/qcom/smem.c | 23 +++++++++++++++++++++++ > include/linux/soc/qcom/smem.h | 2 ++ > 2 files changed, 25 insertions(+) > > diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c > index bc98520c4969..78cf79ea4924 100644 > --- a/drivers/soc/qcom/smem.c > +++ b/drivers/soc/qcom/smem.c > @@ -14,6 +14,7 @@ > #include <linux/sizes.h> > #include <linux/slab.h> > #include <linux/soc/qcom/smem.h> > +#include <linux/soc/qcom/socinfo.h> > > /* > * The Qualcomm shared memory system is a allocate only heap structure that > @@ -772,6 +773,28 @@ phys_addr_t qcom_smem_virt_to_phys(void *p) > } > EXPORT_SYMBOL_GPL(qcom_smem_virt_to_phys); > > +/** > + * qcom_smem_get_soc_id() - return the SoC ID > + * @id: On success, we return the SoC ID here. > + * > + * Look up SoC ID from HW/SW build ID and return it. > + * > + * Return: 0 on success, negative errno on failure. > + */ > +int qcom_smem_get_soc_id(u32 *id) > +{ > + struct socinfo *info; > + > + info = qcom_smem_get(QCOM_SMEM_HOST_ANY, SMEM_HW_SW_BUILD_ID, NULL); > + if (IS_ERR(info)) > + return PTR_ERR(info); > + > + *id = info->id; So just to make the discussion between Konrad and me clear, please wrap the info->id access in __le32_to_cpu() and the series is ready to go. Thanks, Bjorn > + > + return 0; > +} > +EXPORT_SYMBOL_GPL(qcom_smem_get_soc_id); > + > 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 86e1b358688a..223db6a9c733 100644 > --- a/include/linux/soc/qcom/smem.h > +++ b/include/linux/soc/qcom/smem.h > @@ -11,4 +11,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); > + > #endif > -- > 2.40.1 >
diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c index bc98520c4969..78cf79ea4924 100644 --- a/drivers/soc/qcom/smem.c +++ b/drivers/soc/qcom/smem.c @@ -14,6 +14,7 @@ #include <linux/sizes.h> #include <linux/slab.h> #include <linux/soc/qcom/smem.h> +#include <linux/soc/qcom/socinfo.h> /* * The Qualcomm shared memory system is a allocate only heap structure that @@ -772,6 +773,28 @@ phys_addr_t qcom_smem_virt_to_phys(void *p) } EXPORT_SYMBOL_GPL(qcom_smem_virt_to_phys); +/** + * qcom_smem_get_soc_id() - return the SoC ID + * @id: On success, we return the SoC ID here. + * + * Look up SoC ID from HW/SW build ID and return it. + * + * Return: 0 on success, negative errno on failure. + */ +int qcom_smem_get_soc_id(u32 *id) +{ + struct socinfo *info; + + info = qcom_smem_get(QCOM_SMEM_HOST_ANY, SMEM_HW_SW_BUILD_ID, NULL); + if (IS_ERR(info)) + return PTR_ERR(info); + + *id = info->id; + + return 0; +} +EXPORT_SYMBOL_GPL(qcom_smem_get_soc_id); + 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 86e1b358688a..223db6a9c733 100644 --- a/include/linux/soc/qcom/smem.h +++ b/include/linux/soc/qcom/smem.h @@ -11,4 +11,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); + #endif