/* Copyright (C) 2018 RDA Technologies Limited and/or its affiliates("RDA").
 * All rights reserved.
 *
 * This software is supplied "AS IS" without any warranties.
 * RDA assumes no responsibility or liability for the use of the software,
 * conveys no license or title under any patent, copyright, or mask work
 * right to the product. RDA reserves the right to make changes in the
 * software without notification.  RDA also make no representation or
 * warranty that such application will be suitable for the specified use
 * without further testing or modification.
 */

#ifndef _BUSMON_H_
#define _BUSMON_H_

// Auto generated by dtools(see dtools.txt for its version).
// Don't edit it manually!

#define REG_AP_BUSMON_BASE (0x04802000)
#define REG_CP_BUSMON_BASE (0x14004000)

typedef volatile struct
{
    uint32_t mon_ctrl;           // 0x00000000
    uint32_t mon_conf;           // 0x00000004
    uint32_t mon_time;           // 0x00000008
    uint32_t mon_cont;           // 0x0000000c
    uint32_t mon_int_en;         // 0x00000010
    uint32_t mon_int_flag;       // 0x00000014
    uint32_t mon_m0_start_addr0; // 0x00000018
    uint32_t mon_m0_end_addr0;   // 0x0000001c
    uint32_t mon_m0_addr_wid;    // 0x00000020
    uint32_t __36[2];            // 0x00000024
    uint32_t mon_lock_time;      // 0x0000002c
    uint32_t mon_rcommand0;      // 0x00000030
    uint32_t mon_rdata0;         // 0x00000034
    uint32_t mon_wcommand0;      // 0x00000038
    uint32_t mon_wdata0;         // 0x0000003c
    uint32_t mon_rcommand1;      // 0x00000040
    uint32_t mon_rdata1;         // 0x00000044
    uint32_t mon_wcommand1;      // 0x00000048
    uint32_t mon_wdata1;         // 0x0000004c
    uint32_t mon_rcommand2;      // 0x00000050
    uint32_t mon_rdata2;         // 0x00000054
    uint32_t mon_wcommand2;      // 0x00000058
    uint32_t mon_wdata2;         // 0x0000005c
    uint32_t mon_rcommand3;      // 0x00000060
    uint32_t mon_rdata3;         // 0x00000064
    uint32_t mon_wcommand3;      // 0x00000068
    uint32_t mon_wdata3;         // 0x0000006c
    uint32_t mon_rcommand4;      // 0x00000070
    uint32_t mon_rdata4;         // 0x00000074
    uint32_t mon_wcommand4;      // 0x00000078
    uint32_t mon_wdata4;         // 0x0000007c
    uint32_t mon_m0_start_addr1; // 0x00000080
    uint32_t mon_m0_end_addr1;   // 0x00000084
    uint32_t mon_m0_start_addr2; // 0x00000088
    uint32_t mon_m0_end_addr2;   // 0x0000008c
    uint32_t mon_m0_start_addr3; // 0x00000090
    uint32_t mon_m0_end_addr3;   // 0x00000094
    uint32_t mon_m0_addr;        // 0x00000098
} HWP_BUSMON_T;

#define hwp_apBusmon ((HWP_BUSMON_T *)REG_ACCESS_ADDRESS(REG_AP_BUSMON_BASE))
#define hwp_cpBusmon ((HWP_BUSMON_T *)REG_ACCESS_ADDRESS(REG_CP_BUSMON_BASE))

// mon_ctrl
typedef union {
    uint32_t v;
    struct
    {
        uint32_t busmon_ctrl : 1; // [0]
        uint32_t __31_1 : 31;     // [31:1]
    } b;
} REG_BUSMON_MON_CTRL_T;

// mon_conf
typedef union {
    uint32_t v;
    struct
    {
        uint32_t gint_en : 1;         // [0]
        uint32_t mon_lock_en : 1;     // [1]
        uint32_t mon_time_en : 1;     // [2]
        uint32_t mon_cont_en : 1;     // [3]
        uint32_t mon_num_en : 1;      // [4]
        uint32_t mon_in_addr_en : 1;  // [5]
        uint32_t wbusy_en : 1;        // [6]
        uint32_t rbusy_en : 1;        // [7]
        uint32_t busy_en : 1;         // [8]
        uint32_t mon_ext_addr_en : 1; // [9]
        uint32_t __31_10 : 22;        // [31:10]
    } b;
} REG_BUSMON_MON_CONF_T;

