Skip to content

Commit

Permalink
Drivers: ClockDxe: Turn on clocks in specific drivers instead
Browse files Browse the repository at this point in the history
  • Loading branch information
Dominduchami committed Feb 6, 2024
1 parent 807da33 commit cbc6932
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 42 deletions.
52 changes: 15 additions & 37 deletions HtcLeoPkg/GPLDrivers/ClockDxe/ClockDxe.c
Original file line number Diff line number Diff line change
Expand Up @@ -274,22 +274,6 @@ int msm_pll_request(unsigned id, unsigned on)
return msm_proc_comm(PCOM_CLKCTL_RPC_PLL_REQUEST, &id, &on);
}

static int ClocksOn[] = {
SDC1_CLK,
SDC2_CLK,
SDC3_CLK,
SDC4_CLK,
};

EFI_STATUS
MsmClockInit(VOID)
{
for (int i = 0; i < (int)ARRAY_SIZE(ClocksOn); i++)
ClkEnable(ClocksOn[i]);

return EFI_SUCCESS;
}

/**
Protocol variable definition
**/
Expand All @@ -315,28 +299,22 @@ ClockDxeInitialize(
ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEmbeddedClockProtocolGuid);

FillClocksLookup();
if (MsmClockInit() == EFI_SUCCESS)
{
DEBUG((EFI_D_INFO, "Clock init done!\n"));

// Install the Embedded Clock Protocol onto a new handle
Handle = NULL;
Status = gBS->InstallMultipleProtocolInterfaces (
&Handle,
&gEmbeddedClockProtocolGuid,
&gClock,
NULL
);

if (EFI_ERROR (Status)) {
Status = EFI_OUT_OF_RESOURCES;
}
// Setup Scorpion PLL
msm_acpu_clock_init(11+6);

// Setup Scorpion PLL
msm_acpu_clock_init(11+6);
return EFI_SUCCESS;
}
else {
return EFI_D_ERROR;
// Install the Embedded Clock Protocol onto a new handle
Handle = NULL;
Status = gBS->InstallMultipleProtocolInterfaces (
&Handle,
&gEmbeddedClockProtocolGuid,
&gClock,
NULL
);

if (EFI_ERROR (Status)) {
Status = EFI_OUT_OF_RESOURCES;
}

return EFI_SUCCESS;
}
4 changes: 0 additions & 4 deletions HtcLeoPkg/GPLDrivers/ClockDxe/acpuclock.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ unsigned acpuclk_init_done = 0;
#define SRC_RAW 0 /* clock from SPSS_CLK_CNTL */
#define SRC_SCPLL 1 /* output of scpll 128-998 MHZ */

//#define dmb() __asm__ __volatile__("DMB")

//extern void dmb(void);

/* Set rate and enable the clock */
void clock_config(UINT32 ns, UINT32 md, UINT32 ns_addr, UINT32 md_addr)
{
Expand Down
14 changes: 13 additions & 1 deletion HtcLeoPkg/GPLDrivers/SdCardDxe/SdCardDxe.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
#include <Protocol/BlockIo.h>
#include <Protocol/DevicePath.h>
#include <Protocol/GpioTlmm.h>
#include <Protocol/EmbeddedClock.h>

#include <Chipset/clock.h>

#include "SdCardDxe.h"

Expand All @@ -46,6 +49,9 @@ static block_dev_desc_t *sdc_dev;
// Cached copy of the Hardware Gpio protocol instance
TLMM_GPIO *gGpio = NULL;

// Cached copy of the Embedded Clock protocol instance
EMBEDDED_CLOCK_PROTOCOL *gClock = NULL;

EFI_BLOCK_IO_MEDIA gMMCHSMedia =
{
SIGNATURE_32('s', 'd', 'c', 'c'), // MediaId
Expand Down Expand Up @@ -83,7 +89,6 @@ MMCHS_DEVICE_PATH gMmcHsDevicePath = {
};



/**
Reset the Block Device.
Expand Down Expand Up @@ -296,8 +301,15 @@ SdCardInitialize(
Status = gBS->LocateProtocol (&gTlmmGpioProtocolGuid, NULL, (VOID **)&gGpio);
ASSERT_EFI_ERROR (Status);

// Find the clock controller protocol. ASSERT if not found.
Status = gBS->LocateProtocol (&gEmbeddedClockProtocolGuid, NULL, (VOID **)&gClock);
ASSERT_EFI_ERROR (Status);

if (!gGpio->Get(HTCLEO_GPIO_SD_STATUS))
{
// Enable the SDC2 clock
gClock->ClkEnable(SDC2_CLK);

// Enable SD
mmc_legacy_init(0);

Expand Down
1 change: 1 addition & 0 deletions HtcLeoPkg/GPLDrivers/SdCardDxe/SdCardDxe.inf
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
gEfiCpuArchProtocolGuid
gEfiDevicePathProtocolGuid
gTlmmGpioProtocolGuid
gEmbeddedClockProtocolGuid

[Pcd]

Expand Down

0 comments on commit cbc6932

Please sign in to comment.