hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/mmc/host/tmio_mmc.h
....@@ -1,18 +1,14 @@
1
+/* SPDX-License-Identifier: GPL-2.0 */
12 /*
23 * Driver for the MMC / SD / SDIO cell found in:
34 *
45 * TC6393XB TC6391XB TC6387XB T7L66XB ASIC3
56 *
6
- * Copyright (C) 2015-17 Renesas Electronics Corporation
7
- * Copyright (C) 2016-17 Sang Engineering, Wolfram Sang
7
+ * Copyright (C) 2015-19 Renesas Electronics Corporation
8
+ * Copyright (C) 2016-19 Sang Engineering, Wolfram Sang
89 * Copyright (C) 2016-17 Horms Solutions, Simon Horman
910 * Copyright (C) 2007 Ian Molton
1011 * Copyright (C) 2004 Ian Molton
11
- *
12
- * This program is free software; you can redistribute it and/or modify
13
- * it under the terms of the GNU General Public License version 2 as
14
- * published by the Free Software Foundation.
15
- *
1612 */
1713
1814 #ifndef TMIO_MMC_H
....@@ -47,9 +43,6 @@
4743 #define CTL_RESET_SD 0xe0
4844 #define CTL_VERSION 0xe2
4945 #define CTL_SDIF_MODE 0xe6
50
-#define CTL_SDIO_REGS 0x100
51
-#define CTL_CLK_AND_WAIT_CTL 0x138
52
-#define CTL_RESET_SDIO 0x1e0
5346
5447 /* Definitions for values the CTL_STOP_INTERNAL_ACTION register can take */
5548 #define TMIO_STOP_STP BIT(0)
....@@ -77,6 +70,7 @@
7770 #define TMIO_STAT_DAT0 BIT(23) /* only known on R-Car so far */
7871 #define TMIO_STAT_RXRDY BIT(24)
7972 #define TMIO_STAT_TXRQ BIT(25)
73
+#define TMIO_STAT_ALWAYS_SET_27 BIT(27) /* only known on R-Car 2+ so far */
8074 #define TMIO_STAT_ILL_FUNC BIT(29) /* only when !TMIO_MMC_HAS_IDLE_WAIT */
8175 #define TMIO_STAT_SCLKDIVEN BIT(29) /* only when TMIO_MMC_HAS_IDLE_WAIT */
8276 #define TMIO_STAT_CMD_BUSY BIT(30)
....@@ -103,12 +97,15 @@
10397
10498 /* Define some IRQ masks */
10599 /* This is the mask used at reset by the chip */
100
+#define TMIO_MASK_INIT_RCAR2 0x8b7f031d /* Initial value for R-Car Gen2+ */
106101 #define TMIO_MASK_ALL 0x837f031d
107102 #define TMIO_MASK_READOP (TMIO_STAT_RXRDY | TMIO_STAT_DATAEND)
108103 #define TMIO_MASK_WRITEOP (TMIO_STAT_TXRQ | TMIO_STAT_DATAEND)
109104 #define TMIO_MASK_CMD (TMIO_STAT_CMDRESPEND | TMIO_STAT_CMDTIMEOUT | \
110105 TMIO_STAT_CARD_REMOVE | TMIO_STAT_CARD_INSERT)
111106 #define TMIO_MASK_IRQ (TMIO_MASK_READOP | TMIO_MASK_WRITEOP | TMIO_MASK_CMD)
107
+
108
+#define TMIO_MAX_BLK_SIZE 512
112109
113110 struct tmio_mmc_data;
114111 struct tmio_mmc_host;
....@@ -121,6 +118,9 @@
121118 void (*release)(struct tmio_mmc_host *host);
122119 void (*abort)(struct tmio_mmc_host *host);
123120 void (*dataend)(struct tmio_mmc_host *host);
121
+
122
+ /* optional */
123
+ void (*end)(struct tmio_mmc_host *host); /* held host->lock */
124124 };
125125
126126 struct tmio_mmc_host {
....@@ -133,7 +133,6 @@
133133
134134 /* Callbacks for clock / power control */
135135 void (*set_pwr)(struct platform_device *host, int state);
136
- void (*set_clk_div)(struct platform_device *host, int state);
137136
138137 /* pio related stuff */
139138 struct scatterlist *sg_ptr;
....@@ -146,7 +145,7 @@
146145 struct tmio_mmc_data *pdata;
147146
148147 /* DMA support */
149
- bool force_pio;
148
+ bool dma_on;
150149 struct dma_chan *chan_rx;
151150 struct dma_chan *chan_tx;
152151 struct tasklet_struct dma_issue;
....@@ -161,6 +160,7 @@
161160 u32 sdcard_irq_mask;
162161 u32 sdio_irq_mask;
163162 unsigned int clk_cache;
163
+ u32 sdcard_irq_setbit_mask;
164164
165165 spinlock_t lock; /* protect host private data */
166166 unsigned long last_req_ts;
....@@ -170,29 +170,16 @@
170170
171171 /* Mandatory callback */
172172 int (*clk_enable)(struct tmio_mmc_host *host);
173
+ void (*set_clock)(struct tmio_mmc_host *host, unsigned int clock);
173174
174175 /* Optional callbacks */
175
- unsigned int (*clk_update)(struct tmio_mmc_host *host,
176
- unsigned int new_clock);
177176 void (*clk_disable)(struct tmio_mmc_host *host);
178177 int (*multi_io_quirk)(struct mmc_card *card,
179178 unsigned int direction, int blk_size);
180179 int (*write16_hook)(struct tmio_mmc_host *host, int addr);
181
- void (*hw_reset)(struct tmio_mmc_host *host);
182
- void (*prepare_tuning)(struct tmio_mmc_host *host, unsigned long tap);
183
- bool (*check_scc_error)(struct tmio_mmc_host *host);
184
-
185
- /*
186
- * Mandatory callback for tuning to occur which is optional for SDR50
187
- * and mandatory for SDR104.
188
- */
189
- unsigned int (*init_tuning)(struct tmio_mmc_host *host);
190
- int (*select_tuning)(struct tmio_mmc_host *host);
191
-
192
- /* Tuning values: 1 for success, 0 for failure */
193
- DECLARE_BITMAP(taps, BITS_PER_BYTE * sizeof(long));
194
- unsigned int tap_num;
195
- unsigned long tap_set;
180
+ void (*reset)(struct tmio_mmc_host *host);
181
+ bool (*check_retune)(struct tmio_mmc_host *host);
182
+ void (*fixup_request)(struct tmio_mmc_host *host, struct mmc_request *mrq);
196183
197184 void (*prepare_hs400_tuning)(struct tmio_mmc_host *host);
198185 void (*hs400_downgrade)(struct tmio_mmc_host *host);
....@@ -275,6 +262,9 @@
275262 static inline void sd_ctrl_write32_as_16_and_16(struct tmio_mmc_host *host,
276263 int addr, u32 val)
277264 {
265
+ if (addr == CTL_IRQ_MASK || addr == CTL_STATUS)
266
+ val |= host->sdcard_irq_setbit_mask;
267
+
278268 iowrite16(val & 0xffff, host->ctl + (addr << host->bus_shift));
279269 iowrite16(val >> 16, host->ctl + ((addr + 2) << host->bus_shift));
280270 }