From owner-p4-projects@FreeBSD.ORG Wed Jan 10 06:54:53 2007 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 74A8916A492; Wed, 10 Jan 2007 06:54:53 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 3AE7B16A47B for ; Wed, 10 Jan 2007 06:54:53 +0000 (UTC) (envelope-from imp@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [69.147.83.41]) by mx1.freebsd.org (Postfix) with ESMTP id 29F6613C45A for ; Wed, 10 Jan 2007 06:54:53 +0000 (UTC) (envelope-from imp@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id l0A6srYJ065678 for ; Wed, 10 Jan 2007 06:54:53 GMT (envelope-from imp@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id l0A6sqfW065675 for perforce@freebsd.org; Wed, 10 Jan 2007 06:54:52 GMT (envelope-from imp@freebsd.org) Date: Wed, 10 Jan 2007 06:54:52 GMT Message-Id: <200701100654.l0A6sqfW065675@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to imp@freebsd.org using -f From: Warner Losh To: Perforce Change Reviews Cc: Subject: PERFORCE change 112699 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Jan 2007 06:54:53 -0000 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); }