/* * Returns JEDEC ID from SPI flash */ static ulong read_id(void){ unsigned int flashid = 0; ar7240_reg_wr_nf(AR7240_SPI_FS, 1); ar7240_reg_wr_nf(AR7240_SPI_WRITE, AR7240_SPI_CS_DIS); ar7240_spi_bit_banger(0x9F); ar7240_spi_delay_8(); ar7240_spi_delay_8(); ar7240_spi_delay_8(); ar7240_spi_delay_8(); flashid = ar7240_reg_rd(AR7240_SPI_RD_STATUS); /* * We have 3 bytes: * - manufacture ID (1b) * - product ID (2b) */ flashid = flashid >> 8; ar7240_spi_done(); return((ulong)flashid); }
static void read_id(void) { u32 rd = 0x777777; ar7240_reg_wr_nf(AR7240_SPI_WRITE, AR7240_SPI_CS_DIS); ar7240_spi_bit_banger(0x9f); ar7240_spi_delay_8(); ar7240_spi_delay_8(); ar7240_spi_delay_8(); ar7240_spi_done(); /* rd = ar7240_reg_rd(AR7240_SPI_RD_STATUS); */ rd = ar7240_reg_rd(AR7240_SPI_READ); printf("id read %#x\n", rd); }
static void ath_spi_read_id(void) { u32 rd = 0x777777; ar7240_reg_wr_nf(AR7240_SPI_WRITE, AR7240_SPI_CS_DIS); ar7240_spi_bit_banger(AR7240_SPI_CMD_RDID); ar7240_spi_delay_8(); ar7240_spi_delay_8(); ar7240_spi_delay_8(); ar7240_spi_go(); rd = ar7240_reg_rd(AR7240_SPI_RD_STATUS); printf("Flash Manuf Id 0x%x, DeviceId0 0x%x, DeviceId1 0x%x\n", (rd >> 16) & 0xff, (rd >> 8) & 0xff, (rd >> 0) & 0xff); }
static void ar7240_spi_poll(){ int rd; do { ar7240_reg_wr_nf(AR7240_SPI_WRITE, AR7240_SPI_CS_DIS); ar7240_spi_bit_banger(AR7240_SPI_CMD_RD_STATUS); ar7240_spi_delay_8(); rd = (ar7240_reg_rd(AR7240_SPI_RD_STATUS) & 1); } while(rd); }