hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/mmc/host/android-goldfish.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright 2007, Google Inc.
34 * Copyright 2012, Intel Inc.
....@@ -7,10 +8,6 @@
78 * Written by Tuukka Tikkanen and Juha Yrjölä <juha.yrjola@nokia.com>
89 * Misc hacks here and there by Tony Lindgren <tony@atomide.com>
910 * 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.
1411 */
1512
1613 #include <linux/module.h>
....@@ -30,7 +27,6 @@
3027 #include <linux/mutex.h>
3128 #include <linux/scatterlist.h>
3229 #include <linux/mmc/mmc.h>
33
-#include <linux/mmc/sdio.h>
3430 #include <linux/mmc/host.h>
3531 #include <linux/mmc/card.h>
3632
....@@ -113,7 +109,6 @@
113109 struct mmc_request *mrq;
114110 struct mmc_command *cmd;
115111 struct mmc_data *data;
116
- struct mmc_host *mmc;
117112 struct device *dev;
118113 unsigned char id; /* 16xx chips have 2 MMC blocks */
119114 void *virt_base;
....@@ -175,7 +170,7 @@
175170 resptype = 3;
176171 break;
177172 default:
178
- dev_err(mmc_dev(host->mmc),
173
+ dev_err(mmc_dev(mmc_from_priv(host)),
179174 "Invalid response type: %04x\n", mmc_resp_type(cmd));
180175 break;
181176 }
....@@ -221,8 +216,8 @@
221216 data->sg->length);
222217 }
223218 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);
226221 }
227222
228223 host->data = NULL;
....@@ -236,7 +231,7 @@
236231
237232 if (!data->stop) {
238233 host->mrq = NULL;
239
- mmc_request_done(host->mmc, data->mrq);
234
+ mmc_request_done(mmc_from_priv(host), data->mrq);
240235 return;
241236 }
242237
....@@ -278,7 +273,7 @@
278273
279274 if (host->data == NULL || cmd->error) {
280275 host->mrq = NULL;
281
- mmc_request_done(host->mmc, cmd->mrq);
276
+ mmc_request_done(mmc_from_priv(host), cmd->mrq);
282277 }
283278 }
284279
....@@ -313,7 +308,7 @@
313308 struct mmc_request *mrq = host->mrq;
314309 mrq->cmd->error = -ETIMEDOUT;
315310 host->mrq = NULL;
316
- mmc_request_done(host->mmc, mrq);
311
+ mmc_request_done(mmc_from_priv(host), mrq);
317312 }
318313
319314 if (end_command)
....@@ -339,12 +334,13 @@
339334 u32 state = GOLDFISH_MMC_READ(host, MMC_STATE);
340335 pr_info("%s: Card detect now %d\n", __func__,
341336 (state & MMC_STATE_INSERTED));
342
- mmc_detect_change(host->mmc, 0);
337
+ mmc_detect_change(mmc_from_priv(host), 0);
343338 }
344339
345340 if (!end_command && !end_transfer && !state_changed && !cmd_timeout) {
346341 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);
348344 if (status != 0) {
349345 GOLDFISH_MMC_WRITE(host, MMC_INT_STATUS, status);
350346 GOLDFISH_MMC_WRITE(host, MMC_INT_ENABLE, 0);
....@@ -383,7 +379,7 @@
383379
384380 dma_data_dir = mmc_get_dma_dir(data);
385381
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,
387383 sg_len, dma_data_dir);
388384 host->dma_done = 0;
389385 host->dma_in_use = 1;
....@@ -407,14 +403,6 @@
407403 host->mrq = req;
408404 goldfish_mmc_prepare_data(host, req);
409405 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;
418406 }
419407
420408 static void goldfish_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
....@@ -461,7 +449,6 @@
461449 }
462450
463451 host = mmc_priv(mmc);
464
- host->mmc = mmc;
465452
466453 pr_err("mmc: Mapping %lX to %lX\n", (long)res->start, (long)res->end);
467454 host->reg_base = ioremap(res->start, resource_size(res));
....@@ -486,6 +473,7 @@
486473 mmc->f_max = 24000000;
487474 mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34;
488475 mmc->caps = MMC_CAP_4_BIT_DATA;
476
+ mmc->caps2 = MMC_CAP2_NO_SDIO;
489477
490478 /* Use scatterlist DMA to reduce per-transfer costs.
491479 * NOTE max_seg_size assumption that small blocks aren't
....@@ -508,8 +496,7 @@
508496
509497 ret = device_create_file(&pdev->dev, &dev_attr_cover_switch);
510498 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");
513500
514501 GOLDFISH_MMC_WRITE(host, MMC_SET_BUFFER, host->phys_base);
515502 GOLDFISH_MMC_WRITE(host, MMC_INT_ENABLE,
....@@ -525,7 +512,7 @@
525512 dma_alloc_failed:
526513 iounmap(host->reg_base);
527514 ioremap_failed:
528
- mmc_free_host(host->mmc);
515
+ mmc_free_host(mmc);
529516 err_alloc_host_failed:
530517 return ret;
531518 }
....@@ -533,14 +520,15 @@
533520 static int goldfish_mmc_remove(struct platform_device *pdev)
534521 {
535522 struct goldfish_mmc_host *host = platform_get_drvdata(pdev);
523
+ struct mmc_host *mmc = mmc_from_priv(host);
536524
537525 BUG_ON(host == NULL);
538526
539
- mmc_remove_host(host->mmc);
527
+ mmc_remove_host(mmc);
540528 free_irq(host->irq, host);
541529 dma_free_coherent(&pdev->dev, BUFFER_SIZE, host->virt_base, host->phys_base);
542530 iounmap(host->reg_base);
543
- mmc_free_host(host->mmc);
531
+ mmc_free_host(mmc);
544532 return 0;
545533 }
546534