Use GPIO based FAN Tachometer but always got a shutdown event

Hi
I’m using GPIO03_PY.04 (Signal Name: SPI1_CS1, Ball Name: SPI3_CS1, #pin: 112) as a FAN tacometer on a custom board with Nvidia NX. Here’s what I proceed

  1. update pinmux
  • customer usage: GPIO03_PY.04
  • Pin direction: Input
  • Req. Initial State: N/A
  • Wake pin: No
  • 3.3 Tolarance Enable: disable
  • LPDR Enable: Disable
  1. Enable Kernel config (GPIO Tachometer)
  2. Update Device Tree
	gpio_tachometer {
        compatible = "nvidia,gpio-tachometer";
        win-len = <2>;
        pulse-per-rev = <2>;
        schedule-delay = <10000>;
        gpio = <&tegra_main_gpio TEGRA194_MAIN_GPIO(Y, 4) 1>;
        status = "okay";
    };

After doing these , I got a success tachometer initialization.

But few seconds later, system shutdown

root@nvidia-nx:~# [   46.437170] gpio tegra-gpio wake58 for gpio=196(Y:4)

Broadcast message from root@nvidia-nx(Fri Mar  9 13:20:51 2018):

The system is going down for system halt NOW!
logout
[   52.073306] EXT4-fs (mmcblk0p1): re-mounted. Opts: data=ordered
[   52.218464] therm-fan-est: shutting down
[   52.218855] nvgpu: 17000000.gv11b                 gk20a_pm_shutdown:961  [INFO]  shutting down
[   52.219007] nvgpu: 17000000.gv11b                 gk20a_pm_shutdown:992  [INFO]  shut down complete
[   52.220035] i2c i2c-4: Bus is shutdown down...
[   52.220499] late_shutdown started
[   52.220823] tegra-i2c 31e0000.i2c: Bus is shutdown down..
[   52.220940] tegra-i2c c250000.i2c: Bus is shutdown down..
[   52.221032] tegra-i2c 31c0000.i2c: Bus is shutdown down..
[   52.221122] tegra-i2c 31b0000.i2c: Bus is shutdown down..
[   52.221263] tegra-i2c 3190000.i2c: Bus is shutdown down..
[   52.221354] tegra-i2c 3180000.i2c: Bus is shutdown down..
[   52.221445] tegra-i2c c240000.i2c: Bus is shutdown down..
[   52.221537] tegra-i2c 3160000.i2c: Bus is shutdown down..
[   52.221685] Disabling non-boot CPUs ...
[   52.250402] ras_fhi_disable: FHI 467 disabled
[   52.252717] CPU1: shutdown
[   52.252805] psci: CPU1 killed.
[   52.278322] ras_fhi_disable: FHI 468 disabled
[   52.281069] CPU2: shutdown
[   52.301159] psci: Retrying again to check for CPU kill
[   52.301306] psci: CPU2 killed.
[   52.322628] ras_fhi_disable: FHI 469 disabled
[   52.328850] CPU3: shutdown
[   52.345163] psci: Retrying again to check for CPU kill
[   52.345302] psci: CPU3 killed.
[   52.362231] ras_fhi_disable: FHI 470 disabled
[   52.362905] CPU4: shutdown
[   52.381156] psci: Retrying again to check for CPU kill
[   52.381284] psci: CPU4 killed.
[   52.410200] ras_fhi_disable: FHI 471 disabled
[   52.416365] CPU5: shutdown
[   52.433178] psci: Retrying again to check for CPU kill
[   52.433302] psci: CPU5 killed.
[   52.434028] reboot: Power down

Some updates about this.
I looked into the driver : gpio-tachometer.c line: 234.

I notice when measured RPM = 0, it launch shutdown command.
I have no idea why should turn off the system when RPM = 0. But problem solved.

static void tach_measure_work(struct work_struct *workp)
{
	struct delayed_work *work = container_of(workp, struct delayed_work,
									work);
	struct gpio_tachometer_device *gpio_tachd =
		container_of(work, struct gpio_tachometer_device, tach_work);
	struct device *tach;

	tach = gpio_tachd->tach_dev;

	(void)gpio_tachometer_read_rpm(tach);
	if (gpio_tachd->rpm == 0)
		orderly_poweroff(true);
	else
		queue_delayed_work(gpio_tachd->tach_workqueue,
			&gpio_tachd->tach_work, gpio_tachd->schedule_delay);
}