grunt: custom power_state controller for grunt.

To address the bug attached here, this change ensures that before we
turn off the DUT (power_state:off, power_state:rec), we disable the PP1
on the PPC on the ccd port. This prevents the PPC from turning off the
SBU lines, and maintains the DUT available over ccd/servod.

BUG=b:173059305

TEST=sudo servod -b grunt //
     dut-control servo_v4_role:snk
     dut-control power_state:off
     sleep 10
     dut-control cr50_version servo_v4_sbu2_mv
cr50_version:0.5.6/cr50_v1.9308_87_mp.510-d2da4373
servo_v4_sbu2_mv:2918
     dut-control power_state:on
     dut-control power_state:rec
     sleep 10
     dut-control cr50_version servo_v4_sbu2_mv
cr50_version:0.5.6/cr50_v1.9308_87_mp.510-d2da4373
servo_v4_sbu2_mv:2916

// running offending test through grunt
// this if after reverting the last CL that removes the `snk` on grunt
TEST=test_that $gip  platform_ServoPowerStateController.USBPluggedin
[...]/results-1-platform_ServoPowerStateController.USBPluggedin
[  PASSED  ]
[...]/results-1-platform_ServoPowerStateController.USBPluggedin/platform_ServoPowerStateController
[  PASSED  ]

// showing correct turning on when v4 is a snk
TEST=sudo servod -b grunt // servo v4
     dut-control servo_v4_role:snk
     dut-control power_state:off
     dut-control c0_ppc_pp1_en
c0_ppc_pp1_en:off
     dut-control power_state:on
     dut-control c0_ppc_pp1_en
c0_ppc_pp1_en:on

// showing correct leaving off when v4 is a src
TEST=sudo servod -b grunt // servo v4
     dut-control servo_v4_role:src
     dut-control power_state:off
     dut-control c0_ppc_pp1_en
c0_ppc_pp1_en:off
     dut-control power_state:on
     dut-control c0_ppc_pp1_en
c0_ppc_pp1_en:off

// before this change, showing the need for reset() as well
TEST=sudo servod -b grunt // servo v4
     dut-control servo_v4_role:snk
     dut-control power_state:reset
2020-12-14 10:49:32,963 - cr50 - WARNING - Consider checking whether the
servo device has read/write access to the Cr50 UART console.
2020-12-14 10:49:32,964 - Controls - ERROR - (cr50Error) Failed setting
cold_reset -> off: cr50 uart is unresponsive
2020-12-14 10:49:32,969 - Controls - ERROR - (cr50Error) Failed setting
power_state -> reset: cr50 uart is unresponsive
Problem with ['power_state:reset'] :: cr50 uart is unresponsive

     dut-control servo_v4_sbu2_mv
servo_v4_sbu2_mv:2325 // the voltage indicative of sbu issue

// after this change
TEST=sudo servod -b grunt
     dut-control servo_v4_role:snk
     dut-control power_state:reset
     sleep 10
     dut-control ec_board
ec_board:careena

Change-Id: I0be38750b161bd8dc9b6fd82bef4864f33a2445a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/hdctools/+/2538579
Tested-by: Ruben Rodriguez Buchillon <coconutruben@chromium.org>
Reviewed-by: Edward Hill <ecgh@chromium.org>
Reviewed-by: Wai-Hong Tam <waihong@google.com>
Commit-Queue: Ruben Rodriguez Buchillon <coconutruben@chromium.org>
diff --git a/servo/servo_server.py b/servo/servo_server.py
index 73865c9..50056d8 100755
--- a/servo/servo_server.py
+++ b/servo/servo_server.py
@@ -336,6 +336,10 @@
       self._drv_dict[control_name]['set'] = (params, drv, device_info)
     return (params, drv, device_info)
 
+  def _has_control(self, control):
+    """Returns True if control is available in servod."""
+    return self._syscfg.is_control(control)
+
   def doc_all(self):
     """Return all documenation for controls.