Hi,
Because network rework has not been going smoothely, let's remove it from the platform upstream hotpath. It's being finalized in background and will be sent later, once ready. Hereby I present small patchset with three items - introduce USB2.0 PHY support (so called UTMI), reset driver and small I2c fix for devices' enumeration.
The patches are also available in the public github tree: https://github.com/MarvellEmbeddedProcessors/edk2-open-platform/commits/opp-...
Any comments or remarks would be welcome.
Best regards, Marcin
Bartosz Szczepanek (2): Platforms/Marvell: Add MvResetSystem driver Platforms/Marvell: Enable MvResetSystem driver for A70x0 platform
Jan Dąbroś (3): Drivers/I2c: Fix enumaration of I2c devices Platforms/Marvell: Add UtmiPhyLib Platforms/Marvell: Enable UtmiPhyLib for Armada70x0 Platforms
Documentation/Marvell/PortingGuide/Reset.txt | 7 + Documentation/Marvell/PortingGuide/Utmi.txt | 35 ++ Drivers/I2c/MvI2cDxe/MvI2cDxe.c | 13 +- Drivers/ResetSystem/MvResetSystem.c | 158 +++++++++ Drivers/ResetSystem/MvResetSystem.inf | 65 ++++ Platforms/Marvell/Armada/Armada.dsc.inc | 4 +- Platforms/Marvell/Armada/Armada70x0.dsc | 11 + Platforms/Marvell/Armada/Armada70x0.fdf | 2 +- .../Armada/Library/Armada70x0Lib/Armada70x0Lib.c | 2 + .../Armada/Library/Armada70x0Lib/Armada70x0Lib.inf | 1 + Platforms/Marvell/Include/Library/UtmiPhyLib.h | 43 +++ Platforms/Marvell/Library/UtmiPhyLib/UtmiPhyLib.c | 352 +++++++++++++++++++++ Platforms/Marvell/Library/UtmiPhyLib/UtmiPhyLib.h | 110 +++++++ .../Marvell/Library/UtmiPhyLib/UtmiPhyLib.inf | 64 ++++ Platforms/Marvell/Marvell.dec | 11 + 15 files changed, 869 insertions(+), 9 deletions(-) create mode 100644 Documentation/Marvell/PortingGuide/Reset.txt create mode 100644 Documentation/Marvell/PortingGuide/Utmi.txt create mode 100644 Drivers/ResetSystem/MvResetSystem.c create mode 100644 Drivers/ResetSystem/MvResetSystem.inf create mode 100644 Platforms/Marvell/Include/Library/UtmiPhyLib.h create mode 100644 Platforms/Marvell/Library/UtmiPhyLib/UtmiPhyLib.c create mode 100644 Platforms/Marvell/Library/UtmiPhyLib/UtmiPhyLib.h create mode 100644 Platforms/Marvell/Library/UtmiPhyLib/UtmiPhyLib.inf
From: Jan Dąbroś jsd@semihalf.com
I2c driver will now enumerate all devices from the PCD table without assumption that this table ends with '\0' entry. This condition occurred to be toolchain-dependent. Size of table will be gathered from PCD's size.
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jan Dabros jsd@semihalf.com Signed-off-by: Marcin Wojtas mw@semihalf.com --- Drivers/I2c/MvI2cDxe/MvI2cDxe.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/Drivers/I2c/MvI2cDxe/MvI2cDxe.c b/Drivers/I2c/MvI2cDxe/MvI2cDxe.c index cc19aef..fa79ebc 100755 --- a/Drivers/I2c/MvI2cDxe/MvI2cDxe.c +++ b/Drivers/I2c/MvI2cDxe/MvI2cDxe.c @@ -684,31 +684,32 @@ MvI2cEnumerate ( { UINT8 *DevicesPcd; UINT8 *DeviceBusPcd; - UINTN Index, NextIndex; + UINTN Index, NextIndex, DevCount; UINT8 NextDeviceAddress; I2C_MASTER_CONTEXT *I2cMasterContext = I2C_SC_FROM_ENUMERATE(This);
+ DevCount = PcdGetSize (PcdI2cSlaveAddresses); DevicesPcd = PcdGetPtr (PcdI2cSlaveAddresses); DeviceBusPcd = PcdGetPtr (PcdI2cSlaveBuses); if (*Device == NULL) { - for (Index = 0; DevicesPcd[Index] != '\0'; Index++) { + for (Index = 0; Index < DevCount ; Index++) { if (DeviceBusPcd[Index] != I2cMasterContext->Bus) continue; - if (DevicesPcd[Index] != '\0') + if (Index < DevCount) MvI2cAllocDevice (DevicesPcd[Index], I2cMasterContext->Bus, Device); return EFI_SUCCESS; } } else { /* Device is not NULL, so something was already allocated */ - for (Index = 0; DevicesPcd[Index] != '\0'; Index++) { + for (Index = 0; Index < DevCount; Index++) { if (DeviceBusPcd[Index] != I2cMasterContext->Bus) continue; if (DevicesPcd[Index] == I2C_DEVICE_ADDRESS((*Device)->DeviceIndex)) { - for (NextIndex = Index + 1; DevicesPcd[NextIndex] != '\0'; NextIndex++) { + for (NextIndex = Index + 1; NextIndex < DevCount; NextIndex++) { if (DeviceBusPcd[NextIndex] != I2cMasterContext->Bus) continue; NextDeviceAddress = DevicesPcd[NextIndex]; - if (NextDeviceAddress != '\0') + if (NextIndex < DevCount) MvI2cAllocDevice(NextDeviceAddress, I2cMasterContext->Bus, Device); return EFI_SUCCESS; }
On Mon, Sep 12, 2016 at 12:58:10PM +0200, Marcin Wojtas wrote:
From: Jan Dąbroś jsd@semihalf.com
I2c driver will now enumerate all devices from the PCD table without assumption that this table ends with '\0' entry. This condition occurred to be toolchain-dependent. Size of table will be gathered from PCD's size.
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jan Dabros jsd@semihalf.com Signed-off-by: Marcin Wojtas mw@semihalf.com
Reviewed-by: Leif Lindholm leif.lindholm@linaro.org
Drivers/I2c/MvI2cDxe/MvI2cDxe.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/Drivers/I2c/MvI2cDxe/MvI2cDxe.c b/Drivers/I2c/MvI2cDxe/MvI2cDxe.c index cc19aef..fa79ebc 100755 --- a/Drivers/I2c/MvI2cDxe/MvI2cDxe.c +++ b/Drivers/I2c/MvI2cDxe/MvI2cDxe.c @@ -684,31 +684,32 @@ MvI2cEnumerate ( { UINT8 *DevicesPcd; UINT8 *DeviceBusPcd;
- UINTN Index, NextIndex;
- UINTN Index, NextIndex, DevCount; UINT8 NextDeviceAddress; I2C_MASTER_CONTEXT *I2cMasterContext = I2C_SC_FROM_ENUMERATE(This);
- DevCount = PcdGetSize (PcdI2cSlaveAddresses); DevicesPcd = PcdGetPtr (PcdI2cSlaveAddresses); DeviceBusPcd = PcdGetPtr (PcdI2cSlaveBuses); if (*Device == NULL) {
- for (Index = 0; DevicesPcd[Index] != '\0'; Index++) {
- for (Index = 0; Index < DevCount ; Index++) { if (DeviceBusPcd[Index] != I2cMasterContext->Bus) continue;
if (DevicesPcd[Index] != '\0')
} } else { /* Device is not NULL, so something was already allocated */if (Index < DevCount) MvI2cAllocDevice (DevicesPcd[Index], I2cMasterContext->Bus, Device); return EFI_SUCCESS;
- for (Index = 0; DevicesPcd[Index] != '\0'; Index++) {
- for (Index = 0; Index < DevCount; Index++) { if (DeviceBusPcd[Index] != I2cMasterContext->Bus) continue; if (DevicesPcd[Index] == I2C_DEVICE_ADDRESS((*Device)->DeviceIndex)) {
for (NextIndex = Index + 1; DevicesPcd[NextIndex] != '\0'; NextIndex++) {
for (NextIndex = Index + 1; NextIndex < DevCount; NextIndex++) { if (DeviceBusPcd[NextIndex] != I2cMasterContext->Bus) continue; NextDeviceAddress = DevicesPcd[NextIndex];
if (NextDeviceAddress != '\0')
if (NextIndex < DevCount) MvI2cAllocDevice(NextDeviceAddress, I2cMasterContext->Bus, Device); return EFI_SUCCESS; }
-- 1.8.3.1
From: Jan Dąbroś jsd@semihalf.com
UTMI PHY must be configured properly in order to enable USB2.0 usage on platforms.
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jan Dabros jsd@semihalf.com Signed-off-by: Marcin Wojtas mw@semihalf.com --- Documentation/Marvell/PortingGuide/Utmi.txt | 35 ++ Platforms/Marvell/Include/Library/UtmiPhyLib.h | 43 +++ Platforms/Marvell/Library/UtmiPhyLib/UtmiPhyLib.c | 352 +++++++++++++++++++++ Platforms/Marvell/Library/UtmiPhyLib/UtmiPhyLib.h | 110 +++++++ .../Marvell/Library/UtmiPhyLib/UtmiPhyLib.inf | 64 ++++ Platforms/Marvell/Marvell.dec | 7 + 6 files changed, 611 insertions(+) create mode 100644 Documentation/Marvell/PortingGuide/Utmi.txt create mode 100644 Platforms/Marvell/Include/Library/UtmiPhyLib.h create mode 100644 Platforms/Marvell/Library/UtmiPhyLib/UtmiPhyLib.c create mode 100644 Platforms/Marvell/Library/UtmiPhyLib/UtmiPhyLib.h create mode 100644 Platforms/Marvell/Library/UtmiPhyLib/UtmiPhyLib.inf
diff --git a/Documentation/Marvell/PortingGuide/Utmi.txt b/Documentation/Marvell/PortingGuide/Utmi.txt new file mode 100644 index 0000000..cff4843 --- /dev/null +++ b/Documentation/Marvell/PortingGuide/Utmi.txt @@ -0,0 +1,35 @@ +UTMI PHY configuration +---------------------- +In order to configure UTMI, following PCDs are available: + + gMarvellTokenSpaceGuid.PcdUtmiPhyCount + +Indicates how many UTMI PHYs are available on platform. + +Next four PCDs are in unicode string format containing settings for all devices +separated with semicolon. + + gMarvellTokenSpaceGuid.PcdUtmiPhyRegUtmiUnit + +Indicates base address of the UTMI unit. + + gMarvellTokenSpaceGuid.PcdUtmiPhyRegUsbCfg + +Indicates address of USB Configuration register. + + gMarvellTokenSpaceGuid.PcdUtmiPhyRegUtmiCfg + +Indicates address of external UTMI configuration. + + gMarvellTokenSpaceGuid.PcdUtmiPhyUtmiPort + +Indicates type of the connected USB port. + +Example +------- +#UtmiPhy + gMarvellTokenSpaceGuid.PcdUtmiPhyCount|2 + gMarvellTokenSpaceGuid.PcdUtmiPhyRegUtmiUnit|L"0xF2580000;0xF2581000" + gMarvellTokenSpaceGuid.PcdUtmiPhyRegUsbCfg|L"0xF2440420;0xF2440420" + gMarvellTokenSpaceGuid.PcdUtmiPhyRegUtmiCfg|L"0xF2440440;0xF2440444" + gMarvellTokenSpaceGuid.PcdUtmiPhyUtmiPort|L"0x0;0x1" diff --git a/Platforms/Marvell/Include/Library/UtmiPhyLib.h b/Platforms/Marvell/Include/Library/UtmiPhyLib.h new file mode 100644 index 0000000..1863f30 --- /dev/null +++ b/Platforms/Marvell/Include/Library/UtmiPhyLib.h @@ -0,0 +1,43 @@ +/******************************************************************************* +Copyright (C) 2016 Marvell International Ltd. + +Marvell BSD License Option + +If you received this File from Marvell, you may opt to use, redistribute and/or +modify this File under the following licensing terms. +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +* Neither the name of Marvell nor the names of its contributors may be + used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*******************************************************************************/ + +#ifndef __UTMIPHYLIB_H__ +#define __UTMIPHYLIB_H__ + +EFI_STATUS +UtmiPhyInit ( + VOID + ); + +#endif diff --git a/Platforms/Marvell/Library/UtmiPhyLib/UtmiPhyLib.c b/Platforms/Marvell/Library/UtmiPhyLib/UtmiPhyLib.c new file mode 100644 index 0000000..c89601e --- /dev/null +++ b/Platforms/Marvell/Library/UtmiPhyLib/UtmiPhyLib.c @@ -0,0 +1,352 @@ +/******************************************************************************** +Copyright (C) 2016 Marvell International Ltd. + +Marvell BSD License Option + +If you received this File from Marvell, you may opt to use, redistribute and/or +modify this File under the following licensing terms. +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +* Redistributions of source code must Retain the above copyright notice, + this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +* Neither the name of Marvell nor the names of its contributors may be + used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*******************************************************************************/ + +#include "UtmiPhyLib.h" + +typedef struct { + EFI_PHYSICAL_ADDRESS UtmiBaseAddr; + EFI_PHYSICAL_ADDRESS UsbCfgAddr; + EFI_PHYSICAL_ADDRESS UtmiCfgAddr; + UINT32 UtmiPhyPort; +} UTMI_PHY_DATA; + +STATIC +VOID +RegSetSilent ( + IN EFI_PHYSICAL_ADDRESS Addr, + IN UINT32 Data, + IN UINT32 Mask + ) +{ + UINT32 RegData; + + RegData = MmioRead32 (Addr); + RegData &= ~Mask; + RegData |= Data; + MmioWrite32 (Addr, RegData); +} + +STATIC +VOID +RegSet ( + IN EFI_PHYSICAL_ADDRESS Addr, + IN UINT32 Data, + IN UINT32 Mask + ) +{ + DEBUG((DEBUG_INFO, "Write to address = %10x, data = %10x (mask = %10x)" + "- ", Addr, Data, Mask)); + DEBUG((DEBUG_INFO, "old value = %10x ==> ", MmioRead32 (Addr))); + RegSetSilent (Addr, Data, Mask); + DEBUG((DEBUG_INFO, "new value %10x\n", MmioRead32 (Addr))); +} + +STATIC +VOID +UtmiPhyPowerDown ( + IN UINT32 UtmiIndex, + IN EFI_PHYSICAL_ADDRESS UtmiBaseAddr, + IN EFI_PHYSICAL_ADDRESS UsbCfgAddr, + IN EFI_PHYSICAL_ADDRESS UtmiCfgAddr, + IN UINT32 UtmiPhyPort + ) +{ + UINT32 Mask, Data; + + DEBUG((DEBUG_INFO, "UtmiPhy: stage: UTMI %d - Power down transceiver (power " + "down Phy), Power down PLL, and SuspendDM\n", UtmiIndex)); + /* Power down UTMI PHY */ + RegSet (UtmiCfgAddr, 0x0 << UTMI_PHY_CFG_PU_OFFSET, UTMI_PHY_CFG_PU_MASK); + /* Config USB3 Device UTMI enable */ + Mask = UTMI_USB_CFG_DEVICE_EN_MASK; + + /* + * Prior to PHY init, configure mux for Device + * (Device can be connected to UTMI0 or to UTMI1) + */ + if (UtmiPhyPort == UTMI_PHY_TO_USB_DEVICE0) { + Data = 0x1 << UTMI_USB_CFG_DEVICE_EN_OFFSET; + /* Config USB3 Device UTMI MUX */ + Mask |= UTMI_USB_CFG_DEVICE_MUX_MASK; + Data |= UtmiIndex << UTMI_USB_CFG_DEVICE_MUX_OFFSET; + } else { + Data = 0x0 << UTMI_USB_CFG_DEVICE_EN_OFFSET; + } + + /* Set Test suspendm mode */ + Mask = UTMI_CTRL_STATUS0_SUSPENDM_MASK; + Data = 0x1 << UTMI_CTRL_STATUS0_SUSPENDM_OFFSET; + /* Enable Test UTMI select */ + Mask |= UTMI_CTRL_STATUS0_TEST_SEL_MASK; + Data |= 0x1 << UTMI_CTRL_STATUS0_TEST_SEL_OFFSET; + RegSet (UtmiBaseAddr + UTMI_CTRL_STATUS0_REG, Data, Mask); + + /* Wait for UTMI power down */ + MicroSecondDelay (1000); +} + +STATIC +VOID +UtmiPhyConfig ( + IN UINT32 UtmiIndex, + IN EFI_PHYSICAL_ADDRESS UtmiBaseAddr, + IN EFI_PHYSICAL_ADDRESS UsbCfgAddr, + IN EFI_PHYSICAL_ADDRESS UtmiCfgAddr, + IN UINT32 UtmiPhyPort + ) +{ + UINT32 Mask, Data; + + DEBUG((DEBUG_INFO, "UtmiPhy: stage: Configure UTMI PHY %d registers\n", + UtmiIndex)); + /* Reference Clock Divider Select */ + Mask = UTMI_PLL_CTRL_REFDIV_MASK; + Data = 0x5 << UTMI_PLL_CTRL_REFDIV_OFFSET; + /* Feedback Clock Divider Select - 90 for 25Mhz*/ + Mask |= UTMI_PLL_CTRL_FBDIV_MASK; + Data |= 0x60 << UTMI_PLL_CTRL_FBDIV_OFFSET; + /* Select LPFR - 0x0 for 25Mhz/5=5Mhz*/ + Mask |= UTMI_PLL_CTRL_SEL_LPFR_MASK; + Data |= 0x0 << UTMI_PLL_CTRL_SEL_LPFR_OFFSET; + RegSet (UtmiBaseAddr + UTMI_PLL_CTRL_REG, Data, Mask); + + /* Impedance Calibration Threshold Setting */ + RegSet (UtmiBaseAddr + UTMI_CALIB_CTRL_REG, + 0x6 << UTMI_CALIB_CTRL_IMPCAL_VTH_OFFSET, UTMI_CALIB_CTRL_IMPCAL_VTH_MASK); + + /* Set LS TX driver strength coarse control */ + Mask = UTMI_TX_CH_CTRL_DRV_EN_LS_MASK; + Data = 0x3 << UTMI_TX_CH_CTRL_DRV_EN_LS_OFFSET; + /* Set LS TX driver fine adjustment */ + Mask |= UTMI_TX_CH_CTRL_IMP_SEL_LS_MASK; + Data |= 0x3 << UTMI_TX_CH_CTRL_IMP_SEL_LS_OFFSET; + RegSet (UtmiBaseAddr + UTMI_TX_CH_CTRL_REG, Data, Mask); + + /* Enable SQ */ + Mask = UTMI_RX_CH_CTRL0_SQ_DET_MASK; + Data = 0x0 << UTMI_RX_CH_CTRL0_SQ_DET_OFFSET; + /* Enable analog squelch detect */ + Mask |= UTMI_RX_CH_CTRL0_SQ_ANA_DTC_MASK; + Data |= 0x1 << UTMI_RX_CH_CTRL0_SQ_ANA_DTC_OFFSET; + RegSet (UtmiBaseAddr + UTMI_RX_CH_CTRL0_REG, Data, Mask); + + /* Set External squelch calibration number */ + Mask = UTMI_RX_CH_CTRL1_SQ_AMP_CAL_MASK; + Data = 0x1 << UTMI_RX_CH_CTRL1_SQ_AMP_CAL_OFFSET; + /* Enable the External squelch calibration */ + Mask |= UTMI_RX_CH_CTRL1_SQ_AMP_CAL_EN_MASK; + Data |= 0x1 << UTMI_RX_CH_CTRL1_SQ_AMP_CAL_EN_OFFSET; + RegSet (UtmiBaseAddr + UTMI_RX_CH_CTRL1_REG, Data, Mask); + + /* Set Control VDAT Reference Voltage - 0.325V */ + Mask = UTMI_CHGDTC_CTRL_VDAT_MASK; + Data = 0x1 << UTMI_CHGDTC_CTRL_VDAT_OFFSET; + /* Set Control VSRC Reference Voltage - 0.6V */ + Mask |= UTMI_CHGDTC_CTRL_VSRC_MASK; + Data |= 0x1 << UTMI_CHGDTC_CTRL_VSRC_OFFSET; + RegSet (UtmiBaseAddr + UTMI_CHGDTC_CTRL_REG, Data, Mask); +} + +STATIC +UINTN +UtmiPhyPowerUp ( + IN UINT32 UtmiIndex, + IN EFI_PHYSICAL_ADDRESS UtmiBaseAddr, + IN EFI_PHYSICAL_ADDRESS UsbCfgAddr, + IN EFI_PHYSICAL_ADDRESS UtmiCfgAddr, + IN UINT32 UtmiPhyPort + ) +{ + EFI_STATUS Status; + UINT32 Data; + + DEBUG((DEBUG_INFO, "UtmiPhy: stage: UTMI %d - Power up transceiver(Power up " + "Phy), and exit SuspendDM\n", UtmiIndex)); + /* Power up UTMI PHY */ + RegSet (UtmiCfgAddr, 0x1 << UTMI_PHY_CFG_PU_OFFSET, UTMI_PHY_CFG_PU_MASK); + /* Disable Test UTMI select */ + RegSet (UtmiBaseAddr + UTMI_CTRL_STATUS0_REG, + 0x0 << UTMI_CTRL_STATUS0_TEST_SEL_OFFSET, UTMI_CTRL_STATUS0_TEST_SEL_MASK); + + DEBUG((DEBUG_INFO, "UtmiPhy: stage: Wait for PLL and impedance calibration " + "done, and PLL ready done\n")); + + /* Delay 10ms */ + MicroSecondDelay (10000); + + DEBUG((DEBUG_ERROR, "UtmiPhy: stage: Check PLL.. ")); + Data = MmioRead32 (UtmiBaseAddr + UTMI_CALIB_CTRL_REG); + if ((Data & UTMI_CALIB_CTRL_IMPCAL_DONE_MASK) == 0) { + DEBUG((DEBUG_ERROR, "UtmiPhy: Impedance calibration is not done\n")); + Status = EFI_D_ERROR; + } + if ((Data & UTMI_CALIB_CTRL_PLLCAL_DONE_MASK) == 0) { + DEBUG((DEBUG_ERROR, "UtmiPhy: PLL calibration is not done\n")); + Status = EFI_D_ERROR; + } + Data = MmioRead32 (UtmiBaseAddr + UTMI_PLL_CTRL_REG); + if ((Data & UTMI_PLL_CTRL_PLL_RDY_MASK) == 0) { + DEBUG((DEBUG_ERROR, "UtmiPhy: PLL is not ready\n")); + Status = EFI_D_ERROR; + } + + if (EFI_ERROR(Status)) + DEBUG((DEBUG_ERROR, "\n")); + else + DEBUG((DEBUG_ERROR, "Passed\n")); + + return Status; +} + +/* + * Cp110UtmiPhyInit initializes the UTMI PHY + * the init split in 3 parts: + * 1. Power down transceiver and PLL + * 2. UTMI PHY configure + * 3. Power up transceiver and PLL + */ +STATIC +VOID +Cp110UtmiPhyInit ( + IN UINT32 UtmiPhyCount, + IN UTMI_PHY_DATA *UtmiData + ) +{ + UINT32 i; + + for (i = 0; i < UtmiPhyCount; i++) { + UtmiPhyPowerDown(i, UtmiData[i].UtmiBaseAddr, + UtmiData[i].UsbCfgAddr, UtmiData[i].UtmiCfgAddr, + UtmiData[i].UtmiPhyPort); + } + + /* Power down PLL */ + DEBUG((DEBUG_INFO, "UtmiPhy: stage: PHY power down PLL\n")); + RegSet (UtmiData[0].UsbCfgAddr, 0x0 << UTMI_USB_CFG_PLL_OFFSET, + UTMI_USB_CFG_PLL_MASK); + + for (i = 0; i < UtmiPhyCount; i++) { + UtmiPhyConfig(i, UtmiData[i].UtmiBaseAddr, + UtmiData[i].UsbCfgAddr, UtmiData[i].UtmiCfgAddr, + UtmiData[i].UtmiPhyPort); + } + + for (i = 0; i < UtmiPhyCount; i++) { + if (EFI_ERROR(UtmiPhyPowerUp(i, UtmiData[i].UtmiBaseAddr, + UtmiData[i].UsbCfgAddr, UtmiData[i].UtmiCfgAddr, + UtmiData[i].UtmiPhyPort))) { + DEBUG((DEBUG_ERROR, "UtmiPhy: Failed to initialize UTMI PHY %d\n", i)); + continue; + } + DEBUG((DEBUG_ERROR, "UTMI PHY %d initialized to ", i)); + + if (UtmiData[i].UtmiPhyPort == UTMI_PHY_TO_USB_DEVICE0) + DEBUG((DEBUG_ERROR, "USB Device\n")); + else + DEBUG((DEBUG_ERROR, "USB Host%d\n", UtmiData[i].UtmiPhyPort)); + } + + /* Power up PLL */ + DEBUG((DEBUG_INFO, "UtmiPhy: stage: PHY power up PLL\n")); + RegSet (UtmiData[0].UsbCfgAddr, 0x1 << UTMI_USB_CFG_PLL_OFFSET, + UTMI_USB_CFG_PLL_MASK); +} + +EFI_STATUS +UtmiPhyInit ( + VOID + ) +{ + EFI_STATUS Status; + UTMI_PHY_DATA UtmiData[PcdGet32 (PcdUtmiPhyCount)]; + EFI_PHYSICAL_ADDRESS RegUtmiUnit[PcdGet32 (PcdUtmiPhyCount)]; + EFI_PHYSICAL_ADDRESS RegUsbCfg[PcdGet32 (PcdUtmiPhyCount)]; + EFI_PHYSICAL_ADDRESS RegUtmiCfg[PcdGet32 (PcdUtmiPhyCount)]; + UINTN UtmiPort[PcdGet32 (PcdUtmiPhyCount)]; + UINTN i, Count; + + Count = PcdGet32 (PcdUtmiPhyCount); + if (Count == 0) { + /* No UTMI PHY on platform */ + return EFI_SUCCESS; + } + + DEBUG((DEBUG_INFO, "UtmiPhy: Initialize USB UTMI PHYs\n")); + /* Parse UtmiPhy PCDs */ + Status = ParsePcdString ((CHAR16 *) PcdGetPtr (PcdUtmiPhyRegUtmiUnit), + Count, RegUtmiUnit, NULL); + if (EFI_ERROR(Status)) { + DEBUG((DEBUG_ERROR, "UtmiPhy: Wrong PcdUtmiPhyRegUtmiUnit format\n")); + return EFI_INVALID_PARAMETER; + } + + Status = ParsePcdString ((CHAR16 *) PcdGetPtr (PcdUtmiPhyRegUsbCfg), + Count, RegUsbCfg, NULL); + if (EFI_ERROR(Status)) { + DEBUG((DEBUG_ERROR, "UtmiPhy: Wrong PcdUtmiPhyRegUsbCfg format\n")); + return EFI_INVALID_PARAMETER; + } + + Status = ParsePcdString ((CHAR16 *) PcdGetPtr (PcdUtmiPhyRegUtmiCfg), + Count, RegUtmiCfg, NULL); + if (EFI_ERROR(Status)) { + DEBUG((DEBUG_ERROR, "UtmiPhy: Wrong PcdUtmiPhyRegUtmiCfg format\n")); + return EFI_INVALID_PARAMETER; + } + + Status = ParsePcdString ((CHAR16 *) PcdGetPtr (PcdUtmiPhyUtmiPort), + Count, UtmiPort, NULL); + if (EFI_ERROR(Status)) { + DEBUG((DEBUG_ERROR, "UtmiPhy: Wrong PcdUtmiPhyUtmiPort format\n")); + return EFI_INVALID_PARAMETER; + } + + for (i = 0 ; i < Count ; i++) { + /* Get base address of UTMI phy */ + UtmiData[i].UtmiBaseAddr = RegUtmiUnit[i]; + + /* Get usb config address */ + UtmiData[i].UsbCfgAddr = RegUsbCfg[i]; + + /* Get UTMI config address */ + UtmiData[i].UtmiCfgAddr = RegUtmiCfg[i]; + + /* Get the port number (to check if the utmi connected to host/device) */ + UtmiData[i].UtmiPhyPort = UtmiPort[i]; + } + /* Currently only Cp110 is supported */ + Cp110UtmiPhyInit (Count, UtmiData); + + return EFI_SUCCESS; +} diff --git a/Platforms/Marvell/Library/UtmiPhyLib/UtmiPhyLib.h b/Platforms/Marvell/Library/UtmiPhyLib/UtmiPhyLib.h new file mode 100644 index 0000000..f23c387 --- /dev/null +++ b/Platforms/Marvell/Library/UtmiPhyLib/UtmiPhyLib.h @@ -0,0 +1,110 @@ +/******************************************************************************** +Copyright (C) 2016 Marvell International Ltd. + +Marvell BSD License Option + +If you received this File from Marvell, you may opt to use, redistribute and/or +modify this File under the following licensing terms. +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +* Neither the name of Marvell nor the names of its contributors may be + used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*******************************************************************************/ + +#ifndef __UTMIPHY_H__ +#define __UTMIPHY_H__ + +#include <Library/ArmLib.h> +#include <Library/ArmPlatformLib.h> +#include <Library/DebugLib.h> +#include <Library/PcdLib.h> +#include <Library/MemoryAllocationLib.h> +#include <Library/IoLib.h> +#include <Library/TimerLib.h> +#include <Library/ParsePcdLib.h> + +#define UTMI_USB_CFG_DEVICE_EN_OFFSET 0 +#define UTMI_USB_CFG_DEVICE_EN_MASK (0x1 << UTMI_USB_CFG_DEVICE_EN_OFFSET) +#define UTMI_USB_CFG_DEVICE_MUX_OFFSET 1 +#define UTMI_USB_CFG_DEVICE_MUX_MASK (0x1 << UTMI_USB_CFG_DEVICE_MUX_OFFSET) +#define UTMI_USB_CFG_PLL_OFFSET 25 +#define UTMI_USB_CFG_PLL_MASK (0x1 << UTMI_USB_CFG_PLL_OFFSET) + +#define UTMI_PHY_CFG_PU_OFFSET 5 +#define UTMI_PHY_CFG_PU_MASK (0x1 << UTMI_PHY_CFG_PU_OFFSET) + +#define UTMI_PLL_CTRL_REG 0x0 +#define UTMI_PLL_CTRL_REFDIV_OFFSET 0 +#define UTMI_PLL_CTRL_REFDIV_MASK (0x7f << UTMI_PLL_CTRL_REFDIV_OFFSET) +#define UTMI_PLL_CTRL_FBDIV_OFFSET 16 +#define UTMI_PLL_CTRL_FBDIV_MASK (0x1FF << UTMI_PLL_CTRL_FBDIV_OFFSET) +#define UTMI_PLL_CTRL_SEL_LPFR_OFFSET 28 +#define UTMI_PLL_CTRL_SEL_LPFR_MASK (0x3 << UTMI_PLL_CTRL_SEL_LPFR_OFFSET) +#define UTMI_PLL_CTRL_PLL_RDY_OFFSET 31 +#define UTMI_PLL_CTRL_PLL_RDY_MASK (0x1 << UTMI_PLL_CTRL_PLL_RDY_OFFSET) + +#define UTMI_CALIB_CTRL_REG 0x8 +#define UTMI_CALIB_CTRL_IMPCAL_VTH_OFFSET 8 +#define UTMI_CALIB_CTRL_IMPCAL_VTH_MASK (0x7 << UTMI_CALIB_CTRL_IMPCAL_VTH_OFFSET) +#define UTMI_CALIB_CTRL_IMPCAL_DONE_OFFSET 23 +#define UTMI_CALIB_CTRL_IMPCAL_DONE_MASK (0x1 << UTMI_CALIB_CTRL_IMPCAL_DONE_OFFSET) +#define UTMI_CALIB_CTRL_PLLCAL_DONE_OFFSET 31 +#define UTMI_CALIB_CTRL_PLLCAL_DONE_MASK (0x1 << UTMI_CALIB_CTRL_PLLCAL_DONE_OFFSET) + +#define UTMI_TX_CH_CTRL_REG 0xC +#define UTMI_TX_CH_CTRL_DRV_EN_LS_OFFSET 12 +#define UTMI_TX_CH_CTRL_DRV_EN_LS_MASK (0xf << UTMI_TX_CH_CTRL_DRV_EN_LS_OFFSET) +#define UTMI_TX_CH_CTRL_IMP_SEL_LS_OFFSET 16 +#define UTMI_TX_CH_CTRL_IMP_SEL_LS_MASK (0xf << UTMI_TX_CH_CTRL_IMP_SEL_LS_OFFSET) + +#define UTMI_RX_CH_CTRL0_REG 0x14 +#define UTMI_RX_CH_CTRL0_SQ_DET_OFFSET 15 +#define UTMI_RX_CH_CTRL0_SQ_DET_MASK (0x1 << UTMI_RX_CH_CTRL0_SQ_DET_OFFSET) +#define UTMI_RX_CH_CTRL0_SQ_ANA_DTC_OFFSET 28 +#define UTMI_RX_CH_CTRL0_SQ_ANA_DTC_MASK (0x1 << UTMI_RX_CH_CTRL0_SQ_ANA_DTC_OFFSET) + +#define UTMI_RX_CH_CTRL1_REG 0x18 +#define UTMI_RX_CH_CTRL1_SQ_AMP_CAL_OFFSET 0 +#define UTMI_RX_CH_CTRL1_SQ_AMP_CAL_MASK (0x3 << UTMI_RX_CH_CTRL1_SQ_AMP_CAL_OFFSET) +#define UTMI_RX_CH_CTRL1_SQ_AMP_CAL_EN_OFFSET 3 +#define UTMI_RX_CH_CTRL1_SQ_AMP_CAL_EN_MASK (0x1 << UTMI_RX_CH_CTRL1_SQ_AMP_CAL_EN_OFFSET) + +#define UTMI_CTRL_STATUS0_REG 0x24 +#define UTMI_CTRL_STATUS0_SUSPENDM_OFFSET 22 +#define UTMI_CTRL_STATUS0_SUSPENDM_MASK (0x1 << UTMI_CTRL_STATUS0_SUSPENDM_OFFSET) +#define UTMI_CTRL_STATUS0_TEST_SEL_OFFSET 25 +#define UTMI_CTRL_STATUS0_TEST_SEL_MASK (0x1 << UTMI_CTRL_STATUS0_TEST_SEL_OFFSET) + +#define UTMI_CHGDTC_CTRL_REG 0x38 +#define UTMI_CHGDTC_CTRL_VDAT_OFFSET 8 +#define UTMI_CHGDTC_CTRL_VDAT_MASK (0x3 << UTMI_CHGDTC_CTRL_VDAT_OFFSET) +#define UTMI_CHGDTC_CTRL_VSRC_OFFSET 10 +#define UTMI_CHGDTC_CTRL_VSRC_MASK (0x3 << UTMI_CHGDTC_CTRL_VSRC_OFFSET) + +#define UTMI_PHY_TO_USB_HOST0 0 +#define UTMI_PHY_TO_USB_HOST1 1 +#define UTMI_PHY_TO_USB_DEVICE0 2 +#define UTMI_PHY_INVALID 0xff + +#endif diff --git a/Platforms/Marvell/Library/UtmiPhyLib/UtmiPhyLib.inf b/Platforms/Marvell/Library/UtmiPhyLib/UtmiPhyLib.inf new file mode 100644 index 0000000..59e576e --- /dev/null +++ b/Platforms/Marvell/Library/UtmiPhyLib/UtmiPhyLib.inf @@ -0,0 +1,64 @@ +# Copyright (C) 2016 Marvell International Ltd. +# +# Marvell BSD License Option +# +# If you received this File from Marvell, you may opt to use, redistribute and/or +# modify this File under the following licensing terms. +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# * Neither the name of Marvell nor the names of its contributors may be +# used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = MarvellUtmiPhyLib + FILE_GUID = e9adaac2-0443-4921-9367-5d575c3c91bc + MODULE_TYPE = BASE + VERSION_STRING = 1.0 + LIBRARY_CLASS = UtmiPhyLib + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + ArmPkg/ArmPkg.dec + ArmPlatformPkg/ArmPlatformPkg.dec + OpenPlatformPkg/Platforms/Marvell/Marvell.dec + +[LibraryClasses] + ArmLib + DebugLib + MemoryAllocationLib + PcdLib + IoLib + ParsePcdLib + +[Sources.common] + UtmiPhyLib.c + +[FixedPcd] + gMarvellTokenSpaceGuid.PcdUtmiPhyCount + gMarvellTokenSpaceGuid.PcdUtmiPhyRegUtmiUnit + gMarvellTokenSpaceGuid.PcdUtmiPhyRegUsbCfg + gMarvellTokenSpaceGuid.PcdUtmiPhyRegUtmiCfg + gMarvellTokenSpaceGuid.PcdUtmiPhyUtmiPort diff --git a/Platforms/Marvell/Marvell.dec b/Platforms/Marvell/Marvell.dec index 73102ed..7ecc89b 100644 --- a/Platforms/Marvell/Marvell.dec +++ b/Platforms/Marvell/Marvell.dec @@ -175,6 +175,13 @@ gMarvellTokenSpaceGuid.PcdChip3ComPhySpeeds|{ 0 }|VOID*|0x30000176 gMarvellTokenSpaceGuid.PcdChip3ComPhyInvFlags|{ 0 }|VOID*|0x30000177
+#UtmiPhy + gMarvellTokenSpaceGuid.PcdUtmiPhyCount|0|UINT32|0x30000205 + gMarvellTokenSpaceGuid.PcdUtmiPhyRegUtmiUnit|{ 0 }|VOID*|0x30000206 + gMarvellTokenSpaceGuid.PcdUtmiPhyRegUsbCfg|{ 0 }|VOID*|0x30000207 + gMarvellTokenSpaceGuid.PcdUtmiPhyRegUtmiCfg|{ 0 }|VOID*|0x30000208 + gMarvellTokenSpaceGuid.PcdUtmiPhyUtmiPort|{ 0 }|VOID*|0x30000209 + #SATA gMarvellTokenSpaceGuid.PcdSataBaseAddress|0|UINT32|0x4000052
On Mon, Sep 12, 2016 at 12:58:11PM +0200, Marcin Wojtas wrote:
From: Jan Dąbroś jsd@semihalf.com
UTMI PHY must be configured properly in order to enable USB2.0 usage on platforms.
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jan Dabros jsd@semihalf.com Signed-off-by: Marcin Wojtas mw@semihalf.com
Documentation/Marvell/PortingGuide/Utmi.txt | 35 ++ Platforms/Marvell/Include/Library/UtmiPhyLib.h | 43 +++ Platforms/Marvell/Library/UtmiPhyLib/UtmiPhyLib.c | 352 +++++++++++++++++++++ Platforms/Marvell/Library/UtmiPhyLib/UtmiPhyLib.h | 110 +++++++ .../Marvell/Library/UtmiPhyLib/UtmiPhyLib.inf | 64 ++++ Platforms/Marvell/Marvell.dec | 7 + 6 files changed, 611 insertions(+) create mode 100644 Documentation/Marvell/PortingGuide/Utmi.txt create mode 100644 Platforms/Marvell/Include/Library/UtmiPhyLib.h create mode 100644 Platforms/Marvell/Library/UtmiPhyLib/UtmiPhyLib.c create mode 100644 Platforms/Marvell/Library/UtmiPhyLib/UtmiPhyLib.h create mode 100644 Platforms/Marvell/Library/UtmiPhyLib/UtmiPhyLib.inf
diff --git a/Documentation/Marvell/PortingGuide/Utmi.txt b/Documentation/Marvell/PortingGuide/Utmi.txt new file mode 100644 index 0000000..cff4843 --- /dev/null +++ b/Documentation/Marvell/PortingGuide/Utmi.txt @@ -0,0 +1,35 @@ +UTMI PHY configuration +---------------------- +In order to configure UTMI, following PCDs are available:
- gMarvellTokenSpaceGuid.PcdUtmiPhyCount
+Indicates how many UTMI PHYs are available on platform.
+Next four PCDs are in unicode string format containing settings for all devices +separated with semicolon.
- gMarvellTokenSpaceGuid.PcdUtmiPhyRegUtmiUnit
+Indicates base address of the UTMI unit.
- gMarvellTokenSpaceGuid.PcdUtmiPhyRegUsbCfg
+Indicates address of USB Configuration register.
- gMarvellTokenSpaceGuid.PcdUtmiPhyRegUtmiCfg
+Indicates address of external UTMI configuration.
- gMarvellTokenSpaceGuid.PcdUtmiPhyUtmiPort
+Indicates type of the connected USB port.
+Example +------- +#UtmiPhy
- gMarvellTokenSpaceGuid.PcdUtmiPhyCount|2
- gMarvellTokenSpaceGuid.PcdUtmiPhyRegUtmiUnit|L"0xF2580000;0xF2581000"
- gMarvellTokenSpaceGuid.PcdUtmiPhyRegUsbCfg|L"0xF2440420;0xF2440420"
- gMarvellTokenSpaceGuid.PcdUtmiPhyRegUtmiCfg|L"0xF2440440;0xF2440444"
- gMarvellTokenSpaceGuid.PcdUtmiPhyUtmiPort|L"0x0;0x1"
diff --git a/Platforms/Marvell/Include/Library/UtmiPhyLib.h b/Platforms/Marvell/Include/Library/UtmiPhyLib.h new file mode 100644 index 0000000..1863f30 --- /dev/null +++ b/Platforms/Marvell/Include/Library/UtmiPhyLib.h @@ -0,0 +1,43 @@ +/******************************************************************************* +Copyright (C) 2016 Marvell International Ltd.
+Marvell BSD License Option
+If you received this File from Marvell, you may opt to use, redistribute and/or +modify this File under the following licensing terms. +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met:
+* Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
+* Neither the name of Marvell nor the names of its contributors may be
- used to endorse or promote products derived from this software without
- specific prior written permission.
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*******************************************************************************/
+#ifndef __UTMIPHYLIB_H__ +#define __UTMIPHYLIB_H__
+EFI_STATUS +UtmiPhyInit (
- VOID
- );
+#endif diff --git a/Platforms/Marvell/Library/UtmiPhyLib/UtmiPhyLib.c b/Platforms/Marvell/Library/UtmiPhyLib/UtmiPhyLib.c new file mode 100644 index 0000000..c89601e --- /dev/null +++ b/Platforms/Marvell/Library/UtmiPhyLib/UtmiPhyLib.c @@ -0,0 +1,352 @@ +/******************************************************************************** +Copyright (C) 2016 Marvell International Ltd.
+Marvell BSD License Option
+If you received this File from Marvell, you may opt to use, redistribute and/or +modify this File under the following licensing terms. +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met:
+* Redistributions of source code must Retain the above copyright notice,
- this list of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
+* Neither the name of Marvell nor the names of its contributors may be
- used to endorse or promote products derived from this software without
- specific prior written permission.
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*******************************************************************************/
+#include "UtmiPhyLib.h"
+typedef struct {
- EFI_PHYSICAL_ADDRESS UtmiBaseAddr;
- EFI_PHYSICAL_ADDRESS UsbCfgAddr;
- EFI_PHYSICAL_ADDRESS UtmiCfgAddr;
- UINT32 UtmiPhyPort;
+} UTMI_PHY_DATA;
+STATIC +VOID +RegSetSilent (
- IN EFI_PHYSICAL_ADDRESS Addr,
- IN UINT32 Data,
- IN UINT32 Mask
- )
+{
- UINT32 RegData;
- RegData = MmioRead32 (Addr);
- RegData &= ~Mask;
- RegData |= Data;
- MmioWrite32 (Addr, RegData);
+}
+STATIC +VOID +RegSet (
- IN EFI_PHYSICAL_ADDRESS Addr,
- IN UINT32 Data,
- IN UINT32 Mask
- )
+{
- DEBUG((DEBUG_INFO, "Write to address = %10x, data = %10x (mask = %10x)"
- "- ", Addr, Data, Mask));
I'd prefer debug message format strings to be kept unbroken, to facilitate searching the codebase for them.
- DEBUG((DEBUG_INFO, "old value = %10x ==> ", MmioRead32 (Addr)));
- RegSetSilent (Addr, Data, Mask);
- DEBUG((DEBUG_INFO, "new value %10x\n", MmioRead32 (Addr)));
It seems this printout would be exceedingly long, and pretty much guaranteed to wrap. Consider breaking it over 3 lines - each with an unbroken format string?
+}
+STATIC +VOID +UtmiPhyPowerDown (
- IN UINT32 UtmiIndex,
- IN EFI_PHYSICAL_ADDRESS UtmiBaseAddr,
- IN EFI_PHYSICAL_ADDRESS UsbCfgAddr,
- IN EFI_PHYSICAL_ADDRESS UtmiCfgAddr,
- IN UINT32 UtmiPhyPort
- )
+{
- UINT32 Mask, Data;
- DEBUG((DEBUG_INFO, "UtmiPhy: stage: UTMI %d - Power down transceiver (power "
- "down Phy), Power down PLL, and SuspendDM\n", UtmiIndex));
Another message guaranteed to wrap on an 80-character console.
- /* Power down UTMI PHY */
- RegSet (UtmiCfgAddr, 0x0 << UTMI_PHY_CFG_PU_OFFSET, UTMI_PHY_CFG_PU_MASK);
- /* Config USB3 Device UTMI enable */
- Mask = UTMI_USB_CFG_DEVICE_EN_MASK;
- /*
- Prior to PHY init, configure mux for Device
- (Device can be connected to UTMI0 or to UTMI1)
- */
- if (UtmiPhyPort == UTMI_PHY_TO_USB_DEVICE0) {
- Data = 0x1 << UTMI_USB_CFG_DEVICE_EN_OFFSET;
- /* Config USB3 Device UTMI MUX */
- Mask |= UTMI_USB_CFG_DEVICE_MUX_MASK;
- Data |= UtmiIndex << UTMI_USB_CFG_DEVICE_MUX_OFFSET;
- } else {
- Data = 0x0 << UTMI_USB_CFG_DEVICE_EN_OFFSET;
- }
- /* Set Test suspendm mode */
- Mask = UTMI_CTRL_STATUS0_SUSPENDM_MASK;
- Data = 0x1 << UTMI_CTRL_STATUS0_SUSPENDM_OFFSET;
- /* Enable Test UTMI select */
- Mask |= UTMI_CTRL_STATUS0_TEST_SEL_MASK;
- Data |= 0x1 << UTMI_CTRL_STATUS0_TEST_SEL_OFFSET;
- RegSet (UtmiBaseAddr + UTMI_CTRL_STATUS0_REG, Data, Mask);
- /* Wait for UTMI power down */
- MicroSecondDelay (1000);
+}
+STATIC +VOID +UtmiPhyConfig (
- IN UINT32 UtmiIndex,
- IN EFI_PHYSICAL_ADDRESS UtmiBaseAddr,
- IN EFI_PHYSICAL_ADDRESS UsbCfgAddr,
- IN EFI_PHYSICAL_ADDRESS UtmiCfgAddr,
- IN UINT32 UtmiPhyPort
- )
+{
- UINT32 Mask, Data;
- DEBUG((DEBUG_INFO, "UtmiPhy: stage: Configure UTMI PHY %d registers\n",
- UtmiIndex));
- /* Reference Clock Divider Select */
- Mask = UTMI_PLL_CTRL_REFDIV_MASK;
- Data = 0x5 << UTMI_PLL_CTRL_REFDIV_OFFSET;
- /* Feedback Clock Divider Select - 90 for 25Mhz*/
- Mask |= UTMI_PLL_CTRL_FBDIV_MASK;
- Data |= 0x60 << UTMI_PLL_CTRL_FBDIV_OFFSET;
- /* Select LPFR - 0x0 for 25Mhz/5=5Mhz*/
A space before that "*/", please.
- Mask |= UTMI_PLL_CTRL_SEL_LPFR_MASK;
- Data |= 0x0 << UTMI_PLL_CTRL_SEL_LPFR_OFFSET;
- RegSet (UtmiBaseAddr + UTMI_PLL_CTRL_REG, Data, Mask);
- /* Impedance Calibration Threshold Setting */
- RegSet (UtmiBaseAddr + UTMI_CALIB_CTRL_REG,
- 0x6 << UTMI_CALIB_CTRL_IMPCAL_VTH_OFFSET, UTMI_CALIB_CTRL_IMPCAL_VTH_MASK);
Wrap above line like my email client just did automatically?
- /* Set LS TX driver strength coarse control */
- Mask = UTMI_TX_CH_CTRL_DRV_EN_LS_MASK;
- Data = 0x3 << UTMI_TX_CH_CTRL_DRV_EN_LS_OFFSET;
- /* Set LS TX driver fine adjustment */
- Mask |= UTMI_TX_CH_CTRL_IMP_SEL_LS_MASK;
- Data |= 0x3 << UTMI_TX_CH_CTRL_IMP_SEL_LS_OFFSET;
- RegSet (UtmiBaseAddr + UTMI_TX_CH_CTRL_REG, Data, Mask);
- /* Enable SQ */
- Mask = UTMI_RX_CH_CTRL0_SQ_DET_MASK;
- Data = 0x0 << UTMI_RX_CH_CTRL0_SQ_DET_OFFSET;
- /* Enable analog squelch detect */
- Mask |= UTMI_RX_CH_CTRL0_SQ_ANA_DTC_MASK;
- Data |= 0x1 << UTMI_RX_CH_CTRL0_SQ_ANA_DTC_OFFSET;
- RegSet (UtmiBaseAddr + UTMI_RX_CH_CTRL0_REG, Data, Mask);
- /* Set External squelch calibration number */
- Mask = UTMI_RX_CH_CTRL1_SQ_AMP_CAL_MASK;
- Data = 0x1 << UTMI_RX_CH_CTRL1_SQ_AMP_CAL_OFFSET;
- /* Enable the External squelch calibration */
- Mask |= UTMI_RX_CH_CTRL1_SQ_AMP_CAL_EN_MASK;
- Data |= 0x1 << UTMI_RX_CH_CTRL1_SQ_AMP_CAL_EN_OFFSET;
- RegSet (UtmiBaseAddr + UTMI_RX_CH_CTRL1_REG, Data, Mask);
- /* Set Control VDAT Reference Voltage - 0.325V */
- Mask = UTMI_CHGDTC_CTRL_VDAT_MASK;
- Data = 0x1 << UTMI_CHGDTC_CTRL_VDAT_OFFSET;
- /* Set Control VSRC Reference Voltage - 0.6V */
- Mask |= UTMI_CHGDTC_CTRL_VSRC_MASK;
- Data |= 0x1 << UTMI_CHGDTC_CTRL_VSRC_OFFSET;
- RegSet (UtmiBaseAddr + UTMI_CHGDTC_CTRL_REG, Data, Mask);
+}
+STATIC +UINTN +UtmiPhyPowerUp (
- IN UINT32 UtmiIndex,
- IN EFI_PHYSICAL_ADDRESS UtmiBaseAddr,
- IN EFI_PHYSICAL_ADDRESS UsbCfgAddr,
- IN EFI_PHYSICAL_ADDRESS UtmiCfgAddr,
- IN UINT32 UtmiPhyPort
- )
+{
- EFI_STATUS Status;
- UINT32 Data;
- DEBUG((DEBUG_INFO, "UtmiPhy: stage: UTMI %d - Power up transceiver(Power up "
- "Phy), and exit SuspendDM\n", UtmiIndex));
Debug message exceeds 80 characters if UtmiIndex exceeds 2 digits. Please keep format string on one line.
- /* Power up UTMI PHY */
- RegSet (UtmiCfgAddr, 0x1 << UTMI_PHY_CFG_PU_OFFSET, UTMI_PHY_CFG_PU_MASK);
- /* Disable Test UTMI select */
- RegSet (UtmiBaseAddr + UTMI_CTRL_STATUS0_REG,
- 0x0 << UTMI_CTRL_STATUS0_TEST_SEL_OFFSET, UTMI_CTRL_STATUS0_TEST_SEL_MASK);
Please wrap above line like my email client just did.
- DEBUG((DEBUG_INFO, "UtmiPhy: stage: Wait for PLL and impedance calibration "
- "done, and PLL ready done\n"));
Plese keep format string on one line.
- /* Delay 10ms */
- MicroSecondDelay (10000);
- DEBUG((DEBUG_ERROR, "UtmiPhy: stage: Check PLL.. "));
- Data = MmioRead32 (UtmiBaseAddr + UTMI_CALIB_CTRL_REG);
- if ((Data & UTMI_CALIB_CTRL_IMPCAL_DONE_MASK) == 0) {
- DEBUG((DEBUG_ERROR, "UtmiPhy: Impedance calibration is not done\n"));
- Status = EFI_D_ERROR;
- }
- if ((Data & UTMI_CALIB_CTRL_PLLCAL_DONE_MASK) == 0) {
- DEBUG((DEBUG_ERROR, "UtmiPhy: PLL calibration is not done\n"));
- Status = EFI_D_ERROR;
- }
- Data = MmioRead32 (UtmiBaseAddr + UTMI_PLL_CTRL_REG);
- if ((Data & UTMI_PLL_CTRL_PLL_RDY_MASK) == 0) {
- DEBUG((DEBUG_ERROR, "UtmiPhy: PLL is not ready\n"));
- Status = EFI_D_ERROR;
- }
- if (EFI_ERROR(Status))
- DEBUG((DEBUG_ERROR, "\n"));
No error message?
- else
- DEBUG((DEBUG_ERROR, "Passed\n"));
What passed? And why is that an ERROR?
- return Status;
+}
+/*
- Cp110UtmiPhyInit initializes the UTMI PHY
- the init split in 3 parts:
- Power down transceiver and PLL
- UTMI PHY configure
- Power up transceiver and PLL
- */
+STATIC +VOID +Cp110UtmiPhyInit (
- IN UINT32 UtmiPhyCount,
- IN UTMI_PHY_DATA *UtmiData
- )
+{
- UINT32 i;
- for (i = 0; i < UtmiPhyCount; i++) {
- UtmiPhyPowerDown(i, UtmiData[i].UtmiBaseAddr,
UtmiData[i].UsbCfgAddr, UtmiData[i].UtmiCfgAddr,
UtmiData[i].UtmiPhyPort);
- }
- /* Power down PLL */
- DEBUG((DEBUG_INFO, "UtmiPhy: stage: PHY power down PLL\n"));
- RegSet (UtmiData[0].UsbCfgAddr, 0x0 << UTMI_USB_CFG_PLL_OFFSET,
- UTMI_USB_CFG_PLL_MASK);
- for (i = 0; i < UtmiPhyCount; i++) {
- UtmiPhyConfig(i, UtmiData[i].UtmiBaseAddr,
UtmiData[i].UsbCfgAddr, UtmiData[i].UtmiCfgAddr,
UtmiData[i].UtmiPhyPort);
- }
- for (i = 0; i < UtmiPhyCount; i++) {
- if (EFI_ERROR(UtmiPhyPowerUp(i, UtmiData[i].UtmiBaseAddr,
UtmiData[i].UsbCfgAddr, UtmiData[i].UtmiCfgAddr,
UtmiData[i].UtmiPhyPort))) {
DEBUG((DEBUG_ERROR, "UtmiPhy: Failed to initialize UTMI PHY %d\n", i));
continue;
- }
- DEBUG((DEBUG_ERROR, "UTMI PHY %d initialized to ", i));
- if (UtmiData[i].UtmiPhyPort == UTMI_PHY_TO_USB_DEVICE0)
DEBUG((DEBUG_ERROR, "USB Device\n"));
- else
DEBUG((DEBUG_ERROR, "USB Host%d\n", UtmiData[i].UtmiPhyPort));
- }
- /* Power up PLL */
- DEBUG((DEBUG_INFO, "UtmiPhy: stage: PHY power up PLL\n"));
- RegSet (UtmiData[0].UsbCfgAddr, 0x1 << UTMI_USB_CFG_PLL_OFFSET,
- UTMI_USB_CFG_PLL_MASK);
+}
+EFI_STATUS +UtmiPhyInit (
- VOID
- )
+{
- EFI_STATUS Status;
- UTMI_PHY_DATA UtmiData[PcdGet32 (PcdUtmiPhyCount)];
- EFI_PHYSICAL_ADDRESS RegUtmiUnit[PcdGet32 (PcdUtmiPhyCount)];
- EFI_PHYSICAL_ADDRESS RegUsbCfg[PcdGet32 (PcdUtmiPhyCount)];
- EFI_PHYSICAL_ADDRESS RegUtmiCfg[PcdGet32 (PcdUtmiPhyCount)];
- UINTN UtmiPort[PcdGet32 (PcdUtmiPhyCount)];
- UINTN i, Count;
- Count = PcdGet32 (PcdUtmiPhyCount);
- if (Count == 0) {
- /* No UTMI PHY on platform */
- return EFI_SUCCESS;
- }
- DEBUG((DEBUG_INFO, "UtmiPhy: Initialize USB UTMI PHYs\n"));
- /* Parse UtmiPhy PCDs */
- Status = ParsePcdString ((CHAR16 *) PcdGetPtr (PcdUtmiPhyRegUtmiUnit),
- Count, RegUtmiUnit, NULL);
- if (EFI_ERROR(Status)) {
- DEBUG((DEBUG_ERROR, "UtmiPhy: Wrong PcdUtmiPhyRegUtmiUnit format\n"));
- return EFI_INVALID_PARAMETER;
- }
- Status = ParsePcdString ((CHAR16 *) PcdGetPtr (PcdUtmiPhyRegUsbCfg),
- Count, RegUsbCfg, NULL);
- if (EFI_ERROR(Status)) {
- DEBUG((DEBUG_ERROR, "UtmiPhy: Wrong PcdUtmiPhyRegUsbCfg format\n"));
- return EFI_INVALID_PARAMETER;
- }
- Status = ParsePcdString ((CHAR16 *) PcdGetPtr (PcdUtmiPhyRegUtmiCfg),
- Count, RegUtmiCfg, NULL);
- if (EFI_ERROR(Status)) {
- DEBUG((DEBUG_ERROR, "UtmiPhy: Wrong PcdUtmiPhyRegUtmiCfg format\n"));
- return EFI_INVALID_PARAMETER;
- }
- Status = ParsePcdString ((CHAR16 *) PcdGetPtr (PcdUtmiPhyUtmiPort),
- Count, UtmiPort, NULL);
- if (EFI_ERROR(Status)) {
- DEBUG((DEBUG_ERROR, "UtmiPhy: Wrong PcdUtmiPhyUtmiPort format\n"));
- return EFI_INVALID_PARAMETER;
- }
- for (i = 0 ; i < Count ; i++) {
- /* Get base address of UTMI phy */
- UtmiData[i].UtmiBaseAddr = RegUtmiUnit[i];
- /* Get usb config address */
- UtmiData[i].UsbCfgAddr = RegUsbCfg[i];
- /* Get UTMI config address */
- UtmiData[i].UtmiCfgAddr = RegUtmiCfg[i];
- /* Get the port number (to check if the utmi connected to host/device) */
Which port number, and where is this information used?
- UtmiData[i].UtmiPhyPort = UtmiPort[i];
- }
Insert blank line here.
- /* Currently only Cp110 is supported */
- Cp110UtmiPhyInit (Count, UtmiData);
- return EFI_SUCCESS;
+} diff --git a/Platforms/Marvell/Library/UtmiPhyLib/UtmiPhyLib.h b/Platforms/Marvell/Library/UtmiPhyLib/UtmiPhyLib.h new file mode 100644 index 0000000..f23c387 --- /dev/null +++ b/Platforms/Marvell/Library/UtmiPhyLib/UtmiPhyLib.h @@ -0,0 +1,110 @@ +/******************************************************************************** +Copyright (C) 2016 Marvell International Ltd.
+Marvell BSD License Option
+If you received this File from Marvell, you may opt to use, redistribute and/or +modify this File under the following licensing terms. +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met:
+* Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
+* Neither the name of Marvell nor the names of its contributors may be
- used to endorse or promote products derived from this software without
- specific prior written permission.
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*******************************************************************************/
+#ifndef __UTMIPHY_H__ +#define __UTMIPHY_H__
+#include <Library/ArmLib.h> +#include <Library/ArmPlatformLib.h> +#include <Library/DebugLib.h> +#include <Library/PcdLib.h> +#include <Library/MemoryAllocationLib.h> +#include <Library/IoLib.h> +#include <Library/TimerLib.h> +#include <Library/ParsePcdLib.h>
+#define UTMI_USB_CFG_DEVICE_EN_OFFSET 0 +#define UTMI_USB_CFG_DEVICE_EN_MASK (0x1 << UTMI_USB_CFG_DEVICE_EN_OFFSET) +#define UTMI_USB_CFG_DEVICE_MUX_OFFSET 1 +#define UTMI_USB_CFG_DEVICE_MUX_MASK (0x1 << UTMI_USB_CFG_DEVICE_MUX_OFFSET) +#define UTMI_USB_CFG_PLL_OFFSET 25 +#define UTMI_USB_CFG_PLL_MASK (0x1 << UTMI_USB_CFG_PLL_OFFSET)
+#define UTMI_PHY_CFG_PU_OFFSET 5 +#define UTMI_PHY_CFG_PU_MASK (0x1 << UTMI_PHY_CFG_PU_OFFSET)
+#define UTMI_PLL_CTRL_REG 0x0 +#define UTMI_PLL_CTRL_REFDIV_OFFSET 0 +#define UTMI_PLL_CTRL_REFDIV_MASK (0x7f << UTMI_PLL_CTRL_REFDIV_OFFSET) +#define UTMI_PLL_CTRL_FBDIV_OFFSET 16 +#define UTMI_PLL_CTRL_FBDIV_MASK (0x1FF << UTMI_PLL_CTRL_FBDIV_OFFSET) +#define UTMI_PLL_CTRL_SEL_LPFR_OFFSET 28 +#define UTMI_PLL_CTRL_SEL_LPFR_MASK (0x3 << UTMI_PLL_CTRL_SEL_LPFR_OFFSET) +#define UTMI_PLL_CTRL_PLL_RDY_OFFSET 31 +#define UTMI_PLL_CTRL_PLL_RDY_MASK (0x1 << UTMI_PLL_CTRL_PLL_RDY_OFFSET)
+#define UTMI_CALIB_CTRL_REG 0x8 +#define UTMI_CALIB_CTRL_IMPCAL_VTH_OFFSET 8 +#define UTMI_CALIB_CTRL_IMPCAL_VTH_MASK (0x7 << UTMI_CALIB_CTRL_IMPCAL_VTH_OFFSET) +#define UTMI_CALIB_CTRL_IMPCAL_DONE_OFFSET 23 +#define UTMI_CALIB_CTRL_IMPCAL_DONE_MASK (0x1 << UTMI_CALIB_CTRL_IMPCAL_DONE_OFFSET) +#define UTMI_CALIB_CTRL_PLLCAL_DONE_OFFSET 31 +#define UTMI_CALIB_CTRL_PLLCAL_DONE_MASK (0x1 << UTMI_CALIB_CTRL_PLLCAL_DONE_OFFSET)
+#define UTMI_TX_CH_CTRL_REG 0xC +#define UTMI_TX_CH_CTRL_DRV_EN_LS_OFFSET 12 +#define UTMI_TX_CH_CTRL_DRV_EN_LS_MASK (0xf << UTMI_TX_CH_CTRL_DRV_EN_LS_OFFSET) +#define UTMI_TX_CH_CTRL_IMP_SEL_LS_OFFSET 16 +#define UTMI_TX_CH_CTRL_IMP_SEL_LS_MASK (0xf << UTMI_TX_CH_CTRL_IMP_SEL_LS_OFFSET)
+#define UTMI_RX_CH_CTRL0_REG 0x14 +#define UTMI_RX_CH_CTRL0_SQ_DET_OFFSET 15 +#define UTMI_RX_CH_CTRL0_SQ_DET_MASK (0x1 << UTMI_RX_CH_CTRL0_SQ_DET_OFFSET) +#define UTMI_RX_CH_CTRL0_SQ_ANA_DTC_OFFSET 28 +#define UTMI_RX_CH_CTRL0_SQ_ANA_DTC_MASK (0x1 << UTMI_RX_CH_CTRL0_SQ_ANA_DTC_OFFSET)
+#define UTMI_RX_CH_CTRL1_REG 0x18 +#define UTMI_RX_CH_CTRL1_SQ_AMP_CAL_OFFSET 0 +#define UTMI_RX_CH_CTRL1_SQ_AMP_CAL_MASK (0x3 << UTMI_RX_CH_CTRL1_SQ_AMP_CAL_OFFSET) +#define UTMI_RX_CH_CTRL1_SQ_AMP_CAL_EN_OFFSET 3 +#define UTMI_RX_CH_CTRL1_SQ_AMP_CAL_EN_MASK (0x1 << UTMI_RX_CH_CTRL1_SQ_AMP_CAL_EN_OFFSET)
+#define UTMI_CTRL_STATUS0_REG 0x24 +#define UTMI_CTRL_STATUS0_SUSPENDM_OFFSET 22 +#define UTMI_CTRL_STATUS0_SUSPENDM_MASK (0x1 << UTMI_CTRL_STATUS0_SUSPENDM_OFFSET) +#define UTMI_CTRL_STATUS0_TEST_SEL_OFFSET 25 +#define UTMI_CTRL_STATUS0_TEST_SEL_MASK (0x1 << UTMI_CTRL_STATUS0_TEST_SEL_OFFSET)
+#define UTMI_CHGDTC_CTRL_REG 0x38 +#define UTMI_CHGDTC_CTRL_VDAT_OFFSET 8 +#define UTMI_CHGDTC_CTRL_VDAT_MASK (0x3 << UTMI_CHGDTC_CTRL_VDAT_OFFSET) +#define UTMI_CHGDTC_CTRL_VSRC_OFFSET 10 +#define UTMI_CHGDTC_CTRL_VSRC_MASK (0x3 << UTMI_CHGDTC_CTRL_VSRC_OFFSET)
+#define UTMI_PHY_TO_USB_HOST0 0 +#define UTMI_PHY_TO_USB_HOST1 1 +#define UTMI_PHY_TO_USB_DEVICE0 2 +#define UTMI_PHY_INVALID 0xff
+#endif diff --git a/Platforms/Marvell/Library/UtmiPhyLib/UtmiPhyLib.inf b/Platforms/Marvell/Library/UtmiPhyLib/UtmiPhyLib.inf new file mode 100644 index 0000000..59e576e --- /dev/null +++ b/Platforms/Marvell/Library/UtmiPhyLib/UtmiPhyLib.inf @@ -0,0 +1,64 @@ +# Copyright (C) 2016 Marvell International Ltd. +# +# Marvell BSD License Option +# +# If you received this File from Marvell, you may opt to use, redistribute and/or +# modify this File under the following licensing terms. +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# * Neither the name of Marvell nor the names of its contributors may be +# used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#
+[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = MarvellUtmiPhyLib
- FILE_GUID = e9adaac2-0443-4921-9367-5d575c3c91bc
- MODULE_TYPE = BASE
- VERSION_STRING = 1.0
- LIBRARY_CLASS = UtmiPhyLib
+[Packages]
- MdePkg/MdePkg.dec
- MdeModulePkg/MdeModulePkg.dec
- ArmPkg/ArmPkg.dec
- ArmPlatformPkg/ArmPlatformPkg.dec
- OpenPlatformPkg/Platforms/Marvell/Marvell.dec
Sorted?
+[LibraryClasses]
- ArmLib
- DebugLib
- MemoryAllocationLib
- PcdLib
- IoLib
- ParsePcdLib
Sorted?
+[Sources.common]
- UtmiPhyLib.c
+[FixedPcd]
- gMarvellTokenSpaceGuid.PcdUtmiPhyCount
- gMarvellTokenSpaceGuid.PcdUtmiPhyRegUtmiUnit
- gMarvellTokenSpaceGuid.PcdUtmiPhyRegUsbCfg
- gMarvellTokenSpaceGuid.PcdUtmiPhyRegUtmiCfg
- gMarvellTokenSpaceGuid.PcdUtmiPhyUtmiPort
Sorted?
diff --git a/Platforms/Marvell/Marvell.dec b/Platforms/Marvell/Marvell.dec index 73102ed..7ecc89b 100644 --- a/Platforms/Marvell/Marvell.dec +++ b/Platforms/Marvell/Marvell.dec @@ -175,6 +175,13 @@ gMarvellTokenSpaceGuid.PcdChip3ComPhySpeeds|{ 0 }|VOID*|0x30000176 gMarvellTokenSpaceGuid.PcdChip3ComPhyInvFlags|{ 0 }|VOID*|0x30000177 +#UtmiPhy
- gMarvellTokenSpaceGuid.PcdUtmiPhyCount|0|UINT32|0x30000205
- gMarvellTokenSpaceGuid.PcdUtmiPhyRegUtmiUnit|{ 0 }|VOID*|0x30000206
- gMarvellTokenSpaceGuid.PcdUtmiPhyRegUsbCfg|{ 0 }|VOID*|0x30000207
- gMarvellTokenSpaceGuid.PcdUtmiPhyRegUtmiCfg|{ 0 }|VOID*|0x30000208
- gMarvellTokenSpaceGuid.PcdUtmiPhyUtmiPort|{ 0 }|VOID*|0x30000209
#SATA gMarvellTokenSpaceGuid.PcdSataBaseAddress|0|UINT32|0x4000052
Sorted?
/ Leif
From: Jan Dąbroś jsd@semihalf.com
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jan Dabros jsd@semihalf.com Signed-off-by: Marcin Wojtas mw@semihalf.com --- Platforms/Marvell/Armada/Armada.dsc.inc | 1 + Platforms/Marvell/Armada/Armada70x0.dsc | 7 +++++++ Platforms/Marvell/Armada/Library/Armada70x0Lib/Armada70x0Lib.c | 2 ++ Platforms/Marvell/Armada/Library/Armada70x0Lib/Armada70x0Lib.inf | 1 + 4 files changed, 11 insertions(+)
diff --git a/Platforms/Marvell/Armada/Armada.dsc.inc b/Platforms/Marvell/Armada/Armada.dsc.inc index 47934b2..490799b 100644 --- a/Platforms/Marvell/Armada/Armada.dsc.inc +++ b/Platforms/Marvell/Armada/Armada.dsc.inc @@ -34,6 +34,7 @@ ComPhyLib|OpenPlatformPkg/Platforms/Marvell/Library/ComPhyLib/ComPhyLib.inf MppLib|OpenPlatformPkg/Platforms/Marvell/Library/MppLib/MppLib.inf ParsePcdLib|OpenPlatformPkg/Platforms/Marvell/Library/ParsePcdLib/ParsePcdLib.inf + UtmiPhyLib|OpenPlatformPkg/Platforms/Marvell/Library/UtmiPhyLib/UtmiPhyLib.inf
DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf UncachedMemoryAllocationLib|ArmPkg/Library/UncachedMemoryAllocationLib/UncachedMemoryAllocationLib.inf diff --git a/Platforms/Marvell/Armada/Armada70x0.dsc b/Platforms/Marvell/Armada/Armada70x0.dsc index 3062591..38e7a57 100644 --- a/Platforms/Marvell/Armada/Armada70x0.dsc +++ b/Platforms/Marvell/Armada/Armada70x0.dsc @@ -105,6 +105,13 @@ gMarvellTokenSpaceGuid.PcdChip0ComPhyMuxBitCount|4 gMarvellTokenSpaceGuid.PcdChip0Compatible|L"Cp110"
+ #UtmiPhy + gMarvellTokenSpaceGuid.PcdUtmiPhyCount|2 + gMarvellTokenSpaceGuid.PcdUtmiPhyRegUtmiUnit|L"0xF2580000;0xF2581000" + gMarvellTokenSpaceGuid.PcdUtmiPhyRegUsbCfg|L"0xF2440420;0xF2440420" + gMarvellTokenSpaceGuid.PcdUtmiPhyRegUtmiCfg|L"0xF2440440;0xF2440444" + gMarvellTokenSpaceGuid.PcdUtmiPhyUtmiPort|L"0x0;0x1" + gMarvellTokenSpaceGuid.PcdChip0ComPhyTypes|L"SGMII2;USB3_HOST0;SGMII0;SATA1;USB3_HOST1;PCIE2" gMarvellTokenSpaceGuid.PcdChip0ComPhySpeeds|L"3125;5000;1250;5000;5000;5000"
diff --git a/Platforms/Marvell/Armada/Library/Armada70x0Lib/Armada70x0Lib.c b/Platforms/Marvell/Armada/Library/Armada70x0Lib/Armada70x0Lib.c index e9fe92c..0ed310f 100644 --- a/Platforms/Marvell/Armada/Library/Armada70x0Lib/Armada70x0Lib.c +++ b/Platforms/Marvell/Armada/Library/Armada70x0Lib/Armada70x0Lib.c @@ -17,6 +17,7 @@ #include <Library/ArmPlatformLib.h> #include <Library/MppLib.h> #include <Library/MvComPhyLib.h> +#include <Library/UtmiPhyLib.h> #include <Ppi/ArmMpCoreInfo.h>
@@ -94,6 +95,7 @@ ArmPlatformInitialize ( }
MvComPhyInit (); + UtmiPhyInit (); MppInitialize (); return RETURN_SUCCESS; } diff --git a/Platforms/Marvell/Armada/Library/Armada70x0Lib/Armada70x0Lib.inf b/Platforms/Marvell/Armada/Library/Armada70x0Lib/Armada70x0Lib.inf index 367d1ce..23b17f0 100644 --- a/Platforms/Marvell/Armada/Library/Armada70x0Lib/Armada70x0Lib.inf +++ b/Platforms/Marvell/Armada/Library/Armada70x0Lib/Armada70x0Lib.inf @@ -51,6 +51,7 @@ DebugLib MemoryAllocationLib MppLib + UtmiPhyLib
[Sources.common] Armada70x0Lib.c
On Mon, Sep 12, 2016 at 12:58:12PM +0200, Marcin Wojtas wrote:
From: Jan Dąbroś jsd@semihalf.com
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jan Dabros jsd@semihalf.com Signed-off-by: Marcin Wojtas mw@semihalf.com
Platforms/Marvell/Armada/Armada.dsc.inc | 1 + Platforms/Marvell/Armada/Armada70x0.dsc | 7 +++++++ Platforms/Marvell/Armada/Library/Armada70x0Lib/Armada70x0Lib.c | 2 ++ Platforms/Marvell/Armada/Library/Armada70x0Lib/Armada70x0Lib.inf | 1 + 4 files changed, 11 insertions(+)
diff --git a/Platforms/Marvell/Armada/Armada.dsc.inc b/Platforms/Marvell/Armada/Armada.dsc.inc index 47934b2..490799b 100644 --- a/Platforms/Marvell/Armada/Armada.dsc.inc +++ b/Platforms/Marvell/Armada/Armada.dsc.inc @@ -34,6 +34,7 @@ ComPhyLib|OpenPlatformPkg/Platforms/Marvell/Library/ComPhyLib/ComPhyLib.inf MppLib|OpenPlatformPkg/Platforms/Marvell/Library/MppLib/MppLib.inf ParsePcdLib|OpenPlatformPkg/Platforms/Marvell/Library/ParsePcdLib/ParsePcdLib.inf
- UtmiPhyLib|OpenPlatformPkg/Platforms/Marvell/Library/UtmiPhyLib/UtmiPhyLib.inf
DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf UncachedMemoryAllocationLib|ArmPkg/Library/UncachedMemoryAllocationLib/UncachedMemoryAllocationLib.inf diff --git a/Platforms/Marvell/Armada/Armada70x0.dsc b/Platforms/Marvell/Armada/Armada70x0.dsc index 3062591..38e7a57 100644 --- a/Platforms/Marvell/Armada/Armada70x0.dsc +++ b/Platforms/Marvell/Armada/Armada70x0.dsc @@ -105,6 +105,13 @@ gMarvellTokenSpaceGuid.PcdChip0ComPhyMuxBitCount|4 gMarvellTokenSpaceGuid.PcdChip0Compatible|L"Cp110"
- #UtmiPhy
- gMarvellTokenSpaceGuid.PcdUtmiPhyCount|2
- gMarvellTokenSpaceGuid.PcdUtmiPhyRegUtmiUnit|L"0xF2580000;0xF2581000"
- gMarvellTokenSpaceGuid.PcdUtmiPhyRegUsbCfg|L"0xF2440420;0xF2440420"
- gMarvellTokenSpaceGuid.PcdUtmiPhyRegUtmiCfg|L"0xF2440440;0xF2440444"
- gMarvellTokenSpaceGuid.PcdUtmiPhyUtmiPort|L"0x0;0x1"
Sorted?
/ Leif
- gMarvellTokenSpaceGuid.PcdChip0ComPhyTypes|L"SGMII2;USB3_HOST0;SGMII0;SATA1;USB3_HOST1;PCIE2" gMarvellTokenSpaceGuid.PcdChip0ComPhySpeeds|L"3125;5000;1250;5000;5000;5000"
diff --git a/Platforms/Marvell/Armada/Library/Armada70x0Lib/Armada70x0Lib.c b/Platforms/Marvell/Armada/Library/Armada70x0Lib/Armada70x0Lib.c index e9fe92c..0ed310f 100644 --- a/Platforms/Marvell/Armada/Library/Armada70x0Lib/Armada70x0Lib.c +++ b/Platforms/Marvell/Armada/Library/Armada70x0Lib/Armada70x0Lib.c @@ -17,6 +17,7 @@ #include <Library/ArmPlatformLib.h> #include <Library/MppLib.h> #include <Library/MvComPhyLib.h> +#include <Library/UtmiPhyLib.h> #include <Ppi/ArmMpCoreInfo.h> @@ -94,6 +95,7 @@ ArmPlatformInitialize ( } MvComPhyInit ();
- UtmiPhyInit (); MppInitialize (); return RETURN_SUCCESS;
} diff --git a/Platforms/Marvell/Armada/Library/Armada70x0Lib/Armada70x0Lib.inf b/Platforms/Marvell/Armada/Library/Armada70x0Lib/Armada70x0Lib.inf index 367d1ce..23b17f0 100644 --- a/Platforms/Marvell/Armada/Library/Armada70x0Lib/Armada70x0Lib.inf +++ b/Platforms/Marvell/Armada/Library/Armada70x0Lib/Armada70x0Lib.inf @@ -51,6 +51,7 @@ DebugLib MemoryAllocationLib MppLib
- UtmiPhyLib
[Sources.common] Armada70x0Lib.c -- 1.8.3.1
From: Bartosz Szczepanek bsz@semihalf.com
MvResetSystem driver implements functionality required to restart the platform. This approach implements Reset in a way that is compatible with ResetSystem runtime service.
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Bartosz Szczepanek bsz@semihalf.com Signed-off-by: Jan Dabros jsd@semihalf.com Signed-off-by: Marcin Wojtas mw@semihalf.com --- Documentation/Marvell/PortingGuide/Reset.txt | 7 ++ Drivers/ResetSystem/MvResetSystem.c | 158 +++++++++++++++++++++++++++ Drivers/ResetSystem/MvResetSystem.inf | 65 +++++++++++ Platforms/Marvell/Marvell.dec | 4 + 4 files changed, 234 insertions(+) create mode 100644 Documentation/Marvell/PortingGuide/Reset.txt create mode 100644 Drivers/ResetSystem/MvResetSystem.c create mode 100644 Drivers/ResetSystem/MvResetSystem.inf
diff --git a/Documentation/Marvell/PortingGuide/Reset.txt b/Documentation/Marvell/PortingGuide/Reset.txt new file mode 100644 index 0000000..1430fc0 --- /dev/null +++ b/Documentation/Marvell/PortingGuide/Reset.txt @@ -0,0 +1,7 @@ +MarvellResetSystemLib configuration +----------------------------------- +This simple library allows to mask given bits in given reg at UEFI 'reset' +command call. These variables are configurable through PCDs: + + gMarvellTokenSpaceGuid.PcdResetRegAddress + gMarvellTokenSpaceGuid.PcdResetRegMask diff --git a/Drivers/ResetSystem/MvResetSystem.c b/Drivers/ResetSystem/MvResetSystem.c new file mode 100644 index 0000000..79aa86e --- /dev/null +++ b/Drivers/ResetSystem/MvResetSystem.c @@ -0,0 +1,158 @@ +/******************************************************************************** +Copyright (C) 2016 Marvell International Ltd. + +Marvell BSD License Option + +If you received this File from Marvell, you may opt to use, redistribute and/or +modify this File under the following licensing terms. +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + * Neither the name of Marvell nor the names of its contributors may be + used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*******************************************************************************/ + + +#include <Guid/EventGroup.h> +#include <Library/DebugLib.h> +#include <Library/DxeServicesTableLib.h> +#include <Library/IoLib.h> +#include <Library/UefiBootServicesTableLib.h> +#include <Library/UefiDriverEntryPoint.h> +#include <Library/UefiRuntimeLib.h> +#include <Library/UefiRuntimeServicesTableLib.h> +#include <PiDxe.h> +#include <Protocol/Reset.h> + +STATIC EFI_EVENT mResetSystemVirtualAddrChangeEvent; +STATIC UINT64 mAddress; + +VOID +EFIAPI +LibResetSystemVirtualNotifyEvent ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + // + // Convert physical address to virtual address. + // + EfiConvertPointer (0x0, (VOID**)&mAddress); + return; +} + +/** + Resets the entire platform. + + @param ResetType The type of reset to perform. + @param ResetStatus The status code for the reset. + @param DataSize The size, in bytes, of WatchdogData. + @param ResetData For a ResetType of EfiResetCold, EfiResetWarm, + or EfiResetShutdown the data buffer starts with + a Null-terminated Unicode string, optionally + followed by additional binary data. +**/ +VOID +EFIAPI +ResetSystemViaLib ( + IN EFI_RESET_TYPE ResetType, + IN EFI_STATUS ResetStatus, + IN UINTN DataSize, + IN VOID *ResetData OPTIONAL + ) +{ + UINT32 Data; + + switch (ResetType) { + case EfiResetCold: + case EfiResetWarm: + Data = MmioRead32 (mAddress); + Data &= ~PcdGet32 (PcdResetRegMask); + MmioWrite32 (mAddress, Data); + break; + case EfiResetShutdown: + return; + break; + + default: + return; + } + + return; +} + +EFI_STATUS +EFIAPI +InitializeReset ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + EFI_HANDLE Handle; + + mAddress = PcdGet64 (PcdResetRegAddress); + + Status = gDS->AddMemorySpace ( + EfiGcdMemoryTypeMemoryMappedIo, + mAddress & ~(EFI_PAGE_MASK), SIZE_4KB, + EFI_MEMORY_UC | EFI_MEMORY_RUNTIME + ); + if (EFI_ERROR (Status)) { + ASSERT_EFI_ERROR (Status); + return Status; + } + + Status = gDS->SetMemorySpaceAttributes (mAddress & ~(EFI_PAGE_MASK), SIZE_4KB, + EFI_MEMORY_UC | EFI_MEMORY_RUNTIME); + if (EFI_ERROR (Status)) { + ASSERT_EFI_ERROR (Status); + return Status; + } + + gRT->ResetSystem = ResetSystemViaLib; + + Handle = NULL; + Status = gBS->InstallMultipleProtocolInterfaces ( + &Handle, + &gEfiResetArchProtocolGuid, + NULL, + NULL + ); + ASSERT_EFI_ERROR (Status); + + // + // Register for the virtual address change event + // + Status = gBS->CreateEventEx ( + EVT_NOTIFY_SIGNAL, + TPL_NOTIFY, + LibResetSystemVirtualNotifyEvent, + NULL, + &gEfiEventVirtualAddressChangeGuid, + &mResetSystemVirtualAddrChangeEvent + ); + ASSERT_EFI_ERROR (Status); + + return Status; +} diff --git a/Drivers/ResetSystem/MvResetSystem.inf b/Drivers/ResetSystem/MvResetSystem.inf new file mode 100644 index 0000000..ab7db92 --- /dev/null +++ b/Drivers/ResetSystem/MvResetSystem.inf @@ -0,0 +1,65 @@ +# Copyright (C) 2016 Marvell International Ltd. +# +# Marvell BSD License Option +# +# If you received this File from Marvell, you may opt to use, redistribute and/or +# modify this File under the following licensing terms. +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# * Neither the name of Marvell nor the names of its contributors may be +# used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = Reset + FILE_GUID = 9d1373c0-6fac-432c-88e7-818744dc45d9 + MODULE_TYPE = DXE_RUNTIME_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = InitializeReset + +[Sources.common] + MvResetSystem.c + +[Packages] + MdePkg/MdePkg.dec + OpenPlatformPkg/Platforms/Marvell/Marvell.dec + +[LibraryClasses] + UefiBootServicesTableLib + UefiDriverEntryPoint + DebugLib + IoLib + UefiLib + DxeServicesTableLib + UefiRuntimeLib + +[Pcd] + gMarvellTokenSpaceGuid.PcdResetRegAddress + gMarvellTokenSpaceGuid.PcdResetRegMask + +[Protocols] + gEfiResetArchProtocolGuid # PROTOCOL ALWAYS_PRODUCED + +[Depex] + TRUE diff --git a/Platforms/Marvell/Marvell.dec b/Platforms/Marvell/Marvell.dec index 7ecc89b..a646cc3 100644 --- a/Platforms/Marvell/Marvell.dec +++ b/Platforms/Marvell/Marvell.dec @@ -193,6 +193,10 @@ gMarvellTokenSpaceGuid.PcdPhyDeviceIds|{ 0 }|VOID*|0x3000095 gMarvellTokenSpaceGuid.PcdPhyStartupAutoneg|FALSE|BOOLEAN|0x3000070
+#ResetLib + gMarvellTokenSpaceGuid.PcdResetRegAddress|0|UINT64|0x40000050 + gMarvellTokenSpaceGuid.PcdResetRegMask|0|UINT32|0x4000051 + [Protocols] gMarvellEepromProtocolGuid = { 0xcd728a1f, 0x45b5, 0x4feb, { 0x98, 0xc8, 0x31, 0x3d, 0xa8, 0x11, 0x74, 0x62 }} gMarvellMdioProtocolGuid = { 0x0d728a1f, 0x45b5, 0x4feb, { 0x98, 0xc8, 0x31, 0x3d, 0xa8, 0x11, 0x74, 0x62 }}
On Mon, Sep 12, 2016 at 12:58:13PM +0200, Marcin Wojtas wrote:
From: Bartosz Szczepanek bsz@semihalf.com
MvResetSystem driver implements functionality required to restart the platform. This approach implements Reset in a way that is compatible with ResetSystem runtime service.
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Bartosz Szczepanek bsz@semihalf.com Signed-off-by: Jan Dabros jsd@semihalf.com Signed-off-by: Marcin Wojtas mw@semihalf.com
Documentation/Marvell/PortingGuide/Reset.txt | 7 ++ Drivers/ResetSystem/MvResetSystem.c | 158 +++++++++++++++++++++++++++ Drivers/ResetSystem/MvResetSystem.inf | 65 +++++++++++ Platforms/Marvell/Marvell.dec | 4 + 4 files changed, 234 insertions(+) create mode 100644 Documentation/Marvell/PortingGuide/Reset.txt create mode 100644 Drivers/ResetSystem/MvResetSystem.c create mode 100644 Drivers/ResetSystem/MvResetSystem.inf
diff --git a/Documentation/Marvell/PortingGuide/Reset.txt b/Documentation/Marvell/PortingGuide/Reset.txt new file mode 100644 index 0000000..1430fc0 --- /dev/null +++ b/Documentation/Marvell/PortingGuide/Reset.txt @@ -0,0 +1,7 @@ +MarvellResetSystemLib configuration +----------------------------------- +This simple library allows to mask given bits in given reg at UEFI 'reset' +command call. These variables are configurable through PCDs:
- gMarvellTokenSpaceGuid.PcdResetRegAddress
- gMarvellTokenSpaceGuid.PcdResetRegMask
diff --git a/Drivers/ResetSystem/MvResetSystem.c b/Drivers/ResetSystem/MvResetSystem.c new file mode 100644 index 0000000..79aa86e --- /dev/null +++ b/Drivers/ResetSystem/MvResetSystem.c @@ -0,0 +1,158 @@ +/******************************************************************************** +Copyright (C) 2016 Marvell International Ltd.
+Marvell BSD License Option
+If you received this File from Marvell, you may opt to use, redistribute and/or +modify this File under the following licensing terms. +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- Neither the name of Marvell nor the names of its contributors may be
- used to endorse or promote products derived from this software without
- specific prior written permission.
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*******************************************************************************/
+#include <Guid/EventGroup.h> +#include <Library/DebugLib.h> +#include <Library/DxeServicesTableLib.h> +#include <Library/IoLib.h> +#include <Library/UefiBootServicesTableLib.h> +#include <Library/UefiDriverEntryPoint.h> +#include <Library/UefiRuntimeLib.h> +#include <Library/UefiRuntimeServicesTableLib.h> +#include <PiDxe.h> +#include <Protocol/Reset.h>
+STATIC EFI_EVENT mResetSystemVirtualAddrChangeEvent; +STATIC UINT64 mAddress;
STATIC?
+VOID +EFIAPI +LibResetSystemVirtualNotifyEvent (
- IN EFI_EVENT Event,
- IN VOID *Context
- )
+{
- //
- // Convert physical address to virtual address.
- //
- EfiConvertPointer (0x0, (VOID**)&mAddress);
- return;
+}
+/**
- Resets the entire platform.
- @param ResetType The type of reset to perform.
- @param ResetStatus The status code for the reset.
- @param DataSize The size, in bytes, of WatchdogData.
- @param ResetData For a ResetType of EfiResetCold, EfiResetWarm,
or EfiResetShutdown the data buffer starts with
a Null-terminated Unicode string, optionally
followed by additional binary data.
+**/
STATIC?
+VOID +EFIAPI +ResetSystemViaLib (
- IN EFI_RESET_TYPE ResetType,
- IN EFI_STATUS ResetStatus,
- IN UINTN DataSize,
- IN VOID *ResetData OPTIONAL
- )
+{
- UINT32 Data;
- switch (ResetType) {
- case EfiResetCold:
- case EfiResetWarm:
- Data = MmioRead32 (mAddress);
- Data &= ~PcdGet32 (PcdResetRegMask);
- MmioWrite32 (mAddress, Data);
- break;
- case EfiResetShutdown:
- return;
- break;
Delete blank line.
- default:
- return;
- }
- return;
+}
+EFI_STATUS +EFIAPI +InitializeReset (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
+{
- EFI_STATUS Status;
- EFI_HANDLE Handle;
- mAddress = PcdGet64 (PcdResetRegAddress);
- Status = gDS->AddMemorySpace (
EfiGcdMemoryTypeMemoryMappedIo,
mAddress & ~(EFI_PAGE_MASK), SIZE_4KB,
EFI_MEMORY_UC | EFI_MEMORY_RUNTIME
);
To permit this to work as expected under a kernel with 16/64k pages, it would be useful to set up a 64k aligned 64k page. (If that memory region contains other things, a big warning in a comment here wouldn't go amiss.)
- if (EFI_ERROR (Status)) {
- ASSERT_EFI_ERROR (Status);
- return Status;
- }
- Status = gDS->SetMemorySpaceAttributes (mAddress & ~(EFI_PAGE_MASK), SIZE_4KB,
- EFI_MEMORY_UC | EFI_MEMORY_RUNTIME);
- if (EFI_ERROR (Status)) {
- ASSERT_EFI_ERROR (Status);
- return Status;
- }
- gRT->ResetSystem = ResetSystemViaLib;
- Handle = NULL;
- Status = gBS->InstallMultipleProtocolInterfaces (
&Handle,
&gEfiResetArchProtocolGuid,
NULL,
NULL
);
- ASSERT_EFI_ERROR (Status);
- //
- // Register for the virtual address change event
- //
- Status = gBS->CreateEventEx (
EVT_NOTIFY_SIGNAL,
TPL_NOTIFY,
LibResetSystemVirtualNotifyEvent,
NULL,
&gEfiEventVirtualAddressChangeGuid,
&mResetSystemVirtualAddrChangeEvent
);
- ASSERT_EFI_ERROR (Status);
- return Status;
+} diff --git a/Drivers/ResetSystem/MvResetSystem.inf b/Drivers/ResetSystem/MvResetSystem.inf new file mode 100644 index 0000000..ab7db92 --- /dev/null +++ b/Drivers/ResetSystem/MvResetSystem.inf @@ -0,0 +1,65 @@ +# Copyright (C) 2016 Marvell International Ltd. +# +# Marvell BSD License Option +# +# If you received this File from Marvell, you may opt to use, redistribute and/or +# modify this File under the following licensing terms. +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# * Neither the name of Marvell nor the names of its contributors may be +# used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#
+[Defines]
- INF_VERSION = 0x00010005
So, having recently read the .INF file spec - this should probably be 0x00010019, if you want to be current :)
- BASE_NAME = Reset
- FILE_GUID = 9d1373c0-6fac-432c-88e7-818744dc45d9
- MODULE_TYPE = DXE_RUNTIME_DRIVER
- VERSION_STRING = 1.0
- ENTRY_POINT = InitializeReset
+[Sources.common]
- MvResetSystem.c
+[Packages]
- MdePkg/MdePkg.dec
- OpenPlatformPkg/Platforms/Marvell/Marvell.dec
+[LibraryClasses]
- UefiBootServicesTableLib
- UefiDriverEntryPoint
- DebugLib
- IoLib
- UefiLib
- DxeServicesTableLib
- UefiRuntimeLib
Sorted?
/ Leif
+[Pcd]
- gMarvellTokenSpaceGuid.PcdResetRegAddress
- gMarvellTokenSpaceGuid.PcdResetRegMask
+[Protocols]
- gEfiResetArchProtocolGuid # PROTOCOL ALWAYS_PRODUCED
+[Depex]
- TRUE
diff --git a/Platforms/Marvell/Marvell.dec b/Platforms/Marvell/Marvell.dec index 7ecc89b..a646cc3 100644 --- a/Platforms/Marvell/Marvell.dec +++ b/Platforms/Marvell/Marvell.dec @@ -193,6 +193,10 @@ gMarvellTokenSpaceGuid.PcdPhyDeviceIds|{ 0 }|VOID*|0x3000095 gMarvellTokenSpaceGuid.PcdPhyStartupAutoneg|FALSE|BOOLEAN|0x3000070 +#ResetLib
- gMarvellTokenSpaceGuid.PcdResetRegAddress|0|UINT64|0x40000050
- gMarvellTokenSpaceGuid.PcdResetRegMask|0|UINT32|0x4000051
[Protocols] gMarvellEepromProtocolGuid = { 0xcd728a1f, 0x45b5, 0x4feb, { 0x98, 0xc8, 0x31, 0x3d, 0xa8, 0x11, 0x74, 0x62 }} gMarvellMdioProtocolGuid = { 0x0d728a1f, 0x45b5, 0x4feb, { 0x98, 0xc8, 0x31, 0x3d, 0xa8, 0x11, 0x74, 0x62 }} -- 1.8.3.1
From: Bartosz Szczepanek bsz@semihalf.com
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Bartosz Szczepanek bsz@semihalf.com Signed-off-by: Marcin Wojtas mw@semihalf.com --- Platforms/Marvell/Armada/Armada.dsc.inc | 3 +-- Platforms/Marvell/Armada/Armada70x0.dsc | 4 ++++ Platforms/Marvell/Armada/Armada70x0.fdf | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/Platforms/Marvell/Armada/Armada.dsc.inc b/Platforms/Marvell/Armada/Armada.dsc.inc index 490799b..79cdd2f 100644 --- a/Platforms/Marvell/Armada/Armada.dsc.inc +++ b/Platforms/Marvell/Armada/Armada.dsc.inc @@ -89,7 +89,6 @@ PlatformHookLib|MdeModulePkg/Library/BasePlatformHookLibNull/BasePlatformHookLibNull.inf
# Reset and Time libraries - EfiResetSystemLib|EmbeddedPkg/Library/TemplateResetSystemLib/TemplateResetSystemLib.inf RealTimeClockLib|EmbeddedPkg/Library/TemplateRealTimeClockLib/TemplateRealTimeClockLib.inf
# Network support @@ -411,7 +410,7 @@ MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntimeDxe.inf
EmbeddedPkg/EmbeddedMonotonicCounter/EmbeddedMonotonicCounter.inf - EmbeddedPkg/ResetRuntimeDxe/ResetRuntimeDxe.inf + OpenPlatformPkg/Drivers/ResetSystem/MvResetSystem.inf EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf EmbeddedPkg/MetronomeDxe/MetronomeDxe.inf
diff --git a/Platforms/Marvell/Armada/Armada70x0.dsc b/Platforms/Marvell/Armada/Armada70x0.dsc index 38e7a57..4f353ee 100644 --- a/Platforms/Marvell/Armada/Armada70x0.dsc +++ b/Platforms/Marvell/Armada/Armada70x0.dsc @@ -122,3 +122,7 @@ gMarvellTokenSpaceGuid.PcdPhyConnectionTypes|{ 0x0, 0x0 } gMarvellTokenSpaceGuid.PcdPhyDeviceIds|{ 0x0, 0x0 } gMarvellTokenSpaceGuid.PcdPhyStartupAutoneg|FALSE + + #ResetLib + gMarvellTokenSpaceGuid.PcdResetRegAddress|0xf06f0084 + gMarvellTokenSpaceGuid.PcdResetRegMask|0x1 diff --git a/Platforms/Marvell/Armada/Armada70x0.fdf b/Platforms/Marvell/Armada/Armada70x0.fdf index c56d4e3..2c215b9 100644 --- a/Platforms/Marvell/Armada/Armada70x0.fdf +++ b/Platforms/Marvell/Armada/Armada70x0.fdf @@ -99,7 +99,7 @@ FvNameGuid = 5eda4200-2c5f-43cb-9da3-0baf74b1b30c INF MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf INF MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntimeDxe.inf INF EmbeddedPkg/EmbeddedMonotonicCounter/EmbeddedMonotonicCounter.inf - INF EmbeddedPkg/ResetRuntimeDxe/ResetRuntimeDxe.inf + INF OpenPlatformPkg/Drivers/ResetSystem/MvResetSystem.inf INF EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf INF EmbeddedPkg/MetronomeDxe/MetronomeDxe.inf INF OpenPlatformPkg/Drivers/I2c/MvI2cDxe/MvI2cDxe.inf
On Mon, Sep 12, 2016 at 12:58:14PM +0200, Marcin Wojtas wrote:
From: Bartosz Szczepanek bsz@semihalf.com
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Bartosz Szczepanek bsz@semihalf.com Signed-off-by: Marcin Wojtas mw@semihalf.com
Platforms/Marvell/Armada/Armada.dsc.inc | 3 +-- Platforms/Marvell/Armada/Armada70x0.dsc | 4 ++++ Platforms/Marvell/Armada/Armada70x0.fdf | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/Platforms/Marvell/Armada/Armada.dsc.inc b/Platforms/Marvell/Armada/Armada.dsc.inc index 490799b..79cdd2f 100644 --- a/Platforms/Marvell/Armada/Armada.dsc.inc +++ b/Platforms/Marvell/Armada/Armada.dsc.inc @@ -89,7 +89,6 @@ PlatformHookLib|MdeModulePkg/Library/BasePlatformHookLibNull/BasePlatformHookLibNull.inf # Reset and Time libraries
- EfiResetSystemLib|EmbeddedPkg/Library/TemplateResetSystemLib/TemplateResetSystemLib.inf RealTimeClockLib|EmbeddedPkg/Library/TemplateRealTimeClockLib/TemplateRealTimeClockLib.inf
# Network support @@ -411,7 +410,7 @@ MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntimeDxe.inf EmbeddedPkg/EmbeddedMonotonicCounter/EmbeddedMonotonicCounter.inf
- EmbeddedPkg/ResetRuntimeDxe/ResetRuntimeDxe.inf
OK, so this doesn't really affect this patch, but can you explain why you decided to not use ResetRuntimeDxe?
Reviewed-by: Leif Lindholm leif.lindholm@linaro.org
- OpenPlatformPkg/Drivers/ResetSystem/MvResetSystem.inf EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf EmbeddedPkg/MetronomeDxe/MetronomeDxe.inf
diff --git a/Platforms/Marvell/Armada/Armada70x0.dsc b/Platforms/Marvell/Armada/Armada70x0.dsc index 38e7a57..4f353ee 100644 --- a/Platforms/Marvell/Armada/Armada70x0.dsc +++ b/Platforms/Marvell/Armada/Armada70x0.dsc @@ -122,3 +122,7 @@ gMarvellTokenSpaceGuid.PcdPhyConnectionTypes|{ 0x0, 0x0 } gMarvellTokenSpaceGuid.PcdPhyDeviceIds|{ 0x0, 0x0 } gMarvellTokenSpaceGuid.PcdPhyStartupAutoneg|FALSE
- #ResetLib
- gMarvellTokenSpaceGuid.PcdResetRegAddress|0xf06f0084
- gMarvellTokenSpaceGuid.PcdResetRegMask|0x1
diff --git a/Platforms/Marvell/Armada/Armada70x0.fdf b/Platforms/Marvell/Armada/Armada70x0.fdf index c56d4e3..2c215b9 100644 --- a/Platforms/Marvell/Armada/Armada70x0.fdf +++ b/Platforms/Marvell/Armada/Armada70x0.fdf @@ -99,7 +99,7 @@ FvNameGuid = 5eda4200-2c5f-43cb-9da3-0baf74b1b30c INF MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf INF MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntimeDxe.inf INF EmbeddedPkg/EmbeddedMonotonicCounter/EmbeddedMonotonicCounter.inf
- INF EmbeddedPkg/ResetRuntimeDxe/ResetRuntimeDxe.inf
- INF OpenPlatformPkg/Drivers/ResetSystem/MvResetSystem.inf INF EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf INF EmbeddedPkg/MetronomeDxe/MetronomeDxe.inf INF OpenPlatformPkg/Drivers/I2c/MvI2cDxe/MvI2cDxe.inf
-- 1.8.3.1
Hi Leif,
Thanks for your review. In general I agree with all of your comments, so I wouldn't response to them. The only exception is your question here, please find answear inline.
Best Regards, Jan
EmbeddedPkg/EmbeddedMonotonicCounter/EmbeddedMonotonicCounter.inf
- EmbeddedPkg/ResetRuntimeDxe/ResetRuntimeDxe.inf
OK, so this doesn't really affect this patch, but can you explain why you decided to not use ResetRuntimeDxe?
We have used ResetRuntimeDxe for our old Reset implementation, but it wasn't compatible with ResetRuntimeService (and obviously didn't work from OS). That's why I decided to write completely new driver. As I review ResetRuntimeDxe code, I think I should use it and add my driver as LibResetSystem implementation. I will try to achieve it in v2.
Apologies I took so long to get around to reviewing, UEFI plugfest, Linaro Connect, preparations for both and catching up afterwards took nearly a month out of my schedule :]
Expect much faster turnaround in future.
Best Regards,
Leif
On Mon, Sep 12, 2016 at 12:58:09PM +0200, Marcin Wojtas wrote:
Hi,
Because network rework has not been going smoothely, let's remove it from the platform upstream hotpath. It's being finalized in background and will be sent later, once ready. Hereby I present small patchset with three items - introduce USB2.0 PHY support (so called UTMI), reset driver and small I2c fix for devices' enumeration.
The patches are also available in the public github tree: https://github.com/MarvellEmbeddedProcessors/edk2-open-platform/commits/opp-...
Any comments or remarks would be welcome.
Best regards, Marcin
Bartosz Szczepanek (2): Platforms/Marvell: Add MvResetSystem driver Platforms/Marvell: Enable MvResetSystem driver for A70x0 platform
Jan Dąbroś (3): Drivers/I2c: Fix enumaration of I2c devices Platforms/Marvell: Add UtmiPhyLib Platforms/Marvell: Enable UtmiPhyLib for Armada70x0 Platforms
Documentation/Marvell/PortingGuide/Reset.txt | 7 + Documentation/Marvell/PortingGuide/Utmi.txt | 35 ++ Drivers/I2c/MvI2cDxe/MvI2cDxe.c | 13 +- Drivers/ResetSystem/MvResetSystem.c | 158 +++++++++ Drivers/ResetSystem/MvResetSystem.inf | 65 ++++ Platforms/Marvell/Armada/Armada.dsc.inc | 4 +- Platforms/Marvell/Armada/Armada70x0.dsc | 11 + Platforms/Marvell/Armada/Armada70x0.fdf | 2 +- .../Armada/Library/Armada70x0Lib/Armada70x0Lib.c | 2 + .../Armada/Library/Armada70x0Lib/Armada70x0Lib.inf | 1 + Platforms/Marvell/Include/Library/UtmiPhyLib.h | 43 +++ Platforms/Marvell/Library/UtmiPhyLib/UtmiPhyLib.c | 352 +++++++++++++++++++++ Platforms/Marvell/Library/UtmiPhyLib/UtmiPhyLib.h | 110 +++++++ .../Marvell/Library/UtmiPhyLib/UtmiPhyLib.inf | 64 ++++ Platforms/Marvell/Marvell.dec | 11 + 15 files changed, 869 insertions(+), 9 deletions(-) create mode 100644 Documentation/Marvell/PortingGuide/Reset.txt create mode 100644 Documentation/Marvell/PortingGuide/Utmi.txt create mode 100644 Drivers/ResetSystem/MvResetSystem.c create mode 100644 Drivers/ResetSystem/MvResetSystem.inf create mode 100644 Platforms/Marvell/Include/Library/UtmiPhyLib.h create mode 100644 Platforms/Marvell/Library/UtmiPhyLib/UtmiPhyLib.c create mode 100644 Platforms/Marvell/Library/UtmiPhyLib/UtmiPhyLib.h create mode 100644 Platforms/Marvell/Library/UtmiPhyLib/UtmiPhyLib.inf
-- 1.8.3.1
Hi Leif,
Thanks a lot for your remarks. We will try to proceed now as fast as possible on our side, so that we can get over upstreaming whole support quickly.
Best regards, Marcin
2016-10-10 20:51 GMT+02:00 Leif Lindholm leif.lindholm@linaro.org:
Apologies I took so long to get around to reviewing, UEFI plugfest, Linaro Connect, preparations for both and catching up afterwards took nearly a month out of my schedule :]
Expect much faster turnaround in future.
Best Regards,
Leif
On Mon, Sep 12, 2016 at 12:58:09PM +0200, Marcin Wojtas wrote:
Hi,
Because network rework has not been going smoothely, let's remove it from the platform upstream hotpath. It's being finalized in background and will be sent later, once ready. Hereby I present small patchset with three items - introduce USB2.0 PHY support (so called UTMI), reset driver and small I2c fix for devices' enumeration.
The patches are also available in the public github tree: https://github.com/MarvellEmbeddedProcessors/edk2-open-platform/commits/opp-...
Any comments or remarks would be welcome.
Best regards, Marcin
Bartosz Szczepanek (2): Platforms/Marvell: Add MvResetSystem driver Platforms/Marvell: Enable MvResetSystem driver for A70x0 platform
Jan Dąbroś (3): Drivers/I2c: Fix enumaration of I2c devices Platforms/Marvell: Add UtmiPhyLib Platforms/Marvell: Enable UtmiPhyLib for Armada70x0 Platforms
Documentation/Marvell/PortingGuide/Reset.txt | 7 + Documentation/Marvell/PortingGuide/Utmi.txt | 35 ++ Drivers/I2c/MvI2cDxe/MvI2cDxe.c | 13 +- Drivers/ResetSystem/MvResetSystem.c | 158 +++++++++ Drivers/ResetSystem/MvResetSystem.inf | 65 ++++ Platforms/Marvell/Armada/Armada.dsc.inc | 4 +- Platforms/Marvell/Armada/Armada70x0.dsc | 11 + Platforms/Marvell/Armada/Armada70x0.fdf | 2 +- .../Armada/Library/Armada70x0Lib/Armada70x0Lib.c | 2 + .../Armada/Library/Armada70x0Lib/Armada70x0Lib.inf | 1 + Platforms/Marvell/Include/Library/UtmiPhyLib.h | 43 +++ Platforms/Marvell/Library/UtmiPhyLib/UtmiPhyLib.c | 352 +++++++++++++++++++++ Platforms/Marvell/Library/UtmiPhyLib/UtmiPhyLib.h | 110 +++++++ .../Marvell/Library/UtmiPhyLib/UtmiPhyLib.inf | 64 ++++ Platforms/Marvell/Marvell.dec | 11 + 15 files changed, 869 insertions(+), 9 deletions(-) create mode 100644 Documentation/Marvell/PortingGuide/Reset.txt create mode 100644 Documentation/Marvell/PortingGuide/Utmi.txt create mode 100644 Drivers/ResetSystem/MvResetSystem.c create mode 100644 Drivers/ResetSystem/MvResetSystem.inf create mode 100644 Platforms/Marvell/Include/Library/UtmiPhyLib.h create mode 100644 Platforms/Marvell/Library/UtmiPhyLib/UtmiPhyLib.c create mode 100644 Platforms/Marvell/Library/UtmiPhyLib/UtmiPhyLib.h create mode 100644 Platforms/Marvell/Library/UtmiPhyLib/UtmiPhyLib.inf
-- 1.8.3.1