History log of /linux-master/include/linux/mmc/sdio_func.h
Revision Date Author Comments
# 94cd1011 29-Mar-2024 Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

mmc: sdio: store owner from modules with sdio_register_driver()

Modules registering driver with sdio_register_driver() might
forget to set .owner field. The field is used by some of other kernel
parts for reference counting (try_module_get()), so it is expected that
drivers will set it.

Solve the problem by moving this task away from the drivers to the core
code, just like we did for platform_driver in
commit 9447057eaff8 ("platform_device: use a macro instead of
platform_driver_register").

Since many drivers forget to set the .owner, this effectively will fix
them. Examples of fixed drivers are: ath6kl, b43, btsdio.c, ks7010,
libertas, MediaTek WiFi drivers, Realtek WiFi drivers, rsi, siano,
wilc1000, wl1251 and more.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: Francesco Dolcini <francesco.dolcini@toradex.com>
Link: https://lore.kernel.org/r/20240329-module-owner-sdio-v1-1-e4010b11ccaa@linaro.org
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>


# 78366e9c 27-Jul-2020 Pali Rohár <pali@kernel.org>

mmc: sdio: Parse CISTPL_VERS_1 major and minor revision numbers

They should indicate compliance of standard.

Signed-off-by: Pali Rohár <pali@kernel.org>
Link: https://lore.kernel.org/r/20200727133837.19086-3-pali@kernel.org
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>


# 1a91a36a 26-Feb-2020 Gustavo A. R. Silva <gustavo@embeddedor.com>

mmc: Replace zero-length array with flexible-array member

The current codebase makes use of the zero-length array language
extension to the C90 standard, but the preferred mechanism to declare
variable-length types such as these ones is a flexible array member[1][2],
introduced in C99:

struct foo {
int stuff;
struct boo array[];
};

By making use of the mechanism above, we will get a compiler warning
in case the flexible array does not occur last in the structure, which
will help us prevent some kind of undefined behavior bugs from being
inadvertently introduced[3] to the codebase from now on.

Also, notice that, dynamic memory allocations won't be affected by
this change:

"Flexible array members have incomplete type, and so the sizeof operator
may not be applied. As a quirk of the original implementation of
zero-length arrays, sizeof evaluates to zero."[1]

This issue was found with the help of Coccinelle.

[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
[2] https://github.com/KSPP/linux/issues/21
[3] commit 76497732932f ("cxgb3/l2t: Fix undefined behaviour")

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Link: https://lore.kernel.org/r/20200226223125.GA20630@embeddedor
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>


# b4c9f938 17-Jun-2019 Douglas Anderson <dianders@chromium.org>

mmc: core: Add sdio_retune_hold_now() and sdio_retune_release()

We want SDIO drivers to be able to temporarily stop retuning when the
driver knows that the SDIO card is not in a state where retuning will
work (maybe because the card is asleep). We'll move the relevant
functions to a place where drivers can call them.

Cc: stable@vger.kernel.org #v4.18+
Signed-off-by: Douglas Anderson <dianders@chromium.org>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: Kalle Valo <kvalo@codeaurora.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>


# 0a55f4ab 17-Jun-2019 Douglas Anderson <dianders@chromium.org>

mmc: core: API to temporarily disable retuning for SDIO CRC errors

Normally when the MMC core sees an "-EILSEQ" error returned by a host
controller then it will trigger a retuning of the card. This is
generally a good idea.

However, if a command is expected to sometimes cause transfer errors
then these transfer errors shouldn't cause a re-tuning. This
re-tuning will be a needless waste of time. One example case where a
transfer is expected to cause errors is when transitioning between
idle (sometimes referred to as "sleep" in Broadcom code) and active
state on certain Broadcom WiFi SDIO cards. Specifically if the card
was already transitioning between states when the command was sent it
could cause an error on the SDIO bus.

Let's add an API that the SDIO function drivers can call that will
temporarily disable the auto-tuning functionality. Then we can add a
call to this in the Broadcom WiFi driver and any other driver that
might have similar needs.

NOTE: this makes the assumption that the card is already tuned well
enough that it's OK to disable the auto-retuning during one of these
error-prone situations. Presumably the driver code performing the
error-prone transfer knows how to recover / retry from errors. ...and
after we can get back to a state where transfers are no longer
error-prone then we can enable the auto-retuning again. If we truly
find ourselves in a case where the card needs to be retuned sometimes
to handle one of these error-prone transfers then we can always try a
few transfers first without auto-retuning and then re-try with
auto-retuning if the first few fail.

Without this change on rk3288-veyron-minnie I periodically see this in
the logs of a machine just sitting there idle:
dwmmc_rockchip ff0d0000.dwmmc: Successfully tuned phase to XYZ

Cc: stable@vger.kernel.org #v4.18+
Signed-off-by: Douglas Anderson <dianders@chromium.org>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: Kalle Valo <kvalo@codeaurora.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>


# 2874c5fd 27-May-2019 Thomas Gleixner <tglx@linutronix.de>

treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152

Based on 1 normalized pattern(s):

this program is free software you can redistribute it and or modify
it under the terms of the gnu general public license as published by
the free software foundation either version 2 of the license or at
your option any later version

extracted by the scancode license scanner the SPDX license identifier

GPL-2.0-or-later

has been chosen to replace the boilerplate/reference in 3029 file(s).

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Allison Randal <allison@lohutok.net>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190527070032.746973796@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# db0a3908 13-Mar-2019 Sean Wang <sean.wang@mediatek.com>

mmc: sdio: Add helper macro for sdio_driver boilerplate

This patch introduces the module_sdio_driver macro which is a convenience
macro for SDIO driver modules similar to module_usb_driver. It is intended
to be used by drivers which init/exit section does nothing but register/
unregister the SDIO driver. By using this macro it is possible to eliminate
a few lines of boilerplate code per SDIO driver.

Suggested-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Acked-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>


# 5ef1ecf0 29-Mar-2017 Heiner Kallweit <hkallweit1@gmail.com>

mmc: sdio: fix alignment issue in struct sdio_func

Certain 64-bit systems (e.g. Amlogic Meson GX) require buffers to be
used for DMA to be 8-byte-aligned. struct sdio_func has an embedded
small DMA buffer not meeting this requirement.
When testing switching to descriptor chain mode in meson-gx driver
SDIO is broken therefore. Fix this by allocating the small DMA buffer
separately as kmalloc ensures that the returned memory area is
properly aligned for every basic data type.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Tested-by: Helmut Klein <hgkr.klein@gmail.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>


# 433b7b12 06-Oct-2014 Ulf Hansson <ulf.hansson@linaro.org>

mmc: core: Don't export the to_sdio_driver macro

The macro is only used by the mmc core, so let's move it in there.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>


# 100e9186 27-May-2011 Robert P. J. Day <rpjday@crashcourse.ca>

mmc: Standardize header file inclusion checks.

Standardize the checks for multiple MMC header file inclusion,
including adding comments to terminating #endif's, and fixing
one incorrect comment.

Signed-off-by: Robert P. J. Day <rpjday@crashcourse.ca>
Signed-off-by: Chris Ball <cjb@laptop.org>


# 6c1f716e 26-May-2010 Grazvydas Ignotas <notasas@gmail.com>

sdio: add new function for RAW (Read after Write) operation

SDIO specification allows RAW (Read after Write) operation using
IO_RW_DIRECT command (CMD52) by setting the RAW bit. This operation is
similar to ordinary read/write commands, except that both write and read
are performed using single command/response pair. The Linux SDIO layer
already supports this internaly, only external function is missing for
drivers to make use, which is added by this patch.

This type of command is required to implement proper power save mode
support in wl1251 wifi driver.

Android has similar patch for G1 in it's tree for the same reason:

http://android.git.kernel.org/?p=kernel/common.git;a=commitdiff;h=74a47786f6ecbe6c1cf9fb15efe6a968451deb52

Signed-off-by: Grazvydas Ignotas <notasas@gmail.com>
Acked-by: Kalle Valo <kalle.valo@iki.fi>
Cc: Dmitry Shmidt <dimitrysh@google.com>
Cc: <linux-mmc@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# da68c4eb 05-Mar-2010 Nicolas Pitre <nico@fluxnic.net>

sdio: introduce API for special power management features

This patch series provides the core changes needed to allow SDIO cards to
remain powered and active while the host system is suspended, and let them
wake up the host system when needed. This is used to implement
wake-on-lan with SDIO wireless cards at the moment. Patches to add that
support to the libertas driver will be posted separately.

This patch:

Some SDIO cards have the ability to keep on running autonomously when the
host system is suspended, and wake it up when needed. This however
requires that the host controller preserve power to the card, and
configure itself appropriately for wake-up.

There is however 4 layers of abstractions involved: the host controller
driver, the MMC core code, the SDIO card management code, and the actual
SDIO function driver. To make things simple and manageable, host drivers
must advertise their PM capabilities with a feature bitmask, then function
drivers can query and set those features from their suspend method. Then
each layer in the suspend call chain is expected to act upon those bits
accordingly.

[akpm@linux-foundation.org: fix typo in comment]
Signed-off-by: Nicolas Pitre <nico@marvell.com>
Cc: <linux-mmc@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 996ad568 22-Sep-2009 Nicolas Pitre <nico@fluxnic.net>

mmc: make SDIO device/driver struct accessors public

Especially with the PM framework, those are quite handy to have in driver
code too.

Signed-off-by: Nicolas Pitre <nico@marvell.com>
Cc: <linux-mmc@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# d1b26863 08-Nov-2008 Kay Sievers <kay.sievers@vrfy.org>

mmc: struct device - replace bus_id with dev_name(), dev_set_name()

Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-Off-By: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>


# 62a7573e 09-Jul-2008 Benzi Zbit <benzi.zbit@intel.com>

sdio: fix the use of hard coded timeout value.

This adds reading and using of enable_timeout from the CIS

Signed-off-by: Benzi Zbit <benzi.zbit@intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>


# 6d373331 30-Jun-2008 Tomas Winkler <tomas.winkler@intel.com>

mmc: fix sdio_io sparse errors

This patch fixes sdio_io sparse errors.
This fix changes signature of API functions,
changing
unsigned char -> u8
unsigned short -> u16
unsigned long -> u32 - this was probably a bug in 64 bit platforms

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>


# ad3868b2 27-Jun-2008 Pierre Ossman <drzeus@drzeus.cx>

mmc,sdio: helper function for transfer padding

There are a lot of crappy controllers out there that cannot handle
all the request sizes that the MMC/SD/SDIO specifications require.
In case the card driver can pad the data to overcome the problems,
this commit adds a helper that calculates how much that padding
should be.

A corresponding helper is also added for SDIO, but it can also deal
with all the complexities of splitting up a large transfer efficiently.

Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>


# 759bdc7a 19-Sep-2007 Pierre Ossman <drzeus@drzeus.cx>

sdio: store vendor strings

Store vendor strings found in CISTPL_VERS_1 so that function drivers
can access them.

Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>


# 7806cdb4 10-Aug-2007 David Vrabel <david.vrabel@csr.com>

sdio: add sdio_f0_readb() and sdio_f0_writeb()

Add sdio_f0_readb() and sdio_f0_writeb() functions to reading and
writing function 0 registers. Writes outside the vendor specific CCCR
registers (0xF0 - 0xFF) are not permitted.

Signed-off-by: David Vrabel <david.vrabel@csr.com>
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>


# 9a08f82b 08-Aug-2007 David Vrabel <david.vrabel@csr.com>

sdio: set the functions' block size

Before a driver is probed, set the function's block size to the default so the
driver is sure the block size is something sensible and it needn't explicitly
set it.

The default block size is the largest that's supported by both the card and
the host, with a maximum of 512 to ensure aribitrarily sized transfer use the
optimal (least) number of commands.

See http://lkml.org/lkml/2007/8/7/150 for reasons for the block size choice.

Signed-off-by: David Vrabel <david.vrabel@csr.com>
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>


# 112c9db9 06-Jul-2007 Pierre Ossman <drzeus@drzeus.cx>

sdio: support IO_RW_EXTENDED

Support the multi-byte transfer operation, including handlers for
common operations like writel()/readl().

Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>


# d1496c39 30-Jun-2007 Nicolas Pitre <nico@cam.org>

sdio: core support for SDIO function interrupt

Signed-off-by: Nicolas Pitre <npitre@mvista.com>
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>


# 3b38bea0 16-Jun-2007 Pierre Ossman <drzeus@drzeus.cx>

sdio: add device id table and matching

Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>


# 1a632f8c 30-Jul-2007 Pierre Ossman <drzeus@drzeus.cx>

sdio: split up common and function CIS parsing

Add a more clean separation between global, common CIS information
and the function specific one as we need the common information in
places where no specific function is specified.

Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>


# b1538bcf 16-Jun-2007 Nicolas Pitre <nico@cam.org>

sdio: link unknown CIS tuples to the sdio_func structure

This way those tuples that the core cares about are consumed by the core
code, and tuples that only function drivers might make sense of are
available to drivers.

Signed-off-by: Nicolas Pitre <npitre@mvista.com>
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>


# 0597007f 11-Jun-2007 Pierre Ossman <drzeus@drzeus.cx>

sdio: basic parsing of FBR

Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>


# fa64efa1 27-May-2007 Pierre Ossman <drzeus@drzeus.cx>

mmc: enable/disable functions for SDIO

Like many other buses, the devices (functions) on the SDIO bus
must be enabled before they can be used. Add functions that allow
drivers to do so.

Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>


# 46f555f2 26-May-2007 Pierre Ossman <drzeus@drzeus.cx>

mmc: add basic SDIO I/O operations

Add command wrappers that simplify register access from SDIO
function drivers.

Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>


# f76c8515 26-May-2007 Pierre Ossman <drzeus@drzeus.cx>

mmc: add SDIO driver handling

Add basic driver handling to the SDIO device model.

Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>


# e29a7d73 26-May-2007 Pierre Ossman <drzeus@drzeus.cx>

mmc: basic SDIO device model

Add the sdio bus type and basic device handling.

Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>