Skip to content

Commit 785bcb4

Browse files
committed
Merge tag 'for-linus-20161104' of git://git.infradead.org/linux-mtd
Pull MTD fixes from Brian Norris: - MAINTAINERS updates to reflect some new maintainers/submaintainers. We have some great volunteers who've been developing and reviewing already. We're going to try a group maintainership model, so eventually you'll probably see pull requests from people besides me. - NAND fixes from Boris: "Three simple fixes: - fix a non-critical bug in the gpmi driver - fix a bug in the 'automatic NAND timings selection' feature introduced in 4.9-rc1 - fix a false positive uninitialized-var warning" * tag 'for-linus-20161104' of git://git.infradead.org/linux-mtd: mtd: mtk: avoid warning in mtk_ecc_encode mtd: nand: Fix data interface configuration logic mtd: nand: gpmi: disable the clocks on errors MAINTAINERS: add more people to the MTD maintainer team MAINTAINERS: add a maintainer for the SPI NOR subsystem
2 parents d299704 + 0e2ce9d commit 785bcb4

5 files changed

Lines changed: 71 additions & 31 deletions

File tree

MAINTAINERS

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7925,6 +7925,10 @@ F: mm/
79257925
MEMORY TECHNOLOGY DEVICES (MTD)
79267926
M: David Woodhouse <dwmw2@infradead.org>
79277927
M: Brian Norris <computersforpeace@gmail.com>
7928+
M: Boris Brezillon <boris.brezillon@free-electrons.com>
7929+
M: Marek Vasut <marek.vasut@gmail.com>
7930+
M: Richard Weinberger <richard@nod.at>
7931+
M: Cyrille Pitchen <cyrille.pitchen@atmel.com>
79287932
L: linux-mtd@lists.infradead.org
79297933
W: http://www.linux-mtd.infradead.org/
79307934
Q: http://patchwork.ozlabs.org/project/linux-mtd/list/
@@ -11404,6 +11408,17 @@ W: http://www.st.com/spear
1140411408
S: Maintained
1140511409
F: drivers/clk/spear/
1140611410

11411+
SPI NOR SUBSYSTEM
11412+
M: Cyrille Pitchen <cyrille.pitchen@atmel.com>
11413+
M: Marek Vasut <marek.vasut@gmail.com>
11414+
L: linux-mtd@lists.infradead.org
11415+
W: http://www.linux-mtd.infradead.org/
11416+
Q: http://patchwork.ozlabs.org/project/linux-mtd/list/
11417+
T: git git://github.com/spi-nor/linux.git
11418+
S: Maintained
11419+
F: drivers/mtd/spi-nor/
11420+
F: include/linux/mtd/spi-nor.h
11421+
1140711422
SPI SUBSYSTEM
1140811423
M: Mark Brown <broonie@kernel.org>
1140911424
L: linux-spi@vger.kernel.org

drivers/mtd/nand/gpmi-nand/gpmi-lib.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ int gpmi_init(struct gpmi_nand_data *this)
161161

162162
ret = gpmi_enable_clk(this);
163163
if (ret)
164-
goto err_out;
164+
return ret;
165165
ret = gpmi_reset_block(r->gpmi_regs, false);
166166
if (ret)
167167
goto err_out;
@@ -197,6 +197,7 @@ int gpmi_init(struct gpmi_nand_data *this)
197197
gpmi_disable_clk(this);
198198
return 0;
199199
err_out:
200+
gpmi_disable_clk(this);
200201
return ret;
201202
}
202203

@@ -270,7 +271,7 @@ int bch_set_geometry(struct gpmi_nand_data *this)
270271

271272
ret = gpmi_enable_clk(this);
272273
if (ret)
273-
goto err_out;
274+
return ret;
274275

