Example #1
0
File: main.c Project: eerimoq/simba
static int storage_init(fat16_read_t *read_p,
                        fat16_write_t *write_p,
                        void **arg_pp)
{
    std_printf(FSTR("SD storage.\r\n"));

    std_printf(FSTR("spi bitrate = %lu kbps\r\n"),
               2 * 16 * SAMPLES_PER_SOCOND / 1024);

    /* Initialize SPI for the SD card. */
    spi_init(&spi,
             &spi_device[0],
             &pin_d53_dev,
             SPI_MODE_MASTER,
             SPI_SPEED_2MBPS,
             0,
             1);

    sd_init(&sd, &spi);

    if (sd_start(&sd) != 0) {
        return (-1);
    }

    std_printf(FSTR("sd card started\r\n"));

    *read_p = (fat16_read_t)sd_read_block;
    *write_p = (fat16_write_t)sd_write_block;
    *arg_pp = &sd;

    return (0);
}
Example #2
0
/* init mmc/sd card we assume that the card is in the slot */
static int  mmc_init(unsigned int msc_clkrt_val)
{
    int retries, ret;
    u8 *resp;
    //unsigned int msc_clk_div = (__cpm_get_pllout())/24000000;
    __msc_reset();
    mmc_init_gpio();
    REG_MSC_IMASK = 0xffff;
    REG_MSC_IREG = 0xffff;
    REG_MSC_CLKRT = 6;    //200k

    /* just for reading and writing, suddenly it was reset, and the power of sd card was not broken off */
    resp = mmc_cmd(12, 0, 0x41, MSC_CMDAT_RESPONSE_R1);

    /* reset */
    resp = mmc_cmd(0, 0, 0x80, 0);
    resp = mmc_cmd(8, 0x1aa, 0x1, MSC_CMDAT_RESPONSE_R1);
    resp = mmc_cmd(55, 0, 0x1, MSC_CMDAT_RESPONSE_R1);
    if(resp[5] == 0x37) {
        resp = mmc_cmd(41, 0x40ff8000, 0x3, MSC_CMDAT_RESPONSE_R3);
        if(resp[5] == 0x3f)
            ret = sd_init(msc_clkrt_val);
        return ret;
    }
    ret = mmc_found(msc_clkrt_val);
    return ret;
}
Example #3
0
master* master_init() {
	//init sd
	sd_init();

	//allocates memory
	master* m = (master*)malloc(sizeof(master));
	m->l = malloc(sizeof(level));
	m->c = malloc(sizeof(charac));
	//m->o = malloc(sizeof(object));
	m->o = &box;
	m->co = &co;
	m->spikes = &spikes;
	m->box_3 = &box_3;
	m->box_1 = &box_1;
	m->flag = &flag;


	srand(time(NULL));


	m->ab = malloc(sizeof(audio_buffer));

	//audio init
	av_config_setup();
	m->ab->audio_dev = alt_up_audio_open_dev(AUDIO_NAME); //audio setup

	reset_audio_buffer(m->ab); //init circular buffer
	preload_sfx(SFX, m->ab); //preloads sfx
	//TODO: fix sfx
	preload_sfx1("coin.wav", m->ab);

	alt_irq_register(AUDIO_IRQ,m->ab,(alt_isr_func)audio_isr);

	return m;
}
Example #4
0
int init_soc(int soc_type)
{
	switch(soc_type)	
	{
		case MCIMX233:
			init_all_pins(); //base on board layout
			
			init_clock_power();
			//init_dma();

			serial_init(); //heading by serial_ means this function is from serial.c
			printf("INIT: \n<..uart..>\n");
			printf("INIT: sdram...\n");
			init_sdram();
			//gpmi_init(); //heading by gpmi_ means this function is from gpmi.c

			printf("INIT: sd card...\n");
			sd_init();
			
			printf("INIT: dm9k...\n");
			dm9000_initialize();

			printf("INIT: tag-list...\n");
//			init_taglist(0x40000000);

			printf("INIT: booting...\n");
			break;
	}
	return 0;
}
Example #5
0
File: main.c Project: eerimoq/simba
int test_init(struct harness_t *harness_p)
{
#if defined(ARCH_LINUX)
    /* Create an empty sd card file. */
    system("../../create_sdcard_linux.sh");
    file_p = fopen("sdcard", "r+b");
    BTASSERT(fat16_init(&fs,
                        linux_read_block,
                        linux_write_block,
                        file_p,
                        0) == 0);
#else
    BTASSERT(spi_init(&spi,
                      &spi_device[0],
                      &pin_d6_dev,
                      SPI_MODE_MASTER,
                      SPI_SPEED_500KBPS,
                      0,
                      0) == 0);
    BTASSERT(sd_init(&sd, &spi) == 0);
    BTASSERT(sd_start(&sd) == 0);
    BTASSERT(fat16_init(&fs,
                        (fat16_read_t)sd_read_block,
                        (fat16_write_t)sd_write_block,
                        &sd,
                        0) == 0);
#endif

    return (0);
}
Example #6
0
void storage_switch_sd_ide(UINT8 sd_active, BOOL first)
{
    if (sd_active)
    {
		if (!first)
		{
#ifdef IDE_SUPPORT
			ide_disable();
#endif
		}
#ifdef SDIO_SUPPORT
        sd_enable(SDIO_GPIO_CS, SDIO_GPIO_CS_POLOR, SDIO_GPIO_DETECT, SDIO_GPIO_LOCK);
        sd_init();
#endif
		DM_DEBUG("storage device : sdio active\n");
    }
    else
    { 
		if (!first)
		{
#ifdef SDIO_SUPPORT
			sd_disable();
#endif
		}
#ifdef IDE_SUPPORT
        ide_enable(25, 1); 
        ide_init();
#endif
		DM_DEBUG("storage device : hdd(ide) active\n");
    }	
}
Example #7
0
File: sd_boot.c Project: ykli/misc
int emmc_boot(void)
{
	int ret;

	current_boot = EMMC_BOOT;
	ctl_num = 0;

	sd_init();
	REG_MSC_CLKRT(ctl_num) = 1;
	REG_MSC_LPM(ctl_num) = 1;

	/* cmd12 reset when we reading or writing from the card, send this cmd */
	mmc_cmd(12, 0, 0x1, MSC_CMDAT_RESPONSE_R1);

	mmc_cmd(0, 0xf0f0f0f0, 0x80, MSC_CMDAT_RESPONSE_NONE);

	REG_MSC_BLKLEN(ctl_num) = 0x200;
	REG_MSC_NOB(ctl_num) = (SPL_SIZE + redundancy_size) / 512;
	mmc_cmd(0, 0xfffffffa, ((MSC_CMDAT_INIT) | (MSC_CMDAT_EXP_BOOT_ACK) | (MSC_CMDAT_BOOT_MODE_A) | (MSC_CMDAT_DATA_EN)), MSC_CMDAT_RESPONSE_NONE);

	ret = mmc_block_readp(SPL_SIZE + redundancy_size, (u32 *)start_addr);

	if(!ret){
		mmc_cmd(0, 0, 0x0, MSC_CMDAT_RESPONSE_NONE);

		if (!(REG32(start_addr) == 0x4d53504c)){
			return sd_boot(1);
		}

		return xfer_d2i(start_addr + jump_offset, SPL_SIZE);
	}else{
		return error_handler(current_boot);
	}
}
Example #8
0
__attribute__((no_instrument_function))  void not_main(void)
{

    unsigned int ra;

    serial_init();
    print_s("\n\rTesting SD CARD INITIALIZATION\n\r");
    sd_init();


   // list_root_directory();
    FILE *fd;
    fd = fopen("TORNADO.JPG");

    fwrite(fd,"Yaaayie",10);
    unsigned char *test = (unsigned char*)malloc(sizeof(unsigned char)*6);
    fread(fd,test,10);
    print_s("\n\rContents: ");
    for(int i=0;i<10;i++)
        print_ch(test[i]);


    free(test);
    free(fd);
    return;
}
Example #9
0
PXA2xxMMCIState *pxa2xx_mmci_init(MemoryRegion *sysmem,
                hwaddr base,
                BlockBackend *blk, qemu_irq irq,
                qemu_irq rx_dma, qemu_irq tx_dma)
{
    PXA2xxMMCIState *s;

    s = (PXA2xxMMCIState *) g_malloc0(sizeof(PXA2xxMMCIState));
    s->irq = irq;
    s->rx_dma = rx_dma;
    s->tx_dma = tx_dma;

    memory_region_init_io(&s->iomem, NULL, &pxa2xx_mmci_ops, s,
                          "pxa2xx-mmci", 0x00100000);
    memory_region_add_subregion(sysmem, base, &s->iomem);

    /* Instantiate the actual storage */
    s->card = sd_init(blk, false);
    if (s->card == NULL) {
        exit(1);
    }

    register_savevm(NULL, "pxa2xx_mmci", 0, 0,
                    pxa2xx_mmci_save, pxa2xx_mmci_load, s);

    return s;
}
Example #10
0
void setup() {
    ROM_SysCtlClockSet(SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);

    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);

    ROM_FPULazyStackingEnable();
    ROM_FPUEnable();

    uart_setup();

    sd_init();
    dac_setup();
    keycontrol_setup();
    initConfig();
    tick_setup();    
    soundoutcontrol_setup();
    setupADC();
    setupUSBStore();
    initSampleBlocks();
    
    
    ROM_TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
    ROM_IntMasterEnable();

    DEBUG_PRINT("Setup complete\n", NULL);
}
Example #11
0
int main(void)
{
    MCUSR &= ~(1 << WDRF);
    wdt_disable();

     // led
    SETUPRED();
    SETUPGREEN();
    GREENON();
    REDON();

    uint8_t bootloader_version[5] = "b002";
    eeprom_update_block((void *)&bootloader_version, BOOTLOADER_VERSION_ADDR, 4);

    sd_disk sd;
    _delay_ms(250);

     uint16_t flash = 0;
     if (!sd_init(&sd) && disk_init(&sd)) {
         if (!find_and_load_bootfile(&sd)) {
             flash = 4*3;
         }
     }
     GREENOFF();
     REDOFF();

     for (int i=0; i<flash; i++) {
         REDTOGGLE();
        _delay_ms(250);
      }
    REDOFF();
     __asm__("jmp 0000");
     sd_write_block(0,0);
}
/*
 * Checks if the given EXI device is a MMC/SD card and makes it available
 * if true.
 */
