Skip to content

Commit

Permalink
Merge tag 'mmc-v6.13' 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:
   - Add support for Ultra Capacity SD cards (SDUC, 2TB to 128TB)
   - Add support for Ultra High-Speed II SD cards (UHS-II)
   - Use a reset control for pwrseq_simple
   - Add SD card quirk for broken poweroff notification
   - Use GFP_NOIO for SD ACMD22

  MMC host:
   - bcm2835: Introduce proper clock handling
   - mtk-sd: Add support for the Host-Software-Queue interface
   - mtk-sd: Add support for the mt7988/mt8196 variants
   - mtk-sd: Fix a couple of error paths in ->probe()
   - sdhci: Add interface to support UHS-II SD cards
   - sdhci_am654: Fixup support for changing the signal voltage level
   - sdhci-cadence: Add support for the Microchip PIC64GX variant
   - sdhci-esdhc-imx: Add support for eMMC HW-reset
   - sdhci-msm: Add support for the X1E80100/IPQ5424/SAR2130P/QCS615 variants
   - sdhci-of-arasan: Add support for eMMC HW-reset
   - sdhci-pci-gli: Add UHS-II support for the GL9767/GL9755 variants

  MEMSTICK:
   - A couple of minor updates"

* tag 'mmc-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc: (78 commits)
  mmc: pwrseq_simple: Handle !RESET_CONTROLLER properly
  mmc: mtk-sd: Fix MMC_CAP2_CRYPTO flag setting
  mmc: mtk-sd: Fix error handle of probe function
  mmc: core: Correction a warning caused by incorrect type in assignment for UHS-II
  mmc: sdhci-esdhc-imx: Update esdhc sysctl dtocv bitmask
  mmc: sdhci-esdhc-imx: Implement emmc hardware reset
  mmc: core: Correct type in variable assignment for UHS-II
  mmc: sdhci-uhs2: correction a warning caused by incorrect type in argument
  mmc: sdhci-uhs2: Remove unnecessary variables
  mmc: sdhci-uhs2: Correct incorrect type in argument
  mmc: sdhci: Make MMC_SDHCI_UHS2 config symbol invisible
  mmc: sdhci-uhs2: Remove unnecessary NULL check
  mmc: core: Fix error paths for UHS-II card init and re-init
  mmc: core: Add error handling of sd_uhs2_power_up()
  mmc: core: Simplify sd_uhs2_power_up()
  mmc: bcm2835: Introduce proper clock handling
  mmc: bcm2835: Fix type of current clock speed
  dt-bindings: mmc: Add sdhci compatible for QCS615
  mmc: core: Use GFP_NOIO in ACMD22
  dt-bindings: mmc: sdhci-msm: Add SAR2130P compatible
  ...
  • Loading branch information
torvalds committed Nov 20, 2024
2 parents 75f2b37 + c0baf6e commit 3855629
Show file tree
Hide file tree
Showing 116 changed files with 4,580 additions and 398 deletions.
3 changes: 2 additions & 1 deletion Documentation/devicetree/bindings/mmc/cdns,sdhci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ properties:
- enum:
- amd,pensando-elba-sd4hc
- microchip,mpfs-sd4hc
- microchip,pic64gx-sd4hc
- socionext,uniphier-sd4hc
- const: cdns,sd4hc

Expand Down Expand Up @@ -120,7 +121,7 @@ required:
- clocks

allOf:
- $ref: mmc-controller.yaml
- $ref: sdhci-common.yaml
- if:
properties:
compatible:
Expand Down
24 changes: 24 additions & 0 deletions Documentation/devicetree/bindings/mmc/mtk-sd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ properties:
- mediatek,mt7620-mmc
- mediatek,mt7622-mmc
- mediatek,mt7986-mmc
- mediatek,mt7988-mmc
- mediatek,mt8135-mmc
- mediatek,mt8173-mmc
- mediatek,mt8183-mmc
- mediatek,mt8196-mmc
- mediatek,mt8516-mmc
- items:
- const: mediatek,mt7623-mmc
Expand Down Expand Up @@ -190,6 +192,7 @@ allOf:
- mediatek,mt8186-mmc
- mediatek,mt8188-mmc
- mediatek,mt8195-mmc
- mediatek,mt8196-mmc
- mediatek,mt8516-mmc
then:
properties:
Expand Down Expand Up @@ -263,6 +266,27 @@ allOf:
- const: bus_clk
- const: sys_cg

