blob: 898be5a0913a89d700e540c6220f680a13673778 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Michal Simek0dd222b2013-04-22 14:56:49 +02002/*
Ashok Reddy Soma0ab38fd2023-01-10 04:31:21 -07003 * (C) Copyright 2013 - 2022, Xilinx, Inc.
4 * (C) Copyright 2022, Advanced Micro Devices, Inc.
Michal Simek0dd222b2013-04-22 14:56:49 +02005 *
6 * Xilinx Zynq SD Host Controller Interface
Michal Simek0dd222b2013-04-22 14:56:49 +02007 */
8
Stefan Herbrechtsmeier739ae402017-01-17 16:27:32 +01009#include <clk.h>
Michal Simek9ecd2682015-11-30 16:13:03 +010010#include <dm.h>
Michal Simekc57ba042014-02-24 11:16:31 +010011#include <fdtdec.h>
Simon Glassdbd79542020-05-10 11:40:11 -060012#include <linux/delay.h>
Siva Durga Prasad Paladugucad14a82018-04-19 12:37:09 +053013#include "mmc_private.h"
Simon Glass0f2af882020-05-10 11:40:05 -060014#include <log.h>
Ashok Reddy Somaca7d8472022-02-23 15:36:05 +010015#include <reset.h>
Algapally Santosh Sagar58f731a2023-03-01 03:33:33 -070016#include <asm/arch/sys_proto.h>
Simon Glass9bc15642020-02-03 07:36:16 -070017#include <dm/device_compat.h>
Simon Glassd66c5f72020-02-03 07:36:15 -070018#include <linux/err.h>
Masahiro Yamada75f82d02018-03-05 01:20:11 +090019#include <linux/libfdt.h>
Ashok Reddy Soma0ab38fd2023-01-10 04:31:21 -070020#include <linux/iopoll.h>
Ashok Reddy Somaca7d8472022-02-23 15:36:05 +010021#include <asm/types.h>
22#include <linux/math64.h>
Ashok Reddy Soma7a5f8102021-08-02 23:20:44 -060023#include <asm/cache.h>
Michal Simek0dd222b2013-04-22 14:56:49 +020024#include <malloc.h>
25#include <sdhci.h>
Ashok Reddy Soma467d0782021-08-02 23:20:43 -060026#include <zynqmp_firmware.h>
Michal Simek0dd222b2013-04-22 14:56:49 +020027
Ashok Reddy Soma24a51072021-07-09 05:53:41 -060028#define SDHCI_ARASAN_ITAPDLY_REGISTER 0xF0F8
29#define SDHCI_ARASAN_ITAPDLY_SEL_MASK GENMASK(7, 0)
30#define SDHCI_ARASAN_OTAPDLY_REGISTER 0xF0FC
31#define SDHCI_ARASAN_OTAPDLY_SEL_MASK GENMASK(5, 0)
32#define SDHCI_ITAPDLY_CHGWIN BIT(9)
33#define SDHCI_ITAPDLY_ENABLE BIT(8)
34#define SDHCI_OTAPDLY_ENABLE BIT(6)
Ashok Reddy Soma568edfd2020-10-23 04:59:02 -060035
Michal Simek5b5101e2020-10-23 04:58:59 -060036#define SDHCI_TUNING_LOOP_COUNT 40
Michal Simek33a6b772020-10-23 04:59:00 -060037#define MMC_BANK2 0x2
38
Ashok Reddy Soma7a5f8102021-08-02 23:20:44 -060039#define SD_DLL_CTRL 0xFF180358
40#define SD_ITAP_DLY 0xFF180314
41#define SD_OTAP_DLY 0xFF180318
42#define SD0_DLL_RST BIT(2)
43#define SD1_DLL_RST BIT(18)
44#define SD0_ITAPCHGWIN BIT(9)
45#define SD1_ITAPCHGWIN BIT(25)
46#define SD0_ITAPDLYENA BIT(8)
47#define SD1_ITAPDLYENA BIT(24)
48#define SD0_ITAPDLYSEL_MASK GENMASK(7, 0)
49#define SD1_ITAPDLYSEL_MASK GENMASK(23, 16)
50#define SD0_OTAPDLYSEL_MASK GENMASK(5, 0)
51#define SD1_OTAPDLYSEL_MASK GENMASK(21, 16)
52
Ashok Reddy Soma0ab38fd2023-01-10 04:31:21 -070053#define MIN_PHY_CLK_HZ 50000000
54
55#define PHY_CTRL_REG1 0x270
56#define PHY_CTRL_ITAPDLY_ENA_MASK BIT(0)
57#define PHY_CTRL_ITAPDLY_SEL_MASK GENMASK(5, 1)
58#define PHY_CTRL_ITAPDLY_SEL_SHIFT 1
59#define PHY_CTRL_ITAP_CHG_WIN_MASK BIT(6)
60#define PHY_CTRL_OTAPDLY_ENA_MASK BIT(8)
61#define PHY_CTRL_OTAPDLY_SEL_MASK GENMASK(15, 12)
62#define PHY_CTRL_OTAPDLY_SEL_SHIFT 12
63#define PHY_CTRL_STRB_SEL_MASK GENMASK(23, 16)
64#define PHY_CTRL_STRB_SEL_SHIFT 16
65#define PHY_CTRL_TEST_CTRL_MASK GENMASK(31, 24)
66
67#define PHY_CTRL_REG2 0x274
68#define PHY_CTRL_EN_DLL_MASK BIT(0)
69#define PHY_CTRL_DLL_RDY_MASK BIT(1)
70#define PHY_CTRL_FREQ_SEL_MASK GENMASK(6, 4)
71#define PHY_CTRL_FREQ_SEL_SHIFT 4
72#define PHY_CTRL_SEL_DLY_TX_MASK BIT(16)
73#define PHY_CTRL_SEL_DLY_RX_MASK BIT(17)
74#define FREQSEL_200M_170M 0x0
75#define FREQSEL_170M_140M 0x1
76#define FREQSEL_140M_110M 0x2
77#define FREQSEL_110M_80M 0x3
78#define FREQSEL_80M_50M 0x4
79#define FREQSEL_275M_250M 0x5
80#define FREQSEL_250M_225M 0x6
81#define FREQSEL_225M_200M 0x7
82#define PHY_DLL_TIMEOUT_MS 100
83
84#define VERSAL_NET_EMMC_ICLK_PHASE_DDR52_DLY_CHAIN 39
85#define VERSAL_NET_EMMC_ICLK_PHASE_DDR52_DLL 146
86#define VERSAL_NET_PHY_CTRL_STRB90_STRB180_VAL 0X77
87
Michal Simek33a6b772020-10-23 04:59:00 -060088struct arasan_sdhci_clk_data {
89 int clk_phase_in[MMC_TIMING_MMC_HS400 + 1];
90 int clk_phase_out[MMC_TIMING_MMC_HS400 + 1];
91};
Michal Simek5b5101e2020-10-23 04:58:59 -060092
Simon Glass4cc87fb2016-07-05 17:10:15 -060093struct arasan_sdhci_plat {
94 struct mmc_config cfg;
95 struct mmc mmc;
96};
97
Siva Durga Prasad Paladugucad14a82018-04-19 12:37:09 +053098struct arasan_sdhci_priv {
99 struct sdhci_host *host;
Michal Simek33a6b772020-10-23 04:59:00 -0600100 struct arasan_sdhci_clk_data clk_data;
Ashok Reddy Soma33154532022-09-30 03:25:47 -0600101 u32 node_id;
Siva Durga Prasad Paladugucad14a82018-04-19 12:37:09 +0530102 u8 bank;
Ashok Reddy Soma61e0df92020-10-23 04:58:57 -0600103 u8 no_1p8;
Ashok Reddy Soma0ab38fd2023-01-10 04:31:21 -0700104 bool internal_phy_reg;
Ashok Reddy Somaca7d8472022-02-23 15:36:05 +0100105 struct reset_ctl_bulk resets;
Siva Durga Prasad Paladugucad14a82018-04-19 12:37:09 +0530106};
107
Ashok Reddy Soma7a5f8102021-08-02 23:20:44 -0600108/* For Versal platforms zynqmp_mmio_write() won't be available */
109__weak int zynqmp_mmio_write(const u32 address, const u32 mask, const u32 value)
110{
111 return 0;
112}
113
T Karthik Reddyd0618272021-10-01 16:38:38 +0530114__weak int xilinx_pm_request(u32 api_id, u32 arg0, u32 arg1, u32 arg2,
115 u32 arg3, u32 *ret_payload)
116{
117 return 0;
118}
119
T Karthik Reddy0b35fa22022-04-27 10:27:12 +0200120__weak int zynqmp_pm_is_function_supported(const u32 api_id, const u32 id)
121{
122 return 1;
123}
124
Ashok Reddy Soma0ab38fd2023-01-10 04:31:21 -0700125#if defined(CONFIG_ARCH_ZYNQMP) || defined(CONFIG_ARCH_VERSAL) || defined(CONFIG_ARCH_VERSAL_NET)
Michal Simek33a6b772020-10-23 04:59:00 -0600126/* Default settings for ZynqMP Clock Phases */
Michal Simek635cf4a2021-07-09 05:53:44 -0600127static const u32 zynqmp_iclk_phases[] = {0, 63, 63, 0, 63, 0,
128 0, 183, 54, 0, 0};
129static const u32 zynqmp_oclk_phases[] = {0, 72, 60, 0, 60, 72,
130 135, 48, 72, 135, 0};
Michal Simek33a6b772020-10-23 04:59:00 -0600131
Ashok Reddy Soma568edfd2020-10-23 04:59:02 -0600132/* Default settings for Versal Clock Phases */
Michal Simek635cf4a2021-07-09 05:53:44 -0600133static const u32 versal_iclk_phases[] = {0, 132, 132, 0, 132,
134 0, 0, 162, 90, 0, 0};
135static const u32 versal_oclk_phases[] = {0, 60, 48, 0, 48, 72,
136 90, 36, 60, 90, 0};
Ashok Reddy Soma568edfd2020-10-23 04:59:02 -0600137
Ashok Reddy Soma0ab38fd2023-01-10 04:31:21 -0700138/* Default settings for versal-net eMMC Clock Phases */
139static const u32 versal_net_emmc_iclk_phases[] = {0, 0, 0, 0, 0, 0, 0, 0, 39,
140 0, 0};
141static const u32 versal_net_emmc_oclk_phases[] = {0, 113, 0, 0, 0, 0, 0, 0,
142 113, 79, 45};
143
Siva Durga Prasad Paladugucad14a82018-04-19 12:37:09 +0530144static const u8 mode2timing[] = {
Ashok Reddy Soma0afdfe32020-10-23 04:58:58 -0600145 [MMC_LEGACY] = MMC_TIMING_LEGACY,
146 [MMC_HS] = MMC_TIMING_MMC_HS,
147 [SD_HS] = MMC_TIMING_SD_HS,
Ashok Reddy Soma5ff7acf2022-06-27 14:22:45 +0530148 [MMC_HS_52] = MMC_TIMING_MMC_HS,
149 [MMC_DDR_52] = MMC_TIMING_MMC_DDR52,
Ashok Reddy Soma0afdfe32020-10-23 04:58:58 -0600150 [UHS_SDR12] = MMC_TIMING_UHS_SDR12,
151 [UHS_SDR25] = MMC_TIMING_UHS_SDR25,
152 [UHS_SDR50] = MMC_TIMING_UHS_SDR50,
153 [UHS_DDR50] = MMC_TIMING_UHS_DDR50,
154 [UHS_SDR104] = MMC_TIMING_UHS_SDR104,
155 [MMC_HS_200] = MMC_TIMING_MMC_HS200,
Ashok Reddy Soma407a5612023-01-10 04:31:24 -0700156 [MMC_HS_400] = MMC_TIMING_MMC_HS400,
Siva Durga Prasad Paladugucad14a82018-04-19 12:37:09 +0530157};
158
Ashok Reddy Soma0ab38fd2023-01-10 04:31:21 -0700159#if defined(CONFIG_ARCH_VERSAL_NET)
160/**
161 * arasan_phy_set_delaychain - Set eMMC delay chain based Input/Output clock
162 *
163 * @host: Pointer to the sdhci_host structure
164 * @enable: Enable or disable Delay chain based Tx and Rx clock
165 * Return: None
166 *
167 * Enable or disable eMMC delay chain based Input and Output clock in
168 * PHY_CTRL_REG2
169 */
170static void arasan_phy_set_delaychain(struct sdhci_host *host, bool enable)
171{
172 u32 reg;
173
174 reg = sdhci_readw(host, PHY_CTRL_REG2);
175 if (enable)
176 reg |= PHY_CTRL_SEL_DLY_TX_MASK | PHY_CTRL_SEL_DLY_RX_MASK;
177 else
178 reg &= ~(PHY_CTRL_SEL_DLY_TX_MASK | PHY_CTRL_SEL_DLY_RX_MASK);
179
180 sdhci_writew(host, reg, PHY_CTRL_REG2);
181}
182
183/**
184 * arasan_phy_set_dll - Set eMMC DLL clock
185 *
186 * @host: Pointer to the sdhci_host structure
187 * @enable: Enable or disable DLL clock
188 * Return: 0 if success or timeout error
189 *
190 * Enable or disable eMMC DLL clock in PHY_CTRL_REG2. When DLL enable is
191 * set, wait till DLL is locked
192 */
193static int arasan_phy_set_dll(struct sdhci_host *host, bool enable)
194{
195 u32 reg;
196
197 reg = sdhci_readw(host, PHY_CTRL_REG2);
198 if (enable)
199 reg |= PHY_CTRL_EN_DLL_MASK;
200 else
201 reg &= ~PHY_CTRL_EN_DLL_MASK;
202
203 sdhci_writew(host, reg, PHY_CTRL_REG2);
204
205 /* If DLL is disabled return success */
206 if (!enable)
207 return 0;
208
209 /* If DLL is enabled wait till DLL loop is locked, which is
210 * indicated by dll_rdy bit(bit1) in PHY_CTRL_REG2
211 */
212 return readl_relaxed_poll_timeout(host->ioaddr + PHY_CTRL_REG2, reg,
213 (reg & PHY_CTRL_DLL_RDY_MASK),
214 1000 * PHY_DLL_TIMEOUT_MS);
215}
216
217/**
218 * arasan_phy_dll_set_freq - Select frequency range of DLL for eMMC
219 *
220 * @host: Pointer to the sdhci_host structure
221 * @clock: clock value
222 * Return: None
223 *
224 * Set frequency range bits based on the selected clock for eMMC
225 */
226static void arasan_phy_dll_set_freq(struct sdhci_host *host, int clock)
227{
228 u32 reg, freq_sel, freq;
229
230 freq = DIV_ROUND_CLOSEST(clock, 1000000);
231 if (freq <= 200 && freq > 170)
232 freq_sel = FREQSEL_200M_170M;
233 else if (freq <= 170 && freq > 140)
234 freq_sel = FREQSEL_170M_140M;
235 else if (freq <= 140 && freq > 110)
236 freq_sel = FREQSEL_140M_110M;
237 else if (freq <= 110 && freq > 80)
238 freq_sel = FREQSEL_110M_80M;
239 else
240 freq_sel = FREQSEL_80M_50M;
241
242 reg = sdhci_readw(host, PHY_CTRL_REG2);
243 reg &= ~PHY_CTRL_FREQ_SEL_MASK;
244 reg |= (freq_sel << PHY_CTRL_FREQ_SEL_SHIFT);
245 sdhci_writew(host, reg, PHY_CTRL_REG2);
246}
247
248static int arasan_sdhci_config_dll(struct sdhci_host *host, unsigned int clock, bool enable)
249{
250 struct mmc *mmc = (struct mmc *)host->mmc;
251 struct arasan_sdhci_priv *priv = dev_get_priv(mmc->dev);
252
253 if (enable) {
254 if (priv->internal_phy_reg && clock >= MIN_PHY_CLK_HZ && enable)
255 arasan_phy_set_dll(host, 1);
256 return 0;
257 }
258
259 if (priv->internal_phy_reg && clock >= MIN_PHY_CLK_HZ) {
260 sdhci_writew(host, 0, SDHCI_CLOCK_CONTROL);
261 arasan_phy_set_dll(host, 0);
262 arasan_phy_set_delaychain(host, 0);
263 arasan_phy_dll_set_freq(host, clock);
264 return 0;
265 }
266
267 sdhci_writew(host, 0, SDHCI_CLOCK_CONTROL);
268 arasan_phy_set_delaychain(host, 1);
269
270 return 0;
271}
272#endif
273
Ashok Reddy Somaa23e6ee2022-09-30 03:25:46 -0600274static inline int arasan_zynqmp_set_in_tapdelay(u32 node_id, u32 itap_delay)
Ashok Reddy Soma7a5f8102021-08-02 23:20:44 -0600275{
276 int ret;
277
278 if (IS_ENABLED(CONFIG_SPL_BUILD) || current_el() == 3) {
279 if (node_id == NODE_SD_0) {
280 ret = zynqmp_mmio_write(SD_ITAP_DLY, SD0_ITAPCHGWIN,
281 SD0_ITAPCHGWIN);
282 if (ret)
283 return ret;
284
285 ret = zynqmp_mmio_write(SD_ITAP_DLY, SD0_ITAPDLYENA,
286 SD0_ITAPDLYENA);
287 if (ret)
288 return ret;
289
290 ret = zynqmp_mmio_write(SD_ITAP_DLY, SD0_ITAPDLYSEL_MASK,
291 itap_delay);
292 if (ret)
293 return ret;
294
295 ret = zynqmp_mmio_write(SD_ITAP_DLY, SD0_ITAPCHGWIN, 0);
296 if (ret)
297 return ret;
298 }
299 ret = zynqmp_mmio_write(SD_ITAP_DLY, SD1_ITAPCHGWIN,
300 SD1_ITAPCHGWIN);
301 if (ret)
302 return ret;
303
304 ret = zynqmp_mmio_write(SD_ITAP_DLY, SD1_ITAPDLYENA,
305 SD1_ITAPDLYENA);
306 if (ret)
307 return ret;
308
309 ret = zynqmp_mmio_write(SD_ITAP_DLY, SD1_ITAPDLYSEL_MASK,
310 (itap_delay << 16));
311 if (ret)
312 return ret;
313
314 ret = zynqmp_mmio_write(SD_ITAP_DLY, SD1_ITAPCHGWIN, 0);
315 if (ret)
316 return ret;
317 } else {
Ashok Reddy Somaa23e6ee2022-09-30 03:25:46 -0600318 return xilinx_pm_request(PM_IOCTL, node_id,
Ashok Reddy Soma7a5f8102021-08-02 23:20:44 -0600319 IOCTL_SET_SD_TAPDELAY,
320 PM_TAPDELAY_INPUT, itap_delay, NULL);
321 }
322
323 return 0;
324}
325
Ashok Reddy Somaa23e6ee2022-09-30 03:25:46 -0600326static inline int arasan_zynqmp_set_out_tapdelay(u32 node_id, u32 otap_delay)
Ashok Reddy Soma7a5f8102021-08-02 23:20:44 -0600327{
328 if (IS_ENABLED(CONFIG_SPL_BUILD) || current_el() == 3) {
329 if (node_id == NODE_SD_0)
330 return zynqmp_mmio_write(SD_OTAP_DLY,
331 SD0_OTAPDLYSEL_MASK,
332 otap_delay);
333
334 return zynqmp_mmio_write(SD_OTAP_DLY, SD1_OTAPDLYSEL_MASK,
335 (otap_delay << 16));
336 } else {
Ashok Reddy Somaa23e6ee2022-09-30 03:25:46 -0600337 return xilinx_pm_request(PM_IOCTL, node_id,
Ashok Reddy Soma7a5f8102021-08-02 23:20:44 -0600338 IOCTL_SET_SD_TAPDELAY,
339 PM_TAPDELAY_OUTPUT, otap_delay, NULL);
340 }
341}
342
Ashok Reddy Somaa23e6ee2022-09-30 03:25:46 -0600343static inline int zynqmp_dll_reset(u32 node_id, u32 type)
Ashok Reddy Soma7a5f8102021-08-02 23:20:44 -0600344{
345 if (IS_ENABLED(CONFIG_SPL_BUILD) || current_el() == 3) {
346 if (node_id == NODE_SD_0)
347 return zynqmp_mmio_write(SD_DLL_CTRL, SD0_DLL_RST,
348 type == PM_DLL_RESET_ASSERT ?
349 SD0_DLL_RST : 0);
350
351 return zynqmp_mmio_write(SD_DLL_CTRL, SD1_DLL_RST,
352 type == PM_DLL_RESET_ASSERT ?
353 SD1_DLL_RST : 0);
354 } else {
Ashok Reddy Somaa23e6ee2022-09-30 03:25:46 -0600355 return xilinx_pm_request(PM_IOCTL, node_id,
Ashok Reddy Soma7a5f8102021-08-02 23:20:44 -0600356 IOCTL_SD_DLL_RESET, type, 0, NULL);
357 }
358}
359
Ashok Reddy Somaa23e6ee2022-09-30 03:25:46 -0600360static int arasan_zynqmp_dll_reset(struct sdhci_host *host, u32 node_id)
Siva Durga Prasad Paladugucad14a82018-04-19 12:37:09 +0530361{
Ashok Reddy Soma467d0782021-08-02 23:20:43 -0600362 struct mmc *mmc = (struct mmc *)host->mmc;
363 struct udevice *dev = mmc->dev;
Siva Durga Prasad Paladugucad14a82018-04-19 12:37:09 +0530364 unsigned long timeout;
Ashok Reddy Soma467d0782021-08-02 23:20:43 -0600365 int ret;
366 u16 clk;
Siva Durga Prasad Paladugucad14a82018-04-19 12:37:09 +0530367
368 clk = sdhci_readw(host, SDHCI_CLOCK_CONTROL);
369 clk &= ~(SDHCI_CLOCK_CARD_EN);
370 sdhci_writew(host, clk, SDHCI_CLOCK_CONTROL);
371
372 /* Issue DLL Reset */
Ashok Reddy Soma467d0782021-08-02 23:20:43 -0600373 ret = zynqmp_dll_reset(node_id, PM_DLL_RESET_ASSERT);
374 if (ret) {
375 dev_err(dev, "dll_reset assert failed with err: %d\n", ret);
376 return ret;
377 }
378
379 /* Allow atleast 1ms delay for proper DLL reset */
380 mdelay(1);
381 ret = zynqmp_dll_reset(node_id, PM_DLL_RESET_RELEASE);
382 if (ret) {
383 dev_err(dev, "dll_reset release failed with err: %d\n", ret);
384 return ret;
385 }
Siva Durga Prasad Paladugucad14a82018-04-19 12:37:09 +0530386
387 /* Wait max 20 ms */
388 timeout = 100;
389 while (!((clk = sdhci_readw(host, SDHCI_CLOCK_CONTROL))
390 & SDHCI_CLOCK_INT_STABLE)) {
391 if (timeout == 0) {
Ashok Reddy Soma467d0782021-08-02 23:20:43 -0600392 dev_err(dev, ": Internal clock never stabilised.\n");
393 return -EBUSY;
Siva Durga Prasad Paladugucad14a82018-04-19 12:37:09 +0530394 }
395 timeout--;
396 udelay(1000);
397 }
398
399 clk |= SDHCI_CLOCK_CARD_EN;
400 sdhci_writew(host, clk, SDHCI_CLOCK_CONTROL);
Ashok Reddy Soma467d0782021-08-02 23:20:43 -0600401
402 return 0;
Siva Durga Prasad Paladugucad14a82018-04-19 12:37:09 +0530403}
404
405static int arasan_sdhci_execute_tuning(struct mmc *mmc, u8 opcode)
406{
407 struct mmc_cmd cmd;
408 struct mmc_data data;
409 u32 ctrl;
410 struct sdhci_host *host;
411 struct arasan_sdhci_priv *priv = dev_get_priv(mmc->dev);
Algapally Santosh Sagar99a98ca2023-01-19 22:36:17 -0700412 int tuning_loop_counter = SDHCI_TUNING_LOOP_COUNT;
Siva Durga Prasad Paladugucad14a82018-04-19 12:37:09 +0530413
Ashok Reddy Somaca7d8472022-02-23 15:36:05 +0100414 dev_dbg(mmc->dev, "%s\n", __func__);
Siva Durga Prasad Paladugucad14a82018-04-19 12:37:09 +0530415
416 host = priv->host;
Siva Durga Prasad Paladugucad14a82018-04-19 12:37:09 +0530417
Faiz Abbas2eddc002019-06-11 00:43:40 +0530418 ctrl = sdhci_readw(host, SDHCI_HOST_CONTROL2);
Siva Durga Prasad Paladugucad14a82018-04-19 12:37:09 +0530419 ctrl |= SDHCI_CTRL_EXEC_TUNING;
Faiz Abbas2eddc002019-06-11 00:43:40 +0530420 sdhci_writew(host, ctrl, SDHCI_HOST_CONTROL2);
Siva Durga Prasad Paladugucad14a82018-04-19 12:37:09 +0530421
422 mdelay(1);
423
Ashok Reddy Soma00d98c22023-07-10 14:11:59 +0200424 if (device_is_compatible(mmc->dev, "xlnx,zynqmp-8.9a"))
425 arasan_zynqmp_dll_reset(host, priv->node_id);
Siva Durga Prasad Paladugucad14a82018-04-19 12:37:09 +0530426
427 sdhci_writel(host, SDHCI_INT_DATA_AVAIL, SDHCI_INT_ENABLE);
428 sdhci_writel(host, SDHCI_INT_DATA_AVAIL, SDHCI_SIGNAL_ENABLE);
429
430 do {
431 cmd.cmdidx = opcode;
432 cmd.resp_type = MMC_RSP_R1;
433 cmd.cmdarg = 0;
434
435 data.blocksize = 64;
436 data.blocks = 1;
437 data.flags = MMC_DATA_READ;
438
439 if (tuning_loop_counter-- == 0)
440 break;
441
442 if (cmd.cmdidx == MMC_CMD_SEND_TUNING_BLOCK_HS200 &&
443 mmc->bus_width == 8)
444 data.blocksize = 128;
445
446 sdhci_writew(host, SDHCI_MAKE_BLKSZ(SDHCI_DEFAULT_BOUNDARY_ARG,
447 data.blocksize),
448 SDHCI_BLOCK_SIZE);
449 sdhci_writew(host, data.blocks, SDHCI_BLOCK_COUNT);
450 sdhci_writew(host, SDHCI_TRNS_READ, SDHCI_TRANSFER_MODE);
451
452 mmc_send_cmd(mmc, &cmd, NULL);
Faiz Abbas2eddc002019-06-11 00:43:40 +0530453 ctrl = sdhci_readw(host, SDHCI_HOST_CONTROL2);
Siva Durga Prasad Paladugucad14a82018-04-19 12:37:09 +0530454
455 if (cmd.cmdidx == MMC_CMD_SEND_TUNING_BLOCK)
456 udelay(1);
457
458 } while (ctrl & SDHCI_CTRL_EXEC_TUNING);
459
460 if (tuning_loop_counter < 0) {
461 ctrl &= ~SDHCI_CTRL_TUNED_CLK;
Faiz Abbas2eddc002019-06-11 00:43:40 +0530462 sdhci_writel(host, ctrl, SDHCI_HOST_CONTROL2);
Siva Durga Prasad Paladugucad14a82018-04-19 12:37:09 +0530463 }
464
465 if (!(ctrl & SDHCI_CTRL_TUNED_CLK)) {
466 printf("%s:Tuning failed\n", __func__);
467 return -1;
468 }
469
470 udelay(1);
Ashok Reddy Soma00d98c22023-07-10 14:11:59 +0200471
472 if (device_is_compatible(mmc->dev, "xlnx,zynqmp-8.9a"))
473 arasan_zynqmp_dll_reset(host, priv->node_id);
Siva Durga Prasad Paladugucad14a82018-04-19 12:37:09 +0530474
475 /* Enable only interrupts served by the SD controller */
476 sdhci_writel(host, SDHCI_INT_DATA_MASK | SDHCI_INT_CMD_MASK,
477 SDHCI_INT_ENABLE);
478 /* Mask all sdhci interrupt sources */
479 sdhci_writel(host, 0x0, SDHCI_SIGNAL_ENABLE);
480
481 return 0;
482}
483
Ashok Reddy Soma8f629862020-10-23 04:59:01 -0600484/**
485 * sdhci_zynqmp_sdcardclk_set_phase - Set the SD Output Clock Tap Delays
486 *
Ashok Reddy Soma8f629862020-10-23 04:59:01 -0600487 * @host: Pointer to the sdhci_host structure.
488 * @degrees: The clock phase shift between 0 - 359.
Ashok Reddy Soma94a755d2021-07-09 05:53:39 -0600489 * Return: 0
Michal Simek2a43ab82021-07-09 05:53:43 -0600490 *
491 * Set the SD Output Clock Tap Delays for Output path
Ashok Reddy Soma8f629862020-10-23 04:59:01 -0600492 */
493static int sdhci_zynqmp_sdcardclk_set_phase(struct sdhci_host *host,
494 int degrees)
495{
Ashok Reddy Soma8f629862020-10-23 04:59:01 -0600496 struct mmc *mmc = (struct mmc *)host->mmc;
Ashok Reddy Soma467d0782021-08-02 23:20:43 -0600497 struct udevice *dev = mmc->dev;
498 struct arasan_sdhci_priv *priv = dev_get_priv(mmc->dev);
Ashok Reddy Soma8f629862020-10-23 04:59:01 -0600499 u8 tap_delay, tap_max = 0;
Ashok Reddy Soma8f629862020-10-23 04:59:01 -0600500 int timing = mode2timing[mmc->selected_mode];
Ashok Reddy Soma467d0782021-08-02 23:20:43 -0600501 int ret;
Ashok Reddy Soma8f629862020-10-23 04:59:01 -0600502
503 /*
504 * This is applicable for SDHCI_SPEC_300 and above
505 * ZynqMP does not set phase for <=25MHz clock.
506 * If degrees is zero, no need to do anything.
507 */
Ashok Reddy Soma6f645382021-07-09 05:53:40 -0600508 if (SDHCI_GET_VERSION(host) < SDHCI_SPEC_300)
Ashok Reddy Soma8f629862020-10-23 04:59:01 -0600509 return 0;
510
511 switch (timing) {
512 case MMC_TIMING_MMC_HS:
513 case MMC_TIMING_SD_HS:
514 case MMC_TIMING_UHS_SDR25:
515 case MMC_TIMING_UHS_DDR50:
516 case MMC_TIMING_MMC_DDR52:
517 /* For 50MHz clock, 30 Taps are available */
518 tap_max = 30;
519 break;
520 case MMC_TIMING_UHS_SDR50:
521 /* For 100MHz clock, 15 Taps are available */
522 tap_max = 15;
523 break;
524 case MMC_TIMING_UHS_SDR104:
525 case MMC_TIMING_MMC_HS200:
526 /* For 200MHz clock, 8 Taps are available */
527 tap_max = 8;
528 default:
529 break;
530 }
531
532 tap_delay = (degrees * tap_max) / 360;
533
Ashok Reddy Soma39a177a2021-07-09 05:53:42 -0600534 /* Limit output tap_delay value to 6 bits */
535 tap_delay &= SDHCI_ARASAN_OTAPDLY_SEL_MASK;
536
Ashok Reddy Soma467d0782021-08-02 23:20:43 -0600537 /* Set the Clock Phase */
Ashok Reddy Soma33154532022-09-30 03:25:47 -0600538 ret = arasan_zynqmp_set_out_tapdelay(priv->node_id, tap_delay);
Ashok Reddy Soma467d0782021-08-02 23:20:43 -0600539 if (ret) {
540 dev_err(dev, "Error setting output Tap Delay\n");
541 return ret;
542 }
543
544 /* Release DLL Reset */
Ashok Reddy Soma33154532022-09-30 03:25:47 -0600545 ret = zynqmp_dll_reset(priv->node_id, PM_DLL_RESET_RELEASE);
Ashok Reddy Soma467d0782021-08-02 23:20:43 -0600546 if (ret) {
547 dev_err(dev, "dll_reset release failed with err: %d\n", ret);
548 return ret;
549 }
Ashok Reddy Soma8f629862020-10-23 04:59:01 -0600550
Ashok Reddy Soma94a755d2021-07-09 05:53:39 -0600551 return 0;
Ashok Reddy Soma8f629862020-10-23 04:59:01 -0600552}
553
554/**
555 * sdhci_zynqmp_sampleclk_set_phase - Set the SD Input Clock Tap Delays
556 *
Ashok Reddy Soma8f629862020-10-23 04:59:01 -0600557 * @host: Pointer to the sdhci_host structure.
558 * @degrees: The clock phase shift between 0 - 359.
Ashok Reddy Soma94a755d2021-07-09 05:53:39 -0600559 * Return: 0
Michal Simek2a43ab82021-07-09 05:53:43 -0600560 *
561 * Set the SD Input Clock Tap Delays for Input path
Ashok Reddy Soma8f629862020-10-23 04:59:01 -0600562 */
563static int sdhci_zynqmp_sampleclk_set_phase(struct sdhci_host *host,
564 int degrees)
565{
Ashok Reddy Soma8f629862020-10-23 04:59:01 -0600566 struct mmc *mmc = (struct mmc *)host->mmc;
Ashok Reddy Soma467d0782021-08-02 23:20:43 -0600567 struct udevice *dev = mmc->dev;
568 struct arasan_sdhci_priv *priv = dev_get_priv(mmc->dev);
Ashok Reddy Soma8f629862020-10-23 04:59:01 -0600569 u8 tap_delay, tap_max = 0;
Ashok Reddy Soma8f629862020-10-23 04:59:01 -0600570 int timing = mode2timing[mmc->selected_mode];
Ashok Reddy Soma467d0782021-08-02 23:20:43 -0600571 int ret;
Ashok Reddy Soma8f629862020-10-23 04:59:01 -0600572
573 /*
574 * This is applicable for SDHCI_SPEC_300 and above
575 * ZynqMP does not set phase for <=25MHz clock.
576 * If degrees is zero, no need to do anything.
577 */
Ashok Reddy Soma6f645382021-07-09 05:53:40 -0600578 if (SDHCI_GET_VERSION(host) < SDHCI_SPEC_300)
Ashok Reddy Soma8f629862020-10-23 04:59:01 -0600579 return 0;
580
Ashok Reddy Soma467d0782021-08-02 23:20:43 -0600581 /* Assert DLL Reset */
Ashok Reddy Soma33154532022-09-30 03:25:47 -0600582 ret = zynqmp_dll_reset(priv->node_id, PM_DLL_RESET_ASSERT);
Ashok Reddy Soma467d0782021-08-02 23:20:43 -0600583 if (ret) {
584 dev_err(dev, "dll_reset assert failed with err: %d\n", ret);
585 return ret;
586 }
587
Ashok Reddy Soma8f629862020-10-23 04:59:01 -0600588 switch (timing) {
589 case MMC_TIMING_MMC_HS:
590 case MMC_TIMING_SD_HS:
591 case MMC_TIMING_UHS_SDR25:
592 case MMC_TIMING_UHS_DDR50:
593 case MMC_TIMING_MMC_DDR52:
594 /* For 50MHz clock, 120 Taps are available */
595 tap_max = 120;
596 break;
597 case MMC_TIMING_UHS_SDR50:
598 /* For 100MHz clock, 60 Taps are available */
599 tap_max = 60;
600 break;
601 case MMC_TIMING_UHS_SDR104:
602 case MMC_TIMING_MMC_HS200:
603 /* For 200MHz clock, 30 Taps are available */
604 tap_max = 30;
605 default:
606 break;
607 }
608
609 tap_delay = (degrees * tap_max) / 360;
610
Ashok Reddy Soma39a177a2021-07-09 05:53:42 -0600611 /* Limit input tap_delay value to 8 bits */
612 tap_delay &= SDHCI_ARASAN_ITAPDLY_SEL_MASK;
613
Ashok Reddy Soma33154532022-09-30 03:25:47 -0600614 ret = arasan_zynqmp_set_in_tapdelay(priv->node_id, tap_delay);
Ashok Reddy Soma467d0782021-08-02 23:20:43 -0600615 if (ret) {
616 dev_err(dev, "Error setting Input Tap Delay\n");
617 return ret;
618 }
Ashok Reddy Soma8f629862020-10-23 04:59:01 -0600619
Ashok Reddy Soma94a755d2021-07-09 05:53:39 -0600620 return 0;
Ashok Reddy Soma8f629862020-10-23 04:59:01 -0600621}
622
Ashok Reddy Soma568edfd2020-10-23 04:59:02 -0600623/**
624 * sdhci_versal_sdcardclk_set_phase - Set the SD Output Clock Tap Delays
625 *
Ashok Reddy Soma568edfd2020-10-23 04:59:02 -0600626 * @host: Pointer to the sdhci_host structure.
Michal Simek2a43ab82021-07-09 05:53:43 -0600627 * @degrees: The clock phase shift between 0 - 359.
Ashok Reddy Soma94a755d2021-07-09 05:53:39 -0600628 * Return: 0
Michal Simek2a43ab82021-07-09 05:53:43 -0600629 *
630 * Set the SD Output Clock Tap Delays for Output path
Ashok Reddy Soma568edfd2020-10-23 04:59:02 -0600631 */
632static int sdhci_versal_sdcardclk_set_phase(struct sdhci_host *host,
633 int degrees)
634{
635 struct mmc *mmc = (struct mmc *)host->mmc;
636 u8 tap_delay, tap_max = 0;
Ashok Reddy Soma568edfd2020-10-23 04:59:02 -0600637 int timing = mode2timing[mmc->selected_mode];
Ashok Reddy Soma24a51072021-07-09 05:53:41 -0600638 u32 regval;
Ashok Reddy Soma568edfd2020-10-23 04:59:02 -0600639
640 /*
641 * This is applicable for SDHCI_SPEC_300 and above
642 * Versal does not set phase for <=25MHz clock.
643 * If degrees is zero, no need to do anything.
644 */
Ashok Reddy Soma6f645382021-07-09 05:53:40 -0600645 if (SDHCI_GET_VERSION(host) < SDHCI_SPEC_300)
Ashok Reddy Soma568edfd2020-10-23 04:59:02 -0600646 return 0;
647
648 switch (timing) {
649 case MMC_TIMING_MMC_HS:
650 case MMC_TIMING_SD_HS:
651 case MMC_TIMING_UHS_SDR25:
652 case MMC_TIMING_UHS_DDR50:
653 case MMC_TIMING_MMC_DDR52:
654 /* For 50MHz clock, 30 Taps are available */
655 tap_max = 30;
656 break;
657 case MMC_TIMING_UHS_SDR50:
658 /* For 100MHz clock, 15 Taps are available */
659 tap_max = 15;
660 break;
661 case MMC_TIMING_UHS_SDR104:
662 case MMC_TIMING_MMC_HS200:
663 /* For 200MHz clock, 8 Taps are available */
664 tap_max = 8;
665 default:
666 break;
667 }
668
669 tap_delay = (degrees * tap_max) / 360;
670
Ashok Reddy Soma24a51072021-07-09 05:53:41 -0600671 /* Limit output tap_delay value to 6 bits */
672 tap_delay &= SDHCI_ARASAN_OTAPDLY_SEL_MASK;
Ashok Reddy Soma568edfd2020-10-23 04:59:02 -0600673
Ashok Reddy Soma24a51072021-07-09 05:53:41 -0600674 /* Set the Clock Phase */
675 regval = sdhci_readl(host, SDHCI_ARASAN_OTAPDLY_REGISTER);
676 regval |= SDHCI_OTAPDLY_ENABLE;
677 sdhci_writel(host, regval, SDHCI_ARASAN_OTAPDLY_REGISTER);
678 regval &= ~SDHCI_ARASAN_OTAPDLY_SEL_MASK;
679 regval |= tap_delay;
680 sdhci_writel(host, regval, SDHCI_ARASAN_OTAPDLY_REGISTER);
Ashok Reddy Soma568edfd2020-10-23 04:59:02 -0600681
Ashok Reddy Soma94a755d2021-07-09 05:53:39 -0600682 return 0;
Ashok Reddy Soma568edfd2020-10-23 04:59:02 -0600683}
684
685/**
686 * sdhci_versal_sampleclk_set_phase - Set the SD Input Clock Tap Delays
687 *
Ashok Reddy Soma568edfd2020-10-23 04:59:02 -0600688 * @host: Pointer to the sdhci_host structure.
Michal Simek2a43ab82021-07-09 05:53:43 -0600689 * @degrees: The clock phase shift between 0 - 359.
Ashok Reddy Soma94a755d2021-07-09 05:53:39 -0600690 * Return: 0
Michal Simek2a43ab82021-07-09 05:53:43 -0600691 *
692 * Set the SD Input Clock Tap Delays for Input path
Ashok Reddy Soma568edfd2020-10-23 04:59:02 -0600693 */
694static int sdhci_versal_sampleclk_set_phase(struct sdhci_host *host,
695 int degrees)
696{
697 struct mmc *mmc = (struct mmc *)host->mmc;
698 u8 tap_delay, tap_max = 0;
Ashok Reddy Soma568edfd2020-10-23 04:59:02 -0600699 int timing = mode2timing[mmc->selected_mode];
Ashok Reddy Soma24a51072021-07-09 05:53:41 -0600700 u32 regval;
Ashok Reddy Soma568edfd2020-10-23 04:59:02 -0600701
702 /*
703 * This is applicable for SDHCI_SPEC_300 and above
704 * Versal does not set phase for <=25MHz clock.
705 * If degrees is zero, no need to do anything.
706 */
Ashok Reddy Soma6f645382021-07-09 05:53:40 -0600707 if (SDHCI_GET_VERSION(host) < SDHCI_SPEC_300)
Ashok Reddy Soma568edfd2020-10-23 04:59:02 -0600708 return 0;
709
710 switch (timing) {
711 case MMC_TIMING_MMC_HS:
712 case MMC_TIMING_SD_HS:
713 case MMC_TIMING_UHS_SDR25:
714 case MMC_TIMING_UHS_DDR50:
715 case MMC_TIMING_MMC_DDR52:
716 /* For 50MHz clock, 120 Taps are available */
717 tap_max = 120;
718 break;
719 case MMC_TIMING_UHS_SDR50:
720 /* For 100MHz clock, 60 Taps are available */
721 tap_max = 60;
722 break;
723 case MMC_TIMING_UHS_SDR104:
724 case MMC_TIMING_MMC_HS200:
725 /* For 200MHz clock, 30 Taps are available */
726 tap_max = 30;
727 default:
728 break;
729 }
730
731 tap_delay = (degrees * tap_max) / 360;
732
Ashok Reddy Soma24a51072021-07-09 05:53:41 -0600733 /* Limit input tap_delay value to 8 bits */
734 tap_delay &= SDHCI_ARASAN_ITAPDLY_SEL_MASK;
Ashok Reddy Soma568edfd2020-10-23 04:59:02 -0600735
Ashok Reddy Soma24a51072021-07-09 05:53:41 -0600736 /* Set the Clock Phase */
737 regval = sdhci_readl(host, SDHCI_ARASAN_ITAPDLY_REGISTER);
738 regval |= SDHCI_ITAPDLY_CHGWIN;
739 sdhci_writel(host, regval, SDHCI_ARASAN_ITAPDLY_REGISTER);
740 regval |= SDHCI_ITAPDLY_ENABLE;
741 sdhci_writel(host, regval, SDHCI_ARASAN_ITAPDLY_REGISTER);
742 regval &= ~SDHCI_ARASAN_ITAPDLY_SEL_MASK;
743 regval |= tap_delay;
744 sdhci_writel(host, regval, SDHCI_ARASAN_ITAPDLY_REGISTER);
745 regval &= ~SDHCI_ITAPDLY_CHGWIN;
746 sdhci_writel(host, regval, SDHCI_ARASAN_ITAPDLY_REGISTER);
Ashok Reddy Soma568edfd2020-10-23 04:59:02 -0600747
Ashok Reddy Soma94a755d2021-07-09 05:53:39 -0600748 return 0;
Ashok Reddy Soma568edfd2020-10-23 04:59:02 -0600749}
750
Ashok Reddy Soma0ab38fd2023-01-10 04:31:21 -0700751/**
752 * sdhci_versal_net_emmc_sdcardclk_set_phase - Set eMMC Output Clock Tap Delays
753 *
754 * @host: Pointer to the sdhci_host structure.
755 * @degrees: The clock phase shift between 0 - 359.
756 * Return: 0
757 *
758 * Set eMMC Output Clock Tap Delays for Output path
759 */
760static int sdhci_versal_net_emmc_sdcardclk_set_phase(struct sdhci_host *host, int degrees)
761{
762 struct mmc *mmc = (struct mmc *)host->mmc;
763 int timing = mode2timing[mmc->selected_mode];
764 u8 tap_delay, tap_max = 0;
765 u32 regval;
766
767 switch (timing) {
768 case MMC_TIMING_MMC_HS:
769 case MMC_TIMING_MMC_DDR52:
770 tap_max = 16;
771 break;
772 case MMC_TIMING_MMC_HS200:
773 case MMC_TIMING_MMC_HS400:
774 /* For 200MHz clock, 32 Taps are available */
775 tap_max = 32;
776 break;
777 default:
778 break;
779 }
780
781 tap_delay = (degrees * tap_max) / 360;
782 /* Set the Clock Phase */
783 if (tap_delay) {
784 regval = sdhci_readl(host, PHY_CTRL_REG1);
785 regval |= PHY_CTRL_OTAPDLY_ENA_MASK;
786 sdhci_writel(host, regval, PHY_CTRL_REG1);
787 regval &= ~PHY_CTRL_OTAPDLY_SEL_MASK;
788 regval |= tap_delay << PHY_CTRL_OTAPDLY_SEL_SHIFT;
789 sdhci_writel(host, regval, PHY_CTRL_REG1);
790 }
791
792 return 0;
793}
794
795/**
796 * sdhci_versal_net_emmc_sampleclk_set_phase - Set eMMC Input Clock Tap Delays
797 *
798 * @host: Pointer to the sdhci_host structure.
799 * @degrees: The clock phase shift between 0 - 359.
800 * Return: 0
801 *
802 * Set eMMC Input Clock Tap Delays for Input path. If HS400 is selected,
803 * set strobe90 and strobe180 in PHY_CTRL_REG1.
804 */
805static int sdhci_versal_net_emmc_sampleclk_set_phase(struct sdhci_host *host, int degrees)
806{
807 struct mmc *mmc = (struct mmc *)host->mmc;
808 int timing = mode2timing[mmc->selected_mode];
809 u8 tap_delay, tap_max = 0;
810 u32 regval;
811
812 switch (timing) {
813 case MMC_TIMING_MMC_HS:
814 case MMC_TIMING_MMC_DDR52:
815 tap_max = 32;
816 break;
817 case MMC_TIMING_MMC_HS400:
818 /* Strobe select tap point for strb90 and strb180 */
819 regval = sdhci_readl(host, PHY_CTRL_REG1);
820 regval &= ~PHY_CTRL_STRB_SEL_MASK;
821 regval |= VERSAL_NET_PHY_CTRL_STRB90_STRB180_VAL << PHY_CTRL_STRB_SEL_SHIFT;
822 sdhci_writel(host, regval, PHY_CTRL_REG1);
823 break;
824 default:
825 break;
826 }
827
828 tap_delay = (degrees * tap_max) / 360;
829 /* Set the Clock Phase */
830 if (tap_delay) {
831 regval = sdhci_readl(host, PHY_CTRL_REG1);
832 regval |= PHY_CTRL_ITAP_CHG_WIN_MASK;
833 sdhci_writel(host, regval, PHY_CTRL_REG1);
834 regval |= PHY_CTRL_ITAPDLY_ENA_MASK;
835 sdhci_writel(host, regval, PHY_CTRL_REG1);
836 regval &= ~PHY_CTRL_ITAPDLY_SEL_MASK;
837 regval |= tap_delay << PHY_CTRL_ITAPDLY_SEL_SHIFT;
838 sdhci_writel(host, regval, PHY_CTRL_REG1);
839 regval &= ~PHY_CTRL_ITAP_CHG_WIN_MASK;
840 sdhci_writel(host, regval, PHY_CTRL_REG1);
841 }
842
843 return 0;
844}
845
Ashok Reddy Soma21fd7632021-08-02 23:20:40 -0600846static int arasan_sdhci_set_tapdelay(struct sdhci_host *host)
Siva Durga Prasad Paladugucad14a82018-04-19 12:37:09 +0530847{
848 struct arasan_sdhci_priv *priv = dev_get_priv(host->mmc->dev);
Ashok Reddy Soma8f629862020-10-23 04:59:01 -0600849 struct arasan_sdhci_clk_data *clk_data = &priv->clk_data;
Siva Durga Prasad Paladugucad14a82018-04-19 12:37:09 +0530850 struct mmc *mmc = (struct mmc *)host->mmc;
Ashok Reddy Soma8f629862020-10-23 04:59:01 -0600851 struct udevice *dev = mmc->dev;
852 u8 timing = mode2timing[mmc->selected_mode];
853 u32 iclk_phase = clk_data->clk_phase_in[timing];
854 u32 oclk_phase = clk_data->clk_phase_out[timing];
Ashok Reddy Soma21fd7632021-08-02 23:20:40 -0600855 int ret;
Siva Durga Prasad Paladugucad14a82018-04-19 12:37:09 +0530856
Ashok Reddy Soma8f629862020-10-23 04:59:01 -0600857 dev_dbg(dev, "%s, host:%s, mode:%d\n", __func__, host->name, timing);
Siva Durga Prasad Paladugucad14a82018-04-19 12:37:09 +0530858
Ashok Reddy Soma8f629862020-10-23 04:59:01 -0600859 if (IS_ENABLED(CONFIG_ARCH_ZYNQMP) &&
860 device_is_compatible(dev, "xlnx,zynqmp-8.9a")) {
Ashok Reddy Soma21fd7632021-08-02 23:20:40 -0600861 ret = sdhci_zynqmp_sampleclk_set_phase(host, iclk_phase);
862 if (ret)
863 return ret;
864
865 ret = sdhci_zynqmp_sdcardclk_set_phase(host, oclk_phase);
866 if (ret)
867 return ret;
Ashok Reddy Soma568edfd2020-10-23 04:59:02 -0600868 } else if (IS_ENABLED(CONFIG_ARCH_VERSAL) &&
869 device_is_compatible(dev, "xlnx,versal-8.9a")) {
Ashok Reddy Soma21fd7632021-08-02 23:20:40 -0600870 ret = sdhci_versal_sampleclk_set_phase(host, iclk_phase);
871 if (ret)
872 return ret;
873
874 ret = sdhci_versal_sdcardclk_set_phase(host, oclk_phase);
875 if (ret)
876 return ret;
Ashok Reddy Soma0ab38fd2023-01-10 04:31:21 -0700877 } else if (IS_ENABLED(CONFIG_ARCH_VERSAL_NET) &&
Michal Simekb1fa0d02023-05-17 10:22:48 +0200878 device_is_compatible(dev, "xlnx,versal-net-emmc")) {
Ashok Reddy Soma0ab38fd2023-01-10 04:31:21 -0700879 if (mmc->clock >= MIN_PHY_CLK_HZ)
880 if (iclk_phase == VERSAL_NET_EMMC_ICLK_PHASE_DDR52_DLY_CHAIN)
881 iclk_phase = VERSAL_NET_EMMC_ICLK_PHASE_DDR52_DLL;
882
883 ret = sdhci_versal_net_emmc_sampleclk_set_phase(host, iclk_phase);
884 if (ret)
885 return ret;
886
887 ret = sdhci_versal_net_emmc_sdcardclk_set_phase(host, oclk_phase);
888 if (ret)
889 return ret;
Ashok Reddy Soma8f629862020-10-23 04:59:01 -0600890 }
Ashok Reddy Soma21fd7632021-08-02 23:20:40 -0600891
892 return 0;
Siva Durga Prasad Paladugucad14a82018-04-19 12:37:09 +0530893}
894
Michal Simek33a6b772020-10-23 04:59:00 -0600895static void arasan_dt_read_clk_phase(struct udevice *dev, unsigned char timing,
896 const char *prop)
897{
898 struct arasan_sdhci_priv *priv = dev_get_priv(dev);
899 struct arasan_sdhci_clk_data *clk_data = &priv->clk_data;
900 u32 clk_phase[2] = {0};
901
902 /*
903 * Read Tap Delay values from DT, if the DT does not contain the
904 * Tap Values then use the pre-defined values
905 */
906 if (dev_read_u32_array(dev, prop, &clk_phase[0], 2)) {
907 dev_dbg(dev, "Using predefined clock phase for %s = %d %d\n",
908 prop, clk_data->clk_phase_in[timing],
909 clk_data->clk_phase_out[timing]);
910 return;
911 }
912
913 /* The values read are Input and Output Clock Delays in order */
914 clk_data->clk_phase_in[timing] = clk_phase[0];
915 clk_data->clk_phase_out[timing] = clk_phase[1];
916}
917
918/**
919 * arasan_dt_parse_clk_phases - Read Tap Delay values from DT
920 *
Michal Simek33a6b772020-10-23 04:59:00 -0600921 * @dev: Pointer to our struct udevice.
Michal Simek2a43ab82021-07-09 05:53:43 -0600922 *
923 * Called at initialization to parse the values of Tap Delays.
Michal Simek33a6b772020-10-23 04:59:00 -0600924 */
925static void arasan_dt_parse_clk_phases(struct udevice *dev)
926{
927 struct arasan_sdhci_priv *priv = dev_get_priv(dev);
928 struct arasan_sdhci_clk_data *clk_data = &priv->clk_data;
929 int i;
930
931 if (IS_ENABLED(CONFIG_ARCH_ZYNQMP) &&
932 device_is_compatible(dev, "xlnx,zynqmp-8.9a")) {
933 for (i = 0; i <= MMC_TIMING_MMC_HS400; i++) {
934 clk_data->clk_phase_in[i] = zynqmp_iclk_phases[i];
935 clk_data->clk_phase_out[i] = zynqmp_oclk_phases[i];
936 }
937
938 if (priv->bank == MMC_BANK2) {
939 clk_data->clk_phase_out[MMC_TIMING_UHS_SDR104] = 90;
940 clk_data->clk_phase_out[MMC_TIMING_MMC_HS200] = 90;
941 }
942 }
943
Ashok Reddy Soma568edfd2020-10-23 04:59:02 -0600944 if (IS_ENABLED(CONFIG_ARCH_VERSAL) &&
945 device_is_compatible(dev, "xlnx,versal-8.9a")) {
946 for (i = 0; i <= MMC_TIMING_MMC_HS400; i++) {
947 clk_data->clk_phase_in[i] = versal_iclk_phases[i];
948 clk_data->clk_phase_out[i] = versal_oclk_phases[i];
949 }
950 }
951
Ashok Reddy Soma0ab38fd2023-01-10 04:31:21 -0700952 if (IS_ENABLED(CONFIG_ARCH_VERSAL_NET) &&
Michal Simekb1fa0d02023-05-17 10:22:48 +0200953 device_is_compatible(dev, "xlnx,versal-net-emmc")) {
Ashok Reddy Soma0ab38fd2023-01-10 04:31:21 -0700954 for (i = 0; i <= MMC_TIMING_MMC_HS400; i++) {
955 clk_data->clk_phase_in[i] = versal_net_emmc_iclk_phases[i];
956 clk_data->clk_phase_out[i] = versal_net_emmc_oclk_phases[i];
957 }
958 }
959
Michal Simek33a6b772020-10-23 04:59:00 -0600960 arasan_dt_read_clk_phase(dev, MMC_TIMING_LEGACY,
961 "clk-phase-legacy");
962 arasan_dt_read_clk_phase(dev, MMC_TIMING_MMC_HS,
963 "clk-phase-mmc-hs");
964 arasan_dt_read_clk_phase(dev, MMC_TIMING_SD_HS,
965 "clk-phase-sd-hs");
966 arasan_dt_read_clk_phase(dev, MMC_TIMING_UHS_SDR12,
967 "clk-phase-uhs-sdr12");
968 arasan_dt_read_clk_phase(dev, MMC_TIMING_UHS_SDR25,
969 "clk-phase-uhs-sdr25");
970 arasan_dt_read_clk_phase(dev, MMC_TIMING_UHS_SDR50,
971 "clk-phase-uhs-sdr50");
972 arasan_dt_read_clk_phase(dev, MMC_TIMING_UHS_SDR104,
973 "clk-phase-uhs-sdr104");
974 arasan_dt_read_clk_phase(dev, MMC_TIMING_UHS_DDR50,
975 "clk-phase-uhs-ddr50");
976 arasan_dt_read_clk_phase(dev, MMC_TIMING_MMC_DDR52,
977 "clk-phase-mmc-ddr52");
978 arasan_dt_read_clk_phase(dev, MMC_TIMING_MMC_HS200,
979 "clk-phase-mmc-hs200");
980 arasan_dt_read_clk_phase(dev, MMC_TIMING_MMC_HS400,
981 "clk-phase-mmc-hs400");
982}
983
Michal Simek635cf4a2021-07-09 05:53:44 -0600984static const struct sdhci_ops arasan_ops = {
985 .platform_execute_tuning = &arasan_sdhci_execute_tuning,
Siva Durga Prasad Paladugucad14a82018-04-19 12:37:09 +0530986 .set_delay = &arasan_sdhci_set_tapdelay,
Ashok Reddy Soma8ee49f02021-08-02 23:20:46 -0600987 .set_control_reg = &sdhci_set_control_reg,
Ashok Reddy Soma0ab38fd2023-01-10 04:31:21 -0700988#if defined(CONFIG_ARCH_VERSAL_NET)
989 .config_dll = &arasan_sdhci_config_dll,
990#endif
Siva Durga Prasad Paladugucad14a82018-04-19 12:37:09 +0530991};
992#endif
993
Algapally Santosh Sagarbf34dd42023-02-01 02:55:53 -0700994#if defined(CONFIG_ARCH_ZYNQMP) && defined(CONFIG_ZYNQMP_FIRMWARE)
Ashok Reddy Somaca7d8472022-02-23 15:36:05 +0100995static int sdhci_zynqmp_set_dynamic_config(struct arasan_sdhci_priv *priv,
996 struct udevice *dev)
997{
998 int ret;
Ashok Reddy Somaca7d8472022-02-23 15:36:05 +0100999 struct clk clk;
1000 unsigned long clock, mhz;
1001
Ashok Reddy Soma33154532022-09-30 03:25:47 -06001002 ret = xilinx_pm_request(PM_REQUEST_NODE, priv->node_id,
1003 ZYNQMP_PM_CAPABILITY_ACCESS, ZYNQMP_PM_MAX_QOS,
1004 ZYNQMP_PM_REQUEST_ACK_NO, NULL);
Ashok Reddy Somaca7d8472022-02-23 15:36:05 +01001005 if (ret) {
Ashok Reddy Soma33154532022-09-30 03:25:47 -06001006 dev_err(dev, "Request node failed for %d\n", priv->node_id);
Ashok Reddy Somaca7d8472022-02-23 15:36:05 +01001007 return ret;
1008 }
1009
1010 ret = reset_get_bulk(dev, &priv->resets);
1011 if (ret == -ENOTSUPP || ret == -ENOENT) {
1012 dev_err(dev, "Reset not found\n");
1013 return 0;
1014 } else if (ret) {
1015 dev_err(dev, "Reset failed\n");
1016 return ret;
1017 }
1018
1019 ret = reset_assert_bulk(&priv->resets);
1020 if (ret) {
1021 dev_err(dev, "Reset assert failed\n");
1022 return ret;
1023 }
1024
Ashok Reddy Soma33154532022-09-30 03:25:47 -06001025 ret = zynqmp_pm_set_sd_config(priv->node_id, SD_CONFIG_FIXED, 0);
Ashok Reddy Somaca7d8472022-02-23 15:36:05 +01001026 if (ret) {
1027 dev_err(dev, "SD_CONFIG_FIXED failed\n");
1028 return ret;
1029 }
1030
Ashok Reddy Soma33154532022-09-30 03:25:47 -06001031 ret = zynqmp_pm_set_sd_config(priv->node_id, SD_CONFIG_EMMC_SEL,
Ashok Reddy Somaca7d8472022-02-23 15:36:05 +01001032 dev_read_bool(dev, "non-removable"));
1033 if (ret) {
1034 dev_err(dev, "SD_CONFIG_EMMC_SEL failed\n");
1035 return ret;
1036 }
1037
1038 ret = clk_get_by_index(dev, 0, &clk);
1039 if (ret < 0) {
1040 dev_err(dev, "failed to get clock\n");
1041 return ret;
1042 }
1043
1044 clock = clk_get_rate(&clk);
1045 if (IS_ERR_VALUE(clock)) {
1046 dev_err(dev, "failed to get rate\n");
1047 return clock;
1048 }
1049
1050 mhz = DIV64_U64_ROUND_UP(clock, 1000000);
1051
Ashok Reddy Soma088febe2022-03-25 13:11:10 +01001052 if (mhz > 100 && mhz <= 200)
1053 mhz = 200;
1054 else if (mhz > 50 && mhz <= 100)
1055 mhz = 100;
1056 else if (mhz > 25 && mhz <= 50)
1057 mhz = 50;
1058 else
1059 mhz = 25;
1060
Ashok Reddy Soma33154532022-09-30 03:25:47 -06001061 ret = zynqmp_pm_set_sd_config(priv->node_id, SD_CONFIG_BASECLK, mhz);
Ashok Reddy Somaca7d8472022-02-23 15:36:05 +01001062 if (ret) {
1063 dev_err(dev, "SD_CONFIG_BASECLK failed\n");
1064 return ret;
1065 }
1066
Ashok Reddy Soma33154532022-09-30 03:25:47 -06001067 ret = zynqmp_pm_set_sd_config(priv->node_id, SD_CONFIG_8BIT,
Ashok Reddy Somaca7d8472022-02-23 15:36:05 +01001068 (dev_read_u32_default(dev, "bus-width", 1) == 8));
1069 if (ret) {
1070 dev_err(dev, "SD_CONFIG_8BIT failed\n");
1071 return ret;
1072 }
1073
1074 ret = reset_deassert_bulk(&priv->resets);
1075 if (ret) {
1076 dev_err(dev, "Reset release failed\n");
1077 return ret;
1078 }
1079
1080 return 0;
1081}
1082#endif
1083
Michal Simek9ecd2682015-11-30 16:13:03 +01001084static int arasan_sdhci_probe(struct udevice *dev)
Michal Simek0dd222b2013-04-22 14:56:49 +02001085{
Simon Glassfa20e932020-12-03 16:55:20 -07001086 struct arasan_sdhci_plat *plat = dev_get_plat(dev);
Michal Simek9ecd2682015-11-30 16:13:03 +01001087 struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
Siva Durga Prasad Paladugucad14a82018-04-19 12:37:09 +05301088 struct arasan_sdhci_priv *priv = dev_get_priv(dev);
1089 struct sdhci_host *host;
Stefan Herbrechtsmeier739ae402017-01-17 16:27:32 +01001090 struct clk clk;
1091 unsigned long clock;
Simon Glass4cc87fb2016-07-05 17:10:15 -06001092 int ret;
Michal Simek0dd222b2013-04-22 14:56:49 +02001093
Siva Durga Prasad Paladugucad14a82018-04-19 12:37:09 +05301094 host = priv->host;
1095
Algapally Santosh Sagarbf34dd42023-02-01 02:55:53 -07001096#if defined(CONFIG_ARCH_ZYNQMP) && defined(CONFIG_ZYNQMP_FIRMWARE)
Ashok Reddy Somaca7d8472022-02-23 15:36:05 +01001097 if (device_is_compatible(dev, "xlnx,zynqmp-8.9a")) {
1098 ret = zynqmp_pm_is_function_supported(PM_IOCTL,
1099 IOCTL_SET_SD_CONFIG);
1100 if (!ret) {
1101 ret = sdhci_zynqmp_set_dynamic_config(priv, dev);
1102 if (ret)
1103 return ret;
1104 }
1105 }
1106#endif
Michal Simekb1fa0d02023-05-17 10:22:48 +02001107 if (device_is_compatible(dev, "xlnx,versal-net-emmc"))
Ashok Reddy Soma0ab38fd2023-01-10 04:31:21 -07001108 priv->internal_phy_reg = true;
Ashok Reddy Somaca7d8472022-02-23 15:36:05 +01001109
Stefan Herbrechtsmeier739ae402017-01-17 16:27:32 +01001110 ret = clk_get_by_index(dev, 0, &clk);
1111 if (ret < 0) {
1112 dev_err(dev, "failed to get clock\n");
1113 return ret;
1114 }
1115
1116 clock = clk_get_rate(&clk);
1117 if (IS_ERR_VALUE(clock)) {
1118 dev_err(dev, "failed to get rate\n");
1119 return clock;
1120 }
Siva Durga Prasad Paladugucad14a82018-04-19 12:37:09 +05301121
Ashok Reddy Somaca7d8472022-02-23 15:36:05 +01001122 dev_dbg(dev, "%s: CLK %ld\n", __func__, clock);
Stefan Herbrechtsmeier739ae402017-01-17 16:27:32 +01001123
1124 ret = clk_enable(&clk);
Michal Simek41710952021-02-09 15:28:15 +01001125 if (ret) {
Stefan Herbrechtsmeier739ae402017-01-17 16:27:32 +01001126 dev_err(dev, "failed to enable clock\n");
1127 return ret;
1128 }
1129
Siva Durga Prasad Paladugu049e0032014-07-08 15:31:04 +05301130 host->quirks = SDHCI_QUIRK_WAIT_SEND_CMD |
Siva Durga Prasad Paladugu0d6891b2014-01-22 09:17:09 +01001131 SDHCI_QUIRK_BROKEN_R1B;
Siva Durga Prasad Paladugua1619fe2016-01-12 15:12:16 +05301132
1133#ifdef CONFIG_ZYNQ_HISPD_BROKEN
Hannes Schmelzer94a5bbc2018-03-07 08:00:57 +01001134 host->quirks |= SDHCI_QUIRK_BROKEN_HISPD_MODE;
Siva Durga Prasad Paladugua1619fe2016-01-12 15:12:16 +05301135#endif
1136
Ashok Reddy Soma61e0df92020-10-23 04:58:57 -06001137 if (priv->no_1p8)
1138 host->quirks |= SDHCI_QUIRK_NO_1_8_V;
1139
Ashok Reddy Soma407a5612023-01-10 04:31:24 -07001140 if (CONFIG_IS_ENABLED(ARCH_VERSAL_NET) &&
Michal Simekb1fa0d02023-05-17 10:22:48 +02001141 device_is_compatible(dev, "xlnx,versal-net-emmc"))
Ashok Reddy Soma407a5612023-01-10 04:31:24 -07001142 host->quirks |= SDHCI_QUIRK_CAPS_BIT63_FOR_HS400;
1143
Benedikt Grassl529e6f02020-04-14 07:32:12 +02001144 plat->cfg.f_max = CONFIG_ZYNQ_SDHCI_MAX_FREQ;
1145
1146 ret = mmc_of_parse(dev, &plat->cfg);
1147 if (ret)
1148 return ret;
Siva Durga Prasad Paladugucad14a82018-04-19 12:37:09 +05301149
Stefan Herbrechtsmeier739ae402017-01-17 16:27:32 +01001150 host->max_clk = clock;
Stefan Herbrechtsmeierbc47e0e2017-01-17 15:58:48 +01001151
Matwey V. Kornilov194b8602019-08-01 18:00:05 +03001152 host->mmc = &plat->mmc;
1153 host->mmc->dev = dev;
1154 host->mmc->priv = host;
1155
Benedikt Grassl529e6f02020-04-14 07:32:12 +02001156 ret = sdhci_setup_cfg(&plat->cfg, host, plat->cfg.f_max,
Jaehoon Chung8a5ffbb2016-07-26 19:06:24 +09001157 CONFIG_ZYNQ_SDHCI_MIN_FREQ);
Simon Glass4cc87fb2016-07-05 17:10:15 -06001158 if (ret)
1159 return ret;
Simon Glass4cc87fb2016-07-05 17:10:15 -06001160 upriv->mmc = host->mmc;
Michal Simek9ecd2682015-11-30 16:13:03 +01001161
T Karthik Reddyab0a7492021-08-02 23:20:45 -06001162 /*
1163 * WORKAROUND: Versal platforms have an issue with card detect state.
1164 * Due to this, host controller is switching off voltage to sd card
1165 * causing sd card timeout error. Workaround this by adding a wait for
1166 * 1000msec till the card detect state gets stable.
1167 */
Ashok Reddy Soma6556bff2022-02-23 15:13:32 +01001168 if (IS_ENABLED(CONFIG_ARCH_ZYNQMP) || IS_ENABLED(CONFIG_ARCH_VERSAL)) {
Ashok Reddy Somadd745772022-02-23 15:13:31 +01001169 u32 timeout = 1000000;
T Karthik Reddyab0a7492021-08-02 23:20:45 -06001170
1171 while (((sdhci_readl(host, SDHCI_PRESENT_STATE) &
Ashok Reddy Soma09f38902022-02-23 15:13:30 +01001172 SDHCI_CARD_STATE_STABLE) == 0) && timeout) {
Ashok Reddy Somadd745772022-02-23 15:13:31 +01001173 udelay(1);
Ashok Reddy Soma09f38902022-02-23 15:13:30 +01001174 timeout--;
T Karthik Reddyab0a7492021-08-02 23:20:45 -06001175 }
1176 if (!timeout) {
1177 dev_err(dev, "Sdhci card detect state not stable\n");
1178 return -ETIMEDOUT;
1179 }
1180 }
1181
Simon Glass4cc87fb2016-07-05 17:10:15 -06001182 return sdhci_probe(dev);
Michal Simek0dd222b2013-04-22 14:56:49 +02001183}
Michal Simek9ecd2682015-11-30 16:13:03 +01001184
Simon Glassaad29ae2020-12-03 16:55:21 -07001185static int arasan_sdhci_of_to_plat(struct udevice *dev)
Michal Simek9ecd2682015-11-30 16:13:03 +01001186{
Siva Durga Prasad Paladugucad14a82018-04-19 12:37:09 +05301187 struct arasan_sdhci_priv *priv = dev_get_priv(dev);
Ashok Reddy Soma33154532022-09-30 03:25:47 -06001188 u32 pm_info[2];
Michal Simek9ecd2682015-11-30 16:13:03 +01001189
Siva Durga Prasad Paladugucad14a82018-04-19 12:37:09 +05301190 priv->host = calloc(1, sizeof(struct sdhci_host));
1191 if (!priv->host)
1192 return -1;
1193
1194 priv->host->name = dev->name;
Siva Durga Prasad Paladugucad14a82018-04-19 12:37:09 +05301195
Ashok Reddy Soma0ab38fd2023-01-10 04:31:21 -07001196#if defined(CONFIG_ARCH_ZYNQMP) || defined(CONFIG_ARCH_VERSAL) || defined(CONFIG_ARCH_VERSAL_NET)
Siva Durga Prasad Paladugucad14a82018-04-19 12:37:09 +05301197 priv->host->ops = &arasan_ops;
Michal Simek33a6b772020-10-23 04:59:00 -06001198 arasan_dt_parse_clk_phases(dev);
Siva Durga Prasad Paladugucad14a82018-04-19 12:37:09 +05301199#endif
Michal Simek9ecd2682015-11-30 16:13:03 +01001200
Johan Jonker8d5d8e02023-03-13 01:32:04 +01001201 priv->host->ioaddr = dev_read_addr_ptr(dev);
1202 if (!priv->host->ioaddr)
1203 return -EINVAL;
Michal Simek921a8de2018-05-16 10:57:07 +02001204
Michal Simeke40ae572020-07-22 17:46:31 +02001205 priv->bank = dev_read_u32_default(dev, "xlnx,mio-bank", 0);
Ashok Reddy Soma61e0df92020-10-23 04:58:57 -06001206 priv->no_1p8 = dev_read_bool(dev, "no-1-8-v");
Stefan Herbrechtsmeier5567b422017-01-17 16:27:33 +01001207
Ashok Reddy Soma33154532022-09-30 03:25:47 -06001208 priv->node_id = 0;
1209 if (!dev_read_u32_array(dev, "power-domains", pm_info, ARRAY_SIZE(pm_info)))
1210 priv->node_id = pm_info[1];
1211
Michal Simek9ecd2682015-11-30 16:13:03 +01001212 return 0;
1213}
1214
Simon Glass4cc87fb2016-07-05 17:10:15 -06001215static int arasan_sdhci_bind(struct udevice *dev)
1216{
Simon Glassfa20e932020-12-03 16:55:20 -07001217 struct arasan_sdhci_plat *plat = dev_get_plat(dev);
Simon Glass4cc87fb2016-07-05 17:10:15 -06001218
Masahiro Yamadacdb67f32016-09-06 22:17:32 +09001219 return sdhci_bind(dev, &plat->mmc, &plat->cfg);
Simon Glass4cc87fb2016-07-05 17:10:15 -06001220}
1221
Michal Simek9ecd2682015-11-30 16:13:03 +01001222static const struct udevice_id arasan_sdhci_ids[] = {
1223 { .compatible = "arasan,sdhci-8.9a" },
Michal Simekb1fa0d02023-05-17 10:22:48 +02001224 { .compatible = "xlnx,versal-net-emmc" },
Michal Simek9ecd2682015-11-30 16:13:03 +01001225 { }
1226};
1227
1228U_BOOT_DRIVER(arasan_sdhci_drv) = {
1229 .name = "arasan_sdhci",
1230 .id = UCLASS_MMC,
1231 .of_match = arasan_sdhci_ids,
Simon Glassaad29ae2020-12-03 16:55:21 -07001232 .of_to_plat = arasan_sdhci_of_to_plat,
Simon Glass4cc87fb2016-07-05 17:10:15 -06001233 .ops = &sdhci_ops,
1234 .bind = arasan_sdhci_bind,
Michal Simek9ecd2682015-11-30 16:13:03 +01001235 .probe = arasan_sdhci_probe,
Simon Glass8a2b47f2020-12-03 16:55:17 -07001236 .priv_auto = sizeof(struct arasan_sdhci_priv),
Simon Glass71fa5b42020-12-03 16:55:18 -07001237 .plat_auto = sizeof(struct arasan_sdhci_plat),
Michal Simek9ecd2682015-11-30 16:13:03 +01001238};