Skip to content

Commit

Permalink
Merge tag 'mmc-v5.18' of git://git.kernel.org/pub/scm/linux/kernel/gi…
Browse files Browse the repository at this point in the history
…t/ulfh/mmc

Pull MMC updates from Ulf Hansson:
 "MMC core:
   - Convert to sysfs_emit() in favor of sprintf()

   - Improve fallback to speed modes if eMMC HS200 fails

  MMC host:
   - dw_mmc: Allow variants to set minimal supported clock rate

   - dw-mmc-rockchip: Fix problems with invalid clock rates

   - litex_mmc: Add new DT based driver for the LiteX's LiteSDCard
     interface

   - litex_mmc: Add Gabriel Somlo and Joel Stanley as co-maintainers for
     LiteX

   - mtk-sd: Add support for the Mediatek MT8186 variant

   - renesas_sdhi: Add support for RZ/G2UL variant

   - renesas_sdhi: Add support for RZ/V2L variant

   - rtsx_pci: Adjust power-on sequence to conform to the SD spec

   - sdhci-am654: Add support for TI's AM62 variant

   - sdhci_am654: Fixup support for TI's AM64 variant

   - sdhci-esdhc-imx: Add support for the imx93 variant

   - sdhci-msm: Add support for the msm8953 variant

   - sdhci-pci-gli: Add support for runtime PM for the GL9763E variant

   - sdhci-pci-gli: Adjustments of the SSC function for the GL975x
     variants

   - sdhci-tegra: Add support for wake on SD card event

   - sunxi-mmc: Add support for Allwinner's F1c100s variant

   - sunxi-mmc: Add support for D1 MMC variant"

* tag 'mmc-v5.18' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc: (37 commits)
  dt-bindings: mmc: renesas,sdhi: Document RZ/G2UL SoC
  mmc: tmio: remove outdated members from host struct
  mmc: mtk-sd: Silence delay phase calculation debug log
  mmc: davinci_mmc: Handle error for clk_enable
  mmc: sdhci-pci-gli: Add runtime PM for GL9763E
  mmc: core: Drop HS400 caps unless 8-bit bus is supported too
  mmc: host: Return an error when ->enable_sdio_irq() ops is missing
  mmc: core: Improve fallback to speed modes if eMMC HS200 fails
  dt-bindings: mmc: sunxi: add Allwinner F1c100s compatible
  mmc: dw-mmc-rockchip: Fix handling invalid clock rates
  mmc: dw_mmc: Support setting f_min from host drivers
  mmc: host: Drop commas after SoC match table sentinels
  mmc: rtsx: add 74 Clocks in power on flow
  dt-bindings: mmc: renesas,sdhi: Document RZ/V2L SoC
  mmc: sh_mmcif: Simplify division/shift logic
  mmc: sdhci_am654: Add Support for TI's AM62 SoC
  dt-bindings: mmc: imx-esdhc: Add imx93 compatible string
  dt-bindings: mmc: sdhci-am654: Add compatible string for AM62 SoC
  mmc: sdhci_am654: Fix the driver data of AM64 SoC
  mmc: core: use sysfs_emit() instead of sprintf()
  ...
  • Loading branch information
torvalds committed Mar 23, 2022
2 parents c7d4b15 + dc3d879 commit 5bebe2c
Show file tree
Hide file tree
Showing 34 changed files with 1,076 additions and 123 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ properties:
- const: allwinner,sun7i-a20-mmc
- const: allwinner,sun8i-a83t-emmc
- const: allwinner,sun9i-a80-mmc
- const: allwinner,sun20i-d1-mmc
- const: allwinner,sun50i-a64-emmc
- const: allwinner,sun50i-a64-mmc
- const: allwinner,sun50i-a100-emmc
Expand All @@ -49,12 +50,18 @@ properties:
- items:
- const: allwinner,sun50i-h6-mmc
- const: allwinner,sun50i-a64-mmc
- items:
- const: allwinner,sun20i-d1-emmc
- const: allwinner,sun50i-a100-emmc
- items:
- const: allwinner,sun50i-h616-emmc
- const: allwinner,sun50i-a100-emmc
- items:
- const: allwinner,sun50i-h616-mmc
- const: allwinner,sun50i-a100-mmc
- items:
- const: allwinner,suniv-f1c100s-mmc
- const: allwinner,sun7i-a20-mmc