- if:
properties:
compatible:
contains:
enum:
- mediatek,mt7988-mmc
then:
properties:
clocks:
items:
- description: source clock
- description: HCLK which used for host
- description: Advanced eXtensible Interface
- description: Advanced High-performance Bus clock
clock-names:
items:
- const: source
- const: hclk
- const: axi_cg
- const: ahb_cg

- if:
properties:
compatible:
Expand Down
4 changes: 4 additions & 0 deletions Documentation/devicetree/bindings/mmc/sdhci-msm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,14 @@ properties:
- enum:
- qcom,ipq5018-sdhci
- qcom,ipq5332-sdhci
- qcom,ipq5424-sdhci
- qcom,ipq6018-sdhci
- qcom,ipq9574-sdhci
- qcom,qcm2290-sdhci
- qcom,qcs404-sdhci
- qcom,qcs615-sdhci
- qcom,qdu1000-sdhci
- qcom,sar2130p-sdhci
- qcom,sc7180-sdhci
- qcom,sc7280-sdhci
- qcom,sc8280xp-sdhci
Expand All @@ -62,6 +65,7 @@ properties:
- qcom,sm8450-sdhci
- qcom,sm8550-sdhci
- qcom,sm8650-sdhci
- qcom,x1e80100-sdhci
- const: qcom,sdhci-msm-v5 # for sdcc version 5.0

reg:
Expand Down
4 changes: 2 additions & 2 deletions drivers/memstick/core/memstick.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ static DEFINE_IDR(memstick_host_idr);
static DEFINE_SPINLOCK(memstick_host_lock);

