Can fan-pwm be used for pulse counting?

I want to use fan-pwm pin to output pulse counting support?

Yes, it is GP_PWM4 21KHz~28KHz, please check pinmux and TRM for more info.

My version is 28.1 TX2
Want to turn off the temperature of self-starting fan, instead of the PWM output the specified pulse signal
Like I want to output 50 pulse PWM signal
How to do it? Need to set up

pwm_fan_shared_data: pfsd {
		status = "okay";
		num_resources = <0>;
		secret = <47>;
		active_steps = <10>;
		active_rpm = <0 1000 2000 3000 4000 5000 6000 7000 10000 11000>;
		rpm_diff_tolerance = <2>;
		active_rru = <40 2 1 1 1 1 1 1 1 1>;
		active_rrd = <40 2 1 1 1 1 1 1 1 1>;
		state_cap_lookup = <2 2 2 2 3 3 3 4 4 4>;
		pwm_period = <45334>;
		pwm_id = <3>;
		step_time = <100>; /* mesecs */
		state_cap = <7>;
		active_pwm_max = <256>;
		tach_period = <1000>;
		pwm_gpio = <&tegra_aon_gpio TEGRA_AON_GPIO(V, 6) GPIO_ACTIVE_LOW>; /* TEGRA_MAIN_GPIO_PV6 */
	};
	pwm-fan {
		status = "okay";
		compatible = "pwm-fan";

		shared_data = <&pwm_fan_shared_data>;
		active_pwm = <0 80 120 160 255 255 255 255 255 255>;
	};
};

I found the definition of pwm_fan
But turn off the temperature to start
Pulse output method does not know the method

Please try below method

Now to configure the pwm with 20us period and 50% duty cycle through sysfs, do the following:
# cd /sys/class/pwm/pwmchip3
# echo 0 > export
# cd pwm3
# echo 20000 > period (20us is the total time period of the pulse)
# echo 10000 > duty_cycle (50% duty cycle)
# echo 1 > enable
Now if we probe the pwm lines we can see pwm pulse of period 20us and 50% duty cycle.

/sys/class/pwm/pwmchip0 --> LCD0_BKLT_PWM
/sys/class/pwm/pwmchip1 --> N/A
/sys/class/pwm/pwmchip2 --> LCD1_BKLT_PWM
/sys/class/pwm/pwmchip3 --> FAN_PWM

root@tegra-ubuntu:/sys/class/pwm/pwmchip3# echo 0 >export
bash: echo: write error: Device or resource busy
root@tegra-ubuntu:/sys/class/pwm/pwmchip3# cd pwm3
bash: cd: pwm3: No such file or directory

Where did I find the PWM3 file?
And I want to know how to turn off the CPU temperature to start the fan

root@tegra-ubuntu:/sys/kernel/debug# cat  pwm 
platform/c340000.pwm, 1 PWM device
 pwm-0   (pwm-fan             ): requested enabled

platform/32a0000.pwm, 1 PWM device
 pwm-0   ((null)              ):

platform/3290000.pwm, 1 PWM device
 pwm-0   ((null)              ):

platform/3280000.pwm, 1 PWM device
 pwm-0   ((null)              ):

Sorry for my typo. It should be “pwm0” and it would be generated after you do “echo > 0 export”.

However, since some driver occupies this pwm device, you need to disable it first before any operation.

[    3.479396] FAN dev name: pwm-fan
[    3.482789] FAN:gpio request success.
[    3.486482] FAN: can't find tach_gpio
[    3.490222] pwm_fan_driver pwm-fan: cap state:7, cap pwm:255
[    3.496129] pwm_fan_driver pwm-fan: unable to request PWM, trying legacy API
[    3.503202] pwm_fan_driver pwm-fan: got pwm for fan
[    3.508098] pwm_fan_driver pwm-fan: tach period: 1000
[    3.513529] pwm_fan_driver pwm-fan: index 0: pwm=0, rpm=0, rru=40, rrd=40, state:2
[    3.521126] pwm_fan_driver pwm-fan: index 1: pwm=80, rpm=1000, rru=2, rrd=2, state:2
[    3.528886] pwm_fan_driver pwm-fan: index 2: pwm=120, rpm=2000, rru=1, rrd=1, state:2
[    3.536733] pwm_fan_driver pwm-fan: index 3: pwm=160, rpm=3000, rru=1, rrd=1, state:2
[    3.544578] pwm_fan_driver pwm-fan: index 4: pwm=255, rpm=4000, rru=1, rrd=1, state:3
[    3.552423] pwm_fan_driver pwm-fan: index 5: pwm=255, rpm=5000, rru=1, rrd=1, state:3
[    3.560273] pwm_fan_driver pwm-fan: index 6: pwm=255, rpm=6000, rru=1, rrd=1, state:3
[    3.568118] pwm_fan_driver pwm-fan: index 7: pwm=255, rpm=7000, rru=1, rrd=1, state:4
[    3.575963] pwm_fan_driver pwm-fan: index 8: pwm=255, rpm=10000, rru=1, rrd=1, state:4
[    3.583894] pwm_fan_driver pwm-fan: index 9: pwm=255, rpm=11000, rru=1, rrd=1, state:4
[    3.592868] device-mapper: uevent: version 1.0.3
[    3.597752] device-mapper: ioctl: 4.34.0-ioctl (2015-10-28) initialised: dm-devel@redhat.com
[    3.606684] sdhci: Secure Digital Host Controller Interface driver

PWM_FAN_drivice=n
It should be this takes up the driver, but I disabled, the command is also sent without response

Exception PWM_fan can be used as a pulse count it?
I did not find the relevant register ah?
Still need to set up another GPIO interrupt capture?

“command is also sent without response”

Did you still detect nothing after disable pwm fan driver and use that command to period and duty cycle?

We have another thread talking about pwm. But it is using lcd1_bklt_pwm.

https://devtalk.nvidia.com/default/topic/1026920/jetson-tx2/can-i-control-lcd1_bklt_pwm-/

Can be used in pulse counting output?
I want to specify the output 28 pulse signal
tx2 I did not find the relevant count register, but also need to do a separate gpio interrupt capture it?

#11 Yes, disable the use of the command can not see the signal waveform
However, I open the FAN_PWM use the following instructions can see the waveform
echo 255> / sys / kernel / debug / tegra_fan / target_pwm

Calmcar-Bao,

So you can see the node “pwm0” generated and echo some value to “period” + “duty_cycle” but no effect?

Yes, there is a pwm0 node
Set the duty cycle and frequency, open the end of the implementation of the end of no response
Can not see the waveform on the oscilloscope

Hi Calmcar-Bao,

Could you check if this pin is in sfio mode or not?

I am a novice
How to check and set it?

I am curious about if you can test on other pin first as this thread mentioned. As least it is a successful case.

https://devtalk.nvidia.com/default/topic/1026920/jetson-tx2/can-i-control-lcd1_bklt_pwm-/

Please also dump the result of
/sys/kernel/debug# cat tegra-gpio-aon
and
/sys/kernel/debug/tegra_pinctrl_reg