mirror of
https://github.com/smaeul/u-boot.git
synced 2025-10-14 04:46:01 +01:00
mtd: rawnand: stm32_fmc2: add NAND Write Protect support
This patch adds the support of the WP# signal. WP will be disabled before the first access to the NAND flash. Signed-off-by: Christophe Kerello <christophe.kerello@foss.st.com> Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
This commit is contained in:
parent
c149bf4140
commit
7ce4f1fad2
@ -12,6 +12,7 @@
|
|||||||
#include <log.h>
|
#include <log.h>
|
||||||
#include <nand.h>
|
#include <nand.h>
|
||||||
#include <reset.h>
|
#include <reset.h>
|
||||||
|
#include <asm/gpio.h>
|
||||||
#include <dm/device_compat.h>
|
#include <dm/device_compat.h>
|
||||||
#include <linux/bitfield.h>
|
#include <linux/bitfield.h>
|
||||||
#include <linux/bitops.h>
|
#include <linux/bitops.h>
|
||||||
@ -149,6 +150,7 @@ struct stm32_fmc2_timings {
|
|||||||
struct stm32_fmc2_nand {
|
struct stm32_fmc2_nand {
|
||||||
struct nand_chip chip;
|
struct nand_chip chip;
|
||||||
struct stm32_fmc2_timings timings;
|
struct stm32_fmc2_timings timings;
|
||||||
|
struct gpio_desc wp_gpio;
|
||||||
int ncs;
|
int ncs;
|
||||||
int cs_used[FMC2_MAX_CE];
|
int cs_used[FMC2_MAX_CE];
|
||||||
};
|
};
|
||||||
@ -824,6 +826,9 @@ static int stm32_fmc2_nfc_parse_child(struct stm32_fmc2_nfc *nfc, ofnode node)
|
|||||||
nand->cs_used[i] = cs[i];
|
nand->cs_used[i] = cs[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gpio_request_by_name_nodev(node, "wp-gpios", 0, &nand->wp_gpio,
|
||||||
|
GPIOD_IS_OUT | GPIOD_IS_OUT_ACTIVE);
|
||||||
|
|
||||||
nand->chip.flash_node = node;
|
nand->chip.flash_node = node;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -972,6 +977,10 @@ static int stm32_fmc2_nfc_probe(struct udevice *dev)
|
|||||||
chip->ecc.size = FMC2_ECC_STEP_SIZE;
|
chip->ecc.size = FMC2_ECC_STEP_SIZE;
|
||||||
chip->ecc.strength = FMC2_ECC_BCH8;
|
chip->ecc.strength = FMC2_ECC_BCH8;
|
||||||
|
|
||||||
|
/* Disable Write Protect */
|
||||||
|
if (dm_gpio_is_valid(&nand->wp_gpio))
|
||||||
|
dm_gpio_set_value(&nand->wp_gpio, 0);
|
||||||
|
|
||||||
ret = nand_scan_ident(mtd, nand->ncs, NULL);
|
ret = nand_scan_ident(mtd, nand->ncs, NULL);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user