kitty: add servo overlay for kitty

Add servo overlay for kitty with the following features:
  - 'rec_mode' to control recovery button;
  - 'power_state' to control power button (not issuing EC command, in
    case EC is removed);
  - use USB_KM232 cable for FAFT tests.

BUG=chrome-os-partner:33531,chrome-os-partner:33063
TEST="sudo servod --board=nyan_kitty --usbkm32=$USBKM232_UART_DEVICE"
     pass firmware_FAFTSetup and firmware_DevMode tests

Change-Id: Icd7685449e7e12757ad8f98081d69520dcd61181
Signed-off-by: Yen Lin <yelin@nvidia.com>
Reviewed-on: https://chromium-review.googlesource.com/229521
Reviewed-by: Shawn Nematbakhsh <shawnn@chromium.org>
diff --git a/servo/data/servo_nyan_kitty_overlay.xml b/servo/data/servo_nyan_kitty_overlay.xml
new file mode 100644
index 0000000..2aaa384
--- /dev/null
+++ b/servo/data/servo_nyan_kitty_overlay.xml
@@ -0,0 +1,58 @@
+<root>
+  <include>
+    <name>servoflex_v2_r0_p50.xml</name>
+  </include>
+  <include>
+    <name>ec_common.xml</name>
+  </include>
+  <!-- ******** Controls ******** -->
+  <control>
+    <name>ec_uart_capture</name>
+    <doc>ec_uart_capture</doc>
+    <params subtype="uart_capture" interface="7" drv="uart"
+            map="onoff"></params>
+  </control>
+  <control>
+    <name>ec_uart_cmd</name>
+    <doc>
+      Set to send command to EC UART. Get to obtain the matched
+      results with the regular expression of ec_uart_regexp.
+    </doc>
+    <params subtype="uart_cmd" interface="7" drv="ec"
+    input_type="str"></params>
+  </control>
+  <control>
+    <name>ec_uart_multicmd</name>
+    <doc>Set to send multiple commands to EC UART.</doc>
+    <params subtype="uart_multicmd" interface="7" drv="ec"
+    input_type="str" cmd="set"></params>
+  </control>
+  <control>
+    <name>ec_uart_regexp</name>
+    <doc>
+      List of regular expressions which matches the response of
+      ec_uart_cmd.
+    </doc>
+    <params subtype="uart_regexp" interface="7" drv="ec"
+    input_type="str"></params>
+  </control>
+  <control>
+    <name>ec_uart_stream</name>
+    <doc>Ec uart stream collected while ec_uart_capture is set to 'on'</doc>
+    <params cmd="get" subtype="uart_stream" interface="7" drv="uart"></params>
+  </control>
+  <control>
+    <name>ec_uart_timeout</name>
+    <doc>
+      Timeout value for waiting EC UART response of issuing an
+      EC command.
+    </doc>
+    <params subtype="uart_timeout" interface="7" drv="ec"
+    input_type="float"></params>
+  </control>
+  <control>
+    <name>power_state</name>
+    <doc>Used to turn the DUT off and on</doc>
+    <params clobber_ok="" input_type="str" interface="servo" drv="kitty_power"/>
+  </control>
+</root>
diff --git a/servo/drv/__init__.py b/servo/drv/__init__.py
index 50c3c87..127053f 100644
--- a/servo/drv/__init__.py
+++ b/servo/drv/__init__.py
@@ -21,6 +21,7 @@
 import ina2xx
 import ina219
 import ina231
+import kitty_power
 import larvae_adc
 import lcm2004
 import ltc1663
diff --git a/servo/drv/kitty_power.py b/servo/drv/kitty_power.py
new file mode 100644
index 0000000..e885971
--- /dev/null
+++ b/servo/drv/kitty_power.py
@@ -0,0 +1,21 @@
+# Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Driver for power_state for kitty board.
+"""
+import cros_ec_hardrec_power
+
+class kittyPower(cros_ec_hardrec_power.crosEcHardrecPower):
+
+  """
+  kitty uses 'rec_mode' signal (recovery button) to enter RECOVERY mode.
+  Also, the driver uses long-press of power_button to turn off power.
+  """
+
+  # _PWR_BUTTON_SHUTDOWN_TIME: This represents the long-press time of power
+  # button.  Used in _power_off().
+  _PWR_BUTTON_SHUTDOWN_TIME = 10
+
+  def _power_off(self):
+    self._interface.power_key(self._PWR_BUTTON_SHUTDOWN_TIME)
diff --git a/servo/servo_server.py b/servo/servo_server.py
index 8bfe890..d187646 100644
--- a/servo/servo_server.py
+++ b/servo/servo_server.py
@@ -132,7 +132,8 @@
       return keyboard_handlers.ParrotHandler(servo)
     elif board == 'stout':
       return keyboard_handlers.StoutHandler(servo)
-    elif board in ('mccloud', 'monroe', 'panther', 'tricky', 'zako'):
+    elif board in ('mccloud', 'monroe', 'nyan_kitty', 'panther', 'tricky',
+                   'zako'):
       if self._usbkm232 is None:
         logging.warn("No device path specified for usbkm232 handler. Returning "
                      "the DefaultHandler, which is likely the wrong keyboard "