static int sd_probe(struct exi_device *exi_device)
{
	struct sd_host *host;
	int retval;

	/* don't try to drive a device which already has a real identifier */
	if (exi_device->eid.id != EXI_ID_NONE)
		return -ENODEV;

	host = kzalloc(sizeof(*host), GFP_KERNEL);
	if (!host)
		return -ENOMEM;

	host->exi_device = exi_device_get(exi_device);
	WARN_ON(exi_get_drvdata(exi_device));
	exi_set_drvdata(exi_device, host);
	retval = sd_init(host);
	if (retval) {
		exi_set_drvdata(exi_device, NULL);
		host->exi_device = NULL;
		kfree(host);
		exi_device_put(exi_device);
	}
	return retval;
}
Example #13
0
void handle_sdcard()
{

  DEBUG_PUTS("[Card inserted]\n");

  if (sd_init())
    if (fatfs_mount())
      if (find_imgfile())
	if (imgfile_init()) {
	  set_disk_type(imgheader.disk_type);
	  PORTA = fatfs_filenumber;
	  fatfs_next_filename();
	} else {
	  fatfs_reset_filename();
	  PORTA = ~0;
	}

  while (SDCARD_INSERTED) {
    service_ide();
    service_cdda();
  }

  DEBUG_PUTS("[Card extracted]\n");
  cdda_stop();
  set_disk_type(0xff);
}
Example #14
0
void scsi_sd_init(uint8_t lun)
{
    const sdio_t* sdio = (const sdio_t*)scsi_lun[lun].info;

    if (sd_init(*sdio) != SD_NO_ERROR)
    {
	log_error("MSC sd_init() error");
    }
}
static void
nm_session_monitor_init (NMSessionMonitor *monitor)
{
#ifdef SESSION_TRACKING_SYSTEMD
	sd_init (monitor);
#endif

#ifdef SESSION_TRACKING_CONSOLEKIT
	ck_init (monitor);
#endif
}
Example #16
0
/* init mmc/sd card we assume that the card is in the slot */
static int  mmc_init(void)
{
	int retries;
	u8 *resp;

	__gpio_as_msc();
	__msc_reset();
	MMC_IRQ_MASK();	

	REG_CPM_MSCCDR = __cpm_get_pllout2()%24000000 ? __cpm_get_pllout2()/24000000 : __cpm_get_pllout2()/24000000 - 1;
	REG_CPM_CPCCR |= CPM_CPCCR_CE;

	REG_MSC_CLKRT = 7;    //250k
	REG_MSC_RDTO = 0xffffffff;

	resp = mmc_cmd(12, 0, 0x41, MSC_CMDAT_RESPONSE_R1);
	/* reset */
	resp = mmc_cmd(0, 0, 0x80, 0);
	resp = mmc_cmd(8, 0x1aa, 0x1, MSC_CMDAT_RESPONSE_R1);
	resp = mmc_cmd(55, 0, 0x1, MSC_CMDAT_RESPONSE_R1);
	if(!(resp[0] & 0x20) && (resp[5] != 0x37)) { 
		resp = mmc_cmd(1, 0x40ff8000, 0x3, MSC_CMDAT_RESPONSE_R3);
		retries = 500;
		while (retries-- && resp && !(resp[4] & 0x80)) {
			resp = mmc_cmd(1, 0x40300000, 0x3, MSC_CMDAT_RESPONSE_R3);
			udelay(1000);
			udelay(1000);
		}

		if ((resp[4] & 0x80 ) == 0x80) 
			serial_puts("MMC init ok\n");
		else 
			serial_puts("MMC init fail\n");

		if((resp[4] & 0x60) == 0x40)
			highcap = 1;
		else
			highcap = 0;
	
		/* try to get card id */
		resp = mmc_cmd(2, 0, 0x2, MSC_CMDAT_RESPONSE_R2);
		resp = mmc_cmd(3, 0x10, 0x1, MSC_CMDAT_RESPONSE_R1);

		REG_MSC_CLKRT = 2;	/* 16/1 MHz */
		resp = mmc_cmd(7, 0x10, 0x1, MSC_CMDAT_RESPONSE_R1);
		resp = mmc_cmd(6, 0x3b70101, 0x441, MSC_CMDAT_RESPONSE_R1);
		while(!(REG_MSC_STAT & MSC_STAT_PRG_DONE))
			;
		REG_MSC_IREG |= MSC_IREG_PRG_DONE;
	}
	else
		sd_init();
	return 0;
}
static int accounts_settings_init(void)
{
	g_accounts.current_uid = get_active_seat_uid();

	/* Register for login changes */
	sd_init(&g_accounts);

	/* Get property values for current user */
	get_user_settings(&g_accounts);

	return ofono_system_settings_driver_register(&accounts_settings_driver);
}
Example #18
0
DSTATUS disk_initialize (BYTE drv)
{
	s32 r;
	if(drv != 0)
		return RES_PARERR;
	
	r = sd_init();

	if(r == 0)
		return RES_OK;
	else
		return RES_NOTRDY;
}
Example #19
0
void sdtest_init() {
	BaseType_t ret;
	struct sd_setting setting = {
		.clock = 400000,
		.wide = SD_BusWide_1b,
		.mode = SD_SD,
	};
	sd = sd_init(SDIO_ID, &setting);
	CONFIG_ASSERT(sd != NULL);

	ret = OS_CREATE_TASK(sdtest_task, "SD Test Task", 512, NULL, 1, sdTask);
	CONFIG_ASSERT(ret == pdPASS);
}
Example #20
0
File: pl181.c Project: poblces/qemu
static int pl181_init(SysBusDevice *dev)
{
    pl181_state *s = FROM_SYSBUS(pl181_state, dev);
    DriveInfo *dinfo;

    memory_region_init_io(&s->iomem, OBJECT(s), &pl181_ops, s, "pl181", 0x1000);
    sysbus_init_mmio(dev, &s->iomem);
    sysbus_init_irq(dev, &s->irq[0]);
    sysbus_init_irq(dev, &s->irq[1]);
    qdev_init_gpio_out(&s->busdev.qdev, s->cardstatus, 2);
    dinfo = drive_get_next(IF_SD);
    s->card = sd_init(dinfo ? dinfo->bdrv : NULL, false);
    return 0;
}
Example #21
0
static void init(void) {
	usart1_init(115200, buf_in, ARR_LEN(buf_in), buf_out, ARR_LEN(buf_out));
	sei();
	printf("Running init\n");
	int rc = sd_init();


	if (rc == 0) {
		puts_P(PSTR("Init complete\n\n"));
	} else {
		puts_P(PSTR("\n\n\nInit failed\n\n"));
		// Hard_reset();
	}
}
Example #22
0
int
securid_setup(struct passwd *pw, char **promptp, sudo_auth *auth)
{
    struct SD_CLIENT *sd = (struct SD_CLIENT *) auth->data;

    /* Re-initialize SecurID every time. */
    if (sd_init(sd) == 0) {
	/* The programmer's guide says username is 32 bytes */
	strlcpy(sd->username, pw->pw_name, 32);
	return AUTH_SUCCESS;
    } else {
	warningx(_("unable to contact the SecurID server"));
	return AUTH_FATAL;
    }
}
Example #23
0
static int milkymist_memcard_init(SysBusDevice *dev)
{
    MilkymistMemcardState *s = FROM_SYSBUS(typeof(*s), dev);
    DriveInfo *dinfo;

    dinfo = drive_get_next(IF_SD);
    s->card = sd_init(dinfo ? dinfo->bdrv : NULL, 0);
    s->enabled = dinfo ? bdrv_is_inserted(dinfo->bdrv) : 0;

    memory_region_init_io(&s->regs_region, &memcard_mmio_ops, s,
            "milkymist-memcard", R_MAX * 4);
    sysbus_init_mmio(dev, &s->regs_region);

    return 0;
}
Example #24
0
/* init mmc/sd card we assume that the card is in the slot */
int  mmc_init(void)
{
	int retries, wait;
	u8 *resp;

	__gpio_as_msc();
	__msc_reset();
	MMC_IRQ_MASK();	
	REG_MSC_CLKRT = 7;    //250k
	REG_MSC_RDTO = 0xffffffff;

	serial_puts("\n\nMMC/SD INIT\n");

	/* reset */
	resp = mmc_cmd(0, 0, 0x80, 0);
	resp = mmc_cmd(8, 0x1aa, 0x1, MSC_CMDAT_RESPONSE_R1);
	resp = mmc_cmd(55, 0, 0x1, MSC_CMDAT_RESPONSE_R1);
	if(!(resp[0] & 0x20) && (resp[5] != 0x37)) { 
		serial_puts("MMC card found!\n");
		resp = mmc_cmd(1, 0x40ff8000, 0x3, MSC_CMDAT_RESPONSE_R3);
		retries = 100;
		while (retries-- && resp && !(resp[4] & 0x80)) {
			resp = mmc_cmd(1, 0x40300000, 0x3, MSC_CMDAT_RESPONSE_R3);
			sd_mdelay(10);
		}

		if ((resp[4] & 0x80) == 0x80) 
			serial_puts("MMC init ok\n");
		else 
			serial_puts("MMC init fail\n");
		
		if((resp[4] & 0x60) == 0x40)
			highcap = 1;
		else
			highcap = 0;
		/* try to get card id */
		resp = mmc_cmd(2, 0, 0x2, MSC_CMDAT_RESPONSE_R2);
		resp = mmc_cmd(3, 0x10, 0x1, MSC_CMDAT_RESPONSE_R1);

		REG_MSC_CLKRT = 0;	/* 16/1 MHz */
		resp = mmc_cmd(7, 0x10, 0x1, MSC_CMDAT_RESPONSE_R1);
		resp = mmc_cmd(6, 0x3b70101, 0x441, MSC_CMDAT_RESPONSE_R1);
	}
	else
		sd_init();
	return 0;
}
Example #25
0
static void ronaldo_sdhci_realize(DeviceState *dev, Error **errp)
{
    DeviceClass *dc_parent = DEVICE_CLASS(RONALDO_SDHCI_PARENT_CLASS);
    RonaldoSDHCIState *s = RONALDO_SDHCI(dev);
    DriveInfo *di_sd;
    DriveInfo *di_mmc;

    di_sd = drive_get_by_index(IF_SD , s->drive_index);
    di_mmc = drive_get_by_index(IF_SD, (s->drive_index + 2));

    s->sd_card = sd_init(di_sd ? blk_by_legacy_dinfo(di_sd) : NULL, false);
    s->mmc_card = mmc_init(di_mmc ? blk_by_legacy_dinfo(di_mmc) : NULL);

    dc_parent->realize(dev, errp);

    qdev_init_gpio_in_named(dev, ronaldo_sdhci_slottype_handler, "SLOTTYPE", 1);
}
Example #26
0
/**
 * Create a new Sd object.
 */
