Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Michal Simek | 0dd222b | 2013-04-22 14:56:49 +0200 | [diff] [blame] | 2 | /* |
Michal Simek | 9ecd268 | 2015-11-30 16:13:03 +0100 | [diff] [blame] | 3 | * (C) Copyright 2013 - 2015 Xilinx, Inc. |
Michal Simek | 0dd222b | 2013-04-22 14:56:49 +0200 | [diff] [blame] | 4 | * |
| 5 | * Xilinx Zynq SD Host Controller Interface |
Michal Simek | 0dd222b | 2013-04-22 14:56:49 +0200 | [diff] [blame] | 6 | */ |
| 7 | |
Stefan Herbrechtsmeier | 739ae40 | 2017-01-17 16:27:32 +0100 | [diff] [blame] | 8 | #include <clk.h> |
Michal Simek | 0dd222b | 2013-04-22 14:56:49 +0200 | [diff] [blame] | 9 | #include <common.h> |
Michal Simek | 9ecd268 | 2015-11-30 16:13:03 +0100 | [diff] [blame] | 10 | #include <dm.h> |
Michal Simek | c57ba04 | 2014-02-24 11:16:31 +0100 | [diff] [blame] | 11 | #include <fdtdec.h> |
Simon Glass | dbd7954 | 2020-05-10 11:40:11 -0600 | [diff] [blame] | 12 | #include <linux/delay.h> |
Siva Durga Prasad Paladugu | cad14a8 | 2018-04-19 12:37:09 +0530 | [diff] [blame] | 13 | #include "mmc_private.h" |
Simon Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 14 | #include <log.h> |
Ashok Reddy Soma | ca7d847 | 2022-02-23 15:36:05 +0100 | [diff] [blame] | 15 | #include <reset.h> |
Simon Glass | 9bc1564 | 2020-02-03 07:36:16 -0700 | [diff] [blame] | 16 | #include <dm/device_compat.h> |
Simon Glass | d66c5f7 | 2020-02-03 07:36:15 -0700 | [diff] [blame] | 17 | #include <linux/err.h> |
Masahiro Yamada | 75f82d0 | 2018-03-05 01:20:11 +0900 | [diff] [blame] | 18 | #include <linux/libfdt.h> |
Ashok Reddy Soma | ca7d847 | 2022-02-23 15:36:05 +0100 | [diff] [blame] | 19 | #include <asm/types.h> |
| 20 | #include <linux/math64.h> |
Ashok Reddy Soma | 7a5f810 | 2021-08-02 23:20:44 -0600 | [diff] [blame] | 21 | #include <asm/cache.h> |
Michal Simek | 0dd222b | 2013-04-22 14:56:49 +0200 | [diff] [blame] | 22 | #include <malloc.h> |
| 23 | #include <sdhci.h> |
Ashok Reddy Soma | 467d078 | 2021-08-02 23:20:43 -0600 | [diff] [blame] | 24 | #include <zynqmp_firmware.h> |
Michal Simek | 0dd222b | 2013-04-22 14:56:49 +0200 | [diff] [blame] | 25 | |
Ashok Reddy Soma | 24a5107 | 2021-07-09 05:53:41 -0600 | [diff] [blame] | 26 | #define SDHCI_ARASAN_ITAPDLY_REGISTER 0xF0F8 |
| 27 | #define SDHCI_ARASAN_ITAPDLY_SEL_MASK GENMASK(7, 0) |
| 28 | #define SDHCI_ARASAN_OTAPDLY_REGISTER 0xF0FC |
| 29 | #define SDHCI_ARASAN_OTAPDLY_SEL_MASK GENMASK(5, 0) |
| 30 | #define SDHCI_ITAPDLY_CHGWIN BIT(9) |
| 31 | #define SDHCI_ITAPDLY_ENABLE BIT(8) |
| 32 | #define SDHCI_OTAPDLY_ENABLE BIT(6) |
Ashok Reddy Soma | 568edfd | 2020-10-23 04:59:02 -0600 | [diff] [blame] | 33 | |
Michal Simek | 5b5101e | 2020-10-23 04:58:59 -0600 | [diff] [blame] | 34 | #define SDHCI_TUNING_LOOP_COUNT 40 |
Michal Simek | 33a6b77 | 2020-10-23 04:59:00 -0600 | [diff] [blame] | 35 | #define MMC_BANK2 0x2 |
| 36 | |
Ashok Reddy Soma | 7a5f810 | 2021-08-02 23:20:44 -0600 | [diff] [blame] | 37 | #define SD_DLL_CTRL 0xFF180358 |
| 38 | #define SD_ITAP_DLY 0xFF180314 |
| 39 | #define SD_OTAP_DLY 0xFF180318 |
| 40 | #define SD0_DLL_RST BIT(2) |
| 41 | #define SD1_DLL_RST BIT(18) |
| 42 | #define SD0_ITAPCHGWIN BIT(9) |
| 43 | #define SD1_ITAPCHGWIN BIT(25) |
| 44 | #define SD0_ITAPDLYENA BIT(8) |
| 45 | #define SD1_ITAPDLYENA BIT(24) |
| 46 | #define SD0_ITAPDLYSEL_MASK GENMASK(7, 0) |
| 47 | #define SD1_ITAPDLYSEL_MASK GENMASK(23, 16) |
| 48 | #define SD0_OTAPDLYSEL_MASK GENMASK(5, 0) |
| 49 | #define SD1_OTAPDLYSEL_MASK GENMASK(21, 16) |
| 50 | |
Michal Simek | 33a6b77 | 2020-10-23 04:59:00 -0600 | [diff] [blame] | 51 | struct arasan_sdhci_clk_data { |
| 52 | int clk_phase_in[MMC_TIMING_MMC_HS400 + 1]; |
| 53 | int clk_phase_out[MMC_TIMING_MMC_HS400 + 1]; |
| 54 | }; |
Michal Simek | 5b5101e | 2020-10-23 04:58:59 -0600 | [diff] [blame] | 55 | |
Simon Glass | 4cc87fb | 2016-07-05 17:10:15 -0600 | [diff] [blame] | 56 | struct arasan_sdhci_plat { |
| 57 | struct mmc_config cfg; |
| 58 | struct mmc mmc; |
| 59 | }; |
| 60 | |
Siva Durga Prasad Paladugu | cad14a8 | 2018-04-19 12:37:09 +0530 | [diff] [blame] | 61 | struct arasan_sdhci_priv { |
| 62 | struct sdhci_host *host; |
Michal Simek | 33a6b77 | 2020-10-23 04:59:00 -0600 | [diff] [blame] | 63 | struct arasan_sdhci_clk_data clk_data; |
Siva Durga Prasad Paladugu | cad14a8 | 2018-04-19 12:37:09 +0530 | [diff] [blame] | 64 | u8 deviceid; |
| 65 | u8 bank; |
Ashok Reddy Soma | 61e0df9 | 2020-10-23 04:58:57 -0600 | [diff] [blame] | 66 | u8 no_1p8; |
Ashok Reddy Soma | ca7d847 | 2022-02-23 15:36:05 +0100 | [diff] [blame] | 67 | struct reset_ctl_bulk resets; |
Siva Durga Prasad Paladugu | cad14a8 | 2018-04-19 12:37:09 +0530 | [diff] [blame] | 68 | }; |
| 69 | |
Ashok Reddy Soma | 7a5f810 | 2021-08-02 23:20:44 -0600 | [diff] [blame] | 70 | /* For Versal platforms zynqmp_mmio_write() won't be available */ |
| 71 | __weak int zynqmp_mmio_write(const u32 address, const u32 mask, const u32 value) |
| 72 | { |
| 73 | return 0; |
| 74 | } |
| 75 | |
T Karthik Reddy | d061827 | 2021-10-01 16:38:38 +0530 | [diff] [blame] | 76 | __weak int xilinx_pm_request(u32 api_id, u32 arg0, u32 arg1, u32 arg2, |
| 77 | u32 arg3, u32 *ret_payload) |
| 78 | { |
| 79 | return 0; |
| 80 | } |
| 81 | |
T Karthik Reddy | 0b35fa2 | 2022-04-27 10:27:12 +0200 | [diff] [blame] | 82 | __weak int zynqmp_pm_is_function_supported(const u32 api_id, const u32 id) |
| 83 | { |
| 84 | return 1; |
| 85 | } |
| 86 | |
Ashok Reddy Soma | 568edfd | 2020-10-23 04:59:02 -0600 | [diff] [blame] | 87 | #if defined(CONFIG_ARCH_ZYNQMP) || defined(CONFIG_ARCH_VERSAL) |
Michal Simek | 33a6b77 | 2020-10-23 04:59:00 -0600 | [diff] [blame] | 88 | /* Default settings for ZynqMP Clock Phases */ |
Michal Simek | 635cf4a | 2021-07-09 05:53:44 -0600 | [diff] [blame] | 89 | static const u32 zynqmp_iclk_phases[] = {0, 63, 63, 0, 63, 0, |
| 90 | 0, 183, 54, 0, 0}; |
| 91 | static const u32 zynqmp_oclk_phases[] = {0, 72, 60, 0, 60, 72, |
| 92 | 135, 48, 72, 135, 0}; |
Michal Simek | 33a6b77 | 2020-10-23 04:59:00 -0600 | [diff] [blame] | 93 | |
Ashok Reddy Soma | 568edfd | 2020-10-23 04:59:02 -0600 | [diff] [blame] | 94 | /* Default settings for Versal Clock Phases */ |
Michal Simek | 635cf4a | 2021-07-09 05:53:44 -0600 | [diff] [blame] | 95 | static const u32 versal_iclk_phases[] = {0, 132, 132, 0, 132, |
| 96 | 0, 0, 162, 90, 0, 0}; |
| 97 | static const u32 versal_oclk_phases[] = {0, 60, 48, 0, 48, 72, |
| 98 | 90, 36, 60, 90, 0}; |
Ashok Reddy Soma | 568edfd | 2020-10-23 04:59:02 -0600 | [diff] [blame] | 99 | |
Siva Durga Prasad Paladugu | cad14a8 | 2018-04-19 12:37:09 +0530 | [diff] [blame] | 100 | static const u8 mode2timing[] = { |
Ashok Reddy Soma | 0afdfe3 | 2020-10-23 04:58:58 -0600 | [diff] [blame] | 101 | [MMC_LEGACY] = MMC_TIMING_LEGACY, |
| 102 | [MMC_HS] = MMC_TIMING_MMC_HS, |
| 103 | [SD_HS] = MMC_TIMING_SD_HS, |
| 104 | [MMC_HS_52] = MMC_TIMING_UHS_SDR50, |
| 105 | [MMC_DDR_52] = MMC_TIMING_UHS_DDR50, |
| 106 | [UHS_SDR12] = MMC_TIMING_UHS_SDR12, |
| 107 | [UHS_SDR25] = MMC_TIMING_UHS_SDR25, |
| 108 | [UHS_SDR50] = MMC_TIMING_UHS_SDR50, |
| 109 | [UHS_DDR50] = MMC_TIMING_UHS_DDR50, |
| 110 | [UHS_SDR104] = MMC_TIMING_UHS_SDR104, |
| 111 | [MMC_HS_200] = MMC_TIMING_MMC_HS200, |
Siva Durga Prasad Paladugu | cad14a8 | 2018-04-19 12:37:09 +0530 | [diff] [blame] | 112 | }; |
| 113 | |
Ashok Reddy Soma | 7a5f810 | 2021-08-02 23:20:44 -0600 | [diff] [blame] | 114 | static inline int arasan_zynqmp_set_in_tapdelay(u8 node_id, u32 itap_delay) |
| 115 | { |
| 116 | int ret; |
| 117 | |
| 118 | if (IS_ENABLED(CONFIG_SPL_BUILD) || current_el() == 3) { |
| 119 | if (node_id == NODE_SD_0) { |
| 120 | ret = zynqmp_mmio_write(SD_ITAP_DLY, SD0_ITAPCHGWIN, |
| 121 | SD0_ITAPCHGWIN); |
| 122 | if (ret) |
| 123 | return ret; |
| 124 | |
| 125 | ret = zynqmp_mmio_write(SD_ITAP_DLY, SD0_ITAPDLYENA, |
| 126 | SD0_ITAPDLYENA); |
| 127 | if (ret) |
| 128 | return ret; |
| 129 | |
| 130 | ret = zynqmp_mmio_write(SD_ITAP_DLY, SD0_ITAPDLYSEL_MASK, |
| 131 | itap_delay); |
| 132 | if (ret) |
| 133 | return ret; |
| 134 | |
| 135 | ret = zynqmp_mmio_write(SD_ITAP_DLY, SD0_ITAPCHGWIN, 0); |
| 136 | if (ret) |
| 137 | return ret; |
| 138 | } |
| 139 | ret = zynqmp_mmio_write(SD_ITAP_DLY, SD1_ITAPCHGWIN, |
| 140 | SD1_ITAPCHGWIN); |
| 141 | if (ret) |
| 142 | return ret; |
| 143 | |
| 144 | ret = zynqmp_mmio_write(SD_ITAP_DLY, SD1_ITAPDLYENA, |
| 145 | SD1_ITAPDLYENA); |
| 146 | if (ret) |
| 147 | return ret; |
| 148 | |
| 149 | ret = zynqmp_mmio_write(SD_ITAP_DLY, SD1_ITAPDLYSEL_MASK, |
| 150 | (itap_delay << 16)); |
| 151 | if (ret) |
| 152 | return ret; |
| 153 | |
| 154 | ret = zynqmp_mmio_write(SD_ITAP_DLY, SD1_ITAPCHGWIN, 0); |
| 155 | if (ret) |
| 156 | return ret; |
| 157 | } else { |
| 158 | return xilinx_pm_request(PM_IOCTL, (u32)node_id, |
| 159 | IOCTL_SET_SD_TAPDELAY, |
| 160 | PM_TAPDELAY_INPUT, itap_delay, NULL); |
| 161 | } |
| 162 | |
| 163 | return 0; |
| 164 | } |
| 165 | |
| 166 | static inline int arasan_zynqmp_set_out_tapdelay(u8 node_id, u32 otap_delay) |
| 167 | { |
| 168 | if (IS_ENABLED(CONFIG_SPL_BUILD) || current_el() == 3) { |
| 169 | if (node_id == NODE_SD_0) |
| 170 | return zynqmp_mmio_write(SD_OTAP_DLY, |
| 171 | SD0_OTAPDLYSEL_MASK, |
| 172 | otap_delay); |
| 173 | |
| 174 | return zynqmp_mmio_write(SD_OTAP_DLY, SD1_OTAPDLYSEL_MASK, |
| 175 | (otap_delay << 16)); |
| 176 | } else { |
| 177 | return xilinx_pm_request(PM_IOCTL, (u32)node_id, |
| 178 | IOCTL_SET_SD_TAPDELAY, |
| 179 | PM_TAPDELAY_OUTPUT, otap_delay, NULL); |
| 180 | } |
| 181 | } |
| 182 | |
| 183 | static inline int zynqmp_dll_reset(u8 node_id, u32 type) |
| 184 | { |
| 185 | if (IS_ENABLED(CONFIG_SPL_BUILD) || current_el() == 3) { |
| 186 | if (node_id == NODE_SD_0) |
| 187 | return zynqmp_mmio_write(SD_DLL_CTRL, SD0_DLL_RST, |
| 188 | type == PM_DLL_RESET_ASSERT ? |
| 189 | SD0_DLL_RST : 0); |
| 190 | |
| 191 | return zynqmp_mmio_write(SD_DLL_CTRL, SD1_DLL_RST, |
| 192 | type == PM_DLL_RESET_ASSERT ? |
| 193 | SD1_DLL_RST : 0); |
| 194 | } else { |
| 195 | return xilinx_pm_request(PM_IOCTL, (u32)node_id, |
| 196 | IOCTL_SD_DLL_RESET, type, 0, NULL); |
| 197 | } |
| 198 | } |
| 199 | |
Ashok Reddy Soma | 467d078 | 2021-08-02 23:20:43 -0600 | [diff] [blame] | 200 | static int arasan_zynqmp_dll_reset(struct sdhci_host *host, u8 node_id) |
Siva Durga Prasad Paladugu | cad14a8 | 2018-04-19 12:37:09 +0530 | [diff] [blame] | 201 | { |
Ashok Reddy Soma | 467d078 | 2021-08-02 23:20:43 -0600 | [diff] [blame] | 202 | struct mmc *mmc = (struct mmc *)host->mmc; |
| 203 | struct udevice *dev = mmc->dev; |
Siva Durga Prasad Paladugu | cad14a8 | 2018-04-19 12:37:09 +0530 | [diff] [blame] | 204 | unsigned long timeout; |
Ashok Reddy Soma | 467d078 | 2021-08-02 23:20:43 -0600 | [diff] [blame] | 205 | int ret; |
| 206 | u16 clk; |
Siva Durga Prasad Paladugu | cad14a8 | 2018-04-19 12:37:09 +0530 | [diff] [blame] | 207 | |
| 208 | clk = sdhci_readw(host, SDHCI_CLOCK_CONTROL); |
| 209 | clk &= ~(SDHCI_CLOCK_CARD_EN); |
| 210 | sdhci_writew(host, clk, SDHCI_CLOCK_CONTROL); |
| 211 | |
| 212 | /* Issue DLL Reset */ |
Ashok Reddy Soma | 467d078 | 2021-08-02 23:20:43 -0600 | [diff] [blame] | 213 | ret = zynqmp_dll_reset(node_id, PM_DLL_RESET_ASSERT); |
| 214 | if (ret) { |
| 215 | dev_err(dev, "dll_reset assert failed with err: %d\n", ret); |
| 216 | return ret; |
| 217 | } |
| 218 | |
| 219 | /* Allow atleast 1ms delay for proper DLL reset */ |
| 220 | mdelay(1); |
| 221 | ret = zynqmp_dll_reset(node_id, PM_DLL_RESET_RELEASE); |
| 222 | if (ret) { |
| 223 | dev_err(dev, "dll_reset release failed with err: %d\n", ret); |
| 224 | return ret; |
| 225 | } |
Siva Durga Prasad Paladugu | cad14a8 | 2018-04-19 12:37:09 +0530 | [diff] [blame] | 226 | |
| 227 | /* Wait max 20 ms */ |
| 228 | timeout = 100; |
| 229 | while (!((clk = sdhci_readw(host, SDHCI_CLOCK_CONTROL)) |
| 230 | & SDHCI_CLOCK_INT_STABLE)) { |
| 231 | if (timeout == 0) { |
Ashok Reddy Soma | 467d078 | 2021-08-02 23:20:43 -0600 | [diff] [blame] | 232 | dev_err(dev, ": Internal clock never stabilised.\n"); |
| 233 | return -EBUSY; |
Siva Durga Prasad Paladugu | cad14a8 | 2018-04-19 12:37:09 +0530 | [diff] [blame] | 234 | } |
| 235 | timeout--; |
| 236 | udelay(1000); |
| 237 | } |
| 238 | |
| 239 | clk |= SDHCI_CLOCK_CARD_EN; |
| 240 | sdhci_writew(host, clk, SDHCI_CLOCK_CONTROL); |
Ashok Reddy Soma | 467d078 | 2021-08-02 23:20:43 -0600 | [diff] [blame] | 241 | |
| 242 | return 0; |
Siva Durga Prasad Paladugu | cad14a8 | 2018-04-19 12:37:09 +0530 | [diff] [blame] | 243 | } |
| 244 | |
| 245 | static int arasan_sdhci_execute_tuning(struct mmc *mmc, u8 opcode) |
| 246 | { |
| 247 | struct mmc_cmd cmd; |
| 248 | struct mmc_data data; |
| 249 | u32 ctrl; |
| 250 | struct sdhci_host *host; |
| 251 | struct arasan_sdhci_priv *priv = dev_get_priv(mmc->dev); |
Michal Simek | 91e95ff | 2018-06-13 09:12:29 +0200 | [diff] [blame] | 252 | char tuning_loop_counter = SDHCI_TUNING_LOOP_COUNT; |
Ashok Reddy Soma | 467d078 | 2021-08-02 23:20:43 -0600 | [diff] [blame] | 253 | u8 node_id = priv->deviceid ? NODE_SD_1 : NODE_SD_0; |
Siva Durga Prasad Paladugu | cad14a8 | 2018-04-19 12:37:09 +0530 | [diff] [blame] | 254 | |
Ashok Reddy Soma | ca7d847 | 2022-02-23 15:36:05 +0100 | [diff] [blame] | 255 | dev_dbg(mmc->dev, "%s\n", __func__); |
Siva Durga Prasad Paladugu | cad14a8 | 2018-04-19 12:37:09 +0530 | [diff] [blame] | 256 | |
| 257 | host = priv->host; |
Siva Durga Prasad Paladugu | cad14a8 | 2018-04-19 12:37:09 +0530 | [diff] [blame] | 258 | |
Faiz Abbas | 2eddc00 | 2019-06-11 00:43:40 +0530 | [diff] [blame] | 259 | ctrl = sdhci_readw(host, SDHCI_HOST_CONTROL2); |
Siva Durga Prasad Paladugu | cad14a8 | 2018-04-19 12:37:09 +0530 | [diff] [blame] | 260 | ctrl |= SDHCI_CTRL_EXEC_TUNING; |
Faiz Abbas | 2eddc00 | 2019-06-11 00:43:40 +0530 | [diff] [blame] | 261 | sdhci_writew(host, ctrl, SDHCI_HOST_CONTROL2); |
Siva Durga Prasad Paladugu | cad14a8 | 2018-04-19 12:37:09 +0530 | [diff] [blame] | 262 | |
| 263 | mdelay(1); |
| 264 | |
Ashok Reddy Soma | 467d078 | 2021-08-02 23:20:43 -0600 | [diff] [blame] | 265 | arasan_zynqmp_dll_reset(host, node_id); |
Siva Durga Prasad Paladugu | cad14a8 | 2018-04-19 12:37:09 +0530 | [diff] [blame] | 266 | |
| 267 | sdhci_writel(host, SDHCI_INT_DATA_AVAIL, SDHCI_INT_ENABLE); |
| 268 | sdhci_writel(host, SDHCI_INT_DATA_AVAIL, SDHCI_SIGNAL_ENABLE); |
| 269 | |
| 270 | do { |
| 271 | cmd.cmdidx = opcode; |
| 272 | cmd.resp_type = MMC_RSP_R1; |
| 273 | cmd.cmdarg = 0; |
| 274 | |
| 275 | data.blocksize = 64; |
| 276 | data.blocks = 1; |
| 277 | data.flags = MMC_DATA_READ; |
| 278 | |
| 279 | if (tuning_loop_counter-- == 0) |
| 280 | break; |
| 281 | |
| 282 | if (cmd.cmdidx == MMC_CMD_SEND_TUNING_BLOCK_HS200 && |
| 283 | mmc->bus_width == 8) |
| 284 | data.blocksize = 128; |
| 285 | |
| 286 | sdhci_writew(host, SDHCI_MAKE_BLKSZ(SDHCI_DEFAULT_BOUNDARY_ARG, |
| 287 | data.blocksize), |
| 288 | SDHCI_BLOCK_SIZE); |
| 289 | sdhci_writew(host, data.blocks, SDHCI_BLOCK_COUNT); |
| 290 | sdhci_writew(host, SDHCI_TRNS_READ, SDHCI_TRANSFER_MODE); |
| 291 | |
| 292 | mmc_send_cmd(mmc, &cmd, NULL); |
Faiz Abbas | 2eddc00 | 2019-06-11 00:43:40 +0530 | [diff] [blame] | 293 | ctrl = sdhci_readw(host, SDHCI_HOST_CONTROL2); |
Siva Durga Prasad Paladugu | cad14a8 | 2018-04-19 12:37:09 +0530 | [diff] [blame] | 294 | |
| 295 | if (cmd.cmdidx == MMC_CMD_SEND_TUNING_BLOCK) |
| 296 | udelay(1); |
| 297 | |
| 298 | } while (ctrl & SDHCI_CTRL_EXEC_TUNING); |
| 299 | |
| 300 | if (tuning_loop_counter < 0) { |
| 301 | ctrl &= ~SDHCI_CTRL_TUNED_CLK; |
Faiz Abbas | 2eddc00 | 2019-06-11 00:43:40 +0530 | [diff] [blame] | 302 | sdhci_writel(host, ctrl, SDHCI_HOST_CONTROL2); |
Siva Durga Prasad Paladugu | cad14a8 | 2018-04-19 12:37:09 +0530 | [diff] [blame] | 303 | } |
| 304 | |
| 305 | if (!(ctrl & SDHCI_CTRL_TUNED_CLK)) { |
| 306 | printf("%s:Tuning failed\n", __func__); |
| 307 | return -1; |
| 308 | } |
| 309 | |
| 310 | udelay(1); |
Ashok Reddy Soma | 467d078 | 2021-08-02 23:20:43 -0600 | [diff] [blame] | 311 | arasan_zynqmp_dll_reset(host, node_id); |
Siva Durga Prasad Paladugu | cad14a8 | 2018-04-19 12:37:09 +0530 | [diff] [blame] | 312 | |
| 313 | /* Enable only interrupts served by the SD controller */ |
| 314 | sdhci_writel(host, SDHCI_INT_DATA_MASK | SDHCI_INT_CMD_MASK, |
| 315 | SDHCI_INT_ENABLE); |
| 316 | /* Mask all sdhci interrupt sources */ |
| 317 | sdhci_writel(host, 0x0, SDHCI_SIGNAL_ENABLE); |
| 318 | |
| 319 | return 0; |
| 320 | } |
| 321 | |
Ashok Reddy Soma | 8f62986 | 2020-10-23 04:59:01 -0600 | [diff] [blame] | 322 | /** |
| 323 | * sdhci_zynqmp_sdcardclk_set_phase - Set the SD Output Clock Tap Delays |
| 324 | * |
Ashok Reddy Soma | 8f62986 | 2020-10-23 04:59:01 -0600 | [diff] [blame] | 325 | * @host: Pointer to the sdhci_host structure. |
| 326 | * @degrees: The clock phase shift between 0 - 359. |
Ashok Reddy Soma | 94a755d | 2021-07-09 05:53:39 -0600 | [diff] [blame] | 327 | * Return: 0 |
Michal Simek | 2a43ab8 | 2021-07-09 05:53:43 -0600 | [diff] [blame] | 328 | * |
| 329 | * Set the SD Output Clock Tap Delays for Output path |
Ashok Reddy Soma | 8f62986 | 2020-10-23 04:59:01 -0600 | [diff] [blame] | 330 | */ |
| 331 | static int sdhci_zynqmp_sdcardclk_set_phase(struct sdhci_host *host, |
| 332 | int degrees) |
| 333 | { |
Ashok Reddy Soma | 8f62986 | 2020-10-23 04:59:01 -0600 | [diff] [blame] | 334 | struct mmc *mmc = (struct mmc *)host->mmc; |
Ashok Reddy Soma | 467d078 | 2021-08-02 23:20:43 -0600 | [diff] [blame] | 335 | struct udevice *dev = mmc->dev; |
| 336 | struct arasan_sdhci_priv *priv = dev_get_priv(mmc->dev); |
| 337 | u8 node_id = priv->deviceid ? NODE_SD_1 : NODE_SD_0; |
Ashok Reddy Soma | 8f62986 | 2020-10-23 04:59:01 -0600 | [diff] [blame] | 338 | u8 tap_delay, tap_max = 0; |
Ashok Reddy Soma | 8f62986 | 2020-10-23 04:59:01 -0600 | [diff] [blame] | 339 | int timing = mode2timing[mmc->selected_mode]; |
Ashok Reddy Soma | 467d078 | 2021-08-02 23:20:43 -0600 | [diff] [blame] | 340 | int ret; |
Ashok Reddy Soma | 8f62986 | 2020-10-23 04:59:01 -0600 | [diff] [blame] | 341 | |
| 342 | /* |
| 343 | * This is applicable for SDHCI_SPEC_300 and above |
| 344 | * ZynqMP does not set phase for <=25MHz clock. |
| 345 | * If degrees is zero, no need to do anything. |
| 346 | */ |
Ashok Reddy Soma | 6f64538 | 2021-07-09 05:53:40 -0600 | [diff] [blame] | 347 | if (SDHCI_GET_VERSION(host) < SDHCI_SPEC_300) |
Ashok Reddy Soma | 8f62986 | 2020-10-23 04:59:01 -0600 | [diff] [blame] | 348 | return 0; |
| 349 | |
| 350 | switch (timing) { |
| 351 | case MMC_TIMING_MMC_HS: |
| 352 | case MMC_TIMING_SD_HS: |
| 353 | case MMC_TIMING_UHS_SDR25: |
| 354 | case MMC_TIMING_UHS_DDR50: |
| 355 | case MMC_TIMING_MMC_DDR52: |
| 356 | /* For 50MHz clock, 30 Taps are available */ |
| 357 | tap_max = 30; |
| 358 | break; |
| 359 | case MMC_TIMING_UHS_SDR50: |
| 360 | /* For 100MHz clock, 15 Taps are available */ |
| 361 | tap_max = 15; |
| 362 | break; |
| 363 | case MMC_TIMING_UHS_SDR104: |
| 364 | case MMC_TIMING_MMC_HS200: |
| 365 | /* For 200MHz clock, 8 Taps are available */ |
| 366 | tap_max = 8; |
| 367 | default: |
| 368 | break; |
| 369 | } |
| 370 | |
| 371 | tap_delay = (degrees * tap_max) / 360; |
| 372 | |
Ashok Reddy Soma | 39a177a | 2021-07-09 05:53:42 -0600 | [diff] [blame] | 373 | /* Limit output tap_delay value to 6 bits */ |
| 374 | tap_delay &= SDHCI_ARASAN_OTAPDLY_SEL_MASK; |
| 375 | |
Ashok Reddy Soma | 467d078 | 2021-08-02 23:20:43 -0600 | [diff] [blame] | 376 | /* Set the Clock Phase */ |
| 377 | ret = arasan_zynqmp_set_out_tapdelay(node_id, tap_delay); |
| 378 | if (ret) { |
| 379 | dev_err(dev, "Error setting output Tap Delay\n"); |
| 380 | return ret; |
| 381 | } |
| 382 | |
| 383 | /* Release DLL Reset */ |
| 384 | ret = zynqmp_dll_reset(node_id, PM_DLL_RESET_RELEASE); |
| 385 | if (ret) { |
| 386 | dev_err(dev, "dll_reset release failed with err: %d\n", ret); |
| 387 | return ret; |
| 388 | } |
Ashok Reddy Soma | 8f62986 | 2020-10-23 04:59:01 -0600 | [diff] [blame] | 389 | |
Ashok Reddy Soma | 94a755d | 2021-07-09 05:53:39 -0600 | [diff] [blame] | 390 | return 0; |
Ashok Reddy Soma | 8f62986 | 2020-10-23 04:59:01 -0600 | [diff] [blame] | 391 | } |
| 392 | |
| 393 | /** |
| 394 | * sdhci_zynqmp_sampleclk_set_phase - Set the SD Input Clock Tap Delays |
| 395 | * |
Ashok Reddy Soma | 8f62986 | 2020-10-23 04:59:01 -0600 | [diff] [blame] | 396 | * @host: Pointer to the sdhci_host structure. |
| 397 | * @degrees: The clock phase shift between 0 - 359. |
Ashok Reddy Soma | 94a755d | 2021-07-09 05:53:39 -0600 | [diff] [blame] | 398 | * Return: 0 |
Michal Simek | 2a43ab8 | 2021-07-09 05:53:43 -0600 | [diff] [blame] | 399 | * |
| 400 | * Set the SD Input Clock Tap Delays for Input path |
Ashok Reddy Soma | 8f62986 | 2020-10-23 04:59:01 -0600 | [diff] [blame] | 401 | */ |
| 402 | static int sdhci_zynqmp_sampleclk_set_phase(struct sdhci_host *host, |
| 403 | int degrees) |
| 404 | { |
Ashok Reddy Soma | 8f62986 | 2020-10-23 04:59:01 -0600 | [diff] [blame] | 405 | struct mmc *mmc = (struct mmc *)host->mmc; |
Ashok Reddy Soma | 467d078 | 2021-08-02 23:20:43 -0600 | [diff] [blame] | 406 | struct udevice *dev = mmc->dev; |
| 407 | struct arasan_sdhci_priv *priv = dev_get_priv(mmc->dev); |
| 408 | u8 node_id = priv->deviceid ? NODE_SD_1 : NODE_SD_0; |
Ashok Reddy Soma | 8f62986 | 2020-10-23 04:59:01 -0600 | [diff] [blame] | 409 | u8 tap_delay, tap_max = 0; |
Ashok Reddy Soma | 8f62986 | 2020-10-23 04:59:01 -0600 | [diff] [blame] | 410 | int timing = mode2timing[mmc->selected_mode]; |
Ashok Reddy Soma | 467d078 | 2021-08-02 23:20:43 -0600 | [diff] [blame] | 411 | int ret; |
Ashok Reddy Soma | 8f62986 | 2020-10-23 04:59:01 -0600 | [diff] [blame] | 412 | |
| 413 | /* |
| 414 | * This is applicable for SDHCI_SPEC_300 and above |
| 415 | * ZynqMP does not set phase for <=25MHz clock. |
| 416 | * If degrees is zero, no need to do anything. |
| 417 | */ |
Ashok Reddy Soma | 6f64538 | 2021-07-09 05:53:40 -0600 | [diff] [blame] | 418 | if (SDHCI_GET_VERSION(host) < SDHCI_SPEC_300) |
Ashok Reddy Soma | 8f62986 | 2020-10-23 04:59:01 -0600 | [diff] [blame] | 419 | return 0; |
| 420 | |
Ashok Reddy Soma | 467d078 | 2021-08-02 23:20:43 -0600 | [diff] [blame] | 421 | /* Assert DLL Reset */ |
| 422 | ret = zynqmp_dll_reset(node_id, PM_DLL_RESET_ASSERT); |
| 423 | if (ret) { |
| 424 | dev_err(dev, "dll_reset assert failed with err: %d\n", ret); |
| 425 | return ret; |
| 426 | } |
| 427 | |
Ashok Reddy Soma | 8f62986 | 2020-10-23 04:59:01 -0600 | [diff] [blame] | 428 | switch (timing) { |
| 429 | case MMC_TIMING_MMC_HS: |
| 430 | case MMC_TIMING_SD_HS: |
| 431 | case MMC_TIMING_UHS_SDR25: |
| 432 | case MMC_TIMING_UHS_DDR50: |
| 433 | case MMC_TIMING_MMC_DDR52: |
| 434 | /* For 50MHz clock, 120 Taps are available */ |
| 435 | tap_max = 120; |
| 436 | break; |
| 437 | case MMC_TIMING_UHS_SDR50: |
| 438 | /* For 100MHz clock, 60 Taps are available */ |
| 439 | tap_max = 60; |
| 440 | break; |
| 441 | case MMC_TIMING_UHS_SDR104: |
| 442 | case MMC_TIMING_MMC_HS200: |
| 443 | /* For 200MHz clock, 30 Taps are available */ |
| 444 | tap_max = 30; |
| 445 | default: |
| 446 | break; |
| 447 | } |
| 448 | |
| 449 | tap_delay = (degrees * tap_max) / 360; |
| 450 | |
Ashok Reddy Soma | 39a177a | 2021-07-09 05:53:42 -0600 | [diff] [blame] | 451 | /* Limit input tap_delay value to 8 bits */ |
| 452 | tap_delay &= SDHCI_ARASAN_ITAPDLY_SEL_MASK; |
| 453 | |
Ashok Reddy Soma | 467d078 | 2021-08-02 23:20:43 -0600 | [diff] [blame] | 454 | ret = arasan_zynqmp_set_in_tapdelay(node_id, tap_delay); |
| 455 | if (ret) { |
| 456 | dev_err(dev, "Error setting Input Tap Delay\n"); |
| 457 | return ret; |
| 458 | } |
Ashok Reddy Soma | 8f62986 | 2020-10-23 04:59:01 -0600 | [diff] [blame] | 459 | |
Ashok Reddy Soma | 94a755d | 2021-07-09 05:53:39 -0600 | [diff] [blame] | 460 | return 0; |
Ashok Reddy Soma | 8f62986 | 2020-10-23 04:59:01 -0600 | [diff] [blame] | 461 | } |
| 462 | |
Ashok Reddy Soma | 568edfd | 2020-10-23 04:59:02 -0600 | [diff] [blame] | 463 | /** |
| 464 | * sdhci_versal_sdcardclk_set_phase - Set the SD Output Clock Tap Delays |
| 465 | * |
Ashok Reddy Soma | 568edfd | 2020-10-23 04:59:02 -0600 | [diff] [blame] | 466 | * @host: Pointer to the sdhci_host structure. |
Michal Simek | 2a43ab8 | 2021-07-09 05:53:43 -0600 | [diff] [blame] | 467 | * @degrees: The clock phase shift between 0 - 359. |
Ashok Reddy Soma | 94a755d | 2021-07-09 05:53:39 -0600 | [diff] [blame] | 468 | * Return: 0 |
Michal Simek | 2a43ab8 | 2021-07-09 05:53:43 -0600 | [diff] [blame] | 469 | * |
| 470 | * Set the SD Output Clock Tap Delays for Output path |
Ashok Reddy Soma | 568edfd | 2020-10-23 04:59:02 -0600 | [diff] [blame] | 471 | */ |
| 472 | static int sdhci_versal_sdcardclk_set_phase(struct sdhci_host *host, |
| 473 | int degrees) |
| 474 | { |
| 475 | struct mmc *mmc = (struct mmc *)host->mmc; |
| 476 | u8 tap_delay, tap_max = 0; |
Ashok Reddy Soma | 568edfd | 2020-10-23 04:59:02 -0600 | [diff] [blame] | 477 | int timing = mode2timing[mmc->selected_mode]; |
Ashok Reddy Soma | 24a5107 | 2021-07-09 05:53:41 -0600 | [diff] [blame] | 478 | u32 regval; |
Ashok Reddy Soma | 568edfd | 2020-10-23 04:59:02 -0600 | [diff] [blame] | 479 | |
| 480 | /* |
| 481 | * This is applicable for SDHCI_SPEC_300 and above |
| 482 | * Versal does not set phase for <=25MHz clock. |
| 483 | * If degrees is zero, no need to do anything. |
| 484 | */ |
Ashok Reddy Soma | 6f64538 | 2021-07-09 05:53:40 -0600 | [diff] [blame] | 485 | if (SDHCI_GET_VERSION(host) < SDHCI_SPEC_300) |
Ashok Reddy Soma | 568edfd | 2020-10-23 04:59:02 -0600 | [diff] [blame] | 486 | return 0; |
| 487 | |
| 488 | switch (timing) { |
| 489 | case MMC_TIMING_MMC_HS: |
| 490 | case MMC_TIMING_SD_HS: |
| 491 | case MMC_TIMING_UHS_SDR25: |
| 492 | case MMC_TIMING_UHS_DDR50: |
| 493 | case MMC_TIMING_MMC_DDR52: |
| 494 | /* For 50MHz clock, 30 Taps are available */ |
| 495 | tap_max = 30; |
| 496 | break; |
| 497 | case MMC_TIMING_UHS_SDR50: |
| 498 | /* For 100MHz clock, 15 Taps are available */ |
| 499 | tap_max = 15; |
| 500 | break; |
| 501 | case MMC_TIMING_UHS_SDR104: |
| 502 | case MMC_TIMING_MMC_HS200: |
| 503 | /* For 200MHz clock, 8 Taps are available */ |
| 504 | tap_max = 8; |
| 505 | default: |
| 506 | break; |
| 507 | } |
| 508 | |
| 509 | tap_delay = (degrees * tap_max) / 360; |
| 510 | |
Ashok Reddy Soma | 24a5107 | 2021-07-09 05:53:41 -0600 | [diff] [blame] | 511 | /* Limit output tap_delay value to 6 bits */ |
| 512 | tap_delay &= SDHCI_ARASAN_OTAPDLY_SEL_MASK; |
Ashok Reddy Soma | 568edfd | 2020-10-23 04:59:02 -0600 | [diff] [blame] | 513 | |
Ashok Reddy Soma | 24a5107 | 2021-07-09 05:53:41 -0600 | [diff] [blame] | 514 | /* Set the Clock Phase */ |
| 515 | regval = sdhci_readl(host, SDHCI_ARASAN_OTAPDLY_REGISTER); |
| 516 | regval |= SDHCI_OTAPDLY_ENABLE; |
| 517 | sdhci_writel(host, regval, SDHCI_ARASAN_OTAPDLY_REGISTER); |
| 518 | regval &= ~SDHCI_ARASAN_OTAPDLY_SEL_MASK; |
| 519 | regval |= tap_delay; |
| 520 | sdhci_writel(host, regval, SDHCI_ARASAN_OTAPDLY_REGISTER); |
Ashok Reddy Soma | 568edfd | 2020-10-23 04:59:02 -0600 | [diff] [blame] | 521 | |
Ashok Reddy Soma | 94a755d | 2021-07-09 05:53:39 -0600 | [diff] [blame] | 522 | return 0; |
Ashok Reddy Soma | 568edfd | 2020-10-23 04:59:02 -0600 | [diff] [blame] | 523 | } |
| 524 | |
| 525 | /** |
| 526 | * sdhci_versal_sampleclk_set_phase - Set the SD Input Clock Tap Delays |
| 527 | * |
Ashok Reddy Soma | 568edfd | 2020-10-23 04:59:02 -0600 | [diff] [blame] | 528 | * @host: Pointer to the sdhci_host structure. |
Michal Simek | 2a43ab8 | 2021-07-09 05:53:43 -0600 | [diff] [blame] | 529 | * @degrees: The clock phase shift between 0 - 359. |
Ashok Reddy Soma | 94a755d | 2021-07-09 05:53:39 -0600 | [diff] [blame] | 530 | * Return: 0 |
Michal Simek | 2a43ab8 | 2021-07-09 05:53:43 -0600 | [diff] [blame] | 531 | * |
| 532 | * Set the SD Input Clock Tap Delays for Input path |
Ashok Reddy Soma | 568edfd | 2020-10-23 04:59:02 -0600 | [diff] [blame] | 533 | */ |
| 534 | static int sdhci_versal_sampleclk_set_phase(struct sdhci_host *host, |
| 535 | int degrees) |
| 536 | { |
| 537 | struct mmc *mmc = (struct mmc *)host->mmc; |
| 538 | u8 tap_delay, tap_max = 0; |
Ashok Reddy Soma | 568edfd | 2020-10-23 04:59:02 -0600 | [diff] [blame] | 539 | int timing = mode2timing[mmc->selected_mode]; |
Ashok Reddy Soma | 24a5107 | 2021-07-09 05:53:41 -0600 | [diff] [blame] | 540 | u32 regval; |
Ashok Reddy Soma | 568edfd | 2020-10-23 04:59:02 -0600 | [diff] [blame] | 541 | |
| 542 | /* |
| 543 | * This is applicable for SDHCI_SPEC_300 and above |
| 544 | * Versal does not set phase for <=25MHz clock. |
| 545 | * If degrees is zero, no need to do anything. |
| 546 | */ |
Ashok Reddy Soma | 6f64538 | 2021-07-09 05:53:40 -0600 | [diff] [blame] | 547 | if (SDHCI_GET_VERSION(host) < SDHCI_SPEC_300) |
Ashok Reddy Soma | 568edfd | 2020-10-23 04:59:02 -0600 | [diff] [blame] | 548 | return 0; |
| 549 | |
| 550 | switch (timing) { |
| 551 | case MMC_TIMING_MMC_HS: |
| 552 | case MMC_TIMING_SD_HS: |
| 553 | case MMC_TIMING_UHS_SDR25: |
| 554 | case MMC_TIMING_UHS_DDR50: |
| 555 | case MMC_TIMING_MMC_DDR52: |
| 556 | /* For 50MHz clock, 120 Taps are available */ |
| 557 | tap_max = 120; |
| 558 | break; |
| 559 | case MMC_TIMING_UHS_SDR50: |
| 560 | /* For 100MHz clock, 60 Taps are available */ |
| 561 | tap_max = 60; |
| 562 | break; |
| 563 | case MMC_TIMING_UHS_SDR104: |
| 564 | case MMC_TIMING_MMC_HS200: |
| 565 | /* For 200MHz clock, 30 Taps are available */ |
| 566 | tap_max = 30; |
| 567 | default: |
| 568 | break; |
| 569 | } |
| 570 | |
| 571 | tap_delay = (degrees * tap_max) / 360; |
| 572 | |
Ashok Reddy Soma | 24a5107 | 2021-07-09 05:53:41 -0600 | [diff] [blame] | 573 | /* Limit input tap_delay value to 8 bits */ |
| 574 | tap_delay &= SDHCI_ARASAN_ITAPDLY_SEL_MASK; |
Ashok Reddy Soma | 568edfd | 2020-10-23 04:59:02 -0600 | [diff] [blame] | 575 | |
Ashok Reddy Soma | 24a5107 | 2021-07-09 05:53:41 -0600 | [diff] [blame] | 576 | /* Set the Clock Phase */ |
| 577 | regval = sdhci_readl(host, SDHCI_ARASAN_ITAPDLY_REGISTER); |
| 578 | regval |= SDHCI_ITAPDLY_CHGWIN; |
| 579 | sdhci_writel(host, regval, SDHCI_ARASAN_ITAPDLY_REGISTER); |
| 580 | regval |= SDHCI_ITAPDLY_ENABLE; |
| 581 | sdhci_writel(host, regval, SDHCI_ARASAN_ITAPDLY_REGISTER); |
| 582 | regval &= ~SDHCI_ARASAN_ITAPDLY_SEL_MASK; |
| 583 | regval |= tap_delay; |
| 584 | sdhci_writel(host, regval, SDHCI_ARASAN_ITAPDLY_REGISTER); |
| 585 | regval &= ~SDHCI_ITAPDLY_CHGWIN; |
| 586 | sdhci_writel(host, regval, SDHCI_ARASAN_ITAPDLY_REGISTER); |
Ashok Reddy Soma | 568edfd | 2020-10-23 04:59:02 -0600 | [diff] [blame] | 587 | |
Ashok Reddy Soma | 94a755d | 2021-07-09 05:53:39 -0600 | [diff] [blame] | 588 | return 0; |
Ashok Reddy Soma | 568edfd | 2020-10-23 04:59:02 -0600 | [diff] [blame] | 589 | } |
| 590 | |
Ashok Reddy Soma | 21fd763 | 2021-08-02 23:20:40 -0600 | [diff] [blame] | 591 | static int arasan_sdhci_set_tapdelay(struct sdhci_host *host) |
Siva Durga Prasad Paladugu | cad14a8 | 2018-04-19 12:37:09 +0530 | [diff] [blame] | 592 | { |
| 593 | struct arasan_sdhci_priv *priv = dev_get_priv(host->mmc->dev); |
Ashok Reddy Soma | 8f62986 | 2020-10-23 04:59:01 -0600 | [diff] [blame] | 594 | struct arasan_sdhci_clk_data *clk_data = &priv->clk_data; |
Siva Durga Prasad Paladugu | cad14a8 | 2018-04-19 12:37:09 +0530 | [diff] [blame] | 595 | struct mmc *mmc = (struct mmc *)host->mmc; |
Ashok Reddy Soma | 8f62986 | 2020-10-23 04:59:01 -0600 | [diff] [blame] | 596 | struct udevice *dev = mmc->dev; |
| 597 | u8 timing = mode2timing[mmc->selected_mode]; |
| 598 | u32 iclk_phase = clk_data->clk_phase_in[timing]; |
| 599 | u32 oclk_phase = clk_data->clk_phase_out[timing]; |
Ashok Reddy Soma | 21fd763 | 2021-08-02 23:20:40 -0600 | [diff] [blame] | 600 | int ret; |
Siva Durga Prasad Paladugu | cad14a8 | 2018-04-19 12:37:09 +0530 | [diff] [blame] | 601 | |
Ashok Reddy Soma | 8f62986 | 2020-10-23 04:59:01 -0600 | [diff] [blame] | 602 | dev_dbg(dev, "%s, host:%s, mode:%d\n", __func__, host->name, timing); |
Siva Durga Prasad Paladugu | cad14a8 | 2018-04-19 12:37:09 +0530 | [diff] [blame] | 603 | |
Ashok Reddy Soma | 8f62986 | 2020-10-23 04:59:01 -0600 | [diff] [blame] | 604 | if (IS_ENABLED(CONFIG_ARCH_ZYNQMP) && |
| 605 | device_is_compatible(dev, "xlnx,zynqmp-8.9a")) { |
Ashok Reddy Soma | 21fd763 | 2021-08-02 23:20:40 -0600 | [diff] [blame] | 606 | ret = sdhci_zynqmp_sampleclk_set_phase(host, iclk_phase); |
| 607 | if (ret) |
| 608 | return ret; |
| 609 | |
| 610 | ret = sdhci_zynqmp_sdcardclk_set_phase(host, oclk_phase); |
| 611 | if (ret) |
| 612 | return ret; |
Ashok Reddy Soma | 568edfd | 2020-10-23 04:59:02 -0600 | [diff] [blame] | 613 | } else if (IS_ENABLED(CONFIG_ARCH_VERSAL) && |
| 614 | device_is_compatible(dev, "xlnx,versal-8.9a")) { |
Ashok Reddy Soma | 21fd763 | 2021-08-02 23:20:40 -0600 | [diff] [blame] | 615 | ret = sdhci_versal_sampleclk_set_phase(host, iclk_phase); |
| 616 | if (ret) |
| 617 | return ret; |
| 618 | |
| 619 | ret = sdhci_versal_sdcardclk_set_phase(host, oclk_phase); |
| 620 | if (ret) |
| 621 | return ret; |
Ashok Reddy Soma | 8f62986 | 2020-10-23 04:59:01 -0600 | [diff] [blame] | 622 | } |
Ashok Reddy Soma | 21fd763 | 2021-08-02 23:20:40 -0600 | [diff] [blame] | 623 | |
| 624 | return 0; |
Siva Durga Prasad Paladugu | cad14a8 | 2018-04-19 12:37:09 +0530 | [diff] [blame] | 625 | } |
| 626 | |
Michal Simek | 33a6b77 | 2020-10-23 04:59:00 -0600 | [diff] [blame] | 627 | static void arasan_dt_read_clk_phase(struct udevice *dev, unsigned char timing, |
| 628 | const char *prop) |
| 629 | { |
| 630 | struct arasan_sdhci_priv *priv = dev_get_priv(dev); |
| 631 | struct arasan_sdhci_clk_data *clk_data = &priv->clk_data; |
| 632 | u32 clk_phase[2] = {0}; |
| 633 | |
| 634 | /* |
| 635 | * Read Tap Delay values from DT, if the DT does not contain the |
| 636 | * Tap Values then use the pre-defined values |
| 637 | */ |
| 638 | if (dev_read_u32_array(dev, prop, &clk_phase[0], 2)) { |
| 639 | dev_dbg(dev, "Using predefined clock phase for %s = %d %d\n", |
| 640 | prop, clk_data->clk_phase_in[timing], |
| 641 | clk_data->clk_phase_out[timing]); |
| 642 | return; |
| 643 | } |
| 644 | |
| 645 | /* The values read are Input and Output Clock Delays in order */ |
| 646 | clk_data->clk_phase_in[timing] = clk_phase[0]; |
| 647 | clk_data->clk_phase_out[timing] = clk_phase[1]; |
| 648 | } |
| 649 | |
| 650 | /** |
| 651 | * arasan_dt_parse_clk_phases - Read Tap Delay values from DT |
| 652 | * |
Michal Simek | 33a6b77 | 2020-10-23 04:59:00 -0600 | [diff] [blame] | 653 | * @dev: Pointer to our struct udevice. |
Michal Simek | 2a43ab8 | 2021-07-09 05:53:43 -0600 | [diff] [blame] | 654 | * |
| 655 | * Called at initialization to parse the values of Tap Delays. |
Michal Simek | 33a6b77 | 2020-10-23 04:59:00 -0600 | [diff] [blame] | 656 | */ |
| 657 | static void arasan_dt_parse_clk_phases(struct udevice *dev) |
| 658 | { |
| 659 | struct arasan_sdhci_priv *priv = dev_get_priv(dev); |
| 660 | struct arasan_sdhci_clk_data *clk_data = &priv->clk_data; |
| 661 | int i; |
| 662 | |
| 663 | if (IS_ENABLED(CONFIG_ARCH_ZYNQMP) && |
| 664 | device_is_compatible(dev, "xlnx,zynqmp-8.9a")) { |
| 665 | for (i = 0; i <= MMC_TIMING_MMC_HS400; i++) { |
| 666 | clk_data->clk_phase_in[i] = zynqmp_iclk_phases[i]; |
| 667 | clk_data->clk_phase_out[i] = zynqmp_oclk_phases[i]; |
| 668 | } |
| 669 | |
| 670 | if (priv->bank == MMC_BANK2) { |
| 671 | clk_data->clk_phase_out[MMC_TIMING_UHS_SDR104] = 90; |
| 672 | clk_data->clk_phase_out[MMC_TIMING_MMC_HS200] = 90; |
| 673 | } |
| 674 | } |
| 675 | |
Ashok Reddy Soma | 568edfd | 2020-10-23 04:59:02 -0600 | [diff] [blame] | 676 | if (IS_ENABLED(CONFIG_ARCH_VERSAL) && |
| 677 | device_is_compatible(dev, "xlnx,versal-8.9a")) { |
| 678 | for (i = 0; i <= MMC_TIMING_MMC_HS400; i++) { |
| 679 | clk_data->clk_phase_in[i] = versal_iclk_phases[i]; |
| 680 | clk_data->clk_phase_out[i] = versal_oclk_phases[i]; |
| 681 | } |
| 682 | } |
| 683 | |
Michal Simek | 33a6b77 | 2020-10-23 04:59:00 -0600 | [diff] [blame] | 684 | arasan_dt_read_clk_phase(dev, MMC_TIMING_LEGACY, |
| 685 | "clk-phase-legacy"); |
| 686 | arasan_dt_read_clk_phase(dev, MMC_TIMING_MMC_HS, |
| 687 | "clk-phase-mmc-hs"); |
| 688 | arasan_dt_read_clk_phase(dev, MMC_TIMING_SD_HS, |
| 689 | "clk-phase-sd-hs"); |
| 690 | arasan_dt_read_clk_phase(dev, MMC_TIMING_UHS_SDR12, |
| 691 | "clk-phase-uhs-sdr12"); |
| 692 | arasan_dt_read_clk_phase(dev, MMC_TIMING_UHS_SDR25, |
| 693 | "clk-phase-uhs-sdr25"); |
| 694 | arasan_dt_read_clk_phase(dev, MMC_TIMING_UHS_SDR50, |
| 695 | "clk-phase-uhs-sdr50"); |
| 696 | arasan_dt_read_clk_phase(dev, MMC_TIMING_UHS_SDR104, |
| 697 | "clk-phase-uhs-sdr104"); |
| 698 | arasan_dt_read_clk_phase(dev, MMC_TIMING_UHS_DDR50, |
| 699 | "clk-phase-uhs-ddr50"); |
| 700 | arasan_dt_read_clk_phase(dev, MMC_TIMING_MMC_DDR52, |
| 701 | "clk-phase-mmc-ddr52"); |
| 702 | arasan_dt_read_clk_phase(dev, MMC_TIMING_MMC_HS200, |
| 703 | "clk-phase-mmc-hs200"); |
| 704 | arasan_dt_read_clk_phase(dev, MMC_TIMING_MMC_HS400, |
| 705 | "clk-phase-mmc-hs400"); |
| 706 | } |
| 707 | |
Michal Simek | 635cf4a | 2021-07-09 05:53:44 -0600 | [diff] [blame] | 708 | static const struct sdhci_ops arasan_ops = { |
| 709 | .platform_execute_tuning = &arasan_sdhci_execute_tuning, |
Siva Durga Prasad Paladugu | cad14a8 | 2018-04-19 12:37:09 +0530 | [diff] [blame] | 710 | .set_delay = &arasan_sdhci_set_tapdelay, |
Ashok Reddy Soma | 8ee49f0 | 2021-08-02 23:20:46 -0600 | [diff] [blame] | 711 | .set_control_reg = &sdhci_set_control_reg, |
Siva Durga Prasad Paladugu | cad14a8 | 2018-04-19 12:37:09 +0530 | [diff] [blame] | 712 | }; |
| 713 | #endif |
| 714 | |
Ashok Reddy Soma | ca7d847 | 2022-02-23 15:36:05 +0100 | [diff] [blame] | 715 | #if defined(CONFIG_ARCH_ZYNQMP) |
| 716 | static int sdhci_zynqmp_set_dynamic_config(struct arasan_sdhci_priv *priv, |
| 717 | struct udevice *dev) |
| 718 | { |
| 719 | int ret; |
| 720 | u32 node_id = priv->deviceid ? NODE_SD_1 : NODE_SD_0; |
| 721 | struct clk clk; |
| 722 | unsigned long clock, mhz; |
| 723 | |
| 724 | ret = xilinx_pm_request(PM_REQUEST_NODE, node_id, ZYNQMP_PM_CAPABILITY_ACCESS, |
| 725 | ZYNQMP_PM_MAX_QOS, ZYNQMP_PM_REQUEST_ACK_NO, NULL); |
| 726 | if (ret) { |
| 727 | dev_err(dev, "Request node failed for %d\n", node_id); |
| 728 | return ret; |
| 729 | } |
| 730 | |
| 731 | ret = reset_get_bulk(dev, &priv->resets); |
| 732 | if (ret == -ENOTSUPP || ret == -ENOENT) { |
| 733 | dev_err(dev, "Reset not found\n"); |
| 734 | return 0; |
| 735 | } else if (ret) { |
| 736 | dev_err(dev, "Reset failed\n"); |
| 737 | return ret; |
| 738 | } |
| 739 | |
| 740 | ret = reset_assert_bulk(&priv->resets); |
| 741 | if (ret) { |
| 742 | dev_err(dev, "Reset assert failed\n"); |
| 743 | return ret; |
| 744 | } |
| 745 | |
| 746 | ret = zynqmp_pm_set_sd_config(node_id, SD_CONFIG_FIXED, 0); |
| 747 | if (ret) { |
| 748 | dev_err(dev, "SD_CONFIG_FIXED failed\n"); |
| 749 | return ret; |
| 750 | } |
| 751 | |
| 752 | ret = zynqmp_pm_set_sd_config(node_id, SD_CONFIG_EMMC_SEL, |
| 753 | dev_read_bool(dev, "non-removable")); |
| 754 | if (ret) { |
| 755 | dev_err(dev, "SD_CONFIG_EMMC_SEL failed\n"); |
| 756 | return ret; |
| 757 | } |
| 758 | |
| 759 | ret = clk_get_by_index(dev, 0, &clk); |
| 760 | if (ret < 0) { |
| 761 | dev_err(dev, "failed to get clock\n"); |
| 762 | return ret; |
| 763 | } |
| 764 | |
| 765 | clock = clk_get_rate(&clk); |
| 766 | if (IS_ERR_VALUE(clock)) { |
| 767 | dev_err(dev, "failed to get rate\n"); |
| 768 | return clock; |
| 769 | } |
| 770 | |
| 771 | mhz = DIV64_U64_ROUND_UP(clock, 1000000); |
| 772 | |
Ashok Reddy Soma | 088febe | 2022-03-25 13:11:10 +0100 | [diff] [blame] | 773 | if (mhz > 100 && mhz <= 200) |
| 774 | mhz = 200; |
| 775 | else if (mhz > 50 && mhz <= 100) |
| 776 | mhz = 100; |
| 777 | else if (mhz > 25 && mhz <= 50) |
| 778 | mhz = 50; |
| 779 | else |
| 780 | mhz = 25; |
| 781 | |
Ashok Reddy Soma | ca7d847 | 2022-02-23 15:36:05 +0100 | [diff] [blame] | 782 | ret = zynqmp_pm_set_sd_config(node_id, SD_CONFIG_BASECLK, mhz); |
| 783 | if (ret) { |
| 784 | dev_err(dev, "SD_CONFIG_BASECLK failed\n"); |
| 785 | return ret; |
| 786 | } |
| 787 | |
| 788 | ret = zynqmp_pm_set_sd_config(node_id, SD_CONFIG_8BIT, |
| 789 | (dev_read_u32_default(dev, "bus-width", 1) == 8)); |
| 790 | if (ret) { |
| 791 | dev_err(dev, "SD_CONFIG_8BIT failed\n"); |
| 792 | return ret; |
| 793 | } |
| 794 | |
| 795 | ret = reset_deassert_bulk(&priv->resets); |
| 796 | if (ret) { |
| 797 | dev_err(dev, "Reset release failed\n"); |
| 798 | return ret; |
| 799 | } |
| 800 | |
| 801 | return 0; |
| 802 | } |
| 803 | #endif |
| 804 | |
Michal Simek | 9ecd268 | 2015-11-30 16:13:03 +0100 | [diff] [blame] | 805 | static int arasan_sdhci_probe(struct udevice *dev) |
Michal Simek | 0dd222b | 2013-04-22 14:56:49 +0200 | [diff] [blame] | 806 | { |
Simon Glass | fa20e93 | 2020-12-03 16:55:20 -0700 | [diff] [blame] | 807 | struct arasan_sdhci_plat *plat = dev_get_plat(dev); |
Michal Simek | 9ecd268 | 2015-11-30 16:13:03 +0100 | [diff] [blame] | 808 | struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev); |
Siva Durga Prasad Paladugu | cad14a8 | 2018-04-19 12:37:09 +0530 | [diff] [blame] | 809 | struct arasan_sdhci_priv *priv = dev_get_priv(dev); |
| 810 | struct sdhci_host *host; |
Stefan Herbrechtsmeier | 739ae40 | 2017-01-17 16:27:32 +0100 | [diff] [blame] | 811 | struct clk clk; |
| 812 | unsigned long clock; |
Simon Glass | 4cc87fb | 2016-07-05 17:10:15 -0600 | [diff] [blame] | 813 | int ret; |
Michal Simek | 0dd222b | 2013-04-22 14:56:49 +0200 | [diff] [blame] | 814 | |
Siva Durga Prasad Paladugu | cad14a8 | 2018-04-19 12:37:09 +0530 | [diff] [blame] | 815 | host = priv->host; |
| 816 | |
Ashok Reddy Soma | ca7d847 | 2022-02-23 15:36:05 +0100 | [diff] [blame] | 817 | #if defined(CONFIG_ARCH_ZYNQMP) |
| 818 | if (device_is_compatible(dev, "xlnx,zynqmp-8.9a")) { |
| 819 | ret = zynqmp_pm_is_function_supported(PM_IOCTL, |
| 820 | IOCTL_SET_SD_CONFIG); |
| 821 | if (!ret) { |
| 822 | ret = sdhci_zynqmp_set_dynamic_config(priv, dev); |
| 823 | if (ret) |
| 824 | return ret; |
| 825 | } |
| 826 | } |
| 827 | #endif |
| 828 | |
Stefan Herbrechtsmeier | 739ae40 | 2017-01-17 16:27:32 +0100 | [diff] [blame] | 829 | ret = clk_get_by_index(dev, 0, &clk); |
| 830 | if (ret < 0) { |
| 831 | dev_err(dev, "failed to get clock\n"); |
| 832 | return ret; |
| 833 | } |
| 834 | |
| 835 | clock = clk_get_rate(&clk); |
| 836 | if (IS_ERR_VALUE(clock)) { |
| 837 | dev_err(dev, "failed to get rate\n"); |
| 838 | return clock; |
| 839 | } |
Siva Durga Prasad Paladugu | cad14a8 | 2018-04-19 12:37:09 +0530 | [diff] [blame] | 840 | |
Ashok Reddy Soma | ca7d847 | 2022-02-23 15:36:05 +0100 | [diff] [blame] | 841 | dev_dbg(dev, "%s: CLK %ld\n", __func__, clock); |
Stefan Herbrechtsmeier | 739ae40 | 2017-01-17 16:27:32 +0100 | [diff] [blame] | 842 | |
| 843 | ret = clk_enable(&clk); |
Michal Simek | 4171095 | 2021-02-09 15:28:15 +0100 | [diff] [blame] | 844 | if (ret) { |
Stefan Herbrechtsmeier | 739ae40 | 2017-01-17 16:27:32 +0100 | [diff] [blame] | 845 | dev_err(dev, "failed to enable clock\n"); |
| 846 | return ret; |
| 847 | } |
| 848 | |
Siva Durga Prasad Paladugu | 049e003 | 2014-07-08 15:31:04 +0530 | [diff] [blame] | 849 | host->quirks = SDHCI_QUIRK_WAIT_SEND_CMD | |
Siva Durga Prasad Paladugu | 0d6891b | 2014-01-22 09:17:09 +0100 | [diff] [blame] | 850 | SDHCI_QUIRK_BROKEN_R1B; |
Siva Durga Prasad Paladugu | a1619fe | 2016-01-12 15:12:16 +0530 | [diff] [blame] | 851 | |
| 852 | #ifdef CONFIG_ZYNQ_HISPD_BROKEN |
Hannes Schmelzer | 94a5bbc | 2018-03-07 08:00:57 +0100 | [diff] [blame] | 853 | host->quirks |= SDHCI_QUIRK_BROKEN_HISPD_MODE; |
Siva Durga Prasad Paladugu | a1619fe | 2016-01-12 15:12:16 +0530 | [diff] [blame] | 854 | #endif |
| 855 | |
Ashok Reddy Soma | 61e0df9 | 2020-10-23 04:58:57 -0600 | [diff] [blame] | 856 | if (priv->no_1p8) |
| 857 | host->quirks |= SDHCI_QUIRK_NO_1_8_V; |
| 858 | |
Benedikt Grassl | 529e6f0 | 2020-04-14 07:32:12 +0200 | [diff] [blame] | 859 | plat->cfg.f_max = CONFIG_ZYNQ_SDHCI_MAX_FREQ; |
| 860 | |
| 861 | ret = mmc_of_parse(dev, &plat->cfg); |
| 862 | if (ret) |
| 863 | return ret; |
Siva Durga Prasad Paladugu | cad14a8 | 2018-04-19 12:37:09 +0530 | [diff] [blame] | 864 | |
Stefan Herbrechtsmeier | 739ae40 | 2017-01-17 16:27:32 +0100 | [diff] [blame] | 865 | host->max_clk = clock; |
Stefan Herbrechtsmeier | bc47e0e | 2017-01-17 15:58:48 +0100 | [diff] [blame] | 866 | |
Matwey V. Kornilov | 194b860 | 2019-08-01 18:00:05 +0300 | [diff] [blame] | 867 | host->mmc = &plat->mmc; |
| 868 | host->mmc->dev = dev; |
| 869 | host->mmc->priv = host; |
| 870 | |
Benedikt Grassl | 529e6f0 | 2020-04-14 07:32:12 +0200 | [diff] [blame] | 871 | ret = sdhci_setup_cfg(&plat->cfg, host, plat->cfg.f_max, |
Jaehoon Chung | 8a5ffbb | 2016-07-26 19:06:24 +0900 | [diff] [blame] | 872 | CONFIG_ZYNQ_SDHCI_MIN_FREQ); |
Simon Glass | 4cc87fb | 2016-07-05 17:10:15 -0600 | [diff] [blame] | 873 | if (ret) |
| 874 | return ret; |
Simon Glass | 4cc87fb | 2016-07-05 17:10:15 -0600 | [diff] [blame] | 875 | upriv->mmc = host->mmc; |
Michal Simek | 9ecd268 | 2015-11-30 16:13:03 +0100 | [diff] [blame] | 876 | |
T Karthik Reddy | ab0a749 | 2021-08-02 23:20:45 -0600 | [diff] [blame] | 877 | /* |
| 878 | * WORKAROUND: Versal platforms have an issue with card detect state. |
| 879 | * Due to this, host controller is switching off voltage to sd card |
| 880 | * causing sd card timeout error. Workaround this by adding a wait for |
| 881 | * 1000msec till the card detect state gets stable. |
| 882 | */ |
Ashok Reddy Soma | 6556bff | 2022-02-23 15:13:32 +0100 | [diff] [blame] | 883 | if (IS_ENABLED(CONFIG_ARCH_ZYNQMP) || IS_ENABLED(CONFIG_ARCH_VERSAL)) { |
Ashok Reddy Soma | dd74577 | 2022-02-23 15:13:31 +0100 | [diff] [blame] | 884 | u32 timeout = 1000000; |
T Karthik Reddy | ab0a749 | 2021-08-02 23:20:45 -0600 | [diff] [blame] | 885 | |
| 886 | while (((sdhci_readl(host, SDHCI_PRESENT_STATE) & |
Ashok Reddy Soma | 09f3890 | 2022-02-23 15:13:30 +0100 | [diff] [blame] | 887 | SDHCI_CARD_STATE_STABLE) == 0) && timeout) { |
Ashok Reddy Soma | dd74577 | 2022-02-23 15:13:31 +0100 | [diff] [blame] | 888 | udelay(1); |
Ashok Reddy Soma | 09f3890 | 2022-02-23 15:13:30 +0100 | [diff] [blame] | 889 | timeout--; |
T Karthik Reddy | ab0a749 | 2021-08-02 23:20:45 -0600 | [diff] [blame] | 890 | } |
| 891 | if (!timeout) { |
| 892 | dev_err(dev, "Sdhci card detect state not stable\n"); |
| 893 | return -ETIMEDOUT; |
| 894 | } |
| 895 | } |
| 896 | |
Simon Glass | 4cc87fb | 2016-07-05 17:10:15 -0600 | [diff] [blame] | 897 | return sdhci_probe(dev); |
Michal Simek | 0dd222b | 2013-04-22 14:56:49 +0200 | [diff] [blame] | 898 | } |
Michal Simek | 9ecd268 | 2015-11-30 16:13:03 +0100 | [diff] [blame] | 899 | |
Simon Glass | aad29ae | 2020-12-03 16:55:21 -0700 | [diff] [blame] | 900 | static int arasan_sdhci_of_to_plat(struct udevice *dev) |
Michal Simek | 9ecd268 | 2015-11-30 16:13:03 +0100 | [diff] [blame] | 901 | { |
Siva Durga Prasad Paladugu | cad14a8 | 2018-04-19 12:37:09 +0530 | [diff] [blame] | 902 | struct arasan_sdhci_priv *priv = dev_get_priv(dev); |
Michal Simek | 9ecd268 | 2015-11-30 16:13:03 +0100 | [diff] [blame] | 903 | |
Siva Durga Prasad Paladugu | cad14a8 | 2018-04-19 12:37:09 +0530 | [diff] [blame] | 904 | priv->host = calloc(1, sizeof(struct sdhci_host)); |
| 905 | if (!priv->host) |
| 906 | return -1; |
| 907 | |
| 908 | priv->host->name = dev->name; |
Siva Durga Prasad Paladugu | cad14a8 | 2018-04-19 12:37:09 +0530 | [diff] [blame] | 909 | |
Ashok Reddy Soma | 568edfd | 2020-10-23 04:59:02 -0600 | [diff] [blame] | 910 | #if defined(CONFIG_ARCH_ZYNQMP) || defined(CONFIG_ARCH_VERSAL) |
Siva Durga Prasad Paladugu | cad14a8 | 2018-04-19 12:37:09 +0530 | [diff] [blame] | 911 | priv->host->ops = &arasan_ops; |
Michal Simek | 33a6b77 | 2020-10-23 04:59:00 -0600 | [diff] [blame] | 912 | arasan_dt_parse_clk_phases(dev); |
Siva Durga Prasad Paladugu | cad14a8 | 2018-04-19 12:37:09 +0530 | [diff] [blame] | 913 | #endif |
Michal Simek | 9ecd268 | 2015-11-30 16:13:03 +0100 | [diff] [blame] | 914 | |
Michal Simek | 921a8de | 2018-05-16 10:57:07 +0200 | [diff] [blame] | 915 | priv->host->ioaddr = (void *)dev_read_addr(dev); |
| 916 | if (IS_ERR(priv->host->ioaddr)) |
| 917 | return PTR_ERR(priv->host->ioaddr); |
| 918 | |
| 919 | priv->deviceid = dev_read_u32_default(dev, "xlnx,device_id", -1); |
Michal Simek | e40ae57 | 2020-07-22 17:46:31 +0200 | [diff] [blame] | 920 | priv->bank = dev_read_u32_default(dev, "xlnx,mio-bank", 0); |
Ashok Reddy Soma | 61e0df9 | 2020-10-23 04:58:57 -0600 | [diff] [blame] | 921 | priv->no_1p8 = dev_read_bool(dev, "no-1-8-v"); |
Stefan Herbrechtsmeier | 5567b42 | 2017-01-17 16:27:33 +0100 | [diff] [blame] | 922 | |
Michal Simek | 9ecd268 | 2015-11-30 16:13:03 +0100 | [diff] [blame] | 923 | return 0; |
| 924 | } |
| 925 | |
Simon Glass | 4cc87fb | 2016-07-05 17:10:15 -0600 | [diff] [blame] | 926 | static int arasan_sdhci_bind(struct udevice *dev) |
| 927 | { |
Simon Glass | fa20e93 | 2020-12-03 16:55:20 -0700 | [diff] [blame] | 928 | struct arasan_sdhci_plat *plat = dev_get_plat(dev); |
Simon Glass | 4cc87fb | 2016-07-05 17:10:15 -0600 | [diff] [blame] | 929 | |
Masahiro Yamada | cdb67f3 | 2016-09-06 22:17:32 +0900 | [diff] [blame] | 930 | return sdhci_bind(dev, &plat->mmc, &plat->cfg); |
Simon Glass | 4cc87fb | 2016-07-05 17:10:15 -0600 | [diff] [blame] | 931 | } |
| 932 | |
Michal Simek | 9ecd268 | 2015-11-30 16:13:03 +0100 | [diff] [blame] | 933 | static const struct udevice_id arasan_sdhci_ids[] = { |
| 934 | { .compatible = "arasan,sdhci-8.9a" }, |
| 935 | { } |
| 936 | }; |
| 937 | |
| 938 | U_BOOT_DRIVER(arasan_sdhci_drv) = { |
| 939 | .name = "arasan_sdhci", |
| 940 | .id = UCLASS_MMC, |
| 941 | .of_match = arasan_sdhci_ids, |
Simon Glass | aad29ae | 2020-12-03 16:55:21 -0700 | [diff] [blame] | 942 | .of_to_plat = arasan_sdhci_of_to_plat, |
Simon Glass | 4cc87fb | 2016-07-05 17:10:15 -0600 | [diff] [blame] | 943 | .ops = &sdhci_ops, |
| 944 | .bind = arasan_sdhci_bind, |
Michal Simek | 9ecd268 | 2015-11-30 16:13:03 +0100 | [diff] [blame] | 945 | .probe = arasan_sdhci_probe, |
Simon Glass | 8a2b47f | 2020-12-03 16:55:17 -0700 | [diff] [blame] | 946 | .priv_auto = sizeof(struct arasan_sdhci_priv), |
Simon Glass | 71fa5b4 | 2020-12-03 16:55:18 -0700 | [diff] [blame] | 947 | .plat_auto = sizeof(struct arasan_sdhci_plat), |
Michal Simek | 9ecd268 | 2015-11-30 16:13:03 +0100 | [diff] [blame] | 948 | }; |