0ba9fefb0f16d7951d21838f98f9c9ecd21fedd6
[openwrt.git] / target / linux / rb532 / patches-2.6.35 / 002-rb532_nand_fixup.patch
1 --- a/arch/mips/rb532/devices.c
2 +++ b/arch/mips/rb532/devices.c
3 @@ -139,6 +139,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 @@ -280,6 +293,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 @@ -299,6 +322,8 @@ static void __init rb532_nand_setup(void
41         rb532_nand_data.chip.partitions = rb532_partition_info;
42         rb532_nand_data.chip.chip_delay = NAND_CHIP_DELAY;
43         rb532_nand_data.chip.options = NAND_NO_AUTOINCR;
44 +       
45 +       rb532_nand_data.chip.chip_fixup = &rb532_nand_fixup;
46  }
47  
48