eve: add FP MCU UART support

The FP MCU should be wired the same way the PD MCU was on GLaDOS
platform.
Keep the usbpd_XXX names as aliases to re-use existing scripts.

BUG=chrome-os-partner:62893
TEST=not tested on the real hardware. 'sudo servod -b eve'

Change-Id: I85f0c5aac99a3a06e40a38f54db0c3febe77eca2
Reviewed-on: https://chromium-review.googlesource.com/443230
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Todd Broch <tbroch@chromium.org>
Reviewed-by: Todd Broch <tbroch@chromium.org>
diff --git a/servo/data/fpmcu.xml b/servo/data/fpmcu.xml
new file mode 100644
index 0000000..fec4bfc
--- /dev/null
+++ b/servo/data/fpmcu.xml
@@ -0,0 +1,128 @@
+<root>
+  <!-- FP MCU is also named 'usbpd' for compatibility with previous scripts -->
+  <!-- FP MCU UART Controls -->
+  <control>
+    <name>uart4_pty</name>
+    <alias>raw_fpmcu_uart_pty,raw_usbpd_uart_pty</alias>
+    <doc>Pseudo-terminal (pty) thats connnected to FP MCU's
+    uart console</doc>
+    <params cmd="get" subtype="pty" interface="1" drv="uart" clobber_ok=""
+    servo_v4_interface="2" servo_micro_interface="2"></params>
+  </control>
+  <!-- EC-3PO console interpreter for FP MCU -->
+  <control>
+    <name>ec3po_fpmcu_uart_pty</name>
+    <alias>ec3po_usbpd_uart_pty,fpmcu_uart_pty,usbpd_uart_pty</alias>
+    <doc>FP MCU UART console provided via EC-3PO console interpreter.</doc>
+    <params cmd="get" subtype="pty" interface="9" drv="uart"></params>
+  </control>
+  <control>
+    <name>fpmcu_ec3po_interp_connect</name>
+    <alias>usbpd_ec3po_interp_connect</alias>
+    <doc>State indicating if interpreter is listening to the EC UART.</doc>
+    <params interface="9" drv="ec3po_driver" map="onoff" init="on"
+    subtype="interp_connect" clobber_ok=""></params>
+  </control>
+  <control>
+    <name>uart4_baudrate</name>
+    <alias>fpmcu_uart_baudrate,usbpd_uart_baudrate</alias>
+    <doc>Baudrate for FP MCU's uart console</doc>
+    <params drv="uart" subtype="props" line_prop="baudrate" clobber_ok=""
+    interface="1"></params>
+  </control>
+  <control>
+    <name>uart4_parity</name>
+    <alias>fpmcu_uart_parity,usbpd_uart_parity</alias>
+    <doc>Parity for FP MCU's uart console</doc>
+    <params drv="uart" subtype="props" line_prop="parity" clobber_ok=""
+    interface="1" map="uart_parity"></params>
+  </control>
+  <control>
+    <name>uart4_sbits</name>
+    <alias>fpmcu_uart_sbits,usbpd_uart_sbits</alias>
+    <doc>Number of stop bits for FP MCU's uart console</doc>
+    <params drv="uart" subtype="props" line_prop="sbits" clobber_ok=""
+    interface="1" map="uart_sbits"></params>
+  </control>
+  <control>
+    <name>uart4_bits</name>
+    <alias>fpmcu_uart_bits,usbpd_uart_bits</alias>
+    <doc>Number of data bits for FP MCU's uart console</doc>
+    <params drv="uart" subtype="props" line_prop="bits" clobber_ok=""
+    interface="1" map="uart_bits"></params>
+  </control>
+  <!-- FP MCU UART Automation Controls -->
+  <control>
+    <name>fpmcu_uart_cmd</name>
+    <alias>usbpd_uart_cmd</alias>
+    <doc>Set to send command to FP MCU UART. Get to obtain the
+    matched results with the regular expression of
+    fpmcu_uart_regexp.</doc>
+    <params subtype="uart_cmd" interface="9" drv="uart"
+    input_type="str"></params>
+  </control>
+  <control>
+    <name>fpmcu_uart_multicmd</name>
+    <alias>usbpd_uart_multicmd</alias>
+    <doc>Set to send multiple commands to FP MCU UART.</doc>
+    <params subtype="uart_multicmd" interface="9" drv="uart"
+    input_type="str" cmd="set"></params>
+  </control>
+  <control>
+    <name>fpmcu_uart_regexp</name>
+    <alias>usbpd_uart_regexp</alias>
+    <doc>List of regular expressions to match the response of
+    fpmcu_uart_cmd.</doc>
+    <params subtype="uart_regexp" interface="9" drv="uart"
+    input_type="str"></params>
+  </control>
+  <control>
+    <name>fpmcu_uart_timeout</name>
+    <alias>usbpd_uart_timeout</alias>
+    <doc>Timeout value for a response after issuing a command on
+    fpmcu_uart_cmd.</doc>
+    <params subtype="uart_timeout" interface="9" drv="uart"
+    input_type="float"></params>
+  </control>
+  <control>
+    <name>fpmcu_uart_capture</name>
+    <alias>usbpd_uart_capture</alias>
+    <doc>Enables capture of FP MCU console via
+    fpmcu_uart_stream</doc>
+    <params subtype="uart_capture" interface="9" drv="uart"
+    map="onoff"></params>
+  </control>
+  <control>
+    <name>fpmcu_uart_stream</name>
+    <alias>usbpd_uart_stream</alias>
+    <doc>FP MCU console stream captured while fpmcu_uart_capture is
+    set to 'on'</doc>
+    <params cmd="get" subtype="uart_stream" interface="9"
+    drv="uart"></params>
+  </control>
+  <!-- FP MCU UART Buffers & VREF Controls -->
+  <control>
+    <name>jtag_buf_en</name>
+    <alias>fpmcu_uart_en,usbpd_uart_en</alias>
+    <doc>Enabled JTAG buffer on servo ... re-purposed to uart4.</doc>
+    <params clobber_ok="" init="on"></params>
+  </control>
+  <control>
+    <name>uart4_on_flex_en</name>
+    <alias>fpmcu_uart_on_flex_en,usbpd_uart_on_flex_en</alias>
+    <doc>Enables JTAG buffer on servo flex ... repurposed to uart4.</doc>
+    <params interface="2" servo_v3_interface="4" drv="pca95xx" subtype="gpio"
+    slv="0x26" offset="3" map="onoff_i" init="on" clobber_ok=""></params>
+  </control>
+  <!-- Override from definition in servo_v2_r0.xml -->
+  <control>
+    <name>dev_mode</name>
+    <alias>fpmcu_boot_mode,usbpd_boot_mode</alias>
+    <params clobber_ok="" od="PU" map="onoff_i"></params>
+  </control>
+  <control>
+    <name>pch_disable</name>
+    <alias>fpmcu_reset,usbpd_reset</alias>
+    <params clobber_ok=""></params>
+  </control>
+</root>
diff --git a/servo/data/servo_eve_overlay.xml b/servo/data/servo_eve_overlay.xml
index 871d6b3..f9e74e7 100644
--- a/servo/data/servo_eve_overlay.xml
+++ b/servo/data/servo_eve_overlay.xml
@@ -5,6 +5,9 @@
   <include>
     <name>x86_ec_common.xml</name>
   </include>
