View | Details | Raw Unified | Return to bug 204521 | Differences between
and this patch

Collapse All | Expand All

(-)b/rtsx.c (-14 / +17 lines)
Lines 434-439 rtsx_intr(void *arg) Link Here
434
	/* start task to handle SD card status change */
434
	/* start task to handle SD card status change */
435
	/* from dwmmc.c */
435
	/* from dwmmc.c */
436
	if (status & RTSX_SD_INT) {
436
	if (status & RTSX_SD_INT) {
437
        if(status & RTSX_SD_EXIST)  {
438
            sc->rtsx_flags |= RTSX_F_CARD_PRESENT;
439
        } else {
440
            sc->rtsx_flags &= ~RTSX_F_CARD_PRESENT;
441
        }
437
		device_printf(sc->rtsx_dev, "Card inserted/removed\n");
442
		device_printf(sc->rtsx_dev, "Card inserted/removed\n");
438
		rtsx_handle_card_present(sc);
443
		rtsx_handle_card_present(sc);
439
	}
444
	}
Lines 488-495 rtsx_handle_card_present(struct rtsx_softc *sc) Link Here
488
	bool was_present;
493
	bool was_present;
489
	bool is_present;
494
	bool is_present;
490
495
491
	was_present = sc->rtsx_mmc_dev != NULL;
496
    was_present = sc->rtsx_mmc_dev != NULL;
492
	is_present = rtsx_is_card_present(sc);
497
    is_present = rtsx_is_card_present(sc);
493
498
494
	if (!was_present && is_present) {
499
	if (!was_present && is_present) {
495
		/* small delay for the controller */
500
		/* small delay for the controller */
Lines 506-515 rtsx_card_task(void *arg, int pending __unused) Link Here
506
{
511
{
507
	struct rtsx_softc *sc = arg;
512
	struct rtsx_softc *sc = arg;
508
513
509
	RTSX_LOCK(sc);
510
514
515
    RTSX_LOCK(sc);
511
	if (rtsx_is_card_present(sc)) {
516
	if (rtsx_is_card_present(sc)) {
512
		sc->rtsx_flags |= RTSX_F_CARD_PRESENT;
513
		/* Card is present, attach if necessary */
517
		/* Card is present, attach if necessary */
514
		if (sc->rtsx_mmc_dev == NULL) {
518
		if (sc->rtsx_mmc_dev == NULL) {
515
			if (bootverbose)
519
			if (bootverbose)
Lines 527-542 rtsx_card_task(void *arg, int pending __unused) Link Here
527
			RTSX_UNLOCK(sc);
531
			RTSX_UNLOCK(sc);
528
		
532
		
529
	} else {
533
	} else {
530
		sc->rtsx_flags &= ~RTSX_F_CARD_PRESENT;
531
		/* Card isn't present, detach if necessary */
534
		/* Card isn't present, detach if necessary */
532
		if (sc->rtsx_mmc_dev != NULL) {
535
		if (sc->rtsx_mmc_dev != NULL) {
533
			if (bootverbose)
536
			if (bootverbose)
534
				device_printf(sc->rtsx_dev, "Card removed\n");
537
				device_printf(sc->rtsx_dev, "Card removed\n");
535
538
            RTSX_UNLOCK(sc);
536
			if (device_delete_child(sc->rtsx_dev, sc->rtsx_mmc_dev))
539
			if (device_delete_child(sc->rtsx_dev, sc->rtsx_mmc_dev))
537
				device_printf(sc->rtsx_dev, "Detaching MMC bus failed\n");
540
				device_printf(sc->rtsx_dev, "Detaching MMC bus failed\n");
538
			sc->rtsx_mmc_dev = NULL;
541
            RTSX_LOCK(sc);
539
			RTSX_UNLOCK(sc);
542
            sc->rtsx_mmc_dev = NULL;
543
            RTSX_UNLOCK(sc);
540
		} else
544
		} else
541
			RTSX_UNLOCK(sc);
545
			RTSX_UNLOCK(sc);
542
	}
546
	}
Lines 545-554 rtsx_card_task(void *arg, int pending __unused) Link Here
545
static int
549
static int
546
rtsx_is_card_present(struct rtsx_softc *sc)
550
rtsx_is_card_present(struct rtsx_softc *sc)
547
{
551
{
548
	uint32_t status;
552
    return ISSET(sc->rtsx_flags,RTSX_F_CARD_PRESENT);
549
550
	status = READ4(sc, RTSX_BIPR);
551
	return (status & RTSX_SD_EXIST);
552
}
553
}
553
554
554
static int
555
static int
Lines 591-597 rtsx_init(struct rtsx_softc *sc) Link Here
591
	/* Clear any pending interrupts. */
592
	/* Clear any pending interrupts. */
592
	status = READ4(sc, RTSX_BIPR);
593
	status = READ4(sc, RTSX_BIPR);
593
	WRITE4(sc, RTSX_BIPR, status);
594
	WRITE4(sc, RTSX_BIPR, status);
594
595
    if (status & RTSX_SD_EXIST)
596
            sc->rtsx_flags |= RTSX_F_CARD_PRESENT;
595
	/* Enable interrupts. */
597
	/* Enable interrupts. */
596
	WRITE4(sc, RTSX_BIER,
598
	WRITE4(sc, RTSX_BIER,
597
	       RTSX_TRANS_OK_INT_EN | RTSX_TRANS_FAIL_INT_EN | RTSX_SD_INT_EN);
599
	       RTSX_TRANS_OK_INT_EN | RTSX_TRANS_FAIL_INT_EN | RTSX_SD_INT_EN);
Lines 2206-2212 rtsx_attach(device_t dev) Link Here
2206
	 * Schedule a card detection as we won't get an interrupt
2208
	 * Schedule a card detection as we won't get an interrupt
2207
	 * if the card is inserted when we attach
2209
	 * if the card is inserted when we attach
2208
	 */
2210
	 */
2209
	rtsx_card_task(sc, 0);
2211
2212
    rtsx_card_task(sc, 0);
2210
2213
2211
	if (bootverbose)
2214
	if (bootverbose)
2212
		device_printf(dev, "Device attached\n");
2215
		device_printf(dev, "Device attached\n");

Return to bug 204521