275276
/*
276277
* Due to erratum #2847 of the MX23, the BCH cannot be soft reset on this
@@ -308,6 +309,7 @@ int bch_set_geometry(struct gpmi_nand_data *this)
308309
gpmi_disable_clk(this);
309310
return 0;
310311
err_out:
312+
gpmi_disable_clk(this);
311313
return ret;
312314
}
313315

drivers/mtd/nand/mtk_ecc.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ struct mtk_ecc {
8686
struct completion done;
8787
struct mutex lock;
8888
u32 sectors;
89+
90+
u8 eccdata[112];
8991
};
9092

9193
static inline void mtk_ecc_wait_idle(struct mtk_ecc *ecc,
@@ -366,9 +368,8 @@ int mtk_ecc_encode(struct mtk_ecc *ecc, struct mtk_ecc_config *config,
366368
u8 *data, u32 bytes)
367369
{
368370
dma_addr_t addr;
369-
u8 *p;
370-
u32 len, i, val;
371-
int ret = 0;
371+
u32 len;
372+
int ret;
372373

373374
addr = dma_map_single(ecc->dev, data, bytes, DMA_TO_DEVICE);
374375
ret = dma_mapping_error(ecc->dev, addr);
@@ -393,14 +394,12 @@ int mtk_ecc_encode(struct mtk_ecc *ecc, struct mtk_ecc_config *config,
393394

394395
/* Program ECC bytes to OOB: per sector oob = FDM + ECC + SPARE */
395396
len = (config->strength * ECC_PARITY_BITS + 7) >> 3;
396-
p = data + bytes;
397397

398-
/* write the parity bytes generated by the ECC back to the OOB region */
399-
for (i = 0; i < len; i++) {
400-
if ((i % 4) == 0)
401-
val = readl(ecc->regs + ECC_ENCPAR(i / 4));
402-
p[i] = (val >> ((i % 4) * 8)) & 0xff;
403-
}
398+
/* write the parity bytes generated by the ECC back to temp buffer */
399+
__ioread32_copy(ecc->eccdata, ecc->regs + ECC_ENCPAR(0), round_up(len, 4));
400+
401+
/* copy into possibly unaligned OOB region with actual length */
402+
memcpy(data + bytes, ecc->eccdata, len);
404403
timeout:
405404

406405
dma_unmap_single(ecc->dev, addr, bytes, DMA_TO_DEVICE);

drivers/mtd/nand/nand_base.c

