linux/drivers/hte/hte-tegra194-test.c

// SPDX-License-Identifier: GPL-2.0
/*
 * Copyright (c) 2021-2022 NVIDIA Corporation
 *
 * Author: Dipen Patel <[email protected]>
 */

#include <linux/err.h>
#include <linux/gpio/consumer.h>
#include <linux/hte.h>
#include <linux/interrupt.h>
#include <linux/mod_devicetable.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/timer.h>
#include <linux/workqueue.h>

/*
 * This sample HTE test driver demonstrates HTE API usage by enabling
 * hardware timestamp on gpio_in and specified LIC IRQ lines.
 *
 * Note: gpio_out and gpio_in need to be shorted externally in order for this
 * test driver to work for the GPIO monitoring. The test driver has been
 * tested on Jetson AGX Xavier platform by shorting pin 32 and 16 on 40 pin
 * header.
 *
 * Device tree snippet to activate this driver:
 *	tegra_hte_test {
 *		compatible = "nvidia,tegra194-hte-test";
 *		in-gpio = <&gpio_aon TEGRA194_AON_GPIO(BB, 1)>;
 *		out-gpio = <&gpio_aon TEGRA194_AON_GPIO(BB, 0)>;
 *		timestamps = <&tegra_hte_aon TEGRA194_AON_GPIO(BB, 1)>,
 *			     <&tegra_hte_lic 0x19>;
 *		timestamp-names = "hte-gpio", "hte-i2c-irq";
 *		status = "okay";
 *	};
 *
 * How to run test driver:
 * - Load test driver.
 * - For the GPIO, at regular interval gpio_out pin toggles triggering
 *   HTE for rising edge on gpio_in pin.
 *
 * - For the LIC IRQ line, it uses 0x19 interrupt which is i2c controller 1.
 * - Run i2cdetect -y 1 1>/dev/null, this command will generate i2c bus
 *   transactions which creates timestamp data.
 * - It prints below message for both the lines.
 *   HW timestamp(<line id>:<ts seq number>): <timestamp>, edge: <edge>.
 * - Unloading the driver disables and deallocate the HTE.
 */

static struct tegra_hte_test {} hte;

static enum hte_return process_hw_ts(struct hte_ts_data *ts, void *p)
{}

static void gpio_timer_cb(struct timer_list *t)
{}

static irqreturn_t tegra_hte_test_gpio_isr(int irq, void *data)
{}

static const struct of_device_id tegra_hte_test_of_match[] =;
MODULE_DEVICE_TABLE(of, tegra_hte_test_of_match);

static int tegra_hte_test_probe(struct platform_device *pdev)
{}

static void tegra_hte_test_remove(struct platform_device *pdev)
{}

static struct platform_driver tegra_hte_test_driver =;
module_platform_driver();

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();