History log of /freebsd-current/sys/dev/mmc/host/dwmmc.c
Revision Date Author Comments
# ea7f45d3 24-Sep-2021 Andriy Gapon <avg@FreeBSD.org>

dwmmc: fix a typo


# be82b3a0 26-Dec-2023 Emmanuel Vadot <manu@FreeBSD.org>

clk: Move clock code in dev/clk

We've removed kernel option EXT_RESOURCES almost two years ago.
While it was ok to have some code under a common 'extres' subdirectory
at first, we now have a lot of consumer of it and we made it mandatory
so no need to have it under a cryptic name.

Reviewed by: mhorne
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D43191


# fdafd315 24-Nov-2023 Warner Losh <imp@FreeBSD.org>

sys: Automated cleanup of cdefs and other formatting

Apply the following automated changes to try to eliminate
no-longer-needed sys/cdefs.h includes as well as now-empty
blank lines in a row.

Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/
Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/
Remove /\n+#if.*\n#endif.*\n+/
Remove /^#if.*\n#endif.*\n/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/

Sponsored by: Netflix


# 685dc743 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

sys: Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# b4cc0f7d 11-Jan-2022 Emmanuel Vadot <manu@FreeBSD.org>

dwmmc: Make ext_resources non-optional

EXT_RESOURCES have been introduced in 12-CURRENT and all supported
releases have it enabled in their kernel config.

MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D33822


# 44682688 12-Jan-2022 Andriy Gapon <avg@FreeBSD.org>

mmc_da: implement d_dump method, sddadump

sddadump has been derived from sddastart.

mmc_sim interface has grown a new method, cam_poll, to support polled
operation.

mmc_sim code has been changed to provide a sim_poll hook only if the
controller implements the new method. The hooks is implemented in terms
of the new mmc_sim_cam_poll method.
Additionally, in-progress CCB-s now have CAM_REQ_INPROG status to
satisfy xpt_pollwait().

mmc_sim_cam_poll method has been implemented in dwmmc host controller.

Reviewed by: manu, mav, imp
MFC after: 2 weeks
Relnotes: perhaps
Differential Revision: https://reviews.freebsd.org/D33843


# dfb73602 07-Oct-2021 Michal Meloun <mmel@FreeBSD.org>

dwmmc: Calculate the maximum transaction length correctly.

We should reserve two descriptors (not MMC_SECTORS) for potentially
unaligned (so bounced) buffer fragments, one for the starting fragment
and one for the ending fragment.

Submitted by: kjopek@gmail.com
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D30387


# 559f6021 21-Sep-2021 Emmanuel Vadot <manu@FreeBSD.org>

dwmmc: Remove dwmmc_setup_bus call from start_cmd

There is no need to re-setup the bus before each commands.
Tested-on: Rock64, RockPro64
Reported by: avg


# af32e2cc 21-Sep-2021 Emmanuel Vadot <manu@FreeBSD.org>

dwmmc: Properly implement power_off/power_up

Write to the PWREN register should be done in update_ios based
on the power_mode value in the ios struct.
Also none of the manual (RockChip and Altera) and Linux talks about
the needed for an inverted PWREN value so just remove this.
This fixes eMMC (and possibly SD) when u-boot didn't setup the controller.

Reported by: avg
Tested-on: Rock64, RockPro64


# 990a1dbf 14-Jul-2021 Emmanuel Vadot <manu@FreeBSD.org>

dwmmc: Fix MMCCAM block size support

When using SDIO the block size if per function and most of the time
not equal to MMC_SECTOR_SIZE, fix sdio on dwmmc by setting the correct
block size in the mmc registers.

MFC after: 1 month
Sponsored by: Diablotin Systems


# c99d887c 16-May-2021 Emmanuel Vadot <manu@FreeBSD.org>

dwmmc: Add bus_generic_add_child in the methods

Otherwise sdiob cannot add it's children.

Sponsored by: Diablotin Systems
Differential Revision: https://reviews.freebsd.org/D30295


# ce41765c 16-May-2021 Emmanuel Vadot <manu@FreeBSD.org>

mmc: dwmmc: Call mmc_fdt_set_power

This allow us to powerup/down the card and enabling/disabling the
regulators if any.

