All of lore.kernel.org
 help / color / mirror / Atom feed
* [AST2600] PWM/TACH driver and dbus-sensor issue
@ 2022-02-09 14:40 Tung Nguyen OS
  2022-02-11  5:13 ` Troy Lee
  0 siblings, 1 reply; 11+ messages in thread
From: Tung Nguyen OS @ 2022-02-09 14:40 UTC (permalink / raw)
  To: openbmc; +Cc: Thu Nguyen OS, Thang Nguyen OS, Phong Vo OS

Dear community,
We have ported the PWM/TACH hwmon driver for AST2600 from ASPEED's repository https://github.com/AspeedTech-BMC/linux/tree/aspeed-master-v5.4/drivers/hwmon to support Ampere Computing's systems. Verify with AST2600 EVB, i can see the driver works. However there is a concern like:
1. The change of hwmon fan pwm/tach in sysfs (as below), this is different from the ast2500 as the separated of the fan*_input and pwm1 in various hwmon directories. At this time, the driver doesn't exist in the OpenBMC linux at https://github.com/openbmc/linux. Is OpenBMC going to merge and keep this driver ?

root@mtmitchell:~# ls -la /sys/class/hwmon/hwmon
hwmon0/ hwmon1/ hwmon2/ hwmon3/ hwmon4/ hwmon5/ hwmon6/ hwmon7/ hwmon8/ hwmon9/
root@mtmitchell:~# ls -la /sys/class/hwmon/hwmon0/
drwxr-xr-x    3 root     root             0 Jan  1  1970 .
drwxr-xr-x    3 root     root             0 Jan  1  1970 ..
lrwxrwxrwx    1 root     root             0 Feb  9 08:38 device -> ../../../1e610000.pwm_tach:tach
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan10_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan11_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan12_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan13_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan14_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan15_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan16_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan1_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan2_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan3_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan4_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan5_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan6_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan7_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan8_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan9_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 name
lrwxrwxrwx    1 root     root             0 Feb  9 08:38 of_node -> ../../../../../../../../firmware/devicetree/base/ahb/apb/pwm_tach@1e610000/tach
drwxr-xr-x    2 root     root             0 Feb  9 08:38 power
lrwxrwxrwx    1 root     root             0 Jan  1  1970 subsystem -> ../../../../../../../../class/hwmon
-rw-r--r--    1 root     root          4096 Jan  1  1970 uevent
root@mtmitchell:~# ls -la /sys/class/hwmon/hwmon*/pwm*
-rw-r--r--    1 root     root          4096 Feb  9 09:13 /sys/class/hwmon/hwmon1/pwm1
-rw-r--r--    1 root     root          4096 Feb  9 09:20 /sys/class/hwmon/hwmon2/pwm1
-rw-r--r--    1 root     root          4096 Feb  9 08:38 /sys/class/hwmon/hwmon3/pwm1
-rw-r--r--    1 root     root          4096 Feb  9 08:38 /sys/class/hwmon/hwmon4/pwm1
-rw-r--r--    1 root     root          4096 Feb  9 08:38 /sys/class/hwmon/hwmon5/pwm1
-rw-r--r--    1 root     root          4096 Feb  9 08:38 /sys/class/hwmon/hwmon6/pwm1
-rw-r--r--    1 root     root          4096 Feb  9 08:38 /sys/class/hwmon/hwmon7/pwm1
-rw-r--r--    1 root     root          4096 Feb  9 08:38 /sys/class/hwmon/hwmon8/pwm1

2. With above changes, the dbus-sensor for FAN/PWM shall not work because of the compatibility. So if OpenBMC want to keep above PWM/TACH driver, does any sides have the plan to support the fan sensor, if not, we can join and do it.

Thank you and best regards,
Tung

^ permalink raw reply	[flat|nested] 11+ messages in thread

* RE: [AST2600] PWM/TACH driver and dbus-sensor issue
  2022-02-09 14:40 [AST2600] PWM/TACH driver and dbus-sensor issue Tung Nguyen OS
@ 2022-02-11  5:13 ` Troy Lee
  2022-02-14  3:45   ` Tung Nguyen OS
  0 siblings, 1 reply; 11+ messages in thread
From: Troy Lee @ 2022-02-11  5:13 UTC (permalink / raw)
  To: Tung Nguyen OS, openbmc; +Cc: Thu Nguyen OS, Thang Nguyen OS, Phong Vo OS

Hi Tung,

> -----Original Message-----
> From: openbmc <openbmc-
> bounces+troy_lee=aspeedtech.com@lists.ozlabs.org> On Behalf Of Tung
> Nguyen OS
> Sent: Wednesday, February 9, 2022 10:40 PM
> To: openbmc@lists.ozlabs.org
> Cc: Thu Nguyen OS <thu@os.amperecomputing.com>; Thang Nguyen OS
> <thang@os.amperecomputing.com>; Phong Vo OS
> <phong@os.amperecomputing.com>
> Subject: [AST2600] PWM/TACH driver and dbus-sensor issue
> 
> Dear community,
> We have ported the PWM/TACH hwmon driver for AST2600 from ASPEED's
> repository https://github.com/AspeedTech-BMC/linux/tree/aspeed-master-
> v5.4/drivers/hwmon to support Ampere Computing's systems. Verify with
> AST2600 EVB, i can see the driver works. However there is a concern like:
> 1. The change of hwmon fan pwm/tach in sysfs (as below), this is different
> from the ast2500 as the separated of the fan*_input and pwm1 in various
> hwmon directories. At this time, the driver doesn't exist in the OpenBMC
> linux at https://github.com/openbmc/linux. Is OpenBMC going to merge and
> keep this driver ?

Please have a look on this patch.
https://gerrit.openbmc-project.xyz/c/openbmc/dbus-sensors/+/49253

Thanks,
Troy Lee

> root@mtmitchell:~# ls -la /sys/class/hwmon/hwmon hwmon0/ hwmon1/
> hwmon2/ hwmon3/ hwmon4/ hwmon5/ hwmon6/ hwmon7/ hwmon8/
> hwmon9/ root@mtmitchell:~# ls -la /sys/class/hwmon/hwmon0/
> drwxr-xr-x    3 root     root             0 Jan  1  1970 .
> drwxr-xr-x    3 root     root             0 Jan  1  1970 ..
> lrwxrwxrwx    1 root     root             0 Feb  9 08:38 device -
> > ../../../1e610000.pwm_tach:tach
> -r--r--r--    1 root     root          4096 Feb  9 08:38 fan10_input
> -r--r--r--    1 root     root          4096 Feb  9 08:38 fan11_input
> -r--r--r--    1 root     root          4096 Feb  9 08:38 fan12_input
> -r--r--r--    1 root     root          4096 Feb  9 08:38 fan13_input
> -r--r--r--    1 root     root          4096 Feb  9 08:38 fan14_input
> -r--r--r--    1 root     root          4096 Feb  9 08:38 fan15_input
> -r--r--r--    1 root     root          4096 Feb  9 08:38 fan16_input
> -r--r--r--    1 root     root          4096 Feb  9 08:38 fan1_input
> -r--r--r--    1 root     root          4096 Feb  9 08:38 fan2_input
> -r--r--r--    1 root     root          4096 Feb  9 08:38 fan3_input
> -r--r--r--    1 root     root          4096 Feb  9 08:38 fan4_input
> -r--r--r--    1 root     root          4096 Feb  9 08:38 fan5_input
> -r--r--r--    1 root     root          4096 Feb  9 08:38 fan6_input
> -r--r--r--    1 root     root          4096 Feb  9 08:38 fan7_input
> -r--r--r--    1 root     root          4096 Feb  9 08:38 fan8_input
> -r--r--r--    1 root     root          4096 Feb  9 08:38 fan9_input
> -r--r--r--    1 root     root          4096 Feb  9 08:38 name
> lrwxrwxrwx    1 root     root             0 Feb  9 08:38 of_node -
> > ../../../../../../../../firmware/devicetree/base/ahb/apb/pwm_tach@1e610
> 000/tach
> drwxr-xr-x    2 root     root             0 Feb  9 08:38 power
> lrwxrwxrwx    1 root     root             0 Jan  1  1970 subsystem -
> > ../../../../../../../../class/hwmon
> -rw-r--r--    1 root     root          4096 Jan  1  1970 uevent
> root@mtmitchell:~# ls -la /sys/class/hwmon/hwmon*/pwm*
> -rw-r--r--    1 root     root          4096 Feb  9 09:13
> /sys/class/hwmon/hwmon1/pwm1
> -rw-r--r--    1 root     root          4096 Feb  9 09:20
> /sys/class/hwmon/hwmon2/pwm1
> -rw-r--r--    1 root     root          4096 Feb  9 08:38
> /sys/class/hwmon/hwmon3/pwm1
> -rw-r--r--    1 root     root          4096 Feb  9 08:38
> /sys/class/hwmon/hwmon4/pwm1
> -rw-r--r--    1 root     root          4096 Feb  9 08:38
> /sys/class/hwmon/hwmon5/pwm1
> -rw-r--r--    1 root     root          4096 Feb  9 08:38
> /sys/class/hwmon/hwmon6/pwm1
> -rw-r--r--    1 root     root          4096 Feb  9 08:38
> /sys/class/hwmon/hwmon7/pwm1
> -rw-r--r--    1 root     root          4096 Feb  9 08:38
> /sys/class/hwmon/hwmon8/pwm1
> 
> 2. With above changes, the dbus-sensor for FAN/PWM shall not work
> because of the compatibility. So if OpenBMC want to keep above
> PWM/TACH driver, does any sides have the plan to support the fan sensor, if
> not, we can join and do it.
> 
> Thank you and best regards,
> Tung

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [AST2600] PWM/TACH driver and dbus-sensor issue
  2022-02-11  5:13 ` Troy Lee
@ 2022-02-14  3:45   ` Tung Nguyen OS
  2022-02-14  4:02     ` Troy Lee
  0 siblings, 1 reply; 11+ messages in thread
From: Tung Nguyen OS @ 2022-02-14  3:45 UTC (permalink / raw)
  To: Troy Lee, openbmc; +Cc: Thu Nguyen OS, Thang Nguyen OS, Phong Vo OS

Hi Troy,
Thank you for the information, i have merged the dbus-sensor patch and see it creates the Fan sensors well.
One more issue i have observed about the fan tach report like this:

root@mtmitchell:~# echo 120 > /sys/class/hwmon/hwmon1/pwm1
root@mtmitchell:~# cat /sys/class/hwmon/hwmon0/fan1_input
418526
root@mtmitchell:~# echo 100 > /sys/class/hwmon/hwmon1/pwm1
root@mtmitchell:~# cat /sys/class/hwmon/hwmon0/fan1_input
195312
root@mtmitchell:~# echo 255 > /sys/class/hwmon/hwmon1/pwm1
root@mtmitchell:~# cat /sys/class/hwmon/hwmon0/fan1_input
0
root@mtmitchell:~# echo 50 > /sys/class/hwmon/hwmon1/pwm1
root@mtmitchell:~# cat /sys/class/hwmon/hwmon0/fan1_input
0

It means the fan speed is reported incorrectly somehow, but i can see the fan speed changes by eyes, do you have idea on this issue ?

________________________________________
From: Troy Lee <troy_lee@aspeedtech.com>
Sent: Friday, February 11, 2022 12:13 PM
To: Tung Nguyen OS; openbmc@lists.ozlabs.org
Cc: Thu Nguyen OS; Thang Nguyen OS; Phong Vo OS
Subject: RE: [AST2600] PWM/TACH driver and dbus-sensor issue

Hi Tung,

> -----Original Message-----
> From: openbmc <openbmc-
> bounces+troy_lee=aspeedtech.com@lists.ozlabs.org> On Behalf Of Tung
> Nguyen OS
> Sent: Wednesday, February 9, 2022 10:40 PM
> To: openbmc@lists.ozlabs.org
> Cc: Thu Nguyen OS <thu@os.amperecomputing.com>; Thang Nguyen OS
> <thang@os.amperecomputing.com>; Phong Vo OS
> <phong@os.amperecomputing.com>
> Subject: [AST2600] PWM/TACH driver and dbus-sensor issue
>
> Dear community,
> We have ported the PWM/TACH hwmon driver for AST2600 from ASPEED's
> repository https://github.com/AspeedTech-BMC/linux/tree/aspeed-master-
> v5.4/drivers/hwmon to support Ampere Computing's systems. Verify with
> AST2600 EVB, i can see the driver works. However there is a concern like:
> 1. The change of hwmon fan pwm/tach in sysfs (as below), this is different
> from the ast2500 as the separated of the fan*_input and pwm1 in various
> hwmon directories. At this time, the driver doesn't exist in the OpenBMC
> linux at https://github.com/openbmc/linux. Is OpenBMC going to merge and
> keep this driver ?

Please have a look on this patch.
https://gerrit.openbmc-project.xyz/c/openbmc/dbus-sensors/+/49253

Thanks,
Troy Lee

> root@mtmitchell:~# ls -la /sys/class/hwmon/hwmon hwmon0/ hwmon1/
> hwmon2/ hwmon3/ hwmon4/ hwmon5/ hwmon6/ hwmon7/ hwmon8/
> hwmon9/ root@mtmitchell:~# ls -la /sys/class/hwmon/hwmon0/
> drwxr-xr-x    3 root     root             0 Jan  1  1970 .
> drwxr-xr-x    3 root     root             0 Jan  1  1970 ..
> lrwxrwxrwx    1 root     root             0 Feb  9 08:38 device -
> > ../../../1e610000.pwm_tach:tach
> -r--r--r--    1 root     root          4096 Feb  9 08:38 fan10_input
> -r--r--r--    1 root     root          4096 Feb  9 08:38 fan11_input
> -r--r--r--    1 root     root          4096 Feb  9 08:38 fan12_input
> -r--r--r--    1 root     root          4096 Feb  9 08:38 fan13_input
> -r--r--r--    1 root     root          4096 Feb  9 08:38 fan14_input
> -r--r--r--    1 root     root          4096 Feb  9 08:38 fan15_input
> -r--r--r--    1 root     root          4096 Feb  9 08:38 fan16_input
> -r--r--r--    1 root     root          4096 Feb  9 08:38 fan1_input
> -r--r--r--    1 root     root          4096 Feb  9 08:38 fan2_input
> -r--r--r--    1 root     root          4096 Feb  9 08:38 fan3_input
> -r--r--r--    1 root     root          4096 Feb  9 08:38 fan4_input
> -r--r--r--    1 root     root          4096 Feb  9 08:38 fan5_input
> -r--r--r--    1 root     root          4096 Feb  9 08:38 fan6_input
> -r--r--r--    1 root     root          4096 Feb  9 08:38 fan7_input
> -r--r--r--    1 root     root          4096 Feb  9 08:38 fan8_input
> -r--r--r--    1 root     root          4096 Feb  9 08:38 fan9_input
> -r--r--r--    1 root     root          4096 Feb  9 08:38 name
> lrwxrwxrwx    1 root     root             0 Feb  9 08:38 of_node -
> > ../../../../../../../../firmware/devicetree/base/ahb/apb/pwm_tach@1e610
> 000/tach
> drwxr-xr-x    2 root     root             0 Feb  9 08:38 power
> lrwxrwxrwx    1 root     root             0 Jan  1  1970 subsystem -
> > ../../../../../../../../class/hwmon
> -rw-r--r--    1 root     root          4096 Jan  1  1970 uevent
> root@mtmitchell:~# ls -la /sys/class/hwmon/hwmon*/pwm*
> -rw-r--r--    1 root     root          4096 Feb  9 09:13
> /sys/class/hwmon/hwmon1/pwm1
> -rw-r--r--    1 root     root          4096 Feb  9 09:20
> /sys/class/hwmon/hwmon2/pwm1
> -rw-r--r--    1 root     root          4096 Feb  9 08:38
> /sys/class/hwmon/hwmon3/pwm1
> -rw-r--r--    1 root     root          4096 Feb  9 08:38
> /sys/class/hwmon/hwmon4/pwm1
> -rw-r--r--    1 root     root          4096 Feb  9 08:38
> /sys/class/hwmon/hwmon5/pwm1
> -rw-r--r--    1 root     root          4096 Feb  9 08:38
> /sys/class/hwmon/hwmon6/pwm1
> -rw-r--r--    1 root     root          4096 Feb  9 08:38
> /sys/class/hwmon/hwmon7/pwm1
> -rw-r--r--    1 root     root          4096 Feb  9 08:38
> /sys/class/hwmon/hwmon8/pwm1
>
> 2. With above changes, the dbus-sensor for FAN/PWM shall not work
> because of the compatibility. So if OpenBMC want to keep above
> PWM/TACH driver, does any sides have the plan to support the fan sensor, if
> not, we can join and do it.
>
> Thank you and best regards,
> Tung

