1 // Copyright 2018 The Fuchsia Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #pragma once
6 
7 #include <ddk/device.h>
8 
9 #include <ddktl/device.h>
10 #include <ddktl/protocol/platform/bus.h>
11 
12 #include <fbl/macros.h>
13 
14 #include <threads.h>
15 
16 namespace board_mt8167 {
17 
18 // BTI IDs for our devices
19 enum {
20     BTI_BOARD,
21     BTI_DISPLAY,
22     BTI_EMMC,
23     BTI_SDIO,
24     BTI_USB,
25 };
26 
27 class Mt8167;
28 using Mt8167Type = ddk::Device<Mt8167>;
29 
30 // This is the main class for the platform bus driver.
31 class Mt8167 : public Mt8167Type {
32 public:
Mt8167(zx_device_t * parent,pbus_protocol_t * pbus,pdev_board_info_t * board_info)33     explicit Mt8167(zx_device_t* parent, pbus_protocol_t* pbus, pdev_board_info_t* board_info)
34         : Mt8167Type(parent), pbus_(pbus), board_info_(*board_info) {}
35 
36     static zx_status_t Create(zx_device_t* parent);
37 
38     // Device protocol implementation.
39     void DdkRelease();
40 
41 private:
42     DISALLOW_COPY_ASSIGN_AND_MOVE(Mt8167);
43 
44     zx_status_t Start();
45     zx_status_t EmmcInit();
46     zx_status_t SdioInit();
47     zx_status_t SocInit();
48     zx_status_t GpioInit();
49     zx_status_t GpuInit();
50     zx_status_t DisplayInit();
51     zx_status_t I2cInit();
52     zx_status_t ButtonsInit();
53     zx_status_t ClkInit();
54     zx_status_t UsbInit();
55     zx_status_t ThermalInit();
56     zx_status_t TouchInit();
57     int Thread();
58 
59     ddk::PBusProtocolClient pbus_;
60     pdev_board_info_t board_info_;
61     thrd_t thread_;
62 };
63 
64 } // namespace board_mt8167
65 
66 __BEGIN_CDECLS
67 zx_status_t mt8167_bind(void* ctx, zx_device_t* parent);
68 __END_CDECLS
69