Sponsored by: Diablotin Systems
Differential Revision: https://reviews.freebsd.org/D30292


# 7cbdf8a0 22-Apr-2021 Emmanuel Vadot <manu@FreeBSD.org>

dwmmc: Add \n to a debug printf


# f1cc48e5 21-Apr-2021 Emmanuel Vadot <manu@FreeBSD.org>

mmc: dwmmc: Convert driver to use the mmc_sim interface

A lot more generic cam related things are done in mmc_sim so this simplify
the driver a lot.

Differential Revision: https://reviews.freebsd.org/D27487
Reviewed by: kibab


# 4c1ecf55 26-Apr-2021 Ruslan Bukin <br@FreeBSD.org>

Consider the broken card detect flag that comes from 'broken-cd;'
dts property.

This fixes operation on Intel Stratix 10 devices.

Tested on Terasic DE10-Pro.

Reviewed by: manu
Sponsored by: UKRI
Differential revision: https://reviews.freebsd.org/D29999


# 8727c174 21-Jan-2021 Michal Meloun <mmel@FreeBSD.org>

dwmmc: Multiple busdma fixes.

- limit maximum segment size to 2048 bytes. Although dwmmc supports a buffer
fragment with a maximum length of 4095 bytes, use the nearest lower power
of two as the maximum fragment size. Otherwise, busdma create excessive
buffer fragments.
- fix off by one error in computation of the maximum data transfer length.
- in addition, reserve two DMA descriptors that can be used by busdma
bouncing. The beginning or end of the buffer can be misaligned.
- Don’t ignore errors passed to bus_dmamap_load() callback function.
- In theory, a DMA engine may be running at time when next dma descriptor is
constructed. Create a full DMA descriptor before OWN bit is set.

MFC after: 2 weeks


# f4e5e045 16-Nov-2020 Emmanuel Vadot <manu@FreeBSD.org>

dwmmc: dwmmc_switch_vccq is only used in MMCCAM kernel

Silence the build for non MMCCAM kernel


# 56feefcc 01-Sep-2020 Mateusz Guzik <mjg@FreeBSD.org>

mmc: clean up empty lines in .c and .h files


# d3fd812c 17-Aug-2020 Bjoern A. Zeeb <bz@FreeBSD.org>

dwmmc: remove printf even under bootverbose

Remove two debugging printfs, even if hidden under boot -v.
They seemed to be of debug nature and always spit onto the
console when running camcontrol devlist -v.

Reviewed by: manu
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D25962


# 41c653be 24-Jul-2020 Emmanuel Vadot <manu@FreeBSD.org>

dwmmc: Add MMCCAM part

Add support for MMCCAM for dwmmc

Submitted by: kibab
Tested On: Rock64, RockPro64


# a1af70e5 14-Apr-2020 Emmanuel Vadot <manu@FreeBSD.org>

arm: dwmmc: Use mmc_fdt_helpers

Use the mmc_fdt_parse function instead of parsing everything in the
driver.

MFC after: 1 month


# c30e9beb 04-Mar-2020 Emmanuel Vadot <manu@FreeBSD.org>

dwmmc: Rework the DMA engine

Each segment can be up to 4096 bytes in chain structure according to the
RK3399 TRM Part 2.
Set the buffers in full ring where the last one point to the first one.
Correctly reports the MMC_IVAR_MAX_DATA.
Use CACHE_LINE_SIZE for bus_dma alignment.

MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D23894


# d5151ea8 28-Feb-2020 Emmanuel Vadot <manu@FreeBSD.org>

mmc: dwmmc: Fix off by one error

The IVAR_MAX_DATA is supposed to have the number of descriptor X the mmc
block size and desc_count contain all this information + 1.

Reported by: phk
MFC after: 1 week


# 8c7cd14a 27-Jan-2020 Warner Losh <imp@FreeBSD.org>

Create a convenince wrapper to fill in a CAM_PATH_INQ request for MMC sims. Pass
in the parameters needed for the different sims, but it's almost all identical.


# e82ba2c5 16-Jan-2020 Emmanuel Vadot <manu@FreeBSD.org>

dwmmc: Remove max_hz from the softc

We never use it so directly set the value to the mmc host structure.


