linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Sudeep Holla <sudeep.holla@arm.com>
To: linux-arm-kernel@lists.infradead.org
Cc: Mark Rutland <mark.rutland@arm.com>,
	Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>,
	Arnd Bergmann <arnd@arndb.de>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-kernel@vger.kernel.org, harb@amperecomputing.com,
	Sudeep Holla <sudeep.holla@arm.com>,
	Will Deacon <will@kernel.org>
Subject: [PATCH 1/2] base: soc: Add JEDEC JEP106 manufacturer's identification code attribute
Date: Fri, 22 May 2020 13:49:50 +0100	[thread overview]
Message-ID: <20200522124951.35776-2-sudeep.holla@arm.com> (raw)
In-Reply-To: <20200522124951.35776-1-sudeep.holla@arm.com>

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@arm.com>
---
 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@linaro.org>
 		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@arm.com>
+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@linaro.org>
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


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2020-05-22 12:50 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-22 12:49 [PATCH 0/2] base: soc: Add JEP106 manufacturer's identification code Sudeep Holla
2020-05-22 12:49 ` Sudeep Holla [this message]
2020-05-22 12:49 ` [PATCH 2/2] firmware: smccc: Add ARCH_SOC_ID support Sudeep Holla
2020-05-22 14:46   ` Arnd Bergmann
2020-05-22 16:54     ` Sudeep Holla
2020-05-22 17:13       ` Sudeep Holla
2020-05-22 18:41       ` Arnd Bergmann
2020-05-23 17:27         ` Sudeep Holla
2020-05-23 19:40           ` Arnd Bergmann
2020-05-28 13:05             ` Jose Marinho

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200522124951.35776-2-sudeep.holla@arm.com \
    --to=sudeep.holla@arm.com \
    --cc=arnd@arndb.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=harb@amperecomputing.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=mark.rutland@arm.com \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).