^ permalink raw reply	[flat|nested] 11+ messages in thread

* RE: [AST2600] PWM/TACH driver and dbus-sensor issue
  2022-02-14  3:45   ` Tung Nguyen OS
@ 2022-02-14  4:02     ` Troy Lee
  2022-02-14  4:24       ` Tung Nguyen OS
  0 siblings, 1 reply; 11+ messages in thread
From: Troy Lee @ 2022-02-14  4:02 UTC (permalink / raw)
  To: Tung Nguyen OS, openbmc
  Cc: Billy Tsai, Thu Nguyen OS, Thang Nguyen OS, Phong Vo OS

Adding Billy.

Hi Tung,

> -----Original Message-----
> From: Tung Nguyen OS <tungnguyen@os.amperecomputing.com>
> Sent: Monday, February 14, 2022 11:46 AM
> To: Troy Lee <troy_lee@aspeedtech.com>; openbmc@lists.ozlabs.org
> Cc: Thu Nguyen OS <thu@os.amperecomputing.com>; Thang Nguyen OS
> <thang@os.amperecomputing.com>; Phong Vo OS
> <phong@os.amperecomputing.com>
> Subject: Re: [AST2600] PWM/TACH driver and dbus-sensor issue
> 
> Hi Troy,
> Thank you for the information, i have merged the dbus-sensor patch and see
> it creates the Fan sensors well.
> One more issue i have observed about the fan tach report like this:
> 
> root@mtmitchell:~# echo 120 > /sys/class/hwmon/hwmon1/pwm1
> root@mtmitchell:~# cat /sys/class/hwmon/hwmon0/fan1_input
> 418526
> root@mtmitchell:~# echo 100 > /sys/class/hwmon/hwmon1/pwm1
> root@mtmitchell:~# cat /sys/class/hwmon/hwmon0/fan1_input
> 195312
> root@mtmitchell:~# echo 255 > /sys/class/hwmon/hwmon1/pwm1
> root@mtmitchell:~# cat /sys/class/hwmon/hwmon0/fan1_input
> 0
> root@mtmitchell:~# echo 50 > /sys/class/hwmon/hwmon1/pwm1
> root@mtmitchell:~# cat /sys/class/hwmon/hwmon0/fan1_input
> 0
> 
> It means the fan speed is reported incorrectly somehow, but i can see the
> fan speed changes by eyes, do you have idea on this issue ?

Does the aspeed,pulse-pr property of fan node set correspondingly?
What is the expected RPM of you fan? 418526 RPM?

Thanks,
Troy Lee

> 
> ________________________________________
> From: Troy Lee <troy_lee@aspeedtech.com>
> Sent: Friday, February 11, 2022 12:13 PM
> To: Tung Nguyen OS; openbmc@lists.ozlabs.org
> Cc: Thu Nguyen OS; Thang Nguyen OS; Phong Vo OS
> Subject: RE: [AST2600] PWM/TACH driver and dbus-sensor issue
> 
> Hi Tung,
> 
> > -----Original Message-----
> > From: openbmc <openbmc-
> > bounces+troy_lee=aspeedtech.com@lists.ozlabs.org> On Behalf Of Tung
> > Nguyen OS
> > Sent: Wednesday, February 9, 2022 10:40 PM
> > To: openbmc@lists.ozlabs.org
> > Cc: Thu Nguyen OS <thu@os.amperecomputing.com>; Thang Nguyen OS
> > <thang@os.amperecomputing.com>; Phong Vo OS
> > <phong@os.amperecomputing.com>
> > Subject: [AST2600] PWM/TACH driver and dbus-sensor issue
> >
> > Dear community,
> > We have ported the PWM/TACH hwmon driver for AST2600 from ASPEED's
> > repository https://github.com/AspeedTech-BMC/linux/tree/aspeed-
> master-
> > v5.4/drivers/hwmon to support Ampere Computing's systems. Verify with
> > AST2600 EVB, i can see the driver works. However there is a concern like:
> > 1. The change of hwmon fan pwm/tach in sysfs (as below), this is
> > different from the ast2500 as the separated of the fan*_input and pwm1
> > in various hwmon directories. At this time, the driver doesn't exist
> > in the OpenBMC linux at https://github.com/openbmc/linux. Is OpenBMC
> > going to merge and keep this driver ?
> 
> Please have a look on this patch.
> https://gerrit.openbmc-project.xyz/c/openbmc/dbus-sensors/+/49253
> 
> Thanks,
> Troy Lee
> 
> > root@mtmitchell:~# ls -la /sys/class/hwmon/hwmon hwmon0/ hwmon1/
> > hwmon2/ hwmon3/ hwmon4/ hwmon5/ hwmon6/ hwmon7/ hwmon8/
> hwmon9/
> > root@mtmitchell:~# ls -la /sys/class/hwmon/hwmon0/
> > drwxr-xr-x    3 root     root             0 Jan  1  1970 .
> > drwxr-xr-x    3 root     root             0 Jan  1  1970 ..
> > lrwxrwxrwx    1 root     root             0 Feb  9 08:38 device -
> > > ../../../1e610000.pwm_tach:tach
> > -r--r--r--    1 root     root          4096 Feb  9 08:38 fan10_input
> > -r--r--r--    1 root     root          4096 Feb  9 08:38 fan11_input
> > -r--r--r--    1 root     root          4096 Feb  9 08:38 fan12_input
> > -r--r--r--    1 root     root          4096 Feb  9 08:38 fan13_input
> > -r--r--r--    1 root     root          4096 Feb  9 08:38 fan14_input
> > -r--r--r--    1 root     root          4096 Feb  9 08:38 fan15_input
> > -r--r--r--    1 root     root          4096 Feb  9 08:38 fan16_input
> > -r--r--r--    1 root     root          4096 Feb  9 08:38 fan1_input
> > -r--r--r--    1 root     root          4096 Feb  9 08:38 fan2_input
> > -r--r--r--    1 root     root          4096 Feb  9 08:38 fan3_input
> > -r--r--r--    1 root     root          4096 Feb  9 08:38 fan4_input
> > -r--r--r--    1 root     root          4096 Feb  9 08:38 fan5_input
> > -r--r--r--    1 root     root          4096 Feb  9 08:38 fan6_input
> > -r--r--r--    1 root     root          4096 Feb  9 08:38 fan7_input
> > -r--r--r--    1 root     root          4096 Feb  9 08:38 fan8_input
> > -r--r--r--    1 root     root          4096 Feb  9 08:38 fan9_input
> > -r--r--r--    1 root     root          4096 Feb  9 08:38 name
> > lrwxrwxrwx    1 root     root             0 Feb  9 08:38 of_node -
> > > ../../../../../../../../firmware/devicetree/base/ahb/apb/pwm_tach@1e
> > > 610
> > 000/tach
> > drwxr-xr-x    2 root     root             0 Feb  9 08:38 power
> > lrwxrwxrwx    1 root     root             0 Jan  1  1970 subsystem -
> > > ../../../../../../../../class/hwmon
> > -rw-r--r--    1 root     root          4096 Jan  1  1970 uevent
> > root@mtmitchell:~# ls -la /sys/class/hwmon/hwmon*/pwm*
> > -rw-r--r--    1 root     root          4096 Feb  9 09:13
> > /sys/class/hwmon/hwmon1/pwm1
> > -rw-r--r--    1 root     root          4096 Feb  9 09:20
> > /sys/class/hwmon/hwmon2/pwm1
> > -rw-r--r--    1 root     root          4096 Feb  9 08:38
> > /sys/class/hwmon/hwmon3/pwm1
> > -rw-r--r--    1 root     root          4096 Feb  9 08:38
> > /sys/class/hwmon/hwmon4/pwm1
> > -rw-r--r--    1 root     root          4096 Feb  9 08:38
> > /sys/class/hwmon/hwmon5/pwm1
> > -rw-r--r--    1 root     root          4096 Feb  9 08:38
> > /sys/class/hwmon/hwmon6/pwm1
> > -rw-r--r--    1 root     root          4096 Feb  9 08:38
> > /sys/class/hwmon/hwmon7/pwm1
> > -rw-r--r--    1 root     root          4096 Feb  9 08:38
> > /sys/class/hwmon/hwmon8/pwm1
> >
> > 2. With above changes, the dbus-sensor for FAN/PWM shall not work
> > because of the compatibility. So if OpenBMC want to keep above
> > PWM/TACH driver, does any sides have the plan to support the fan
> > sensor, if not, we can join and do it.
> >
> > Thank you and best regards,
> > Tung

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [AST2600] PWM/TACH driver and dbus-sensor issue
  2022-02-14  4:02     ` Troy Lee
@ 2022-02-14  4:24       ` Tung Nguyen OS
  2022-02-14  6:34         ` Billy Tsai
  0 siblings, 1 reply; 11+ messages in thread
From: Tung Nguyen OS @ 2022-02-14  4:24 UTC (permalink / raw)
  To: Troy Lee, openbmc; +Cc: Billy Tsai, Thu Nguyen OS, Thang Nguyen OS, Phong Vo OS

Hi Troy,
the fan settings in device tree are similar to aspeed-ast2600a1-evb.dts, like:

        fan0: pwm-fan0 {
                compatible = "pwm-fan";
                pwms = <&pwm 0 40000 0>;        /* Target freq:25 kHz */
                cooling-min-state = <0>;
                cooling-max-state = <3>;
                #cooling-cells = <2>;
                cooling-levels = <0 25 128 255>;
        };
 .....
        fan@0 {
                reg = <0x00>;
                aspeed,pulse-pr = <2>;
        };

I test with co-fan F-5010HH12B and San Ace 92 with above setting, and the result looks like in-correct as in previous email.

________________________________________
From: Troy Lee <troy_lee@aspeedtech.com>
Sent: Monday, February 14, 2022 11:02 AM
To: Tung Nguyen OS; openbmc@lists.ozlabs.org
Cc: Thu Nguyen OS; Thang Nguyen OS; Phong Vo OS; Billy Tsai
Subject: RE: [AST2600] PWM/TACH driver and dbus-sensor issue

Adding Billy.

Hi Tung,

> -----Original Message-----
> From: Tung Nguyen OS <tungnguyen@os.amperecomputing.com>
> Sent: Monday, February 14, 2022 11:46 AM
> To: Troy Lee <troy_lee@aspeedtech.com>; openbmc@lists.ozlabs.org
> Cc: Thu Nguyen OS <thu@os.amperecomputing.com>; Thang Nguyen OS
> <thang@os.amperecomputing.com>; Phong Vo OS
> <phong@os.amperecomputing.com>
> Subject: Re: [AST2600] PWM/TACH driver and dbus-sensor issue
>
> Hi Troy,
> Thank you for the information, i have merged the dbus-sensor patch and see
> it creates the Fan sensors well.
> One more issue i have observed about the fan tach report like this:
>
> root@mtmitchell:~# echo 120 > /sys/class/hwmon/hwmon1/pwm1
> root@mtmitchell:~# cat /sys/class/hwmon/hwmon0/fan1_input
> 418526
> root@mtmitchell:~# echo 100 > /sys/class/hwmon/hwmon1/pwm1
> root@mtmitchell:~# cat /sys/class/hwmon/hwmon0/fan1_input
> 195312
> root@mtmitchell:~# echo 255 > /sys/class/hwmon/hwmon1/pwm1
> root@mtmitchell:~# cat /sys/class/hwmon/hwmon0/fan1_input
> 0
> root@mtmitchell:~# echo 50 > /sys/class/hwmon/hwmon1/pwm1
> root@mtmitchell:~# cat /sys/class/hwmon/hwmon0/fan1_input
> 0
>
> It means the fan speed is reported incorrectly somehow, but i can see the
> fan speed changes by eyes, do you have idea on this issue ?

Does the aspeed,pulse-pr property of fan node set correspondingly?
What is the expected RPM of you fan? 418526 RPM?

Thanks,
Troy Lee

