Skip to content

Commit

Permalink
msm8916: lk: Android SD Card boot
Browse files Browse the repository at this point in the history
msm8916: lk: Needed changes for the Android SD Card Boot

Change-Id: I8af6a2527f4f8063d25a46bce30590289f376ede
Signed-off-by: Baji Patthan <bpatth@codeaurora.org>
(cherry picked from commit 3bac025eb7a081f7f1598fdb5e7cb0c25912bdf0)
(cherry picked from commit f3d777e1394aa2690a19075b6a6ebde772805b91)
  • Loading branch information
Baji Patthan authored and TravMurav committed Jul 19, 2021
1 parent d7ac6af commit 1cd872e
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 12 deletions.
1 change: 1 addition & 0 deletions platform/msm8916/include/platform/iomap.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@
#define SDCC1_N (CLK_CTL_BASE + 0x42010) /* n */
#define SDCC1_D (CLK_CTL_BASE + 0x42014) /* d */

#define SDC2_HDRV_PULL_CTL (TLMM_BASE_ADDR + 0x109000)
#define SDCC2_BCR (CLK_CTL_BASE + 0x43000) /* block reset */
#define SDCC2_APPS_CBCR (CLK_CTL_BASE + 0x43018) /* branch control */
#define SDCC2_AHB_CBCR (CLK_CTL_BASE + 0x4301C)
Expand Down
54 changes: 42 additions & 12 deletions target/msm8916/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
#define CE_WRITE_PIPE_LOCK_GRP 0
#define CE_ARRAY_SIZE 20

static void set_sdc_power_ctrl(void);
static void set_sdc_power_ctrl(uint8_t slot);

struct mmc_device *dev;

Expand Down Expand Up @@ -112,18 +112,20 @@ void target_sdc_init()
{
struct mmc_config_data config;

/* Set drive strength & pull ctrl values */
set_sdc_power_ctrl();

config.bus_width = DATA_BUS_WIDTH_8BIT;
config.bus_width = DATA_BUS_WIDTH_4BIT;
config.max_clk_rate = MMC_CLK_177MHZ;

/* Try slot 1*/
config.slot = 1;
config.slot = MMC_SLOT;
config.sdhc_base = mmc_sdhci_base[config.slot - 1];
config.pwrctl_base = mmc_pwrctl_base[config.slot - 1];
config.pwr_irq = mmc_sdc_pwrctl_irq[config.slot - 1];
config.hs400_support = 0;
dprintf(CRITICAL, "initialising mmc_slot =%u\n",MMC_SLOT);

/* Set drive strength & pull ctrl values */
set_sdc_power_ctrl(config.slot);

if (!(dev = mmc_init(&config))) {
/* Try slot 2 */
Expand All @@ -133,6 +135,9 @@ void target_sdc_init()
config.pwrctl_base = mmc_pwrctl_base[config.slot - 1];
config.pwr_irq = mmc_sdc_pwrctl_irq[config.slot - 1];

/* Set drive strength & pull ctrl values */
set_sdc_power_ctrl(config.slot);

if (!(dev = mmc_init(&config))) {
dprintf(CRITICAL, "mmc init failed!");
ASSERT(0);
Expand Down Expand Up @@ -346,22 +351,47 @@ int emmc_recovery_init(void)
return _emmc_recovery_init();
}

static void set_sdc_power_ctrl()
static void set_sdc_power_ctrl(uint8_t slot)
{
uint32_t reg = 0;
uint8_t clk;
uint8_t cmd;
uint8_t dat;

if(slot == 1)
{
clk = TLMM_CUR_VAL_16MA;
cmd = TLMM_CUR_VAL_10MA;
dat = TLMM_CUR_VAL_10MA;
reg = SDC1_HDRV_PULL_CTL;
}
else if(slot == 2)
{
clk = TLMM_CUR_VAL_16MA;
cmd = TLMM_CUR_VAL_10MA;
dat = TLMM_CUR_VAL_10MA;
reg = SDC2_HDRV_PULL_CTL;
}
else
{
dprintf(CRITICAL,"Unsupported SDC slot passed\n");
return;
}

/* Drive strength configs for sdc pins */
struct tlmm_cfgs sdc1_hdrv_cfg[] =
{
{ SDC1_CLK_HDRV_CTL_OFF, TLMM_CUR_VAL_16MA, TLMM_HDRV_MASK },
{ SDC1_CMD_HDRV_CTL_OFF, TLMM_CUR_VAL_10MA, TLMM_HDRV_MASK },
{ SDC1_DATA_HDRV_CTL_OFF, TLMM_CUR_VAL_10MA, TLMM_HDRV_MASK },
{ SDC1_CLK_HDRV_CTL_OFF, clk, TLMM_HDRV_MASK, reg },
{ SDC1_CMD_HDRV_CTL_OFF, cmd, TLMM_HDRV_MASK, reg },
{ SDC1_DATA_HDRV_CTL_OFF, dat, TLMM_HDRV_MASK, reg },
};

/* Pull configs for sdc pins */
struct tlmm_cfgs sdc1_pull_cfg[] =
{
{ SDC1_CLK_PULL_CTL_OFF, TLMM_NO_PULL, TLMM_PULL_MASK },
{ SDC1_CMD_PULL_CTL_OFF, TLMM_PULL_UP, TLMM_PULL_MASK },
{ SDC1_DATA_PULL_CTL_OFF, TLMM_PULL_UP, TLMM_PULL_MASK },
{ SDC1_CLK_PULL_CTL_OFF, TLMM_NO_PULL, TLMM_PULL_MASK, reg },
{ SDC1_CMD_PULL_CTL_OFF, TLMM_PULL_UP, TLMM_PULL_MASK, reg },
{ SDC1_DATA_PULL_CTL_OFF, TLMM_PULL_UP, TLMM_PULL_MASK, reg },
};

/* Set the drive strength & pull control values */
Expand Down

0 comments on commit 1cd872e

Please sign in to comment.