Received: by 2002:a25:1104:0:0:0:0:0 with SMTP id 4csp250154ybr; Fri, 22 May 2020 05:52:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzpNgRrYRIut1Ih4rxffldPC5YiU9MbYBGB0iwHWA24qzhjX+kKJ4ylBbuyw8wXgKL1MABU X-Received: by 2002:aa7:da8c:: with SMTP id q12mr2849733eds.334.1590151933463; Fri, 22 May 2020 05:52:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590151933; cv=none; d=google.com; s=arc-20160816; b=pH7j42drRM79dqfPoPEPwAJeCWNFG1YlPSeRRT+Lw/VKCwxhj7/MfUMJK7tRCifUvT OxtxHxoUvT6Wd8nZkij0bRkSeqT3O2Ws0VbUKgfBs7ZsDN9XUEWwIbOUPJIr9l8jn0tf TBp6GdJx8UOg/JG+KSJEehv7SWiyfgA6cE0sfV0lG/v0ibxLQu6d2MBy6VjxmrXkYtkJ C3/QBNMRVUsfksprLKwoK1G+TsCyZeoMpqflZ1jvy3oEBQAgUkWa4JOvCbv70/U6ECsH mWJreUKqtToDt6pcaEa1tHmtTMyex/UjBEU+7091VpK6WaSf3FQZaGNk6KwE0Ukp++bh 1hUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=haLVxscKNDaO4oIWstfaCg3fnrXlFmUVDgDIYbcSif0=; b=wRlTdFngcRrl8DRRYG28f5/QCT0BfaZa2CHJHoXVn1fuPNXjMcm1euieZD+j95grYC +AP75QimOwqJKW+x/3H1de6fVdwpjKxSZcvSG3yLaDQXiY3PaA4Wot1DlT6nArBTjm/h TwHVdAUs1ITTMKrItxpCWU8IndQCmiM6cJkfDAzX9p92yrsmkYiY38lAO39TM+0o51O6 X0jc1o6NdtyT+kcRqRTvb+G37sdzPmj+nF8VzuvsL+V1nZILsYyOttiGJjoPxorIf/C8 Y6xAx/cfsvmqRvsWxlMm1poCfSAHZiUKVp/WWdOZ6xo/arHfVeT3MJLI4HNI1aObW7ZX Sj6g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m24si4869935ejo.686.2020.05.22.05.51.49; Fri, 22 May 2020 05:52:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729377AbgEVMuF (ORCPT + 99 others); Fri, 22 May 2020 08:50:05 -0400 Received: from foss.arm.com ([217.140.110.172]:34898 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728878AbgEVMuC (ORCPT ); Fri, 22 May 2020 08:50:02 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4C0461063; Fri, 22 May 2020 05:50:02 -0700 (PDT) Received: from usa.arm.com (e103737-lin.cambridge.arm.com [10.1.197.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 16E1C3F68F; Fri, 22 May 2020 05:50:00 -0700 (PDT) From: Sudeep Holla To: linux-arm-kernel@lists.infradead.org Cc: Sudeep Holla , Will Deacon , Mark Rutland , Lorenzo Pieralisi , linux-kernel@vger.kernel.org, Arnd Bergmann , harb@amperecomputing.com, Greg Kroah-Hartman Subject: [PATCH 1/2] base: soc: Add JEDEC JEP106 manufacturer's identification code attribute Date: Fri, 22 May 2020 13:49:50 +0100 Message-Id: <20200522124951.35776-2-sudeep.holla@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200522124951.35776-1-sudeep.holla@arm.com> References: <20200522124951.35776-1-sudeep.holla@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 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 +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 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