>
> ________________________________________
> From: Troy Lee <troy_lee@aspeedtech.com>
> Sent: Friday, February 11, 2022 12:13 PM
> To: Tung Nguyen OS; openbmc@lists.ozlabs.org
> Cc: Thu Nguyen OS; Thang Nguyen OS; Phong Vo OS
> Subject: RE: [AST2600] PWM/TACH driver and dbus-sensor issue
>
> Hi Tung,
>
> > -----Original Message-----
> > From: openbmc <openbmc-
> > bounces+troy_lee=aspeedtech.com@lists.ozlabs.org> On Behalf Of Tung
> > Nguyen OS
> > Sent: Wednesday, February 9, 2022 10:40 PM
> > To: openbmc@lists.ozlabs.org
> > Cc: Thu Nguyen OS <thu@os.amperecomputing.com>; Thang Nguyen OS
> > <thang@os.amperecomputing.com>; Phong Vo OS
> > <phong@os.amperecomputing.com>
> > Subject: [AST2600] PWM/TACH driver and dbus-sensor issue
> >
> > Dear community,
> > We have ported the PWM/TACH hwmon driver for AST2600 from ASPEED's
> > repository https://github.com/AspeedTech-BMC/linux/tree/aspeed-
> master-
> > v5.4/drivers/hwmon to support Ampere Computing's systems. Verify with
> > AST2600 EVB, i can see the driver works. However there is a concern like:
> > 1. The change of hwmon fan pwm/tach in sysfs (as below), this is
> > different from the ast2500 as the separated of the fan*_input and pwm1
> > in various hwmon directories. At this time, the driver doesn't exist
> > in the OpenBMC linux at https://github.com/openbmc/linux. Is OpenBMC
> > going to merge and keep this driver ?
>
> Please have a look on this patch.
> https://gerrit.openbmc-project.xyz/c/openbmc/dbus-sensors/+/49253
>
> Thanks,
> Troy Lee
>
> > root@mtmitchell:~# ls -la /sys/class/hwmon/hwmon hwmon0/ hwmon1/
> > hwmon2/ hwmon3/ hwmon4/ hwmon5/ hwmon6/ hwmon7/ hwmon8/
> hwmon9/
> > root@mtmitchell:~# ls -la /sys/class/hwmon/hwmon0/
> > drwxr-xr-x    3 root     root             0 Jan  1  1970 .
> > drwxr-xr-x    3 root     root             0 Jan  1  1970 ..
> > lrwxrwxrwx    1 root     root             0 Feb  9 08:38 device -
> > > ../../../1e610000.pwm_tach:tach
> > -r--r--r--    1 root     root          4096 Feb  9 08:38 fan10_input
> > -r--r--r--    1 root     root          4096 Feb  9 08:38 fan11_input
> > -r--r--r--    1 root     root          4096 Feb  9 08:38 fan12_input
> > -r--r--r--    1 root     root          4096 Feb  9 08:38 fan13_input
> > -r--r--r--    1 root     root          4096 Feb  9 08:38 fan14_input
> > -r--r--r--    1 root     root          4096 Feb  9 08:38 fan15_input
> > -r--r--r--    1 root     root          4096 Feb  9 08:38 fan16_input
> > -r--r--r--    1 root     root          4096 Feb  9 08:38 fan1_input
> > -r--r--r--    1 root     root          4096 Feb  9 08:38 fan2_input
> > -r--r--r--    1 root     root          4096 Feb  9 08:38 fan3_input
> > -r--r--r--    1 root     root          4096 Feb  9 08:38 fan4_input
> > -r--r--r--    1 root     root          4096 Feb  9 08:38 fan5_input
> > -r--r--r--    1 root     root          4096 Feb  9 08:38 fan6_input
> > -r--r--r--    1 root     root          4096 Feb  9 08:38 fan7_input
> > -r--r--r--    1 root     root          4096 Feb  9 08:38 fan8_input
> > -r--r--r--    1 root     root          4096 Feb  9 08:38 fan9_input
> > -r--r--r--    1 root     root          4096 Feb  9 08:38 name
> > lrwxrwxrwx    1 root     root             0 Feb  9 08:38 of_node -
> > > ../../../../../../../../firmware/devicetree/base/ahb/apb/pwm_tach@1e
> > > 610
> > 000/tach
> > drwxr-xr-x    2 root     root             0 Feb  9 08:38 power
> > lrwxrwxrwx    1 root     root             0 Jan  1  1970 subsystem -
> > > ../../../../../../../../class/hwmon
> > -rw-r--r--    1 root     root          4096 Jan  1  1970 uevent
> > root@mtmitchell:~# ls -la /sys/class/hwmon/hwmon*/pwm*
> > -rw-r--r--    1 root     root          4096 Feb  9 09:13
> > /sys/class/hwmon/hwmon1/pwm1
> > -rw-r--r--    1 root     root          4096 Feb  9 09:20
> > /sys/class/hwmon/hwmon2/pwm1
> > -rw-r--r--    1 root     root          4096 Feb  9 08:38
> > /sys/class/hwmon/hwmon3/pwm1
> > -rw-r--r--    1 root     root          4096 Feb  9 08:38
> > /sys/class/hwmon/hwmon4/pwm1
> > -rw-r--r--    1 root     root          4096 Feb  9 08:38
> > /sys/class/hwmon/hwmon5/pwm1
> > -rw-r--r--    1 root     root          4096 Feb  9 08:38
> > /sys/class/hwmon/hwmon6/pwm1
> > -rw-r--r--    1 root     root          4096 Feb  9 08:38
> > /sys/class/hwmon/hwmon7/pwm1
> > -rw-r--r--    1 root     root          4096 Feb  9 08:38
> > /sys/class/hwmon/hwmon8/pwm1
> >
> > 2. With above changes, the dbus-sensor for FAN/PWM shall not work
> > because of the compatibility. So if OpenBMC want to keep above
> > PWM/TACH driver, does any sides have the plan to support the fan
> > sensor, if not, we can join and do it.
> >
> > Thank you and best regards,
> > Tung

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [AST2600] PWM/TACH driver and dbus-sensor issue
  2022-02-14  4:24       ` Tung Nguyen OS
@ 2022-02-14  6:34         ` Billy Tsai
  2022-02-15 10:10           ` Tung Nguyen OS
  0 siblings, 1 reply; 11+ messages in thread
From: Billy Tsai @ 2022-02-14  6:34 UTC (permalink / raw)
  To: Tung Nguyen OS, Troy Lee, openbmc
  Cc: Thu Nguyen OS, Thang Nguyen OS, Phong Vo OS

[-- Attachment #1: Type: text/plain, Size: 8081 bytes --]

Hi Tung,

Can you check the PWM frequency and dump the register value 0x1e610000~0x1e61000c?

Thanks

Best Regards,
Billy Tsai

From: Tung Nguyen OS <tungnguyen@os.amperecomputing.com>
Date: Monday, February 14, 2022 at 12:24 PM
To: Troy Lee <troy_lee@aspeedtech.com>, "openbmc@lists.ozlabs.org" <openbmc@lists.ozlabs.org>
Cc: Thu Nguyen OS <thu@os.amperecomputing.com>, Thang Nguyen OS <thang@os.amperecomputing.com>, Phong Vo OS <phong@os.amperecomputing.com>, Billy Tsai <billy_tsai@aspeedtech.com>
Subject: Re: [AST2600] PWM/TACH driver and dbus-sensor issue

Hi Troy,
the fan settings in device tree are similar to aspeed-ast2600a1-evb.dts, like:

        fan0: pwm-fan0 {
                compatible = "pwm-fan";
                pwms = <&pwm 0 40000 0>;        /* Target freq:25 kHz */
                cooling-min-state = <0>;
                cooling-max-state = <3>;
                #cooling-cells = <2>;
                cooling-levels = <0 25 128 255>;
        };
.....
        fan@0 {
                reg = <0x00>;
                aspeed,pulse-pr = <2>;
        };

I test with co-fan F-5010HH12B and San Ace 92 with above setting, and the result looks like in-correct as in previous email.

________________________________________
From: Troy Lee <troy_lee@aspeedtech.com<mailto:troy_lee@aspeedtech.com>>
Sent: Monday, February 14, 2022 11:02 AM
To: Tung Nguyen OS; openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org>
Cc: Thu Nguyen OS; Thang Nguyen OS; Phong Vo OS; Billy Tsai
Subject: RE: [AST2600] PWM/TACH driver and dbus-sensor issue

Adding Billy.

Hi Tung,

-----Original Message-----
From: Tung Nguyen OS <tungnguyen@os.amperecomputing.com<mailto:tungnguyen@os.amperecomputing.com>>
Sent: Monday, February 14, 2022 11:46 AM
To: Troy Lee <troy_lee@aspeedtech.com<mailto:troy_lee@aspeedtech.com>>; openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org>
Cc: Thu Nguyen OS <thu@os.amperecomputing.com<mailto:thu@os.amperecomputing.com>>; Thang Nguyen OS
<thang@os.amperecomputing.com<mailto:thang@os.amperecomputing.com>>; Phong Vo OS
<phong@os.amperecomputing.com<mailto:phong@os.amperecomputing.com>>
Subject: Re: [AST2600] PWM/TACH driver and dbus-sensor issue

Hi Troy,
Thank you for the information, i have merged the dbus-sensor patch and see
it creates the Fan sensors well.
One more issue i have observed about the fan tach report like this:

root@mtmitchell:~# echo 120 > /sys/class/hwmon/hwmon1/pwm1
root@mtmitchell:~# cat /sys/class/hwmon/hwmon0/fan1_input
418526
root@mtmitchell:~# echo 100 > /sys/class/hwmon/hwmon1/pwm1
root@mtmitchell:~# cat /sys/class/hwmon/hwmon0/fan1_input
195312
root@mtmitchell:~# echo 255 > /sys/class/hwmon/hwmon1/pwm1
root@mtmitchell:~# cat /sys/class/hwmon/hwmon0/fan1_input
0
root@mtmitchell:~# echo 50 > /sys/class/hwmon/hwmon1/pwm1
root@mtmitchell:~# cat /sys/class/hwmon/hwmon0/fan1_input
0

It means the fan speed is reported incorrectly somehow, but i can see the
fan speed changes by eyes, do you have idea on this issue ?

Does the aspeed,pulse-pr property of fan node set correspondingly?
What is the expected RPM of you fan? 418526 RPM?

Thanks,
Troy Lee


________________________________________
From: Troy Lee <troy_lee@aspeedtech.com<mailto:troy_lee@aspeedtech.com>>
Sent: Friday, February 11, 2022 12:13 PM
To: Tung Nguyen OS; openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org>
Cc: Thu Nguyen OS; Thang Nguyen OS; Phong Vo OS
Subject: RE: [AST2600] PWM/TACH driver and dbus-sensor issue

Hi Tung,

> -----Original Message-----
> From: openbmc <openbmc-
> bounces+troy_lee=aspeedtech.com@lists.ozlabs.org<mailto:aspeedtech.com@lists.ozlabs.org>> On Behalf Of Tung
> Nguyen OS
> Sent: Wednesday, February 9, 2022 10:40 PM
> To: openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org>
> Cc: Thu Nguyen OS <thu@os.amperecomputing.com<mailto:thu@os.amperecomputing.com>>; Thang Nguyen OS
> <thang@os.amperecomputing.com<mailto:thang@os.amperecomputing.com>>; Phong Vo OS
> <phong@os.amperecomputing.com<mailto:phong@os.amperecomputing.com>>
> Subject: [AST2600] PWM/TACH driver and dbus-sensor issue
>
> Dear community,
> We have ported the PWM/TACH hwmon driver for AST2600 from ASPEED's
> repository https://github.com/AspeedTech-BMC/linux/tree/aspeed-
master-
> v5.4/drivers/hwmon to support Ampere Computing's systems. Verify with
> AST2600 EVB, i can see the driver works. However there is a concern like:
> 1. The change of hwmon fan pwm/tach in sysfs (as below), this is
> different from the ast2500 as the separated of the fan*_input and pwm1
> in various hwmon directories. At this time, the driver doesn't exist
> in the OpenBMC linux at https://github.com/openbmc/linux. Is OpenBMC
> going to merge and keep this driver ?

Please have a look on this patch.
https://gerrit.openbmc-project.xyz/c/openbmc/dbus-sensors/+/49253

Thanks,
Troy Lee

> root@mtmitchell:~# ls -la /sys/class/hwmon/hwmon hwmon0/ hwmon1/
> hwmon2/ hwmon3/ hwmon4/ hwmon5/ hwmon6/ hwmon7/ hwmon8/
hwmon9/
> root@mtmitchell:~# ls -la /sys/class/hwmon/hwmon0/
> drwxr-xr-x    3 root     root             0 Jan  1  1970 .
> drwxr-xr-x    3 root     root             0 Jan  1  1970 ..
> lrwxrwxrwx    1 root     root             0 Feb  9 08:38 device -
> > ../../../1e610000.pwm_tach:tach
> -r--r--r--    1 root     root          4096 Feb  9 08:38 fan10_input
> -r--r--r--    1 root     root          4096 Feb  9 08:38 fan11_input
> -r--r--r--    1 root     root          4096 Feb  9 08:38 fan12_input
> -r--r--r--    1 root     root          4096 Feb  9 08:38 fan13_input
> -r--r--r--    1 root     root          4096 Feb  9 08:38 fan14_input
> -r--r--r--    1 root     root          4096 Feb  9 08:38 fan15_input
> -r--r--r--    1 root     root          4096 Feb  9 08:38 fan16_input
> -r--r--r--    1 root     root          4096 Feb  9 08:38 fan1_input
> -r--r--r--    1 root     root          4096 Feb  9 08:38 fan2_input
> -r--r--r--    1 root     root          4096 Feb  9 08:38 fan3_input
> -r--r--r--    1 root     root          4096 Feb  9 08:38 fan4_input
> -r--r--r--    1 root     root          4096 Feb  9 08:38 fan5_input
> -r--r--r--    1 root     root          4096 Feb  9 08:38 fan6_input
> -r--r--r--    1 root     root          4096 Feb  9 08:38 fan7_input
> -r--r--r--    1 root     root          4096 Feb  9 08:38 fan8_input
> -r--r--r--    1 root     root          4096 Feb  9 08:38 fan9_input
> -r--r--r--    1 root     root          4096 Feb  9 08:38 name
> lrwxrwxrwx    1 root     root             0 Feb  9 08:38 of_node -
> > ../../../../../../../../firmware/devicetree/base/ahb/apb/pwm_tach@1e
> > 610
> 000/tach
> drwxr-xr-x    2 root     root             0 Feb  9 08:38 power
> lrwxrwxrwx    1 root     root             0 Jan  1  1970 subsystem -
> > ../../../../../../../../class/hwmon
> -rw-r--r--    1 root     root          4096 Jan  1  1970 uevent
> root@mtmitchell:~# ls -la /sys/class/hwmon/hwmon*/pwm*
> -rw-r--r--    1 root     root          4096 Feb  9 09:13
> /sys/class/hwmon/hwmon1/pwm1
> -rw-r--r--    1 root     root          4096 Feb  9 09:20
> /sys/class/hwmon/hwmon2/pwm1
> -rw-r--r--    1 root     root          4096 Feb  9 08:38
> /sys/class/hwmon/hwmon3/pwm1
> -rw-r--r--    1 root     root          4096 Feb  9 08:38
> /sys/class/hwmon/hwmon4/pwm1
> -rw-r--r--    1 root     root          4096 Feb  9 08:38
> /sys/class/hwmon/hwmon5/pwm1
> -rw-r--r--    1 root     root          4096 Feb  9 08:38
> /sys/class/hwmon/hwmon6/pwm1
> -rw-r--r--    1 root     root          4096 Feb  9 08:38
> /sys/class/hwmon/hwmon7/pwm1
> -rw-r--r--    1 root     root          4096 Feb  9 08:38
> /sys/class/hwmon/hwmon8/pwm1
>
> 2. With above changes, the dbus-sensor for FAN/PWM shall not work
> because of the compatibility. So if OpenBMC want to keep above
> PWM/TACH driver, does any sides have the plan to support the fan
> sensor, if not, we can join and do it.
>
> Thank you and best regards,
> Tung


[-- Attachment #2: Type: text/html, Size: 24879 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [AST2600] PWM/TACH driver and dbus-sensor issue
  2022-02-14  6:34         ` Billy Tsai
@ 2022-02-15 10:10           ` Tung Nguyen OS
  2022-02-15 10:33             ` Billy Tsai
  0 siblings, 1 reply; 11+ messages in thread
From: Tung Nguyen OS @ 2022-02-15 10:10 UTC (permalink / raw)
  To: Billy Tsai, Troy Lee, openbmc; +Cc: Thu Nguyen OS, Thang Nguyen OS, Phong Vo OS

Hi Billy,

Please help check:
root@sunmoonlake:/tmp# ./test.sh 100
echo 100 > /sys/class/hwmon/hwmon1/pwm1
cat /sys/class/hwmon/hwmon0/fan1_input
0
devmem 0x1e610000
0x0001101E
devmem 0x1e610004
0xFF006500
devmem 0x1e610008
0x10500000
devmem 0x1e61000c
0xA5400000
root@sunmoonlake:/tmp# ./test.sh 120
echo 120 > /sys/class/hwmon/hwmon1/pwm1
cat /sys/class/hwmon/hwmon0/fan1_input
266335
devmem 0x1e610000
0x0001101E
devmem 0x1e610004
0xFF007900
devmem 0x1e610008
0x10500000
devmem 0x1e61000c
0xF4B00016
root@sunmoonlake:/tmp# ./test.sh 140
echo 140 > /sys/class/hwmon/hwmon1/pwm1
cat /sys/class/hwmon/hwmon0/fan1_input
837053
devmem 0x1e610000
0x0001101E
devmem 0x1e610004
0xFF008D00
devmem 0x1e610008
0x10500000
devmem 0x1e61000c
0xE4B00007
root@sunmoonlake:/tmp# ./test.sh 255
echo 255 > /sys/class/hwmon/hwmon1/pwm1
cat /sys/class/hwmon/hwmon0/fan1_input
0
devmem 0x1e610000
0x0001101E
devmem 0x1e610004
0xFF000000
devmem 0x1e610008
0x10500000
devmem 0x1e61000c
0xB5C00000
root@sunmoonlake:/tmp#

Please note that i'm using the fan settings as:

        fan0: pwm-fan0 {
                compatible = "pwm-fan";
                pwms = <&pwm 0 40000 0>;        /* Target freq:25 kHz */
                cooling-min-state = <0>;
                cooling-max-state = <3>;
                #cooling-cells = <2>;
                cooling-levels = <0 25 128 255>;
        };
.....
        fan@0 {
                reg = <0x00>;
                aspeed,pulse-pr = <2>;
        };


________________________________________
From: Billy Tsai <billy_tsai@aspeedtech.com>
Sent: Monday, February 14, 2022 1:34 PM
To: Tung Nguyen OS; Troy Lee; openbmc@lists.ozlabs.org
Cc: Thu Nguyen OS; Thang Nguyen OS; Phong Vo OS
Subject: Re: [AST2600] PWM/TACH driver and dbus-sensor issue

Hi Tung,

Can you check the PWM frequency and dump the register value 0x1e610000~0x1e61000c?

Thanks

Best Regards,
Billy Tsai

From: Tung Nguyen OS <tungnguyen@os.amperecomputing.com>
Date: Monday, February 14, 2022 at 12:24 PM
To: Troy Lee <troy_lee@aspeedtech.com>, "openbmc@lists.ozlabs.org" <openbmc@lists.ozlabs.org>
Cc: Thu Nguyen OS <thu@os.amperecomputing.com>, Thang Nguyen OS <thang@os.amperecomputing.com>, Phong Vo OS <phong@os.amperecomputing.com>, Billy Tsai <billy_tsai@aspeedtech.com>
Subject: Re: [AST2600] PWM/TACH driver and dbus-sensor issue

Hi Troy,
the fan settings in device tree are similar to aspeed-ast2600a1-evb.dts, like:

        fan0: pwm-fan0 {
                compatible = "pwm-fan";
                pwms = <&pwm 0 40000 0>;        /* Target freq:25 kHz */
                cooling-min-state = <0>;
                cooling-max-state = <3>;
                #cooling-cells = <2>;
                cooling-levels = <0 25 128 255>;
        };
.....
        fan@0 {
                reg = <0x00>;
                aspeed,pulse-pr = <2>;
        };

I test with co-fan F-5010HH12B and San Ace 92 with above setting, and the result looks like in-correct as in previous email.

________________________________________
From: Troy Lee <troy_lee@aspeedtech.com<mailto:troy_lee@aspeedtech.com>>
Sent: Monday, February 14, 2022 11:02 AM
To: Tung Nguyen OS; openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org>
Cc: Thu Nguyen OS; Thang Nguyen OS; Phong Vo OS; Billy Tsai
Subject: RE: [AST2600] PWM/TACH driver and dbus-sensor issue

Adding Billy.

Hi Tung,