static mp_obj_t class_sd_make_new(const mp_obj_type_t *type_p,
                                   mp_uint_t n_args,
                                   mp_uint_t n_kw,
                                   const mp_obj_t *args_p)
{
    static const mp_arg_t allowed_args[] = {
        { MP_QSTR_spi, MP_ARG_REQUIRED | MP_ARG_OBJ }
    };
    struct class_sd_t *self_p;
    mp_map_t kwargs;
    mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
    struct class_spi_t *spi_p;

    mp_arg_check_num(n_args, n_kw, 1, MP_OBJ_FUN_ARGS_MAX, true);

    /* Parse the arguments. */
    mp_map_init(&kwargs, 0);
    mp_arg_parse_all(n_args,
                     args_p,
                     &kwargs,
                     MP_ARRAY_SIZE(allowed_args),
                     allowed_args,
                     args);

    /* Validate SPI driver argument. */
    spi_p = args[0].u_obj;

    if (spi_p->base.type != &module_drivers_class_spi) {
        nlr_raise(mp_obj_new_exception_msg(&mp_type_TypeError,
                                           "expected spi driver"));
    }

    /* Create a new SD object. */
    self_p = m_new_obj(struct class_sd_t);
    self_p->base.type = &module_drivers_class_sd;
    self_p->spi_p = spi_p;

    if (sd_init(&self_p->drv, &spi_p->drv) != 0) {
        nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError,
                                           "sd_init() failed"));
    }

    return (self_p);
}
Example #27
0
int try_sd_load(void)
{
	int err;

	err = sd_init();
	if (err) {
		printf("SD card not found (%d)\n", err);
		return err;
	}

	err = fat_init();
	if (err == 0)
		printf("SD card detected\n");
	else {
		printf("SD card not detected (%d)\n", err);
		return err;
	}

//	if (usbgecko_checkgecko())
//		printf("USBGecko serial interface detected\n");
//	else
//		printf("USBGecko serial interface not detected\n");

	printf("Opening boot.elf:\n");
	err = fat_open("boot.elf");

	if (err) {
		printf("boot.elf not found (%d)\n", err);
		return err;
	}

extern u32 fat_file_size;

	printf("reading %d bytes...\n", fat_file_size);
	err = fat_read(code_buffer, fat_file_size);
	if (err) {
		printf("Error %d reading file\n", err);
		return err;
	}

	printf("Done.\n");
	return 0;
}
Example #28
0
int main()
{
  char c;
  char block[512];
  int i;

  uart_init();
  /* version = get_master_version(); */
  /* uart_print_str("0x"); */
  /* uart_print_hex8(version); */
  /* uart_print_str("\n"); */
  
  if (!sd_init())
    uart_print_str("sd card initialized!");
  else uart_print_str("sd card initialisation fails!");
  uart_print_str("\n");

  uart_print_str("Before: RX FIFO entries:");
  while(1)
  c = REG8(SPI_MASTER_BASE+RX_FIFO_DATA_COUNT_MSB);
  uart_print_hex8(c);
  c = REG8(SPI_MASTER_BASE+RX_FIFO_DATA_COUNT_LSB);
  uart_print_hex8(c);
  uart_print_str("\n");

  /* if (!sd_block_write()) */
  /*   uart_print_str("sd card write succeeds!"); */
  /* else uart_print_str("sd card write fails!"); */
  /* uart_print_str("\n"); */

  /* if (!sd_block_read()) */
  /*   uart_print_str("sd card read succeeds!"); */
  /* else uart_print_str("sd card read fails!"); */
  /* uart_print_str("\n"); */
  
  /* for (i=0;i<512;i++) */
  /*   { */
  /*     uart_print_hex8(block[i]); */
  /*     uart_print_str("."); */
  /*   } */
  uart_print_str("\n");
  return 0;
}
Example #29
0
/* init mmc/sd card we assume that the card is in the slot */
static int  mmc_init(void)
{
	int retries;
	u8 *resp;

	__gpio_as_msc();
	__msc_reset();
	MMC_IRQ_MASK();	
	__cpm_select_msc_clk(0,1);
	REG_MSC_CLKRT = 7;    //250k

	resp = mmc_cmd(12, 0, 0x41, MSC_CMDAT_RESPONSE_R1);
	/* reset */
	resp = mmc_cmd(0, 0, 0x80, 0);
	resp = mmc_cmd(8, 0x1aa, 0x1, MSC_CMDAT_RESPONSE_R1);
	resp = mmc_cmd(55, 0, 0x1, MSC_CMDAT_RESPONSE_R1);
	if(!(resp[0] & 0x20) && (resp[5] != 0x37)) { 
		resp = mmc_cmd(1, 0xff8000, 0x3, MSC_CMDAT_RESPONSE_R3);
		retries = 500;
		while (retries-- && resp && !(resp[4] & 0x80)) {
			resp = mmc_cmd(1, 0x40300000, 0x3, MSC_CMDAT_RESPONSE_R3);
			udelay(1000);
			udelay(1000);
		}

		if (resp[4]== 0x80) 
			serial_puts("MMC init ok\n");
		else 
			serial_puts("MMC init fail\n");

		/* try to get card id */
		resp = mmc_cmd(2, 0, 0x2, MSC_CMDAT_RESPONSE_R2);
		resp = mmc_cmd(3, 0x10, 0x1, MSC_CMDAT_RESPONSE_R1);

		REG_MSC_CLKRT = 2;	/* 16/1 MHz */
		resp = mmc_cmd(7, 0x10, 0x1, MSC_CMDAT_RESPONSE_R1);
		resp = mmc_cmd(6, 0x3b70101, 0x401, MSC_CMDAT_RESPONSE_R1);
	}
	else
		sd_init();
	return 0;
}
Example #30
0
DSTATUS disk_initialize (
	BYTE pdrv				/* Physical drive nmuber (0..) */
)
{
	//tty_printf("Disk init called %d\n\r", pdrv);
	DSTATUS stat;

	switch (pdrv) {
	case ATA :
		return STA_NODISK;

	case MMC :
		stat = sd_init();
		return stat;

	case USB :
		return STA_NODISK;
	}
	return STA_NOINIT;
}