Skip to content

Commit c0aa051

Browse files
Kuwano-sanambarus
authored andcommitted
mtd: spi-nor: spansion: prepare octal dtr methods for multi chip support
Infineon's multi-chip package (MCP) devices require the octal DTR configuration to be set for each die. Split common code in dedicated methods to ease the octal DDR MCP support addition. Signed-off-by: Takahiro Kuwano <Takahiro.Kuwano@infineon.com> Link: https://lore.kernel.org/r/20230726075257.12985-4-tudor.ambarus@linaro.org Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
1 parent 1e611e1 commit c0aa051

File tree

1 file changed

+37
-13
lines changed

1 file changed

+37
-13
lines changed

drivers/mtd/spi-nor/spansion.c

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -156,16 +156,15 @@ static int cypress_nor_sr_ready_and_clear(struct spi_nor *nor)
156156
return 1;
157157
}
158158

159-
static int cypress_nor_octal_dtr_en(struct spi_nor *nor)
159+
static int cypress_nor_set_memlat(struct spi_nor *nor, u64 addr)
160160
{
161161
struct spi_mem_op op;
162162
u8 *buf = nor->bouncebuf;
163163
int ret;
164164
u8 addr_mode_nbytes = nor->params->addr_mode_nbytes;
165165

166166
op = (struct spi_mem_op)
167-
CYPRESS_NOR_RD_ANY_REG_OP(addr_mode_nbytes,
168-
SPINOR_REG_CYPRESS_CFR2V, 0, buf);
167+
CYPRESS_NOR_RD_ANY_REG_OP(addr_mode_nbytes, addr, 0, buf);
169168

170169
ret = spi_nor_read_any_reg(nor, &op, nor->reg_proto);
171170
if (ret)
@@ -176,22 +175,41 @@ static int cypress_nor_octal_dtr_en(struct spi_nor *nor)
176175
*buf |= FIELD_PREP(SPINOR_REG_CYPRESS_CFR2_MEMLAT_MASK,
177176
SPINOR_REG_CYPRESS_CFR2_MEMLAT_11_24);
178177
op = (struct spi_mem_op)
179-
CYPRESS_NOR_WR_ANY_REG_OP(addr_mode_nbytes,
180-
SPINOR_REG_CYPRESS_CFR2V, 1, buf);
178+
CYPRESS_NOR_WR_ANY_REG_OP(addr_mode_nbytes, addr, 1, buf);
181179

182180
ret = spi_nor_write_any_volatile_reg(nor, &op, nor->reg_proto);
183181
if (ret)
184182
return ret;
185183

186184
nor->read_dummy = 24;
187185

186+
return 0;
187+
}
188+
189+
static int cypress_nor_set_octal_dtr_bits(struct spi_nor *nor, u64 addr)
190+
{
191+
struct spi_mem_op op;
192+
u8 *buf = nor->bouncebuf;
193+
188194
/* Set the octal and DTR enable bits. */
189195
buf[0] = SPINOR_REG_CYPRESS_CFR5_OCT_DTR_EN;
190196
op = (struct spi_mem_op)
191-
CYPRESS_NOR_WR_ANY_REG_OP(addr_mode_nbytes,
192-
SPINOR_REG_CYPRESS_CFR5V, 1, buf);
197+
CYPRESS_NOR_WR_ANY_REG_OP(nor->params->addr_mode_nbytes,
198+
addr, 1, buf);
193199

194-
ret = spi_nor_write_any_volatile_reg(nor, &op, nor->reg_proto);
200+
return spi_nor_write_any_volatile_reg(nor, &op, nor->reg_proto);
201+
}
202+
203+
static int cypress_nor_octal_dtr_en(struct spi_nor *nor)
204+
{
205+
u8 *buf = nor->bouncebuf;
206+
int ret;
207+
208+
ret = cypress_nor_set_memlat(nor, SPINOR_REG_CYPRESS_CFR2V);
209+
if (ret)
210+
return ret;
211+
212+
ret = cypress_nor_set_octal_dtr_bits(nor, SPINOR_REG_CYPRESS_CFR5V);
195213
if (ret)
196214
return ret;
197215

@@ -209,11 +227,10 @@ static int cypress_nor_octal_dtr_en(struct spi_nor *nor)
209227
return 0;
210228
}
211229

212-
static int cypress_nor_octal_dtr_dis(struct spi_nor *nor)
230+
static int cypress_nor_set_single_spi_bits(struct spi_nor *nor, u64 addr)
213231
{
214232
struct spi_mem_op op;
215233
u8 *buf = nor->bouncebuf;
216-
int ret;
217234

218235
/*
219236
* The register is 1-byte wide, but 1-byte transactions are not allowed
@@ -223,9 +240,16 @@ static int cypress_nor_octal_dtr_dis(struct spi_nor *nor)
223240
buf[0] = SPINOR_REG_CYPRESS_CFR5_OCT_DTR_DS;
224241
buf[1] = 0;
225242
op = (struct spi_mem_op)
226-
CYPRESS_NOR_WR_ANY_REG_OP(nor->addr_nbytes,
227-
SPINOR_REG_CYPRESS_CFR5V, 2, buf);
228-
ret = spi_nor_write_any_volatile_reg(nor, &op, SNOR_PROTO_8_8_8_DTR);
243+
CYPRESS_NOR_WR_ANY_REG_OP(nor->addr_nbytes, addr, 2, buf);
244+
return spi_nor_write_any_volatile_reg(nor, &op, SNOR_PROTO_8_8_8_DTR);
245+
}
246+
247+
static int cypress_nor_octal_dtr_dis(struct spi_nor *nor)
248+
{
249+
u8 *buf = nor->bouncebuf;
250+
int ret;
251+
252+
ret = cypress_nor_set_single_spi_bits(nor, SPINOR_REG_CYPRESS_CFR5V);
229253
if (ret)
230254
return ret;
231255

0 commit comments

Comments
 (0)