From 94d1f1a772c6655398e9773c0851330ead4ff49c Mon Sep 17 00:00:00 2001 From: Vegard Storheil Eriksen Date: Thu, 21 Jan 2021 21:52:07 +0100 Subject: usb/dwc_otg: Use mmio_ptr. --- usb/dwc_otg_def.h | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'usb/dwc_otg_def.h') diff --git a/usb/dwc_otg_def.h b/usb/dwc_otg_def.h index 6ed6ba8..2c22af4 100644 --- a/usb/dwc_otg_def.h +++ b/usb/dwc_otg_def.h @@ -1,10 +1,8 @@ #ifndef DWC_OTG_DEF_H #define DWC_OTG_DEF_H -#include +#include -class DWC_OTG_t { - private: struct DWC_OTG_reg_t { volatile uint32_t GOTGCTL; volatile uint32_t GOTGINT; @@ -67,19 +65,19 @@ class DWC_OTG_t { volatile uint32_t buf[1024]; }; +class DWC_OTG_t : public mmio_ptr { public: - DWC_OTG_reg_t& reg; - DWC_OTG_dev_reg_t& dev_reg; - DWC_OTG_dev_iep_reg_t* const dev_iep_reg; - DWC_OTG_dev_oep_reg_t* const dev_oep_reg; - DWC_OTG_fifo_reg_t* const fifo; + mmio_ptr dev_reg; + mmio_ptr dev_iep_reg; + mmio_ptr dev_oep_reg; + mmio_ptr fifo; - DWC_OTG_t(uint32_t reg_addr) : - reg(*(DWC_OTG_reg_t*)reg_addr), - dev_reg(*(DWC_OTG_dev_reg_t*)(reg_addr + 0x800)), - dev_iep_reg((DWC_OTG_dev_iep_reg_t*)(reg_addr + 0x900)), - dev_oep_reg((DWC_OTG_dev_oep_reg_t*)(reg_addr + 0xb00)), - fifo((DWC_OTG_fifo_reg_t*)(reg_addr + 0x1000)) {} + constexpr DWC_OTG_t(uint32_t reg_addr) : + mmio_ptr(reg_addr), + dev_reg(reg_addr + 0x800), + dev_iep_reg(reg_addr + 0x900), + dev_oep_reg(reg_addr + 0xb00), + fifo(reg_addr + 0x1000) {} }; #endif -- cgit v1.2.3