-----Original Message-----
From: Tung Nguyen OS <tungnguyen@os.amperecomputing.com<mailto:tungnguyen@os.amperecomputing.com>>
Sent: Monday, February 14, 2022 11:46 AM
To: Troy Lee <troy_lee@aspeedtech.com<mailto:troy_lee@aspeedtech.com>>; openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org>
Cc: Thu Nguyen OS <thu@os.amperecomputing.com<mailto:thu@os.amperecomputing.com>>; Thang Nguyen OS
<thang@os.amperecomputing.com<mailto:thang@os.amperecomputing.com>>; Phong Vo OS
<phong@os.amperecomputing.com<mailto:phong@os.amperecomputing.com>>
Subject: Re: [AST2600] PWM/TACH driver and dbus-sensor issue

Hi Troy,
Thank you for the information, i have merged the dbus-sensor patch and see
it creates the Fan sensors well.
One more issue i have observed about the fan tach report like this:

root@mtmitchell:~# echo 120 > /sys/class/hwmon/hwmon1/pwm1
root@mtmitchell:~# cat /sys/class/hwmon/hwmon0/fan1_input
418526
root@mtmitchell:~# echo 100 > /sys/class/hwmon/hwmon1/pwm1
root@mtmitchell:~# cat /sys/class/hwmon/hwmon0/fan1_input
195312
root@mtmitchell:~# echo 255 > /sys/class/hwmon/hwmon1/pwm1
root@mtmitchell:~# cat /sys/class/hwmon/hwmon0/fan1_input
0
root@mtmitchell:~# echo 50 > /sys/class/hwmon/hwmon1/pwm1
root@mtmitchell:~# cat /sys/class/hwmon/hwmon0/fan1_input
0

It means the fan speed is reported incorrectly somehow, but i can see the
fan speed changes by eyes, do you have idea on this issue ?

Does the aspeed,pulse-pr property of fan node set correspondingly?
What is the expected RPM of you fan? 418526 RPM?

Thanks,
Troy Lee


________________________________________
From: Troy Lee <troy_lee@aspeedtech.com<mailto:troy_lee@aspeedtech.com>>
Sent: Friday, February 11, 2022 12:13 PM
To: Tung Nguyen OS; openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org>
Cc: Thu Nguyen OS; Thang Nguyen OS; Phong Vo OS
Subject: RE: [AST2600] PWM/TACH driver and dbus-sensor issue

Hi Tung,

> -----Original Message-----
> From: openbmc <openbmc-
> bounces+troy_lee=aspeedtech.com@lists.ozlabs.org<mailto:aspeedtech.com@lists.ozlabs.org>> On Behalf Of Tung
> Nguyen OS
> Sent: Wednesday, February 9, 2022 10:40 PM
> To: openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org>
> Cc: Thu Nguyen OS <thu@os.amperecomputing.com<mailto:thu@os.amperecomputing.com>>; Thang Nguyen OS
> <thang@os.amperecomputing.com<mailto:thang@os.amperecomputing.com>>; Phong Vo OS
> <phong@os.amperecomputing.com<mailto:phong@os.amperecomputing.com>>
> Subject: [AST2600] PWM/TACH driver and dbus-sensor issue
>
> Dear community,
> We have ported the PWM/TACH hwmon driver for AST2600 from ASPEED's
> repository https://github.com/AspeedTech-BMC/linux/tree/aspeed-
master-
> v5.4/drivers/hwmon to support Ampere Computing's systems. Verify with
> AST2600 EVB, i can see the driver works. However there is a concern like:
> 1. The change of hwmon fan pwm/tach in sysfs (as below), this is
> different from the ast2500 as the separated of the fan*_input and pwm1
> in various hwmon directories. At this time, the driver doesn't exist
> in the OpenBMC linux at https://github.com/openbmc/linux. Is OpenBMC
> going to merge and keep this driver ?

Please have a look on this patch.
https://gerrit.openbmc-project.xyz/c/openbmc/dbus-sensors/+/49253

Thanks,
Troy Lee

> root@mtmitchell:~# ls -la /sys/class/hwmon/hwmon hwmon0/ hwmon1/
> hwmon2/ hwmon3/ hwmon4/ hwmon5/ hwmon6/ hwmon7/ hwmon8/
hwmon9/
> root@mtmitchell:~# ls -la /sys/class/hwmon/hwmon0/
> drwxr-xr-x    3 root     root             0 Jan  1  1970 .
> drwxr-xr-x    3 root     root             0 Jan  1  1970 ..
> lrwxrwxrwx    1 root     root             0 Feb  9 08:38 device -
> > ../../../1e610000.pwm_tach:tach
> -r--r--r--    1 root     root          4096 Feb  9 08:38 fan10_input
> -r--r--r--    1 root     root          4096 Feb  9 08:38 fan11_input
> -r--r--r--    1 root     root          4096 Feb  9 08:38 fan12_input
> -r--r--r--    1 root     root          4096 Feb  9 08:38 fan13_input
> -r--r--r--    1 root     root          4096 Feb  9 08:38 fan14_input
> -r--r--r--    1 root     root          4096 Feb  9 08:38 fan15_input
> -r--r--r--    1 root     root          4096 Feb  9 08:38 fan16_input
> -r--r--r--    1 root     root          4096 Feb  9 08:38 fan1_input
> -r--r--r--    1 root     root          4096 Feb  9 08:38 fan2_input
> -r--r--r--    1 root     root          4096 Feb  9 08:38 fan3_input
> -r--r--r--    1 root     root          4096 Feb  9 08:38 fan4_input
> -r--r--r--    1 root     root          4096 Feb  9 08:38 fan5_input
> -r--r--r--    1 root     root          4096 Feb  9 08:38 fan6_input
> -r--r--r--    1 root     root          4096 Feb  9 08:38 fan7_input
> -r--r--r--    1 root     root          4096 Feb  9 08:38 fan8_input
> -r--r--r--    1 root     root          4096 Feb  9 08:38 fan9_input
> -r--r--r--    1 root     root          4096 Feb  9 08:38 name
> lrwxrwxrwx    1 root     root             0 Feb  9 08:38 of_node -
> > ../../../../../../../../firmware/devicetree/base/ahb/apb/pwm_tach@1e
> > 610
> 000/tach
> drwxr-xr-x    2 root     root             0 Feb  9 08:38 power
> lrwxrwxrwx    1 root     root             0 Jan  1  1970 subsystem -
> > ../../../../../../../../class/hwmon
> -rw-r--r--    1 root     root          4096 Jan  1  1970 uevent
> root@mtmitchell:~# ls -la /sys/class/hwmon/hwmon*/pwm*
> -rw-r--r--    1 root     root          4096 Feb  9 09:13
> /sys/class/hwmon/hwmon1/pwm1
> -rw-r--r--    1 root     root          4096 Feb  9 09:20
> /sys/class/hwmon/hwmon2/pwm1
> -rw-r--r--    1 root     root          4096 Feb  9 08:38
> /sys/class/hwmon/hwmon3/pwm1
> -rw-r--r--    1 root     root          4096 Feb  9 08:38
> /sys/class/hwmon/hwmon4/pwm1
> -rw-r--r--    1 root     root          4096 Feb  9 08:38
> /sys/class/hwmon/hwmon5/pwm1
> -rw-r--r--    1 root     root          4096 Feb  9 08:38
> /sys/class/hwmon/hwmon6/pwm1
> -rw-r--r--    1 root     root          4096 Feb  9 08:38
> /sys/class/hwmon/hwmon7/pwm1
> -rw-r--r--    1 root     root          4096 Feb  9 08:38
> /sys/class/hwmon/hwmon8/pwm1
>
> 2. With above changes, the dbus-sensor for FAN/PWM shall not work
> because of the compatibility. So if OpenBMC want to keep above
> PWM/TACH driver, does any sides have the plan to support the fan
> sensor, if not, we can join and do it.
>
> Thank you and best regards,
> Tung


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [AST2600] PWM/TACH driver and dbus-sensor issue
  2022-02-15 10:10           ` Tung Nguyen OS
@ 2022-02-15 10:33             ` Billy Tsai
  2022-02-16  7:07               ` Tung Nguyen OS
  0 siblings, 1 reply; 11+ messages in thread
From: Billy Tsai @ 2022-02-15 10:33 UTC (permalink / raw)
  To: Tung Nguyen OS, Troy Lee, openbmc
  Cc: Thu Nguyen OS, Thang Nguyen OS, Phong Vo OS

[-- Attachment #1: Type: text/plain, Size: 12506 bytes --]

Hi Tung,

The register setting looks fine.
Can you check the connection of the FAN tach pin and BMC tach input pin?
If it is normal, can you check the FAN tach output waveform?

I test with San Ace 80 and get the result below:

root@ast2600-default:~# cat /sys/class/hwmon/hwmon1/fan1_input
3570
root@ast2600-default:~# echo 100 > /sys/class/hwmon/hwmon4/pwm1
root@ast2600-default:~# cat /sys/class/hwmon/hwmon1/fan1_input
3568
root@ast2600-default:~# echo 120 > /sys/class/hwmon/hwmon4/pwm1
root@ast2600-default:~# cat /sys/class/hwmon/hwmon1/fan1_input
4032
root@ast2600-default:~# echo 140 > /sys/class/hwmon/hwmon4/pwm1
root@ast2600-default:~# cat /sys/class/hwmon/hwmon1/fan1_input
4422
root@ast2600-default:~# echo 255 > /sys/class/hwmon/hwmon4/pwm1
root@ast2600-default:~# cat /sys/class/hwmon/hwmon1/fan1_input
6293


Thanks

Best Regards,
Billy Tsai

From: Tung Nguyen OS <tungnguyen@os.amperecomputing.com>
Date: Tuesday, February 15, 2022 at 6:10 PM
To: Billy Tsai <billy_tsai@aspeedtech.com>, Troy Lee <troy_lee@aspeedtech.com>, "openbmc@lists.ozlabs.org" <openbmc@lists.ozlabs.org>
Cc: Thu Nguyen OS <thu@os.amperecomputing.com>, Thang Nguyen OS <thang@os.amperecomputing.com>, Phong Vo OS <phong@os.amperecomputing.com>
Subject: Re: [AST2600] PWM/TACH driver and dbus-sensor issue

Hi Billy,

Please help check:
root@sunmoonlake:/tmp# ./test.sh 100
echo 100 > /sys/class/hwmon/hwmon1/pwm1
cat /sys/class/hwmon/hwmon0/fan1_input
0
devmem 0x1e610000
0x0001101E
devmem 0x1e610004
0xFF006500
devmem 0x1e610008
0x10500000
devmem 0x1e61000c
0xA5400000
root@sunmoonlake:/tmp# ./test.sh 120
echo 120 > /sys/class/hwmon/hwmon1/pwm1
cat /sys/class/hwmon/hwmon0/fan1_input
266335
devmem 0x1e610000
0x0001101E
devmem 0x1e610004
0xFF007900
devmem 0x1e610008
0x10500000
devmem 0x1e61000c
0xF4B00016
root@sunmoonlake:/tmp# ./test.sh 140
echo 140 > /sys/class/hwmon/hwmon1/pwm1
cat /sys/class/hwmon/hwmon0/fan1_input
837053
devmem 0x1e610000
0x0001101E
devmem 0x1e610004
0xFF008D00
devmem 0x1e610008
0x10500000
devmem 0x1e61000c
0xE4B00007
root@sunmoonlake:/tmp# ./test.sh 255
echo 255 > /sys/class/hwmon/hwmon1/pwm1
cat /sys/class/hwmon/hwmon0/fan1_input
0
devmem 0x1e610000
0x0001101E
devmem 0x1e610004
0xFF000000
devmem 0x1e610008
0x10500000
devmem 0x1e61000c
0xB5C00000
root@sunmoonlake:/tmp#

Please note that i'm using the fan settings as:

        fan0: pwm-fan0 {
                compatible = "pwm-fan";
                pwms = <&pwm 0 40000 0>;        /* Target freq:25 kHz */
                cooling-min-state = <0>;
                cooling-max-state = <3>;
                #cooling-cells = <2>;
                cooling-levels = <0 25 128 255>;
        };
.....
        fan@0 {
                reg = <0x00>;
                aspeed,pulse-pr = <2>;
        };


________________________________________
From: Billy Tsai <billy_tsai@aspeedtech.com<mailto:billy_tsai@aspeedtech.com>>
Sent: Monday, February 14, 2022 1:34 PM
To: Tung Nguyen OS; Troy Lee; openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org>
Cc: Thu Nguyen OS; Thang Nguyen OS; Phong Vo OS
Subject: Re: [AST2600] PWM/TACH driver and dbus-sensor issue

Hi Tung,

Can you check the PWM frequency and dump the register value 0x1e610000~0x1e61000c?

Thanks

Best Regards,
Billy Tsai

From: Tung Nguyen OS <tungnguyen@os.amperecomputing.com<mailto:tungnguyen@os.amperecomputing.com>>
Date: Monday, February 14, 2022 at 12:24 PM
To: Troy Lee <troy_lee@aspeedtech.com<mailto:troy_lee@aspeedtech.com>>, "openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org>" <openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org>>
Cc: Thu Nguyen OS <thu@os.amperecomputing.com<mailto:thu@os.amperecomputing.com>>, Thang Nguyen OS <thang@os.amperecomputing.com<mailto:thang@os.amperecomputing.com>>, Phong Vo OS <phong@os.amperecomputing.com<mailto:phong@os.amperecomputing.com>>, Billy Tsai <billy_tsai@aspeedtech.com<mailto:billy_tsai@aspeedtech.com>>
Subject: Re: [AST2600] PWM/TACH driver and dbus-sensor issue

Hi Troy,
the fan settings in device tree are similar to aspeed-ast2600a1-evb.dts, like:

        fan0: pwm-fan0 {
                compatible = "pwm-fan";
                pwms = <&pwm 0 40000 0>;        /* Target freq:25 kHz */
                cooling-min-state = <0>;
                cooling-max-state = <3>;
                #cooling-cells = <2>;
                cooling-levels = <0 25 128 255>;
        };
.....
        fan@0 {
                reg = <0x00>;
                aspeed,pulse-pr = <2>;
        };

I test with co-fan F-5010HH12B and San Ace 92 with above setting, and the result looks like in-correct as in previous email.

________________________________________
From: Troy Lee <troy_lee@aspeedtech.com<mailto:troy_lee@aspeedtech.com><mailto:troy_lee@aspeedtech.com<mailto:troy_lee@aspeedtech.com>>>
Sent: Monday, February 14, 2022 11:02 AM
To: Tung Nguyen OS; openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org><mailto:openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org>>
Cc: Thu Nguyen OS; Thang Nguyen OS; Phong Vo OS; Billy Tsai
Subject: RE: [AST2600] PWM/TACH driver and dbus-sensor issue

Adding Billy.

Hi Tung,

-----Original Message-----
From: Tung Nguyen OS <tungnguyen@os.amperecomputing.com<mailto:tungnguyen@os.amperecomputing.com><mailto:tungnguyen@os.amperecomputing.com<mailto:tungnguyen@os.amperecomputing.com>>>
Sent: Monday, February 14, 2022 11:46 AM
To: Troy Lee <troy_lee@aspeedtech.com<mailto:troy_lee@aspeedtech.com><mailto:troy_lee@aspeedtech.com<mailto:troy_lee@aspeedtech.com>>>; openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org><mailto:openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org>>
Cc: Thu Nguyen OS <thu@os.amperecomputing.com<mailto:thu@os.amperecomputing.com><mailto:thu@os.amperecomputing.com<mailto:thu@os.amperecomputing.com>>>; Thang Nguyen OS
<thang@os.amperecomputing.com<mailto:thang@os.amperecomputing.com><mailto:thang@os.amperecomputing.com<mailto:thang@os.amperecomputing.com>>>; Phong Vo OS
<phong@os.amperecomputing.com<mailto:phong@os.amperecomputing.com><mailto:phong@os.amperecomputing.com<mailto:phong@os.amperecomputing.com>>>
Subject: Re: [AST2600] PWM/TACH driver and dbus-sensor issue

Hi Troy,
Thank you for the information, i have merged the dbus-sensor patch and see
it creates the Fan sensors well.
One more issue i have observed about the fan tach report like this:

root@mtmitchell:~# echo 120 > /sys/class/hwmon/hwmon1/pwm1
root@mtmitchell:~# cat /sys/class/hwmon/hwmon0/fan1_input
418526
root@mtmitchell:~# echo 100 > /sys/class/hwmon/hwmon1/pwm1
root@mtmitchell:~# cat /sys/class/hwmon/hwmon0/fan1_input
195312
root@mtmitchell:~# echo 255 > /sys/class/hwmon/hwmon1/pwm1
root@mtmitchell:~# cat /sys/class/hwmon/hwmon0/fan1_input
0
root@mtmitchell:~# echo 50 > /sys/class/hwmon/hwmon1/pwm1
root@mtmitchell:~# cat /sys/class/hwmon/hwmon0/fan1_input
0

It means the fan speed is reported incorrectly somehow, but i can see the
fan speed changes by eyes, do you have idea on this issue ?

Does the aspeed,pulse-pr property of fan node set correspondingly?
What is the expected RPM of you fan? 418526 RPM?

Thanks,
Troy Lee


________________________________________
From: Troy Lee <troy_lee@aspeedtech.com<mailto:troy_lee@aspeedtech.com><mailto:troy_lee@aspeedtech.com<mailto:troy_lee@aspeedtech.com>>>
Sent: Friday, February 11, 2022 12:13 PM
To: Tung Nguyen OS; openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org><mailto:openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org>>
Cc: Thu Nguyen OS; Thang Nguyen OS; Phong Vo OS
Subject: RE: [AST2600] PWM/TACH driver and dbus-sensor issue

Hi Tung,

-----Original Message-----
From: openbmc <openbmc-
bounces+troy_lee=aspeedtech.com@lists.ozlabs.org<mailto:aspeedtech.com@lists.ozlabs.org><mailto:aspeedtech.com@lists.ozlabs.org<mailto:aspeedtech.com@lists.ozlabs.org>>> On Behalf Of Tung
Nguyen OS
Sent: Wednesday, February 9, 2022 10:40 PM
To: openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org><mailto:openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org>>
Cc: Thu Nguyen OS <thu@os.amperecomputing.com<mailto:thu@os.amperecomputing.com><mailto:thu@os.amperecomputing.com<mailto:thu@os.amperecomputing.com>>>; Thang Nguyen OS
<thang@os.amperecomputing.com<mailto:thang@os.amperecomputing.com><mailto:thang@os.amperecomputing.com<mailto:thang@os.amperecomputing.com>>>; Phong Vo OS
<phong@os.amperecomputing.com<mailto:phong@os.amperecomputing.com><mailto:phong@os.amperecomputing.com<mailto:phong@os.amperecomputing.com>>>
Subject: [AST2600] PWM/TACH driver and dbus-sensor issue

Dear community,
We have ported the PWM/TACH hwmon driver for AST2600 from ASPEED's
repository https://github.com/AspeedTech-BMC/linux/tree/aspeed-
master-
v5.4/drivers/hwmon to support Ampere Computing's systems. Verify with
AST2600 EVB, i can see the driver works. However there is a concern like:
1. The change of hwmon fan pwm/tach in sysfs (as below), this is
different from the ast2500 as the separated of the fan*_input and pwm1
in various hwmon directories. At this time, the driver doesn't exist
in the OpenBMC linux at https://github.com/openbmc/linux. Is OpenBMC
going to merge and keep this driver ?

Please have a look on this patch.
https://gerrit.openbmc-project.xyz/c/openbmc/dbus-sensors/+/49253

Thanks,
Troy Lee

root@mtmitchell:~# ls -la /sys/class/hwmon/hwmon hwmon0/ hwmon1/
hwmon2/ hwmon3/ hwmon4/ hwmon5/ hwmon6/ hwmon7/ hwmon8/
hwmon9/
root@mtmitchell:~# ls -la /sys/class/hwmon/hwmon0/
drwxr-xr-x    3 root     root             0 Jan  1  1970 .
drwxr-xr-x    3 root     root             0 Jan  1  1970 ..
lrwxrwxrwx    1 root     root             0 Feb  9 08:38 device -
> ../../../1e610000.pwm_tach:tach
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan10_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan11_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan12_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan13_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan14_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan15_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan16_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan1_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan2_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan3_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan4_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan5_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan6_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan7_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan8_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan9_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 name
lrwxrwxrwx    1 root     root             0 Feb  9 08:38 of_node -
> ../../../../../../../../firmware/devicetree/base/ahb/apb/pwm_tach@1e
> 610
000/tach
drwxr-xr-x    2 root     root             0 Feb  9 08:38 power
lrwxrwxrwx    1 root     root             0 Jan  1  1970 subsystem -
> ../../../../../../../../class/hwmon
-rw-r--r--    1 root     root          4096 Jan  1  1970 uevent
root@mtmitchell:~# ls -la /sys/class/hwmon/hwmon*/pwm*
-rw-r--r--    1 root     root          4096 Feb  9 09:13
/sys/class/hwmon/hwmon1/pwm1
-rw-r--r--    1 root     root          4096 Feb  9 09:20
/sys/class/hwmon/hwmon2/pwm1
-rw-r--r--    1 root     root          4096 Feb  9 08:38
/sys/class/hwmon/hwmon3/pwm1
-rw-r--r--    1 root     root          4096 Feb  9 08:38
/sys/class/hwmon/hwmon4/pwm1
-rw-r--r--    1 root     root          4096 Feb  9 08:38
/sys/class/hwmon/hwmon5/pwm1
-rw-r--r--    1 root     root          4096 Feb  9 08:38
/sys/class/hwmon/hwmon6/pwm1
-rw-r--r--    1 root     root          4096 Feb  9 08:38
/sys/class/hwmon/hwmon7/pwm1
-rw-r--r--    1 root     root          4096 Feb  9 08:38
/sys/class/hwmon/hwmon8/pwm1

2. With above changes, the dbus-sensor for FAN/PWM shall not work
because of the compatibility. So if OpenBMC want to keep above
PWM/TACH driver, does any sides have the plan to support the fan
sensor, if not, we can join and do it.

Thank you and best regards,
Tung



[-- Attachment #2: Type: text/html, Size: 42709 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [AST2600] PWM/TACH driver and dbus-sensor issue
  2022-02-15 10:33             ` Billy Tsai
