History log of /freebsd-current/sys/arm/allwinner/aw_mmc.c
Revision Date Author Comments
# b2f0caf1 26-Dec-2023 Emmanuel Vadot <manu@FreeBSD.org>

regulator: Move regulator code in dev/regulator

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: emaste, imp
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D43194


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

hwreset: Move reset code in dev/hwreset

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: imp
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D43192


# 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/


# 4d846d26 10-May-2023 Warner Losh <imp@FreeBSD.org>

spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD

The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with: pfg
MFC After: 3 days
Sponsored by: Netflix


# 7e1e2ba1 09-May-2022 John Baldwin <jhb@FreeBSD.org>

arm allwinner: Remove unused devclass arguments to DRIVER_MODULE.


# af8b51b0 16-Feb-2022 Andriy Gapon <avg@FreeBSD.org>

aw_mmc: add crash dumping support in MMCCAM mode

MFC after: 1 week


# 8a8166e5 02-Aug-2021 Bartlomiej Grzesik <bag@semihalf.com>

mmc: switch mmc_helper to device_ api

Add generic mmc_helper which uses newly introduced device_*_property
api. Thanks to this change the sd/mmc drivers will be capable
of parsing both DT and ACPI description.

Ensure backward compatibility for all mmc_fdt_helper users.

Reviewed by: manu, mw
Sponsored by: Semihalf
Differential revision: https://reviews.freebsd.org/D31598


# 6bc8fe8a 26-May-2021 Emmanuel Vadot <manu@FreeBSD.org>

arm: allwinner: Add mmc_pwrseq support

If a pwrseq is found, set power accordingly.

Sponsored by: Diablotin Systems


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

arm: allwinner: aw_mmc: Check regulators status before enabling/disabling them

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


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

allwinner: aw_mmc: 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/D27486
Reviewed by: imp


# 020df509 30-Nov-2020 Emmanuel Vadot <manu@FreeBSD.org>

arm: allwinner: aw_mmc: Add a sysctl for debuging

Add a new hw.aw_mmc.debug sysctl to help debugging the driver.
Bit 0 will debug card changes (removal, insertion, power up/down)
Bit 1 will debug ios changes
Bit 2 will debug interrupts received
Bit 3 will debug commands sent


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

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


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

mmccam: aw_mmc: Only print the new ios value under bootverbose


# 9bca4667 22-Jul-2020 Emmanuel Vadot <manu@FreeBSD.org>

aw_mmc: Start a mmccam discovery when the CD handler is called.

Submitted by: kibab


# cbba9a7b 16-Apr-2020 Emmanuel Vadot <manu@FreeBSD.org>

arm: allwinner: aw_mmc: Make it possible to unload the module

While here, add a makefile in sys/modules/allwinner so it is built.
Also add the PNP info so devmatch will load this module automatically.

MFC after: 1 month


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

arm: allwinner: aw_mmc: Use the mmc_fdt_helper

The fdt properties are now parsed via the help of mmc_fdt_helper functions.
This also adds card detection.
Note that on some boards (like the Pine64) card detection is broken due to
a missing resistor on the cd pin.

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


# 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.


# 94d3675e 06-Nov-2019 Emmanuel Vadot <manu@FreeBSD.org>

arm: allwinner: aw_mmc: Check if the regulator support the voltage

Don't blindy say that we support both 3.3V and 1.8V.
If we have a regulator for the data lines, check that the voltage is
supported before adding the signaling caps.
If we don't have a regulator, just assume that the data lines are 3.3V
This unbreak eMMC on some allwinner boards.

Reported by: ganbold
MFC after: 1 month
X-MFC-With: r354396


# ef546520 30-Oct-2019 Ilya Bakulin <kibab@FreeBSD.org>

Use the new cam_sim_alloc_dev function to properly initialize SIM

Using cam_sim_alloc_dev() allows to properly set sim_dev field so that
sdiob(4) can attach to the CAM device that represents SDIO card.
The same change for SDHCI driver happened in r348800.

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


# 101260f3 14-Oct-2019 Emmanuel Vadot <manu@FreeBSD.org>

arm: allwinner: Disable the clock before changing it's freq

You aren't supposed to changing the freq of a clock when it is
enable so disable the clock before changing the freq and then
re-enable it.

MFC after: 1 month


# 440565da 10-Jun-2019 Bjoern A. Zeeb <bz@FreeBSD.org>

allwinner mmc: move variable assignment into block

"blksz is only used in one of the two blocks, so assign it inside
that block rather than outside.

MFC after: 2 weeks


# 5d5ae066 10-Apr-2019 Ilya Bakulin <kibab@FreeBSD.org>

Implement CMD53 block mode support for SDHCI and AllWinner-based boards

If a custom block size requested, use it, otherwise revert to the previous logic
of using just a data size if it's less than MMC_BLOCK_SIZE, and MMC_BLOCK_SIZE otherwise.

Reviewed by: bz
Approved by: imp (mentor)
Differential Revision: https://reviews.freebsd.org/D19783


# 5d20e651 01-Apr-2019 Ilya Bakulin <kibab@FreeBSD.org>

Use information about max data size that the controller is able to operate

Using DFLTPHYS/MAXPHYS is not always OK, instead make it possible for the
controller driver to provide maximum data size to MMCCAM, and use it there.

The old stack already does this.

Reviewed by: manu
Approved by: imp (mentor)
Differential Revision: https://reviews.freebsd.org/D15892


# 55f3f71c 23-Aug-2018 Emmanuel Vadot <manu@FreeBSD.org>

