CVS commit: src/sys/dev/sdmmc
Module Name:src Committed By: riastradh Date: Tue Jan 23 23:13:05 UTC 2024 Modified Files: src/sys/dev/sdmmc: ld_sdmmc.c Log Message: ld@sdmmc(4): Hack around deadlock in cache sync on detach. Yanking a card triggers the sdmmc discovery task, which runs in the sdmmc task thread, to detach any attached child devices. Detaching ld@sdmmc triggers a cache flush (via ldbegindetach -> disk_begindetach -> ld_lastclose -> ld_flush -> ioctl DIOCCACHESYNC), which is implemented by scheduling a task to do sdmmc_mem_flush_cache and then waiting for it to complete. The sdmmc_mem_cache_flush is done by an sdmmc task so it happens after all previously scheduled I/O operations -- that way the cache flush doesn't complete until the previously scheduled I/O operations are complete. However, when the cache flush task is issued from the discovery task, this doesn't work, because the cache flush task can't start until the discovery task has returned -- but the discovery task won't return until the cache flush task has completed. To work around this deadlock, which usually happens only when the device has been yanked anyway so further I/O would be lost anyway, just do the cache flush synchronously in DIOCCACHESYNC if we're running in the task thread. This isn't quite right -- implementation details of the task thread shouldn't bleed into ld@sdmmc, and running the cache sync _before_ any subsequently scheduled I/O tasks is asking for trouble -- but it should serve to avoid the deadlock in PR kern/57870 until we can fix a host of concurrency bugs in sdmmc by fixing the locking scheme and running discovery in a separate thread from tasks. XXX pullup-10 To generate a diff of this commit: cvs rdiff -u -r1.42 -r1.43 src/sys/dev/sdmmc/ld_sdmmc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sdmmc/ld_sdmmc.c diff -u src/sys/dev/sdmmc/ld_sdmmc.c:1.42 src/sys/dev/sdmmc/ld_sdmmc.c:1.43 --- src/sys/dev/sdmmc/ld_sdmmc.c:1.42 Mon May 16 10:03:23 2022 +++ src/sys/dev/sdmmc/ld_sdmmc.c Tue Jan 23 23:13:05 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: ld_sdmmc.c,v 1.42 2022/05/16 10:03:23 jmcneill Exp $ */ +/* $NetBSD: ld_sdmmc.c,v 1.43 2024/01/23 23:13:05 riastradh Exp $ */ /* * Copyright (c) 2008 KIYOHARA Takashi @@ -28,7 +28,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ld_sdmmc.c,v 1.42 2022/05/16 10:03:23 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ld_sdmmc.c,v 1.43 2024/01/23 23:13:05 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_sdmmc.h" @@ -599,9 +599,24 @@ static int ld_sdmmc_cachesync(struct ld_softc *ld, bool poll) { struct ld_sdmmc_softc *sc = device_private(ld->sc_dv); + struct sdmmc_softc *sdmmc = device_private(device_parent(ld->sc_dv)); struct ld_sdmmc_task *task; int error = -1; + /* + * If we come here through the sdmmc discovery task, we can't + * wait for a new task because the new task can't even begin + * until the sdmmc discovery task has completed. + * + * XXX This is wrong, because there may already be queued I/O + * tasks ahead of us. Fixing this properly requires doing + * discovery in a separate thread. But this should avoid the + * deadlock of PR kern/57870 (https://gnats.NetBSD.org/57870) + * until we do split that up. + */ + if (curlwp == sdmmc->sc_tskq_lwp) + return sdmmc_mem_flush_cache(sc->sc_sf, poll); + mutex_enter(&sc->sc_lock); /* Acquire a free task, or fail with EBUSY. */
CVS commit: src/sys/dev/sdmmc
Module Name:src Committed By: riastradh Date: Tue Jan 23 23:13:05 UTC 2024 Modified Files: src/sys/dev/sdmmc: ld_sdmmc.c Log Message: ld@sdmmc(4): Hack around deadlock in cache sync on detach. Yanking a card triggers the sdmmc discovery task, which runs in the sdmmc task thread, to detach any attached child devices. Detaching ld@sdmmc triggers a cache flush (via ldbegindetach -> disk_begindetach -> ld_lastclose -> ld_flush -> ioctl DIOCCACHESYNC), which is implemented by scheduling a task to do sdmmc_mem_flush_cache and then waiting for it to complete. The sdmmc_mem_cache_flush is done by an sdmmc task so it happens after all previously scheduled I/O operations -- that way the cache flush doesn't complete until the previously scheduled I/O operations are complete. However, when the cache flush task is issued from the discovery task, this doesn't work, because the cache flush task can't start until the discovery task has returned -- but the discovery task won't return until the cache flush task has completed. To work around this deadlock, which usually happens only when the device has been yanked anyway so further I/O would be lost anyway, just do the cache flush synchronously in DIOCCACHESYNC if we're running in the task thread. This isn't quite right -- implementation details of the task thread shouldn't bleed into ld@sdmmc, and running the cache sync _before_ any subsequently scheduled I/O tasks is asking for trouble -- but it should serve to avoid the deadlock in PR kern/57870 until we can fix a host of concurrency bugs in sdmmc by fixing the locking scheme and running discovery in a separate thread from tasks. XXX pullup-10 To generate a diff of this commit: cvs rdiff -u -r1.42 -r1.43 src/sys/dev/sdmmc/ld_sdmmc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/sdmmc
Module Name:src Committed By: jmcneill Date: Sat Jan 20 00:22:11 UTC 2024 Modified Files: src/sys/dev/sdmmc: sdhc.c sdhcvar.h Log Message: sdmmc: add support for optional delay after register write To generate a diff of this commit: cvs rdiff -u -r1.117 -r1.118 src/sys/dev/sdmmc/sdhc.c cvs rdiff -u -r1.33 -r1.34 src/sys/dev/sdmmc/sdhcvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sdmmc/sdhc.c diff -u src/sys/dev/sdmmc/sdhc.c:1.117 src/sys/dev/sdmmc/sdhc.c:1.118 --- src/sys/dev/sdmmc/sdhc.c:1.117 Wed Nov 2 10:38:04 2022 +++ src/sys/dev/sdmmc/sdhc.c Sat Jan 20 00:22:11 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: sdhc.c,v 1.117 2022/11/02 10:38:04 jmcneill Exp $ */ +/* $NetBSD: sdhc.c,v 1.118 2024/01/20 00:22:11 jmcneill Exp $ */ /* $OpenBSD: sdhc.c,v 1.25 2009/01/13 19:44:20 grange Exp $ */ /* @@ -23,7 +23,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sdhc.c,v 1.117 2022/11/02 10:38:04 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sdhc.c,v 1.118 2024/01/20 00:22:11 jmcneill Exp $"); #ifdef _KERNEL_OPT #include "opt_sdmmc.h" @@ -142,6 +142,9 @@ hwrite1(struct sdhc_host *hp, bus_size_t tmp = (val << shift) | (tmp & ~(0xffU << shift)); bus_space_write_4(hp->iot, hp->ioh, o, tmp); } + if (hp->sc->sc_write_delay != 0) { + delay(hp->sc->sc_write_delay); + } } static void @@ -157,6 +160,9 @@ hwrite2(struct sdhc_host *hp, bus_size_t tmp = (val << shift) | (tmp & ~(0xU << shift)); bus_space_write_4(hp->iot, hp->ioh, o, tmp); } + if (hp->sc->sc_write_delay != 0) { + delay(hp->sc->sc_write_delay); + } } static void @@ -164,6 +170,9 @@ hwrite4(struct sdhc_host *hp, bus_size_t { bus_space_write_4(hp->iot, hp->ioh, o, val); + if (hp->sc->sc_write_delay != 0) { + delay(hp->sc->sc_write_delay); + } } #define HWRITE1(hp, reg, val) hwrite1(hp, reg, val) Index: src/sys/dev/sdmmc/sdhcvar.h diff -u src/sys/dev/sdmmc/sdhcvar.h:1.33 src/sys/dev/sdmmc/sdhcvar.h:1.34 --- src/sys/dev/sdmmc/sdhcvar.h:1.33 Fri Oct 14 07:54:49 2022 +++ src/sys/dev/sdmmc/sdhcvar.h Sat Jan 20 00:22:11 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: sdhcvar.h,v 1.33 2022/10/14 07:54:49 jmcneill Exp $ */ +/* $NetBSD: sdhcvar.h,v 1.34 2024/01/20 00:22:11 jmcneill Exp $ */ /* $OpenBSD: sdhcvar.h,v 1.3 2007/09/06 08:01:01 jsg Exp $ */ /* @@ -82,6 +82,8 @@ struct sdhc_softc { int (*sc_vendor_transfer_data_dma)(struct sdhc_softc *, struct sdmmc_command *); void (*sc_vendor_hw_reset)(struct sdhc_softc *, struct sdhc_host *); int (*sc_vendor_signal_voltage)(struct sdhc_softc *, int); + + u_int sc_write_delay; /* delay (us) after io write */ }; /* Host controller functions called by the attachment driver. */
CVS commit: src/sys/dev/sdmmc
Module Name:src Committed By: jmcneill Date: Sat Jan 20 00:22:11 UTC 2024 Modified Files: src/sys/dev/sdmmc: sdhc.c sdhcvar.h Log Message: sdmmc: add support for optional delay after register write To generate a diff of this commit: cvs rdiff -u -r1.117 -r1.118 src/sys/dev/sdmmc/sdhc.c cvs rdiff -u -r1.33 -r1.34 src/sys/dev/sdmmc/sdhcvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/sdmmc
Module Name:src Committed By: jmcneill Date: Sat Apr 29 13:21:31 UTC 2023 Modified Files: src/sys/dev/sdmmc: sdmmc_mem.c Log Message: sdmmc: Only check chipset WP status for SD cards. The sdmmc_chip_write_protect callback returns the write protect switch status from the controller (SDWP#). This signal does not exist for eMMC; instead, write protect is signaled using card registers (CSD). So lets skip asking the chipset for WP status on eMMC cards for each write request. To generate a diff of this commit: cvs rdiff -u -r1.74 -r1.75 src/sys/dev/sdmmc/sdmmc_mem.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/sdmmc
Module Name:src Committed By: jmcneill Date: Sat Apr 29 13:21:31 UTC 2023 Modified Files: src/sys/dev/sdmmc: sdmmc_mem.c Log Message: sdmmc: Only check chipset WP status for SD cards. The sdmmc_chip_write_protect callback returns the write protect switch status from the controller (SDWP#). This signal does not exist for eMMC; instead, write protect is signaled using card registers (CSD). So lets skip asking the chipset for WP status on eMMC cards for each write request. To generate a diff of this commit: cvs rdiff -u -r1.74 -r1.75 src/sys/dev/sdmmc/sdmmc_mem.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sdmmc/sdmmc_mem.c diff -u src/sys/dev/sdmmc/sdmmc_mem.c:1.74 src/sys/dev/sdmmc/sdmmc_mem.c:1.75 --- src/sys/dev/sdmmc/sdmmc_mem.c:1.74 Tue Aug 3 07:54:39 2021 +++ src/sys/dev/sdmmc/sdmmc_mem.c Sat Apr 29 13:21:31 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: sdmmc_mem.c,v 1.74 2021/08/03 07:54:39 msaitoh Exp $ */ +/* $NetBSD: sdmmc_mem.c,v 1.75 2023/04/29 13:21:31 jmcneill Exp $ */ /* $OpenBSD: sdmmc_mem.c,v 1.10 2009/01/09 10:55:22 jsg Exp $ */ /* @@ -45,7 +45,7 @@ /* Routines for SD/MMC memory cards. */ #include -__KERNEL_RCSID(0, "$NetBSD: sdmmc_mem.c,v 1.74 2021/08/03 07:54:39 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sdmmc_mem.c,v 1.75 2023/04/29 13:21:31 jmcneill Exp $"); #ifdef _KERNEL_OPT #include "opt_sdmmc.h" @@ -2125,7 +2125,8 @@ sdmmc_mem_write_block(struct sdmmc_funct SDMMC_LOCK(sc); mutex_enter(&sc->sc_mtx); - if (sdmmc_chip_write_protect(sc->sc_sct, sc->sc_sch)) { + if (ISSET(sc->sc_flags, SMF_SD_MODE) && + sdmmc_chip_write_protect(sc->sc_sct, sc->sc_sch)) { aprint_normal_dev(sc->sc_dev, "write-protected\n"); error = EIO; goto out;
CVS commit: src/sys/dev/sdmmc
Module Name:src Committed By: jmcneill Date: Wed Nov 2 10:38:04 UTC 2022 Modified Files: src/sys/dev/sdmmc: sdhc.c Log Message: Select DMA mode after programming the ADMA base address register(s). The Arasan SDHCI 8.9a found in the Xilinx Zynq-7000 SoC requires this sequence to avoid sporadic transfer errors. To generate a diff of this commit: cvs rdiff -u -r1.116 -r1.117 src/sys/dev/sdmmc/sdhc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sdmmc/sdhc.c diff -u src/sys/dev/sdmmc/sdhc.c:1.116 src/sys/dev/sdmmc/sdhc.c:1.117 --- src/sys/dev/sdmmc/sdhc.c:1.116 Fri Oct 14 07:54:49 2022 +++ src/sys/dev/sdmmc/sdhc.c Wed Nov 2 10:38:04 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: sdhc.c,v 1.116 2022/10/14 07:54:49 jmcneill Exp $ */ +/* $NetBSD: sdhc.c,v 1.117 2022/11/02 10:38:04 jmcneill Exp $ */ /* $OpenBSD: sdhc.c,v 1.25 2009/01/13 19:44:20 grange Exp $ */ /* @@ -23,7 +23,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sdhc.c,v 1.116 2022/10/14 07:54:49 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sdhc.c,v 1.117 2022/11/02 10:38:04 jmcneill Exp $"); #ifdef _KERNEL_OPT #include "opt_sdmmc.h" @@ -1835,21 +1835,21 @@ sdhc_start_command(struct sdhc_host *hp, } bus_dmamap_sync(sc->sc_dmat, hp->adma_map, 0, PAGE_SIZE, BUS_DMASYNC_PREWRITE); - if (ISSET(hp->sc->sc_flags, SDHC_FLAG_USDHC)) { - HCLR4(hp, SDHC_HOST_CTL, SDHC_USDHC_DMA_SELECT); - HSET4(hp, SDHC_HOST_CTL, SDHC_USDHC_DMA_SELECT_ADMA2); - } else { - HCLR1(hp, SDHC_HOST_CTL, SDHC_DMA_SELECT); - HSET1(hp, SDHC_HOST_CTL, SDHC_DMA_SELECT_ADMA2); - } const bus_addr_t desc_addr = hp->adma_map->dm_segs[0].ds_addr; - HWRITE4(hp, SDHC_ADMA_SYSTEM_ADDR, desc_addr & 0x); if (ISSET(hp->flags, SHF_USE_ADMA2_64)) { HWRITE4(hp, SDHC_ADMA_SYSTEM_ADDR + 4, (uint64_t)desc_addr >> 32); } + + if (ISSET(hp->sc->sc_flags, SDHC_FLAG_USDHC)) { + HCLR4(hp, SDHC_HOST_CTL, SDHC_USDHC_DMA_SELECT); + HSET4(hp, SDHC_HOST_CTL, SDHC_USDHC_DMA_SELECT_ADMA2); + } else { + HCLR1(hp, SDHC_HOST_CTL, SDHC_DMA_SELECT); + HSET1(hp, SDHC_HOST_CTL, SDHC_DMA_SELECT_ADMA2); + } } else if (ISSET(mode, SDHC_DMA_ENABLE) && !ISSET(sc->sc_flags, SDHC_FLAG_EXTERNAL_DMA)) { if (ISSET(hp->sc->sc_flags, SDHC_FLAG_USDHC)) {
CVS commit: src/sys/dev/sdmmc
Module Name:src Committed By: jmcneill Date: Wed Nov 2 10:38:04 UTC 2022 Modified Files: src/sys/dev/sdmmc: sdhc.c Log Message: Select DMA mode after programming the ADMA base address register(s). The Arasan SDHCI 8.9a found in the Xilinx Zynq-7000 SoC requires this sequence to avoid sporadic transfer errors. To generate a diff of this commit: cvs rdiff -u -r1.116 -r1.117 src/sys/dev/sdmmc/sdhc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/sdmmc
Module Name:src Committed By: skrll Date: Sat Jun 18 08:22:11 UTC 2022 Modified Files: src/sys/dev/sdmmc: if_bwfm_sdio.c Log Message: Trailing whitespace To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/sys/dev/sdmmc/if_bwfm_sdio.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sdmmc/if_bwfm_sdio.c diff -u src/sys/dev/sdmmc/if_bwfm_sdio.c:1.28 src/sys/dev/sdmmc/if_bwfm_sdio.c:1.29 --- src/sys/dev/sdmmc/if_bwfm_sdio.c:1.28 Mon Mar 14 06:40:12 2022 +++ src/sys/dev/sdmmc/if_bwfm_sdio.c Sat Jun 18 08:22:10 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: if_bwfm_sdio.c,v 1.28 2022/03/14 06:40:12 mlelstv Exp $ */ +/* $NetBSD: if_bwfm_sdio.c,v 1.29 2022/06/18 08:22:10 skrll Exp $ */ /* $OpenBSD: if_bwfm_sdio.c,v 1.1 2017/10/11 17:19:50 patrick Exp $ */ /* * Copyright (c) 2010-2016 Broadcom Corporation @@ -182,9 +182,9 @@ static void bwfm_sdio_rx_frames(struct b static void bwfm_sdio_rx_glom(struct bwfm_sdio_softc *, uint16_t *, int, uint16_t *); -#ifdef BWFM_DEBUG +#ifdef BWFM_DEBUG static void bwfm_sdio_debug_console(struct bwfm_sdio_softc *); -#endif +#endif static const struct bwfm_firmware_selector bwfm_sdio_fwtab[] = { BWFM_FW_ENTRY(BRCM_CC_43143_CHIP_ID, @@ -233,7 +233,7 @@ static const struct bwfm_firmware_select BWFM_FW_ENTRY(BRCM_CC_4354_CHIP_ID, BWFM_FWSEL_ALLREVS, "brcmfmac4354-sdio"), - + BWFM_FW_ENTRY(BRCM_CC_4356_CHIP_ID, BWFM_FWSEL_ALLREVS, "brcmfmac4356-sdio"), @@ -274,32 +274,32 @@ static const struct bwfm_sdio_product { } bwfm_sdio_products[] = { { SDMMC_VENDOR_BROADCOM, - SDMMC_PRODUCT_BROADCOM_BCM4330, + SDMMC_PRODUCT_BROADCOM_BCM4330, SDMMC_CIS_BROADCOM_BCM4330 }, { SDMMC_VENDOR_BROADCOM, - SDMMC_PRODUCT_BROADCOM_BCM4334, + SDMMC_PRODUCT_BROADCOM_BCM4334, SDMMC_CIS_BROADCOM_BCM4334 }, { SDMMC_VENDOR_BROADCOM, - SDMMC_PRODUCT_BROADCOM_BCM43143, + SDMMC_PRODUCT_BROADCOM_BCM43143, SDMMC_CIS_BROADCOM_BCM43143 }, { SDMMC_VENDOR_BROADCOM, - SDMMC_PRODUCT_BROADCOM_BCM43430, + SDMMC_PRODUCT_BROADCOM_BCM43430, SDMMC_CIS_BROADCOM_BCM43430 }, { SDMMC_VENDOR_BROADCOM, - SDMMC_PRODUCT_BROADCOM_BCM43455, + SDMMC_PRODUCT_BROADCOM_BCM43455, SDMMC_CIS_BROADCOM_BCM43455 }, { SDMMC_VENDOR_BROADCOM, - SDMMC_PRODUCT_BROADCOM_BCM43362, + SDMMC_PRODUCT_BROADCOM_BCM43362, SDMMC_CIS_BROADCOM_BCM43362 }, }; @@ -379,7 +379,7 @@ bwfm_sdio_attach(device_t parent, device sc->sc_sf[sf->number] = sf; } - sdmmc_io_set_blocklen(sc->sc_sf[1], 64); + sdmmc_io_set_blocklen(sc->sc_sf[1], 64); sdmmc_io_set_blocklen(sc->sc_sf[2], 512); /* Enable Function 1. */ @@ -1308,9 +1308,9 @@ static struct bwfm_sdio_dstab pmu11_1v8[ {1, 0x1}, {0, 0x0} }, pmu17_1v8[] = { - {3, 0x3}, - {2, 0x2}, - {1, 0x1}, + {3, 0x3}, + {2, 0x2}, + {1, 0x1}, {0, 0x0} }, pmu17_3v3[] = { {16, 0x7}, @@ -1536,7 +1536,7 @@ bwfm_sdio_tx_ok(struct bwfm_sdio_softc * ((uint8_t)(sc->sc_tx_max_seq - sc->sc_tx_seq) & 0x80) == 0; } -static void +static void bwfm_sdio_tx_frames(struct bwfm_sdio_softc *sc) { struct mbuf *m; @@ -1556,7 +1556,7 @@ bwfm_sdio_tx_frames(struct bwfm_sdio_sof if (m->m_type == MT_CONTROL) bwfm_sdio_tx_ctrlframe(sc, m); else { - bwfm_sdio_tx_dataframe(sc, m); + bwfm_sdio_tx_dataframe(sc, m); if_statinc(ifp, if_opackets); ifstart = true; } @@ -1576,7 +1576,7 @@ bwfm_sdio_tx_ctrlframe(struct bwfm_sdio_ struct bwfm_sdio_hwhdr *hwhdr; struct bwfm_sdio_swhdr *swhdr; size_t len, roundto; - + len = sizeof(*hwhdr) + sizeof(*swhdr) + m->m_len; /* Zero-pad to either block-size or 4-byte alignment. */ @@ -1586,24 +1586,24 @@ bwfm_sdio_tx_ctrlframe(struct bwfm_sdio_ roundto = 4; KASSERT(roundup(len, roundto) <= sc->sc_bounce_size); - + hwhdr = (void *)sc->sc_bounce_buf; hwhdr->frmlen = htole16(len); hwhdr->cksum = htole16(~len); - + swhdr = (void *)&hwhdr[1]; swhdr->seqnr = sc->sc_tx_seq++; swhdr->chanflag = BWFM_SDIO_SWHDR_CHANNEL_CONTROL; swhdr->nextlen = 0; swhdr->dataoff = sizeof(*hwhdr) + sizeof(*swhdr); swhdr->maxseqnr = 0; - + m_copydata(m, 0, m->m_len, &swhdr[1]); - + if (roundup(len, roundto) != len) memset(sc->sc_bounce_buf + len, 0, roundup(len, roundto) - len); - + bwfm_sdio_frame_read_write(sc, sc->sc_bounce_buf, roundup(len, roundto), 1); } @@ -1688,11 +1688,11 @@ bwfm_sdio_rxctl(struct bwfm_softc *bwfm, static void bwfm_sdio_rx_frames(struct bwfm_sdio_softc *sc) -{ +{ struct bwfm_sdio_hwhdr *hwhdr; struct bwfm_sdio_swhdr *swhdr; struct bwfm_proto_bcdc_hdr *bcdc; - uint16_t *sublen, nextlen = 0; + uint16_t *sublen, nextlen = 0; struct mbuf *m; size_t flen, off, hoff; char *data; @@ -1702,7 +1702,7 @@ bwfm_sdio_rx_frames(struct bwfm_sdio_sof hwhdr = (struct bwfm_sdio_hwhdr *)sc->sc_bounce_buf; swhdr = (struct bw
CVS commit: src/sys/dev/sdmmc
Module Name:src Committed By: skrll Date: Sat Jun 18 08:22:11 UTC 2022 Modified Files: src/sys/dev/sdmmc: if_bwfm_sdio.c Log Message: Trailing whitespace To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/sys/dev/sdmmc/if_bwfm_sdio.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/sdmmc
Module Name:src Committed By: jmcneill Date: Mon May 16 10:03:23 UTC 2022 Modified Files: src/sys/dev/sdmmc: ld_sdmmc.c Log Message: sdmmc: ld: Include the card type (SD card, MMC) in the disk description. To generate a diff of this commit: cvs rdiff -u -r1.41 -r1.42 src/sys/dev/sdmmc/ld_sdmmc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sdmmc/ld_sdmmc.c diff -u src/sys/dev/sdmmc/ld_sdmmc.c:1.41 src/sys/dev/sdmmc/ld_sdmmc.c:1.42 --- src/sys/dev/sdmmc/ld_sdmmc.c:1.41 Sun Aug 2 01:17:56 2020 +++ src/sys/dev/sdmmc/ld_sdmmc.c Mon May 16 10:03:23 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: ld_sdmmc.c,v 1.41 2020/08/02 01:17:56 riastradh Exp $ */ +/* $NetBSD: ld_sdmmc.c,v 1.42 2022/05/16 10:03:23 jmcneill Exp $ */ /* * Copyright (c) 2008 KIYOHARA Takashi @@ -28,7 +28,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ld_sdmmc.c,v 1.41 2020/08/02 01:17:56 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ld_sdmmc.c,v 1.42 2022/05/16 10:03:23 jmcneill Exp $"); #ifdef _KERNEL_OPT #include "opt_sdmmc.h" @@ -247,6 +247,7 @@ ld_sdmmc_attach(device_t parent, device_ struct ld_softc *ld = &sc->sc_ld; struct ld_sdmmc_task *task; struct lwp *lwp; + const char *cardtype; int i; ld->sc_dv = self; @@ -256,8 +257,13 @@ ld_sdmmc_attach(device_t parent, device_ sa->sf->cid.rev, sa->sf->cid.psn, sa->sf->cid.mdt); aprint_naive("\n"); - sc->sc_typename = kmem_asprintf("0x%02x:0x%04x:%s", - sa->sf->cid.mid, sa->sf->cid.oid, sa->sf->cid.pnm); + if (ISSET(sa->sf->sc->sc_flags, SMF_SD_MODE)) { + cardtype = "SD card"; + } else { + cardtype = "MMC"; + } + sc->sc_typename = kmem_asprintf("%s 0x%02x:0x%04x:%s", + cardtype, sa->sf->cid.mid, sa->sf->cid.oid, sa->sf->cid.pnm); evcnt_attach_dynamic(&sc->sc_ev_discard, EVCNT_TYPE_MISC, NULL, device_xname(self), "sdmmc discard count");
CVS commit: src/sys/dev/sdmmc
Module Name:src Committed By: jmcneill Date: Mon May 16 10:03:23 UTC 2022 Modified Files: src/sys/dev/sdmmc: ld_sdmmc.c Log Message: sdmmc: ld: Include the card type (SD card, MMC) in the disk description. To generate a diff of this commit: cvs rdiff -u -r1.41 -r1.42 src/sys/dev/sdmmc/ld_sdmmc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/sdmmc
Module Name:src Committed By: mrg Date: Mon Jan 17 20:10:37 UTC 2022 Modified Files: src/sys/dev/sdmmc: sdhc.c Log Message: sdhc: avoid taking adaptive mutex while holding spin mutex the clock_bus pre- and post- callbacks used in sdhc_bus_clock_ddr() are called with a spin mutex held, and the new sdhc@acpi ends up calling into (sleeping) ACPI code, triggering lockdebug assertion. introduce an adaptive mutex that is held around these callbacks, and reduce the spin mutex held time in sdhc_bus_clock_ddr(). To generate a diff of this commit: cvs rdiff -u -r1.113 -r1.114 src/sys/dev/sdmmc/sdhc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/sdmmc
Module Name:src Committed By: mrg Date: Mon Jan 17 20:10:37 UTC 2022 Modified Files: src/sys/dev/sdmmc: sdhc.c Log Message: sdhc: avoid taking adaptive mutex while holding spin mutex the clock_bus pre- and post- callbacks used in sdhc_bus_clock_ddr() are called with a spin mutex held, and the new sdhc@acpi ends up calling into (sleeping) ACPI code, triggering lockdebug assertion. introduce an adaptive mutex that is held around these callbacks, and reduce the spin mutex held time in sdhc_bus_clock_ddr(). To generate a diff of this commit: cvs rdiff -u -r1.113 -r1.114 src/sys/dev/sdmmc/sdhc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sdmmc/sdhc.c diff -u src/sys/dev/sdmmc/sdhc.c:1.113 src/sys/dev/sdmmc/sdhc.c:1.114 --- src/sys/dev/sdmmc/sdhc.c:1.113 Sat Jan 15 14:33:36 2022 +++ src/sys/dev/sdmmc/sdhc.c Mon Jan 17 20:10:37 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: sdhc.c,v 1.113 2022/01/15 14:33:36 jmcneill Exp $ */ +/* $NetBSD: sdhc.c,v 1.114 2022/01/17 20:10:37 mrg Exp $ */ /* $OpenBSD: sdhc.c,v 1.25 2009/01/13 19:44:20 grange Exp $ */ /* @@ -23,7 +23,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sdhc.c,v 1.113 2022/01/15 14:33:36 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sdhc.c,v 1.114 2022/01/17 20:10:37 mrg Exp $"); #ifdef _KERNEL_OPT #include "opt_sdmmc.h" @@ -77,6 +77,7 @@ struct sdhc_host { uint16_t intr_status; /* soft interrupt status */ uint16_t intr_error_status; /* soft error status */ kmutex_t intr_lock; + kmutex_t bus_clock_lock; kcondvar_t intr_cv; callout_t tuning_timer; @@ -296,6 +297,7 @@ sdhc_host_found(struct sdhc_softc *sc, b hp->dmat = sc->sc_dmat; mutex_init(&hp->intr_lock, MUTEX_DEFAULT, IPL_SDMMC); + mutex_init(&hp->bus_clock_lock, MUTEX_DEFAULT, IPL_NONE); cv_init(&hp->intr_cv, "sdhcintr"); callout_init(&hp->tuning_timer, CALLOUT_MPSAFE); callout_setfunc(&hp->tuning_timer, sdhc_tuning_timer, hp); @@ -650,6 +652,7 @@ adma_done: err: callout_destroy(&hp->tuning_timer); cv_destroy(&hp->intr_cv); + mutex_destroy(&hp->bus_clock_lock); mutex_destroy(&hp->intr_lock); free(hp, M_DEVBUF); sc->sc_host[--sc->sc_nhosts] = NULL; @@ -1097,8 +1100,6 @@ sdhc_bus_clock_ddr(sdmmc_chipset_handle_ int error = 0; bool present __diagused; - mutex_enter(&hp->intr_lock); - #ifdef DIAGNOSTIC present = ISSET(HREAD4(hp, SDHC_PRESENT_STATE), SDHC_CMD_INHIBIT_MASK); @@ -1110,11 +,15 @@ sdhc_bus_clock_ddr(sdmmc_chipset_handle_ #endif if (hp->sc->sc_vendor_bus_clock) { + mutex_enter(&hp->bus_clock_lock); error = (*hp->sc->sc_vendor_bus_clock)(hp->sc, freq); + mutex_exit(&hp->bus_clock_lock); if (error != 0) - goto out; + return error; } + mutex_enter(&hp->intr_lock); + /* * Stop SD clock before changing the frequency. */ @@ -1275,11 +1280,14 @@ sdhc_bus_clock_ddr(sdmmc_chipset_handle_ HCLR1(hp, SDHC_HOST_CTL, SDHC_HIGH_SPEED); } + mutex_exit(&hp->intr_lock); + if (hp->sc->sc_vendor_bus_clock_post) { + mutex_enter(&hp->bus_clock_lock); error = (*hp->sc->sc_vendor_bus_clock_post)(hp->sc, freq); - if (error != 0) - goto out; + mutex_exit(&hp->bus_clock_lock); } + return error; out: mutex_exit(&hp->intr_lock);
CVS commit: src/sys/dev/sdmmc
Module Name:src Committed By: jmcneill Date: Sat Jan 15 14:33:36 UTC 2022 Modified Files: src/sys/dev/sdmmc: sdhc.c Log Message: sdhc: High speed support capability flag applies to eMMC too. To generate a diff of this commit: cvs rdiff -u -r1.112 -r1.113 src/sys/dev/sdmmc/sdhc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/sdmmc
Module Name:src Committed By: jmcneill Date: Sat Jan 15 14:33:36 UTC 2022 Modified Files: src/sys/dev/sdmmc: sdhc.c Log Message: sdhc: High speed support capability flag applies to eMMC too. To generate a diff of this commit: cvs rdiff -u -r1.112 -r1.113 src/sys/dev/sdmmc/sdhc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sdmmc/sdhc.c diff -u src/sys/dev/sdmmc/sdhc.c:1.112 src/sys/dev/sdmmc/sdhc.c:1.113 --- src/sys/dev/sdmmc/sdhc.c:1.112 Wed Nov 10 16:53:28 2021 +++ src/sys/dev/sdmmc/sdhc.c Sat Jan 15 14:33:36 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: sdhc.c,v 1.112 2021/11/10 16:53:28 msaitoh Exp $ */ +/* $NetBSD: sdhc.c,v 1.113 2022/01/15 14:33:36 jmcneill Exp $ */ /* $OpenBSD: sdhc.c,v 1.25 2009/01/13 19:44:20 grange Exp $ */ /* @@ -23,7 +23,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sdhc.c,v 1.112 2021/11/10 16:53:28 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sdhc.c,v 1.113 2022/01/15 14:33:36 jmcneill Exp $"); #ifdef _KERNEL_OPT #include "opt_sdmmc.h" @@ -620,7 +620,8 @@ adma_done: if (ISSET(sc->sc_flags, SDHC_FLAG_8BIT_MODE)) saa.saa_caps |= SMC_CAPS_8BIT_MODE; if (ISSET(caps, SDHC_HIGH_SPEED_SUPP)) - saa.saa_caps |= SMC_CAPS_SD_HIGHSPEED; + saa.saa_caps |= SMC_CAPS_SD_HIGHSPEED | +SMC_CAPS_MMC_HIGHSPEED; if (ISSET(caps2, SDHC_SDR104_SUPP)) saa.saa_caps |= SMC_CAPS_UHS_SDR104 | SMC_CAPS_UHS_SDR50 |
CVS commit: src/sys/dev/sdmmc
Module Name:src Committed By: joerg Date: Mon Oct 28 18:11:16 UTC 2019 Modified Files: src/sys/dev/sdmmc: sdhc.c Log Message: Avoid warnings for tautological shifts as sole conditional. To generate a diff of this commit: cvs rdiff -u -r1.105 -r1.106 src/sys/dev/sdmmc/sdhc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/sdmmc
Module Name:src Committed By: joerg Date: Mon Oct 28 18:11:16 UTC 2019 Modified Files: src/sys/dev/sdmmc: sdhc.c Log Message: Avoid warnings for tautological shifts as sole conditional. To generate a diff of this commit: cvs rdiff -u -r1.105 -r1.106 src/sys/dev/sdmmc/sdhc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sdmmc/sdhc.c diff -u src/sys/dev/sdmmc/sdhc.c:1.105 src/sys/dev/sdmmc/sdhc.c:1.106 --- src/sys/dev/sdmmc/sdhc.c:1.105 Mon Oct 28 06:00:14 2019 +++ src/sys/dev/sdmmc/sdhc.c Mon Oct 28 18:11:15 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sdhc.c,v 1.105 2019/10/28 06:00:14 mlelstv Exp $ */ +/* $NetBSD: sdhc.c,v 1.106 2019/10/28 18:11:15 joerg Exp $ */ /* $OpenBSD: sdhc.c,v 1.25 2009/01/13 19:44:20 grange Exp $ */ /* @@ -23,7 +23,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sdhc.c,v 1.105 2019/10/28 06:00:14 mlelstv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sdhc.c,v 1.106 2019/10/28 18:11:15 joerg Exp $"); #ifdef _KERNEL_OPT #include "opt_sdmmc.h" @@ -170,17 +170,17 @@ hwrite4(struct sdhc_host *hp, bus_size_t #define HWRITE4(hp, reg, val) hwrite4(hp, reg, val) #define HCLR1(hp, reg, bits) \ - do if (bits) HWRITE1((hp), (reg), HREAD1((hp), (reg)) & ~(bits)); while (0) + do if ((bits) != 0) HWRITE1((hp), (reg), HREAD1((hp), (reg)) & ~(bits)); while (0) #define HCLR2(hp, reg, bits) \ - do if (bits) HWRITE2((hp), (reg), HREAD2((hp), (reg)) & ~(bits)); while (0) + do if ((bits) != 0) HWRITE2((hp), (reg), HREAD2((hp), (reg)) & ~(bits)); while (0) #define HCLR4(hp, reg, bits) \ - do if (bits) HWRITE4((hp), (reg), HREAD4((hp), (reg)) & ~(bits)); while (0) + do if ((bits) != 0) HWRITE4((hp), (reg), HREAD4((hp), (reg)) & ~(bits)); while (0) #define HSET1(hp, reg, bits) \ - do if (bits) HWRITE1((hp), (reg), HREAD1((hp), (reg)) | (bits)); while (0) + do if ((bits) != 0) HWRITE1((hp), (reg), HREAD1((hp), (reg)) | (bits)); while (0) #define HSET2(hp, reg, bits) \ - do if (bits) HWRITE2((hp), (reg), HREAD2((hp), (reg)) | (bits)); while (0) + do if ((bits) != 0) HWRITE2((hp), (reg), HREAD2((hp), (reg)) | (bits)); while (0) #define HSET4(hp, reg, bits) \ - do if (bits) HWRITE4((hp), (reg), HREAD4((hp), (reg)) | (bits)); while (0) + do if ((bits) != 0) HWRITE4((hp), (reg), HREAD4((hp), (reg)) | (bits)); while (0) static int sdhc_host_reset(sdmmc_chipset_handle_t); static int sdhc_host_reset1(sdmmc_chipset_handle_t);
CVS commit: src/sys/dev/sdmmc
Module Name:src Committed By: mlelstv Date: Mon Oct 28 06:32:11 UTC 2019 Modified Files: src/sys/dev/sdmmc: sdmmcdevs.h Log Message: regen To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/dev/sdmmc/sdmmcdevs.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/sdmmc
Module Name:src Committed By: mlelstv Date: Mon Oct 28 06:31:39 UTC 2019 Modified Files: src/sys/dev/sdmmc: ld_sdmmc.c sdmmc_cis.c sdmmc_mem.c sdmmcdevs Log Message: Whitespace police To generate a diff of this commit: cvs rdiff -u -r1.36 -r1.37 src/sys/dev/sdmmc/ld_sdmmc.c cvs rdiff -u -r1.7 -r1.8 src/sys/dev/sdmmc/sdmmc_cis.c cvs rdiff -u -r1.69 -r1.70 src/sys/dev/sdmmc/sdmmc_mem.c cvs rdiff -u -r1.6 -r1.7 src/sys/dev/sdmmc/sdmmcdevs Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sdmmc/ld_sdmmc.c diff -u src/sys/dev/sdmmc/ld_sdmmc.c:1.36 src/sys/dev/sdmmc/ld_sdmmc.c:1.37 --- src/sys/dev/sdmmc/ld_sdmmc.c:1.36 Tue Mar 19 07:08:43 2019 +++ src/sys/dev/sdmmc/ld_sdmmc.c Mon Oct 28 06:31:39 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: ld_sdmmc.c,v 1.36 2019/03/19 07:08:43 mlelstv Exp $ */ +/* $NetBSD: ld_sdmmc.c,v 1.37 2019/10/28 06:31:39 mlelstv Exp $ */ /* * Copyright (c) 2008 KIYOHARA Takashi @@ -28,7 +28,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ld_sdmmc.c,v 1.36 2019/03/19 07:08:43 mlelstv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ld_sdmmc.c,v 1.37 2019/10/28 06:31:39 mlelstv Exp $"); #ifdef _KERNEL_OPT #include "opt_sdmmc.h" @@ -460,7 +460,7 @@ MODULE(MODULE_CLASS_DRIVER, ld_sdmmc, "l */ #undef CFDRIVER_DECL #define CFDRIVER_DECL(name, class, attr) -#include "ioconf.c" +#include "ioconf.c" #endif static int @@ -474,13 +474,13 @@ ld_sdmmc_modcmd(modcmd_t cmd, void *opaq static struct cfdriver * const no_cfdriver_vec[] = { NULL }; #endif int error = 0; - + #ifdef _MODULE switch (cmd) { case MODULE_CMD_INIT: error = config_init_component(no_cfdriver_vec, cfattach_ioconf_ld_sdmmc, cfdata_ioconf_ld_sdmmc); - break; + break; case MODULE_CMD_FINI: error = config_fini_component(no_cfdriver_vec, cfattach_ioconf_ld_sdmmc, cfdata_ioconf_ld_sdmmc); Index: src/sys/dev/sdmmc/sdmmc_cis.c diff -u src/sys/dev/sdmmc/sdmmc_cis.c:1.7 src/sys/dev/sdmmc/sdmmc_cis.c:1.8 --- src/sys/dev/sdmmc/sdmmc_cis.c:1.7 Tue Sep 24 04:56:54 2019 +++ src/sys/dev/sdmmc/sdmmc_cis.c Mon Oct 28 06:31:39 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sdmmc_cis.c,v 1.7 2019/09/24 04:56:54 mlelstv Exp $ */ +/* $NetBSD: sdmmc_cis.c,v 1.8 2019/10/28 06:31:39 mlelstv Exp $ */ /* $OpenBSD: sdmmc_cis.c,v 1.1 2006/06/01 21:53:41 uwe Exp $ */ /* @@ -20,7 +20,7 @@ /* Routines to decode the Card Information Structure of SD I/O cards */ #include -__KERNEL_RCSID(0, "$NetBSD: sdmmc_cis.c,v 1.7 2019/09/24 04:56:54 mlelstv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sdmmc_cis.c,v 1.8 2019/10/28 06:31:39 mlelstv Exp $"); #ifdef _KERNEL_OPT #include "opt_sdmmc.h" @@ -202,7 +202,7 @@ sdmmc_read_cis(struct sdmmc_function *sf } #ifdef SDMMCCISDEBUG - { + { int i; /* print the tuple */ @@ -317,7 +317,7 @@ sdmmc_check_cis_quirks(struct sdmmc_func if (sf->cis.manufacturer == SDMMC_VENDOR_SPECTEC && sf->cis.product == SDMMC_PRODUCT_SPECTEC_SDW820) { /* This card lacks the VERS_1 tuple. */ - static const char cis1_info[] = + static const char cis1_info[] = "Spectec\0SDIO WLAN Card\0SDW-820\0\0"; sf->cis.cis1_major = 0x01; Index: src/sys/dev/sdmmc/sdmmc_mem.c diff -u src/sys/dev/sdmmc/sdmmc_mem.c:1.69 src/sys/dev/sdmmc/sdmmc_mem.c:1.70 --- src/sys/dev/sdmmc/sdmmc_mem.c:1.69 Mon Oct 28 06:16:46 2019 +++ src/sys/dev/sdmmc/sdmmc_mem.c Mon Oct 28 06:31:39 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sdmmc_mem.c,v 1.69 2019/10/28 06:16:46 mlelstv Exp $ */ +/* $NetBSD: sdmmc_mem.c,v 1.70 2019/10/28 06:31:39 mlelstv Exp $ */ /* $OpenBSD: sdmmc_mem.c,v 1.10 2009/01/09 10:55:22 jsg Exp $ */ /* @@ -45,7 +45,7 @@ /* Routines for SD/MMC memory cards. */ #include -__KERNEL_RCSID(0, "$NetBSD: sdmmc_mem.c,v 1.69 2019/10/28 06:16:46 mlelstv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sdmmc_mem.c,v 1.70 2019/10/28 06:31:39 mlelstv Exp $"); #ifdef _KERNEL_OPT #include "opt_sdmmc.h" @@ -771,7 +771,7 @@ sdmmc_mem_execute_tuning(struct sdmmc_so break; case 208000: timing = SDMMC_TIMING_UHS_SDR104; - break; + break; default: return 0; } Index: src/sys/dev/sdmmc/sdmmcdevs diff -u src/sys/dev/sdmmc/sdmmcdevs:1.6 src/sys/dev/sdmmc/sdmmcdevs:1.7 --- src/sys/dev/sdmmc/sdmmcdevs:1.6 Sat Aug 24 11:24:00 2019 +++ src/sys/dev/sdmmc/sdmmcdevs Mon Oct 28 06:31:39 2019 @@ -1,4 +1,4 @@ - $NetBSD: sdmmcdevs,v 1.6 2019/08/24 11:24:00 mlelstv Exp $ + $NetBSD: sdmmcdevs,v 1.7 2019/10/28 06:31:39 mlelstv Exp $ /* $OpenBSD: sdmmcdevs,v 1.8 2007/05/11 17:16:16 mglocker Exp $ */ /* @@ -40,13 +40,13 @@ vendor ABOCOM 0x13d1 AboCom Systems, I /* AboCom Systems, Inc. */ product ABOCOM SDW11G 0xac02 SDW11G -/* Atheros */ +/* Atheros */ product ATHEROS AR6001_8 0x0108 AR6001 product ATHEROS AR6001_9 0x0109 AR6001 product ATHEROS AR6001_a 0x010a AR6001 product ATHEROS AR6001_b 0x010b AR6001 -/* Broadcom */ +/* Broadcom */ product BROADCOM BCM4324 0x4324
CVS commit: src/sys/dev/sdmmc
Module Name:src Committed By: mlelstv Date: Mon Oct 28 06:31:39 UTC 2019 Modified Files: src/sys/dev/sdmmc: ld_sdmmc.c sdmmc_cis.c sdmmc_mem.c sdmmcdevs Log Message: Whitespace police To generate a diff of this commit: cvs rdiff -u -r1.36 -r1.37 src/sys/dev/sdmmc/ld_sdmmc.c cvs rdiff -u -r1.7 -r1.8 src/sys/dev/sdmmc/sdmmc_cis.c cvs rdiff -u -r1.69 -r1.70 src/sys/dev/sdmmc/sdmmc_mem.c cvs rdiff -u -r1.6 -r1.7 src/sys/dev/sdmmc/sdmmcdevs Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/sdmmc
Module Name:src Committed By: mlelstv Date: Mon Oct 28 06:32:11 UTC 2019 Modified Files: src/sys/dev/sdmmc: sdmmcdevs.h Log Message: regen To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/dev/sdmmc/sdmmcdevs.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sdmmc/sdmmcdevs.h diff -u src/sys/dev/sdmmc/sdmmcdevs.h:1.6 src/sys/dev/sdmmc/sdmmcdevs.h:1.7 --- src/sys/dev/sdmmc/sdmmcdevs.h:1.6 Sat Aug 24 11:24:17 2019 +++ src/sys/dev/sdmmc/sdmmcdevs.h Mon Oct 28 06:32:10 2019 @@ -1,10 +1,10 @@ -/* $NetBSD: sdmmcdevs.h,v 1.6 2019/08/24 11:24:17 mlelstv Exp $ */ +/* $NetBSD: sdmmcdevs.h,v 1.7 2019/10/28 06:32:10 mlelstv Exp $ */ /* * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT. * * generated from: - * NetBSD: sdmmcdevs,v 1.6 2019/08/24 11:24:00 mlelstv Exp + * NetBSD: sdmmcdevs,v 1.7 2019/10/28 06:31:39 mlelstv Exp */ /* $OpenBSD: sdmmcdevs,v 1.8 2007/05/11 17:16:16 mglocker Exp $ */ @@ -48,7 +48,7 @@ #define SDMMC_CIS_ABOCOM_SDW11G { NULL, NULL, NULL, NULL } #define SDMMC_PRODUCT_ABOCOM_SDW11G 0xac02 -/* Atheros */ +/* Atheros */ #define SDMMC_CIS_ATHEROS_AR6001_8 { NULL, NULL, NULL, NULL } #define SDMMC_PRODUCT_ATHEROS_AR6001_8 0x0108 #define SDMMC_CIS_ATHEROS_AR6001_9 { NULL, NULL, NULL, NULL } @@ -58,7 +58,7 @@ #define SDMMC_CIS_ATHEROS_AR6001_b { NULL, NULL, NULL, NULL } #define SDMMC_PRODUCT_ATHEROS_AR6001_b 0x010b -/* Broadcom */ +/* Broadcom */ #define SDMMC_CIS_BROADCOM_BCM4324 { NULL, NULL, NULL, NULL } #define SDMMC_PRODUCT_BROADCOM_BCM4324 0x4324 #define SDMMC_CIS_BROADCOM_BCM4329 { NULL, NULL, NULL, NULL }
CVS commit: src/sys/dev/sdmmc
Module Name:src Committed By: mlelstv Date: Mon Oct 28 06:26:19 UTC 2019 Modified Files: src/sys/dev/sdmmc: sdmmc_ioreg.h Log Message: Missing commit for sdio abort function. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/dev/sdmmc/sdmmc_ioreg.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sdmmc/sdmmc_ioreg.h diff -u src/sys/dev/sdmmc/sdmmc_ioreg.h:1.4 src/sys/dev/sdmmc/sdmmc_ioreg.h:1.5 --- src/sys/dev/sdmmc/sdmmc_ioreg.h:1.4 Sun Sep 1 05:45:42 2019 +++ src/sys/dev/sdmmc/sdmmc_ioreg.h Mon Oct 28 06:26:19 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sdmmc_ioreg.h,v 1.4 2019/09/01 05:45:42 mlelstv Exp $ */ +/* $NetBSD: sdmmc_ioreg.h,v 1.5 2019/10/28 06:26:19 mlelstv Exp $ */ /* $OpenBSD: sdmmc_ioreg.h,v 1.4 2007/06/02 01:48:37 uwe Exp $ */ /* @@ -88,6 +88,7 @@ #define SD_IO_CCCR_FN_INTPENDING 0x05 #define SD_IO_CCCR_CTL 0x06 #define CCCR_CTL_RES (1<<3) +#define CCCR_CTL_AS(x) ((x) & 0x7) #define SD_IO_CCCR_BUS_WIDTH 0x07 #define CCCR_BUS_WIDTH_4 (2<<0) #define CCCR_BUS_WIDTH_1 (0<<0)
CVS commit: src/sys/dev/sdmmc
Module Name:src Committed By: mlelstv Date: Mon Oct 28 06:26:19 UTC 2019 Modified Files: src/sys/dev/sdmmc: sdmmc_ioreg.h Log Message: Missing commit for sdio abort function. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/dev/sdmmc/sdmmc_ioreg.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/sdmmc
Module Name:src Committed By: mlelstv Date: Mon Oct 28 06:20:01 UTC 2019 Modified Files: src/sys/dev/sdmmc: if_bwfm_sdio.c sdmmc_io.c sdmmcvar.h Log Message: Simplyfy sdmmc_io_set_blocklen function signature by dropping the extra softc pointer. Aligns with OpenBSD. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/dev/sdmmc/if_bwfm_sdio.c cvs rdiff -u -r1.17 -r1.18 src/sys/dev/sdmmc/sdmmc_io.c cvs rdiff -u -r1.33 -r1.34 src/sys/dev/sdmmc/sdmmcvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/sdmmc
Module Name:src Committed By: mlelstv Date: Mon Oct 28 06:20:01 UTC 2019 Modified Files: src/sys/dev/sdmmc: if_bwfm_sdio.c sdmmc_io.c sdmmcvar.h Log Message: Simplyfy sdmmc_io_set_blocklen function signature by dropping the extra softc pointer. Aligns with OpenBSD. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/dev/sdmmc/if_bwfm_sdio.c cvs rdiff -u -r1.17 -r1.18 src/sys/dev/sdmmc/sdmmc_io.c cvs rdiff -u -r1.33 -r1.34 src/sys/dev/sdmmc/sdmmcvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sdmmc/if_bwfm_sdio.c diff -u src/sys/dev/sdmmc/if_bwfm_sdio.c:1.7 src/sys/dev/sdmmc/if_bwfm_sdio.c:1.8 --- src/sys/dev/sdmmc/if_bwfm_sdio.c:1.7 Sun Oct 27 21:39:50 2019 +++ src/sys/dev/sdmmc/if_bwfm_sdio.c Mon Oct 28 06:20:01 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: if_bwfm_sdio.c,v 1.7 2019/10/27 21:39:50 bad Exp $ */ +/* $NetBSD: if_bwfm_sdio.c,v 1.8 2019/10/28 06:20:01 mlelstv Exp $ */ /* $OpenBSD: if_bwfm_sdio.c,v 1.1 2017/10/11 17:19:50 patrick Exp $ */ /* * Copyright (c) 2010-2016 Broadcom Corporation @@ -293,8 +293,8 @@ bwfm_sdio_attach(device_t parent, device sc->sc_sf[sf->number] = sf; } - sdmmc_io_set_blocklen(sc->sc_sf[1]->sc, sc->sc_sf[1], 64); - sdmmc_io_set_blocklen(sc->sc_sf[2]->sc, sc->sc_sf[2], 512); + sdmmc_io_set_blocklen(sc->sc_sf[1], 64); + sdmmc_io_set_blocklen(sc->sc_sf[2], 512); /* Enable Function 1. */ if (sdmmc_io_function_enable(sc->sc_sf[1]) != 0) { Index: src/sys/dev/sdmmc/sdmmc_io.c diff -u src/sys/dev/sdmmc/sdmmc_io.c:1.17 src/sys/dev/sdmmc/sdmmc_io.c:1.18 --- src/sys/dev/sdmmc/sdmmc_io.c:1.17 Mon Oct 28 06:16:46 2019 +++ src/sys/dev/sdmmc/sdmmc_io.c Mon Oct 28 06:20:01 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sdmmc_io.c,v 1.17 2019/10/28 06:16:46 mlelstv Exp $ */ +/* $NetBSD: sdmmc_io.c,v 1.18 2019/10/28 06:20:01 mlelstv Exp $ */ /* $OpenBSD: sdmmc_io.c,v 1.10 2007/09/17 01:33:33 krw Exp $ */ /* @@ -20,7 +20,7 @@ /* Routines for SD I/O cards. */ #include -__KERNEL_RCSID(0, "$NetBSD: sdmmc_io.c,v 1.17 2019/10/28 06:16:46 mlelstv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sdmmc_io.c,v 1.18 2019/10/28 06:20:01 mlelstv Exp $"); #ifdef _KERNEL_OPT #include "opt_sdmmc.h" @@ -825,9 +825,10 @@ sdmmc_intr_task(void *arg) } int -sdmmc_io_set_blocklen(struct sdmmc_softc *sc, struct sdmmc_function *sf, +sdmmc_io_set_blocklen(struct sdmmc_function *sf, int blklen) { + struct sdmmc_softc *sc = sf->sc; struct sdmmc_function *sf0 = sc->sc_fn0; int error = EINVAL; Index: src/sys/dev/sdmmc/sdmmcvar.h diff -u src/sys/dev/sdmmc/sdmmcvar.h:1.33 src/sys/dev/sdmmc/sdmmcvar.h:1.34 --- src/sys/dev/sdmmc/sdmmcvar.h:1.33 Mon Oct 28 06:16:46 2019 +++ src/sys/dev/sdmmc/sdmmcvar.h Mon Oct 28 06:20:01 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sdmmcvar.h,v 1.33 2019/10/28 06:16:46 mlelstv Exp $ */ +/* $NetBSD: sdmmcvar.h,v 1.34 2019/10/28 06:20:01 mlelstv Exp $ */ /* $OpenBSD: sdmmcvar.h,v 1.13 2009/01/09 10:55:22 jsg Exp $ */ /* @@ -359,8 +359,7 @@ void sdmmc_dump_data(const char *, void int sdmmc_io_enable(struct sdmmc_softc *); void sdmmc_io_scan(struct sdmmc_softc *); int sdmmc_io_init(struct sdmmc_softc *, struct sdmmc_function *); -int sdmmc_io_set_blocklen(struct sdmmc_softc *, struct sdmmc_function *, - int); +int sdmmc_io_set_blocklen(struct sdmmc_function *, int); uint8_t sdmmc_io_read_1(struct sdmmc_function *, int); uint16_t sdmmc_io_read_2(struct sdmmc_function *, int); uint32_t sdmmc_io_read_4(struct sdmmc_function *, int);
CVS commit: src/sys/dev/sdmmc
Module Name:src Committed By: mlelstv Date: Mon Oct 28 06:16:46 UTC 2019 Modified Files: src/sys/dev/sdmmc: sdmmc.c sdmmc_io.c sdmmc_mem.c sdmmcvar.h Log Message: Add and use sdmmc_pause to avoid long-term busy waits. Add sdio abort function. Additional error messages. Print parameters for SDIO devices. Minor cosmetics. To generate a diff of this commit: cvs rdiff -u -r1.38 -r1.39 src/sys/dev/sdmmc/sdmmc.c cvs rdiff -u -r1.16 -r1.17 src/sys/dev/sdmmc/sdmmc_io.c cvs rdiff -u -r1.68 -r1.69 src/sys/dev/sdmmc/sdmmc_mem.c cvs rdiff -u -r1.32 -r1.33 src/sys/dev/sdmmc/sdmmcvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/sdmmc
Module Name:src Committed By: mlelstv Date: Mon Oct 28 06:16:46 UTC 2019 Modified Files: src/sys/dev/sdmmc: sdmmc.c sdmmc_io.c sdmmc_mem.c sdmmcvar.h Log Message: Add and use sdmmc_pause to avoid long-term busy waits. Add sdio abort function. Additional error messages. Print parameters for SDIO devices. Minor cosmetics. To generate a diff of this commit: cvs rdiff -u -r1.38 -r1.39 src/sys/dev/sdmmc/sdmmc.c cvs rdiff -u -r1.16 -r1.17 src/sys/dev/sdmmc/sdmmc_io.c cvs rdiff -u -r1.68 -r1.69 src/sys/dev/sdmmc/sdmmc_mem.c cvs rdiff -u -r1.32 -r1.33 src/sys/dev/sdmmc/sdmmcvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sdmmc/sdmmc.c diff -u src/sys/dev/sdmmc/sdmmc.c:1.38 src/sys/dev/sdmmc/sdmmc.c:1.39 --- src/sys/dev/sdmmc/sdmmc.c:1.38 Wed Oct 23 05:20:52 2019 +++ src/sys/dev/sdmmc/sdmmc.c Mon Oct 28 06:16:46 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sdmmc.c,v 1.38 2019/10/23 05:20:52 hkenken Exp $ */ +/* $NetBSD: sdmmc.c,v 1.39 2019/10/28 06:16:46 mlelstv Exp $ */ /* $OpenBSD: sdmmc.c,v 1.18 2009/01/09 10:58:38 jsg Exp $ */ /* @@ -49,7 +49,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sdmmc.c,v 1.38 2019/10/23 05:20:52 hkenken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sdmmc.c,v 1.39 2019/10/28 06:16:46 mlelstv Exp $"); #ifdef _KERNEL_OPT #include "opt_sdmmc.h" @@ -568,7 +568,7 @@ sdmmc_enable(struct sdmmc_softc *sc) } /* XXX wait for card to power up */ - sdmmc_delay(10); + sdmmc_pause(10, NULL); if (!ISSET(sc->sc_caps, SMC_CAPS_SPI_MODE)) { /* Initialize SD I/O card function(s). */ @@ -790,6 +790,17 @@ sdmmc_delay(u_int usecs) delay(usecs); } +void +sdmmc_pause(u_int usecs, kmutex_t *lock) +{ + unsigned ticks = mstohz(usecs/1000); + + if (cold || ticks < 1) + delay(usecs); + else + kpause("sdmmcdelay", false, ticks, lock); +} + int sdmmc_app_command(struct sdmmc_softc *sc, struct sdmmc_function *sf, struct sdmmc_command *cmd) { @@ -910,7 +921,7 @@ sdmmc_set_relative_addr(struct sdmmc_sof /* Don't lock */ if (ISSET(sc->sc_caps, SMC_CAPS_SPI_MODE)) { - aprint_error_dev(sc->sc_dev, + device_printf(sc->sc_dev, "sdmmc_set_relative_addr: SMC_CAPS_SPI_MODE set"); return EIO; } @@ -943,7 +954,7 @@ sdmmc_select_card(struct sdmmc_softc *sc /* Don't lock */ if (ISSET(sc->sc_caps, SMC_CAPS_SPI_MODE)) { - aprint_error_dev(sc->sc_dev, + device_printf(sc->sc_dev, "sdmmc_select_card: SMC_CAPS_SPI_MODE set"); return EIO; } @@ -962,6 +973,11 @@ sdmmc_select_card(struct sdmmc_softc *sc if (error == 0 || sf == NULL) sc->sc_card = sf; + if (error) { + device_printf(sc->sc_dev, + "sdmmc_select_card: error %d", error); + } + return error; } Index: src/sys/dev/sdmmc/sdmmc_io.c diff -u src/sys/dev/sdmmc/sdmmc_io.c:1.16 src/sys/dev/sdmmc/sdmmc_io.c:1.17 --- src/sys/dev/sdmmc/sdmmc_io.c:1.16 Mon Sep 2 11:09:42 2019 +++ src/sys/dev/sdmmc/sdmmc_io.c Mon Oct 28 06:16:46 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sdmmc_io.c,v 1.16 2019/09/02 11:09:42 jmcneill Exp $ */ +/* $NetBSD: sdmmc_io.c,v 1.17 2019/10/28 06:16:46 mlelstv Exp $ */ /* $OpenBSD: sdmmc_io.c,v 1.10 2007/09/17 01:33:33 krw Exp $ */ /* @@ -20,7 +20,7 @@ /* Routines for SD I/O cards. */ #include -__KERNEL_RCSID(0, "$NetBSD: sdmmc_io.c,v 1.16 2019/09/02 11:09:42 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sdmmc_io.c,v 1.17 2019/10/28 06:16:46 mlelstv Exp $"); #ifdef _KERNEL_OPT #include "opt_sdmmc.h" @@ -230,7 +230,7 @@ sdmmc_io_init(struct sdmmc_softc *sc, st sf->csd.tran_speed = 5; /* 50MHz */ /* Wait 400KHz x 8 clock */ - delay(1); + sdmmc_delay(20); } if (sc->sc_busclk > sf->csd.tran_speed) sc->sc_busclk = sf->csd.tran_speed; @@ -240,6 +240,15 @@ sdmmc_io_init(struct sdmmc_softc *sc, st if (error) aprint_error_dev(sc->sc_dev, "can't change bus clock\n"); + + aprint_normal_dev(sc->sc_dev, "%u-bit width,", sf->width); + if ((sc->sc_busclk / 1000) != 0) + aprint_normal(" %u.%03u MHz\n", + sc->sc_busclk / 1000, sc->sc_busclk % 1000); + else + aprint_normal(" %u KHz\n", sc->sc_busclk % 1000); + + } else { reg = sdmmc_io_read_1(sf0, SD_IO_FBR(sf->number) + 0x000); sf->interface = FBR_STD_FUNC_IF_CODE(reg); @@ -357,7 +366,15 @@ sdmmc_io_rw_direct(struct sdmmc_softc *s cmd.c_flags = SCF_CMD_AC | SCF_RSP_R5; error = sdmmc_mmc_command(sc, &cmd); - *datap = SD_R5_DATA(cmd.c_resp); + if (error == 0) + *datap = SD_R5_DATA(cmd.c_resp); + + if (error) { + device_printf(sc->sc_dev, + "direct I/O error %d, r=%d p=%p %s\n", + error, reg, datap, + ISSET(arg, SD_ARG_CMD53_WRITE) ? "write" : "read"); + } return error; } @@ -404,6 +421,13 @@ sdmmc_io_rw_extended(struct sdmmc_softc error = sdmmc_mmc_command(sc, &cmd); + if (error) { + device_printf(sc->sc_dev, + "extended I/O error %d, r=%d p=%p l=%d %s\n", + error, reg, datap, datalen, + ISSET(arg, SD_ARG_CMD53
CVS commit: src/sys/dev/sdmmc
Module Name:src Committed By: mlelstv Date: Mon Oct 28 06:00:14 UTC 2019 Modified Files: src/sys/dev/sdmmc: sdhc.c Log Message: Skip setting power when the voltage doesn't change. Also increase some timeouts. To generate a diff of this commit: cvs rdiff -u -r1.104 -r1.105 src/sys/dev/sdmmc/sdhc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sdmmc/sdhc.c diff -u src/sys/dev/sdmmc/sdhc.c:1.104 src/sys/dev/sdmmc/sdhc.c:1.105 --- src/sys/dev/sdmmc/sdhc.c:1.104 Wed Oct 23 05:20:52 2019 +++ src/sys/dev/sdmmc/sdhc.c Mon Oct 28 06:00:14 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sdhc.c,v 1.104 2019/10/23 05:20:52 hkenken Exp $ */ +/* $NetBSD: sdhc.c,v 1.105 2019/10/28 06:00:14 mlelstv Exp $ */ /* $OpenBSD: sdhc.c,v 1.25 2009/01/13 19:44:20 grange Exp $ */ /* @@ -23,7 +23,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sdhc.c,v 1.104 2019/10/23 05:20:52 hkenken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sdhc.c,v 1.105 2019/10/28 06:00:14 mlelstv Exp $"); #ifdef _KERNEL_OPT #include "opt_sdmmc.h" @@ -98,6 +98,8 @@ struct sdhc_host { bus_dmamap_t adma_map; bus_dma_segment_t adma_segs[1]; void *adma2; + + uint8_t vdd; /* last vdd setting */ }; #define HDEVNAME(hp) (device_xname((hp)->sc->sc_dev)) @@ -156,10 +158,16 @@ hwrite2(struct sdhc_host *hp, bus_size_t } } +static void +hwrite4(struct sdhc_host *hp, bus_size_t o, uint32_t val) +{ + + bus_space_write_4(hp->iot, hp->ioh, o, val); +} + #define HWRITE1(hp, reg, val) hwrite1(hp, reg, val) #define HWRITE2(hp, reg, val) hwrite2(hp, reg, val) -#define HWRITE4(hp, reg, val) \ - bus_space_write_4((hp)->iot, (hp)->ioh, (reg), (val)) +#define HWRITE4(hp, reg, val) hwrite4(hp, reg, val) #define HCLR1(hp, reg, bits) \ do if (bits) HWRITE1((hp), (reg), HREAD1((hp), (reg)) & ~(bits)); while (0) @@ -788,6 +796,9 @@ sdhc_host_reset1(sdmmc_chipset_handle_t HWRITE2(hp, SDHC_NINTR_SIGNAL_EN, 0); } + /* Let sdhc_bus_power restore power */ + hp->vdd = 0; + /* * Reset the entire host controller and wait up to 100ms for * the controller to clear the reset bit. @@ -902,6 +913,7 @@ sdhc_bus_power(sdmmc_chipset_handle_t sc int error = 0; const uint32_t pcmask = ~(SDHC_BUS_POWER | (SDHC_VOLTAGE_MASK << SDHC_VOLTAGE_SHIFT)); + uint32_t reg; mutex_enter(&hp->intr_lock); @@ -909,8 +921,10 @@ sdhc_bus_power(sdmmc_chipset_handle_t sc * Disable bus power before voltage change. */ if (!ISSET(hp->sc->sc_flags, SDHC_FLAG_32BIT_ACCESS) - && !ISSET(hp->sc->sc_flags, SDHC_FLAG_NO_PWR0)) + && !ISSET(hp->sc->sc_flags, SDHC_FLAG_NO_PWR0)) { + hp->vdd = 0; HWRITE1(hp, SDHC_POWER_CTL, 0); + } /* If power is disabled, reset the host and return now. */ if (ocr == 0) { @@ -935,6 +949,12 @@ sdhc_bus_power(sdmmc_chipset_handle_t sc goto out; } + /* + * Did voltage change ? + */ + if (vdd == hp->vdd) + goto out; + if (!ISSET(hp->sc->sc_flags, SDHC_FLAG_ENHANCED)) { /* * Enable bus power. Wait at least 1 ms (or 74 clocks) plus @@ -945,13 +965,14 @@ sdhc_bus_power(sdmmc_chipset_handle_t sc HWRITE1(hp, SDHC_POWER_CTL, (vdd << SDHC_VOLTAGE_SHIFT) | SDHC_BUS_POWER); } else { - HWRITE1(hp, SDHC_POWER_CTL, - HREAD1(hp, SDHC_POWER_CTL) & pcmask); + reg = HREAD1(hp, SDHC_POWER_CTL) & pcmask; + HWRITE1(hp, SDHC_POWER_CTL, reg); sdmmc_delay(1); - HWRITE1(hp, SDHC_POWER_CTL, - (vdd << SDHC_VOLTAGE_SHIFT)); + reg |= (vdd << SDHC_VOLTAGE_SHIFT); + HWRITE1(hp, SDHC_POWER_CTL, reg); sdmmc_delay(1); - HSET1(hp, SDHC_POWER_CTL, SDHC_BUS_POWER); + reg |= SDHC_BUS_POWER; + HWRITE1(hp, SDHC_POWER_CTL, reg); sdmmc_delay(1); } @@ -966,6 +987,9 @@ sdhc_bus_power(sdmmc_chipset_handle_t sc } } + /* power successfully changed */ + hp->vdd = vdd; + out: mutex_exit(&hp->intr_lock); @@ -1522,7 +1546,7 @@ sdhc_wait_state(struct sdhc_host *hp, ui uint32_t state; int timeout; - for (timeout = 1; timeout > 0; timeout--) { + for (timeout = 10; timeout > 0; timeout--) { if (((state = HREAD4(hp, SDHC_PRESENT_STATE)) & mask) == value) return 0; sdmmc_delay(10); @@ -1587,7 +1611,7 @@ sdhc_exec_command(sdmmc_chipset_handle_t * is marked done for any other reason. */ probing = (cmd->c_flags & SCF_TOUT_OK) != 0; - if (!sdhc_wait_intr(hp, SDHC_COMMAND_COMPLETE, SDHC_COMMAND_TIMEOUT, probing)) { + if (!sdhc_wait_intr(hp, SDHC_COMMAND_COMPLETE, SDHC_COMMAND_TIMEOUT*3, probing)) { DPRINTF(1,("%s: timeout for command\n", __func__)); sdmmc_delay(50); cmd->c_error = ETIMEDOUT;
CVS commit: src/sys/dev/sdmmc
Module Name:src Committed By: mlelstv Date: Mon Oct 28 06:00:14 UTC 2019 Modified Files: src/sys/dev/sdmmc: sdhc.c Log Message: Skip setting power when the voltage doesn't change. Also increase some timeouts. To generate a diff of this commit: cvs rdiff -u -r1.104 -r1.105 src/sys/dev/sdmmc/sdhc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/sdmmc
Module Name:src Committed By: bad Date: Sun Oct 27 21:39:50 UTC 2019 Modified Files: src/sys/dev/sdmmc: if_bwfm_sdio.c Log Message: white space police. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/dev/sdmmc/if_bwfm_sdio.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sdmmc/if_bwfm_sdio.c diff -u src/sys/dev/sdmmc/if_bwfm_sdio.c:1.6 src/sys/dev/sdmmc/if_bwfm_sdio.c:1.7 --- src/sys/dev/sdmmc/if_bwfm_sdio.c:1.6 Wed Sep 25 16:21:14 2019 +++ src/sys/dev/sdmmc/if_bwfm_sdio.c Sun Oct 27 21:39:50 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: if_bwfm_sdio.c,v 1.6 2019/09/25 16:21:14 mlelstv Exp $ */ +/* $NetBSD: if_bwfm_sdio.c,v 1.7 2019/10/27 21:39:50 bad Exp $ */ /* $OpenBSD: if_bwfm_sdio.c,v 1.1 2017/10/11 17:19:50 patrick Exp $ */ /* * Copyright (c) 2010-2016 Broadcom Corporation @@ -171,9 +171,9 @@ voidbwfm_sdio_rx_frames(stru voidbwfm_sdio_rx_glom(struct bwfm_sdio_softc *, uint16_t *, int, uint16_t *); -#ifdef BWFM_DEBUG +#ifdef BWFM_DEBUG void bwfm_sdio_debug_console(struct bwfm_sdio_softc *); -#endif +#endif struct bwfm_bus_ops bwfm_sdio_bus_ops = { .bs_init = NULL, @@ -203,22 +203,22 @@ static const struct bwfm_sdio_product { } bwfm_sdio_products[] = { { SDMMC_VENDOR_BROADCOM, - SDMMC_PRODUCT_BROADCOM_BCM4330, + SDMMC_PRODUCT_BROADCOM_BCM4330, SDMMC_CIS_BROADCOM_BCM4330 }, { SDMMC_VENDOR_BROADCOM, - SDMMC_PRODUCT_BROADCOM_BCM4334, + SDMMC_PRODUCT_BROADCOM_BCM4334, SDMMC_CIS_BROADCOM_BCM4334 }, { SDMMC_VENDOR_BROADCOM, - SDMMC_PRODUCT_BROADCOM_BCM43143, + SDMMC_PRODUCT_BROADCOM_BCM43143, SDMMC_CIS_BROADCOM_BCM43143 }, { SDMMC_VENDOR_BROADCOM, - SDMMC_PRODUCT_BROADCOM_BCM43430, + SDMMC_PRODUCT_BROADCOM_BCM43430, SDMMC_CIS_BROADCOM_BCM43430 }, }; @@ -296,14 +296,14 @@ bwfm_sdio_attach(device_t parent, device sdmmc_io_set_blocklen(sc->sc_sf[1]->sc, sc->sc_sf[1], 64); sdmmc_io_set_blocklen(sc->sc_sf[2]->sc, sc->sc_sf[2], 512); -/* Enable Function 1. */ -if (sdmmc_io_function_enable(sc->sc_sf[1]) != 0) { -printf("%s: cannot enable function 1\n", DEVNAME(sc)); -return; -} + /* Enable Function 1. */ + if (sdmmc_io_function_enable(sc->sc_sf[1]) != 0) { + printf("%s: cannot enable function 1\n", DEVNAME(sc)); + return; + } -DPRINTF(("%s: F1 signature read @0x1800=%x\n", DEVNAME(sc), -bwfm_sdio_read_4(sc, 0x1800))); + DPRINTF(("%s: F1 signature read @0x1800=%x\n", DEVNAME(sc), + bwfm_sdio_read_4(sc, 0x1800))); /* Force PLL off */ bwfm_sdio_write_1(sc, BWFM_SDIO_FUNC1_CHIPCLKCSR, @@ -486,8 +486,8 @@ bwfm_sdio_attachhook(device_t self) bwfm_sdio_dev_write(sc, SDPCMD_TOSBMAILBOXDATA, SDPCM_PROT_VERSION << SDPCM_PROT_VERSION_SHIFT); if (sdmmc_io_function_enable(sc->sc_sf[2])) { -printf("%s: cannot enable function 2\n", DEVNAME(sc)); -goto err; + printf("%s: cannot enable function 2\n", DEVNAME(sc)); + goto err; } bwfm_sdio_dev_write(sc, SDPCMD_HOSTINTMASK, @@ -1264,7 +1264,7 @@ bwfm_sdio_intr(void *v) { struct bwfm_sdio_softc *sc = (void *)v; -DPRINTF(("%s: sdio_intr\n", DEVNAME(sc))); + DPRINTF(("%s: sdio_intr\n", DEVNAME(sc))); mutex_enter(&sc->sc_intr_lock); if (!sdmmc_task_pending(&sc->sc_task)) @@ -1312,7 +1312,7 @@ bwfm_sdio_task1(struct bwfm_sdio_softc * } intstat = bwfm_sdio_dev_read(sc, BWFM_SDPCMD_INTSTATUS); -DPRINTF(("%s: intstat 0x%" PRIx32 "\n", DEVNAME(sc), intstat)); + DPRINTF(("%s: intstat 0x%" PRIx32 "\n", DEVNAME(sc), intstat)); intstat &= (SDPCMD_INTSTATUS_HMB_SW_MASK|SDPCMD_INTSTATUS_CHIPACTIVE); /* XXX fc state */ if (intstat) @@ -1320,7 +1320,7 @@ bwfm_sdio_task1(struct bwfm_sdio_softc * if (intstat & SDPCMD_INTSTATUS_HMB_HOST_INT) { hostint = bwfm_sdio_dev_read(sc, SDPCMD_TOHOSTMAILBOXDATA); - DPRINTF(("%s: hostint 0x%" PRIx32 "\n", DEVNAME(sc), hostint)); + DPRINTF(("%s: hostint 0x%" PRIx32 "\n", DEVNAME(sc), hostint)); bwfm_sdio_dev_write(sc, SDPCMD_TOSBMAILBOX, SDPCMD_TOSBMAILBOX_INT_ACK); if (hostint & SDPCMD_TOHOSTMAILBOXDATA_NAKHANDLED) @@ -1345,7 +1345,7 @@ bwfm_sdio_tx_ok(struct bwfm_sdio_softc * ((uint8_t)(sc->sc_tx_max_seq - sc->sc_tx_seq) & 0x80) == 0; } -void +void bwfm_sdio_tx_frames(struct bwfm_sdio_softc *sc) { struct mbuf *m; @@ -1365,7 +1365,7 @@ bwfm_sdio_tx_frames(struct bwfm_sdio_sof if (m->m_type == MT_CONTROL) bwfm_sdio_tx_ctrlframe(sc, m); else { - bwfm_sdio_tx_dataframe(sc, m); + bwfm_sdio_tx_dataframe(sc, m); ifp->if_opackets++; ifstart = true; } @@ -1385,7 +1385,7 @@ bwfm_sdio_tx_ctrlframe(struct bwfm_sdio_ struct bwfm_sdio_hwhdr *hwhdr; struct bwfm_sdio_swhdr *swhdr; size_t len, roundto; - + len = sizeof(*hwhdr) + sizeof(*swhdr) + m->m_len; /* Zero-pa
CVS commit: src/sys/dev/sdmmc
Module Name:src Committed By: bad Date: Sun Oct 27 21:39:50 UTC 2019 Modified Files: src/sys/dev/sdmmc: if_bwfm_sdio.c Log Message: white space police. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/dev/sdmmc/if_bwfm_sdio.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/sdmmc
Module Name:src Committed By: mlelstv Date: Thu Oct 3 10:53:34 UTC 2019 Modified Files: src/sys/dev/sdmmc: if_bwfm_sdio.h Log Message: More register definitions. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/dev/sdmmc/if_bwfm_sdio.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/sdmmc
Module Name:src Committed By: mlelstv Date: Thu Oct 3 10:53:34 UTC 2019 Modified Files: src/sys/dev/sdmmc: if_bwfm_sdio.h Log Message: More register definitions. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/dev/sdmmc/if_bwfm_sdio.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sdmmc/if_bwfm_sdio.h diff -u src/sys/dev/sdmmc/if_bwfm_sdio.h:1.1 src/sys/dev/sdmmc/if_bwfm_sdio.h:1.2 --- src/sys/dev/sdmmc/if_bwfm_sdio.h:1.1 Sun Sep 1 05:51:45 2019 +++ src/sys/dev/sdmmc/if_bwfm_sdio.h Thu Oct 3 10:53:34 2019 @@ -41,6 +41,11 @@ #define BWFM_SDIO_FUNC1_SBADDRLOW 0x1000A #define BWFM_SDIO_FUNC1_SBADDRMID 0x1000B #define BWFM_SDIO_FUNC1_SBADDRHIGH 0x1000C +#define BWFM_SDIO_FUNC1_FRAMECTRL 0x1000D +#define BWFM_SDIO_FUNC1_FRAMECTRL_RF_TERM (1 << 0) +#define BWFM_SDIO_FUNC1_FRAMECTRL_WF_TERM (1 << 1) +#define BWFM_SDIO_FUNC1_FRAMECTRL_CRC4WOOS (1 << 2) +#define BWFM_SDIO_FUNC1_FRAMECTRL_ABORTALL (1 << 3) #define BWFM_SDIO_FUNC1_CHIPCLKCSR 0x1000E #define BWFM_SDIO_FUNC1_CHIPCLKCSR_FORCE_ALP 0x01 #define BWFM_SDIO_FUNC1_CHIPCLKCSR_FORCE_HT 0x02 @@ -65,6 +70,11 @@ (BWFM_SDIO_FUNC1_CHIPCLKCSR_ALPAV(regval) && \ (alponly ? 1 : BWFM_SDIO_FUNC1_CHIPCLKCSR_HTAV(regval))) #define BWFM_SDIO_FUNC1_SDIOPULLUP 0x1000F +#define BWFM_SDIO_FUNC1_WFRAMEBCLO 0x10019 +#define BWFM_SDIO_FUNC1_WFRAMEBCHI 0x1001A +#define BWFM_SDIO_FUNC1_RFRAMEBCLO 0x1001B +#define BWFM_SDIO_FUNC1_RFRAMEBCHI 0x1001C +#define BWFM_SDIO_FUNC1_MESBUSYCTRL 0x1001D #define BWFM_SDIO_FUNC1_WAKEUPCTRL 0x1001E #define BWFM_SDIO_FUNC1_WAKEUPCTRL_HTWAIT (1 << 1) #define BWFM_SDIO_FUNC1_SLEEPCSR 0x1001F
CVS commit: src/sys/dev/sdmmc
Module Name:src Committed By: mlelstv Date: Wed Sep 25 16:21:14 UTC 2019 Modified Files: src/sys/dev/sdmmc: if_bwfm_sdio.c Log Message: Use correct function to verify if a task has been queued. Avoids race that can corrupt the task queue. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/dev/sdmmc/if_bwfm_sdio.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sdmmc/if_bwfm_sdio.c diff -u src/sys/dev/sdmmc/if_bwfm_sdio.c:1.5 src/sys/dev/sdmmc/if_bwfm_sdio.c:1.6 --- src/sys/dev/sdmmc/if_bwfm_sdio.c:1.5 Fri Sep 13 11:21:03 2019 +++ src/sys/dev/sdmmc/if_bwfm_sdio.c Wed Sep 25 16:21:14 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: if_bwfm_sdio.c,v 1.5 2019/09/13 11:21:03 mlelstv Exp $ */ +/* $NetBSD: if_bwfm_sdio.c,v 1.6 2019/09/25 16:21:14 mlelstv Exp $ */ /* $OpenBSD: if_bwfm_sdio.c,v 1.1 2017/10/11 17:19:50 patrick Exp $ */ /* * Copyright (c) 2010-2016 Broadcom Corporation @@ -1267,10 +1267,9 @@ bwfm_sdio_intr(void *v) DPRINTF(("%s: sdio_intr\n", DEVNAME(sc))); mutex_enter(&sc->sc_intr_lock); - if (!sc->sc_task_queued) { - sc->sc_task_queued = true; + if (!sdmmc_task_pending(&sc->sc_task)) sdmmc_add_task(sc->sc_sf[1]->sc, &sc->sc_task); - } + sc->sc_task_queued = true; mutex_exit(&sc->sc_intr_lock); return 1; }
CVS commit: src/sys/dev/sdmmc
Module Name:src Committed By: mlelstv Date: Wed Sep 25 16:21:14 UTC 2019 Modified Files: src/sys/dev/sdmmc: if_bwfm_sdio.c Log Message: Use correct function to verify if a task has been queued. Avoids race that can corrupt the task queue. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/dev/sdmmc/if_bwfm_sdio.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/sdmmc
Module Name:src Committed By: mlelstv Date: Tue Sep 24 04:56:54 UTC 2019 Modified Files: src/sys/dev/sdmmc: sdmmc_cis.c Log Message: Remove debug printf. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/dev/sdmmc/sdmmc_cis.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sdmmc/sdmmc_cis.c diff -u src/sys/dev/sdmmc/sdmmc_cis.c:1.6 src/sys/dev/sdmmc/sdmmc_cis.c:1.7 --- src/sys/dev/sdmmc/sdmmc_cis.c:1.6 Sun Sep 1 05:45:42 2019 +++ src/sys/dev/sdmmc/sdmmc_cis.c Tue Sep 24 04:56:54 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sdmmc_cis.c,v 1.6 2019/09/01 05:45:42 mlelstv Exp $ */ +/* $NetBSD: sdmmc_cis.c,v 1.7 2019/09/24 04:56:54 mlelstv Exp $ */ /* $OpenBSD: sdmmc_cis.c,v 1.1 2006/06/01 21:53:41 uwe Exp $ */ /* @@ -20,7 +20,7 @@ /* Routines to decode the Card Information Structure of SD I/O cards */ #include -__KERNEL_RCSID(0, "$NetBSD: sdmmc_cis.c,v 1.6 2019/09/01 05:45:42 mlelstv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sdmmc_cis.c,v 1.7 2019/09/24 04:56:54 mlelstv Exp $"); #ifdef _KERNEL_OPT #include "opt_sdmmc.h" @@ -130,7 +130,6 @@ decode_funce_function(struct sdmmc_funct max_blk_size = sdmmc_io_read_1(sf0, reg + 11); max_blk_size |= sdmmc_io_read_1(sf0, reg + 12) << 8; -device_printf(dev, "MAX_BLK_SIZE%d = %d\n", sf->number, max_blk_size); DPRINTF(("CISTPL_FUNCE: MAX_BLK_SIZE=0x%x\n", max_blk_size)); }
CVS commit: src/sys/dev/sdmmc
Module Name:src Committed By: mlelstv Date: Tue Sep 24 04:56:54 UTC 2019 Modified Files: src/sys/dev/sdmmc: sdmmc_cis.c Log Message: Remove debug printf. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/dev/sdmmc/sdmmc_cis.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/sdmmc
Module Name:src Committed By: mlelstv Date: Fri Sep 13 11:21:03 UTC 2019 Modified Files: src/sys/dev/sdmmc: if_bwfm_sdio.c Log Message: Don't pass empty mbufs to the network stack. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/dev/sdmmc/if_bwfm_sdio.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/sdmmc
Module Name:src Committed By: mlelstv Date: Fri Sep 13 11:21:03 UTC 2019 Modified Files: src/sys/dev/sdmmc: if_bwfm_sdio.c Log Message: Don't pass empty mbufs to the network stack. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/dev/sdmmc/if_bwfm_sdio.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sdmmc/if_bwfm_sdio.c diff -u src/sys/dev/sdmmc/if_bwfm_sdio.c:1.4 src/sys/dev/sdmmc/if_bwfm_sdio.c:1.5 --- src/sys/dev/sdmmc/if_bwfm_sdio.c:1.4 Sun Sep 1 05:51:45 2019 +++ src/sys/dev/sdmmc/if_bwfm_sdio.c Fri Sep 13 11:21:03 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: if_bwfm_sdio.c,v 1.4 2019/09/01 05:51:45 mlelstv Exp $ */ +/* $NetBSD: if_bwfm_sdio.c,v 1.5 2019/09/13 11:21:03 mlelstv Exp $ */ /* $OpenBSD: if_bwfm_sdio.c,v 1.1 2017/10/11 17:19:50 patrick Exp $ */ /* * Copyright (c) 2010-2016 Broadcom Corporation @@ -1614,6 +1614,11 @@ bwfm_sdio_rx_frames(struct bwfm_sdio_sof break; } m_adj(m, hoff); + /* don't pass empty packet to stack */ + if (m->m_len == 0) { +m_freem(m); +break; + } bwfm_rx(&sc->sc_sc, m); nextlen = swhdr->nextlen << 4; break; @@ -1752,6 +1757,11 @@ bwfm_sdio_rx_glom(struct bwfm_sdio_softc break; } m_adj(m, hoff); + /* don't pass empty packet to stack */ + if (m->m_len == 0) { +m_freem(m); +break; + } bwfm_rx(&sc->sc_sc, m); break; case BWFM_SDIO_SWHDR_CHANNEL_GLOM:
CVS commit: src/sys/dev/sdmmc
Module Name:src Committed By: jmcneill Date: Mon Sep 2 11:09:42 UTC 2019 Modified Files: src/sys/dev/sdmmc: sdmmc_io.c Log Message: SD_IO_RW_EXTENDED is a data transfer command, so set ADTC flag instead of AC To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/sys/dev/sdmmc/sdmmc_io.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sdmmc/sdmmc_io.c diff -u src/sys/dev/sdmmc/sdmmc_io.c:1.15 src/sys/dev/sdmmc/sdmmc_io.c:1.16 --- src/sys/dev/sdmmc/sdmmc_io.c:1.15 Sun Sep 1 05:45:42 2019 +++ src/sys/dev/sdmmc/sdmmc_io.c Mon Sep 2 11:09:42 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sdmmc_io.c,v 1.15 2019/09/01 05:45:42 mlelstv Exp $ */ +/* $NetBSD: sdmmc_io.c,v 1.16 2019/09/02 11:09:42 jmcneill Exp $ */ /* $OpenBSD: sdmmc_io.c,v 1.10 2007/09/17 01:33:33 krw Exp $ */ /* @@ -20,7 +20,7 @@ /* Routines for SD I/O cards. */ #include -__KERNEL_RCSID(0, "$NetBSD: sdmmc_io.c,v 1.15 2019/09/01 05:45:42 mlelstv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sdmmc_io.c,v 1.16 2019/09/02 11:09:42 jmcneill Exp $"); #ifdef _KERNEL_OPT #include "opt_sdmmc.h" @@ -394,7 +394,7 @@ sdmmc_io_rw_extended(struct sdmmc_softc memset(&cmd, 0, sizeof cmd); cmd.c_opcode = SD_IO_RW_EXTENDED; cmd.c_arg = arg; - cmd.c_flags = SCF_CMD_AC | SCF_RSP_R5; + cmd.c_flags = SCF_CMD_ADTC | SCF_RSP_R5; cmd.c_data = datap; cmd.c_datalen = datalen; cmd.c_blklen = MIN(datalen, sf->blklen);
CVS commit: src/sys/dev/sdmmc
Module Name:src Committed By: jmcneill Date: Mon Sep 2 11:09:42 UTC 2019 Modified Files: src/sys/dev/sdmmc: sdmmc_io.c Log Message: SD_IO_RW_EXTENDED is a data transfer command, so set ADTC flag instead of AC To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/sys/dev/sdmmc/sdmmc_io.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/sdmmc
Module Name:src Committed By: mlelstv Date: Sun Sep 1 05:51:45 UTC 2019 Modified Files: src/sys/dev/sdmmc: if_bwfm_sdio.c Added Files: src/sys/dev/sdmmc: if_bwfm_sdio.h Log Message: >From OpenBSD: - All the missing pieces (firmware load, chip setup, protocol handling) TX queue and interrupt handling via sdmmc_task. Fix locking. Fix packet parsing. Add parser for original firmware config files. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/dev/sdmmc/if_bwfm_sdio.c cvs rdiff -u -r0 -r1.1 src/sys/dev/sdmmc/if_bwfm_sdio.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/sdmmc
Module Name:src Committed By: mlelstv Date: Sun Sep 1 05:51:45 UTC 2019 Modified Files: src/sys/dev/sdmmc: if_bwfm_sdio.c Added Files: src/sys/dev/sdmmc: if_bwfm_sdio.h Log Message: >From OpenBSD: - All the missing pieces (firmware load, chip setup, protocol handling) TX queue and interrupt handling via sdmmc_task. Fix locking. Fix packet parsing. Add parser for original firmware config files. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/dev/sdmmc/if_bwfm_sdio.c cvs rdiff -u -r0 -r1.1 src/sys/dev/sdmmc/if_bwfm_sdio.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sdmmc/if_bwfm_sdio.c diff -u src/sys/dev/sdmmc/if_bwfm_sdio.c:1.3 src/sys/dev/sdmmc/if_bwfm_sdio.c:1.4 --- src/sys/dev/sdmmc/if_bwfm_sdio.c:1.3 Fri May 11 07:41:11 2018 +++ src/sys/dev/sdmmc/if_bwfm_sdio.c Sun Sep 1 05:51:45 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: if_bwfm_sdio.c,v 1.3 2018/05/11 07:41:11 maya Exp $ */ +/* $NetBSD: if_bwfm_sdio.c,v 1.4 2019/09/01 05:51:45 mlelstv Exp $ */ /* $OpenBSD: if_bwfm_sdio.c,v 1.1 2017/10/11 17:19:50 patrick Exp $ */ /* * Copyright (c) 2010-2016 Broadcom Corporation @@ -20,14 +20,13 @@ #include #include #include +#include #include #include #include #include #include #include -#include -#include #include #include @@ -37,20 +36,16 @@ #include +#include + #include +#include #include #include #include - -#define BWFM_SDIO_CCCR_BRCM_CARDCAP 0xf0 -#define BWFM_SDIO_CCCR_BRCM_CARDCAP_CMD14_SUPPORT 0x02 -#define BWFM_SDIO_CCCR_BRCM_CARDCAP_CMD14_EXT 0x04 -#define BWFM_SDIO_CCCR_BRCM_CARDCAP_CMD_NODEC 0x08 -#define BWFM_SDIO_CCCR_BRCM_CARDCTRL 0xf1 -#define BWFM_SDIO_CCCR_BRCM_CARDCTRL_WLANRESET 0x02 -#define BWFM_SDIO_CCCR_BRCM_SEPINT 0xf2 +#include #ifdef BWFM_DEBUG #define DPRINTF(x) do { if (bwfm_debug > 0) printf x; } while (0) @@ -63,34 +58,122 @@ static int bwfm_debug = 2; #define DEVNAME(sc) device_xname((sc)->sc_sc.sc_dev) +enum bwfm_sdio_clkstate { + CLK_NONE, + CLK_SDONLY, + CLK_PENDING, + CLK_AVAIL +}; + struct bwfm_sdio_softc { - struct bwfm_softc sc_sc; + struct bwfm_softc sc_sc; + kmutex_t sc_lock; + kmutex_t sc_intr_lock; + + bool sc_bwfm_attached; + struct sdmmc_function **sc_sf; - uint32_t sc_bar0; + size_t sc_sf_size; + + uint32_t sc_bar0; + enum bwfm_sdio_clkstate sc_clkstate; + bool sc_sr_enabled; + bool sc_alp_only; + bool sc_sleeping; + + struct sdmmc_task sc_task; + bool sc_task_queued; + + uint8_t sc_tx_seq; + uint8_t sc_tx_max_seq; + int sc_tx_count; + MBUFQ_HEAD() sc_tx_queue; + + struct mbuf *sc_rxctl_queue; + kcondvar_t sc_rxctl_cv; + + void *sc_ih; + struct bwfm_core *sc_cc; + + char *sc_bounce_buf; + size_t sc_bounce_size; + + uint32_t sc_console_addr; + char *sc_console_buf; + size_t sc_console_buf_size; + uint32_t sc_console_readidx; }; -int bwfm_sdio_match(device_t, cfdata_t, void *); -void bwfm_sdio_attach(device_t, struct device *, void *); -int bwfm_sdio_detach(device_t, int); - -void bwfm_sdio_backplane(struct bwfm_sdio_softc *, uint32_t); -uint8_t bwfm_sdio_read_1(struct bwfm_sdio_softc *, uint32_t); -uint32_t bwfm_sdio_read_4(struct bwfm_sdio_softc *, uint32_t); -void bwfm_sdio_write_1(struct bwfm_sdio_softc *, uint32_t, +int bwfm_sdio_match(device_t, cfdata_t, void *); +void bwfm_sdio_attach(device_t, struct device *, void *); +int bwfm_sdio_detach(device_t, int); +void bwfm_sdio_attachhook(device_t); + +void bwfm_sdio_backplane(struct bwfm_sdio_softc *, uint32_t); +uint8_t bwfm_sdio_read_1(struct bwfm_sdio_softc *, uint32_t); +uint32_t bwfm_sdio_read_4(struct bwfm_sdio_softc *, uint32_t); +void bwfm_sdio_write_1(struct bwfm_sdio_softc *, uint32_t, uint8_t); -void bwfm_sdio_write_4(struct bwfm_sdio_softc *, uint32_t, +void bwfm_sdio_write_4(struct bwfm_sdio_softc *, uint32_t, + uint32_t); + +uint32_t bwfm_sdio_dev_read(struct bwfm_sdio_softc *, uint32_t); +void bwfm_sdio_dev_write(struct bwfm_sdio_softc *, uint32_t, uint32_t); -uint32_t bwfm_sdio_buscore_read(struct bwfm_softc *, uint32_t); -void bwfm_sdio_buscore_write(struct bwfm_softc *, uint32_t, +uint32_t bwfm_sdio_buscore_read(struct bwfm_softc *, uint32_t); +void bwfm_sdio_buscore_write(struct bwfm_softc *, uint32_t, uint32_t); -int bwfm_sdio_buscore_prepare(struct bwfm_softc *); -void bwfm_sdio_buscore_activate(struct bwfm_softc *, uint32_t); +int bwfm_sdio_buscore_prepare(struct bwfm_softc *); +void bwfm_sdio_buscore_activate(struct bwfm_softc *, uint32_t); -int bwfm_sdio_txcheck(struct bwfm_softc *); -int bwfm_sdio_txdata(struct bwfm_softc *, struct mbuf *); -int bwfm_sdio_txctl(struct bwfm_softc *, char *, size_t); -int bwfm_sdio_rxctl(struct bwfm_softc *, char *, size_t *); +int bwfm_sdio_buf_read(struct bwfm_sdio_softc *, + struct sdmmc_function *, uint32_t, c
CVS commit: src/sys/dev/sdmmc
Module Name:src Committed By: mlelstv Date: Sun Sep 1 05:45:42 UTC 2019 Modified Files: src/sys/dev/sdmmc: sdmmc.c sdmmc_cis.c sdmmc_io.c sdmmc_ioreg.h sdmmcvar.h Log Message: >From OpenBSD: - support block length per function - add functions to read/write regions Decode (but not use) SDIO tuple in CIS. Fix locking. Add more SDIO defines (partially from version 3.0). To generate a diff of this commit: cvs rdiff -u -r1.36 -r1.37 src/sys/dev/sdmmc/sdmmc.c cvs rdiff -u -r1.5 -r1.6 src/sys/dev/sdmmc/sdmmc_cis.c cvs rdiff -u -r1.14 -r1.15 src/sys/dev/sdmmc/sdmmc_io.c cvs rdiff -u -r1.3 -r1.4 src/sys/dev/sdmmc/sdmmc_ioreg.h cvs rdiff -u -r1.30 -r1.31 src/sys/dev/sdmmc/sdmmcvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/sdmmc
Module Name:src Committed By: mlelstv Date: Sun Sep 1 05:45:42 UTC 2019 Modified Files: src/sys/dev/sdmmc: sdmmc.c sdmmc_cis.c sdmmc_io.c sdmmc_ioreg.h sdmmcvar.h Log Message: >From OpenBSD: - support block length per function - add functions to read/write regions Decode (but not use) SDIO tuple in CIS. Fix locking. Add more SDIO defines (partially from version 3.0). To generate a diff of this commit: cvs rdiff -u -r1.36 -r1.37 src/sys/dev/sdmmc/sdmmc.c cvs rdiff -u -r1.5 -r1.6 src/sys/dev/sdmmc/sdmmc_cis.c cvs rdiff -u -r1.14 -r1.15 src/sys/dev/sdmmc/sdmmc_io.c cvs rdiff -u -r1.3 -r1.4 src/sys/dev/sdmmc/sdmmc_ioreg.h cvs rdiff -u -r1.30 -r1.31 src/sys/dev/sdmmc/sdmmcvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sdmmc/sdmmc.c diff -u src/sys/dev/sdmmc/sdmmc.c:1.36 src/sys/dev/sdmmc/sdmmc.c:1.37 --- src/sys/dev/sdmmc/sdmmc.c:1.36 Tue Nov 6 16:01:38 2018 +++ src/sys/dev/sdmmc/sdmmc.c Sun Sep 1 05:45:42 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sdmmc.c,v 1.36 2018/11/06 16:01:38 jmcneill Exp $ */ +/* $NetBSD: sdmmc.c,v 1.37 2019/09/01 05:45:42 mlelstv Exp $ */ /* $OpenBSD: sdmmc.c,v 1.18 2009/01/09 10:58:38 jsg Exp $ */ /* @@ -49,7 +49,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sdmmc.c,v 1.36 2018/11/06 16:01:38 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sdmmc.c,v 1.37 2019/09/01 05:45:42 mlelstv Exp $"); #ifdef _KERNEL_OPT #include "opt_sdmmc.h" @@ -656,6 +656,7 @@ sdmmc_function_alloc(struct sdmmc_softc sf->cis.product = SDMMC_PRODUCT_INVALID; sf->cis.function = SDMMC_FUNCTION_INVALID; sf->width = 1; + sf->blklen = sdmmc_chip_host_maxblklen(sc->sc_sct, sc->sc_sch); if (ISSET(sc->sc_flags, SMF_MEM_MODE) && ISSET(sc->sc_caps, SMC_CAPS_DMA) && Index: src/sys/dev/sdmmc/sdmmc_cis.c diff -u src/sys/dev/sdmmc/sdmmc_cis.c:1.5 src/sys/dev/sdmmc/sdmmc_cis.c:1.6 --- src/sys/dev/sdmmc/sdmmc_cis.c:1.5 Sun Jan 28 14:34:06 2018 +++ src/sys/dev/sdmmc/sdmmc_cis.c Sun Sep 1 05:45:42 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sdmmc_cis.c,v 1.5 2018/01/28 14:34:06 jmcneill Exp $ */ +/* $NetBSD: sdmmc_cis.c,v 1.6 2019/09/01 05:45:42 mlelstv Exp $ */ /* $OpenBSD: sdmmc_cis.c,v 1.1 2006/06/01 21:53:41 uwe Exp $ */ /* @@ -20,7 +20,7 @@ /* Routines to decode the Card Information Structure of SD I/O cards */ #include -__KERNEL_RCSID(0, "$NetBSD: sdmmc_cis.c,v 1.5 2018/01/28 14:34:06 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sdmmc_cis.c,v 1.6 2019/09/01 05:45:42 mlelstv Exp $"); #ifdef _KERNEL_OPT #include "opt_sdmmc.h" @@ -130,6 +130,7 @@ decode_funce_function(struct sdmmc_funct max_blk_size = sdmmc_io_read_1(sf0, reg + 11); max_blk_size |= sdmmc_io_read_1(sf0, reg + 12) << 8; +device_printf(dev, "MAX_BLK_SIZE%d = %d\n", sf->number, max_blk_size); DPRINTF(("CISTPL_FUNCE: MAX_BLK_SIZE=0x%x\n", max_blk_size)); } @@ -259,6 +260,11 @@ sdmmc_read_cis(struct sdmmc_function *sf reg += tpllen; break; + case PCMCIA_CISTPL_SDIO: + aprint_normal_dev(dev, "SDIO function\n"); + reg += tpllen; + break; + default: /* * Tuple codes between 80h-8Fh are vendor unique. Index: src/sys/dev/sdmmc/sdmmc_io.c diff -u src/sys/dev/sdmmc/sdmmc_io.c:1.14 src/sys/dev/sdmmc/sdmmc_io.c:1.15 --- src/sys/dev/sdmmc/sdmmc_io.c:1.14 Sun Oct 14 17:37:40 2018 +++ src/sys/dev/sdmmc/sdmmc_io.c Sun Sep 1 05:45:42 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sdmmc_io.c,v 1.14 2018/10/14 17:37:40 jdolecek Exp $ */ +/* $NetBSD: sdmmc_io.c,v 1.15 2019/09/01 05:45:42 mlelstv Exp $ */ /* $OpenBSD: sdmmc_io.c,v 1.10 2007/09/17 01:33:33 krw Exp $ */ /* @@ -20,7 +20,7 @@ /* Routines for SD I/O cards. */ #include -__KERNEL_RCSID(0, "$NetBSD: sdmmc_io.c,v 1.14 2018/10/14 17:37:40 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sdmmc_io.c,v 1.15 2019/09/01 05:45:42 mlelstv Exp $"); #ifdef _KERNEL_OPT #include "opt_sdmmc.h" @@ -194,6 +194,8 @@ sdmmc_io_init(struct sdmmc_softc *sc, st SDMMC_LOCK(sc); + sf->blklen = sdmmc_chip_host_maxblklen(sc->sc_sct, sc->sc_sch); + if (sf->number == 0) { reg = sdmmc_io_read_1(sf, SD_IO_CCCR_CAPABILITY); if (!(reg & CCCR_CAPS_LSC) || (reg & CCCR_CAPS_4BLS)) { @@ -395,8 +397,8 @@ sdmmc_io_rw_extended(struct sdmmc_softc cmd.c_flags = SCF_CMD_AC | SCF_RSP_R5; cmd.c_data = datap; cmd.c_datalen = datalen; - cmd.c_blklen = MIN(datalen, - sdmmc_chip_host_maxblklen(sc->sc_sct,sc->sc_sch)); + cmd.c_blklen = MIN(datalen, sf->blklen); + if (!ISSET(arg, SD_ARG_CMD53_WRITE)) cmd.c_flags |= SCF_CMD_READ; @@ -476,21 +478,26 @@ int sdmmc_io_read_multi_1(struct sdmmc_function *sf, int reg, u_char *data, int datalen) { - int error; + int blocks, bytes, error = 0; /* Don't lock */ - while (datalen > SD_ARG_CMD53_LENGTH_MAX) { + while (datalen >= sf->blklen) { + //blocks = imin(datalen / sf->blklen, + // SD_ARG_CMD53_LENGTH_MAX); + blocks = 1; + bytes = blocks * sf->blklen; er
CVS commit: src/sys/dev/sdmmc
Module Name:src Committed By: mlelstv Date: Sat Aug 24 11:24:17 UTC 2019 Modified Files: src/sys/dev/sdmmc: sdmmcdevs.h Log Message: regen To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/dev/sdmmc/sdmmcdevs.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/sdmmc
Module Name:src Committed By: mlelstv Date: Sat Aug 24 11:24:17 UTC 2019 Modified Files: src/sys/dev/sdmmc: sdmmcdevs.h Log Message: regen To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/dev/sdmmc/sdmmcdevs.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sdmmc/sdmmcdevs.h diff -u src/sys/dev/sdmmc/sdmmcdevs.h:1.5 src/sys/dev/sdmmc/sdmmcdevs.h:1.6 --- src/sys/dev/sdmmc/sdmmcdevs.h:1.5 Sun Aug 18 14:32:34 2019 +++ src/sys/dev/sdmmc/sdmmcdevs.h Sat Aug 24 11:24:17 2019 @@ -1,10 +1,10 @@ -/* $NetBSD: sdmmcdevs.h,v 1.5 2019/08/18 14:32:34 mlelstv Exp $ */ +/* $NetBSD: sdmmcdevs.h,v 1.6 2019/08/24 11:24:17 mlelstv Exp $ */ /* * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT. * * generated from: - * NetBSD: sdmmcdevs,v 1.5 2019/08/18 14:32:04 mlelstv Exp + * NetBSD: sdmmcdevs,v 1.6 2019/08/24 11:24:00 mlelstv Exp */ /* $OpenBSD: sdmmcdevs,v 1.8 2007/05/11 17:16:16 mglocker Exp $ */ @@ -31,8 +31,8 @@ #define SDMMC_VENDOR_TOSHIBA 0x0098 /* Toshiba */ #define SDMMC_VENDOR_SOCKETCOM 0x0104 /* Socket Communications, Inc. */ #define SDMMC_VENDOR_REALTEK 0x024c /* Realtek */ -#define SDMMC_VENDOR_BROADCOM 0x0270 /* Broadcom */ #define SDMMC_VENDOR_ATHEROS 0x0271 /* Atheros */ +#define SDMMC_VENDOR_BROADCOM 0x02d0 /* Broadcom */ #define SDMMC_VENDOR_SYCHIP 0x02db /* SyChip Inc. */ #define SDMMC_VENDOR_SPECTEC 0x02fe /* Spectec Computer Co., Ltd */ #define SDMMC_VENDOR_MEDIATEK 0x037a /* MediaTek Inc. */
CVS commit: src/sys/dev/sdmmc
Module Name:src Committed By: mlelstv Date: Sat Aug 24 11:24:00 UTC 2019 Modified Files: src/sys/dev/sdmmc: sdmmcdevs Log Message: Fix typo To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/dev/sdmmc/sdmmcdevs Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sdmmc/sdmmcdevs diff -u src/sys/dev/sdmmc/sdmmcdevs:1.5 src/sys/dev/sdmmc/sdmmcdevs:1.6 --- src/sys/dev/sdmmc/sdmmcdevs:1.5 Sun Aug 18 14:32:04 2019 +++ src/sys/dev/sdmmc/sdmmcdevs Sat Aug 24 11:24:00 2019 @@ -1,4 +1,4 @@ - $NetBSD: sdmmcdevs,v 1.5 2019/08/18 14:32:04 mlelstv Exp $ + $NetBSD: sdmmcdevs,v 1.6 2019/08/24 11:24:00 mlelstv Exp $ /* $OpenBSD: sdmmcdevs,v 1.8 2007/05/11 17:16:16 mglocker Exp $ */ /* @@ -24,8 +24,8 @@ vendor CGUYS 0x0092 C-guys, Inc. vendor TOSHIBA 0x0098 Toshiba vendor SOCKETCOM 0x0104 Socket Communications, Inc. vendor REALTEK 0x024c Realtek -vendor BROADCOM 0x0270 Broadcom vendor ATHEROS 0x0271 Atheros +vendor BROADCOM 0x02d0 Broadcom vendor SYCHIP 0x02db SyChip Inc. vendor SPECTEC 0x02fe Spectec Computer Co., Ltd vendor MEDIATEK 0x037a MediaTek Inc.
CVS commit: src/sys/dev/sdmmc
Module Name:src Committed By: mlelstv Date: Sat Aug 24 11:24:00 UTC 2019 Modified Files: src/sys/dev/sdmmc: sdmmcdevs Log Message: Fix typo To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/dev/sdmmc/sdmmcdevs Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/sdmmc
Module Name:src Committed By: mlelstv Date: Sun Aug 18 14:32:34 UTC 2019 Modified Files: src/sys/dev/sdmmc: sdmmcdevs.h Log Message: regen To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/dev/sdmmc/sdmmcdevs.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/sdmmc
Module Name:src Committed By: mlelstv Date: Sun Aug 18 14:32:05 UTC 2019 Modified Files: src/sys/dev/sdmmc: sdmmcdevs Log Message: Add Broadcom devices To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/dev/sdmmc/sdmmcdevs Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sdmmc/sdmmcdevs diff -u src/sys/dev/sdmmc/sdmmcdevs:1.4 src/sys/dev/sdmmc/sdmmcdevs:1.5 --- src/sys/dev/sdmmc/sdmmcdevs:1.4 Sat Dec 29 04:58:52 2018 +++ src/sys/dev/sdmmc/sdmmcdevs Sun Aug 18 14:32:04 2019 @@ -1,4 +1,4 @@ - $NetBSD: sdmmcdevs,v 1.4 2018/12/29 04:58:52 thorpej Exp $ + $NetBSD: sdmmcdevs,v 1.5 2019/08/18 14:32:04 mlelstv Exp $ /* $OpenBSD: sdmmcdevs,v 1.8 2007/05/11 17:16:16 mglocker Exp $ */ /* @@ -24,6 +24,7 @@ vendor CGUYS 0x0092 C-guys, Inc. vendor TOSHIBA 0x0098 Toshiba vendor SOCKETCOM 0x0104 Socket Communications, Inc. vendor REALTEK 0x024c Realtek +vendor BROADCOM 0x0270 Broadcom vendor ATHEROS 0x0271 Atheros vendor SYCHIP 0x02db SyChip Inc. vendor SPECTEC 0x02fe Spectec Computer Co., Ltd @@ -45,6 +46,20 @@ product ATHEROS AR6001_9 0x0109 AR6001 product ATHEROS AR6001_a 0x010a AR6001 product ATHEROS AR6001_b 0x010b AR6001 +/* Broadcom */ +product BROADCOM BCM4324 0x4324 BCM 4324 +product BROADCOM BCM4329 0x4329 BCM 4329 +product BROADCOM BCM4330 0x4330 BCM 4330 +product BROADCOM BCM4334 0x4334 BCM 4334 +product BROADCOM BCM4339 0x4339 BCM 4339 +product BROADCOM BCM4345 0x4345 BCM 4345 +product BROADCOM BCM4354 0x4354 BCM 4354 +product BROADCOM BCM43143 0xa887 BCM 43143 +product BROADCOM BCM43340 0xa94c BCM 43140 +product BROADCOM BCM43341 0xa94d BCM 43141 +product BROADCOM BCM43362 0xa962 BCM 43362 +product BROADCOM BCM43430 0xa9a6 BCM 43430 + /* C-guys, Inc. */ product CGUYS TIACX100 0x0001 TI ACX100 SD-Link11b WiFi Card product CGUYS SDFMRADIO2 0x0005 C-guys SD FM Radio 2
CVS commit: src/sys/dev/sdmmc
Module Name:src Committed By: mlelstv Date: Sun Aug 18 14:32:05 UTC 2019 Modified Files: src/sys/dev/sdmmc: sdmmcdevs Log Message: Add Broadcom devices To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/dev/sdmmc/sdmmcdevs Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/sdmmc
Module Name:src Committed By: mlelstv Date: Sun Aug 18 14:32:34 UTC 2019 Modified Files: src/sys/dev/sdmmc: sdmmcdevs.h Log Message: regen To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/dev/sdmmc/sdmmcdevs.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sdmmc/sdmmcdevs.h diff -u src/sys/dev/sdmmc/sdmmcdevs.h:1.4 src/sys/dev/sdmmc/sdmmcdevs.h:1.5 --- src/sys/dev/sdmmc/sdmmcdevs.h:1.4 Sat Dec 29 04:59:33 2018 +++ src/sys/dev/sdmmc/sdmmcdevs.h Sun Aug 18 14:32:34 2019 @@ -1,10 +1,10 @@ -/* $NetBSD: sdmmcdevs.h,v 1.4 2018/12/29 04:59:33 thorpej Exp $ */ +/* $NetBSD: sdmmcdevs.h,v 1.5 2019/08/18 14:32:34 mlelstv Exp $ */ /* * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT. * * generated from: - * NetBSD: sdmmcdevs,v 1.4 2018/12/29 04:58:52 thorpej Exp + * NetBSD: sdmmcdevs,v 1.5 2019/08/18 14:32:04 mlelstv Exp */ /* $OpenBSD: sdmmcdevs,v 1.8 2007/05/11 17:16:16 mglocker Exp $ */ @@ -31,6 +31,7 @@ #define SDMMC_VENDOR_TOSHIBA 0x0098 /* Toshiba */ #define SDMMC_VENDOR_SOCKETCOM 0x0104 /* Socket Communications, Inc. */ #define SDMMC_VENDOR_REALTEK 0x024c /* Realtek */ +#define SDMMC_VENDOR_BROADCOM 0x0270 /* Broadcom */ #define SDMMC_VENDOR_ATHEROS 0x0271 /* Atheros */ #define SDMMC_VENDOR_SYCHIP 0x02db /* SyChip Inc. */ #define SDMMC_VENDOR_SPECTEC 0x02fe /* Spectec Computer Co., Ltd */ @@ -57,6 +58,32 @@ #define SDMMC_CIS_ATHEROS_AR6001_b { NULL, NULL, NULL, NULL } #define SDMMC_PRODUCT_ATHEROS_AR6001_b 0x010b +/* Broadcom */ +#define SDMMC_CIS_BROADCOM_BCM4324 { NULL, NULL, NULL, NULL } +#define SDMMC_PRODUCT_BROADCOM_BCM4324 0x4324 +#define SDMMC_CIS_BROADCOM_BCM4329 { NULL, NULL, NULL, NULL } +#define SDMMC_PRODUCT_BROADCOM_BCM4329 0x4329 +#define SDMMC_CIS_BROADCOM_BCM4330 { NULL, NULL, NULL, NULL } +#define SDMMC_PRODUCT_BROADCOM_BCM4330 0x4330 +#define SDMMC_CIS_BROADCOM_BCM4334 { NULL, NULL, NULL, NULL } +#define SDMMC_PRODUCT_BROADCOM_BCM4334 0x4334 +#define SDMMC_CIS_BROADCOM_BCM4339 { NULL, NULL, NULL, NULL } +#define SDMMC_PRODUCT_BROADCOM_BCM4339 0x4339 +#define SDMMC_CIS_BROADCOM_BCM4345 { NULL, NULL, NULL, NULL } +#define SDMMC_PRODUCT_BROADCOM_BCM4345 0x4345 +#define SDMMC_CIS_BROADCOM_BCM4354 { NULL, NULL, NULL, NULL } +#define SDMMC_PRODUCT_BROADCOM_BCM4354 0x4354 +#define SDMMC_CIS_BROADCOM_BCM43143 { NULL, NULL, NULL, NULL } +#define SDMMC_PRODUCT_BROADCOM_BCM43143 0xa887 +#define SDMMC_CIS_BROADCOM_BCM43340 { NULL, NULL, NULL, NULL } +#define SDMMC_PRODUCT_BROADCOM_BCM43340 0xa94c +#define SDMMC_CIS_BROADCOM_BCM43341 { NULL, NULL, NULL, NULL } +#define SDMMC_PRODUCT_BROADCOM_BCM43341 0xa94d +#define SDMMC_CIS_BROADCOM_BCM43362 { NULL, NULL, NULL, NULL } +#define SDMMC_PRODUCT_BROADCOM_BCM43362 0xa962 +#define SDMMC_CIS_BROADCOM_BCM43430 { NULL, NULL, NULL, NULL } +#define SDMMC_PRODUCT_BROADCOM_BCM43430 0xa9a6 + /* C-guys, Inc. */ #define SDMMC_CIS_CGUYS_TIACX100 { NULL, NULL, NULL, NULL } #define SDMMC_PRODUCT_CGUYS_TIACX100 0x0001
Re: CVS commit: src/sys/dev/sdmmc
On 24/07/2019 06:45, SAITOH Masanobu wrote: [snip] @@ -27,7 +27,7 @@ /* CMD52 arguments */ #define SD_ARG_CMD52_READ (0<<31) -#define SD_ARG_CMD52_WRITE (1<<31) +#define SD_ARG_CMD52_WRITE (1UL<<31) #define SD_ARG_CMD52_FUNC_SHIFT 28 #define SD_ARG_CMD52_FUNC_MASK0x7 #define SD_ARG_CMD52_EXCHANGE (1<<27) mmm __BIT(3)
CVS commit: src/sys/dev/sdmmc
Module Name:src Committed By: msaitoh Date: Wed Jul 24 05:45:42 UTC 2019 Modified Files: src/sys/dev/sdmmc: sdmmc_ioreg.h Log Message: Define SD_ARG_CMD52_WRITE macro correctly. Found by KUBSan. This macro is used in sdmmc_io_write_1() and sdmmc_io_reset. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/dev/sdmmc/sdmmc_ioreg.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sdmmc/sdmmc_ioreg.h diff -u src/sys/dev/sdmmc/sdmmc_ioreg.h:1.2 src/sys/dev/sdmmc/sdmmc_ioreg.h:1.3 --- src/sys/dev/sdmmc/sdmmc_ioreg.h:1.2 Thu Oct 7 12:40:34 2010 +++ src/sys/dev/sdmmc/sdmmc_ioreg.h Wed Jul 24 05:45:42 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sdmmc_ioreg.h,v 1.2 2010/10/07 12:40:34 kiyohara Exp $ */ +/* $NetBSD: sdmmc_ioreg.h,v 1.3 2019/07/24 05:45:42 msaitoh Exp $ */ /* $OpenBSD: sdmmc_ioreg.h,v 1.4 2007/06/02 01:48:37 uwe Exp $ */ /* @@ -27,7 +27,7 @@ /* CMD52 arguments */ #define SD_ARG_CMD52_READ (0<<31) -#define SD_ARG_CMD52_WRITE (1<<31) +#define SD_ARG_CMD52_WRITE (1UL<<31) #define SD_ARG_CMD52_FUNC_SHIFT 28 #define SD_ARG_CMD52_FUNC_MASK 0x7 #define SD_ARG_CMD52_EXCHANGE (1<<27)
CVS commit: src/sys/dev/sdmmc
Module Name:src Committed By: msaitoh Date: Wed Jul 24 05:45:42 UTC 2019 Modified Files: src/sys/dev/sdmmc: sdmmc_ioreg.h Log Message: Define SD_ARG_CMD52_WRITE macro correctly. Found by KUBSan. This macro is used in sdmmc_io_write_1() and sdmmc_io_reset. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/dev/sdmmc/sdmmc_ioreg.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/sdmmc
Module Name:src Committed By: jmcneill Date: Wed Jul 3 23:10:08 UTC 2019 Modified Files: src/sys/dev/sdmmc: sdhc.c Log Message: If switching to fixed sampling clock, do not return an error to the sdmmc layer. To generate a diff of this commit: cvs rdiff -u -r1.102 -r1.103 src/sys/dev/sdmmc/sdhc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sdmmc/sdhc.c diff -u src/sys/dev/sdmmc/sdhc.c:1.102 src/sys/dev/sdmmc/sdhc.c:1.103 --- src/sys/dev/sdmmc/sdhc.c:1.102 Wed Mar 13 12:16:49 2019 +++ src/sys/dev/sdmmc/sdhc.c Wed Jul 3 23:10:08 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sdhc.c,v 1.102 2019/03/13 12:16:49 jmcneill Exp $ */ +/* $NetBSD: sdhc.c,v 1.103 2019/07/03 23:10:08 jmcneill Exp $ */ /* $OpenBSD: sdhc.c,v 1.25 2009/01/13 19:44:20 grange Exp $ */ /* @@ -23,7 +23,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sdhc.c,v 1.102 2019/03/13 12:16:49 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sdhc.c,v 1.103 2019/07/03 23:10:08 jmcneill Exp $"); #ifdef _KERNEL_OPT #include "opt_sdmmc.h" @@ -1460,7 +1460,7 @@ sdhc_execute_tuning1(struct sdhc_host *h sdhc_soft_reset(hp, SDHC_RESET_DAT|SDHC_RESET_CMD); aprint_error_dev(hp->sc->sc_dev, "tuning did not complete, using fixed sampling clock\n"); - return EIO; /* tuning did not complete */ + return 0; /* tuning did not complete */ } if ((HREAD2(hp, SDHC_HOST_CTL2) & SDHC_SAMPLING_CLOCK_SEL) == 0) { @@ -1469,7 +1469,7 @@ sdhc_execute_tuning1(struct sdhc_host *h sdhc_soft_reset(hp, SDHC_RESET_DAT|SDHC_RESET_CMD); aprint_error_dev(hp->sc->sc_dev, "tuning failed, using fixed sampling clock\n"); - return EIO; /* tuning failed */ + return 0; /* tuning failed */ } if (hp->tuning_timer_count) {
CVS commit: src/sys/dev/sdmmc
Module Name:src Committed By: jmcneill Date: Wed Jul 3 23:10:08 UTC 2019 Modified Files: src/sys/dev/sdmmc: sdhc.c Log Message: If switching to fixed sampling clock, do not return an error to the sdmmc layer. To generate a diff of this commit: cvs rdiff -u -r1.102 -r1.103 src/sys/dev/sdmmc/sdhc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/sdmmc
Module Name:src Committed By: jmcneill Date: Thu Jun 6 20:50:46 UTC 2019 Modified Files: src/sys/dev/sdmmc: sdmmc_mem.c Log Message: If setting HS_TIMING fails, keep trying slower speeds instead of bailing out. To generate a diff of this commit: cvs rdiff -u -r1.67 -r1.68 src/sys/dev/sdmmc/sdmmc_mem.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sdmmc/sdmmc_mem.c diff -u src/sys/dev/sdmmc/sdmmc_mem.c:1.67 src/sys/dev/sdmmc/sdmmc_mem.c:1.68 --- src/sys/dev/sdmmc/sdmmc_mem.c:1.67 Tue May 28 00:25:27 2019 +++ src/sys/dev/sdmmc/sdmmc_mem.c Thu Jun 6 20:50:46 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sdmmc_mem.c,v 1.67 2019/05/28 00:25:27 jmcneill Exp $ */ +/* $NetBSD: sdmmc_mem.c,v 1.68 2019/06/06 20:50:46 jmcneill Exp $ */ /* $OpenBSD: sdmmc_mem.c,v 1.10 2009/01/09 10:55:22 jsg Exp $ */ /* @@ -45,7 +45,7 @@ /* Routines for SD/MMC memory cards. */ #include -__KERNEL_RCSID(0, "$NetBSD: sdmmc_mem.c,v 1.67 2019/05/28 00:25:27 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sdmmc_mem.c,v 1.68 2019/06/06 20:50:46 jmcneill Exp $"); #ifdef _KERNEL_OPT #include "opt_sdmmc.h" @@ -124,6 +124,12 @@ static const struct { { "DDR50", SMC_CAPS_UHS_DDR50, 5 }, }; +static const int sdmmc_mmc_timings[] = { + [EXT_CSD_HS_TIMING_LEGACY] = 26000, + [EXT_CSD_HS_TIMING_HIGHSPEED] = 52000, + [EXT_CSD_HS_TIMING_HS200] = 20 +}; + /* * Initialize SD/MMC memory cards and memory in SDIO "combo" cards. */ @@ -955,18 +961,14 @@ sdmmc_mem_mmc_init(struct sdmmc_softc *s if (ISSET(sc->sc_caps, SMC_CAPS_MMC_HS200) && ext_csd[EXT_CSD_CARD_TYPE] & EXT_CSD_CARD_TYPE_F_HS200_1_8V) { - sf->csd.tran_speed = 20; /* 200MHz SDR */ hs_timing = EXT_CSD_HS_TIMING_HS200; } else if (ISSET(sc->sc_caps, SMC_CAPS_MMC_DDR52) && ext_csd[EXT_CSD_CARD_TYPE] & EXT_CSD_CARD_TYPE_F_DDR52_1_8V) { - sf->csd.tran_speed = 52000; /* 52MHz */ hs_timing = EXT_CSD_HS_TIMING_HIGHSPEED; ddr = true; } else if (ext_csd[EXT_CSD_CARD_TYPE] & EXT_CSD_CARD_TYPE_F_52M) { - sf->csd.tran_speed = 52000; /* 52MHz */ hs_timing = EXT_CSD_HS_TIMING_HIGHSPEED; } else if (ext_csd[EXT_CSD_CARD_TYPE] & EXT_CSD_CARD_TYPE_F_26M) { - sf->csd.tran_speed = 26000; /* 26MHz */ hs_timing = EXT_CSD_HS_TIMING_LEGACY; } else { aprint_error_dev(sc->sc_dev, @@ -1007,16 +1009,25 @@ sdmmc_mem_mmc_init(struct sdmmc_softc *s !ISSET(sc->sc_caps, SMC_CAPS_MMC_HIGHSPEED)) { hs_timing = EXT_CSD_HS_TIMING_LEGACY; } + + const int target_timing = hs_timing; if (hs_timing != EXT_CSD_HS_TIMING_LEGACY) { - error = sdmmc_mem_mmc_switch(sf, EXT_CSD_CMD_SET_NORMAL, - EXT_CSD_HS_TIMING, hs_timing, false); - if (error) { -aprint_error_dev(sc->sc_dev, -"can't change high speed %d, error %d\n", -hs_timing, error); -return error; + while (hs_timing >= EXT_CSD_HS_TIMING_LEGACY) { +error = sdmmc_mem_mmc_switch(sf, EXT_CSD_CMD_SET_NORMAL, +EXT_CSD_HS_TIMING, hs_timing, false); +if (error == 0 || hs_timing == EXT_CSD_HS_TIMING_LEGACY) + break; +hs_timing--; } } + if (hs_timing != target_timing) { + aprint_debug_dev(sc->sc_dev, + "card failed to switch to timing mode %d, using %d\n", + target_timing, hs_timing); + } + + KASSERT(hs_timing < __arraycount(sdmmc_mmc_timings)); + sf->csd.tran_speed = sdmmc_mmc_timings[hs_timing]; if (sc->sc_busclk > sf->csd.tran_speed) sc->sc_busclk = sf->csd.tran_speed;
CVS commit: src/sys/dev/sdmmc
Module Name:src Committed By: jmcneill Date: Thu Jun 6 20:50:46 UTC 2019 Modified Files: src/sys/dev/sdmmc: sdmmc_mem.c Log Message: If setting HS_TIMING fails, keep trying slower speeds instead of bailing out. To generate a diff of this commit: cvs rdiff -u -r1.67 -r1.68 src/sys/dev/sdmmc/sdmmc_mem.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/sdmmc
Module Name:src Committed By: jmcneill Date: Tue May 28 00:25:27 UTC 2019 Modified Files: src/sys/dev/sdmmc: sdmmc_mem.c Log Message: If a mem function fails to initialize, set the error flag so sdmmc doesn't try to use it anyway. To generate a diff of this commit: cvs rdiff -u -r1.66 -r1.67 src/sys/dev/sdmmc/sdmmc_mem.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sdmmc/sdmmc_mem.c diff -u src/sys/dev/sdmmc/sdmmc_mem.c:1.66 src/sys/dev/sdmmc/sdmmc_mem.c:1.67 --- src/sys/dev/sdmmc/sdmmc_mem.c:1.66 Fri Nov 9 14:38:36 2018 +++ src/sys/dev/sdmmc/sdmmc_mem.c Tue May 28 00:25:27 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sdmmc_mem.c,v 1.66 2018/11/09 14:38:36 jmcneill Exp $ */ +/* $NetBSD: sdmmc_mem.c,v 1.67 2019/05/28 00:25:27 jmcneill Exp $ */ /* $OpenBSD: sdmmc_mem.c,v 1.10 2009/01/09 10:55:22 jsg Exp $ */ /* @@ -45,7 +45,7 @@ /* Routines for SD/MMC memory cards. */ #include -__KERNEL_RCSID(0, "$NetBSD: sdmmc_mem.c,v 1.66 2018/11/09 14:38:36 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sdmmc_mem.c,v 1.67 2019/05/28 00:25:27 jmcneill Exp $"); #ifdef _KERNEL_OPT #include "opt_sdmmc.h" @@ -589,6 +589,9 @@ sdmmc_mem_init(struct sdmmc_softc *sc, s else error = sdmmc_mem_mmc_init(sc, sf); + if (error != 0) + SET(sf->flags, SFF_ERROR); + out: SDMMC_UNLOCK(sc);
CVS commit: src/sys/dev/sdmmc
Module Name:src Committed By: jmcneill Date: Tue May 28 00:25:27 UTC 2019 Modified Files: src/sys/dev/sdmmc: sdmmc_mem.c Log Message: If a mem function fails to initialize, set the error flag so sdmmc doesn't try to use it anyway. To generate a diff of this commit: cvs rdiff -u -r1.66 -r1.67 src/sys/dev/sdmmc/sdmmc_mem.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Re: CVS commit: src/sys/dev/sdmmc
Hi Jared, On 07/11/2017 18:01, Jared McNeill wrote: > Could have saved yourself a lot of time if you had emailed me first, > I've been sitting on this code since I ported bwfm but didn't commit it > as the original code doesn't actually work. Do you plan on finishing it? Sorry, I could not guess that, and I currently do not have reliable Internet at home so I often have to work on this offline. I got this part to build, thought this was a net positive and decided to commit it so it can benefit others too. You are much better and faster than me at working on this, I am interested in this area but feel free to go ahead and commit what you have if you can improve it or get it to work. Cheers, -- khorben > On Tue, 7 Nov 2017, Pierre Pronchery wrote: > >> Module Name: src >> Committed By: khorben >> Date: Tue Nov 7 16:30:32 UTC 2017 >> >> Modified Files: >> src/sys/dev/sdmmc: files.sdmmc >> Added Files: >> src/sys/dev/sdmmc: if_bwfm_sdio.c >> >> Log Message: >> Add driver for Broadcom 802.11a/b/g/n/ac SDIO wireless devices, based on >> the OpenBSD bwfm(4) driver. >> >> I could not test this on any hardware yet, as it does not attach as-is on >> my Raspberry PI 3. >> >> >> To generate a diff of this commit: >> cvs rdiff -u -r1.4 -r1.5 src/sys/dev/sdmmc/files.sdmmc >> cvs rdiff -u -r0 -r1.1 src/sys/dev/sdmmc/if_bwfm_sdio.c >> >> Please note that diffs are not public domain; they are subject to the >> copyright notices on the relevant files. >> >> -- khorben
Re: CVS commit: src/sys/dev/sdmmc
On Wed, 8 Nov 2017, Pierre Pronchery wrote: Sorry, I could not guess that, and I currently do not have reliable Internet at home so I often have to work on this offline. I got this part to build, thought this was a net positive and decided to commit it so it can benefit others too. You are much better and faster than me at working on this, I am interested in this area but feel free to go ahead and commit what you have if you can improve it or get it to work. Your patch was more or less the same as mine :) I was waiting for the author of the original author to get it working on OpenBSD -- there's a non-trivial amount of work that needs to be done. The current bwfm sdio code doesn't do much more than read a device ID and then print a TODO message. It was enough for me to work out some kinks in our sdmmc stack, but it's quite a ways away from being ready to use.
Re: CVS commit: src/sys/dev/sdmmc
Could have saved yourself a lot of time if you had emailed me first, I've been sitting on this code since I ported bwfm but didn't commit it as the original code doesn't actually work. Do you plan on finishing it? On Tue, 7 Nov 2017, Pierre Pronchery wrote: Module Name:src Committed By: khorben Date: Tue Nov 7 16:30:32 UTC 2017 Modified Files: src/sys/dev/sdmmc: files.sdmmc Added Files: src/sys/dev/sdmmc: if_bwfm_sdio.c Log Message: Add driver for Broadcom 802.11a/b/g/n/ac SDIO wireless devices, based on the OpenBSD bwfm(4) driver. I could not test this on any hardware yet, as it does not attach as-is on my Raspberry PI 3. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/dev/sdmmc/files.sdmmc cvs rdiff -u -r0 -r1.1 src/sys/dev/sdmmc/if_bwfm_sdio.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Re: CVS commit: src/sys/dev/sdmmc
Thank you, I will see if I can make some progress in this area. One of my sunxi boards has DDR52-capable eMMC. On Mon, 17 Jul 2017, Kimihiro Nonaka wrote: I remember that it was not working yet. 2017-07-17 3:36 GMT+09:00 Jared McNeill : Does the DDR52 code work? I don't see sdhc setting SMC_CAPS_MMC_DDR52 anywhere.. On Fri, 17 Feb 2017, NONAKA Kimihiro wrote: Module Name:src Committed By: nonaka Date: Fri Feb 17 10:50:43 UTC 2017 Modified Files: src/sys/dev/sdmmc: sdhc.c sdmmc_mem.c sdmmcchip.h Log Message: sdhc(4), sdmmc(4): Added MMC HS DDR52 support. To generate a diff of this commit: cvs rdiff -u -r1.97 -r1.98 src/sys/dev/sdmmc/sdhc.c cvs rdiff -u -r1.53 -r1.54 src/sys/dev/sdmmc/sdmmc_mem.c cvs rdiff -u -r1.7 -r1.8 src/sys/dev/sdmmc/sdmmcchip.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Re: CVS commit: src/sys/dev/sdmmc
I remember that it was not working yet. 2017-07-17 3:36 GMT+09:00 Jared McNeill : > Does the DDR52 code work? I don't see sdhc setting SMC_CAPS_MMC_DDR52 > anywhere.. > > > > On Fri, 17 Feb 2017, NONAKA Kimihiro wrote: > >> Module Name:src >> Committed By: nonaka >> Date: Fri Feb 17 10:50:43 UTC 2017 >> >> Modified Files: >> src/sys/dev/sdmmc: sdhc.c sdmmc_mem.c sdmmcchip.h >> >> Log Message: >> sdhc(4), sdmmc(4): Added MMC HS DDR52 support. >> >> >> To generate a diff of this commit: >> cvs rdiff -u -r1.97 -r1.98 src/sys/dev/sdmmc/sdhc.c >> cvs rdiff -u -r1.53 -r1.54 src/sys/dev/sdmmc/sdmmc_mem.c >> cvs rdiff -u -r1.7 -r1.8 src/sys/dev/sdmmc/sdmmcchip.h >> >> Please note that diffs are not public domain; they are subject to the >> copyright notices on the relevant files. >> >> >
Re: CVS commit: src/sys/dev/sdmmc
Does the DDR52 code work? I don't see sdhc setting SMC_CAPS_MMC_DDR52 anywhere.. On Fri, 17 Feb 2017, NONAKA Kimihiro wrote: Module Name:src Committed By: nonaka Date: Fri Feb 17 10:50:43 UTC 2017 Modified Files: src/sys/dev/sdmmc: sdhc.c sdmmc_mem.c sdmmcchip.h Log Message: sdhc(4), sdmmc(4): Added MMC HS DDR52 support. To generate a diff of this commit: cvs rdiff -u -r1.97 -r1.98 src/sys/dev/sdmmc/sdhc.c cvs rdiff -u -r1.53 -r1.54 src/sys/dev/sdmmc/sdmmc_mem.c cvs rdiff -u -r1.7 -r1.8 src/sys/dev/sdmmc/sdmmcchip.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
KTHREAD_MPSAFE [was Re: CVS commit: src/sys/dev/sdmmc]
On 07/08/17 19:38, Jared D. McNeill wrote: Module Name:src Committed By: jmcneill Date: Sat Jul 8 18:38:57 UTC 2017 Modified Files: src/sys/dev/sdmmc: ld_sdmmc.c Log Message: The config_* APIs are not MPSAFE, so make sure the deferred attach thread holds KERNEL_LOCK. [snip] @@ -157,7 +157,7 @@ ld_sdmmc_attach(device_t parent, device_ * when wedge is supported. */ config_pending_incr(self); - if (kthread_create(PRI_NONE, KTHREAD_MPSAFE, NULL, + if (kthread_create(PRI_NONE, 0, NULL, ld_sdmmc_doattach, sc, &lwp, "%sattach", device_xname(self))) { aprint_error_dev(self, "couldn't create thread\n"); } I think we should mark all kthreads KTHREAD_MPSAFE (or even get rid of the option) and sprinkle KERNEL_{,UN}LOCK as appropriate. Nick
Re: CVS commit: src/sys/dev/sdmmc
Hi! From: Nick Hudson Date: Mon, 4 Jul 2016 20:34:15 +0100 > On 07/03/16 13:12, KIYOHARA Takashi wrote: >> Hi! >> >> From: Nick Hudson >> Date: Sun, 3 Jul 2016 12:58:58 +0100 >> >>> On 07/03/16 12:55, KIYOHARA Takashi wrote: Module Name: src Committed By: kiyohara Date: Sun Jul 3 11:55:27 UTC 2016 Modified Files: src/sys/dev/sdmmc: sdhc.c Log Message: Please more delay, if timeout in sdhc_wait_intr(). >>> err, why? >> i.e. sdmmc(4) first try sdmmc_io_enable(). But MicroSD is not >> io-card. And detect error. > why should sdhc_exec_command delay before returning ETIMEDOUT? I think some of the command was appeared to be based on the assumption the timeout. And if time of SDHC_COMMAND_TIMEOUT has passed, I thought that there is no problem in adding about further 50usec. Thnaks, -- kiyohara
Re: CVS commit: src/sys/dev/sdmmc
On 07/03/16 13:12, KIYOHARA Takashi wrote: Hi! From: Nick Hudson Date: Sun, 3 Jul 2016 12:58:58 +0100 On 07/03/16 12:55, KIYOHARA Takashi wrote: Module Name:src Committed By: kiyohara Date: Sun Jul 3 11:55:27 UTC 2016 Modified Files: src/sys/dev/sdmmc: sdhc.c Log Message: Please more delay, if timeout in sdhc_wait_intr(). err, why? i.e. sdmmc(4) first try sdmmc_io_enable(). But MicroSD is not io-card. And detect error. I'm sorry I don't follow. why should sdhc_exec_command delay before returning ETIMEDOUT? Thanks, -- kiyohara Thanks, Nick
Re: CVS commit: src/sys/dev/sdmmc
Hi! From: Nick Hudson Date: Sun, 3 Jul 2016 12:58:58 +0100 > On 07/03/16 12:55, KIYOHARA Takashi wrote: >> Module Name: src >> Committed By:kiyohara >> Date:Sun Jul 3 11:55:27 UTC 2016 >> >> Modified Files: >> src/sys/dev/sdmmc: sdhc.c >> >> Log Message: >> Please more delay, if timeout in sdhc_wait_intr(). > > err, why? i.e. sdmmc(4) first try sdmmc_io_enable(). But MicroSD is not io-card. And detect error. Thanks, -- kiyohara
Re: CVS commit: src/sys/dev/sdmmc
On 07/03/16 12:55, KIYOHARA Takashi wrote: Module Name:src Committed By: kiyohara Date: Sun Jul 3 11:55:27 UTC 2016 Modified Files: src/sys/dev/sdmmc: sdhc.c Log Message: Please more delay, if timeout in sdhc_wait_intr(). err, why? Nick
Re: CVS commit: src/sys/dev/sdmmc
> it seems odd to have bits set in SDHC_EINTR_STATUS without > SDHC_ERROR_INTERRUPT set in SDHC_NINTR_STATUS, and > the two code paths seem different still This is because the ESDHC doesn't set SDHC_ERROR_INTERRUPT in its register since you've read SDHC_EINTR_STATUS and can see those bits directly. So, for the sdhc driver, it needs to be emulated. Don't we need to look at the error bits and take that into account before the continue? As I read the code below, if SDHC_NINTR_STATUS doesn't have SDHC_ERROR_INTERRUPT set, but some bits are set in SDHC_EINTR_STATUS, then the continue (none for us) will still be taken. Don't we still need to set the bit in status before that test? Isn't that what the code did before? If I understand, the bug was not putting SDHC_ERROR_INTERRUPT into xstatus for write-back/ack, and how the synthetic SDHC_ERROR_INTERRUPT was generated for local consumption was ok? (Sorry if I'm being dense - I'm finding this all a little hard to follow.) uint32_t xstatus = HREAD4(hp, SDHC_NINTR_STATUS); status = xstatus; error = xstatus >> 16; if (!ISSET(status, SDHC_NINTR_STATUS_MASK)) continue; /* no interrupt for us */ /* Acknowledge the interrupts we are about to handle. */ xstatus |= (error ? SDHC_ERROR_INTERRUPT : 0); HWRITE4(hp, SDHC_NINTR_STATUS, xstatus); pgp6bMiZ67Qzv.pgp Description: PGP signature
Re: CVS commit: src/sys/dev/sdmmc
On Jul 17, 2012, at 7:08 AM, Greg Troxel wrote: > So the 4-byte read causes the SDHC_ERROR_INTERRUPT not to get set because > the same read reads EINTR_STATUS, or the chip that's in systems that need > 4-byte reads is different (ESDHC vs SDHC?)? The chip does not implement SDHC_ERROR_INTERRUPT. It's always 0. It depends on the vendor. Freescale decided to not set it.
Re: CVS commit: src/sys/dev/sdmmc
On Jul 17, 2012, at 0925 , Matt Thomas wrote: > > On Jul 17, 2012, at 5:39 AM, Greg Troxel wrote: > >> > > 0x30 is aligned and that is the address that is read from a 32-bit access. Not enough coffee - I was reading hex as decimal :-) >> In the non-32 case, it seems that the EINTR register is read and then >> written back exactly if the error bit is set in the NINTR register. In >> the 32 case, it seems that the SDHC_ERROR_INTERRUPT bit is set in NINTR >> if any bits are set in EINTR, in addition to writing both. >> >> So while I see the point that the |= into status is effectively a dead >> store, >> >> it seems odd to have bits set in SDHC_EINTR_STATUS without >> SDHC_ERROR_INTERRUPT set in SDHC_NINTR_STATUS, and >> the two code paths seem different still > > This is because the ESDHC doesn't set SDHC_ERROR_INTERRUPT in its > register since you've read SDHC_EINTR_STATUS and can see those bits > directly. So, for the sdhc driver, it needs to be emulated. So the 4-byte read causes the SDHC_ERROR_INTERRUPT not to get set because the same read reads EINTR_STATUS, or the chip that's in systems that need 4-byte reads is different (ESDHC vs SDHC?)? >> I'm curious if you've been seeing bits in EINTR without ERROR in NINTR, >> and what the symptoms are that provoked this fix - I have a system with >> an sdhc (on evbppc/P2020) that mostly works but has occasional write >> errors. > > That is exactly what the ESDHC on the P2020 does. Thanks; that could be our issue then.
Re: CVS commit: src/sys/dev/sdmmc
On Jul 17, 2012, at 5:39 AM, Greg Troxel wrote: > > Modified Files: > src/sys/dev/sdmmc: sdhc.c > > Log Message: > Handle interrupt acknowledgement in the SDHC_FLAG_32BIT_ACCESS case in > the same way as non-SDHC_FLAG_32BIT_ACCESS case. > > To generate a diff of this commit: > cvs rdiff -u -r1.20 -r1.21 src/sys/dev/sdmmc/sdhc.c > > Two questions, one of which isn't about your change. > > It seems that the HREAD4 of SDHC_NINTR_STATUS is reading both that and > SDHC_EINTR_STATUS, but it seems odd that those are addresses 0x30 and > 0x32, which don't seem 4-byte aligned. So is it really ok to do an > HREAD4 across boundaries like that? It seems odd, but maybe it's about > the bus and the chip is fine with it. 0x30 is aligned and that is the address that is read from a 32-bit acccess. > In the non-32 case, it seems that the EINTR register is read and then > written back exactly if the error bit is set in the NINTR register. In > the 32 case, it seems that the SDHC_ERROR_INTERRUPT bit is set in NINTR > if any bits are set in EINTR, in addition to writing both. > > So while I see the point that the |= into status is effectively a dead > store, > > it seems odd to have bits set in SDHC_EINTR_STATUS without > SDHC_ERROR_INTERRUPT set in SDHC_NINTR_STATUS, and > the two code paths seem different still This is because the ESDHC doesn't set SDHC_ERROR_INTERRUPT in its register since you've read SDHC_EINTR_STATUS and can see those bits directly. So, for the sdhc driver, it needs to be emulated. > I'm curious if you've been seeing bits in EINTR without ERROR in NINTR, > and what the symptoms are that provoked this fix - I have a system with > an sdhc (on evbppc/P2020) that mostly works but has occasional write > errors. That is exactly what the ESDHC on the P2020 does.
Re: CVS commit: src/sys/dev/sdmmc
Modified Files: src/sys/dev/sdmmc: sdhc.c Log Message: Handle interrupt acknowledgement in the SDHC_FLAG_32BIT_ACCESS case in the same way as non-SDHC_FLAG_32BIT_ACCESS case. To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/sys/dev/sdmmc/sdhc.c Two questions, one of which isn't about your change. It seems that the HREAD4 of SDHC_NINTR_STATUS is reading both that and SDHC_EINTR_STATUS, but it seems odd that those are addresses 0x30 and 0x32, which don't seem 4-byte aligned. So is it really ok to do an HREAD4 across boundaries like that? It seems odd, but maybe it's about the bus and the chip is fine with it. In the non-32 case, it seems that the EINTR register is read and then written back exactly if the error bit is set in the NINTR register. In the 32 case, it seems that the SDHC_ERROR_INTERRUPT bit is set in NINTR if any bits are set in EINTR, in addition to writing both. So while I see the point that the |= into status is effectively a dead store, it seems odd to have bits set in SDHC_EINTR_STATUS without SDHC_ERROR_INTERRUPT set in SDHC_NINTR_STATUS, and the two code paths seem different still I'm curious if you've been seeing bits in EINTR without ERROR in NINTR, and what the symptoms are that provoked this fix - I have a system with an sdhc (on evbppc/P2020) that mostly works but has occasional write errors. Thanks, Greg pgpnAXFg7lo2L.pgp Description: PGP signature
Re: CVS commit: src/sys/dev/sdmmc
On Tue, Sep 21, 2010 at 04:57:44 +, KIYOHARA Takashi wrote: > Module Name: src > Committed By: kiyohara > Date: Tue Sep 21 04:57:44 UTC 2010 > > Modified Files: > src/sys/dev/sdmmc: sdmmcvar.h > > Log Message: > + Add macro SMC_CAPS_8BIT_MODE for 8bit mode support. > + Typo. s/automagically/automatically/. "automagically" is NOT a typo. http://catb.org/jargon/html/A/automagically.html -uwe
Re: CVS commit: src/sys/dev/sdmmc
Hi! Tom, From: Tom Spindler Date: Mon, 20 Sep 2010 13:34:29 + > > Modified Files: > > src/sys/dev/sdmmc: sdmmc_mem.c > > Did you miss committing a header file and/or further sets of patches? Yes. ;-) This problem fixed. Try once cvs update. And, I am looking for the tester with sdhc. SDIO of my Marvell Sheevaplug is not good at the steering wheel of two or more DMA segment. I am testing DMA-multi-segment support. Thanks, -- kiyohara
Re: CVS commit: src/sys/dev/sdmmc
> Modified Files: > src/sys/dev/sdmmc: sdmmc_mem.c Did you miss committing a header file and/or further sets of patches? /usr/src/sys/dev/sdmmc/sdmmc_mem.c: In function 'sdmmc_mem_init': /usr/src/sys/dev/sdmmc/sdmmc_mem.c:476: error: 'SMC_CAPS_8BIT_MODE' undeclared (first use in this function) /usr/src/sys/dev/sdmmc/sdmmc_mem.c:476: error: (Each undeclared identifier is reported only once /usr/src/sys/dev/sdmmc/sdmmc_mem.c:476: error: for each function it appears in.) /usr/src/sys/dev/sdmmc/sdmmc_mem.c:477: error: 'width' undeclared (first use in this function) /usr/src/sys/dev/sdmmc/sdmmc_mem.c:478: error: 'value' undeclared (first use in this function)
CVS commit: src/sys/dev/sdmmc
Module Name:src Committed By: uebayasi Date: Tue Jan 12 08:41:16 UTC 2010 Modified Files: src/sys/dev/sdmmc: sdhc.c Log Message: According to SD Host Controller Simplified Specification Version 2.00, 2.2.10. Host Control Register (Offset 028h), the "Data Transfer Width" bit is in Host Control Register (Offset 028h), not Power Control Register (Offset 029h). To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/dev/sdmmc/sdhc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/sdmmc
Module Name:src Committed By: dyoung Date: Fri Jan 8 19:53:10 UTC 2010 Modified Files: src/sys/dev/sdmmc: sdhc.c sdhcvar.h Log Message: Expand PMF_FN_* macros. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/dev/sdmmc/sdhc.c cvs rdiff -u -r1.1 -r1.2 src/sys/dev/sdmmc/sdhcvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Re: CVS commit: src/sys/dev/sdmmc
>>> NONAKA Kimihiro wrote > Module Name: src > Committed By: nonaka > Date: Sun Apr 26 07:21:13 UTC 2009 > > Modified Files: > src/sys/dev/sdmmc: sdmmcreg.h > > Log Message: > Added some command definitions. | | -/* SD commands */ /* response type */ | -#define SD_SEND_RELATIVE_ADDR 3 /* R6 */ | +/* SD commands */ /* response type */ | +#define SD_SET_RELATIVE_ADDR 3 /* R6 */ | #define SD_SEND_IF_COND8 /* R7 */ This part of changes broke the kernel build. -- Takeshi Nakayama
Re: CVS commit: src/sys/dev/sdmmc
fixed. 2009/4/26 Takeshi Nakayama : NONAKA Kimihiro wrote > >> Module Name: src >> Committed By: nonaka >> Date: Sun Apr 26 07:21:13 UTC 2009 >> >> Modified Files: >> src/sys/dev/sdmmc: sdmmcreg.h >> >> Log Message: >> Added some command definitions. > > | > | -/* SD commands */ /* response type */ > | -#define SD_SEND_RELATIVE_ADDR 3 /* R6 */ > | +/* SD commands */ /* response type */ > | +#define SD_SET_RELATIVE_ADDR 3 /* R6 */ > | #define SD_SEND_IF_COND 8 /* R7 */ > > This part of changes broke the kernel build. > > -- Takeshi Nakayama >