cardid.c
925 Bytes
#include <ultra64.h>
#include "bcp.h"
#include "bbnand.h"
#include "bbfs.h"
#include "os_bbcard.h"
#include "bbint.h"
#include "piint.h"
#define VERBOSE(x)
s32
osBbCardReadId(u32 dev, u32 *mfg, u32* type) {
u32 status;
s32 rv;
if ((rv = __osBbCardGetAccess()) < 0) return rv;
IO_WRITE(PI_FLASH_ADDR_REG, 0);
IO_WRITE(PI_FLASH_CTRL_REG, PI_FLASH_CTRL_START |
PI_FLASH_CTRL_INTR |
PI_FLASH_CTRL_RDPH |
(1 << PI_FLASH_CTRL_ADPH_SHIFT) |
(NAND_CMD_READ_ID << PI_FLASH_CTRL_CMD_SHIFT) |
PI_FLASH_CTRL_BUF0 |
(dev << PI_FLASH_CTRL_DEV_SHIFT) |
(4 << PI_FLASH_CTRL_SIZE_SHIFT) );
rv = __osBbCardWaitEvent();
status = IO_READ(PI_BUFFER_BASE_REG);
*mfg = (status>>24)&0xff; *type = (status >> 16)&0xff;
#define NAND_ID_MULTIPLANE 0xc0
__osBbCardMultiplane = (status&0xff) == NAND_ID_MULTIPLANE;
__osBbCardRelAccess();
return rv;
}