diff mbox series

[1/4] soc: qcom: socinfo: move SMEM item struct and defines to a header

Message ID 20230121112947.53433-1-robimarko@gmail.com (mailing list archive)
State Superseded
Headers show
Series [1/4] soc: qcom: socinfo: move SMEM item struct and defines to a header | expand

Commit Message

Robert Marko Jan. 21, 2023, 11:29 a.m. UTC
Move SMEM item struct and related defines to a header in order to be able
to reuse them in the Qualcomm NVMEM CPUFreq driver instead of duplicating
them.

Signed-off-by: Robert Marko <robimarko@gmail.com>
---
 drivers/soc/qcom/socinfo.c       | 65 +-----------------------------
 include/linux/soc/qcom/socinfo.h | 68 ++++++++++++++++++++++++++++++++
 2 files changed, 69 insertions(+), 64 deletions(-)
 create mode 100644 include/linux/soc/qcom/socinfo.h

Comments

Christophe JAILLET Jan. 21, 2023, 11:33 a.m. UTC | #1
Le 21/01/2023 à 12:29, Robert Marko a écrit :
> Move SMEM item struct and related defines to a header in order to be able
> to reuse them in the Qualcomm NVMEM CPUFreq driver instead of duplicating
> them.
> 
> Signed-off-by: Robert Marko <robimarko@gmail.com>
> ---
>   drivers/soc/qcom/socinfo.c       | 65 +-----------------------------
>   include/linux/soc/qcom/socinfo.h | 68 ++++++++++++++++++++++++++++++++
>   2 files changed, 69 insertions(+), 64 deletions(-)
>   create mode 100644 include/linux/soc/qcom/socinfo.h
> 
> diff --git a/drivers/soc/qcom/socinfo.c b/drivers/soc/qcom/socinfo.c
> index 3b970a80f3aa..5919f863f369 100644
> --- a/drivers/soc/qcom/socinfo.c
> +++ b/drivers/soc/qcom/socinfo.c
> @@ -11,6 +11,7 @@
>   #include <linux/random.h>
>   #include <linux/slab.h>
>   #include <linux/soc/qcom/smem.h>
> +#include <linux/soc/qcom/socinfo.h>
>   #include <linux/string.h>
>   #include <linux/stringify.h>
>   #include <linux/sys_soc.h>
> @@ -32,15 +33,6 @@
>   #define qcom_board_id(id) QCOM_ID_ ## id, __stringify(id)
>   #define qcom_board_id_named(id, name) QCOM_ID_ ## id, (name)
>   
> -#define SMEM_SOCINFO_BUILD_ID_LENGTH           32
> -#define SMEM_SOCINFO_CHIP_ID_LENGTH            32
> -
> -/*
> - * SMEM item id, used to acquire handles to respective
> - * SMEM region.
> - */
> -#define SMEM_HW_SW_BUILD_ID            137
> -
>   #ifdef CONFIG_DEBUG_FS
>   #define SMEM_IMAGE_VERSION_BLOCKS_COUNT        32
>   #define SMEM_IMAGE_VERSION_SIZE                4096
> @@ -121,62 +113,7 @@ static const char *const pmic_models[] = {
>   	[58] = "PM8450",
>   	[65] = "PM8010",
>   };
> -#endif /* CONFIG_DEBUG_FS */

This removal is spurious.

CJ


