-
Notifications
You must be signed in to change notification settings - Fork 6.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
drivers/flash/nrf_qspi_nor: add support for enter 4-byte addressing mode #41743
drivers/flash/nrf_qspi_nor: add support for enter 4-byte addressing mode #41743
Conversation
@@ -564,7 +576,20 @@ static int qspi_nrfx_configure(const struct device *dev) | |||
} | |||
} | |||
|
|||
return 0; | |||
if (INST_0_4BA != 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should add LOG_DBG that would be stating that we got into 4-byte address mode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Shouldn't we also address usage of sfdp-bfp in DTS? The enter_4byte_addr, as the binding states, is less important than sfdp bpfs, which stores the same info. |
This driver doesn't support DTS bundled sfd-bfp. I think runtime processing of these build time records is not something I should apply in this PR. I was looking into spi-nor driver: It looks like support of that possibly results in implementation of features unused in given application. Anyway, adding (runtime) read of DW16 of SFDP BFP make sense to me here. |
@de-nordic After I have been looking into spi_nor driver I conclude that the read and the runtime processing of SFDP might be implemented as there. Best approach would be extraction of common code from spi_nor.c (at last commonality of functionality of |
Great. So I leave adding the LOG_DBG line up to you. I have looked at the code and it looks OK. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks OK. Thanks.
63cf20f
to
114f457
Compare
drivers/flash/nrf_qspi_nor.c
Outdated
if (INST_0_4BA & 0x02) { | ||
qspi_nor_write_protection_set(dev, false); | ||
} | ||
|
||
struct qspi_cmd cmd = { | ||
.op_code = SPI_NOR_CMD_4BA, | ||
.rx_buf = NULL, | ||
.tx_buf = NULL, | ||
}; | ||
ret = qspi_send_cmd(dev, &cmd, false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about just:
struct qspi_cmd cmd = {
.op_code = SPI_NOR_CMD_4BA,
};
ret = qspi_send_cmd(dev, &cmd, (INST_0_4BA & 0x02));
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and right, the rest of struct members will be zeroed automatically.
drivers/flash/nrf_qspi_nor.c
Outdated
if (ret < 0) { | ||
LOG_DBG("E4BA cmd issued."); | ||
} else { | ||
LOG_ERR("E4BA cmd issue failed: %d.", ret); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ret < 0
means that an error occurred, so this should be the other way around.
drivers/flash/nrf_qspi_nor.c
Outdated
#if DT_INST_NODE_HAS_PROP(0, enter_4byte_addr) | ||
#define INST_0_4BA DT_INST_PROP(0, enter_4byte_addr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#if DT_INST_NODE_HAS_PROP(0, enter_4byte_addr) | |
#define INST_0_4BA DT_INST_PROP(0, enter_4byte_addr) | |
#define INST_0_4BA DT_INST_PROP_OR(0, enter_4byte_addr, 0) |
114f457
to
0f01f03
Compare
What is the status of this pull request? I'm very interested in this change as the solution to #40453 |
@richesonk I'm going to test this finally. |
drivers/flash/nrf_qspi_nor.c
Outdated
#if (INST_0_4BA != 0) | ||
BUILD_ASSERT(((INST_0_4BA & 0x03) != 0), | ||
"Driver only supports command (0xB7) for entering 4 byte addressing mode"); | ||
BUILD_ASSERT((DT_INST_PROP(0, address_size_32) == NRF_QSPI_ADDRMODE_32BIT), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BUILD_ASSERT((DT_INST_PROP(0, address_size_32) == NRF_QSPI_ADDRMODE_32BIT), | |
BUILD_ASSERT(DT_INST_PROP(0, address_size_32), |
This is a boolean property, so it should not be compared with the value of NRF_QSPI_ADDRMODE_32BIT
(which by chance evaluates to 1, hence it works in the current form).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
applied
I also need this change for an active development project soon. I hope it makes the next NCS release. Thanks |
0f01f03
to
bc0f3a1
Compare
@de-nordic @anangl Can you revisit? |
@@ -0,0 +1,37 @@ | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should add a test configuration in testcase.yaml
that will use this overlay so that CI has a chance to check it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
&qspi { | ||
sck-pin = <30>; | ||
io-pins = <29>, <28>, <04>, <03>; | ||
csn-pins = <31>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This board (nRF52840 DK) uses PINCTRL now, so you need to rebase and then modify pinctrl-*
properties instead.
&qspi { | |
sck-pin = <30>; | |
io-pins = <29>, <28>, <04>, <03>; | |
csn-pins = <31>; | |
&pinctrl { | |
qspi_default: qspi_default { | |
group1 { | |
psels = <NRF_PSEL(QSPI_SCK, 0, 30)>, | |
<NRF_PSEL(QSPI_IO0, 0, 29)>, | |
<NRF_PSEL(QSPI_IO1, 0, 28)>, | |
<NRF_PSEL(QSPI_IO2, 0, 04)>, | |
<NRF_PSEL(QSPI_IO3, 0, 03)>, | |
<NRF_PSEL(QSPI_CSN, 0, 31)>; | |
}; | |
}; | |
qspi_sleep: qspi_sleep { | |
group1 { | |
psels = <NRF_PSEL(QSPI_SCK, 0, 30)>, | |
<NRF_PSEL(QSPI_IO0, 0, 29)>, | |
<NRF_PSEL(QSPI_IO1, 0, 28)>, | |
<NRF_PSEL(QSPI_IO2, 0, 04)>, | |
<NRF_PSEL(QSPI_IO3, 0, 03)>, | |
<NRF_PSEL(QSPI_CSN, 0, 31)>; | |
low-power-enable; | |
}; | |
}; | |
}; | |
&qspi { | |
pinctrl-0 = <&qspi_default_alt>; | |
pinctrl-1 = <&qspi_sleep_alt>; | |
pinctrl-names = "default", "sleep"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK
ea55ed2
to
d21447e
Compare
tests/drivers/flash/testcase.yaml
Outdated
extra_args: OVERLAY_CONFIG=boards/nrf52840_flash_qspi.conf | ||
DTC_OVERLAY_FILE=./boards/nrf52840dk_mx25l51245g.overlay |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this "./" actually needed?
extra_args: OVERLAY_CONFIG=boards/nrf52840_flash_qspi.conf | |
DTC_OVERLAY_FILE=./boards/nrf52840dk_mx25l51245g.overlay | |
extra_args: OVERLAY_CONFIG=boards/nrf52840_flash_qspi.conf | |
DTC_OVERLAY_FILE=boards/nrf52840dk_mx25l51245g.overlay |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'./' is not needed.
d21447e
to
df7d819
Compare
df7d819
to
d214543
Compare
9c46b98
to
1b83bf9
Compare
Added basic support for enter 4-byte addressing command. Patch supports command 0xB7 (Enter 4-Byte Address Mode), with or without preceding WREN. Similar as for SPI-NOR the `enter-4byte-addr` property of memory node is used or describing how to Enter 4-Byte Addressing mode. Worth to notice that along with that property the `address-size-32` property is expected as it switch the driver to use 4-byte addressing in operations. Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
Added overlay with DTS of MX25L51245G qspi flash memory. DTS configures qspi clock to 2 MHz which is supported by nRF52840. Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
1b83bf9
to
f440424
Compare
Added basic support for enter 4-byte addressing command.
Patch supports command 0xB7 (Enter 4-Byte Address Mode),
with or without preceding WREN.
Similar as for SPI-NOR the
enter-4byte-addr
property ofmemory node is used or describing how to Enter 4-Byte Addressing
mode.
Worth to notice that along with that property the
address-size-32
property is expected as it switch the driver to use 4-byte addressing
in operations.
Signed-off-by: Andrzej Puzdrowski andrzej.puzdrowski@nordicsemi.no
not tested on hardware yetwas tested using MX25L51245G