summaryrefslogtreecommitdiff
path: root/arch/arm/mach-tegra/tegra_bb.c
diff options
context:
space:
mode:
authorAlexandre Berdery <aberdery@nvidia.com>2013-02-14 11:44:18 +0100
committerDan Willemsen <dwillemsen@nvidia.com>2013-09-14 13:00:36 -0700
commit137b2e30928291e9cad3709ef76bb9e4444e5bc1 (patch)
tree79e91ad572b0ce44991964d702912deea8c072ad /arch/arm/mach-tegra/tegra_bb.c
parenta1fbdb2bbc85a3a697bcd2a3ba05ea6e928661e9 (diff)
drivers:staging:nvshm: Add support for BBC serial number
If compatible SHM config version, BBC serial number (PCID) is populated in tegra_bb sysfs Bug 1226888 Change-Id: Ic2ee91547b0454ecbefac5aee580f247b1e081d4 Signed-off-by: Alexandre Berdery <aberdery@nvidia.com> Reviewed-on: http://git-master/r/200765 (cherry picked from commit 35f75aa0191e05d6c8d3b9dac8316e93bb877d8e) Reviewed-on: http://git-master/r/204573 Reviewed-by: Automatic_Commit_Validation_User Tested-by: Martin Chabot <mchabot@nvidia.com> Reviewed-by: Neil Patel <neilp@nvidia.com> Reviewed-by: Thomas Cherry <tcherry@nvidia.com>
Diffstat (limited to 'arch/arm/mach-tegra/tegra_bb.c')
-rw-r--r--arch/arm/mach-tegra/tegra_bb.c87
1 files changed, 87 insertions, 0 deletions
diff --git a/arch/arm/mach-tegra/tegra_bb.c b/arch/arm/mach-tegra/tegra_bb.c
index 268d2b66835a..019f1b823431 100644
--- a/arch/arm/mach-tegra/tegra_bb.c
+++ b/arch/arm/mach-tegra/tegra_bb.c
@@ -98,6 +98,7 @@ struct tegra_bb {
unsigned long priv_size;
unsigned long ipc_size;
unsigned long ipc_irq;
+ char ipc_serial[NVSHM_SERIAL_BYTE_SIZE];
unsigned int irq;
struct regulator *vdd_buck4;
struct regulator *vdd_ldo8;
@@ -576,6 +577,92 @@ static ssize_t show_tegra_bb_state(struct device *dev,
static DEVICE_ATTR(state, S_IRUSR | S_IRGRP, show_tegra_bb_state, NULL);
+static ssize_t show_tegra_bb_serial(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct tegra_bb *bb;
+ struct platform_device *pdev = container_of(dev,
+ struct platform_device,
+ dev);
+ struct tegra_bb_platform_data *pdata;
+ int idx, ret, total_len = 0;
+
+ if (!pdev) {
+ dev_err(dev, "%s platform device is NULL!\n", __func__);
+ return 0;
+ }
+
+ pdata = pdev->dev.platform_data;
+
+ if (!pdata) {
+ dev_err(&pdev->dev, "%s platform data not found!\n", __func__);
+ return 0;
+ }
+
+ bb = (struct tegra_bb *)pdata->bb_handle;
+
+ if (!bb) {
+ dev_err(&pdev->dev, "%s tegra_bb not found!\n", __func__);
+ return 0;
+ }
+
+ for (idx = 0; NVSHM_SERIAL_BYTE_SIZE > idx; ++idx) {
+ ret = sprintf(buf+2*idx, "%02X", bb->ipc_serial[idx]);
+ if (ret < 0) {
+ dev_err(&pdev->dev, "%s sprintf shm serial failure!\n",
+ __func__);
+ return 0;
+ }
+ total_len += ret;
+ }
+
+ buf[2*NVSHM_SERIAL_BYTE_SIZE] = '\n';
+ buf[2*NVSHM_SERIAL_BYTE_SIZE+1] = '\0';
+ total_len += 2;
+
+ return total_len;
+}
+
+static DEVICE_ATTR(serial, S_IRUSR | S_IRGRP, show_tegra_bb_serial, NULL);
+
+void tegra_bb_set_ipc_serial(struct platform_device *pdev, char *serial)
+{
+ struct tegra_bb *bb;
+ struct tegra_bb_platform_data *pdata;
+
+ if (!pdev) {
+ pr_err("%s platform device is NULL!\n", __func__);
+ return;
+ }
+
+ pdata = pdev->dev.platform_data;
+
+ if (!pdata) {
+ dev_err(&pdev->dev, "%s platform dev not found!\n", __func__);
+ return;
+ }
+
+ bb = (struct tegra_bb *)pdata->bb_handle;
+
+ if (!bb) {
+ dev_err(&pdev->dev, "%s tegra_bb not found!\n", __func__);
+ return;
+ }
+
+ if (serial == NULL) {
+ /* Remove sysfs entry */
+ device_remove_file(&pdev->dev, &dev_attr_serial);
+ return;
+ }
+
+ /* Create sysfs entry */
+ device_create_file(&pdev->dev, &dev_attr_serial);
+
+ /* Locally store serail number for future sysfs access */
+ memcpy(bb->ipc_serial, serial, sizeof(bb->ipc_serial));
+}
+EXPORT_SYMBOL_GPL(tegra_bb_set_ipc_serial);
+
#ifndef CONFIG_TEGRA_BASEBAND_SIMU
static irqreturn_t tegra_bb_isr_handler(int irq, void *data)
{