summaryrefslogtreecommitdiffstats
path: root/drivers/hte
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 17:35:05 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 17:39:31 +0000
commit85c675d0d09a45a135bddd15d7b385f8758c32fb (patch)
tree76267dbc9b9a130337be3640948fe397b04ac629 /drivers/hte
parentAdding upstream version 6.6.15. (diff)
downloadlinux-85c675d0d09a45a135bddd15d7b385f8758c32fb.tar.xz
linux-85c675d0d09a45a135bddd15d7b385f8758c32fb.zip
Adding upstream version 6.7.7.upstream/6.7.7
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'drivers/hte')
-rw-r--r--drivers/hte/Kconfig5
-rw-r--r--drivers/hte/hte-tegra194.c56
-rw-r--r--drivers/hte/hte.c15
3 files changed, 37 insertions, 39 deletions
diff --git a/drivers/hte/Kconfig b/drivers/hte/Kconfig
index cf29e0218b..641af722b5 100644
--- a/drivers/hte/Kconfig
+++ b/drivers/hte/Kconfig
@@ -16,7 +16,8 @@ if HTE
config HTE_TEGRA194
tristate "NVIDIA Tegra194 HTE Support"
- depends on ARCH_TEGRA_194_SOC
+ depends on (ARCH_TEGRA_194_SOC || COMPILE_TEST)
+ depends on GPIOLIB
help
Enable this option for integrated hardware timestamping engine also
known as generic timestamping engine (GTE) support on NVIDIA Tegra194
@@ -25,7 +26,7 @@ config HTE_TEGRA194
config HTE_TEGRA194_TEST
tristate "NVIDIA Tegra194 HTE Test"
- depends on HTE_TEGRA194
+ depends on (HTE_TEGRA194 || COMPILE_TEST)
help
The NVIDIA Tegra194 GTE test driver demonstrates how to use HTE
framework to timestamp GPIO and LIC IRQ lines.
diff --git a/drivers/hte/hte-tegra194.c b/drivers/hte/hte-tegra194.c
index 6fe6897047..690eb9be30 100644
--- a/drivers/hte/hte-tegra194.c
+++ b/drivers/hte/hte-tegra194.c
@@ -132,7 +132,7 @@ struct tegra_hte_soc {
const struct tegra_hte_data *prov_data;
struct tegra_hte_line_data *line_data;
struct hte_chip *chip;
- struct gpio_chip *c;
+ struct gpio_device *gdev;
void __iomem *regs;
};
@@ -407,18 +407,21 @@ static int tegra_hte_line_xlate(struct hte_chip *gc,
return -EINVAL;
/*
+ * GPIO consumers can access GPIOs in two ways:
*
- * There are two paths GPIO consumers can take as follows:
- * 1) The consumer (gpiolib-cdev for example) which uses GPIO global
- * number which gets assigned run time.
- * 2) The consumer passing GPIO from the DT which is assigned
- * statically for example by using TEGRA194_AON_GPIO gpio DT binding.
+ * 1) Using the global GPIO numberspace.
+ *
+ * This is the old, now DEPRECATED method and should not be used in
+ * new code. TODO: Check if tegra is even concerned by this.
+ *
+ * 2) Using GPIO descriptors that can be assigned to consumer devices
+ * using device-tree, ACPI or lookup tables.
*
* The code below addresses both the consumer use cases and maps into
* HTE/GTE namespace.
*/
if (gs->prov_data->type == HTE_TEGRA_TYPE_GPIO && !args) {
- line_id = desc->attr.line_id - gs->c->base;
+ line_id = desc->attr.line_id - gpio_device_get_base(gs->gdev);
map = gs->prov_data->map;
map_sz = gs->prov_data->map_sz;
} else if (gs->prov_data->type == HTE_TEGRA_TYPE_GPIO && args) {
@@ -645,7 +648,7 @@ static bool tegra_hte_match_from_linedata(const struct hte_chip *chip,
if (!hte_dev || (hte_dev->prov_data->type != HTE_TEGRA_TYPE_GPIO))
return false;
- return hte_dev->c == gpiod_to_chip(hdesc->attr.line_data);
+ return hte_dev->gdev == gpiod_to_gpio_device(hdesc->attr.line_data);
}
static const struct of_device_id tegra_hte_of_match[] = {
@@ -673,14 +676,11 @@ static void tegra_gte_disable(void *data)
tegra_hte_writel(gs, HTE_TECTRL, 0);
}
-static int tegra_get_gpiochip_from_name(struct gpio_chip *chip, void *data)
+static void tegra_hte_put_gpio_device(void *data)
{
- return !strcmp(chip->label, data);
-}
+ struct gpio_device *gdev = data;
-static int tegra_gpiochip_match(struct gpio_chip *chip, void *data)
-{
- return chip->fwnode == of_node_to_fwnode(data);
+ gpio_device_put(gdev);
}
static int tegra_hte_probe(struct platform_device *pdev)
@@ -728,10 +728,8 @@ static int tegra_hte_probe(struct platform_device *pdev)
return -ENOMEM;
ret = platform_get_irq(pdev, 0);
- if (ret < 0) {
- dev_err_probe(dev, ret, "failed to get irq\n");
+ if (ret < 0)
return ret;
- }
hte_dev->hte_irq = ret;
ret = devm_request_irq(dev, hte_dev->hte_irq, tegra_hte_isr, 0,
dev_name(dev), hte_dev);
@@ -760,8 +758,8 @@ static int tegra_hte_probe(struct platform_device *pdev)
if (of_device_is_compatible(dev->of_node,
"nvidia,tegra194-gte-aon")) {
- hte_dev->c = gpiochip_find("tegra194-gpio-aon",
- tegra_get_gpiochip_from_name);
+ hte_dev->gdev =
+ gpio_device_find_by_label("tegra194-gpio-aon");
} else {
gpio_ctrl = of_parse_phandle(dev->of_node,
"nvidia,gpio-controller",
@@ -772,14 +770,19 @@ static int tegra_hte_probe(struct platform_device *pdev)
return -ENODEV;
}
- hte_dev->c = gpiochip_find(gpio_ctrl,
- tegra_gpiochip_match);
+ hte_dev->gdev =
+ gpio_device_find_by_fwnode(of_fwnode_handle(gpio_ctrl));
of_node_put(gpio_ctrl);
}
- if (!hte_dev->c)
+ if (!hte_dev->gdev)
return dev_err_probe(dev, -EPROBE_DEFER,
"wait for gpio controller\n");
+
+ ret = devm_add_action_or_reset(dev, tegra_hte_put_gpio_device,
+ hte_dev->gdev);
+ if (ret)
+ return ret;
}
hte_dev->chip = gc;
@@ -809,7 +812,7 @@ static int tegra_hte_probe(struct platform_device *pdev)
return 0;
}
-static int __maybe_unused tegra_hte_resume_early(struct device *dev)
+static int tegra_hte_resume_early(struct device *dev)
{
u32 i;
struct tegra_hte_soc *gs = dev_get_drvdata(dev);
@@ -830,7 +833,7 @@ static int __maybe_unused tegra_hte_resume_early(struct device *dev)
return 0;
}
-static int __maybe_unused tegra_hte_suspend_late(struct device *dev)
+static int tegra_hte_suspend_late(struct device *dev)
{
u32 i;
struct tegra_hte_soc *gs = dev_get_drvdata(dev);
@@ -850,15 +853,14 @@ static int __maybe_unused tegra_hte_suspend_late(struct device *dev)
}
static const struct dev_pm_ops tegra_hte_pm = {
- SET_LATE_SYSTEM_SLEEP_PM_OPS(tegra_hte_suspend_late,
- tegra_hte_resume_early)
+ LATE_SYSTEM_SLEEP_PM_OPS(tegra_hte_suspend_late, tegra_hte_resume_early)
};
static struct platform_driver tegra_hte_driver = {
.probe = tegra_hte_probe,
.driver = {
.name = "tegra_hte",
- .pm = &tegra_hte_pm,
+ .pm = pm_sleep_ptr(&tegra_hte_pm),
.of_match_table = tegra_hte_of_match,
},
};
diff --git a/drivers/hte/hte.c b/drivers/hte/hte.c
index 598a716b73..23a6eeb8c5 100644
--- a/drivers/hte/hte.c
+++ b/drivers/hte/hte.c
@@ -17,8 +17,6 @@
#include <linux/debugfs.h>
#include <linux/device.h>
-#define HTE_TS_NAME_LEN 10
-
/* Global list of the HTE devices */
static DEFINE_SPINLOCK(hte_lock);
static LIST_HEAD(hte_devices);
@@ -88,7 +86,7 @@ struct hte_device {
struct list_head list;
struct hte_chip *chip;
struct module *owner;
- struct hte_ts_info ei[];
+ struct hte_ts_info ei[] __counted_by(nlines);
};
#ifdef CONFIG_DEBUG_FS
@@ -389,13 +387,10 @@ static int __hte_req_ts(struct hte_ts_desc *desc, hte_ts_cb_t cb,
atomic_inc(&gdev->ts_req);
- ei->line_name = NULL;
- if (!desc->attr.name) {
- ei->line_name = kzalloc(HTE_TS_NAME_LEN, GFP_KERNEL);
- if (ei->line_name)
- scnprintf(ei->line_name, HTE_TS_NAME_LEN, "ts_%u",
- desc->attr.line_id);
- }
+ if (desc->attr.name)
+ ei->line_name = NULL;
+ else
+ ei->line_name = kasprintf(GFP_KERNEL, "ts_%u", desc->attr.line_id);
hte_ts_dbgfs_init(desc->attr.name == NULL ?
ei->line_name : desc->attr.name, ei);