os/kernelhwsrv/kernel/eka/include/drivers/iic_channel.inl
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kernel/eka/include/drivers/iic_channel.inl	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,223 @@
     1.4 +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of the License "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// e32/include/iic_channel.inl
    1.18 +// Channel
    1.19 +//
    1.20 +// WARNING: This file contains some APIs which are internal and are subject
    1.21 +//          to change without noticed. Such APIs should therefore not be used
    1.22 +//          outside the Kernel and Hardware Services package.
    1.23 +//
    1.24 +
    1.25 +inline DIicBusChannel::DIicBusChannel(TChannelType aChanType, TBusType aBusType, TChannelDuplex aChanDuplex)
    1.26 +	{
    1.27 +	__KTRACE_OPT(KIIC, Kern::Printf("DIicBusChannel::DIicBusChannel, aChanType=%d, aBusType=%d, aChanDuplex=%d\n",aChanType,aBusType,aChanDuplex));
    1.28 +
    1.29 +	// Arbitary ...
    1.30 +	iFlags=(TUint8)((aChanType&KChannelTypeMask) | ((aBusType<<KBusTypeShift)&KBusTypeMask) | ((aChanDuplex<<KChannelDuplexShift)&(KChannelDuplexMask)));
    1.31 +	}
    1.32 +
    1.33 +inline DIicBusChannel::TChannelType DIicBusChannel::ChannelType() 
    1.34 +	{return((TChannelType)(iFlags&KChannelTypeMask));}
    1.35 +
    1.36 +inline void DIicBusChannel::SetChannelType(TChannelType aChanType) 
    1.37 +	{
    1.38 +	iFlags &= ~KChannelTypeMask;
    1.39 +	iFlags |= (aChanType & KChannelTypeMask);
    1.40 +	};
    1.41 +
    1.42 +inline DIicBusChannel::TBusType DIicBusChannel::BusType() 
    1.43 +	{return((TBusType)((iFlags & KBusTypeMask) >> KBusTypeShift));};
    1.44 +
    1.45 +inline void DIicBusChannel::SetBusType(TBusType aBusType) 
    1.46 +	{
    1.47 +	iFlags &= ~KBusTypeMask;
    1.48 +	iFlags |= ((aBusType << KBusTypeShift) & KBusTypeMask);
    1.49 +	};
    1.50 +
    1.51 +inline DIicBusChannel::TChannelDuplex DIicBusChannel::ChannelDuplex() 
    1.52 +	{return((TChannelDuplex)((iFlags & KChannelDuplexMask) >> KChannelDuplexShift));};
    1.53 +
    1.54 +inline void DIicBusChannel::SetChannelType(TChannelDuplex aChanDuplex) 
    1.55 +	{
    1.56 +	iFlags &= ~KChannelDuplexMask;
    1.57 +	iFlags |= ((aChanDuplex << KChannelDuplexShift) & KChannelDuplexMask);
    1.58 +	};
    1.59 +
    1.60 +inline TInt8 DIicBusChannel::ChannelNumber() const 
    1.61 +	{return iChannelNumber;};
    1.62 +
    1.63 +//
    1.64 +//		Master Channel
    1.65 +//
    1.66 +
    1.67 +
    1.68 +// Methods to make private data of TIicBusTransfer object accessible to derivatives of this class
    1.69 +inline TIicBusTransfer* DIicBusChannelMaster::GetTferNextTfer(const TIicBusTransfer* aTransfer) 
    1.70 +	{return aTransfer->iNext;};
    1.71 +
    1.72 +inline TInt8 DIicBusChannelMaster::GetTferType(const TIicBusTransfer* aTransfer) 
    1.73 +	{return aTransfer->iType;};
    1.74 +
    1.75 +inline TInt8 DIicBusChannelMaster::GetTferBufGranularity(const TIicBusTransfer* aTransfer) 
    1.76 +	{return aTransfer->iBufGranularity;};
    1.77 +
    1.78 +inline const TDes8* DIicBusChannelMaster::GetTferBuffer(const TIicBusTransfer* aTransfer) 
    1.79 +	{return aTransfer->iBuffer;};
    1.80 +
    1.81 +// Methods to make private data of TIicBusTransaction object accessible to derivatives of this class
    1.82 +inline TDes8* DIicBusChannelMaster::GetTransactionHeader(const TIicBusTransaction* aTransaction) 
    1.83 +	{return aTransaction->iHeader;};
    1.84 +
    1.85 +inline TIicBusTransfer* DIicBusChannelMaster::GetTransHalfDuplexTferPtr(const TIicBusTransaction* aTransaction)
    1.86 +	{return aTransaction->iHalfDuplexTrans;};
    1.87 +
    1.88 +inline TIicBusTransfer* DIicBusChannelMaster::GetTransFullDuplexTferPtr(const TIicBusTransaction* aTransaction) 
    1.89 +	{return aTransaction->iFullDuplexTrans;};
    1.90 +
    1.91 +inline TIicBusCallback* DIicBusChannelMaster::GetTransCallback(const TIicBusTransaction* aTransaction) 
    1.92 +	{return aTransaction->iCallback;};
    1.93 +
    1.94 +inline TUint8 DIicBusChannelMaster::GetTransFlags(const TIicBusTransaction* aTransaction) 
    1.95 +	{return aTransaction->iFlags;};
    1.96 +
    1.97 +
    1.98 +// Methods to make private data of TIicBusTransactionPreamble object accessible to derivatives of this class
    1.99 +inline TIicBusPreamble  DIicBusChannelMaster::GetPreambleFuncPtr(const TIicBusTransactionPreamble* aTransfer)
   1.100 +	{return aTransfer->iPreamble;};
   1.101 +
   1.102 +inline TAny* DIicBusChannelMaster::GetPreambleFuncArg(const TIicBusTransactionPreamble* aTransfer)
   1.103 +	{return aTransfer->iPreambleArg;};
   1.104 +
   1.105 +inline TIicBusMultiTranscCbFn  DIicBusChannelMaster::GetMultiTranscFuncPtr(const TIicBusTransactionMultiTransc* aTransfer)
   1.106 +	{return aTransfer->iMultiTransc;};
   1.107 +
   1.108 +inline TAny* DIicBusChannelMaster::GetMultiTranscFuncArg(const TIicBusTransactionMultiTransc* aTransfer)
   1.109 +	{return aTransfer->iMultiTranscArg;};
   1.110 +
   1.111 +inline TIicBusMultiTranscCbFn  DIicBusChannelMaster::GetExtTranscFuncPtr(const TIicBusTransactionPreambleExt* aTransfer)
   1.112 +	{return aTransfer->iMultiTransc;};
   1.113 +
   1.114 +inline TAny* DIicBusChannelMaster::GetExtTranscFuncArg(const TIicBusTransactionPreambleExt* aTransfer)
   1.115 +	{return aTransfer->iMultiTranscArg;};
   1.116 +
   1.117 +inline TInt8 DIicBusChannelSlave::GetMasterWaitTime() 
   1.118 +	{return iMasterWaitTime;}
   1.119 +
   1.120 +inline TInt8 DIicBusChannelSlave::GetClientWaitTime() 
   1.121 +	{return iClientWaitTime;};
   1.122 +
   1.123 +#ifndef STANDALONE_CHANNEL
   1.124 +inline DIicBusChannelMasterSlave::DIicBusChannelMasterSlave(TBusType aBusType, TChannelDuplex aChanDuplex, DIicBusChannelMaster* aMasterChan, DIicBusChannelSlave* aSlaveChan)
   1.125 +	: DIicBusChannel(DIicBusChannel::EMasterSlave, aBusType, aChanDuplex),
   1.126 +	iMasterChannel(aMasterChan),
   1.127 +	iSlaveChannel(aSlaveChan)
   1.128 +	{
   1.129 +	//If in stand-alone channel mode, the client assigns a channel number to the MasterSlave channel it creates. 
   1.130 +	__ASSERT_ALWAYS(iMasterChannel->iChannelNumber == iSlaveChannel->iChannelNumber,Kern::Fault("MasterSlave channel number ambiguity",0));	
   1.131 +	iChannelNumber = iMasterChannel->iChannelNumber;
   1.132 +	}
   1.133 +#endif
   1.134 +
   1.135 +inline TInt DIicBusChannelMasterSlave::DoCreate()
   1.136 +	{
   1.137 +	__ASSERT_ALWAYS(iMasterChannel && iSlaveChannel,Kern::Fault("MasterSlave channel not properly initialised",0));
   1.138 +	TInt r=iMasterChannel->DoCreate();
   1.139 +	if(r == KErrNone)
   1.140 +		r=iSlaveChannel->DoCreate();
   1.141 +	return r;
   1.142 +	}
   1.143 +
   1.144 +inline TInt DIicBusChannelMasterSlave::CancelTransaction(TIicBusTransaction* aTransaction)
   1.145 +	{return(iMasterChannel->CancelTransaction(aTransaction));}
   1.146 +
   1.147 +inline TInt DIicBusChannelMasterSlave::RegisterRxBuffer(TPtr8 aRxBuffer, TInt8 aBufGranularity, TInt8 aNumWords, TInt8 aOffset)
   1.148 +	{return(iSlaveChannel->RegisterRxBuffer(aRxBuffer, aBufGranularity, aNumWords, aOffset));}
   1.149 +
   1.150 +inline TInt DIicBusChannelMasterSlave::RegisterTxBuffer(TPtr8 aTxBuffer, TInt8 aBufGranularity, TInt8 aNumWords, TInt8 aOffset)
   1.151 +	{return(iSlaveChannel->RegisterTxBuffer(aTxBuffer, aBufGranularity, aNumWords, aOffset));}
   1.152 +
   1.153 +inline TInt DIicBusChannelMasterSlave::SetNotificationTrigger(TInt aTrigger)
   1.154 +	{return(iSlaveChannel->SetNotificationTrigger(aTrigger));}
   1.155 +
   1.156 +#ifdef _DEBUG
   1.157 +inline void DIicBusChannel::DumpChannel()
   1.158 +	{
   1.159 +	__KTRACE_OPT(KIIC, Kern::Printf("\n"));	// start
   1.160 +	switch((TInt)ChannelType())
   1.161 +		{
   1.162 +		case(EMaster):
   1.163 +			{
   1.164 +			__KTRACE_OPT(KIIC, Kern::Printf("ChannelType = EMaster\n"));
   1.165 +			break;
   1.166 +			}
   1.167 +		case(ESlave):
   1.168 +			{
   1.169 +			__KTRACE_OPT(KIIC, Kern::Printf("ChannelType = ESlave\n"));
   1.170 +			break;
   1.171 +			}
   1.172 +		case(EMasterSlave):
   1.173 +			{
   1.174 +			__KTRACE_OPT(KIIC, Kern::Printf("ChannelType = EMasterSlave\n"));
   1.175 +			break;
   1.176 +			}
   1.177 +		default:
   1.178 +			__KTRACE_OPT(KIIC, Kern::Printf("ChannelType %d is not recognised \n",((TInt)ChannelType())));
   1.179 +		}
   1.180 +	switch((TInt)BusType())
   1.181 +		{
   1.182 +		case(EI2c):
   1.183 +			{
   1.184 +			__KTRACE_OPT(KIIC, Kern::Printf("BusType = EI2c\n"));
   1.185 +			break;
   1.186 +			}
   1.187 +		case(ESpi):
   1.188 +			{
   1.189 +			__KTRACE_OPT(KIIC, Kern::Printf("BusType = ESpi\n"));
   1.190 +			break;
   1.191 +			}
   1.192 +		case(EMicrowire):
   1.193 +			{
   1.194 +			__KTRACE_OPT(KIIC, Kern::Printf("BusType = EMicrowire\n"));
   1.195 +			break;
   1.196 +			}
   1.197 +		case(ECci):
   1.198 +			{
   1.199 +			__KTRACE_OPT(KIIC, Kern::Printf("BusType = ECci\n"));
   1.200 +			break;
   1.201 +			}
   1.202 +		case(ESccb):
   1.203 +			{
   1.204 +			__KTRACE_OPT(KIIC, Kern::Printf("BusType = ESccb\n"));
   1.205 +			break;
   1.206 +			}
   1.207 +		default:
   1.208 +			__KTRACE_OPT(KIIC, Kern::Printf("BusType %d is not recognised \n",((TInt)BusType())));
   1.209 +		}
   1.210 +	switch((TInt)ChannelDuplex())
   1.211 +		{
   1.212 +		case(EHalfDuplex):
   1.213 +			{
   1.214 +			__KTRACE_OPT(KIIC, Kern::Printf("ChannelDuplex = EHalfDuplex\n"));
   1.215 +			break;
   1.216 +			}
   1.217 +		case(EFullDuplex):
   1.218 +			{
   1.219 +			__KTRACE_OPT(KIIC, Kern::Printf("ChannelDuplex = EFullDuplex\n"));
   1.220 +			break;
   1.221 +			}
   1.222 +		default:
   1.223 +			__KTRACE_OPT(KIIC, Kern::Printf("ChannelDuplex %d is not recognised \n",((TInt)ChannelDuplex())));
   1.224 +		}
   1.225 +	}
   1.226 +#endif