RTEMS
6.1-rc1
bsps
include
grlib
spictrl.h
1
/* SPDX-License-Identifier: BSD-2-Clause */
2
3
/*
4
* SPICTRL SPI Driver interface.
5
*
6
* COPYRIGHT (c) 2009.
7
* Cobham Gaisler AB.
8
*
9
* Redistribution and use in source and binary forms, with or without
10
* modification, are permitted provided that the following conditions
11
* are met:
12
* 1. Redistributions of source code must retain the above copyright
13
* notice, this list of conditions and the following disclaimer.
14
* 2. Redistributions in binary form must reproduce the above copyright
15
* notice, this list of conditions and the following disclaimer in the
16
* documentation and/or other materials provided with the distribution.
17
*
18
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28
* POSSIBILITY OF SUCH DAMAGE.
29
*/
30
31
#ifndef __SPICTRL_H__
32
#define __SPICTRL_H__
33
34
#ifdef __cplusplus
35
extern
"C"
{
36
#endif
37
38
extern
void
spictrl_register_drv (
void
);
39
40
/*** REGISTER LAYOUT ***/
41
struct
spictrl_regs
{
42
volatile
unsigned
int
capability;
/* 0x00 */
43
volatile
unsigned
int
resv[7];
/* 0x04 */
44
volatile
unsigned
int
mode;
/* 0x20 */
45
volatile
unsigned
int
event;
/* 0x24 */
46
volatile
unsigned
int
mask;
/* 0x28 */
47
volatile
unsigned
int
command;
/* 0x2c */
48
volatile
unsigned
int
tx;
/* 0x30 */
49
volatile
unsigned
int
rx;
/* 0x34 */
50
volatile
unsigned
int
slvsel;
/* 0x38 */
51
volatile
unsigned
int
am_slvsel;
/* 0x3c */
52
volatile
unsigned
int
am_cfg;
/* 0x40 */
53
volatile
unsigned
int
am_period;
/* 0x44 */
54
int
reserved0[2];
55
volatile
unsigned
int
am_mask[4];
/* 0x50-0x5C */
56
int
reserved1[(0x200-0x60)/4];
57
volatile
unsigned
int
am_tx[128];
/* 0x200-0x3FC */
58
volatile
unsigned
int
am_rx[128];
/* 0x400-0x5FC */
59
};
60
61
/* -- About automated periodic transfer mode --
62
*
63
* Core must support this feature.
64
*
65
* The SPI core must be configured in periodic mode before
66
* writing the data into the transfer FIFO which will be used
67
* mutiple times in different transfers, it will also make
68
* the receive FIFO to be updated.
69
*
70
* In periodic mode the following sequence is performed,
71
* 1. start()
72
* 2. ioctl(CONFIG, &config) - Enable periodic mode
73
* 3. set_address()
74
* 4. write() - Fills TX FIFO, this has some constraints
75
* 5. ioctl(START) - Starts the periodic transmission of the TX FIFO
76
* 6. read() - Read one response of the tranistted data. It will
77
* hang until data is available. If hanging is not an
78
* options use ioctl(STATUS)
79
* 7. go back to 6.
80
*
81
* 8. ioctl(STOP) - Stop to set up a new periodic or normal transfer
82
* 9. stop()
83
*
84
* Note that the the read length must equal the total write length.
85
*/
86
87
/* Custom SPICTRL driver ioctl commands */
88
#define SPICTRL_IOCTL_PERIOD_START 5000
/* Start automated periodic transfer mode */
89
#define SPICTRL_IOCTL_PERIOD_STOP 5001
/* Stop to SPI core from doing periodic transfers */
90
#define SPICTRL_IOCTL_CONFIG 5002
/* Configure Periodic transfer mode (before calling write() and START) */
91
#define SPICTRL_IOCTL_STATUS 5003
/* Get status */
92
93
#define SPICTRL_IOCTL_PERIOD_READ 5005
/* Write transmit registers and mask register
94
* (only in automatic periodic mode)
95
* Note that it is probably prefferred to read
96
* the received words using the read() using
97
* operations instead.
98
*/
99
#define SPICTRL_IOCTL_PERIOD_WRITE 5006
/* Read receive registers and mask register
100
* (only in automatic periodic mode) */
101
#define SPICTRL_IOCTL_REGS 5007
/* Get SPICTRL Register */
102
103
/* SPICTRL_IOCTL_CONFIG argument */
104
struct
spictrl_ioctl_config
{
105
int
clock_gap;
/* Clock GAP between */
106
unsigned
int
flags;
/* Normal mode flags */
107
int
periodic_mode;
/* 1=Enables Automated periodic transfers if supported by hardware */
108
unsigned
int
period;
/* Number of clocks between automated transfers are started */
109
unsigned
int
period_flags;
/* Options */
110
unsigned
int
period_slvsel;
/* Slave Select when transfer is not active, default is 0xffffffff */
111
};
112
#define SPICTRL_FLAGS_TAC 0x10
113
114
#define SPICTRL_PERIOD_FLAGS_ERPT 0x80
/* Trigger start-period from external signal */
115
#define SPICTRL_PERIOD_FLAGS_SEQ 0x40
116
#define SPICTRL_PERIOD_FLAGS_STRICT 0x20
117
#define SPICTRL_PERIOD_FLAGS_OVTB 0x10
118
#define SPICTRL_PERIOD_FLAGS_OVDB 0x08
119
#define SPICTRL_PERIOD_FLAGS_ASEL 0x04
120
#define SPICTRL_PERIOD_FLAGS_EACT 0x01
121
122
/* SPICTRL_IOCTL_PERIOD_READ and SPICTRL_IOCTL_PERIOD_WRITE Argument data structure
123
*
124
* Note that the order of reading the mask registers are different for read/write
125
* operation. See options notes.
126
*/
127
struct
spictrl_period_io
{
128
int
options;
/* READ: bit0=Read Mask Registers into masks[].
129
* bit1=Read Receive registers according to masks[]
130
* (after reading masks).
131
*
132
* WRITE: bit0=Update Mask accoring to masks[].
133
* bit1=Update Transmit registers according to masks[].
134
* (before reading masks)
135
*/
136
unsigned
int
masks[4];
137
138
void
*data;
/* Data read sequentially according to masks[] bit. */
139
};
140
141
#ifdef __cplusplus
142
}
143
#endif
144
145
#endif
spictrl_ioctl_config
Definition:
spictrl.h:98
spictrl_period_io
Definition:
spictrl.h:121
spictrl_regs
Definition:
spictrl.h:41
Generated by
1.9.4