/******************************************************************************* NAME $RCSfile: i2cBS.c,v $ SUMMARY I2C/SMBus Board Stress Test VERSION $Revision: 1.4 $ UPDATE DATE $Date: 2009/09/18 08:13:39 $ PROGRAMMER $Author: cloud $ Copyright 2009 LSI Corporation. All Rights Reserved. DESCRIPTION: REFERENCE: *******************************************************************************/ #include #include #include #include #include #include #include #include #include #include #include "i2cDiag.h" static struct task_struct *zebulonTask = NULL; static struct task_struct *pchTask = NULL; static int i2cBsZebulon( void *unused ) { int ret; printk( "Stressing SBB/MB/HIC VPDs, SAS EEPROMs, and Sensor on Zebulon I2C buses\n" ); while( !kthread_should_stop() ) { // SBB VPDs & PCA9548 ret = i2cZebulonBusLineTest(); if( ret ) { printk( "%s: Zebulon Bus Line Stress Failed(%d)\n", __func__, ret ); break; } // Test all channels ret = i2cSwitchChannLineTest(); if( ret ) { printk( "%s: Zebulon/MUX Bus Line Stress Failed(%d)\n", __func__, ret ); break; } } /* clear up task handle */ zebulonTask = NULL; return (0); } static int i2cBsPCH(void *unused) { struct i2c_client *ck420, *db1201; int ret; // CK420 ck420 = getI2cDevClient( CK420_NAME, CK420_ADDR, PCH_I2C_BUS_0 ); if( !ck420 ) { printk( "%s: cannot get CK420 device\n", __func__ ); return -ENODEV; } // DB1201 db1201 = getI2cDevClient( DB1201_NAME, DB1201_ADDR, PCH_I2C_BUS_0 ); if( !db1201 ) { printk( "%s: cannot get DB1201 device\n", __func__ ); return -ENODEV; } // Stress Loop printk( "Stressing CK420 & DB1201 devies on the PCH I2C Bus\n" ); while( !kthread_should_stop() ) { ret = i2c_smbus_read_byte_data( ck420, 0x07 ); if( ret < 0 ) { printk( "Read CK505/CK420 Failed(%d)\n", ret ); break; } ret = i2c_smbus_read_byte_data( db1201, 0x00 ); if( ret < 0 ) { printk( "Read DB1201 Failed(%d)\n", ret ); break; } } /* clear up task handle */ pchTask = NULL; return 0; } /******************************************************************************* * PROCEDURE * * NAME: i2cBsZebulonStart * SUMMARY: Start I2C/SMBus traffic on FPGA Zebulon master * * SCOPE: Public * * DESCRIPTION: * * RETURNS: * * NOTES: * */ int i2cBsZebulonStart( void ) { if( zebulonTask ) { printk( "zebulon I2C task is running\n" ); return -EINVAL; } zebulonTask = kthread_run( i2cBsZebulon, NULL, "i2cZebulon" ); if( IS_ERR( zebulonTask ) ) { printk( "Create I2C Zebulon BS Task Failed\n" ); return -EFAULT; } return 0; } /******************************************************************************* * PROCEDURE * * NAME: i2cBsPCHStart * SUMMARY: Start I2C/SMBus traffic on Intel Ibex-Peak master * * SCOPE: Public * * DESCRIPTION: * * RETURNS: * * NOTES: * */ int i2cBsPCHStart( void ) { if( pchTask ) { printk( "PCH I2C task is running\n" ); return -EINVAL; } pchTask = kthread_run( i2cBsPCH, NULL, "i2cPCH" ); if( IS_ERR( pchTask ) ) { printk( "Create I2C PCH BS Task Failed\n" ); return -EFAULT; } return 0; } void i2cBsZebulonStop( void ) { if ( zebulonTask ) kthread_stop( zebulonTask ); } void i2cBsPCHStop( void ) { if( pchTask ) kthread_stop( pchTask ); } MODULE_AUTHOR( "merck.hung@netapp.com" ); MODULE_DESCRIPTION( "NetApp I2C Stress Code" ); MODULE_LICENSE( "GPL" ); MODULE_VERSION( "0.1" );