From patchwork Thu Feb 14 03:41:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaishali Thakkar X-Patchwork-Id: 158300 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp860095jaa; Wed, 13 Feb 2019 19:41:37 -0800 (PST) X-Google-Smtp-Source: AHgI3IaJixfn6hBdCfWlt/OuDBx48JOQO9kD60X4h+tsgmnMCmF5xfIDerK+XZdptN0rVHX6YHYq X-Received: by 2002:a17:902:a612:: with SMTP id u18mr1826320plq.145.1550115697087; Wed, 13 Feb 2019 19:41:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550115697; cv=none; d=google.com; s=arc-20160816; b=eJWqXxpFTBHw8icyJB4md8P9PyfwBoaxsHTtvIqAxTtX1VULSjIkauRYUBYuPVNlFU HVt1CK9VP7/fNXGxw9VOzGMmjrt2uivvTiTPWHIAOYyXvgD8V0rYetuMFVbqAuof87t7 vhau0RpytsbNoGB58BGBJYQKGLY0ezmv1GxUHUHhD2idhMjWzLP5nX25+Dh1uPKT81Fz brNtD5//e8n/u5UrlV3UAetBA6kjyxT06o33ZkWMSjjF7d+5WjQPMw4U0Ncgp3BvnwrH juZHDlP3N8k74icBX6LTxeNqvKKyE9L2hd0k4EQTkYUUEDiJ9jTGhgzkbBxgU/ffpkGL PDHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=4DDZa9UNNDPoHClqayQDB3fdzoTjX8XIC8Ufn84AuJY=; b=a7i0EzahGbc3mKck3aemNv3A3WtUBzyhQLQK4yG9uPttu9/QorpPTcFves2uUuDqqT vIPQJvHYJ/ZG0iv0Ng4PFWLWR096+nxp7p/wVA/zbBWddWlR3vR+o4oAPWb8CPFi+17b mjQBBuc7jnAqmtjbLHmIlgv4If2NSRuZPZHLNAI53v8wK5KxkzQdB5pF4+tJNpDfvxFn hvpCPeZcf7fvFpoOSN+QW68wHVACw+lbJ40EZJE/+1lQLwzacMCz1LGh0VNVxdL0bL8t wgMPaM7QQNWo1b5c8ExxsnoMzezY9ULdwes5gHsfz1VL8n1ryVarzEpYkXg8rr4mSxy6 mgJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ajKonsCV; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n4si1155692pgp.318.2019.02.13.19.41.36; Wed, 13 Feb 2019 19:41:37 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ajKonsCV; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2395358AbfBNDlg (ORCPT + 15 others); Wed, 13 Feb 2019 22:41:36 -0500 Received: from mail-pf1-f193.google.com ([209.85.210.193]:45365 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2395357AbfBNDlg (ORCPT ); Wed, 13 Feb 2019 22:41:36 -0500 Received: by mail-pf1-f193.google.com with SMTP id j3so2321026pfi.12 for ; Wed, 13 Feb 2019 19:41:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=4DDZa9UNNDPoHClqayQDB3fdzoTjX8XIC8Ufn84AuJY=; b=ajKonsCVsozjnHRPiMt/M59coQrxnCYDUHQaMDgPEWs+cRf5gPDoZ8CuWLsTMnBCb4 hG3/C1MCfYm8272yABsG724DmOO2xy/TwVvLeFDMyX95pO4mWHLX7q4UzpGqqcPmNgpJ ooWU48Glax6VF1U5kAQlQtDp2GwILHjZQU2rr7JzMhKAv/3u5rYhYlaD3r4TDgif3EfB l/pIj6dRUdVg8WxNHDQya8vdnnFSnEr5gkh+hHAMM5E5WZavdtRoP2XPWMUOMjXvJigv Fr0c5e7XbVjGE5/ZRzXMJssvwoWILQBDCvBVwGb52nOTikr594vH1lz6Moeqk2KgUwxi iEfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=4DDZa9UNNDPoHClqayQDB3fdzoTjX8XIC8Ufn84AuJY=; b=ZbyqoYFgESEkmVV/iz583vU52C7sG8iaCW7NB1if6KwdtO2rnyc2JPhTJarzFFNi3V NIIsmtf1qkutmHPmopYDNcbImsqnWqcT71ybbW9AIAmnXyTZPr3K8dS2gjOdYsLw8aLU zcCbQbyhQJqRomP7YOp9+fXNg2tZRGqwI2BmtUW30gtOGiDjisuOjbkF6SGGEEuLRKK8 jmN7P/NUoDGoEHFlacMMMkOTjjP14LlkMpxRcdfN/mR9OiBTm2w2P7wYEBEqhSfIeVJ6 XFXi1//GpAncot9yrU+DV+2rXjNUwT5m6f9Dw/xwZrNf+J21Fh4pqEerpoB7nrMhgXPc T1hQ== X-Gm-Message-State: AHQUAuYIhd3MdMrray0+m+Ob7XD9p4qOlZGajA0VotBtvFiJn5Fe78sU m/bJUvnTz0Apanrgm/6dWBY4ug== X-Received: by 2002:a63:eb02:: with SMTP id t2mr1701163pgh.57.1550115695089; Wed, 13 Feb 2019 19:41:35 -0800 (PST) Received: from localhost.localdomain ([103.240.171.178]) by smtp.gmail.com with ESMTPSA id l184sm1038583pfc.112.2019.02.13.19.41.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Feb 2019 19:41:34 -0800 (PST) From: Vaishali Thakkar To: andy.gross@linaro.org Cc: david.brown@linaro.org, gregkh@linuxfoundation.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, rafael@kernel.org, bjorn.andersson@linaro.org, vkoul@kernel.org, Vaishali Thakkar Subject: [PATCH 1/5] base: soc: Add serial_number attribute to soc Date: Thu, 14 Feb 2019 09:11:28 +0530 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Bjorn Andersson Add new attribute named "serial_number" as a standard interface for user space to acquire the serial number of the device. For ST-Ericsson SoCs this is exposed by the cryptically named "soc_id" attribute, but this provides a human readable standardized name for this property. Signed-off-by: Bjorn Andersson Signed-off-by: Vaishali Thakkar --- Documentation/ABI/testing/sysfs-devices-soc | 7 +++++++ drivers/base/soc.c | 7 +++++++ include/linux/sys_soc.h | 1 + 3 files changed, 15 insertions(+) -- 2.17.1 diff --git a/Documentation/ABI/testing/sysfs-devices-soc b/Documentation/ABI/testing/sysfs-devices-soc index 6d9cc253f2b2..919109697bf0 100644 --- a/Documentation/ABI/testing/sysfs-devices-soc +++ b/Documentation/ABI/testing/sysfs-devices-soc @@ -26,6 +26,13 @@ Description: Read-only attribute common to all SoCs. Contains SoC family name (e.g. DB8500). +What: /sys/devices/socX/serial_number +Date: January 2019 +contact: Bjorn Andersson +Description: + Read-only attribute supported by most SoCs. Contains the SoC's + serial number. + What: /sys/devices/socX/soc_id Date: January 2012 contact: Lee Jones diff --git a/drivers/base/soc.c b/drivers/base/soc.c index 10b280f30217..b0933b9fe67f 100644 --- a/drivers/base/soc.c +++ b/drivers/base/soc.c @@ -33,6 +33,7 @@ static struct bus_type soc_bus_type = { static DEVICE_ATTR(machine, S_IRUGO, soc_info_get, NULL); 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); @@ -57,6 +58,9 @@ static umode_t soc_attribute_mode(struct kobject *kobj, if ((attr == &dev_attr_revision.attr) && (soc_dev->attr->revision != NULL)) return attr->mode; + if ((attr == &dev_attr_serial_number.attr) + && (soc_dev->attr->serial_number != NULL)) + return attr->mode; if ((attr == &dev_attr_soc_id.attr) && (soc_dev->attr->soc_id != NULL)) return attr->mode; @@ -77,6 +81,8 @@ static ssize_t soc_info_get(struct device *dev, return sprintf(buf, "%s\n", soc_dev->attr->family); if (attr == &dev_attr_revision) return sprintf(buf, "%s\n", soc_dev->attr->revision); + if (attr == &dev_attr_serial_number) + 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); @@ -87,6 +93,7 @@ static ssize_t soc_info_get(struct device *dev, static struct attribute *soc_attr[] = { &dev_attr_machine.attr, &dev_attr_family.attr, + &dev_attr_serial_number.attr, &dev_attr_soc_id.attr, &dev_attr_revision.attr, NULL, diff --git a/include/linux/sys_soc.h b/include/linux/sys_soc.h index bed223b70217..2a13bc033bd6 100644 --- a/include/linux/sys_soc.h +++ b/include/linux/sys_soc.h @@ -12,6 +12,7 @@ struct soc_device_attribute { const char *machine; const char *family; const char *revision; + const char *serial_number; const char *soc_id; const void *data; }; From patchwork Thu Feb 14 03:41:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaishali Thakkar X-Patchwork-Id: 158301 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp860249jaa; Wed, 13 Feb 2019 19:41:49 -0800 (PST) X-Google-Smtp-Source: AHgI3IZLrRb6sGHaPcdE0HuDx3qvQHHeur1iCW2XOmIYLRwgrg+aNY6KtZKHuGi+wDNRYfxeFEoj X-Received: by 2002:a65:6215:: with SMTP id d21mr1669063pgv.289.1550115709926; Wed, 13 Feb 2019 19:41:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550115709; cv=none; d=google.com; s=arc-20160816; b=ZL0N+uUxuDJHsjivC+1f5TPYgRGhcr6OzcyvuiKCuoO2XDz+mbdwGcdbcKQN+BDh7d SC+gkXFEN3PM6zRd5CUn31UiIxUb++J2OT+xXIgjsdlSfaglMWRp4QSfyUZkUSDW9heg GVoQGneAAa6XYmKf3SyOklmzq1sI60NNw5EzvxrkfXymOCe4EyVft4384zkVHDsRTEIA UePWtxv0x766WcPIKvPywvxVO8HETdebc2UG5QXZO0ZL2ywP55ACXTyPm5afE9VIv1vG VnfeGy+sQWmME96VvXP2lZ+Axo3W6QpiaGTJvm/DNKoOJJcQkAE2EzsROl5pkK6Vzy2N f1mQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=wseL0Pd2SRrAzvi0h0ZOmtAXsIE/vn/nGWi0cl+/f04=; b=ElcMu5hop7eTsKOR+9Eb0Cvyn8GlZn+OhTcl1oqi/zeAbnKKYD6D+j0cC+hmnRG624 TfWiKpyzfzyCzStXY+i+fmemH3Grd/N4xKEtJKUDeFaIV9taBbqjKLP7TxfCt7VLwa/P 8IUAubPdhO6wfIxOaDbcmlO35qlKJsRn5ICQcACdNumBlWmDr2wY+YYa/f7gjWU6cs0T O4ehtuC3iluZaCNBp9vXU8nZJekY/d0p7eeBL0BbKubX1DpQTtlhCB/i3jWLmByyJrm9 5eu/blwwRsac/4ZE38i6vq9rdODWuW2lacuKbOP/3Mx8vWF4LNOnPOTPKUycTtV/gVto qI9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tzmEuAPl; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l19si1210380pgh.554.2019.02.13.19.41.49; Wed, 13 Feb 2019 19:41:49 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tzmEuAPl; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2395384AbfBNDlr (ORCPT + 15 others); Wed, 13 Feb 2019 22:41:47 -0500 Received: from mail-pl1-f195.google.com ([209.85.214.195]:44522 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389764AbfBNDlq (ORCPT ); Wed, 13 Feb 2019 22:41:46 -0500 Received: by mail-pl1-f195.google.com with SMTP id p4so2362596plq.11 for ; Wed, 13 Feb 2019 19:41:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=wseL0Pd2SRrAzvi0h0ZOmtAXsIE/vn/nGWi0cl+/f04=; b=tzmEuAPltrPH61We14SnlpWuAFrTLoS6wJfu1ov6+XMXz0znQO08OmlqCATdi6idv8 K17+1JfqwBGy9q0apnCRDnqeMFHb+Fs4pcnnQfyF+u16INF3ZzqEk404bAPBzbzsZzz+ JffvfiMyMWPsq2KNR0WUzWJiMWVGwIEh09BH2KlkJSzC9bSlE8FA4iyAVXPDrN+46AQI qMyou3+J6lVpwrfFu72rRWA1BlDkRsGoPvigtFkIomF2Mr5CN/1/93IonQsfl53Zp3S2 pMzHmQXOKZIerG3YMZSZjits9aWy7WSr7TIq8vUZEBoiVuIOkSkJ/Mtd37uVPZ6gWXEf jZYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=wseL0Pd2SRrAzvi0h0ZOmtAXsIE/vn/nGWi0cl+/f04=; b=fxId0HpukvLSXlKfQqDLVd1W6q6Ssoy1B8UDvMxa8eCOoj0aKfWpzKfWdqiOn8DIut YwStVLFWdai0fhWkJ3d61eX+l1FSkQh5Td+Wu8c34Poj/mT+CLSK5dtFv+mBEVBC1weu mmovVCihkRWrANoQNwMHV2sONOo0+O2pMCTBJHDOH+wZ2my+JBGcCFFS6Hrec36sHjK/ YT0lZdxFCrj7NnkUPkH3BGjloawbyOtqV26Cb4LW1mWutyynbQ9ZKTkxNVSfqsv+ASe7 O1BIZQWyLY3XAlQ2UtR0FWPGbU6tJ9KjmJhJrTPdwWlQjxHarlFAb8tjdzsWGz/Nz+UF w+rw== X-Gm-Message-State: AHQUAuafktb65NuiNVI55YD0rSuB5E78DTobnT2ZA7AlVmym+XMSRvbJ aMp+9manVxgGU/Rar3JKMpl20g== X-Received: by 2002:a17:902:bb89:: with SMTP id m9mr1839791pls.320.1550115705446; Wed, 13 Feb 2019 19:41:45 -0800 (PST) Received: from localhost.localdomain ([103.240.171.178]) by smtp.gmail.com with ESMTPSA id y21sm948840pfe.57.2019.02.13.19.41.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Feb 2019 19:41:44 -0800 (PST) From: Vaishali Thakkar To: andy.gross@linaro.org Cc: david.brown@linaro.org, gregkh@linuxfoundation.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, rafael@kernel.org, bjorn.andersson@linaro.org, vkoul@kernel.org, Imran Khan , Vaishali Thakkar Subject: [PATCH 2/5] soc: qcom: Add socinfo driver Date: Thu, 14 Feb 2019 09:11:38 +0530 Message-Id: <925df36b602fab1aba08d4e2b7b58e8080a06a82.1550114271.git.vaishali.thakkar@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Imran Khan The Qualcomm socinfo driver exposes information about the SoC, its version and its serial number to user space. Signed-off-by: Imran Khan [Bjorn: Extract code to platform_driver, split patch in multiple] Signed-off-by: Bjorn Andersson [Vaishali: Simplify declarations, introduce qcom_socinfo struc, Fix memory leak, Remove extra code and Misc code refactoring] Signed-off-by: Vaishali Thakkar --- drivers/soc/qcom/Kconfig | 8 ++ drivers/soc/qcom/Makefile | 1 + drivers/soc/qcom/smem.c | 8 ++ drivers/soc/qcom/socinfo.c | 197 +++++++++++++++++++++++++++++++++++++ 4 files changed, 214 insertions(+) create mode 100644 drivers/soc/qcom/socinfo.c -- 2.17.1 diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig index fcbf8a2e4080..1e31eda07934 100644 --- a/drivers/soc/qcom/Kconfig +++ b/drivers/soc/qcom/Kconfig @@ -144,6 +144,14 @@ config QCOM_SMSM Say yes here to support the Qualcomm Shared Memory State Machine. The state machine is represented by bits in shared memory. +config QCOM_SOCINFO + tristate "Qualcomm socinfo driver" + depends on QCOM_SMEM + select SOC_BUS + help + Say yes here to support the Qualcomm socinfo driver, providing + information about the SoC to user space. + config QCOM_WCNSS_CTRL tristate "Qualcomm WCNSS control driver" depends on ARCH_QCOM || COMPILE_TEST diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile index f25b54cd6cf8..c817da4f4140 100644 --- a/drivers/soc/qcom/Makefile +++ b/drivers/soc/qcom/Makefile @@ -14,6 +14,7 @@ qcom_rpmh-y += rpmh-rsc.o qcom_rpmh-y += rpmh.o obj-$(CONFIG_QCOM_SMD_RPM) += smd-rpm.o obj-$(CONFIG_QCOM_SMEM) += smem.o +obj-$(CONFIG_QCOM_SOCINFO) += socinfo.o obj-$(CONFIG_QCOM_SMEM_STATE) += smem_state.o obj-$(CONFIG_QCOM_SMP2P) += smp2p.o obj-$(CONFIG_QCOM_SMSM) += smsm.o diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c index f80d040601fd..efe0b053ef82 100644 --- a/drivers/soc/qcom/smem.c +++ b/drivers/soc/qcom/smem.c @@ -276,6 +276,7 @@ struct qcom_smem { struct smem_partition_header *partitions[SMEM_HOST_COUNT]; size_t cacheline[SMEM_HOST_COUNT]; u32 item_count; + struct platform_device *socinfo; unsigned num_regions; struct smem_region regions[]; @@ -971,11 +972,18 @@ static int qcom_smem_probe(struct platform_device *pdev) __smem = smem; + smem->socinfo = platform_device_register_data(&pdev->dev, "qcom-socinfo", + PLATFORM_DEVID_NONE, NULL, + 0); + if (IS_ERR(smem->socinfo)) + dev_err(&pdev->dev, "failed to register socinfo device\n"); + return 0; } static int qcom_smem_remove(struct platform_device *pdev) { + hwspin_lock_free(__smem->hwlock); __smem = NULL; diff --git a/drivers/soc/qcom/socinfo.c b/drivers/soc/qcom/socinfo.c new file mode 100644 index 000000000000..02078049fac7 --- /dev/null +++ b/drivers/soc/qcom/socinfo.c @@ -0,0 +1,197 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2009-2017, The Linux Foundation. All rights reserved. + * Copyright (c) 2017-2019, Linaro Ltd. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * SoC version type with major number in the upper 16 bits and minor + * number in the lower 16 bits. + */ +#define SOCINFO_MAJOR(ver) (((ver) >> 16) & 0xffff) +#define SOCINFO_MINOR(ver) ((ver) & 0xffff) + +#define SMEM_SOCINFO_BUILD_ID_LENGTH 32 + +/* + * SMEM item ids, used to acquire handles to respective + * SMEM region. + */ +#define SMEM_HW_SW_BUILD_ID 137 + +/* 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; +}; + +struct qcom_socinfo { + struct soc_device *soc_dev; + struct soc_device_attribute attr; +}; + +struct soc_of_id { + unsigned int id; + const char *name; +}; + +static const struct soc_of_id soc_of_id[] = { + {87, "MSM8960"}, + {109, "APQ8064"}, + {122, "MSM8660A"}, + {123, "MSM8260A"}, + {124, "APQ8060A"}, + {126, "MSM8974"}, + {130, "MPQ8064"}, + {138, "MSM8960AB"}, + {139, "APQ8060AB"}, + {140, "MSM8260AB"}, + {141, "MSM8660AB"}, + {178, "APQ8084"}, + {184, "APQ8074"}, + {185, "MSM8274"}, + {186, "MSM8674"}, + {194, "MSM8974PRO"}, + {206, "MSM8916"}, + {208, "APQ8074-AA"}, + {209, "APQ8074-AB"}, + {210, "APQ8074PRO"}, + {211, "MSM8274-AA"}, + {212, "MSM8274-AB"}, + {213, "MSM8274PRO"}, + {214, "MSM8674-AA"}, + {215, "MSM8674-AB"}, + {216, "MSM8674PRO"}, + {217, "MSM8974-AA"}, + {218, "MSM8974-AB"}, + {246, "MSM8996"}, + {247, "APQ8016"}, + {248, "MSM8216"}, + {249, "MSM8116"}, + {250, "MSM8616"}, + {291, "APQ8096"}, + {305, "MSM8996SG"}, + {310, "MSM8996AU"}, + {311, "APQ8096AU"}, + {312, "APQ8096SG"}, +}; + +static const char *socinfo_machine(struct device *dev, unsigned int id) +{ + int idx; + + for (idx = 0; idx < ARRAY_SIZE(soc_of_id); idx++) { + if (soc_of_id[idx].id == id) + return soc_of_id[idx].name; + } + + if (IS_ERR(soc_of_id[idx].name)) + dev_err(dev, "Unknown soc id\n"); + + return NULL; +} + +static int qcom_socinfo_probe(struct platform_device *pdev) +{ + struct qcom_socinfo *qs; + struct socinfo *info; + size_t item_size; + + info = qcom_smem_get(QCOM_SMEM_HOST_ANY, SMEM_HW_SW_BUILD_ID, + &item_size); + if (IS_ERR(info)) { + dev_err(&pdev->dev, "Couldn't find socinfo\n"); + return -EINVAL; + } + + qs = devm_kzalloc(&pdev->dev, sizeof(*qs), GFP_KERNEL); + if (!qs) + return -ENOMEM; + + qs->attr.family = "Snapdragon"; + qs->attr.machine = socinfo_machine(&pdev->dev, + le32_to_cpu(info->id)); + qs->attr.revision = devm_kasprintf(&pdev->dev, GFP_KERNEL, "%u.%u", + SOCINFO_MAJOR(le32_to_cpu(info->ver)), + SOCINFO_MINOR(le32_to_cpu(info->ver))); + if (le32_to_cpu(info->fmt) >= 10) + qs->attr.serial_number = devm_kasprintf(&pdev->dev, GFP_KERNEL, + "%u", + le32_to_cpu(info->serial_num)); + + qs->soc_dev = soc_device_register(&qs->attr); + if (IS_ERR(qs->soc_dev)) + return PTR_ERR(qs->soc_dev); + + /* Feed the soc specific unique data into entropy pool */ + add_device_randomness(info, item_size); + + platform_set_drvdata(pdev, qs->soc_dev); + + return 0; +} + +static int qcom_socinfo_remove(struct platform_device *pdev) +{ + struct qcom_socinfo *qs = platform_get_drvdata(pdev); + + soc_device_unregister(qs->soc_dev); + + return 0; +} + +static struct platform_driver qcom_socinfo_driver = { + .probe = qcom_socinfo_probe, + .remove = qcom_socinfo_remove, + .driver = { + .name = "qcom-socinfo", + }, +}; + +module_platform_driver(qcom_socinfo_driver); + +MODULE_DESCRIPTION("Qualcomm socinfo driver"); +MODULE_LICENSE("GPL v2"); +MODULE_ALIAS("platform:qcom-socinfo"); From patchwork Thu Feb 14 03:41:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaishali Thakkar X-Patchwork-Id: 158302 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp860396jaa; Wed, 13 Feb 2019 19:42:02 -0800 (PST) X-Google-Smtp-Source: AHgI3Ib8nCdXu3wZpU4emBg9bsMn3UU8zcfnRGpAo6tjwkrhnUDf21QsXW8iVQ76rHJ4oVyLT7nr X-Received: by 2002:a63:ce50:: with SMTP id r16mr1629807pgi.217.1550115722413; Wed, 13 Feb 2019 19:42:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550115722; cv=none; d=google.com; s=arc-20160816; b=TFwxbSuDla+BZpgRV7o4KJZOrOrZAc1idZS311JZ+7sXTCd1bp7msQFiq55PoGax/p jvcN2b/a+QngHvLuQHHWuRC16N1gLr4l1FDLjZHJAvTgEpdIPm2+VJqVKpwi6dtbSSvW xUTnIF0bv1WK0a4ZFK6ZT8wl2ex5us5L8zOzKUQuB8a4+Av0nGlaEHcZFpi3Yu8fUlE0 e/7UCmk+zudBSYPNDu5s6u0kuHDUd0v/3/EGZZjMWwXHHiXnPN4Izn8qmxe6l1pwN3cO 1gbKUvf3F6MLwCwv6xeMuoroX8qu/x4WGbOkCUBs//7/pmzx751YVak3v69gtmwhs96/ 3x3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=a2V1jnvFMgLl6Lz0njStHM5JTJuI4W2yZndCgLSfHUE=; b=jMaqwThbpNquanbad0RuneyQYAqErG5j2ZICDwcTUCG/oGRDFZOkBB6OpOqlA1a2im 3SejsoNdIZbbu1Ri2LDDL5wQqwpm0QdrGkoDQP+uU03ycgeaWBmVDT5HnH+YdKKKKdw3 zBPm8bjvyw2PT4Z4+FrnnPAWK39cBxzAkG2QsTME3pzPunqpRlOldTjCvk3ew9x1cCcx YTsMrmjqBz3UIy+YqXw3UB6dykUpQmuXlIth7l51AOCl0svCrpr+V38gc+MNJ0sunnX7 qXp7t9Cygs7YOmB26W8uQX4ps5sqbDnKbMffXiJTfiSvG3FdZ77ARhuRYOW5pWTBEP4F IUrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="fMK4Kcn/"; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x11si1264438plv.76.2019.02.13.19.42.02; Wed, 13 Feb 2019 19:42:02 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="fMK4Kcn/"; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2395398AbfBNDmB (ORCPT + 15 others); Wed, 13 Feb 2019 22:42:01 -0500 Received: from mail-pg1-f195.google.com ([209.85.215.195]:42039 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2395309AbfBNDmB (ORCPT ); Wed, 13 Feb 2019 22:42:01 -0500 Received: by mail-pg1-f195.google.com with SMTP id d72so2287575pga.9 for ; Wed, 13 Feb 2019 19:42:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=a2V1jnvFMgLl6Lz0njStHM5JTJuI4W2yZndCgLSfHUE=; b=fMK4Kcn/qHfGkrG8QXl4FzsuMVKShlnPABuApQXOfdESFDx9bWllRRGOiBJowuOOp6 8Bx4+oWS2Odho8l7Uy0iLjom+OG3tN+TeO4jMY+Fk0OQmlLCYGRrMW3da/I0DtVjKh1W lYcYb5j3sFIn5KyR38mYue20Olt/l8L5eDd4dYueUw0nrK8OpZazfai4whUefiO/vxMr LzD4BULzQnyld4sbtzecgIL/3vpHBhofVtSIRsk/5alYK3e845ApJ+PPKXUazmko3sXW 22N3EMZmvoBvpWSTJUQEG4H6CHsYGzSo1CdxoBQrrR5GIA4t42OHVVb0FS34FMcRGYD8 Si2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=a2V1jnvFMgLl6Lz0njStHM5JTJuI4W2yZndCgLSfHUE=; b=LvfRC9tEQg/zH7gaJKJNIg3Q57D0nF+zrGja79H1vLyEuU8uxR9tP08AW/EYaPguYf 4+2ikH+v0EQTwBjWUj2tULL6CrAHS93af1chsm/FD5zPZl8VU2tuqdG2WFEs93ClB4le VvVleMwTrItQsEDkcrjMBuiJZ8+hJkETy30JckQ33uUxrSpycNiKBtvbz68bsfRjekJx +cuDvgvS7fgbNS8W8qhz48Yi4uordKz1/dEqhhFYbO+DPW3HH72lcY+55kwBqB+XuTqx MeUQdl8VRHYACc3330aOS5+/UEG8qSTMoTdtDpsPQRVbsvAkbsH1ycXE1OKoGfaXgb+W 1cjw== X-Gm-Message-State: AHQUAubI3b5rZfzn9x1pWexwatvpdw9x1STTm5sAmGzEXI6TtLFAov2Y Ht6nMW2de45FJNmx74JLOg6Kuw== X-Received: by 2002:a63:d84b:: with SMTP id k11mr1720024pgj.142.1550115720382; Wed, 13 Feb 2019 19:42:00 -0800 (PST) Received: from localhost.localdomain ([103.240.171.178]) by smtp.gmail.com with ESMTPSA id k129sm928179pgk.29.2019.02.13.19.41.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Feb 2019 19:41:59 -0800 (PST) From: Vaishali Thakkar To: andy.gross@linaro.org Cc: david.brown@linaro.org, gregkh@linuxfoundation.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, rafael@kernel.org, bjorn.andersson@linaro.org, vkoul@kernel.org, Vaishali Thakkar Subject: [PATCH 3/5] soc: qcom: socinfo: Expose custom attributes Date: Thu, 14 Feb 2019 09:11:49 +0530 Message-Id: <297ee5e7840077f0330d4ae02dcd13c2ad97f910.1550114271.git.vaishali.thakkar@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org The Qualcomm socinfo provides a number of additional attributes, add these to the socinfo driver and expose them via debugfs functionality. Signed-off-by: Vaishali Thakkar --- Note that this may have some 80 char checkpatch warnings as fixing them makes code less readable. --- drivers/soc/qcom/socinfo.c | 203 +++++++++++++++++++++++++++++++++++++ 1 file changed, 203 insertions(+) -- 2.17.1 diff --git a/drivers/soc/qcom/socinfo.c b/drivers/soc/qcom/socinfo.c index 02078049fac7..58665067beb8 100644 --- a/drivers/soc/qcom/socinfo.c +++ b/drivers/soc/qcom/socinfo.c @@ -4,6 +4,7 @@ * Copyright (c) 2017-2019, Linaro Ltd. */ +#include #include #include #include @@ -29,6 +30,28 @@ */ #define SMEM_HW_SW_BUILD_ID 137 +#ifdef CONFIG_DEBUG_FS +/* pmic model info */ +static const char *const pmic_model[] = { + [0] = "Unknown PMIC model", + [9] = "PM8994", + [11] = "PM8916", + [13] = "PM8058", + [14] = "PM8028", + [15] = "PM8901", + [16] = "PM8027", + [17] = "ISL9519", + [18] = "PM8921", + [19] = "PM8018", + [20] = "PM8015", + [21] = "PM8014", + [22] = "PM8821", + [23] = "PM8038", + [24] = "PM8922", + [25] = "PM8917", +}; +#endif /* CONFIG_DEBUG_FS */ + /* Socinfo SMEM item structure */ struct socinfo { __le32 fmt; @@ -70,6 +93,10 @@ struct socinfo { struct qcom_socinfo { struct soc_device *soc_dev; struct soc_device_attribute attr; + #ifdef CONFIG_DEBUG_FS + struct dentry *dbg_root; + #endif /* CONFIG_DEBUG_FS */ + struct socinfo *socinfo; }; struct soc_of_id { @@ -133,6 +160,176 @@ static const char *socinfo_machine(struct device *dev, unsigned int id) return NULL; } +#ifdef CONFIG_DEBUG_FS + +#define UINT_SHOW(name, attr) \ +static int qcom_show_##name(struct seq_file *seq, void *p) \ +{ \ + struct socinfo *socinfo = seq->private; \ + seq_printf(seq, "%u\n", le32_to_cpu(socinfo->attr)); \ + return 0; \ +} \ +static int qcom_open_##name(struct inode *inode, struct file *file) \ +{ \ + return single_open(file, qcom_show_##name, inode->i_private); \ +} \ + \ +static const struct file_operations qcom_ ##name## _ops = { \ + .open = qcom_open_##name, \ + .read = seq_read, \ + .llseek = seq_lseek, \ + .release = single_release, \ +} + +#define DEBUGFS_UINT_ADD(name) \ + debugfs_create_file(__stringify(name), 0400, \ + qcom_socinfo->dbg_root, \ + qcom_socinfo->socinfo, &qcom_ ##name## _ops) + +#define HEX_SHOW(name, attr) \ +static int qcom_show_##name(struct seq_file *seq, void *p) \ +{ \ + struct socinfo *socinfo = seq->private; \ + seq_printf(seq, "0x%x\n", le32_to_cpu(socinfo->attr)); \ + return 0; \ +} \ +static int qcom_open_##name(struct inode *inode, struct file *file) \ +{ \ + return single_open(file, qcom_show_##name, inode->i_private); \ +} \ + \ +static const struct file_operations qcom_ ##name## _ops = { \ + .open = qcom_open_##name, \ + .read = seq_read, \ + .llseek = seq_lseek, \ + .release = single_release, \ +} + +#define DEBUGFS_HEX_ADD(name) \ + debugfs_create_file(__stringify(name), 0400, \ + qcom_socinfo->dbg_root, \ + qcom_socinfo->socinfo, &qcom_ ##name## _ops) + + +#define QCOM_OPEN(name, _func) \ +static int qcom_open_##name(struct inode *inode, struct file *file) \ +{ \ + return single_open(file, _func, inode->i_private); \ +} \ + \ +static const struct file_operations qcom_ ##name## _ops = { \ + .open = qcom_open_##name, \ + .read = seq_read, \ + .llseek = seq_lseek, \ + .release = single_release, \ +} + +#define DEBUGFS_ADD(name) \ + debugfs_create_file(__stringify(name), 0400, \ + qcom_socinfo->dbg_root, \ + qcom_socinfo->socinfo, &qcom_ ##name## _ops) + + +static int qcom_show_build_id(struct seq_file *seq, void *p) +{ + struct socinfo *socinfo = seq->private; + + seq_printf(seq, "%s\n", socinfo->build_id); + + return 0; +} + +static int qcom_show_accessory_chip(struct seq_file *seq, void *p) +{ + struct socinfo *socinfo = seq->private; + + seq_printf(seq, "%d\n", le32_to_cpu(socinfo->accessory_chip)); + + return 0; +} + +static int qcom_show_platform_subtype(struct seq_file *seq, void *p) +{ + struct socinfo *socinfo = seq->private; + int subtype = le32_to_cpu(socinfo->hw_plat_subtype); + + if (subtype < 0) + return -EINVAL; + + seq_printf(seq, "%u\n", subtype); + + return 0; +} + +static int qcom_show_pmic_model(struct seq_file *seq, void *p) +{ + struct socinfo *socinfo = seq->private; + int model = SOCINFO_MINOR(le32_to_cpu(socinfo->pmic_model)); + + if (model < 0) + return -EINVAL; + + seq_printf(seq, "%s\n", pmic_model[model]); + + return 0; +} + +static int qcom_show_pmic_die_revision(struct seq_file *seq, void *p) +{ + struct socinfo *socinfo = seq->private; + + seq_printf(seq, "%u.%u\n", + SOCINFO_MAJOR(le32_to_cpu(socinfo->pmic_die_rev)), + SOCINFO_MINOR(le32_to_cpu(socinfo->pmic_die_rev))); + + return 0; +} + +UINT_SHOW(raw_version, raw_ver); +UINT_SHOW(hardware_platform, hw_plat); +UINT_SHOW(platform_version, plat_ver); +UINT_SHOW(foundry_id, foundry_id); +HEX_SHOW(chip_family, chip_family); +HEX_SHOW(raw_device_family, raw_device_family); +HEX_SHOW(raw_device_number, raw_device_num); +QCOM_OPEN(build_id, qcom_show_build_id); +QCOM_OPEN(accessory_chip, qcom_show_accessory_chip); +QCOM_OPEN(pmic_model, qcom_show_pmic_model); +QCOM_OPEN(platform_subtype, qcom_show_platform_subtype); +QCOM_OPEN(pmic_die_revision, qcom_show_pmic_die_revision); + +static void socinfo_debugfs_init(struct qcom_socinfo *qcom_socinfo) +{ + qcom_socinfo->dbg_root = debugfs_create_dir("qcom_socinfo", NULL); + + if (!qcom_socinfo->dbg_root) { + pr_err("Cannot create debugfs directory\n"); + return; + } + + DEBUGFS_UINT_ADD(raw_version); + DEBUGFS_UINT_ADD(hardware_platform); + DEBUGFS_UINT_ADD(platform_version); + DEBUGFS_UINT_ADD(foundry_id); + DEBUGFS_HEX_ADD(chip_family); + DEBUGFS_HEX_ADD(raw_device_family); + DEBUGFS_HEX_ADD(raw_device_number); + DEBUGFS_ADD(build_id); + DEBUGFS_ADD(accessory_chip); + DEBUGFS_ADD(pmic_model); + DEBUGFS_ADD(platform_subtype); + DEBUGFS_ADD(pmic_die_revision); +} + +static void socinfo_debugfs_exit(struct qcom_socinfo *qcom_socinfo) +{ + debugfs_remove_recursive(qcom_socinfo->dbg_root); +} +#else +socinfo_debugfs_init(struct qcom_socinfo *qcom_socinfo) { return 0; } +socinfo_debugfs_exit(struct qcom_socinfo *qcom_socinfo) { return 0; } +#endif /* CONFIG_DEBUG_FS */ + static int qcom_socinfo_probe(struct platform_device *pdev) { struct qcom_socinfo *qs; @@ -165,6 +362,10 @@ static int qcom_socinfo_probe(struct platform_device *pdev) if (IS_ERR(qs->soc_dev)) return PTR_ERR(qs->soc_dev); + qs->socinfo = info; + + socinfo_debugfs_init(qs); + /* Feed the soc specific unique data into entropy pool */ add_device_randomness(info, item_size); @@ -179,6 +380,8 @@ static int qcom_socinfo_remove(struct platform_device *pdev) soc_device_unregister(qs->soc_dev); + socinfo_debugfs_exit(qs); + return 0; }