dreambox: use backported DVB API from mercurial for kernel 2.6.18
[openembedded.git] / recipes / linux / linux-dm500hd-2.6.18 / linux-2.6.18-several-nand-flash-fixes.patch
1 --- a/drivers/mtd/brcmnand/brcmnand_base.c
2 +++ b/drivers/mtd/brcmnand/brcmnand_base.c
3 @@ -616,10 +616,37 @@ static const unsigned char ffchars[] = {
4  
5  //static unsigned char eccmask[128]; // Will be initialized during probe
6  
7 +static uint32_t reg_p23[] = {
8 +       0x2848, 0x2850, 0x2854,                         //2844..284c
9 +       0x2858, 0x2860, 0x2868, 0x286c,         //2850..285c
10 +       0x2870, 0x2874, 0x2878, 0x287c,         //2860..286c
11 +       0x2890, 0x2894, 0x2898, 0x289c,         //2870..287c
12 +       0x28a0, 0x28a4, 0x28a8, 0x28ac,         //2880..288c
13 +       0x28b0, 0x28b4, 0x28c0};                        //2890..2898
14 +
15 +static int p23_init, p23_rev;
16 +
17 +static inline uint32_t __attribute__((always_inline)) fixreg_p23(uint32_t reg)
18 +{
19 +       if (unlikely(!p23_init)) {
20 +               int revid = *(volatile unsigned long *)0xb0404000;
21 +               p23_init = 1;
22 +               if ((revid >> 16) == 0x7413)
23 +                       p23_rev = 1;
24 +       }
25 +
26 +       if (likely(!p23_rev || reg < 0x2844))
27 +               return reg;
28 +
29 +       return reg_p23[(reg-0x2844)>>2];
30 +}
31  
32  static uint32_t brcmnand_ctrl_read(uint32_t nandCtrlReg) 
33  {
34 -       volatile unsigned long* pReg = (volatile unsigned long*) (BRCMNAND_CTRL_REGS 
35 +       volatile unsigned long* pReg;
36 +       nandCtrlReg = fixreg_p23(nandCtrlReg);
37 +
38 +       pReg = (volatile unsigned long*) (BRCMNAND_CTRL_REGS 
39                 + nandCtrlReg - BCHP_NAND_REVISION);
40  
41         if (nandCtrlReg < BCHP_NAND_REVISION || nandCtrlReg > BCHP_NAND_BLK_WR_PROTECT ||
42 @@ -633,7 +660,10 @@ if (gdebug > 3) printk("%s: CMDREG=%08x val=%08x\n", __FUNCTION__, (unsigned int
43  
44  static void brcmnand_ctrl_write(uint32_t nandCtrlReg, uint32_t val) 
45  {
46 -       volatile unsigned long* pReg = (volatile unsigned long*) (BRCMNAND_CTRL_REGS 
47 +       volatile unsigned long* pReg;
48 +       nandCtrlReg = fixreg_p23(nandCtrlReg);
49 +
50 +       pReg = (volatile unsigned long*) (BRCMNAND_CTRL_REGS 
51                 + nandCtrlReg - BCHP_NAND_REVISION);
52  
53         if (nandCtrlReg < BCHP_NAND_REVISION || nandCtrlReg > BCHP_NAND_BLK_WR_PROTECT ||
54 --- a/include/mtd/mtd-abi.h
55 +++ b/include/mtd/mtd-abi.h
56 @@ -189,7 +189,7 @@ struct nand_oobfree {
57         uint32_t length;
58  };
59  
60 -#define MTD_MAX_OOBFREE_ENTRIES        9
61 +#define MTD_MAX_OOBFREE_ENTRIES        10
62  #define MTD_MAX_ECCPOS_ENTRIES 218     // Was 64 for SLC
63  /*
64   * ECC layout control structure. Exported to userspace for