-
Notifications
You must be signed in to change notification settings - Fork 7
/
81-pwm-noroot.rules
40 lines (34 loc) · 2.06 KB
/
81-pwm-noroot.rules
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# /etc/udev/rules.d/81-pwm-noroot.rules
#
# ReWritten by: Matthijs van Duin
# Corrects sys PWM permissions on the BB so non-root users in the pwm group can
# manipulate pwm along with creating a symlink under /dev/pwm/
#
SUBSYSTEM=="pwm", ACTION=="add|change", \
RUN+="/bin/chgrp -R gpio '/sys%p'", \
RUN+="/bin/chmod -R g=u '/sys%p'"
# automatically export pwm channels
# SUBSYSTEM=="pwm", KERNEL=="pwmchip*", ACTION=="add", ATTR{export}="0"
# SUBSYSTEM=="pwm", KERNEL=="pwmchip*", ACTION=="add", ATTR{npwm}!="1", ATTR{export}="1"
# identify pwm peripherals on am335x
SUBSYSTEM=="pwm", KERNELS=="48300100.*", ENV{PWMCHIP_NAME}="ecap0"
SUBSYSTEM=="pwm", KERNELS=="48300200.*", ENV{PWMCHIP_NAME}="ehrpwm0"
SUBSYSTEM=="pwm", KERNELS=="48302100.*", ENV{PWMCHIP_NAME}="ecap1"
SUBSYSTEM=="pwm", KERNELS=="48302200.*", ENV{PWMCHIP_NAME}="ehrpwm1"
SUBSYSTEM=="pwm", KERNELS=="48304100.*", ENV{PWMCHIP_NAME}="ecap2"
SUBSYSTEM=="pwm", KERNELS=="48304200.*", ENV{PWMCHIP_NAME}="ehrpwm2"
# identify pwm peripherals on am57xx/dra7xx
SUBSYSTEM=="pwm", KERNELS=="4843e100.*", ENV{PWMCHIP_NAME}="ecap0"
SUBSYSTEM=="pwm", KERNELS=="4843e200.*", ENV{PWMCHIP_NAME}="ehrpwm0"
SUBSYSTEM=="pwm", KERNELS=="48440100.*", ENV{PWMCHIP_NAME}="ecap1"
SUBSYSTEM=="pwm", KERNELS=="48440200.*", ENV{PWMCHIP_NAME}="ehrpwm1"
SUBSYSTEM=="pwm", KERNELS=="48442100.*", ENV{PWMCHIP_NAME}="ecap2"
SUBSYSTEM=="pwm", KERNELS=="48442200.*", ENV{PWMCHIP_NAME}="ehrpwm2"
# identify pwm channels
SUBSYSTEM=="pwm", ENV{DEVTYPE}=="pwm_channel", ENV{PWMCHIP_NAME}!="", ATTR{../npwm}=="1", ENV{PWM_NAME}="%E{PWMCHIP_NAME}"
SUBSYSTEM=="pwm", ENV{DEVTYPE}=="pwm_channel", ENV{PWMCHIP_NAME}!="", DRIVERS=="ehrpwm", KERNEL=="*:0", ENV{PWM_NAME}="%E{PWMCHIP_NAME}a"
SUBSYSTEM=="pwm", ENV{DEVTYPE}=="pwm_channel", ENV{PWMCHIP_NAME}!="", DRIVERS=="ehrpwm", KERNEL=="*:1", ENV{PWM_NAME}="%E{PWMCHIP_NAME}b"
# create symlinks in /dev/pwm
SUBSYSTEM=="pwm", ENV{DEVTYPE}=="pwm_channel", ACTION=="add", ENV{PWM_NAME}!="", \
RUN+="/bin/mkdir -p /dev/pwm", \
RUN+="/bin/ln -sT '/sys/class/pwm/%k' /dev/pwm/%E{PWM_NAME}"