blob: 3a6e51c8c5d2d7057c3ac5a46aa93e458709e03a [file] [log] [blame]
Kevin Hilman51c5d842016-10-19 11:18:24 -07001/*
2 * Amlogic SD/eMMC driver for the GX/S905 family SoCs
3 *
4 * Copyright (c) 2016 BayLibre, SAS.
5 * Author: Kevin Hilman <khilman@baylibre.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of version 2 of the GNU General Public License as
9 * published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
18 * The full GNU General Public License is included in this distribution
19 * in the file called COPYING.
20 */
21#include <linux/kernel.h>
22#include <linux/module.h>
23#include <linux/init.h>
24#include <linux/device.h>
25#include <linux/of_device.h>
26#include <linux/platform_device.h>
27#include <linux/ioport.h>
28#include <linux/spinlock.h>
29#include <linux/dma-mapping.h>
30#include <linux/mmc/host.h>
31#include <linux/mmc/mmc.h>
32#include <linux/mmc/sdio.h>
33#include <linux/mmc/slot-gpio.h>
34#include <linux/io.h>
35#include <linux/clk.h>
36#include <linux/clk-provider.h>
37#include <linux/regulator/consumer.h>
Ulf Hanssonb8789ec2016-12-30 13:47:23 +010038#include <linux/interrupt.h>
Heiner Kallweit1231e7e2017-03-25 11:23:24 +010039#include <linux/bitfield.h>
Kevin Hilman51c5d842016-10-19 11:18:24 -070040
41#define DRIVER_NAME "meson-gx-mmc"
42
43#define SD_EMMC_CLOCK 0x0
Heiner Kallweit1231e7e2017-03-25 11:23:24 +010044#define CLK_DIV_MASK GENMASK(5, 0)
Kevin Hilman51c5d842016-10-19 11:18:24 -070045#define CLK_DIV_MAX 63
Heiner Kallweit1231e7e2017-03-25 11:23:24 +010046#define CLK_SRC_MASK GENMASK(7, 6)
Kevin Hilman51c5d842016-10-19 11:18:24 -070047#define CLK_SRC_XTAL 0 /* external crystal */
48#define CLK_SRC_XTAL_RATE 24000000
49#define CLK_SRC_PLL 1 /* FCLK_DIV2 */
50#define CLK_SRC_PLL_RATE 1000000000
Heiner Kallweit1231e7e2017-03-25 11:23:24 +010051#define CLK_CORE_PHASE_MASK GENMASK(9, 8)
Heiner Kallweitc08bcb62017-04-04 21:03:22 +020052#define CLK_TX_PHASE_MASK GENMASK(11, 10)
53#define CLK_RX_PHASE_MASK GENMASK(13, 12)
Kevin Hilman51c5d842016-10-19 11:18:24 -070054#define CLK_PHASE_0 0
55#define CLK_PHASE_90 1
56#define CLK_PHASE_180 2
57#define CLK_PHASE_270 3
58#define CLK_ALWAYS_ON BIT(24)
59
60#define SD_EMMC_DElAY 0x4
61#define SD_EMMC_ADJUST 0x8
62#define SD_EMMC_CALOUT 0x10
63#define SD_EMMC_START 0x40
64#define START_DESC_INIT BIT(0)
65#define START_DESC_BUSY BIT(1)
Heiner Kallweit1231e7e2017-03-25 11:23:24 +010066#define START_DESC_ADDR_MASK GENMASK(31, 2)
Kevin Hilman51c5d842016-10-19 11:18:24 -070067
68#define SD_EMMC_CFG 0x44
Heiner Kallweit1231e7e2017-03-25 11:23:24 +010069#define CFG_BUS_WIDTH_MASK GENMASK(1, 0)
Kevin Hilman51c5d842016-10-19 11:18:24 -070070#define CFG_BUS_WIDTH_1 0x0
71#define CFG_BUS_WIDTH_4 0x1
72#define CFG_BUS_WIDTH_8 0x2
73#define CFG_DDR BIT(2)
Heiner Kallweit1231e7e2017-03-25 11:23:24 +010074#define CFG_BLK_LEN_MASK GENMASK(7, 4)
75#define CFG_RESP_TIMEOUT_MASK GENMASK(11, 8)
76#define CFG_RC_CC_MASK GENMASK(15, 12)
Kevin Hilman51c5d842016-10-19 11:18:24 -070077#define CFG_STOP_CLOCK BIT(22)
78#define CFG_CLK_ALWAYS_ON BIT(18)
Heiner Kallweite21e6fd2017-02-07 22:35:59 +010079#define CFG_CHK_DS BIT(20)
Kevin Hilman51c5d842016-10-19 11:18:24 -070080#define CFG_AUTO_CLK BIT(23)
81
82#define SD_EMMC_STATUS 0x48
83#define STATUS_BUSY BIT(31)
84
85#define SD_EMMC_IRQ_EN 0x4c
Heiner Kallweit1231e7e2017-03-25 11:23:24 +010086#define IRQ_EN_MASK GENMASK(13, 0)
87#define IRQ_RXD_ERR_MASK GENMASK(7, 0)
Kevin Hilman51c5d842016-10-19 11:18:24 -070088#define IRQ_TXD_ERR BIT(8)
89#define IRQ_DESC_ERR BIT(9)
90#define IRQ_RESP_ERR BIT(10)
91#define IRQ_RESP_TIMEOUT BIT(11)
92#define IRQ_DESC_TIMEOUT BIT(12)
93#define IRQ_END_OF_CHAIN BIT(13)
94#define IRQ_RESP_STATUS BIT(14)
95#define IRQ_SDIO BIT(15)
96
97#define SD_EMMC_CMD_CFG 0x50
98#define SD_EMMC_CMD_ARG 0x54
99#define SD_EMMC_CMD_DAT 0x58
100#define SD_EMMC_CMD_RSP 0x5c
101#define SD_EMMC_CMD_RSP1 0x60
102#define SD_EMMC_CMD_RSP2 0x64
103#define SD_EMMC_CMD_RSP3 0x68
104
105#define SD_EMMC_RXD 0x94
106#define SD_EMMC_TXD 0x94
107#define SD_EMMC_LAST_REG SD_EMMC_TXD
108
109#define SD_EMMC_CFG_BLK_SIZE 512 /* internal buffer max: 512 bytes */
110#define SD_EMMC_CFG_RESP_TIMEOUT 256 /* in clock cycles */
Heiner Kallweitbb11eff2017-03-04 13:37:46 +0100111#define SD_EMMC_CMD_TIMEOUT 1024 /* in ms */
112#define SD_EMMC_CMD_TIMEOUT_DATA 4096 /* in ms */
Kevin Hilman51c5d842016-10-19 11:18:24 -0700113#define SD_EMMC_CFG_CMD_GAP 16 /* in clock cycles */
114#define MUX_CLK_NUM_PARENTS 2
115
Heiner Kallweitc08bcb62017-04-04 21:03:22 +0200116struct meson_tuning_params {
117 u8 core_phase;
118 u8 tx_phase;
119 u8 rx_phase;
120};
121
Kevin Hilman51c5d842016-10-19 11:18:24 -0700122struct meson_host {
123 struct device *dev;
124 struct mmc_host *mmc;
Kevin Hilman51c5d842016-10-19 11:18:24 -0700125 struct mmc_command *cmd;
126
127 spinlock_t lock;
128 void __iomem *regs;
Kevin Hilman51c5d842016-10-19 11:18:24 -0700129 struct clk *core_clk;
130 struct clk_mux mux;
131 struct clk *mux_clk;
Heiner Kallweit5da86882017-02-07 22:34:32 +0100132 unsigned long current_clock;
Kevin Hilman51c5d842016-10-19 11:18:24 -0700133
134 struct clk_divider cfg_div;
135 struct clk *cfg_div_clk;
136
137 unsigned int bounce_buf_size;
138 void *bounce_buf;
139 dma_addr_t bounce_dma_addr;
140
Heiner Kallweitc08bcb62017-04-04 21:03:22 +0200141 struct meson_tuning_params tp;
Kevin Hilman51c5d842016-10-19 11:18:24 -0700142 bool vqmmc_enabled;
143};
144
145struct sd_emmc_desc {
146 u32 cmd_cfg;
147 u32 cmd_arg;
148 u32 cmd_data;
149 u32 cmd_resp;
150};
Heiner Kallweit1231e7e2017-03-25 11:23:24 +0100151
152#define CMD_CFG_LENGTH_MASK GENMASK(8, 0)
Kevin Hilman51c5d842016-10-19 11:18:24 -0700153#define CMD_CFG_BLOCK_MODE BIT(9)
154#define CMD_CFG_R1B BIT(10)
155#define CMD_CFG_END_OF_CHAIN BIT(11)
Heiner Kallweit1231e7e2017-03-25 11:23:24 +0100156#define CMD_CFG_TIMEOUT_MASK GENMASK(15, 12)
Kevin Hilman51c5d842016-10-19 11:18:24 -0700157#define CMD_CFG_NO_RESP BIT(16)
158#define CMD_CFG_NO_CMD BIT(17)
159#define CMD_CFG_DATA_IO BIT(18)
160#define CMD_CFG_DATA_WR BIT(19)
161#define CMD_CFG_RESP_NOCRC BIT(20)
162#define CMD_CFG_RESP_128 BIT(21)
163#define CMD_CFG_RESP_NUM BIT(22)
164#define CMD_CFG_DATA_NUM BIT(23)
Heiner Kallweit1231e7e2017-03-25 11:23:24 +0100165#define CMD_CFG_CMD_INDEX_MASK GENMASK(29, 24)
Kevin Hilman51c5d842016-10-19 11:18:24 -0700166#define CMD_CFG_ERROR BIT(30)
167#define CMD_CFG_OWNER BIT(31)
168
Heiner Kallweit1231e7e2017-03-25 11:23:24 +0100169#define CMD_DATA_MASK GENMASK(31, 2)
Kevin Hilman51c5d842016-10-19 11:18:24 -0700170#define CMD_DATA_BIG_ENDIAN BIT(1)
171#define CMD_DATA_SRAM BIT(0)
Heiner Kallweit1231e7e2017-03-25 11:23:24 +0100172#define CMD_RESP_MASK GENMASK(31, 1)
Kevin Hilman51c5d842016-10-19 11:18:24 -0700173#define CMD_RESP_SRAM BIT(0)
174
Heiner Kallweit4eee86c2017-03-25 11:26:18 +0100175static unsigned int meson_mmc_get_timeout_msecs(struct mmc_data *data)
176{
177 unsigned int timeout = data->timeout_ns / NSEC_PER_MSEC;
178
179 if (!timeout)
180 return SD_EMMC_CMD_TIMEOUT_DATA;
181
182 timeout = roundup_pow_of_two(timeout);
183
184 return min(timeout, 32768U); /* max. 2^15 ms */
185}
186
Heiner Kallweite5e4a3e2017-03-25 11:28:13 +0100187static struct mmc_command *meson_mmc_get_next_command(struct mmc_command *cmd)
188{
189 if (cmd->opcode == MMC_SET_BLOCK_COUNT && !cmd->error)
190 return cmd->mrq->cmd;
191 else if (mmc_op_multi(cmd->opcode) &&
192 (!cmd->mrq->sbc || cmd->error || cmd->data->error))
193 return cmd->mrq->stop;
194 else
195 return NULL;
196}
197
Kevin Hilman51c5d842016-10-19 11:18:24 -0700198static int meson_mmc_clk_set(struct meson_host *host, unsigned long clk_rate)
199{
200 struct mmc_host *mmc = host->mmc;
Heiner Kallweit5da86882017-02-07 22:34:32 +0100201 int ret;
Kevin Hilman51c5d842016-10-19 11:18:24 -0700202 u32 cfg;
203
204 if (clk_rate) {
205 if (WARN_ON(clk_rate > mmc->f_max))
206 clk_rate = mmc->f_max;
207 else if (WARN_ON(clk_rate < mmc->f_min))
208 clk_rate = mmc->f_min;
209 }
210
Heiner Kallweit5da86882017-02-07 22:34:32 +0100211 if (clk_rate == host->current_clock)
Kevin Hilman51c5d842016-10-19 11:18:24 -0700212 return 0;
213
214 /* stop clock */
215 cfg = readl(host->regs + SD_EMMC_CFG);
216 if (!(cfg & CFG_STOP_CLOCK)) {
217 cfg |= CFG_STOP_CLOCK;
218 writel(cfg, host->regs + SD_EMMC_CFG);
219 }
220
221 dev_dbg(host->dev, "change clock rate %u -> %lu\n",
222 mmc->actual_clock, clk_rate);
223
Heiner Kallweit5da86882017-02-07 22:34:32 +0100224 if (!clk_rate) {
Kevin Hilman51c5d842016-10-19 11:18:24 -0700225 mmc->actual_clock = 0;
Heiner Kallweit5da86882017-02-07 22:34:32 +0100226 host->current_clock = 0;
227 /* return with clock being stopped */
Kevin Hilman51c5d842016-10-19 11:18:24 -0700228 return 0;
229 }
230
231 ret = clk_set_rate(host->cfg_div_clk, clk_rate);
Heiner Kallweit5da86882017-02-07 22:34:32 +0100232 if (ret) {
233 dev_err(host->dev, "Unable to set cfg_div_clk to %lu. ret=%d\n",
234 clk_rate, ret);
235 return ret;
Kevin Hilman51c5d842016-10-19 11:18:24 -0700236 }
237
Heiner Kallweit5da86882017-02-07 22:34:32 +0100238 mmc->actual_clock = clk_get_rate(host->cfg_div_clk);
239 host->current_clock = clk_rate;
240
241 if (clk_rate != mmc->actual_clock)
242 dev_dbg(host->dev,
243 "divider requested rate %lu != actual rate %u\n",
244 clk_rate, mmc->actual_clock);
245
246 /* (re)start clock */
247 cfg = readl(host->regs + SD_EMMC_CFG);
248 cfg &= ~CFG_STOP_CLOCK;
249 writel(cfg, host->regs + SD_EMMC_CFG);
250
251 return 0;
Kevin Hilman51c5d842016-10-19 11:18:24 -0700252}
253
254/*
255 * The SD/eMMC IP block has an internal mux and divider used for
256 * generating the MMC clock. Use the clock framework to create and
257 * manage these clocks.
258 */
259static int meson_mmc_clk_init(struct meson_host *host)
260{
261 struct clk_init_data init;
262 char clk_name[32];
263 int i, ret = 0;
264 const char *mux_parent_names[MUX_CLK_NUM_PARENTS];
Kevin Hilman51c5d842016-10-19 11:18:24 -0700265 const char *clk_div_parents[1];
Kevin Hilman51c5d842016-10-19 11:18:24 -0700266 u32 clk_reg, cfg;
267
268 /* get the mux parents */
269 for (i = 0; i < MUX_CLK_NUM_PARENTS; i++) {
Heiner Kallweite9883ef2017-03-04 13:24:09 +0100270 struct clk *clk;
Kevin Hilman51c5d842016-10-19 11:18:24 -0700271 char name[16];
272
273 snprintf(name, sizeof(name), "clkin%d", i);
Heiner Kallweite9883ef2017-03-04 13:24:09 +0100274 clk = devm_clk_get(host->dev, name);
275 if (IS_ERR(clk)) {
276 if (clk != ERR_PTR(-EPROBE_DEFER))
Kevin Hilman51c5d842016-10-19 11:18:24 -0700277 dev_err(host->dev, "Missing clock %s\n", name);
Heiner Kallweite9883ef2017-03-04 13:24:09 +0100278 return PTR_ERR(clk);
Kevin Hilman51c5d842016-10-19 11:18:24 -0700279 }
280
Heiner Kallweite9883ef2017-03-04 13:24:09 +0100281 mux_parent_names[i] = __clk_get_name(clk);
Kevin Hilman51c5d842016-10-19 11:18:24 -0700282 }
283
Kevin Hilman51c5d842016-10-19 11:18:24 -0700284 /* create the mux */
285 snprintf(clk_name, sizeof(clk_name), "%s#mux", dev_name(host->dev));
286 init.name = clk_name;
287 init.ops = &clk_mux_ops;
288 init.flags = 0;
289 init.parent_names = mux_parent_names;
Heiner Kallweit7558c112017-03-04 13:22:57 +0100290 init.num_parents = MUX_CLK_NUM_PARENTS;
Kevin Hilman51c5d842016-10-19 11:18:24 -0700291 host->mux.reg = host->regs + SD_EMMC_CLOCK;
Heiner Kallweit1231e7e2017-03-25 11:23:24 +0100292 host->mux.shift = __bf_shf(CLK_SRC_MASK);
Kevin Hilman51c5d842016-10-19 11:18:24 -0700293 host->mux.mask = CLK_SRC_MASK;
294 host->mux.flags = 0;
295 host->mux.table = NULL;
296 host->mux.hw.init = &init;
297
298 host->mux_clk = devm_clk_register(host->dev, &host->mux.hw);
299 if (WARN_ON(IS_ERR(host->mux_clk)))
300 return PTR_ERR(host->mux_clk);
301
302 /* create the divider */
303 snprintf(clk_name, sizeof(clk_name), "%s#div", dev_name(host->dev));
Heiner Kallweit7b9ebad2017-03-04 13:26:24 +0100304 init.name = clk_name;
Kevin Hilman51c5d842016-10-19 11:18:24 -0700305 init.ops = &clk_divider_ops;
306 init.flags = CLK_SET_RATE_PARENT;
307 clk_div_parents[0] = __clk_get_name(host->mux_clk);
308 init.parent_names = clk_div_parents;
309 init.num_parents = ARRAY_SIZE(clk_div_parents);
310
311 host->cfg_div.reg = host->regs + SD_EMMC_CLOCK;
Heiner Kallweit1231e7e2017-03-25 11:23:24 +0100312 host->cfg_div.shift = __bf_shf(CLK_DIV_MASK);
313 host->cfg_div.width = __builtin_popcountl(CLK_DIV_MASK);
Kevin Hilman51c5d842016-10-19 11:18:24 -0700314 host->cfg_div.hw.init = &init;
315 host->cfg_div.flags = CLK_DIVIDER_ONE_BASED |
316 CLK_DIVIDER_ROUND_CLOSEST | CLK_DIVIDER_ALLOW_ZERO;
317
318 host->cfg_div_clk = devm_clk_register(host->dev, &host->cfg_div.hw);
319 if (WARN_ON(PTR_ERR_OR_ZERO(host->cfg_div_clk)))
320 return PTR_ERR(host->cfg_div_clk);
321
322 /* init SD_EMMC_CLOCK to sane defaults w/min clock rate */
323 clk_reg = 0;
Heiner Kallweitc08bcb62017-04-04 21:03:22 +0200324 clk_reg |= FIELD_PREP(CLK_CORE_PHASE_MASK, host->tp.core_phase);
325 clk_reg |= FIELD_PREP(CLK_TX_PHASE_MASK, host->tp.tx_phase);
326 clk_reg |= FIELD_PREP(CLK_RX_PHASE_MASK, host->tp.rx_phase);
Heiner Kallweit1231e7e2017-03-25 11:23:24 +0100327 clk_reg |= FIELD_PREP(CLK_SRC_MASK, CLK_SRC_XTAL);
328 clk_reg |= FIELD_PREP(CLK_DIV_MASK, CLK_DIV_MAX);
Kevin Hilman51c5d842016-10-19 11:18:24 -0700329 clk_reg &= ~CLK_ALWAYS_ON;
330 writel(clk_reg, host->regs + SD_EMMC_CLOCK);
331
332 /* Ensure clock starts in "auto" mode, not "always on" */
333 cfg = readl(host->regs + SD_EMMC_CFG);
334 cfg &= ~CFG_CLK_ALWAYS_ON;
335 cfg |= CFG_AUTO_CLK;
336 writel(cfg, host->regs + SD_EMMC_CFG);
337
338 ret = clk_prepare_enable(host->cfg_div_clk);
Ulf Hanssona4c38c82017-02-08 12:36:20 +0100339 if (ret)
340 return ret;
Kevin Hilman51c5d842016-10-19 11:18:24 -0700341
Ulf Hanssona4c38c82017-02-08 12:36:20 +0100342 /* Get the nearest minimum clock to 400KHz */
343 host->mmc->f_min = clk_round_rate(host->cfg_div_clk, 400000);
344
345 ret = meson_mmc_clk_set(host, host->mmc->f_min);
Heiner Kallweitcac3a472017-03-04 13:25:14 +0100346 if (ret)
Kevin Hilman51c5d842016-10-19 11:18:24 -0700347 clk_disable_unprepare(host->cfg_div_clk);
348
349 return ret;
350}
351
352static void meson_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
353{
354 struct meson_host *host = mmc_priv(mmc);
355 u32 bus_width;
356 u32 val, orig;
357
358 /*
359 * GPIO regulator, only controls switching between 1v8 and
360 * 3v3, doesn't support MMC_POWER_OFF, MMC_POWER_ON.
361 */
362 switch (ios->power_mode) {
363 case MMC_POWER_OFF:
364 if (!IS_ERR(mmc->supply.vmmc))
365 mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, 0);
366
367 if (!IS_ERR(mmc->supply.vqmmc) && host->vqmmc_enabled) {
368 regulator_disable(mmc->supply.vqmmc);
369 host->vqmmc_enabled = false;
370 }
371
372 break;
373
374 case MMC_POWER_UP:
375 if (!IS_ERR(mmc->supply.vmmc))
376 mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, ios->vdd);
377 break;
378
379 case MMC_POWER_ON:
380 if (!IS_ERR(mmc->supply.vqmmc) && !host->vqmmc_enabled) {
381 int ret = regulator_enable(mmc->supply.vqmmc);
382
383 if (ret < 0)
384 dev_err(mmc_dev(mmc),
385 "failed to enable vqmmc regulator\n");
386 else
387 host->vqmmc_enabled = true;
388 }
389
390 break;
391 }
392
393
394 meson_mmc_clk_set(host, ios->clock);
395
396 /* Bus width */
Kevin Hilman51c5d842016-10-19 11:18:24 -0700397 switch (ios->bus_width) {
398 case MMC_BUS_WIDTH_1:
399 bus_width = CFG_BUS_WIDTH_1;
400 break;
401 case MMC_BUS_WIDTH_4:
402 bus_width = CFG_BUS_WIDTH_4;
403 break;
404 case MMC_BUS_WIDTH_8:
405 bus_width = CFG_BUS_WIDTH_8;
406 break;
407 default:
408 dev_err(host->dev, "Invalid ios->bus_width: %u. Setting to 4.\n",
409 ios->bus_width);
410 bus_width = CFG_BUS_WIDTH_4;
Kevin Hilman51c5d842016-10-19 11:18:24 -0700411 }
412
413 val = readl(host->regs + SD_EMMC_CFG);
414 orig = val;
415
Heiner Kallweit1231e7e2017-03-25 11:23:24 +0100416 val &= ~CFG_BUS_WIDTH_MASK;
417 val |= FIELD_PREP(CFG_BUS_WIDTH_MASK, bus_width);
Kevin Hilman51c5d842016-10-19 11:18:24 -0700418
Heiner Kallweite21e6fd2017-02-07 22:35:59 +0100419 val &= ~CFG_DDR;
420 if (ios->timing == MMC_TIMING_UHS_DDR50 ||
421 ios->timing == MMC_TIMING_MMC_DDR52 ||
422 ios->timing == MMC_TIMING_MMC_HS400)
423 val |= CFG_DDR;
424
425 val &= ~CFG_CHK_DS;
426 if (ios->timing == MMC_TIMING_MMC_HS400)
427 val |= CFG_CHK_DS;
428
Heiner Kallweitc01d1212017-03-04 13:35:13 +0100429 if (val != orig) {
430 writel(val, host->regs + SD_EMMC_CFG);
Kevin Hilman51c5d842016-10-19 11:18:24 -0700431 dev_dbg(host->dev, "%s: SD_EMMC_CFG: 0x%08x -> 0x%08x\n",
432 __func__, orig, val);
Heiner Kallweitc01d1212017-03-04 13:35:13 +0100433 }
Kevin Hilman51c5d842016-10-19 11:18:24 -0700434}
435
Heiner Kallweit3d6c9912017-03-04 13:20:44 +0100436static void meson_mmc_request_done(struct mmc_host *mmc,
437 struct mmc_request *mrq)
Kevin Hilman51c5d842016-10-19 11:18:24 -0700438{
439 struct meson_host *host = mmc_priv(mmc);
440
Kevin Hilman51c5d842016-10-19 11:18:24 -0700441 host->cmd = NULL;
442 mmc_request_done(host->mmc, mrq);
Kevin Hilman51c5d842016-10-19 11:18:24 -0700443}
444
Heiner Kallweit3d03f6a2017-03-27 21:57:11 +0200445static void meson_mmc_set_blksz(struct mmc_host *mmc, unsigned int blksz)
446{
447 struct meson_host *host = mmc_priv(mmc);
448 u32 cfg, blksz_old;
449
450 cfg = readl(host->regs + SD_EMMC_CFG);
451 blksz_old = FIELD_GET(CFG_BLK_LEN_MASK, cfg);
452
453 if (!is_power_of_2(blksz))
454 dev_err(host->dev, "blksz %u is not a power of 2\n", blksz);
455
456 blksz = ilog2(blksz);
457
458 /* check if block-size matches, if not update */
459 if (blksz == blksz_old)
460 return;
461
462 dev_dbg(host->dev, "%s: update blk_len %d -> %d\n", __func__,
463 blksz_old, blksz);
464
465 cfg &= ~CFG_BLK_LEN_MASK;
466 cfg |= FIELD_PREP(CFG_BLK_LEN_MASK, blksz);
467 writel(cfg, host->regs + SD_EMMC_CFG);
468}
469
Heiner Kallweit75c7fd92017-03-27 22:02:32 +0200470static void meson_mmc_set_response_bits(struct mmc_command *cmd, u32 *cmd_cfg)
471{
472 if (cmd->flags & MMC_RSP_PRESENT) {
473 if (cmd->flags & MMC_RSP_136)
474 *cmd_cfg |= CMD_CFG_RESP_128;
475 *cmd_cfg |= CMD_CFG_RESP_NUM;
476
477 if (!(cmd->flags & MMC_RSP_CRC))
478 *cmd_cfg |= CMD_CFG_RESP_NOCRC;
479
480 if (cmd->flags & MMC_RSP_BUSY)
481 *cmd_cfg |= CMD_CFG_R1B;
482 } else {
483 *cmd_cfg |= CMD_CFG_NO_RESP;
484 }
485}
486
Kevin Hilman51c5d842016-10-19 11:18:24 -0700487static void meson_mmc_start_cmd(struct mmc_host *mmc, struct mmc_command *cmd)
488{
489 struct meson_host *host = mmc_priv(mmc);
Heiner Kallweit00412dd2017-03-22 22:33:44 +0100490 struct mmc_data *data = cmd->data;
Heiner Kallweit3d03f6a2017-03-27 21:57:11 +0200491 u32 cmd_cfg = 0, cmd_data = 0;
Kevin Hilman51c5d842016-10-19 11:18:24 -0700492 unsigned int xfer_bytes = 0;
493
494 /* Setup descriptors */
495 dma_rmb();
Kevin Hilman51c5d842016-10-19 11:18:24 -0700496
Heiner Kallweit1231e7e2017-03-25 11:23:24 +0100497 cmd_cfg |= FIELD_PREP(CMD_CFG_CMD_INDEX_MASK, cmd->opcode);
Heiner Kallweita322feb2017-03-22 22:33:47 +0100498 cmd_cfg |= CMD_CFG_OWNER; /* owned by CPU */
Kevin Hilman51c5d842016-10-19 11:18:24 -0700499
Heiner Kallweit75c7fd92017-03-27 22:02:32 +0200500 meson_mmc_set_response_bits(cmd, &cmd_cfg);
Kevin Hilman51c5d842016-10-19 11:18:24 -0700501
502 /* data? */
Heiner Kallweit00412dd2017-03-22 22:33:44 +0100503 if (data) {
Heiner Kallweita322feb2017-03-22 22:33:47 +0100504 cmd_cfg |= CMD_CFG_DATA_IO;
Heiner Kallweit1231e7e2017-03-25 11:23:24 +0100505 cmd_cfg |= FIELD_PREP(CMD_CFG_TIMEOUT_MASK,
Heiner Kallweit4eee86c2017-03-25 11:26:18 +0100506 ilog2(meson_mmc_get_timeout_msecs(data)));
Heiner Kallweita744c6f2017-03-22 22:34:01 +0100507
Heiner Kallweit00412dd2017-03-22 22:33:44 +0100508 if (data->blocks > 1) {
Heiner Kallweita322feb2017-03-22 22:33:47 +0100509 cmd_cfg |= CMD_CFG_BLOCK_MODE;
Heiner Kallweit1231e7e2017-03-25 11:23:24 +0100510 cmd_cfg |= FIELD_PREP(CMD_CFG_LENGTH_MASK,
511 data->blocks);
Heiner Kallweit3d03f6a2017-03-27 21:57:11 +0200512 meson_mmc_set_blksz(mmc, data->blksz);
Kevin Hilman51c5d842016-10-19 11:18:24 -0700513 } else {
Heiner Kallweit1231e7e2017-03-25 11:23:24 +0100514 cmd_cfg |= FIELD_PREP(CMD_CFG_LENGTH_MASK, data->blksz);
Kevin Hilman51c5d842016-10-19 11:18:24 -0700515 }
516
Heiner Kallweit00412dd2017-03-22 22:33:44 +0100517 data->bytes_xfered = 0;
518 xfer_bytes = data->blksz * data->blocks;
519 if (data->flags & MMC_DATA_WRITE) {
Heiner Kallweita322feb2017-03-22 22:33:47 +0100520 cmd_cfg |= CMD_CFG_DATA_WR;
Kevin Hilman51c5d842016-10-19 11:18:24 -0700521 WARN_ON(xfer_bytes > host->bounce_buf_size);
Heiner Kallweit00412dd2017-03-22 22:33:44 +0100522 sg_copy_to_buffer(data->sg, data->sg_len,
Kevin Hilman51c5d842016-10-19 11:18:24 -0700523 host->bounce_buf, xfer_bytes);
Kevin Hilman51c5d842016-10-19 11:18:24 -0700524 dma_wmb();
Kevin Hilman51c5d842016-10-19 11:18:24 -0700525 }
526
Heiner Kallweita322feb2017-03-22 22:33:47 +0100527 cmd_data = host->bounce_dma_addr & CMD_DATA_MASK;
Kevin Hilman51c5d842016-10-19 11:18:24 -0700528 } else {
Heiner Kallweit1231e7e2017-03-25 11:23:24 +0100529 cmd_cfg |= FIELD_PREP(CMD_CFG_TIMEOUT_MASK,
530 ilog2(SD_EMMC_CMD_TIMEOUT));
Kevin Hilman51c5d842016-10-19 11:18:24 -0700531 }
Kevin Hilman51c5d842016-10-19 11:18:24 -0700532
533 host->cmd = cmd;
534
535 /* Last descriptor */
Heiner Kallweita322feb2017-03-22 22:33:47 +0100536 cmd_cfg |= CMD_CFG_END_OF_CHAIN;
537 writel(cmd_cfg, host->regs + SD_EMMC_CMD_CFG);
538 writel(cmd_data, host->regs + SD_EMMC_CMD_DAT);
539 writel(0, host->regs + SD_EMMC_CMD_RSP);
Kevin Hilman51c5d842016-10-19 11:18:24 -0700540 wmb(); /* ensure descriptor is written before kicked */
Heiner Kallweita322feb2017-03-22 22:33:47 +0100541 writel(cmd->arg, host->regs + SD_EMMC_CMD_ARG);
Kevin Hilman51c5d842016-10-19 11:18:24 -0700542}
543
544static void meson_mmc_request(struct mmc_host *mmc, struct mmc_request *mrq)
545{
546 struct meson_host *host = mmc_priv(mmc);
547
Kevin Hilman51c5d842016-10-19 11:18:24 -0700548 /* Stop execution */
549 writel(0, host->regs + SD_EMMC_START);
550
Kevin Hilman51c5d842016-10-19 11:18:24 -0700551 if (mrq->sbc)
552 meson_mmc_start_cmd(mmc, mrq->sbc);
553 else
554 meson_mmc_start_cmd(mmc, mrq->cmd);
555}
556
Heiner Kallweit3d6c9912017-03-04 13:20:44 +0100557static void meson_mmc_read_resp(struct mmc_host *mmc, struct mmc_command *cmd)
Kevin Hilman51c5d842016-10-19 11:18:24 -0700558{
559 struct meson_host *host = mmc_priv(mmc);
560
561 if (cmd->flags & MMC_RSP_136) {
562 cmd->resp[0] = readl(host->regs + SD_EMMC_CMD_RSP3);
563 cmd->resp[1] = readl(host->regs + SD_EMMC_CMD_RSP2);
564 cmd->resp[2] = readl(host->regs + SD_EMMC_CMD_RSP1);
565 cmd->resp[3] = readl(host->regs + SD_EMMC_CMD_RSP);
566 } else if (cmd->flags & MMC_RSP_PRESENT) {
567 cmd->resp[0] = readl(host->regs + SD_EMMC_CMD_RSP);
568 }
Kevin Hilman51c5d842016-10-19 11:18:24 -0700569}
570
571static irqreturn_t meson_mmc_irq(int irq, void *dev_id)
572{
573 struct meson_host *host = dev_id;
Heinrich Schuchardt19a91dd2016-12-23 16:01:08 +0100574 struct mmc_command *cmd;
Heiner Kallweit2c8d96a2017-03-22 22:33:53 +0100575 struct mmc_data *data;
Kevin Hilman51c5d842016-10-19 11:18:24 -0700576 u32 irq_en, status, raw_status;
577 irqreturn_t ret = IRQ_HANDLED;
578
579 if (WARN_ON(!host))
580 return IRQ_NONE;
581
Heinrich Schuchardt19a91dd2016-12-23 16:01:08 +0100582 cmd = host->cmd;
583
Kevin Hilman51c5d842016-10-19 11:18:24 -0700584 if (WARN_ON(!cmd))
585 return IRQ_NONE;
586
Heiner Kallweit2c8d96a2017-03-22 22:33:53 +0100587 data = cmd->data;
588
Kevin Hilman51c5d842016-10-19 11:18:24 -0700589 spin_lock(&host->lock);
590 irq_en = readl(host->regs + SD_EMMC_IRQ_EN);
591 raw_status = readl(host->regs + SD_EMMC_STATUS);
592 status = raw_status & irq_en;
593
594 if (!status) {
595 dev_warn(host->dev, "Spurious IRQ! status=0x%08x, irq_en=0x%08x\n",
596 raw_status, irq_en);
597 ret = IRQ_NONE;
598 goto out;
599 }
600
Heiner Kallweit1f8066d2017-03-22 22:33:50 +0100601 meson_mmc_read_resp(host->mmc, cmd);
602
Kevin Hilman51c5d842016-10-19 11:18:24 -0700603 cmd->error = 0;
604 if (status & IRQ_RXD_ERR_MASK) {
605 dev_dbg(host->dev, "Unhandled IRQ: RXD error\n");
606 cmd->error = -EILSEQ;
607 }
608 if (status & IRQ_TXD_ERR) {
609 dev_dbg(host->dev, "Unhandled IRQ: TXD error\n");
610 cmd->error = -EILSEQ;
611 }
612 if (status & IRQ_DESC_ERR)
613 dev_dbg(host->dev, "Unhandled IRQ: Descriptor error\n");
614 if (status & IRQ_RESP_ERR) {
615 dev_dbg(host->dev, "Unhandled IRQ: Response error\n");
616 cmd->error = -EILSEQ;
617 }
618 if (status & IRQ_RESP_TIMEOUT) {
619 dev_dbg(host->dev, "Unhandled IRQ: Response timeout\n");
620 cmd->error = -ETIMEDOUT;
621 }
622 if (status & IRQ_DESC_TIMEOUT) {
623 dev_dbg(host->dev, "Unhandled IRQ: Descriptor timeout\n");
624 cmd->error = -ETIMEDOUT;
625 }
626 if (status & IRQ_SDIO)
627 dev_dbg(host->dev, "Unhandled IRQ: SDIO.\n");
628
Heiner Kallweit2c8d96a2017-03-22 22:33:53 +0100629 if (status & (IRQ_END_OF_CHAIN | IRQ_RESP_STATUS)) {
630 if (data && !cmd->error)
631 data->bytes_xfered = data->blksz * data->blocks;
Kevin Hilman51c5d842016-10-19 11:18:24 -0700632 ret = IRQ_WAKE_THREAD;
Heiner Kallweit2c8d96a2017-03-22 22:33:53 +0100633 } else {
Kevin Hilman51c5d842016-10-19 11:18:24 -0700634 dev_warn(host->dev, "Unknown IRQ! status=0x%04x: MMC CMD%u arg=0x%08x flags=0x%08x stop=%d\n",
635 status, cmd->opcode, cmd->arg,
Heiner Kallweit7cdcc482017-03-04 13:36:45 +0100636 cmd->flags, cmd->mrq->stop ? 1 : 0);
Kevin Hilman51c5d842016-10-19 11:18:24 -0700637 if (cmd->data) {
638 struct mmc_data *data = cmd->data;
639
640 dev_warn(host->dev, "\tblksz %u blocks %u flags 0x%08x (%s%s)",
641 data->blksz, data->blocks, data->flags,
642 data->flags & MMC_DATA_WRITE ? "write" : "",
643 data->flags & MMC_DATA_READ ? "read" : "");
644 }
645 }
646
647out:
648 /* ack all (enabled) interrupts */
649 writel(status, host->regs + SD_EMMC_STATUS);
650
Heiner Kallweit1f8066d2017-03-22 22:33:50 +0100651 if (ret == IRQ_HANDLED)
Kevin Hilman51c5d842016-10-19 11:18:24 -0700652 meson_mmc_request_done(host->mmc, cmd->mrq);
Kevin Hilman51c5d842016-10-19 11:18:24 -0700653
654 spin_unlock(&host->lock);
655 return ret;
656}
657
658static irqreturn_t meson_mmc_irq_thread(int irq, void *dev_id)
659{
660 struct meson_host *host = dev_id;
Heiner Kallweite5e4a3e2017-03-25 11:28:13 +0100661 struct mmc_command *next_cmd, *cmd = host->cmd;
Kevin Hilman51c5d842016-10-19 11:18:24 -0700662 struct mmc_data *data;
663 unsigned int xfer_bytes;
Kevin Hilman51c5d842016-10-19 11:18:24 -0700664
Kevin Hilman51c5d842016-10-19 11:18:24 -0700665 if (WARN_ON(!cmd))
Heinrich Schuchardt19a91dd2016-12-23 16:01:08 +0100666 return IRQ_NONE;
Kevin Hilman51c5d842016-10-19 11:18:24 -0700667
668 data = cmd->data;
Heiner Kallweit690f90b2017-02-07 22:34:41 +0100669 if (data && data->flags & MMC_DATA_READ) {
Kevin Hilman51c5d842016-10-19 11:18:24 -0700670 xfer_bytes = data->blksz * data->blocks;
Heiner Kallweit690f90b2017-02-07 22:34:41 +0100671 WARN_ON(xfer_bytes > host->bounce_buf_size);
672 sg_copy_from_buffer(data->sg, data->sg_len,
673 host->bounce_buf, xfer_bytes);
Kevin Hilman51c5d842016-10-19 11:18:24 -0700674 }
675
Heiner Kallweite5e4a3e2017-03-25 11:28:13 +0100676 next_cmd = meson_mmc_get_next_command(cmd);
677 if (next_cmd)
678 meson_mmc_start_cmd(host->mmc, next_cmd);
Kevin Hilman51c5d842016-10-19 11:18:24 -0700679 else
Heiner Kallweite5e4a3e2017-03-25 11:28:13 +0100680 meson_mmc_request_done(host->mmc, cmd->mrq);
Kevin Hilman51c5d842016-10-19 11:18:24 -0700681
Heiner Kallweit690f90b2017-02-07 22:34:41 +0100682 return IRQ_HANDLED;
Kevin Hilman51c5d842016-10-19 11:18:24 -0700683}
684
685/*
686 * NOTE: we only need this until the GPIO/pinctrl driver can handle
687 * interrupts. For now, the MMC core will use this for polling.
688 */
689static int meson_mmc_get_cd(struct mmc_host *mmc)
690{
691 int status = mmc_gpio_get_cd(mmc);
692
693 if (status == -ENOSYS)
694 return 1; /* assume present */
695
696 return status;
697}
698
Heiner Kallweitc01d1212017-03-04 13:35:13 +0100699static void meson_mmc_cfg_init(struct meson_host *host)
700{
701 u32 cfg = 0;
702
Heiner Kallweit1231e7e2017-03-25 11:23:24 +0100703 cfg |= FIELD_PREP(CFG_RESP_TIMEOUT_MASK,
704 ilog2(SD_EMMC_CFG_RESP_TIMEOUT));
705 cfg |= FIELD_PREP(CFG_RC_CC_MASK, ilog2(SD_EMMC_CFG_CMD_GAP));
706 cfg |= FIELD_PREP(CFG_BLK_LEN_MASK, ilog2(SD_EMMC_CFG_BLK_SIZE));
Heiner Kallweitc01d1212017-03-04 13:35:13 +0100707
708 writel(cfg, host->regs + SD_EMMC_CFG);
709}
710
Kevin Hilman51c5d842016-10-19 11:18:24 -0700711static const struct mmc_host_ops meson_mmc_ops = {
712 .request = meson_mmc_request,
713 .set_ios = meson_mmc_set_ios,
714 .get_cd = meson_mmc_get_cd,
715};
716
717static int meson_mmc_probe(struct platform_device *pdev)
718{
719 struct resource *res;
720 struct meson_host *host;
721 struct mmc_host *mmc;
Heiner Kallweit9a1da4d2017-03-04 13:21:54 +0100722 int ret, irq;
Kevin Hilman51c5d842016-10-19 11:18:24 -0700723
724 mmc = mmc_alloc_host(sizeof(struct meson_host), &pdev->dev);
725 if (!mmc)
726 return -ENOMEM;
727 host = mmc_priv(mmc);
728 host->mmc = mmc;
729 host->dev = &pdev->dev;
730 dev_set_drvdata(&pdev->dev, host);
731
732 spin_lock_init(&host->lock);
733
734 /* Get regulators and the supported OCR mask */
735 host->vqmmc_enabled = false;
736 ret = mmc_regulator_get_supply(mmc);
737 if (ret == -EPROBE_DEFER)
738 goto free_host;
739
740 ret = mmc_of_parse(mmc);
741 if (ret) {
Kevin Hilmandc012052017-01-25 16:01:39 -0800742 if (ret != -EPROBE_DEFER)
743 dev_warn(&pdev->dev, "error parsing DT: %d\n", ret);
Kevin Hilman51c5d842016-10-19 11:18:24 -0700744 goto free_host;
745 }
746
747 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
748 host->regs = devm_ioremap_resource(&pdev->dev, res);
749 if (IS_ERR(host->regs)) {
750 ret = PTR_ERR(host->regs);
751 goto free_host;
752 }
753
Heiner Kallweit9a1da4d2017-03-04 13:21:54 +0100754 irq = platform_get_irq(pdev, 0);
755 if (!irq) {
Kevin Hilman51c5d842016-10-19 11:18:24 -0700756 dev_err(&pdev->dev, "failed to get interrupt resource.\n");
757 ret = -EINVAL;
758 goto free_host;
759 }
760
761 host->core_clk = devm_clk_get(&pdev->dev, "core");
762 if (IS_ERR(host->core_clk)) {
763 ret = PTR_ERR(host->core_clk);
764 goto free_host;
765 }
766
767 ret = clk_prepare_enable(host->core_clk);
768 if (ret)
769 goto free_host;
770
Heiner Kallweitc08bcb62017-04-04 21:03:22 +0200771 host->tp.core_phase = CLK_PHASE_180;
772 host->tp.tx_phase = CLK_PHASE_0;
773 host->tp.rx_phase = CLK_PHASE_0;
774
Kevin Hilman51c5d842016-10-19 11:18:24 -0700775 ret = meson_mmc_clk_init(host);
776 if (ret)
Michał Zegance473d52017-03-14 21:05:20 +0100777 goto err_core_clk;
Kevin Hilman51c5d842016-10-19 11:18:24 -0700778
779 /* Stop execution */
780 writel(0, host->regs + SD_EMMC_START);
781
782 /* clear, ack, enable all interrupts */
783 writel(0, host->regs + SD_EMMC_IRQ_EN);
784 writel(IRQ_EN_MASK, host->regs + SD_EMMC_STATUS);
Heiner Kallweit92763b92017-02-07 22:34:51 +0100785 writel(IRQ_EN_MASK, host->regs + SD_EMMC_IRQ_EN);
Kevin Hilman51c5d842016-10-19 11:18:24 -0700786
Heiner Kallweitc01d1212017-03-04 13:35:13 +0100787 /* set config to sane default */
788 meson_mmc_cfg_init(host);
789
Heiner Kallweit9a1da4d2017-03-04 13:21:54 +0100790 ret = devm_request_threaded_irq(&pdev->dev, irq, meson_mmc_irq,
791 meson_mmc_irq_thread, IRQF_SHARED,
Heiner Kallweitf016c672017-03-25 11:24:41 +0100792 NULL, host);
Kevin Hilman51c5d842016-10-19 11:18:24 -0700793 if (ret)
Heiner Kallweitcac3a472017-03-04 13:25:14 +0100794 goto err_div_clk;
Kevin Hilman51c5d842016-10-19 11:18:24 -0700795
Heiner Kallweite5e4a3e2017-03-25 11:28:13 +0100796 mmc->caps |= MMC_CAP_CMD23;
Heiner Kallweitefe0b662017-02-07 22:34:58 +0100797 mmc->max_blk_count = CMD_CFG_LENGTH_MASK;
798 mmc->max_req_size = mmc->max_blk_count * mmc->max_blk_size;
799
Kevin Hilman51c5d842016-10-19 11:18:24 -0700800 /* data bounce buffer */
Heiner Kallweit4136fcb2017-02-07 22:35:02 +0100801 host->bounce_buf_size = mmc->max_req_size;
Kevin Hilman51c5d842016-10-19 11:18:24 -0700802 host->bounce_buf =
803 dma_alloc_coherent(host->dev, host->bounce_buf_size,
804 &host->bounce_dma_addr, GFP_KERNEL);
805 if (host->bounce_buf == NULL) {
806 dev_err(host->dev, "Unable to map allocate DMA bounce buffer.\n");
807 ret = -ENOMEM;
Heiner Kallweitcac3a472017-03-04 13:25:14 +0100808 goto err_div_clk;
Kevin Hilman51c5d842016-10-19 11:18:24 -0700809 }
810
811 mmc->ops = &meson_mmc_ops;
812 mmc_add_host(mmc);
813
814 return 0;
815
Heiner Kallweitcac3a472017-03-04 13:25:14 +0100816err_div_clk:
Kevin Hilman51c5d842016-10-19 11:18:24 -0700817 clk_disable_unprepare(host->cfg_div_clk);
Michał Zegance473d52017-03-14 21:05:20 +0100818err_core_clk:
Kevin Hilman51c5d842016-10-19 11:18:24 -0700819 clk_disable_unprepare(host->core_clk);
Michał Zegance473d52017-03-14 21:05:20 +0100820free_host:
Kevin Hilman51c5d842016-10-19 11:18:24 -0700821 mmc_free_host(mmc);
822 return ret;
823}
824
825static int meson_mmc_remove(struct platform_device *pdev)
826{
827 struct meson_host *host = dev_get_drvdata(&pdev->dev);
828
Michał Zegana01fc2a2017-02-18 18:06:47 +0100829 mmc_remove_host(host->mmc);
830
Heiner Kallweit92763b92017-02-07 22:34:51 +0100831 /* disable interrupts */
832 writel(0, host->regs + SD_EMMC_IRQ_EN);
833
Heiner Kallweit62d721a2017-02-07 22:35:40 +0100834 dma_free_coherent(host->dev, host->bounce_buf_size,
835 host->bounce_buf, host->bounce_dma_addr);
Kevin Hilman51c5d842016-10-19 11:18:24 -0700836
837 clk_disable_unprepare(host->cfg_div_clk);
838 clk_disable_unprepare(host->core_clk);
839
840 mmc_free_host(host->mmc);
841 return 0;
842}
843
844static const struct of_device_id meson_mmc_of_match[] = {
845 { .compatible = "amlogic,meson-gx-mmc", },
846 { .compatible = "amlogic,meson-gxbb-mmc", },
847 { .compatible = "amlogic,meson-gxl-mmc", },
848 { .compatible = "amlogic,meson-gxm-mmc", },
849 {}
850};
851MODULE_DEVICE_TABLE(of, meson_mmc_of_match);
852
853static struct platform_driver meson_mmc_driver = {
854 .probe = meson_mmc_probe,
855 .remove = meson_mmc_remove,
856 .driver = {
857 .name = DRIVER_NAME,
858 .of_match_table = of_match_ptr(meson_mmc_of_match),
859 },
860};
861
862module_platform_driver(meson_mmc_driver);
863
864MODULE_DESCRIPTION("Amlogic S905*/GX* SD/eMMC driver");
865MODULE_AUTHOR("Kevin Hilman <khilman@baylibre.com>");
866MODULE_LICENSE("GPL v2");