os/kernelhwsrv/kernel/eka/include/d32usbcshared.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kernel/eka/include/d32usbcshared.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,399 @@
     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/d32usbcshared.h
    1.18 +// User side class definitions for USB Device support.
    1.19 +// 
    1.20 +//
    1.21 +
    1.22 +/**
    1.23 + @file d32usbcshared.h
    1.24 + @publishedPartner
    1.25 + @released
    1.26 +*/
    1.27 +
    1.28 +#ifndef __D32USBCSHARED_H__
    1.29 +#define __D32USBCSHARED_H__
    1.30 +
    1.31 +// USB driver error codes
    1.32 +
    1.33 +/** USB driver specific error codes start from here
    1.34 +*/
    1.35 +const TInt KErrUsbDriverBase = -6701;
    1.36 +
    1.37 +/**	Attempt at data transfer, or something interface related,
    1.38 +	when neither an Interface has been set up nor Device Control is owned by
    1.39 +	the channel
    1.40 +*/
    1.41 +const TInt KErrUsbInterfaceNotReady = -6702;
    1.42 +
    1.43 +/**	Attempt at data transfer on an endpoint that does not belong to the active interface
    1.44 +*/
    1.45 +const TInt KErrUsbEpNotInInterface = -6703;
    1.46 +
    1.47 +/**	Attempt at data transfer in a direction not supported by the endpoint
    1.48 +*/
    1.49 +const TInt KErrUsbEpBadDirection = -6704;
    1.50 +
    1.51 +/**	The data transfer size specified exceeds that of the source or
    1.52 +	destination buffer descriptor
    1.53 +*/
    1.54 +const TInt KErrUsbTransferSize = -6705;
    1.55 +
    1.56 +/**	This has multiple uses:
    1.57 +	1) User request completed because device is no longer in configured state
    1.58 +	2) Something endpoint related, stall, unstall, status enquiry etc,
    1.59 +	   that requires the device to be configured
    1.60 +*/
    1.61 +const TInt KErrUsbDeviceNotConfigured = -6706;
    1.62 +
    1.63 +/**	Requested endpoint properties inconsistent during Interface setup
    1.64 +*/
    1.65 +const TInt KErrUsbBadEndpoint = -6707;
    1.66 +
    1.67 +/**	User data request completed because channel is closing (channel destructor called)
    1.68 +*/
    1.69 +const TInt KErrUsbDeviceClosing = -6708;
    1.70 +
    1.71 +/**	User data request completed because current endpoint set is being
    1.72 +	replaced since alternate setting is changing
    1.73 +*/
    1.74 +const TInt KErrUsbInterfaceChange = -6709;
    1.75 +
    1.76 +/**	User data request completed because cable has been detached (or equivalent)
    1.77 +*/
    1.78 +const TInt KErrUsbCableDetached = -6710;
    1.79 +
    1.80 +/**	User data request completed because cable has been detached (or equivalent)
    1.81 +*/
    1.82 +const TInt KErrUsbDeviceBusReset = -6711;
    1.83 +
    1.84 +/**	This means that read data is still available when a write request is made.
    1.85 +	Relates to bidirectional eps only (ep0).
    1.86 +	A bidirectional ep must consume all of its read data before attempting to write.
    1.87 +*/
    1.88 +const TInt KErrUsbEpNotReady = -6712;
    1.89 +
    1.90 +/** These are states that are described in the USB standard.
    1.91 +
    1.92 +	@see RDevUsbcClient::DeviceStatus()
    1.93 +	@see RDevUsbcClient::AlternateDeviceStatusNotify()
    1.94 +*/
    1.95 +enum TUsbcDeviceState
    1.96 +	{
    1.97 +	EUsbcDeviceStateUndefined,								// 0
    1.98 +	EUsbcDeviceStateAttached,								// 1
    1.99 +	EUsbcDeviceStatePowered,								// 2
   1.100 +	EUsbcDeviceStateDefault,								// 3
   1.101 +	EUsbcDeviceStateAddress,								// 4
   1.102 +	EUsbcDeviceStateConfigured,								// 5
   1.103 +	EUsbcDeviceStateSuspended,								// 6
   1.104 + 	EUsbcNoState = 0xff										// 255 (used as a place holder)
   1.105 +	};
   1.106 +
   1.107 +/** The endpoint states.
   1.108 +
   1.109 +	@see RDevUsbcClient::EndpointStatus()
   1.110 +	@see RDevUsbcClient::EndpointStatusNotify()
   1.111 +*/
   1.112 +enum TEndpointState
   1.113 +	{
   1.114 +	EEndpointStateNotStalled,
   1.115 +	EEndpointStateStalled,
   1.116 +	EEndpointStateUnknown
   1.117 +	};
   1.118 +
   1.119 +/** Endpoint resources/behaviours.
   1.120 +
   1.121 +	@see AllocateEndpointResource()
   1.122 +	@see DeAllocateEndpointResource()
   1.123 +	@see QueryEndpointResourceUse()
   1.124 +*/
   1.125 +enum TUsbcEndpointResource
   1.126 +	{
   1.127 +	/** Requests the use of DMA. */
   1.128 +	EUsbcEndpointResourceDMA = 0,
   1.129 +	/** Requests the use of double FIFO buffering. */
   1.130 +	EUsbcEndpointResourceDoubleBuffering = 1
   1.131 +	};
   1.132 +
   1.133 +
   1.134 +/** The USB client device capability class.
   1.135 +*/
   1.136 +class TCapsDevUsbc
   1.137 +	{
   1.138 +public:
   1.139 +	/** The device version. */
   1.140 +	TVersion version;
   1.141 +	};
   1.142 +
   1.143 +
   1.144 +/** The maximum number of endpoints supported by the device, excluding ep0.
   1.145 +*/
   1.146 +const TInt KUsbcMaxEndpoints = 30;
   1.147 +
   1.148 +/** The maximum number of endpoints per interface, excluding ep0.
   1.149 +*/
   1.150 +const TInt KMaxEndpointsPerClient = 5;
   1.151 +
   1.152 +/** @internalComponent
   1.153 +*/
   1.154 +const TInt KInvalidEndpointNumber = 31;
   1.155 +
   1.156 +/** The alternate setting flag; when this bit is set the state change notified by
   1.157 +	RDevUsbcClient::AlternateDeviceStatusNotify() is an alternate setting number.
   1.158 +*/
   1.159 +const TUint KUsbAlternateSetting = 0x80000000;
   1.160 +
   1.161 +/** The USB cable detection feature flag; used by TUsbDeviceCapsV01::iFeatureWord1.
   1.162 +	When this bit is set then the USB controller hardware (UDC) supports detection
   1.163 +	of a plugged-in USB cable even when not powered.
   1.164 +
   1.165 +	@see TUsbDeviceCapsV01
   1.166 +*/
   1.167 +const TUint KUsbDevCapsFeatureWord1_CableDetectWithoutPower = 0x00000001;
   1.168 +
   1.169 +/** If this flag is set then the driver supports the new endpoint resource
   1.170 +	allocation scheme for DMA and Double-buffering via
   1.171 +	TUsbcEndpointInfo::iFeatureWord1.
   1.172 +
   1.173 +	@see TUsbDeviceCapsV01
   1.174 +*/
   1.175 +const TUint KUsbDevCapsFeatureWord1_EndpointResourceAllocV2 = 0x00000002;
   1.176 +
   1.177 +
   1.178 +/** Device USB capabilities.
   1.179 +*/
   1.180 +class TUsbDeviceCapsV01
   1.181 +	{
   1.182 +public:
   1.183 +	/** The total number of endpoints on the device. */
   1.184 +	TInt iTotalEndpoints;
   1.185 +	/** Indicates whether the device supports software connect/disconnect. */
   1.186 +	TBool iConnect;
   1.187 +	/** Indicates whether the device is self powered. */
   1.188 +	TBool iSelfPowered;
   1.189 +	/** Indicates whether the device can send Remote Wakeup. */
   1.190 +	TBool iRemoteWakeup;
   1.191 +	/** Indicates whether the device supports High-speed mode. */
   1.192 +	TBool iHighSpeed;
   1.193 +	/** 32 flag bits indicating miscellaneous UDC/device features.
   1.194 +		Currently defined are:
   1.195 +		- KUsbDevCapsFeatureWord1_CableDetectWithoutPower = 0x00000001
   1.196 +		- KUsbDevCapsFeatureWord1_EndpointResourceAllocV2 = 0x00000002
   1.197 +	*/
   1.198 +	TUint32 iFeatureWord1;
   1.199 +	/** Reserved for future use. */
   1.200 +	TUint32 iReserved;
   1.201 +	};
   1.202 +
   1.203 +/** Package buffer for a TUsbDeviceCapsV01 object.
   1.204 +
   1.205 +	@see TUsbDeviceCapsV01
   1.206 +*/
   1.207 +typedef TPckgBuf<TUsbDeviceCapsV01> TUsbDeviceCaps;
   1.208 +
   1.209 +/** Bitmaps for TUsbcEndpointCaps.iSizes.
   1.210 +
   1.211 +	This endpoint is not available (= no size).
   1.212 +*/
   1.213 +const TUint KUsbEpNotAvailable = 0x00000000;
   1.214 +/**	Max packet size is continuously variable up to some size specified.
   1.215 +	(Interrupt and Isochronous endpoints only.)
   1.216 +*/
   1.217 +const TUint KUsbEpSizeCont     = 0x00000001;
   1.218 +/** Max packet size 8 bytes is supported
   1.219 +*/
   1.220 +const TUint KUsbEpSize8        = 0x00000008;
   1.221 +/** Max packet size 16 bytes is supported
   1.222 +*/
   1.223 +const TUint KUsbEpSize16       = 0x00000010;
   1.224 +/** Max packet size 32 bytes is supported
   1.225 +*/
   1.226 +const TUint KUsbEpSize32       = 0x00000020;
   1.227 +/** Max packet size 64 bytes is supported
   1.228 +*/
   1.229 +const TUint KUsbEpSize64       = 0x00000040;
   1.230 +/** Max packet size 128 bytes is supported
   1.231 +*/
   1.232 +const TUint KUsbEpSize128      = 0x00000080;
   1.233 +/** Max packet size 256 bytes is supported
   1.234 +*/
   1.235 +const TUint KUsbEpSize256      = 0x00000100;
   1.236 +/** Max packet size 512 bytes is supported
   1.237 +*/
   1.238 +const TUint KUsbEpSize512      = 0x00000200;
   1.239 +/** Max packet size 1023 bytes is supported
   1.240 +*/
   1.241 +const TUint KUsbEpSize1023     = 0x00000400;
   1.242 +/** Max packet size 1024 bytes is supported
   1.243 +*/
   1.244 +const TUint KUsbEpSize1024     = 0x00000800;
   1.245 +
   1.246 +
   1.247 +/** Bitmaps for TUsbcEndpointCaps.iSupportedTypesAndDir.
   1.248 +
   1.249 +	Endpoint supports Control transfer type.
   1.250 +*/
   1.251 +const TUint KUsbEpTypeControl     = 0x00000001;
   1.252 +/** Endpoint supports Isochronous transfer type.
   1.253 +*/
   1.254 +const TUint KUsbEpTypeIsochronous = 0x00000002;
   1.255 +/** Endpoint supports Bulk transfer type.
   1.256 +*/
   1.257 +const TUint KUsbEpTypeBulk        = 0x00000004;
   1.258 +/** Endpoint supports Interrupt transfer type.
   1.259 +*/
   1.260 +const TUint KUsbEpTypeInterrupt   = 0x00000008;
   1.261 +/** Endpoint supports IN transfers.
   1.262 +*/
   1.263 +const TUint KUsbEpDirIn           = 0x80000000;
   1.264 +/** Endpoint supports OUT transfers.
   1.265 +*/
   1.266 +const TUint KUsbEpDirOut          = 0x40000000;
   1.267 +/** Endpoint supports bidirectional (Control) transfers only.
   1.268 +*/
   1.269 +const TUint KUsbEpDirBidirect     = 0x20000000;
   1.270 +
   1.271 +
   1.272 +/** Converts an absolute size value into a KUsbEpSize... mask.
   1.273 +*/
   1.274 +static inline TUint PacketSize2Mask(TInt aSize);
   1.275 +
   1.276 +/** Converts an endpoint type mask KUsbEpType...  into an endpoint attribute
   1.277 +	value KUsbEpAttr_....
   1.278 +*/
   1.279 +static inline TUint EpTypeMask2Value(TInt aType);
   1.280 +
   1.281 +
   1.282 +/** Endpoint capabilities as reported by the driver.
   1.283 +*/
   1.284 +class TUsbcEndpointCaps
   1.285 +	{
   1.286 +public:
   1.287 +	/** Returns the greatest available packet size for this endpoint. */
   1.288 +	TInt MaxPacketSize() const;
   1.289 +	/** Returns the smallest available packet size for this endpoint. */
   1.290 +	TInt MinPacketSize() const;
   1.291 +public:
   1.292 +	/** The supported maximum packet sizes. */
   1.293 +	TUint iSizes;
   1.294 +	/** The supported endpoint types and directions. */
   1.295 +	TUint iTypesAndDir;
   1.296 +	/** This is a 'high-speed, high bandwidth' endpoint. */
   1.297 +	TBool iHighBandwidth;
   1.298 +	/** Reserved for future use. */
   1.299 +	TUint32 iReserved[2];
   1.300 +	};
   1.301 +
   1.302 +
   1.303 +/** Endpoint capabilities as returned by RDevUsbcClient::EndpointCaps().
   1.304 +*/
   1.305 +class TUsbcEndpointData
   1.306 +	{
   1.307 +public:
   1.308 +	/** Detail of endpoint capabilities. */
   1.309 +	TUsbcEndpointCaps iCaps;
   1.310 +	/** Indicates whether this endpoint is already claimed. */
   1.311 +	TBool iInUse;
   1.312 +	};
   1.313 +
   1.314 +/** The endpoint resource allocation flags;
   1.315 +	used by TUsbcEndpointInfo::iFeatureWord1.
   1.316 +
   1.317 +	@see TUsbcEndpointInfo
   1.318 +*/
   1.319 +const TUint KUsbcEndpointInfoFeatureWord1_DMA             = 0x00000001;
   1.320 +const TUint KUsbcEndpointInfoFeatureWord1_DoubleBuffering = 0x00000002;
   1.321 +
   1.322 +/** The desired endpoint capabilities used in RDevUsbcClient::SetInterface().
   1.323 +*/
   1.324 +class TUsbcEndpointInfo
   1.325 +	{
   1.326 +public:
   1.327 +	TUsbcEndpointInfo(TUint aType=KUsbEpTypeBulk, TUint aDir=KUsbEpDirOut,
   1.328 +					  TInt aSize=0, TInt aInterval=0, TInt aExtra=0);
   1.329 +	/** @internalComponent */
   1.330 +	TInt AdjustEpSizes(TInt& aEpSize_Fs, TInt& aEpSize_Hs) const;
   1.331 +	/** @internalComponent */
   1.332 +	TInt AdjustPollInterval();
   1.333 +public:
   1.334 +	/** Endpoint type (mask: KUsbEpTypeControl, etc., but used as value). */
   1.335 +	TUint iType;
   1.336 +	/** Direction (mask: KUsbEpDirIn, etc., but used as value). */
   1.337 +	TUint iDir;
   1.338 +	/** Maximum packet size (literal, no mask). */
   1.339 +	TInt iSize;
   1.340 +	/** Interval for polling full-speed interrupt and isochronous endpoints.
   1.341 +		Expressed either directly in milliseconds with a valid range 1..255
   1.342 +		(interrupt), or for use as 'value' in the expression interval=2^(value-1)
   1.343 +		with a valid range 1..16 (isochronous).
   1.344 +	*/
   1.345 +	TInt iInterval;
   1.346 +	/** Interval for polling high-speed interrupt and isochronous endpoints,
   1.347 +		or to specify the NAK rate for high-speed control and bulk OUT endpoints.
   1.348 +		Expressed either for use as 'value' in the expression interval=2^(value-1)
   1.349 +		with a valid range 1..16 (interrupt and isochronous), or directly as the
   1.350 +		maximum NAK rate with a valid range 0..255 (control and bulk).
   1.351 +	*/
   1.352 +	TInt iInterval_Hs;
   1.353 +	/** The number of additional transactions per uframe to be scheduled (0..2)
   1.354 +		(A value greater than zero is only valid for high-speed high bandwidth
   1.355 +		 interrupt and isochronous endpoints. Also note that there are endpoint size
   1.356 +		 restrictions associated with additional transactions - see 9.6.6.)
   1.357 +	*/
   1.358 +	TInt iTransactions;
   1.359 +	/** The number of extra bytes that the standard endpoint descriptor should be extended by.
   1.360 +		In almost all cases, this should be 0 (zero).
   1.361 +	*/
   1.362 +	TInt iExtra;
   1.363 +	/** 32 flag bits indicating miscellaneous endpoint features.
   1.364 +		Currently defined are:
   1.365 +		- KUsbcEndpointInfoFeatureWord1_DMA             = 0x00000001
   1.366 +		- KUsbcEndpointInfoFeatureWord1_DoubleBuffering = 0x00000002
   1.367 +	*/
   1.368 +	TUint32 iFeatureWord1;
   1.369 +	/** Reserved for future use. */
   1.370 +	TUint32 iReserved;
   1.371 +	};
   1.372 +
   1.373 +/** USB Class information used in RDevUsbcClient::SetInterface().
   1.374 +*/
   1.375 +class TUsbcClassInfo
   1.376 +	{
   1.377 +public:
   1.378 +	TUsbcClassInfo(TInt aClass=0, TInt aSubClass=0, TInt aProtocol=0);
   1.379 +public:
   1.380 +	/** The class type number. */
   1.381 +	TInt iClassNum;
   1.382 +	/** The sub-class type number. */
   1.383 +	TInt iSubClassNum;
   1.384 +	/** The protocol number. */
   1.385 +	TInt iProtocolNum;
   1.386 +	/** Reserved for future use. */
   1.387 +	TUint32 iReserved;
   1.388 +	};
   1.389 +
   1.390 +
   1.391 +/** The Ep0 Setup request 'unsubscribe' flag; used by
   1.392 +	TUsbcInterfaceInfo::iFeatureWord. When this bit is set then valid vendor-
   1.393 +	or class-specific Ep0 requests addressed to this interface or any of its
   1.394 +	endpoints will be stalled by the USB PDD PIL.
   1.395 +
   1.396 +	@see TUsbcInterfaceInfo
   1.397 +*/
   1.398 +const TUint KUsbcInterfaceInfo_NoEp0RequestsPlease = 0x00000001;
   1.399 +
   1.400 +#include <d32usbcshared.inl>
   1.401 +
   1.402 +#endif 
   1.403 \ No newline at end of file