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