aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLee Jones <lee.jones@linaro.org>2014-03-20 05:20:34 -0400
committerBrian Norris <computersforpeace@gmail.com>2014-03-20 07:17:14 -0400
commitbc09fb5756b90df65b1776cf38d67bbb306b72fd (patch)
tree15991a714a09233fdbae698993b2d2f34e62f54b
parentd90db4a074292ec07d09e54c70d62b3ab6f21591 (diff)
mtd: st_spi_fsm: Supply all register address and bit logic defines
Here we provide the FSM's register addresses, register bit names/offsets and some commands which will prove useful as we start bulk the FMS's driver out with functionality. Acked-by Angus Clark <angus.clark@st.com> Signed-off-by: Lee Jones <lee.jones@linaro.org> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
-rw-r--r--drivers/mtd/devices/st_spi_fsm.c164
1 files changed, 164 insertions, 0 deletions
diff --git a/drivers/mtd/devices/st_spi_fsm.c b/drivers/mtd/devices/st_spi_fsm.c
index b1e67406d367..000bc25edd19 100644
--- a/drivers/mtd/devices/st_spi_fsm.c
+++ b/drivers/mtd/devices/st_spi_fsm.c
@@ -21,6 +21,170 @@
21#include <linux/io.h> 21#include <linux/io.h>
22#include <linux/of.h> 22#include <linux/of.h>
23 23
24/*
25 * FSM SPI Controller Registers
26 */
27#define SPI_CLOCKDIV 0x0010
28#define SPI_MODESELECT 0x0018
29#define SPI_CONFIGDATA 0x0020
30#define SPI_STA_MODE_CHANGE 0x0028
31#define SPI_FAST_SEQ_TRANSFER_SIZE 0x0100
32#define SPI_FAST_SEQ_ADD1 0x0104
33#define SPI_FAST_SEQ_ADD2 0x0108
34#define SPI_FAST_SEQ_ADD_CFG 0x010c
35#define SPI_FAST_SEQ_OPC1 0x0110
36#define SPI_FAST_SEQ_OPC2 0x0114
37#define SPI_FAST_SEQ_OPC3 0x0118
38#define SPI_FAST_SEQ_OPC4 0x011c
39#define SPI_FAST_SEQ_OPC5 0x0120
40#define SPI_MODE_BITS 0x0124
41#define SPI_DUMMY_BITS 0x0128
42#define SPI_FAST_SEQ_FLASH_STA_DATA 0x012c
43#define SPI_FAST_SEQ_1 0x0130
44#define SPI_FAST_SEQ_2 0x0134
45#define SPI_FAST_SEQ_3 0x0138
46#define SPI_FAST_SEQ_4 0x013c
47#define SPI_FAST_SEQ_CFG 0x0140
48#define SPI_FAST_SEQ_STA 0x0144
49#define SPI_QUAD_BOOT_SEQ_INIT_1 0x0148
50#define SPI_QUAD_BOOT_SEQ_INIT_2 0x014c
51#define SPI_QUAD_BOOT_READ_SEQ_1 0x0150
52#define SPI_QUAD_BOOT_READ_SEQ_2 0x0154
53#define SPI_PROGRAM_ERASE_TIME 0x0158
54#define SPI_MULT_PAGE_REPEAT_SEQ_1 0x015c
55#define SPI_MULT_PAGE_REPEAT_SEQ_2 0x0160
56#define SPI_STATUS_WR_TIME_REG 0x0164
57#define SPI_FAST_SEQ_DATA_REG 0x0300
58
59/*
60 * Register: SPI_MODESELECT
61 */
62#define SPI_MODESELECT_CONTIG 0x01
63#define SPI_MODESELECT_FASTREAD 0x02
64#define SPI_MODESELECT_DUALIO 0x04
65#define SPI_MODESELECT_FSM 0x08
66#define SPI_MODESELECT_QUADBOOT 0x10
67
68/*
69 * Register: SPI_CONFIGDATA
70 */
71#define SPI_CFG_DEVICE_ST 0x1
72#define SPI_CFG_DEVICE_ATMEL 0x4
73#define SPI_CFG_MIN_CS_HIGH(x) (((x) & 0xfff) << 4)
74#define SPI_CFG_CS_SETUPHOLD(x) (((x) & 0xff) << 16)
75#define SPI_CFG_DATA_HOLD(x) (((x) & 0xff) << 24)
76
77/*
78 * Register: SPI_FAST_SEQ_TRANSFER_SIZE
79 */
80#define TRANSFER_SIZE(x) ((x) * 8)
81
82/*
83 * Register: SPI_FAST_SEQ_ADD_CFG
84 */
85#define ADR_CFG_CYCLES_ADD1(x) ((x) << 0)
86#define ADR_CFG_PADS_1_ADD1 (0x0 << 6)
87#define ADR_CFG_PADS_2_ADD1 (0x1 << 6)
88#define ADR_CFG_PADS_4_ADD1 (0x3 << 6)
89#define ADR_CFG_CSDEASSERT_ADD1 (1 << 8)
90#define ADR_CFG_CYCLES_ADD2(x) ((x) << (0+16))
91#define ADR_CFG_PADS_1_ADD2 (0x0 << (6+16))
92#define ADR_CFG_PADS_2_ADD2 (0x1 << (6+16))
93#define ADR_CFG_PADS_4_ADD2 (0x3 << (6+16))
94#define ADR_CFG_CSDEASSERT_ADD2 (1 << (8+16))
95
96/*
97 * Register: SPI_FAST_SEQ_n
98 */
99#define SEQ_OPC_OPCODE(x) ((x) << 0)
100#define SEQ_OPC_CYCLES(x) ((x) << 8)
101#define SEQ_OPC_PADS_1 (0x0 << 14)
102#define SEQ_OPC_PADS_2 (0x1 << 14)
103#define SEQ_OPC_PADS_4 (0x3 << 14)
104#define SEQ_OPC_CSDEASSERT (1 << 16)
105
106/*
107 * Register: SPI_FAST_SEQ_CFG
108 */
109#define SEQ_CFG_STARTSEQ (1 << 0)
110#define SEQ_CFG_SWRESET (1 << 5)
111#define SEQ_CFG_CSDEASSERT (1 << 6)
112#define SEQ_CFG_READNOTWRITE (1 << 7)
113#define SEQ_CFG_ERASE (1 << 8)
114#define SEQ_CFG_PADS_1 (0x0 << 16)
115#define SEQ_CFG_PADS_2 (0x1 << 16)
116#define SEQ_CFG_PADS_4 (0x3 << 16)
117
118/*
119 * Register: SPI_MODE_BITS
120 */
121#define MODE_DATA(x) (x & 0xff)
122#define MODE_CYCLES(x) ((x & 0x3f) << 16)
123#define MODE_PADS_1 (0x0 << 22)
124#define MODE_PADS_2 (0x1 << 22)
125#define MODE_PADS_4 (0x3 << 22)
126#define DUMMY_CSDEASSERT (1 << 24)
127
128/*
129 * Register: SPI_DUMMY_BITS
130 */
131#define DUMMY_CYCLES(x) ((x & 0x3f) << 16)
132#define DUMMY_PADS_1 (0x0 << 22)
133#define DUMMY_PADS_2 (0x1 << 22)
134#define DUMMY_PADS_4 (0x3 << 22)
135#define DUMMY_CSDEASSERT (1 << 24)
136
137/*
138 * Register: SPI_FAST_SEQ_FLASH_STA_DATA
139 */
140#define STA_DATA_BYTE1(x) ((x & 0xff) << 0)
141#define STA_DATA_BYTE2(x) ((x & 0xff) << 8)
142#define STA_PADS_1 (0x0 << 16)
143#define STA_PADS_2 (0x1 << 16)
144#define STA_PADS_4 (0x3 << 16)
145#define STA_CSDEASSERT (0x1 << 20)
146#define STA_RDNOTWR (0x1 << 21)
147
148/*
149 * FSM SPI Instruction Opcodes
150 */
151#define STFSM_OPC_CMD 0x1
152#define STFSM_OPC_ADD 0x2
153#define STFSM_OPC_STA 0x3
154#define STFSM_OPC_MODE 0x4
155#define STFSM_OPC_DUMMY 0x5
156#define STFSM_OPC_DATA 0x6
157#define STFSM_OPC_WAIT 0x7
158#define STFSM_OPC_JUMP 0x8
159#define STFSM_OPC_GOTO 0x9
160#define STFSM_OPC_STOP 0xF
161
162/*
163 * FSM SPI Instructions (== opcode + operand).
164 */
165#define STFSM_INSTR(cmd, op) ((cmd) | ((op) << 4))
166
167#define STFSM_INST_CMD1 STFSM_INSTR(STFSM_OPC_CMD, 1)
168#define STFSM_INST_CMD2 STFSM_INSTR(STFSM_OPC_CMD, 2)
169#define STFSM_INST_CMD3 STFSM_INSTR(STFSM_OPC_CMD, 3)
170#define STFSM_INST_CMD4 STFSM_INSTR(STFSM_OPC_CMD, 4)
171#define STFSM_INST_CMD5 STFSM_INSTR(STFSM_OPC_CMD, 5)
172#define STFSM_INST_ADD1 STFSM_INSTR(STFSM_OPC_ADD, 1)
173#define STFSM_INST_ADD2 STFSM_INSTR(STFSM_OPC_ADD, 2)
174
175#define STFSM_INST_DATA_WRITE STFSM_INSTR(STFSM_OPC_DATA, 1)
176#define STFSM_INST_DATA_READ STFSM_INSTR(STFSM_OPC_DATA, 2)
177
178#define STFSM_INST_STA_RD1 STFSM_INSTR(STFSM_OPC_STA, 0x1)
179#define STFSM_INST_STA_WR1 STFSM_INSTR(STFSM_OPC_STA, 0x1)
180#define STFSM_INST_STA_RD2 STFSM_INSTR(STFSM_OPC_STA, 0x2)
181#define STFSM_INST_STA_WR1_2 STFSM_INSTR(STFSM_OPC_STA, 0x3)
182
183#define STFSM_INST_MODE STFSM_INSTR(STFSM_OPC_MODE, 0)
184#define STFSM_INST_DUMMY STFSM_INSTR(STFSM_OPC_DUMMY, 0)
185#define STFSM_INST_WAIT STFSM_INSTR(STFSM_OPC_WAIT, 0)
186#define STFSM_INST_STOP STFSM_INSTR(STFSM_OPC_STOP, 0)
187
24struct stfsm { 188struct stfsm {
25 struct device *dev; 189 struct device *dev;
26 void __iomem *base; 190 void __iomem *base;