Skip to content

Commit b086a46

Browse files
mandrzejewski-iceyemiquelraynal
authored andcommitted
mtd: rawnand: arasan: Fix double assertion of chip-select
When two chip-selects are configured in the device tree, and the second is a non-native GPIO, both the GPIO-based chip-select and the first native chip-select may be asserted simultaneously. This double assertion causes incorrect read and write operations. The issue occurs because when nfc->ncs <= 2, nfc->spare_cs is always initialized to 0 due to static initialization. Consequently, when the second chip-select (GPIO-based) is selected in anfc_assert_cs(), it is detected by anfc_is_gpio_cs(), and nfc->native_cs is assigned the value 0. This results in both the GPIO-based chip-select being asserted and the NAND controller register receiving 0, erroneously selecting the native chip-select. This patch resolves the issue, as confirmed by oscilloscope testing with configurations involving two or more chip-selects in the device tree. Fixes: acbd3d0 ("mtd: rawnand: arasan: Leverage additional GPIO CS") Cc: [email protected] Signed-off-by: Maciej Andrzejewski <[email protected]> Signed-off-by: Miquel Raynal <[email protected]>
1 parent 9b458e8 commit b086a46

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/mtd/nand/raw/arasan-nand-controller.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1409,8 +1409,8 @@ static int anfc_parse_cs(struct arasan_nfc *nfc)
14091409
* case, the "not" chosen CS is assigned to nfc->spare_cs and selected
14101410
* whenever a GPIO CS must be asserted.
14111411
*/
1412-
if (nfc->cs_array && nfc->ncs > 2) {
1413-
if (!nfc->cs_array[0] && !nfc->cs_array[1]) {
1412+
if (nfc->cs_array) {
1413+
if (nfc->ncs > 2 && !nfc->cs_array[0] && !nfc->cs_array[1]) {
14141414
dev_err(nfc->dev,
14151415
"Assign a single native CS when using GPIOs\n");
14161416
return -EINVAL;

0 commit comments

Comments
 (0)