> -
> -/* Socinfo SMEM item structure */
> -struct socinfo {
> -	__le32 fmt;
> -	__le32 id;
> -	__le32 ver;
> -	char build_id[SMEM_SOCINFO_BUILD_ID_LENGTH];
> -	/* Version 2 */
> -	__le32 raw_id;
> -	__le32 raw_ver;
> -	/* Version 3 */
> -	__le32 hw_plat;
> -	/* Version 4 */
> -	__le32 plat_ver;
> -	/* Version 5 */
> -	__le32 accessory_chip;
> -	/* Version 6 */
> -	__le32 hw_plat_subtype;
> -	/* Version 7 */
> -	__le32 pmic_model;
> -	__le32 pmic_die_rev;
> -	/* Version 8 */
> -	__le32 pmic_model_1;
> -	__le32 pmic_die_rev_1;
> -	__le32 pmic_model_2;
> -	__le32 pmic_die_rev_2;
> -	/* Version 9 */
> -	__le32 foundry_id;
> -	/* Version 10 */
> -	__le32 serial_num;
> -	/* Version 11 */
> -	__le32 num_pmics;
> -	__le32 pmic_array_offset;
> -	/* Version 12 */
> -	__le32 chip_family;
> -	__le32 raw_device_family;
> -	__le32 raw_device_num;
> -	/* Version 13 */
> -	__le32 nproduct_id;
> -	char chip_id[SMEM_SOCINFO_CHIP_ID_LENGTH];
> -	/* Version 14 */
> -	__le32 num_clusters;
> -	__le32 ncluster_array_offset;
> -	__le32 num_defective_parts;
> -	__le32 ndefective_parts_array_offset;
> -	/* Version 15 */
> -	__le32 nmodem_supported;
> -	/* Version 16 */
> -	__le32  feature_code;
> -	__le32  pcode;
> -	__le32  npartnamemap_offset;
> -	__le32  nnum_partname_mapping;
> -};
>   
> -#ifdef CONFIG_DEBUG_FS
>   struct socinfo_params {
>   	u32 raw_device_family;
>   	u32 hw_plat_subtype;
> diff --git a/include/linux/soc/qcom/socinfo.h b/include/linux/soc/qcom/socinfo.h
> new file mode 100644
> index 000000000000..6a175d635617
> --- /dev/null
> +++ b/include/linux/soc/qcom/socinfo.h
> @@ -0,0 +1,68 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +
> +#ifndef __QCOM_SOCINFO_H__
> +#define __QCOM_SOCINFO_H__
> +
> +/*
> + * SMEM item id, used to acquire handles to respective
> + * SMEM region.
> + */
> +#define SMEM_HW_SW_BUILD_ID		137
> +
> +#define SMEM_SOCINFO_BUILD_ID_LENGTH	32
> +#define SMEM_SOCINFO_CHIP_ID_LENGTH	32
> +
> +/* Socinfo SMEM item structure */
> +struct socinfo {
> +	__le32 fmt;
> +	__le32 id;
> +	__le32 ver;
> +	char build_id[SMEM_SOCINFO_BUILD_ID_LENGTH];
> +	/* Version 2 */
> +	__le32 raw_id;
> +	__le32 raw_ver;
> +	/* Version 3 */
> +	__le32 hw_plat;
> +	/* Version 4 */
> +	__le32 plat_ver;
> +	/* Version 5 */
> +	__le32 accessory_chip;
> +	/* Version 6 */
> +	__le32 hw_plat_subtype;
> +	/* Version 7 */
> +	__le32 pmic_model;
> +	__le32 pmic_die_rev;
> +	/* Version 8 */
> +	__le32 pmic_model_1;
> +	__le32 pmic_die_rev_1;
> +	__le32 pmic_model_2;
> +	__le32 pmic_die_rev_2;
> +	/* Version 9 */
> +	__le32 foundry_id;
> +	/* Version 10 */
> +	__le32 serial_num;
> +	/* Version 11 */
> +	__le32 num_pmics;
> +	__le32 pmic_array_offset;
> +	/* Version 12 */
> +	__le32 chip_family;
> +	__le32 raw_device_family;
> +	__le32 raw_device_num;
> +	/* Version 13 */
> +	__le32 nproduct_id;
> +	char chip_id[SMEM_SOCINFO_CHIP_ID_LENGTH];
> +	/* Version 14 */
> +	__le32 num_clusters;
> +	__le32 ncluster_array_offset;
> +	__le32 num_defective_parts;
> +	__le32 ndefective_parts_array_offset;
> +	/* Version 15 */
> +	__le32 nmodem_supported;
> +	/* Version 16 */
> +	__le32  feature_code;
> +	__le32  pcode;
> +	__le32  npartnamemap_offset;
> +	__le32  nnum_partname_mapping;
> +};
> +
> +#endif
Robert Marko Jan. 21, 2023, 11:42 a.m. UTC | #2
On Sat, 21 Jan 2023 at 12:33, Christophe JAILLET
<christophe.jaillet@wanadoo.fr> wrote:
>
> Le 21/01/2023 à 12:29, Robert Marko a écrit :
> > Move SMEM item struct and related defines to a header in order to be able
> > to reuse them in the Qualcomm NVMEM CPUFreq driver instead of duplicating
> > them.
> >
> > Signed-off-by: Robert Marko <robimarko@gmail.com>
> > ---
> >   drivers/soc/qcom/socinfo.c       | 65 +-----------------------------
> >   include/linux/soc/qcom/socinfo.h | 68 ++++++++++++++++++++++++++++++++
> >   2 files changed, 69 insertions(+), 64 deletions(-)
> >   create mode 100644 include/linux/soc/qcom/socinfo.h
> >
> > diff --git a/drivers/soc/qcom/socinfo.c b/drivers/soc/qcom/socinfo.c
> > index 3b970a80f3aa..5919f863f369 100644
> > --- a/drivers/soc/qcom/socinfo.c
> > +++ b/drivers/soc/qcom/socinfo.c
> > @@ -11,6 +11,7 @@
> >   #include <linux/random.h>
> >   #include <linux/slab.h>
> >   #include <linux/soc/qcom/smem.h>
> > +#include <linux/soc/qcom/socinfo.h>
> >   #include <linux/string.h>
> >   #include <linux/stringify.h>
> >   #include <linux/sys_soc.h>
> > @@ -32,15 +33,6 @@
> >   #define qcom_board_id(id) QCOM_ID_ ## id, __stringify(id)
> >   #define qcom_board_id_named(id, name) QCOM_ID_ ## id, (name)
> >
> > -#define SMEM_SOCINFO_BUILD_ID_LENGTH           32
> > -#define SMEM_SOCINFO_CHIP_ID_LENGTH            32
> > -
> > -/*
> > - * SMEM item id, used to acquire handles to respective
> > - * SMEM region.
> > - */
> > -#define SMEM_HW_SW_BUILD_ID            137
> > -
> >   #ifdef CONFIG_DEBUG_FS
> >   #define SMEM_IMAGE_VERSION_BLOCKS_COUNT        32
> >   #define SMEM_IMAGE_VERSION_SIZE                4096
> > @@ -121,62 +113,7 @@ static const char *const pmic_models[] = {
> >       [58] = "PM8450",
> >       [65] = "PM8010",
> >   };
> > -#endif /* CONFIG_DEBUG_FS */
>
> This removal is spurious.

Hi,
Its intentional as only the socinfo struct was not guarded with an
debugfs ifdef,
so after moving it to a separate header you would have:

#endif /* CONFIG_DEBUG_FS */
#ifdef CONFIG_DEBUG_FS

This doesn't really make sense to me, so that is why endif is removed.

Regards,
Robert
>
> CJ
>
>
> > -
> > -/* Socinfo SMEM item structure */
> > -struct socinfo {
> > -     __le32 fmt;
> > -     __le32 id;
> > -     __le32 ver;
> > -     char build_id[SMEM_SOCINFO_BUILD_ID_LENGTH];
> > -     /* Version 2 */
> > -     __le32 raw_id;
> > -     __le32 raw_ver;
> > -     /* Version 3 */
> > -     __le32 hw_plat;
> > -     /* Version 4 */
> > -     __le32 plat_ver;
> > -     /* Version 5 */
> > -     __le32 accessory_chip;
> > -     /* Version 6 */
> > -     __le32 hw_plat_subtype;
> > -     /* Version 7 */
> > -     __le32 pmic_model;
> > -     __le32 pmic_die_rev;
> > -     /* Version 8 */
> > -     __le32 pmic_model_1;
> > -     __le32 pmic_die_rev_1;
> > -     __le32 pmic_model_2;
> > -     __le32 pmic_die_rev_2;
> > -     /* Version 9 */
> > -     __le32 foundry_id;
> > -     /* Version 10 */
> > -     __le32 serial_num;
> > -     /* Version 11 */
> > -     __le32 num_pmics;
> > -     __le32 pmic_array_offset;
> > -     /* Version 12 */
> > -     __le32 chip_family;
> > -     __le32 raw_device_family;
> > -     __le32 raw_device_num;
> > -     /* Version 13 */
> > -     __le32 nproduct_id;
> > -     char chip_id[SMEM_SOCINFO_CHIP_ID_LENGTH];
> > -     /* Version 14 */
> > -     __le32 num_clusters;
> > -     __le32 ncluster_array_offset;
> > -     __le32 num_defective_parts;
> > -     __le32 ndefective_parts_array_offset;
> > -     /* Version 15 */
> > -     __le32 nmodem_supported;
> > -     /* Version 16 */
> > -     __le32  feature_code;
> > -     __le32  pcode;
> > -     __le32  npartnamemap_offset;
> > -     __le32  nnum_partname_mapping;
> > -};
> >
> > -#ifdef CONFIG_DEBUG_FS
> >   struct socinfo_params {
> >       u32 raw_device_family;
> >       u32 hw_plat_subtype;
> > diff --git a/include/linux/soc/qcom/socinfo.h b/include/linux/soc/qcom/socinfo.h
> > new file mode 100644
> > index 000000000000..6a175d635617
> > --- /dev/null
> > +++ b/include/linux/soc/qcom/socinfo.h
> > @@ -0,0 +1,68 @@
> > +/* SPDX-License-Identifier: GPL-2.0 */
> > +
> > +#ifndef __QCOM_SOCINFO_H__
> > +#define __QCOM_SOCINFO_H__
> > +
> > +/*
> > + * SMEM item id, used to acquire handles to respective
> > + * SMEM region.
> > + */
> > +#define SMEM_HW_SW_BUILD_ID          137
> > +
> > +#define SMEM_SOCINFO_BUILD_ID_LENGTH 32
> > +#define SMEM_SOCINFO_CHIP_ID_LENGTH  32
> > +
> > +/* Socinfo SMEM item structure */
> > +struct socinfo {
> > +     __le32 fmt;
> > +     __le32 id;
> > +     __le32 ver;
> > +     char build_id[SMEM_SOCINFO_BUILD_ID_LENGTH];
> > +     /* Version 2 */
> > +     __le32 raw_id;
> > +     __le32 raw_ver;
> > +     /* Version 3 */
> > +     __le32 hw_plat;
> > +     /* Version 4 */
> > +     __le32 plat_ver;
> > +     /* Version 5 */
> > +     __le32 accessory_chip;
> > +     /* Version 6 */
> > +     __le32 hw_plat_subtype;
> > +     /* Version 7 */
> > +     __le32 pmic_model;
> > +     __le32 pmic_die_rev;
> > +     /* Version 8 */
> > +     __le32 pmic_model_1;
> > +     __le32 pmic_die_rev_1;
> > +     __le32 pmic_model_2;
> > +     __le32 pmic_die_rev_2;
> > +     /* Version 9 */
> > +     __le32 foundry_id;
> > +     /* Version 10 */
> > +     __le32 serial_num;
> > +     /* Version 11 */
> > +     __le32 num_pmics;
> > +     __le32 pmic_array_offset;
> > +     /* Version 12 */
> > +     __le32 chip_family;
> > +     __le32 raw_device_family;
> > +     __le32 raw_device_num;
> > +     /* Version 13 */
> > +     __le32 nproduct_id;
> > +     char chip_id[SMEM_SOCINFO_CHIP_ID_LENGTH];
> > +     /* Version 14 */
> > +     __le32 num_clusters;
> > +     __le32 ncluster_array_offset;
> > +     __le32 num_defective_parts;
> > +     __le32 ndefective_parts_array_offset;
> > +     /* Version 15 */
> > +     __le32 nmodem_supported;
> > +     /* Version 16 */
> > +     __le32  feature_code;
> > +     __le32  pcode;
> > +     __le32  npartnamemap_offset;
> > +     __le32  nnum_partname_mapping;
> > +};
> > +
> > +#endif
>
Bjorn Andersson May 27, 2023, 4 a.m. UTC | #3
On Sat, 21 Jan 2023 12:29:44 +0100, Robert Marko wrote:
> Move SMEM item struct and related defines to a header in order to be able
> to reuse them in the Qualcomm NVMEM CPUFreq driver instead of duplicating
> them.
> 
> 

Applied, thanks!

[1/4] soc: qcom: socinfo: move SMEM item struct and defines to a header
      commit: ec001bb71e4476f7f5be9db693d5f43e65b9d8cb

Best regards,
diff mbox series

Patch

diff --git a/drivers/soc/qcom/socinfo.c b/drivers/soc/qcom/socinfo.c
index 3b970a80f3aa..5919f863f369 100644
--- a/drivers/soc/qcom/socinfo.c
+++ b/drivers/soc/qcom/socinfo.c
@@ -11,6 +11,7 @@ 
 #include <linux/random.h>
 #include <linux/slab.h>
 #include <linux/soc/qcom/smem.h>
+#include <linux/soc/qcom/socinfo.h>
 #include <linux/string.h>
 #include <linux/stringify.h>
 #include <linux/sys_soc.h>
@@ -32,15 +33,6 @@ 
 #define qcom_board_id(id) QCOM_ID_ ## id, __stringify(id)
 #define qcom_board_id_named(id, name) QCOM_ID_ ## id, (name)
 
-#define SMEM_SOCINFO_BUILD_ID_LENGTH           32
-#define SMEM_SOCINFO_CHIP_ID_LENGTH            32
-
-/*
- * SMEM item id, used to acquire handles to respective
- * SMEM region.
- */
-#define SMEM_HW_SW_BUILD_ID            137
-
 #ifdef CONFIG_DEBUG_FS
 #define SMEM_IMAGE_VERSION_BLOCKS_COUNT        32
 #define SMEM_IMAGE_VERSION_SIZE                4096
@@ -121,62 +113,7 @@  static const char *const pmic_models[] = {
 	[58] = "PM8450",
 	[65] = "PM8010",
 };
-#endif /* CONFIG_DEBUG_FS */
-
-/* Socinfo SMEM item structure */
-struct socinfo {
-	__le32 fmt;
-	__le32 id;
-	__le32 ver;
-	char build_id[SMEM_SOCINFO_BUILD_ID_LENGTH];
-	/* Version 2 */
-	__le32 raw_id;
-	__le32 raw_ver;
-	/* Version 3 */
-	__le32 hw_plat;
-	/* Version 4 */
-	__le32 plat_ver;
-	/* Version 5 */
-	__le32 accessory_chip;
-	/* Version 6 */
-	__le32 hw_plat_subtype;
-	/* Version 7 */
-	__le32 pmic_model;
-	__le32 pmic_die_rev;
-	/* Version 8 */
-	__le32 pmic_model_1;
-	__le32 pmic_die_rev_1;
-	__le32 pmic_model_2;
-	__le32 pmic_die_rev_2;
-	/* Version 9 */
-	__le32 foundry_id;
-	/* Version 10 */
-	__le32 serial_num;
-	/* Version 11 */
-	__le32 num_pmics;
-	__le32 pmic_array_offset;
-	/* Version 12 */
-	__le32 chip_family;
-	__le32 raw_device_family;
-	__le32 raw_device_num;
-	/* Version 13 */
-	__le32 nproduct_id;
-	char chip_id[SMEM_SOCINFO_CHIP_ID_LENGTH];
-	/* Version 14 */
-	__le32 num_clusters;
-	__le32 ncluster_array_offset;
-	__le32 num_defective_parts;
-	__le32 ndefective_parts_array_offset;
-	/* Version 15 */
-	__le32 nmodem_supported;
-	/* Version 16 */
-	__le32  feature_code;
-	__le32  pcode;
-	__le32  npartnamemap_offset;
-	__le32  nnum_partname_mapping;
-};
 
-#ifdef CONFIG_DEBUG_FS
 struct socinfo_params {
 	u32 raw_device_family;
 	u32 hw_plat_subtype;
diff --git a/include/linux/soc/qcom/socinfo.h b/include/linux/soc/qcom/socinfo.h
new file mode 100644
index 000000000000..6a175d635617
--- /dev/null
+++ b/include/linux/soc/qcom/socinfo.h
@@ -0,0 +1,68 @@ 
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#ifndef __QCOM_SOCINFO_H__
+#define __QCOM_SOCINFO_H__
+
+/*
+ * SMEM item id, used to acquire handles to respective
+ * SMEM region.
+ */
+#define SMEM_HW_SW_BUILD_ID		137
+
+#define SMEM_SOCINFO_BUILD_ID_LENGTH	32
+#define SMEM_SOCINFO_CHIP_ID_LENGTH	32
+
+/* Socinfo SMEM item structure */
+struct socinfo {
+	__le32 fmt;
+	__le32 id;
+	__le32 ver;
+	char build_id[SMEM_SOCINFO_BUILD_ID_LENGTH];
+	/* Version 2 */
+	__le32 raw_id;
+	__le32 raw_ver;
+	/* Version 3 */
+	__le32 hw_plat;
+	/* Version 4 */
+	__le32 plat_ver;
+	/* Version 5 */
+	__le32 accessory_chip;
+	/* Version 6 */
+	__le32 hw_plat_subtype;
+	/* Version 7 */
+	__le32 pmic_model;
+	__le32 pmic_die_rev;
+	/* Version 8 */
+	__le32 pmic_model_1;
+	__le32 pmic_die_rev_1;
+	__le32 pmic_model_2;
+	__le32 pmic_die_rev_2;
+	/* Version 9 */
+	__le32 foundry_id;
+	/* Version 10 */
+	__le32 serial_num;
+	/* Version 11 */
+	__le32 num_pmics;
+	__le32 pmic_array_offset;
+	/* Version 12 */
+	__le32 chip_family;
+	__le32 raw_device_family;
+	__le32 raw_device_num;
+	/* Version 13 */
+	__le32 nproduct_id;
+	char chip_id[SMEM_SOCINFO_CHIP_ID_LENGTH];
+	/* Version 14 */
+	__le32 num_clusters;
+	__le32 ncluster_array_offset;
+	__le32 num_defective_parts;
+	__le32 ndefective_parts_array_offset;
+	/* Version 15 */
+	__le32 nmodem_supported;
+	/* Version 16 */
+	__le32  feature_code;
+	__le32  pcode;
+	__le32  npartnamemap_offset;
+	__le32  nnum_partname_mapping;
+};
+
+#endif