/* * 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.
*/
hte.gpio_out = gpiod_get(&pdev->dev, "out", 0); if (IS_ERR(hte.gpio_out)) {
dev_err(&pdev->dev, "failed to get gpio out\n");
ret = -EINVAL; goto out;
}
hte.gpio_in = gpiod_get(&pdev->dev, "in", 0); if (IS_ERR(hte.gpio_in)) {
dev_err(&pdev->dev, "failed to get gpio in\n");
ret = -EINVAL; goto free_gpio_out;
}
ret = gpiod_direction_output(hte.gpio_out, 0); if (ret) {
dev_err(&pdev->dev, "failed to set output\n");
ret = -EINVAL; goto free_gpio_in;
}
ret = gpiod_direction_input(hte.gpio_in); if (ret) {
dev_err(&pdev->dev, "failed to set input\n");
ret = -EINVAL; goto free_gpio_in;
}
ret = gpiod_to_irq(hte.gpio_in); if (ret < 0) {
dev_err(&pdev->dev, "failed to map GPIO to IRQ: %d\n", ret);
ret = -ENXIO; goto free_gpio_in;
}
hte.gpio_in_irq = ret;
ret = request_irq(ret, tegra_hte_test_gpio_isr,
IRQF_TRIGGER_RISING, "tegra_hte_gpio_test_isr", &hte); if (ret) {
dev_err(&pdev->dev, "failed to acquire IRQ\n");
ret = -ENXIO; goto free_irq;
}
cnt = of_hte_req_count(hte.pdev); if (cnt < 0) {
ret = cnt; goto free_irq;
}
hte.desc = devm_kzalloc(hte.pdev, sizeof(*hte.desc) * cnt, GFP_KERNEL); if (!hte.desc) {
ret = -ENOMEM; goto free_irq;
}
for (i = 0; i < cnt; i++) { if (i == 0) /* * GPIO hte init, line_id and name will be parsed from * the device tree node. The edge_flag is implicitly * set by request_irq call. Only line_data is needed to be * set.
*/
hte_init_line_attr(&hte.desc[i], 0, 0, NULL,
hte.gpio_in); else /* * same comment as above except that IRQ does not need * line data.
*/
hte_init_line_attr(&hte.desc[i], 0, 0, NULL, NULL);
ret = hte_ts_get(hte.pdev, &hte.desc[i], i); if (ret) goto ts_put;
ret = devm_hte_request_ts_ns(hte.pdev, &hte.desc[i],
process_hw_ts, NULL,
&hte.desc[i]); if (ret) /* no need to ts_put, request API takes care */ goto free_irq;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.