1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/boardsupport/haitest/bspsvs/suite/bsp/mmc/ldd/src/mmclddpsu.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,330 @@
1.4 +/*
1.5 +* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +*
1.19 +*/
1.20 +
1.21 +
1.22 +#include <kernel.h>
1.23 +#include <mmc.h>
1.24 +#include <locmedia.h>
1.25 +
1.26 +#include "mmcldd.h"
1.27 +#include "d_mmcsdif.h"
1.28 +
1.29 +/**
1.30 + * Do a kernel side control for DMMCPsu
1.31 + *
1.32 + * @param TInt aFunction - Request Function ID
1.33 + * @param TAny* a1 - Given parameter
1.34 + * @param TAny* a2 - Given parameter
1.35 + *
1.36 + * @return TInt the error code
1.37 + *
1.38 + * @leave N/A
1.39 + */
1.40 +TInt DLddMmcCntrlInterface::PsuDoControl(TInt aFunction, TAny* a1, TAny* a2)
1.41 + {
1.42 + MMCSDLOG("<--PsuDoControl-->");
1.43 + TInt r = KErrNone;
1.44 +
1.45 + if (!iPsu)
1.46 + {
1.47 + MMCSDLOG("DLddMmcCntrlInterface::PsuDoControl - iPsu is NULL");
1.48 + return KErrGeneral;
1.49 + }
1.50 + else if (!iClient)
1.51 + {
1.52 + MMCSDLOG("DLddMmcCntrlInterface::PsuDoControl - iClient is NULL");
1.53 + return KErrGeneral;
1.54 + }
1.55 +
1.56 + switch(TTCFunctionId(aFunction).FunctionId())
1.57 + {
1.58 + case RMMCSDTestControllerInterface::EPsu:
1.59 + {
1.60 + r = Kern::ThreadRawWrite(iClient, a1, &iPsu, sizeof(iPsu));
1.61 + }
1.62 + break;
1.63 + case RMMCSDTestControllerInterface::EPsuInfo:
1.64 + {
1.65 + TPBusPsuInfo psuInfo;
1.66 + MMCSDLOG("<--PsuInfo-->");
1.67 + iPsu->PsuInfo(psuInfo);
1.68 + r = Kern::ThreadRawWrite(iClient, a1, &psuInfo, sizeof(TPBusPsuInfo));
1.69 + break;
1.70 + }
1.71 + case RMMCSDTestControllerInterface::EPsuState:
1.72 + {
1.73 + if(iPsu != NULL)
1.74 + {
1.75 + TPBusPsuState aState;
1.76 + aState = (TPBusPsuState&)a1;
1.77 + r= iPsu->SetState(aState);
1.78 + MMCSDLOG2("EPsuState :%d", aState);
1.79 + }
1.80 + else
1.81 + {
1.82 + r= KErrGeneral;
1.83 + }
1.84 + break;
1.85 + }
1.86 + case RMMCSDTestControllerInterface::EPsuVoltage:
1.87 + {
1.88 + if(iPsu != NULL)
1.89 + {
1.90 + TUint32 aVoltOpRange;
1.91 + aVoltOpRange = (TUint32)a1;
1.92 + iPsu->SetVoltage(aVoltOpRange);
1.93 + MMCSDLOG2("EPsuVoltage :0x%x", aVoltOpRange);
1.94 + }
1.95 + else
1.96 + {
1.97 + r= KErrGeneral;
1.98 + }
1.99 + break;
1.100 + }
1.101 + case RMMCSDTestControllerInterface::EPsuNum:
1.102 + {
1.103 + if(iPsu != NULL)
1.104 + {
1.105 + r = Kern::ThreadRawWrite(iClient, a1, &iPsu->iPsuNum, sizeof(TInt));
1.106 + MMCSDLOG2("EPsuNum :%d", &iPsu->iPsuNum);
1.107 + }
1.108 + else
1.109 + {
1.110 + r= KErrGeneral;
1.111 + }
1.112 + break;
1.113 + }
1.114 + case RMMCSDTestControllerInterface::EMediaChangeNum:
1.115 + {
1.116 + if(iPsu != NULL)
1.117 + {
1.118 + r = Kern::ThreadRawWrite(iClient, a1, &iPsu->iMediaChangeNum, sizeof(TInt));
1.119 + MMCSDLOG2("EMediaChangeNum :%d", &iPsu->iMediaChangeNum);
1.120 + }
1.121 + else
1.122 + {
1.123 + r= KErrGeneral;
1.124 + }
1.125 + break;
1.126 + }
1.127 + case RMMCSDTestControllerInterface::EPsuCurLimit:
1.128 + {
1.129 + if(iPsu != NULL)
1.130 + {
1.131 + r = Kern::ThreadRawWrite(iClient, a1, &iPsu->iCurrLimited, sizeof(TBool));
1.132 + MMCSDLOG2("EPsuCurLimit :%d", &iPsu->iCurrLimited);
1.133 + }
1.134 + else
1.135 + {
1.136 + r= KErrGeneral;
1.137 + }
1.138 + break;
1.139 + }
1.140 + case RMMCSDTestControllerInterface::EPbusState:
1.141 + {
1.142 + if (iSocket)
1.143 + {
1.144 + r = Kern::ThreadRawWrite(iClient, a1, &iSocket->iState, sizeof(TInt));
1.145 + MMCSDLOG2("EPbusState :%d", &iSocket->iState);
1.146 + }
1.147 + else
1.148 + {
1.149 + MMCSDLOG("RMMCSDTestControllerInterface::EPbusState - iSocket is NULL");
1.150 + r = KErrGeneral;
1.151 + }
1.152 + break;
1.153 + }
1.154 + case RMMCSDTestControllerInterface::EVccState:
1.155 + {
1.156 + if(iPsu)
1.157 + {
1.158 + r = Kern::ThreadRawWrite(iClient, a1, &iPsu->iState,sizeof(TInt));
1.159 + MMCSDLOG2("EVccState :%d", &iPsu->iState);
1.160 + }
1.161 + else
1.162 + {
1.163 + r=KErrGeneral;
1.164 + }
1.165 + break;
1.166 + }
1.167 + case RMMCSDTestControllerInterface::EIsLocked:
1.168 + {
1.169 + if(iPsu)
1.170 + {
1.171 + TBool lock =iPsu->IsLocked();
1.172 + r = Kern::ThreadRawWrite(iClient, a1, &lock,sizeof(TBool));
1.173 + MMCSDLOG2("EIsLocked :%d", lock);
1.174 + }
1.175 + else
1.176 + {
1.177 + r=KErrGeneral;
1.178 + }
1.179 + break;
1.180 + }
1.181 + case RMMCSDTestControllerInterface::EIsOff:
1.182 + {
1.183 + if(iPsu)
1.184 + {
1.185 + TBool isoff =iPsu->IsOff();
1.186 + r = Kern::ThreadRawWrite(iClient, a1, &isoff,sizeof(TBool));
1.187 + MMCSDLOG2("EIsOff :%d", isoff);
1.188 + }
1.189 + else
1.190 + {
1.191 + r=KErrGeneral;
1.192 + }
1.193 + break;
1.194 + }
1.195 + case RMMCSDTestControllerInterface::EMaxCurrentInMicroAmps:
1.196 + {
1.197 + if(iPsu)
1.198 + {
1.199 + TInt current =iPsu->MaxCurrentInMicroAmps();
1.200 + r = Kern::ThreadRawWrite(iClient, a1, ¤t,sizeof(TInt));
1.201 + MMCSDLOG2("EMaxCurrentInMicroAmps :%d", current);
1.202 + }
1.203 + else
1.204 + {
1.205 + r=KErrGeneral;
1.206 + }
1.207 + break;
1.208 + }
1.209 + case RMMCSDTestControllerInterface::EResetInactivityTimer:
1.210 + {
1.211 + if(iPsu)
1.212 + {
1.213 + iPsu->ResetInactivityTimer();
1.214 + MMCSDLOG("EResetInactivityTimer");
1.215 + }
1.216 + else
1.217 + {
1.218 + r=KErrGeneral;
1.219 + }
1.220 + break;
1.221 + }
1.222 + case RMMCSDTestControllerInterface::EVoltageSupported:
1.223 + {
1.224 + if(iPsu)
1.225 + {
1.226 + TUint vol =iPsu->VoltageSupported();
1.227 + r = Kern::ThreadRawWrite(iClient, a1, &vol,sizeof(TUint));
1.228 + MMCSDLOG2("EVoltageSupported :0x%x", vol);
1.229 + }
1.230 + else
1.231 + {
1.232 + r=KErrGeneral;
1.233 + }
1.234 + break;
1.235 + }
1.236 + case RMMCSDTestControllerInterface::EMemInactivityCount:
1.237 + {
1.238 + if(iPsu)
1.239 + {
1.240 + r = Kern::ThreadRawWrite(iClient, a1, &iPsu->iInactivityCount,sizeof(&iPsu->iInactivityCount));
1.241 + MMCSDLOG2("EMemInactivityCount :%d", &iPsu->iInactivityCount);
1.242 + }
1.243 + else
1.244 + {
1.245 + r=KErrGeneral;
1.246 + }
1.247 + break;
1.248 + }
1.249 + case RMMCSDTestControllerInterface::EMemNotLockedCount:
1.250 + {
1.251 + if(iPsu)
1.252 + {
1.253 + r = Kern::ThreadRawWrite(iClient, a1, &iPsu->iNotLockedCount,sizeof(&iPsu->iNotLockedCount));
1.254 + MMCSDLOG2("EMemNotLockedCount :%d", &iPsu->iNotLockedCount);
1.255 + }
1.256 + else
1.257 + {
1.258 + r=KErrGeneral;
1.259 + }
1.260 + break;
1.261 + }
1.262 + case RMMCSDTestControllerInterface::EMemInactivityTimeout:
1.263 + {
1.264 + if(iPsu)
1.265 + {
1.266 + r = Kern::ThreadRawWrite(iClient, a1, &iPsu->iInactivityTimeout,sizeof(&iPsu->iInactivityTimeout));
1.267 + MMCSDLOG2("EMemInactivityTimeout :%d", &iPsu->iInactivityTimeout);
1.268 + }
1.269 + else
1.270 + {
1.271 + r=KErrGeneral;
1.272 + }
1.273 + break;
1.274 + }
1.275 + case RMMCSDTestControllerInterface::EMemNotLockedTimeout:
1.276 + {
1.277 + if(iPsu && iClient)
1.278 + {
1.279 + r = Kern::ThreadRawWrite(iClient, a1, &iPsu->iNotLockedTimeout,sizeof(&iPsu->iNotLockedTimeout));
1.280 + MMCSDLOG2("EMemNotLockedTimeout :%d", &iPsu->iNotLockedTimeout);
1.281 + }
1.282 + else
1.283 + {
1.284 + r=KErrGeneral;
1.285 + }
1.286 + break;
1.287 + }
1.288 + case RMMCSDTestControllerInterface::EMemVoltageSupported:
1.289 + {
1.290 + if(iPsu && iClient)
1.291 + {
1.292 + r = Kern::ThreadRawWrite(iClient, a1, &iPsu->iVoltageSupported,sizeof(&iPsu->iVoltageSupported));
1.293 + MMCSDLOG2("EMemVoltageSupported :%d", &iPsu->iVoltageSupported);
1.294 + }
1.295 + else
1.296 + {
1.297 + r=KErrGeneral;
1.298 + }
1.299 + break;
1.300 + }
1.301 + case RMMCSDTestControllerInterface::EMemMaxCurrentInMicroAmps:
1.302 + {
1.303 + if(iPsu && iClient)
1.304 + {
1.305 + r = Kern::ThreadRawWrite(iClient, a1, &iPsu->iMaxCurrentInMicroAmps,sizeof(&iPsu->iMaxCurrentInMicroAmps));
1.306 + MMCSDLOG2("EMemMaxCurrentInMicroAmps :%d", &iPsu->iMaxCurrentInMicroAmps);
1.307 + }
1.308 + else
1.309 + {
1.310 + r=KErrGeneral;
1.311 + }
1.312 + break;
1.313 + }
1.314 + case RMMCSDTestControllerInterface::EMemVoltCheckInterval:
1.315 + {
1.316 + if(iPsu && iClient)
1.317 + {
1.318 + r = Kern::ThreadRawWrite(iClient, a1, &iPsu->iVoltCheckInterval,sizeof(&iPsu->iVoltCheckInterval));
1.319 + MMCSDLOG2("EMemVoltCheckInterval :%d", &iPsu->iVoltCheckInterval);
1.320 + }
1.321 + else
1.322 + {
1.323 + r=KErrGeneral;
1.324 + }
1.325 + break;
1.326 + }
1.327 + default:
1.328 + r = KErrNotFound;
1.329 + break;
1.330 +
1.331 + }
1.332 + return (r);
1.333 + }