From patchwork Tue Jul 23 22:35:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaishali Thakkar X-Patchwork-Id: 169578 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp9425525ilk; Tue, 23 Jul 2019 15:35:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqzvHf9kJH/v1p2IWGcjYZlbyP7t5WUUY0pK/93ssFr9N8jrofDNdcaGEsRjZFBxrq382Th/ X-Received: by 2002:a17:90a:1ae2:: with SMTP id p89mr79962857pjp.26.1563921328722; Tue, 23 Jul 2019 15:35:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563921328; cv=none; d=google.com; s=arc-20160816; b=NfJV+WakEtBrfOwXEdgbaOaRO31zrY0sAw2mVy3t+pA47pDQj8fG56eYWIpq9uzSd9 ZKwk7Bqw3QH7nnO6fGPt+mvlbsR8MldJ8M+A0fPdVbZl/tj7aoZ1H/C1/1ZNmxZTX4BS LwXaSJBUIpD72kOIO7a0ji8heAl//M8OWc0wSSjTz2Apwk91uqN/YquhxbEI1BPZ4X4U F+E4RH8kNVxCVgDoyjn8144gqjfJUz90faYek5Xkqn7t8ija+RtC8EIww0OfQDz11hr/ OjE4lswKboJd+iD1V8hJbbn31OwSz9ORid64bRzuTW08bAGrDxClQ+zzeEg49fQIn21T Ggmg== 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=x0riv3qXFNUHW9aogl2u0KORFwMPTEBgnFJrb7TrTKo=; b=0bbrfo4NK+Q5sqy4xhpd7XCo543HuhFbpJN+EO7nE2J/hw6h4G7fSi5zLTguOQDFer JUDkyMy/x93dNZjVpf+lOeVvVqrL/NyDE54iGIRs8R7MsoOc+fyNLK6qta5FajyjDxXE viViOJaJwyeKHiOZ6AnkYz22ywQEUYrbuvcDKcLUNbfKNMJiPb+WmsyZjyVq4qIAO/de yNatOOTMYOCahg6YmZodB3h9aRBLxnVld87zd9TVBMqVuKJndjMj5Vmeq+aWNRj83gK9 prwRVeGzEoUVgQPJ9K2wd5cTJHIJ7pV5tUTHVKC2psgg2v7A8u4FQc2QvZtsumV34SRi BMlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NdUtwPTD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 o3si10163863plb.238.2019.07.23.15.35.28; Tue, 23 Jul 2019 15:35:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=NdUtwPTD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 S2389557AbfGWWf1 (ORCPT + 29 others); Tue, 23 Jul 2019 18:35:27 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:36135 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389434AbfGWWf0 (ORCPT ); Tue, 23 Jul 2019 18:35:26 -0400 Received: by mail-pf1-f194.google.com with SMTP id r7so19846643pfl.3 for ; Tue, 23 Jul 2019 15:35:26 -0700 (PDT) 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=x0riv3qXFNUHW9aogl2u0KORFwMPTEBgnFJrb7TrTKo=; b=NdUtwPTDmyF+MRh1jbsokxVgxD6AafcT12ED5L6Y9I5m2QfLdOnwiR6uwiYtOV9tk0 h6VY892u4JoMBt9AMQKwRr3HNCU5gkqEMiFHV7K7lGmwXCVIOMPwP+eNArEltUq4Htwk hZS5Zxmjtgtn/s7/3OKCx94HAQCliNP+XIaOEFOLyGWmeqk9aYexZPS0KUaFd0cAlQJQ SDEKqRKPo4kEiGUAXM+TRKI3qSZr/0FLyRhUmimH4ErvW+ecrpeSW7bbOQVlwkym9WLT e1rMnmwknhLBjz5GK9JBdbitBQZl7iFX0SPhBn3UI9mUaXPGBhAsUr5bmwvdaKhKiHrq odSQ== 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=x0riv3qXFNUHW9aogl2u0KORFwMPTEBgnFJrb7TrTKo=; b=QuPfRxxtX0kKDV3ZGwIV2ox4fQdz3fURrtQQq3KW9Mqj+nyKpaGg24tT8l6c0ZqPOc c0X7MrXD22vexJaBfSBFGsQGcq8smAh+YHfbDBtfjZl7yl2cu6eygJIi6SYeFgDnLwZg 2skZZVEK3PovOs/h1rP7C1SkbVw9jIutQWThgtr/2M5GMhJvBP2eEehgb2J63lBFz1Kp v9/mBq6hiboKE3bCMR7xC1m6S7VfhHth1f4JiG0vOpm5htG2g4mJOBD2YzhfBlXlTffr ULxagvxF7+lPCI1/15STPvhDxUTWQfj0V6lZunHSkmxMqjMwXMUygnJ/vMOCRb6MCkDa Lphg== X-Gm-Message-State: APjAAAW0KrrA4L7288RFOrNOGUWm/aiVY6yn9lQP6lYEH7Mo61ccKAc6 kvtU+kJljycoH/yVvYBNrBjWbw== X-Received: by 2002:aa7:9481:: with SMTP id z1mr8048059pfk.92.1563921326084; Tue, 23 Jul 2019 15:35:26 -0700 (PDT) Received: from localhost.localdomain ([115.99.187.56]) by smtp.gmail.com with ESMTPSA id h16sm49036917pfo.34.2019.07.23.15.35.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Jul 2019 15:35:25 -0700 (PDT) From: Vaishali Thakkar To: agross@kernel.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 v6 1/5] base: soc: Add serial_number attribute to soc Date: Wed, 24 Jul 2019 04:05:11 +0530 Message-Id: <20190723223515.27839-2-vaishali.thakkar@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190723223515.27839-1-vaishali.thakkar@linaro.org> References: <20190723223515.27839-1-vaishali.thakkar@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 Reviewed-by: Greg Kroah-Hartman Reviewed-by: Stephen Boyd --- Changes since v5: - No code changes, fix diff.context setting for formatting patches. Version 5 was adding context at the bottom of the file with 'git am'. Changes since v4: - Add Stephen's reviewed-by Changes since v3: - Add Greg's Reviewed-by Changes since v2: - None Changes since v1: - Make comment more clear for the case when serial number is not available --- 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..ba3a3fac0ee1 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, if available. + 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 b7c70c3e953f..48ceea867dd6 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 Tue Jul 23 22:35:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaishali Thakkar X-Patchwork-Id: 169581 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp9425746ilk; Tue, 23 Jul 2019 15:35:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqxkN85T6q9exrKuK0jIIZcTfWDDmDRRHl8eN9p3xVCxWp6hs8XNn20iA0gZGOHMoPKHBprW X-Received: by 2002:a17:902:aa95:: with SMTP id d21mr79344128plr.185.1563921344001; Tue, 23 Jul 2019 15:35:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563921343; cv=none; d=google.com; s=arc-20160816; b=Onct5V+AB/VVWqNEKB53WTtnuciLOwBQHHH2rJbpnolqfTw4Zb4VphSNFkW289gVx+ RBHiXG7AUKsg1amE5QiJW7ITed2duPN5ItYNSKSNjThpx4gUDq/mNkQCDz3fO4S6FBsa /SmzIzmx49ErlnAMGGfQaib9ZYbqx576r2qmRpGDik7uczuG+QU4ASkbEn19JI8ZFfgm fB/LKIOqj2NZDWloGYHtmJEez+MaEAWfHThZjkK9UU0tqGBUpTP0e88nbChwk+Om23P9 nvmG8pwrinc/mYE8TBu8n8vrDvU72uztVsroLK+6F+Pu3FcPGsKSrT8fmivdbgcJkWgm symA== 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=Kzw48hnOfa4vVn93dbjkEVKUi4wwL3FJuUWFXLCPa8A=; b=ZbTrJ+Riy5SiuJjU4CejzcB2CCaYKsyrUN/kffIqwzDSJvjGiyq3TcPO7nwNjXjL+U /+CltkMedZ5Ri7b5VhUjSIKkmXmFVhaml62Y6EnbkHdtmmkBVvj/2T55Wj8QlHKcCR4d DMXbo/OwfADx7cSbFvuRpECV6s7T+SAMGoisOUt4twT1X50XW5SNJlVD8FsvVoweJjAt TKBToePOWdy64YGObK14TW+nR6YOGLEkgl4rZw6NDsX1q9CX+aFry09zGgJdM+7bADRn kfA1d4Byj5LYiBTKNSWM8Yg3fy3KICTf7cs9n9hADgd1KV1FCiAvi7i50hBa5Gai8w76 UPOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NdUIvuir; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 i15si15353350pfd.259.2019.07.23.15.35.43; Tue, 23 Jul 2019 15:35:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=NdUIvuir; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 S2389618AbfGWWfm (ORCPT + 29 others); Tue, 23 Jul 2019 18:35:42 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:32966 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389591AbfGWWfi (ORCPT ); Tue, 23 Jul 2019 18:35:38 -0400 Received: by mail-pl1-f195.google.com with SMTP id c14so21098290plo.0 for ; Tue, 23 Jul 2019 15:35:37 -0700 (PDT) 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=Kzw48hnOfa4vVn93dbjkEVKUi4wwL3FJuUWFXLCPa8A=; b=NdUIvuirRhD58ngXrSIrWrkjefkELDeGHP+b3/enXWKITirUydYKichVsx7dQwRj7S 1gNBk/uDGnT9SIxTy796d716WNcwK/Q5YPh9+s9VDJFDpzfHHT44uTnF4yHOYMSXncEu RafpbLy69mNPKc0BxV99z7ZyfwFwcBOHSOFavEtKG6nEcXntMNiiSmn5aLVmUqGOrb8k /AufNT3eGMUCEyv77c3YmV8z5M7YA23FeTgmnEkPz0yWP3IJtAOpDMhqG0fjeGyIWWpT Kp182rzy7KOrifvQNtuRy7I58OnTs2SxfDGAMBj0BN2IdPlwQeiRWghEc6kVdbMcQzEK sQ0A== 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=Kzw48hnOfa4vVn93dbjkEVKUi4wwL3FJuUWFXLCPa8A=; b=MfzIK1btOr5vRUW8+wuNCQHg+RFzjqhJSJP5Xbjd1ojVAC82I9Fuay4xYUnc5tqrui fqSc/pZY3puPY2eszeW0JRcHqnN9R1t4Zlhx/1caq1l0wlBKBc8Bpg1fTw7dpHd5b2PF 5DCPYIZ89ggpaxKvbmz1aqDCHw+XrjTeb4n1jQhGjEqhzGULXAgUtpYpBFU+viITzPin TW51lKqzSKNLvnlRblttm0dcYK9aQrw+TDNYhwEAZJeE0znBrUuRaMfWgOkx164sUCr2 pHwHeXk3y4bi53EySH79M2Jxh50FVGQ+7tRQCrENI1BC8Tzmel9yBT8+jco9npgD0zpm Qo4Q== X-Gm-Message-State: APjAAAVcCA/0uwAtrpIi4U8jEIhqwV48++yBzEa0EtH+cntq+NmHrIFu RLXIH4QbTKAjm0COcld7xcZkuA== X-Received: by 2002:a17:902:549:: with SMTP id 67mr82351914plf.86.1563921337409; Tue, 23 Jul 2019 15:35:37 -0700 (PDT) Received: from localhost.localdomain ([115.99.187.56]) by smtp.gmail.com with ESMTPSA id h16sm49036917pfo.34.2019.07.23.15.35.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Jul 2019 15:35:37 -0700 (PDT) From: Vaishali Thakkar To: agross@kernel.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 v6 4/5] soc: qcom: socinfo: Expose custom attributes Date: Wed, 24 Jul 2019 04:05:14 +0530 Message-Id: <20190723223515.27839-5-vaishali.thakkar@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190723223515.27839-1-vaishali.thakkar@linaro.org> References: <20190723223515.27839-1-vaishali.thakkar@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 --- Changes since v5: - No code changes, fix my diff.context setting for formatting patches. Version 5 was adding context at the bottom of the file with 'git am'. Changes since v4: - Introduce socinfo_params and use create_debugfs_{u32,x32} instead of driver specific macros - Remove some unnecessary separate functions [qcom_show_{platform_subtype,accessory_chip}] and use debugfs core functions to expose their values - Use switch to expose custom attributes based on the firmware version - Misc: Drop unnecessory comments, pmic_model->pmic_models, don't pass socinfo pointer in qcom_socinfo - Note: I didn't introduce any new debugfs core functions for printing string values because it wasn't possible to cover both cases of string arrays in this file - pmic_model and build_id by introducing a single function. Morever, I still needed QCOM_OPEN and DEBUGFS_ADD to cover the case of pmic_die_rev so introducing the 'debugfs create string array function' wasn't completely eliminating extra macro code. So, I'm just using the above mentioned macros to print string array values for now. Feel free to on this matter. Thanks! Changes since v3: - Fix compilation error in function signatures when debugfs is disabled Changes since v2: - None Changes since v1: - Remove unnecessary debugfs dir creation check - Align ifdefs to left - Fix function signatures for debugfs init/exit --- drivers/soc/qcom/socinfo.c | 190 +++++++++++++++++++++++++++++++++++++ 1 file changed, 190 insertions(+) -- 2.17.1 diff --git a/drivers/soc/qcom/socinfo.c b/drivers/soc/qcom/socinfo.c index 1b9eb44df7fe..6a4795433d57 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 @@ -20,6 +21,7 @@ */ #define SOCINFO_MAJOR(ver) (((ver) >> 16) & 0xffff) #define SOCINFO_MINOR(ver) ((ver) & 0xffff) +#define SOCINFO_VERSION(maj, min) ((((maj) & 0xffff) << 16)|((min) & 0xffff)) #define SMEM_SOCINFO_BUILD_ID_LENGTH 32 @@ -29,6 +31,27 @@ */ #define SMEM_HW_SW_BUILD_ID 137 +#ifdef CONFIG_DEBUG_FS +static const char *const pmic_models[] = { + [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; @@ -67,9 +90,28 @@ struct socinfo { __le32 raw_device_num; }; +#ifdef CONFIG_DEBUG_FS +struct socinfo_params { + u32 raw_device_family; + u32 hw_plat_subtype; + u32 accessory_chip; + u32 raw_device_num; + u32 chip_family; + u32 foundry_id; + u32 plat_ver; + u32 raw_ver; + u32 hw_plat; + u32 fmt; +}; +#endif /* CONFIG_DEBUG_FS */ + struct qcom_socinfo { struct soc_device *soc_dev; struct soc_device_attribute attr; +#ifdef CONFIG_DEBUG_FS + struct dentry *dbg_root; + struct socinfo_params info; +#endif /* CONFIG_DEBUG_FS */ }; struct soc_id { @@ -130,6 +172,150 @@ static const char *socinfo_machine(struct device *dev, unsigned int id) return NULL; } +#ifdef CONFIG_DEBUG_FS + +#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(info, name) \ + debugfs_create_file(__stringify(name), 0400, \ + qcom_socinfo->dbg_root, \ + info, &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_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_models[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; +} + +QCOM_OPEN(build_id, qcom_show_build_id); +QCOM_OPEN(pmic_model, qcom_show_pmic_model); +QCOM_OPEN(pmic_die_rev, qcom_show_pmic_die_revision); + +static void socinfo_debugfs_init(struct qcom_socinfo *qcom_socinfo, + struct socinfo *info) +{ + size_t size; + + qcom_socinfo->dbg_root = debugfs_create_dir("qcom_socinfo", NULL); + + qcom_socinfo->info.fmt = __le32_to_cpu(info->fmt); + + switch (qcom_socinfo->info.fmt) { + case SOCINFO_VERSION(0, 12): + qcom_socinfo->info.chip_family = + __le32_to_cpu(info->chip_family); + qcom_socinfo->info.raw_device_family = + __le32_to_cpu(info->raw_device_family); + qcom_socinfo->info.raw_device_num = + __le32_to_cpu(info->raw_device_num); + + debugfs_create_x32("chip_family", 0400, qcom_socinfo->dbg_root, + &qcom_socinfo->info.chip_family); + debugfs_create_x32("raw_device_family", 0400, + qcom_socinfo->dbg_root, + &qcom_socinfo->info.raw_device_family); + debugfs_create_x32("raw_device_number", 0400, + qcom_socinfo->dbg_root, + &qcom_socinfo->info.raw_device_num); + case SOCINFO_VERSION(0, 11): + case SOCINFO_VERSION(0, 10): + case SOCINFO_VERSION(0, 9): + qcom_socinfo->info.foundry_id = __le32_to_cpu(info->foundry_id); + + debugfs_create_u32("foundry_id", 0400, qcom_socinfo->dbg_root, + &qcom_socinfo->info.foundry_id); + case SOCINFO_VERSION(0, 8): + case SOCINFO_VERSION(0, 7): + DEBUGFS_ADD(info, pmic_model); + DEBUGFS_ADD(info, pmic_die_rev); + case SOCINFO_VERSION(0, 6): + qcom_socinfo->info.hw_plat_subtype = + __le32_to_cpu(info->hw_plat_subtype); + + debugfs_create_u32("hardware_platform_subtype", 0400, + qcom_socinfo->dbg_root, + &qcom_socinfo->info.hw_plat_subtype); + case SOCINFO_VERSION(0, 5): + qcom_socinfo->info.accessory_chip = + __le32_to_cpu(info->accessory_chip); + + debugfs_create_u32("accessory_chip", 0400, + qcom_socinfo->dbg_root, + &qcom_socinfo->info.accessory_chip); + case SOCINFO_VERSION(0, 4): + qcom_socinfo->info.plat_ver = __le32_to_cpu(info->plat_ver); + + debugfs_create_u32("platform_version", 0400, + qcom_socinfo->dbg_root, + &qcom_socinfo->info.plat_ver); + case SOCINFO_VERSION(0, 3): + qcom_socinfo->info.hw_plat = __le32_to_cpu(info->hw_plat); + + debugfs_create_u32("hardware_platform", 0400, + qcom_socinfo->dbg_root, + &qcom_socinfo->info.hw_plat); + case SOCINFO_VERSION(0, 2): + qcom_socinfo->info.raw_ver = __le32_to_cpu(info->raw_ver); + + debugfs_create_u32("raw_version", 0400, qcom_socinfo->dbg_root, + &qcom_socinfo->info.raw_ver); + case SOCINFO_VERSION(0, 1): + DEBUGFS_ADD(info, build_id); + break; + } +} + +static void socinfo_debugfs_exit(struct qcom_socinfo *qcom_socinfo) +{ + debugfs_remove_recursive(qcom_socinfo->dbg_root); +} +#else +static void socinfo_debugfs_init(struct qcom_socinfo *qcom_socinfo, + struct socinfo *info) +{ +} +static void socinfo_debugfs_exit(struct qcom_socinfo *qcom_socinfo) { } +#endif /* CONFIG_DEBUG_FS */ + static int qcom_socinfo_probe(struct platform_device *pdev) { struct qcom_socinfo *qs; @@ -162,6 +348,8 @@ static int qcom_socinfo_probe(struct platform_device *pdev) if (IS_ERR(qs->soc_dev)) return PTR_ERR(qs->soc_dev); + socinfo_debugfs_init(qs, info); + /* Feed the soc specific unique data into entropy pool */ add_device_randomness(info, item_size); @@ -176,6 +364,8 @@ static int qcom_socinfo_remove(struct platform_device *pdev) soc_device_unregister(qs->soc_dev); + socinfo_debugfs_exit(qs); + return 0; }