# 5757a34c 11-Dec-2019 Emmanuel Vadot <manu@FreeBSD.org>

dwmmc: Use device_delete_children

Instead of first detaching the children(s) and then delete them,
use the device_delete_children function that does all of that.

MFC after: 1 month
Suggested by: ian


# 87d4212b 11-Dec-2019 Emmanuel Vadot <manu@FreeBSD.org>

dwmmc: Handle the card detect interrupt

The driver used to always add the mmc device as it's child even
it no card was detected. Add a function that will detect if the
card is present or not and that will attach/detach the mmc device.
The function is either call on attach (as we won't have the interrupt
fired) or from two taskqueues. The first taskqueue will directly call
the function when the sdcard was present and is now removed and the other
one will delay a bit the attach when we didn't had a card and now have one.
This is mostly based on comments from the sdhci driver where it describe
a situation when the CD pin is detected before the others pins are connected.

MFC after: 1 month


# 87dc015d 11-Dec-2019 Emmanuel Vadot <manu@FreeBSD.org>

dwmmc: Add a detach method

This method will disable the regulators, clocks and assert the reset of
the module. It will also detach it's children (the mmc device) and release
it's resources.
While here enable the regulators on attach as we need them to power up
the sdcard or emmc.

MFC after: 1 month


# a53a43d9 15-Oct-2019 Ruslan Bukin <br@FreeBSD.org>

Fix dwmmc(4) driver attachment when ext_resources are not present.

Ignore only ENOENT (no DTS properties found) and ENODEV (driver not
present) non-zero return values from ext_resources.

Reviewed by: manu
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D22043


# 3ee93b74 14-Oct-2019 Ruslan Bukin <br@FreeBSD.org>

Fix the driver attachment in cases when the external resource devices
(resets, regulators, clocks) are not available.

Rely on a system initialization done by a bootloader in that cases.

This fixes operation on Terasic DE10-Pro (an Intel Stratix 10
development kit).

Sponsored by: DARPA, AFRL


# e3014a57 09-Oct-2019 Emmanuel Vadot <manu@FreeBSD.org>

dwmmc: Reset the dma controller at attach

If the bootloader enabled DMA we need to fully reset the DMA controller
otherwise we might have some stale data in it that provoke weird
behavior.

MFC after: 1 week


# e088e853 18-Aug-2019 Michal Meloun <mmel@FreeBSD.org>

Enhance support of extres in dwmmc driver.
Handle all clocks, regulators and resets defined by dwmmc bindings.

MFC after: 2 weeks


# fbcd7187 04-Jul-2019 Warner Losh <imp@FreeBSD.org>

Fix cut-and-pasto that slipped through my testing.


# 4924bcd3 04-Jul-2019 Warner Losh <imp@FreeBSD.org>

Implement missing MMCBR ivars

All MMCBR bridges have to implement all the MMCBR variables. This
implements them for everybody that currently doesn't.

A common routine for this should be written.


# a4e0b5a4 01-Jul-2019 Emmanuel Vadot <manu@FreeBSD.org>

Since r349571 we need all the accessor to be present for set or get
otherwise we panic.
dwmmc don't handle VCCQ (voltage for the IO line of the SD/eMMC) or
TIMING.
Add the needed accessor in the {read,write}_ivar functions.

Reviewed by: imp (previous version)


# e2e050c8 19-May-2019 Conrad Meyer <cem@FreeBSD.org>

Extract eventfilter declarations to sys/_eventfilter.h

This allows replacing "sys/eventfilter.h" includes with "sys/_eventfilter.h"
in other header files (e.g., sys/{bus,conf,cpu}.h) and reduces header
pollution substantially.

EVENTHANDLER_DECLARE and EVENTHANDLER_LIST_DECLAREs were moved out of .c
files into appropriate headers (e.g., sys/proc.h, powernv/opal.h).

As a side effect of reduced header pollution, many .c files and headers no
longer contain needed definitions. The remainder of the patch addresses
adding appropriate includes to fix those files.

LOCK_DEBUG and LOCK_FILE_LINE_ARG are moved to sys/_lock.h, as required by
sys/mutex.h since r326106 (but silently protected by header pollution prior
to this change).

