Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 10 Jan 2007 06:54:52 GMT
From:      Warner Losh <imp@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 112699 for review
Message-ID:  <200701100654.l0A6sqfW065675@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=112699

Change 112699 by imp@imp_lighthouse on 2007/01/10 06:54:10

	MF FreeBSD-tsc-6: for flash writes, we have to wait until
	the device can handle the next write before starting it.

Affected files ...

.. //depot/projects/arm/src/sys/dev/flash/at45d.c#12 edit

Differences ...

==== //depot/projects/arm/src/sys/dev/flash/at45d.c#12 (text+ko) ====

@@ -77,94 +77,6 @@
 #define PROGRAM_THROUGH_BUFFER		0x82
 #define MANUFACTURER_ID			0x9F
 
-#if 0
-
-/*************************** GLOBAL FUNCTIONS ********************************/
-
-
-/*
- * .KB_C_FN_DEFINITION_START
- * void SPI_ReadFlash(unsigned flash_addr, unsigned dest_addr, unsigned size)
- *  Global function to read the SPI flash device using the continuous read
- * array command.
- * .KB_C_FN_DEFINITION_END
- */
-void
-SPI_ReadFlash(unsigned flash_addr, char *dest_addr, unsigned size)
-{
-	unsigned	pageAddress, byteAddress;
-
-	// determine page address
-	pageAddress = flash_addr / FLASH_PAGE_SIZE;
-
-	// determine byte address
-	byteAddress = flash_addr % FLASH_PAGE_SIZE;
-
-	p_memset(tx_commandBuffer, 0, 8);
-	tx_commandBuffer[0] = CONTINUOUS_ARRAY_READ_HF;
-	tx_commandBuffer[1] = ((pageAddress >> 5) & 0xFF);
-	tx_commandBuffer[2] = ((pageAddress << 3) & 0xF8) |
-				((byteAddress >> 8) & 0x7);
-	tx_commandBuffer[3] = byteAddress & 0xFF;
-	spi_command.tx_cmd = tx_commandBuffer;
-	spi_command.tx_cmd_size = 5;
-	spi_command.tx_data_size = size;
-	spi_command.tx_data = dest_addr;
-
-	p_memset(rx_commandBuffer, 0, 8);
-	spi_command.rx_cmd = rx_commandBuffer;
-	spi_command.rx_cmd_size = 5;
-	spi_command.rx_data_size = size;
-	spi_command.rx_data = dest_addr;
-
-	SendCommand(&spi_command);
-}
-
-
-/*
- * .KB_C_FN_DEFINITION_START
- * void SPI_WriteFlash(unsigned flash_addr, unsigned src_addr, unsigned size)
- *  Global function to program the SPI flash device.  Notice the warning
- * provided in lower-level functions regarding corruption of data in non-
- * page aligned write operations.
- * .KB_C_FN_DEFINITION_END
- */
-void
-SPI_WriteFlash(unsigned flash_addr, char *src_addr, unsigned size)
-{
-	unsigned	pageAddress, byteAddress;
-
-	// determine page address
-	pageAddress = flash_addr / FLASH_PAGE_SIZE;
-
-	// determine byte address
-	byteAddress = flash_addr % FLASH_PAGE_SIZE;
-
-	p_memset(tx_commandBuffer, 0, 8);
-	tx_commandBuffer[0] = PROGRAM_THROUGH_BUFFER;
-	tx_commandBuffer[1] = ((pageAddress >> 5) & 0xFF);
-	tx_commandBuffer[2] = ((pageAddress << 3) & 0xF8) |
-				((byteAddress >> 8) & 0x7);
-	tx_commandBuffer[3] = (byteAddress & 0xFF);
-
-	p_memset(rx_commandBuffer, 0, 8);
-
-	spi_command.tx_cmd = tx_commandBuffer;
-	spi_command.rx_cmd = rx_commandBuffer;
-	spi_command.rx_cmd_size = 4;
-	spi_command.tx_cmd_size = 4;
-
-	spi_command.tx_data_size = size;
-	spi_command.tx_data = src_addr;
-	spi_command.rx_data_size = size;
-	spi_command.rx_data = src_addr;
-
-	SendCommand(&spi_command);
-
-	WaitForDeviceReady();
-}
-#endif
-
 static uint8_t
 at45d_get_status(device_t dev)
 {
@@ -255,9 +167,7 @@
 	uint8_t buf[4];
 	
 	at45d_get_mfg_info(sc->dev, buf);
-//	printf("Reply is %#x %#x %#x %#x\n", buf[0], buf[1], buf[2], buf[3]);
 	at45d_wait_for_device_ready(sc->dev);
-//	printf("Status is %#x\n", at45d_get_status(sc->dev));
 
 	sc->disk = disk_alloc();
 	sc->disk->d_open = at45d_open;
@@ -349,6 +259,8 @@
 			cmd.rx_data_sz = sz;
 			err = SPIBUS_TRANSFER(pdev, dev, &cmd);
 			// XXX err check?
+			if (bp->bio_cmd != BIO_READ)
+				at45d_wait_for_device_ready(dev);
 		}
 		biodone(bp);
 	}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200701100654.l0A6sqfW065675>