summaryrefslogtreecommitdiff
path: root/drivers/platform
diff options
context:
space:
mode:
authorNeil Gabriel <ngabriel@nvidia.com>2014-02-25 15:40:54 -0600
committerTerje Bergstrom <tbergstrom@nvidia.com>2014-03-04 01:08:16 -0800
commitc18e51d364467a1eae094bb1c896fb2623bffd3f (patch)
treec1037fdca11fac26baebea0144b50d09ac7dd31b /drivers/platform
parent398f8633bf11960b25ca05bdf0e7819c01e1a0d5 (diff)
Make the mselect timeout sysfs configurable.
Implement the necessary sysfs interfaces to expose the mselect timeout as device attribute with +rw permissions. Change-Id: I654823603d148cfee5d1f33d9373aebd7bafa474 Signed-off-by: Neil Gabriel <ngabriel@nvidia.com> Reviewed-on: http://git-master/r/374430 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: Marc Delvaux <mdelvaux@nvidia.com> Reviewed-by: Sobby Thakalath <sthakalath@nvidia.com> Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
Diffstat (limited to 'drivers/platform')
-rw-r--r--drivers/platform/tegra/hier_ictlr/Makefile1
-rw-r--r--drivers/platform/tegra/hier_ictlr/hier_ictlr.c34
-rw-r--r--drivers/platform/tegra/hier_ictlr/hier_ictlr.h35
-rw-r--r--drivers/platform/tegra/hier_ictlr/hier_ictlr_sysfs.c63
4 files changed, 126 insertions, 7 deletions
diff --git a/drivers/platform/tegra/hier_ictlr/Makefile b/drivers/platform/tegra/hier_ictlr/Makefile
index bfcbe36455c6..56e572684b67 100644
--- a/drivers/platform/tegra/hier_ictlr/Makefile
+++ b/drivers/platform/tegra/hier_ictlr/Makefile
@@ -5,4 +5,5 @@
subdir-ccflags-y = -Werror
obj-y += hier_ictlr.o
+obj-y += hier_ictlr_sysfs.o
diff --git a/drivers/platform/tegra/hier_ictlr/hier_ictlr.c b/drivers/platform/tegra/hier_ictlr/hier_ictlr.c
index 5e565d0aa090..077258071a10 100644
--- a/drivers/platform/tegra/hier_ictlr/hier_ictlr.c
+++ b/drivers/platform/tegra/hier_ictlr/hier_ictlr.c
@@ -21,6 +21,7 @@
#include <linux/platform_device.h>
#include <linux/err.h>
#include <linux/io.h>
+#include "hier_ictlr.h"
#define HIER_GROUP_CPU_ENABLE 0x00000000
#define HIER_GROUP_CPU_STATUS 0x00000004
@@ -38,12 +39,7 @@
#define MSELECT_TIMEOUT_TIMER_0 0x5c
#define MSELECT_ERROR_STATUS_0 0x60
-
-struct tegra_hier_ictlr {
- u32 irq;
- void __iomem *hier_ictlr_base;
- void __iomem *mselect_base;
-};
+#define MSELECT_DEFAULT_TIMEOUT 0xFFFFFF
static irqreturn_t tegra_hier_ictlr_irq_handler(int irq, void *data)
{
@@ -128,7 +124,7 @@ static int tegra_hier_ictlr_mselect_init(struct platform_device *pdev,
{
unsigned long reg;
- writel(0xFFFFFF, ictlr->mselect_base + MSELECT_TIMEOUT_TIMER_0);
+ tegra_hier_ictlr_set_mselect_timeout(ictlr, MSELECT_DEFAULT_TIMEOUT);
reg = readl(ictlr->mselect_base + MSELECT_CONFIG_0);
writel(reg |
@@ -145,6 +141,15 @@ static int tegra_hier_ictlr_mselect_init(struct platform_device *pdev,
return 0;
}
+void tegra_hier_ictlr_set_mselect_timeout(struct tegra_hier_ictlr *ictlr,
+ u32 timeout_cycles)
+{
+ ictlr->mselect_timeout_cycles = timeout_cycles;
+
+ writel(ictlr->mselect_timeout_cycles, ictlr->mselect_base +
+ MSELECT_TIMEOUT_TIMER_0);
+}
+
static int tegra_hier_ictlr_probe(struct platform_device *pdev)
{
struct tegra_hier_ictlr *ictlr;
@@ -167,18 +172,27 @@ static int tegra_hier_ictlr_probe(struct platform_device *pdev)
if (ret)
return ret;
+ tegra_hier_ictlr_create_sysfs(pdev);
+
dev_notice(&pdev->dev, "probed\n");
dev_set_drvdata(&pdev->dev, ictlr);
return 0;
}
+static int __exit tegra_hier_ictlr_remove(struct platform_device *pdev)
+{
+ tegra_hier_ictlr_remove_sysfs(pdev);
+ return 0;
+}
+
static struct platform_driver tegra_hier_ictlr_driver = {
.driver = {
.name = "tegra-hier-ictlr",
.owner = THIS_MODULE,
},
.probe = tegra_hier_ictlr_probe,
+ .remove = __exit_p(tegra_hier_ictrl_remove),
};
static int __init tegra_hier_ictlr_init(void)
@@ -186,7 +200,13 @@ static int __init tegra_hier_ictlr_init(void)
return platform_driver_register(&tegra_hier_ictlr_driver);
}
+static void __exit tegra_hier_ictlr_exit(void)
+{
+ platform_driver_unregister(&tegra_hier_ictlr_driver);
+}
+
module_init(tegra_hier_ictlr_init);
+module_exit(tegra_hier_ictlr_exit);
MODULE_DESCRIPTION("Tegra Hierarchical Interrupt Controller Driver");
MODULE_LICENSE("GPL v2");
diff --git a/drivers/platform/tegra/hier_ictlr/hier_ictlr.h b/drivers/platform/tegra/hier_ictlr/hier_ictlr.h
new file mode 100644
index 000000000000..88e0c84a1655
--- /dev/null
+++ b/drivers/platform/tegra/hier_ictlr/hier_ictlr.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2013-2014, NVIDIA Corporation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __HIER_ICTLR_H
+#define __HIER_ICTLR_H
+
+#include <linux/types.h>
+
+struct tegra_hier_ictlr {
+ u32 irq;
+ u32 mselect_timeout_cycles;
+ void __iomem *hier_ictlr_base;
+ void __iomem *mselect_base;
+};
+
+void tegra_hier_ictlr_create_sysfs(struct platform_device *pdev);
+void tegra_hier_ictlr_remove_sysfs(struct platform_device *pdev);
+
+void tegra_hier_ictlr_set_mselect_timeout(struct tegra_hier_ictlr *ictlr,
+ u32 timeout);
+
+#endif
diff --git a/drivers/platform/tegra/hier_ictlr/hier_ictlr_sysfs.c b/drivers/platform/tegra/hier_ictlr/hier_ictlr_sysfs.c
new file mode 100644
index 000000000000..eb1bc17acdbb
--- /dev/null
+++ b/drivers/platform/tegra/hier_ictlr/hier_ictlr_sysfs.c
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2014-2014, NVIDIA CORPORATION. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/err.h>
+#include "hier_ictlr.h"
+
+static ssize_t mselect_timeout_show(struct device *device,
+ struct device_attribute *attr, char *buf)
+{
+ struct tegra_hier_ictlr *ictlr = dev_get_drvdata(device);
+
+ return sprintf(buf, "%d\n", ictlr->mselect_timeout_cycles);
+}
+
+static ssize_t mselect_timeout_store(struct device *device,
+ struct device_attribute *attr, const char *buf, size_t count)
+{
+ struct tegra_hier_ictlr *ictlr = dev_get_drvdata(device);
+ unsigned long val = 0;
+
+ if (kstrtoul(buf, 10, &val) < 0)
+ return -EINVAL;
+
+ tegra_hier_ictlr_set_mselect_timeout(ictlr, val);
+
+ return count;
+}
+
+static DEVICE_ATTR(mselect_timeout, S_IWUSR | S_IRUGO, mselect_timeout_show,
+ mselect_timeout_store);
+
+void tegra_hier_ictlr_create_sysfs(struct platform_device *pdev)
+{
+ int error;
+
+ error = device_create_file(&pdev->dev, &dev_attr_mselect_timeout);
+
+ if (error)
+ dev_err(&pdev->dev, "Failed to create sysfs attributes!\n");
+}
+
+void tegra_hier_ictlr_remove_sysfs(struct platform_device *pdev)
+{
+ device_remove_file(&pdev->dev, &dev_attr_mselect_timeout);
+}
+