blob: bfce8a2e4a6cd410394b3738031d795ec2aac1c4 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Patrice Chotardae19b812017-09-04 17:56:22 +02002/*
Patrice Chotard789ee0e2017-10-23 09:53:58 +02003 * Copyright (C) 2017, STMicroelectronics - All Rights Reserved
Patrice Chotard5d9950d2020-12-02 18:47:30 +01004 * Author(s): Patrice Chotard, <patrice.chotard@foss.st.com> for STMicroelectronics.
Patrice Chotardae19b812017-09-04 17:56:22 +02005 */
6
Patrick Delaunay758de432020-11-06 19:01:37 +01007#define LOG_CATEGORY UCLASS_MMC
8
Patrice Chotardae19b812017-09-04 17:56:22 +02009#include <common.h>
10#include <clk.h>
Simon Glass63334482019-11-14 12:57:39 -070011#include <cpu_func.h>
Patrice Chotardae19b812017-09-04 17:56:22 +020012#include <dm.h>
13#include <fdtdec.h>
Simon Glass0f2af882020-05-10 11:40:05 -060014#include <log.h>
Simon Glass9bc15642020-02-03 07:36:16 -070015#include <malloc.h>
Simon Glass4dcacfc2020-05-10 11:40:13 -060016#include <asm/bitops.h>
Simon Glass274e0b02020-05-10 11:39:56 -060017#include <asm/cache.h>
Patrick Delaunay758de432020-11-06 19:01:37 +010018#include <dm/device_compat.h>
Marek Vasut98a12052021-11-13 03:29:43 +010019#include <dm/pinctrl.h>
Simon Glass4dcacfc2020-05-10 11:40:13 -060020#include <linux/bitops.h>
Simon Glassdbd79542020-05-10 11:40:11 -060021#include <linux/delay.h>
Masahiro Yamada75f82d02018-03-05 01:20:11 +090022#include <linux/libfdt.h>
Patrice Chotardae19b812017-09-04 17:56:22 +020023#include <mmc.h>
24#include <reset.h>
25#include <asm/io.h>
26#include <asm/gpio.h>
27#include <linux/iopoll.h>
Christophe Kerelloe0452e82019-07-30 19:16:45 +020028#include <watchdog.h>
Patrice Chotardae19b812017-09-04 17:56:22 +020029
30struct stm32_sdmmc2_plat {
31 struct mmc_config cfg;
32 struct mmc mmc;
Patrice Chotardae19b812017-09-04 17:56:22 +020033 fdt_addr_t base;
34 struct clk clk;
35 struct reset_ctl reset_ctl;
36 struct gpio_desc cd_gpio;
37 u32 clk_reg_msk;
38 u32 pwr_reg_msk;
39};
40
41struct stm32_sdmmc2_ctx {
42 u32 cache_start;
43 u32 cache_end;
44 u32 data_length;
45 bool dpsm_abort;
46};
47
48/* SDMMC REGISTERS OFFSET */
49#define SDMMC_POWER 0x00 /* SDMMC power control */
50#define SDMMC_CLKCR 0x04 /* SDMMC clock control */
51#define SDMMC_ARG 0x08 /* SDMMC argument */
52#define SDMMC_CMD 0x0C /* SDMMC command */
53#define SDMMC_RESP1 0x14 /* SDMMC response 1 */
54#define SDMMC_RESP2 0x18 /* SDMMC response 2 */
55#define SDMMC_RESP3 0x1C /* SDMMC response 3 */
56#define SDMMC_RESP4 0x20 /* SDMMC response 4 */
57#define SDMMC_DTIMER 0x24 /* SDMMC data timer */
58#define SDMMC_DLEN 0x28 /* SDMMC data length */
59#define SDMMC_DCTRL 0x2C /* SDMMC data control */
60#define SDMMC_DCOUNT 0x30 /* SDMMC data counter */
61#define SDMMC_STA 0x34 /* SDMMC status */
62#define SDMMC_ICR 0x38 /* SDMMC interrupt clear */
63#define SDMMC_MASK 0x3C /* SDMMC mask */
64#define SDMMC_IDMACTRL 0x50 /* SDMMC DMA control */
65#define SDMMC_IDMABASE0 0x58 /* SDMMC DMA buffer 0 base address */
66
67/* SDMMC_POWER register */
Patrick Delaunay69351082018-06-27 10:15:33 +020068#define SDMMC_POWER_PWRCTRL_MASK GENMASK(1, 0)
69#define SDMMC_POWER_PWRCTRL_OFF 0
70#define SDMMC_POWER_PWRCTRL_CYCLE 2
71#define SDMMC_POWER_PWRCTRL_ON 3
Patrice Chotardae19b812017-09-04 17:56:22 +020072#define SDMMC_POWER_VSWITCH BIT(2)
73#define SDMMC_POWER_VSWITCHEN BIT(3)
74#define SDMMC_POWER_DIRPOL BIT(4)
75
76/* SDMMC_CLKCR register */
77#define SDMMC_CLKCR_CLKDIV GENMASK(9, 0)
78#define SDMMC_CLKCR_CLKDIV_MAX SDMMC_CLKCR_CLKDIV
79#define SDMMC_CLKCR_PWRSAV BIT(12)
80#define SDMMC_CLKCR_WIDBUS_4 BIT(14)
81#define SDMMC_CLKCR_WIDBUS_8 BIT(15)
82#define SDMMC_CLKCR_NEGEDGE BIT(16)
83#define SDMMC_CLKCR_HWFC_EN BIT(17)
84#define SDMMC_CLKCR_DDR BIT(18)
85#define SDMMC_CLKCR_BUSSPEED BIT(19)
Patrick Delaunaya36da362018-02-07 17:19:59 +010086#define SDMMC_CLKCR_SELCLKRX_MASK GENMASK(21, 20)
87#define SDMMC_CLKCR_SELCLKRX_CK 0
88#define SDMMC_CLKCR_SELCLKRX_CKIN BIT(20)
89#define SDMMC_CLKCR_SELCLKRX_FBCK BIT(21)
Patrice Chotardae19b812017-09-04 17:56:22 +020090
91/* SDMMC_CMD register */
92#define SDMMC_CMD_CMDINDEX GENMASK(5, 0)
93#define SDMMC_CMD_CMDTRANS BIT(6)
94#define SDMMC_CMD_CMDSTOP BIT(7)
95#define SDMMC_CMD_WAITRESP GENMASK(9, 8)
96#define SDMMC_CMD_WAITRESP_0 BIT(8)
97#define SDMMC_CMD_WAITRESP_1 BIT(9)
98#define SDMMC_CMD_WAITINT BIT(10)
99#define SDMMC_CMD_WAITPEND BIT(11)
100#define SDMMC_CMD_CPSMEN BIT(12)
101#define SDMMC_CMD_DTHOLD BIT(13)
102#define SDMMC_CMD_BOOTMODE BIT(14)
103#define SDMMC_CMD_BOOTEN BIT(15)
104#define SDMMC_CMD_CMDSUSPEND BIT(16)
105
106/* SDMMC_DCTRL register */
107#define SDMMC_DCTRL_DTEN BIT(0)
108#define SDMMC_DCTRL_DTDIR BIT(1)
109#define SDMMC_DCTRL_DTMODE GENMASK(3, 2)
110#define SDMMC_DCTRL_DBLOCKSIZE GENMASK(7, 4)
111#define SDMMC_DCTRL_DBLOCKSIZE_SHIFT 4
112#define SDMMC_DCTRL_RWSTART BIT(8)
113#define SDMMC_DCTRL_RWSTOP BIT(9)
114#define SDMMC_DCTRL_RWMOD BIT(10)
115#define SDMMC_DCTRL_SDMMCEN BIT(11)
116#define SDMMC_DCTRL_BOOTACKEN BIT(12)
117#define SDMMC_DCTRL_FIFORST BIT(13)
118
119/* SDMMC_STA register */
120#define SDMMC_STA_CCRCFAIL BIT(0)
121#define SDMMC_STA_DCRCFAIL BIT(1)
122#define SDMMC_STA_CTIMEOUT BIT(2)
123#define SDMMC_STA_DTIMEOUT BIT(3)
124#define SDMMC_STA_TXUNDERR BIT(4)
125#define SDMMC_STA_RXOVERR BIT(5)
126#define SDMMC_STA_CMDREND BIT(6)
127#define SDMMC_STA_CMDSENT BIT(7)
128#define SDMMC_STA_DATAEND BIT(8)
129#define SDMMC_STA_DHOLD BIT(9)
130#define SDMMC_STA_DBCKEND BIT(10)
131#define SDMMC_STA_DABORT BIT(11)
132#define SDMMC_STA_DPSMACT BIT(12)
133#define SDMMC_STA_CPSMACT BIT(13)
134#define SDMMC_STA_TXFIFOHE BIT(14)
135#define SDMMC_STA_RXFIFOHF BIT(15)
136#define SDMMC_STA_TXFIFOF BIT(16)
137#define SDMMC_STA_RXFIFOF BIT(17)
138#define SDMMC_STA_TXFIFOE BIT(18)
139#define SDMMC_STA_RXFIFOE BIT(19)
140#define SDMMC_STA_BUSYD0 BIT(20)
141#define SDMMC_STA_BUSYD0END BIT(21)
142#define SDMMC_STA_SDMMCIT BIT(22)
143#define SDMMC_STA_ACKFAIL BIT(23)
144#define SDMMC_STA_ACKTIMEOUT BIT(24)
145#define SDMMC_STA_VSWEND BIT(25)
146#define SDMMC_STA_CKSTOP BIT(26)
147#define SDMMC_STA_IDMATE BIT(27)
148#define SDMMC_STA_IDMABTC BIT(28)
149
150/* SDMMC_ICR register */
151#define SDMMC_ICR_CCRCFAILC BIT(0)
152#define SDMMC_ICR_DCRCFAILC BIT(1)
153#define SDMMC_ICR_CTIMEOUTC BIT(2)
154#define SDMMC_ICR_DTIMEOUTC BIT(3)
155#define SDMMC_ICR_TXUNDERRC BIT(4)
156#define SDMMC_ICR_RXOVERRC BIT(5)
157#define SDMMC_ICR_CMDRENDC BIT(6)
158#define SDMMC_ICR_CMDSENTC BIT(7)
159#define SDMMC_ICR_DATAENDC BIT(8)
160#define SDMMC_ICR_DHOLDC BIT(9)
161#define SDMMC_ICR_DBCKENDC BIT(10)
162#define SDMMC_ICR_DABORTC BIT(11)
163#define SDMMC_ICR_BUSYD0ENDC BIT(21)
164#define SDMMC_ICR_SDMMCITC BIT(22)
165#define SDMMC_ICR_ACKFAILC BIT(23)
166#define SDMMC_ICR_ACKTIMEOUTC BIT(24)
167#define SDMMC_ICR_VSWENDC BIT(25)
168#define SDMMC_ICR_CKSTOPC BIT(26)
169#define SDMMC_ICR_IDMATEC BIT(27)
170#define SDMMC_ICR_IDMABTCC BIT(28)
171#define SDMMC_ICR_STATIC_FLAGS ((GENMASK(28, 21)) | (GENMASK(11, 0)))
172
173/* SDMMC_MASK register */
174#define SDMMC_MASK_CCRCFAILIE BIT(0)
175#define SDMMC_MASK_DCRCFAILIE BIT(1)
176#define SDMMC_MASK_CTIMEOUTIE BIT(2)
177#define SDMMC_MASK_DTIMEOUTIE BIT(3)
178#define SDMMC_MASK_TXUNDERRIE BIT(4)
179#define SDMMC_MASK_RXOVERRIE BIT(5)
180#define SDMMC_MASK_CMDRENDIE BIT(6)
181#define SDMMC_MASK_CMDSENTIE BIT(7)
182#define SDMMC_MASK_DATAENDIE BIT(8)
183#define SDMMC_MASK_DHOLDIE BIT(9)
184#define SDMMC_MASK_DBCKENDIE BIT(10)
185#define SDMMC_MASK_DABORTIE BIT(11)
186#define SDMMC_MASK_TXFIFOHEIE BIT(14)
187#define SDMMC_MASK_RXFIFOHFIE BIT(15)
188#define SDMMC_MASK_RXFIFOFIE BIT(17)
189#define SDMMC_MASK_TXFIFOEIE BIT(18)
190#define SDMMC_MASK_BUSYD0ENDIE BIT(21)
191#define SDMMC_MASK_SDMMCITIE BIT(22)
192#define SDMMC_MASK_ACKFAILIE BIT(23)
193#define SDMMC_MASK_ACKTIMEOUTIE BIT(24)
194#define SDMMC_MASK_VSWENDIE BIT(25)
195#define SDMMC_MASK_CKSTOPIE BIT(26)
196#define SDMMC_MASK_IDMABTCIE BIT(28)
197
198/* SDMMC_IDMACTRL register */
199#define SDMMC_IDMACTRL_IDMAEN BIT(0)
200
201#define SDMMC_CMD_TIMEOUT 0xFFFFFFFF
Patrice Chotardbd16b4c2019-07-22 11:41:10 +0200202#define SDMMC_BUSYD0END_TIMEOUT_US 2000000
Patrice Chotardae19b812017-09-04 17:56:22 +0200203
Patrick Delaunay758de432020-11-06 19:01:37 +0100204static void stm32_sdmmc2_start_data(struct udevice *dev,
Patrice Chotardae19b812017-09-04 17:56:22 +0200205 struct mmc_data *data,
206 struct stm32_sdmmc2_ctx *ctx)
207{
Patrick Delaunayf375d372022-06-30 10:01:46 +0200208 struct stm32_sdmmc2_plat *plat = dev_get_plat(dev);
Patrice Chotardae19b812017-09-04 17:56:22 +0200209 u32 data_ctrl, idmabase0;
210
211 /* Configure the SDMMC DPSM (Data Path State Machine) */
212 data_ctrl = (__ilog2(data->blocksize) <<
213 SDMMC_DCTRL_DBLOCKSIZE_SHIFT) &
214 SDMMC_DCTRL_DBLOCKSIZE;
215
216 if (data->flags & MMC_DATA_READ) {
217 data_ctrl |= SDMMC_DCTRL_DTDIR;
218 idmabase0 = (u32)data->dest;
219 } else {
220 idmabase0 = (u32)data->src;
221 }
222
Patrice Chotardae19b812017-09-04 17:56:22 +0200223 /* Set the SDMMC DataLength value */
Patrick Delaunayf375d372022-06-30 10:01:46 +0200224 writel(ctx->data_length, plat->base + SDMMC_DLEN);
Patrice Chotardae19b812017-09-04 17:56:22 +0200225
226 /* Write to SDMMC DCTRL */
Patrick Delaunayf375d372022-06-30 10:01:46 +0200227 writel(data_ctrl, plat->base + SDMMC_DCTRL);
Patrice Chotardae19b812017-09-04 17:56:22 +0200228
229 /* Cache align */
230 ctx->cache_start = rounddown(idmabase0, ARCH_DMA_MINALIGN);
231 ctx->cache_end = roundup(idmabase0 + ctx->data_length,
232 ARCH_DMA_MINALIGN);
233
234 /*
235 * Flush data cache before DMA start (clean and invalidate)
236 * Clean also needed for read
237 * Avoid issue on buffer not cached-aligned
238 */
239 flush_dcache_range(ctx->cache_start, ctx->cache_end);
240
241 /* Enable internal DMA */
Patrick Delaunayf375d372022-06-30 10:01:46 +0200242 writel(idmabase0, plat->base + SDMMC_IDMABASE0);
243 writel(SDMMC_IDMACTRL_IDMAEN, plat->base + SDMMC_IDMACTRL);
Patrice Chotardae19b812017-09-04 17:56:22 +0200244}
245
Patrick Delaunay758de432020-11-06 19:01:37 +0100246static void stm32_sdmmc2_start_cmd(struct udevice *dev,
Christophe Kerello8a0b5232018-12-06 15:58:10 +0100247 struct mmc_cmd *cmd, u32 cmd_param,
248 struct stm32_sdmmc2_ctx *ctx)
Patrice Chotardae19b812017-09-04 17:56:22 +0200249{
Patrick Delaunayf375d372022-06-30 10:01:46 +0200250 struct stm32_sdmmc2_plat *plat = dev_get_plat(dev);
Christophe Kerello8a0b5232018-12-06 15:58:10 +0100251 u32 timeout = 0;
252
Patrick Delaunayf375d372022-06-30 10:01:46 +0200253 if (readl(plat->base + SDMMC_CMD) & SDMMC_CMD_CPSMEN)
254 writel(0, plat->base + SDMMC_CMD);
Patrice Chotardae19b812017-09-04 17:56:22 +0200255
256 cmd_param |= cmd->cmdidx | SDMMC_CMD_CPSMEN;
257 if (cmd->resp_type & MMC_RSP_PRESENT) {
258 if (cmd->resp_type & MMC_RSP_136)
259 cmd_param |= SDMMC_CMD_WAITRESP;
260 else if (cmd->resp_type & MMC_RSP_CRC)
261 cmd_param |= SDMMC_CMD_WAITRESP_0;
262 else
263 cmd_param |= SDMMC_CMD_WAITRESP_1;
264 }
265
Christophe Kerello8a0b5232018-12-06 15:58:10 +0100266 /*
267 * SDMMC_DTIME must be set in two case:
268 * - on data transfert.
269 * - on busy request.
270 * If not done or too short, the dtimeout flag occurs and DPSM stays
271 * enabled/busy and waits for abort (stop transmission cmd).
272 * Next data command is not possible whereas DPSM is activated.
273 */
274 if (ctx->data_length) {
275 timeout = SDMMC_CMD_TIMEOUT;
276 } else {
Patrick Delaunayf375d372022-06-30 10:01:46 +0200277 writel(0, plat->base + SDMMC_DCTRL);
Christophe Kerello8a0b5232018-12-06 15:58:10 +0100278
279 if (cmd->resp_type & MMC_RSP_BUSY)
280 timeout = SDMMC_CMD_TIMEOUT;
281 }
282
283 /* Set the SDMMC Data TimeOut value */
Patrick Delaunayf375d372022-06-30 10:01:46 +0200284 writel(timeout, plat->base + SDMMC_DTIMER);
Christophe Kerello8a0b5232018-12-06 15:58:10 +0100285
Patrice Chotardae19b812017-09-04 17:56:22 +0200286 /* Clear flags */
Patrick Delaunayf375d372022-06-30 10:01:46 +0200287 writel(SDMMC_ICR_STATIC_FLAGS, plat->base + SDMMC_ICR);
Patrice Chotardae19b812017-09-04 17:56:22 +0200288
289 /* Set SDMMC argument value */
Patrick Delaunayf375d372022-06-30 10:01:46 +0200290 writel(cmd->cmdarg, plat->base + SDMMC_ARG);
Patrice Chotardae19b812017-09-04 17:56:22 +0200291
292 /* Set SDMMC command parameters */
Patrick Delaunayf375d372022-06-30 10:01:46 +0200293 writel(cmd_param, plat->base + SDMMC_CMD);
Patrice Chotardae19b812017-09-04 17:56:22 +0200294}
295
Patrick Delaunay758de432020-11-06 19:01:37 +0100296static int stm32_sdmmc2_end_cmd(struct udevice *dev,
Patrice Chotardae19b812017-09-04 17:56:22 +0200297 struct mmc_cmd *cmd,
298 struct stm32_sdmmc2_ctx *ctx)
299{
Patrick Delaunayf375d372022-06-30 10:01:46 +0200300 struct stm32_sdmmc2_plat *plat = dev_get_plat(dev);
Patrice Chotardae19b812017-09-04 17:56:22 +0200301 u32 mask = SDMMC_STA_CTIMEOUT;
302 u32 status;
303 int ret;
304
305 if (cmd->resp_type & MMC_RSP_PRESENT) {
306 mask |= SDMMC_STA_CMDREND;
307 if (cmd->resp_type & MMC_RSP_CRC)
308 mask |= SDMMC_STA_CCRCFAIL;
309 } else {
310 mask |= SDMMC_STA_CMDSENT;
311 }
312
313 /* Polling status register */
Patrick Delaunayf375d372022-06-30 10:01:46 +0200314 ret = readl_poll_timeout(plat->base + SDMMC_STA, status, status & mask,
Christophe Kerelloc9ab62c2017-10-09 17:02:28 +0200315 10000);
Patrice Chotardae19b812017-09-04 17:56:22 +0200316
317 if (ret < 0) {
Patrick Delaunay758de432020-11-06 19:01:37 +0100318 dev_dbg(dev, "timeout reading SDMMC_STA register\n");
Patrice Chotardae19b812017-09-04 17:56:22 +0200319 ctx->dpsm_abort = true;
320 return ret;
321 }
322
323 /* Check status */
324 if (status & SDMMC_STA_CTIMEOUT) {
Patrick Delaunay758de432020-11-06 19:01:37 +0100325 dev_dbg(dev, "error SDMMC_STA_CTIMEOUT (0x%x) for cmd %d\n",
326 status, cmd->cmdidx);
Patrice Chotardae19b812017-09-04 17:56:22 +0200327 ctx->dpsm_abort = true;
328 return -ETIMEDOUT;
329 }
330
331 if (status & SDMMC_STA_CCRCFAIL && cmd->resp_type & MMC_RSP_CRC) {
Patrick Delaunay758de432020-11-06 19:01:37 +0100332 dev_dbg(dev, "error SDMMC_STA_CCRCFAIL (0x%x) for cmd %d\n",
333 status, cmd->cmdidx);
Patrice Chotardae19b812017-09-04 17:56:22 +0200334 ctx->dpsm_abort = true;
335 return -EILSEQ;
336 }
337
338 if (status & SDMMC_STA_CMDREND && cmd->resp_type & MMC_RSP_PRESENT) {
Patrick Delaunayf375d372022-06-30 10:01:46 +0200339 cmd->response[0] = readl(plat->base + SDMMC_RESP1);
Patrice Chotardae19b812017-09-04 17:56:22 +0200340 if (cmd->resp_type & MMC_RSP_136) {
Patrick Delaunayf375d372022-06-30 10:01:46 +0200341 cmd->response[1] = readl(plat->base + SDMMC_RESP2);
342 cmd->response[2] = readl(plat->base + SDMMC_RESP3);
343 cmd->response[3] = readl(plat->base + SDMMC_RESP4);
Patrice Chotardae19b812017-09-04 17:56:22 +0200344 }
Christophe Kerello8a0b5232018-12-06 15:58:10 +0100345
346 /* Wait for BUSYD0END flag if busy status is detected */
347 if (cmd->resp_type & MMC_RSP_BUSY &&
348 status & SDMMC_STA_BUSYD0) {
349 mask = SDMMC_STA_DTIMEOUT | SDMMC_STA_BUSYD0END;
350
351 /* Polling status register */
Patrick Delaunayf375d372022-06-30 10:01:46 +0200352 ret = readl_poll_timeout(plat->base + SDMMC_STA,
Christophe Kerello8a0b5232018-12-06 15:58:10 +0100353 status, status & mask,
354 SDMMC_BUSYD0END_TIMEOUT_US);
355
356 if (ret < 0) {
Patrick Delaunay758de432020-11-06 19:01:37 +0100357 dev_dbg(dev, "timeout reading SDMMC_STA\n");
Christophe Kerello8a0b5232018-12-06 15:58:10 +0100358 ctx->dpsm_abort = true;
359 return ret;
360 }
361
362 if (status & SDMMC_STA_DTIMEOUT) {
Patrick Delaunay758de432020-11-06 19:01:37 +0100363 dev_dbg(dev,
364 "error SDMMC_STA_DTIMEOUT (0x%x)\n",
365 status);
Christophe Kerello8a0b5232018-12-06 15:58:10 +0100366 ctx->dpsm_abort = true;
367 return -ETIMEDOUT;
368 }
369 }
Patrice Chotardae19b812017-09-04 17:56:22 +0200370 }
371
372 return 0;
373}
374
Patrick Delaunay758de432020-11-06 19:01:37 +0100375static int stm32_sdmmc2_end_data(struct udevice *dev,
Patrice Chotardae19b812017-09-04 17:56:22 +0200376 struct mmc_cmd *cmd,
377 struct mmc_data *data,
378 struct stm32_sdmmc2_ctx *ctx)
379{
Patrick Delaunayf375d372022-06-30 10:01:46 +0200380 struct stm32_sdmmc2_plat *plat = dev_get_plat(dev);
Patrice Chotardae19b812017-09-04 17:56:22 +0200381 u32 mask = SDMMC_STA_DCRCFAIL | SDMMC_STA_DTIMEOUT |
382 SDMMC_STA_IDMATE | SDMMC_STA_DATAEND;
383 u32 status;
384
385 if (data->flags & MMC_DATA_READ)
386 mask |= SDMMC_STA_RXOVERR;
387 else
388 mask |= SDMMC_STA_TXUNDERR;
389
Patrick Delaunayf375d372022-06-30 10:01:46 +0200390 status = readl(plat->base + SDMMC_STA);
Patrice Chotardae19b812017-09-04 17:56:22 +0200391 while (!(status & mask))
Patrick Delaunayf375d372022-06-30 10:01:46 +0200392 status = readl(plat->base + SDMMC_STA);
Patrice Chotardae19b812017-09-04 17:56:22 +0200393
394 /*
395 * Need invalidate the dcache again to avoid any
396 * cache-refill during the DMA operations (pre-fetching)
397 */
398 if (data->flags & MMC_DATA_READ)
399 invalidate_dcache_range(ctx->cache_start, ctx->cache_end);
400
401 if (status & SDMMC_STA_DCRCFAIL) {
Patrick Delaunay758de432020-11-06 19:01:37 +0100402 dev_dbg(dev, "error SDMMC_STA_DCRCFAIL (0x%x) for cmd %d\n",
403 status, cmd->cmdidx);
Patrick Delaunayf375d372022-06-30 10:01:46 +0200404 if (readl(plat->base + SDMMC_DCOUNT))
Patrice Chotardae19b812017-09-04 17:56:22 +0200405 ctx->dpsm_abort = true;
406 return -EILSEQ;
407 }
408
409 if (status & SDMMC_STA_DTIMEOUT) {
Patrick Delaunay758de432020-11-06 19:01:37 +0100410 dev_dbg(dev, "error SDMMC_STA_DTIMEOUT (0x%x) for cmd %d\n",
411 status, cmd->cmdidx);
Patrice Chotardae19b812017-09-04 17:56:22 +0200412 ctx->dpsm_abort = true;
413 return -ETIMEDOUT;
414 }
415
416 if (status & SDMMC_STA_TXUNDERR) {
Patrick Delaunay758de432020-11-06 19:01:37 +0100417 dev_dbg(dev, "error SDMMC_STA_TXUNDERR (0x%x) for cmd %d\n",
418 status, cmd->cmdidx);
Patrice Chotardae19b812017-09-04 17:56:22 +0200419 ctx->dpsm_abort = true;
420 return -EIO;
421 }
422
423 if (status & SDMMC_STA_RXOVERR) {
Patrick Delaunay758de432020-11-06 19:01:37 +0100424 dev_dbg(dev, "error SDMMC_STA_RXOVERR (0x%x) for cmd %d\n",
425 status, cmd->cmdidx);
Patrice Chotardae19b812017-09-04 17:56:22 +0200426 ctx->dpsm_abort = true;
427 return -EIO;
428 }
429
430 if (status & SDMMC_STA_IDMATE) {
Patrick Delaunay758de432020-11-06 19:01:37 +0100431 dev_dbg(dev, "error SDMMC_STA_IDMATE (0x%x) for cmd %d\n",
432 status, cmd->cmdidx);
Patrice Chotardae19b812017-09-04 17:56:22 +0200433 ctx->dpsm_abort = true;
434 return -EIO;
435 }
436
437 return 0;
438}
439
440static int stm32_sdmmc2_send_cmd(struct udevice *dev, struct mmc_cmd *cmd,
441 struct mmc_data *data)
442{
Patrick Delaunayf375d372022-06-30 10:01:46 +0200443 struct stm32_sdmmc2_plat *plat = dev_get_plat(dev);
Patrice Chotardae19b812017-09-04 17:56:22 +0200444 struct stm32_sdmmc2_ctx ctx;
445 u32 cmdat = data ? SDMMC_CMD_CMDTRANS : 0;
446 int ret, retry = 3;
447
Christophe Kerelloe0452e82019-07-30 19:16:45 +0200448 WATCHDOG_RESET();
449
Patrice Chotardae19b812017-09-04 17:56:22 +0200450retry_cmd:
451 ctx.data_length = 0;
452 ctx.dpsm_abort = false;
453
454 if (data) {
455 ctx.data_length = data->blocks * data->blocksize;
Patrick Delaunay758de432020-11-06 19:01:37 +0100456 stm32_sdmmc2_start_data(dev, data, &ctx);
Patrice Chotardae19b812017-09-04 17:56:22 +0200457 }
458
Patrick Delaunay758de432020-11-06 19:01:37 +0100459 stm32_sdmmc2_start_cmd(dev, cmd, cmdat, &ctx);
Patrice Chotardae19b812017-09-04 17:56:22 +0200460
Patrick Delaunay758de432020-11-06 19:01:37 +0100461 dev_dbg(dev, "send cmd %d data: 0x%x @ 0x%x\n",
462 cmd->cmdidx, data ? ctx.data_length : 0, (unsigned int)data);
Patrice Chotardae19b812017-09-04 17:56:22 +0200463
Patrick Delaunay758de432020-11-06 19:01:37 +0100464 ret = stm32_sdmmc2_end_cmd(dev, cmd, &ctx);
Patrice Chotardae19b812017-09-04 17:56:22 +0200465
466 if (data && !ret)
Patrick Delaunay758de432020-11-06 19:01:37 +0100467 ret = stm32_sdmmc2_end_data(dev, cmd, data, &ctx);
Patrice Chotardae19b812017-09-04 17:56:22 +0200468
469 /* Clear flags */
Patrick Delaunayf375d372022-06-30 10:01:46 +0200470 writel(SDMMC_ICR_STATIC_FLAGS, plat->base + SDMMC_ICR);
Patrice Chotardae19b812017-09-04 17:56:22 +0200471 if (data)
Patrick Delaunayf375d372022-06-30 10:01:46 +0200472 writel(0x0, plat->base + SDMMC_IDMACTRL);
Patrice Chotardae19b812017-09-04 17:56:22 +0200473
474 /*
475 * To stop Data Path State Machine, a stop_transmission command
476 * shall be send on cmd or data errors.
477 */
478 if (ctx.dpsm_abort && (cmd->cmdidx != MMC_CMD_STOP_TRANSMISSION)) {
479 struct mmc_cmd stop_cmd;
480
481 stop_cmd.cmdidx = MMC_CMD_STOP_TRANSMISSION;
482 stop_cmd.cmdarg = 0;
483 stop_cmd.resp_type = MMC_RSP_R1b;
484
Patrick Delaunay758de432020-11-06 19:01:37 +0100485 dev_dbg(dev, "send STOP command to abort dpsm treatments\n");
Patrice Chotardae19b812017-09-04 17:56:22 +0200486
Christophe Kerello8a0b5232018-12-06 15:58:10 +0100487 ctx.data_length = 0;
488
Patrick Delaunay758de432020-11-06 19:01:37 +0100489 stm32_sdmmc2_start_cmd(dev, &stop_cmd,
Christophe Kerello8a0b5232018-12-06 15:58:10 +0100490 SDMMC_CMD_CMDSTOP, &ctx);
Patrick Delaunay758de432020-11-06 19:01:37 +0100491 stm32_sdmmc2_end_cmd(dev, &stop_cmd, &ctx);
Patrice Chotardae19b812017-09-04 17:56:22 +0200492
Patrick Delaunayf375d372022-06-30 10:01:46 +0200493 writel(SDMMC_ICR_STATIC_FLAGS, plat->base + SDMMC_ICR);
Patrice Chotardae19b812017-09-04 17:56:22 +0200494 }
495
496 if ((ret != -ETIMEDOUT) && (ret != 0) && retry) {
Patrick Delaunay758de432020-11-06 19:01:37 +0100497 dev_err(dev, "cmd %d failed, retrying ...\n", cmd->cmdidx);
Patrice Chotardae19b812017-09-04 17:56:22 +0200498 retry--;
499 goto retry_cmd;
500 }
501
Patrick Delaunay758de432020-11-06 19:01:37 +0100502 dev_dbg(dev, "end for CMD %d, ret = %d\n", cmd->cmdidx, ret);
Patrice Chotardae19b812017-09-04 17:56:22 +0200503
504 return ret;
505}
506
Patrick Delaunay69351082018-06-27 10:15:33 +0200507/*
508 * Reset the SDMMC with the RCC.SDMMCxRST register bit.
509 * This will reset the SDMMC to the reset state and the CPSM and DPSM
510 * to the Idle state. SDMMC is disabled, Signals Hiz.
511 */
Patrick Delaunayf375d372022-06-30 10:01:46 +0200512static void stm32_sdmmc2_reset(struct stm32_sdmmc2_plat *plat)
Patrice Chotardae19b812017-09-04 17:56:22 +0200513{
Patrick Delaunayf375d372022-06-30 10:01:46 +0200514 if (reset_valid(&plat->reset_ctl)) {
Patrick Delaunay6be3ccc2022-05-20 18:24:51 +0200515 /* Reset */
Patrick Delaunayf375d372022-06-30 10:01:46 +0200516 reset_assert(&plat->reset_ctl);
Patrick Delaunay6be3ccc2022-05-20 18:24:51 +0200517 udelay(2);
Patrick Delaunayf375d372022-06-30 10:01:46 +0200518 reset_deassert(&plat->reset_ctl);
Patrick Delaunay6be3ccc2022-05-20 18:24:51 +0200519 }
Patrice Chotardae19b812017-09-04 17:56:22 +0200520
Patrick Delaunay69351082018-06-27 10:15:33 +0200521 /* init the needed SDMMC register after reset */
Patrick Delaunayf375d372022-06-30 10:01:46 +0200522 writel(plat->pwr_reg_msk, plat->base + SDMMC_POWER);
Patrick Delaunay69351082018-06-27 10:15:33 +0200523}
524
525/*
526 * Set the SDMMC in power-cycle state.
527 * This will make that the SDMMC_D[7:0],
528 * SDMMC_CMD and SDMMC_CK are driven low, to prevent the card from being
529 * supplied through the signal lines.
530 */
Patrick Delaunayf375d372022-06-30 10:01:46 +0200531static void stm32_sdmmc2_pwrcycle(struct stm32_sdmmc2_plat *plat)
Patrick Delaunay69351082018-06-27 10:15:33 +0200532{
Patrick Delaunayf375d372022-06-30 10:01:46 +0200533 if ((readl(plat->base + SDMMC_POWER) & SDMMC_POWER_PWRCTRL_MASK) ==
Patrick Delaunay69351082018-06-27 10:15:33 +0200534 SDMMC_POWER_PWRCTRL_CYCLE)
535 return;
536
Patrick Delaunayf375d372022-06-30 10:01:46 +0200537 stm32_sdmmc2_reset(plat);
Patrick Delaunay69351082018-06-27 10:15:33 +0200538}
539
540/*
541 * set the SDMMC state Power-on: the card is clocked
542 * manage the SDMMC state control:
543 * Reset => Power-Cycle => Power-Off => Power
544 * PWRCTRL=10 PWCTRL=00 PWCTRL=11
545 */
Patrick Delaunayf375d372022-06-30 10:01:46 +0200546static void stm32_sdmmc2_pwron(struct stm32_sdmmc2_plat *plat)
Patrick Delaunay69351082018-06-27 10:15:33 +0200547{
548 u32 pwrctrl =
Patrick Delaunayf375d372022-06-30 10:01:46 +0200549 readl(plat->base + SDMMC_POWER) & SDMMC_POWER_PWRCTRL_MASK;
Patrice Chotardae19b812017-09-04 17:56:22 +0200550
Patrick Delaunay69351082018-06-27 10:15:33 +0200551 if (pwrctrl == SDMMC_POWER_PWRCTRL_ON)
552 return;
553
554 /* warning: same PWRCTRL value after reset and for power-off state
555 * it is the reset state here = the only managed by the driver
556 */
557 if (pwrctrl == SDMMC_POWER_PWRCTRL_OFF) {
Patrick Delaunayf375d372022-06-30 10:01:46 +0200558 writel(SDMMC_POWER_PWRCTRL_CYCLE | plat->pwr_reg_msk,
559 plat->base + SDMMC_POWER);
Patrick Delaunay69351082018-06-27 10:15:33 +0200560 }
Patrice Chotardae19b812017-09-04 17:56:22 +0200561
562 /*
Patrick Delaunay69351082018-06-27 10:15:33 +0200563 * the remaining case is SDMMC_POWER_PWRCTRL_CYCLE
564 * switch to Power-Off state: SDMCC disable, signals drive 1
Patrice Chotardae19b812017-09-04 17:56:22 +0200565 */
Patrick Delaunayf375d372022-06-30 10:01:46 +0200566 writel(SDMMC_POWER_PWRCTRL_OFF | plat->pwr_reg_msk,
567 plat->base + SDMMC_POWER);
Patrick Delaunay69351082018-06-27 10:15:33 +0200568
569 /* After the 1ms delay set the SDMMC to power-on */
570 mdelay(1);
Patrick Delaunayf375d372022-06-30 10:01:46 +0200571 writel(SDMMC_POWER_PWRCTRL_ON | plat->pwr_reg_msk,
572 plat->base + SDMMC_POWER);
Patrick Delaunay69351082018-06-27 10:15:33 +0200573
574 /* during the first 74 SDMMC_CK cycles the SDMMC is still disabled. */
Patrice Chotardae19b812017-09-04 17:56:22 +0200575}
576
577#define IS_RISING_EDGE(reg) (reg & SDMMC_CLKCR_NEGEDGE ? 0 : 1)
578static int stm32_sdmmc2_set_ios(struct udevice *dev)
579{
580 struct mmc *mmc = mmc_get_mmc_dev(dev);
Patrick Delaunayf375d372022-06-30 10:01:46 +0200581 struct stm32_sdmmc2_plat *plat = dev_get_plat(dev);
Patrice Chotardae19b812017-09-04 17:56:22 +0200582 u32 desired = mmc->clock;
Patrick Delaunayf375d372022-06-30 10:01:46 +0200583 u32 sys_clock = clk_get_rate(&plat->clk);
Patrice Chotardae19b812017-09-04 17:56:22 +0200584 u32 clk = 0;
585
Patrick Delaunay758de432020-11-06 19:01:37 +0100586 dev_dbg(dev, "bus_with = %d, clock = %d\n",
587 mmc->bus_width, mmc->clock);
Patrice Chotardae19b812017-09-04 17:56:22 +0200588
Patrick Delaunay69351082018-06-27 10:15:33 +0200589 if (mmc->clk_disable)
Patrick Delaunayf375d372022-06-30 10:01:46 +0200590 stm32_sdmmc2_pwrcycle(plat);
Patrick Delaunay69351082018-06-27 10:15:33 +0200591 else
Patrick Delaunayf375d372022-06-30 10:01:46 +0200592 stm32_sdmmc2_pwron(plat);
Patrice Chotardae19b812017-09-04 17:56:22 +0200593
594 /*
595 * clk_div = 0 => command and data generated on SDMMCCLK falling edge
596 * clk_div > 0 and NEGEDGE = 0 => command and data generated on
597 * SDMMCCLK rising edge
598 * clk_div > 0 and NEGEDGE = 1 => command and data generated on
599 * SDMMCCLK falling edge
600 */
601 if (desired && ((sys_clock > desired) ||
Patrick Delaunayf375d372022-06-30 10:01:46 +0200602 IS_RISING_EDGE(plat->clk_reg_msk))) {
Patrice Chotardae19b812017-09-04 17:56:22 +0200603 clk = DIV_ROUND_UP(sys_clock, 2 * desired);
604 if (clk > SDMMC_CLKCR_CLKDIV_MAX)
605 clk = SDMMC_CLKCR_CLKDIV_MAX;
606 }
607
608 if (mmc->bus_width == 4)
609 clk |= SDMMC_CLKCR_WIDBUS_4;
610 if (mmc->bus_width == 8)
611 clk |= SDMMC_CLKCR_WIDBUS_8;
612
Patrick Delaunayf375d372022-06-30 10:01:46 +0200613 writel(clk | plat->clk_reg_msk | SDMMC_CLKCR_HWFC_EN,
614 plat->base + SDMMC_CLKCR);
Patrice Chotardae19b812017-09-04 17:56:22 +0200615
616 return 0;
617}
618
619static int stm32_sdmmc2_getcd(struct udevice *dev)
620{
Patrick Delaunayf375d372022-06-30 10:01:46 +0200621 struct stm32_sdmmc2_plat *plat = dev_get_plat(dev);
Patrice Chotardae19b812017-09-04 17:56:22 +0200622
Patrick Delaunay758de432020-11-06 19:01:37 +0100623 dev_dbg(dev, "%s called\n", __func__);
Patrice Chotardae19b812017-09-04 17:56:22 +0200624
Patrick Delaunayf375d372022-06-30 10:01:46 +0200625 if (dm_gpio_is_valid(&plat->cd_gpio))
626 return dm_gpio_get_value(&plat->cd_gpio);
Patrice Chotardae19b812017-09-04 17:56:22 +0200627
628 return 1;
629}
630
Yann Gautierae3cd2a2019-09-19 17:56:13 +0200631static int stm32_sdmmc2_host_power_cycle(struct udevice *dev)
632{
Patrick Delaunayf375d372022-06-30 10:01:46 +0200633 struct stm32_sdmmc2_plat *plat = dev_get_plat(dev);
Yann Gautierae3cd2a2019-09-19 17:56:13 +0200634
Patrick Delaunayf375d372022-06-30 10:01:46 +0200635 writel(SDMMC_POWER_PWRCTRL_CYCLE | plat->pwr_reg_msk,
636 plat->base + SDMMC_POWER);
Yann Gautierae3cd2a2019-09-19 17:56:13 +0200637
638 return 0;
639}
640
Patrice Chotardae19b812017-09-04 17:56:22 +0200641static const struct dm_mmc_ops stm32_sdmmc2_ops = {
642 .send_cmd = stm32_sdmmc2_send_cmd,
643 .set_ios = stm32_sdmmc2_set_ios,
644 .get_cd = stm32_sdmmc2_getcd,
Yann Gautierae3cd2a2019-09-19 17:56:13 +0200645 .host_power_cycle = stm32_sdmmc2_host_power_cycle,
Patrice Chotardae19b812017-09-04 17:56:22 +0200646};
647
Patrick Delaunay4f6a1ba2022-06-30 10:01:47 +0200648static int stm32_sdmmc2_of_to_plat(struct udevice *dev)
649{
650 struct stm32_sdmmc2_plat *plat = dev_get_plat(dev);
651 struct mmc_config *cfg = &plat->cfg;
652 int ret;
653
654 plat->base = dev_read_addr(dev);
655 if (plat->base == FDT_ADDR_T_NONE)
656 return -EINVAL;
657
658 if (dev_read_bool(dev, "st,neg-edge"))
659 plat->clk_reg_msk |= SDMMC_CLKCR_NEGEDGE;
660 if (dev_read_bool(dev, "st,sig-dir"))
661 plat->pwr_reg_msk |= SDMMC_POWER_DIRPOL;
662 if (dev_read_bool(dev, "st,use-ckin"))
663 plat->clk_reg_msk |= SDMMC_CLKCR_SELCLKRX_CKIN;
664
665 cfg->f_min = 400000;
666 cfg->voltages = MMC_VDD_32_33 | MMC_VDD_33_34 | MMC_VDD_165_195;
667 cfg->b_max = CONFIG_SYS_MMC_MAX_BLK_COUNT;
668 cfg->name = "STM32 SD/MMC";
669 cfg->host_caps = 0;
670 cfg->f_max = 52000000;
671 ret = mmc_of_parse(dev, cfg);
672 if (ret)
673 return ret;
674
675 ret = clk_get_by_index(dev, 0, &plat->clk);
676 if (ret)
677 return ret;
678
679 ret = reset_get_by_index(dev, 0, &plat->reset_ctl);
680 if (ret)
681 dev_dbg(dev, "No reset provided\n");
682
683 gpio_request_by_name(dev, "cd-gpios", 0, &plat->cd_gpio,
684 GPIOD_IS_IN);
685
686 return 0;
687}
688
Marek Vasut98a12052021-11-13 03:29:43 +0100689static int stm32_sdmmc2_probe_level_translator(struct udevice *dev)
690{
Patrick Delaunayf375d372022-06-30 10:01:46 +0200691 struct stm32_sdmmc2_plat *plat = dev_get_plat(dev);
Marek Vasut98a12052021-11-13 03:29:43 +0100692 struct gpio_desc cmd_gpio;
693 struct gpio_desc ck_gpio;
694 struct gpio_desc ckin_gpio;
695 int clk_hi, clk_lo, ret;
696
Marek Vasut98a12052021-11-13 03:29:43 +0100697 ret = gpio_request_by_name(dev, "st,cmd-gpios", 0, &cmd_gpio,
698 GPIOD_IS_OUT | GPIOD_IS_OUT_ACTIVE);
699 if (ret)
700 goto exit_cmd;
701
702 ret = gpio_request_by_name(dev, "st,ck-gpios", 0, &ck_gpio,
703 GPIOD_IS_OUT | GPIOD_IS_OUT_ACTIVE);
704 if (ret)
705 goto exit_ck;
706
707 ret = gpio_request_by_name(dev, "st,ckin-gpios", 0, &ckin_gpio,
708 GPIOD_IS_IN);
709 if (ret)
710 goto exit_ckin;
711
712 /* All GPIOs are valid, test whether level translator works */
713
714 /* Sample CKIN */
715 clk_hi = !!dm_gpio_get_value(&ckin_gpio);
716
717 /* Set CK low */
718 dm_gpio_set_value(&ck_gpio, 0);
719
720 /* Sample CKIN */
721 clk_lo = !!dm_gpio_get_value(&ckin_gpio);
722
723 /* Tristate all */
724 dm_gpio_set_dir_flags(&cmd_gpio, GPIOD_IS_IN);
725 dm_gpio_set_dir_flags(&ck_gpio, GPIOD_IS_IN);
726
727 /* Level translator is present if CK signal is propagated to CKIN */
728 if (!clk_hi || clk_lo)
Patrick Delaunayf375d372022-06-30 10:01:46 +0200729 plat->clk_reg_msk &= ~SDMMC_CLKCR_SELCLKRX_CKIN;
Marek Vasut98a12052021-11-13 03:29:43 +0100730
731 dm_gpio_free(dev, &ckin_gpio);
732
733exit_ckin:
734 dm_gpio_free(dev, &ck_gpio);
735exit_ck:
736 dm_gpio_free(dev, &cmd_gpio);
737exit_cmd:
738 pinctrl_select_state(dev, "default");
739
740 return 0;
741}
742
Patrice Chotardae19b812017-09-04 17:56:22 +0200743static int stm32_sdmmc2_probe(struct udevice *dev)
744{
745 struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
Simon Glassfa20e932020-12-03 16:55:20 -0700746 struct stm32_sdmmc2_plat *plat = dev_get_plat(dev);
Patrice Chotardae19b812017-09-04 17:56:22 +0200747 int ret;
748
Patrick Delaunayf375d372022-06-30 10:01:46 +0200749 ret = clk_enable(&plat->clk);
Patrick Delaunay4f6a1ba2022-06-30 10:01:47 +0200750 if (ret) {
751 clk_free(&plat->clk);
752 return ret;
753 }
Patrice Chotardae19b812017-09-04 17:56:22 +0200754
755 upriv->mmc = &plat->mmc;
756
Patrick Delaunay4f6a1ba2022-06-30 10:01:47 +0200757 if (plat->clk_reg_msk & SDMMC_CLKCR_SELCLKRX_CKIN)
758 stm32_sdmmc2_probe_level_translator(dev);
759
Patrick Delaunay69351082018-06-27 10:15:33 +0200760 /* SDMMC init */
Patrick Delaunayf375d372022-06-30 10:01:46 +0200761 stm32_sdmmc2_reset(plat);
Patrice Chotardae19b812017-09-04 17:56:22 +0200762
Patrick Delaunay4f6a1ba2022-06-30 10:01:47 +0200763 return 0;
Patrice Chotardae19b812017-09-04 17:56:22 +0200764}
765
Patrick Delaunay1db48bf2022-06-30 10:01:45 +0200766static int stm32_sdmmc2_bind(struct udevice *dev)
Patrice Chotardae19b812017-09-04 17:56:22 +0200767{
Simon Glassfa20e932020-12-03 16:55:20 -0700768 struct stm32_sdmmc2_plat *plat = dev_get_plat(dev);
Patrice Chotardae19b812017-09-04 17:56:22 +0200769
770 return mmc_bind(dev, &plat->mmc, &plat->cfg);
771}
772
773static const struct udevice_id stm32_sdmmc2_ids[] = {
774 { .compatible = "st,stm32-sdmmc2" },
775 { }
776};
777
778U_BOOT_DRIVER(stm32_sdmmc2) = {
779 .name = "stm32_sdmmc2",
780 .id = UCLASS_MMC,
781 .of_match = stm32_sdmmc2_ids,
782 .ops = &stm32_sdmmc2_ops,
783 .probe = stm32_sdmmc2_probe,
Patrick Delaunay1db48bf2022-06-30 10:01:45 +0200784 .bind = stm32_sdmmc2_bind,
Patrick Delaunay4f6a1ba2022-06-30 10:01:47 +0200785 .of_to_plat = stm32_sdmmc2_of_to_plat,
Simon Glass71fa5b42020-12-03 16:55:18 -0700786 .plat_auto = sizeof(struct stm32_sdmmc2_plat),
Patrice Chotardae19b812017-09-04 17:56:22 +0200787};