Bug#906268: rules

Josua Mayer josua.mayer97 at gmail.com
Thu Aug 16 10:25:15 BST 2018


Please find the current rules file and script attached.

-------------- next part --------------
#
# This udev rule connects the USB ID pin with the charging current setting
# of the twl4030 through a helper script.
#
# This allows to use default charging current 500 mA and switch to higher
# values if a more capable power supply indicates through the ID pin.
#
# Implementation is a little tricky since an udev rule can'd dynamically
# identify two different nodes. And ATTR{} can not reference arbitrary
# files relative to root (ATTR is relative to /sys/%p even if it starts
# with a /). And we can't create symlinks within /sysfs.
#
# Therefore connecting two device nodes in /sys is beyond udev rules
# and we need a helper script.
#

# 1. provide stable name to access the id pin of the USB connector and the max_current setting for the usb charger
# /dev/usb_id -> /sys/devices/platform/68000000.ocp/48070000.i2c/i2c-0/0-0048/48070000.i2c:twl at 48:twl4030-usb/id
# /dev/usb_max_current -> /sys/devices/platform/68000000.ocp/48070000.i2c/i2c-0/0-0048/48070000.i2c:twl at 48:bci/power_supply/twl4030_usb/input_current_limit
# to find patters use e.g. udevadm info -a -p /sys/devices/platform/68000000.ocp/48070000.i2c/i2c-0/0-0048/48070000.i2c:twl at 48:bci/power_supply/twl4030_usb

ACTION=="add", SUBSYSTEM=="platform", KERNEL=="*twl4030-usb", DRIVER=="twl4030_usb", RUN+="/bin/ln -s /sys%p/id /dev/usb_id"
ACTION=="add", SUBSYSTEM=="power_supply", KERNEL=="twl4030_usb", ATTR{type}=="USB", RUN+="/bin/ln -s /sys%p/input_current_limit /dev/usb_max_current"

# 2. default to 500 mA right after boot (independently what the ID pin says)
ACTION=="add", SUBSYSTEM=="power_supply", KERNEL=="twl4030_usb", ATTR{type}=="USB", ATTR{input_current_limit}="500000"

# 3. this is preparation for the Pyra but neither tested nor complete nor working
ACTION=="add", SUBSYSTEM=="power_supply", KERNEL=="bq24297", ATTR{type}=="USB", RUN+="/bin/ln -s /sys%p/id /dev/usb_id"
ACTION=="add", SUBSYSTEM=="power_supply", KERNEL=="bq24297", ATTR{type}=="USB", RUN+="/bin/ln -s /sys%p/input_current_limit /dev/usb_max_current"

# 4. charger has been plugged in (or removed): run external script
# this script reads the id pin value and make a decision for the current setting of /dev/usb_max_current
ACTION=="change", SUBSYSTEM=="power_supply", KERNEL=="twl4030_usb", ATTR{type}=="USB", RUN+="/etc/udev/rules.d/charging.sh"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: charging.sh
Type: application/x-shellscript
Size: 416 bytes
Desc: not available
URL: <http://alioth-lists.debian.net/pipermail/pkg-systemd-maintainers/attachments/20180816/c064f3f2/attachment-0002.bin>


More information about the Pkg-systemd-maintainers mailing list