@ 2022-02-16  7:07               ` Tung Nguyen OS
  2022-02-17  2:57                 ` Billy Tsai
  0 siblings, 1 reply; 11+ messages in thread
From: Tung Nguyen OS @ 2022-02-16  7:07 UTC (permalink / raw)
  To: Billy Tsai, Troy Lee, openbmc; +Cc: Thu Nguyen OS, Thang Nguyen OS, Phong Vo OS

Hi Billy,
I don't have the device to capture the waveform here, i will need our HW team's help. Meanwhile, debugging in the tach-aspeed-ast2600.c i have observed that:
+ In the case that can read the fan speed, the debug messages output like:
# cat /sys/class/hwmon/hwmon1/pwm1
120
# echo 110 > /sys/class/hwmon/hwmon1/pwm1
# cat /sys/class/hwmon/hwmon0/fan1_input
837053
[  325.499388] clk 200000000, raw_data 7 , tach_div 14336
[  326.070305] clk 200000000, raw_data 7 , tach_div 14336
[  326.641221] clk 200000000, raw_data 7 , tach_div 14336
[  327.212095] clk 200000000, raw_data 7 , tach_div 14336
[  327.783012] clk 200000000, raw_data 7 , tach_div 14336

+ In the issue case, i can see the code is timeout at regmap_read_poll_timeout (below)
150 static int aspeed_get_fan_tach_ch_rpm(struct aspeed_tach_data *priv,
151                                       u8 fan_tach_ch)
152 {
153         u32 raw_data, tach_div, clk_source, usec, val;
154         u64 rpm;
155         int ret;
156
157         usec = priv->tacho_channel[fan_tach_ch].sample_period;
158         /* Restart the Tach channel to guarantee the value is fresh */
159         regmap_update_bits(priv->regmap, ASPEED_TACHO_CTRL_CH(fan_tach_ch),
160                              TACHO_ENABLE, 0);
161         regmap_update_bits(priv->regmap, ASPEED_TACHO_CTRL_CH(fan_tach_ch),
162                              TACHO_ENABLE, TACHO_ENABLE);
163         ret = regmap_read_poll_timeout(
164                 priv->regmap, ASPEED_TACHO_STS_CH(fan_tach_ch), val,
165                 (val & TACHO_FULL_MEASUREMENT) && (val & TACHO_VALUE_UPDATE),
166                 RPM_POLLING_PERIOD_US, usec);
167
168         if (ret) {
169                 /* return 0 if we didn't get an answer because of timeout*/
170                 if (ret == -ETIMEDOUT)
171                         return 0; ==> TIMEOUT HERE
172                 else
173                         return ret;
174         }
175
176         raw_data = val & TACHO_VALUE_MASK;

Do you have comments on what should be checked here ?

________________________________________
From: Billy Tsai <billy_tsai@aspeedtech.com>
Sent: Tuesday, February 15, 2022 5:33 PM
To: Tung Nguyen OS; Troy Lee; openbmc@lists.ozlabs.org
Cc: Thu Nguyen OS; Thang Nguyen OS; Phong Vo OS
Subject: Re: [AST2600] PWM/TACH driver and dbus-sensor issue

Hi Tung,

The register setting looks fine.
Can you check the connection of the FAN tach pin and BMC tach input pin?
If it is normal, can you check the FAN tach output waveform?

I test with San Ace 80 and get the result below:

root@ast2600-default:~# cat /sys/class/hwmon/hwmon1/fan1_input
3570
root@ast2600-default:~# echo 100 > /sys/class/hwmon/hwmon4/pwm1
root@ast2600-default:~# cat /sys/class/hwmon/hwmon1/fan1_input
3568
root@ast2600-default:~# echo 120 > /sys/class/hwmon/hwmon4/pwm1
root@ast2600-default:~# cat /sys/class/hwmon/hwmon1/fan1_input
4032
root@ast2600-default:~# echo 140 > /sys/class/hwmon/hwmon4/pwm1
root@ast2600-default:~# cat /sys/class/hwmon/hwmon1/fan1_input
4422
root@ast2600-default:~# echo 255 > /sys/class/hwmon/hwmon4/pwm1
root@ast2600-default:~# cat /sys/class/hwmon/hwmon1/fan1_input
6293


Thanks

Best Regards,
Billy Tsai

From: Tung Nguyen OS <tungnguyen@os.amperecomputing.com>
Date: Tuesday, February 15, 2022 at 6:10 PM
To: Billy Tsai <billy_tsai@aspeedtech.com>, Troy Lee <troy_lee@aspeedtech.com>, "openbmc@lists.ozlabs.org" <openbmc@lists.ozlabs.org>
Cc: Thu Nguyen OS <thu@os.amperecomputing.com>, Thang Nguyen OS <thang@os.amperecomputing.com>, Phong Vo OS <phong@os.amperecomputing.com>
Subject: Re: [AST2600] PWM/TACH driver and dbus-sensor issue

Hi Billy,

Please help check:
root@sunmoonlake:/tmp# ./test.sh 100
echo 100 > /sys/class/hwmon/hwmon1/pwm1
cat /sys/class/hwmon/hwmon0/fan1_input
0
devmem 0x1e610000
0x0001101E
devmem 0x1e610004
0xFF006500
devmem 0x1e610008
0x10500000
devmem 0x1e61000c
0xA5400000
root@sunmoonlake:/tmp# ./test.sh 120
echo 120 > /sys/class/hwmon/hwmon1/pwm1
cat /sys/class/hwmon/hwmon0/fan1_input
266335
devmem 0x1e610000
0x0001101E
devmem 0x1e610004
0xFF007900
devmem 0x1e610008
0x10500000
devmem 0x1e61000c
0xF4B00016
root@sunmoonlake:/tmp# ./test.sh 140
echo 140 > /sys/class/hwmon/hwmon1/pwm1
cat /sys/class/hwmon/hwmon0/fan1_input
837053
devmem 0x1e610000
0x0001101E
devmem 0x1e610004
0xFF008D00
devmem 0x1e610008
0x10500000
devmem 0x1e61000c
0xE4B00007
root@sunmoonlake:/tmp# ./test.sh 255
echo 255 > /sys/class/hwmon/hwmon1/pwm1
cat /sys/class/hwmon/hwmon0/fan1_input
0
devmem 0x1e610000
0x0001101E
devmem 0x1e610004
0xFF000000
devmem 0x1e610008
0x10500000
devmem 0x1e61000c
0xB5C00000
root@sunmoonlake:/tmp#

Please note that i'm using the fan settings as:

        fan0: pwm-fan0 {
                compatible = "pwm-fan";
                pwms = <&pwm 0 40000 0>;        /* Target freq:25 kHz */
                cooling-min-state = <0>;
                cooling-max-state = <3>;
                #cooling-cells = <2>;
                cooling-levels = <0 25 128 255>;
        };
.....
        fan@0 {
                reg = <0x00>;
                aspeed,pulse-pr = <2>;
        };


________________________________________
From: Billy Tsai <billy_tsai@aspeedtech.com<mailto:billy_tsai@aspeedtech.com>>
Sent: Monday, February 14, 2022 1:34 PM
To: Tung Nguyen OS; Troy Lee; openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org>
Cc: Thu Nguyen OS; Thang Nguyen OS; Phong Vo OS
Subject: Re: [AST2600] PWM/TACH driver and dbus-sensor issue

Hi Tung,

Can you check the PWM frequency and dump the register value 0x1e610000~0x1e61000c?

Thanks

Best Regards,
Billy Tsai

From: Tung Nguyen OS <tungnguyen@os.amperecomputing.com<mailto:tungnguyen@os.amperecomputing.com>>
Date: Monday, February 14, 2022 at 12:24 PM
To: Troy Lee <troy_lee@aspeedtech.com<mailto:troy_lee@aspeedtech.com>>, "openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org>" <openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org>>
Cc: Thu Nguyen OS <thu@os.amperecomputing.com<mailto:thu@os.amperecomputing.com>>, Thang Nguyen OS <thang@os.amperecomputing.com<mailto:thang@os.amperecomputing.com>>, Phong Vo OS <phong@os.amperecomputing.com<mailto:phong@os.amperecomputing.com>>, Billy Tsai <billy_tsai@aspeedtech.com<mailto:billy_tsai@aspeedtech.com>>
Subject: Re: [AST2600] PWM/TACH driver and dbus-sensor issue

Hi Troy,
the fan settings in device tree are similar to aspeed-ast2600a1-evb.dts, like:

        fan0: pwm-fan0 {
                compatible = "pwm-fan";
                pwms = <&pwm 0 40000 0>;        /* Target freq:25 kHz */
                cooling-min-state = <0>;
                cooling-max-state = <3>;
                #cooling-cells = <2>;
                cooling-levels = <0 25 128 255>;
        };
.....
        fan@0 {
                reg = <0x00>;
                aspeed,pulse-pr = <2>;
        };

I test with co-fan F-5010HH12B and San Ace 92 with above setting, and the result looks like in-correct as in previous email.

________________________________________
From: Troy Lee <troy_lee@aspeedtech.com<mailto:troy_lee@aspeedtech.com><mailto:troy_lee@aspeedtech.com<mailto:troy_lee@aspeedtech.com>>>
Sent: Monday, February 14, 2022 11:02 AM
To: Tung Nguyen OS; openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org><mailto:openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org>>
Cc: Thu Nguyen OS; Thang Nguyen OS; Phong Vo OS; Billy Tsai
Subject: RE: [AST2600] PWM/TACH driver and dbus-sensor issue

Adding Billy.

Hi Tung,

-----Original Message-----
From: Tung Nguyen OS <tungnguyen@os.amperecomputing.com<mailto:tungnguyen@os.amperecomputing.com><mailto:tungnguyen@os.amperecomputing.com<mailto:tungnguyen@os.amperecomputing.com>>>
Sent: Monday, February 14, 2022 11:46 AM
To: Troy Lee <troy_lee@aspeedtech.com<mailto:troy_lee@aspeedtech.com><mailto:troy_lee@aspeedtech.com<mailto:troy_lee@aspeedtech.com>>>; openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org><mailto:openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org>>
Cc: Thu Nguyen OS <thu@os.amperecomputing.com<mailto:thu@os.amperecomputing.com><mailto:thu@os.amperecomputing.com<mailto:thu@os.amperecomputing.com>>>; Thang Nguyen OS
<thang@os.amperecomputing.com<mailto:thang@os.amperecomputing.com><mailto:thang@os.amperecomputing.com<mailto:thang@os.amperecomputing.com>>>; Phong Vo OS
<phong@os.amperecomputing.com<mailto:phong@os.amperecomputing.com><mailto:phong@os.amperecomputing.com<mailto:phong@os.amperecomputing.com>>>
Subject: Re: [AST2600] PWM/TACH driver and dbus-sensor issue

Hi Troy,
Thank you for the information, i have merged the dbus-sensor patch and see
it creates the Fan sensors well.
One more issue i have observed about the fan tach report like this:

root@mtmitchell:~# echo 120 > /sys/class/hwmon/hwmon1/pwm1
root@mtmitchell:~# cat /sys/class/hwmon/hwmon0/fan1_input
418526
root@mtmitchell:~# echo 100 > /sys/class/hwmon/hwmon1/pwm1
root@mtmitchell:~# cat /sys/class/hwmon/hwmon0/fan1_input
195312
root@mtmitchell:~# echo 255 > /sys/class/hwmon/hwmon1/pwm1
root@mtmitchell:~# cat /sys/class/hwmon/hwmon0/fan1_input
0
root@mtmitchell:~# echo 50 > /sys/class/hwmon/hwmon1/pwm1
root@mtmitchell:~# cat /sys/class/hwmon/hwmon0/fan1_input
0

It means the fan speed is reported incorrectly somehow, but i can see the
fan speed changes by eyes, do you have idea on this issue ?

Does the aspeed,pulse-pr property of fan node set correspondingly?
What is the expected RPM of you fan? 418526 RPM?

Thanks,
Troy Lee


________________________________________
From: Troy Lee <troy_lee@aspeedtech.com<mailto:troy_lee@aspeedtech.com><mailto:troy_lee@aspeedtech.com<mailto:troy_lee@aspeedtech.com>>>
Sent: Friday, February 11, 2022 12:13 PM
To: Tung Nguyen OS; openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org><mailto:openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org>>
Cc: Thu Nguyen OS; Thang Nguyen OS; Phong Vo OS
Subject: RE: [AST2600] PWM/TACH driver and dbus-sensor issue

Hi Tung,

-----Original Message-----
From: openbmc <openbmc-
bounces+troy_lee=aspeedtech.com@lists.ozlabs.org<mailto:aspeedtech.com@lists.ozlabs.org><mailto:aspeedtech.com@lists.ozlabs.org<mailto:aspeedtech.com@lists.ozlabs.org>>> On Behalf Of Tung
Nguyen OS
Sent: Wednesday, February 9, 2022 10:40 PM
To: openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org><mailto:openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org>>
Cc: Thu Nguyen OS <thu@os.amperecomputing.com<mailto:thu@os.amperecomputing.com><mailto:thu@os.amperecomputing.com<mailto:thu@os.amperecomputing.com>>>; Thang Nguyen OS
<thang@os.amperecomputing.com<mailto:thang@os.amperecomputing.com><mailto:thang@os.amperecomputing.com<mailto:thang@os.amperecomputing.com>>>; Phong Vo OS
<phong@os.amperecomputing.com<mailto:phong@os.amperecomputing.com><mailto:phong@os.amperecomputing.com<mailto:phong@os.amperecomputing.com>>>
Subject: [AST2600] PWM/TACH driver and dbus-sensor issue

Dear community,
We have ported the PWM/TACH hwmon driver for AST2600 from ASPEED's
repository https://github.com/AspeedTech-BMC/linux/tree/aspeed-
master-
v5.4/drivers/hwmon to support Ampere Computing's systems. Verify with
AST2600 EVB, i can see the driver works. However there is a concern like:
1. The change of hwmon fan pwm/tach in sysfs (as below), this is
different from the ast2500 as the separated of the fan*_input and pwm1
in various hwmon directories. At this time, the driver doesn't exist
in the OpenBMC linux at https://github.com/openbmc/linux. Is OpenBMC
going to merge and keep this driver ?

Please have a look on this patch.
https://gerrit.openbmc-project.xyz/c/openbmc/dbus-sensors/+/49253

Thanks,
Troy Lee

root@mtmitchell:~# ls -la /sys/class/hwmon/hwmon hwmon0/ hwmon1/
hwmon2/ hwmon3/ hwmon4/ hwmon5/ hwmon6/ hwmon7/ hwmon8/
hwmon9/
root@mtmitchell:~# ls -la /sys/class/hwmon/hwmon0/
drwxr-xr-x    3 root     root             0 Jan  1  1970 .
drwxr-xr-x    3 root     root             0 Jan  1  1970 ..
lrwxrwxrwx    1 root     root             0 Feb  9 08:38 device -
> ../../../1e610000.pwm_tach:tach
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan10_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan11_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan12_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan13_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan14_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan15_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan16_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan1_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan2_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan3_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan4_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan5_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan6_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan7_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan8_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan9_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 name
lrwxrwxrwx    1 root     root             0 Feb  9 08:38 of_node -
> ../../../../../../../../firmware/devicetree/base/ahb/apb/pwm_tach@1e
> 610
000/tach
drwxr-xr-x    2 root     root             0 Feb  9 08:38 power
lrwxrwxrwx    1 root     root             0 Jan  1  1970 subsystem -
> ../../../../../../../../class/hwmon
-rw-r--r--    1 root     root          4096 Jan  1  1970 uevent
root@mtmitchell:~# ls -la /sys/class/hwmon/hwmon*/pwm*
-rw-r--r--    1 root     root          4096 Feb  9 09:13
/sys/class/hwmon/hwmon1/pwm1
-rw-r--r--    1 root     root          4096 Feb  9 09:20
/sys/class/hwmon/hwmon2/pwm1
-rw-r--r--    1 root     root          4096 Feb  9 08:38
/sys/class/hwmon/hwmon3/pwm1
-rw-r--r--    1 root     root          4096 Feb  9 08:38
/sys/class/hwmon/hwmon4/pwm1
-rw-r--r--    1 root     root          4096 Feb  9 08:38
/sys/class/hwmon/hwmon5/pwm1
-rw-r--r--    1 root     root          4096 Feb  9 08:38
/sys/class/hwmon/hwmon6/pwm1
-rw-r--r--    1 root     root          4096 Feb  9 08:38
/sys/class/hwmon/hwmon7/pwm1
-rw-r--r--    1 root     root          4096 Feb  9 08:38
/sys/class/hwmon/hwmon8/pwm1

2. With above changes, the dbus-sensor for FAN/PWM shall not work
because of the compatibility. So if OpenBMC want to keep above
PWM/TACH driver, does any sides have the plan to support the fan
sensor, if not, we can join and do it.

Thank you and best regards,
Tung



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [AST2600] PWM/TACH driver and dbus-sensor issue
  2022-02-16  7:07               ` Tung Nguyen OS
@ 2022-02-17  2:57                 ` Billy Tsai
  2022-02-17 10:35                   ` Tung Nguyen OS
  0 siblings, 1 reply; 11+ messages in thread
From: Billy Tsai @ 2022-02-17  2:57 UTC (permalink / raw)
  To: Tung Nguyen OS, Troy Lee, openbmc
  Cc: Thu Nguyen OS, Thang Nguyen OS, Phong Vo OS

[-- Attachment #1: Type: text/plain, Size: 18700 bytes --]

Hi Tung,

I can reproduce your issue by shorting out the PWM and TACH pin.
Are you using our evb for testing? If yes, please check there is no jumper at J80.

Thanks

Best Regards,
Billy Tsai

From: Tung Nguyen OS <tungnguyen@os.amperecomputing.com>
Date: Wednesday, February 16, 2022 at 3:07 PM
To: Billy Tsai <billy_tsai@aspeedtech.com>, Troy Lee <troy_lee@aspeedtech.com>, "openbmc@lists.ozlabs.org" <openbmc@lists.ozlabs.org>
Cc: Thu Nguyen OS <thu@os.amperecomputing.com>, Thang Nguyen OS <thang@os.amperecomputing.com>, Phong Vo OS <phong@os.amperecomputing.com>
Subject: Re: [AST2600] PWM/TACH driver and dbus-sensor issue

Hi Billy,
I don't have the device to capture the waveform here, i will need our HW team's help. Meanwhile, debugging in the tach-aspeed-ast2600.c i have observed that:
+ In the case that can read the fan speed, the debug messages output like:
# cat /sys/class/hwmon/hwmon1/pwm1
120
# echo 110 > /sys/class/hwmon/hwmon1/pwm1
# cat /sys/class/hwmon/hwmon0/fan1_input
837053
[  325.499388] clk 200000000, raw_data 7 , tach_div 14336
[  326.070305] clk 200000000, raw_data 7 , tach_div 14336
[  326.641221] clk 200000000, raw_data 7 , tach_div 14336
[  327.212095] clk 200000000, raw_data 7 , tach_div 14336
[  327.783012] clk 200000000, raw_data 7 , tach_div 14336

+ In the issue case, i can see the code is timeout at regmap_read_poll_timeout (below)
150 static int aspeed_get_fan_tach_ch_rpm(struct aspeed_tach_data *priv,
151                                       u8 fan_tach_ch)
152 {
153         u32 raw_data, tach_div, clk_source, usec, val;
154         u64 rpm;
155         int ret;
156
157         usec = priv->tacho_channel[fan_tach_ch].sample_period;
158         /* Restart the Tach channel to guarantee the value is fresh */
159         regmap_update_bits(priv->regmap, ASPEED_TACHO_CTRL_CH(fan_tach_ch),
160                              TACHO_ENABLE, 0);
161         regmap_update_bits(priv->regmap, ASPEED_TACHO_CTRL_CH(fan_tach_ch),
162                              TACHO_ENABLE, TACHO_ENABLE);
163         ret = regmap_read_poll_timeout(
164                 priv->regmap, ASPEED_TACHO_STS_CH(fan_tach_ch), val,
165                 (val & TACHO_FULL_MEASUREMENT) && (val & TACHO_VALUE_UPDATE),
166                 RPM_POLLING_PERIOD_US, usec);
167
168         if (ret) {
169                 /* return 0 if we didn't get an answer because of timeout*/
170                 if (ret == -ETIMEDOUT)
171                         return 0; ==> TIMEOUT HERE
172                 else
173                         return ret;
174         }
175
176         raw_data = val & TACHO_VALUE_MASK;

Do you have comments on what should be checked here ?

________________________________________
From: Billy Tsai <billy_tsai@aspeedtech.com<mailto:billy_tsai@aspeedtech.com>>
Sent: Tuesday, February 15, 2022 5:33 PM
To: Tung Nguyen OS; Troy Lee; openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org>
Cc: Thu Nguyen OS; Thang Nguyen OS; Phong Vo OS
Subject: Re: [AST2600] PWM/TACH driver and dbus-sensor issue

Hi Tung,

The register setting looks fine.
Can you check the connection of the FAN tach pin and BMC tach input pin?
If it is normal, can you check the FAN tach output waveform?

I test with San Ace 80 and get the result below:

root@ast2600-default:~# cat /sys/class/hwmon/hwmon1/fan1_input
3570
root@ast2600-default:~# echo 100 > /sys/class/hwmon/hwmon4/pwm1
root@ast2600-default:~# cat /sys/class/hwmon/hwmon1/fan1_input
3568
root@ast2600-default:~# echo 120 > /sys/class/hwmon/hwmon4/pwm1
root@ast2600-default:~# cat /sys/class/hwmon/hwmon1/fan1_input
4032
root@ast2600-default:~# echo 140 > /sys/class/hwmon/hwmon4/pwm1
root@ast2600-default:~# cat /sys/class/hwmon/hwmon1/fan1_input
4422
root@ast2600-default:~# echo 255 > /sys/class/hwmon/hwmon4/pwm1
root@ast2600-default:~# cat /sys/class/hwmon/hwmon1/fan1_input
6293


Thanks

Best Regards,
Billy Tsai

From: Tung Nguyen OS <tungnguyen@os.amperecomputing.com<mailto:tungnguyen@os.amperecomputing.com>>
Date: Tuesday, February 15, 2022 at 6:10 PM
To: Billy Tsai <billy_tsai@aspeedtech.com<mailto:billy_tsai@aspeedtech.com>>, Troy Lee <troy_lee@aspeedtech.com<mailto:troy_lee@aspeedtech.com>>, "openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org>" <openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org>>
Cc: Thu Nguyen OS <thu@os.amperecomputing.com<mailto:thu@os.amperecomputing.com>>, Thang Nguyen OS <thang@os.amperecomputing.com<mailto:thang@os.amperecomputing.com>>, Phong Vo OS <phong@os.amperecomputing.com<mailto:phong@os.amperecomputing.com>>
Subject: Re: [AST2600] PWM/TACH driver and dbus-sensor issue

Hi Billy,

Please help check:
root@sunmoonlake:/tmp# ./test.sh 100
echo 100 > /sys/class/hwmon/hwmon1/pwm1
cat /sys/class/hwmon/hwmon0/fan1_input
0
devmem 0x1e610000
0x0001101E
devmem 0x1e610004
0xFF006500
devmem 0x1e610008
0x10500000
devmem 0x1e61000c
0xA5400000
root@sunmoonlake:/tmp# ./test.sh 120
echo 120 > /sys/class/hwmon/hwmon1/pwm1
cat /sys/class/hwmon/hwmon0/fan1_input
266335
devmem 0x1e610000
0x0001101E
devmem 0x1e610004
0xFF007900
devmem 0x1e610008
0x10500000
devmem 0x1e61000c
0xF4B00016
root@sunmoonlake:/tmp# ./test.sh 140
echo 140 > /sys/class/hwmon/hwmon1/pwm1
cat /sys/class/hwmon/hwmon0/fan1_input
837053
devmem 0x1e610000
0x0001101E
devmem 0x1e610004
0xFF008D00
devmem 0x1e610008
0x10500000
devmem 0x1e61000c
0xE4B00007
root@sunmoonlake:/tmp# ./test.sh 255
echo 255 > /sys/class/hwmon/hwmon1/pwm1
cat /sys/class/hwmon/hwmon0/fan1_input
0
devmem 0x1e610000
0x0001101E
devmem 0x1e610004
0xFF000000
devmem 0x1e610008
0x10500000
devmem 0x1e61000c
0xB5C00000
root@sunmoonlake:/tmp#

Please note that i'm using the fan settings as:

        fan0: pwm-fan0 {
                compatible = "pwm-fan";
                pwms = <&pwm 0 40000 0>;        /* Target freq:25 kHz */
                cooling-min-state = <0>;
                cooling-max-state = <3>;
                #cooling-cells = <2>;
                cooling-levels = <0 25 128 255>;
        };
.....
        fan@0 {
                reg = <0x00>;
                aspeed,pulse-pr = <2>;
        };


________________________________________
From: Billy Tsai <billy_tsai@aspeedtech.com<mailto:billy_tsai@aspeedtech.com><mailto:billy_tsai@aspeedtech.com<mailto:billy_tsai@aspeedtech.com>>>
Sent: Monday, February 14, 2022 1:34 PM
To: Tung Nguyen OS; Troy Lee; openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org><mailto:openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org>>
Cc: Thu Nguyen OS; Thang Nguyen OS; Phong Vo OS
Subject: Re: [AST2600] PWM/TACH driver and dbus-sensor issue

Hi Tung,

Can you check the PWM frequency and dump the register value 0x1e610000~0x1e61000c?

Thanks

Best Regards,
Billy Tsai

From: Tung Nguyen OS <tungnguyen@os.amperecomputing.com<mailto:tungnguyen@os.amperecomputing.com><mailto:tungnguyen@os.amperecomputing.com<mailto:tungnguyen@os.amperecomputing.com>>>
Date: Monday, February 14, 2022 at 12:24 PM
To: Troy Lee <troy_lee@aspeedtech.com<mailto:troy_lee@aspeedtech.com><mailto:troy_lee@aspeedtech.com<mailto:troy_lee@aspeedtech.com>>>, "openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org><mailto:openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org>>" <openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org><mailto:openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org>>>
Cc: Thu Nguyen OS <thu@os.amperecomputing.com<mailto:thu@os.amperecomputing.com><mailto:thu@os.amperecomputing.com<mailto:thu@os.amperecomputing.com>>>, Thang Nguyen OS <thang@os.amperecomputing.com<mailto:thang@os.amperecomputing.com><mailto:thang@os.amperecomputing.com<mailto:thang@os.amperecomputing.com>>>, Phong Vo OS <phong@os.amperecomputing.com<mailto:phong@os.amperecomputing.com><mailto:phong@os.amperecomputing.com<mailto:phong@os.amperecomputing.com>>>, Billy Tsai <billy_tsai@aspeedtech.com<mailto:billy_tsai@aspeedtech.com><mailto:billy_tsai@aspeedtech.com<mailto:billy_tsai@aspeedtech.com>>>
Subject: Re: [AST2600] PWM/TACH driver and dbus-sensor issue

Hi Troy,
the fan settings in device tree are similar to aspeed-ast2600a1-evb.dts, like:

        fan0: pwm-fan0 {
                compatible = "pwm-fan";
                pwms = <&pwm 0 40000 0>;        /* Target freq:25 kHz */
                cooling-min-state = <0>;
                cooling-max-state = <3>;
                #cooling-cells = <2>;
                cooling-levels = <0 25 128 255>;
        };
.....
        fan@0 {
                reg = <0x00>;
                aspeed,pulse-pr = <2>;
        };

I test with co-fan F-5010HH12B and San Ace 92 with above setting, and the result looks like in-correct as in previous email.

________________________________________
From: Troy Lee <troy_lee@aspeedtech.com<mailto:troy_lee@aspeedtech.com><mailto:troy_lee@aspeedtech.com<mailto:troy_lee@aspeedtech.com>><mailto:troy_lee@aspeedtech.com<mailto:troy_lee@aspeedtech.com><mailto:troy_lee@aspeedtech.com<mailto:troy_lee@aspeedtech.com>>>>
Sent: Monday, February 14, 2022 11:02 AM
To: Tung Nguyen OS; openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org><mailto:openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org>><mailto:openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org><mailto:openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org>>>
Cc: Thu Nguyen OS; Thang Nguyen OS; Phong Vo OS; Billy Tsai
Subject: RE: [AST2600] PWM/TACH driver and dbus-sensor issue

Adding Billy.

Hi Tung,

-----Original Message-----
From: Tung Nguyen OS <tungnguyen@os.amperecomputing.com<mailto:tungnguyen@os.amperecomputing.com><mailto:tungnguyen@os.amperecomputing.com<mailto:tungnguyen@os.amperecomputing.com>><mailto:tungnguyen@os.amperecomputing.com<mailto:tungnguyen@os.amperecomputing.com><mailto:tungnguyen@os.amperecomputing.com<mailto:tungnguyen@os.amperecomputing.com>>>>
Sent: Monday, February 14, 2022 11:46 AM
To: Troy Lee <troy_lee@aspeedtech.com<mailto:troy_lee@aspeedtech.com><mailto:troy_lee@aspeedtech.com<mailto:troy_lee@aspeedtech.com>><mailto:troy_lee@aspeedtech.com<mailto:troy_lee@aspeedtech.com><mailto:troy_lee@aspeedtech.com<mailto:troy_lee@aspeedtech.com>>>>; openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org><mailto:openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org>><mailto:openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org><mailto:openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org>>>
Cc: Thu Nguyen OS <thu@os.amperecomputing.com<mailto:thu@os.amperecomputing.com><mailto:thu@os.amperecomputing.com<mailto:thu@os.amperecomputing.com>><mailto:thu@os.amperecomputing.com<mailto:thu@os.amperecomputing.com><mailto:thu@os.amperecomputing.com<mailto:thu@os.amperecomputing.com>>>>; Thang Nguyen OS
<thang@os.amperecomputing.com<mailto:thang@os.amperecomputing.com><mailto:thang@os.amperecomputing.com<mailto:thang@os.amperecomputing.com>><mailto:thang@os.amperecomputing.com<mailto:thang@os.amperecomputing.com><mailto:thang@os.amperecomputing.com<mailto:thang@os.amperecomputing.com>>>>; Phong Vo OS
<phong@os.amperecomputing.com<mailto:phong@os.amperecomputing.com><mailto:phong@os.amperecomputing.com<mailto:phong@os.amperecomputing.com>><mailto:phong@os.amperecomputing.com<mailto:phong@os.amperecomputing.com><mailto:phong@os.amperecomputing.com<mailto:phong@os.amperecomputing.com>>>>
Subject: Re: [AST2600] PWM/TACH driver and dbus-sensor issue

Hi Troy,
Thank you for the information, i have merged the dbus-sensor patch and see
it creates the Fan sensors well.
One more issue i have observed about the fan tach report like this:

root@mtmitchell:~# echo 120 > /sys/class/hwmon/hwmon1/pwm1
root@mtmitchell:~# cat /sys/class/hwmon/hwmon0/fan1_input
418526
root@mtmitchell:~# echo 100 > /sys/class/hwmon/hwmon1/pwm1
root@mtmitchell:~# cat /sys/class/hwmon/hwmon0/fan1_input
195312
root@mtmitchell:~# echo 255 > /sys/class/hwmon/hwmon1/pwm1
root@mtmitchell:~# cat /sys/class/hwmon/hwmon0/fan1_input
0
root@mtmitchell:~# echo 50 > /sys/class/hwmon/hwmon1/pwm1
root@mtmitchell:~# cat /sys/class/hwmon/hwmon0/fan1_input
0

It means the fan speed is reported incorrectly somehow, but i can see the
fan speed changes by eyes, do you have idea on this issue ?

Does the aspeed,pulse-pr property of fan node set correspondingly?
What is the expected RPM of you fan? 418526 RPM?

Thanks,
Troy Lee


________________________________________
From: Troy Lee <troy_lee@aspeedtech.com<mailto:troy_lee@aspeedtech.com><mailto:troy_lee@aspeedtech.com<mailto:troy_lee@aspeedtech.com>><mailto:troy_lee@aspeedtech.com<mailto:troy_lee@aspeedtech.com><mailto:troy_lee@aspeedtech.com<mailto:troy_lee@aspeedtech.com>>>>
Sent: Friday, February 11, 2022 12:13 PM
To: Tung Nguyen OS; openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org><mailto:openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org>><mailto:openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org><mailto:openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org>>>
Cc: Thu Nguyen OS; Thang Nguyen OS; Phong Vo OS
Subject: RE: [AST2600] PWM/TACH driver and dbus-sensor issue

Hi Tung,

-----Original Message-----
From: openbmc <openbmc-
bounces+troy_lee=aspeedtech.com@lists.ozlabs.org<mailto:aspeedtech.com@lists.ozlabs.org><mailto:aspeedtech.com@lists.ozlabs.org<mailto:aspeedtech.com@lists.ozlabs.org>><mailto:aspeedtech.com@lists.ozlabs.org<mailto:aspeedtech.com@lists.ozlabs.org><mailto:aspeedtech.com@lists.ozlabs.org<mailto:aspeedtech.com@lists.ozlabs.org>>>> On Behalf Of Tung
Nguyen OS
Sent: Wednesday, February 9, 2022 10:40 PM
To: openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org><mailto:openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org>><mailto:openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org><mailto:openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org>>>
Cc: Thu Nguyen OS <thu@os.amperecomputing.com<mailto:thu@os.amperecomputing.com><mailto:thu@os.amperecomputing.com<mailto:thu@os.amperecomputing.com>><mailto:thu@os.amperecomputing.com<mailto:thu@os.amperecomputing.com><mailto:thu@os.amperecomputing.com<mailto:thu@os.amperecomputing.com>>>>; Thang Nguyen OS
<thang@os.amperecomputing.com<mailto:thang@os.amperecomputing.com><mailto:thang@os.amperecomputing.com<mailto:thang@os.amperecomputing.com>><mailto:thang@os.amperecomputing.com<mailto:thang@os.amperecomputing.com><mailto:thang@os.amperecomputing.com<mailto:thang@os.amperecomputing.com>>>>; Phong Vo OS
<phong@os.amperecomputing.com<mailto:phong@os.amperecomputing.com><mailto:phong@os.amperecomputing.com<mailto:phong@os.amperecomputing.com>><mailto:phong@os.amperecomputing.com<mailto:phong@os.amperecomputing.com><mailto:phong@os.amperecomputing.com<mailto:phong@os.amperecomputing.com>>>>
Subject: [AST2600] PWM/TACH driver and dbus-sensor issue

Dear community,
We have ported the PWM/TACH hwmon driver for AST2600 from ASPEED's
repository https://github.com/AspeedTech-BMC/linux/tree/aspeed-
master-
v5.4/drivers/hwmon to support Ampere Computing's systems. Verify with
AST2600 EVB, i can see the driver works. However there is a concern like:
1. The change of hwmon fan pwm/tach in sysfs (as below), this is
different from the ast2500 as the separated of the fan*_input and pwm1
in various hwmon directories. At this time, the driver doesn't exist
in the OpenBMC linux at https://github.com/openbmc/linux. Is OpenBMC
going to merge and keep this driver ?

Please have a look on this patch.
https://gerrit.openbmc-project.xyz/c/openbmc/dbus-sensors/+/49253

Thanks,
Troy Lee

root@mtmitchell:~# ls -la /sys/class/hwmon/hwmon hwmon0/ hwmon1/
hwmon2/ hwmon3/ hwmon4/ hwmon5/ hwmon6/ hwmon7/ hwmon8/
hwmon9/
root@mtmitchell:~# ls -la /sys/class/hwmon/hwmon0/
drwxr-xr-x    3 root     root             0 Jan  1  1970 .
drwxr-xr-x    3 root     root             0 Jan  1  1970 ..
lrwxrwxrwx    1 root     root             0 Feb  9 08:38 device -
../../../1e610000.pwm_tach:tach
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan10_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan11_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan12_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan13_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan14_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan15_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan16_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan1_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan2_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan3_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan4_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan5_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan6_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan7_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan8_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan9_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 name
lrwxrwxrwx    1 root     root             0 Feb  9 08:38 of_node -
../../../../../../../../firmware/devicetree/base/ahb/apb/pwm_tach@1e
610
000/tach
drwxr-xr-x    2 root     root             0 Feb  9 08:38 power
lrwxrwxrwx    1 root     root             0 Jan  1  1970 subsystem -
../../../../../../../../class/hwmon
-rw-r--r--    1 root     root          4096 Jan  1  1970 uevent
root@mtmitchell:~# ls -la /sys/class/hwmon/hwmon*/pwm*
-rw-r--r--    1 root     root          4096 Feb  9 09:13
/sys/class/hwmon/hwmon1/pwm1
-rw-r--r--    1 root     root          4096 Feb  9 09:20
/sys/class/hwmon/hwmon2/pwm1
-rw-r--r--    1 root     root          4096 Feb  9 08:38
/sys/class/hwmon/hwmon3/pwm1
-rw-r--r--    1 root     root          4096 Feb  9 08:38
/sys/class/hwmon/hwmon4/pwm1
-rw-r--r--    1 root     root          4096 Feb  9 08:38
/sys/class/hwmon/hwmon5/pwm1
-rw-r--r--    1 root     root          4096 Feb  9 08:38
/sys/class/hwmon/hwmon6/pwm1
-rw-r--r--    1 root     root          4096 Feb  9 08:38
/sys/class/hwmon/hwmon7/pwm1
-rw-r--r--    1 root     root          4096 Feb  9 08:38
/sys/class/hwmon/hwmon8/pwm1

2. With above changes, the dbus-sensor for FAN/PWM shall not work
because of the compatibility. So if OpenBMC want to keep above
PWM/TACH driver, does any sides have the plan to support the fan
sensor, if not, we can join and do it.

Thank you and best regards,
Tung




[-- Attachment #2: Type: text/html, Size: 49021 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [AST2600] PWM/TACH driver and dbus-sensor issue
  2022-02-17  2:57                 ` Billy Tsai
@ 2022-02-17 10:35                   ` Tung Nguyen OS
  0 siblings, 0 replies; 11+ messages in thread
From: Tung Nguyen OS @ 2022-02-17 10:35 UTC (permalink / raw)
  To: Billy Tsai, Troy Lee, openbmc; +Cc: Thu Nguyen OS, Thang Nguyen OS, Phong Vo OS

Hi Bill,
Yes, I'm using EVB. After removing the jumper at J80 i can see the fan works well, and the speeds show correctly. I think It implies that the ported driver works OK.

Thank you for your support.
Tung

________________________________________
From: Billy Tsai <billy_tsai@aspeedtech.com>
Sent: Thursday, February 17, 2022 9:57 AM
To: Tung Nguyen OS; Troy Lee; openbmc@lists.ozlabs.org
Cc: Thu Nguyen OS; Thang Nguyen OS; Phong Vo OS
Subject: Re: [AST2600] PWM/TACH driver and dbus-sensor issue

Hi Tung,

I can reproduce your issue by shorting out the PWM and TACH pin.
Are you using our evb for testing? If yes, please check there is no jumper at J80.

Thanks

Best Regards,
Billy Tsai

From: Tung Nguyen OS <tungnguyen@os.amperecomputing.com>
Date: Wednesday, February 16, 2022 at 3:07 PM
To: Billy Tsai <billy_tsai@aspeedtech.com>, Troy Lee <troy_lee@aspeedtech.com>, "openbmc@lists.ozlabs.org" <openbmc@lists.ozlabs.org>
Cc: Thu Nguyen OS <thu@os.amperecomputing.com>, Thang Nguyen OS <thang@os.amperecomputing.com>, Phong Vo OS <phong@os.amperecomputing.com>
Subject: Re: [AST2600] PWM/TACH driver and dbus-sensor issue

Hi Billy,
I don't have the device to capture the waveform here, i will need our HW team's help. Meanwhile, debugging in the tach-aspeed-ast2600.c i have observed that:
+ In the case that can read the fan speed, the debug messages output like:
# cat /sys/class/hwmon/hwmon1/pwm1
120
# echo 110 > /sys/class/hwmon/hwmon1/pwm1
# cat /sys/class/hwmon/hwmon0/fan1_input
837053
[  325.499388] clk 200000000, raw_data 7 , tach_div 14336
[  326.070305] clk 200000000, raw_data 7 , tach_div 14336
[  326.641221] clk 200000000, raw_data 7 , tach_div 14336
[  327.212095] clk 200000000, raw_data 7 , tach_div 14336
[  327.783012] clk 200000000, raw_data 7 , tach_div 14336

+ In the issue case, i can see the code is timeout at regmap_read_poll_timeout (below)
150 static int aspeed_get_fan_tach_ch_rpm(struct aspeed_tach_data *priv,
151                                       u8 fan_tach_ch)
152 {
153         u32 raw_data, tach_div, clk_source, usec, val;
154         u64 rpm;
155         int ret;
156
157         usec = priv->tacho_channel[fan_tach_ch].sample_period;
158         /* Restart the Tach channel to guarantee the value is fresh */
159         regmap_update_bits(priv->regmap, ASPEED_TACHO_CTRL_CH(fan_tach_ch),
160                              TACHO_ENABLE, 0);
161         regmap_update_bits(priv->regmap, ASPEED_TACHO_CTRL_CH(fan_tach_ch),
162                              TACHO_ENABLE, TACHO_ENABLE);
163         ret = regmap_read_poll_timeout(
164                 priv->regmap, ASPEED_TACHO_STS_CH(fan_tach_ch), val,
165                 (val & TACHO_FULL_MEASUREMENT) && (val & TACHO_VALUE_UPDATE),
166                 RPM_POLLING_PERIOD_US, usec);
167
168         if (ret) {
169                 /* return 0 if we didn't get an answer because of timeout*/
170                 if (ret == -ETIMEDOUT)
171                         return 0; ==> TIMEOUT HERE
172                 else
173                         return ret;
174         }
175
176         raw_data = val & TACHO_VALUE_MASK;

Do you have comments on what should be checked here ?

________________________________________
From: Billy Tsai <billy_tsai@aspeedtech.com<mailto:billy_tsai@aspeedtech.com>>
Sent: Tuesday, February 15, 2022 5:33 PM
To: Tung Nguyen OS; Troy Lee; openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org>
Cc: Thu Nguyen OS; Thang Nguyen OS; Phong Vo OS
Subject: Re: [AST2600] PWM/TACH driver and dbus-sensor issue

Hi Tung,

The register setting looks fine.
Can you check the connection of the FAN tach pin and BMC tach input pin?
If it is normal, can you check the FAN tach output waveform?

I test with San Ace 80 and get the result below:

root@ast2600-default:~# cat /sys/class/hwmon/hwmon1/fan1_input
3570
root@ast2600-default:~# echo 100 > /sys/class/hwmon/hwmon4/pwm1
root@ast2600-default:~# cat /sys/class/hwmon/hwmon1/fan1_input
3568
root@ast2600-default:~# echo 120 > /sys/class/hwmon/hwmon4/pwm1
root@ast2600-default:~# cat /sys/class/hwmon/hwmon1/fan1_input
4032
root@ast2600-default:~# echo 140 > /sys/class/hwmon/hwmon4/pwm1
root@ast2600-default:~# cat /sys/class/hwmon/hwmon1/fan1_input
4422
root@ast2600-default:~# echo 255 > /sys/class/hwmon/hwmon4/pwm1
root@ast2600-default:~# cat /sys/class/hwmon/hwmon1/fan1_input
6293


Thanks

Best Regards,
Billy Tsai

From: Tung Nguyen OS <tungnguyen@os.amperecomputing.com<mailto:tungnguyen@os.amperecomputing.com>>
Date: Tuesday, February 15, 2022 at 6:10 PM
To: Billy Tsai <billy_tsai@aspeedtech.com<mailto:billy_tsai@aspeedtech.com>>, Troy Lee <troy_lee@aspeedtech.com<mailto:troy_lee@aspeedtech.com>>, "openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org>" <openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org>>
Cc: Thu Nguyen OS <thu@os.amperecomputing.com<mailto:thu@os.amperecomputing.com>>, Thang Nguyen OS <thang@os.amperecomputing.com<mailto:thang@os.amperecomputing.com>>, Phong Vo OS <phong@os.amperecomputing.com<mailto:phong@os.amperecomputing.com>>
Subject: Re: [AST2600] PWM/TACH driver and dbus-sensor issue

Hi Billy,

Please help check:
root@sunmoonlake:/tmp# ./test.sh 100
echo 100 > /sys/class/hwmon/hwmon1/pwm1
cat /sys/class/hwmon/hwmon0/fan1_input
0
devmem 0x1e610000
0x0001101E
devmem 0x1e610004
0xFF006500
devmem 0x1e610008
0x10500000
devmem 0x1e61000c
0xA5400000
root@sunmoonlake:/tmp# ./test.sh 120
echo 120 > /sys/class/hwmon/hwmon1/pwm1
cat /sys/class/hwmon/hwmon0/fan1_input
266335
devmem 0x1e610000
0x0001101E
devmem 0x1e610004
0xFF007900
devmem 0x1e610008
0x10500000
devmem 0x1e61000c
0xF4B00016
root@sunmoonlake:/tmp# ./test.sh 140
echo 140 > /sys/class/hwmon/hwmon1/pwm1
cat /sys/class/hwmon/hwmon0/fan1_input
837053
devmem 0x1e610000
0x0001101E
devmem 0x1e610004
0xFF008D00
devmem 0x1e610008
0x10500000
devmem 0x1e61000c
0xE4B00007
root@sunmoonlake:/tmp# ./test.sh 255
echo 255 > /sys/class/hwmon/hwmon1/pwm1
cat /sys/class/hwmon/hwmon0/fan1_input
0
devmem 0x1e610000
0x0001101E
devmem 0x1e610004
0xFF000000
devmem 0x1e610008
0x10500000
devmem 0x1e61000c
0xB5C00000
root@sunmoonlake:/tmp#

Please note that i'm using the fan settings as:

        fan0: pwm-fan0 {
                compatible = "pwm-fan";
                pwms = <&pwm 0 40000 0>;        /* Target freq:25 kHz */
                cooling-min-state = <0>;
                cooling-max-state = <3>;
                #cooling-cells = <2>;
                cooling-levels = <0 25 128 255>;
        };
.....
        fan@0 {
                reg = <0x00>;
                aspeed,pulse-pr = <2>;
        };


________________________________________
From: Billy Tsai <billy_tsai@aspeedtech.com<mailto:billy_tsai@aspeedtech.com><mailto:billy_tsai@aspeedtech.com<mailto:billy_tsai@aspeedtech.com>>>
Sent: Monday, February 14, 2022 1:34 PM
To: Tung Nguyen OS; Troy Lee; openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org><mailto:openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org>>
Cc: Thu Nguyen OS; Thang Nguyen OS; Phong Vo OS
Subject: Re: [AST2600] PWM/TACH driver and dbus-sensor issue

Hi Tung,

Can you check the PWM frequency and dump the register value 0x1e610000~0x1e61000c?

Thanks

Best Regards,
Billy Tsai

From: Tung Nguyen OS <tungnguyen@os.amperecomputing.com<mailto:tungnguyen@os.amperecomputing.com><mailto:tungnguyen@os.amperecomputing.com<mailto:tungnguyen@os.amperecomputing.com>>>
Date: Monday, February 14, 2022 at 12:24 PM
To: Troy Lee <troy_lee@aspeedtech.com<mailto:troy_lee@aspeedtech.com><mailto:troy_lee@aspeedtech.com<mailto:troy_lee@aspeedtech.com>>>, "openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org><mailto:openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org>>" <openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org><mailto:openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org>>>
Cc: Thu Nguyen OS <thu@os.amperecomputing.com<mailto:thu@os.amperecomputing.com><mailto:thu@os.amperecomputing.com<mailto:thu@os.amperecomputing.com>>>, Thang Nguyen OS <thang@os.amperecomputing.com<mailto:thang@os.amperecomputing.com><mailto:thang@os.amperecomputing.com<mailto:thang@os.amperecomputing.com>>>, Phong Vo OS <phong@os.amperecomputing.com<mailto:phong@os.amperecomputing.com><mailto:phong@os.amperecomputing.com<mailto:phong@os.amperecomputing.com>>>, Billy Tsai <billy_tsai@aspeedtech.com<mailto:billy_tsai@aspeedtech.com><mailto:billy_tsai@aspeedtech.com<mailto:billy_tsai@aspeedtech.com>>>
Subject: Re: [AST2600] PWM/TACH driver and dbus-sensor issue

Hi Troy,
the fan settings in device tree are similar to aspeed-ast2600a1-evb.dts, like:

        fan0: pwm-fan0 {
                compatible = "pwm-fan";
                pwms = <&pwm 0 40000 0>;        /* Target freq:25 kHz */
                cooling-min-state = <0>;
                cooling-max-state = <3>;
                #cooling-cells = <2>;
                cooling-levels = <0 25 128 255>;
        };
.....
        fan@0 {
                reg = <0x00>;
                aspeed,pulse-pr = <2>;
        };

I test with co-fan F-5010HH12B and San Ace 92 with above setting, and the result looks like in-correct as in previous email.

________________________________________
From: Troy Lee <troy_lee@aspeedtech.com<mailto:troy_lee@aspeedtech.com><mailto:troy_lee@aspeedtech.com<mailto:troy_lee@aspeedtech.com>><mailto:troy_lee@aspeedtech.com<mailto:troy_lee@aspeedtech.com><mailto:troy_lee@aspeedtech.com<mailto:troy_lee@aspeedtech.com>>>>
Sent: Monday, February 14, 2022 11:02 AM
To: Tung Nguyen OS; openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org><mailto:openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org>><mailto:openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org><mailto:openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org>>>
Cc: Thu Nguyen OS; Thang Nguyen OS; Phong Vo OS; Billy Tsai
Subject: RE: [AST2600] PWM/TACH driver and dbus-sensor issue

Adding Billy.

Hi Tung,

-----Original Message-----
From: Tung Nguyen OS <tungnguyen@os.amperecomputing.com<mailto:tungnguyen@os.amperecomputing.com><mailto:tungnguyen@os.amperecomputing.com<mailto:tungnguyen@os.amperecomputing.com>><mailto:tungnguyen@os.amperecomputing.com<mailto:tungnguyen@os.amperecomputing.com><mailto:tungnguyen@os.amperecomputing.com<mailto:tungnguyen@os.amperecomputing.com>>>>
Sent: Monday, February 14, 2022 11:46 AM
To: Troy Lee <troy_lee@aspeedtech.com<mailto:troy_lee@aspeedtech.com><mailto:troy_lee@aspeedtech.com<mailto:troy_lee@aspeedtech.com>><mailto:troy_lee@aspeedtech.com<mailto:troy_lee@aspeedtech.com><mailto:troy_lee@aspeedtech.com<mailto:troy_lee@aspeedtech.com>>>>; openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org><mailto:openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org>><mailto:openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org><mailto:openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org>>>
Cc: Thu Nguyen OS <thu@os.amperecomputing.com<mailto:thu@os.amperecomputing.com><mailto:thu@os.amperecomputing.com<mailto:thu@os.amperecomputing.com>><mailto:thu@os.amperecomputing.com<mailto:thu@os.amperecomputing.com><mailto:thu@os.amperecomputing.com<mailto:thu@os.amperecomputing.com>>>>; Thang Nguyen OS
<thang@os.amperecomputing.com<mailto:thang@os.amperecomputing.com><mailto:thang@os.amperecomputing.com<mailto:thang@os.amperecomputing.com>><mailto:thang@os.amperecomputing.com<mailto:thang@os.amperecomputing.com><mailto:thang@os.amperecomputing.com<mailto:thang@os.amperecomputing.com>>>>; Phong Vo OS
<phong@os.amperecomputing.com<mailto:phong@os.amperecomputing.com><mailto:phong@os.amperecomputing.com<mailto:phong@os.amperecomputing.com>><mailto:phong@os.amperecomputing.com<mailto:phong@os.amperecomputing.com><mailto:phong@os.amperecomputing.com<mailto:phong@os.amperecomputing.com>>>>
Subject: Re: [AST2600] PWM/TACH driver and dbus-sensor issue

Hi Troy,
Thank you for the information, i have merged the dbus-sensor patch and see
it creates the Fan sensors well.
One more issue i have observed about the fan tach report like this:

root@mtmitchell:~# echo 120 > /sys/class/hwmon/hwmon1/pwm1
root@mtmitchell:~# cat /sys/class/hwmon/hwmon0/fan1_input
418526
root@mtmitchell:~# echo 100 > /sys/class/hwmon/hwmon1/pwm1
root@mtmitchell:~# cat /sys/class/hwmon/hwmon0/fan1_input
195312
root@mtmitchell:~# echo 255 > /sys/class/hwmon/hwmon1/pwm1
root@mtmitchell:~# cat /sys/class/hwmon/hwmon0/fan1_input
0
root@mtmitchell:~# echo 50 > /sys/class/hwmon/hwmon1/pwm1
root@mtmitchell:~# cat /sys/class/hwmon/hwmon0/fan1_input
0

It means the fan speed is reported incorrectly somehow, but i can see the
fan speed changes by eyes, do you have idea on this issue ?

Does the aspeed,pulse-pr property of fan node set correspondingly?
What is the expected RPM of you fan? 418526 RPM?

Thanks,
Troy Lee


________________________________________
From: Troy Lee <troy_lee@aspeedtech.com<mailto:troy_lee@aspeedtech.com><mailto:troy_lee@aspeedtech.com<mailto:troy_lee@aspeedtech.com>><mailto:troy_lee@aspeedtech.com<mailto:troy_lee@aspeedtech.com><mailto:troy_lee@aspeedtech.com<mailto:troy_lee@aspeedtech.com>>>>
Sent: Friday, February 11, 2022 12:13 PM
To: Tung Nguyen OS; openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org><mailto:openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org>><mailto:openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org><mailto:openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org>>>
Cc: Thu Nguyen OS; Thang Nguyen OS; Phong Vo OS
Subject: RE: [AST2600] PWM/TACH driver and dbus-sensor issue

Hi Tung,

-----Original Message-----
From: openbmc <openbmc-
bounces+troy_lee=aspeedtech.com@lists.ozlabs.org<mailto:aspeedtech.com@lists.ozlabs.org><mailto:aspeedtech.com@lists.ozlabs.org<mailto:aspeedtech.com@lists.ozlabs.org>><mailto:aspeedtech.com@lists.ozlabs.org<mailto:aspeedtech.com@lists.ozlabs.org><mailto:aspeedtech.com@lists.ozlabs.org<mailto:aspeedtech.com@lists.ozlabs.org>>>> On Behalf Of Tung
Nguyen OS
Sent: Wednesday, February 9, 2022 10:40 PM
To: openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org><mailto:openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org>><mailto:openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org><mailto:openbmc@lists.ozlabs.org<mailto:openbmc@lists.ozlabs.org>>>
Cc: Thu Nguyen OS <thu@os.amperecomputing.com<mailto:thu@os.amperecomputing.com><mailto:thu@os.amperecomputing.com<mailto:thu@os.amperecomputing.com>><mailto:thu@os.amperecomputing.com<mailto:thu@os.amperecomputing.com><mailto:thu@os.amperecomputing.com<mailto:thu@os.amperecomputing.com>>>>; Thang Nguyen OS
<thang@os.amperecomputing.com<mailto:thang@os.amperecomputing.com><mailto:thang@os.amperecomputing.com<mailto:thang@os.amperecomputing.com>><mailto:thang@os.amperecomputing.com<mailto:thang@os.amperecomputing.com><mailto:thang@os.amperecomputing.com<mailto:thang@os.amperecomputing.com>>>>; Phong Vo OS
<phong@os.amperecomputing.com<mailto:phong@os.amperecomputing.com><mailto:phong@os.amperecomputing.com<mailto:phong@os.amperecomputing.com>><mailto:phong@os.amperecomputing.com<mailto:phong@os.amperecomputing.com><mailto:phong@os.amperecomputing.com<mailto:phong@os.amperecomputing.com>>>>
Subject: [AST2600] PWM/TACH driver and dbus-sensor issue

Dear community,
We have ported the PWM/TACH hwmon driver for AST2600 from ASPEED's
repository https://github.com/AspeedTech-BMC/linux/tree/aspeed-
master-
v5.4/drivers/hwmon to support Ampere Computing's systems. Verify with
AST2600 EVB, i can see the driver works. However there is a concern like:
1. The change of hwmon fan pwm/tach in sysfs (as below), this is
different from the ast2500 as the separated of the fan*_input and pwm1
in various hwmon directories. At this time, the driver doesn't exist
in the OpenBMC linux at https://github.com/openbmc/linux. Is OpenBMC
going to merge and keep this driver ?

Please have a look on this patch.
https://gerrit.openbmc-project.xyz/c/openbmc/dbus-sensors/+/49253

Thanks,
Troy Lee

root@mtmitchell:~# ls -la /sys/class/hwmon/hwmon hwmon0/ hwmon1/
hwmon2/ hwmon3/ hwmon4/ hwmon5/ hwmon6/ hwmon7/ hwmon8/
hwmon9/
root@mtmitchell:~# ls -la /sys/class/hwmon/hwmon0/
drwxr-xr-x    3 root     root             0 Jan  1  1970 .
drwxr-xr-x    3 root     root             0 Jan  1  1970 ..
lrwxrwxrwx    1 root     root             0 Feb  9 08:38 device -
../../../1e610000.pwm_tach:tach
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan10_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan11_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan12_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan13_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan14_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan15_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan16_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan1_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan2_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan3_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan4_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan5_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan6_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan7_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan8_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 fan9_input
-r--r--r--    1 root     root          4096 Feb  9 08:38 name
lrwxrwxrwx    1 root     root             0 Feb  9 08:38 of_node -
../../../../../../../../firmware/devicetree/base/ahb/apb/pwm_tach@1e
610
000/tach
drwxr-xr-x    2 root     root             0 Feb  9 08:38 power
lrwxrwxrwx    1 root     root             0 Jan  1  1970 subsystem -
../../../../../../../../class/hwmon
-rw-r--r--    1 root     root          4096 Jan  1  1970 uevent
root@mtmitchell:~# ls -la /sys/class/hwmon/hwmon*/pwm*
-rw-r--r--    1 root     root          4096 Feb  9 09:13
/sys/class/hwmon/hwmon1/pwm1
-rw-r--r--    1 root     root          4096 Feb  9 09:20
/sys/class/hwmon/hwmon2/pwm1
-rw-r--r--    1 root     root          4096 Feb  9 08:38
/sys/class/hwmon/hwmon3/pwm1
-rw-r--r--    1 root     root          4096 Feb  9 08:38
/sys/class/hwmon/hwmon4/pwm1
-rw-r--r--    1 root     root          4096 Feb  9 08:38
/sys/class/hwmon/hwmon5/pwm1
-rw-r--r--    1 root     root          4096 Feb  9 08:38
/sys/class/hwmon/hwmon6/pwm1
-rw-r--r--    1 root     root          4096 Feb  9 08:38
/sys/class/hwmon/hwmon7/pwm1
-rw-r--r--    1 root     root          4096 Feb  9 08:38
/sys/class/hwmon/hwmon8/pwm1

2. With above changes, the dbus-sensor for FAN/PWM shall not work
because of the compatibility. So if OpenBMC want to keep above
PWM/TACH driver, does any sides have the plan to support the fan
sensor, if not, we can join and do it.

Thank you and best regards,
Tung




^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2022-02-18  2:37 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-09 14:40 [AST2600] PWM/TACH driver and dbus-sensor issue Tung Nguyen OS
2022-02-11  5:13 ` Troy Lee
2022-02-14  3:45   ` Tung Nguyen OS
2022-02-14  4:02     ` Troy Lee
2022-02-14  4:24       ` Tung Nguyen OS
2022-02-14  6:34         ` Billy Tsai
2022-02-15 10:10           ` Tung Nguyen OS
2022-02-15 10:33             ` Billy Tsai
2022-02-16  7:07               ` Tung Nguyen OS
2022-02-17  2:57                 ` Billy Tsai
2022-02-17 10:35                   ` Tung Nguyen OS

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.