diff -r 000000000000 -r 6663340f3fc9 omap3530/omap3530_drivers/usbcc/omap3530_usbc.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/omap3530/omap3530_drivers/usbcc/omap3530_usbc.h Thu Oct 15 12:59:54 2009 +0100 @@ -0,0 +1,318 @@ +// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of the License "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// omap3530/omap3530_drivers/usbcc/omap3530_usbc.h +// Platform-dependent USB client controller layer (USB PSL). +// + + +#ifndef __OMAP3530_USBC_H__ +#define __OMAP3530_USBC_H__ + +#include +#include +#include + +// This is the header file for the implementation of the USB driver PSL layer for an imaginary USB client +// (device) controller. +// For simplicity's sake we assume the following endpoint layout of the controller. +// We have 5 endpoints in total - two Bulk endpoints (IN and OUT), two Isochronous endpoint (IN and OUT), +// one Interrupt endpoint (IN), and of course endpoint zero (Ep0). +// +// This is the mapping of "Hardware Endpoint Numbers" to "Real Endpoints" (and thus is also +// used as the array index for our local TTemplateAsspUsbcc::iEndpoints[]): +// +// 0 - 0 (Ep0 OUT) +// 0 - 1 (Ep0 IN) +// 1 - 3 (Bulk IN, Address 0x11, -> EpAddr2Idx(0x11) = 3) +// 2 - 4 (Bulk OUT, Address 0x02, -> EpAddr2Idx(0x02) = 4) +// 3 - 7 (Iso IN, Address 0x13, -> EpAddr2Idx(0x13) = 7) +// 4 - 8 (Iso OUT, Address 0x04, -> EpAddr2Idx(0x04) = 8) +// 5 - 11 (Int IN, Address 0x15, -> EpAddr2Idx(0x15) = 11) +// +// For the reason why this is so (or rather for the perhaps not so obvious system behind it), +// see the comment at the beginning of \e32\drivers\usbcc\ps_usbc.cpp and also the structure +// DeviceEndpoints[] at the top of pa_usbc.cpp. + +// The total number of endpoints in our local endpoint array: +static const TInt KUsbTotalEndpoints = 16; //32; // Disabled due to limited FIFO space + +// The numbers used in the following macros are 'aRealEndpoint's (i.e. array indices): +#define IS_VALID_ENDPOINT(x) ((x) > 0 && (x) < KUsbTotalEndpoints) +#define IS_OUT_ENDPOINT(x) IS_VALID_ENDPOINT(x) && ((x) == 0 || (x) == 2 || (x) == 4 || (x) == 6 || (x) == 8 || (x) == 10 || (x) == 12 || (x) == 14 || (x) == 16 || (x) == 18 || (x) == 20 || (x) == 22 ||(x) == 24 || (x) == 26 ||(x) == 28) +#define IS_IN_ENDPOINT(x) IS_VALID_ENDPOINT(x) && ((x) == 1 || (x) == 3 || (x) == 5 || (x) == 7 || (x) == 9 || (x) == 11 || (x) == 13 || (x) == 15 || (x) == 17 || (x) == 19 || (x) == 21 || (x) == 23 ||(x) == 25 || (x) == 27 ||(x) == 29) +#define IS_BULK_IN_ENDPOINT(x) IS_VALID_ENDPOINT(x) && ((x) == 1 || (x) == 3 || (x) == 5 || (x) == 7 || (x) == 9 || (x) == 11 || (x) == 13 || (x) == 15 || (x) == 17 || (x) == 19 || (x) == 21 || (x) == 23 ||(x) == 25 || (x) == 27) +#define IS_BULK_OUT_ENDPOINT(x) IS_VALID_ENDPOINT(x) &&((x) == 2 || (x) == 4 || (x) == 6 || (x) == 8 || (x) == 10 || (x) == 12 || (x) == 14 || (x) == 16 || (x) == 18 || (x) == 20 || (x) == 22 ||(x) == 24 || (x) == 26 ||(x) == 28) +#define IS_BULK_ENDPOINT(x) (IS_BULK_IN_ENDPOINT(x) || IS_BULK_OUT_ENDPOINT(x)) +#define IS_ISO_IN_ENDPOINT(x) EFalse +#define IS_ISO_OUT_ENDPOINT(x) EFalse +#define IS_ISO_ENDPOINT(x) (IS_ISO_IN_ENDPOINT(x) || IS_ISO_OUT_ENDPOINT(x)) +#define IS_INT_IN_ENDPOINT(x) IS_VALID_ENDPOINT(x) && ((x) == 29) + +// This takes as an index the TTemplateAsspUsbcc::iEndpoints index (== aRealEndpoint) 0..11 +// and returns the hardware endpoint number 0..5 (note that not all input indices are valid; +// these will return -1): +/*static const TInt TBeagleAsspEndpoints[KUsbTotalEndpoints] = +{0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30};*/ +static const TInt TBeagleAsspEndpoints[KUsbTotalEndpoints] = +{0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}; + +// And here is a function to use the above array: +static inline TInt ArrayIdx2TemplateEp(TInt aRealEndpoint) + { + if (IS_VALID_ENDPOINT(aRealEndpoint)) return TBeagleAsspEndpoints[aRealEndpoint]; + else return -1; + } + +static inline TInt TemplateEp2ArrayIdx(TInt aRealEndpoint) + { + for(TInt x=0; x