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 #include <ddktl/device.h> 9 #include <ddktl/protocol/gpio.h> 10 #include <ddktl/protocol/usb/modeswitch.h> 11 #include <fbl/macros.h> 12 13 namespace hikey_usb { 14 15 class HikeyUsb; 16 using HikeyUsbType = ddk::Device<HikeyUsb>; 17 18 // This is the main class for the platform bus driver. 19 class HikeyUsb : public HikeyUsbType, 20 public ddk::UsbModeSwitchProtocol<HikeyUsb, ddk::base_protocol> { 21 public: HikeyUsb(zx_device_t * parent)22 explicit HikeyUsb(zx_device_t* parent) 23 : HikeyUsbType(parent), usb_mode_(USB_MODE_NONE) {} 24 25 static zx_status_t Create(zx_device_t* parent); 26 27 // Device protocol implementation. 28 void DdkRelease(); 29 30 // USB mode switch protocol implementation. 31 zx_status_t UsbModeSwitchSetMode(usb_mode_t mode); 32 33 private: 34 DISALLOW_COPY_ASSIGN_AND_MOVE(HikeyUsb); 35 36 enum { 37 HUB_VDD33_EN, 38 VBUS_TYPEC, 39 USBSW_SW_SEL, 40 GPIO_COUNT, 41 }; 42 43 zx_status_t Init(); 44 45 gpio_protocol_t gpios_[GPIO_COUNT]; 46 usb_mode_t usb_mode_; 47 }; 48 49 } // namespace hikey_usb 50