Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 231692
b: refs/heads/master
c: 593cd87
h: refs/heads/master
v: v3
  • Loading branch information
Linus Walleij authored and David Woodhouse committed Dec 3, 2010
1 parent d790c4c commit 0a96a8d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 23 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 4ad916bca7c372110815e77c2db95fb2eb2f8ab3
refs/heads/master: 593cd8711221c9661dbf9beb2fb42fecca03e693
23 changes: 20 additions & 3 deletions trunk/drivers/mtd/nand/fsmc_nand.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <linux/io.h>
#include <linux/slab.h>
#include <linux/mtd/fsmc.h>
#include <linux/amba/bus.h>
#include <mtd/mtd-abi.h>

static struct nand_ecclayout fsmc_ecc1_layout = {
Expand Down Expand Up @@ -184,8 +185,9 @@ const char *part_probes[] = { "cmdlinepart", NULL };
#endif

/**
* struct fsmc_nand_data - atructure for FSMC NAND device state
* struct fsmc_nand_data - structure for FSMC NAND device state
*
* @pid: Part ID on the AMBA PrimeCell format
* @mtd: MTD info for a NAND flash.
* @nand: Chip related info for a NAND flash.
* @partitions: Partition info for a NAND Flash.
Expand All @@ -201,6 +203,7 @@ const char *part_probes[] = { "cmdlinepart", NULL };
* @regs_va: FSMC regs base address.
*/
struct fsmc_nand_data {
u32 pid;
struct mtd_info mtd;
struct nand_chip nand;
struct mtd_partition *partitions;
Expand Down Expand Up @@ -541,6 +544,8 @@ static int __init fsmc_nand_probe(struct platform_device *pdev)
struct fsmc_regs *regs;
struct resource *res;
int ret = 0;
u32 pid;
int i;

if (!pdata) {
dev_err(&pdev->dev, "platform data is NULL\n");
Expand Down Expand Up @@ -630,6 +635,18 @@ static int __init fsmc_nand_probe(struct platform_device *pdev)
if (ret)
goto err_probe1;

/*
* This device ID is actually a common AMBA ID as used on the
* AMBA PrimeCell bus. However it is not a PrimeCell.
*/
for (pid = 0, i = 0; i < 4; i++)
pid |= (readl(host->regs_va + resource_size(res) - 0x20 + 4 * i) & 255) << (i * 8);
host->pid = pid;
dev_info(&pdev->dev, "FSMC device partno %03x, manufacturer %02x, "
"revision %02x, config %02x\n",
AMBA_PART_BITS(pid), AMBA_MANF_BITS(pid),
AMBA_REV_BITS(pid), AMBA_CONFIG_BITS(pid));

host->bank = pdata->bank;
host->select_chip = pdata->select_bank;
regs = host->regs_va;
Expand Down Expand Up @@ -657,7 +674,7 @@ static int __init fsmc_nand_probe(struct platform_device *pdev)

fsmc_nand_setup(regs, host->bank, nand->options & NAND_BUSWIDTH_16);

if (get_fsmc_version(host->regs_va) == FSMC_VER8) {
if (AMBA_REV_BITS(host->pid) >= 8) {
nand->ecc.read_page = fsmc_read_page_hwecc;
nand->ecc.calculate = fsmc_read_hwecc_ecc4;
nand->ecc.correct = fsmc_correct_data;
Expand All @@ -677,7 +694,7 @@ static int __init fsmc_nand_probe(struct platform_device *pdev)
goto err_probe;
}

if (get_fsmc_version(host->regs_va) == FSMC_VER8) {
if (AMBA_REV_BITS(host->pid) >= 8) {
if (host->mtd.writesize == 512) {
nand->ecc.layout = &fsmc_ecc4_sp_layout;
host->ecc_place = &fsmc_ecc4_sp_place;
Expand Down
19 changes: 0 additions & 19 deletions trunk/include/linux/mtd/fsmc.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,25 +115,6 @@ struct fsmc_regs {
#define FSMC_THOLD_4 (4 << 16)
#define FSMC_THIZ_1 (1 << 24)

/* peripid2 register definitions */
#define FSMC_REVISION_MSK (0xf)
#define FSMC_REVISION_SHFT (0x4)

#define FSMC_VER1 1
#define FSMC_VER2 2
#define FSMC_VER3 3
#define FSMC_VER4 4
#define FSMC_VER5 5
#define FSMC_VER6 6
#define FSMC_VER7 7
#define FSMC_VER8 8

static inline uint32_t get_fsmc_version(struct fsmc_regs *regs)
{
return (readl(&regs->peripid2) >> FSMC_REVISION_SHFT) &
FSMC_REVISION_MSK;
}

/*
* There are 13 bytes of ecc for every 512 byte block in FSMC version 8
* and it has to be read consecutively and immediately after the 512
Expand Down

0 comments on commit 0a96a8d

Please sign in to comment.