# HG changeset patch # User Ross Younger # Date 1257854676 0 # Node ID 013b321ed7df9905a5ba77c2a763f4444924c9bc # Parent fbb6348661fe4ea3cd74b9b3a20f16b1159bb019 ea_lpc2468_nand.c: Fix interrupt-mode brokenness when the debug level was low. diff --git a/packages/hal/arm/lpc24xx/ea2468/current/ChangeLog b/packages/hal/arm/lpc24xx/ea2468/current/ChangeLog --- a/packages/hal/arm/lpc24xx/ea2468/current/ChangeLog +++ b/packages/hal/arm/lpc24xx/ea2468/current/ChangeLog @@ -1,3 +1,8 @@ +2009-11-10 Ross Younger + + * ea_lpc2468_nand.c: Fix interrupt-mode brokenness when the debug + level was low. + 2009-11-06 Ross Younger * ea_lpc2468_nand.c: Use mtd_ecc256_fast, not linux_mtd_ecc. diff --git a/packages/hal/arm/lpc24xx/ea2468/current/src/ea_lpc2468_nand.c b/packages/hal/arm/lpc24xx/ea2468/current/src/ea_lpc2468_nand.c --- a/packages/hal/arm/lpc24xx/ea2468/current/src/ea_lpc2468_nand.c +++ b/packages/hal/arm/lpc24xx/ea2468/current/src/ea_lpc2468_nand.c @@ -65,7 +65,7 @@ struct _mypriv { cyg_handle_t inthdl; // interrupt handle cyg_interrupt intr; // interrupt object - int ready; // Set when interrupt fires. Protected by DSR lock. + volatile int ready; // Set when interrupt fires. Protected by DSR lock. #else char dummy; // shush, gcc #endif @@ -151,6 +151,11 @@ static void wait_ready_or_status(cyg_nan #define POLL_INTERVAL 10 /* us */ +#define POLLCOUNT_COUNTING_LEVEL 7 +#if defined(CYGSEM_IO_NAND_DEBUG_LEVEL) && (CYGSEM_IO_NAND_DEBUG_LEVEL >= POLLCOUNT_COUNTING_LEVEL) +#define REPORT_POLLS +#endif + /* Case 1: The NAND_RDY line is not connected. ---------------------- */ #ifndef CYGHWR_HAL_ARM_LPC2XXX_EA_LPC2468_USE_NAND_RDY @@ -163,11 +168,6 @@ static void wait_ready_or_time(cyg_nand_ HAL_DELAY_US(initial+fallback); } -#define POLLCOUNT_COUNTING_LEVEL 7 -#if defined(CYGSEM_IO_NAND_DEBUG_LEVEL) && (CYGSEM_IO_NAND_DEBUG_LEVEL >= POLLCOUNT_COUNTING_LEVEL) -#define REPORT_POLLS -#endif - static void wait_ready_or_status(cyg_nand_device *dev, CYG_BYTE mask) { // The Ready line won't be ready for at least tWB (100ns), so out of @@ -207,26 +207,7 @@ static inline int is_chip_ready(cyg_nand return rv; } -/* Polling loop, does not return until the chip is READY. - * Callers should themselves wait for tWB or other initial time - * to ensure that READY is deasserted. */ -static void wait_ready_polled(cyg_nand_device *ctx) -{ -#ifdef REPORT_POLLS - int polls=0; -#endif - while (0==is_chip_ready(ctx)) { - HAL_DELAY_US(POLL_INTERVAL); -#ifdef REPORT_POLLS - ++polls; -#endif - } -#ifdef REPORT_POLLS - NAND_CHATTER(8, ctx, "!BUSY: pollcount %d\n",polls); -#endif -} - - +static void wait_ready_polled(cyg_nand_device *ctx); # ifdef CYGHWR_HAL_ARM_LPC2XXX_EA_LPC2468_NAND_RDY_USE_INTERRUPT /* Case 2A: We are using sleep+interrupt wherever possible. */ @@ -377,7 +358,33 @@ static inline int ea_plf_init_nointerrup } # endif + +/* Polling loop, does not return until the chip is READY. + * Callers should themselves wait for tWB or other initial time + * to ensure that READY is deasserted. */ +static void wait_ready_polled(cyg_nand_device *ctx) +{ +#ifdef REPORT_POLLS + int polls=0; #endif +#ifdef CYGHWR_HAL_ARM_LPC2XXX_EA_LPC2468_NAND_RDY_USE_INTERRUPT + cyg_drv_interrupt_unmask(NAND_RDY_VECTOR); +#endif + while (0==is_chip_ready(ctx)) { + HAL_DELAY_US(POLL_INTERVAL); +#ifdef REPORT_POLLS + ++polls; +#endif + } +#ifdef CYGHWR_HAL_ARM_LPC2XXX_EA_LPC2468_NAND_RDY_USE_INTERRUPT + cyg_drv_interrupt_mask(NAND_RDY_VECTOR); +#endif +#ifdef REPORT_POLLS + NAND_CHATTER(8, ctx, "!BUSY: pollcount %d\n",polls); +#endif +} + +#endif // USE_INTERRUPT ? static int k9_plf_init(cyg_nand_device *dev) {