[PATCH 1/2] base: soc: Add JEDEC JEP106 manufacturer's identification code attribute
From: Sudeep Holla
Date: Fri May 22 2020 - 08:50:17 EST
SMCCC v1.2 adds a new optional function SMCCC_ARCH_SOC_ID to obtain a
SiP defined SoC identification value. Indeed of making it custom
attribute, let us add the same as generic attribute to soc_device.
There are various ways in which it can be represented in shortened form
for efficiency and ease of parsing for userspace. The chosen form is
described in the ABI document.
Signed-off-by: Sudeep Holla <sudeep.holla@xxxxxxx>
---
Documentation/ABI/testing/sysfs-devices-soc | 31 +++++++++++++++++++++
drivers/base/soc.c | 12 ++++++++
include/linux/sys_soc.h | 1 +
3 files changed, 44 insertions(+)
diff --git a/Documentation/ABI/testing/sysfs-devices-soc b/Documentation/ABI/testing/sysfs-devices-soc
index ba3a3fac0ee1..fd44c9b1e09a 100644
--- a/Documentation/ABI/testing/sysfs-devices-soc
+++ b/Documentation/ABI/testing/sysfs-devices-soc
@@ -54,6 +54,37 @@ contact: Lee Jones <lee.jones@xxxxxxxxxx>
Read-only attribute supported ST-Ericsson's silicon. Contains the
the process by which the silicon chip was manufactured.
+What: /sys/devices/socX/jep106_identification_code
+Date: June 2020
+Contact: Sudeep Holla <sudeep.holla@xxxxxxx>
+Description:
+ Read-only attribute supported on many of ARM based silicon
+ with SMCCC v1.2+ compliant firmware. Contains the JEDEC
+ JEP106 manufacturerâs identification code.
+
+ This manufacturerâs identification code is defined by one
+ or more eight (8) bit fields, each consisting of seven (7)
+ data bits plus one (1) odd parity bit. It is a single field,
+ limiting the possible number of vendors to 126. To expand
+ the maximum number of identification codes, a continuation
+ scheme has been defined.
+
+ The specified mechanism is that an identity code of 0x7F
+ represents the "continuation code" and implies the presence
+ of an additional identity code field, and this mechanism
+ may be extended to multiple continuation codes followed
+ by the manufacturer's identity code.
+
+ For example, ARM has identity code 0x7F 0x7F 0x7F 0x7F 0x3B,
+ which is code 0x3B on the fifth 'page'. This can be shortened
+ as JEP106 identity code of 0x3B and a continuation code of
+ 0x4 to represent the four continuation codes preceding the
+ identity code.
+
+ This property represents it in the shortened form:
+ 8-bit continuation code followed by 8 bit identity code
+ without the parity bit.
+
What: /sys/bus/soc
Date: January 2012
contact: Lee Jones <lee.jones@xxxxxxxxxx>
diff --git a/drivers/base/soc.c b/drivers/base/soc.c
index 4af11a423475..44dc757aadf4 100644
--- a/drivers/base/soc.c
+++ b/drivers/base/soc.c
@@ -36,6 +36,7 @@ static DEVICE_ATTR(family, S_IRUGO, soc_info_get, NULL);
static DEVICE_ATTR(serial_number, S_IRUGO, soc_info_get, NULL);
static DEVICE_ATTR(soc_id, S_IRUGO, soc_info_get, NULL);
static DEVICE_ATTR(revision, S_IRUGO, soc_info_get, NULL);
+static DEVICE_ATTR(jep106_identification_code, S_IRUGO, soc_info_get, NULL);
struct device *soc_device_to_device(struct soc_device *soc_dev)
{
@@ -64,6 +65,9 @@ static umode_t soc_attribute_mode(struct kobject *kobj,
if ((attr == &dev_attr_soc_id.attr)
&& (soc_dev->attr->soc_id != NULL))
return attr->mode;
+ if ((attr == &dev_attr_jep106_identification_code.attr)
+ && (soc_dev->attr->jep106_id != NULL))
+ return attr->mode;
/* Unknown or unfilled attribute. */
return 0;
@@ -85,6 +89,8 @@ static ssize_t soc_info_get(struct device *dev,
return sprintf(buf, "%s\n", soc_dev->attr->serial_number);
if (attr == &dev_attr_soc_id)
return sprintf(buf, "%s\n", soc_dev->attr->soc_id);
+ if (attr == &dev_attr_jep106_identification_code)
+ return sprintf(buf, "%s\n", soc_dev->attr->jep106_id);
return -EINVAL;
@@ -96,6 +102,7 @@ static struct attribute *soc_attr[] = {
&dev_attr_serial_number.attr,
&dev_attr_soc_id.attr,
&dev_attr_revision.attr,
+ &dev_attr_jep106_identification_code.attr,
NULL,
};
@@ -214,6 +221,11 @@ static int soc_device_match_attr(const struct soc_device_attribute *attr,
(!attr->soc_id || !glob_match(match->soc_id, attr->soc_id)))
return 0;
+ if (match->jep106_id &&
+ (!attr->jep106_id ||
+ !glob_match(match->jep106_id, attr->jep106_id)))
+ return 0;
+
return 1;
}
diff --git a/include/linux/sys_soc.h b/include/linux/sys_soc.h
index d9b3cf0f410c..394fa70ae16f 100644
--- a/include/linux/sys_soc.h
+++ b/include/linux/sys_soc.h
@@ -14,6 +14,7 @@ struct soc_device_attribute {
const char *revision;
const char *serial_number;
const char *soc_id;
+ const char *jep106_id;
const void *data;
const struct attribute_group *custom_attr_group;
};
--
2.17.1