1 /*
2  * Copyright (c) 2006-2021, RT-Thread Development Team
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  *
6  * Change Logs:
7  * Date           Author                   Notes
8  * 2020-10-28     0xcccccccccccc           Initial Version
9  */
10 /**
11  * @addtogroup ls2k
12  */
13 /*@{*/
14 #ifndef LS2K_DRV_SPI_H
15 #define LS2K_DRV_SPI_H
16 
17 // kseg1 byte operation
18 #define KSEG1_STORE8(addr,val)   *(volatile char *)(0xffffffffa0000000 | addr) = val
19 #define KSEG1_LOAD8(addr)    *(volatile char *)(0xffffffffa0000000 | addr)
20 // clock configurations
21 #define APB_MAX_SPEED 125000000U
22 #define APB_FREQSCALE (((KSEG1_LOAD8(0xffffffffbfe104d2)>>4)&0x7)+1)
23 // base addrs
24 #define SPI_BASE  0x1fff0220
25 #define PMON_ADDR 0xa1000000
26 #define FLASH_ADDR 0x000000
27 // bit bias
28 #define SPCR      0x0
29 #define SPSR      0x1
30 #define FIFO      0x2
31 #define TXFIFO    0x2
32 #define RXFIFO    0x2
33 #define SPER      0x3
34 #define PARAM     0x4
35 #define SOFTCS    0x5
36 #define PARAM2    0x6
37 #define RFEMPTY 1
38 // SPI controller operaion macros
39 #define SET_SPI(addr,val)        KSEG1_STORE8(SPI_BASE+addr,val)
40 #define GET_SPI(addr)            KSEG1_LOAD8(SPI_BASE+addr)
41 
42 #endif
43 /*@}*/
44