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/protocol/platform/device.h> 8 #include <ddktl/device.h> 9 #include <fbl/unique_ptr.h> 10 #include <hwreg/mmio.h> 11 #include <optional> 12 #include <unistd.h> 13 #include <zircon/compiler.h> 14 15 #include "common.h" 16 #include "hhi-regs.h" 17 #include "vpu-regs.h" 18 #include "lcd.h" 19 #include "aml-mipi-phy.h" 20 21 namespace astro_display { 22 23 class AmlDsiHost { 24 public: AmlDsiHost(zx_device_t * parent,uint32_t bitrate,uint8_t panel_type)25 AmlDsiHost(zx_device_t* parent, uint32_t bitrate, uint8_t panel_type) 26 : parent_(parent), bitrate_(bitrate), panel_type_(panel_type) {} 27 28 // This function sets up mipi dsi interface. It includes both DWC and AmLogic blocks 29 // The DesignWare setup could technically be moved to the dw_mipi_dsi driver. However, 30 // given the highly configurable nature of this block, we'd have to provide a lot of 31 // information to the generic driver. Therefore, it's just simpler to configure it here 32 zx_status_t Init(); 33 zx_status_t HostOn(const DisplaySetting& disp_setting); 34 // This function will turn off DSI Host. It is a "best-effort" function. We will attempt 35 // to shutdown whatever we can. Error during shutdown path is ignored and function proceeds 36 // with shutting down. 37 void HostOff(const DisplaySetting& disp_setting); 38 void Dump(); 39 private: 40 void PhyEnable(); 41 void PhyDisable(); 42 zx_status_t HostModeInit(uint32_t opp, const DisplaySetting& disp_setting); 43 44 std::optional<ddk::MmioBuffer> mipi_dsi_mmio_; 45 std::optional<ddk::MmioBuffer> hhi_mmio_; 46 47 pdev_protocol_t pdev_ = {}; 48 49 zx_device_t* parent_; 50 51 uint32_t bitrate_; 52 uint8_t panel_type_; 53 54 bool initialized_ = false; 55 bool host_on_ = false; 56 57 fbl::unique_ptr<Lcd> lcd_; 58 fbl::unique_ptr<AmlMipiPhy> phy_; 59 60 }; 61 62 } // namespace astro_display 63