blob: c1470e6b138de32586420bbe24a1a6a363dc1f6c [file] [log] [blame]
Guennadi Liakhovetskib6147492011-03-23 12:42:44 +01001/*
2 * linux/drivers/mmc/host/tmio_mmc.h
3 *
4 * Copyright (C) 2007 Ian Molton
5 * Copyright (C) 2004 Ian Molton
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 *
11 * Driver for the MMC / SD / SDIO cell found in:
12 *
13 * TC6393XB TC6391XB TC6387XB T7L66XB ASIC3
14 */
15
16#ifndef TMIO_MMC_H
17#define TMIO_MMC_H
18
19#include <linux/highmem.h>
Simon Hormancba179a2011-03-24 09:48:36 +010020#include <linux/mmc/tmio.h>
Guennadi Liakhovetskib6147492011-03-23 12:42:44 +010021#include <linux/pagemap.h>
22
Guennadi Liakhovetskib6147492011-03-23 12:42:44 +010023/* Definitions for values the CTRL_SDIO_STATUS register can take. */
Simon Hormancba179a2011-03-24 09:48:36 +010024#define TMIO_SDIO_STAT_IOIRQ 0x0001
Guennadi Liakhovetskib6147492011-03-23 12:42:44 +010025#define TMIO_SDIO_STAT_EXPUB52 0x4000
Simon Hormancba179a2011-03-24 09:48:36 +010026#define TMIO_SDIO_STAT_EXWT 0x8000
27#define TMIO_SDIO_MASK_ALL 0xc007
Guennadi Liakhovetskib6147492011-03-23 12:42:44 +010028
29/* Define some IRQ masks */
30/* This is the mask used at reset by the chip */
31#define TMIO_MASK_ALL 0x837f031d
32#define TMIO_MASK_READOP (TMIO_STAT_RXRDY | TMIO_STAT_DATAEND)
33#define TMIO_MASK_WRITEOP (TMIO_STAT_TXRQ | TMIO_STAT_DATAEND)
34#define TMIO_MASK_CMD (TMIO_STAT_CMDRESPEND | TMIO_STAT_CMDTIMEOUT | \
35 TMIO_STAT_CARD_REMOVE | TMIO_STAT_CARD_INSERT)
36#define TMIO_MASK_IRQ (TMIO_MASK_READOP | TMIO_MASK_WRITEOP | TMIO_MASK_CMD)
37
38struct tmio_mmc_data;
39
40struct tmio_mmc_host {
41 void __iomem *ctl;
42 unsigned long bus_shift;
43 struct mmc_command *cmd;
44 struct mmc_request *mrq;
45 struct mmc_data *data;
46 struct mmc_host *mmc;
47 int irq;
48 unsigned int sdio_irq_enabled;
49
50 /* Callbacks for clock / power control */
51 void (*set_pwr)(struct platform_device *host, int state);
52 void (*set_clk_div)(struct platform_device *host, int state);
53
Guennadi Liakhovetskie6ee7182011-05-05 16:13:12 +000054 int pm_error;
55
Guennadi Liakhovetskib6147492011-03-23 12:42:44 +010056 /* pio related stuff */
57 struct scatterlist *sg_ptr;
58 struct scatterlist *sg_orig;
59 unsigned int sg_len;
60 unsigned int sg_off;
61
62 struct platform_device *pdev;
63 struct tmio_mmc_data *pdata;
64
65 /* DMA support */
66 bool force_pio;
67 struct dma_chan *chan_rx;
68 struct dma_chan *chan_tx;
69 struct tasklet_struct dma_complete;
70 struct tasklet_struct dma_issue;
71 struct scatterlist bounce_sg;
72 u8 *bounce_buf;
73
74 /* Track lost interrupts */
75 struct delayed_work delayed_reset_work;
76 spinlock_t lock;
77 unsigned long last_req_ts;
78};
79
80int tmio_mmc_host_probe(struct tmio_mmc_host **host,
81 struct platform_device *pdev,
82 struct tmio_mmc_data *pdata);
83void tmio_mmc_host_remove(struct tmio_mmc_host *host);
84void tmio_mmc_do_data_irq(struct tmio_mmc_host *host);
85
86void tmio_mmc_enable_mmc_irqs(struct tmio_mmc_host *host, u32 i);
87void tmio_mmc_disable_mmc_irqs(struct tmio_mmc_host *host, u32 i);
88
89static inline char *tmio_mmc_kmap_atomic(struct scatterlist *sg,
90 unsigned long *flags)
91{
92 local_irq_save(*flags);
93 return kmap_atomic(sg_page(sg), KM_BIO_SRC_IRQ) + sg->offset;
94}
95
96static inline void tmio_mmc_kunmap_atomic(struct scatterlist *sg,
97 unsigned long *flags, void *virt)
98{
99 kunmap_atomic(virt - sg->offset, KM_BIO_SRC_IRQ);
100 local_irq_restore(*flags);
101}
102
Guennadi Liakhovetski42051e82011-03-14 09:52:33 +0100103#if defined(CONFIG_MMC_SDHI) || defined(CONFIG_MMC_SDHI_MODULE)
Guennadi Liakhovetskib6147492011-03-23 12:42:44 +0100104void tmio_mmc_start_dma(struct tmio_mmc_host *host, struct mmc_data *data);
105void tmio_mmc_request_dma(struct tmio_mmc_host *host, struct tmio_mmc_data *pdata);
106void tmio_mmc_release_dma(struct tmio_mmc_host *host);
107#else
108static inline void tmio_mmc_start_dma(struct tmio_mmc_host *host,
109 struct mmc_data *data)
110{
111}
112
113static inline void tmio_mmc_request_dma(struct tmio_mmc_host *host,
114 struct tmio_mmc_data *pdata)
115{
116 host->chan_tx = NULL;
117 host->chan_rx = NULL;
118}
119
120static inline void tmio_mmc_release_dma(struct tmio_mmc_host *host)
121{
122}
123#endif
124
Guennadi Liakhovetskie6ee7182011-05-05 16:13:12 +0000125#ifdef CONFIG_PM
126int tmio_mmc_host_suspend(struct device *dev);
127int tmio_mmc_host_resume(struct device *dev);
128#else
129#define tmio_mmc_host_suspend NULL
130#define tmio_mmc_host_resume NULL
131#endif
132
Guennadi Liakhovetskib6147492011-03-23 12:42:44 +0100133#endif