aw_mmc: Handle MMCBR_IVAR_RETUNE_REQ

Without this the mmc stack sometimes think that we are in in a retune
operation and some command like switch the bus width to 4 bits failed.
We now switch correctly to 4 bits mode for sd card.

Reported by: jmg, others in pine64 irc channel


# 7e807acf 23-Jun-2018 Emmanuel Vadot <manu@FreeBSD.org>

aw_mmc: Fix style(9) after r335476


# 5e03278f 21-Jun-2018 Ilya Bakulin <kibab@FreeBSD.org>

Add MMCCAM support to AllWinner MMC driver

Using MMCCAM on AllWinner boards is now possible, reaching highest
possible data transfer speed.

For now, MMCCAM doesn't scan cards on boot. This means that scanning
has to be done manually and that it's not possible to mount root FS
from MMC/SD card since there is no block device at the boot time.

For manually scanning the cards, run:
# camcontrol rescan X:0:0
Where X is the bus number (look at camcontrol devlist to determine
bus number assigned to the MMC controller).

Reviewed by: manu
Approved by: imp (mentor)
Differential Revision: https://reviews.freebsd.org/D15891


# bbf8c8fa 31-May-2018 Emmanuel Vadot <manu@FreeBSD.org>

aw_mmc: Get max-frequency from the dtb

If a max-frequency is supplied in the dtb use it, otherwise fallback to a
default one of 52Mhz.


# 623966e1 31-May-2018 Emmanuel Vadot <manu@FreeBSD.org>

aw_mmc: Use the DEVMETHOD vccq for the IO line voltage

MMC controller should use this and not set the voltage during update_ios.


# c39ea909 31-May-2018 Emmanuel Vadot <manu@FreeBSD.org>

aw_mmc: Rework DMA

- Calculate the number of segments based on the page size
- Add some comments on dma function so it's easier to read
- Only enable interrupts on the last dma segment
- If the segments size is the max transfer size, use the special size 0
for the controller.
- The max_data ivars is in block so calculate it properly.


# ffdb1aa8 31-May-2018 Emmanuel Vadot <manu@FreeBSD.org>

aw_mmc: Rename clock register defines consistently


# b091392e 21-May-2018 Emmanuel Vadot <manu@FreeBSD.org>

aw_mmc: Correctly reset the mmc controller

Always disable FIFO access as we don't use it.
Rename some register bits so they are in sync with the register name.

While here add my copyright as I've probably wrote 70% of the code here.


# dfb8c122 12-May-2018 Emmanuel Vadot <manu@FreeBSD.org>

aw_mmc: Rework regulator handling

Don't enable regulator on attach but dealt with them on power_up/power_off
Only set the voltage for the signaling regulator since I don't have boards
that can change the supply voltage.
Enable 1.8v signaling voltage.


# 35a18619 12-May-2018 Emmanuel Vadot <manu@FreeBSD.org>

aw_mmc: Do not fully init the controller in attach

Only do a reset of the controller at attach and init it at power_up.
We use to enable some interrupts in reset, only enable the interrupts
we are interested in when doing a request.
While here remove the regulators handling in power_on as it is very wrong
and will be dealt with in another commit.

Tested on: A31, A64


# 2445c37a 12-May-2018 Emmanuel Vadot <manu@FreeBSD.org>

aw_mmc: Remove hardware reset

From all the BSP (Board Source Package) source that I've looked at it seems
that it's never done, remove it.

Tested On: A31, A64


# a37d59c1 12-May-2018 Emmanuel Vadot <manu@FreeBSD.org>

aw_mmc: Read interrupt register value before writing to it

Reported by: jmcneill


# 3177f7cd 03-Mar-2018 Emmanuel Vadot <manu@FreeBSD.org>

aw_mmc: Regulator improvement

Getting regulator is good, enabling them is better.
When the mmc stack decide to change the voltage for IO, don't
change the main vcc of the sd/mmc, only the io vcc.


# 0f7a6420 17-Feb-2018 Emmanuel Vadot <manu@FreeBSD.org>

aw_mmc: Only change the clock if it has really changed

This also seems to fix problem when booting Pine64 from the mmc.

Tested On: Pine64
Tested On: Pine64-LTS


# ce0618be 14-Jan-2018 Emmanuel Vadot <manu@FreeBSD.org>

allwinner: mmc: Multiple improvement

- Add a per compatible configuration struct
- Not all SoC uses the same size for DMA transfert, add this into the
configuration data
- Use new timing mode for some SoC (A64 mmc)
- Auto calibrate clock for A64 mmc/emmc
- A64 mmc controller need masking of data0
- Add support for vmmc/vqmmc regulator
- Add more capabilities, r/w speed is better for eMMC
- MMC_CAP_SIGNALING_180 gives weird result so do not enable it for now.
- Add new register documented in H3/A64 user manual

Tested-On: Pine64-LTS (A64), eMMC still doesn't work
Tested-On: A64-Olinuxino (A64), sd and eMMC are working
Tested-On: NanoPi Neo Plus2 (H5), sd and eMMC are working
Tested-On: OrangePi PC2 (H5), sd only (no eMMC)
Tested-On: OrangePi One (H3), sd only (no eMMC)
Tested-On: BananaPi M2 (A31s), sd only (no eMMC)


# b5be541f 25-Dec-2017 Emmanuel Vadot <manu@FreeBSD.org>

Allwinner: mmc: Rename driver to aw_mmc and add a man page for it

Reviewed by: bcr (manpages)
Differential Revision: https://reviews.freebsd.org/D13616