916653da542e63b351821b632808e78ab5e2537f
[openwrt/staging/chunkeey.git] / target / linux / rb532 / patches-3.10 / 002-rb532_nand_fixup.patch
1 --- a/arch/mips/rb532/devices.c
2 +++ b/arch/mips/rb532/devices.c
3 @@ -140,6 +140,19 @@ static struct platform_device cf_slot0 =
4 };
5
6 /* Resources and device for NAND */
7 +
8 +/*
9 + * We need to use the OLD Yaffs-1 OOB layout, otherwise the RB bootloader
10 + * will not be able to find the kernel that we load. So set the oobinfo
11 + * when creating the partitions
12 + */
13 +static struct nand_ecclayout rb532_nand_ecclayout = {
14 + .eccbytes = 6,
15 + .eccpos = { 8, 9, 10, 13, 14, 15 },
16 + .oobavail = 9,
17 + .oobfree = { { 0, 4 }, { 6, 2 }, { 11, 2 }, { 4, 1 } }
18 +};
19 +
20 static int rb532_dev_ready(struct mtd_info *mtd)
21 {
22 return gpio_get_value(GPIO_RDY);
23 @@ -275,6 +288,16 @@ static void __init parse_mac_addr(char *
24 /* NAND definitions */
25 #define NAND_CHIP_DELAY 25
26
27 +static int rb532_nand_fixup(struct mtd_info *mtd)
28 +{
29 + struct nand_chip *chip = mtd->priv;
30 +
31 + if (mtd->writesize == 512)
32 + chip->ecc.layout = &rb532_nand_ecclayout;
33 +
34 + return 0;
35 +}
36 +
37 static void __init rb532_nand_setup(void)
38 {
39 switch (mips_machtype) {
40 @@ -293,6 +316,7 @@ static void __init rb532_nand_setup(void
41 rb532_nand_data.chip.nr_partitions = ARRAY_SIZE(rb532_partition_info);
42 rb532_nand_data.chip.partitions = rb532_partition_info;
43 rb532_nand_data.chip.chip_delay = NAND_CHIP_DELAY;
44 + rb532_nand_data.chip.chip_fixup = &rb532_nand_fixup;
45 }
46
47