Micron MT29F NAND driver
void __build_cycle_addr ( nand_addr_t  addr,
MT_uint8 addr_cycle_stream 
)

Definition at line 2098 of file nand_MT29F_lld.c.

References nand_address_t::block, BLOCK, BUILD_ADDR_ROW, COL, nand_address_t::column, device_info, LOW, nand_address_t::lun, LUN, nand_address_t::page, PAGE, and parameter_page_t::pages_per_block.

                                                                       {
   #define LOW          0
   #define HIGH         1

   /* extract n-th bit from a value */
   #define CHECK_BIT(val, n) ((val & (1 << n)) >> n)

   /* extract from column address */
   #define COL(n)          CHECK_BIT(addr.column, n)

   /* extract from page address */
   #define PAGE(n)      CHECK_BIT(addr.page, n)

   /* extract from block address */
   #define BLOCK(n)     CHECK_BIT(addr.block, n)

   /* extract from lun number */
   #define LUN(n)          CHECK_BIT(addr.lun, n)

   /* build a single row of address cycle */
   #define BUILD_ADDR_ROW(i_07, i_06, i_05, i_04, i_03, i_02, i_01, i_00) (\
       ((i_07) << 7) \
      | ((i_06) << 6) \
      | ((i_05) << 5) \
      | ((i_04) << 4) \
      | ((i_03) << 3) \
      | ((i_02) << 2) \
      | ((i_01) << 1) \
      | ((i_00) << 0) \
   );

   int cycle;

   /* build the address cycle stream (64 pages per block) */
   if (64 == device_info.pages_per_block) {

      /* Col 1 - I cycle */
      addr_cycle_stream[0] =
            (MT_uint8) BUILD_ADDR_ROW(COL(7), COL(6), COL(5), COL(4), COL(3), COL(2), COL(1), COL(0));

      /* Col 2 - II cycle */
      addr_cycle_stream[1] =
            (MT_uint8) BUILD_ADDR_ROW(LOW, LOW, COL(13), COL(12), COL(11), COL(10),COL(9),COL(8));

      /* Row 1 - III cycle */
      addr_cycle_stream[2] =
            (MT_uint8) BUILD_ADDR_ROW(BLOCK(1), BLOCK(0), PAGE(5), PAGE(4), PAGE(3), PAGE(2), PAGE(1), PAGE(0));

      /* Row 2 - IV cycle */
      addr_cycle_stream[3] =
            (MT_uint8) BUILD_ADDR_ROW(BLOCK(9), BLOCK(8), BLOCK(7), BLOCK(6), BLOCK(5), BLOCK(4), BLOCK(3), BLOCK(2));

      /* Row 3 - V cycle */
      addr_cycle_stream[4] =
            (MT_uint8) BUILD_ADDR_ROW(LOW, LOW, LOW, LOW, LUN(0), BLOCK(12), BLOCK(11), BLOCK(10));

   }

   /* build the address cycle stream (128 pages per block) */
   if (128 == device_info.pages_per_block) {

      /* Col 1 - I cycle */
      addr_cycle_stream[0] =
            (MT_uint8) BUILD_ADDR_ROW(COL(7), COL(6), COL(5), COL(4), COL(3), COL(2), COL(1), COL(0));

      /* Col 2 - II cycle */
      addr_cycle_stream[1] =
            (MT_uint8) BUILD_ADDR_ROW(LOW, LOW, COL(13), COL(12), COL(11), COL(10),COL(9),COL(8));

      /* Row 1 - III cycle */
      addr_cycle_stream[2] =
            (MT_uint8) BUILD_ADDR_ROW(BLOCK(0), PAGE(6), PAGE(5), PAGE(4), PAGE(3), PAGE(2), PAGE(1), PAGE(0));

      /* Row 2 - IV cycle */
      addr_cycle_stream[3] =
            (MT_uint8) BUILD_ADDR_ROW(BLOCK(8), BLOCK(7), BLOCK(6), BLOCK(5), BLOCK(4), BLOCK(3), BLOCK(2), BLOCK(1));

      /* Row 3 - V cycle */
      addr_cycle_stream[4] =
            (MT_uint8) BUILD_ADDR_ROW(LOW, LOW, LOW, LOW, LUN(0), BLOCK(11), BLOCK(10), BLOCK(9));

   }

   #ifdef DEBUG_PRINT_ADDRESS
   printf("DEBUG: addr: LUN=%x, BLOCK=%x, PAGE=%x, COL=%x\n", \
         addr.lun, addr.block, addr.page, addr.column);
   printf("DEBUG: addr_cycl = I=%x II=%x III=%x IV=%x V=%x\n", \
         addr_cycle_stream[0], addr_cycle_stream[1], addr_cycle_stream[2], addr_cycle_stream[3], addr_cycle_stream[4]);
   #endif
}