From 0e24873e3a38776a8aff5f64c4338bf7135e15a9 Mon Sep 17 00:00:00 2001 From: Jarielle Catbagan Date: Tue, 4 Aug 2015 11:03:22 -0700 Subject: BBB: Migrate MMC0 clock enable from am335x_sd.c:sdInit() to cpuio.c:initCPUio() The reason why the MMC0 clock enable has to be executed much earlier is a result of the invocation of sdInstalled() in sd.h before sdInit(). Without this migration, an exception occurs since the MMC0 interface has not been enabled before it is accessed by sdInstalled(). --- ports/beagleboneblack/am335x_sd.c | 4 ---- ports/beagleboneblack/cpuio.c | 4 ++++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ports/beagleboneblack/am335x_sd.c b/ports/beagleboneblack/am335x_sd.c index ac2392c..7eb0180 100644 --- a/ports/beagleboneblack/am335x_sd.c +++ b/ports/beagleboneblack/am335x_sd.c @@ -47,10 +47,6 @@ sdInit(int interface, int verbosity) { uint32_t cmd, arg, resp[4]; - /* Enable MMC0 clocks */ - CM_PER_REG(CM_PER_MMC0_CLKCTRL) |= CM_PER_MMC0_CLKCTRL_MODULEMODE_ENABLE; - while (CM_PER_REG(CM_PER_MMC0_CLKCTRL) & CM_PER_MMC0_CLKCTRL_IDLEST); - /* Reset the MMC/SD controller */ MMCHS0_REG(SD_SYSCONFIG) = SD_SYSCONFIG_SOFTRESET; while (!(MMCHS0_REG(SD_SYSSTATUS) & SD_SYSSTATUS_RESETDONE)); diff --git a/ports/beagleboneblack/cpuio.c b/ports/beagleboneblack/cpuio.c index eab0a00..a1ca3aa 100644 --- a/ports/beagleboneblack/cpuio.c +++ b/ports/beagleboneblack/cpuio.c @@ -205,6 +205,10 @@ initCPUio(void) // Enable clock for GPIO1: CM_PER_REG(CM_PER_GPIO1_CLKCTRL) |= 2; + /* Enable MMC0 clocks */ + CM_PER_REG(CM_PER_MMC0_CLKCTRL) |= CM_PER_MMC0_CLKCTRL_MODULEMODE_ENABLE; + while (CM_PER_REG(CM_PER_MMC0_CLKCTRL) & CM_PER_MMC0_CLKCTRL_IDLEST); + pinMuxInit(); InitUART(DEFAULT_BAUD_RATE); -- cgit v1.2.3