|
6 | 6 |
|
7 | 7 | #include <linux/bitfield.h>
|
8 | 8 | #include <linux/device.h>
|
| 9 | +#include <linux/errno.h> |
9 | 10 | #include <linux/mtd/spi-nor.h>
|
10 | 11 |
|
11 | 12 | #include "core.h"
|
|
37 | 38 | (SPINOR_REG_CYPRESS_VREG + SPINOR_REG_CYPRESS_CFR3)
|
38 | 39 | #define SPINOR_REG_CYPRESS_CFR3_PGSZ BIT(4) /* Page size. */
|
39 | 40 | #define SPINOR_REG_CYPRESS_CFR5 0x6
|
40 |
| -#define SPINOR_REG_CYPRESS_CFR5V \ |
41 |
| - (SPINOR_REG_CYPRESS_VREG + SPINOR_REG_CYPRESS_CFR5) |
42 | 41 | #define SPINOR_REG_CYPRESS_CFR5_BIT6 BIT(6)
|
43 | 42 | #define SPINOR_REG_CYPRESS_CFR5_DDR BIT(1)
|
44 | 43 | #define SPINOR_REG_CYPRESS_CFR5_OPI BIT(0)
|
@@ -202,14 +201,18 @@ static int cypress_nor_set_octal_dtr_bits(struct spi_nor *nor, u64 addr)
|
202 | 201 |
|
203 | 202 | static int cypress_nor_octal_dtr_en(struct spi_nor *nor)
|
204 | 203 | {
|
| 204 | + const struct spi_nor_flash_parameter *params = nor->params; |
205 | 205 | u8 *buf = nor->bouncebuf;
|
| 206 | + u64 addr; |
206 | 207 | int ret;
|
207 | 208 |
|
208 |
| - ret = cypress_nor_set_memlat(nor, SPINOR_REG_CYPRESS_CFR2V); |
| 209 | + addr = params->vreg_offset[0] + SPINOR_REG_CYPRESS_CFR2; |
| 210 | + ret = cypress_nor_set_memlat(nor, addr); |
209 | 211 | if (ret)
|
210 | 212 | return ret;
|
211 | 213 |
|
212 |
| - ret = cypress_nor_set_octal_dtr_bits(nor, SPINOR_REG_CYPRESS_CFR5V); |
| 214 | + addr = params->vreg_offset[0] + SPINOR_REG_CYPRESS_CFR5; |
| 215 | + ret = cypress_nor_set_octal_dtr_bits(nor, addr); |
213 | 216 | if (ret)
|
214 | 217 | return ret;
|
215 | 218 |
|
@@ -247,9 +250,11 @@ static int cypress_nor_set_single_spi_bits(struct spi_nor *nor, u64 addr)
|
247 | 250 | static int cypress_nor_octal_dtr_dis(struct spi_nor *nor)
|
248 | 251 | {
|
249 | 252 | u8 *buf = nor->bouncebuf;
|
| 253 | + u64 addr; |
250 | 254 | int ret;
|
251 | 255 |
|
252 |
| - ret = cypress_nor_set_single_spi_bits(nor, SPINOR_REG_CYPRESS_CFR5V); |
| 256 | + addr = nor->params->vreg_offset[0] + SPINOR_REG_CYPRESS_CFR5; |
| 257 | + ret = cypress_nor_set_single_spi_bits(nor, addr); |
253 | 258 | if (ret)
|
254 | 259 | return ret;
|
255 | 260 |
|
@@ -714,7 +719,15 @@ static int s28hx_t_post_bfpt_fixup(struct spi_nor *nor,
|
714 | 719 |
|
715 | 720 | static int s28hx_t_late_init(struct spi_nor *nor)
|
716 | 721 | {
|
717 |
| - nor->params->set_octal_dtr = cypress_nor_set_octal_dtr; |
| 722 | + struct spi_nor_flash_parameter *params = nor->params; |
| 723 | + |
| 724 | + if (!params->n_dice || !params->vreg_offset) { |
| 725 | + dev_err(nor->dev, "%s failed. The volatile register offset could not be retrieved from SFDP.\n", |
| 726 | + __func__); |
| 727 | + return -EOPNOTSUPP; |
| 728 | + } |
| 729 | + |
| 730 | + params->set_octal_dtr = cypress_nor_set_octal_dtr; |
718 | 731 | cypress_nor_ecc_init(nor);
|
719 | 732 |
|
720 | 733 | return 0;
|
|
0 commit comments