static int memstick_dev_match(struct memstick_dev *card,
struct memstick_device_id *id)
const struct memstick_device_id *id)
{
if (id->match_flags & MEMSTICK_MATCH_ALL) {
if ((id->type == card->id.type)
Expand All @@ -44,7 +44,7 @@ static int memstick_bus_match(struct device *dev, const struct device_driver *dr
dev);
const struct memstick_driver *ms_drv = container_of_const(drv, struct memstick_driver,
driver);
struct memstick_device_id *ids = ms_drv->id_table;
const struct memstick_device_id *ids = ms_drv->id_table;

if (ids) {
while (ids->match_flags) {
Expand Down
8 changes: 4 additions & 4 deletions drivers/memstick/core/ms_block.c
Original file line number Diff line number Diff line change
Expand Up @@ -996,7 +996,7 @@ static int msb_verify_block(struct msb_data *msb, u16 pba,
return 0;
}

/* Writes exectly one block + oob */
/* Writes exactly one block + oob */
static int msb_write_block(struct msb_data *msb,
u16 pba, u32 lba, struct scatterlist *sg, int offset)
{
Expand Down Expand Up @@ -1684,7 +1684,7 @@ static int msb_cache_read(struct msb_data *msb, int lba,
*/

static const struct chs_entry chs_table[] = {
/* size sectors cylynders heads */
/* size sectors cylinders heads */
{ 4, 16, 247, 2 },
{ 8, 16, 495, 2 },
{ 16, 16, 495, 4 },
Expand Down Expand Up @@ -1729,7 +1729,7 @@ static int msb_init_card(struct memstick_dev *card)

boot_block = &msb->boot_page[0];

/* Save intersting attributes from boot page */
/* Save interesting attributes from boot page */
msb->block_count = boot_block->attr.number_of_blocks;
msb->page_size = boot_block->attr.page_size;

Expand Down Expand Up @@ -2279,7 +2279,7 @@ static int msb_resume(struct memstick_dev *card)

#endif /* CONFIG_PM */

static struct memstick_device_id msb_id_tbl[] = {
static const struct memstick_device_id msb_id_tbl[] = {
{MEMSTICK_MATCH_ALL, MEMSTICK_TYPE_LEGACY, MEMSTICK_CATEGORY_STORAGE,
MEMSTICK_CLASS_FLASH},

Expand Down
2 changes: 1 addition & 1 deletion drivers/memstick/core/mspro_block.c
Original file line number Diff line number Diff line change
Expand Up @@ -1349,7 +1349,7 @@ static int mspro_block_resume(struct memstick_dev *card)

#endif /* CONFIG_PM */

static struct memstick_device_id mspro_block_id_tbl[] = {
static const struct memstick_device_id mspro_block_id_tbl[] = {
{MEMSTICK_MATCH_ALL, MEMSTICK_TYPE_PRO, MEMSTICK_CATEGORY_STORAGE_DUO,
MEMSTICK_CLASS_DUO},
{}
Expand Down
2 changes: 1 addition & 1 deletion drivers/memstick/host/r592.c
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ static irqreturn_t r592_irq(int irq, void *data)
return ret;
}

/* External inteface: set settings */
/* External interface: set settings */
static int r592_set_param(struct memstick_host *host,
enum memstick_param param, int value)
{
Expand Down
2 changes: 1 addition & 1 deletion drivers/mmc/core/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ obj-$(CONFIG_MMC) += mmc_core.o
mmc_core-y := core.o bus.o host.o \
mmc.o mmc_ops.o sd.o sd_ops.o \
sdio.o sdio_ops.o sdio_bus.o \
sdio_cis.o sdio_io.o sdio_irq.o \
sdio_cis.o sdio_io.o sdio_irq.o sd_uhs2.o\
slot-gpio.o regulator.o
mmc_core-$(CONFIG_OF) += pwrseq.o
obj-$(CONFIG_PWRSEQ_SIMPLE) += pwrseq_simple.o
Expand Down
39 changes: 31 additions & 8 deletions drivers/mmc/core/block.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
#include <linux/mmc/sd.h>

#include <linux/uaccess.h>
#include <linux/unaligned.h>

#include "queue.h"
#include "block.h"
Expand Down Expand Up @@ -993,11 +994,12 @@ static int mmc_sd_num_wr_blocks(struct mmc_card *card, u32 *written_blocks)
int err;
u32 result;
__be32 *blocks;
u8 resp_sz = mmc_card_ult_capacity(card) ? 8 : 4;
unsigned int noio_flag;

struct mmc_request mrq = {};
struct mmc_command cmd = {};
struct mmc_data data = {};

struct scatterlist sg;

err = mmc_app_cmd(card->host, card);
Expand All @@ -1008,7 +1010,7 @@ static int mmc_sd_num_wr_blocks(struct mmc_card *card, u32 *written_blocks)
cmd.arg = 0;
cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_ADTC;

data.blksz = 4;
data.blksz = resp_sz;
data.blocks = 1;
data.flags = MMC_DATA_READ;
data.sg = &sg;
Expand All @@ -1018,15 +1020,29 @@ static int mmc_sd_num_wr_blocks(struct mmc_card *card, u32 *written_blocks)
mrq.cmd = &cmd;
mrq.data = &data;

blocks = kmalloc(4, GFP_KERNEL);
noio_flag = memalloc_noio_save();
blocks = kmalloc(resp_sz, GFP_KERNEL);
memalloc_noio_restore(noio_flag);
if (!blocks)
return -ENOMEM;

sg_init_one(&sg, blocks, 4);
sg_init_one(&sg, blocks, resp_sz);

mmc_wait_for_req(card->host, &mrq);

result = ntohl(*blocks);
if (mmc_card_ult_capacity(card)) {
/*
* Normally, ACMD22 returns the number of written sectors as
* u32. SDUC, however, returns it as u64. This is not a
* superfluous requirement, because SDUC writes may exceed 2TB.
* For Linux mmc however, the previously write operation could
* not be more than the block layer limits, thus just make room
* for a u64 and cast the response back to u32.
*/
result = clamp_val(get_unaligned_be64(blocks), 0, UINT_MAX);
} else {
result = ntohl(*blocks);
}
kfree(blocks);

if (cmd.error || data.error)
Expand Down Expand Up @@ -1199,7 +1215,8 @@ static void mmc_blk_issue_erase_rq(struct mmc_queue *mq, struct request *req,
{
struct mmc_blk_data *md = mq->blkdata;
struct mmc_card *card = md->queue.card;
unsigned int from, nr;
unsigned int nr;
sector_t from;
int err = 0;
blk_status_t status = BLK_STS_OK;

Expand Down Expand Up @@ -1254,7 +1271,8 @@ static void mmc_blk_issue_secdiscard_rq(struct mmc_queue *mq,
{
struct mmc_blk_data *md = mq->blkdata;
struct mmc_card *card = md->queue.card;
unsigned int from, nr, arg;
unsigned int nr, arg;
sector_t from;
int err = 0, type = MMC_BLK_SECDISCARD;
blk_status_t status = BLK_STS_OK;

Expand Down Expand Up @@ -1759,6 +1777,11 @@ static void mmc_blk_rw_rq_prep(struct mmc_queue_req *mqrq,
brq->sbc.flags = MMC_RSP_R1 | MMC_CMD_AC;
brq->mrq.sbc = &brq->sbc;
}

if (mmc_card_ult_capacity(card)) {
brq->cmd.ext_addr = blk_rq_pos(req) >> 32;
brq->cmd.has_ext_addr = true;
}
}

#define MMC_MAX_RETRIES 5
Expand Down Expand Up @@ -2598,7 +2621,7 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card,
if (mmc_host_cmd23(card->host)) {
if ((mmc_card_mmc(card) &&
card->csd.mmca_vsn >= CSD_SPEC_VER_3) ||
(mmc_card_sd(card) &&
(mmc_card_sd(card) && !mmc_card_ult_capacity(card) &&
card->scr.cmds & SD_SCR_CMD23_SUPPORT))
md->flags |= MMC_BLK_CMD23;
}
Expand Down
42 changes: 25 additions & 17 deletions drivers/mmc/core/bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ int mmc_add_card(struct mmc_card *card)
{
int ret;
const char *type;
const char *speed_mode = "";
const char *uhs_bus_speed_mode = "";
static const char *const uhs_speeds[] = {
[UHS_SDR12_BUS_SPEED] = "SDR12 ",
Expand All @@ -321,7 +322,9 @@ int mmc_add_card(struct mmc_card *card)
case MMC_TYPE_SD:
type = "SD";
if (mmc_card_blockaddr(card)) {
if (mmc_card_ext_capacity(card))
if (mmc_card_ult_capacity(card))
type = "SDUC";
else if (mmc_card_ext_capacity(card))
type = "SDXC";
else
type = "SDHC";
Expand All @@ -340,27 +343,32 @@ int mmc_add_card(struct mmc_card *card)
break;
}

if (mmc_card_hs(card))
speed_mode = "high speed ";
else if (mmc_card_uhs(card))
speed_mode = "UHS-I speed ";
else if (mmc_card_uhs2(card->host))
speed_mode = "UHS-II speed ";
else if (mmc_card_ddr52(card))
speed_mode = "high speed DDR ";
else if (mmc_card_hs200(card))
speed_mode = "HS200 ";
else if (mmc_card_hs400es(card))
speed_mode = "HS400 Enhanced strobe ";
else if (mmc_card_hs400(card))
speed_mode = "HS400 ";

if (mmc_card_uhs(card) &&
(card->sd_bus_speed < ARRAY_SIZE(uhs_speeds)))
uhs_bus_speed_mode = uhs_speeds[card->sd_bus_speed];

if (mmc_host_is_spi(card->host)) {
pr_info("%s: new %s%s%s card on SPI\n",
mmc_hostname(card->host),
mmc_card_hs(card) ? "high speed " : "",
mmc_card_ddr52(card) ? "DDR " : "",
type);
} else {
pr_info("%s: new %s%s%s%s%s%s card at address %04x\n",
mmc_hostname(card->host),
mmc_card_uhs(card) ? "ultra high speed " :
(mmc_card_hs(card) ? "high speed " : ""),
mmc_card_hs400(card) ? "HS400 " :
(mmc_card_hs200(card) ? "HS200 " : ""),
mmc_card_hs400es(card) ? "Enhanced strobe " : "",
mmc_card_ddr52(card) ? "DDR " : "",
if (mmc_host_is_spi(card->host))
pr_info("%s: new %s%s card on SPI\n",
mmc_hostname(card->host), speed_mode, type);
else
pr_info("%s: new %s%s%s card at address %04x\n",
mmc_hostname(card->host), speed_mode,
uhs_bus_speed_mode, type, card->rca);
}

mmc_add_card_debugfs(card);
card->dev.of_node = mmc_of_find_child_device(card->host, 0);
Expand Down
10 changes: 10 additions & 0 deletions drivers/mmc/core/card.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,21 @@
#define MMC_CARD_SDXC (1<<3) /* card is SDXC */
#define MMC_CARD_REMOVED (1<<4) /* card has been removed */
#define MMC_STATE_SUSPENDED (1<<5) /* card is suspended */
#define MMC_CARD_SDUC (1<<6) /* card is SDUC */

#define mmc_card_present(c) ((c)->state & MMC_STATE_PRESENT)
#define mmc_card_readonly(c) ((c)->state & MMC_STATE_READONLY)
#define mmc_card_blockaddr(c) ((c)->state & MMC_STATE_BLOCKADDR)
#define mmc_card_ext_capacity(c) ((c)->state & MMC_CARD_SDXC)
#define mmc_card_removed(c) ((c) && ((c)->state & MMC_CARD_REMOVED))
#define mmc_card_suspended(c) ((c)->state & MMC_STATE_SUSPENDED)
#define mmc_card_ult_capacity(c) ((c)->state & MMC_CARD_SDUC)

#define mmc_card_set_present(c) ((c)->state |= MMC_STATE_PRESENT)
#define mmc_card_set_readonly(c) ((c)->state |= MMC_STATE_READONLY)
#define mmc_card_set_blockaddr(c) ((c)->state |= MMC_STATE_BLOCKADDR)
#define mmc_card_set_ext_capacity(c) ((c)->state |= MMC_CARD_SDXC)
#define mmc_card_set_ult_capacity(c) ((c)->state |= MMC_CARD_SDUC)
#define mmc_card_set_removed(c) ((c)->state |= MMC_CARD_REMOVED)
#define mmc_card_set_suspended(c) ((c)->state |= MMC_STATE_SUSPENDED)
#define mmc_card_clr_suspended(c) ((c)->state &= ~MMC_STATE_SUSPENDED)
Expand Down Expand Up @@ -82,6 +85,7 @@ struct mmc_fixup {
#define CID_MANFID_SANDISK_SD 0x3
#define CID_MANFID_ATP 0x9
#define CID_MANFID_TOSHIBA 0x11
#define CID_MANFID_GIGASTONE 0x12
#define CID_MANFID_MICRON 0x13
#define CID_MANFID_SAMSUNG 0x15
#define CID_MANFID_APACER 0x27
Expand Down Expand Up @@ -284,4 +288,10 @@ static inline int mmc_card_broken_cache_flush(const struct mmc_card *c)
{
return c->quirks & MMC_QUIRK_BROKEN_CACHE_FLUSH;
}

static inline int mmc_card_broken_sd_poweroff_notify(const struct mmc_card *c)
{
return c->quirks & MMC_QUIRK_BROKEN_SD_POWEROFF_NOTIFY;
}

#endif
Loading

0 comments on commit 3855629

Please sign in to comment.