uint32_t fs_sd_unmount () { sd = mmc_close (sd); (void)disable_vaux3 (); return 0; }
static void dsource_OnDestroy(t_DSAppStore* pme) { if(pme->root){ __AppStoreDir_Free(pme->root); FREE(pme->root); } mmc_stop(pme->mmc_anim); mmc_close(pme->mmc_anim); }
/* * mmc_init */ mmc_properties_t* mmc_init (uint32_t sdi_base_address, int *status, int expect_sd) { mmc_properties_t *device; *status = MMC_ERROR; /* Voltage Check@VAUX2 before accessing the eMMC */ uint8_t vaux = ab8500_reg_read(AB8500_REGU_VAUX2_SEL_REG); if ((vaux > AB8500_VAUX2_2V7) && (vaux <= AB8500_VAUX2_MAX)) dprintf(INFO,"Proper voltage 0x0%x applied to eMMC\n", vaux); else { if (ab8500_reg_write(AB8500_REGU_VAUX2_SEL_REG, AB8500_VAUX2_2V9) < 0) dprintf(INFO,"EMMC: Failed to set default voltage\n"); else dprintf(INFO,"EMMC:Set to Default 0x0%x as Voltage is not in the Range!\n", vaux); } /* Create meta data struct */ device = u8500_alloc_mmc_struct(); if (!device) { dprintf(INFO, "error allocating mmc structure\n"); return NULL; } /* Init host. Cast to void, function return 0 in all cases... */ if (EXPECT_SD == expect_sd) { (void)u8500_mmc_host_init(device, (struct sdi_registers *)sdi_base_address); } else { (void)u8500_emmc_host_init(device, (struct sdi_registers *)sdi_base_address); } /* Reset host */ *status = mmc_host_reset(device); if (MMC_OK != *status) { dprintf(INFO,"mmc_init (%d) status %d\n", __LINE__, *status); goto ErrorExit; } /* Setup bus width, initial value, changed after investigating host * capabilites */ device->bus_width = BUS_WIDTH_1; /* Setup clock , initial value, changed after investigating host * capabilites */ device->device_clock = INIT_CLOCK; /* Set bus and clock */ host_set_ios(device); /* Reset card */ *status = mmc_send_go_idle(device); if (MMC_OK != *status) { dprintf(INFO,"mmc_init (%d) status %d\n", __LINE__, *status); goto ErrorExit; } /* Test for SD card */ *status = mmc_send_sd_send_if_cond (device); if (MMC_OK != *status) { dprintf(INFO,"mmc_init (%d) Check for SD: status %d\n", __LINE__, *status); } /* Check if SD-card */ *status = mmc_send_op_cond(device, 1); if (MMC_OK == *status) { device->is_sd_card = 1; } else { dprintf(INFO,"mmc_init SD check (%d) status %d. Not an SD card\n", __LINE__, *status); /* Try eMMMC */ *status = mmc_send_op_cond(device, 0); if (MMC_OK != *status) { dprintf(INFO,"mmc_init (%d) status %d\n", __LINE__, *status); goto ErrorExit; } } *status = mmc_send_all_send_cid(device); if (MMC_OK != *status) { dprintf(INFO,"mmc_init (%d) status %d\n", __LINE__, *status); goto ErrorExit; } *status = mmc_send_set_relative_addr(device); if (MMC_OK != *status) { dprintf(INFO,"mmc_init (%d) status %d\n", __LINE__, *status); goto ErrorExit; } *status = mmc_send_csd(device); if (MMC_OK != *status) { dprintf(INFO,"mmc_init (%d) status %d\n", __LINE__, *status); goto ErrorExit; } *status = mmc_send_select_card(device, 0); if (MMC_OK != *status) { dprintf(INFO,"mmc_init (%d) status %d\n", __LINE__, *status); goto ErrorExit; } if (!device->is_sd_card) { *status = mmc_send_ext_csd(device, device->ext_csd); if (MMC_OK != *status) { dprintf(INFO,"mmc_init (%d) status %d\n", __LINE__, *status); goto ErrorExit; } } parse_csd(device); dump_csd_to_debug(device); *status = mmc_set_hs_timing (device); if (MMC_OK != *status) { dprintf(INFO,"mmc_init (%d) status %d\n", __LINE__, *status); goto ErrorExit; } /* Set ecsd buswidth and device buswidth according to host capabilities */ *status = mmc_set_bus (device); if (MMC_OK != *status) { dprintf(INFO,"mmc_init (%d) status %d\n", __LINE__, *status); goto ErrorExit; } /* Set host buswidth and clock */ device->device_clock = MAX_CLOCK; if (device->is_sd_card) device->device_clock = MAX_CLOCK / 2; host_set_ios(device); if (device->rel_write == REL_WRITE_TRUE) { *status = mmc_send_switch(device, ECSD_ACCESS_MODE_WRITE_BYTE, ECSD_WR_REL_SET, 0x1F); if (MMC_OK != *status) { dprintf(INFO,"mmc_init (%d) status %d\n", __LINE__, *status); goto ErrorExit; } } *status = mmc_send_set_blocklen(device, MMC_BLOCK_SIZE_512); if (MMC_OK != *status) { dprintf(INFO,"mmc_init (%d) status %d\n", __LINE__, *status); goto ErrorExit; } ErrorExit: if (MMC_OK != *status) { dprintf (INFO, "\n\nINIT EMMC FAILED %d\n\n", *status); device = mmc_close (device); } return device; }