# WRTD systems are pre programmed, so it is fine to unreset the MockTurtle
# CPUs as soon as we have a running driver

SUBSYSTEM=="mockturtle", KERNEL=="trtl-[0-9a-zA-Z][0-9a-zA-Z][0-9a-zA-Z][0-9a-zA-Z]-[0-9][0-9]" ACTION=="add", ATTRS{application_id}=="0x57544e[0-9a-zA-Z][0-9a-zA-Z]", ATTR{reset}=="1", ATTR{reset}:="0"


# Assign wrtd group to mockturtle devices, cpus and hmqs (if the wrtd group
# does not exits, then it will be root)

SUBSYSTEM=="mockturtle", KERNEL=="trtl-[0-9a-zA-Z][0-9a-zA-Z][0-9a-zA-Z][0-9a-zA-Z]" ACTION=="add", ATTR{application_id}=="0x57544e[0-9a-zA-Z][0-9a-zA-Z]", GROUP="wrtd"
SUBSYSTEM=="mockturtle", KERNEL=="trtl-[0-9a-zA-Z][0-9a-zA-Z][0-9a-zA-Z][0-9a-zA-Z]-[0-9][0-9]" ACTION=="add", ATTRS{application_id}=="0x57544e[0-9a-zA-Z][0-9a-zA-Z]", GROUP="wrtd"
SUBSYSTEM=="mockturtle", KERNEL=="trtl-[0-9a-zA-Z][0-9a-zA-Z][0-9a-zA-Z][0-9a-zA-Z]-[0-9][0-9]-[0-9][0-9]" ACTION=="add", ATTRS{application_id}=="0x57544e[0-9a-zA-Z][0-9a-zA-Z]", GROUP="wrtd"

SUBSYSTEM=="mockturtle", KERNEL=="trtl-[0-9a-zA-Z][0-9a-zA-Z][0-9a-zA-Z][0-9a-zA-Z]" ACTION=="add", ATTR{application_id}=="0x57544e[0-9a-zA-Z][0-9a-zA-Z]" RUN+="/usr/bin/chown root:wrtd $sys/$devpath/reset_mask"
SUBSYSTEM=="mockturtle", KERNEL=="trtl-[0-9a-zA-Z][0-9a-zA-Z][0-9a-zA-Z][0-9a-zA-Z]-[0-9][0-9]" ACTION=="add", ATTRS{application_id}=="0x57544e[0-9a-zA-Z][0-9a-zA-Z]" RUN+="/usr/bin/chown root:wrtd $sys/$devpath/reset"
SUBSYSTEM=="mockturtle", KERNEL=="trtl-[0-9a-zA-Z][0-9a-zA-Z][0-9a-zA-Z][0-9a-zA-Z]-[0-9][0-9]-[0-9][0-9]" ACTION=="add", ATTRS{application_id}=="0x57544e[0-9a-zA-Z][0-9a-zA-Z]" RUN+="/usr/bin/chown root:wrtd $sys/$devpath/discard_all"
