Lines Matching defs:host
30 #include <linux/mmc/host.h>
52 #define GOLDFISH_MMC_READ(host, addr) (readl(host->reg_base + addr))
53 #define GOLDFISH_MMC_WRITE(host, addr, x) (writel(x, host->reg_base + addr))
128 goldfish_mmc_cover_is_open(struct goldfish_mmc_host *host)
137 struct goldfish_mmc_host *host = dev_get_drvdata(dev);
139 return sprintf(buf, "%s\n", goldfish_mmc_cover_is_open(host) ? "open" :
146 goldfish_mmc_start_command(struct goldfish_mmc_host *host, struct mmc_command *cmd)
152 host->cmd = cmd;
173 dev_err(mmc_dev(mmc_from_priv(host)),
189 if (host->bus_mode == MMC_BUSMODE_OPENDRAIN)
195 if (host->data && !(host->data->flags & MMC_DATA_WRITE))
198 GOLDFISH_MMC_WRITE(host, MMC_ARG, cmd->arg);
199 GOLDFISH_MMC_WRITE(host, MMC_CMD, cmdreg);
202 static void goldfish_mmc_xfer_done(struct goldfish_mmc_host *host,
205 if (host->dma_in_use) {
215 sg_copy_from_buffer(data->sg, 1, host->virt_base,
218 host->data->bytes_xfered += data->sg->length;
219 dma_unmap_sg(mmc_dev(mmc_from_priv(host)), data->sg,
220 host->sg_len, dma_data_dir);
223 host->data = NULL;
224 host->sg_len = 0;
233 host->mrq = NULL;
234 mmc_request_done(mmc_from_priv(host), data->mrq);
238 goldfish_mmc_start_command(host, data->stop);
241 static void goldfish_mmc_end_of_data(struct goldfish_mmc_host *host,
244 if (!host->dma_in_use) {
245 goldfish_mmc_xfer_done(host, data);
248 if (host->dma_done)
249 goldfish_mmc_xfer_done(host, data);
252 static void goldfish_mmc_cmd_done(struct goldfish_mmc_host *host,
255 host->cmd = NULL;
260 GOLDFISH_MMC_READ(host, MMC_RESP_0);
262 GOLDFISH_MMC_READ(host, MMC_RESP_1);
264 GOLDFISH_MMC_READ(host, MMC_RESP_2);
266 GOLDFISH_MMC_READ(host, MMC_RESP_3);
270 GOLDFISH_MMC_READ(host, MMC_RESP_0);
274 if (host->data == NULL || cmd->error) {
275 host->mrq = NULL;
276 mmc_request_done(mmc_from_priv(host), cmd->mrq);
282 struct goldfish_mmc_host *host = (struct goldfish_mmc_host *)dev_id;
289 while ((status = GOLDFISH_MMC_READ(host, MMC_INT_STATUS)) != 0) {
290 GOLDFISH_MMC_WRITE(host, MMC_INT_STATUS, status);
308 struct mmc_request *mrq = host->mrq;
310 host->mrq = NULL;
311 mmc_request_done(mmc_from_priv(host), mrq);
315 goldfish_mmc_cmd_done(host, host->cmd);
318 host->dma_done = 1;
319 goldfish_mmc_end_of_data(host, host->data);
320 } else if (host->data != NULL) {
323 * during device initialization, cases where host->data is
329 host->dma_done = 1;
330 goldfish_mmc_end_of_data(host, host->data);
334 u32 state = GOLDFISH_MMC_READ(host, MMC_STATE);
337 mmc_detect_change(mmc_from_priv(host), 0);
341 status = GOLDFISH_MMC_READ(host, MMC_INT_STATUS);
342 dev_info(mmc_dev(mmc_from_priv(host)), "spurious irq 0x%04x\n",
345 GOLDFISH_MMC_WRITE(host, MMC_INT_STATUS, status);
346 GOLDFISH_MMC_WRITE(host, MMC_INT_ENABLE, 0);
353 static void goldfish_mmc_prepare_data(struct goldfish_mmc_host *host,
361 host->data = data;
363 GOLDFISH_MMC_WRITE(host, MMC_BLOCK_LENGTH, 0);
364 GOLDFISH_MMC_WRITE(host, MMC_BLOCK_COUNT, 0);
365 host->dma_in_use = 0;
371 GOLDFISH_MMC_WRITE(host, MMC_BLOCK_COUNT, data->blocks - 1);
372 GOLDFISH_MMC_WRITE(host, MMC_BLOCK_LENGTH, block_size - 1);
382 host->sg_len = dma_map_sg(mmc_dev(mmc_from_priv(host)), data->sg,
384 host->dma_done = 0;
385 host->dma_in_use = 1;
392 sg_copy_to_buffer(data->sg, 1, host->virt_base,
399 struct goldfish_mmc_host *host = mmc_priv(mmc);
401 WARN_ON(host->mrq != NULL);
403 host->mrq = req;
404 goldfish_mmc_prepare_data(host, req);
405 goldfish_mmc_start_command(host, req->cmd);
410 struct goldfish_mmc_host *host = mmc_priv(mmc);
412 host->bus_mode = ios->bus_mode;
413 host->hw_bus_mode = host->bus_mode;
419 struct goldfish_mmc_host *host = mmc_priv(mmc);
421 state = GOLDFISH_MMC_READ(host, MMC_STATE);
434 struct goldfish_mmc_host *host = NULL;
451 host = mmc_priv(mmc);
454 host->reg_base = ioremap(res->start, resource_size(res));
455 if (host->reg_base == NULL) {
459 host->virt_base = dma_alloc_coherent(&pdev->dev, BUFFER_SIZE,
462 if (host->virt_base == 0) {
466 host->phys_base = buf_addr;
468 host->id = pdev->id;
469 host->irq = irq;
488 ret = request_irq(host->irq, goldfish_mmc_irq, 0, DRIVER_NAME, host);
494 host->dev = &pdev->dev;
495 platform_set_drvdata(pdev, host);
501 GOLDFISH_MMC_WRITE(host, MMC_SET_BUFFER, host->phys_base);
502 GOLDFISH_MMC_WRITE(host, MMC_INT_ENABLE,
510 dma_free_coherent(&pdev->dev, BUFFER_SIZE, host->virt_base,
511 host->phys_base);
513 iounmap(host->reg_base);
522 struct goldfish_mmc_host *host = platform_get_drvdata(pdev);
523 struct mmc_host *mmc = mmc_from_priv(host);
525 BUG_ON(host == NULL);
528 free_irq(host->irq, host);
529 dma_free_coherent(&pdev->dev, BUFFER_SIZE, host->virt_base, host->phys_base);
530 iounmap(host->reg_base);