Date: Tue, 18 Apr 2006 16:32:45 GMT From: Warner Losh <imp@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 95498 for review Message-ID: <200604181632.k3IGWjb1014192@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=95498 Change 95498 by imp@imp_hammer on 2006/04/18 16:32:20 Move Affected files ... .. //depot/projects/arm/src/sys/boot/arm/at91/bootiic/Makefile#7 edit .. //depot/projects/arm/src/sys/boot/arm/at91/libat91/eeprom.c#2 edit .. //depot/projects/arm/src/sys/boot/arm/at91/libat91/eeprom.h#2 edit Differences ... ==== //depot/projects/arm/src/sys/boot/arm/at91/bootiic/Makefile#7 (text+ko) ==== @@ -2,7 +2,7 @@ P=bootiic FILES=${P} -SRCS=arm_init.s main.c eeprom.c \ +SRCS=arm_init.s main.c \ env_vars.c loader_prompt.c p_string.c emac.c NO_MAN= LDFLAGS=-e 0 -T linker.cfg ==== //depot/projects/arm/src/sys/boot/arm/at91/libat91/eeprom.c#2 (text+ko) ==== @@ -1,4 +1,4 @@ -/******************************************************************************* +/****************************************************************************** * * Filename: eeprom.c * @@ -17,25 +17,27 @@ * owners. This software is not copyrighted and is intended for reference * only. * END_BLOCK - ******************************************************************************/ + *****************************************************************************/ #include "at91rm9200_lowlevel.h" -#include "eeprom.h" #include "at91rm9200.h" #include "lib.h" -/* ****************************** GLOBALS *************************************/ +/******************************* GLOBALS *************************************/ -/* ********************** PRIVATE FUNCTIONS/DATA ******************************/ +/*********************** PRIVATE FUNCTIONS/DATA ******************************/ /* Use a macro to calculate the TWI clock generator value to save code space. */ +#define AT91C_TWSI_CLOCK 100000 +#define TWSI_EEPROM_ADDRESS 0x50 + #define TWI_CLK_BASE_DIV ((AT91C_MASTER_CLOCK/(4*AT91C_TWSI_CLOCK)) - 2) #define SET_TWI_CLOCK ((0x00010000) | (TWI_CLK_BASE_DIV) | (TWI_CLK_BASE_DIV << 8)) -/* ************************** GLOBAL FUNCTIONS ********************************/ +/*************************** GLOBAL FUNCTIONS ********************************/ /* @@ -78,8 +80,9 @@ * This function does not utilize the page read mode to simplify the code. * .KB_C_FN_DEFINITION_END */ -void ReadEEPROM(unsigned ee_addr, char *data_addr, unsigned size) { - +void +ReadEEPROM(unsigned ee_addr, char *data_addr, unsigned size) +{ const AT91PS_TWI twiPtr = AT91C_BASE_TWI; unsigned int status; @@ -87,7 +90,8 @@ status = twiPtr->TWI_RHR; // Set the TWI Master Mode Register - twiPtr->TWI_MMR = (TWSI_EEPROM_ADDRESS << 16) | AT91C_TWI_IADRSZ_2_BYTE | AT91C_TWI_MREAD; + twiPtr->TWI_MMR = (TWSI_EEPROM_ADDRESS << 16) | + AT91C_TWI_IADRSZ_2_BYTE | AT91C_TWI_MREAD; // Set TWI Internal Address Register twiPtr->TWI_IADR = ee_addr; @@ -100,7 +104,8 @@ while (size-- > 1){ // Wait RHR Holding register is full - while (!(twiPtr->TWI_SR & AT91C_TWI_RXRDY)); + while (!(twiPtr->TWI_SR & AT91C_TWI_RXRDY)) + continue; // Read byte *(data_addr++) = twiPtr->TWI_RHR; @@ -111,7 +116,8 @@ status = twiPtr->TWI_SR; // Wait transfer is finished - while (!(twiPtr->TWI_SR & AT91C_TWI_TXCOMP)); + while (!(twiPtr->TWI_SR & AT91C_TWI_TXCOMP)) + continue; // Read last byte *data_addr = twiPtr->TWI_RHR; @@ -128,8 +134,9 @@ * functionality. This allows the function to be much simpler. * .KB_C_FN_DEFINITION_END */ -void WriteEEPROM(unsigned ee_addr, char *data_addr, unsigned size) { - +void +WriteEEPROM(unsigned ee_addr, char *data_addr, unsigned size) +{ const AT91PS_TWI twiPtr = AT91C_BASE_TWI; unsigned status; char test_data; @@ -139,7 +146,8 @@ putchar('.'); // Set the TWI Master Mode Register - twiPtr->TWI_MMR = ((TWSI_EEPROM_ADDRESS << 16) | AT91C_TWI_IADRSZ_2_BYTE ) & ~AT91C_TWI_MREAD; + twiPtr->TWI_MMR = ((TWSI_EEPROM_ADDRESS << 16) | + AT91C_TWI_IADRSZ_2_BYTE) & ~AT91C_TWI_MREAD; // Set TWI Internal Address Register twiPtr->TWI_IADR = ee_addr++; @@ -151,14 +159,16 @@ twiPtr->TWI_CR = AT91C_TWI_START; // Wait transfer is finished - while (!(twiPtr->TWI_SR & AT91C_TWI_TXRDY)); + while (!(twiPtr->TWI_SR & AT91C_TWI_TXRDY)) + continue; twiPtr->TWI_CR = AT91C_TWI_STOP; status = twiPtr->TWI_SR; // Wait transfer is finished - while (!(twiPtr->TWI_SR & AT91C_TWI_TXCOMP)); + while (!(twiPtr->TWI_SR & AT91C_TWI_TXCOMP)) + continue; // wait for write operation to complete ReadEEPROM(ee_addr, &test_data, 1); ==== //depot/projects/arm/src/sys/boot/arm/at91/libat91/eeprom.h#2 (text+ko) ==== @@ -22,13 +22,4 @@ #ifndef _EEPROM_H_ #define _EEPROM_H_ -#define AT91C_TWSI_CLOCK 100000 -#define TWSI_EEPROM_ADDRESS 0x50 - -/* The following function write eeprom at ee_addr using data */ -/* from data_add for size bytes. */ -extern void ReadEEPROM(unsigned ee_addr, char *data_addr, unsigned size); -extern void WriteEEPROM(unsigned ee_addr, char *data_addr, unsigned size); -extern void InitEEPROM(void); - #endif /* _EEPROM_H_ */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200604181632.k3IGWjb1014192>