[as370][board] Add board driver for AS370

Test: 'dm dump' shows board driver
Change-Id: I5143ef17ac06a4131b3ce772a123bfb49cf22e59
diff --git a/zircon/system/dev/board/BUILD.gn b/zircon/system/dev/board/BUILD.gn
index db738be..b201f7b3 100644
--- a/zircon/system/dev/board/BUILD.gn
+++ b/zircon/system/dev/board/BUILD.gn
@@ -12,6 +12,7 @@
   ]
   if (current_cpu == "arm64") {
     deps += [
+      "as370",
       "astro",
       "gauss",
       "hikey960",
diff --git a/zircon/system/dev/board/as370/BUILD.gn b/zircon/system/dev/board/as370/BUILD.gn
new file mode 100644
index 0000000..e2f5f9c
--- /dev/null
+++ b/zircon/system/dev/board/as370/BUILD.gn
@@ -0,0 +1,19 @@
+# Copyright 2019 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.
+
+driver("as370") {
+  sources = [
+    "as370.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+  data_deps = [
+    "$zx/kernel/target/arm64/boot-shim:as370",
+  ]
+}
diff --git a/zircon/system/dev/board/as370/as370.cpp b/zircon/system/dev/board/as370/as370.cpp
new file mode 100644
index 0000000..63f8519
--- /dev/null
+++ b/zircon/system/dev/board/as370/as370.cpp
@@ -0,0 +1,45 @@
+// Copyright 2019 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 "as370.h"
+
+#include <ddk/binding.h>
+#include <ddk/debug.h>
+#include <ddk/platform-defs.h>
+#include <fbl/alloc_checker.h>
+#include <fbl/unique_ptr.h>
+
+namespace board_as370 {
+
+zx_status_t As370::Create(void* ctx, zx_device_t* parent) {
+    fbl::AllocChecker ac;
+    auto board = fbl::make_unique_checked<As370>(&ac, parent);
+    if (!ac.check()) {
+        return ZX_ERR_NO_MEMORY;
+    }
+
+    zx_status_t status = board->DdkAdd("as370", DEVICE_ADD_NON_BINDABLE);
+    if (status != ZX_OK) {
+        return status;
+    }
+
+    __UNUSED auto* dummy = board.release();
+
+    return ZX_OK;
+}
+
+}  // namespace board_as370
+
+static zx_driver_ops_t driver_ops = []() {
+    zx_driver_ops_t ops;
+    ops.version = DRIVER_OPS_VERSION;
+    ops.bind = board_as370::As370::Create;
+    return ops;
+}();
+
+ZIRCON_DRIVER_BEGIN(as370, driver_ops, "zircon", "0.1", 3)
+    BI_ABORT_IF(NE, BIND_PROTOCOL, ZX_PROTOCOL_PBUS),
+    BI_ABORT_IF(NE, BIND_PLATFORM_DEV_VID, PDEV_VID_SYNAPTICS),
+    BI_MATCH_IF(EQ, BIND_PLATFORM_DEV_PID, PDEV_PID_SYNAPTICS_AS370),
+ZIRCON_DRIVER_END(as370)
diff --git a/zircon/system/dev/board/as370/as370.h b/zircon/system/dev/board/as370/as370.h
new file mode 100644
index 0000000..5b36818
--- /dev/null
+++ b/zircon/system/dev/board/as370/as370.h
@@ -0,0 +1,20 @@
+// Copyright 2019 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 <ddktl/device.h>
+
+namespace board_as370 {
+
+class As370 : public ddk::Device<As370> {
+public:
+    As370(zx_device_t* parent) : ddk::Device<As370>(parent) {}
+
+    static zx_status_t Create(void* ctx, zx_device_t* parent);
+
+    void DdkRelease() { delete this; }
+};
+
+}  // namespace board_as370