xref: /openbmc/linux/drivers/mmc/host/litex_mmc.c (revision ab02d58f)
192e09910SGabriel Somlo // SPDX-License-Identifier: GPL-2.0
292e09910SGabriel Somlo /*
392e09910SGabriel Somlo  * LiteX LiteSDCard driver
492e09910SGabriel Somlo  *
592e09910SGabriel Somlo  * Copyright (C) 2019-2020 Antmicro <contact@antmicro.com>
692e09910SGabriel Somlo  * Copyright (C) 2019-2020 Kamil Rakoczy <krakoczy@antmicro.com>
792e09910SGabriel Somlo  * Copyright (C) 2019-2020 Maciej Dudek <mdudek@internships.antmicro.com>
892e09910SGabriel Somlo  * Copyright (C) 2020 Paul Mackerras <paulus@ozlabs.org>
992e09910SGabriel Somlo  * Copyright (C) 2020-2022 Gabriel Somlo <gsomlo@gmail.com>
1092e09910SGabriel Somlo  */
1192e09910SGabriel Somlo 
1292e09910SGabriel Somlo #include <linux/bits.h>
1392e09910SGabriel Somlo #include <linux/clk.h>
1492e09910SGabriel Somlo #include <linux/delay.h>
1592e09910SGabriel Somlo #include <linux/dma-mapping.h>
1692e09910SGabriel Somlo #include <linux/interrupt.h>
1792e09910SGabriel Somlo #include <linux/iopoll.h>
1892e09910SGabriel Somlo #include <linux/litex.h>
1992e09910SGabriel Somlo #include <linux/mod_devicetable.h>
2092e09910SGabriel Somlo #include <linux/module.h>
2192e09910SGabriel Somlo #include <linux/platform_device.h>
2292e09910SGabriel Somlo 
2392e09910SGabriel Somlo #include <linux/mmc/host.h>
2492e09910SGabriel Somlo #include <linux/mmc/mmc.h>
2592e09910SGabriel Somlo #include <linux/mmc/sd.h>
2692e09910SGabriel Somlo 
2792e09910SGabriel Somlo #define LITEX_PHY_CARDDETECT  0x00
2892e09910SGabriel Somlo #define LITEX_PHY_CLOCKERDIV  0x04
2992e09910SGabriel Somlo #define LITEX_PHY_INITIALIZE  0x08
3092e09910SGabriel Somlo #define LITEX_PHY_WRITESTATUS 0x0C
3192e09910SGabriel Somlo #define LITEX_CORE_CMDARG     0x00
3292e09910SGabriel Somlo #define LITEX_CORE_CMDCMD     0x04
3392e09910SGabriel Somlo #define LITEX_CORE_CMDSND     0x08
3492e09910SGabriel Somlo #define LITEX_CORE_CMDRSP     0x0C
3592e09910SGabriel Somlo #define LITEX_CORE_CMDEVT     0x1C
3692e09910SGabriel Somlo #define LITEX_CORE_DATEVT     0x20
3792e09910SGabriel Somlo #define LITEX_CORE_BLKLEN     0x24
3892e09910SGabriel Somlo #define LITEX_CORE_BLKCNT     0x28
3992e09910SGabriel Somlo #define LITEX_BLK2MEM_BASE    0x00
4092e09910SGabriel Somlo #define LITEX_BLK2MEM_LEN     0x08
4192e09910SGabriel Somlo #define LITEX_BLK2MEM_ENA     0x0C
4292e09910SGabriel Somlo #define LITEX_BLK2MEM_DONE    0x10
4392e09910SGabriel Somlo #define LITEX_BLK2MEM_LOOP    0x14
4492e09910SGabriel Somlo #define LITEX_MEM2BLK_BASE    0x00
4592e09910SGabriel Somlo #define LITEX_MEM2BLK_LEN     0x08
4692e09910SGabriel Somlo #define LITEX_MEM2BLK_ENA     0x0C
4792e09910SGabriel Somlo #define LITEX_MEM2BLK_DONE    0x10
4892e09910SGabriel Somlo #define LITEX_MEM2BLK_LOOP    0x14
4992e09910SGabriel Somlo #define LITEX_MEM2BLK         0x18
5092e09910SGabriel Somlo #define LITEX_IRQ_STATUS      0x00
5192e09910SGabriel Somlo #define LITEX_IRQ_PENDING     0x04
5292e09910SGabriel Somlo #define LITEX_IRQ_ENABLE      0x08
5392e09910SGabriel Somlo 
5492e09910SGabriel Somlo #define SD_CTL_DATA_XFER_NONE  0
5592e09910SGabriel Somlo #define SD_CTL_DATA_XFER_READ  1
5692e09910SGabriel Somlo #define SD_CTL_DATA_XFER_WRITE 2
5792e09910SGabriel Somlo 
5892e09910SGabriel Somlo #define SD_CTL_RESP_NONE       0
5992e09910SGabriel Somlo #define SD_CTL_RESP_SHORT      1
6092e09910SGabriel Somlo #define SD_CTL_RESP_LONG       2
6192e09910SGabriel Somlo #define SD_CTL_RESP_SHORT_BUSY 3
6292e09910SGabriel Somlo 
6392e09910SGabriel Somlo #define SD_BIT_DONE    BIT(0)
6492e09910SGabriel Somlo #define SD_BIT_WR_ERR  BIT(1)
6592e09910SGabriel Somlo #define SD_BIT_TIMEOUT BIT(2)
6692e09910SGabriel Somlo #define SD_BIT_CRC_ERR BIT(3)
6792e09910SGabriel Somlo 
6892e09910SGabriel Somlo #define SD_SLEEP_US       5
6992e09910SGabriel Somlo #define SD_TIMEOUT_US 20000
7092e09910SGabriel Somlo 
7192e09910SGabriel Somlo #define SDIRQ_CARD_DETECT    1
7292e09910SGabriel Somlo #define SDIRQ_SD_TO_MEM_DONE 2
7392e09910SGabriel Somlo #define SDIRQ_MEM_TO_SD_DONE 4
7492e09910SGabriel Somlo #define SDIRQ_CMD_DONE       8
7592e09910SGabriel Somlo 
7692e09910SGabriel Somlo struct litex_mmc_host {
7792e09910SGabriel Somlo 	struct mmc_host *mmc;
7892e09910SGabriel Somlo 
7992e09910SGabriel Somlo 	void __iomem *sdphy;
8092e09910SGabriel Somlo 	void __iomem *sdcore;
8192e09910SGabriel Somlo 	void __iomem *sdreader;
8292e09910SGabriel Somlo 	void __iomem *sdwriter;
8392e09910SGabriel Somlo 	void __iomem *sdirq;
8492e09910SGabriel Somlo 
8592e09910SGabriel Somlo 	void *buffer;
8692e09910SGabriel Somlo 	size_t buf_size;
8792e09910SGabriel Somlo 	dma_addr_t dma;
8892e09910SGabriel Somlo 
8992e09910SGabriel Somlo 	struct completion cmd_done;
9092e09910SGabriel Somlo 	int irq;
9192e09910SGabriel Somlo 
9292e09910SGabriel Somlo 	unsigned int ref_clk;
9392e09910SGabriel Somlo 	unsigned int sd_clk;
9492e09910SGabriel Somlo 
9592e09910SGabriel Somlo 	u32 resp[4];
9692e09910SGabriel Somlo 	u16 rca;
9792e09910SGabriel Somlo 
9892e09910SGabriel Somlo 	bool is_bus_width_set;
9992e09910SGabriel Somlo 	bool app_cmd;
10092e09910SGabriel Somlo };
10192e09910SGabriel Somlo 
litex_mmc_sdcard_wait_done(void __iomem * reg,struct device * dev)10292e09910SGabriel Somlo static int litex_mmc_sdcard_wait_done(void __iomem *reg, struct device *dev)
10392e09910SGabriel Somlo {
10492e09910SGabriel Somlo 	u8 evt;
10592e09910SGabriel Somlo 	int ret;
10692e09910SGabriel Somlo 
10792e09910SGabriel Somlo 	ret = readx_poll_timeout(litex_read8, reg, evt, evt & SD_BIT_DONE,
10892e09910SGabriel Somlo 				 SD_SLEEP_US, SD_TIMEOUT_US);
10992e09910SGabriel Somlo 	if (ret)
11092e09910SGabriel Somlo 		return ret;
11192e09910SGabriel Somlo 	if (evt == SD_BIT_DONE)
11292e09910SGabriel Somlo 		return 0;
11392e09910SGabriel Somlo 	if (evt & SD_BIT_WR_ERR)
11492e09910SGabriel Somlo 		return -EIO;
11592e09910SGabriel Somlo 	if (evt & SD_BIT_TIMEOUT)
11692e09910SGabriel Somlo 		return -ETIMEDOUT;
11792e09910SGabriel Somlo 	if (evt & SD_BIT_CRC_ERR)
11892e09910SGabriel Somlo 		return -EILSEQ;
11992e09910SGabriel Somlo 	dev_err(dev, "%s: unknown error (evt=%x)\n", __func__, evt);
12092e09910SGabriel Somlo 	return -EINVAL;
12192e09910SGabriel Somlo }
12292e09910SGabriel Somlo 
litex_mmc_send_cmd(struct litex_mmc_host * host,u8 cmd,u32 arg,u8 response_len,u8 transfer)12392e09910SGabriel Somlo static int litex_mmc_send_cmd(struct litex_mmc_host *host,
12492e09910SGabriel Somlo 			      u8 cmd, u32 arg, u8 response_len, u8 transfer)
12592e09910SGabriel Somlo {
12692e09910SGabriel Somlo 	struct device *dev = mmc_dev(host->mmc);
12792e09910SGabriel Somlo 	void __iomem *reg;
12892e09910SGabriel Somlo 	int ret;
12992e09910SGabriel Somlo 	u8 evt;
13092e09910SGabriel Somlo 
13192e09910SGabriel Somlo 	litex_write32(host->sdcore + LITEX_CORE_CMDARG, arg);
13292e09910SGabriel Somlo 	litex_write32(host->sdcore + LITEX_CORE_CMDCMD,
13392e09910SGabriel Somlo 		      cmd << 8 | transfer << 5 | response_len);
13492e09910SGabriel Somlo 	litex_write8(host->sdcore + LITEX_CORE_CMDSND, 1);
13592e09910SGabriel Somlo 
13692e09910SGabriel Somlo 	/*
13792e09910SGabriel Somlo 	 * Wait for an interrupt if we have an interrupt and either there is
13892e09910SGabriel Somlo 	 * data to be transferred, or if the card can report busy via DAT0.
13992e09910SGabriel Somlo 	 */
14092e09910SGabriel Somlo 	if (host->irq > 0 &&
14192e09910SGabriel Somlo 	    (transfer != SD_CTL_DATA_XFER_NONE ||
14292e09910SGabriel Somlo 	     response_len == SD_CTL_RESP_SHORT_BUSY)) {
14392e09910SGabriel Somlo 		reinit_completion(&host->cmd_done);
14492e09910SGabriel Somlo 		litex_write32(host->sdirq + LITEX_IRQ_ENABLE,
14592e09910SGabriel Somlo 			      SDIRQ_CMD_DONE | SDIRQ_CARD_DETECT);
14692e09910SGabriel Somlo 		wait_for_completion(&host->cmd_done);
14792e09910SGabriel Somlo 	}
14892e09910SGabriel Somlo 
14992e09910SGabriel Somlo 	ret = litex_mmc_sdcard_wait_done(host->sdcore + LITEX_CORE_CMDEVT, dev);
15092e09910SGabriel Somlo 	if (ret) {
15192e09910SGabriel Somlo 		dev_err(dev, "Command (cmd %d) error, status %d\n", cmd, ret);
15292e09910SGabriel Somlo 		return ret;
15392e09910SGabriel Somlo 	}
15492e09910SGabriel Somlo 
15592e09910SGabriel Somlo 	if (response_len != SD_CTL_RESP_NONE) {
15692e09910SGabriel Somlo 		/*
15792e09910SGabriel Somlo 		 * NOTE: this matches the semantics of litex_read32()
15892e09910SGabriel Somlo 		 * regardless of underlying arch endianness!
15992e09910SGabriel Somlo 		 */
16092e09910SGabriel Somlo 		memcpy_fromio(host->resp,
16192e09910SGabriel Somlo 			      host->sdcore + LITEX_CORE_CMDRSP, 0x10);
16292e09910SGabriel Somlo 	}
16392e09910SGabriel Somlo 
16492e09910SGabriel Somlo 	if (!host->app_cmd && cmd == SD_SEND_RELATIVE_ADDR)
16592e09910SGabriel Somlo 		host->rca = (host->resp[3] >> 16);
16692e09910SGabriel Somlo 
16792e09910SGabriel Somlo 	host->app_cmd = (cmd == MMC_APP_CMD);
16892e09910SGabriel Somlo 
16992e09910SGabriel Somlo 	if (transfer == SD_CTL_DATA_XFER_NONE)
17092e09910SGabriel Somlo 		return ret; /* OK from prior litex_mmc_sdcard_wait_done() */
17192e09910SGabriel Somlo 
17292e09910SGabriel Somlo 	ret = litex_mmc_sdcard_wait_done(host->sdcore + LITEX_CORE_DATEVT, dev);
17392e09910SGabriel Somlo 	if (ret) {
17492e09910SGabriel Somlo 		dev_err(dev, "Data xfer (cmd %d) error, status %d\n", cmd, ret);
17592e09910SGabriel Somlo 		return ret;
17692e09910SGabriel Somlo 	}
17792e09910SGabriel Somlo 
17892e09910SGabriel Somlo 	/* Wait for completion of (read or write) DMA transfer */
17992e09910SGabriel Somlo 	reg = (transfer == SD_CTL_DATA_XFER_READ) ?
18092e09910SGabriel Somlo 		host->sdreader + LITEX_BLK2MEM_DONE :
18192e09910SGabriel Somlo 		host->sdwriter + LITEX_MEM2BLK_DONE;
18292e09910SGabriel Somlo 	ret = readx_poll_timeout(litex_read8, reg, evt, evt & SD_BIT_DONE,
18392e09910SGabriel Somlo 				 SD_SLEEP_US, SD_TIMEOUT_US);
18492e09910SGabriel Somlo 	if (ret)
18592e09910SGabriel Somlo 		dev_err(dev, "DMA timeout (cmd %d)\n", cmd);
18692e09910SGabriel Somlo 
18792e09910SGabriel Somlo 	return ret;
18892e09910SGabriel Somlo }
18992e09910SGabriel Somlo 
litex_mmc_send_app_cmd(struct litex_mmc_host * host)19092e09910SGabriel Somlo static int litex_mmc_send_app_cmd(struct litex_mmc_host *host)
19192e09910SGabriel Somlo {
19292e09910SGabriel Somlo 	return litex_mmc_send_cmd(host, MMC_APP_CMD, host->rca << 16,
19392e09910SGabriel Somlo 				  SD_CTL_RESP_SHORT, SD_CTL_DATA_XFER_NONE);
19492e09910SGabriel Somlo }
19592e09910SGabriel Somlo 
litex_mmc_send_set_bus_w_cmd(struct litex_mmc_host * host,u32 width)19692e09910SGabriel Somlo static int litex_mmc_send_set_bus_w_cmd(struct litex_mmc_host *host, u32 width)
19792e09910SGabriel Somlo {
19892e09910SGabriel Somlo 	return litex_mmc_send_cmd(host, SD_APP_SET_BUS_WIDTH, width,
19992e09910SGabriel Somlo 				  SD_CTL_RESP_SHORT, SD_CTL_DATA_XFER_NONE);
20092e09910SGabriel Somlo }
20192e09910SGabriel Somlo 
litex_mmc_set_bus_width(struct litex_mmc_host * host)20292e09910SGabriel Somlo static int litex_mmc_set_bus_width(struct litex_mmc_host *host)
20392e09910SGabriel Somlo {
20492e09910SGabriel Somlo 	bool app_cmd_sent;
20592e09910SGabriel Somlo 	int ret;
20692e09910SGabriel Somlo 
20792e09910SGabriel Somlo 	if (host->is_bus_width_set)
20892e09910SGabriel Somlo 		return 0;
20992e09910SGabriel Somlo 
21092e09910SGabriel Somlo 	/* Ensure 'app_cmd' precedes 'app_set_bus_width_cmd' */
21192e09910SGabriel Somlo 	app_cmd_sent = host->app_cmd; /* was preceding command app_cmd? */
21292e09910SGabriel Somlo 	if (!app_cmd_sent) {
21392e09910SGabriel Somlo 		ret = litex_mmc_send_app_cmd(host);
21492e09910SGabriel Somlo 		if (ret)
21592e09910SGabriel Somlo 			return ret;
21692e09910SGabriel Somlo 	}
21792e09910SGabriel Somlo 
21892e09910SGabriel Somlo 	/* LiteSDCard only supports 4-bit bus width */
21992e09910SGabriel Somlo 	ret = litex_mmc_send_set_bus_w_cmd(host, MMC_BUS_WIDTH_4);
22092e09910SGabriel Somlo 	if (ret)
22192e09910SGabriel Somlo 		return ret;
22292e09910SGabriel Somlo 
22392e09910SGabriel Somlo 	/* Re-send 'app_cmd' if necessary */
22492e09910SGabriel Somlo 	if (app_cmd_sent) {
22592e09910SGabriel Somlo 		ret = litex_mmc_send_app_cmd(host);
22692e09910SGabriel Somlo 		if (ret)
22792e09910SGabriel Somlo 			return ret;
22892e09910SGabriel Somlo 	}
22992e09910SGabriel Somlo 
23092e09910SGabriel Somlo 	host->is_bus_width_set = true;
23192e09910SGabriel Somlo 
23292e09910SGabriel Somlo 	return 0;
23392e09910SGabriel Somlo }
23492e09910SGabriel Somlo 
litex_mmc_get_cd(struct mmc_host * mmc)23592e09910SGabriel Somlo static int litex_mmc_get_cd(struct mmc_host *mmc)
23692e09910SGabriel Somlo {
23792e09910SGabriel Somlo 	struct litex_mmc_host *host = mmc_priv(mmc);
23892e09910SGabriel Somlo 	int ret;
23992e09910SGabriel Somlo 
24092e09910SGabriel Somlo 	if (!mmc_card_is_removable(mmc))
24192e09910SGabriel Somlo 		return 1;
24292e09910SGabriel Somlo 
24392e09910SGabriel Somlo 	ret = !litex_read8(host->sdphy + LITEX_PHY_CARDDETECT);
24492e09910SGabriel Somlo 	if (ret)
24592e09910SGabriel Somlo 		return ret;
24692e09910SGabriel Somlo 
24792e09910SGabriel Somlo 	/* Ensure bus width will be set (again) upon card (re)insertion */
24892e09910SGabriel Somlo 	host->is_bus_width_set = false;
24992e09910SGabriel Somlo 
25092e09910SGabriel Somlo 	return 0;
25192e09910SGabriel Somlo }
25292e09910SGabriel Somlo 
litex_mmc_interrupt(int irq,void * arg)25392e09910SGabriel Somlo static irqreturn_t litex_mmc_interrupt(int irq, void *arg)
25492e09910SGabriel Somlo {
25592e09910SGabriel Somlo 	struct mmc_host *mmc = arg;
25692e09910SGabriel Somlo 	struct litex_mmc_host *host = mmc_priv(mmc);
25792e09910SGabriel Somlo 	u32 pending = litex_read32(host->sdirq + LITEX_IRQ_PENDING);
25892e09910SGabriel Somlo 	irqreturn_t ret = IRQ_NONE;
25992e09910SGabriel Somlo 
26092e09910SGabriel Somlo 	/* Check for card change interrupt */
26192e09910SGabriel Somlo 	if (pending & SDIRQ_CARD_DETECT) {
26292e09910SGabriel Somlo 		litex_write32(host->sdirq + LITEX_IRQ_PENDING,
26392e09910SGabriel Somlo 			      SDIRQ_CARD_DETECT);
26492e09910SGabriel Somlo 		mmc_detect_change(mmc, msecs_to_jiffies(10));
26592e09910SGabriel Somlo 		ret = IRQ_HANDLED;
26692e09910SGabriel Somlo 	}
26792e09910SGabriel Somlo 
26892e09910SGabriel Somlo 	/* Check for command completed */
26992e09910SGabriel Somlo 	if (pending & SDIRQ_CMD_DONE) {
27092e09910SGabriel Somlo 		/* Disable it so it doesn't keep interrupting */
27192e09910SGabriel Somlo 		litex_write32(host->sdirq + LITEX_IRQ_ENABLE,
27292e09910SGabriel Somlo 			      SDIRQ_CARD_DETECT);
27392e09910SGabriel Somlo 		complete(&host->cmd_done);
27492e09910SGabriel Somlo 		ret = IRQ_HANDLED;
27592e09910SGabriel Somlo 	}
27692e09910SGabriel Somlo 
27792e09910SGabriel Somlo 	return ret;
27892e09910SGabriel Somlo }
27992e09910SGabriel Somlo 
litex_mmc_response_len(struct mmc_command * cmd)28092e09910SGabriel Somlo static u32 litex_mmc_response_len(struct mmc_command *cmd)
28192e09910SGabriel Somlo {
28292e09910SGabriel Somlo 	if (cmd->flags & MMC_RSP_136)
28392e09910SGabriel Somlo 		return SD_CTL_RESP_LONG;
28492e09910SGabriel Somlo 	if (!(cmd->flags & MMC_RSP_PRESENT))
28592e09910SGabriel Somlo 		return SD_CTL_RESP_NONE;
28692e09910SGabriel Somlo 	if (cmd->flags & MMC_RSP_BUSY)
28792e09910SGabriel Somlo 		return SD_CTL_RESP_SHORT_BUSY;
28892e09910SGabriel Somlo 	return SD_CTL_RESP_SHORT;
28992e09910SGabriel Somlo }
29092e09910SGabriel Somlo 
litex_mmc_do_dma(struct litex_mmc_host * host,struct mmc_data * data,unsigned int * len,bool * direct,u8 * transfer)29192e09910SGabriel Somlo static void litex_mmc_do_dma(struct litex_mmc_host *host, struct mmc_data *data,
29292e09910SGabriel Somlo 			     unsigned int *len, bool *direct, u8 *transfer)
29392e09910SGabriel Somlo {
29492e09910SGabriel Somlo 	struct device *dev = mmc_dev(host->mmc);
29592e09910SGabriel Somlo 	dma_addr_t dma;
29692e09910SGabriel Somlo 	int sg_count;
29792e09910SGabriel Somlo 
29892e09910SGabriel Somlo 	/*
29992e09910SGabriel Somlo 	 * Try to DMA directly to/from the data buffer.
30092e09910SGabriel Somlo 	 * We can do that if the buffer can be mapped for DMA
30192e09910SGabriel Somlo 	 * in one contiguous chunk.
30292e09910SGabriel Somlo 	 */
30392e09910SGabriel Somlo 	dma = host->dma;
30492e09910SGabriel Somlo 	*len = data->blksz * data->blocks;
30592e09910SGabriel Somlo 	sg_count = dma_map_sg(dev, data->sg, data->sg_len,
30692e09910SGabriel Somlo 			      mmc_get_dma_dir(data));
30792e09910SGabriel Somlo 	if (sg_count == 1) {
30892e09910SGabriel Somlo 		dma = sg_dma_address(data->sg);
30992e09910SGabriel Somlo 		*len = sg_dma_len(data->sg);
31092e09910SGabriel Somlo 		*direct = true;
31192e09910SGabriel Somlo 	} else if (*len > host->buf_size)
31292e09910SGabriel Somlo 		*len = host->buf_size;
31392e09910SGabriel Somlo 
31492e09910SGabriel Somlo 	if (data->flags & MMC_DATA_READ) {
31592e09910SGabriel Somlo 		litex_write8(host->sdreader + LITEX_BLK2MEM_ENA, 0);
31692e09910SGabriel Somlo 		litex_write64(host->sdreader + LITEX_BLK2MEM_BASE, dma);
31792e09910SGabriel Somlo 		litex_write32(host->sdreader + LITEX_BLK2MEM_LEN, *len);
31892e09910SGabriel Somlo 		litex_write8(host->sdreader + LITEX_BLK2MEM_ENA, 1);
31992e09910SGabriel Somlo 		*transfer = SD_CTL_DATA_XFER_READ;
32092e09910SGabriel Somlo 	} else if (data->flags & MMC_DATA_WRITE) {
32192e09910SGabriel Somlo 		if (!*direct)
32292e09910SGabriel Somlo 			sg_copy_to_buffer(data->sg, data->sg_len,
32392e09910SGabriel Somlo 					  host->buffer, *len);
32492e09910SGabriel Somlo 		litex_write8(host->sdwriter + LITEX_MEM2BLK_ENA, 0);
32592e09910SGabriel Somlo 		litex_write64(host->sdwriter + LITEX_MEM2BLK_BASE, dma);
32692e09910SGabriel Somlo 		litex_write32(host->sdwriter + LITEX_MEM2BLK_LEN, *len);
32792e09910SGabriel Somlo 		litex_write8(host->sdwriter + LITEX_MEM2BLK_ENA, 1);
32892e09910SGabriel Somlo 		*transfer = SD_CTL_DATA_XFER_WRITE;
32992e09910SGabriel Somlo 	} else {
33092e09910SGabriel Somlo 		dev_warn(dev, "Data present w/o read or write flag.\n");
33192e09910SGabriel Somlo 		/* Continue: set cmd status, mark req done */
33292e09910SGabriel Somlo 	}
33392e09910SGabriel Somlo 
33492e09910SGabriel Somlo 	litex_write16(host->sdcore + LITEX_CORE_BLKLEN, data->blksz);
33592e09910SGabriel Somlo 	litex_write32(host->sdcore + LITEX_CORE_BLKCNT, data->blocks);
33692e09910SGabriel Somlo }
33792e09910SGabriel Somlo 
litex_mmc_request(struct mmc_host * mmc,struct mmc_request * mrq)33892e09910SGabriel Somlo static void litex_mmc_request(struct mmc_host *mmc, struct mmc_request *mrq)
33992e09910SGabriel Somlo {
34092e09910SGabriel Somlo 	struct litex_mmc_host *host = mmc_priv(mmc);
34192e09910SGabriel Somlo 	struct device *dev = mmc_dev(mmc);
34292e09910SGabriel Somlo 	struct mmc_command *cmd = mrq->cmd;
34392e09910SGabriel Somlo 	struct mmc_command *sbc = mrq->sbc;
34492e09910SGabriel Somlo 	struct mmc_data *data = mrq->data;
34592e09910SGabriel Somlo 	struct mmc_command *stop = mrq->stop;
34692e09910SGabriel Somlo 	unsigned int retries = cmd->retries;
34792e09910SGabriel Somlo 	unsigned int len = 0;
34892e09910SGabriel Somlo 	bool direct = false;
34992e09910SGabriel Somlo 	u32 response_len = litex_mmc_response_len(cmd);
35092e09910SGabriel Somlo 	u8 transfer = SD_CTL_DATA_XFER_NONE;
35192e09910SGabriel Somlo 
35292e09910SGabriel Somlo 	/* First check that the card is still there */
35392e09910SGabriel Somlo 	if (!litex_mmc_get_cd(mmc)) {
35492e09910SGabriel Somlo 		cmd->error = -ENOMEDIUM;
35592e09910SGabriel Somlo 		mmc_request_done(mmc, mrq);
35692e09910SGabriel Somlo 		return;
35792e09910SGabriel Somlo 	}
35892e09910SGabriel Somlo 
35992e09910SGabriel Somlo 	/* Send set-block-count command if needed */
36092e09910SGabriel Somlo 	if (sbc) {
36192e09910SGabriel Somlo 		sbc->error = litex_mmc_send_cmd(host, sbc->opcode, sbc->arg,
36292e09910SGabriel Somlo 						litex_mmc_response_len(sbc),
36392e09910SGabriel Somlo 						SD_CTL_DATA_XFER_NONE);
36492e09910SGabriel Somlo 		if (sbc->error) {
36592e09910SGabriel Somlo 			host->is_bus_width_set = false;
36692e09910SGabriel Somlo 			mmc_request_done(mmc, mrq);
36792e09910SGabriel Somlo 			return;
36892e09910SGabriel Somlo 		}
36992e09910SGabriel Somlo 	}
37092e09910SGabriel Somlo 
37192e09910SGabriel Somlo 	if (data) {
37292e09910SGabriel Somlo 		/*
37392e09910SGabriel Somlo 		 * LiteSDCard only supports 4-bit bus width; therefore, we MUST
37492e09910SGabriel Somlo 		 * inject a SET_BUS_WIDTH (acmd6) before the very first data
37592e09910SGabriel Somlo 		 * transfer, earlier than when the mmc subsystem would normally
37692e09910SGabriel Somlo 		 * get around to it!
37792e09910SGabriel Somlo 		 */
37892e09910SGabriel Somlo 		cmd->error = litex_mmc_set_bus_width(host);
37992e09910SGabriel Somlo 		if (cmd->error) {
38092e09910SGabriel Somlo 			dev_err(dev, "Can't set bus width!\n");
38192e09910SGabriel Somlo 			mmc_request_done(mmc, mrq);
38292e09910SGabriel Somlo 			return;
38392e09910SGabriel Somlo 		}
38492e09910SGabriel Somlo 
38592e09910SGabriel Somlo 		litex_mmc_do_dma(host, data, &len, &direct, &transfer);
38692e09910SGabriel Somlo 	}
38792e09910SGabriel Somlo 
38892e09910SGabriel Somlo 	do {
38992e09910SGabriel Somlo 		cmd->error = litex_mmc_send_cmd(host, cmd->opcode, cmd->arg,
39092e09910SGabriel Somlo 						response_len, transfer);
39192e09910SGabriel Somlo 	} while (cmd->error && retries-- > 0);
39292e09910SGabriel Somlo 
39392e09910SGabriel Somlo 	if (cmd->error) {
39492e09910SGabriel Somlo 		/* Card may be gone; don't assume bus width is still set */
39592e09910SGabriel Somlo 		host->is_bus_width_set = false;
39692e09910SGabriel Somlo 	}
39792e09910SGabriel Somlo 
39892e09910SGabriel Somlo 	if (response_len == SD_CTL_RESP_SHORT) {
39992e09910SGabriel Somlo 		/* Pull short response fields from appropriate host registers */
40092e09910SGabriel Somlo 		cmd->resp[0] = host->resp[3];
40192e09910SGabriel Somlo 		cmd->resp[1] = host->resp[2] & 0xFF;
40292e09910SGabriel Somlo 	} else if (response_len == SD_CTL_RESP_LONG) {
40392e09910SGabriel Somlo 		cmd->resp[0] = host->resp[0];
40492e09910SGabriel Somlo 		cmd->resp[1] = host->resp[1];
40592e09910SGabriel Somlo 		cmd->resp[2] = host->resp[2];
40692e09910SGabriel Somlo 		cmd->resp[3] = host->resp[3];
40792e09910SGabriel Somlo 	}
40892e09910SGabriel Somlo 
40992e09910SGabriel Somlo 	/* Send stop-transmission command if required */
41092e09910SGabriel Somlo 	if (stop && (cmd->error || !sbc)) {
41192e09910SGabriel Somlo 		stop->error = litex_mmc_send_cmd(host, stop->opcode, stop->arg,
41292e09910SGabriel Somlo 						 litex_mmc_response_len(stop),
41392e09910SGabriel Somlo 						 SD_CTL_DATA_XFER_NONE);
41492e09910SGabriel Somlo 		if (stop->error)
41592e09910SGabriel Somlo 			host->is_bus_width_set = false;
41692e09910SGabriel Somlo 	}
41792e09910SGabriel Somlo 
41892e09910SGabriel Somlo 	if (data) {
41992e09910SGabriel Somlo 		dma_unmap_sg(dev, data->sg, data->sg_len,
42092e09910SGabriel Somlo 			     mmc_get_dma_dir(data));
42192e09910SGabriel Somlo 	}
42292e09910SGabriel Somlo 
42392e09910SGabriel Somlo 	if (!cmd->error && transfer != SD_CTL_DATA_XFER_NONE) {
42492e09910SGabriel Somlo 		data->bytes_xfered = min(len, mmc->max_req_size);
42592e09910SGabriel Somlo 		if (transfer == SD_CTL_DATA_XFER_READ && !direct) {
42692e09910SGabriel Somlo 			sg_copy_from_buffer(data->sg, sg_nents(data->sg),
42792e09910SGabriel Somlo 					    host->buffer, data->bytes_xfered);
42892e09910SGabriel Somlo 		}
42992e09910SGabriel Somlo 	}
43092e09910SGabriel Somlo 
43192e09910SGabriel Somlo 	mmc_request_done(mmc, mrq);
43292e09910SGabriel Somlo }
43392e09910SGabriel Somlo 
litex_mmc_setclk(struct litex_mmc_host * host,unsigned int freq)43492e09910SGabriel Somlo static void litex_mmc_setclk(struct litex_mmc_host *host, unsigned int freq)
43592e09910SGabriel Somlo {
43692e09910SGabriel Somlo 	struct device *dev = mmc_dev(host->mmc);
43792e09910SGabriel Somlo 	u32 div;
43892e09910SGabriel Somlo 
43992e09910SGabriel Somlo 	div = freq ? host->ref_clk / freq : 256U;
44092e09910SGabriel Somlo 	div = roundup_pow_of_two(div);
44192e09910SGabriel Somlo 	div = clamp(div, 2U, 256U);
44292e09910SGabriel Somlo 	dev_dbg(dev, "sd_clk_freq=%d: set to %d via div=%d\n",
44392e09910SGabriel Somlo 		freq, host->ref_clk / div, div);
44492e09910SGabriel Somlo 	litex_write16(host->sdphy + LITEX_PHY_CLOCKERDIV, div);
44592e09910SGabriel Somlo 	host->sd_clk = freq;
44692e09910SGabriel Somlo }
44792e09910SGabriel Somlo 
litex_mmc_set_ios(struct mmc_host * mmc,struct mmc_ios * ios)44892e09910SGabriel Somlo static void litex_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
44992e09910SGabriel Somlo {
45092e09910SGabriel Somlo 	struct litex_mmc_host *host = mmc_priv(mmc);
45192e09910SGabriel Somlo 
45292e09910SGabriel Somlo 	/*
45392e09910SGabriel Somlo 	 * NOTE: Ignore any ios->bus_width updates; they occur right after
45492e09910SGabriel Somlo 	 * the mmc core sends its own acmd6 bus-width change notification,
45592e09910SGabriel Somlo 	 * which is redundant since we snoop on the command flow and inject
45692e09910SGabriel Somlo 	 * an early acmd6 before the first data transfer command is sent!
45792e09910SGabriel Somlo 	 */
45892e09910SGabriel Somlo 
45992e09910SGabriel Somlo 	/* Update sd_clk */
46092e09910SGabriel Somlo 	if (ios->clock != host->sd_clk)
46192e09910SGabriel Somlo 		litex_mmc_setclk(host, ios->clock);
46292e09910SGabriel Somlo }
46392e09910SGabriel Somlo 
46492e09910SGabriel Somlo static const struct mmc_host_ops litex_mmc_ops = {
46592e09910SGabriel Somlo 	.get_cd = litex_mmc_get_cd,
46692e09910SGabriel Somlo 	.request = litex_mmc_request,
46792e09910SGabriel Somlo 	.set_ios = litex_mmc_set_ios,
46892e09910SGabriel Somlo };
46992e09910SGabriel Somlo 
litex_mmc_irq_init(struct platform_device * pdev,struct litex_mmc_host * host)47092e09910SGabriel Somlo static int litex_mmc_irq_init(struct platform_device *pdev,
47192e09910SGabriel Somlo 			      struct litex_mmc_host *host)
47292e09910SGabriel Somlo {
47392e09910SGabriel Somlo 	struct device *dev = mmc_dev(host->mmc);
47492e09910SGabriel Somlo 	int ret;
47592e09910SGabriel Somlo 
47692e09910SGabriel Somlo 	ret = platform_get_irq_optional(pdev, 0);
47792e09910SGabriel Somlo 	if (ret < 0 && ret != -ENXIO)
47892e09910SGabriel Somlo 		return ret;
47992e09910SGabriel Somlo 	if (ret > 0)
48092e09910SGabriel Somlo 		host->irq = ret;
48192e09910SGabriel Somlo 	else {
48292e09910SGabriel Somlo 		dev_warn(dev, "Failed to get IRQ, using polling\n");
48392e09910SGabriel Somlo 		goto use_polling;
48492e09910SGabriel Somlo 	}
48592e09910SGabriel Somlo 
48692e09910SGabriel Somlo 	host->sdirq = devm_platform_ioremap_resource_byname(pdev, "irq");
48792e09910SGabriel Somlo 	if (IS_ERR(host->sdirq))
48892e09910SGabriel Somlo 		return PTR_ERR(host->sdirq);
48992e09910SGabriel Somlo 
49092e09910SGabriel Somlo 	ret = devm_request_irq(dev, host->irq, litex_mmc_interrupt, 0,
49192e09910SGabriel Somlo 			       "litex-mmc", host->mmc);
49292e09910SGabriel Somlo 	if (ret < 0) {
49392e09910SGabriel Somlo 		dev_warn(dev, "IRQ request error %d, using polling\n", ret);
49492e09910SGabriel Somlo 		goto use_polling;
49592e09910SGabriel Somlo 	}
49692e09910SGabriel Somlo 
49792e09910SGabriel Somlo 	/* Clear & enable card-change interrupts */
49892e09910SGabriel Somlo 	litex_write32(host->sdirq + LITEX_IRQ_PENDING, SDIRQ_CARD_DETECT);
49992e09910SGabriel Somlo 	litex_write32(host->sdirq + LITEX_IRQ_ENABLE, SDIRQ_CARD_DETECT);
50092e09910SGabriel Somlo 
50192e09910SGabriel Somlo 	return 0;
50292e09910SGabriel Somlo 
50392e09910SGabriel Somlo use_polling:
50492e09910SGabriel Somlo 	host->mmc->caps |= MMC_CAP_NEEDS_POLL;
5055c1a2b77SGabriel Somlo 	host->irq = 0;
50692e09910SGabriel Somlo 	return 0;
50792e09910SGabriel Somlo }
50892e09910SGabriel Somlo 
litex_mmc_free_host_wrapper(void * mmc)50992e09910SGabriel Somlo static void litex_mmc_free_host_wrapper(void *mmc)
51092e09910SGabriel Somlo {
51192e09910SGabriel Somlo 	mmc_free_host(mmc);
51292e09910SGabriel Somlo }
51392e09910SGabriel Somlo 
litex_mmc_probe(struct platform_device * pdev)51492e09910SGabriel Somlo static int litex_mmc_probe(struct platform_device *pdev)
51592e09910SGabriel Somlo {
51692e09910SGabriel Somlo 	struct device *dev = &pdev->dev;
51792e09910SGabriel Somlo 	struct litex_mmc_host *host;
51892e09910SGabriel Somlo 	struct mmc_host *mmc;
51992e09910SGabriel Somlo 	struct clk *clk;
52092e09910SGabriel Somlo 	int ret;
52192e09910SGabriel Somlo 
52292e09910SGabriel Somlo 	/*
52392e09910SGabriel Somlo 	 * NOTE: defaults to max_[req,seg]_size=PAGE_SIZE, max_blk_size=512,
52492e09910SGabriel Somlo 	 * and max_blk_count accordingly set to 8;
52592e09910SGabriel Somlo 	 * If for some reason we need to modify max_blk_count, we must also
52692e09910SGabriel Somlo 	 * re-calculate `max_[req,seg]_size = max_blk_size * max_blk_count;`
52792e09910SGabriel Somlo 	 */
52892e09910SGabriel Somlo 	mmc = mmc_alloc_host(sizeof(struct litex_mmc_host), dev);
52992e09910SGabriel Somlo 	if (!mmc)
53092e09910SGabriel Somlo 		return -ENOMEM;
53192e09910SGabriel Somlo 
53292e09910SGabriel Somlo 	ret = devm_add_action_or_reset(dev, litex_mmc_free_host_wrapper, mmc);
53392e09910SGabriel Somlo 	if (ret)
53492e09910SGabriel Somlo 		return dev_err_probe(dev, ret,
53592e09910SGabriel Somlo 				     "Can't register mmc_free_host action\n");
53692e09910SGabriel Somlo 
53792e09910SGabriel Somlo 	host = mmc_priv(mmc);
53892e09910SGabriel Somlo 	host->mmc = mmc;
53992e09910SGabriel Somlo 
54092e09910SGabriel Somlo 	/* Initialize clock source */
54192e09910SGabriel Somlo 	clk = devm_clk_get(dev, NULL);
54292e09910SGabriel Somlo 	if (IS_ERR(clk))
54392e09910SGabriel Somlo 		return dev_err_probe(dev, PTR_ERR(clk), "can't get clock\n");
54492e09910SGabriel Somlo 	host->ref_clk = clk_get_rate(clk);
54592e09910SGabriel Somlo 	host->sd_clk = 0;
54692e09910SGabriel Somlo 
54792e09910SGabriel Somlo 	/*
54892e09910SGabriel Somlo 	 * LiteSDCard only supports 4-bit bus width; therefore, we MUST inject
54992e09910SGabriel Somlo 	 * a SET_BUS_WIDTH (acmd6) before the very first data transfer, earlier
55092e09910SGabriel Somlo 	 * than when the mmc subsystem would normally get around to it!
55192e09910SGabriel Somlo 	 */
55292e09910SGabriel Somlo 	host->is_bus_width_set = false;
55392e09910SGabriel Somlo 	host->app_cmd = false;
55492e09910SGabriel Somlo 
55592e09910SGabriel Somlo 	/* LiteSDCard can support 64-bit DMA addressing */
55692e09910SGabriel Somlo 	ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64));
55792e09910SGabriel Somlo 	if (ret)
55892e09910SGabriel Somlo 		return ret;
55992e09910SGabriel Somlo 
56092e09910SGabriel Somlo 	host->buf_size = mmc->max_req_size * 2;
56192e09910SGabriel Somlo 	host->buffer = dmam_alloc_coherent(dev, host->buf_size,
56292e09910SGabriel Somlo 					   &host->dma, GFP_KERNEL);
56392e09910SGabriel Somlo 	if (host->buffer == NULL)
56492e09910SGabriel Somlo 		return -ENOMEM;
56592e09910SGabriel Somlo 
56692e09910SGabriel Somlo 	host->sdphy = devm_platform_ioremap_resource_byname(pdev, "phy");
56792e09910SGabriel Somlo 	if (IS_ERR(host->sdphy))
56892e09910SGabriel Somlo 		return PTR_ERR(host->sdphy);
56992e09910SGabriel Somlo 
57092e09910SGabriel Somlo 	host->sdcore = devm_platform_ioremap_resource_byname(pdev, "core");
57192e09910SGabriel Somlo 	if (IS_ERR(host->sdcore))
57292e09910SGabriel Somlo 		return PTR_ERR(host->sdcore);
57392e09910SGabriel Somlo 
57492e09910SGabriel Somlo 	host->sdreader = devm_platform_ioremap_resource_byname(pdev, "reader");
57592e09910SGabriel Somlo 	if (IS_ERR(host->sdreader))
57692e09910SGabriel Somlo 		return PTR_ERR(host->sdreader);
57792e09910SGabriel Somlo 
57892e09910SGabriel Somlo 	host->sdwriter = devm_platform_ioremap_resource_byname(pdev, "writer");
57992e09910SGabriel Somlo 	if (IS_ERR(host->sdwriter))
58092e09910SGabriel Somlo 		return PTR_ERR(host->sdwriter);
58192e09910SGabriel Somlo 
58292e09910SGabriel Somlo 	/* Ensure DMA bus masters are disabled */
58392e09910SGabriel Somlo 	litex_write8(host->sdreader + LITEX_BLK2MEM_ENA, 0);
58492e09910SGabriel Somlo 	litex_write8(host->sdwriter + LITEX_MEM2BLK_ENA, 0);
58592e09910SGabriel Somlo 
58692e09910SGabriel Somlo 	init_completion(&host->cmd_done);
58792e09910SGabriel Somlo 	ret = litex_mmc_irq_init(pdev, host);
58892e09910SGabriel Somlo 	if (ret)
58992e09910SGabriel Somlo 		return ret;
59092e09910SGabriel Somlo 
59192e09910SGabriel Somlo 	mmc->ops = &litex_mmc_ops;
59292e09910SGabriel Somlo 
59392e09910SGabriel Somlo 	ret = mmc_regulator_get_supply(mmc);
59492e09910SGabriel Somlo 	if (ret || mmc->ocr_avail == 0) {
59592e09910SGabriel Somlo 		dev_warn(dev, "can't get voltage, defaulting to 3.3V\n");
59692e09910SGabriel Somlo 		mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34;
59792e09910SGabriel Somlo 	}
59892e09910SGabriel Somlo 
59992e09910SGabriel Somlo 	/*
60092e09910SGabriel Somlo 	 * Set default sd_clk frequency range based on empirical observations
60192e09910SGabriel Somlo 	 * of LiteSDCard gateware behavior on typical SDCard media
60292e09910SGabriel Somlo 	 */
60392e09910SGabriel Somlo 	mmc->f_min = 12.5e6;
60492e09910SGabriel Somlo 	mmc->f_max = 50e6;
60592e09910SGabriel Somlo 
60692e09910SGabriel Somlo 	ret = mmc_of_parse(mmc);
60792e09910SGabriel Somlo 	if (ret)
60892e09910SGabriel Somlo 		return ret;
60992e09910SGabriel Somlo 
61092e09910SGabriel Somlo 	/* Force 4-bit bus_width (only width supported by hardware) */
61192e09910SGabriel Somlo 	mmc->caps &= ~MMC_CAP_8_BIT_DATA;
61292e09910SGabriel Somlo 	mmc->caps |= MMC_CAP_4_BIT_DATA;
61392e09910SGabriel Somlo 
61492e09910SGabriel Somlo 	/* Set default capabilities */
61592e09910SGabriel Somlo 	mmc->caps |= MMC_CAP_WAIT_WHILE_BUSY |
61692e09910SGabriel Somlo 		     MMC_CAP_DRIVER_TYPE_D |
61792e09910SGabriel Somlo 		     MMC_CAP_CMD23;
61892e09910SGabriel Somlo 	mmc->caps2 |= MMC_CAP2_NO_WRITE_PROTECT |
61992e09910SGabriel Somlo 		      MMC_CAP2_NO_SDIO |
62092e09910SGabriel Somlo 		      MMC_CAP2_NO_MMC;
62192e09910SGabriel Somlo 
62292e09910SGabriel Somlo 	platform_set_drvdata(pdev, host);
62392e09910SGabriel Somlo 
62492e09910SGabriel Somlo 	ret = mmc_add_host(mmc);
62592e09910SGabriel Somlo 	if (ret)
62692e09910SGabriel Somlo 		return ret;
62792e09910SGabriel Somlo 
62892e09910SGabriel Somlo 	dev_info(dev, "LiteX MMC controller initialized.\n");
62992e09910SGabriel Somlo 	return 0;
63092e09910SGabriel Somlo }
63192e09910SGabriel Somlo 
litex_mmc_remove(struct platform_device * pdev)632*ab02d58fSYangtao Li static void litex_mmc_remove(struct platform_device *pdev)
63392e09910SGabriel Somlo {
63492e09910SGabriel Somlo 	struct litex_mmc_host *host = platform_get_drvdata(pdev);
63592e09910SGabriel Somlo 
63692e09910SGabriel Somlo 	mmc_remove_host(host->mmc);
63792e09910SGabriel Somlo }
63892e09910SGabriel Somlo 
63992e09910SGabriel Somlo static const struct of_device_id litex_match[] = {
64092e09910SGabriel Somlo 	{ .compatible = "litex,mmc" },
64192e09910SGabriel Somlo 	{ }
64292e09910SGabriel Somlo };
64392e09910SGabriel Somlo MODULE_DEVICE_TABLE(of, litex_match);
64492e09910SGabriel Somlo 
64592e09910SGabriel Somlo static struct platform_driver litex_mmc_driver = {
64692e09910SGabriel Somlo 	.probe = litex_mmc_probe,
647*ab02d58fSYangtao Li 	.remove_new = litex_mmc_remove,
64892e09910SGabriel Somlo 	.driver = {
64992e09910SGabriel Somlo 		.name = "litex-mmc",
65092e09910SGabriel Somlo 		.of_match_table = litex_match,
651f334ad47SJisheng Zhang 		.probe_type = PROBE_PREFER_ASYNCHRONOUS,
65292e09910SGabriel Somlo 	},
65392e09910SGabriel Somlo };
65492e09910SGabriel Somlo module_platform_driver(litex_mmc_driver);
65592e09910SGabriel Somlo 
65692e09910SGabriel Somlo MODULE_DESCRIPTION("LiteX SDCard driver");
65792e09910SGabriel Somlo MODULE_AUTHOR("Antmicro <contact@antmicro.com>");
65892e09910SGabriel Somlo MODULE_AUTHOR("Kamil Rakoczy <krakoczy@antmicro.com>");
65992e09910SGabriel Somlo MODULE_AUTHOR("Maciej Dudek <mdudek@internships.antmicro.com>");
66092e09910SGabriel Somlo MODULE_AUTHOR("Paul Mackerras <paulus@ozlabs.org>");
66192e09910SGabriel Somlo MODULE_AUTHOR("Gabriel Somlo <gsomlo@gmail.com>");
66292e09910SGabriel Somlo MODULE_LICENSE("GPL v2");
663