Lines Matching refs:host

34 #include <linux/mmc/host.h>
58 #define GOLDFISH_MMC_READ(host, addr) (readl(host->reg_base + addr))
59 #define GOLDFISH_MMC_WRITE(host, addr, x) (writel(x, host->reg_base + addr))
135 goldfish_mmc_cover_is_open(struct goldfish_mmc_host *host)
144 struct goldfish_mmc_host *host = dev_get_drvdata(dev);
146 return sprintf(buf, "%s\n", goldfish_mmc_cover_is_open(host) ? "open" :
153 goldfish_mmc_start_command(struct goldfish_mmc_host *host, struct mmc_command *cmd)
159 host->cmd = cmd;
180 dev_err(mmc_dev(host->mmc),
196 if (host->bus_mode == MMC_BUSMODE_OPENDRAIN)
202 if (host->data && !(host->data->flags & MMC_DATA_WRITE))
205 GOLDFISH_MMC_WRITE(host, MMC_ARG, cmd->arg);
206 GOLDFISH_MMC_WRITE(host, MMC_CMD, cmdreg);
209 static void goldfish_mmc_xfer_done(struct goldfish_mmc_host *host,
212 if (host->dma_in_use) {
226 memcpy(dest, host->virt_base, data->sg->length);
228 host->data->bytes_xfered += data->sg->length;
229 dma_unmap_sg(mmc_dev(host->mmc), data->sg, host->sg_len,
233 host->data = NULL;
234 host->sg_len = 0;
243 host->mrq = NULL;
244 mmc_request_done(host->mmc, data->mrq);
248 goldfish_mmc_start_command(host, data->stop);
251 static void goldfish_mmc_end_of_data(struct goldfish_mmc_host *host,
254 if (!host->dma_in_use) {
255 goldfish_mmc_xfer_done(host, data);
258 if (host->dma_done)
259 goldfish_mmc_xfer_done(host, data);
262 static void goldfish_mmc_cmd_done(struct goldfish_mmc_host *host,
265 host->cmd = NULL;
270 GOLDFISH_MMC_READ(host, MMC_RESP_0);
272 GOLDFISH_MMC_READ(host, MMC_RESP_1);
274 GOLDFISH_MMC_READ(host, MMC_RESP_2);
276 GOLDFISH_MMC_READ(host, MMC_RESP_3);
280 GOLDFISH_MMC_READ(host, MMC_RESP_0);
284 if (host->data == NULL || cmd->error) {
285 host->mrq = NULL;
286 mmc_request_done(host->mmc, cmd->mrq);
292 struct goldfish_mmc_host *host = (struct goldfish_mmc_host *)dev_id;
300 while ((status = GOLDFISH_MMC_READ(host, MMC_INT_STATUS)) != 0) {
301 GOLDFISH_MMC_WRITE(host, MMC_INT_STATUS, status);
319 struct mmc_request *mrq = host->mrq;
321 host->mrq = NULL;
322 mmc_request_done(host->mmc, mrq);
326 goldfish_mmc_cmd_done(host, host->cmd);
329 goldfish_mmc_xfer_done(host, host->data);
331 host->dma_done = 1;
332 goldfish_mmc_end_of_data(host, host->data);
333 } else if (host->data != NULL) {
336 * during device initialization, cases where host->data is
342 host->dma_done = 1;
343 goldfish_mmc_end_of_data(host, host->data);
347 u32 state = GOLDFISH_MMC_READ(host, MMC_STATE);
350 mmc_detect_change(host->mmc, 0);
355 status = GOLDFISH_MMC_READ(host, MMC_INT_STATUS);
356 dev_info(mmc_dev(host->mmc),"spurious irq 0x%04x\n", status);
358 GOLDFISH_MMC_WRITE(host, MMC_INT_STATUS, status);
359 GOLDFISH_MMC_WRITE(host, MMC_INT_ENABLE, 0);
366 static void goldfish_mmc_prepare_data(struct goldfish_mmc_host *host,
374 host->data = data;
376 GOLDFISH_MMC_WRITE(host, MMC_BLOCK_LENGTH, 0);
377 GOLDFISH_MMC_WRITE(host, MMC_BLOCK_COUNT, 0);
378 host->dma_in_use = 0;
384 GOLDFISH_MMC_WRITE(host, MMC_BLOCK_COUNT, data->blocks - 1);
385 GOLDFISH_MMC_WRITE(host, MMC_BLOCK_LENGTH, block_size - 1);
398 host->sg_len = dma_map_sg(mmc_dev(host->mmc), data->sg,
400 host->dma_done = 0;
401 host->dma_in_use = 1;
409 memcpy(host->virt_base, src, data->sg->length);
415 struct goldfish_mmc_host *host = mmc_priv(mmc);
417 WARN_ON(host->mrq != NULL);
419 host->mrq = req;
420 goldfish_mmc_prepare_data(host, req);
421 goldfish_mmc_start_command(host, req->cmd);
434 struct goldfish_mmc_host *host = mmc_priv(mmc);
436 host->bus_mode = ios->bus_mode;
437 host->hw_bus_mode = host->bus_mode;
443 struct goldfish_mmc_host *host = mmc_priv(mmc);
445 state = GOLDFISH_MMC_READ(host, MMC_STATE);
458 struct goldfish_mmc_host *host = NULL;
475 host = mmc_priv(mmc);
476 host->mmc = mmc;
479 host->reg_base = ioremap(res->start, resource_size(res));
480 if (host->reg_base == NULL) {
484 host->virt_base = dma_alloc_coherent(&pdev->dev, BUFFER_SIZE,
487 if (host->virt_base == 0) {
491 host->phys_base = buf_addr;
493 host->id = pdev->id;
494 host->irq = irq;
512 ret = request_irq(host->irq, goldfish_mmc_irq, 0, DRIVER_NAME, host);
518 host->dev = &pdev->dev;
519 platform_set_drvdata(pdev, host);
523 dev_warn(mmc_dev(host->mmc),
526 GOLDFISH_MMC_WRITE(host, MMC_SET_BUFFER, host->phys_base);
527 GOLDFISH_MMC_WRITE(host, MMC_INT_ENABLE,
535 dma_free_coherent(&pdev->dev, BUFFER_SIZE, host->virt_base,
536 host->phys_base);
538 iounmap(host->reg_base);
540 mmc_free_host(host->mmc);
547 struct goldfish_mmc_host *host = platform_get_drvdata(pdev);
549 BUG_ON(host == NULL);
551 mmc_remove_host(host->mmc);
552 free_irq(host->irq, host);
553 dma_free_coherent(&pdev->dev, BUFFER_SIZE, host->virt_base, host->phys_base);
554 iounmap(host->reg_base);
555 mmc_free_host(host->mmc);