sdhci.c (9a696dc6bb0e8e783dfd169c8299e1f33aac2935) | sdhci.c (5d5ae0660a7d14b3a86688e827f13cb9624afdc6) |
---|---|
1/*- 2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD 3 * 4 * Copyright (c) 2008 Alexander Motin <mav@FreeBSD.org> 5 * Copyright (c) 2017 Marius Strobl <marius@FreeBSD.org> 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 482 unchanged lines hidden (view full) --- 491{ 492 uint32_t data; 493 char *buffer; 494 size_t left; 495 496 buffer = slot->curcmd->data->data; 497 buffer += slot->offset; 498 /* Transfer one block at a time. */ | 1/*- 2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD 3 * 4 * Copyright (c) 2008 Alexander Motin <mav@FreeBSD.org> 5 * Copyright (c) 2017 Marius Strobl <marius@FreeBSD.org> 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 482 unchanged lines hidden (view full) --- 491{ 492 uint32_t data; 493 char *buffer; 494 size_t left; 495 496 buffer = slot->curcmd->data->data; 497 buffer += slot->offset; 498 /* Transfer one block at a time. */ |
499 left = min(512, slot->curcmd->data->len - slot->offset); | 499#ifdef MMCCAM 500 if (slot->curcmd->data->flags & MMC_DATA_BLOCK_SIZE) 501 left = min(slot->curcmd->data->block_size, 502 slot->curcmd->data->len - slot->offset); 503 else 504#endif 505 left = min(512, slot->curcmd->data->len - slot->offset); |
500 slot->offset += left; 501 502 /* If we are too fast, broken controllers return zeroes. */ 503 if (slot->quirks & SDHCI_QUIRK_BROKEN_TIMINGS) 504 DELAY(10); 505 /* Handle unaligned and aligned buffer cases. */ 506 if ((intptr_t)buffer & 3) { 507 while (left > 3) { --- 26 unchanged lines hidden (view full) --- 534{ 535 uint32_t data = 0; 536 char *buffer; 537 size_t left; 538 539 buffer = slot->curcmd->data->data; 540 buffer += slot->offset; 541 /* Transfer one block at a time. */ | 506 slot->offset += left; 507 508 /* If we are too fast, broken controllers return zeroes. */ 509 if (slot->quirks & SDHCI_QUIRK_BROKEN_TIMINGS) 510 DELAY(10); 511 /* Handle unaligned and aligned buffer cases. */ 512 if ((intptr_t)buffer & 3) { 513 while (left > 3) { --- 26 unchanged lines hidden (view full) --- 540{ 541 uint32_t data = 0; 542 char *buffer; 543 size_t left; 544 545 buffer = slot->curcmd->data->data; 546 buffer += slot->offset; 547 /* Transfer one block at a time. */ |
542 left = min(512, slot->curcmd->data->len - slot->offset); | 548#ifdef MMCCAM 549 if (slot->curcmd->data->flags & MMC_DATA_BLOCK_SIZE) { 550 left = min(slot->curcmd->data->block_size, 551 slot->curcmd->data->len - slot->offset); 552 } else 553#endif 554 left = min(512, slot->curcmd->data->len - slot->offset); |
543 slot->offset += left; 544 545 /* Handle unaligned and aligned buffer cases. */ 546 if ((intptr_t)buffer & 3) { 547 while (left > 3) { 548 data = buffer[0] + 549 (buffer[1] << 8) + 550 (buffer[2] << 16) + --- 1067 unchanged lines hidden (view full) --- 1618sdhci_set_transfer_mode(struct sdhci_slot *slot, const struct mmc_data *data) 1619{ 1620 uint16_t mode; 1621 1622 if (data == NULL) 1623 return; 1624 1625 mode = SDHCI_TRNS_BLK_CNT_EN; | 555 slot->offset += left; 556 557 /* Handle unaligned and aligned buffer cases. */ 558 if ((intptr_t)buffer & 3) { 559 while (left > 3) { 560 data = buffer[0] + 561 (buffer[1] << 8) + 562 (buffer[2] << 16) + --- 1067 unchanged lines hidden (view full) --- 1630sdhci_set_transfer_mode(struct sdhci_slot *slot, const struct mmc_data *data) 1631{ 1632 uint16_t mode; 1633 1634 if (data == NULL) 1635 return; 1636 1637 mode = SDHCI_TRNS_BLK_CNT_EN; |
1626 if (data->len > 512) { | 1638 if (data->len > 512 || data->block_count > 1) { |
1627 mode |= SDHCI_TRNS_MULTI; | 1639 mode |= SDHCI_TRNS_MULTI; |
1628 if (__predict_true( | 1640 if (data->block_count == 0 && __predict_true( |
1629#ifdef MMCCAM 1630 slot->ccb->mmcio.stop.opcode == MMC_STOP_TRANSMISSION && 1631#else 1632 slot->req->stop != NULL && 1633#endif 1634 !(slot->quirks & SDHCI_QUIRK_BROKEN_AUTO_STOP))) 1635 mode |= SDHCI_TRNS_ACMD12; 1636 } --- 246 unchanged lines hidden (view full) --- 1883 if (data->len == sdma_bbufsz) 1884 slot->intmask &= ~SDHCI_INT_DMA_END; 1885 else 1886 slot->intmask |= SDHCI_INT_DMA_END; 1887 WR4(slot, SDHCI_SIGNAL_ENABLE, slot->intmask); 1888 } 1889 /* Current data offset for both PIO and DMA. */ 1890 slot->offset = 0; | 1641#ifdef MMCCAM 1642 slot->ccb->mmcio.stop.opcode == MMC_STOP_TRANSMISSION && 1643#else 1644 slot->req->stop != NULL && 1645#endif 1646 !(slot->quirks & SDHCI_QUIRK_BROKEN_AUTO_STOP))) 1647 mode |= SDHCI_TRNS_ACMD12; 1648 } --- 246 unchanged lines hidden (view full) --- 1895 if (data->len == sdma_bbufsz) 1896 slot->intmask &= ~SDHCI_INT_DMA_END; 1897 else 1898 slot->intmask |= SDHCI_INT_DMA_END; 1899 WR4(slot, SDHCI_SIGNAL_ENABLE, slot->intmask); 1900 } 1901 /* Current data offset for both PIO and DMA. */ 1902 slot->offset = 0; |
1891 /* Set block size and request border interrupts on the SDMA boundary. */ 1892 blksz = SDHCI_MAKE_BLKSZ(slot->sdma_boundary, ulmin(data->len, 512)); | 1903#ifdef MMCCAM 1904 if (data->flags & MMC_DATA_BLOCK_SIZE) { 1905 /* Set block size and request border interrupts on the SDMA boundary. */ 1906 blksz = SDHCI_MAKE_BLKSZ(slot->sdma_boundary, data->block_size); 1907 blkcnt = data->block_count; 1908 if (__predict_false(sdhci_debug > 0)) 1909 slot_printf(slot, "SDIO Custom block params: blksz: " 1910 "%#10x, blk cnt: %#10x\n", blksz, blkcnt); 1911 } else 1912#endif 1913 { 1914 /* Set block size and request border interrupts on the SDMA boundary. */ 1915 blksz = SDHCI_MAKE_BLKSZ(slot->sdma_boundary, ulmin(data->len, 512)); 1916 blkcnt = howmany(data->len, 512); 1917 } 1918 |
1893 WR2(slot, SDHCI_BLOCK_SIZE, blksz); | 1919 WR2(slot, SDHCI_BLOCK_SIZE, blksz); |
1894 /* Set block count. */ 1895 blkcnt = howmany(data->len, 512); | |
1896 WR2(slot, SDHCI_BLOCK_COUNT, blkcnt); 1897 if (__predict_false(sdhci_debug > 1)) 1898 slot_printf(slot, "Blk size: 0x%08x | Blk cnt: 0x%08x\n", 1899 blksz, blkcnt); 1900} 1901 1902void 1903sdhci_finish_data(struct sdhci_slot *slot) --- 872 unchanged lines hidden (view full) --- 2776 2777 SDHCI_LOCK(slot); 2778/* if (slot->req != NULL) { 2779 SDHCI_UNLOCK(slot); 2780 return (EBUSY); 2781 } 2782*/ 2783 if (__predict_false(sdhci_debug > 1)) { | 1920 WR2(slot, SDHCI_BLOCK_COUNT, blkcnt); 1921 if (__predict_false(sdhci_debug > 1)) 1922 slot_printf(slot, "Blk size: 0x%08x | Blk cnt: 0x%08x\n", 1923 blksz, blkcnt); 1924} 1925 1926void 1927sdhci_finish_data(struct sdhci_slot *slot) --- 872 unchanged lines hidden (view full) --- 2800 2801 SDHCI_LOCK(slot); 2802/* if (slot->req != NULL) { 2803 SDHCI_UNLOCK(slot); 2804 return (EBUSY); 2805 } 2806*/ 2807 if (__predict_false(sdhci_debug > 1)) { |
2784 slot_printf(slot, "CMD%u arg %#x flags %#x dlen %u dflags %#x\n", 2785 mmcio->cmd.opcode, mmcio->cmd.arg, mmcio->cmd.flags, 2786 mmcio->cmd.data != NULL ? (unsigned int) mmcio->cmd.data->len : 0, 2787 mmcio->cmd.data != NULL ? mmcio->cmd.data->flags: 0); | 2808 slot_printf(slot, "CMD%u arg %#x flags %#x dlen %u dflags %#x " 2809 "blksz=%zu blkcnt=%zu\n", 2810 mmcio->cmd.opcode, mmcio->cmd.arg, mmcio->cmd.flags, 2811 mmcio->cmd.data != NULL ? (unsigned int) mmcio->cmd.data->len : 0, 2812 mmcio->cmd.data != NULL ? mmcio->cmd.data->flags : 0, 2813 mmcio->cmd.data != NULL ? mmcio->cmd.data->block_size : 0, 2814 mmcio->cmd.data != NULL ? mmcio->cmd.data->block_count : 0); |
2788 } 2789 if (mmcio->cmd.data != NULL) { 2790 if (mmcio->cmd.data->len == 0 || mmcio->cmd.data->flags == 0) 2791 panic("data->len = %d, data->flags = %d -- something is b0rked", 2792 (int)mmcio->cmd.data->len, mmcio->cmd.data->flags); 2793 } 2794 slot->ccb = ccb; 2795 slot->flags = 0; --- 13 unchanged lines hidden --- | 2815 } 2816 if (mmcio->cmd.data != NULL) { 2817 if (mmcio->cmd.data->len == 0 || mmcio->cmd.data->flags == 0) 2818 panic("data->len = %d, data->flags = %d -- something is b0rked", 2819 (int)mmcio->cmd.data->len, mmcio->cmd.data->flags); 2820 } 2821 slot->ccb = ccb; 2822 slot->flags = 0; --- 13 unchanged lines hidden --- |