diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2024-05-16 08:56:49 -0700 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2024-05-16 08:56:49 -0700 |
| commit | 8b06f7538a1bb6ad15969114e31be7a99420125b (patch) | |
| tree | d3413aea546522452fd9b7bfe5d85e28c1bd5acc /drivers/mmc | |
| parent | 8b35a3bb33b57bc2cb2694a50e49e0ea01b9ff6f (diff) | |
| parent | 35eea0defb6e46b26e286066e0e77ac5d53e7fba (diff) | |
| download | linux-8b06f7538a1bb6ad15969114e31be7a99420125b.tar.gz linux-8b06f7538a1bb6ad15969114e31be7a99420125b.tar.bz2 linux-8b06f7538a1bb6ad15969114e31be7a99420125b.zip | |
Merge tag 'mmc-v6.10' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc
Pull MMC updates from Ulf Hansson:
"MMC core:
- Increase the timeout period of the ACMD41 command
- Add card entry for quirks to debugfs
- Add mmc_gpiod_set_cd_config() function
- Store owner from SDIO modules with sdio_register_driver()
MMC host:
- atmel-mci: Some cleanups and a switch to use dev_err_probe()
- renesas_sdhi:
- Add support for RZ/G2L, RZ/G3S and RZ/V2M variants
- Set the SDBUF after reset
- sdhci: Add support for "Tuning Error" interrupts
- sdhci-acpi:
- Add quirk to enable pull-up on the card-detect GPIO on Asus
T100TA
- Disable write protect detection on Toshiba WT10-A
- Fix Lenovo Yoga Tablet 2 Pro 1380 sdcard slot not working
- sdhci_am654:
- Re-work and fix the tuning support for multiple speed-modes
- Add tuning algorithm for delay chain
- sdhci-esdhc-imx: Add NXP S32G3 support
- sdhci-of-dwcmshc:
- Add tuning support for Sophgo CV1800B and SG200X
- Implement SDHCI CQE support
- sdhci-pci-gli: Use the proper pci_set_power_state() instead of
PMCSR writes"
MEMSTICK:
- Convert a couple of drivers to use the ->remove_new() callback"
* tag 'mmc-v6.10' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc: (59 commits)
mmc: renesas_sdhi: Add compatible string for RZ/G2L family, RZ/G3S, and RZ/V2M SoCs
dt-bindings: mmc: renesas,sdhi: Document RZ/G2L family compatibility
dt-bindings: mmc: renesas,sdhi: Group single const value items into an enum list
mmc: renesas_sdhi: Set the SDBUF after reset
mmc: core: Increase the timeout period of the ACMD41 command
mmc: core: Convert to use __mmc_poll_for_busy() SD_APP_OP_COND too
mmc: atmel-mci: Switch to use dev_err_probe()
mmc: atmel-mci: Incapsulate used to be a platform data into host structure
mmc: atmel-mci: Replace platform device pointer by generic one
mmc: atmel-mci: Use temporary variable for struct device
mmc: atmel-mci: Get rid of platform data leftovers
mmc: sdhci-of-dwcmshc: Add tuning support for Sophgo CV1800B and SG200X
mmc: sdhci-of-dwcmshc: Remove useless "&" of th1520_execute_tuning
mmc: sdhci-s3c: Choose sdhci_ops based on variant
mmc: sdhci_am654: Constify struct sdhci_ops
mmc: sdhci-sprd: Constify struct sdhci_ops
mmc: sdhci-omap: Constify struct sdhci_ops
mmc: sdhci-esdhc-mcf: Constify struct sdhci_ops
mmc: slot-gpio: Use irq_handler_t type
mmc: sdhci-acpi: Add quirk to enable pull-up on the card-detect GPIO on Asus T100TA
...
Diffstat (limited to 'drivers/mmc')
26 files changed, 794 insertions, 332 deletions
diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c index 90c51b12148e..367509b5b646 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -234,7 +234,7 @@ static ssize_t power_ro_lock_show(struct device *dev, else if (card->ext_csd.boot_ro_lock & EXT_CSD_BOOT_WP_B_PWR_WP_EN) locked = 1; - ret = snprintf(buf, PAGE_SIZE, "%d\n", locked); + ret = sysfs_emit(buf, "%d\n", locked); mmc_blk_put(md); @@ -296,9 +296,9 @@ static ssize_t force_ro_show(struct device *dev, struct device_attribute *attr, int ret; struct mmc_blk_data *md = mmc_blk_get(dev_to_disk(dev)); - ret = snprintf(buf, PAGE_SIZE, "%d\n", - get_disk_ro(dev_to_disk(dev)) ^ - md->read_only); + ret = sysfs_emit(buf, "%d\n", + get_disk_ro(dev_to_disk(dev)) ^ + md->read_only); mmc_blk_put(md); return ret; } diff --git a/drivers/mmc/core/debugfs.c b/drivers/mmc/core/debugfs.c index 1642ea72d22c..f10a4dcf1f95 100644 --- a/drivers/mmc/core/debugfs.c +++ b/drivers/mmc/core/debugfs.c @@ -351,11 +351,11 @@ void mmc_add_host_debugfs(struct mmc_host *host) root = debugfs_create_dir(mmc_hostname(host), NULL); host->debugfs_root = root; - debugfs_create_file("ios", S_IRUSR, root, host, &mmc_ios_fops); + debugfs_create_file("ios", 0400, root, host, &mmc_ios_fops); debugfs_create_file("caps", 0600, root, &host->caps, &mmc_caps_fops); debugfs_create_file("caps2", 0600, root, &host->caps2, &mmc_caps2_fops); - debugfs_create_file_unsafe("clock", S_IRUSR | S_IWUSR, root, host, + debugfs_create_file_unsafe("clock", 0600, root, host, &mmc_clock_fops); debugfs_create_file_unsafe("err_state", 0600, root, host, @@ -388,7 +388,8 @@ void mmc_add_card_debugfs(struct mmc_card *card) root = debugfs_create_dir(mmc_card_id(card), host->debugfs_root); card->debugfs_root = root; - debugfs_create_x32("state", S_IRUSR, root, &card->state); + debugfs_create_x32("state", 0400, root, &card->state); + debugfs_create_x32("quirks", 0400, root, &card->quirks); } void mmc_remove_card_debugfs(struct mmc_card *card) diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c index 8f8781d6c25e..48bda70145ee 100644 --- a/drivers/mmc/core/host.c +++ b/drivers/mmc/core/host.c @@ -13,7 +13,6 @@ #include <linux/err.h> #include <linux/idr.h> #include <linux/of.h> -#include <linux/of_gpio.h> #include <linux/pagemap.h> #include <linux/pm_wakeup.h> #include <linux/export.h> diff --git a/drivers/mmc/core/sd_ops.c b/drivers/mmc/core/sd_ops.c index a59cd592f06e..8b9b34286ef3 100644 --- a/drivers/mmc/core/sd_ops.c +++ b/drivers/mmc/core/sd_ops.c @@ -19,6 +19,20 @@ #include "sd_ops.h" #include "mmc_ops.h" +/* + * Extensive testing has shown that some specific SD cards + * require an increased command timeout to be successfully + * initialized. + */ +#define SD_APP_OP_COND_PERIOD_US (10 * 1000) /* 10ms */ +#define SD_APP_OP_COND_TIMEOUT_MS 2000 /* 2s */ + +struct sd_app_op_cond_busy_data { + struct mmc_host *host; + u32 ocr; + struct mmc_command *cmd; +}; + int mmc_app_cmd(struct mmc_host *host, struct mmc_card *card) { int err; @@ -115,10 +129,45 @@ int mmc_app_set_bus_width(struct mmc_card *card, int width) return mmc_wait_for_app_cmd(card->host, card, &cmd); } +static int sd_app_op_cond_cb(void *cb_data, bool *busy) +{ + struct sd_app_op_cond_busy_data *data = cb_data; + struct mmc_host *host = data->host; + struct mmc_command *cmd = data->cmd; + u32 ocr = data->ocr; + int err; + + *busy = false; + + err = mmc_wait_for_app_cmd(host, NULL, cmd); + if (err) + return err; + + /* If we're just probing, do a single pass. */ + if (ocr == 0) + return 0; + + /* Wait until reset completes. */ + if (mmc_host_is_spi(host)) { + if (!(cmd->resp[0] & R1_SPI_IDLE)) + return 0; + } else if (cmd->resp[0] & MMC_CARD_BUSY) { + return 0; + } + + *busy = true; + return 0; +} + int mmc_send_app_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr) { struct mmc_command cmd = {}; - int i, err = 0; + struct sd_app_op_cond_busy_data cb_data = { + .host = host, + .ocr = ocr, + .cmd = &cmd + }; + int err; cmd.opcode = SD_APP_OP_COND; if (mmc_host_is_spi(host)) @@ -127,36 +176,16 @@ int mmc_send_app_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr) cmd.arg = ocr; cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R3 | MMC_CMD_BCR; - for (i = 100; i; i--) { - err = mmc_wait_for_app_cmd(host, NULL, &cmd); - if (err) - break; - - /* if we're just probing, do a single pass */ - if (ocr == 0) - break; - - /* otherwise wait until reset completes */ - if (mmc_host_is_spi(host)) { - if (!(cmd.resp[0] & R1_SPI_IDLE)) - break; - } else { - if (cmd.resp[0] & MMC_CARD_BUSY) - break; - } - - err = -ETIMEDOUT; - - mmc_delay(10); - } - - if (!i) - pr_err("%s: card never left busy state\n", mmc_hostname(host)); + err = __mmc_poll_for_busy(host, SD_APP_OP_COND_PERIOD_US, + SD_APP_OP_COND_TIMEOUT_MS, &sd_app_op_cond_cb, + &cb_data); + if (err) + return err; if (rocr && !mmc_host_is_spi(host)) *rocr = cmd.resp[0]; - return err; + return 0; } static int __mmc_send_if_cond(struct mmc_host *host, u32 ocr, u8 pcie_bits, diff --git a/drivers/mmc/core/sdio_bus.c b/drivers/mmc/core/sdio_bus.c index 71d885fbc228..c5fdfe2325f8 100644 --- a/drivers/mmc/core/sdio_bus.c +++ b/drivers/mmc/core/sdio_bus.c @@ -265,16 +265,19 @@ void sdio_unregister_bus(void) } /** - * sdio_register_driver - register a function driver + * __sdio_register_driver - register a function driver * @drv: SDIO function driver + * @owner: owning module/driver */ -int sdio_register_driver(struct sdio_driver *drv) +int __sdio_register_driver(struct sdio_driver *drv, struct module *owner) { drv->drv.name = drv->name; drv->drv.bus = &sdio_bus_type; + drv->drv.owner = owner; + return driver_register(&drv->drv); } -EXPORT_SYMBOL_GPL(sdio_register_driver); +EXPORT_SYMBOL_GPL(__sdio_register_driver); /** * sdio_unregister_driver - unregister a function driver diff --git a/drivers/mmc/core/slot-gpio.c b/drivers/mmc/core/slot-gpio.c index 39f45c2b6de8..12247219e1c2 100644 --- a/drivers/mmc/core/slot-gpio.c +++ b/drivers/mmc/core/slot-gpio.c @@ -19,7 +19,7 @@ struct mmc_gpio { struct gpio_desc *ro_gpio; struct gpio_desc *cd_gpio; - irqreturn_t (*cd_gpio_isr)(int irq, void *dev_id); + irq_handler_t cd_gpio_isr; char *ro_label; char *cd_label; u32 cd_debounce_delay_ms; @@ -162,8 +162,7 @@ EXPORT_SYMBOL(mmc_gpio_set_cd_wake); /* Register an alternate interrupt service routine for * the card-detect GPIO. */ -void mmc_gpio_set_cd_isr(struct mmc_host *host, - irqreturn_t (*isr)(int irq, void *dev_id)) +void mmc_gpio_set_cd_isr(struct mmc_host *host, irq_handler_t isr) { struct mmc_gpio *ctx = host->slot.handler_priv; @@ -221,6 +220,26 @@ int mmc_gpiod_request_cd(struct mmc_host *host, const char *con_id, } EXPORT_SYMBOL(mmc_gpiod_request_cd); +/** + * mmc_gpiod_set_cd_config - set config for card-detection GPIO + * @host: mmc host + * @config: Generic pinconf config (from pinconf_to_config_packed()) + * + * This can be used by mmc host drivers to fixup a card-detection GPIO's config + * (e.g. set PIN_CONFIG_BIAS_PULL_UP) after acquiring the GPIO descriptor + * through mmc_gpiod_request_cd(). + * + * Returns: + * 0 on success, or a negative errno value on error. + */ +int mmc_gpiod_set_cd_config(struct mmc_host *host, unsigned long config) +{ + struct mmc_gpio *ctx = host->slot.handler_priv; + + return gpiod_set_config(ctx->cd_gpio, config); +} +EXPORT_SYMBOL(mmc_gpiod_set_cd_config); + bool mmc_can_gpio_cd(struct mmc_host *host) { struct mmc_gpio *ctx = host->slot.handler_priv; diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig index aebc587f77a7..bb0d4fb0892a 100644 --- a/drivers/mmc/host/Kconfig +++ b/drivers/mmc/host/Kconfig @@ -233,6 +233,7 @@ config MMC_SDHCI_OF_DWCMSHC depends on MMC_SDHCI_PLTFM depends on OF depends on COMMON_CLK + select MMC_CQHCI help This selects Synopsys DesignWare Cores Mobile Storage Controller support. diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c index dba826db739a..8199d9620075 100644 --- a/drivers/mmc/host/atmel-mci.c +++ b/drivers/mmc/host/atmel-mci.c @@ -224,18 +224,6 @@ struct mci_slot_pdata { bool non_removable; }; -/** - * struct mci_platform_data - board-specific MMC/SDcard configuration - * @dma_slave: DMA slave interface to use in data transfers. - * @dma_filter: Filtering function to filter the DMA channel - * @slot: Per-slot configuration data. - */ -struct mci_platform_data { - void *dma_slave; - dma_filter_fn dma_filter; - struct mci_slot_pdata slot[ATMCI_MAX_NR_SLOTS]; -}; - struct atmel_mci_caps { bool has_dma_conf_reg; bool has_pdc; @@ -300,7 +288,8 @@ struct atmel_mci_dma { * rate and timeout calculations. * @mapbase: Physical address of the MMIO registers. * @mck: The peripheral bus clock hooked up to the MMC controller. - * @pdev: Platform device associated with the MMC controller. + * @dev: Device associated with the MMC controller. + * @pdata: Per-slot configuration data. * @slot: Slots sharing this MMC controller. * @caps: MCI capabilities depending on MCI version. * @prepare_data: function to setup MCI before data transfer which @@ -377,8 +366,9 @@ struct atmel_mci { unsigned long bus_hz; unsigned long mapbase; struct clk *mck; - struct platform_device *pdev; + struct device *dev; + struct mci_slot_pdata pdata[ATMCI_MAX_NR_SLOTS]; struct atmel_mci_slot *slot[ATMCI_MAX_NR_SLOTS]; struct atmel_mci_caps caps; @@ -530,6 +520,7 @@ static void atmci_show_status_reg(struct seq_file *s, static int atmci_regs_show(struct seq_file *s, void *v) { struct atmel_mci *host = s->private; + struct device *dev = host->dev; u32 *buf; int ret = 0; @@ -538,7 +529,7 @@ static int atmci_regs_show(struct seq_file *s, void *v) if (!buf) return -ENOMEM; - pm_runtime_get_sync(&host->pdev->dev); + pm_runtime_get_sync(dev); /* * Grab a more or less consistent snapshot. Note that we're @@ -549,8 +540,8 @@ static int atmci_regs_show(struct seq_file *s, void *v) memcpy_fromio(buf, host->regs, ATMCI_REGS_SIZE); spin_unlock_bh(&host->lock); - pm_runtime_mark_last_busy(&host->pdev->dev); - pm_runtime_put_autosuspend(&host->pdev->dev); + pm_runtime_mark_last_busy(dev); + pm_runtime_put_autosuspend(dev); seq_printf(s, "MR:\t0x%08x%s%s ", buf[ATMCI_MR / 4], @@ -626,7 +617,6 @@ static void atmci_init_debugfs(struct atmel_mci_slot *slot) &host->completed_events); } -#if defined(CONFIG_OF) static const struct of_device_id atmci_dt_ids[] = { { .compatible = "atmel,hsmci" }, { /* sentinel */ } @@ -634,79 +624,64 @@ static const struct of_device_id atmci_dt_ids[] = { MODULE_DEVICE_TABLE(of, atmci_dt_ids); -static struct mci_platform_data* -atmci_of_init(struct platform_device *pdev) +static int atmci_of_init(struct atmel_mci *host) { - struct device_node *np = pdev->dev.of_node; + struct device *dev = host->dev; + struct device_node *np = dev->of_node; struct device_node *cnp; - struct mci_platform_data *pdata; u32 slot_id; int err; - if (!np) { - dev_err(&pdev->dev, "device node not found\n"); - return ERR_PTR(-EINVAL); - } - - pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); - if (!pdata) - return ERR_PTR(-ENOMEM); + if (!np) + return dev_err_probe(dev, -EINVAL, "device node not found\n"); for_each_child_of_node(np, cnp) { if (of_property_read_u32(cnp, "reg", &slot_id)) { - dev_warn(&pdev->dev, "reg property is missing for %pOF\n", - cnp); + dev_warn(dev, "reg property is missing for %pOF\n", cnp); continue; } if (slot_id >= ATMCI_MAX_NR_SLOTS) { - dev_warn(&pdev->dev, "can't have more than %d slots\n", + dev_warn(dev, "can't have more than %d slots\n", ATMCI_MAX_NR_SLOTS); of_node_put(cnp); break; } if (of_property_read_u32(cnp, "bus-width", - &pdata->slot[slot_id].bus_width)) - pdata->slot[slot_id].bus_width = 1; + &host->pdata[slot_id].bus_width)) + host->pdata[slot_id].bus_width = 1; - pdata->slot[slot_id].detect_pin = - devm_fwnode_gpiod_get(&pdev->dev, of_fwnode_handle(cnp), + host->pdata[slot_id].detect_pin = + devm_fwnode_gpiod_get(dev, of_fwnode_handle(cnp), "cd", GPIOD_IN, "cd-gpios"); - err = PTR_ERR_OR_ZERO(pdata->slot[slot_id].detect_pin); + err = PTR_ERR_OR_ZERO(host->pdata[slot_id].detect_pin); if (err) { if (err != -ENOENT) { of_node_put(cnp); - return ERR_PTR(err); + return err; } - pdata->slot[slot_id].detect_pin = NULL; + host->pdata[slot_id].detect_pin = NULL; } - pdata->slot[slot_id].non_removable = + host->pdata[slot_id].non_removable = of_property_read_bool(cnp, "non-removable"); - pdata->slot[slot_id].wp_pin = - devm_fwnode_gpiod_get(&pdev->dev, of_fwnode_handle(cnp), + host->pdata[slot_id].wp_pin = + devm_fwnode_gpiod_get(dev, of_fwnode_handle(cnp), "wp", GPIOD_IN, "wp-gpios"); - err = PTR_ERR_OR_ZERO(pdata->slot[slot_id].wp_pin); + err = PTR_ERR_OR_ZERO(host->pdata[slot_id].wp_pin); if (err) { if (err != -ENOENT) { of_node_put(cnp); - return ERR_PTR(err); + return err; } - pdata->slot[slot_id].wp_pin = NULL; + host->pdata[slot_id].wp_pin = NULL; } } - return pdata; -} -#else /* CONFIG_OF */ -static inline struct mci_platform_data* -atmci_of_init(struct platform_device *dev) -{ - return ERR_PTR(-EINVAL); + return 0; } -#endif static inline unsigned int atmci_get_version(struct atmel_mci *host) { @@ -738,11 +713,10 @@ static inline unsigned int atmci_convert_chksize(struct atmel_mci *host, static void atmci_timeout_timer(struct timer_list *t) { - struct atmel_mci *host; + struct atmel_mci *host = from_timer(host, t, timer); + struct device *dev = host->dev; - host = from_timer(host, t, timer); - - dev_dbg(&host->pdev->dev, "software timeout\n"); + dev_dbg(dev, "software timeout\n"); if (host->mrq->cmd->data) { host->mrq->cmd->data->error = -ETIMEDOUT; @@ -860,15 +834,14 @@ static u32 atmci_prepare_command(struct mmc_host *mmc, static void atmci_send_command(struct atmel_mci *host, struct mmc_command *cmd, u32 cmd_flags) { + struct device *dev = host->dev; unsigned int timeout_ms = cmd->busy_timeout ? cmd->busy_timeout : ATMCI_CMD_TIMEOUT_MS; WARN_ON(host->cmd); host->cmd = cmd; - dev_vdbg(&host->pdev->dev, - "start command: ARGR=0x%08x CMDR=0x%08x\n", - cmd->arg, cmd_flags); + dev_vdbg(dev, "start command: ARGR=0x%08x CMDR=0x%08x\n", cmd->arg, cmd_flags); atmci_writel(host, ATMCI_ARGR, cmd->arg); atmci_writel(host, ATMCI_CMDR, cmd_flags); @@ -878,7 +851,9 @@ static void atmci_send_command(struct atmel_mci *host, static void atmci_send_stop_cmd(struct atmel_mci *host, struct mmc_data *data) { - dev_dbg(&host->pdev->dev, "send stop command\n"); + struct device *dev = host->dev; + + dev_dbg(dev, "send stop command\n"); atmci_send_command(host, data->stop, host->stop_cmdr); atmci_writel(host, ATMCI_IER, ATMCI_CMDRDY); } @@ -951,11 +926,10 @@ static void atmci_pdc_set_both_buf(struct atmel_mci *host, int dir) static void atmci_pdc_cleanup(struct atmel_mci *host) { struct mmc_data *data = host->data; + struct device *dev = host->dev; if (data) - dma_unmap_sg(&host->pdev->dev, - data->sg, data->sg_len, - mmc_get_dma_dir(data)); + dma_unmap_sg(dev, data->sg, data->sg_len, mmc_get_dma_dir(data)); } /* @@ -965,6 +939,7 @@ static void atmci_pdc_cleanup(struct atmel_mci *host) */ static void atmci_pdc_complete(struct atmel_mci *host) { + struct device *dev = host->dev; int transfer_size = host->data->blocks * host->data->blksz; int i; @@ -981,7 +956,7 @@ static void atmci_pdc_complete(struct atmel_mci *host) atmci_pdc_cleanup(host); - dev_dbg(&host->pdev->dev, "(%s) set pending xfer complete\n", __func__); + dev_dbg(dev, "(%s) set pending xfer complete\n", __func__); atmci_set_pending(host, EVENT_XFER_COMPLETE); tasklet_schedule(&host->tasklet); } @@ -1003,8 +978,9 @@ static void atmci_dma_complete(void *arg) { struct atmel_mci *host = arg; struct mmc_data *data = host->data; + struct device *dev = host->dev; - dev_vdbg(&host->pdev->dev, "DMA complete\n"); + dev_vdbg(dev, "DMA complete\n"); if (host->caps.has_dma_conf_reg) /* Disable DMA hardware handshaking on MCI */ @@ -1017,8 +993,7 @@ static void atmci_dma_complete(void *arg) * to send the stop command or waiting for NBUSY in this case. */ if (data) { - dev_dbg(&host->pdev->dev, - "(%s) set pending xfer complete\n", __func__); + dev_dbg(dev, "(%s) set pending xfer complete\n", __func__); atmci_set_pending(host, EVENT_XFER_COMPLETE); tasklet_schedule(&host->tasklet); @@ -1092,6 +1067,7 @@ static u32 atmci_prepare_data(struct atmel_mci *host, struct mmc_data *data) static u32 atmci_prepare_data_pdc(struct atmel_mci *host, struct mmc_data *data) { + struct device *dev = host->dev; u32 iflags, tmp; int i; @@ -1117,8 +1093,7 @@ atmci_prepare_data_pdc(struct atmel_mci *host, struct mmc_data *data) /* Configure PDC */ host->data_size = data->blocks * data->blksz; - dma_map_sg(&host->pdev->dev, data->sg, data->sg_len, - mmc_get_dma_dir(data)); + dma_map_sg(dev, data->sg, data->sg_len, mmc_get_dma_dir(data)); if ((!host->caps.has_rwproof) && (host->data->flags & MMC_DATA_WRITE)) { @@ -1244,8 +1219,9 @@ atmci_submit_data_dma(struct atmel_mci *host, struct mmc_data *data) static void atmci_stop_transfer(struct atmel_mci *host) { - dev_dbg(&host->pdev->dev, - "(%s) set pending xfer complete\n", __func__); + struct device *dev = host->dev; + + dev_dbg(dev, "(%s) set pending xfer complete\n", __func__); atmci_set_pending(host, EVENT_XFER_COMPLETE); atmci_writel(host, ATMCI_IER, ATMCI_NOTBUSY); } @@ -1261,14 +1237,14 @@ static void atmci_stop_transfer_pdc(struct atmel_mci *host) static void atmci_stop_transfer_dma(struct atmel_mci *host) { struct dma_chan *chan = host->data_chan; + struct device *dev = host->dev; if (chan) { dmaengine_terminate_all(chan); atmci_dma_cleanup(host); } else { /* Data transfer was stopped by the interrupt handler */ - dev_dbg(&host->pdev->dev, - "(%s) set pending xfer complete\n", __func__); + dev_dbg(dev, "(%s) set pending xfer complete\n", __func__); atmci_set_pending(host, EVENT_XFER_COMPLETE); atmci_writel(host, ATMCI_IER, ATMCI_NOTBUSY); } @@ -1281,6 +1257,7 @@ static void atmci_stop_transfer_dma(struct atmel_mci *host) static void atmci_start_request(struct atmel_mci *host, struct atmel_mci_slot *slot) { + struct device *dev = host->dev; struct mmc_request *mrq; struct mmc_command *cmd; struct mmc_data *data; @@ -1296,7 +1273,7 @@ static void atmci_start_request(struct atmel_mci *host, host->cmd_status = 0; host->data_status = 0; - dev_dbg(&host->pdev->dev, "start request: cmd %u\n", mrq->cmd->opcode); + dev_dbg(dev, "start request: cmd %u\n", mrq->cmd->opcode); if (host->need_reset || host->caps.need_reset_after_xfer) { iflags = atmci_readl(host, ATMCI_IMR); @@ -1375,6 +1352,8 @@ static void atmci_start_request(struct atmel_mci *host, static void atmci_queue_request(struct atmel_mci *host, struct atmel_mci_slot *slot, struct mmc_request *mrq) { + struct device *dev = host->dev; + dev_vdbg(&slot->mmc->class_dev, "queue request: state=%d\n", host->state); @@ -1384,7 +1363,7 @@ static void atmci_queue_request(struct atmel_mci *host, host->state = STATE_SENDING_CMD; atmci_start_request(host, slot); } else { - dev_dbg(&host->pdev->dev, "queue request\n"); + dev_dbg(dev, "queue request\n"); list_add_tail(&slot->queue_node, &host->queue); } spin_unlock_bh(&host->lock); @@ -1394,10 +1373,11 @@ static void atmci_request(struct mmc_host *mmc, struct mmc_request *mrq) { struct atmel_mci_slot *slot = mmc_priv(mmc); struct atmel_mci *host = slot->host; + struct device *dev = host->dev; struct mmc_data *data; WARN_ON(slot->mrq); - dev_dbg(&host->pdev->dev, "MRQ: cmd %u\n", mrq->cmd->opcode); + dev_dbg(dev, "MRQ: cmd %u\n", mrq->cmd->opcode); /* * We may "know" the card is gone even though there's still an @@ -1607,6 +1587,7 @@ static void atmci_request_end(struct atmel_mci *host, struct mmc_request *mrq) { struct atmel_mci_slot *slot = NULL; struct mmc_host *prev_mmc = host->cur_slot->mmc; + struct device *dev = host->dev; WARN_ON(host->cmd || host->data); @@ -1629,12 +1610,11 @@ static void atmci_request_end(struct atmel_mci *host, struct mmc_request *mrq) slot = list_entry(host->queue.next, struct atmel_mci_slot, queue_node); list_del(&slot->queue_node); - dev_vdbg(&host->pdev->dev, "list not empty: %s is next\n", - mmc_hostname(slot->mmc)); + dev_vdbg(dev, "list not empty: %s is next\n", mmc_hostname(slot->mmc)); host->state = STATE_SENDING_CMD; atmci_start_request(host, slot); } else { - dev_vdbg(&host->pdev->dev, "list empty\n"); + dev_vdbg(dev, "list empty\n"); host->state = STATE_IDLE; } @@ -1770,6 +1750,7 @@ static void atmci_tasklet_func(struct tasklet_struct *t) struct atmel_mci *host = from_tasklet(host, t, tasklet); struct mmc_request *mrq = host->mrq; struct mmc_data *data = host->data; + struct device *dev = host->dev; enum atmel_mci_state state = host->state; enum atmel_mci_state prev_state; u32 status; @@ -1778,14 +1759,13 @@ static void atmci_tasklet_func(struct tasklet_struct *t) state = host->state; - dev_vdbg(&host->pdev->dev, - "tasklet: state %u pending/completed/mask %lx/%lx/%x\n", + dev_vdbg(dev, "tasklet: state %u pending/completed/mask %lx/%lx/%x\n", state, host->pending_events, host->completed_events, atmci_readl(host, ATMCI_IMR)); do { prev_state = state; - dev_dbg(&host->pdev->dev, "FSM: state=%d\n", state); + dev_dbg(dev, "FSM: state=%d\n", state); switch (state) { case STATE_IDLE: @@ -1798,18 +1778,17 @@ static void atmci_tasklet_func(struct tasklet_struct *t) * END_REQUEST by default, WAITING_NOTBUSY if it's a * command needing it or DATA_XFER if there is data. */ - dev_dbg(&host->pdev->dev, "FSM: cmd ready?\n"); + dev_dbg(dev, "FSM: cmd ready?\n"); if (!atmci_test_and_clear_pending(host, EVENT_CMD_RDY)) break; - dev_dbg(&host->pdev->dev, "set completed cmd ready\n"); + dev_dbg(dev, "set completed cmd ready\n"); host->cmd = NULL; atmci_set_completed(host, EVENT_CMD_RDY); atmci_command_complete(host, mrq->cmd); if (mrq->data) { - dev_dbg(&host->pdev->dev, - "command with data transfer"); + dev_dbg(dev, "command with data transfer\n"); /* * If there is a command error don't start * data transfer. @@ -1824,8 +1803,7 @@ static void atmci_tasklet_func(struct tasklet_struct *t) } else state = STATE_DATA_XFER; } else if ((!mrq->data) && (mrq->cmd->flags & MMC_RSP_BUSY)) { - dev_dbg(&host->pdev->dev, - "command response need waiting notbusy"); + dev_dbg(dev, "command response need waiting notbusy\n"); atmci_writel(host, ATMCI_IER, ATMCI_NOTBUSY); state = STATE_WAITING_NOTBUSY; } else @@ -1836,7 +1814,7 @@ static void atmci_tasklet_func(struct tasklet_struct *t) case STATE_DATA_XFER: if (atmci_test_and_clear_pending(host, EVENT_DATA_ERROR)) { - dev_dbg(&host->pdev->dev, "set completed data error\n"); + dev_dbg(dev, "set completed data error\n"); atmci_set_completed(host, EVENT_DATA_ERROR); state = STATE_END_REQUEST; break; @@ -1849,14 +1827,12 @@ static void atmci_tasklet_func(struct tasklet_struct *t) * to the next step which is WAITING_NOTBUSY in write * case and directly SENDING_STOP in read case. */ - dev_dbg(&host->pdev->dev, "FSM: xfer complete?\n"); + dev_dbg(dev, "FSM: xfer complete?\n"); if (!atmci_test_and_clear_pending(host, EVENT_XFER_COMPLETE)) break; - dev_dbg(&host->pdev->dev, - "(%s) set completed xfer complete\n", - __func__); + dev_dbg(dev, "(%s) set completed xfer complete\n", __func__); atmci_set_completed(host, EVENT_XFER_COMPLETE); if (host->caps.need_notbusy_for_read_ops || @@ -1881,12 +1857,12 @@ static void atmci_tasklet_func(struct tasklet_struct *t) * included) or a write operation. In the latest case, * we need to send a stop command. */ - dev_dbg(&host->pdev->dev, "FSM: not busy?\n"); + dev_dbg(dev, "FSM: not busy?\n"); if (!atmci_test_and_clear_pending(host, EVENT_NOTBUSY)) break; - dev_dbg(&host->pdev->dev, "set completed not busy\n"); + dev_dbg(dev, "set completed not busy\n"); atmci_set_completed(host, EVENT_NOTBUSY); if (host->data) { @@ -1916,12 +1892,12 @@ static void atmci_tasklet_func(struct tasklet_struct *t) * in order to go to the end request state instead of |
