diff options
author | Joel Sherrill <joel.sherrill@oarcorp.com> | 2014-10-16 16:20:22 -0500 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@oarcorp.com> | 2014-10-19 17:00:57 -0500 |
commit | 0659b5dea8d237d87857163ce96893b1a7495ad1 (patch) | |
tree | 00bb70573c46d960091f5d4e7a378a3e8d40098c /c/src/lib/libbsp/powerpc/mvme5500/GT64260 | |
parent | libbsp/mips/shared: Fix warnings (diff) | |
download | rtems-0659b5dea8d237d87857163ce96893b1a7495ad1.tar.bz2 |
powerpc/mvme5500: Fix warnings
Diffstat (limited to 'c/src/lib/libbsp/powerpc/mvme5500/GT64260')
-rw-r--r-- | c/src/lib/libbsp/powerpc/mvme5500/GT64260/GT64260TWSI.c | 144 | ||||
-rw-r--r-- | c/src/lib/libbsp/powerpc/mvme5500/GT64260/MVME5500I2C.c | 52 |
2 files changed, 104 insertions, 92 deletions
diff --git a/c/src/lib/libbsp/powerpc/mvme5500/GT64260/GT64260TWSI.c b/c/src/lib/libbsp/powerpc/mvme5500/GT64260/GT64260TWSI.c index c0f34b38c7..6b5b46e511 100644 --- a/c/src/lib/libbsp/powerpc/mvme5500/GT64260/GT64260TWSI.c +++ b/c/src/lib/libbsp/powerpc/mvme5500/GT64260/GT64260TWSI.c @@ -1,5 +1,8 @@ -/* GT64260TWSI.c : Two-Wire Serial Interface (TWSI) support for the GT64260 - * +/* + * Two-Wire Serial Interface (TWSI) support for the GT64260 + */ + +/* * Copyright (c) 2004, Brookhaven National Laboratory and * Shuchen Kate Feng <feng1@bnl.gov> * All rights reserved. @@ -15,11 +18,11 @@ * * We need it to read out I2C devices used for the MVME5500 * (eg. the memory SPD and VPD). - * */ + #include <libcpu/spr.h> /*registers.h included here for rtems_bsp_delay()*/ #include <libcpu/io.h> -#include <rtems/bspIo.h> /* printk */ +#include <rtems/bspIo.h> #include "bsp/gtreg.h" #include "bsp/GT64260TWSI.h" @@ -28,44 +31,44 @@ #define TWSI_DEBUG 0 -static int TWSI_initFlg = 0; /* TWSI Initialization Flag */ +static int TWSI_initFlg = 0; /* TWSI Initialization Flag */ void GT64260TWSIinit(void) { - - if ( !TWSI_initFlg) { + if ( !TWSI_initFlg ) { #if TWSI_DEBUG - printk("GT64260TWSIinit("); + printk("GT64260TWSIinit("); #endif - outl( 0, TWSI_SFT_RST); /* soft reset */ - rtems_bsp_delay(1000); - - /* See 24.2.5 : Assume bus speed is 133MHZ - * Try to be close to the default frequency : 62.5KHZ - * value 0x2c: 69.27 KHz TWSI bus clock - */ - outl(0x2c, TWSI_BAUDE_RATE); - rtems_bsp_delay(1000); - - /* Set Acknowledge and enable TWSI in the Control register */ - outl(0x44, TWSI_CTRL); - rtems_bsp_delay(4000); - TWSI_initFlg = 1; + outl( 0, TWSI_SFT_RST); /* soft reset */ + rtems_bsp_delay(1000); + + /* See 24.2.5 : Assume bus speed is 133MHZ + * Try to be close to the default frequency : 62.5KHZ + * value 0x2c: 69.27 KHz TWSI bus clock + */ + outl(0x2c, TWSI_BAUDE_RATE); + rtems_bsp_delay(1000); + + /* Set Acknowledge and enable TWSI in the Control register */ + outl(0x44, TWSI_CTRL); + rtems_bsp_delay(4000); + TWSI_initFlg = 1; #if TWSI_DEBUG - printk(")\n"); + printk(")\n"); #endif } } /* return the interrupt flag */ -int GT64260TWSIintFlag(void) +static int GT64260TWSIintFlag(void) { unsigned int loop; for (loop = 0; loop < MAX_LOOP; loop++ ) { /* Return 1 if the interrupt flag is set */ - if (inl(TWSI_CTRL) & TWSI_INTFLG) return(1); - rtems_bsp_delay(1000); + if (inl(TWSI_CTRL) & TWSI_INTFLG) + return(1); + rtems_bsp_delay(1000); } return(0); } @@ -111,19 +114,19 @@ int GT64260TWSIstart(void) rtems_bsp_delay(1000); if (GT64260TWSIintFlag()) { - /* Check for completion of START sequence */ - for (loop = 0; loop<MAX_LOOP; loop++ ) { - /* if (start condition transmitted) || - * (repeated start condition transmitted ) - */ - if (((status= inl( TWSI_STATUS)) == 8) || (status == 0x10)) { + /* Check for completion of START sequence */ + for (loop = 0; loop<MAX_LOOP; loop++ ) { + /* if (start condition transmitted) || + * (repeated start condition transmitted ) + */ + if (((status= inl( TWSI_STATUS)) == 8) || (status == 0x10)) { #if TWSI_DEBUG - printk(")"); + printk(")"); #endif - return(0); - } - rtems_bsp_delay(1000); - } + return(0); + } + rtems_bsp_delay(1000); + } } /* if loop ends or intFlag ==0 */ GT64260TWSIstop(); @@ -142,22 +145,23 @@ int GT64260TWSIread(unsigned char * pData, int lastByte) rtems_bsp_delay(1000); if (GT64260TWSIintFlag()) { - for (loop = 0; loop< MAX_LOOP; loop++) { - /* if Master received read data, acknowledge transmitted */ - if ( (inl( TWSI_STATUS) == 0x50)) { - *pData = (unsigned char) inl( TWSI_DATA); - rtems_bsp_delay(1500); - - /* Clear INTFLAG and set Enable bit only */ - if (lastByte) outl(TWSI_TWSIEN, TWSI_CTRL); - rtems_bsp_delay(1500); + for (loop = 0; loop< MAX_LOOP; loop++) { + /* if Master received read data, acknowledge transmitted */ + if ( (inl( TWSI_STATUS) == 0x50)) { + *pData = (unsigned char) inl( TWSI_DATA); + rtems_bsp_delay(1500); + + /* Clear INTFLAG and set Enable bit only */ + if (lastByte) + outl(TWSI_TWSIEN, TWSI_CTRL); + rtems_bsp_delay(1500); #if TWSI_DEBUG - printk(")\n"); + printk(")\n"); #endif - return(0); - } - rtems_bsp_delay(1000); - } /* end for */ + return(0); + } + rtems_bsp_delay(1000); + } /* end for */ } /* if loop ends or intFlag ==0 */ GT64260TWSIstop(); @@ -182,27 +186,27 @@ int GT64260TWSIwrite(unsigned char Data) rtems_bsp_delay(1000); if (GT64260TWSIintFlag() ) { - for (loop = 0; loop< MAX_LOOP; loop++) { - rtems_bsp_delay(1000); - /* if address + write bit transmitted, acknowledge not received */ - if ( (status = inl( TWSI_STATUS)) == 0x20) { - /* No device responding, generate STOP and return -1 */ - printk("no device responding\n"); - GT64260TWSIstop(); - return(-1); - } - /* if (address + write bit transmitted, acknowledge received) - * (Master transmmitted data byte, acknowledge received) - * (address + read bit transmitted, acknowledge received) - */ - if ((status == 0x18)||(status == 0x28)||(status == 0x40)) { + for (loop = 0; loop< MAX_LOOP; loop++) { + rtems_bsp_delay(1000); + /* if address + write bit transmitted, acknowledge not received */ + if ( (status = inl( TWSI_STATUS)) == 0x20) { + /* No device responding, generate STOP and return -1 */ + printk("no device responding\n"); + GT64260TWSIstop(); + return(-1); + } + /* if (address + write bit transmitted, acknowledge received) + * (Master transmmitted data byte, acknowledge received) + * (address + read bit transmitted, acknowledge received) + */ + if ((status == 0x18)||(status == 0x28)||(status == 0x40)) { #if TWSI_DEBUG - printk(")\n"); + printk(")\n"); #endif - return(0); - } - rtems_bsp_delay(1000); - } /* end for */ + return(0); + } + rtems_bsp_delay(1000); + } /* end for */ } printk("No correct status, timeout\n"); GT64260TWSIstop(); diff --git a/c/src/lib/libbsp/powerpc/mvme5500/GT64260/MVME5500I2C.c b/c/src/lib/libbsp/powerpc/mvme5500/GT64260/MVME5500I2C.c index 382425ea35..107b8f15cb 100644 --- a/c/src/lib/libbsp/powerpc/mvme5500/GT64260/MVME5500I2C.c +++ b/c/src/lib/libbsp/powerpc/mvme5500/GT64260/MVME5500I2C.c @@ -1,16 +1,18 @@ -/* MVME5500I2C.c - * +/* + * To read information of the EEPROM via the I2C + */ + +/* * Copyright (c) 2003, 2004 Brookhaven National Laboratory * Author: S. Kate Feng <feng1@bnl.gov> * All rights reserved. * * The license and distribution terms for this file may be * found in the file LICENSE in this distribution. - * - * To read information of the EEPROM via the I2C */ -#include <rtems/bspIo.h> /* printk */ +#include <bsp.h> +#include <rtems/bspIo.h> /* printk */ #include <stdint.h> /* uint32_t */ #include "bsp/GT64260TWSI.h" @@ -28,28 +30,34 @@ static unsigned char I2cDevByteAddr(uint32_t devA2A1A0, unsigned char byteNum) /**************************************************************************** * I2Cread_eeprom - read EEPROM VPD from the I2C */ -int I2Cread_eeprom(unsigned char I2cBusAddr,uint32_t devA2A1A0,uint32_t AddrBytes,unsigned char *pBuff,uint32_t numBytes) +int I2Cread_eeprom( + unsigned char I2cBusAddr, + uint32_t devA2A1A0, + uint32_t AddrBytes, + unsigned char *pBuff, + uint32_t numBytes +) { int status=0, lastByte=0; switch (AddrBytes) { case 1: if ((status=GT64260TWSIstart()) != -1) { - if ((status=GT64260TWSIwrite(I2cAddrPack(I2cBusAddr,devA2A1A0)))!= -1){ - if ((status=GT64260TWSIwrite(devA2A1A0))!=-1){ - if ((status=GT64260TWSIstart())!=-1) - status=GT64260TWSIwrite(I2cAddrPack((I2cBusAddr|0x01),devA2A1A0)); - } + if ((status=GT64260TWSIwrite(I2cAddrPack(I2cBusAddr,devA2A1A0)))!= -1){ + if ((status=GT64260TWSIwrite(devA2A1A0))!=-1){ + if ((status=GT64260TWSIstart())!=-1) + status=GT64260TWSIwrite(I2cAddrPack((I2cBusAddr|0x01),devA2A1A0)); + } } } break; case 2: if ((status=GT64260TWSIstart())!=-1) { - if ((status=GT64260TWSIwrite(I2cBusAddr))!= -1) { - if ((status=GT64260TWSIwrite(I2cDevByteAddr(devA2A1A0,1)))!=-1) { - if ((status=GT64260TWSIwrite(I2cDevByteAddr(devA2A1A0,0)))!= -1){ - if ((status=GT64260TWSIstart()) != -1) { - status = GT64260TWSIwrite((I2cBusAddr | 0x01)); + if ((status=GT64260TWSIwrite(I2cBusAddr))!= -1) { + if ((status=GT64260TWSIwrite(I2cDevByteAddr(devA2A1A0,1)))!=-1) { + if ((status=GT64260TWSIwrite(I2cDevByteAddr(devA2A1A0,0)))!= -1){ + if ((status=GT64260TWSIstart()) != -1) { + status = GT64260TWSIwrite((I2cBusAddr | 0x01)); } } } @@ -58,12 +66,12 @@ int I2Cread_eeprom(unsigned char I2cBusAddr,uint32_t devA2A1A0,uint32_t AddrByte break; case 3: if ((status = GT64260TWSIstart())!= -1) { - if ((status = GT64260TWSIwrite(I2cBusAddr))!= -1) { - if ((status=GT64260TWSIwrite(I2cDevByteAddr(devA2A1A0,2)))!= -1){ - if ((status=GT64260TWSIwrite(I2cDevByteAddr(devA2A1A0,1)))!= -1){ - if ((status=GT64260TWSIwrite(I2cDevByteAddr(devA2A1A0,0)))!= -1){ - if ((status=GT64260TWSIstart())!= -1) { - status = GT64260TWSIwrite(I2cBusAddr | 0x01); + if ((status = GT64260TWSIwrite(I2cBusAddr))!= -1) { + if ((status=GT64260TWSIwrite(I2cDevByteAddr(devA2A1A0,2)))!= -1){ + if ((status=GT64260TWSIwrite(I2cDevByteAddr(devA2A1A0,1)))!= -1){ + if ((status=GT64260TWSIwrite(I2cDevByteAddr(devA2A1A0,0)))!= -1){ + if ((status=GT64260TWSIstart())!= -1) { + status = GT64260TWSIwrite(I2cBusAddr | 0x01); } } } |