reg:
maxItems: 1
Expand Down
1 change: 1 addition & 0 deletions Documentation/devicetree/bindings/mmc/fsl-imx-esdhc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ properties:
- const: fsl,imx7d-usdhc
- items:
- enum:
- fsl,imx93-usdhc
- fsl,imx8ulp-usdhc
- const: fsl,imx8mm-usdhc

Expand Down
78 changes: 78 additions & 0 deletions Documentation/devicetree/bindings/mmc/litex,mmc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# SPDX-License-Identifier: GPL-2.0-or-later OR BSD-2-Clause
%YAML 1.2
---
$id: http://devicetree.org/schemas/mmc/litex,mmc.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: LiteX LiteSDCard device

maintainers:
- Gabriel Somlo <gsomlo@gmail.com>

description: |
LiteSDCard is a small footprint, configurable SDCard core for FPGA based
system on chips.
The hardware source is Open Source and can be found on at
https://github.com/enjoy-digital/litesdcard/.
allOf:
- $ref: mmc-controller.yaml#

properties:
compatible:
const: litex,mmc

reg:
items:
- description: PHY registers
- description: CORE registers
- description: DMA Reader buffer
- description: DMA Writer buffer
- description: IRQ registers
minItems: 4

reg-names:
items:
- const: phy
- const: core
- const: reader
- const: writer
- const: irq
minItems: 4

clocks:
maxItems: 1
description:
Handle to reference clock.

vmmc-supply:
description:
Handle to fixed-voltage supply for the card power.

interrupts:
maxItems: 1

required:
- compatible
- reg
- reg-names
- clocks
- vmmc-supply

additionalProperties: false

examples:
- |
mmc: mmc@12005000 {
compatible = "litex,mmc";
reg = <0x12005000 0x100>,
<0x12003800 0x100>,
<0x12003000 0x100>,
<0x12004800 0x100>,
<0x12004000 0x100>;
reg-names = "phy", "core", "reader", "writer", "irq";
clocks = <&reference_clk>;
vmmc-supply = <&vreg_mmc>;
interrupts = <4>;
};
3 changes: 3 additions & 0 deletions Documentation/devicetree/bindings/mmc/mtk-sd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ properties:
- items:
- const: mediatek,mt7623-mmc
- const: mediatek,mt2701-mmc
- items:
- const: mediatek,mt8186-mmc
- const: mediatek,mt8183-mmc
- items:
- const: mediatek,mt8192-mmc
- const: mediatek,mt8183-mmc
Expand Down
7 changes: 6 additions & 1 deletion Documentation/devicetree/bindings/mmc/renesas,sdhi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ properties:
- renesas,sdhi-r8a77990 # R-Car E3
- renesas,sdhi-r8a77995 # R-Car D3
- renesas,sdhi-r8a779a0 # R-Car V3U
- renesas,sdhi-r9a07g043 # RZ/G2UL
- renesas,sdhi-r9a07g044 # RZ/G2{L,LC}
- renesas,sdhi-r9a07g054 # RZ/V2L
- const: renesas,rcar-gen3-sdhi # R-Car Gen3 or RZ/G2

