.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright 2007, Google Inc. |
---|
3 | 4 | * Copyright 2012, Intel Inc. |
---|
.. | .. |
---|
7 | 8 | * Written by Tuukka Tikkanen and Juha Yrjölä <juha.yrjola@nokia.com> |
---|
8 | 9 | * Misc hacks here and there by Tony Lindgren <tony@atomide.com> |
---|
9 | 10 | * Other hacks (DMA, SD, etc) by David Brownell |
---|
10 | | - * |
---|
11 | | - * This program is free software; you can redistribute it and/or modify |
---|
12 | | - * it under the terms of the GNU General Public License version 2 as |
---|
13 | | - * published by the Free Software Foundation. |
---|
14 | 11 | */ |
---|
15 | 12 | |
---|
16 | 13 | #include <linux/module.h> |
---|
.. | .. |
---|
30 | 27 | #include <linux/mutex.h> |
---|
31 | 28 | #include <linux/scatterlist.h> |
---|
32 | 29 | #include <linux/mmc/mmc.h> |
---|
33 | | -#include <linux/mmc/sdio.h> |
---|
34 | 30 | #include <linux/mmc/host.h> |
---|
35 | 31 | #include <linux/mmc/card.h> |
---|
36 | 32 | |
---|
.. | .. |
---|
113 | 109 | struct mmc_request *mrq; |
---|
114 | 110 | struct mmc_command *cmd; |
---|
115 | 111 | struct mmc_data *data; |
---|
116 | | - struct mmc_host *mmc; |
---|
117 | 112 | struct device *dev; |
---|
118 | 113 | unsigned char id; /* 16xx chips have 2 MMC blocks */ |
---|
119 | 114 | void *virt_base; |
---|
.. | .. |
---|
175 | 170 | resptype = 3; |
---|
176 | 171 | break; |
---|
177 | 172 | default: |
---|
178 | | - dev_err(mmc_dev(host->mmc), |
---|
| 173 | + dev_err(mmc_dev(mmc_from_priv(host)), |
---|
179 | 174 | "Invalid response type: %04x\n", mmc_resp_type(cmd)); |
---|
180 | 175 | break; |
---|
181 | 176 | } |
---|
.. | .. |
---|
221 | 216 | data->sg->length); |
---|
222 | 217 | } |
---|
223 | 218 | host->data->bytes_xfered += data->sg->length; |
---|
224 | | - dma_unmap_sg(mmc_dev(host->mmc), data->sg, host->sg_len, |
---|
225 | | - dma_data_dir); |
---|
| 219 | + dma_unmap_sg(mmc_dev(mmc_from_priv(host)), data->sg, |
---|
| 220 | + host->sg_len, dma_data_dir); |
---|
226 | 221 | } |
---|
227 | 222 | |
---|
228 | 223 | host->data = NULL; |
---|
.. | .. |
---|
236 | 231 | |
---|
237 | 232 | if (!data->stop) { |
---|
238 | 233 | host->mrq = NULL; |
---|
239 | | - mmc_request_done(host->mmc, data->mrq); |
---|
| 234 | + mmc_request_done(mmc_from_priv(host), data->mrq); |
---|
240 | 235 | return; |
---|
241 | 236 | } |
---|
242 | 237 | |
---|
.. | .. |
---|
278 | 273 | |
---|
279 | 274 | if (host->data == NULL || cmd->error) { |
---|
280 | 275 | host->mrq = NULL; |
---|
281 | | - mmc_request_done(host->mmc, cmd->mrq); |
---|
| 276 | + mmc_request_done(mmc_from_priv(host), cmd->mrq); |
---|
282 | 277 | } |
---|
283 | 278 | } |
---|
284 | 279 | |
---|
.. | .. |
---|
313 | 308 | struct mmc_request *mrq = host->mrq; |
---|
314 | 309 | mrq->cmd->error = -ETIMEDOUT; |
---|
315 | 310 | host->mrq = NULL; |
---|
316 | | - mmc_request_done(host->mmc, mrq); |
---|
| 311 | + mmc_request_done(mmc_from_priv(host), mrq); |
---|
317 | 312 | } |
---|
318 | 313 | |
---|
319 | 314 | if (end_command) |
---|
.. | .. |
---|
339 | 334 | u32 state = GOLDFISH_MMC_READ(host, MMC_STATE); |
---|
340 | 335 | pr_info("%s: Card detect now %d\n", __func__, |
---|
341 | 336 | (state & MMC_STATE_INSERTED)); |
---|
342 | | - mmc_detect_change(host->mmc, 0); |
---|
| 337 | + mmc_detect_change(mmc_from_priv(host), 0); |
---|
343 | 338 | } |
---|
344 | 339 | |
---|
345 | 340 | if (!end_command && !end_transfer && !state_changed && !cmd_timeout) { |
---|
346 | 341 | status = GOLDFISH_MMC_READ(host, MMC_INT_STATUS); |
---|
347 | | - dev_info(mmc_dev(host->mmc),"spurious irq 0x%04x\n", status); |
---|
| 342 | + dev_info(mmc_dev(mmc_from_priv(host)), "spurious irq 0x%04x\n", |
---|
| 343 | + status); |
---|
348 | 344 | if (status != 0) { |
---|
349 | 345 | GOLDFISH_MMC_WRITE(host, MMC_INT_STATUS, status); |
---|
350 | 346 | GOLDFISH_MMC_WRITE(host, MMC_INT_ENABLE, 0); |
---|
.. | .. |
---|
383 | 379 | |
---|
384 | 380 | dma_data_dir = mmc_get_dma_dir(data); |
---|
385 | 381 | |
---|
386 | | - host->sg_len = dma_map_sg(mmc_dev(host->mmc), data->sg, |
---|
| 382 | + host->sg_len = dma_map_sg(mmc_dev(mmc_from_priv(host)), data->sg, |
---|
387 | 383 | sg_len, dma_data_dir); |
---|
388 | 384 | host->dma_done = 0; |
---|
389 | 385 | host->dma_in_use = 1; |
---|
.. | .. |
---|
407 | 403 | host->mrq = req; |
---|
408 | 404 | goldfish_mmc_prepare_data(host, req); |
---|
409 | 405 | goldfish_mmc_start_command(host, req->cmd); |
---|
410 | | - |
---|
411 | | - /* |
---|
412 | | - * This is to avoid accidentally being detected as an SDIO card |
---|
413 | | - * in mmc_attach_sdio(). |
---|
414 | | - */ |
---|
415 | | - if (req->cmd->opcode == SD_IO_SEND_OP_COND && |
---|
416 | | - req->cmd->flags == (MMC_RSP_SPI_R4 | MMC_RSP_R4 | MMC_CMD_BCR)) |
---|
417 | | - req->cmd->error = -EINVAL; |
---|
418 | 406 | } |
---|
419 | 407 | |
---|
420 | 408 | static void goldfish_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) |
---|
.. | .. |
---|
461 | 449 | } |
---|
462 | 450 | |
---|
463 | 451 | host = mmc_priv(mmc); |
---|
464 | | - host->mmc = mmc; |
---|
465 | 452 | |
---|
466 | 453 | pr_err("mmc: Mapping %lX to %lX\n", (long)res->start, (long)res->end); |
---|
467 | 454 | host->reg_base = ioremap(res->start, resource_size(res)); |
---|
.. | .. |
---|
486 | 473 | mmc->f_max = 24000000; |
---|
487 | 474 | mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34; |
---|
488 | 475 | mmc->caps = MMC_CAP_4_BIT_DATA; |
---|
| 476 | + mmc->caps2 = MMC_CAP2_NO_SDIO; |
---|
489 | 477 | |
---|
490 | 478 | /* Use scatterlist DMA to reduce per-transfer costs. |
---|
491 | 479 | * NOTE max_seg_size assumption that small blocks aren't |
---|
.. | .. |
---|
508 | 496 | |
---|
509 | 497 | ret = device_create_file(&pdev->dev, &dev_attr_cover_switch); |
---|
510 | 498 | if (ret) |
---|
511 | | - dev_warn(mmc_dev(host->mmc), |
---|
512 | | - "Unable to create sysfs attributes\n"); |
---|
| 499 | + dev_warn(mmc_dev(mmc), "Unable to create sysfs attributes\n"); |
---|
513 | 500 | |
---|
514 | 501 | GOLDFISH_MMC_WRITE(host, MMC_SET_BUFFER, host->phys_base); |
---|
515 | 502 | GOLDFISH_MMC_WRITE(host, MMC_INT_ENABLE, |
---|
.. | .. |
---|
525 | 512 | dma_alloc_failed: |
---|
526 | 513 | iounmap(host->reg_base); |
---|
527 | 514 | ioremap_failed: |
---|
528 | | - mmc_free_host(host->mmc); |
---|
| 515 | + mmc_free_host(mmc); |
---|
529 | 516 | err_alloc_host_failed: |
---|
530 | 517 | return ret; |
---|
531 | 518 | } |
---|
.. | .. |
---|
533 | 520 | static int goldfish_mmc_remove(struct platform_device *pdev) |
---|
534 | 521 | { |
---|
535 | 522 | struct goldfish_mmc_host *host = platform_get_drvdata(pdev); |
---|
| 523 | + struct mmc_host *mmc = mmc_from_priv(host); |
---|
536 | 524 | |
---|
537 | 525 | BUG_ON(host == NULL); |
---|
538 | 526 | |
---|
539 | | - mmc_remove_host(host->mmc); |
---|
| 527 | + mmc_remove_host(mmc); |
---|
540 | 528 | free_irq(host->irq, host); |
---|
541 | 529 | dma_free_coherent(&pdev->dev, BUFFER_SIZE, host->virt_base, host->phys_base); |
---|
542 | 530 | iounmap(host->reg_base); |
---|
543 | | - mmc_free_host(host->mmc); |
---|
| 531 | + mmc_free_host(mmc); |
---|
544 | 532 | return 0; |
---|
545 | 533 | } |
---|
546 | 534 | |
---|