/* 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 _GNSS_SPI_H_
#define _GNSS_SPI_H_

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

#define REG_GNSS_SPI_SET_OFFSET (0x1000)
#define REG_GNSS_SPI_CLR_OFFSET (0x2000)

#define REG_GNSS_SPI_BASE (0x1c040000)

typedef volatile struct
{
    uint32_t spi_cfg;         // 0x00000000
    uint32_t spi_rxdata;      // 0x00000004
    uint32_t spi_immdata;     // 0x00000008
    uint32_t __12[1];         // 0x0000000c
    uint32_t spi_status;      // 0x00000010
    uint32_t __20[1019];      // 0x00000014
    uint32_t spi_cfg_set;     // 0x00001000
    uint32_t __4100[1];       // 0x00001004
    uint32_t spi_immdata_set; // 0x00001008
    uint32_t __4108[1021];    // 0x0000100c
    uint32_t spi_cfg_clr;     // 0x00002000
    uint32_t __8196[1];       // 0x00002004
    uint32_t spi_immdata_clr; // 0x00002008
} HWP_GNSS_SPI_T;

#define hwp_gnssSpi ((HWP_GNSS_SPI_T *)REG_ACCESS_ADDRESS(REG_GNSS_SPI_BASE))

// spi_cfg
typedef union {
    uint32_t v;
    struct
    {
        uint32_t tx_data_len : 5; // [4:0]
        uint32_t rx_data_len : 5; // [9:5]
        uint32_t spol : 1;        // [10]
        uint32_t cpol : 1;        // [11]
        uint32_t cpha : 1;        // [12]
        uint32_t sec : 1;         // [13]
        uint32_t rd_edge : 1;     // [14]
        uint32_t rd_inter : 2;    // [16:15]
        uint32_t ms : 1;          // [17]
        uint32_t dux : 1;         // [18]
        uint32_t cs_inv : 1;      // [19]
        uint32_t frq_div_wr : 3;  // [22:20]
        uint32_t frq_div_rd : 3;  // [25:23]
        uint32_t distance : 4;    // [29:26]
        uint32_t spi_rw : 1;      // [30]
        uint32_t __31_31 : 1;     // [31]
    } b;
} REG_GNSS_SPI_SPI_CFG_T;

// spi_status
typedef union {
    uint32_t v;
    struct
    {
        uint32_t spi_status : 1; // [0], read only
        uint32_t __31_1 : 31;    // [31:1]
    } b;
} REG_GNSS_SPI_SPI_STATUS_T;

// spi_cfg
#define GNSS_SPI_TX_DATA_LEN(n) (((n)&0x1f) << 0)
#define GNSS_SPI_RX_DATA_LEN(n) (((n)&0x1f) << 5)
#define GNSS_SPI_SPOL (1 << 10)
#define GNSS_SPI_CPOL (1 << 11)
#define GNSS_SPI_CPHA (1 << 12)
#define GNSS_SPI_SEC (1 << 13)
#define GNSS_SPI_RD_EDGE (1 << 14)
#define GNSS_SPI_RD_INTER(n) (((n)&0x3) << 15)
#define GNSS_SPI_MS (1 << 17)
#define GNSS_SPI_DUX (1 << 18)
#define GNSS_SPI_CS_INV (1 << 19)
#define GNSS_SPI_FRQ_DIV_WR(n) (((n)&0x7) << 20)
#define GNSS_SPI_FRQ_DIV_RD(n) (((n)&0x7) << 23)
#define GNSS_SPI_DISTANCE(n) (((n)&0xf) << 26)
#define GNSS_SPI_SPI_RW (1 << 30)

// spi_status
#define GNSS_SPI_SPI_STATUS (1 << 0)

#endif // _GNSS_SPI_H_
