int board_app_initialize(uintptr_t arg) { #ifdef NSH_HAVEMMCSD int ret; /* Configure GPIO pins. * * First CD power. The initial state will provide SD power. */ kinetis_pinconfig(GPIO_SD_CARDON); /* Applies power to the card */ /* Attached the card detect interrupt (but don't enable it yet) */ kinetis_pinconfig(GPIO_SD_CARDDETECT); kinetis_pinirqattach(GPIO_SD_CARDDETECT, kinetis_cdinterrupt); /* Mount the SDHC-based MMC/SD block driver */ /* First, get an instance of the SDHC interface */ syslog(LOG_INFO, "Initializing SDHC slot %d\n", CONFIG_NSH_MMCSDSLOTNO); g_nsh.sdhc = sdhc_initialize(CONFIG_NSH_MMCSDSLOTNO); if (!g_nsh.sdhc) { syslog(LOG_ERR, "ERROR: Failed to initialize SDHC slot %d\n", CONFIG_NSH_MMCSDSLOTNO); return -ENODEV; } /* Now bind the SDHC interface to the MMC/SD driver */ syslog(LOG_INFO, "Bind SDHC to the MMC/SD driver, minor=%d\n", CONFIG_NSH_MMCSDMINOR); ret = mmcsd_slotinitialize(CONFIG_NSH_MMCSDMINOR, g_nsh.sdhc); if (ret != OK) { syslog(LOG_ERR, "ERROR: Failed to bind SDHC to the MMC/SD driver: %d\n", ret); return ret; } syslog(LOG_INFO, "Successfully bound SDHC to the MMC/SD driver\n"); /* Handle the initial card state */ kinetis_mediachange(); /* Enable CD interrupts to handle subsequent media changes */ kinetis_pinirqenable(GPIO_SD_CARDDETECT); #endif return OK; }
int nsh_archinitialize(void) { #ifdef NSH_HAVEMMCSD int ret; /* Configure GPIO pins */ /* Attached the card detect interrupt (but don't enable it yet) */ kinetis_pinconfig(GPIO_SD_CARDDETECT); kinetis_pinirqattach(GPIO_SD_CARDDETECT, kinetis_cdinterrupt); /* Configure the write protect GPIO */ kinetis_pinconfig(GPIO_SD_WRPROTECT); /* Mount the SDHC-based MMC/SD block driver */ /* First, get an instance of the SDHC interface */ message("nsh_archinitialize: Initializing SDHC slot %d\n", CONFIG_NSH_MMCSDSLOTNO); g_nsh.sdhc = sdhc_initialize(CONFIG_NSH_MMCSDSLOTNO); if (!g_nsh.sdhc) { message("nsh_archinitialize: Failed to initialize SDHC slot %d\n", CONFIG_NSH_MMCSDSLOTNO); return -ENODEV; } /* Now bind the SDHC interface to the MMC/SD driver */ message("nsh_archinitialize: Bind SDHC to the MMC/SD driver, minor=%d\n", CONFIG_NSH_MMCSDMINOR); ret = mmcsd_slotinitialize(CONFIG_NSH_MMCSDMINOR, g_nsh.sdhc); if (ret != OK) { message("nsh_archinitialize: Failed to bind SDHC to the MMC/SD driver: %d\n", ret); return ret; } message("nsh_archinitialize: Successfully bound SDHC to the MMC/SD driver\n"); /* Handle the initial card state */ kinetis_mediachange(); /* Enable CD interrupts to handle subsequent media changes */ kinetis_pinirqenable(GPIO_SD_CARDDETECT); #endif return OK; }
int k64_sdhc_initialize(void) { int ret; /* Configure GPIO pins */ kinetis_pinconfig(GPIO_SD_CARDDETECT); /* Attached the card detect interrupt (but don't enable it yet) */ kinetis_pinirqattach(GPIO_SD_CARDDETECT, k64_cdinterrupt); /* Configure the write protect GPIO -- None */ /* Mount the SDHC-based MMC/SD block driver */ /* First, get an instance of the SDHC interface */ mcinfo("Initializing SDHC slot %d\n", MMCSD_SLOTNO); g_sdhc.sdhc = sdhc_initialize(MMCSD_SLOTNO); if (!g_sdhc.sdhc) { mcerr("ERROR: Failed to initialize SDHC slot %d\n", MMCSD_SLOTNO); return -ENODEV; } /* Now bind the SDHC interface to the MMC/SD driver */ mcinfo("Bind SDHC to the MMC/SD driver, minor=%d\n", MMSCD_MINOR); ret = mmcsd_slotinitialize(MMSCD_MINOR, g_sdhc.sdhc); if (ret != OK) { syslog(LOG_ERR, "ERROR: Failed to bind SDHC to the MMC/SD driver: %d\n", ret); return ret; } syslog(LOG_INFO, "Successfully bound SDHC to the MMC/SD driver\n"); /* Handle the initial card state */ k64_mediachange(); /* Enable CD interrupts to handle subsequent media changes */ kinetis_pinirqenable(GPIO_SD_CARDDETECT); return OK; }
int fmuk66_sdhc_initialize(void) { int ret; struct fmuk66_sdhc_state_s *sdhc = &g_sdhc; /* Configure GPIO pins */ VDD_3V3_SD_CARD_EN(true); kinetis_pinconfig(GPIO_SD_CARDDETECT); /* Attached the card detect interrupt (but don't enable it yet) */ kinetis_pinirqattach(GPIO_SD_CARDDETECT, fmuk66_cdinterrupt, sdhc); /* Configure the write protect GPIO -- None */ /* Mount the SDHC-based MMC/SD block driver */ /* First, get an instance of the SDHC interface */ mcinfo("Initializing SDHC slot %d\n", CONFIG_NSH_MMCSDSLOTNO); sdhc->sdhc = sdhc_initialize(CONFIG_NSH_MMCSDSLOTNO); if (!sdhc->sdhc) { mcerr("ERROR: Failed to initialize SDHC slot %d\n", CONFIG_NSH_MMCSDSLOTNO); return -ENODEV; } // Testing done on SanDISK HC all failed sd_bench with Drive/Slew other than default and _PIN_OUTPUT_FAST|_PIN_OUTPUT_HIGHDRIVE // _PIN_OUTPUT_FAST|_PIN_OUTPUT_HIGHDRIVE Square noisy, pass SanDISK HC // _PIN_OUTPUT_FAST|_PIN_OUTPUT_LOWDRIVE Square noisy, pass SanDISK HC // _PIN_OUTPUT_HIGHDRIVE|_PIN_OUTPUT_SLOW sinusoidal fail SanDISK HC pass SanDISK HC1 // _PIN_OUTPUT_LOWDRIVE|_PIN_OUTPUT_SLOW sinusoidal fail SanDISK HC pass SanDISK HC1 // _PIN_OUTPUT_SLOW sinusoidal fail SanDISK HC pass SanDISK HC1 // This up dating of the driver setting is for EMI issue with GPS and FCC // With this setting the clock is sinusoidal N.B. sd_bench fails on SanDISK HC, but // Passes SanDISK **HC1** - use HC1 or Kingston cards! kinetis_pinconfig(PIN_SDHC0_DCLK | _PIN_OUTPUT_HIGHDRIVE | _PIN_OUTPUT_SLOW); /* Now bind the SDHC interface to the MMC/SD driver */ mcinfo("Bind SDHC to the MMC/SD driver, minor=%d\n", CONFIG_NSH_MMCSDMINOR); ret = mmcsd_slotinitialize(CONFIG_NSH_MMCSDMINOR, sdhc->sdhc); if (ret != OK) { syslog(LOG_ERR, "ERROR: Failed to bind SDHC to the MMC/SD driver: %d\n", ret); return ret; } syslog(LOG_ERR, "Successfully bound SDHC to the MMC/SD driver\n"); /* Handle the initial card state */ fmuk66_mediachange(sdhc); /* Enable CD interrupts to handle subsequent media changes */ kinetis_pinirqenable(GPIO_SD_CARDDETECT); return OK; }
void mmchs_init(void) { cm2_init(); lvaddr_t mmchs_vaddr; errval_t err = map_device_register(MMCHS_BASE, 0x1000, &mmchs_vaddr); assert(err_is_ok(err)); // Initialize devices omap44xx_mmchs_initialize(&mmchs, (mackerel_addr_t)mmchs_vaddr); sdhc_initialize(&sdhc, (mackerel_addr_t) mmchs_vaddr + 0x200); ctrlmod_init(); printf("\nmmchs: entered init().\n"); // Enable interrupts err = inthandler_setup_arm(mmchs_handle_irq, NULL, MMC1_IRQ); assert(err_is_ok(err)); // Configure Pad multiplexing // Does not change anything ctrlmod_init(); // Enable power cm2_enable_hsmmc1(); // Configure device mmchs_pre_configure(); mmchs_configure(); /* // Change clock frequency to 50 MHz (as Linux) */ /* mmchs_change_clock_frequency(0x2); */ /* mmchs_do_state_machine_reset(); */ switch (sdhc_rev_srev_rdf(&sdhc)) { case 0x0: printf("SD Host Specification Version 1.0\n"); break; case 0x1: printf("SD Host Specification Version 2.0\n"); break; default: assert(!"Don't understand SREV field"); } mmchs_init_stream(); mmchs_detect_card(); /* mmchs_init_and_ident_card(); */ /* printf("mmchs_detect_card\n"); */ /* /\* mmchs_detect_card(); *\/ */ /* sdhc_ie_wr(&sdhc, ~0x0); */ /* sdhc_ise_wr(&sdhc, ~0x0); */ /* mmchs_print_power_state(); */ /* int resp; */ /* int loop = 0; */ /* do { */ /* printf("Trying to init card, step %d\n", ++loop); */ /* /\* mmchs_wait_msec(100); *\/ */ /* /\* // See diagram 24-48 for details on how to set card frequency *\/ */ /* /\* mmchs_change_clock_frequency(); *\/ */ /* mmchs_wait_msec(100); */ /* printf("Init and ident card .. \n"); */ /* resp = mmchs_init_and_ident_card(); */ /* mmchs_wait_msec(1000); */ /* } while(resp!=MMCHS_RESP_SUCCESS && loop<100); */ }