// mon_int_en
typedef union {
    uint32_t v;
    struct
    {
        uint32_t lock_int_en : 1;  // [0]
        uint32_t timer_int_en : 1; // [1]
        uint32_t num_int_en : 1;   // [2]
        uint32_t addr_int_en : 1;  // [3]
        uint32_t __31_4 : 28;      // [31:4]
    } b;
} REG_BUSMON_MON_INT_EN_T;

// mon_int_flag
typedef union {
    uint32_t v;
    struct
    {
        uint32_t m0_lcok_int : 1; // [0], write clear
        uint32_t m1_lcok_int : 1; // [1], write clear
        uint32_t m2_lcok_int : 1; // [2], write clear
        uint32_t m3_lcok_int : 1; // [3], write clear
        uint32_t m4_lcok_int : 1; // [4], write clear
        uint32_t timer_cint : 1;  // [5], write clear
        uint32_t m0_wnum_int : 1; // [6], write clear
        uint32_t m0_rnum_int : 1; // [7], write clear
        uint32_t m1_wnum_int : 1; // [8], write clear
        uint32_t m1_rnum_int : 1; // [9], write clear
        uint32_t m2_wnum_int : 1; // [10], write clear
        uint32_t m2_rnum_int : 1; // [11], write clear
        uint32_t m3_wnum_int : 1; // [12], write clear
        uint32_t m3_rnum_int : 1; // [13], write clear
        uint32_t m4_wnum_int : 1; // [14], write clear
        uint32_t m4_rnum_int : 1; // [15], write clear
        uint32_t addr_int : 1;    // [16], write clear
        uint32_t timer_int : 1;   // [17], write clear
        uint32_t __31_18 : 14;    // [31:18]
    } b;
} REG_BUSMON_MON_INT_FLAG_T;

// mon_m0_addr_wid
typedef union {
    uint32_t v;
    struct
    {
        uint32_t wa_id : 8;   // [7:0], read only
        uint32_t __31_8 : 24; // [31:8]
    } b;
} REG_BUSMON_MON_M0_ADDR_WID_T;

// mon_lock_time
typedef union {
    uint32_t v;
    struct
    {
        uint32_t lock_value : 16; // [15:0]
        uint32_t __31_16 : 16;    // [31:16]
    } b;
} REG_BUSMON_MON_LOCK_TIME_T;

// mon_ctrl
#define BUSMON_BUSMON_CTRL (1 << 0)

// mon_conf
#define BUSMON_GINT_EN (1 << 0)
#define BUSMON_MON_LOCK_EN (1 << 1)
#define BUSMON_MON_TIME_EN (1 << 2)
#define BUSMON_MON_CONT_EN (1 << 3)
#define BUSMON_MON_NUM_EN (1 << 4)
#define BUSMON_MON_IN_ADDR_EN (1 << 5)
#define BUSMON_WBUSY_EN (1 << 6)
#define BUSMON_RBUSY_EN (1 << 7)
#define BUSMON_BUSY_EN (1 << 8)
#define BUSMON_MON_EXT_ADDR_EN (1 << 9)

// mon_int_en
#define BUSMON_LOCK_INT_EN (1 << 0)
#define BUSMON_TIMER_INT_EN (1 << 1)
#define BUSMON_NUM_INT_EN (1 << 2)
#define BUSMON_ADDR_INT_EN (1 << 3)

// mon_int_flag
#define BUSMON_M0_LCOK_INT (1 << 0)
#define BUSMON_M1_LCOK_INT (1 << 1)
#define BUSMON_M2_LCOK_INT (1 << 2)
#define BUSMON_M3_LCOK_INT (1 << 3)
#define BUSMON_M4_LCOK_INT (1 << 4)
#define BUSMON_TIMER_CINT (1 << 5)
#define BUSMON_M0_WNUM_INT (1 << 6)
#define BUSMON_M0_RNUM_INT (1 << 7)
#define BUSMON_M1_WNUM_INT (1 << 8)
#define BUSMON_M1_RNUM_INT (1 << 9)
#define BUSMON_M2_WNUM_INT (1 << 10)
#define BUSMON_M2_RNUM_INT (1 << 11)
#define BUSMON_M3_WNUM_INT (1 << 12)
#define BUSMON_M3_RNUM_INT (1 << 13)
#define BUSMON_M4_WNUM_INT (1 << 14)
#define BUSMON_M4_RNUM_INT (1 << 15)
#define BUSMON_ADDR_INT (1 << 16)
#define BUSMON_TIMER_INT (1 << 17)

// mon_m0_addr_wid
#define BUSMON_WA_ID(n) (((n)&0xff) << 0)

// mon_lock_time
#define BUSMON_LOCK_VALUE(n) (((n)&0xffff) << 0)

#endif // _BUSMON_H_
