[tpm] Remove IOCTLs and utility that used them

There was only one IOCTL defined, and it was from before we had suspend
hooks plumbed through.  Since the behavior the IOCTL triggered is now
done automatically during the suspend hook, we can just get rid of it.

ZX-2846 #done

Test: Booted on a pixelbook
Change-Id: Ie2706221d960a62d5810eb5aad4098af1054ce09
diff --git a/system/dev/misc/tpm/tpm.cpp b/system/dev/misc/tpm/tpm.cpp
index 44ede23..fe04917 100644
--- a/system/dev/misc/tpm/tpm.cpp
+++ b/system/dev/misc/tpm/tpm.cpp
@@ -22,7 +22,6 @@
 #include <fbl/auto_lock.h>
 #include <fbl/unique_ptr.h>
 #include <fbl/unique_free_ptr.h>
-#include <zircon/device/tpm.h>
 #include <zircon/types.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -123,18 +122,6 @@
     delete this;
 }
 
-zx_status_t Device::DdkIoctl(uint32_t op,
-                             const void* in_buf, size_t in_len,
-                             void* out_buf, size_t out_len, size_t* out_actual) {
-    switch (op) {
-        case IOCTL_TPM_SAVE_STATE: {
-            fbl::AutoLock guard(&lock_);
-            return ShutdownLocked(TPM_SU_STATE);
-        }
-    }
-    return ZX_ERR_NOT_SUPPORTED;
-}
-
 zx_status_t Device::DdkSuspend(uint32_t flags) {
     fbl::AutoLock guard(&lock_);
 
diff --git a/system/dev/misc/tpm/tpm.h b/system/dev/misc/tpm/tpm.h
index bbea865..5aab30f 100644
--- a/system/dev/misc/tpm/tpm.h
+++ b/system/dev/misc/tpm/tpm.h
@@ -52,7 +52,7 @@
 };
 
 class Device;
-using DeviceType = ddk::Device<Device, ddk::Ioctlable, ddk::Suspendable>;
+using DeviceType = ddk::Device<Device, ddk::Suspendable>;
 
 class Device : public DeviceType,
                public ddk::EmptyProtocol<ZX_PROTOCOL_TPM> {
@@ -67,8 +67,6 @@
 
     // DDK methods
     void DdkRelease();
-    zx_status_t DdkIoctl(uint32_t op, const void* in_buf, size_t in_len, void* out_buf,
-                         size_t out_len, size_t* actual);
     zx_status_t DdkSuspend(uint32_t flags);
 
     // Register this instance with devmgr and launch the deferred
diff --git a/system/public/zircon/device/ioctl.h b/system/public/zircon/device/ioctl.h
index 497b249..7df5529 100644
--- a/system/public/zircon/device/ioctl.h
+++ b/system/public/zircon/device/ioctl.h
@@ -43,7 +43,6 @@
 // 0x12 unused
 #define IOCTL_FAMILY_BLOCK          0x13
 #define IOCTL_FAMILY_I2C            0x14
-#define IOCTL_FAMILY_TPM            0x15
 #define IOCTL_FAMILY_USB_DEVICE     0x16
 #define IOCTL_FAMILY_HID            0x17
 // 0x18 unused
diff --git a/system/public/zircon/device/tpm.h b/system/public/zircon/device/tpm.h
deleted file mode 100644
index bb89a09..0000000
--- a/system/public/zircon/device/tpm.h
+++ /dev/null
@@ -1,19 +0,0 @@
-// Copyright 2016 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#pragma once
-
-#include <zircon/device/ioctl.h>
-#include <zircon/device/ioctl-wrapper.h>
-
-__BEGIN_CDECLS;
-
-/* TPM IOCTL commands */
-#define IOCTL_TPM_SAVE_STATE \
-    IOCTL(IOCTL_KIND_DEFAULT, IOCTL_FAMILY_TPM, 0)
-
-// ssize_t ioctl_tpm_save_state(int fd);
-IOCTL_WRAPPER(ioctl_tpm_save_state, IOCTL_TPM_SAVE_STATE);
-
-__END_CDECLS;
diff --git a/system/uapp/tpmctl/rules.mk b/system/uapp/tpmctl/rules.mk
deleted file mode 100644
index 62eb805..0000000
--- a/system/uapp/tpmctl/rules.mk
+++ /dev/null
@@ -1,17 +0,0 @@
-# Copyright 2016 The Fuchsia Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-LOCAL_DIR := $(GET_LOCAL_DIR)
-
-MODULE := $(LOCAL_DIR)
-
-MODULE_TYPE := userapp
-MODULE_GROUP := misc
-
-MODULE_SRCS += \
-	$(LOCAL_DIR)/tpmctl.c
-
-MODULE_LIBS := system/ulib/zircon system/ulib/fdio system/ulib/c
-
-include make/module.mk
diff --git a/system/uapp/tpmctl/tpmctl.c b/system/uapp/tpmctl/tpmctl.c
deleted file mode 100644
index 2c136c8..0000000
--- a/system/uapp/tpmctl/tpmctl.c
+++ /dev/null
@@ -1,68 +0,0 @@
-// Copyright 2016 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <zircon/device/tpm.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <zircon/syscalls.h>
-#include <zircon/types.h>
-#include <lib/fdio/util.h>
-#include <stddef.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-const char* prog_name;
-
-void print_usage(void) {
-    printf("Usage:\n");
-    printf("\n");
-    printf("%s save\n", prog_name);
-    printf("save: Issue a TPM_SaveState command.\n");
-}
-
-int cmd_save_state(int fd, int argc, const char** argv) {
-    ssize_t ret = ioctl_tpm_save_state(fd);
-    if (ret < 0) {
-        printf("Error when saving state: (%zd)\n", ret);
-        return 1;
-    }
-
-    return 0;
-}
-
-int main(int argc, const char** argv) {
-    if (argc < 1)
-        return 1;
-
-    prog_name = argv[0];
-
-    if (argc < 2) {
-        print_usage();
-        return 1;
-    }
-
-    const char* cmd = argv[1];
-
-    argc -= 2;
-    argv += 2;
-
-    int fd = open("/dev/class/tpm/000", O_RDWR);
-    if (fd < 0) {
-        printf("Error opening TPM device.\n");
-        return 1;
-    }
-
-    if (!strcmp("save", cmd)) {
-        return cmd_save_state(fd, argc, argv);
-    } else {
-        printf("Unrecognized command %s.\n", cmd);
-        print_usage();
-        return 1;
-    }
-
-    printf("We should never get here!.\n");
-    return 1;
-}