Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 116024
b: refs/heads/master
c: 95ebffd
h: refs/heads/master
v: v3
  • Loading branch information
Anton Vorontsov authored and David Woodhouse committed Oct 10, 2008
1 parent 260f747 commit e7c98fa
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 25 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: 63fd7f30f328f99956d3c774d17219c3c8d54131
refs/heads/master: 95ebffd749c8e6c8cbb746bc0833a5738cc23321
57 changes: 33 additions & 24 deletions trunk/drivers/mtd/nand/fsl_upm.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ struct fsl_upm_nand {
uint8_t upm_cmd_offset;
void __iomem *io_base;
int rnb_gpio;
const uint32_t *wait_pattern;
const uint32_t *wait_write;
int chip_delay;
};

#define to_fsl_upm_nand(mtd) container_of(mtd, struct fsl_upm_nand, mtd)
Expand Down Expand Up @@ -89,8 +86,7 @@ static void fun_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)

fsl_upm_run_pattern(&fun->upm, fun->io_base, cmd);

if (fun->wait_pattern)
fun_wait_rnb(fun);
fun_wait_rnb(fun);
}

static uint8_t fun_read_byte(struct mtd_info *mtd)
Expand All @@ -116,22 +112,24 @@ static void fun_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len)

for (i = 0; i < len; i++) {
out_8(fun->chip.IO_ADDR_W, buf[i]);
if (fun->wait_write)
fun_wait_rnb(fun);
fun_wait_rnb(fun);
}
}

static int __devinit fun_chip_init(struct fsl_upm_nand *fun)
static int __devinit fun_chip_init(struct fsl_upm_nand *fun,
const struct device_node *upm_np,
const struct resource *io_res)
{
int ret;
struct device_node *flash_np;
#ifdef CONFIG_MTD_PARTITIONS
static const char *part_types[] = { "cmdlinepart", NULL, };
#endif

fun->chip.IO_ADDR_R = fun->io_base;
fun->chip.IO_ADDR_W = fun->io_base;
fun->chip.cmd_ctrl = fun_cmd_ctrl;
fun->chip.chip_delay = fun->chip_delay;
fun->chip.chip_delay = 50;
fun->chip.read_byte = fun_read_byte;
fun->chip.read_buf = fun_read_buf;
fun->chip.write_buf = fun_write_buf;
Expand All @@ -143,18 +141,37 @@ static int __devinit fun_chip_init(struct fsl_upm_nand *fun)
fun->mtd.priv = &fun->chip;
fun->mtd.owner = THIS_MODULE;

flash_np = of_get_next_child(upm_np, NULL);
if (!flash_np)
return -ENODEV;

fun->mtd.name = kasprintf(GFP_KERNEL, "%x.%s", io_res->start,
flash_np->name);
if (!fun->mtd.name) {
ret = -ENOMEM;
goto err;
}

ret = nand_scan(&fun->mtd, 1);
if (ret)
return ret;

fun->mtd.name = fun->dev->bus_id;
goto err;

#ifdef CONFIG_MTD_PARTITIONS
ret = parse_mtd_partitions(&fun->mtd, part_types, &fun->parts, 0);

#ifdef CONFIG_MTD_OF_PARTS
if (ret == 0)
ret = of_mtd_parse_partitions(fun->dev, &fun->mtd,
flash_np, &fun->parts);
#endif
if (ret > 0)
return add_mtd_partitions(&fun->mtd, fun->parts, ret);
ret = add_mtd_partitions(&fun->mtd, fun->parts, ret);
else
#endif
return add_mtd_device(&fun->mtd);
ret = add_mtd_device(&fun->mtd);
err:
of_node_put(flash_np);
return ret;
}

static int __devinit fun_probe(struct of_device *ofdev,
Expand Down Expand Up @@ -220,17 +237,8 @@ static int __devinit fun_probe(struct of_device *ofdev,

fun->dev = &ofdev->dev;
fun->last_ctrl = NAND_CLE;
fun->wait_pattern = of_get_property(ofdev->node, "fsl,wait-pattern",
NULL);
fun->wait_write = of_get_property(ofdev->node, "fsl,wait-write", NULL);

prop = of_get_property(ofdev->node, "chip-delay", NULL);
if (prop)
fun->chip_delay = *prop;
else
fun->chip_delay = 50;

ret = fun_chip_init(fun);
ret = fun_chip_init(fun, ofdev->node, &io_res);
if (ret)
goto err2;

Expand All @@ -251,6 +259,7 @@ static int __devexit fun_remove(struct of_device *ofdev)
struct fsl_upm_nand *fun = dev_get_drvdata(&ofdev->dev);

nand_release(&fun->mtd);
kfree(fun->mtd.name);

if (fun->rnb_gpio >= 0)
gpio_free(fun->rnb_gpio);
Expand Down

0 comments on commit e7c98fa

Please sign in to comment.