Lines changed: 42 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,10 +1095,11 @@ static void nand_release_data_interface(struct nand_chip *chip)
10951095
/**
10961096
* nand_reset - Reset and initialize a NAND device
10971097
* @chip: The NAND chip
1098+
* @chipnr: Internal die id
10981099
*
10991100
* Returns 0 for success or negative error code otherwise
11001101
*/
1101-
int nand_reset(struct nand_chip *chip)
1102+
int nand_reset(struct nand_chip *chip, int chipnr)
11021103
{
11031104
struct mtd_info *mtd = nand_to_mtd(chip);
11041105
int ret;
@@ -1107,9 +1108,17 @@ int nand_reset(struct nand_chip *chip)
11071108
if (ret)
11081109
return ret;
11091110

1111+
/*
1112+
* The CS line has to be released before we can apply the new NAND
1113+
* interface settings, hence this weird ->select_chip() dance.
1114+
*/
1115+
chip->select_chip(mtd, chipnr);
11101116
chip->cmdfunc(mtd, NAND_CMD_RESET, -1, -1);
1117+
chip->select_chip(mtd, -1);
11111118

1119+
chip->select_chip(mtd, chipnr);
11121120
ret = nand_setup_data_interface(chip);
1121+
chip->select_chip(mtd, -1);
11131122
if (ret)
11141123
return ret;
11151124

@@ -1185,16 +1194,16 @@ int nand_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
11851194
/* Shift to get chip number */
11861195
chipnr = ofs >> chip->chip_shift;
11871196

1188-
chip->select_chip(mtd, chipnr);
1189-
11901197
/*
11911198
* Reset the chip.
11921199
* If we want to check the WP through READ STATUS and check the bit 7
11931200
* we must reset the chip
11941201
* some operation can also clear the bit 7 of status register
11951202
* eg. erase/program a locked block
11961203
*/
1197-
nand_reset(chip);
1204+
nand_reset(chip, chipnr);
1205+
1206+
chip->select_chip(mtd, chipnr);
11981207

11991208
/* Check, if it is write protected */
12001209
if (nand_check_wp(mtd)) {
@@ -1244,16 +1253,16 @@ int nand_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
12441253
/* Shift to get chip number */
12451254
chipnr = ofs >> chip->chip_shift;
12461255

1247-
chip->select_chip(mtd, chipnr);
1248-
12491256
/*
12501257
* Reset the chip.
12511258
* If we want to check the WP through READ STATUS and check the bit 7
12521259
* we must reset the chip
12531260
* some operation can also clear the bit 7 of status register
12541261
* eg. erase/program a locked block
12551262
*/
1256-
nand_reset(chip);
1263+
nand_reset(chip, chipnr);
1264+
1265+
chip->select_chip(mtd, chipnr);
12571266

12581267
/* Check, if it is write protected */
12591268
if (nand_check_wp(mtd)) {
@@ -2940,18 +2949,19 @@ static int nand_do_write_oob(struct mtd_info *mtd, loff_t to,
29402949
}
29412950

29422951
chipnr = (int)(to >> chip->chip_shift);
2943-
chip->select_chip(mtd, chipnr);
2944-
2945-
/* Shift to get page */
2946-
page = (int)(to >> chip->page_shift);
29472952

29482953
/*
29492954
* Reset the chip. Some chips (like the Toshiba TC5832DC found in one
29502955
* of my DiskOnChip 2000 test units) will clear the whole data page too
29512956
* if we don't do this. I have no clue why, but I seem to have 'fixed'
29522957
* it in the doc2000 driver in August 1999. dwmw2.
29532958
*/
2954-
nand_reset(chip);
2959+
nand_reset(chip, chipnr);
2960+
2961+
chip->select_chip(mtd, chipnr);
2962+
2963+
/* Shift to get page */
2964+
page = (int)(to >> chip->page_shift);
29552965

29562966
/* Check, if it is write protected */
29572967
if (nand_check_wp(mtd)) {
@@ -3984,14 +3994,14 @@ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd,
39843994
int i, maf_idx;
39853995
u8 id_data[8];
39863996

3987-
/* Select the device */
3988-
chip->select_chip(mtd, 0);
3989-
39903997
/*
39913998
* Reset the chip, required by some chips (e.g. Micron MT29FxGxxxxx)
39923999
* after power-up.
39934000
*/
3994-
nand_reset(chip);
4001+
nand_reset(chip, 0);
4002+
4003+
/* Select the device */
4004+
chip->select_chip(mtd, 0);
39954005

39964006
/* Send the command for reading device ID */
39974007
chip->cmdfunc(mtd, NAND_CMD_READID, 0x00, -1);
@@ -4329,17 +4339,31 @@ int nand_scan_ident(struct mtd_info *mtd, int maxchips,
43294339
return PTR_ERR(type);
43304340
}
43314341

4342+
/* Initialize the ->data_interface field. */
43324343
ret = nand_init_data_interface(chip);
43334344
if (ret)
43344345
return ret;
43354346

4347+
/*
4348+
* Setup the data interface correctly on the chip and controller side.
4349+
* This explicit call to nand_setup_data_interface() is only required
4350+
* for the first die, because nand_reset() has been called before
4351+
* ->data_interface and ->default_onfi_timing_mode were set.
4352+
* For the other dies, nand_reset() will automatically switch to the
4353+
* best mode for us.
4354+
*/
4355+
ret = nand_setup_data_interface(chip);
4356+
if (ret)
4357+
return ret;
4358+
43364359
chip->select_chip(mtd, -1);
43374360

43384361
/* Check for a chip array */
43394362
for (i = 1; i < maxchips; i++) {
4340-
chip->select_chip(mtd, i);
43414363
/* See comment in nand_get_flash_type for reset */
4342-
nand_reset(chip);
4364+
nand_reset(chip, i);
4365+
4366+
chip->select_chip(mtd, i);
43434367
/* Send the command for reading device ID */
43444368
chip->cmdfunc(mtd, NAND_CMD_READID, 0x00, -1);
43454369
/* Read manufacturer and device IDs */

include/linux/mtd/nand.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1184,7 +1184,7 @@ int nand_read_oob_syndrome(struct mtd_info *mtd, struct nand_chip *chip,
11841184
int page);
11851185

11861186
/* Reset and initialize a NAND device */
1187-
int nand_reset(struct nand_chip *chip);
1187+
int nand_reset(struct nand_chip *chip, int chipnr);
11881188

11891189
/* Free resources held by the NAND device */
11901190
void nand_cleanup(struct nand_chip *chip);

0 commit comments

Comments
 (0)