Skip to content

Commit 64ddba4

Browse files
Mian Yousaf KaukabDavid Woodhouse
authored andcommitted
mtd: nand: fsmc: update of OF support
Add nand bank selection and timings to the device tree bindings. Signed-off-by: Mian Yousaf Kaukab <mian.yousaf.kaukab@stericsson.com> [Added some documentation] Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
1 parent 52778b2 commit 64ddba4

3 files changed

Lines changed: 43 additions & 1 deletion

File tree

‎Documentation/devicetree/bindings/mtd/fsmc-nand.txt‎

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
* FSMC NAND
1+
ST Microelectronics Flexible Static Memory Controller (FSMC)
2+
NAND Interface
23

34
Required properties:
45
- compatible : "st,spear600-fsmc-nand", "stericsson,fsmc-nand"
@@ -9,6 +10,26 @@ Optional properties:
910
- bank-width : Width (in bytes) of the device. If not present, the width
1011
defaults to 1 byte
1112
- nand-skip-bbtscan: Indicates the the BBT scanning should be skipped
13+
- timings: array of 6 bytes for NAND timings. The meanings of these bytes
14+
are:
15+
byte 0 TCLR : CLE to RE delay in number of AHB clock cycles, only 4 bits
16+
are valid. Zero means one clockcycle, 15 means 16 clock
17+
cycles.
18+
byte 1 TAR : ALE to RE delay, 4 bits are valid. Same format as TCLR.
19+
byte 2 THIZ : number of HCLK clock cycles during which the data bus is
20+
kept in Hi-Z (tristate) after the start of a write access.
21+
Only valid for write transactions. Zero means zero cycles,
22+
255 means 255 cycles.
23+
byte 3 THOLD : number of HCLK clock cycles to hold the address (and data
24+
when writing) after the command deassertation. Zero means
25+
one cycle, 255 means 256 cycles.
26+
byte 4 TWAIT : number of HCLK clock cycles to assert the command to the
27+
NAND flash in response to SMWAITn. Zero means 1 cycle,
28+
255 means 256 cycles.
29+
byte 5 TSET : number of HCLK clock cycles to assert the address before the
30+
command is asserted. Zero means one cycle, 255 means 256
31+
cycles.
32+
- bank: default NAND bank to use (0-3 are valid, 0 is the default).
1233

1334
Example:
1435

@@ -24,6 +45,8 @@ Example:
2445

2546
bank-width = <1>;
2647
nand-skip-bbtscan;
48+
timings = /bits/ 8 <0 0 0 2 3 0>;
49+
bank = <1>;
2750

2851
partition@0 {
2952
...

‎drivers/mtd/nand/fsmc_nand.c‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -889,6 +889,24 @@ static int fsmc_nand_probe_config_dt(struct platform_device *pdev,
889889
if (of_get_property(np, "nand-skip-bbtscan", NULL))
890890
pdata->options = NAND_SKIP_BBTSCAN;
891891

892+
pdata->nand_timings = devm_kzalloc(&pdev->dev,
893+
sizeof(*pdata->nand_timings), GFP_KERNEL);
894+
if (!pdata->nand_timings) {
895+
dev_err(&pdev->dev, "no memory for nand_timing\n");
896+
return -ENOMEM;
897+
}
898+
of_property_read_u8_array(np, "timings", (u8 *)pdata->nand_timings,
899+
sizeof(*pdata->nand_timings));
900+
901+
/* Set default NAND bank to 0 */
902+
pdata->bank = 0;
903+
if (!of_property_read_u32(np, "bank", &val)) {
904+
if (val > 3) {
905+
dev_err(&pdev->dev, "invalid bank %u\n", val);
906+
return -EINVAL;
907+
}
908+
pdata->bank = val;
909+
}
892910
return 0;
893911
}
894912
#else

‎include/linux/mtd/fsmc.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ enum access_mode {
137137

138138
/**
139139
* fsmc_nand_platform_data - platform specific NAND controller config
140+
* @nand_timings: timing setup for the physical NAND interface
140141
* @partitions: partition table for the platform, use a default fallback
141142
* if this is NULL
142143
* @nr_partitions: the number of partitions in the previous entry

0 commit comments

Comments
 (0)