3 Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
4 Copyright (c) 2016, Linaro, Ltd. All rights reserved.<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 #include <Library/BaseLib.h>
19 #include <Library/DebugLib.h>
20 #include <Library/IoLib.h>
21 #include <Library/NonDiscoverableDeviceRegistrationLib.h>
22 #include <Library/UefiBootServicesTableLib.h>
24 #include <Protocol/EmbeddedExternalDevice.h>
27 #include <Omap3530/Omap3530.h>
29 EMBEDDED_EXTERNAL_DEVICE
*gTPS65950
;
31 #define HOST_CONTROLLER_OPERATION_REG_SIZE 0x44
36 NON_DISCOVERABLE_DEVICE
*Device
42 // Take USB host out of force-standby mode
43 MmioWrite32 (UHH_SYSCONFIG
, UHH_SYSCONFIG_MIDLEMODE_NO_STANDBY
44 | UHH_SYSCONFIG_CLOCKACTIVITY_ON
45 | UHH_SYSCONFIG_SIDLEMODE_NO_STANDBY
46 | UHH_SYSCONFIG_ENAWAKEUP_ENABLE
47 | UHH_SYSCONFIG_AUTOIDLE_ALWAYS_RUN
);
48 MmioWrite32 (UHH_HOSTCONFIG
, UHH_HOSTCONFIG_P3_CONNECT_STATUS_DISCONNECT
49 | UHH_HOSTCONFIG_P2_CONNECT_STATUS_DISCONNECT
50 | UHH_HOSTCONFIG_P1_CONNECT_STATUS_DISCONNECT
51 | UHH_HOSTCONFIG_ENA_INCR_ALIGN_DISABLE
52 | UHH_HOSTCONFIG_ENA_INCR16_ENABLE
53 | UHH_HOSTCONFIG_ENA_INCR8_ENABLE
54 | UHH_HOSTCONFIG_ENA_INCR4_ENABLE
55 | UHH_HOSTCONFIG_AUTOPPD_ON_OVERCUR_EN_ON
56 | UHH_HOSTCONFIG_P1_ULPI_BYPASS_ULPI_MODE
);
58 // USB reset (GPIO 147 - Port 5 pin 19) output high
59 MmioAnd32 (GPIO5_BASE
+ GPIO_OE
, ~BIT19
);
60 MmioWrite32 (GPIO5_BASE
+ GPIO_SETDATAOUT
, BIT19
);
62 // Get the Power IC protocol
63 Status
= gBS
->LocateProtocol (&gEmbeddedExternalDeviceProtocolGuid
, NULL
, (VOID
**)&gTPS65950
);
64 ASSERT_EFI_ERROR (Status
);
67 Data
= VAUX_DEV_GRP_P1
;
68 Status
= gTPS65950
->Write (gTPS65950
, EXTERNAL_DEVICE_REGISTER(I2C_ADDR_GRP_ID4
, VAUX2_DEV_GRP
), 1, &Data
);
69 ASSERT_EFI_ERROR(Status
);
71 Data
= VAUX_DEDICATED_18V
;
72 Status
= gTPS65950
->Write (gTPS65950
, EXTERNAL_DEVICE_REGISTER(I2C_ADDR_GRP_ID4
, VAUX2_DEDICATED
), 1, &Data
);
73 ASSERT_EFI_ERROR (Status
);
75 // Enable power to the USB hub
76 Status
= gTPS65950
->Read (gTPS65950
, EXTERNAL_DEVICE_REGISTER(I2C_ADDR_GRP_ID3
, LEDEN
), 1, &Data
);
77 ASSERT_EFI_ERROR (Status
);
79 // LEDAON controls the power to the USB host, PWM is disabled
83 Status
= gTPS65950
->Write (gTPS65950
, EXTERNAL_DEVICE_REGISTER(I2C_ADDR_GRP_ID3
, LEDEN
), 1, &Data
);
84 ASSERT_EFI_ERROR (Status
);
91 PciEmulationEntryPoint (
92 IN EFI_HANDLE ImageHandle
,
93 IN EFI_SYSTEM_TABLE
*SystemTable
96 UINT8 CapabilityLength
;
100 CapabilityLength
= MmioRead8 (USB_EHCI_HCCAPBASE
);
101 PhysicalPorts
= MmioRead32 (USB_EHCI_HCCAPBASE
+ 0x4) & 0x0000000F;
102 MemorySize
= CapabilityLength
+ HOST_CONTROLLER_OPERATION_REG_SIZE
+
103 4 * PhysicalPorts
- 1;
105 return RegisterNonDiscoverableMmioDevice (
106 NonDiscoverableDeviceTypeEhci
,
107 NonDiscoverableDeviceDmaTypeNonCoherent
,
111 USB_EHCI_HCCAPBASE
, MemorySize