+  <include>
+    <name>fpmcu.xml</name>
+  </include>
   <!-- ******** Controls ******** -->
   <control>
     <name>power_state</name>
@@ -23,4 +26,11 @@
     <params clobber_ok="" cmd="get" subtype="chip" interface="servo"
     drv="cros_chip" chip="npcx_spi"/>
   </control>
+  <control>
+    <name>fpmcu_chip</name>
+    <alias>usbpd_chip</alias>
+    <doc>FP MCU chip name (read-only)</doc>
+    <params clobber_ok="" cmd="get" subtype="chip" interface="servo"
+    drv="cros_chip" chip="stm32"/>
+  </control>
 </root>
diff --git a/servo/servo_interfaces.py b/servo/servo_interfaces.py
index 4f0a469..7902fc3 100644
--- a/servo/servo_interfaces.py
+++ b/servo/servo_interfaces.py
@@ -174,7 +174,7 @@
   INTERFACE_BOARDS[board][0x18d1][0x5002][5] = 'ftdi_uart'
 
 # re-purposes JTAG to be UART for USBPD MCU
-for board in ['asuka', 'caroline', 'cave', 'chell', 'glados',
+for board in ['asuka', 'caroline', 'cave', 'chell', 'eve', 'glados',
               'kunimitsu', 'lars', 'pbody', 'sentry', 'strago']:
   INTERFACE_BOARDS[board][0x18d1][0x5002] = \
       list(INTERFACE_DEFAULTS[0x18d1][0x5002])
@@ -182,7 +182,7 @@
 
 # TODO(crosbug.com/p/60939) re-purpose JTAG to H1 uart at some point but dummy
 # for now.
-for board in ['eve', 'poppy']:
+for board in ['poppy']:
   INTERFACE_BOARDS[board][0x18d1][0x5002] = \
       list(INTERFACE_DEFAULTS[0x18d1][0x5002])
   INTERFACE_BOARDS[board][0x18d1][0x5002][0] = 'dummy'