From fa671e65917b6673250af23e58372bcec272ca0e Mon Sep 17 00:00:00 2001 From: Anton Staaf Date: Mon, 16 Mar 2015 10:56:37 -0700 Subject: USB: Add udev rule to handle CCD devices This udev rule creates a directory in /dev/google for each device attached. The name of the directory is unique to the device and is prefixed with the device product name. Within the directory there is a serial directory that contains symlinks to each USB serial port exposed by the device. The symlinks are named based on the USB interface name provided by the EC. Additional subdirectories can be added for I2C, JTAG, GPIOs, and SPI as needed. Signed-off-by: Anton Staaf BRANCH=None BUG=None TEST=Verify that two different CCD devices generate uniquely named entries. Change-Id: I7e6f2ace29b7302c7c072bcf6aab7c8f060b993a Reviewed-on: https://chromium-review.googlesource.com/260420 Trybot-Ready: Anton Staaf Tested-by: Anton Staaf Reviewed-by: Vincent Palatin Commit-Queue: Anton Staaf --- extra/usb_serial/50-google-serial.rules | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 extra/usb_serial/50-google-serial.rules diff --git a/extra/usb_serial/50-google-serial.rules b/extra/usb_serial/50-google-serial.rules new file mode 100644 index 0000000000..ee2db62543 --- /dev/null +++ b/extra/usb_serial/50-google-serial.rules @@ -0,0 +1,14 @@ +# +# Match a Google device with an interface that supports the simple serial +# driver. +# +# The first rule matches the google VID and records the product name, USB bus +# number and USB device path (the device path is the list of hub ports between +# the root and the device). This becomes a unique name under which the second +# rule creates the symlinks to the serial devices. The second rule will only +# fire if the .GOOGLE_CCD_NAME variable has been set by the first rule. If +# some other udev rule has set the same name previously, there would be a +# conflict, so this name is chosen to be verbose and likely unique. +# +SUBSYSTEMS=="usb", ATTRS{idVendor}=="18d1", ENV{.GOOGLE_CCD_NAME}="$attr{product}-$attr{busnum}-$attr{devpath}" +SUBSYSTEMS=="usb", ENV{.GOOGLE_CCD_NAME}!="", ATTRS{bInterfaceClass}=="ff", ATTRS{bInterfaceSubClass}=="50", ATTRS{bInterfaceProtocol}=="01", OPTIONS+="string_escape=replace", SYMLINK+="google/$env{.GOOGLE_CCD_NAME}/serial/$attr{interface}" -- cgit v1.2.1