reg:
Expand Down Expand Up @@ -107,7 +109,10 @@ allOf:
properties:
compatible:
contains:
const: renesas,sdhi-r9a07g044
enum:
- renesas,sdhi-r9a07g043
- renesas,sdhi-r9a07g044
- renesas,sdhi-r9a07g054
then:
properties:
clocks:
Expand Down
1 change: 1 addition & 0 deletions Documentation/devicetree/bindings/mmc/sdhci-am654.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ properties:
- const: ti,j721e-sdhci-4bit
- const: ti,am64-sdhci-8bit
- const: ti,am64-sdhci-4bit
- const: ti,am62-sdhci
- items:
- const: ti,j7200-sdhci-8bit
- const: ti,j721e-sdhci-8bit
Expand Down
1 change: 1 addition & 0 deletions Documentation/devicetree/bindings/mmc/sdhci-msm.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Required properties:
full compatible strings with SoC and version:
"qcom,apq8084-sdhci", "qcom,sdhci-msm-v4"
"qcom,msm8226-sdhci", "qcom,sdhci-msm-v4"
"qcom,msm8953-sdhci", "qcom,sdhci-msm-v4"
"qcom,msm8974-sdhci", "qcom,sdhci-msm-v4"
"qcom,msm8916-sdhci", "qcom,sdhci-msm-v4"
"qcom,msm8992-sdhci", "qcom,sdhci-msm-v4"
Expand Down
9 changes: 7 additions & 2 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -11158,12 +11158,17 @@ F: lib/list-test.c
LITEX PLATFORM
M: Karol Gugala <kgugala@antmicro.com>
M: Mateusz Holenko <mholenko@antmicro.com>
M: Gabriel Somlo <gsomlo@gmail.com>
M: Joel Stanley <joel@jms.id.au>
S: Maintained
F: Documentation/devicetree/bindings/*/litex,*.yaml
F: arch/openrisc/boot/dts/or1klitex.dts
F: drivers/soc/litex/litex_soc_ctrl.c
F: drivers/tty/serial/liteuart.c
F: include/linux/litex.h
F: drivers/tty/serial/liteuart.c
F: drivers/soc/litex/*
F: drivers/net/ethernet/litex/*
F: drivers/mmc/host/litex_mmc.c
N: litex

LIVE PATCHING
M: Josh Poimboeuf <jpoimboe@redhat.com>
Expand Down
9 changes: 5 additions & 4 deletions drivers/mmc/core/bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <linux/stat.h>
#include <linux/of.h>
#include <linux/pm_runtime.h>
#include <linux/sysfs.h>

#include <linux/mmc/card.h>
#include <linux/mmc/host.h>
Expand All @@ -34,13 +35,13 @@ static ssize_t type_show(struct device *dev,

switch (card->type) {
case MMC_TYPE_MMC:
return sprintf(buf, "MMC\n");
return sysfs_emit(buf, "MMC\n");
case MMC_TYPE_SD:
return sprintf(buf, "SD\n");
return sysfs_emit(buf, "SD\n");
case MMC_TYPE_SDIO:
return sprintf(buf, "SDIO\n");
return sysfs_emit(buf, "SDIO\n");
case MMC_TYPE_SD_COMBO:
return sprintf(buf, "SDcombo\n");
return sysfs_emit(buf, "SDcombo\n");
default:
return -EFAULT;
}
Expand Down
3 changes: 2 additions & 1 deletion drivers/mmc/core/bus.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#define _MMC_CORE_BUS_H

#include <linux/device.h>
#include <linux/sysfs.h>

struct mmc_host;
struct mmc_card;
Expand All @@ -17,7 +18,7 @@ struct mmc_card;
static ssize_t mmc_##name##_show (struct device *dev, struct device_attribute *attr, char *buf) \
{ \
struct mmc_card *card = mmc_dev_to_card(dev); \
return sprintf(buf, fmt, args); \
return sysfs_emit(buf, fmt, args); \
} \
static DEVICE_ATTR(name, S_IRUGO, mmc_##name##_show, NULL)

Expand Down
24 changes: 22 additions & 2 deletions drivers/mmc/core/host.c
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,25 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev)

EXPORT_SYMBOL(mmc_alloc_host);

static int mmc_validate_host_caps(struct mmc_host *host)
{
struct device *dev = host->parent;
u32 caps = host->caps, caps2 = host->caps2;

if (caps & MMC_CAP_SDIO_IRQ && !host->ops->enable_sdio_irq) {
dev_warn(dev, "missing ->enable_sdio_irq() ops\n");
return -EINVAL;
}

if (caps2 & (MMC_CAP2_HS400_ES | MMC_CAP2_HS400) &&
!(caps & MMC_CAP_8_BIT_DATA)) {
dev_warn(dev, "drop HS400 support since no 8-bit bus\n");
host->caps2 = caps2 & ~MMC_CAP2_HS400_ES & ~MMC_CAP2_HS400;
}

return 0;
}

/**
* mmc_add_host - initialise host hardware
* @host: mmc host
Expand All @@ -600,8 +619,9 @@ int mmc_add_host(struct mmc_host *host)
{
int err;

WARN_ON((host->caps & MMC_CAP_SDIO_IRQ) &&
!host->ops->enable_sdio_irq);
err = mmc_validate_host_caps(host);
if (err)
return err;

err = device_add(&host->class_dev);
if (err)
Expand Down
37 changes: 21 additions & 16 deletions drivers/mmc/core/mmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <linux/slab.h>
#include <linux/stat.h>
#include <linux/pm_runtime.h>
#include <linux/sysfs.h>

#include <linux/mmc/host.h>
#include <linux/mmc/card.h>
Expand Down Expand Up @@ -812,12 +813,11 @@ static ssize_t mmc_fwrev_show(struct device *dev,
{
struct mmc_card *card = mmc_dev_to_card(dev);

if (card->ext_csd.rev < 7) {
return sprintf(buf, "0x%x\n", card->cid.fwrev);
} else {
return sprintf(buf, "0x%*phN\n", MMC_FIRMWARE_LEN,
card->ext_csd.fwrev);
}
if (card->ext_csd.rev < 7)
return sysfs_emit(buf, "0x%x\n", card->cid.fwrev);
else
return sysfs_emit(buf, "0x%*phN\n", MMC_FIRMWARE_LEN,
card->ext_csd.fwrev);
}

static DEVICE_ATTR(fwrev, S_IRUGO, mmc_fwrev_show, NULL);
Expand All @@ -830,10 +830,10 @@ static ssize_t mmc_dsr_show(struct device *dev,
struct mmc_host *host = card->host;

if (card->csd.dsr_imp && host->dsr_req)
return sprintf(buf, "0x%x\n", host->dsr);
return sysfs_emit(buf, "0x%x\n", host->dsr);
else
/* return default DSR value */
return sprintf(buf, "0x%x\n", 0x404);
return sysfs_emit(buf, "0x%x\n", 0x404);
}

