Update contrib.
1 // Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32\drivers\pbus\pccard\epoc\pccd_socket.cpp
18 #include <pccd_socket.h>
20 DPlatPcCardSocket::DPlatPcCardSocket(TSocket aSocketNum)
24 : DPcCardSocket(aSocketNum)
28 TInt DPlatPcCardSocket::Create(const TDesC* aName)
30 // Allocate any resources.
34 __KTRACE_OPT(KPBUS1,Kern::Printf(">PlatSkt:Create"));
35 TInt r=DPcCardSocket::Create(aName);
39 // Bind to the PC card interrupts for this socket
40 iCardIReqIntId=ThePccdCntrlInterface->IntIdIReq(iSocketNumber);
41 iStatusChangeIntId=ThePccdCntrlInterface->IntIdStsC(iSocketNumber);
42 iReadyChangeIntId=ThePccdCntrlInterface->IntIdRdyC(iSocketNumber);
43 if (iCardIReqIntId!=-1)
45 r=Interrupt::Bind(iCardIReqIntId,CardIReqIsr,this);
49 if (iStatusChangeIntId!=-1)
51 r=Interrupt::Bind(iStatusChangeIntId,StatusChangeIsr,this);
55 if (iReadyChangeIntId!=-1)
57 r=Interrupt::Bind(iReadyChangeIntId,ReadyChangeIsr,this);
64 void DPlatPcCardSocket::Reset1()
70 __KTRACE_OPT(KPBUS1,Kern::Printf(">PlatSkt(%d):Rst1",iSocketNumber));
71 if (iCardIReqIntId!=-1)
72 Interrupt::Disable(iCardIReqIntId);
73 ThePccdCntrlInterface->InterfaceOff(iSocketNumber);
74 DPcCardSocket::Reset1();
77 DPccdChunkBase *DPlatPcCardSocket::NewPccdChunk(TPccdMemType aType)
79 // Create a new pc card hw chunk.
82 return PccdIfc::NewChunk(aType);
85 TInt DPlatPcCardSocket::Indicators(TSocketIndicators &anInd)
87 // Return the current state of this sockets indicators
91 ThePccdCntrlInterface->Indicators(iSocketNumber,anInd);
92 __KTRACE_OPT(KPBUS1,Kern::Printf("<PlatSkt:Indicators(C:%dV:%dW:%dB:%d)",anInd.iCardDetected,anInd.iVoltSense,anInd.iBatState,anInd.iWriteProtected));
96 void DPlatPcCardSocket::HwReset(TBool anAssert)
98 // Apply/remove h/w reset.
102 __KTRACE_OPT(KPBUS1,Kern::Printf(">PlatSkt:HwRst(%d)",anAssert));
103 ThePccdCntrlInterface->CardReset(iSocketNumber,anAssert);
106 TBool DPlatPcCardSocket::Ready(TInt aCardFunc)
108 // Return the current state of the Card Ready signal. When a function
109 // isn't specified then it always reads the Ready pin.
112 // If a function has been specified and this is in I/O mode then read from
113 // the configuration register (Pin replacement register).
114 // if (aCardFunc!=KInvalidFuncNum)
116 // if ( iStatus==ESocketReady && CardFunc(aCardFunc)->IsConfigured() )
119 // if ( ReadConfigReg(aCardFunc,KPinReplacementReg,reg) != KErrNone)
122 // return(reg&KPinRepReadyM);
125 TBool rdy=ThePccdCntrlInterface->CardReady(iSocketNumber);
126 __KTRACE_OPT(KPBUS1,Kern::Printf("<PlatSkt:Rdy-%d",(TInt)rdy));
130 TInt DPlatPcCardSocket::InterruptEnable(TPccdInt anInt, TUint aFlag)
132 // Enable the specified interrupt
141 if (iCardIReqIntId==-1)
143 if (aFlag&KPccdEvFlagReserved)
144 iIReqLevelMode=(aFlag&KPccdEvFlagIReqLevelMode);
145 TInt irqLevel=NKern::DisableAllInterrupts(); // Disable FIQs while we enable IREQ.
146 // IREQ must never be active when Vpc off. Need to check that emergency
147 // power down hasn't just happened since this removes Vpc without altering iStatus.
148 if (iState==EPBusOn && Kern::PowerGood())
149 Interrupt::Enable(iCardIReqIntId);
152 NKern::RestoreInterrupts(irqLevel);
155 case EPccdIntRdyChange:
156 if (iReadyChangeIntId!=-1)
157 Interrupt::Enable(iReadyChangeIntId);
159 case EPccdIntIndChange:
160 if (iStatusChangeIntId!=-1)
161 Interrupt::Enable(iStatusChangeIntId);
169 void DPlatPcCardSocket::InterruptDisable(TPccdInt anInt)
171 // Disable the specified event callback
178 if (iCardIReqIntId!=-1)
179 Interrupt::Disable(iCardIReqIntId);
181 case EPccdIntRdyChange:
182 if (iReadyChangeIntId!=-1)
183 Interrupt::Disable(iReadyChangeIntId);
185 case EPccdIntIndChange:
186 if (iStatusChangeIntId!=-1)
187 Interrupt::Disable(iStatusChangeIntId);
195 void DPlatPcCardSocket::SocketInfo(TPcCardSocketInfo& anInfo)
197 // Return machine info relating to a particular Pc Card socket
201 ThePccdCntrlInterface->SocketInfo(iSocketNumber,anInfo);
204 TBool DPlatPcCardSocket::CardIsPresent()
207 return ThePccdCntrlInterface->CardIsPresent(iSocketNumber);
210 void DPlatPcCardSocket::CardIReqIsr(TAny* aPtr)
212 DPlatPcCardSocket* pS=(DPlatPcCardSocket*)aPtr;
213 if (pS->iIReqLevelMode)
215 pS->Isr(EPccdIntIReq);
216 Interrupt::Clear(pS->iCardIReqIntId);
220 Interrupt::Clear(pS->iCardIReqIntId);
221 pS->Isr(EPccdIntIReq);
225 void DPlatPcCardSocket::ReadyChangeIsr(TAny* aPtr)
227 DPlatPcCardSocket* pS=(DPlatPcCardSocket*)aPtr;
228 Interrupt::Clear(pS->iReadyChangeIntId);
229 pS->Isr(EPccdIntRdyChange);
232 void DPlatPcCardSocket::StatusChangeIsr(TAny* aPtr)
234 DPlatPcCardSocket* pS=(DPlatPcCardSocket*)aPtr;
235 Interrupt::Clear(pS->iStatusChangeIntId);
236 pS->Isr(EPccdIntIndChange);