No functional change (intended). Of course, any out of tree modules that
relied on header pollution for sys/eventhandler.h, sys/lock.h, or
sys/mutex.h inclusion need to be fixed. __FreeBSD_version has been bumped.


# dd198e86 26-Feb-2018 Emmanuel Vadot <manu@FreeBSD.org>

dwmmc: Add clock support and other improvements

* If compiled with EXT_RESOURCES look up the "biu" and "ciu" clocks in
the DT
* Don't use custom property "bus-frequency" but the standard one
"clock-frequency"
* Use the DT property max-frequency and fall back to 200Mhz if it don't exists
* Add more mmc caps suported by the controller
* Always ack all interrupts
* Subclassed driver can supply an update_ios so they can handle update
the clocks accordingly
* Take care of the DDR bit in update_ios (no functional change since we
do not support voltage change for now)
* Make use of the FDT bus-width property


# 74e0613e 30-Dec-2017 Emmanuel Vadot <manu@FreeBSD.org>

dwmmc: Fully subclass driver

Fully subclass the dwmmc driver and split every driver into multiple files.

There is still a few quirks in the dwmmc driver that will need some work.

Tested On: Pine64 Rock64

Differential Revision: https://reviews.freebsd.org/D13615


# 151ba793 24-Dec-2017 Alexander Kabaev <kan@FreeBSD.org>

Do pass removing some write-only variables from the kernel.

This reduces noise when kernel is compiled by newer GCC versions,
such as one used by external toolchain ports.