static DEVICE_ATTR(dsr, S_IRUGO, mmc_dsr_show, NULL);
Expand Down Expand Up @@ -1355,11 +1355,6 @@ static int mmc_select_hs400es(struct mmc_card *card)
int err = -EINVAL;
u8 val;

if (!(host->caps & MMC_CAP_8_BIT_DATA)) {
err = -ENOTSUPP;
goto out_err;
}

if (card->mmc_avail_type & EXT_CSD_CARD_TYPE_HS400_1_2V)
err = mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_120);

Expand Down Expand Up @@ -1523,13 +1518,23 @@ static int mmc_select_timing(struct mmc_card *card)
if (!mmc_can_ext_csd(card))
goto bus_speed;

if (card->mmc_avail_type & EXT_CSD_CARD_TYPE_HS400ES)
if (card->mmc_avail_type & EXT_CSD_CARD_TYPE_HS400ES) {
err = mmc_select_hs400es(card);
else if (card->mmc_avail_type & EXT_CSD_CARD_TYPE_HS200)
goto out;
}

if (card->mmc_avail_type & EXT_CSD_CARD_TYPE_HS200) {
err = mmc_select_hs200(card);
else if (card->mmc_avail_type & EXT_CSD_CARD_TYPE_HS)
if (err == -EBADMSG)
card->mmc_avail_type &= ~EXT_CSD_CARD_TYPE_HS200;
else
goto out;
}

if (card->mmc_avail_type & EXT_CSD_CARD_TYPE_HS)
err = mmc_select_hs(card);

out:
if (err && err != -EBADMSG)
return err;

Expand Down
25 changes: 12 additions & 13 deletions drivers/mmc/core/sd.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <linux/stat.h>
#include <linux/pm_runtime.h>
#include <linux/scatterlist.h>
#include <linux/sysfs.h>

#include <linux/mmc/host.h>
#include <linux/mmc/card.h>
Expand Down Expand Up @@ -708,18 +709,16 @@ MMC_DEV_ATTR(ocr, "0x%08x\n", card->ocr);
MMC_DEV_ATTR(rca, "0x%04x\n", card->rca);


static ssize_t mmc_dsr_show(struct device *dev,
struct device_attribute *attr,
char *buf)
static ssize_t mmc_dsr_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct mmc_card *card = mmc_dev_to_card(dev);
struct mmc_host *host = card->host;

if (card->csd.dsr_imp && host->dsr_req)
return sprintf(buf, "0x%x\n", host->dsr);
else
/* return default DSR value */
return sprintf(buf, "0x%x\n", 0x404);
struct mmc_card *card = mmc_dev_to_card(dev);
struct mmc_host *host = card->host;

if (card->csd.dsr_imp && host->dsr_req)
return sysfs_emit(buf, "0x%x\n", host->dsr);
/* return default DSR value */
return sysfs_emit(buf, "0x%x\n", 0x404);
}

static DEVICE_ATTR(dsr, S_IRUGO, mmc_dsr_show, NULL);
Expand All @@ -735,9 +734,9 @@ static ssize_t info##num##_show(struct device *dev, struct device_attribute *att
\
if (num > card->num_info) \
return -ENODATA; \
if (!card->info[num-1][0]) \
if (!card->info[num - 1][0]) \
return 0; \
return sprintf(buf, "%s\n", card->info[num-1]); \
return sysfs_emit(buf, "%s\n", card->info[num - 1]); \
} \
static DEVICE_ATTR_RO(info##num)

Expand Down
Loading

0 comments on commit 5bebe2c

Please sign in to comment.