Skip to content

Commit

Permalink
target: msm8952: Enable sdcard fs support
Browse files Browse the repository at this point in the history
  • Loading branch information
barni2000 authored and TravMurav committed Aug 26, 2024
1 parent 5dbdfc9 commit 8a72bd6
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 8 deletions.
1 change: 1 addition & 0 deletions platform/msm8952/include/platform/iomap.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@
#define SDCC_HC_PWRCTL_CLEAR_REG (0x000000E4)
#define SDCC_HC_PWRCTL_CTL_REG (0x000000E8)

#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
38 changes: 30 additions & 8 deletions target/msm8952/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,22 +129,23 @@ void target_early_init(void)
#endif
}

static void set_sdc_power_ctrl(void)
static void set_sdc_power_ctrl(uint8_t slot)
{
uint32_t reg = (slot == 1 ? SDC1_HDRV_PULL_CTL: SDC2_HDRV_PULL_CTL);
/* Drive strength configs for sdc pins */
struct tlmm_cfgs sdc1_hdrv_cfg[] =
{
{ SDC1_CLK_HDRV_CTL_OFF, TLMM_CUR_VAL_16MA, TLMM_HDRV_MASK, 0},
{ SDC1_CMD_HDRV_CTL_OFF, TLMM_CUR_VAL_10MA, TLMM_HDRV_MASK, 0},
{ SDC1_DATA_HDRV_CTL_OFF, TLMM_CUR_VAL_10MA, TLMM_HDRV_MASK , 0},
{ SDC1_CLK_HDRV_CTL_OFF, TLMM_CUR_VAL_16MA, TLMM_HDRV_MASK, reg},
{ SDC1_CMD_HDRV_CTL_OFF, TLMM_CUR_VAL_10MA, TLMM_HDRV_MASK, reg},
{ SDC1_DATA_HDRV_CTL_OFF, TLMM_CUR_VAL_10MA, 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, 0},
{ SDC1_CMD_PULL_CTL_OFF, TLMM_PULL_UP, TLMM_PULL_MASK, 0},
{ SDC1_DATA_PULL_CTL_OFF, TLMM_PULL_UP, TLMM_PULL_MASK, 0},
{ 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},
};

struct tlmm_cfgs sdc1_rclk_cfg[] =
Expand All @@ -163,7 +164,7 @@ void target_sdc_init(void)
struct mmc_config_data config;

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

/* Try slot 1*/
config.slot = 1;
Expand All @@ -176,6 +177,7 @@ void target_sdc_init(void)

if (!(dev = mmc_init(&config))) {
/* Try slot 2 */
set_sdc_power_ctrl(2);
config.slot = 2;
config.max_clk_rate = MMC_CLK_200MHZ;
config.sdhc_base = mmc_sdhci_base[config.slot - 1];
Expand All @@ -190,6 +192,26 @@ void target_sdc_init(void)
}
}

struct mmc_device *target_get_sd_mmc(void)
{
struct mmc_config_data config;

if (dev->config.slot == 2)
return NULL;

set_sdc_power_ctrl(2);

config.slot = 2;
config.bus_width = DATA_BUS_WIDTH_8BIT;
config.max_clk_rate = MMC_CLK_200MHZ;
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;

return mmc_init(&config);
}

void *target_mmc_device(void)
{
return (void *) dev;
Expand Down

0 comments on commit 8a72bd6

Please sign in to comment.