Reviewed by: kib, andrew(sys/arm and sys/arm64), emaste(partial), erj(partial)
Reviewed by: jhb (sys/dev/pci/* sys/kern/vfs_aio.c and sys/kern/kern_synch.c)
Differential Revision: https://reviews.freebsd.org/D10385


# 02c474b4 15-Sep-2017 Ilya Bakulin <kibab@FreeBSD.org>

Miscellaneous fixes and improvements to MMCCAM stack

* Demote the level of several debug messages to CAM_DEBUG_TRACE
* Add detection for SDHC cards that can do 1.8V. No voltage switch sequence
is issued yet;
* Don't create a separate LUN for each SDIO function. We need just one to make
pass(4) attach;
* Remove obsolete mmc_sdio* files. SDIO functionality will be moved into the
separate device that will manage a new sdio(4) bus;
* Terminate probing if got no reply to CMD0;
* Make bcm2835 SDHCI host controller driver compile with 'option MMCCAM'.

Approved by: imp (mentor)
Differential Revision: https://reviews.freebsd.org/D12109


# 55dae242 07-Mar-2017 Marius Strobl <marius@FreeBSD.org>

Add and use a MMC_DECLARE_BRIDGE macro for declaring mmc(4) bridges
as kernel drivers and their dependency onto mmc(4); this allows for
incrementing the mmc(4) module version but also for entire omission
of these bridge declarations for mmccam(4) in a single place, i. e.
in dev/mmc/bridge.h.


# b440e965 06-Mar-2017 Marius Strobl <marius@FreeBSD.org>

o Another round fixes for mmc(4), mmcsd(4) and sdhci(4) regarding
comments, marking unused parameters as such, style(9), whitespace,
etc.
o In the mmc(4) bridges and sdhci(4) (bus) front-ends:
- Remove redundant assignments of the default bus_generic_print_child
device method (I've whipped these out of the tree as part of r227843
once, but they keep coming back ...),
- use DEVMETHOD_END,
- use NULL instead of 0 for pointers.
o Trim/adjust includes.


# f3ad8ea0 13-May-2016 Andrew Turner <andrew@FreeBSD.org>

Add DMA sync operations around accessing the dwmmc descriptor ring. Even
with it maps as cache-coherent we still need to call bus_dmamap_sync.

Obtained from: ABT Systems Ltd
Sponsored by: The FreeBSD Foundation


# 057b4402 26-Apr-2016 Pedro F. Giffuni <pfg@FreeBSD.org>

sys/dev: extend use of the howmany() macro when available.

We have a howmany() macro in the <sys/param.h> header that is
convenient to re-use as it makes things easier to read.


# 74b8d63d 10-Apr-2016 Pedro F. Giffuni <pfg@FreeBSD.org>

Cleanup unnecessary semicolons from the kernel.

Found with devel/coccinelle.


# dec48737 20-Mar-2016 Ian Lepore <ian@FreeBSD.org>

Fix fallout from r292180 (Dec 2015)... ensure that every driver which has
a DRIVER_MODULE() referencing mmc_driver has a MODULE_DEPEND() on mmc. This
is because the kernel linker only searches for symbols in dependent modules,
so loading sdhci_pci (and other bus-flavors of sdhci) would fail when mmc
was not compiled into the kernel (even if you hand-loaded mmc first).

(Thanks to jilles@ for providing the vital clue about the kernel linker.)


# 3f627274 13-Dec-2015 Ian Lepore <ian@FreeBSD.org>

Move the DRIVER_MODULE() statements that declare mmc(4) to be a child of
the various bridge drivers out of dev/mmc.c and into the bridge drivers.

Requested by: jhb (almost two years ago; better late than never)


# fa6ea996 01-Sep-2015 Andrew Turner <andrew@FreeBSD.org>

Finish allowing the dwmmc driver to be subclassed, move the softc to a new
header, along with the hwtype enum, device attach prototype, and driver_t.

Sponsored by: ABT Systems Ltd


# 0e308268 01-Sep-2015 Andrew Turner <andrew@FreeBSD.org>

Remove an variable we only ever write to, and stop assigning 0 to values
in the softc as it's the default value. The latter helps with subclassing
this driver.

Sponsored by: ABT Systems Ltd


# 755eb18f 28-Aug-2015 Andrew Turner <andrew@FreeBSD.org>

Move dwmmc.h to dwmmc_reg.h. This is in preperation for adding support to
subclass the dwmmc driver to allow SoC specific attachments.

Sponsored by: ABT Systems Ltd


# 725b72d5 28-Aug-2015 Andrew Turner <andrew@FreeBSD.org>

Only check for the bus frequency if it has not already been set, for
example through a driver running as a subclass of this.

Sponsored by: ABT Systems Ltd


# 2640322a 27-Aug-2015 Andrew Turner <andrew@FreeBSD.org>

There is no need to get the bus tag or handle.

Sponsored by: ABT Systems Ltd


# fd59e3a9 27-Aug-2015 Andrew Turner <andrew@FreeBSD.org>

Limit the speed to the bus frequency.

Sponsored by: ABT Systems Ltd


# 488d593a 27-Aug-2015 Andrew Turner <andrew@FreeBSD.org>

Allow the fifo-depth and num-slots to be missing. For the former we read
the value from the hardware, for the latter assume a single slot.

Sponsored by: ABT Systems Ltd


# 26f0e89a 27-Aug-2015 Andrew Turner <andrew@FreeBSD.org>

Allow us to select the transfer count. This allows us to work with hardware
that seems to only work with a single block at a time.

Sponsored by: ABT Systems Ltd


# 4f768055 26-Aug-2015 Andrew Turner <andrew@FreeBSD.org>

Only access the Samsung registers when targeting Samsung hardware.

Sponsored by: ABT Systems Ltd


# d1b2133d 07-Aug-2015 Andrew Turner <andrew@FreeBSD.org>

Attach dwmmc to the ofwbus, som devicetrees place it here.

Sponsored by: ABT Systems Ltd


# a336c375 07-Aug-2015 Andrew Turner <andrew@FreeBSD.org>

Stop including machine/fdt.h, it's unneeded, and purposefully
unimplemented on arm64.

Sponsored by: ABT Systems Ltd


# e2763dca 20-Jan-2015 Ganbold Tsagaankhuu <ganbold@FreeBSD.org>

Enable Synopsys DesignWare Mobile Storage Host Controller
driver on Rockchip boards. It currently supports PIO mode
and dma mode needs external dma controller to be used.

Submitted by: jmcneill
Approved by: stas (mentor)


# fdbf76c3 08-Oct-2014 Ruslan Bukin <br@FreeBSD.org>

Always wait 'command done' interrupt status bit before proceeding next command.

Sponsored by: DARPA, AFRL


# 41709d23 07-Oct-2014 Ruslan Bukin <br@FreeBSD.org>

Add driver for Synopsys DesignWare Mobile Storage Host Controller.

Sponsored by: DARPA, AFRL