Subversion Repositories freemyipod

Rev

Rev 69 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 69 Rev 85
Line 27... Line 27...
27
#include "util.h"
27
#include "util.h"
28
#include "timer.h"
28
#include "timer.h"
29
#include "nand.h"
29
#include "nand.h"
30
#include "pmu.h"
30
#include "pmu.h"
31
#include "mmu.h"
31
#include "mmu.h"
-
 
32
#include "s5l8701.h"
32
 
33
 
33
#define NAND_CMD_READ       0x00
34
#define NAND_CMD_READ       0x00
34
#define NAND_CMD_PROGCNFRM  0x10
35
#define NAND_CMD_PROGCNFRM  0x10
35
#define NAND_CMD_READ2      0x30
36
#define NAND_CMD_READ2      0x30
36
#define NAND_CMD_BLOCKERASE 0x60
37
#define NAND_CMD_BLOCKERASE 0x60
Line 251... Line 252...
251
static void ecc_start(uint32_t size, void* databuffer, void* sparebuffer,
252
static void ecc_start(uint32_t size, void* databuffer, void* sparebuffer,
252
                      uint32_t type)
253
                      uint32_t type)
253
{
254
{
254
    mutex_lock(&ecc_mtx, TIMEOUT_BLOCK);
255
    mutex_lock(&ecc_mtx, TIMEOUT_BLOCK);
255
    ECC_INT_CLR = 1;
256
    ECC_INT_CLR = 1;
256
    SRCPND = INTMSK_ECC;
257
    SRCPND = (1 << IRQ_ECC);
257
    ECC_UNK1 = size;
258
    ECC_UNK1 = size;
258
    ECC_DATA_PTR = (uint32_t)databuffer;
259
    ECC_DATA_PTR = (uint32_t)databuffer;
259
    ECC_SPARE_PTR = (uint32_t)sparebuffer;
260
    ECC_SPARE_PTR = (uint32_t)sparebuffer;
260
    clean_dcache();
261
    clean_dcache();
261
    ECC_CTRL = type;
262
    ECC_CTRL = type;
262
}
263
}
263
 
264
 
264
static uint32_t ecc_collect(void)
265
static uint32_t ecc_collect(void)
265
{
266
{
266
    uint32_t timeout = USEC_TIMER + 20000;
267
    uint32_t timeout = USEC_TIMER + 20000;
267
    while (!(SRCPND & INTMSK_ECC))
268
    while (!(SRCPND & (1 << IRQ_ECC)))
268
        if (nand_timeout(timeout)) return ecc_unlock(1);
269
        if (nand_timeout(timeout)) return ecc_unlock(1);
269
    invalidate_dcache();
270
    invalidate_dcache();
270
    ECC_INT_CLR = 1;
271
    ECC_INT_CLR = 1;
271
    SRCPND = INTMSK_ECC;
272
    SRCPND = (1 << IRQ_ECC);
272
    return ecc_unlock(ECC_RESULT);
273
    return ecc_unlock(ECC_RESULT);
273
}
274
}
274
 
275
 
275
static uint32_t ecc_decode(uint32_t size, void* databuffer, void* sparebuffer)
276
static uint32_t ecc_decode(uint32_t size, void* databuffer, void* sparebuffer)
276
{
277
{